]> git.lyx.org Git - features.git/commitdiff
Unicode: Avoid another from_utf8(to_utf8()) roundtrip
authorGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Sat, 11 Nov 2006 11:27:47 +0000 (11:27 +0000)
committerGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Sat, 11 Nov 2006 11:27:47 +0000 (11:27 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15854 a592a061-630c-0410-9148-cb99ea01b6c8

src/cursor.C
src/cursor.h
src/lyxtext.h
src/text.C
src/text3.C

index 1d6e67442af467e3c4480fae42127bbcc054509f..e2285a8b18b34d9f41c3a2e4a00fed1dab348457 100644 (file)
@@ -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);
 }
 
 
index 31ac8f4b641c359777d56b76d65d297e36a252c4..46f1834f191df2957166ab25954d133c28701eee 100644 (file)
@@ -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);
index e9303fe37aafdf5cd2a76a45d73a1b8b16ac0b1d..60948936535b18a2eb5b3e0d4035926d02576e41 100644 (file)
@@ -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;
        ///
index eb7195732a5e8aeafbdafdf360b0a1dc9048bfab..be22fb835d3337b12037293ef62c0eeca3afedd6 100644 (file)
@@ -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)
index 2ebf885a66327c7419fa536d1437e3f1c660ef93..649f9067aee8e720bb13fe604ac970a7d39c469e 100644 (file)
@@ -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);