fix bug 913 (toc crash)

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6233 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
John Levon 2003-02-22 20:05:13 +00:00
parent 662eb0b82a
commit f413754ef5
6 changed files with 22 additions and 14 deletions

View File

@ -1,3 +1,9 @@
2003-02-22 John Levon <levon@movementarian.org>
* toc.h:
* toc.C: make TocItem store an id not a Paragraph *
(bug #913)
2003-02-21 Angus Leeming <leeming@lyx.org>
* BufferView_pimpl.C (MenuInsertLyXFile):

View File

@ -1,3 +1,8 @@
2003-02-22 John Levon <levon@movementarian.org>
* insetfloat.C:
* insetwrap.C: TocItem changed API (bug 913)
2003-02-21 Angus Leeming <leeming@lyx.org>
* updatableinset.h (setView, view): remove.

View File

@ -349,7 +349,7 @@ void InsetFloat::addToToc(toc::TocList & toclist, Buffer const * buf) const
string const str =
tostr(toclist[name].size() + 1)
+ ". " + tmp->asString(buf, false);
toc::TocItem const item(tmp, 0 , str);
toc::TocItem const item(tmp->id(), 0 , str);
toclist[name].push_back(item);
}
}

View File

@ -261,7 +261,7 @@ void InsetWrap::addToToc(toc::TocList & toclist, Buffer const * buf) const
string const str =
tostr(toclist[name].size() + 1)
+ ". " + tmp->asString(buf, false);
toc::TocItem const item(tmp, 0 , str);
toc::TocItem const item(tmp->id(), 0 , str);
toclist[name].push_back(item);
}
tmp = tmp->next();

View File

@ -42,7 +42,7 @@ string const TocItem::asString() const
void TocItem::goTo(LyXView & lv_) const
{
string const tmp = tostr(par->id());
string const tmp = tostr(id_);
lv_.dispatch(FuncRequest(LFUN_GOTO_PARAGRAPH, tmp));
}
@ -50,7 +50,7 @@ void TocItem::goTo(LyXView & lv_) const
int TocItem::action() const
{
return lyxaction.getPseudoAction(LFUN_GOTO_PARAGRAPH,
tostr(par->id()));
tostr(id_));
}
@ -86,7 +86,7 @@ TocList const getTocList(Buffer const * buf)
&& labeltype <= LABEL_COUNTER_CHAPTER + buf->params.tocdepth) {
// insert this into the table of contents
const int depth = max(0, labeltype - textclass.maxcounter());
TocItem const item(par, depth,
TocItem const item(par->id(), depth,
par->asString(buf, true));
toclist["TOC"].push_back(item);
}

View File

@ -35,17 +35,17 @@ namespace toc
///
struct TocItem {
TocItem(Paragraph const * p, int d, string const & s)
: par(p), depth(d), str(s) {}
TocItem(int par_id, int d, string const & s)
: id_(par_id), depth(d), str(s) {}
///
string const asString() const;
/// set cursor in LyXView to this TocItem
void goTo(LyXView & lv_) const;
/// the action corresponding to the goTo above
int action() const;
///
Paragraph const * par;
///
/// Paragraph ID containing this item
int id_;
/// nesting depth
int depth;
///
string str;
@ -69,21 +69,18 @@ void asciiTocList(string const &, Buffer const *, std::ostream &);
by ControlToc::getContents() */
string const getType(string const & cmdName);
///
inline
bool operator==(TocItem const & a, TocItem const & b)
{
return a.par == b.par && a.str == b.str;
return a.id_ == b.id_ && a.str == b.str;
// No need to compare depth.
}
///
inline
bool operator!=(TocItem const & a, TocItem const & b)
{
return !(a == b);
// No need to compare depth.
}