Full text in toc for index entries.

* Text::asString(): new method.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@26601 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2008-09-28 17:10:16 +00:00
parent 7c8851a45b
commit 45cd1149e4
6 changed files with 43 additions and 7 deletions

View File

@ -1489,6 +1489,25 @@ docstring Text::getPossibleLabel(Cursor const & cur) const
} }
docstring Text::asString(int options) const
{
return asString(0, pars_.size(), options);
}
docstring Text::asString(pit_type beg, pit_type end, int options) const
{
size_t i = size_t(beg);
docstring str = pars_[i].asString(options);
for (++i; i != size_t(end); ++i) {
str += '\n';
str += pars_[i].asString(options);
}
return str;
}
void Text::charsTranspose(Cursor & cur) void Text::charsTranspose(Cursor & cur)
{ {
LASSERT(this == cur.text(), /**/); LASSERT(this == cur.text(), /**/);

View File

@ -108,6 +108,17 @@ public:
/// FIXME: replace Cursor with DocIterator. /// FIXME: replace Cursor with DocIterator.
docstring getStringToIndex(Cursor const & cur); docstring getStringToIndex(Cursor const & cur);
/// Convert the paragraphs to a string.
/// \param AsStringParameter options. This can contain any combination of
/// asStringParameter values. Valid examples:
/// asString(AS_STR_LABEL)
/// asString(AS_STR_LABEL | AS_STR_INSETS)
/// asString(AS_STR_INSETS)
docstring asString(int options = AS_STR_NONE) const;
///
docstring asString(pit_type beg, pit_type end,
int options = AS_STR_NONE) const;
/// insert a character at cursor position /// insert a character at cursor position
/// FIXME: replace Cursor with DocIterator. /// FIXME: replace Cursor with DocIterator.
void insertChar(Cursor & cur, char_type c); void insertChar(Cursor & cur, char_type c);

View File

@ -230,7 +230,7 @@ int InsetBranch::docbook(odocstream & os,
void InsetBranch::textString(odocstream & os) const void InsetBranch::textString(odocstream & os) const
{ {
if (isBranchSelected()) if (isBranchSelected())
os << paragraphs().begin()->asString(AS_STR_LABEL | AS_STR_INSETS); os << text().asString(0, 1, AS_STR_LABEL | AS_STR_INSETS);
} }

View File

@ -109,7 +109,7 @@ int InsetFlex::docbook(odocstream & os, OutputParams const & runparams) const
void InsetFlex::textString(odocstream & os) const void InsetFlex::textString(odocstream & os) const
{ {
os << paragraphs().begin()->asString(AS_STR_LABEL | AS_STR_INSETS); os << text().asString(0, 1, AS_STR_LABEL | AS_STR_INSETS);
} }

View File

@ -171,15 +171,19 @@ void InsetIndex::write(ostream & os) const
} }
void InsetIndex::textString(odocstream & os) const
{
os << text().asString(0, 1, AS_STR_LABEL | AS_STR_INSETS);
}
void InsetIndex::addToToc(DocIterator const & cpit) void InsetIndex::addToToc(DocIterator const & cpit)
{ {
DocIterator pit = cpit; DocIterator pit = cpit;
pit.push_back(CursorSlice(*this)); pit.push_back(CursorSlice(*this));
odocstringstream ods;
Toc & toc = buffer().tocBackend().toc("index"); textString(ods);
docstring str; buffer().tocBackend().toc("index").push_back(TocItem(pit, 0, ods.str()));
str = getNewLabel(str);
toc.push_back(TocItem(pit, 0, str));
// Proceed with the rest of the inset. // Proceed with the rest of the inset.
InsetCollapsable::addToToc(cpit); InsetCollapsable::addToToc(cpit);
} }

View File

@ -41,6 +41,8 @@ private:
/// should paragraph indendation be omitted in any case? /// should paragraph indendation be omitted in any case?
bool neverIndent() const { return true; } bool neverIndent() const { return true; }
/// ///
void textString(odocstream &) const;
///
void addToToc(DocIterator const &); void addToToc(DocIterator const &);
/// ///
Inset * clone() const { return new InsetIndex(*this); } Inset * clone() const { return new InsetIndex(*this); }