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
This commit is contained in:
Jean-Marc Lasgouttes 2007-12-14 14:51:47 +00:00
parent f702ec6eda
commit 6376641f4e
3 changed files with 75 additions and 64 deletions

View 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();
}

View 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
{

View 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...