X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2FInsetVSpace.cpp;h=4cdd1ba6edd37dfbdca46ea36db7e0770bbbefc8;hb=9762ba5d388e8a81a6e58c464b635ca4cf48cbfa;hp=e73db774d5376dcb8b3d34a7c3512b794bded685;hpb=e7f2bbe1eec4752ae2c88481bd77320186bbb8fb;p=lyx.git diff --git a/src/insets/InsetVSpace.cpp b/src/insets/InsetVSpace.cpp index e73db774d5..4cdd1ba6ed 100644 --- a/src/insets/InsetVSpace.cpp +++ b/src/insets/InsetVSpace.cpp @@ -24,6 +24,7 @@ #include "MetricsInfo.h" #include "OutputParams.h" #include "output_xhtml.h" +#include "texstream.h" #include "Text.h" #include "support/debug.h" @@ -45,7 +46,7 @@ namespace { int const ADD_TO_VSPACE_WIDTH = 5; -} // namespace anon +} // namespace InsetVSpace::InsetVSpace(VSpace const & space) @@ -59,7 +60,12 @@ void InsetVSpace::doDispatch(Cursor & cur, FuncRequest & cmd) case LFUN_INSET_MODIFY: { cur.recordUndo(); - InsetVSpace::string2params(to_utf8(cmd.argument()), space_); + 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 +84,17 @@ bool InsetVSpace::getStatus(Cursor & cur, FuncRequest const & cmd, 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); return true; - + default: return Inset::getStatus(cur, cmd, status); } @@ -92,7 +103,7 @@ bool InsetVSpace::getStatus(Cursor & cur, FuncRequest const & cmd, void InsetVSpace::read(Lexer & lex) { - LASSERT(lex.isOK(), /**/); + LASSERT(lex.isOK(), return); string vsp; lex >> vsp; if (lex) @@ -139,8 +150,6 @@ void InsetVSpace::metrics(MetricsInfo & mi, Dimension & dim) const dim.asc = height / 2 + (a - d) / 2; // align cursor with the dim.des = height - dim.asc; // label text dim.wid = ADD_TO_VSPACE_WIDTH + 2 * vspace_arrow_size + 5 + w; - // Cache the inset dimension. - setDimCache(mi, dim); } @@ -201,14 +210,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; @@ -222,20 +231,18 @@ int InsetVSpace::docbook(odocstream & os, OutputParams const &) const } -docstring InsetVSpace::xhtml(XHTMLStream &, OutputParams const &) const +docstring InsetVSpace::xhtml(XHTMLStream & os, OutputParams const &) const { - odocstringstream ods; - XHTMLStream xds(ods); string const len = space_.asHTMLLength(); string const attr = "style='height:" + (len.empty() ? "1em" : len) + "'"; - xds << html::StartTag("div", attr, true) << html::EndTag("div"); - return ods.str(); + os << html::StartTag("div", attr, true) << html::EndTag("div"); + return docstring(); } -docstring InsetVSpace::contextMenuName() const +string InsetVSpace::contextMenuName() const { - return from_ascii("context-vspace"); + return "context-vspace"; }