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"
29 #include "support/lstrings.h"
35 InsetFoot::InsetFoot(Buffer * buf)
36 : InsetFootlike(buf), intitle_(false)
40 docstring InsetFoot::layoutName() const
42 return intitle_ ? from_ascii("Foot:InTitle") : from_ascii("Foot");
46 void InsetFoot::updateBuffer(ParIterator const & it, UpdateType utype)
48 BufferParams const & bp = buffer().masterBuffer()->params();
49 Counters & cnts = bp.documentClass().counters();
50 if (utype == OutputUpdate) {
51 // the footnote counter is local to this inset
52 cnts.saveLastCounter();
56 for (size_type sl = 0 ; sl < it.depth() ; ++ sl) {
57 if (it[sl].text() && it[sl].paragraph().layout().intitle) {
63 Language const * lang = it.paragraph().getParLanguage(bp);
64 InsetLayout const & il = getLayout();
65 docstring const & count = il.counter();
66 custom_label_ = translateIfPossible(il.labelstring());
67 if (cnts.hasCounter(count))
68 cnts.step(count, utype);
69 custom_label_ += ' ' + cnts.theCounter(count, lang->code());
70 setLabel(custom_label_);
72 InsetCollapsable::updateBuffer(it, utype);
73 if (utype == OutputUpdate)
74 cnts.restoreLastCounter();
78 docstring InsetFoot::toolTip(BufferView const & bv, int x, int y) const
81 // this will give us something useful if there is no button
82 return InsetCollapsable::toolTip(bv, x, y);
83 return toolTipText(custom_label_+ ": ");
87 int InsetFoot::plaintext(odocstringstream & os,
88 OutputParams const & runparams, size_t max_length) const
90 os << '[' << buffer().B_("footnote") << ":\n";
91 InsetText::plaintext(os, runparams, max_length);
94 return PLAINTEXT_NEWLINE + 1; // one char on a separate line
98 int InsetFoot::docbook(odocstream & os, OutputParams const & runparams) const
101 int const i = InsetText::docbook(os, runparams);