]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathRef.C
fix reading UTF8 encoded symbol file
[lyx.git] / src / mathed / InsetMathRef.C
index 606a1f5c799e9525d4d4371b17e5a163368f36bc..eb4a14466b06181e121b59d0bbfd0a974abe757a 100644 (file)
 #include "outputparams.h"
 #include "sgml.h"
 
-#include "frontends/LyXView.h"
-#include "frontends/Dialogs.h"
+
+namespace lyx {
 
 using std::string;
 using std::auto_ptr;
 using std::endl;
 
 
-
 RefInset::RefInset()
-       : CommandInset("ref")
+       : CommandInset(from_ascii("ref"))
 {}
 
 
-RefInset::RefInset(string const & data)
+RefInset::RefInset(docstring const & data)
        : CommandInset(data)
 {}
 
@@ -51,7 +50,7 @@ auto_ptr<InsetBase> RefInset::doClone() const
 }
 
 
-void RefInset::infoize(std::ostream & os) const
+void RefInset::infoize(odocstream & os) const
 {
        os << "Ref: " << cell(0);
 }
@@ -63,7 +62,7 @@ void RefInset::doDispatch(LCursor & cur, FuncRequest & cmd)
        case LFUN_INSET_MODIFY:
                if (cmd.getArg(0) == "ref") {
                        MathArray ar;
-                       if (createInsetMath_fromDialogStr(lyx::to_utf8(cmd.argument()), ar)) {
+                       if (createInsetMath_fromDialogStr(cmd.argument(), ar)) {
                                *this = *ar[0].nucleus()->asRefInset();
                                break;
                        }
@@ -73,21 +72,20 @@ void RefInset::doDispatch(LCursor & cur, FuncRequest & cmd)
 
        case LFUN_INSET_DIALOG_UPDATE: {
                string const data = createDialogStr("ref");
-               if (cur.bv().owner()->getDialogs().visible("ref"))
-                       cur.bv().owner()->getDialogs().update("ref", data);
+               cur.bv().updateDialog("ref", data);
                break;
        }
 
        case LFUN_MOUSE_RELEASE:
                if (cmd.button() == mouse_button::button3) {
-                       lyxerr << "trying to goto ref '" << asString(cell(0)) << "'" << endl;
+                       lyxerr << "trying to goto ref '" << to_utf8(asString(cell(0))) << "'" << endl;
                        cur.bv().dispatch(FuncRequest(LFUN_LABEL_GOTO, asString(cell(0))));
                        break;
                }
                if (cmd.button() == mouse_button::button1) {
                        // Eventually trigger dialog with button 3, not 1
                        string const data = createDialogStr("ref");
-                       cur.bv().owner()->getDialogs().show("ref", data, this);
+                       cur.bv().showInsetDialog("ref", data, this);
                        break;
                }
                cur.undispatched();
@@ -123,15 +121,15 @@ bool RefInset::getStatus(LCursor & cur, FuncRequest const & cmd,
 }
 
 
-string const RefInset::screenLabel() const
+docstring const RefInset::screenLabel() const
 {
-       string str;
-       for (int i = 0; !types[i].latex_name.empty(); ++i)
+       docstring str;
+       for (int i = 0; !types[i].latex_name.empty(); ++i) {
                if (commandname() == types[i].latex_name) {
-                       // FIXME UNICODE
-                       str = lyx::to_utf8(_(types[i].short_gui_name));
+                       str = _(to_utf8(types[i].short_gui_name));
                        break;
                }
+       }
        str += asString(cell(0));
 
        //if (/* !isLatex && */ !cell(0).empty()) {
@@ -151,24 +149,30 @@ void RefInset::validate(LaTeXFeatures & features) const
 }
 
 
-int RefInset::plaintext(std::ostream & os, OutputParams const &) const
+int RefInset::plaintext(odocstream & os, OutputParams const &) const
 {
+       // FIXME UNICODE
        os << '[' << asString(cell(0)) << ']';
        return 0;
 }
 
 
-int RefInset::docbook(Buffer const & buf, std::ostream & os, OutputParams const & runparams) const
+int RefInset::docbook(Buffer const & buf, odocstream & os,
+               OutputParams const & runparams) const
 {
        if (cell(1).empty()) {
-               os << "<xref linkend=\"" << sgml::cleanID(buf, runparams, asString(cell(0)));
+               os << "<xref linkend=\""
+                  << sgml::cleanID(buf, runparams, asString(cell(0)));
                if (runparams.flavor == OutputParams::XML)
                        os << "\"/>";
                else
                        os << "\">";
        } else {
-               os << "<link linkend=\"" << sgml::cleanID(buf, runparams, asString(cell(0)))
-                  << "\">" << asString(cell(1)) << "</link>";
+               os << "<link linkend=\""
+                  << sgml::cleanID(buf, runparams, asString(cell(0)))
+                  << "\">"
+                  << asString(cell(1))
+                  << "</link>";
        }
 
        return 0;
@@ -176,11 +180,14 @@ int RefInset::docbook(Buffer const & buf, std::ostream & os, OutputParams const
 
 
 RefInset::ref_type_info RefInset::types[] = {
-       { "ref",       N_("Standard"),              N_("Ref: ")},
-       { "eqref",     N_("Equation"),              N_("EqRef: ")},
-       { "pageref",   N_("Page Number"),           N_("Page: ")},
-       { "vpageref",  N_("Textual Page Number"),   N_("TextPage: ")},
-       { "vref",      N_("Standard+Textual Page"), N_("Ref+Text: ")},
-       { "prettyref", N_("PrettyRef"),             N_("PrettyRef: ")},
-       { "", "", "" }
+       { from_ascii("ref"),       from_ascii(N_("Standard")),              from_ascii(N_("Ref: "))},
+       { from_ascii("eqref"),     from_ascii(N_("Equation")),              from_ascii(N_("EqRef: "))},
+       { from_ascii("pageref"),   from_ascii(N_("Page Number")),           from_ascii(N_("Page: "))},
+       { from_ascii("vpageref"),  from_ascii(N_("Textual Page Number")),   from_ascii(N_("TextPage: "))},
+       { from_ascii("vref"),      from_ascii(N_("Standard+Textual Page")), from_ascii(N_("Ref+Text: "))},
+       { from_ascii("prettyref"), from_ascii(N_("PrettyRef")),             from_ascii(N_("PrettyRef: "))},
+       { from_ascii(""), from_ascii(""), from_ascii("") }
 };
+
+
+} // namespace lyx