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
20 using std::istringstream;
21 using std::ostringstream;
35 /// how can I put this inside of Spacing (class)
37 char const * spacing_string[] = {"single", "onehalf", "double", "other"};
40 float Spacing::getValue() const
43 case Default: // nothing special should happen with this...
44 case Single: return 1.0;
45 case Onehalf: return 1.25;
46 case Double: return 1.667;
47 case Other: return value;
53 void Spacing::set(Spacing::Space sp, float val)
57 switch(int(val * 1000 + 0.5)) {
58 case 1000: space = Single; break;
59 case 1250: space = Onehalf; break;
60 case 1667: space = Double; break;
61 default: value = val; break;
67 void Spacing::set(Spacing::Space sp, string const & val)
71 istringstream istr(val);
73 // istrstream istr(val.c_str());
80 void Spacing::writeFile(ostream & os, bool para) const
82 if (space == Default) return;
84 string cmd = para ? "\\paragraph_spacing " : "\\spacing ";
86 if (getSpace() == Spacing::Other) {
87 os.setf(ios::showpoint|ios::fixed);
89 os << cmd << spacing_string[getSpace()]
90 << " " << getValue() << " \n";
92 os << cmd << spacing_string[getSpace()] << " \n";
97 string const Spacing::writeEnvirBegin() const
100 case Default: break; // do nothing
102 return "\\begin{singlespace}";
104 return "\\begin{onehalfspace}";
106 return "\\begin{doublespace}";
108 //#ifdef HAVE_SSTREAM
111 ost << "\\begin{spacing}{"
112 << getValue() << "}";
113 return ost.str().c_str();
118 // ostrstream ost(tmp, 512);
119 // ost << "\\begin{spacing}{"
120 // << getValue() << "}\0";
129 string const Spacing::writeEnvirEnd() const
132 case Default: break; // do nothing
134 return "\\end{singlespace}";
136 return "\\end{onehalfspace}";
138 return "\\end{doublespace}";
140 return "\\end{spacing}";