]> git.lyx.org Git - features.git/commitdiff
Unicode: remove more utf8 roundtrips and faulty conversions to docstring
authorGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Sat, 11 Nov 2006 20:55:40 +0000 (20:55 +0000)
committerGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Sat, 11 Nov 2006 20:55:40 +0000 (20:55 +0000)
without from_utf8

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15864 a592a061-630c-0410-9148-cb99ea01b6c8

src/buffer.C
src/frontends/controllers/ControlGraphics.C
src/insets/insetcaption.C
src/insets/insetcaption.h
src/insets/insetcharstyle.C
src/insets/insetcollapsable.C
src/insets/insetinclude.C
src/insets/insetvspace.C
src/insets/insetvspace.h
src/insets/render_graphic.C
src/insets/render_preview.C

index ffd9fa74c0b8118386705c0802a5978ddd6ab8c3..cf93290a146ae648b51733d393d9cab4c61a7fac 100644 (file)
@@ -1639,7 +1639,6 @@ void Buffer::changeRefsIfUnique(docstring const & from, docstring const & to,
        } else
                getLabelList(labels);
 
-       // FIXME UNICODE
        if (lyx::count(labels.begin(), labels.end(), from) > 1)
                return;
 
index 15255c96ba93974f50df3aca0f5d33cdc408b703..c1ce0a7893157419353da49e48fc94e19cf21e41 100644 (file)
@@ -83,7 +83,6 @@ void ControlGraphics::dispatchParams()
 
 docstring const ControlGraphics::browse(docstring const & in_name) const
 {
-       // FIXME UNICODE
        docstring const title = _("Select graphics file");
 
        // Does user clipart directory exist?
index 87f327c80496f8eb183d57c9024d465b5129c8cc..482642f94aa548e824d91410091226de772b4d09 100644 (file)
@@ -114,8 +114,7 @@ void InsetCaption::setLabel(LCursor & cur) const
                        num = convert<docstring>(counter_);
 
                // Generate the label
-               label = to_utf8(
-                       bformat(from_ascii("%1$s %2$s:"), _(s), num));
+               label = bformat(from_ascii("%1$s %2$s:"), _(s), num);
        }
 }
 
@@ -125,8 +124,7 @@ void InsetCaption::metrics(MetricsInfo & mi, Dimension & dim) const
        mi.base.textwidth -= 2 * TEXT_TO_INSET_OFFSET;
        LCursor cur = mi.base.bv->cursor();
        setLabel(cur);
-       docstring dlab(label.begin(), label.end());
-       labelwidth_ = theFontMetrics(mi.base.font).width(dlab);
+       labelwidth_ = theFontMetrics(mi.base.font).width(label);
        dim.wid = labelwidth_;
        Dimension textdim;
        InsetText::metrics(mi, textdim);
@@ -153,11 +151,7 @@ void InsetCaption::draw(PainterInfo & pi, int x, int y) const
        // belongs to.
        LCursor cur = pi.base.bv->cursor();
        setLabel(cur);
-       docstring dlab(label.begin(), label.end());
-       // FXIME: instead of using the fontLoader metrics, we should make
-       // painter::text() returns the drawn text witdh.
-       labelwidth_ = theFontMetrics(pi.base.font).width(dlab);
-       pi.pain.text(x, y, dlab, pi.base.font);
+       labelwidth_ = pi.pain.text(x, y, label, pi.base.font);
        InsetText::draw(pi, x + labelwidth_, y);
        setPosCache(pi, x, y);
 }
index 723b9cf6b0691bfde4be65f4274def03d4279107..d60718c128e1f87bc6aa72f79f9ef7d0278cc73c 100644 (file)
@@ -67,7 +67,7 @@ private:
        ///
        virtual std::auto_ptr<InsetBase> doClone() const;
        ///
-       mutable std::string label;
+       mutable docstring label;
        ///
        mutable int labelwidth_;
        ///
index aa8d3ea292d0166c44202fafef0577bbaa852648..6d953726c8ed08ec2d0e3413b32808c11071b9aa 100644 (file)
@@ -157,12 +157,11 @@ 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 = 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;
@@ -205,14 +204,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 = 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
index 7d95df18c7e7883f10ecef7d876e6400dc993cc6..6c1f127dfc61f400bcf362c487265322c69275fd 100644 (file)
@@ -126,9 +126,8 @@ void InsetCollapsable::read(Buffer const & buf, LyXLex & lex)
 Dimension InsetCollapsable::dimensionCollapsed() const
 {
        Dimension dim;
-       docstring dlab(label.begin(), label.end());
        theFontMetrics(labelfont_).buttonText(
-               dlab, dim.wid, dim.asc, dim.des);
+               label, dim.wid, dim.asc, dim.des);
        return dim;
 }
 
@@ -180,8 +179,7 @@ void InsetCollapsable::draw(PainterInfo & pi, int x, int y) const
                button_dim.y1 = top;
                button_dim.y2 = top + dimc.height();
 
-                docstring dlab(label.begin(), label.end());
-               pi.pain.buttonText(xx, top + dimc.asc, dlab, labelfont_);
+               pi.pain.buttonText(xx, top + dimc.asc, label, labelfont_);
 
                if (status() == Open) {
                        int textx, texty;
index 3a4965eaa12aed8dbbeb2d5b1c571f120a95dca3..af81cea20921d75e161f453d7e24df7df991b948 100644 (file)
@@ -545,7 +545,6 @@ int InsetInclude::docbook(Buffer const & buffer, odocstream & os,
        runparams.exportdata->addExternalFile("docbook-xml", writefile,
                                              exportfile);
 
-        // FIXME UNICODE
        if (isVerbatim(params_)) {
                os << "<inlinegraphic fileref=\""
                   << '&' << include_label << ';'
index 7dd69f8ea00a059311ad097abc849d276cb482bf..c03dd4d67141854d641738ba3bec93318ef58130 100644 (file)
@@ -104,11 +104,11 @@ void InsetVSpace::write(Buffer const &, ostream & os) const
 }
 
 
-string const InsetVSpace::label() const
+docstring const InsetVSpace::label() const
 {
+       static docstring const label = _("Vertical Space");
        // FIXME UNICODE
-       static string const label = to_utf8(_("Vertical Space"));
-       return label + " (" + space_.asGUIName() + ')';
+       return label + " (" + from_utf8(space_.asGUIName()) + ')';
 }
 
 
@@ -130,9 +130,7 @@ void InsetVSpace::metrics(MetricsInfo & mi, Dimension & dim) const
        int w = 0;
        int a = 0;
        int d = 0;
-       string lab = label();
-       docstring dlab(lab.begin(), lab.end());
-       theFontMetrics(font).rectText(dlab, w, a, d);
+       theFontMetrics(font).rectText(label(), w, a, d);
 
        height = max(height, a + d);
 
@@ -182,13 +180,12 @@ void InsetVSpace::draw(PainterInfo & pi, int x, int y) const
        font.setColor(LColor::added_space);
        font.decSize();
        font.decSize();
-       string lab = label();
-       docstring dlab(lab.begin(), lab.end());
-       theFontMetrics(font).rectText(dlab, w, a, d);
+       docstring const lab = label();
+       theFontMetrics(font).rectText(lab, w, a, d);
 
        pi.pain.rectText(x + 2 * arrow_size + 5,
                         start + (end - start) / 2 + (a - d) / 2,
-                        dlab, font, LColor::none, LColor::none);
+                        lab, font, LColor::none, LColor::none);
 
        // top arrow
        pi.pain.line(x, ty1, midx, ty2, LColor::added_space);
index 7afd285601048ecbbd8e71042ef7c3384877c5a4..350748b3f0b7d6b70e9bf1a730827cde3b693700 100644 (file)
@@ -57,7 +57,7 @@ protected:
 private:
        virtual std::auto_ptr<InsetBase> doClone() const;
        ///
-       std::string const label() const;
+       docstring const label() const;
 
        ///
        VSpace space_;
index 46fc091f528078f1d17109a9e149560d1651e1f3..d940d782da21114ad87320e3234f20aa2932302b 100644 (file)
@@ -83,7 +83,7 @@ bool displayGraphic(graphics::Params const & params)
 }
 
 
-string const statusMessage(graphics::Params const & params,
+docstring const statusMessage(graphics::Params const & params,
                           graphics::ImageStatus status)
 {
        docstring ret;
@@ -128,8 +128,7 @@ string const statusMessage(graphics::Params const & params,
                }
        }
 
-       // FIXME UNICODE
-       return to_utf8(ret);
+       return ret;
 }
 
 
@@ -168,9 +167,7 @@ void RenderGraphic::metrics(MetricsInfo & mi, Dimension & dim) const
                                .width(justname);
                }
 
-               // FIXME UNICODE
-               docstring const msg = 
-                       from_utf8(statusMessage(params_, loader_.status()));
+               docstring const msg = statusMessage(params_, loader_.status());
                if (!msg.empty()) {
                        msgFont.setSize(LyXFont::SIZE_TINY);
                        font_width = std::max(font_width,
@@ -216,20 +213,18 @@ void RenderGraphic::draw(PainterInfo & pi, int x, int y) const
                string const justname = onlyFilename(params_.filename);
 
                if (!justname.empty()) {
-                       docstring djust(justname.begin(), justname.end());
                        msgFont.setSize(LyXFont::SIZE_FOOTNOTE);
                        pi.pain.text(x + InsetOld::TEXT_TO_INSET_OFFSET + 6,
                                   y - theFontMetrics(msgFont).maxAscent() - 4,
-                                  djust, msgFont);
+                                  from_utf8(justname), msgFont);
                }
 
                // Print the message.
-               string const msg = statusMessage(params_, loader_.status());
+               docstring const msg = statusMessage(params_, loader_.status());
                if (!msg.empty()) {
-                       docstring dmsg(msg.begin(), msg.end());
                        msgFont.setSize(LyXFont::SIZE_TINY);
                        pi.pain.text(x + InsetOld::TEXT_TO_INSET_OFFSET + 6,
-                                    y - 4, dmsg, msgFont);
+                                    y - 4, msg, msgFont);
                }
        }
 }
index e0745fc8cd9518b8f1f37d073117f396786bbf0e..21ce5c58b68c33c273ca0ec96d8b2c679cae1818 100644 (file)
@@ -74,7 +74,7 @@ graphics::PreviewLoader & getPreviewLoader(Buffer const & buffer)
 }
 
 
-string const statusMessage(BufferView const * bv, string const & snippet)
+docstring const statusMessage(BufferView const * bv, string const & snippet)
 {
        BOOST_ASSERT(bv && bv->buffer());
 
@@ -96,8 +96,7 @@ string const statusMessage(BufferView const * bv, string const & snippet)
                break;
        }
 
-       // FIXME UNICODE
-       return to_utf8(message);
+       return message;
 }
 
 } // namespace anon
@@ -129,8 +128,7 @@ void RenderPreview::metrics(MetricsInfo & mi, Dimension & dim) const
                LyXFont font(mi.base.font);
                font.setFamily(LyXFont::SANS_FAMILY);
                font.setSize(LyXFont::SIZE_FOOTNOTE);
-               // FIXME UNICODE
-               docstring const stat = from_utf8(statusMessage(mi.base.bv, snippet_));
+               docstring const stat = statusMessage(mi.base.bv, snippet_);
                dim.wid = 15 + theFontMetrics(font).width(stat);
        }
 
@@ -163,8 +161,7 @@ void RenderPreview::draw(PainterInfo & pi, int x, int y) const
                font.setFamily(LyXFont::SANS_FAMILY);
                font.setSize(LyXFont::SIZE_FOOTNOTE);
 
-               // FIXME UNICODE
-               docstring const stat = from_utf8(statusMessage(pi.base.bv, snippet_));
+               docstring const stat = statusMessage(pi.base.bv, snippet_);
                pi.pain.text(x + offset + 6,
                             y - theFontMetrics(font).maxAscent() - 4,
                             stat, font);