]> git.lyx.org Git - features.git/commitdiff
Move part of Buffer::validate into a new method BufferParams::validate.
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 14 Dec 2007 14:51:47 +0000 (14:51 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 14 Dec 2007 14:51:47 +0000 (14:51 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22146 a592a061-630c-0410-9148-cb99ea01b6c8

src/Buffer.cpp
src/BufferParams.cpp
src/BufferParams.h

index 2d0a3ad84dbaed39d12d29c98852bc6400315a1a..7c3e85b3bdc603e181958fdc230db8db65648715 100644 (file)
@@ -1285,76 +1285,13 @@ int Buffer::runChktex()
 
 void Buffer::validate(LaTeXFeatures & features) const
 {
-       TextClass const & tclass = params().getTextClass();
-
-       if (params().outputChanges) {
-               bool dvipost    = LaTeXFeatures::isAvailable("dvipost");
-               bool xcolorsoul = LaTeXFeatures::isAvailable("soul") &&
-                                 LaTeXFeatures::isAvailable("xcolor");
-
-               if (features.runparams().flavor == OutputParams::LATEX) {
-                       if (dvipost) {
-                               features.require("ct-dvipost");
-                               features.require("dvipost");
-                       } else if (xcolorsoul) {
-                               features.require("ct-xcolor-soul");
-                               features.require("soul");
-                               features.require("xcolor");
-                       } else {
-                               features.require("ct-none");
-                       }
-               } else if (features.runparams().flavor == OutputParams::PDFLATEX ) {
-                       if (xcolorsoul) {
-                               features.require("ct-xcolor-soul");
-                               features.require("soul");
-                               features.require("xcolor");
-                               features.require("pdfcolmk"); // improves color handling in PDF output
-                       } else {
-                               features.require("ct-none");
-                       }
-               }
-       }
-
-       // Floats with 'Here definitely' as default setting.
-       if (params().float_placement.find('H') != string::npos)
-               features.require("float");
-
-       // AMS Style is at document level
-       if (params().use_amsmath == BufferParams::package_on
-           || tclass.provides("amsmath"))
-               features.require("amsmath");
-       if (params().use_esint == BufferParams::package_on)
-               features.require("esint");
+       params().validate(features);
 
        loadChildDocuments();
 
        for_each(paragraphs().begin(), paragraphs().end(),
                 boost::bind(&Paragraph::validate, _1, boost::ref(features)));
 
-       // the bullet shapes are buffer level not paragraph level
-       // so they are tested here
-       for (int i = 0; i < 4; ++i) {
-               if (params().user_defined_bullet(i) != ITEMIZE_DEFAULTS[i]) {
-                       int const font = params().user_defined_bullet(i).getFont();
-                       if (font == 0) {
-                               int const c = params()
-                                       .user_defined_bullet(i)
-                                       .getCharacter();
-                               if (c == 16
-                                  || c == 17
-                                  || c == 25
-                                  || c == 26
-                                  || c == 31) {
-                                       features.require("latexsym");
-                               }
-                       } else if (font == 1) {
-                               features.require("amssymb");
-                       } else if ((font >= 2 && font <= 5)) {
-                               features.require("pifont");
-                       }
-               }
-       }
-
        if (lyxerr.debugging(Debug::LATEX)) {
                features.showStruct();
        }
index 8003c4b729b5d6a3fe440fa69e742100d338039a..11145b8189424076579b679df22ec667744476da 100644 (file)
@@ -808,6 +808,77 @@ void BufferParams::writeFile(ostream & os) const
 }
 
 
+void BufferParams::validate(LaTeXFeatures & features) const
+{
+       if (outputChanges) {
+               bool dvipost    = LaTeXFeatures::isAvailable("dvipost");
+               bool xcolorsoul = LaTeXFeatures::isAvailable("soul") &&
+                                 LaTeXFeatures::isAvailable("xcolor");
+
+               switch (features.runparams().flavor) {
+               case OutputParams::LATEX:
+                       if (dvipost) {
+                               features.require("ct-dvipost");
+                               features.require("dvipost");
+                       } else if (xcolorsoul) {
+                               features.require("ct-xcolor-soul");
+                               features.require("soul");
+                               features.require("xcolor");
+                       } else {
+                               features.require("ct-none");
+                       }
+                       break;
+               case OutputParams::PDFLATEX:
+                       if (xcolorsoul) {
+                               features.require("ct-xcolor-soul");
+                               features.require("soul");
+                               features.require("xcolor");
+                               // improves color handling in PDF output
+                               features.require("pdfcolmk"); 
+                       } else {
+                               features.require("ct-none");
+                       }
+                       break;
+               default:
+                       break;
+               }
+       }
+
+       // Floats with 'Here definitely' as default setting.
+       if (float_placement.find('H') != string::npos)
+               features.require("float");
+
+       // AMS Style is at document level
+       if (use_amsmath == package_on
+           || getTextClass().provides("amsmath"))
+               features.require("amsmath");
+       if (use_esint == package_on)
+               features.require("esint");
+
+       // the bullet shapes are buffer level not paragraph level
+       // so they are tested here
+       for (int i = 0; i < 4; ++i) {
+               if (user_defined_bullet(i) == ITEMIZE_DEFAULTS[i]) 
+                       continue;
+               int const font = user_defined_bullet(i).getFont();
+               if (font == 0) {
+                       int const c = user_defined_bullet(i).getCharacter();
+                       if (c == 16
+                           || c == 17
+                           || c == 25
+                           || c == 26
+                           || c == 31) {
+                               features.require("latexsym");
+                       }
+               } else if (font == 1) {
+                       features.require("amssymb");
+               } else if (font >= 2 && font <= 5) {
+                       features.require("pifont");
+               }
+       }
+}
+
+
 bool BufferParams::writeLaTeX(odocstream & os, LaTeXFeatures & features,
                              TexRow & texrow) const
 {
index cbf7626818da98b9569d33cc852f396055ba5918..2e670f3eeb13544a2cd044a03962474379241b6a 100644 (file)
@@ -75,6 +75,9 @@ public:
        ///
        void writeFile(std::ostream &) const;
 
+       /// check what features are implied by the buffer parameters.
+       void validate(LaTeXFeatures &) const;
+
        /** \returns true if the babel package is used (interogates
         *  the BufferParams and a LyXRC variable).
         *  This returned value can then be passed to the insets...