]> git.lyx.org Git - features.git/blobdiff - src/insets/insetvspace.C
change "support/std_sstream.h" to <sstream>
[features.git] / src / insets / insetvspace.C
index 8dd06adfa313d5380edcb6916f98dea3fd6a0442..5946dd70e26f6cf58b4dfe07fe9ba0091fba01c9 100644 (file)
@@ -15,6 +15,7 @@
 
 #include "buffer.h"
 #include "BufferView.h"
+#include "cursor.h"
 #include "dispatchresult.h"
 #include "funcrequest.h"
 #include "gettext.h"
@@ -26,7 +27,7 @@
 #include "frontends/font_metrics.h"
 #include "frontends/Painter.h"
 
-#include "support/std_sstream.h"
+#include <sstream>
 
 using std::istringstream;
 using std::ostream;
@@ -59,40 +60,39 @@ std::auto_ptr<InsetBase> InsetVSpace::clone() const
 }
 
 
-DispatchResult
-InsetVSpace::priv_dispatch(FuncRequest const & cmd,
-                          idx_type & idx, pos_type & pos)
+void InsetVSpace::priv_dispatch(LCursor & cur, FuncRequest & cmd)
 {
        switch (cmd.action) {
 
        case LFUN_INSET_MODIFY: {
                InsetVSpaceMailer::string2params(cmd.argument, space_);
-               return DispatchResult(true, true);
+               break;
        }
 
        case LFUN_MOUSE_PRESS:
-               InsetVSpaceMailer(*this).showDialog(cmd.view());
-               return DispatchResult(true, true);
+               InsetVSpaceMailer(*this).showDialog(&cur.bv());
+               break;
 
        default:
-               return InsetOld::priv_dispatch(cmd, idx, pos);
+               InsetOld::priv_dispatch(cur, cmd);
+               break;
        }
 }
-               
+
 
 void InsetVSpace::read(Buffer const &, LyXLex & lex)
 {
-       if (lex.isOK()) {
-               lex.next();
-               space_ = VSpace(lex.getString());
-       }
+       BOOST_ASSERT(lex.isOK());
+       string vsp;
+       lex >> vsp;
+       if (lex)
+               space_ = VSpace(vsp);
 
-       if (lex.isOK())
-               lex.next();
-       if (lex.getString() != "\\end_inset") {
+       string end_token;
+       lex >> end_token;
+       if (end_token != "\\end_inset")
                lex.printError("Missing \\end_inset at this point. "
                               "Read: `$$Token'");
-       }
 }
 
 
@@ -129,8 +129,7 @@ void InsetVSpace::draw(PainterInfo & pi, int x, int y) const
 {
        static std::string const label = _("Vertical Space");
 
-       xo_ = x;
-       yo_ = y;
+       setPosCache(pi, x, y);
 
        x += ADD_TO_VSPACE_WIDTH;
 
@@ -232,22 +231,27 @@ InsetVSpaceMailer::InsetVSpaceMailer(InsetVSpace & inset)
 
 string const InsetVSpaceMailer::inset2string(Buffer const &) const
 {
-       return params2string(inset_.space_);
+       return params2string(inset_.space());
 }
 
 
 void InsetVSpaceMailer::string2params(string const & in, VSpace & vspace)
 {
        vspace = VSpace();
-
        if (in.empty())
                return;
 
        istringstream data(in);
        LyXLex lex(0,0);
        lex.setStream(data);
-       string name, vsp;
-       lex >> name >> vsp; 
+
+       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);
 }