Only the first paragraph in those sequences goes into the TOC, since the environment is merged.
This is needed to handle the forthcoming beamer environments properly in the outliner.
+int Text::getTocLevel(pit_type par_offset) const
+{
+ Paragraph const & par = pars_[par_offset];
+
+ if (par.layout().isEnvironment() && !isFirstInSequence(par_offset))
+ return Layout::NOT_IN_TOC;
+
+ return par.layout().toclevel;
+}
+
+
Font const Text::outerFont(pit_type par_offset) const
{
depth_type par_depth = pars_[par_offset].getDepth();
Font const Text::outerFont(pit_type par_offset) const
{
depth_type par_depth = pars_[par_offset].getDepth();
pit_type outerHook(pit_type par) const;
/// Is it the first par with same depth and layout?
bool isFirstInSequence(pit_type par) const;
pit_type outerHook(pit_type par) const;
/// Is it the first par with same depth and layout?
bool isFirstInSequence(pit_type par) const;
+ /// Is this paragraph in the table of contents?
+ int getTocLevel(pit_type par) const;
/// Get the font of the "environment" of paragraph \p par_offset in \p pars.
/// All font changes of the paragraph are relative to this font.
Font const outerFont(pit_type par_offset) const;
/// Get the font of the "environment" of paragraph \p par_offset in \p pars.
/// All font changes of the paragraph are relative to this font.
Font const outerFont(pit_type par_offset) const;
DocumentClass const & tc = buf.params().documentClass();
DocumentClass const & tc = buf.params().documentClass();
- int const thistoclevel = start->layout().toclevel;
+ int const thistoclevel = buf.text().getTocLevel(distance(bgn, start));
int toclevel;
// Move out (down) from this section header
int toclevel;
// Move out (down) from this section header
// Seek the one (on same level) below
for (; finish != end; ++finish) {
// Seek the one (on same level) below
for (; finish != end; ++finish) {
- toclevel = finish->layout().toclevel;
+ toclevel = buf.text().getTocLevel(distance(bgn, finish));
if (toclevel != Layout::NOT_IN_TOC && toclevel <= thistoclevel)
break;
}
if (toclevel != Layout::NOT_IN_TOC && toclevel <= thistoclevel)
break;
}
// Search previous same-level header above
do {
--dest;
// Search previous same-level header above
do {
--dest;
- toclevel = dest->layout().toclevel;
+ toclevel = buf.text().getTocLevel(distance(bgn, dest));
} while(dest != bgn
&& (toclevel == Layout::NOT_IN_TOC
|| toclevel > thistoclevel));
} while(dest != bgn
&& (toclevel == Layout::NOT_IN_TOC
|| toclevel > thistoclevel));
ParagraphList::iterator dest = boost::next(finish, 1);
// Go further down to find header to insert in front of:
for (; dest != end; ++dest) {
ParagraphList::iterator dest = boost::next(finish, 1);
// Go further down to find header to insert in front of:
for (; dest != end; ++dest) {
- toclevel = dest->layout().toclevel;
+ toclevel = buf.text().getTocLevel(distance(bgn, dest));
if (toclevel != Layout::NOT_IN_TOC
&& toclevel <= thistoclevel)
break;
if (toclevel != Layout::NOT_IN_TOC
&& toclevel <= thistoclevel)
break;
pit_type const len = distance(start, finish);
buf.undo().recordUndo(cur, ATOMIC_UNDO, pit, pit + len - 1);
for (; start != finish; ++start) {
pit_type const len = distance(start, finish);
buf.undo().recordUndo(cur, ATOMIC_UNDO, pit, pit + len - 1);
for (; start != finish; ++start) {
- toclevel = start->layout().toclevel;
+ toclevel = buf.text().getTocLevel(distance(bgn, start));
if (toclevel == Layout::NOT_IN_TOC)
continue;
DocumentClass::const_iterator lit = tc.begin();
if (toclevel == Layout::NOT_IN_TOC)
continue;
DocumentClass::const_iterator lit = tc.begin();
pit_type const len = distance(start, finish);
buf.undo().recordUndo(cur, ATOMIC_UNDO, pit, pit + len - 1);
for (; start != finish; ++start) {
pit_type const len = distance(start, finish);
buf.undo().recordUndo(cur, ATOMIC_UNDO, pit, pit + len - 1);
for (; start != finish; ++start) {
- toclevel = start->layout().toclevel;
+ toclevel = buf.text().getTocLevel(distance(bgn, start));
if (toclevel == Layout::NOT_IN_TOC)
continue;
DocumentClass::const_iterator lit = tc.begin();
if (toclevel == Layout::NOT_IN_TOC)
continue;
DocumentClass::const_iterator lit = tc.begin();
ParagraphList::iterator finish = start;
ParagraphList::iterator end = pars.end();
ParagraphList::iterator finish = start;
ParagraphList::iterator end = pars.end();
- int const thistoclevel = start->layout().toclevel;
+ int const thistoclevel = buf.text().getTocLevel(distance(bgn, start));
if (thistoclevel == Layout::NOT_IN_TOC)
break;
if (thistoclevel == Layout::NOT_IN_TOC)
break;
// Seek the one (on same level) below
for (; finish != end; ++finish, ++cur.pit()) {
// Seek the one (on same level) below
for (; finish != end; ++finish, ++cur.pit()) {
- int const toclevel = finish->layout().toclevel;
+ int const toclevel = buf.text().getTocLevel(distance(bgn, finish));
if (toclevel != Layout::NOT_IN_TOC && toclevel <= thistoclevel)
break;
}
if (toclevel != Layout::NOT_IN_TOC && toclevel <= thistoclevel)
break;
}
case LFUN_OUTLINE_OUT:
// FIXME: LyX is not ready for outlining within inset.
enable = isMainText()
case LFUN_OUTLINE_OUT:
// FIXME: LyX is not ready for outlining within inset.
enable = isMainText()
- && cur.paragraph().layout().toclevel != Layout::NOT_IN_TOC;
+ && cur.buffer()->text().getTocLevel(cur.pit()) != Layout::NOT_IN_TOC;
break;
case LFUN_NEWLINE_INSERT:
break;
case LFUN_NEWLINE_INSERT:
bool TocBackend::updateItem(DocIterator const & dit)
{
bool TocBackend::updateItem(DocIterator const & dit)
{
- if (dit.paragraph().layout().toclevel == Layout::NOT_IN_TOC)
+ if (dit.text()->getTocLevel(dit.pit()) == Layout::NOT_IN_TOC)
return false;
if (toc("tableofcontents").empty()) {
return false;
if (toc("tableofcontents").empty()) {
- int const toclevel = par.layout().toclevel;
+ int const toclevel = toc_item->dit_.text()->getTocLevel(toc_item->dit_.pit());
if (toclevel != Layout::NOT_IN_TOC && toclevel >= min_toclevel
&& tocstring.empty())
tocstring = par.asString(AS_STR_LABEL | AS_STR_INSETS);
if (toclevel != Layout::NOT_IN_TOC && toclevel >= min_toclevel
&& tocstring.empty())
tocstring = par.asString(AS_STR_LABEL | AS_STR_INSETS);
arginset = inset.asInsetText();
}
// now the toc entry for the paragraph
arginset = inset.asInsetText();
}
// now the toc entry for the paragraph
- int const toclevel = par.layout().toclevel;
+ int const toclevel = text().getTocLevel(pit);
if (toclevel != Layout::NOT_IN_TOC && toclevel >= min_toclevel) {
// insert this into the table of contents
docstring tocstring;
if (toclevel != Layout::NOT_IN_TOC && toclevel >= min_toclevel) {
// insert this into the table of contents
docstring tocstring;