]> git.lyx.org Git - features.git/commitdiff
move InsetCollapsable::docbook to InsetText; move InsetCollapsable::undefined to...
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Tue, 14 Jul 2009 20:25:25 +0000 (20:25 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Tue, 14 Jul 2009 20:25:25 +0000 (20:25 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30589 a592a061-630c-0410-9148-cb99ea01b6c8

src/CutAndPaste.cpp
src/insets/Inset.cpp
src/insets/Inset.h
src/insets/InsetCollapsable.cpp
src/insets/InsetCollapsable.h
src/insets/InsetText.cpp

index f92d74dca222c95c6352030a787097a05780e5f6..0e81a04b625c13557fe23d06ef52a33ac6264dfd 100644 (file)
@@ -576,20 +576,17 @@ void switchBetweenClasses(DocumentClass const * const oldone,
        // character styles
        InsetIterator const i_end = inset_iterator_end(in);
        for (InsetIterator it = inset_iterator_begin(in); it != i_end; ++it) {
-               InsetCollapsable * inset = it->asInsetCollapsable();
-               if (!inset)
-                       continue;
-               if (inset->lyxCode() != FLEX_CODE)
+               if (it->lyxCode() != FLEX_CODE)
                        // FIXME: Should we verify all InsetCollapsable?
                        continue;
-               if (!inset->undefined())
+               if (!it->undefined())
                        continue;
                // The flex inset is undefined in newtc
                docstring const s = bformat(_(
                        "Flex inset %1$s is "
                        "undefined because of class "
                        "conversion from\n%2$s to %3$s"),
-                       inset->name(), from_utf8(oldtc.name()),
+                       it->name(), from_utf8(oldtc.name()),
                        from_utf8(newtc.name()));
                // To warn the user that something had to be done.
                errorlist.push_back(ErrorItem(
index 9afae918a616956b44f6ec1e76abb63800c1118f..aa060081efc43a2cbe7e5aaed85f9c99af149459 100644 (file)
@@ -465,6 +465,13 @@ InsetLayout const & Inset::getLayout() const
 }
 
 
+bool Inset::undefined() const
+{
+       docstring const & n = getLayout().name();
+       return n.empty() || n == DocumentClass::plainInsetLayout().name();
+}
+
+
 void Inset::dump() const
 {
        write(lyxerr);
index ddbb5ac3f0bb9ebebce460515e9470b145194098..11de094dedf61b98dd6c2bf7e40ed1809e73a93d 100644 (file)
@@ -383,6 +383,8 @@ public:
        virtual docstring name() const;
        ///
        virtual InsetLayout const & getLayout() const;
+       /// Is this inset's layout defined in the document's textclass?
+       bool undefined() const;
        /// used to toggle insets
        /// is the inset open?
        /// should this inset be handled like a normal charater
index 5a253c8d9d1553c3ef32ea92ed5d1195f4ea5299..42f2af592d546f32bf37d8853e9a4fa13dd937cb 100644 (file)
@@ -616,31 +616,6 @@ InsetLayout::InsetDecoration InsetCollapsable::decoration() const
 }
 
 
-// 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;
-}
-
-
 docstring InsetCollapsable::xhtml(odocstream & os, OutputParams const & runparams) const
 {
        InsetLayout const & il = getLayout();
@@ -668,13 +643,6 @@ docstring InsetCollapsable::xhtml(odocstream & os, OutputParams const & runparam
 }
 
 
-bool InsetCollapsable::undefined() const
-{
-       docstring const & n = getLayout().name();
-       return n.empty() || n == DocumentClass::plainInsetLayout().name();
-}
-
-
 docstring InsetCollapsable::contextMenu(BufferView const & bv, int x,
        int y) const
 {
index 18fca146e46a1cc3ef28c3b55095bcbaac36d5e0..f7ed19e6b9dd84a78bb50cd70dda8c91fd42fb03 100644 (file)
@@ -125,8 +125,6 @@ public:
        ColorCode backgroundColor() const { return getLayout().bgcolor(); }
        ///
        ColorCode labelColor() const { return getLayout().labelfont().color(); }
-       ///
-       int docbook(odocstream &, OutputParams const &) const;
        /// It will rarely be right to call this from subclasses, due
        /// to the fact that it steps counters, etc. Instead, call
        /// InsetText::xhtml().
@@ -136,9 +134,6 @@ public:
 
        ///
        virtual bool usePlainLayout() const { return true; }
-       /// 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;
        ///
index ed386caa18b79634359da811c799c84a846f849f..a2f75424fcd0d9fca83af8e92ed60526b41d459e 100644 (file)
@@ -445,7 +445,17 @@ int InsetText::plaintext(odocstream & os, OutputParams const & runparams) const
 
 int InsetText::docbook(odocstream & os, OutputParams const & runparams) const
 {
+       ParagraphList::const_iterator const beg = paragraphs().begin();
+
+       if (!undefined())
+               sgml::openTag(os, getLayout().latexname(),
+                             beg->getID(buffer(), runparams) + getLayout().latexparam());
+
        docbookParagraphs(paragraphs(), buffer(), os, runparams);
+
+       if (!undefined())
+               sgml::closeTag(os, getLayout().latexname());
+
        return 0;
 }