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.
15 #include "support/lstrings.h"
16 #include "support/convert.h"
26 using std::ostringstream;
30 string const Spacing::spacing_string[]
31 = {"single", "onehalf", "double", "other"};
34 string const Spacing::getValueAsString() const
37 case Default: // nothing special should happen with this...
38 case Single: return "1.0";
39 case Onehalf: return "1.25";
40 case Double: return "1.667";
41 case Other: return value;
47 double Spacing::getValue() const
49 return convert<double>(getValueAsString());
53 void Spacing::set(Spacing::Space sp, double val)
55 set(sp, convert<string>(val));
59 void Spacing::set(Spacing::Space sp, string const & val)
63 switch (int(convert<double>(val) * 1000 + 0.5)) {
81 void Spacing::writeFile(ostream & os, bool para) const
83 if (space == Default) return;
85 string cmd = para ? "\\paragraph_spacing " : "\\spacing ";
87 if (getSpace() == Spacing::Other) {
88 os << cmd << spacing_string[getSpace()]
89 << ' ' << getValueAsString() << "\n";
91 os << cmd << spacing_string[getSpace()] << "\n";
96 string const Spacing::writeEnvirBegin() const
99 case Default: break; // do nothing
101 return "\\begin{singlespace}";
103 return "\\begin{onehalfspace}";
105 return "\\begin{doublespace}";
109 ost << "\\begin{spacing}{"
110 << getValueAsString() << '}';
118 string const Spacing::writeEnvirEnd() const
121 case Default: break; // do nothing
123 return "\\end{singlespace}";
125 return "\\end{onehalfspace}";
127 return "\\end{doublespace}";
129 return "\\end{spacing}";