From: Georg Baum Date: Sat, 11 Nov 2006 11:27:47 +0000 (+0000) Subject: Unicode: Avoid another from_utf8(to_utf8()) roundtrip X-Git-Tag: 1.6.10~11937 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=1354f4b6d645e27b9d1b9247aeb143c606080d8e;p=features.git Unicode: Avoid another from_utf8(to_utf8()) roundtrip git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15854 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/cursor.C b/src/cursor.C index 1d6e67442a..e2285a8b18 100644 --- a/src/cursor.C +++ b/src/cursor.C @@ -1175,9 +1175,9 @@ string LCursor::currentState() } -string LCursor::getPossibleLabel() +docstring LCursor::getPossibleLabel() { - return inMathed() ? "eq:" : text()->getPossibleLabel(*this); + return inMathed() ? from_ascii("eq:") : text()->getPossibleLabel(*this); } diff --git a/src/cursor.h b/src/cursor.h index 31ac8f4b64..46f1834f19 100644 --- a/src/cursor.h +++ b/src/cursor.h @@ -289,7 +289,7 @@ public: /// display an error message void errorMessage(docstring const & msg) const; /// - std::string getPossibleLabel(); + docstring getPossibleLabel(); /// moves position somehow up or down bool goUpDown(bool up); diff --git a/src/lyxtext.h b/src/lyxtext.h index e9303fe37a..6094893653 100644 --- a/src/lyxtext.h +++ b/src/lyxtext.h @@ -322,7 +322,7 @@ public: /// double spacing(Buffer const & buffer, Paragraph const & par) const; /// make a suggestion for a label - std::string getPossibleLabel(LCursor & cur) const; + docstring getPossibleLabel(LCursor & cur) const; /// is this paragraph right-to-left? bool isRTL(Buffer const &, Paragraph const & par) const; /// diff --git a/src/text.C b/src/text.C index eb7195732a..be22fb835d 100644 --- a/src/text.C +++ b/src/text.C @@ -2355,7 +2355,7 @@ string LyXText::currentState(LCursor & cur) } -string LyXText::getPossibleLabel(LCursor & cur) const +docstring LyXText::getPossibleLabel(LCursor & cur) const { pit_type pit = cur.pit(); @@ -2369,7 +2369,7 @@ string LyXText::getPossibleLabel(LCursor & cur) const } } - string name = layout->latexname(); + docstring name = from_ascii(layout->latexname()); // for captions, we want the abbreviation of the float type if (layout->labeltype == LABEL_SENSITIVE) { @@ -2378,26 +2378,25 @@ string LyXText::getPossibleLabel(LCursor & cur) const InsetBase * const in = &cur[i].inset(); if (in->lyxCode() == InsetBase::FLOAT_CODE || in->lyxCode() == InsetBase::WRAP_CODE) { - name = to_utf8(in->getInsetName()); + name = in->getInsetName(); break; } } } - string text = name.substr(0, 3); + docstring text = name.substr(0, 3); if (name == "theorem") - text = "thm"; // Create a correct prefix for prettyref + text = from_ascii("thm"); // Create a correct prefix for prettyref text += ':'; if (layout->latextype == LATEX_PARAGRAPH || lyxrc.label_init_length < 0) text.erase(); - // FIXME UNICODE - string par_text = to_utf8(pars_[pit].asString(cur.buffer(), false)); + docstring par_text = pars_[pit].asString(cur.buffer(), false); for (int i = 0; i < lyxrc.label_init_length; ++i) { if (par_text.empty()) break; - string head; + docstring head; par_text = split(par_text, head, ' '); // Is it legal to use spaces in labels ? if (i > 0) diff --git a/src/text3.C b/src/text3.C index 2ebf885a66..649f9067ae 100644 --- a/src/text3.C +++ b/src/text3.C @@ -1105,8 +1105,7 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd) InsetCommandParams p("label"); // Try to generate a valid label p["name"] = (cmd.argument().empty()) ? - // FIXME UNICODE - from_utf8(cur.getPossibleLabel()) : + cur.getPossibleLabel() : cmd.argument(); string const data = InsetCommandMailer::params2string("label", p);