diff --git a/src/insets/InsetBranch.cpp b/src/insets/InsetBranch.cpp index d33069f62b..5353fde278 100644 --- a/src/insets/InsetBranch.cpp +++ b/src/insets/InsetBranch.cpp @@ -235,7 +235,7 @@ int InsetBranch::docbook(odocstream & os, void InsetBranch::tocString(odocstream & os) const { if (isBranchSelected()) - os << text().asString(0, 1, AS_STR_LABEL | AS_STR_INSETS); + InsetCollapsable::tocString(os); } diff --git a/src/insets/InsetCollapsable.cpp b/src/insets/InsetCollapsable.cpp index db1844a768..31e3daf33c 100644 --- a/src/insets/InsetCollapsable.cpp +++ b/src/insets/InsetCollapsable.cpp @@ -28,7 +28,9 @@ #include "LaTeXFeatures.h" #include "Lexer.h" #include "MetricsInfo.h" +#include "paragraph_funcs.h" #include "ParagraphParameters.h" +#include "sgml.h" #include "TextClass.h" #include "frontends/FontMetrics.h" @@ -817,6 +819,31 @@ int InsetCollapsable::latex(odocstream & os, } +// FIXME It seems as if it ought to be possible to do this more simply, +// maybe by calling InsetText::docbook() in the middle there. +int InsetCollapsable::docbook(odocstream & os, OutputParams const & runparams) const +{ + ParagraphList::const_iterator const beg = paragraphs().begin(); + ParagraphList::const_iterator par = paragraphs().begin(); + ParagraphList::const_iterator const end = paragraphs().end(); + + if (!undefined()) + sgml::openTag(os, getLayout().latexname(), + par->getID(buffer(), runparams) + getLayout().latexparam()); + + for (; par != end; ++par) { + par->simpleDocBookOnePar(buffer(), os, runparams, + outerFont(distance(beg, par), + paragraphs())); + } + + if (!undefined()) + sgml::closeTag(os, getLayout().latexname()); + + return 0; +} + + void InsetCollapsable::validate(LaTeXFeatures & features) const { string const preamble = getLayout().preamble(); @@ -850,4 +877,12 @@ 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 diff --git a/src/insets/InsetCollapsable.h b/src/insets/InsetCollapsable.h index 5a41ca8977..8610516002 100644 --- a/src/insets/InsetCollapsable.h +++ b/src/insets/InsetCollapsable.h @@ -138,6 +138,8 @@ public: /// int latex(odocstream &, OutputParams const &) const; /// + int docbook(odocstream &, OutputParams const &) const; + /// void validate(LaTeXFeatures &) const; /// InsetCode lyxCode() const { return COLLAPSABLE_CODE; } @@ -153,6 +155,8 @@ public: /// Is this inset's layout defined in the document's textclass? /// May be wrong after textclass change or paste from another document bool undefined() const; + /// the string that is passed to the TOC + void tocString(odocstream &) const; /// virtual docstring contextMenu(BufferView const & bv, int x, int y) const; protected: diff --git a/src/insets/InsetFlex.cpp b/src/insets/InsetFlex.cpp index 5931bb4eba..c2dbe8a2bc 100644 --- a/src/insets/InsetFlex.cpp +++ b/src/insets/InsetFlex.cpp @@ -16,18 +16,13 @@ #include "Buffer.h" #include "BufferParams.h" -#include "LaTeXFeatures.h" #include "Lexer.h" -#include "MetricsInfo.h" -#include "Paragraph.h" -#include "paragraph_funcs.h" -#include "sgml.h" -#include "Text.h" #include "support/gettext.h" #include +//#include "support/debug.h" using namespace std; namespace lyx { @@ -61,33 +56,4 @@ void InsetFlex::write(ostream & os) const } -int InsetFlex::docbook(odocstream & os, OutputParams const & runparams) const -{ - ParagraphList::const_iterator const beg = paragraphs().begin(); - ParagraphList::const_iterator par = paragraphs().begin(); - ParagraphList::const_iterator const end = paragraphs().end(); - - if (!undefined()) - sgml::openTag(os, getLayout().latexname(), - par->getID(buffer(), runparams) + getLayout().latexparam()); - - for (; par != end; ++par) { - par->simpleDocBookOnePar(buffer(), os, runparams, - outerFont(distance(beg, par), - paragraphs())); - } - - if (!undefined()) - sgml::closeTag(os, getLayout().latexname()); - - return 0; -} - - -void InsetFlex::tocString(odocstream & os) const -{ - os << text().asString(0, 1, AS_STR_LABEL | AS_STR_INSETS); -} - - } // namespace lyx diff --git a/src/insets/InsetFlex.h b/src/insets/InsetFlex.h index 4b70aba2aa..58ce052194 100644 --- a/src/insets/InsetFlex.h +++ b/src/insets/InsetFlex.h @@ -26,19 +26,12 @@ public: InsetFlex(Buffer const &, std::string const & layoutName); /// docstring name() const { return from_utf8(name_); } - /// docstring editMessage() const; /// InsetCode lyxCode() const { return FLEX_CODE; } /// void write(std::ostream &) const; - - /// - int docbook(odocstream &, OutputParams const &) const; - /// the string that is passed to the TOC - void tocString(odocstream &) const; - /// should paragraph indendation be ommitted in any case? bool neverIndent() const { return true; }