commit ab3e1ddc34bbd3c95cb5a9d88213208b1b054050 Author: Enrico Forestieri <for...@lyx.org> Date: Thu Oct 20 00:06:42 2016 +0200
Introduce the InsetMathHull::outerDisplay method and use it --- src/Paragraph.cpp | 15 ++---------- src/mathed/InsetMathHull.cpp | 48 +++++++++++++++++++++++------------------ src/mathed/InsetMathHull.h | 2 + 3 files changed, 32 insertions(+), 33 deletions(-) diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index 90b5eef..38b1669 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -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, diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp index eab42b0..9c53f6f 100644 --- a/src/mathed/InsetMathHull.cpp +++ b/src/mathed/InsetMathHull.cpp @@ -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. diff --git a/src/mathed/InsetMathHull.h b/src/mathed/InsetMathHull.h index f3ea8a8..f8c04df 100644 --- a/src/mathed/InsetMathHull.h +++ b/src/mathed/InsetMathHull.h @@ -86,6 +86,8 @@ public: /// bool ams() const; /// + bool outerDisplay() const; + /// void validate(LaTeXFeatures & features) const; /// identifies HullInset InsetMathHull const * asHullInset() const { return this; }