// -*- C++ -*-
/* This file is part of
- * ======================================================
+ * ======================================================
*
* LyX, The Document Processor
*
* Copyright 1995 Matthias Ettrich
- * Copyright 1995-1999 the LyX Team.
+ * Copyright 1995-2000 the LyX Team.
*
- * ======================================================*/
+ * ====================================================== */
#include <config.h>
#endif
#include "LString.h"
-#include "error.h"
+#include "debug.h"
#include "lyx_sty.h"
#include "lyxrc.h"
#include "LaTeXFeatures.h"
#include "bufferparams.h"
#include "layout.h"
-extern LyXRC * lyxrc;
-LaTeXFeatures::LaTeXFeatures(int n)
+LaTeXFeatures::LaTeXFeatures(int n)
+ : layout(n, false)
{
// packages
color = false;
LyXParagraphIndent = false;
NeedLyXFootnoteCode = false;
NeedLyXMinipageIndent = false;
-
- // layouts
- layout = new bool[n];
- for (int i = n; i--;)
- layout[i] = false;
}
-string LaTeXFeatures::getPackages(BufferParams const ¶ms)
+string LaTeXFeatures::getPackages(BufferParams const & params)
{
string packages;
- LyXTextClass *tclass = lyxstyle.TextClass(params.textclass);
+ LyXTextClass const & tclass = textclasslist.TextClass(params.textclass);
// color.sty
if (color) {
if (params.graphicsDriver == "default")
- packages +="\\usepackage{color}\n";
+ packages += "\\usepackage{color}\n";
else
packages += "\\usepackage["
+ params.graphicsDriver + "]{color}\n";
// makeidx.sty
if (makeidx) {
- if (! tclass->provides_makeidx
+ if (! tclass.provides(LyXTextClass::makeidx)
&& params.language != "french") // french provides
// \index !
packages += "\\usepackage{makeidx}\n";
packages += "\\doublespacing\n";
break;
case Spacing::Other:
- char value[30];
- sprintf(value, "%.2f", params.spacing.getValue());
+ //char value[30];
+ //sprintf(value, "%.2f", params.spacing.getValue());
+#ifdef HAVE_SSTREAM
+ ostringstream value;
+#else
+ char val[30];
+ ostrstream value(val, 30);
+
+#endif
+ value << params.spacing.getValue(); // setw?
+#ifdef HAVE_SSTREAM
packages += string("\\setstretch{")
- + value + "}\n";
+ + value.str().c_str() + "}\n";
+#else
+ value << '\0';
+ packages += string("\\setstretch{")
+ + value.str() + "}\n";
+#endif
break;
}
packages += "\\usepackage{floatflt}\n";
// url.sty
- if (url && ! tclass->provides_url)
+ if (url && ! tclass.provides(LyXTextClass::url))
packages += "\\IfFileExists{url.sty}{\\usepackage{url}}\n"
" {\\newcommand{\\url}{\\texttt}}\n";
}
-string LaTeXFeatures::getTClassPreamble(BufferParams const ¶ms)
+string LaTeXFeatures::getTClassPreamble(BufferParams const & params)
{
// the text class specific preamble
- LyXTextClass *tclass = lyxstyle.TextClass(params.textclass);
- string tcpreamble = tclass->preamble;
-
- int l;
- for (l = 0 ; l < tclass->number_of_defined_layouts ; l++) {
- if (layout[l]
- && !tclass->style[l].preamble.empty())
- tcpreamble += tclass->style[l].preamble;
+ LyXTextClass const & tclass = textclasslist.TextClass(params.textclass);
+ string tcpreamble = tclass.preamble();
+
+ for (unsigned int i = 0; i < tclass.numLayouts(); ++i) {
+ if (layout[i]) {
+ tcpreamble += tclass[i].preamble();
+ }
}
return tcpreamble;
}
-void LaTeXFeatures::showStruct(BufferParams ¶ms) {
- lyxerr.print("LyX needs the following commands when LaTeXing:");
+void LaTeXFeatures::showStruct(BufferParams const & params) {
+ lyxerr << "LyX needs the following commands when LaTeXing:"
// packs
- lyxerr.print("***** Packages:");
- lyxerr.print(getPackages(params));
- lyxerr.print("***** Macros:");
- lyxerr.print(getMacros(params));
- lyxerr.print("***** Textclass stuff:");
- lyxerr.print(getTClassPreamble(params));
- lyxerr.print("***** done.");
+ << "\n***** Packages:" << getPackages(params)
+ << "\n***** Macros:" << getMacros(params)
+ << "\n***** Textclass stuff:" << getTClassPreamble(params)
+ << "\n***** done." << endl;
}