]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetRef.cpp
Natbib authoryear uses (Ref1; Ref2) by default.
[lyx.git] / src / insets / InsetRef.cpp
index 49743ceea836ea460a01079c6fa88e6848a65352..9a2ddd8bd8aec618719ba9c4b7bb561d1564a2ca 100644 (file)
@@ -16,6 +16,7 @@
 #include "Cursor.h"
 #include "DispatchResult.h"
 #include "InsetLabel.h"
+#include "Language.h"
 #include "LaTeXFeatures.h"
 #include "LyX.h"
 #include "OutputParams.h"
@@ -172,7 +173,8 @@ void InsetRef::latex(otexstream & os, OutputParams const & rp) const
 }
 
 
-int InsetRef::plaintext(odocstream & os, OutputParams const &) const
+int InsetRef::plaintext(odocstringstream & os,
+        OutputParams const &, size_t) const
 {
        docstring const str = getParam("reference");
        os << '[' << str << ']';
@@ -205,7 +207,7 @@ int InsetRef::docbook(odocstream & os, OutputParams const & runparams) const
 }
 
 
-docstring InsetRef::xhtml(XHTMLStream & xs, OutputParams const &) const
+docstring InsetRef::xhtml(XHTMLStream & xs, OutputParams const & op) const
 {
        docstring const & ref = getParam("reference");
        InsetLabel const * il = buffer().insetLabel(ref);
@@ -221,14 +223,20 @@ docstring InsetRef::xhtml(XHTMLStream & xs, OutputParams const &) const
                        // normally, would be "ref on page #", but we have no pages
                        display_string = value;
                else if (cmd == "pageref" || cmd == "vpageref")
-                       // normally would be "on page #", but we have no pages
-                       display_string = _("elsewhere");
+                       // normally would be "on page #", but we have no pages.
+                       display_string = translateIfPossible(from_ascii("elsewhere"),
+                               op.local_font->language()->lang());
                else if (cmd == "eqref")
-                       display_string = bformat(from_ascii("equation (%1$s)"), value);
-               else if (cmd == "formatted"
-                        // we don't really have the ability to handle these 
-                        // properly in XHTML output
-                        || cmd == "nameref")
+                       display_string = '(' + value + ')';
+               else if (cmd == "formatted")
+                       display_string = il->prettyCounter();
+               else if (cmd == "nameref")
+                       // FIXME We don't really have the ability to handle these
+                       // properly in XHTML output yet (bug #8599).
+                       // It might not be that hard to do. We have the InsetLabel,
+                       // and we can presumably find its paragraph using the TOC.
+                       // We could then output the contents of the paragraph using
+                       // something?
                        display_string = il->prettyCounter();
        } else 
                        display_string = ref;
@@ -246,7 +254,9 @@ docstring InsetRef::xhtml(XHTMLStream & xs, OutputParams const &) const
 
 void InsetRef::toString(odocstream & os) const
 {
-       plaintext(os, OutputParams(0));
+       odocstringstream ods;
+       plaintext(ods, OutputParams(0));
+       os << ods.str();
 }
 
 
@@ -262,7 +272,7 @@ void InsetRef::updateBuffer(ParIterator const & it, UpdateType)
 {
        docstring const & ref = getParam("reference");
        // register this inset into the buffer reference cache.
-       buffer().references(ref).push_back(make_pair(this, it));
+       buffer().addReference(ref, this, it);
 
        docstring label;
        for (int i = 0; !types[i].latex_name.empty(); ++i) {
@@ -293,7 +303,7 @@ void InsetRef::updateBuffer(ParIterator const & it, UpdateType)
 }
 
 
-void InsetRef::addToToc(DocIterator const & cpit) const
+void InsetRef::addToToc(DocIterator const & cpit, bool output_active) const
 {
        docstring const & label = getParam("reference");
        if (buffer().insetLabel(label))
@@ -303,7 +313,7 @@ void InsetRef::addToToc(DocIterator const & cpit) const
        // It seems that this reference does not point to any valid label.
        screen_label_ = _("BROKEN: ") + screen_label_;
        Toc & toc = buffer().tocBackend().toc("label");
-       toc.push_back(TocItem(cpit, 0, screen_label_));
+       toc.push_back(TocItem(cpit, 0, screen_label_, output_active));
 }