]> git.lyx.org Git - lyx.git/blobdiff - src/LaTeXFeatures.cpp
* gcc does not like missing characters in keywords
[lyx.git] / src / LaTeXFeatures.cpp
index 06f65e566b6ea0303b322bdfe946fdc61b372402..245267c9b2df4d1e72321b669853bac6f6a715e3 100644 (file)
 
 #include "LaTeXFeatures.h"
 
-#include "BufferParams.h"
 #include "Color.h"
+#include "BufferParams.h"
 #include "debug.h"
 #include "Encoding.h"
 #include "Floating.h"
 #include "FloatList.h"
 #include "Language.h"
+#include "Layout.h"
 #include "Lexer.h"
 #include "LyXRC.h"
 
 #include "support/docstream.h"
 #include "support/filetools.h"
 
-#include "frontends/controllers/frontend_helpers.h"
-
 using std::endl;
 using std::find;
 using std::string;
@@ -187,6 +186,20 @@ static string const changetracking_none_def =
        "\\newcommand{\\lyxadded}[3]{#3}\n"
        "\\newcommand{\\lyxdeleted}[3]{}\n";
 
+static string const textgreek_def =
+       "\\DeclareRobustCommand{\\greektext}{%\n"
+       " \\fontencoding{LGR}\\selectfont\n"
+       " \\def\\encodingdefault{LGR}}\n"
+       "\\DeclareRobustCommand{\\textgreek}[1]{\\leavevmode{\\greektext #1}}\n"
+       "\\DeclareFontEncoding{LGR}{}{}\n";
+
+static string const textcyr_def =
+       "\\DeclareRobustCommand{\\cyrtext}{%\n"
+       " \\fontencoding{T2A}\\selectfont\n"
+       " \\def\\encodingdefault{T2A}}\n"
+       "\\DeclareRobustCommand{\\textcyr}[1]{\\leavevmode{\\cyrtext #1}}\n"
+       "\\DeclareFontEncoding{T2A}{}{}\n";
+
 
 /////////////////////////////////////////////////////////////////////
 //
@@ -397,15 +410,19 @@ char const * simplefeatures[] = {
        "latexsym",
        "pifont",
        "subfigure",
-       "floatflt",
        "varioref",
        "prettyref",
+       /*For a successful cooperation of the `wrapfig' package with the
+         `float' package you should load the `wrapfig' package *after*
+         the `float' package. See the caption package documentation
+         for explanation.*/
        "float",
+       "wrapfig",
        "booktabs",
        "dvipost",
        "fancybox",
        "calc",
-       "nicefrac",
+       "units",
        "tipa",
        "framed",
        "pdfcolmk",
@@ -419,6 +436,7 @@ char const * simplefeatures[] = {
        "txfonts",
        "mathrsfs",
        "ascii",
+       "url",
 };
 
 int const nb_simplefeatures = sizeof(simplefeatures) / sizeof(char const *);
@@ -494,7 +512,7 @@ string const LaTeXFeatures::getPackages() const
        }
        // shadecolor for shaded
        if (mustProvide("framed") && mustProvide("color")) {
-               RGBColor c = RGBColor(lcolor.getX11Name(Color::shadedbg));
+               RGBColor c = RGBColor(lcolor.getX11Name(Color_shadedbg));
                //255.0 to force conversion to double
                //NOTE As Jürgen Spitzmüller pointed out, an alternative would be
                //to use the xcolor package instead, and then we can do
@@ -547,11 +565,6 @@ string const LaTeXFeatures::getPackages() const
            params_.use_esint != BufferParams::package_off)
                packages << "\\usepackage{esint}\n";
 
-       // url.sty
-       if (mustProvide("url"))
-               packages << "\\IfFileExists{url.sty}{\\usepackage{url}}\n"
-                           "                      {\\newcommand{\\url}{\\texttt}}\n";
-
        // natbib.sty
        if (mustProvide("natbib")) {
                packages << "\\usepackage[";
@@ -619,6 +632,12 @@ string const LaTeXFeatures::getMacros() const
        if (mustProvide("lyxarrow"))
                macros << lyxarrow_def << '\n';
 
+       if (mustProvide("textgreek"))
+               macros << textgreek_def << '\n';
+
+       if (mustProvide("textcyr"))
+               macros << textcyr_def << '\n';
+
        // quotes.
        if (mustProvide("quotesinglbase"))
                macros << quotesinglbase_def << '\n';
@@ -668,11 +687,11 @@ string const LaTeXFeatures::getMacros() const
        if (mustProvide("ct-xcolor-soul")) {
                int const prec = macros.precision(2);
        
-               RGBColor cadd = RGBColor(lcolor.getX11Name(Color::addedtext));
+               RGBColor cadd = RGBColor(lcolor.getX11Name(Color_addedtext));
                macros << "\\providecolor{lyxadded}{rgb}{"
                       << cadd.r / 255.0 << ',' << cadd.g / 255.0 << ',' << cadd.b / 255.0 << "}\n";
 
-               RGBColor cdel = RGBColor(lcolor.getX11Name(Color::deletedtext));
+               RGBColor cdel = RGBColor(lcolor.getX11Name(Color_deletedtext));
                macros << "\\providecolor{lyxdeleted}{rgb}{"
                       << cdel.r / 255.0 << ',' << cdel.g / 255.0 << ',' << cdel.b / 255.0 << "}\n";
 
@@ -719,11 +738,13 @@ docstring const LaTeXFeatures::getTClassPreamble() const
                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();