]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetCollapsable.cpp
Restore XHTML output for InsetListings.
[lyx.git] / src / insets / InsetCollapsable.cpp
index 42f2af592d546f32bf37d8853e9a4fa13dd937cb..4497e937d33990477bec993d8ee4561ee2d5977c 100644 (file)
 #include "BufferView.h"
 #include "Cursor.h"
 #include "Dimension.h"
-#include "DispatchResult.h"
 #include "FloatList.h"
 #include "FuncRequest.h"
 #include "FuncStatus.h"
 #include "InsetLayout.h"
-#include "InsetList.h"
-#include "Language.h"
 #include "Lexer.h"
 #include "MetricsInfo.h"
-#include "output_xhtml.h"
 #include "OutputParams.h"
-#include "paragraph_funcs.h"
-#include "ParagraphParameters.h"
-#include "sgml.h"
-#include "TextClass.h"
 
 #include "frontends/FontMetrics.h"
 #include "frontends/Painter.h"
@@ -49,8 +41,8 @@ using namespace std;
 
 namespace lyx {
 
-InsetCollapsable::InsetCollapsable(Buffer const & buf, InsetText::UsePlain ltype)
-       : InsetText(buf, ltype), status_(Inset::Open),
+InsetCollapsable::InsetCollapsable(Buffer * buf, InsetText::UsePlain ltype)
+       : InsetText(buf, ltype), status_(Open),
          openinlined_(false), mouse_hover_(false)
 {
        setAutoBreakRows(true);
@@ -156,7 +148,7 @@ void InsetCollapsable::write(ostream & os) const
                break;
        }
        os << "\n";
-       text().write(buffer(), os);
+       text().write(os);
 }
 
 
@@ -262,9 +254,9 @@ void InsetCollapsable::draw(PainterInfo & pi, int x, int y) const
        // Draw button first -- top, left or only
        Dimension dimc = dimensionCollapsed(bv);
 
-       if (geometry(*pi.base.bv) == TopButton ||
-           geometry(*pi.base.bv) == LeftButton ||
-           geometry(*pi.base.bv) == ButtonOnly) {
+       if (geometry(bv) == TopButton ||
+           geometry(bv) == LeftButton ||
+           geometry(bv) == ButtonOnly) {
                button_dim.x1 = x + 0;
                button_dim.x2 = x + dimc.width();
                button_dim.y1 = y - dimc.asc;
@@ -375,7 +367,6 @@ void InsetCollapsable::cursorPos(BufferView const & bv,
 {
        if (geometry(bv) == ButtonOnly)
                status_ = Open;
-       LASSERT(geometry(bv) != ButtonOnly, /**/);
 
        InsetText::cursorPos(bv, sl, boundary, x, y);
        Dimension const textdim = InsetText::dimension(bv);
@@ -406,9 +397,9 @@ bool InsetCollapsable::editable() const
 }
 
 
-bool InsetCollapsable::descendable() const
+bool InsetCollapsable::descendable(BufferView const & bv) const
 {
-       return geometry() != ButtonOnly;
+       return geometry(bv) != ButtonOnly;
 }
 
 
@@ -584,7 +575,8 @@ void InsetCollapsable::setLabel(docstring const & l)
 
 docstring const InsetCollapsable::buttonLabel(BufferView const &) const
 {
-       return labelstring_.empty() ? getLayout().labelstring() : labelstring_;
+       return labelstring_.empty() ? 
+               translateIfPossible(getLayout().labelstring()) : labelstring_;
 }
 
 
@@ -616,33 +608,6 @@ InsetLayout::InsetDecoration InsetCollapsable::decoration() const
 }
 
 
-docstring InsetCollapsable::xhtml(odocstream & os, OutputParams const & runparams) const
-{
-       InsetLayout const & il = getLayout();
-       if (undefined())
-               return InsetText::xhtml(os, runparams);
-
-       bool const opened = html::openTag(os, il.htmltag(), il.htmlattr());
-       if (!il.counter().empty()) {
-               BufferParams const & bp = buffer().masterBuffer()->params();
-               Counters & cntrs = bp.documentClass().counters();
-               cntrs.step(il.counter());
-               // FIXME: translate to paragraph language
-               if (!il.htmllabel().empty())
-                       os << cntrs.counterLabel(from_utf8(il.htmllabel()), bp.language->code());
-       }
-       bool innertag_opened = false;
-       if (!il.htmlinnertag().empty())
-               innertag_opened = html::openTag(os, il.htmlinnertag(), il.htmlinnerattr());
-       docstring deferred = InsetText::xhtml(os, runparams);
-       if (innertag_opened)
-               html::closeTag(os, il.htmlinnertag());
-       if (opened)
-               html::closeTag(os, il.htmltag());
-       return deferred;
-}
-
-
 docstring InsetCollapsable::contextMenu(BufferView const & bv, int x,
        int y) const
 {
@@ -659,12 +624,4 @@ docstring InsetCollapsable::contextMenu(BufferView const & bv, int x,
        return InsetText::contextMenu(bv, x, y);
 }
 
-void InsetCollapsable::tocString(odocstream & os) const
-{
-       if (!getLayout().isInToc())
-               return;
-       os << text().asString(0, 1, AS_STR_LABEL | AS_STR_INSETS);
-}
-
-
 } // namespace lyx