X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2Finsetcharstyle.C;h=4c6472dcbc080d91bcda94b1c252854952d911ca;hb=e28331ed63062dea10d0a21b9ec12034b4b17b9a;hp=1f5a0520b16c215703c5f74d161dfc11bdb912e4;hpb=8b67659646c6850377cb9f44a2a0a22c0e80840c;p=lyx.git diff --git a/src/insets/insetcharstyle.C b/src/insets/insetcharstyle.C index 1f5a0520b1..4c6472dcbc 100644 --- a/src/insets/insetcharstyle.C +++ b/src/insets/insetcharstyle.C @@ -38,8 +38,8 @@ #include -using lyx::docstring; -using lyx::odocstream; + +namespace lyx { using std::string; using std::auto_ptr; @@ -51,7 +51,7 @@ using std::ostringstream; void InsetCharStyle::init() { - setInsetName("CharStyle"); + setInsetName(from_utf8("CharStyle")); setInlined(); setDrawFrame(false); } @@ -139,7 +139,7 @@ void InsetCharStyle::read(Buffer const & buf, LyXLex & lex) } -void InsetCharStyle::metrics(MetricsInfo & mi, Dimension & dim) const +bool InsetCharStyle::metrics(MetricsInfo & mi, Dimension & dim) const { LyXFont tmpfont = mi.base.font; getDrawFont(mi.base.font); @@ -157,21 +157,22 @@ void InsetCharStyle::metrics(MetricsInfo & mi, Dimension & dim) const int w = 0; int a = 0; int d = 0; - string s(params_.type); + // FIXME UNICODE + docstring s(from_utf8(params_.type)); if (undefined()) - // FIXME UNICODE - s = lyx::to_utf8(_("Undef: ")) + s; - docstring ds(s.begin(), s.end()); - theFontMetrics(font).rectText(ds, w, a, d); + s = _("Undef: ") + s; + theFontMetrics(font).rectText(s, w, a, d); dim.wid = max(dim.wid, w); } dim.asc += TEXT_TO_INSET_OFFSET; dim.des += TEXT_TO_INSET_OFFSET; dim.wid += 2 * TEXT_TO_INSET_OFFSET; mi.base.textwidth += 2 * TEXT_TO_INSET_OFFSET; - dim_ = dim; if (params_.show_label) - dim_.des += ascent(); + dim.des += ascent(); + bool const changed = dim_ != dim; + dim_ = dim; + return changed; } @@ -205,14 +206,13 @@ void InsetCharStyle::draw(PainterInfo & pi, int x, int y) const int w = 0; int a = 0; int d = 0; - string s(params_.type); + // FIXME UNICODE + docstring s(from_utf8(params_.type)); if (undefined()) - // FIXME UNICODE - s = lyx::to_utf8(_("Undef: ")) + s; - docstring ds(s.begin(), s.end()); - theFontMetrics(font).rectText(ds, w, a, d); + s = _("Undef: ") + s; + theFontMetrics(font).rectText(s, w, a, d); pi.pain.rectText(x + (dim_.wid - w) / 2, y + desc + a, - ds, font, LColor::none, LColor::none); + s, font, LColor::none, LColor::none); } // a visual clue when the cursor is inside the inset @@ -288,9 +288,9 @@ int InsetCharStyle::latex(Buffer const & buf, odocstream & os, { if (!undefined()) { // FIXME UNICODE - os << '\\' << lyx::from_utf8(params_.latexname); + os << '\\' << from_utf8(params_.latexname); if (!params_.latexparam.empty()) - os << lyx::from_utf8(params_.latexparam); + os << from_utf8(params_.latexparam); os << '{'; } int i = InsetText::latex(buf, os, runparams); @@ -300,7 +300,7 @@ int InsetCharStyle::latex(Buffer const & buf, odocstream & os, } -int InsetCharStyle::docbook(Buffer const & buf, ostream & os, +int InsetCharStyle::docbook(Buffer const & buf, odocstream & os, OutputParams const & runparams) const { ParagraphList::const_iterator beg = paragraphs().begin(); @@ -308,8 +308,9 @@ int InsetCharStyle::docbook(Buffer const & buf, ostream & os, ParagraphList::const_iterator end = paragraphs().end(); if (!undefined()) - sgml::openTag(os, params_.latexname, - par->getID(buf, runparams) + params_.latexparam); + // FIXME UNICODE + sgml::openTag(os, params_.latexname, + par->getID(buf, runparams) + params_.latexparam); for (; par != end; ++par) { par->simpleDocBookOnePar(buf, os, runparams, @@ -331,10 +332,9 @@ int InsetCharStyle::plaintext(Buffer const & buf, odocstream & os, } -int InsetCharStyle::textString(Buffer const & buf, odocstream & os, - OutputParams const & op) const +void InsetCharStyle::textString(Buffer const & buf, odocstream & os) const { - return plaintext(buf, os, op); + os << paragraphs().begin()->asString(buf, true); } @@ -375,3 +375,6 @@ void InsetCharStyleParams::read(LyXLex & lex) } } } + + +} // namespace lyx