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
This commit is contained in:
Jean-Marc Lasgouttes 2009-07-14 20:25:25 +00:00
parent 56aca11ce9
commit 435a1f67b4
6 changed files with 22 additions and 43 deletions

View 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(

View 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);

View 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

View 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
{

View 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;
///

View 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;
}