]> git.lyx.org Git - lyx.git/blobdiff - src/LaTeXFeatures.C
Move #includes out of header files.
[lyx.git] / src / LaTeXFeatures.C
index f79a7aa5e7a9cbfa4017f844b9204bf6b7d3189c..6984882c5eaa2cd7575f43f3ca3f2ecf8b98e5f6 100644 (file)
@@ -1,12 +1,16 @@
-/* This file is part of
- * ======================================================
+/**
+ * \file LaTeXFeatures.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
  *
- *           LyX, The Document Processor
+ * \author José Matos
+ * \author Lars Gullik Bjønnes
+ * \author Jean-Marc Lasgouttes
+ * \author Jürgen Vigna
+ * \author André Pönitz
  *
- *           Copyright 1995 Matthias Ettrich
- *           Copyright 1995-2001 the LyX Team.
- *
- * ====================================================== */
+ * Full author contact details are available in file CREDITS.
+ */
 
 #include <config.h>
 
@@ -15,6 +19,7 @@
 #include "lyx_sty.h"
 #include "lyxrc.h"
 #include "bufferparams.h"
+#include "Floating.h"
 #include "FloatList.h"
 #include "language.h"
 #include "encoding.h"
@@ -24,6 +29,8 @@
 #include "support/filetools.h"
 #include "support/lstrings.h"
 
+using namespace lyx::support;
+
 using lyx::textclass_type;
 
 using std::endl;
@@ -38,6 +45,14 @@ LaTeXFeatures::LaTeXFeatures(BufferParams const & p)
 {}
 
 
+bool LaTeXFeatures::useBabel() const
+{
+       return lyxrc.language_use_babel ||
+               bufferParams().language->lang() != lyxrc.default_language ||
+               this->hasLanguages();
+}
+
+
 void LaTeXFeatures::require(string const & name)
 {
        if (isRequired(name))
@@ -92,9 +107,12 @@ bool LaTeXFeatures::isRequired(string const & name) const
 }
 
 
-void LaTeXFeatures::addExternalPreamble(string const & pream)
+void LaTeXFeatures::addExternalPreamble(string const & preamble)
 {
-       externalPreambles += pream;
+       FeaturesList::const_iterator begin = preamble_snippets.begin();
+       FeaturesList::const_iterator end   = preamble_snippets.end();
+       if (find(begin, end, preamble) == end)
+               preamble_snippets.push_back(preamble);
 }
 
 
@@ -176,12 +194,12 @@ int const nb_simplefeatures = sizeof(simplefeatures) / sizeof(char const *);
 
 }
 
+
 string const LaTeXFeatures::getPackages() const
 {
        ostringstream packages;
        LyXTextClass const & tclass = params.getLyXTextClass();
 
-
        //
        //  These are all the 'simple' includes.  i.e
        //  packages which we just \usepackage{package}
@@ -284,7 +302,11 @@ string const LaTeXFeatures::getPackages() const
                packages << "]{natbib}\n";
        }
 
-       packages << externalPreambles;
+       FeaturesList::const_iterator pit  = preamble_snippets.begin();
+       FeaturesList::const_iterator pend = preamble_snippets.end();
+       for (; pit != pend; ++pit) {
+               packages << *pit << '\n';
+       }
 
        return STRCONV(packages.str());
 }
@@ -340,6 +362,10 @@ string const LaTeXFeatures::getMacros() const
        if (isRequired("NeedTabularnewline"))
                macros << tabularnewline_def;
 
+       // greyedout environment (note inset)
+       if (isRequired("lyxgreyedout"))
+               macros << lyxgreyedout_def;
+
        // floats
        getFloatDefinitions(macros);