From 6376641f4e419a15501f2a04a9b2c286924e6e92 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Fri, 14 Dec 2007 14:51:47 +0000 Subject: [PATCH] Move part of Buffer::validate into a new method BufferParams::validate. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@22146 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/Buffer.cpp | 65 +--------------------------------------- src/BufferParams.cpp | 71 ++++++++++++++++++++++++++++++++++++++++++++ src/BufferParams.h | 3 ++ 3 files changed, 75 insertions(+), 64 deletions(-) diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 2d0a3ad84d..7c3e85b3bd 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -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(); } diff --git a/src/BufferParams.cpp b/src/BufferParams.cpp index 8003c4b729..11145b8189 100644 --- a/src/BufferParams.cpp +++ b/src/BufferParams.cpp @@ -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 { diff --git a/src/BufferParams.h b/src/BufferParams.h index cbf7626818..2e670f3eeb 100644 --- a/src/BufferParams.h +++ b/src/BufferParams.h @@ -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... -- 2.39.2