]> git.lyx.org Git - lyx.git/blobdiff - src/LaTeXFeatures.C
Fix configure bug with gettext
[lyx.git] / src / LaTeXFeatures.C
index 71bc6d49da6c49ce151449e08b26ea91b2d48184..90c752cad794ec18e7398b5da3d054957b79b49d 100644 (file)
@@ -1,13 +1,13 @@
 // -*- 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;
@@ -66,23 +66,18 @@ LaTeXFeatures::LaTeXFeatures(int n)
        LyXParagraphIndent = false;
        NeedLyXFootnoteCode = false;
        NeedLyXMinipageIndent = false;
-
-       // layouts
-       layout = new bool[n];
-       for (int i = n; i--;) 
-               layout[i] = false;
 }
 
 
-string LaTeXFeatures::getPackages(BufferParams const &params)
+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";
@@ -90,7 +85,7 @@ string LaTeXFeatures::getPackages(BufferParams const &params)
                
        // makeidx.sty
        if (makeidx) {
-               if (! tclass->provides_makeidx
+               if (! tclass.provides(LyXTextClass::makeidx)
                    && params.language != "french") // french provides
                                                    // \index !
                        packages += "\\usepackage{makeidx}\n";
@@ -131,10 +126,24 @@ string LaTeXFeatures::getPackages(BufferParams const &params)
                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;
        }
 
@@ -167,7 +176,7 @@ string LaTeXFeatures::getPackages(BufferParams const &params)
                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";
        
@@ -226,31 +235,27 @@ string LaTeXFeatures::getMacros(BufferParams const & /* params */)
 }
 
 
-string LaTeXFeatures::getTClassPreamble(BufferParams const &params)
+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 &params) {
-       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;
 }