]> git.lyx.org Git - lyx.git/blobdiff - src/LaTeXFeatures.cpp
Fulfill promise to Andre: TextClass_ptr --> TextClassPtr.
[lyx.git] / src / LaTeXFeatures.cpp
index dae61ec0695457ecc983d48d66a40571f956eb64..a9ff651aa879c832c97df02625573bc603e80253 100644 (file)
 #include "support/docstream.h"
 #include "support/filetools.h"
 
-#include "frontends/controllers/frontend_helpers.h"
-
-namespace lyx {
-
-using support::isSGMLFilename;
-using support::libFileSearch;
-using support::makeRelPath;
-using support::onlyPath;
-
 using std::endl;
 using std::find;
 using std::string;
@@ -46,6 +37,14 @@ using std::ostream;
 using std::ostringstream;
 using std::set;
 
+
+namespace lyx {
+
+using support::isSGMLFilename;
+using support::libFileSearch;
+using support::makeRelPath;
+using support::onlyPath;
+
 /////////////////////////////////////////////////////////////////////
 //
 // Strings
@@ -254,7 +253,7 @@ void LaTeXFeatures::getAvailable()
 }
 
 
-void LaTeXFeatures::useLayout(string const & layoutname)
+void LaTeXFeatures::useLayout(docstring const & layoutname)
 {
        // Some code to avoid loops in dependency definition
        static int level = 0;
@@ -262,21 +261,21 @@ void LaTeXFeatures::useLayout(string const & layoutname)
        if (level > maxlevel) {
                lyxerr << "LaTeXFeatures::useLayout: maximum level of "
                       << "recursion attained by layout "
-                      << layoutname << endl;
+                      << to_utf8(layoutname) << endl;
                return;
        }
 
        TextClass const & tclass = params_.getTextClass();
        if (tclass.hasLayout(layoutname)) {
                // Is this layout already in usedLayouts?
-               list<string>::const_iterator cit = usedLayouts_.begin();
-               list<string>::const_iterator end = usedLayouts_.end();
+               list<docstring>::const_iterator cit = usedLayouts_.begin();
+               list<docstring>::const_iterator end = usedLayouts_.end();
                for (; cit != end; ++cit) {
                        if (layoutname == *cit)
                                return;
                }
 
-               Layout_ptr const & lyt = tclass[layoutname];
+               LayoutPtr const & lyt = tclass[layoutname];
                if (!lyt->depends_on().empty()) {
                        ++level;
                        useLayout(lyt->depends_on());
@@ -285,7 +284,7 @@ void LaTeXFeatures::useLayout(string const & layoutname)
                usedLayouts_.push_back(layoutname);
        } else {
                lyxerr << "LaTeXFeatures::useLayout: layout `"
-                      << layoutname << "' does not exist in this class"
+                      << to_utf8(layoutname) << "' does not exist in this class"
                       << endl;
        }
 
@@ -396,7 +395,7 @@ char const * simplefeatures[] = {
        "latexsym",
        "pifont",
        "subfigure",
-       "floatflt",
+       "wrapfig",
        "varioref",
        "prettyref",
        "float",
@@ -404,7 +403,7 @@ char const * simplefeatures[] = {
        "dvipost",
        "fancybox",
        "calc",
-       "nicefrac",
+       "units",
        "tipa",
        "framed",
        "pdfcolmk",
@@ -445,8 +444,11 @@ string const LaTeXFeatures::getPackages() const
        // than those above.
        //
 
-       if (mustProvide("amsmath")
-           && params_.use_amsmath != BufferParams::package_off) {
+       // esint is preferred for esintoramsmath
+       if ((mustProvide("amsmath") &&
+            params_.use_amsmath != BufferParams::package_off) ||
+           (mustProvide("esintoramsmath") &&
+            params_.use_esint == BufferParams::package_off)) {
                packages << "\\usepackage{amsmath}\n";
        }
 
@@ -539,8 +541,8 @@ string const LaTeXFeatures::getPackages() const
 
        // esint must be after amsmath and wasysym, since it will redeclare
        // inconsistent integral symbols
-       if (mustProvide("esint")
-           && params_.use_esint != BufferParams::package_off)
+       if ((mustProvide("esint") || mustProvide("esintoramsmath")) &&
+           params_.use_esint != BufferParams::package_off)
                packages << "\\usepackage{esint}\n";
 
        // url.sty
@@ -709,17 +711,19 @@ docstring const LaTeXFeatures::getTClassPreamble() const
 
        tcpreamble << tclass.preamble();
 
-       list<string>::const_iterator cit = usedLayouts_.begin();
-       list<string>::const_iterator end = usedLayouts_.end();
+       list<docstring>::const_iterator cit = usedLayouts_.begin();
+       list<docstring>::const_iterator end = usedLayouts_.end();
        for (; cit != end; ++cit) {
                tcpreamble << tclass[*cit]->preamble();
        }
 
-       CharStyles::iterator cs = tclass.charstyles().begin();
-       CharStyles::iterator csend = tclass.charstyles().end();
-       for (; cs != csend; ++cs) {
-               if (isRequired(cs->name))
-                       tcpreamble << cs->preamble;
+       InsetLayouts const & insetlayouts = tclass.insetlayouts();
+       InsetLayouts::const_iterator cit2 = insetlayouts.begin();
+       InsetLayouts::const_iterator end2 = insetlayouts.end();
+       for (; cit2 != end2; ++cit2) {
+               if (isRequired(to_utf8(cit2->first))) {
+                       tcpreamble << from_utf8(cit2->second.preamble);
+               }
        }
 
        return tcpreamble.str();