]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetBox.cpp
Pure HTML output for math macros.
[lyx.git] / src / insets / InsetBox.cpp
index 1ca0aa718b3040eee2f6e722b8af4bed27be5299..3b7dec3e19a9ffe49e03f82a10025d903bf88b3c 100644 (file)
 #include "LaTeXFeatures.h"
 #include "Lexer.h"
 #include "MetricsInfo.h"
+#include "output_xhtml.h"
 #include "TextClass.h"
 
 #include "support/debug.h"
+#include "support/docstream.h"
 #include "support/gettext.h"
 #include "support/lstrings.h"
 #include "support/Translator.h"
@@ -95,23 +97,11 @@ BoxTranslatorLoc const & boxtranslator_loc()
 //
 /////////////////////////////////////////////////////////////////////////
 
-InsetBox::InsetBox(Buffer const & buffer, string const & label)
+InsetBox::InsetBox(Buffer * buffer, string const & label)
        : InsetCollapsable(buffer), params_(label)
 {}
 
 
-InsetBox::~InsetBox()
-{
-       hideDialogs("box", this);
-}
-
-
-docstring InsetBox::editMessage() const
-{
-       return _("Opened Box Inset");
-}
-
-
 docstring InsetBox::name() const 
 {
        // FIXME: UNICODE
@@ -194,14 +184,6 @@ bool InsetBox::forcePlainLayout(idx_type) const
 }
 
 
-bool InsetBox::showInsetDialog(BufferView * bv) const
-{
-       bv->showDialog("box", params2string(params_),
-               const_cast<InsetBox *>(this));
-       return true;
-}
-
-
 void InsetBox::doDispatch(Cursor & cur, FuncRequest & cmd)
 {
        switch (cmd.action) {
@@ -212,14 +194,10 @@ void InsetBox::doDispatch(Cursor & cur, FuncRequest & cmd)
                        params_.type = cmd.getArg(1);
                else
                        string2params(to_utf8(cmd.argument()), params_);
-               setLayout(cur.buffer()->params());
+               setButtonLabel();
                break;
        }
 
-       case LFUN_INSET_DIALOG_UPDATE:
-               cur.bv().updateDialog("box", params2string(params_));
-               break;
-
        default:
                InsetCollapsable::doDispatch(cur, cmd);
                break;
@@ -484,21 +462,25 @@ int InsetBox::docbook(odocstream & os, OutputParams const & runparams) const
 }
 
 
-int InsetBox::xhtml(odocstream & os, OutputParams const & runparams) const
+docstring InsetBox::xhtml(XHTMLStream & xs, OutputParams const & runparams) const
 {
+       // construct attributes
+       string attrs = "class='" + params_.type + "'";
        string style;
        if (!params_.width.empty())
-               style += ("width: " + params_.width.asHTMLString() + ";");
-       if (!params_.height.empty())
-               style += ("height: " + params_.height.asHTMLString() + ";");
-       
-       os << from_ascii("<span class='" + params_.type + "'");
+               style += ("width: " + params_.width.asHTMLString() + "; ");
+       // The special heights don't really mean anything for us.
+       if (!params_.height.empty() && params_.height_special == "none")
+               style += ("height: " + params_.height.asHTMLString() + "; ");
        if (!style.empty())
-               os << from_ascii(" style='" + style + "'");
-       os << ">\n";
-       InsetText::xhtml(os, runparams);
-       os << "</span>\n";
-       return 0;
+               attrs += " style='" + style + "'";
+
+       xs << html::StartTag("div", attrs);
+       XHTMLOptions const opts = InsetText::WriteLabel | InsetText::WriteInnerTag;
+       docstring defer = InsetText::insetAsXHTML(xs, runparams, opts);
+       xs << html::EndTag("div");
+       xs << defer;
+       return docstring();
 }