]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathRef.cpp
Fix bug 5802 (http://bugzilla.lyx.org/show_bug.cgi?id=5802)
[lyx.git] / src / mathed / InsetMathRef.cpp
index 0193a2ce01d9a4fcfa6051394102e6ab394b833a..7dace38d1bb197db9ac99d7c7626e36420094ee7 100644 (file)
@@ -3,7 +3,7 @@
  * This file is part of LyX, the document processor.
  * Licence details can be found in the file COPYING.
  *
- * \author André Pönitz
+ * \author André Pönitz
  *
  * Full author contact details are available in file CREDITS.
  */
 #include "LaTeXFeatures.h"
 #include "Buffer.h"
 #include "Cursor.h"
-#include "debug.h"
 #include "FuncRequest.h"
 #include "FuncStatus.h"
-#include "gettext.h"
 #include "MathData.h"
 #include "MathFactory.h"
 #include "MathSupport.h"
 
 #include "insets/InsetCommand.h"
 
+#include "support/debug.h"
+#include "support/gettext.h"
 
-namespace lyx {
+#include <ostream>
 
-using std::string;
-using std::endl;
+using namespace std;
 
+namespace lyx {
 
 InsetMathRef::InsetMathRef()
-       : CommandInset(from_ascii("ref"))
+       : CommandInset(from_ascii("ref"), false)
 {}
 
 
 InsetMathRef::InsetMathRef(docstring const & data)
-       : CommandInset(data)
+       : CommandInset(data, false)
 {}
 
 
@@ -79,14 +79,14 @@ void InsetMathRef::doDispatch(Cursor & cur, FuncRequest & cmd)
 
        case LFUN_MOUSE_RELEASE:
                if (cmd.button() == mouse_button::button3) {
-                       lyxerr << "trying to goto ref '" << to_utf8(asString(cell(0))) << "'" << endl;
+                       LYXERR0("trying to goto ref '" << to_utf8(asString(cell(0))) << "'");
                        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().showInsetDialog("ref", data, this);
+                       cur.bv().showDialog("ref", data, this);
                        break;
                }
                cur.undispatched();
@@ -114,7 +114,7 @@ bool InsetMathRef::getStatus(Cursor & cur, FuncRequest const & cmd,
        case LFUN_MOUSE_RELEASE:
        case LFUN_MOUSE_PRESS:
        case LFUN_MOUSE_MOTION:
-               status.enabled(true);
+               status.setEnabled(true);
                return true;
        default:
                return CommandInset::getStatus(cur, cmd, status);
@@ -147,22 +147,23 @@ void InsetMathRef::validate(LaTeXFeatures & features) const
                features.require("varioref");
        else if (commandname() == "prettyref")
                features.require("prettyref");
+       else if (commandname() == "eqref")
+               features.require("amsmath");
 }
 
 
-int InsetMathRef::docbook(Buffer const & buf, odocstream & os,
-                     OutputParams const & runparams) const
+int InsetMathRef::docbook(odocstream & os, OutputParams const & runparams) const
 {
        if (cell(1).empty()) {
                os << "<xref linkend=\""
-                  << sgml::cleanID(buf, runparams, asString(cell(0)));
+                  << sgml::cleanID(buffer(), runparams, asString(cell(0)));
                if (runparams.flavor == OutputParams::XML)
                        os << "\"/>";
                else
                        os << "\">";
        } else {
                os << "<link linkend=\""
-                  << sgml::cleanID(buf, runparams, asString(cell(0)))
+                  << sgml::cleanID(buffer(), runparams, asString(cell(0)))
                   << "\">"
                   << asString(cell(1))
                   << "</link>";
@@ -174,16 +175,16 @@ int InsetMathRef::docbook(Buffer const & buf, odocstream & os,
 
 string const InsetMathRef::createDialogStr(string const & name) const
 {
-       InsetCommandParams icp(to_ascii(commandname()));
+       InsetCommandParams icp(REF_CODE, to_ascii(commandname()));
        icp["reference"] = asString(cell(0));
        if (!cell(1).empty())
                icp["name"] = asString(cell(1));
-       return InsetCommandMailer::params2string(name, icp);
+       return InsetCommand::params2string(name, icp);
 }
 
 
 InsetMathRef::ref_type_info InsetMathRef::types[] = {
-       { from_ascii("ref"),       from_ascii(N_("Standard")),              from_ascii(N_("Ref: "))},
+       { from_ascii("ref"),       from_ascii(N_("Standard[[mathref]]")),   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: "))},