#include "Paragraph.h"
#include "ParIterator.h"
#include "sgml.h"
+#include "TexRow.h"
#include "TextClass.h"
#include "TextPainter.h"
#include "TocBackend.h"
#include "frontends/Painter.h"
#include "support/convert.h"
-#include "support/lassert.h"
#include "support/debug.h"
-#include "support/filetools.h"
#include "support/gettext.h"
+#include "support/filetools.h"
+#include "support/lassert.h"
#include "support/lstrings.h"
+#include "support/RefChanger.h"
#include <sstream>
void InsetMathHull::draw(PainterInfo & pi, int x, int y) const
{
BufferView const * const bv = pi.base.bv;
+ Dimension const dim = dimension(*bv);
- if (type_ == hullRegexp) {
- Dimension const dim = dimension(*bv);
- pi.pain.rectangle(x + 1, y - dim.ascent() + 1,
- dim.width() - 2, dim.height() - 2, Color_regexpframe);
- }
+ if (type_ == hullRegexp)
+ pi.pain.rectangle(x + 2, y - dim.ascent() + 1,
+ dim.width() - 3, dim.height() - 2, Color_regexpframe);
if (previewState(bv)) {
- Dimension const dim = dimension(*bv);
+ // Do not draw change tracking cue if taken care of by RowPainter
+ // already.
+ Changer dummy = make_change(pi.change_, Change(), !canPaintChange(*bv));
if (previewTooSmall(dim)) {
// we have an extra frame
preview_->draw(pi, x + ERROR_FRAME_WIDTH, y);
pi.draw(xx, yy, nl);
}
}
+ // drawing change line
+ if (canPaintChange(*bv))
+ pi.change_.paintCue(pi, x + 1, y + 1 - dim.asc,
+ x + dim.wid, y + dim.des);
setPosCache(pi, x, y);
}
InsetMathGrid::metricsT(mi, dim);
} else {
odocstringstream os;
- TexRow texrow(false);
- otexrowstream ots(os,texrow);
+ otexrowstream ots(os);
WriteStream wi(ots, false, true, WriteStream::wsDefault);
write(wi);
dim.wid = os.str().size();
InsetMathGrid::drawT(pain, x, y);
} else {
odocstringstream os;
- TexRow texrow(false);
- otexrowstream ots(os,texrow);
+ otexrowstream ots(os);
WriteStream wi(ots, false, true, WriteStream::wsDefault);
write(wi);
pain.draw(x, y, os.str().c_str());
static Encoding const * encoding = 0;
if (inset.isBufferValid())
encoding = &(inset.buffer().params().encoding());
- TexRow texrow(false);
- otexrowstream ots(ls,texrow);
+ otexrowstream ots(ls);
WriteStream wi(ots, false, true, WriteStream::wsPreview, encoding);
inset.write(wi);
return ls.str();
}
+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_) {
if (type_ == hullRegexp) {
features.require("color");
- string frcol = lcolor.getLaTeXName(Color_regexpframe);
- string bgcol = "white";
+ docstring frcol = from_utf8(lcolor.getLaTeXName(Color_regexpframe));
+ docstring bgcol = from_ascii("white");
features.addPreambleSnippet(
- string("\\newcommand{\\regexp}[1]{\\fcolorbox{")
- + frcol + string("}{")
- + bgcol + string("}{\\ensuremath{\\mathtt{#1}}}}"));
+ "\\newcommand{\\regexp}[1]{\\fcolorbox{"
+ + frcol + "}{"
+ + bgcol + "}{\\ensuremath{\\mathtt{#1}}}}");
features.addPreambleSnippet(
- string("\\newcommand{\\endregexp}{}"));
+ from_ascii("\\newcommand{\\endregexp}{}"));
+ } else if (outerDisplay() && features.inDeletedInset()
+ && !features.mustProvide("ct-dvipost")) {
+ features.require("ct-tikz-math-sout");
}
// Validation is necessary only if not using AMS math.
break;
case hullSimple:
+ if (os.ulemCmd())
+ os << "\\mbox{";
os << '$';
os.startOuterRow();
if (cell(0).empty())
break;
case hullEquation:
+ if (os.strikeoutMath()) {
+ if (os.ulemCmd() == WriteStream::UNDERLINE)
+ os << "\\raisebox{1ex}{";
+ os << "\\lyxmathsout{\\parbox{\\columnwidth}{";
+ } else if (os.ulemCmd() == WriteStream::UNDERLINE)
+ os << "\\raisebox{-1ex}{\\parbox[b]{\\columnwidth}{";
+ else if (os.ulemCmd() == WriteStream::STRIKEOUT)
+ os << "\\parbox{\\columnwidth}{";
os << "\n";
os.startOuterRow();
if (n)
case hullFlAlign:
case hullGather:
case hullMultline:
+ if (os.strikeoutMath()) {
+ if (os.ulemCmd() == WriteStream::UNDERLINE)
+ os << "\\raisebox{1ex}{";
+ os << "\\lyxmathsout{\\parbox{\\columnwidth}{";
+ } else if (os.ulemCmd() == WriteStream::UNDERLINE)
+ os << "\\raisebox{-1ex}{\\parbox[b]{\\columnwidth}{";
+ else if (os.ulemCmd() == WriteStream::STRIKEOUT)
+ os << "\\parbox{\\columnwidth}{";
os << "\n";
os.startOuterRow();
os << "\\begin{" << hullName(type_) << star(n) << "}\n";
case hullSimple:
os << '$';
+ if (os.ulemCmd())
+ os << "}";
break;
case hullEquation:
os << "\\end{equation" << star(n) << "}\n";
else
os << "\\]\n";
+ if (os.strikeoutMath()) {
+ if (os.ulemCmd() == WriteStream::UNDERLINE)
+ os << "}";
+ os << "}}\\\\\n";
+ } else if (os.ulemCmd() == WriteStream::UNDERLINE)
+ os << "}}\\\\\n";
+ else if (os.ulemCmd() == WriteStream::STRIKEOUT)
+ os << "}\\\\\n";
break;
case hullEqnArray:
case hullAlign:
case hullFlAlign:
- case hullAlignAt:
- case hullXAlignAt:
case hullGather:
case hullMultline:
+ os << "\n";
+ os.startOuterRow();
+ os << "\\end{" << hullName(type_) << star(n) << "}\n";
+ if (os.strikeoutMath()) {
+ if (os.ulemCmd() == WriteStream::UNDERLINE)
+ os << "}";
+ os << "}}\\\\\n";
+ } else if (os.ulemCmd() == WriteStream::UNDERLINE)
+ os << "}}\\\\\n";
+ else if (os.ulemCmd() == WriteStream::STRIKEOUT)
+ os << "}\\\\\n";
+ break;
+
+ case hullAlignAt:
+ case hullXAlignAt:
os << "\n";
os.startOuterRow();
os << "\\end{" << hullName(type_) << star(n) << "}\n";
void InsetMathHull::write(ostream & os) const
{
odocstringstream oss;
- TexRow texrow(false);
- otexrowstream ots(oss,texrow);
+ otexrowstream ots(oss);
WriteStream wi(ots, false, false, WriteStream::wsDefault);
oss << "Formula ";
write(wi);
}
odocstringstream oss;
- TexRow texrow(false);
- otexrowstream ots(oss,texrow);
+ otexrowstream ots(oss);
Encoding const * const enc = encodings.fromLyXName("utf8");
WriteStream wi(ots, false, true, WriteStream::wsDefault, enc);
++ms.tab(); ms.cr(); ms.os() << '<' << bname << '>';
odocstringstream ls;
- TexRow texrow;
- otexstream ols(ls, texrow);
+ otexstream ols(ls);
if (runparams.flavor == OutputParams::XML) {
ms << MTag("alt role='tex' ");
// Workaround for db2latex: db2latex always includes equations with
} else {
ms << MTag("alt role='tex'");
latex(ols, runparams);
- res = texrow.rows();
+ res = ols.texrow().rows();
ms << from_utf8(subst(subst(to_utf8(ls.str()), "&", "&"), "<", "<"));
ms << ETag("alt");
}
// )
// but what follows is equivalent, since we'll enter only if either (a) we
// tried and failed with MathML or HTML or (b) didn't try yet at all but
- // aren't doing LaTeX, in which case we are doing Images.
+ // aren't doing LaTeX.
+ //
+ // so this is for Images.
if (!success && mathtype != BufferParams::LaTeX) {
graphics::PreviewImage const * pimage = 0;
if (!op.dryrun) {
string const tag = (getType() == hullSimple) ? "span" : "div";
xs << html::CR()
- << html::StartTag(tag)
+ << html::StartTag(tag, "style = \"text-align: center;\"")
<< html::CompTag("img", "src=\"" + filename + "\" alt=\"Mathematical Equation\"")
<< html::EndTag(tag)
<< html::CR();
// Unfortunately, we cannot use latexString() because we do not want
// $...$ or whatever.
odocstringstream ls;
- TexRow texrow(false);
- otexrowstream ots(ls,texrow);
+ otexrowstream ots(ls);
WriteStream wi(ots, false, true, WriteStream::wsPreview);
ModeSpecifier specifier(wi, MATH_MODE);
mathAsLatex(wi);
docit_ = di;
}
+
+bool InsetMathHull::canPaintChange(BufferView const &) const
+{
+ // We let RowPainter do it seamlessly for inline insets
+ return display() != Inline;
+}
+
+
} // namespace lyx