]> git.lyx.org Git - features.git/commitdiff
Move some stuff from InsetFlex to InsetCollapsable, and make use of the
authorRichard Heck <rgheck@comcast.net>
Fri, 6 Feb 2009 17:56:47 +0000 (17:56 +0000)
committerRichard Heck <rgheck@comcast.net>
Fri, 6 Feb 2009 17:56:47 +0000 (17:56 +0000)
InToc tag in a couple places.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@28378 a592a061-630c-0410-9148-cb99ea01b6c8

src/insets/InsetBranch.cpp
src/insets/InsetCollapsable.cpp
src/insets/InsetCollapsable.h
src/insets/InsetFlex.cpp
src/insets/InsetFlex.h

index d33069f62b3ec635518200af8f5b47372c6dcff8..5353fde278fb73702c3fe0d0fdc595d4cc3e9166 100644 (file)
@@ -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);
 }
 
 
index db1844a76849f454ae8ff46da976130241ddd662..31e3daf33cd84b9251787dafe8b39d33e344e595 100644 (file)
@@ -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
index 5a41ca8977d5c1d13507edf9ab568f4125200aff..8610516002b679a87bf2a7af46715565e97c8754 100644 (file)
@@ -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:
index 5931bb4eba2584fdabe7b2a4b3b944257a25eff4..c2dbe8a2bc85c9e3bb4e2080e3d6c817e5b174fe 100644 (file)
 
 #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 <ostream>
 
+//#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
index 4b70aba2aa3a464ef82c0e57d51e22cc5230a254..58ce0521946c9350a2f83d2d7e8ad04fad9ffe14 100644 (file)
@@ -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; }