1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 1995 Matthias Ettrich
7 * Copyright 1995-2001 The LyX Team.
9 * ====================================================== */
14 #pragma implementation
24 string const Spacing::spacing_string[]
25 = {"single", "onehalf", "double", "other"};
27 float Spacing::getValue() const
30 case Default: // nothing special should happen with this...
31 case Single: return 1.0;
32 case Onehalf: return 1.25;
33 case Double: return 1.667;
34 case Other: return value;
40 void Spacing::set(Spacing::Space sp, float val)
44 switch (int(val * 1000 + 0.5)) {
45 case 1000: space = Single; break;
46 case 1250: space = Onehalf; break;
47 case 1667: space = Double; break;
48 default: value = val; break;
54 void Spacing::set(Spacing::Space sp, string const & val)
57 istringstream istr(val.c_str());
63 void Spacing::writeFile(ostream & os, bool para) const
65 if (space == Default) return;
67 string cmd = para ? "\\paragraph_spacing " : "\\spacing ";
69 if (getSpace() == Spacing::Other) {
70 os.setf(ios::showpoint|ios::fixed);
72 os << cmd << spacing_string[getSpace()]
73 << " " << getValue() << " \n";
75 os << cmd << spacing_string[getSpace()] << " \n";
80 string const Spacing::writeEnvirBegin() const
83 case Default: break; // do nothing
85 return "\\begin{singlespace}";
87 return "\\begin{onehalfspace}";
89 return "\\begin{doublespace}";
93 ost << "\\begin{spacing}{"
95 return ost.str().c_str();
102 string const Spacing::writeEnvirEnd() const
105 case Default: break; // do nothing
107 return "\\end{singlespace}";
109 return "\\end{onehalfspace}";
111 return "\\end{doublespace}";
113 return "\\end{spacing}";