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
24 /// how can I put this inside of Spacing (class)
26 char const * spacing_string[] = {"single", "onehalf", "double", "other"};
29 float Spacing::getValue() const
32 case Default: // nothing special should happen with this...
33 case Single: return 1.0;
34 case Onehalf: return 1.25;
35 case Double: return 1.667;
36 case Other: return value;
42 void Spacing::set(Spacing::Space sp, float val)
46 switch(int(val * 1000 + 0.5)) {
47 case 1000: space = Single; break;
48 case 1250: space = Onehalf; break;
49 case 1667: space = Double; break;
50 default: value = val; break;
56 void Spacing::set(Spacing::Space sp, string const & val)
59 istringstream istr(val);
65 void Spacing::writeFile(ostream & os, bool para) const
67 if (space == Default) return;
69 string cmd = para ? "\\paragraph_spacing " : "\\spacing ";
71 if (getSpace() == Spacing::Other) {
72 os.setf(ios::showpoint|ios::fixed);
74 os << cmd << spacing_string[getSpace()]
75 << " " << getValue() << " \n";
77 os << cmd << spacing_string[getSpace()] << " \n";
82 string const Spacing::writeEnvirBegin() const
85 case Default: break; // do nothing
87 return "\\begin{singlespace}";
89 return "\\begin{onehalfspace}";
91 return "\\begin{doublespace}";
95 ost << "\\begin{spacing}{"
97 return ost.str().c_str();
104 string const Spacing::writeEnvirEnd() const
107 case Default: break; // do nothing
109 return "\\end{singlespace}";
111 return "\\end{onehalfspace}";
113 return "\\end{doublespace}";
115 return "\\end{spacing}";