+/* This file is part of
+ * ======================================================
+ *
+ * LyX, The Document Processor
+ *
+ * Copyright 1995 Matthias Ettrich
+ * Copyright 1995-2000 The LyX Team.
+ *
+ * ====================================================== */
+
#include <config.h>
+#ifdef __GNUG__
+#pragma implementation
+#endif
#ifdef HAVE_SSTREAM
#include <sstream>
using std::istringstream;
+using std::ostringstream;
#else
#include <strstream>
#endif
#include "Spacing.h"
+#include "LString.h"
using std::ios;
using std::ostream;
float Spacing::getValue() const
{
switch(space) {
+ case Default: // nothing special should happen with this...
case Single: return 1.0;
case Onehalf: return 1.25;
case Double: return 1.667;
}
-void Spacing::writeFile(ostream & os) const
+void Spacing::writeFile(ostream & os, bool para) const
{
+ if (space == Default) return;
+
+ string cmd = para ? "\\paragraph_spacing " : "\\spacing ";
+
if (getSpace() == Spacing::Other) {
os.setf(ios::showpoint|ios::fixed);
os.precision(2);
- os << "\\spacing " << spacing_string[getSpace()]
+ os << cmd << spacing_string[getSpace()]
<< " " << getValue() << " \n";
} else {
- os << "\\spacing " << spacing_string[getSpace()] << " \n";
+ os << cmd << spacing_string[getSpace()] << " \n";
}
}
+
+
+string Spacing::writeEnvirBegin() const
+{
+ switch(space) {
+ case Default: break; // do nothing
+ case Single:
+ return "\\begin{singlespace}";
+ case Onehalf:
+ return "\\begin{onehalfspace}";
+ case Double:
+ return "\\begin{doublespace}";
+ case Other:
+#ifdef HAVE_SSTREAM
+ ostringstream ost;
+ ost << "\\begin{spacing}{"
+ << getValue() << "}";
+ return ost.str().c_str();
+#else
+ {
+ char tmp[512];
+ ostrstream ost(tmp, 512);
+ ost << "\\begin{spacing}{"
+ << getValue() << "}" << '\0';
+ return ost.str();
+ }
+#endif
+ }
+ return string();
+}
+
+
+string Spacing::writeEnvirEnd() const
+{
+ switch(space) {
+ case Default: break; // do nothing
+ case Single:
+ return "\\end{singlespace}";
+ case Onehalf:
+ return "\\end{onehalfspace}";
+ case Double:
+ return "\\end{doublespace}";
+ case Other:
+ return "\\end{spacing}";
+ }
+ return string();
+}