Unicode: remove more utf8 roundtrips and faulty conversions to docstring

without from_utf8


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15864 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Georg Baum 2006-11-11 20:55:40 +00:00
parent be76af20b3
commit f6730f66b0
11 changed files with 33 additions and 57 deletions

View 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;

View 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?

View 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);
}

View File

@ -67,7 +67,7 @@ private:
///
virtual std::auto_ptr<InsetBase> doClone() const;
///
mutable std::string label;
mutable docstring label;
///
mutable int labelwidth_;
///

View 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

View 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;

View 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 << ';'

View 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);

View 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_;

View 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);
}
}
}

View 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);