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 /// how can I put this inside of Spacing (class)
27 char const * const spacing_string[] = {"single", "onehalf", "double", "other"};
32 float Spacing::getValue() const
35 case Default: // nothing special should happen with this...
36 case Single: return 1.0;
37 case Onehalf: return 1.25;
38 case Double: return 1.667;
39 case Other: return value;
45 void Spacing::set(Spacing::Space sp, float val)
49 switch (int(val * 1000 + 0.5)) {
50 case 1000: space = Single; break;
51 case 1250: space = Onehalf; break;
52 case 1667: space = Double; break;
53 default: value = val; break;
59 void Spacing::set(Spacing::Space sp, string const & val)
62 istringstream istr(val.c_str());
68 void Spacing::writeFile(ostream & os, bool para) const
70 if (space == Default) return;
72 string cmd = para ? "\\paragraph_spacing " : "\\spacing ";
74 if (getSpace() == Spacing::Other) {
75 os.setf(ios::showpoint|ios::fixed);
77 os << cmd << spacing_string[getSpace()]
78 << " " << getValue() << " \n";
80 os << cmd << spacing_string[getSpace()] << " \n";
85 string const Spacing::writeEnvirBegin() const
88 case Default: break; // do nothing
90 return "\\begin{singlespace}";
92 return "\\begin{onehalfspace}";
94 return "\\begin{doublespace}";
98 ost << "\\begin{spacing}{"
100 return ost.str().c_str();
107 string const Spacing::writeEnvirEnd() const
110 case Default: break; // do nothing
112 return "\\end{singlespace}";
114 return "\\end{onehalfspace}";
116 return "\\end{doublespace}";
118 return "\\end{spacing}";