Move some stuff from InsetFlex to InsetCollapsable, and make use of the

InToc tag in a couple places.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@28378 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Richard Heck 2009-02-06 17:56:47 +00:00
parent 5ee35ace6f
commit a864caf6f4
5 changed files with 41 additions and 43 deletions

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

View 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

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

View File

@ -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 <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

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