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), infloattable_(false)
41 docstring InsetFoot::layoutName() const
44 return from_ascii("Foot:InTitle");
45 else if (infloattable_)
46 return from_ascii("Foot:InFloatTable");
47 return from_ascii("Foot");
51 void InsetFoot::updateBuffer(ParIterator const & it, UpdateType utype)
53 BufferParams const & bp = buffer().masterBuffer()->params();
54 Counters & cnts = bp.documentClass().counters();
55 if (utype == OutputUpdate) {
56 // the footnote counter is local to this inset
57 cnts.saveLastCounter();
61 infloattable_ = false;
63 if (it.innerInsetOfType(TABULAR_CODE) != 0)
65 if (it.innerInsetOfType(FLOAT_CODE) != 0)
66 infloattable_ = intable;
67 for (size_type sl = 0 ; sl < it.depth() ; ++sl) {
68 if (it[sl].text() && it[sl].paragraph().layout().intitle) {
74 Language const * lang = it.paragraph().getParLanguage(bp);
75 InsetLayout const & il = getLayout();
76 docstring const & count = il.counter();
77 custom_label_ = translateIfPossible(il.labelstring());
78 if (cnts.hasCounter(count))
79 cnts.step(count, utype);
80 custom_label_ += ' ' + cnts.theCounter(count, lang->code());
81 setLabel(custom_label_);
83 InsetCollapsible::updateBuffer(it, utype);
84 if (utype == OutputUpdate)
85 cnts.restoreLastCounter();
89 docstring InsetFoot::toolTip(BufferView const & bv, int x, int y) const
92 // this will give us something useful if there is no button
93 return InsetCollapsible::toolTip(bv, x, y);
94 return toolTipText(custom_label_+ ": ");
98 int InsetFoot::plaintext(odocstringstream & os,
99 OutputParams const & runparams, size_t max_length) const
101 os << '[' << buffer().B_("footnote") << ":\n";
102 InsetText::plaintext(os, runparams, max_length);
105 return PLAINTEXT_NEWLINE + 1; // one char on a separate line
109 int InsetFoot::docbook(odocstream & os, OutputParams const & runparams) const
112 int const i = InsetText::docbook(os, runparams);
119 void InsetFoot::validate(LaTeXFeatures & features) const
121 // Use footnote package to provide footnotes in tables
122 // unless an alternative approach is built in the class.
123 if (!features.saveNoteEnv().empty()
124 && !features.isProvided("footnote-alternative")) {
125 features.require("footnote");
126 features.addPreambleSnippet(
127 from_ascii("\\makesavenoteenv{"
128 + features.saveNoteEnv()
132 InsetText::validate(features);