d->bibinfo_cache_valid_ = true;
d->cite_labels_valid_ = true;
/// FIXME: Perf
- cbuf.tocBackend().update(utype == OutputUpdate);
+ cbuf.tocBackend().update(true, utype);
if (scope == UpdateMaster)
cbuf.structureChanged();
}
namespace lyx {
+
///////////////////////////////////////////////////////////////////////////
//
// TocItem implementation
///////////////////////////////////////////////////////////////////////////
TocItem::TocItem(DocIterator const & dit, int d, docstring const & s,
- bool output_active, docstring const & t) :
- dit_(dit), depth_(d), str_(s), tooltip_(t), output_(output_active)
+ bool output_active, docstring const & t, FuncRequest action) :
+ dit_(dit), depth_(d), str_(s), tooltip_(t), output_(output_active),
+ action_(action)
{
}
docstring const TocItem::asString() const
{
- return docstring(4 * depth_, ' ') + str_;
+ // U+2327 X IN A RECTANGLE BOX
+ // char_type const cross = 0x2327;
+ // U+274E NEGATIVE SQUARED CROSS MARK
+ char_type const cross = 0x274e;
+ docstring prefix;
+ if (!output_) {
+ prefix += cross;
+ prefix += " ";
+ }
+ return prefix + str_;
}
+// convert a DocIterator into an argument to LFUN_PARAGRAPH_GOTO
+docstring paragraph_goto_arg(DocIterator const & dit)
+{
+ CursorSlice const & s = dit.innerTextSlice();
+ return convert<docstring>(s.paragraph().id()) + ' ' +
+ convert<docstring>(s.pos());
+}
FuncRequest TocItem::action() const
{
- string const arg = convert<string>(dit_.paragraph().id())
- + ' ' + convert<string>(dit_.pos());
- return FuncRequest(LFUN_PARAGRAPH_GOTO, arg);
+ if (action_.action() == LFUN_UNKNOWN_ACTION) {
+ return FuncRequest(LFUN_PARAGRAPH_GOTO, paragraph_goto_arg(dit_));
+ } else
+ return action_;
}
void TocBuilder::captionItem(DocIterator const & dit, docstring const & s,
bool output_active)
{
+ // first show the float before moving to the caption
+ docstring arg = "paragraph-goto " + paragraph_goto_arg(dit);
+ if (!stack_.empty())
+ arg = "paragraph-goto " +
+ paragraph_goto_arg((*toc_)[stack_.top().pos].dit_) + ";" + arg;
+ FuncRequest func(LFUN_COMMAND_SEQUENCE, arg);
+
if (!stack_.empty() && !stack_.top().is_captioned) {
// The float we entered has not yet been assigned a caption.
// Assign the caption string to it.
- (*toc_)[stack_.top().pos].str(s);
+ TocItem & captionable = (*toc_)[stack_.top().pos];
+ captionable.str(s);
+ captionable.setAction(func);
stack_.top().is_captioned = true;
} else {
// This is a new entry.
pop();
- pushItem(dit, s, output_active, true);
+ // the dit is at the float's level, e.g. for the contextual menu of
+ // outliner entries
+ DocIterator captionable_dit = dit;
+ captionable_dit.pop_back();
+ pushItem(captionable_dit, s, output_active, true);
+ (*toc_)[stack_.top().pos].setAction(func);
}
}
&& tocstring.empty())
tocstring = par.asString(AS_STR_LABEL | AS_STR_INSETS);
- const_cast<TocItem &>(*toc_item).str_ = tocstring;
+ const_cast<TocItem &>(*toc_item).str(tocstring);
buffer_->updateTocItem("tableofcontents", dit);
return true;
}
-void TocBackend::update(bool output_active)
+void TocBackend::update(bool output_active, UpdateType utype)
{
for (TocList::iterator it = tocs_.begin(); it != tocs_.end(); ++it)
it->second->clear();
builders_.clear();
if (!buffer_->isInternal()) {
DocIterator dit;
- buffer_->inset().addToToc(dit, output_active);
+ buffer_->inset().addToToc(dit, output_active, utype);
}
}
#define TOC_BACKEND_H
#include "DocIterator.h"
+#include "FuncRequest.h"
+#include "OutputEnums.h"
#include "support/shared_ptr.h"
#include "support/strfwd.h"
namespace lyx {
class Buffer;
-class FuncRequest;
/* FIXME: toc types are currently identified by strings. It cannot be converted
{
friend class Toc;
friend class TocBackend;
+ friend class TocBuilder;
public:
/// Default constructor for STL containers.
int depth,
docstring const & s,
bool output_active,
- docstring const & t = docstring()
+ docstring const & t = docstring(),
+ FuncRequest action = FuncRequest(LFUN_UNKNOWN_ACTION)
);
///
~TocItem() {}
void str(docstring const & s) { str_ = s; }
///
docstring const & tooltip() const;
- ///
+ /// String for display, e.g. it has a mark if output is inactive
docstring const asString() const;
///
DocIterator const & dit() const { return dit_; }
///
bool isOutput() const { return output_; }
-
- /// the action corresponding to the goTo above
+ ///
+ void setAction(FuncRequest a) { action_ = a; }
+ /// custom action, or the default one (paragraph-goto) if not customised
FuncRequest action() const;
protected:
/// Current position of item.
DocIterator dit_;
+
+private:
/// nesting depth
int depth_;
/// Full item string
docstring tooltip_;
/// Is this item in a note, inactive branch, etc?
bool output_;
+ /// Custom action
+ FuncRequest action_;
};
///
void setBuffer(Buffer const * buffer) { buffer_ = buffer; }
///
- void update(bool output_active);
+ void update(bool output_active, UpdateType utype);
/// \return true if the item was updated.
bool updateItem(DocIterator const & pit);
///
}
-size_t const max_number_of_items = 25;
+size_t const max_number_of_items = 30;
void MenuDefinition::expandToc2(Toc const & toc_list,
size_t from, size_t to, int depth)
if (to - from <= max_number_of_items) {
for (size_t i = from; i < to; ++i) {
QString label(4 * max(0, toc_list[i].depth() - depth), ' ');
- label += limitStringLength(toc_list[i].str());
+ label += limitStringLength(toc_list[i].asString());
if (toc_list[i].depth() == depth) {
label += '|';
if (shortcut_count < 9) {
}
add(MenuItem(MenuItem::Command, label,
FuncRequest(toc_list[i].action())));
+ // separator after the menu heading
+ if (toc_list[i].depth() < depth)
+ add(MenuItem(MenuItem::Separator));
}
} else {
size_t pos = from;
++new_pos;
QString label(4 * max(0, toc_list[pos].depth() - depth), ' ');
- label += limitStringLength(toc_list[pos].str());
+ label += limitStringLength(toc_list[pos].asString());
if (toc_list[pos].depth() == depth) {
label += '|';
if (shortcut_count < 9) {
// all MenuItem constructors and to expandToc2. However, we
// know that all the entries in a TOC will be have status_ ==
// OK, so we avoid this unnecessary overhead (JMarc)
-
if (!buf) {
- add(MenuItem(MenuItem::Info, qt_("<No Document Open>")));
+ add(MenuItem(MenuItem::Info, qt_("(No Document Open)")));
return;
}
-
// Add an entry for the master doc if this is a child doc
Buffer const * const master = buf->masterBuffer();
if (buf != master) {
}
MenuDefinition other_lists;
-
FloatList const & floatlist = buf->params().documentClass().floats();
TocList const & toc_list = buf->tocBackend().tocs();
TocList::const_iterator cit = toc_list.begin();
TocList::const_iterator end = toc_list.end();
for (; cit != end; ++cit) {
- // Handle this later
- if (cit->first == "tableofcontents")
+ // Handle table of contents later
+ if (cit->first == "tableofcontents" || cit->second->empty())
continue;
-
MenuDefinition submenu;
- if (floatlist.typeExist(cit->first)) {
- TocIterator ccit = cit->second->begin();
- TocIterator eend = cit->second->end();
- for (; ccit != eend; ++ccit) {
- if (0 == ccit->depth()) {// omit subfloats
- submenu.add(MenuItem(MenuItem::Command,
- limitStringLength(ccit->str()) + '|',
- FuncRequest(ccit->action())));
- }
- }
-
- FuncRequest f(LFUN_DIALOG_SHOW, "toc " + cit->first);
- submenu.add(MenuItem(MenuItem::Separator));
- submenu.add(MenuItem(MenuItem::Command, qt_("Open Navigator..."), f));
- MenuItem item(MenuItem::Submenu, guiName(cit->first, buf->params()));
- // deserves to be in the main menu.
- item.setSubmenu(submenu);
+ // "Open outliner..." entry
+ FuncRequest f(LFUN_DIALOG_SHOW, "toc " + cit->first);
+ submenu.add(MenuItem(MenuItem::Command, qt_("Open outliner..."), f));
+ submenu.add(MenuItem(MenuItem::Separator));
+ // add entries
+ submenu.expandToc2(* cit->second, 0, cit->second->size(), 0);
+ MenuItem item(MenuItem::Submenu, guiName(cit->first, buf->params()));
+ item.setSubmenu(submenu);
+ // deserves to be in the main menu?
+ if (floatlist.typeExist(cit->first) || cit->first == "child")
add(item);
- } else {
- if (cit->second->size() >= 30) {
- // FIXME: the behaviour of the interface should not change
- // arbitrarily. Each type should be audited to see if the list
- // can be optimised like for floats above.
- FuncRequest f(LFUN_DIALOG_SHOW, "toc " + cit->first);
- submenu.add(MenuItem(MenuItem::Command, qt_("Open Navigator..."), f));
- } else {
- TocIterator ccit = cit->second->begin();
- TocIterator eend = cit->second->end();
- for (; ccit != eend; ++ccit) {
- submenu.add(MenuItem(MenuItem::Command,
- limitStringLength(ccit->str()) + '|',
- FuncRequest(ccit->action())));
- }
- }
-
- MenuItem item(MenuItem::Submenu, guiName(cit->first, buf->params()));
- item.setSubmenu(submenu);
- if (cit->first == "child") {
- // deserves to be in the main menu.
- add(item);
- } else
- other_lists.add(item);
- }
+ else
+ other_lists.add(item);
}
if (!other_lists.empty()) {
MenuItem item(MenuItem::Submenu, qt_("Other Lists"));
item.setSubmenu(other_lists);
add(item);
}
-
// Handle normal TOC
+ add(MenuItem(MenuItem::Separator));
cit = toc_list.find("tableofcontents");
if (cit == end)
LYXERR(Debug::GUI, "No table of contents.");
if (!cit->second->empty())
expandToc2(* cit->second, 0, cit->second->size(), 0);
else
- add(MenuItem(MenuItem::Info, qt_("<Empty Table of Contents>")));
+ add(MenuItem(MenuItem::Info, qt_("(Empty Table of Contents)")));
}
}
{
QModelIndex index = modelIndex(dit);
TocItem const & toc_item = tocItem(index);
- model_->setData(index, toqstr(toc_item.str()), Qt::DisplayRole);
+ model_->setData(index, toqstr(toc_item.asString()), Qt::DisplayRole);
model_->setData(index, toqstr(toc_item.tooltip()), Qt::ToolTipRole);
}
int current_row = model_->rowCount();
model_->insertRows(current_row, 1);
QModelIndex top_level_item = model_->index(current_row, 0);
- model_->setData(top_level_item, toqstr(item.str()), Qt::DisplayRole);
+ model_->setData(top_level_item, toqstr(item.asString()), Qt::DisplayRole);
model_->setData(top_level_item, index, Qt::UserRole);
model_->setData(top_level_item, toqstr(item.tooltip()), Qt::ToolTipRole);
LYXERR(Debug::GUI, "Toc: at depth " << item.depth()
- << ", added item " << item.str());
+ << ", added item " << item.asString());
populate(index, top_level_item);
if (index >= end)
int current_row = model_->rowCount(parent);
model_->insertRows(current_row, 1, parent);
child_item = model_->index(current_row, 0, parent);
- model_->setData(child_item, toqstr(item.str()), Qt::DisplayRole);
+ model_->setData(child_item, toqstr(item.asString()), Qt::DisplayRole);
model_->setData(child_item, index, Qt::UserRole);
model_->setData(child_item, toqstr(item.tooltip()), Qt::ToolTipRole);
populate(index, child_item);
}
LASSERT(index.model() == it.value()->model(), return);
TocItem const item = it.value()->tocItem(index);
- LYXERR(Debug::GUI, "TocModels::goTo " << item.str());
+ LYXERR(Debug::GUI, "TocModels::goTo " << item.asString());
dispatch(item.action());
}
else if (current_type_ == "branch"
|| current_type_ == "index"
- || current_type_ == "change")
+ || current_type_ == "change"
+ || current_type_ == "table"
+ || current_type_ == "listing"
+ || current_type_ == "figure")
inset = &dit.inset();
- else if (current_type_ == "table"
- || current_type_ == "listing"
- || current_type_ == "figure") {
- DocIterator tmp_dit(dit);
- tmp_dit.pop_back();
- inset = &tmp_dit.inset();
- }
return inset;
}
case LFUN_LABEL_COPY_AS_REFERENCE: {
// For labels in math, we need to supply the label as a string
- FuncRequest label_copy(LFUN_LABEL_COPY_AS_REFERENCE, item.asString());
+ FuncRequest label_copy(LFUN_LABEL_COPY_AS_REFERENCE, item.str());
if (inset)
return inset->getStatus(cur, label_copy, status);
break;
case LFUN_LABEL_COPY_AS_REFERENCE: {
// For labels in math, we need to supply the label as a string
- FuncRequest label_copy(LFUN_LABEL_COPY_AS_REFERENCE, item.asString());
+ FuncRequest label_copy(LFUN_LABEL_COPY_AS_REFERENCE, item.str());
if (inset)
inset->dispatch(cur, label_copy);
break;
return qt_("Index Entries");
if (type == "marginalnote")
return qt_("Marginal notes");
+ if (type == "math-macro")
+ return qt_("Math macros");
if (type == "nomencl")
return qt_("Nomenclature Entries");
if (type == "note")
/// Eg, insetDisplayName(BRANCH_CODE) == _("Branch")
docstring insetDisplayName(InsetCode);
///
-static int const TOC_ENTRY_LENGTH = 40;
+static int const TOC_ENTRY_LENGTH = 80;
/// Common base class to all insets
/// Add an entry to the TocList
/// Pass a DocIterator that points at the paragraph containing
/// the inset
- virtual void addToToc(DocIterator const & /* di */, bool /* output_active */) const {}
+ ///
+ /// \param output_active : is the inset active or is it in an inactive
+ /// branch or a note?
+ ///
+ /// \param utype : is the toc being generated for use by the output
+ /// routines?
+ virtual void addToToc(DocIterator const & /* di */,
+ bool /* output_active */,
+ UpdateType /* utype*/) const {}
/// Collect BibTeX information
virtual void collectBibKeys(InsetIterator const &) const {}
/// Update the counters of this inset and of its contents.
}
-void InsetBranch::addToToc(DocIterator const & cpit, bool output_active) const
+void InsetBranch::addToToc(DocIterator const & cpit, bool output_active,
+ UpdateType utype) const
{
DocIterator pit = cpit;
pit.push_back(CursorSlice(const_cast<InsetBranch &>(*this)));
toc->push_back(TocItem(pit, 0, str, output_active, toolTipText(docstring(), 3, 60)));
// Proceed with the rest of the inset.
bool const doing_output = output_active && isBranchSelected();
- InsetCollapsable::addToToc(cpit, doing_output);
+ InsetCollapsable::addToToc(cpit, doing_output, utype);
}
///
std::string contextMenuName() const;
///
- void addToToc(DocIterator const & di, bool output_active) const;
+ void addToToc(DocIterator const & di, bool output_active,
+ UpdateType utype) const;
///
InsetBranchParams const & params() const { return params_; }
///
}
-void InsetCaption::addToToc(DocIterator const & cpit, bool output_active) const
+void InsetCaption::addToToc(DocIterator const & cpit, bool output_active,
+ UpdateType utype) const
{
string const & type = floattype_.empty() ? "senseless" : floattype_;
DocIterator pit = cpit;
pit.push_back(CursorSlice(const_cast<InsetCaption &>(*this)));
- docstring str = full_label_;
- int length = output_active ? INT_MAX : TOC_ENTRY_LENGTH;
- text().forOutliner(str, length);
+ int length = (utype == OutputUpdate) ?
+ // For output (e.g. xhtml) all (bug #8603) or nothing
+ (output_active ? INT_MAX : 0) :
+ // TOC for LyX interface
+ TOC_ENTRY_LENGTH;
+ docstring str;
+ if (length > 0) {
+ str = full_label_;
+ text().forOutliner(str, length);
+ }
buffer().tocBackend().builder(type)->captionItem(pit, str, output_active);
// Proceed with the rest of the inset.
- InsetText::addToToc(cpit, output_active);
+ InsetText::addToToc(cpit, output_active, utype);
}
docstring xhtml(XHTMLStream & os, OutputParams const & runparams) const;
///
void setCustomLabel(docstring const & label);
- /// \param output_active : is the toc being generated for use by the
- /// output routines?
- void addToToc(DocIterator const & di, bool output_active) const;
+ ///
+ void addToToc(DocIterator const & di, bool output_active, UpdateType utype) const;
///
virtual bool forcePlainLayout(idx_type = 0) const { return true; }
/// Captions don't accept alignment, spacing, etc.
}
-void InsetCaptionable::addToToc(DocIterator const & cpit, bool output_active) const
+void InsetCaptionable::addToToc(DocIterator const & cpit, bool output_active,
+ UpdateType utype) const
{
DocIterator pit = cpit;
pit.push_back(CursorSlice(const_cast<InsetCaptionable &>(*this)));
docstring str;
- int length = output_active ? INT_MAX : TOC_ENTRY_LENGTH;
- text().forOutliner(str, length);
+ // Leave str empty if we generate for output (e.g. xhtml lists of figures).
+ // This ensures that there is a caption if and only if the string is
+ // non-empty.
+ if (utype != OutputUpdate)
+ text().forOutliner(str, TOC_ENTRY_LENGTH);
shared_ptr<TocBuilder> b = buffer().tocBackend().builder(caption_type_);
b->pushItem(pit, str, output_active);
// Proceed with the rest of the inset.
- InsetCollapsable::addToToc(cpit, output_active);
+ InsetCollapsable::addToToc(cpit, output_active, utype);
b->pop();
}
/// are our captions subcaptions?
virtual bool hasSubCaptions(ParIterator const &) const { return false; }
///
- void addToToc(DocIterator const & di, bool output_active) const;
+ void addToToc(DocIterator const & di, bool output_active,
+ UpdateType utype) const;
/// Update the counters of this inset and of its contents
void updateBuffer(ParIterator const &, UpdateType);
///
}
-void InsetCitation::addToToc(DocIterator const & cpit, bool output_active) const
+void InsetCitation::addToToc(DocIterator const & cpit, bool output_active,
+ UpdateType) const
{
// NOTE
// BiblioInfo::collectCitedEntries() uses the TOC to collect the citations
///
void updateBuffer(ParIterator const & it, UpdateType);
///
- void addToToc(DocIterator const & di, bool output_active) const;
+ void addToToc(DocIterator const & di, bool output_active,
+ UpdateType utype) const;
///
std::string contextMenuName() const;
//@}
op.local_font->language()->lang());
}
- // FIXME Do we need to check if it exists? If so, we need a new
- // routine in TocBackend to do that.
shared_ptr<Toc const> toc = buffer().tocBackend().toc(toctype);
if (toc->empty())
return docstring();
Toc::const_iterator it = toc->begin();
Toc::const_iterator const en = toc->end();
for (; it != en; ++it) {
+ if (it->str().empty())
+ continue;
Paragraph const & par = it->dit().innerParagraph();
string const attr = "class='lyxtoc-floats lyxtoc-" + toctype + "'";
xs << html::StartTag("div", attr);
}
-void InsetFoot::addToToc(DocIterator const & cpit, bool output_active) const
+void InsetFoot::addToToc(DocIterator const & cpit, bool output_active,
+ UpdateType utype) const
{
DocIterator pit = cpit;
pit.push_back(CursorSlice(const_cast<InsetFoot &>(*this)));
text().forOutliner(str, TOC_ENTRY_LENGTH);
toc->push_back(TocItem(pit, 0, str, output_active, toolTipText(docstring(), 3, 60)));
// Proceed with the rest of the inset.
- InsetFootlike::addToToc(cpit, output_active);
+ InsetFootlike::addToToc(cpit, output_active, utype);
}
/// Update the counters of this inset and of its contents
void updateBuffer(ParIterator const &, UpdateType);
///
- void addToToc(DocIterator const & di, bool output_active) const;
+ void addToToc(DocIterator const & di, bool output_active,
+ UpdateType utype) const;
///
docstring toolTip(BufferView const & bv, int x, int y) const;
///
}
-void InsetGraphics::addToToc(DocIterator const & cpit, bool output_active) const
+void InsetGraphics::addToToc(DocIterator const & cpit, bool output_active,
+ UpdateType) const
{
//FIXME UNICODE
docstring const str = from_utf8(params_.filename.onlyFileName());
///
bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
///
- void addToToc(DocIterator const & di, bool output_active) const;
+ void addToToc(DocIterator const & di, bool output_active,
+ UpdateType utype) const;
///
std::string contextMenuName() const;
/// Force inset into LTR environment if surroundings are RTL
}
-void InsetInclude::addToToc(DocIterator const & cpit, bool output_active) const
+void InsetInclude::addToToc(DocIterator const & cpit, bool output_active,
+ UpdateType utype) const
{
TocBackend & backend = buffer().tocBackend();
if (isListings(params())) {
if (label_)
- label_->addToToc(cpit, output_active);
+ label_->addToToc(cpit, output_active, utype);
InsetListingsParams p(to_utf8(params()["lstparams"]));
string caption = p.getParamValue("caption");
docstring str = childbuffer->fileName().displayName();
toc->push_back(TocItem(cpit, 0, str, output_active));
- //TocList & toclist = backend.tocs();
- childbuffer->tocBackend().update(output_active);
+ childbuffer->tocBackend().update(output_active, utype);
TocList const & childtoclist = childbuffer->tocBackend().tocs();
TocList::const_iterator it = childtoclist.begin();
TocList::const_iterator const end = childtoclist.end();
///
void addPreview(DocIterator const &, graphics::PreviewLoader &) const;
///
- void addToToc(DocIterator const & di, bool output_active) const;
+ void addToToc(DocIterator const & di, bool output_active,
+ UpdateType utype) const;
///
void updateBuffer(ParIterator const &, UpdateType);
///
}
-void InsetIndex::addToToc(DocIterator const & cpit, bool output_active) const
+void InsetIndex::addToToc(DocIterator const & cpit, bool output_active,
+ UpdateType utype) const
{
DocIterator pit = cpit;
pit.push_back(CursorSlice(const_cast<InsetIndex &>(*this)));
text().forOutliner(str, INT_MAX);
buffer().tocBackend().toc(type)->push_back(TocItem(pit, 0, str, output_active));
// Proceed with the rest of the inset.
- InsetCollapsable::addToToc(cpit, output_active);
+ InsetCollapsable::addToToc(cpit, output_active, utype);
}
/// should paragraph indendation be omitted in any case?
bool neverIndent() const { return true; }
///
- void addToToc(DocIterator const & di, bool output_active) const;
+ void addToToc(DocIterator const & di, bool output_active,
+ UpdateType utype) const;
///
docstring toolTip(BufferView const & bv, int x, int y) const;
///
}
-void InsetLabel::addToToc(DocIterator const & cpit, bool output_active) const
+void InsetLabel::addToToc(DocIterator const & cpit, bool output_active,
+ UpdateType) const
{
docstring const & label = getParam("name");
shared_ptr<Toc> toc = buffer().tocBackend().toc("label");
///
void updateBuffer(ParIterator const & it, UpdateType);
///
- void addToToc(DocIterator const & di, bool output_active) const;
+ void addToToc(DocIterator const & di, bool output_active,
+ UpdateType utype) const;
//@}
/// \name Static public methods obligated for InsetCommand derived classes
}
-void InsetMarginal::addToToc(DocIterator const & cpit, bool output_active) const
+void InsetMarginal::addToToc(DocIterator const & cpit, bool output_active,
+ UpdateType utype) const
{
DocIterator pit = cpit;
pit.push_back(CursorSlice(const_cast<InsetMarginal &>(*this)));
text().forOutliner(str, TOC_ENTRY_LENGTH);
toc->push_back(TocItem(pit, 0, str, output_active, toolTipText(docstring(), 3, 60)));
// Proceed with the rest of the inset.
- InsetFootlike::addToToc(cpit, output_active);
+ InsetFootlike::addToToc(cpit, output_active, utype);
}
} // namespace lyx
///
int docbook(odocstream &, OutputParams const & runparams) const;
///
- void addToToc(DocIterator const & di, bool output_active) const;
+ void addToToc(DocIterator const & di, bool output_active,
+ UpdateType utype) const;
private:
///
Inset * clone() const { return new InsetMarginal(*this); }
}
-void InsetNomencl::addToToc(DocIterator const & cpit, bool output_active) const
+void InsetNomencl::addToToc(DocIterator const & cpit, bool output_active,
+ UpdateType) const
{
docstring const str = getParam("symbol");
buffer().tocBackend().toc("nomencl")->push_back(TocItem(cpit, 0, str, output_active));
/// Updates needed features for this inset.
void validate(LaTeXFeatures & features) const;
///
- void addToToc(DocIterator const & di, bool output_active) const;
+ void addToToc(DocIterator const & di, bool output_active,
+ UpdateType utype) const;
///
InsetCode lyxCode() const { return NOMENCL_CODE; }
///
}
-void InsetNote::addToToc(DocIterator const & cpit, bool output_active) const
+void InsetNote::addToToc(DocIterator const & cpit, bool output_active,
+ UpdateType utype) const
{
DocIterator pit = cpit;
pit.push_back(CursorSlice(const_cast<InsetNote &>(*this)));
// Proceed with the rest of the inset.
bool doing_output = output_active && producesOutput();
- InsetCollapsable::addToToc(cpit, doing_output);
+ InsetCollapsable::addToToc(cpit, doing_output, utype);
}
///
bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
///
- void addToToc(DocIterator const & di, bool output_active) const;
+ void addToToc(DocIterator const & di, bool output_active,
+ UpdateType utype) const;
///
void doDispatch(Cursor & cur, FuncRequest & cmd);
///
}
-void InsetRef::addToToc(DocIterator const & cpit, bool output_active) const
+void InsetRef::addToToc(DocIterator const & cpit, bool output_active,
+ UpdateType) const
{
docstring const & label = getParam("reference");
if (buffer().insetLabel(label))
///
void updateBuffer(ParIterator const & it, UpdateType);
///
- void addToToc(DocIterator const & di, bool output_active) const;
+ void addToToc(DocIterator const & di, bool output_active,
+ UpdateType utype) const;
///
bool forceLTR() const { return true; }
//@}
}
-void InsetTableCell::addToToc(DocIterator const & di, bool output_active) const
+void InsetTableCell::addToToc(DocIterator const & di, bool output_active,
+ UpdateType utype) const
{
- InsetText::iterateForToc(di, output_active);
+ InsetText::iterateForToc(di, output_active, utype);
}
}
-void InsetTabular::addToToc(DocIterator const & cpit, bool output_active) const
+void InsetTabular::addToToc(DocIterator const & cpit, bool output_active,
+ UpdateType utype) const
{
DocIterator dit = cpit;
dit.forwardPos();
size_t const end = dit.nargs();
for ( ; dit.idx() < end; dit.top().forwardIdx())
- cell(dit.idx())->addToToc(dit, output_active);
+ cell(dit.idx())->addToToc(dit, output_active, utype);
}
///
docstring xhtml(XHTMLStream &, OutputParams const &) const;
///
- void addToToc(DocIterator const & di, bool output_active) const;
+ void addToToc(DocIterator const & di, bool output_active,
+ UpdateType utype) const;
private:
/// unimplemented
InsetTableCell();
/// Update the counters of this inset and of its contents
void updateBuffer(ParIterator const &, UpdateType);
///
- void addToToc(DocIterator const & di, bool output_active) const;
+ void addToToc(DocIterator const & di, bool output_active,
+ UpdateType utype) const;
///
bool completionSupported(Cursor const &) const;
}
-void InsetText::addToToc(DocIterator const & cdit, bool output_active) const
+void InsetText::addToToc(DocIterator const & cdit, bool output_active,
+ UpdateType utype) const
{
DocIterator dit = cdit;
dit.push_back(CursorSlice(const_cast<InsetText &>(*this)));
- iterateForToc(dit, output_active);
+ iterateForToc(dit, output_active, utype);
}
-void InsetText::iterateForToc(DocIterator const & cdit, bool output_active) const
+void InsetText::iterateForToc(DocIterator const & cdit, bool output_active,
+ UpdateType utype) const
{
DocIterator dit = cdit;
- // Ensure that any document has a table of contents
+ // This also ensures that any document has a table of contents
shared_ptr<Toc> toc = buffer().tocBackend().toc("tableofcontents");
BufferParams const & bufparams = buffer_->params();
Inset & inset = *it->inset;
dit.pos() = it->pos;
//lyxerr << (void*)&inset << " code: " << inset.lyxCode() << std::endl;
- inset.addToToc(dit, doing_output);
+ inset.addToToc(dit, doing_output, utype);
if (inset.lyxCode() == ARG_CODE)
arginset = inset.asInsetText();
}
if (toclevel != Layout::NOT_IN_TOC && toclevel >= min_toclevel) {
// insert this into the table of contents
docstring tocstring;
- int const length = doing_output ? INT_MAX : TOC_ENTRY_LENGTH;
+ int const length = (doing_output && utype == OutputUpdate) ?
+ INT_MAX : TOC_ENTRY_LENGTH;
if (arginset) {
tocstring = par.labelString();
if (!tocstring.empty())
///
void forOutliner(docstring &, size_t) const;
///
- void addToToc(DocIterator const & di, bool output_active) const;
+ void addToToc(DocIterator const & di, bool output_active,
+ UpdateType utype) const;
///
Inset * clone() const { return new InsetText(*this); }
///
///
docstring getCaptionHTML(OutputParams const &) const;
///
- void iterateForToc(DocIterator const & cdit, bool output_active) const;
+ void iterateForToc(DocIterator const & cdit, bool output_active,
+ UpdateType utype) const;
private:
///
bool drawFrame_;
}
-void InsetMathHull::addToToc(DocIterator const & pit, bool output_active) const
+void InsetMathHull::addToToc(DocIterator const & pit, bool output_active,
+ UpdateType utype) const
{
if (!buffer_) {
//FIXME: buffer_ should be set at creation for this inset! Problem is
if (!numbered(row))
continue;
if (label_[row])
- label_[row]->addToToc(pit, output_active);
+ label_[row]->addToToc(pit, output_active, utype);
toc->push_back(TocItem(pit, 0, nicelabel(row), output_active));
}
}
///
void updateBuffer(ParIterator const &, UpdateType);
///
- void addToToc(DocIterator const & di, bool output_active) const;
+ void addToToc(DocIterator const & di, bool output_active,
+ UpdateType utype) const;
///
InsetMathHull & operator=(InsetMathHull const &);
///
#include "FuncRequest.h"
#include "FuncStatus.h"
#include "Lexer.h"
+#include "TocBackend.h"
#include "frontends/Painter.h"
return "context-math-macro-definition";
}
+void MathMacroTemplate::addToToc(DocIterator const & pit, bool output_active,
+ UpdateType) const
+{
+ shared_ptr<Toc> toc = buffer().tocBackend().toc("math-macro");
+ docstring str;
+ if (!validMacro())
+ str = bformat(_("Invalid macro! \\%1$s"), name());
+ else
+ str = "\\" + name();
+ toc->push_back(TocItem(pit, 0, str, output_active));
+}
+
+
} // namespace lyx
void infoize(odocstream & os) const;
///
std::string contextMenuName() const;
+ ///
+ void addToToc(DocIterator const & di, bool output_active,
+ UpdateType utype) const;
protected:
///
virtual void doDispatch(Cursor & cur, FuncRequest & cmd);