From 435a1f67b498dfd3bf2aaed293efc6a7aa1e4dd0 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Tue, 14 Jul 2009 20:25:25 +0000 Subject: [PATCH] move InsetCollapsable::docbook to InsetText; move InsetCollapsable::undefined to Inset git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30589 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/CutAndPaste.cpp | 9 +++------ src/insets/Inset.cpp | 7 +++++++ src/insets/Inset.h | 2 ++ src/insets/InsetCollapsable.cpp | 32 -------------------------------- src/insets/InsetCollapsable.h | 5 ----- src/insets/InsetText.cpp | 10 ++++++++++ 6 files changed, 22 insertions(+), 43 deletions(-) diff --git a/src/CutAndPaste.cpp b/src/CutAndPaste.cpp index f92d74dca2..0e81a04b62 100644 --- a/src/CutAndPaste.cpp +++ b/src/CutAndPaste.cpp @@ -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( diff --git a/src/insets/Inset.cpp b/src/insets/Inset.cpp index 9afae918a6..aa060081ef 100644 --- a/src/insets/Inset.cpp +++ b/src/insets/Inset.cpp @@ -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); diff --git a/src/insets/Inset.h b/src/insets/Inset.h index ddbb5ac3f0..11de094ded 100644 --- a/src/insets/Inset.h +++ b/src/insets/Inset.h @@ -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 diff --git a/src/insets/InsetCollapsable.cpp b/src/insets/InsetCollapsable.cpp index 5a253c8d9d..42f2af592d 100644 --- a/src/insets/InsetCollapsable.cpp +++ b/src/insets/InsetCollapsable.cpp @@ -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 { diff --git a/src/insets/InsetCollapsable.h b/src/insets/InsetCollapsable.h index 18fca146e4..f7ed19e6b9 100644 --- a/src/insets/InsetCollapsable.h +++ b/src/insets/InsetCollapsable.h @@ -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; /// diff --git a/src/insets/InsetText.cpp b/src/insets/InsetText.cpp index ed386caa18..a2f75424fc 100644 --- a/src/insets/InsetText.cpp +++ b/src/insets/InsetText.cpp @@ -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; } -- 2.39.2