]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetRef.cpp
Fix wrongly copy-pasted entries in SpellcheckerUi.ui
[lyx.git] / src / insets / InsetRef.cpp
index 95097bed85780ad6bc5a00b3c4c21312d60ed586..4bbb38d46602071bf2985273a40ca67d8c0104af 100644 (file)
@@ -82,7 +82,8 @@ ParamInfo const & InsetRef::findInfo(string const & /* cmdName */)
 // the command: \pfxcmd{suffix}.
 // 
 // for prettyref, we return "\prettyref" and put ref into label
-// and pfx into prefix. this is because prettyref 
+// and pfx into prefix. this is because prettyref uses the whole
+// label, thus: \prettyref{pfx:suffix}.
 //
 docstring InsetRef::getFormattedCmd(docstring const & ref, 
        docstring & label, docstring & prefix) const
@@ -136,26 +137,28 @@ docstring InsetRef::getEscapedLabel(OutputParams const & rp) const
 }
 
 
-int InsetRef::latex(odocstream & os, OutputParams const & rp) const
+void InsetRef::latex(otexstream & os, OutputParams const & rp) const
 {
        string const cmd = getCmdName();
-       if (cmd != "formatted") {
+       docstring const data = getEscapedLabel(rp);
+
+       if (cmd == "eqref" && buffer().params().use_refstyle) {
+               os << '(' << from_ascii("\\ref{") << data << from_ascii("})");
+       } 
+       else if (cmd == "formatted") {
+               docstring label;
+               docstring prefix;
+               docstring const fcmd = getFormattedCmd(data, label, prefix);
+               os << fcmd << '{' << label << '}';
+       }
+       else {
                // We don't want to output p_["name"], since that is only used 
                // in docbook. So we construct new params, without it, and use that.
                InsetCommandParams p(REF_CODE, cmd);
                docstring const ref = getParam("reference");
                p["reference"] = ref;
                os << p.getCommand(rp);
-               return 0;
-       } 
-       
-       // so we're doing a formatted reference.
-       docstring const data = getEscapedLabel(rp);
-       docstring label;
-       docstring prefix;
-       docstring const fcmd = getFormattedCmd(data, label, prefix);
-       os << fcmd << '{' << label << '}';
-       return 0;
+       }
 }
 
 
@@ -239,9 +242,9 @@ void InsetRef::toString(odocstream & os) const
 
 void InsetRef::forToc(docstring & os, size_t) const
 {
-       odocstringstream ods;
-       plaintext(ods, OutputParams(0));
-       os += ods.str();
+       // There's no need for details in the TOC, and a long label
+       // will just get in the way.
+       os += '#';
 }
 
 
@@ -280,7 +283,7 @@ void InsetRef::updateBuffer(ParIterator const & it, UpdateType)
 }
 
 
-void InsetRef::addToToc(DocIterator const & cpit)
+void InsetRef::addToToc(DocIterator const & cpit) const
 {
        docstring const & label = getParam("reference");
        if (buffer().insetLabel(label))