]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetVSpace.cpp
Move isMultiCell() to Cursor, and use it.
[lyx.git] / src / insets / InsetVSpace.cpp
index b352fec43b26f22c5396ed8c94548c4d7e42d6be..0b782f00b859c36eb154623c8905d9e3adbcc683 100644 (file)
 #include "InsetVSpace.h"
 
 #include "Buffer.h"
+#include "BufferView.h"
 #include "Cursor.h"
 #include "Dimension.h"
 #include "DispatchResult.h"
 #include "FuncRequest.h"
 #include "FuncStatus.h"
-#include "support/gettext.h"
 #include "Lexer.h"
-#include "Text.h"
 #include "MetricsInfo.h"
 #include "OutputParams.h"
+#include "Text.h"
+
+#include "support/debug.h"
+#include "support/gettext.h"
+#include "support/lassert.h"
 
+#include "frontends/Application.h"
 #include "frontends/FontMetrics.h"
 #include "frontends/Painter.h"
 
@@ -48,7 +53,7 @@ InsetVSpace::InsetVSpace(VSpace const & space)
 
 InsetVSpace::~InsetVSpace()
 {
-       InsetVSpaceMailer(*this).hideDialog();
+       hideDialogs("vspace", this);
 }
 
 
@@ -57,13 +62,14 @@ void InsetVSpace::doDispatch(Cursor & cur, FuncRequest & cmd)
        switch (cmd.action) {
 
        case LFUN_INSET_MODIFY: {
-               InsetVSpaceMailer::string2params(to_utf8(cmd.argument()), space_);
+               InsetVSpace::string2params(to_utf8(cmd.argument()), space_);
                break;
        }
 
        case LFUN_MOUSE_RELEASE:
                if (!cur.selection() && cmd.button() == mouse_button::button1)
-                       InsetVSpaceMailer(*this).showDialog(&cur.bv());
+                       cur.bv().showDialog("vspace", params2string(space()), 
+                               const_cast<InsetVSpace *>(this));
                break;
 
        default:
@@ -81,10 +87,10 @@ bool InsetVSpace::getStatus(Cursor & cur, FuncRequest const & cmd,
        case LFUN_INSET_MODIFY:
                if (cmd.getArg(0) == "vspace") {
                        VSpace vspace;
-                       InsetVSpaceMailer::string2params(to_utf8(cmd.argument()), vspace);
+                       InsetVSpace::string2params(to_utf8(cmd.argument()), vspace);
                        status.setOnOff(vspace == space_);
-               } else
-                       status.enabled(true);
+               } 
+               status.setEnabled(true);
                return true;
        default:
                return Inset::getStatus(cur, cmd, status);
@@ -94,23 +100,19 @@ bool InsetVSpace::getStatus(Cursor & cur, FuncRequest const & cmd,
 
 void InsetVSpace::edit(Cursor & cur, bool, EntryDirection)
 {
-       InsetVSpaceMailer(*this).showDialog(&cur.bv());
+       cur.bv().showDialog("vspace", params2string(space()), 
+               const_cast<InsetVSpace *>(this));
 }
 
 
 void InsetVSpace::read(Lexer & lex)
 {
-       BOOST_ASSERT(lex.isOK());
+       LASSERT(lex.isOK(), /**/);
        string vsp;
        lex >> vsp;
        if (lex)
                space_ = VSpace(vsp);
-
-       string end_token;
-       lex >> end_token;
-       if (end_token != "\\end_inset")
-               lex.printError("Missing \\end_inset at this point. "
-                              "Read: `$$Token'");
+       lex >> "\\end_inset";
 }
 
 
@@ -241,46 +243,24 @@ docstring InsetVSpace::contextMenu(BufferView const &, int, int) const
 }
 
 
-string const InsetVSpaceMailer::name_ = "vspace";
-
-
-InsetVSpaceMailer::InsetVSpaceMailer(InsetVSpace & inset)
-       : inset_(inset)
-{}
-
-
-string const InsetVSpaceMailer::inset2string(Buffer const &) const
-{
-       return params2string(inset_.space());
-}
-
-
-void InsetVSpaceMailer::string2params(string const & in, VSpace & vspace)
+void InsetVSpace::string2params(string const & in, VSpace & vspace)
 {
        vspace = VSpace();
        if (in.empty())
                return;
 
        istringstream data(in);
-       Lexer lex(0,0);
+       Lexer lex;
        lex.setStream(data);
-
-       string name;
-       lex >> name;
-       if (!lex || name != name_)
-               return print_mailer_error("InsetVSpaceMailer", in, 1, name_);
-
-       string vsp;
-       lex >> vsp;
-       if (lex)
-               vspace = VSpace(vsp);
+       lex.setContext("InsetVSpace::string2params");
+       lex >> "vspace" >> vspace;
 }
 
 
-string const InsetVSpaceMailer::params2string(VSpace const & vspace)
+string InsetVSpace::params2string(VSpace const & vspace)
 {
        ostringstream data;
-       data << name_ << ' ' << vspace.asLyXCommand();
+       data << "vspace" << ' ' << vspace.asLyXCommand();
        return data.str();
 }