Introduce the InsetMathHull::outerDisplay method and use it

This commit is contained in:
Enrico Forestieri 2016-10-20 00:06:42 +02:00
parent 4065f596ad
commit ab3e1ddc34
3 changed files with 32 additions and 33 deletions

View File

@ -2405,18 +2405,9 @@ void Paragraph::latex(BufferParams const & bparams,
if (d->text_[i] == META_INSET
&& i >= start_pos && (end_pos == -1 || i < end_pos)) {
InsetMath const * im = getInset(i)->asInsetMath();
if (im && im->asHullInset()) {
switch (im->asHullInset()->getType()) {
case hullEquation:
case hullEqnArray:
case hullAlign:
case hullFlAlign:
case hullGather:
case hullMultline:
runparams.inDisplayMath = true;
break;
}
}
if (im && im->asHullInset()
&& im->asHullInset()->outerDisplay())
runparams.inDisplayMath = true;
}
column += Changes::latexMarkChange(os, bparams, runningChange,

View File

@ -898,6 +898,29 @@ bool InsetMathHull::ams() const
}
bool InsetMathHull::outerDisplay() const
{
switch (type_) {
case hullEquation:
case hullEqnArray:
case hullAlign:
case hullFlAlign:
case hullGather:
case hullMultline:
return true;
case hullNone:
case hullSimple:
case hullAlignAt:
case hullXAlignAt:
case hullXXAlignAt:
case hullUnknown:
case hullRegexp:
break;
}
return false;
}
Inset::DisplayType InsetMathHull::display() const
{
switch (type_) {
@ -953,26 +976,7 @@ void InsetMathHull::validate(LaTeXFeatures & features) const
if (ams())
features.require("amsmath");
switch(type_) {
case hullNone:
case hullSimple:
case hullAlignAt:
case hullXAlignAt:
case hullXXAlignAt:
case hullUnknown:
break;
case hullEquation:
case hullEqnArray:
case hullAlign:
case hullFlAlign:
case hullGather:
case hullMultline:
if (features.inDeletedInset() && !features.mustProvide("ct-dvipost"))
features.require("ct-tikz-math-sout");
break;
case hullRegexp:
if (type_ == hullRegexp) {
features.require("color");
docstring frcol = from_utf8(lcolor.getLaTeXName(Color_regexpframe));
docstring bgcol = from_ascii("white");
@ -982,7 +986,9 @@ void InsetMathHull::validate(LaTeXFeatures & features) const
+ bgcol + "}{\\ensuremath{\\mathtt{#1}}}}");
features.addPreambleSnippet(
from_ascii("\\newcommand{\\endregexp}{}"));
break;
} else if (outerDisplay() && features.inDeletedInset()
&& !features.mustProvide("ct-dvipost")) {
features.require("ct-tikz-math-sout");
}
// Validation is necessary only if not using AMS math.

View File

@ -86,6 +86,8 @@ public:
///
bool ams() const;
///
bool outerDisplay() const;
///
void validate(LaTeXFeatures & features) const;
/// identifies HullInset
InsetMathHull const * asHullInset() const { return this; }