X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2FInsetVSpace.cpp;h=f621172fe2b5ba28475212002d26c7250fbdf6c7;hb=fd5d47d182a70de532225715a04b77fe4155aa18;hp=b499b0bcc9c6d79f0981e5e01a0f704f85005409;hpb=aa1f01777e504d571d93b6251c7819aa268ed5b6;p=lyx.git diff --git a/src/insets/InsetVSpace.cpp b/src/insets/InsetVSpace.cpp index b499b0bcc9..f621172fe2 100644 --- a/src/insets/InsetVSpace.cpp +++ b/src/insets/InsetVSpace.cpp @@ -53,18 +53,18 @@ InsetVSpace::InsetVSpace(VSpace const & space) {} -InsetVSpace::~InsetVSpace() -{ - hideDialogs("vspace", this); -} - - void InsetVSpace::doDispatch(Cursor & cur, FuncRequest & cmd) { - switch (cmd.action) { + switch (cmd.action()) { case LFUN_INSET_MODIFY: { - InsetVSpace::string2params(to_utf8(cmd.argument()), space_); + cur.recordUndo(); + string arg = to_utf8(cmd.argument()); + if (arg == "vspace custom") + arg = (space_.kind() == VSpace::LENGTH) + ? "vspace " + space_.length().asString() + : "vspace 1" + string(stringFromUnit(Length::defaultUnit())); + InsetVSpace::string2params(arg, space_); break; } @@ -78,12 +78,17 @@ void InsetVSpace::doDispatch(Cursor & cur, FuncRequest & cmd) bool InsetVSpace::getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus & status) const { - switch (cmd.action) { + switch (cmd.action()) { // we handle these case LFUN_INSET_MODIFY: if (cmd.getArg(0) == "vspace") { VSpace vspace; - InsetVSpace::string2params(to_utf8(cmd.argument()), vspace); + string arg = to_utf8(cmd.argument()); + if (arg == "vspace custom") + arg = (space_.kind() == VSpace::LENGTH) + ? "vspace " + space_.length().asString() + : "vspace 1" + string(stringFromUnit(Length::defaultUnit())); + InsetVSpace::string2params(arg, vspace); status.setOnOff(vspace == space_); } status.setEnabled(true); @@ -95,17 +100,9 @@ bool InsetVSpace::getStatus(Cursor & cur, FuncRequest const & cmd, } -bool InsetVSpace::showInsetDialog(BufferView * bv) const -{ - bv->showDialog("vspace", params2string(space()), - const_cast(this)); - return true; -} - - void InsetVSpace::read(Lexer & lex) { - LASSERT(lex.isOK(), /**/); + LASSERT(lex.isOK(), return); string vsp; lex >> vsp; if (lex) @@ -214,14 +211,14 @@ void InsetVSpace::draw(PainterInfo & pi, int x, int y) const } -int InsetVSpace::latex(odocstream & os, OutputParams const &) const +void InsetVSpace::latex(otexstream & os, OutputParams const &) const { os << from_ascii(space_.asLatexCommand(buffer().params())) << '\n'; - return 1; } -int InsetVSpace::plaintext(odocstream & os, OutputParams const &) const +int InsetVSpace::plaintext(odocstringstream & os, + OutputParams const &, size_t) const { os << "\n\n"; return PLAINTEXT_NEWLINE; @@ -241,14 +238,14 @@ docstring InsetVSpace::xhtml(XHTMLStream &, OutputParams const &) const XHTMLStream xds(ods); string const len = space_.asHTMLLength(); string const attr = "style='height:" + (len.empty() ? "1em" : len) + "'"; - xds << StartTag("div", attr, true) << EndTag("div"); + xds << html::StartTag("div", attr, true) << html::EndTag("div"); return ods.str(); } -docstring InsetVSpace::contextMenu(BufferView const &, int, int) const +string InsetVSpace::contextMenuName() const { - return from_ascii("context-vspace"); + return "context-vspace"; }