1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 1995 Matthias Ettrich
7 * Copyright 1995-2000 The LyX Team.
9 * ====================================================== */
14 #pragma implementation
19 using std::istringstream;
20 using std::ostringstream;
31 /// how can I put this inside of Spacing (class)
33 char const * spacing_string[] = {"single", "onehalf", "double", "other"};
36 float Spacing::getValue() const
39 case Default: // nothing special should happen with this...
40 case Single: return 1.0;
41 case Onehalf: return 1.25;
42 case Double: return 1.667;
43 case Other: return value;
49 void Spacing::set(Spacing::Space sp, float val)
53 switch(int(val * 1000 + 0.5)) {
54 case 1000: space = Single; break;
55 case 1250: space = Onehalf; break;
56 case 1667: space = Double; break;
57 default: value = val; break;
63 void Spacing::set(Spacing::Space sp, char const * val)
67 istringstream istr(val);
76 void Spacing::writeFile(ostream & os, bool para) const
78 if (space == Default) return;
80 string cmd = para ? "\\paragraph_spacing " : "\\spacing ";
82 if (getSpace() == Spacing::Other) {
83 os.setf(ios::showpoint|ios::fixed);
85 os << cmd << spacing_string[getSpace()]
86 << " " << getValue() << " \n";
88 os << cmd << spacing_string[getSpace()] << " \n";
93 string Spacing::writeEnvirBegin() const
96 case Default: break; // do nothing
98 return "\\begin{singlespace}";
100 return "\\begin{onehalfspace}";
102 return "\\begin{doublespace}";
106 ost << "\\begin{spacing}{"
107 << getValue() << "}";
108 return ost.str().c_str();
112 ostrstream ost(tmp, 512);
113 ost << "\\begin{spacing}{"
114 << getValue() << "}" << '\0';
123 string Spacing::writeEnvirEnd() const
126 case Default: break; // do nothing
128 return "\\end{singlespace}";
130 return "\\end{onehalfspace}";
132 return "\\end{doublespace}";
134 return "\\end{spacing}";