]> git.lyx.org Git - features.git/blobdiff - src/LaTeXFeatures.C
Dekel language/encoding patch + a few fixes
[features.git] / src / LaTeXFeatures.C
index 67341747bdaf5ce14ff24c14e606e469fe709e29..239f4bf5dcc70a8f5fbe60b5b1f52524ce70eed4 100644 (file)
 
 using std::endl;
 
-LaTeXFeatures::LaTeXFeatures(BufferParams const & p, int n)
+LaTeXFeatures::LaTeXFeatures(BufferParams const & p, LyXTextClass::size_type n)
        : layout(n, false), params(p)
 {
        // packages
+       array = false;
        color = false;
-       graphics = false;
+       graphics = false; // INSET_GRAPHICS: remove this when InsetFig is thrown.
+       graphicx = false;
        setspace = false;
        makeidx = false;
        verbatim = false;
@@ -72,15 +74,16 @@ LaTeXFeatures::LaTeXFeatures(BufferParams const & p, int n)
        NeedLyXMinipageIndent = false;
 }
 
-void LaTeXFeatures::require(string const & name) {
-       if (name == "color") {
+
+void LaTeXFeatures::require(string const & name)
+{
+       if (name == "array") {
+               array = true;
+       } else if (name == "color") {
                color = true;
        } else if (name == "graphics") {
-#ifdef USE_GRAPHICX
                graphicx = true;
-#else
-               graphics = true;
-#endif
+               graphics = true;// INSET_GRAPHICS: remove this when InsetFig is thrown.
        } else if (name == "setspace") {
                setspace = true;
        } else if (name == "makeidx") {
@@ -120,12 +123,17 @@ void LaTeXFeatures::require(string const & name) {
        }
 }
 
-string LaTeXFeatures::getPackages()
+
+string const LaTeXFeatures::getPackages()
 {
        string packages;
        LyXTextClass const & tclass =
                textclasslist.TextClass(params.textclass);
 
+       // array-package
+       if (array)
+               packages += "\\usepackage{array}\n";
+
        // color.sty
        if (color) {
                if (params.graphicsDriver == "default")
@@ -138,12 +146,22 @@ string LaTeXFeatures::getPackages()
        // makeidx.sty
        if (makeidx) {
                if (! tclass.provides(LyXTextClass::makeidx)
-                   && params.language != "french") // french provides
-                                                   // \index !
+                   && params.language->babel() != "french") // french provides
+                                                            // \index !
                        packages += "\\usepackage{makeidx}\n";
                packages += "\\makeindex\n";
        }
 
+       // graphicx.sty
+       if (graphicx && params.graphicsDriver != "none") {
+               if (params.graphicsDriver == "default")
+                       packages += "\\usepackage{graphicx}\n";
+               else
+                       packages += "\\usepackage[" 
+                               + params.graphicsDriver + "]{graphicx}\n";
+       }
+
+       // INSET_GRAPHICS: remove this when InsetFig is thrown.
        // graphics.sty
        if (graphics && params.graphicsDriver != "none") {
                if (params.graphicsDriver == "default")
@@ -185,22 +203,10 @@ string LaTeXFeatures::getPackages()
                packages += "\\doublespacing\n";
                break;
        case Spacing::Other:
-#ifdef HAVE_SSTREAM
                std::ostringstream value;
-#else
-               char val[30];
-               ostrstream value(val, 30);
-               
-#endif
                value << params.spacing.getValue(); // setw?
-#ifdef HAVE_SSTREAM
                packages += string("\\setstretch{") 
                          + value.str().c_str() + "}\n";
-#else
-               value << '\0';
-               packages += string("\\setstretch{") 
-                         + value.str() + "}\n";
-#endif
                break;
        }
 
@@ -258,7 +264,7 @@ string LaTeXFeatures::getPackages()
 }
 
 
-string LaTeXFeatures::getMacros()
+string const LaTeXFeatures::getMacros()
 {
        string macros;
 
@@ -315,7 +321,7 @@ string LaTeXFeatures::getMacros()
 }
 
 
-string LaTeXFeatures::getTClassPreamble()
+string const LaTeXFeatures::getTClassPreamble()
 {
        // the text class specific preamble 
        LyXTextClass const & tclass =
@@ -332,6 +338,18 @@ string LaTeXFeatures::getTClassPreamble()
 }      
 
 
+string const LaTeXFeatures::getIncludedFiles()
+{
+       string sgmlpreamble;
+       FileMap::const_iterator end = IncludedFiles.end();
+       for(FileMap::const_iterator fi=IncludedFiles.begin(); fi != end; ++fi)
+               sgmlpreamble += "\n<!entity " + fi->first
+                       + " system \"" + fi->second + "\">";
+
+       return sgmlpreamble;
+}
+
+
 void LaTeXFeatures::showStruct() {
        lyxerr << "LyX needs the following commands when LaTeXing:"
               << "\n***** Packages:" << getPackages()