]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetVSpace.cpp
Fix bug #8580: Do not include material in the XHTML TOC that is not
[lyx.git] / src / insets / InsetVSpace.cpp
index bcd11091f1a67f9066e0e092d3425fb15e283018..927980dcf301ce8e9f7f9a69444d68e26ca36e4f 100644 (file)
 #include "Lexer.h"
 #include "MetricsInfo.h"
 #include "OutputParams.h"
+#include "output_xhtml.h"
 #include "Text.h"
 
 #include "support/debug.h"
+#include "support/docstream.h"
 #include "support/gettext.h"
 #include "support/lassert.h"
 
@@ -51,17 +53,12 @@ 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: {
+               cur.recordUndo();
                InsetVSpace::string2params(to_utf8(cmd.argument()), space_);
                break;
        }
@@ -76,7 +73,7 @@ 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") {
@@ -93,14 +90,6 @@ bool InsetVSpace::getStatus(Cursor & cur, FuncRequest const & cmd,
 }
 
 
-bool InsetVSpace::showInsetDialog(BufferView * bv) const
-{
-       bv->showDialog("vspace", params2string(space()),
-               const_cast<InsetVSpace *>(this));
-       return true;
-}
-
-
 void InsetVSpace::read(Lexer & lex)
 {
        LASSERT(lex.isOK(), /**/);
@@ -212,14 +201,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;
@@ -233,21 +222,20 @@ int InsetVSpace::docbook(odocstream & os, OutputParams const &) const
 }
 
 
-docstring InsetVSpace::xhtml(odocstream & os, OutputParams const &) const
+docstring InsetVSpace::xhtml(XHTMLStream &, OutputParams const &) const
 {
-       string len = space_.asHTMLLength();
-       if (len.empty())
-               // we didn't understand it
-               os << "<br />\n";
-       else
-               os << "<div style='height:" << from_ascii(len) << "'></div>\n";
-       return docstring();
+       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();
 }
 
 
-docstring InsetVSpace::contextMenu(BufferView const &, int, int) const
+string InsetVSpace::contextMenuName() const
 {
-       return from_ascii("context-vspace");
+       return "context-vspace";
 }