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"
20 #include "LaTeXFeatures.h"
22 #include "OutputParams.h"
23 #include "ParIterator.h"
24 #include "TextClass.h"
25 #include "TocBackend.h"
27 #include "support/debug.h"
28 #include "support/docstream.h"
29 #include "support/gettext.h"
30 #include "support/lstrings.h"
36 InsetFoot::InsetFoot(Buffer * buf)
37 : InsetFootlike(buf), intitle_(false)
41 docstring InsetFoot::layoutName() const
43 return intitle_ ? from_ascii("Foot:InTitle") : from_ascii("Foot");
47 void InsetFoot::updateBuffer(ParIterator const & it, UpdateType utype)
49 BufferParams const & bp = buffer().masterBuffer()->params();
50 Counters & cnts = bp.documentClass().counters();
51 if (utype == OutputUpdate) {
52 // the footnote counter is local to this inset
53 cnts.saveLastCounter();
57 for (size_type sl = 0 ; sl < it.depth() ; ++ sl) {
58 if (it[sl].text() && it[sl].paragraph().layout().intitle) {
64 Language const * lang = it.paragraph().getParLanguage(bp);
65 InsetLayout const & il = getLayout();
66 docstring const & count = il.counter();
67 custom_label_ = translateIfPossible(il.labelstring());
68 if (cnts.hasCounter(count))
69 cnts.step(count, utype);
70 custom_label_ += ' ' + cnts.theCounter(count, lang->code());
71 setLabel(custom_label_);
73 InsetCollapsible::updateBuffer(it, utype);
74 if (utype == OutputUpdate)
75 cnts.restoreLastCounter();
79 docstring InsetFoot::toolTip(BufferView const & bv, int x, int y) const
82 // this will give us something useful if there is no button
83 return InsetCollapsible::toolTip(bv, x, y);
84 return toolTipText(custom_label_+ ": ");
88 int InsetFoot::plaintext(odocstringstream & os,
89 OutputParams const & runparams, size_t max_length) const
91 os << '[' << buffer().B_("footnote") << ":\n";
92 InsetText::plaintext(os, runparams, max_length);
95 return PLAINTEXT_NEWLINE + 1; // one char on a separate line
99 int InsetFoot::docbook(odocstream & os, OutputParams const & runparams) const
102 int const i = InsetText::docbook(os, runparams);
109 void InsetFoot::validate(LaTeXFeatures & features) const
111 if (!features.saveNoteEnv().empty()) {
112 features.require("footnote");
113 features.addPreambleSnippet(
114 from_ascii("\\makesavenoteenv{"
115 + features.saveNoteEnv()
119 InsetText::validate(features);