Inset::addToToc() can and should be const. It wasn't, I take it, because

of things like:
  pit.push_back(CursorSlice(*this));
which I've had to change to:
  pit.push_back(CursorSlice(const_cast<InsetCaption &>(*this)));
and similarly in a few other places.

If anyone thinks we should instead have:
  explicit CursorSlice(Inset const &);
then we can also do that.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37192 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Richard Heck 2011-01-12 22:23:27 +00:00
parent 7c83f74f26
commit 4b1777d2fa
29 changed files with 40 additions and 39 deletions

View File

@ -492,8 +492,9 @@ public:
virtual void initUnicodeMath() const {}
/// Add an entry to the TocList
/// pit is the ParConstIterator of the paragraph containing the inset
virtual void addToToc(DocIterator const &) {}
/// Pass a DocIterator that points at the paragraph containing
/// the inset
virtual void addToToc(DocIterator const &) const {}
/// Collect BibTeX information
virtual void collectBibKeys(InsetIterator const &) const {}
/// Update the counters of this inset and of its contents.

View File

@ -294,10 +294,10 @@ void InsetBranch::string2params(string const & in, InsetBranchParams & params)
}
void InsetBranch::addToToc(DocIterator const & cpit)
void InsetBranch::addToToc(DocIterator const & cpit) const
{
DocIterator pit = cpit;
pit.push_back(CursorSlice(*this));
pit.push_back(CursorSlice(const_cast<InsetBranch &>(*this)));
Toc & toc = buffer().tocBackend().toc("branch");
docstring str = params_.branch + ": ";

View File

@ -81,7 +81,7 @@ private:
///
docstring contextMenuName() const;
///
void addToToc(DocIterator const &);
void addToToc(DocIterator const &) const;
///
InsetBranchParams const & params() const { return params_; }
///

View File

@ -104,13 +104,13 @@ void InsetCaption::setCustomLabel(docstring const & label)
}
void InsetCaption::addToToc(DocIterator const & cpit)
void InsetCaption::addToToc(DocIterator const & cpit) const
{
if (type_.empty())
return;
DocIterator pit = cpit;
pit.push_back(CursorSlice(*this));
pit.push_back(CursorSlice(const_cast<InsetCaption &>(*this)));
Toc & toc = buffer().tocBackend().toc(type_);
docstring str = full_label_ + ". ";

View File

@ -77,7 +77,7 @@ private:
///
void setCustomLabel(docstring const & label);
///
void addToToc(DocIterator const &);
void addToToc(DocIterator const &) const;
///
virtual bool forcePlainLayout(idx_type = 0) const { return true; }
/// Captions don't accept alignment, spacing, etc.

View File

@ -481,7 +481,7 @@ void InsetCitation::updateBuffer(ParIterator const &, UpdateType)
}
void InsetCitation::addToToc(DocIterator const & cpit)
void InsetCitation::addToToc(DocIterator const & cpit) const
{
// NOTE
// XHTML output uses the TOC to collect the citations

View File

@ -59,7 +59,7 @@ public:
///
void updateBuffer(ParIterator const & it, UpdateType);
///
void addToToc(DocIterator const &);
void addToToc(DocIterator const &) const;
///
docstring contextMenuName() const;
//@}

View File

@ -61,10 +61,10 @@ void InsetFoot::updateBuffer(ParIterator const & it, UpdateType utype)
}
void InsetFoot::addToToc(DocIterator const & cpit)
void InsetFoot::addToToc(DocIterator const & cpit) const
{
DocIterator pit = cpit;
pit.push_back(CursorSlice(*this));
pit.push_back(CursorSlice(const_cast<InsetFoot &>(*this)));
Toc & toc = buffer().tocBackend().toc("footnote");
docstring str = custom_label_ + ": ";

View File

@ -40,7 +40,7 @@ private:
/// Update the counters of this inset and of its contents
void updateBuffer(ParIterator const &, UpdateType);
///
void addToToc(DocIterator const &);
void addToToc(DocIterator const &) const;
///
docstring toolTip(BufferView const & bv, int x, int y) const;
///

View File

@ -1031,7 +1031,7 @@ void InsetGraphics::editGraphics(InsetGraphicsParams const & p) const
}
void InsetGraphics::addToToc(DocIterator const & cpit)
void InsetGraphics::addToToc(DocIterator const & cpit) const
{
TocBackend & backend = buffer().tocBackend();

View File

@ -96,7 +96,7 @@ private:
///
bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
///
void addToToc(DocIterator const &);
void addToToc(DocIterator const &) const;
///
docstring contextMenuName() const;
/// Force inset into LTR environment if surroundings are RTL

View File

@ -998,7 +998,7 @@ void InsetInclude::addPreview(DocIterator const & /*inset_pos*/,
}
void InsetInclude::addToToc(DocIterator const & cpit)
void InsetInclude::addToToc(DocIterator const & cpit) const
{
TocBackend & backend = buffer().tocBackend();

View File

@ -99,7 +99,7 @@ public:
///
void addPreview(DocIterator const &, graphics::PreviewLoader &) const;
///
void addToToc(DocIterator const &);
void addToToc(DocIterator const &) const;
///
void updateBuffer(ParIterator const &, UpdateType);
///

View File

@ -356,10 +356,10 @@ void InsetIndex::string2params(string const & in, InsetIndexParams & params)
}
void InsetIndex::addToToc(DocIterator const & cpit)
void InsetIndex::addToToc(DocIterator const & cpit) const
{
DocIterator pit = cpit;
pit.push_back(CursorSlice(*this));
pit.push_back(CursorSlice(const_cast<InsetIndex &>(*this)));
docstring str;
text().forToc(str, TOC_ENTRY_LENGTH);
buffer().tocBackend().toc("index").push_back(TocItem(pit, 0, str));

View File

@ -71,7 +71,7 @@ private:
/// should paragraph indendation be omitted in any case?
bool neverIndent() const { return true; }
///
void addToToc(DocIterator const &);
void addToToc(DocIterator const &) const;
///
docstring toolTip(BufferView const & bv, int x, int y) const;
///

View File

@ -142,7 +142,7 @@ void InsetLabel::updateBuffer(ParIterator const & par, UpdateType utype)
}
void InsetLabel::addToToc(DocIterator const & cpit)
void InsetLabel::addToToc(DocIterator const & cpit) const
{
docstring const & label = getParam("name");
Toc & toc = buffer().tocBackend().toc("label");

View File

@ -53,7 +53,7 @@ public:
///
void updateBuffer(ParIterator const & it, UpdateType);
///
void addToToc(DocIterator const &);
void addToToc(DocIterator const &) const;
//@}
/// \name Static public methods obligated for InsetCommand derived classes

View File

@ -51,10 +51,10 @@ int InsetMarginal::docbook(odocstream & os,
}
void InsetMarginal::addToToc(DocIterator const & cpit)
void InsetMarginal::addToToc(DocIterator const & cpit) const
{
DocIterator pit = cpit;
pit.push_back(CursorSlice(*this));
pit.push_back(CursorSlice(const_cast<InsetMarginal &>(*this)));
Toc & toc = buffer().tocBackend().toc("marginalnote");
docstring str;

View File

@ -35,7 +35,7 @@ public:
///
int docbook(odocstream &, OutputParams const & runparams) const;
///
void addToToc(DocIterator const &);
void addToToc(DocIterator const &) const;
private:
///
Inset * clone() const { return new InsetMarginal(*this); }

View File

@ -195,10 +195,10 @@ bool InsetNote::getStatus(Cursor & cur, FuncRequest const & cmd,
}
void InsetNote::addToToc(DocIterator const & cpit)
void InsetNote::addToToc(DocIterator const & cpit) const
{
DocIterator pit = cpit;
pit.push_back(CursorSlice(*this));
pit.push_back(CursorSlice(const_cast<InsetNote &>(*this)));
Toc & toc = buffer().tocBackend().toc("note");
InsetLayout const & il = getLayout();

View File

@ -91,7 +91,7 @@ private:
///
bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
///
void addToToc(DocIterator const &);
void addToToc(DocIterator const &) const;
///
void doDispatch(Cursor & cur, FuncRequest & cmd);
///

View File

@ -280,7 +280,7 @@ void InsetRef::updateBuffer(ParIterator const & it, UpdateType)
}
void InsetRef::addToToc(DocIterator const & cpit)
void InsetRef::addToToc(DocIterator const & cpit) const
{
docstring const & label = getParam("reference");
if (buffer().insetLabel(label))

View File

@ -67,7 +67,7 @@ public:
///
void updateBuffer(ParIterator const & it, UpdateType);
///
void addToToc(DocIterator const &);
void addToToc(DocIterator const &) const;
///
bool forceLTR() const { return true; }
//@}

View File

@ -3736,7 +3736,7 @@ void InsetTabular::updateBuffer(ParIterator const & it, UpdateType utype)
}
void InsetTabular::addToToc(DocIterator const & cpit)
void InsetTabular::addToToc(DocIterator const & cpit) const
{
DocIterator dit = cpit;
dit.forwardPos();

View File

@ -863,7 +863,7 @@ public:
/// Update the counters of this inset and of its contents
void updateBuffer(ParIterator const &, UpdateType);
///
void addToToc(DocIterator const &);
void addToToc(DocIterator const &) const;
///
bool completionSupported(Cursor const &) const;

View File

@ -682,10 +682,10 @@ void InsetText::forToc(docstring & os, size_t maxlen) const
}
void InsetText::addToToc(DocIterator const & cdit)
void InsetText::addToToc(DocIterator const & cdit) const
{
DocIterator dit = cdit;
dit.push_back(CursorSlice(*this));
dit.push_back(CursorSlice(const_cast<InsetText &>(*this)));
Toc & toc = buffer().tocBackend().toc("tableofcontents");
BufferParams const & bufparams = buffer_->params();
@ -693,13 +693,13 @@ void InsetText::addToToc(DocIterator const & cdit)
// For each paragraph, traverse its insets and let them add
// their toc items
ParagraphList & pars = paragraphs();
ParagraphList const & pars = paragraphs();
pit_type pend = paragraphs().size();
for (pit_type pit = 0; pit != pend; ++pit) {
Paragraph const & par = pars[pit];
dit.pit() = pit;
// if we find an optarg, we'll save it for use later.
InsetText * arginset = 0;
InsetText const * arginset = 0;
InsetList::const_iterator it = par.insetList().begin();
InsetList::const_iterator end = par.insetList().end();
for (; it != end; ++it) {

View File

@ -168,7 +168,7 @@ public:
///
void forToc(docstring &, size_t) const;
///
void addToToc(DocIterator const &);
void addToToc(DocIterator const &) const;
///
Inset * clone() const { return new InsetText(*this); }
///

View File

@ -281,7 +281,7 @@ void InsetMathHull::updateBuffer(ParIterator const & it, UpdateType utype)
}
void InsetMathHull::addToToc(DocIterator const & pit)
void InsetMathHull::addToToc(DocIterator const & pit) const
{
if (!buffer_) {
//FIXME: buffer_ should be set at creation for this inset! Problem is

View File

@ -42,7 +42,7 @@ public:
///
void updateBuffer(ParIterator const &, UpdateType);
///
void addToToc(DocIterator const &);
void addToToc(DocIterator const &) const;
///
InsetMathHull & operator=(InsetMathHull const &);
///