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.
14 #include "support/std_sstream.h"
18 using std::istringstream;
20 using std::ostringstream;
23 string const Spacing::spacing_string[]
24 = {"single", "onehalf", "double", "other"};
26 float Spacing::getValue() const
29 case Default: // nothing special should happen with this...
30 case Single: return 1.0;
31 case Onehalf: return 1.25;
32 case Double: return 1.667;
33 case Other: return value;
39 void Spacing::set(Spacing::Space sp, float val)
43 switch (int(val * 1000 + 0.5)) {
44 case 1000: space = Single; break;
45 case 1250: space = Onehalf; break;
46 case 1667: space = Double; break;
47 default: value = val; break;
53 void Spacing::set(Spacing::Space sp, string const & val)
56 istringstream istr(val.c_str());
62 void Spacing::writeFile(ostream & os, bool para) const
64 if (space == Default) return;
66 string cmd = para ? "\\paragraph_spacing " : "\\spacing ";
68 if (getSpace() == Spacing::Other) {
69 os.setf(ios::showpoint|ios::fixed);
71 os << cmd << spacing_string[getSpace()]
72 << ' ' << getValue() << " \n";
74 os << cmd << spacing_string[getSpace()] << " \n";
79 string const Spacing::writeEnvirBegin() const
82 case Default: break; // do nothing
84 return "\\begin{singlespace}";
86 return "\\begin{onehalfspace}";
88 return "\\begin{doublespace}";
92 ost << "\\begin{spacing}{"
94 return STRCONV(ost.str());
101 string const Spacing::writeEnvirEnd() const
104 case Default: break; // do nothing
106 return "\\end{singlespace}";
108 return "\\end{onehalfspace}";
110 return "\\end{doublespace}";
112 return "\\end{spacing}";