]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetfloatlist.C
Rename LatexRunParams::fragile as moving_arg.
[lyx.git] / src / insets / insetfloatlist.C
index a64693664f73e630697cad54527c5dbbaf3a16b6..3a4aeee2e89dbc38d9f21ca958925ca2370fa552 100644 (file)
@@ -1,20 +1,28 @@
-#include <config.h>
+/**
+ * \file insetfloatlist.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Lars Gullik Bjønnes
+ *
+ * Full author contact details are available in file CREDITS
+ */
 
-#ifdef __GNUG__
-#pragma implementation
-#endif
+#include <config.h>
 
 #include "insetfloatlist.h"
 #include "FloatList.h"
 #include "LaTeXFeatures.h"
 #include "lyxlex.h"
-#include "frontends/Dialogs.h"
-#include "frontends/LyXView.h"
 #include "BufferView.h"
+#include "funcrequest.h"
+#include "buffer.h"
 #include "toc.h"
 #include "gettext.h"
 #include "debug.h"
+#include "Lsstream.h"
 
+#include "support/lstrings.h"
 
 using std::ostream;
 using std::endl;
@@ -22,8 +30,7 @@ using std::endl;
 
 InsetFloatList::InsetFloatList()
        : InsetCommand(InsetCommandParams())
-{
-}
+{}
 
 
 InsetFloatList::InsetFloatList(string const & type)
@@ -33,10 +40,18 @@ InsetFloatList::InsetFloatList(string const & type)
 }
 
 
-string const InsetFloatList::getScreenLabel(Buffer const *) const
+InsetFloatList::~InsetFloatList()
 {
-       FloatList::const_iterator it = floatList[getCmdName()];
-       if (it != floatList.end())
+       InsetCommandMailer mailer("toc", *this);
+       mailer.hideDialog();
+}
+
+
+string const InsetFloatList::getScreenLabel(Buffer const * buf) const
+{
+       FloatList const & floats = buf->params.getLyXTextClass().floats();
+       FloatList::const_iterator it = floats[getCmdName()];
+       if (it != floats.end())
                return _(it->second.listName());
        else
                return _("ERROR: Nonexistent float type!");
@@ -55,14 +70,15 @@ void InsetFloatList::write(Buffer const *, ostream & os) const
 }
 
 
-void InsetFloatList::read(Buffer const *, LyXLex & lex)
+void InsetFloatList::read(Buffer const * buf, LyXLex & lex)
 {
+       FloatList const & floats = buf->params.getLyXTextClass().floats();
        string token;
 
        if (lex.eatLine()) {
                setCmdName(lex.getString());
                lyxerr[Debug::INSETS] << "FloatList::float_type: " << getCmdName() << endl;
-               if (!floatList.typeExist(getCmdName()))
+               if (!floats.typeExist(getCmdName()))
                        lex.printError("InsetFloatList: Unknown float type: `$$Token'");
        } else
                lex.printError("InsetFloatList: Parse error: `$$Token'");
@@ -79,23 +95,25 @@ void InsetFloatList::read(Buffer const *, LyXLex & lex)
 }
 
 
-void InsetFloatList::edit(BufferView * bv, int, int, mouse_button::state)
-{
-       bv->owner()->getDialogs()->showTOC(this);
-}
-
-
-void InsetFloatList::edit(BufferView * bv, bool)
+dispatch_result InsetFloatList::localDispatch(FuncRequest const & cmd)
 {
-       edit(bv, 0, 0, mouse_button::none);
+       switch (cmd.action) {
+               case LFUN_INSET_EDIT:
+                       InsetCommandMailer("toc", *this).showDialog(cmd.view());
+                       return DISPATCHED;
+               default:
+                       return InsetCommand::localDispatch(cmd);
+       }
 }
 
 
-int InsetFloatList::latex(Buffer const *, ostream & os, bool, bool) const
+int InsetFloatList::latex(Buffer const * buf, ostream & os,
+                         LatexRunParams const &) const
 {
-       FloatList::const_iterator cit = floatList[getCmdName()];
+       FloatList const & floats = buf->params.getLyXTextClass().floats();
+       FloatList::const_iterator cit = floats[getCmdName()];
 
-       if (cit != floatList.end()) {
+       if (cit != floats.end()) {
                if (cit->second.builtin()) {
                        // Only two different types allowed here:
                        string const type = cit->second.type();
@@ -112,7 +130,8 @@ int InsetFloatList::latex(Buffer const *, ostream & os, bool, bool) const
                }
        } else {
                os << "%%\\listof{" << getCmdName() << "}{"
-                  << _("List of ") << cit->second.name() << "}\n";
+                  << bformat(_("List of %1$s"), cit->second.name())
+                  << "}\n";
        }
        return 1;
 }