X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fmathed%2FInsetMathDots.cpp;h=63c54c950e03d96603eac45bbe4f8caca1af9b77;hb=3800036b2a376c3ce808386eda0568f2f627d2d1;hp=fa93e4bb924193d80e18819360d1495f55af1661;hpb=137158532b1ac0cde1557226ee486b3fda39b545;p=lyx.git diff --git a/src/mathed/InsetMathDots.cpp b/src/mathed/InsetMathDots.cpp index fa93e4bb92..63c54c950e 100644 --- a/src/mathed/InsetMathDots.cpp +++ b/src/mathed/InsetMathDots.cpp @@ -4,7 +4,7 @@ * Licence details can be found in the file COPYING. * * \author Alejandro Aguilar Sierra - * \author André Pönitz + * \author André Pönitz * * Full author contact details are available in file CREDITS. */ @@ -12,17 +12,21 @@ #include #include "InsetMathDots.h" + +#include "Dimension.h" +#include "LaTeXFeatures.h" #include "MathStream.h" #include "MathSupport.h" #include "MathParser.h" +#include "MetricsInfo.h" #include "frontends/FontMetrics.h" - +#include "support/lassert.h" namespace lyx { InsetMathDots::InsetMathDots(latexkeys const * key) - : key_(key) + : dh_(0), key_(key) {} @@ -34,36 +38,26 @@ Inset * InsetMathDots::clone() const void InsetMathDots::metrics(MetricsInfo & mi, Dimension & dim) const { - dim = theFontMetrics(mi.base.font).dimension('M'); + dim = theFontMetrics(mi.base.font).dimension('X'); dh_ = 0; if (key_->name == "cdots" || key_->name == "dotsb" || key_->name == "dotsm" || key_->name == "dotsi") dh_ = dim.asc / 2; - else if (key_->name == "dotsc") - dh_ = dim.asc / 4; - else if (key_->name == "vdots") { - dim.wid = (dim.wid / 2) + 1; - dh_ = dim.asc; - } - else if (key_->name == "ddots") + else if (key_->name == "ddots" || key_->name == "adots" + || key_->name == "iddots" || key_->name == "vdots") dh_ = dim.asc; - // Cache the inset dimension. - setDimCache(mi, dim); } -void InsetMathDots::draw(PainterInfo & pain, int x, int y) const +void InsetMathDots::draw(PainterInfo & pi, int x, int y) const { - Dimension const dim = dimension(*pain.base.bv); - mathed_draw_deco(pain, x + 2, y - dh_, dim.width() - 2, dim.ascent(), - key_->name); - if (key_->name == "vdots" || key_->name == "ddots") - ++x; - if (key_->name != "vdots") + Dimension const dim = dimension(*pi.base.bv); + if (key_->name == "adots" || key_->name == "iddots") --y; - mathed_draw_deco(pain, x + 2, y - dh_, dim.width() - 2, dim.ascent(), - key_->name); - setPosCache(pain, x, y); + else if (key_->name == "vdots") + x += (dim.width() - 2) / 2; + mathed_draw_deco(pi, x + 1, y - dh_, dim.width() - 2, dim.ascent(), + key_->name); } @@ -73,4 +67,67 @@ docstring InsetMathDots::name() const } +void InsetMathDots::validate(LaTeXFeatures & features) const +{ + if (!key_->required.empty()) + features.require(key_->required); +} + + +void InsetMathDots::mathmlize(MathMLStream & ms) const +{ + // which symbols we support is decided by what is listed in + // lib/symbols as generating a dots inset + docstring const & n = key_->name; + std::string ent; + if (ms.xmlMode()) { + if (n == "dots" || n == "dotsc" || n == "dotso" || n == "ldots") + ent = "…"; + else if (n == "adots" || n == "iddots") + ent = "⋰"; + else if (n == "cdots" || n == "dotsb" || n == "dotsi" || n == "dotsm") + ent = "⋯"; + else if (n == "ddots") + ent = "⋱"; + else if (n == "vdots") + ent = "⋮"; + else LASSERT(false, ent = "…"); + } else { + if (n == "dots" || n == "dotsc" || n == "dotso" || n == "ldots") + ent = "…"; + else if (n == "adots" || n == "iddots") + ent = "⋰"; + else if (n == "cdots" || n == "dotsb" || n == "dotsi" || n == "dotsm") + ent = "⋯"; + else if (n == "ddots") + ent = "⋱"; + else if (n == "vdots") + ent = "⋮"; + else LASSERT(false, ent = "…"); + } + ms << MTagInline("mi") << from_ascii(ent) << ETagInline("mi"); +} + + +void InsetMathDots::htmlize(HtmlStream & os) const +{ + // which symbols we support is decided by what is listed in + // lib/symbols as generating a dots inset + docstring const & n = key_->name; + std::string ent; + if (n == "dots" || n == "dotsc" || n == "dotso" || n == "ldots") + ent = "…"; + else if (n == "adots" || n == "iddots") + ent = "⋰"; + else if (n == "cdots" || n == "dotsb" || n == "dotsi" || n == "dotsm") + ent = "⋯"; + else if (n == "ddots") + ent = "⋱"; + else if (n == "vdots") + ent = "⋮"; + else + LASSERT(false, ent = "#x02026;"); + os << from_ascii(ent); +} + } // namespace lyx