]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetLabel.cpp
This should be the last of the commits refactoring the InsetLayout code.
[lyx.git] / src / insets / InsetLabel.cpp
index 8ecd0e56e4a27b8985e01ff47e693331b3d9c444..b0cf6dfcf55e00d05c2c85f55666c8d897b606f5 100644 (file)
 #include "BufferView.h"
 #include "DispatchResult.h"
 #include "FuncRequest.h"
-#include "InsetList.h"
-#include "LyXText.h"
-#include "Paragraph.h"
-#include "ParIterator.h"
+#include "Text.h"
 #include "sgml.h"
 
 #include "support/lstrings.h"
 #include "support/lyxalgo.h"
-#include "support/std_ostream.h"
 
+using namespace std;
+using namespace lyx::support;
 
 namespace lyx {
 
-using support::escape;
-
-using std::string;
-using std::ostream;
-using std::vector;
-
 
 InsetLabel::InsetLabel(InsetCommandParams const & p)
        : InsetCommand(p, "label")
 {}
 
 
-std::auto_ptr<Inset> InsetLabel::doClone() const
+CommandInfo const * InsetLabel::findInfo(string const & /* cmdName */)
+{
+       static const char * const paramnames[] = {"name", ""};
+       static const bool isoptional[] = {false};
+       static const CommandInfo info = {1, paramnames, isoptional};
+       return &info;
+}
+
+
+Inset * InsetLabel::clone() const
 {
-       return std::auto_ptr<Inset>(new InsetLabel(params()));
+       return new InsetLabel(params());
 }
 
 
-void InsetLabel::getLabelList(Buffer const &, std::vector<docstring> & list) const
+void InsetLabel::getLabelList(Buffer const &, vector<docstring> & list) const
 {
        list.push_back(getParam("name"));
 }
@@ -64,7 +65,7 @@ void InsetLabel::doDispatch(Cursor & cur, FuncRequest & cmd)
        switch (cmd.action) {
 
        case LFUN_INSET_MODIFY: {
-               InsetCommandParams p("label");
+               InsetCommandParams p(LABEL_CODE);
                // FIXME UNICODE
                InsetCommandMailer::string2params("label", to_utf8(cmd.argument()), p);
                if (p.getCmdName().empty()) {
@@ -72,8 +73,8 @@ void InsetLabel::doDispatch(Cursor & cur, FuncRequest & cmd)
                        break;
                }
                if (p["name"] != params()["name"])
-                       cur.bv().buffer()->changeRefsIfUnique(params()["name"],
-                                       p["name"], Inset::REF_CODE);
+                       cur.bv().buffer().changeRefsIfUnique(params()["name"],
+                                       p["name"], REF_CODE);
                setParams(p);
                break;
        }
@@ -86,7 +87,7 @@ void InsetLabel::doDispatch(Cursor & cur, FuncRequest & cmd)
 
 
 int InsetLabel::latex(Buffer const &, odocstream & os,
-                      OutputParams const &) const
+                     OutputParams const &) const
 {
        os << escape(getCommand());
        return 0;
@@ -94,7 +95,7 @@ int InsetLabel::latex(Buffer const &, odocstream & os,
 
 
 int InsetLabel::plaintext(Buffer const &, odocstream & os,
-                          OutputParams const &) const
+                         OutputParams const &) const
 {
        docstring const str = getParam("name");
        os << '<' << str << '>';
@@ -103,11 +104,11 @@ int InsetLabel::plaintext(Buffer const &, odocstream & os,
 
 
 int InsetLabel::docbook(Buffer const & buf, odocstream & os,
-                        OutputParams const & runparams) const
+                       OutputParams const & runparams) const
 {
        os << "<!-- anchor id=\""
-           << sgml::cleanID(buf, runparams, getParam("name"))
-           << "\" -->";
+          << sgml::cleanID(buf, runparams, getParam("name"))
+          << "\" -->";
        return 0;
 }