]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathRef.cpp
Change the interface to a paragraph's layout. We still store a LayoutPtr, but now...
[lyx.git] / src / mathed / InsetMathRef.cpp
index 9864fc390a2a2496b30f4a40d05544407ac6983b..f6ca612983121383c4d85ab03dee3245bd885d62 100644 (file)
 
 #include "BufferView.h"
 #include "LaTeXFeatures.h"
-#include "buffer.h"
-#include "cursor.h"
-#include "debug.h"
-#include "funcrequest.h"
+#include "Buffer.h"
+#include "Cursor.h"
+#include "FuncRequest.h"
 #include "FuncStatus.h"
-#include "gettext.h"
-#include "MathArray.h"
+#include "MathData.h"
 #include "MathFactory.h"
 #include "MathSupport.h"
-#include "outputparams.h"
+#include "OutputParams.h"
 #include "sgml.h"
 
 #include "insets/InsetCommand.h"
 
+#include "support/debug.h"
+#include "support/gettext.h"
 
-namespace lyx {
+#include <ostream>
 
-using std::string;
-using std::auto_ptr;
-using std::endl;
+using namespace std;
 
+namespace lyx {
 
-RefInset::RefInset()
+InsetMathRef::InsetMathRef()
        : CommandInset(from_ascii("ref"))
 {}
 
 
-RefInset::RefInset(docstring const & data)
+InsetMathRef::InsetMathRef(docstring const & data)
        : CommandInset(data)
 {}
 
 
-auto_ptr<InsetBase> RefInset::doClone() const
+Inset * InsetMathRef::clone() const
 {
-       return auto_ptr<InsetBase>(new RefInset(*this));
+       return new InsetMathRef(*this);
 }
 
 
-void RefInset::infoize(odocstream & os) const
+void InsetMathRef::infoize(odocstream & os) const
 {
        os << "Ref: " << cell(0);
 }
 
 
-void RefInset::doDispatch(LCursor & cur, FuncRequest & cmd)
+void InsetMathRef::doDispatch(Cursor & cur, FuncRequest & cmd)
 {
        switch (cmd.action) {
        case LFUN_INSET_MODIFY:
                if (cmd.getArg(0) == "ref") {
-                       MathArray ar;
+                       MathData ar;
                        if (createInsetMath_fromDialogStr(cmd.argument(), ar)) {
                                *this = *ar[0].nucleus()->asRefInset();
                                break;
@@ -80,14 +79,14 @@ void RefInset::doDispatch(LCursor & 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();
@@ -105,7 +104,7 @@ void RefInset::doDispatch(LCursor & cur, FuncRequest & cmd)
 }
 
 
-bool RefInset::getStatus(LCursor & cur, FuncRequest const & cmd,
+bool InsetMathRef::getStatus(Cursor & cur, FuncRequest const & cmd,
                         FuncStatus & status) const
 {
        switch (cmd.action) {
@@ -123,7 +122,7 @@ bool RefInset::getStatus(LCursor & cur, FuncRequest const & cmd,
 }
 
 
-docstring const RefInset::screenLabel() const
+docstring const InsetMathRef::screenLabel() const
 {
        docstring str;
        for (int i = 0; !types[i].latex_name.empty(); ++i) {
@@ -142,7 +141,7 @@ docstring const RefInset::screenLabel() const
 }
 
 
-void RefInset::validate(LaTeXFeatures & features) const
+void InsetMathRef::validate(LaTeXFeatures & features) const
 {
        if (commandname() == "vref" || commandname() == "vpageref")
                features.require("varioref");
@@ -151,19 +150,18 @@ void RefInset::validate(LaTeXFeatures & features) const
 }
 
 
-int RefInset::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>";
@@ -173,9 +171,9 @@ int RefInset::docbook(Buffer const & buf, odocstream & os,
 }
 
 
-string const RefInset::createDialogStr(string const & name) const
+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));
@@ -183,8 +181,8 @@ string const RefInset::createDialogStr(string const & name) const
 }
 
 
-RefInset::ref_type_info RefInset::types[] = {
-       { from_ascii("ref"),       from_ascii(N_("Standard")),              from_ascii(N_("Ref: "))},
+InsetMathRef::ref_type_info InsetMathRef::types[] = {
+       { 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: "))},