]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetwrap.C
The markDirty() and fitCursor() changes
[lyx.git] / src / insets / insetwrap.C
index 92bd136ea00d5ab7e62eef02521a08be2e21bcec..b1d92c0d40a8070d22503a9e1d8c9f486b318b27 100644 (file)
@@ -95,10 +95,17 @@ dispatch_result InsetWrap::localDispatch(FuncRequest const & cmd)
                params_.placement = params.placement;
                params_.width     = params.width;
 
-               cmd.view()->updateInset(this, true);
+               cmd.view()->updateInset(this);
                result = DISPATCHED;
        }
        break;
+
+       case LFUN_INSET_DIALOG_UPDATE: {
+               InsetWrapMailer mailer(*this);
+               mailer.updateDialog(cmd.view());
+       }
+       break;
+
        default:
                result = InsetCollapsable::localDispatch(cmd);
        }
@@ -284,7 +291,7 @@ bool InsetWrap::showInsetDialog(BufferView * bv) const
        if (!inset.showInsetDialog(bv)) {
                InsetWrap * tmp = const_cast<InsetWrap *>(this);
                InsetWrapMailer mailer(*tmp);
-               mailer.showDialog();
+               mailer.showDialog(bv);
        }
        return true;
 }
@@ -310,14 +317,16 @@ void InsetWrap::addToToc(toc::TocList & toclist, Buffer const * buf) const
 }
 
 
+string const InsetWrapMailer::name_("wrap");
+
 InsetWrapMailer::InsetWrapMailer(InsetWrap & inset)
-       : name_("wrap"), inset_(inset)
+       : inset_(inset)
 {}
 
 
 string const InsetWrapMailer::inset2string() const
 {
-       return params2string(name(), inset_.params());
+       return params2string(inset_.params());
 }
 
 
@@ -326,32 +335,37 @@ void InsetWrapMailer::string2params(string const & in,
 {
        params = InsetWrapParams();
 
-       string name;
-       string body = split(in, name, ' ');
+       istringstream data(in);
+       LyXLex lex(0,0);
+       lex.setStream(data);
 
-       if (name != "wrap" || body.empty())
-               return;
+       if (lex.isOK()) {
+               lex.next();
+               string const token = lex.getString();
+               if (token != name_)
+                       return;
+       }
 
        // This is part of the inset proper that is usually swallowed
        // by Buffer::readInset
-       body = split(body, name, '\n');
-       if (!prefixIs(name, "Wrap "))
-               return;
-
-       istringstream data(body);
-       LyXLex lex(0,0);
-       lex.setStream(data);
+       if (lex.isOK()) {
+               lex.next();
+               string const token = lex.getString();
+               if (token != "Wrap" || !lex.eatLine())
+                       return;
+       }
 
-       params.read(lex);
+       if (lex.isOK()) {
+               params.read(lex);
+       }
 }
 
 
 string const
-InsetWrapMailer::params2string(string const & name,
-                              InsetWrapParams const & params)
+InsetWrapMailer::params2string(InsetWrapParams const & params)
 {
        ostringstream data;
-       data << name << ' ';
+       data << name_ << ' ';
        params.write(data);
 
        return data.str();