X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fmathed%2FInsetMathDots.cpp;h=8c4bd8374b3f35b84cdf06d44f23436c39278ed7;hb=5fdc577badb1cb133d6a0dc7d831bb1f82576adb;hp=e949df8fdddd4947654edf7b7422e33d3c51276d;hpb=ed858d73e57ce7aa89e38c1bc4d799362edb0227;p=lyx.git diff --git a/src/mathed/InsetMathDots.cpp b/src/mathed/InsetMathDots.cpp index e949df8fdd..8c4bd8374b 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) {} @@ -32,7 +36,7 @@ Inset * InsetMathDots::clone() const } -bool InsetMathDots::metrics(MetricsInfo & mi, Dimension & dim) const +void InsetMathDots::metrics(MetricsInfo & mi, Dimension & dim) const { dim = theFontMetrics(mi.base.font).dimension('M'); dh_ = 0; @@ -45,26 +49,26 @@ bool InsetMathDots::metrics(MetricsInfo & mi, Dimension & dim) const 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") dh_ = dim.asc; - if (dim_ == dim) - return false; - dim_ = dim; - return true; } -void InsetMathDots::draw(PainterInfo & pain, int x, int y) const +void InsetMathDots::draw(PainterInfo & pi, int x, int y) const { - mathed_draw_deco(pain, x + 2, y - dh_, dim_.width() - 2, dim_.ascent(), - key_->name); - if (key_->name == "vdots" || key_->name == "ddots") + Dimension const dim = dimension(*pi.base.bv); + if (key_->name == "adots" || key_->name == "iddots") + --y; + mathed_draw_deco(pi, x + 2, y - dh_, dim.width() - 2, dim.ascent(), + key_->name); + if (key_->name == "vdots" || key_->name == "ddots" || key_->name == "adots" || key_->name == "iddots") ++x; - if (key_->name != "vdots") + if (key_->name == "adots" || key_->name == "iddots") + ++y; + else if (key_->name != "vdots") --y; - mathed_draw_deco(pain, x + 2, y - dh_, dim_.width() - 2, dim_.ascent(), + mathed_draw_deco(pi, x + 2, y - dh_, dim.width() - 2, dim.ascent(), key_->name); - setPosCache(pain, x, y); } @@ -74,4 +78,54 @@ docstring InsetMathDots::name() const } +void InsetMathDots::validate(LaTeXFeatures & features) const +{ + if (!key_->requires.empty()) + features.require(key_->requires); +} + + +void InsetMathDots::mathmlize(MathStream & 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 = "…"); + os << MTag("mi") << from_ascii(ent) << ETag("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