]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetref.C
* In the process of fixing the math background color bug, this commit transfer backgr...
[lyx.git] / src / insets / insetref.C
index 5ae1406d103145109cec01f4d8e0494eaad9464f..85dca1c86529ab7fdf0bfa45524a34ee86ee0f8f 100644 (file)
@@ -24,9 +24,9 @@
 #include "support/lstrings.h"
 
 
-using lyx::docstring;
-using lyx::odocstream;
-using lyx::support::escape;
+namespace lyx {
+
+using support::escape;
 
 using std::string;
 using std::ostream;
@@ -48,7 +48,7 @@ void InsetRef::doDispatch(LCursor & cur, FuncRequest & cmd)
        case LFUN_MOUSE_PRESS:
                // Eventually trigger dialog with button 3 not 1
                if (cmd.button() == mouse_button::button3)
-                       lyx::dispatch(FuncRequest(LFUN_LABEL_GOTO, getContents()));
+                       lyx::dispatch(FuncRequest(LFUN_LABEL_GOTO, getParam("reference")));
                else {
                        InsetCommandMailer("ref", *this).showDialog(&cur.bv());
                        cur.undispatched();
@@ -73,20 +73,18 @@ docstring const InsetRef::getScreenLabel(Buffer const &) const
                        break;
                }
        }
-       // FIXME UNICODE
-       temp += lyx::from_utf8(getContents());
+       temp += getParam("reference");
 
-       if (!isLatex && !getOptions().empty()) {
+       if (!isLatex && !getParam("name").empty()) {
                temp += "||";
-               // FIXME UNICODE
-               temp += lyx::from_utf8(getOptions());
+               temp += getParam("name");
        }
        return temp;
 }
 
 
 int InsetRef::latex(Buffer const &, odocstream & os,
-                   OutputParams const &) const
+                    OutputParams const &) const
 {
        // Don't output p_["name"], this is only used in docbook
        InsetCommandParams p(getCmdName());
@@ -97,24 +95,34 @@ int InsetRef::latex(Buffer const &, odocstream & os,
 
 
 int InsetRef::plaintext(Buffer const &, odocstream & os,
-                   OutputParams const &) const
+                        OutputParams const &) const
 {
-       // FIXME UNICODE
-       os << '[' << lyx::from_utf8(getContents()) << ']';
-       return 0;
+       docstring const str = getParam("reference");
+       os << '[' << str << ']';
+       return 2 + str.size();
 }
 
 
-int InsetRef::docbook(Buffer const & buf, ostream & os,
-                     OutputParams const & runparams) const
+int InsetRef::docbook(Buffer const & buf, odocstream & os,
+                      OutputParams const & runparams) const
 {
-       if (getOptions().empty() && runparams.flavor == OutputParams::XML) {
-               os << "<xref linkend=\"" << sgml::cleanID(buf, runparams, getContents()) << "\" />";
-       } else if (getOptions().empty()) {
-               os << "<xref linkend=\"" << sgml::cleanID(buf, runparams, getContents()) << "\">";
+       docstring const & name = getParam("name");
+       if (name.empty()) {
+               if (runparams.flavor == OutputParams::XML) {
+                       os << "<xref linkend=\"" 
+                          << sgml::cleanID(buf, runparams, getParam("reference")) 
+                          << "\" />";
+               } else {
+                       os << "<xref linkend=\"" 
+                          << sgml::cleanID(buf, runparams, getParam("reference")) 
+                          << "\">";
+               }
        } else {
-               os << "<link linkend=\"" << sgml::cleanID(buf, runparams, getContents())
-                  << "\">" << getOptions() << "</link>";
+               os << "<link linkend=\"" 
+                  << sgml::cleanID(buf, runparams, getParam("reference"))
+                  << "\">" 
+                  << getParam("name")
+                  << "</link>";
        }
 
        return 0;
@@ -145,7 +153,7 @@ InsetRef::type_info InsetRef::types[] = {
        { "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: ")},
+       { "prettyref", N_("PrettyRef"),             N_("FormatRef: ")},
        { "", "", "" }
 };
 
@@ -163,3 +171,6 @@ string const & InsetRef::getName(int type)
 {
        return types[type].latex_name;
 }
+
+
+} // namespace lyx