3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Lars Gullik Bjønnes
7 * \author Jean-Marc Lasgouttes
9 * Full author contact details are available in file CREDITS.
21 string const Spacing::spacing_string[]
22 = {"single", "onehalf", "double", "other"};
24 float Spacing::getValue() const
27 case Default: // nothing special should happen with this...
28 case Single: return 1.0;
29 case Onehalf: return 1.25;
30 case Double: return 1.667;
31 case Other: return value;
37 void Spacing::set(Spacing::Space sp, float val)
41 switch (int(val * 1000 + 0.5)) {
42 case 1000: space = Single; break;
43 case 1250: space = Onehalf; break;
44 case 1667: space = Double; break;
45 default: value = val; break;
51 void Spacing::set(Spacing::Space sp, string const & val)
54 istringstream istr(val.c_str());
60 void Spacing::writeFile(ostream & os, bool para) const
62 if (space == Default) return;
64 string cmd = para ? "\\paragraph_spacing " : "\\spacing ";
66 if (getSpace() == Spacing::Other) {
67 os.setf(ios::showpoint|ios::fixed);
69 os << cmd << spacing_string[getSpace()]
70 << ' ' << getValue() << " \n";
72 os << cmd << spacing_string[getSpace()] << " \n";
77 string const Spacing::writeEnvirBegin() const
80 case Default: break; // do nothing
82 return "\\begin{singlespace}";
84 return "\\begin{onehalfspace}";
86 return "\\begin{doublespace}";
90 ost << "\\begin{spacing}{"
92 return STRCONV(ost.str());
99 string const Spacing::writeEnvirEnd() const
102 case Default: break; // do nothing
104 return "\\end{singlespace}";
106 return "\\end{onehalfspace}";
108 return "\\end{doublespace}";
110 return "\\end{spacing}";