* Inset: Prepare for an eventual merge of updateLabels() and addToToc()

* TocBackend: add non const toc() and tocs() access methods.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23018 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2008-02-15 10:13:32 +00:00
parent 5b7eb343ec
commit c3a8b3a566
17 changed files with 34 additions and 24 deletions

View File

@ -92,6 +92,12 @@ Toc const & TocBackend::toc(string const & type) const
}
Toc & TocBackend::toc(string const & type)
{
return tocs_[type];
}
void TocBackend::updateItem(ParConstIterator const & par_it)
{
if (toc("tableofcontents").empty()) {
@ -157,7 +163,7 @@ void TocBackend::update()
InsetList::const_iterator end = pit->insetList().end();
for (; it != end; ++it) {
Inset & inset = *it->inset;
inset.addToToc(tocs_, *buffer_, pit);
inset.addToToc(*buffer_, pit);
switch (inset.lyxCode()) {
case OPTARG_CODE: {
if (!tocstring.empty())

View File

@ -95,11 +95,13 @@ public:
///
TocList const & tocs() const { return tocs_; }
TocList & tocs() { return tocs_; }
///
Toc const & toc(std::string const & type) const;
/// Return the first Toc Item before the cursor
Toc & toc(std::string const & type);
/// Return the first Toc Item before the cursor
TocIterator item(
std::string const & type, ///< Type of Toc.
ParConstIterator const & ///< The cursor location in the document.

View File

@ -369,7 +369,7 @@ public:
virtual void addPreview(graphics::PreviewLoader &) const {}
/// Add an entry to the TocList
/// pit is the ParConstIterator of the paragraph containing the inset
virtual void addToToc(TocList &, Buffer const &, ParConstIterator const &) const {}
virtual void addToToc(Buffer const &, ParConstIterator const &) const {}
/// report files that can be embedded with the lyx file
virtual void registerEmbeddedFiles(Buffer const &, EmbeddedFileList &) const {}
/// use embedded or external file after the embedding status of a file is changed

View File

@ -115,7 +115,7 @@ void InsetCaption::setCustomLabel(docstring const & label)
}
void InsetCaption::addToToc(TocList & toclist, Buffer const & buf,
void InsetCaption::addToToc(Buffer const & buf,
ParConstIterator const & cpit) const
{
if (type_.empty())
@ -124,7 +124,7 @@ void InsetCaption::addToToc(TocList & toclist, Buffer const & buf,
ParConstIterator pit = cpit;
pit.push_back(*this);
Toc & toc = toclist[type_];
Toc & toc = buf.tocBackend().toc(type_);
docstring const str = full_label_ + ". " + pit->asString(buf, false);
toc.push_back(TocItem(pit, 0, str));
}

View File

@ -78,7 +78,7 @@ public:
///
void setCustomLabel(docstring const & label);
///
void addToToc(TocList &, Buffer const &, ParConstIterator const &) const;
void addToToc(Buffer const &, ParConstIterator const &) const;
///
virtual bool forceEmptyLayout() const { return true; }
/// Captions don't accept alignment, spacing, etc.

View File

@ -75,13 +75,13 @@ void InsetFoot::updateLabels(Buffer const & buf, ParIterator const & it)
}
void InsetFoot::addToToc(TocList & toclist, Buffer const & buf,
void InsetFoot::addToToc(Buffer const & buf,
ParConstIterator const & cpit) const
{
ParConstIterator pit = cpit;
pit.push_back(*this);
Toc & toc = toclist["footnote"];
Toc & toc = buf.tocBackend().toc("footnote");
// FIXME: we probably want the footnote number too.
docstring str;
str = getNewLabel(str);

View File

@ -43,7 +43,7 @@ public:
/// Update the counters of this inset and of its contents
void updateLabels(Buffer const &, ParIterator const &);
///
void addToToc(TocList &, Buffer const &, ParConstIterator const &) const;
void addToToc(Buffer const &, ParConstIterator const &) const;
protected:
InsetFoot(InsetFoot const &);

View File

@ -853,7 +853,7 @@ void InsetInclude::addPreview(graphics::PreviewLoader & ploader) const
}
void InsetInclude::addToToc(TocList & toclist, Buffer const & buffer,
void InsetInclude::addToToc(Buffer const & buffer,
ParConstIterator const & cpit) const
{
if (isListings(params())) {
@ -861,7 +861,7 @@ void InsetInclude::addToToc(TocList & toclist, Buffer const & buffer,
string caption = p.getParamValue("caption");
if (caption.empty())
return;
Toc & toc = toclist["listing"];
Toc & toc = buffer.tocBackend().toc("listing");
docstring const str = convert<docstring>(toc.size() + 1)
+ ". " + from_utf8(caption);
ParConstIterator pit = cpit;
@ -873,6 +873,7 @@ void InsetInclude::addToToc(TocList & toclist, Buffer const & buffer,
if (!childbuffer)
return;
TocList & toclist = buffer.tocBackend().tocs();
TocList const & childtoclist = childbuffer->tocBackend().tocs();
TocList::const_iterator it = childtoclist.begin();
TocList::const_iterator const end = childtoclist.end();

View File

@ -88,7 +88,7 @@ public:
///
void addPreview(graphics::PreviewLoader &) const;
///
void addToToc(TocList &, Buffer const &, ParConstIterator const &) const;
void addToToc(Buffer const &, ParConstIterator const &) const;
///
void updateLabels(Buffer const & buffer, ParIterator const &);
/// child document can be embedded

View File

@ -11,6 +11,7 @@
#include "InsetIndex.h"
#include "Buffer.h"
#include "DispatchResult.h"
#include "FuncRequest.h"
#include "FuncStatus.h"
@ -61,13 +62,13 @@ void InsetIndex::write(Buffer const & buf, ostream & os) const
}
void InsetIndex::addToToc(TocList & toclist, Buffer const & buf,
void InsetIndex::addToToc(Buffer const & buf,
ParConstIterator const & cpit) const
{
ParConstIterator pit = cpit;
pit.push_back(*this);
Toc & toc = toclist["index"];
Toc & toc = buf.tocBackend().toc("index");
docstring str;
str = getNewLabel(str);
toc.push_back(TocItem(pit, 0, str));

View File

@ -43,7 +43,7 @@ public:
/// should paragraph indendation be omitted in any case?
bool neverIndent(Buffer const &) const { return true; }
///
void addToToc(TocList &, Buffer const &, ParConstIterator const &) const;
void addToToc(Buffer const &, ParConstIterator const &) const;
private:
///
virtual Inset * clone() const;

View File

@ -79,13 +79,13 @@ int InsetMarginal::docbook(Buffer const & buf, odocstream & os,
}
void InsetMarginal::addToToc(TocList & toclist, Buffer const &/* buf*/,
void InsetMarginal::addToToc(Buffer const & buf,
ParConstIterator const & cpit) const
{
ParConstIterator pit = cpit;
pit.push_back(*this);
Toc & toc = toclist["marginalnote"];
Toc & toc = buf.tocBackend().toc("marginalnote");
docstring str;
str = getNewLabel(str);
toc.push_back(TocItem(pit, 0, str));

View File

@ -42,7 +42,7 @@ public:
///
virtual docstring const editMessage() const;
///
void addToToc(TocList &, Buffer const &, ParConstIterator const &) const;
void addToToc(Buffer const &, ParConstIterator const &) const;
protected:
InsetMarginal(InsetMarginal const &);
private:

View File

@ -220,13 +220,13 @@ void InsetNote::updateLabels(Buffer const & buf, ParIterator const & it)
}
void InsetNote::addToToc(TocList & toclist, Buffer const & /*buf*/,
void InsetNote::addToToc(Buffer const & buf,
ParConstIterator const & cpit) const
{
ParConstIterator pit = cpit;
pit.push_back(*this);
Toc & toc = toclist["note"];
Toc & toc = buf.tocBackend().toc("note");
docstring str;
str = notetranslator_loc().find(params_.type) + from_ascii(": ")
+ getNewLabel(str);

View File

@ -78,7 +78,7 @@ public:
// Update the counters of this inset and of its contents
virtual void updateLabels(Buffer const &, ParIterator const &);
///
void addToToc(TocList &, Buffer const &, ParConstIterator const &) const;
void addToToc(Buffer const &, ParConstIterator const &) const;
protected:
InsetNote(InsetNote const &);
///

View File

@ -194,7 +194,7 @@ InsetMathHull & InsetMathHull::operator=(InsetMathHull const & other)
}
void InsetMathHull::addToToc(TocList & toclist, Buffer const & buf,
void InsetMathHull::addToToc(Buffer const & buf,
ParConstIterator const & pit) const
{
vector<docstring> labels;
@ -202,7 +202,7 @@ void InsetMathHull::addToToc(TocList & toclist, Buffer const & buf,
if (labels.empty())
return;
Toc & toc = toclist["equation"];
Toc & toc = buf.tocBackend().toc("equation");
toc.push_back(TocItem(pit, 0, labels[0]));
}

View File

@ -33,7 +33,7 @@ public:
///
~InsetMathHull();
///
void addToToc(TocList &, Buffer const &, ParConstIterator const &) const;
void addToToc(Buffer const &, ParConstIterator const &) const;
///
InsetMathHull & operator=(InsetMathHull const &);
///