]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetBox.cpp
Restore XHTML output for InsetListings.
[lyx.git] / src / insets / InsetBox.cpp
index 4882f78e4b72c38e9598e5c9fc23f25bcd3ef2d5..ad2084f5bb7497c54d54f6e4db9390c075aa3a7f 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,7 +97,7 @@ BoxTranslatorLoc const & boxtranslator_loc()
 //
 /////////////////////////////////////////////////////////////////////////
 
-InsetBox::InsetBox(Buffer const & buffer, string const & label)
+InsetBox::InsetBox(Buffer * buffer, string const & label)
        : InsetCollapsable(buffer), params_(label)
 {}
 
@@ -106,12 +108,6 @@ InsetBox::~InsetBox()
 }
 
 
-docstring InsetBox::editMessage() const
-{
-       return _("Opened Box Inset");
-}
-
-
 docstring InsetBox::name() const 
 {
        // FIXME: UNICODE
@@ -212,7 +208,6 @@ void InsetBox::doDispatch(Cursor & cur, FuncRequest & cmd)
                        params_.type = cmd.getArg(1);
                else
                        string2params(to_utf8(cmd.argument()), params_);
-               setLayout(cur.buffer()->params());
                break;
        }
 
@@ -239,7 +234,6 @@ bool InsetBox::getStatus(Cursor & cur, FuncRequest const & cmd,
                return true;
 
        case LFUN_INSET_DIALOG_UPDATE:
-       case LFUN_INSET_SETTINGS:
                flag.setEnabled(true);
                return true;
 
@@ -485,6 +479,27 @@ int InsetBox::docbook(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() + ";");
+       if (!style.empty())
+               attrs += " style='" + style + "'";
+
+       xs << StartTag("div", attrs);
+       XHTMLOptions const opts = InsetText::WriteLabel | InsetText::WriteInnerTag;
+       docstring defer = InsetText::insetAsXHTML(xs, runparams, opts);
+       xs << EndTag("div");
+       xs << defer;
+       return docstring();
+}
+
+
 void InsetBox::validate(LaTeXFeatures & features) const
 {
        BoxType btype = boxtranslator().find(params_.type);