3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
7 * \author Lars Gullik Bjønnes
9 * Full author contact details are available in file CREDITS.
14 #include "InsetFoot.h"
17 #include "BufferParams.h"
21 #include "OutputParams.h"
22 #include "ParIterator.h"
23 #include "TextClass.h"
24 #include "TocBackend.h"
26 #include "support/debug.h"
27 #include "support/docstream.h"
28 #include "support/gettext.h"
34 InsetFoot::InsetFoot(Buffer * buf)
35 : InsetFootlike(buf), intitle_(false)
39 docstring InsetFoot::layoutName() const
41 return intitle_ ? from_ascii("Foot:InTitle") : from_ascii("Foot");
45 void InsetFoot::updateBuffer(ParIterator const & it, UpdateType utype)
47 BufferParams const & bp = buffer().masterBuffer()->params();
48 Counters & cnts = bp.documentClass().counters();
49 if (utype == OutputUpdate) {
50 // the footnote counter is local to this inset
51 cnts.saveLastCounter();
55 for (size_type sl = 0 ; sl < it.depth() ; ++ sl) {
56 if (it[sl].text() && it[sl].paragraph().layout().intitle) {
62 Language const * lang = it.paragraph().getParLanguage(bp);
63 InsetLayout const & il = getLayout();
64 docstring const & count = il.counter();
65 custom_label_ = translateIfPossible(il.labelstring());
66 if (cnts.hasCounter(count))
67 cnts.step(count, utype);
68 custom_label_ += ' ' + cnts.theCounter(count, lang->code());
69 setLabel(custom_label_);
71 InsetCollapsable::updateBuffer(it, utype);
72 if (utype == OutputUpdate)
73 cnts.restoreLastCounter();
77 void InsetFoot::addToToc(DocIterator const & cpit, bool output_active,
78 UpdateType utype) const
80 DocIterator pit = cpit;
81 pit.push_back(CursorSlice(const_cast<InsetFoot &>(*this)));
83 shared_ptr<Toc> toc = buffer().tocBackend().toc("footnote");
84 docstring str = custom_label_ + ": ";
85 text().forOutliner(str, TOC_ENTRY_LENGTH);
86 toc->push_back(TocItem(pit, 0, str, output_active, toolTipText(docstring(), 3, 60)));
87 // Proceed with the rest of the inset.
88 InsetFootlike::addToToc(cpit, output_active, utype);
92 docstring InsetFoot::toolTip(BufferView const & bv, int x, int y) const
95 // this will give us something useful if there is no button
96 return InsetCollapsable::toolTip(bv, x, y);
97 return toolTipText(custom_label_+ ": ");
101 int InsetFoot::plaintext(odocstringstream & os,
102 OutputParams const & runparams, size_t max_length) const
104 os << '[' << buffer().B_("footnote") << ":\n";
105 InsetText::plaintext(os, runparams, max_length);
108 return PLAINTEXT_NEWLINE + 1; // one char on a separate line
112 int InsetFoot::docbook(odocstream & os, OutputParams const & runparams) const
115 int const i = InsetText::docbook(os, runparams);