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)
39 void InsetFoot::updateBuffer(ParIterator const & it, UpdateType utype)
41 BufferParams const & bp = buffer().masterBuffer()->params();
42 Counters & cnts = bp.documentClass().counters();
43 if (utype == OutputUpdate) {
44 // the footnote counter is local to this inset
45 cnts.saveLastCounter();
47 Paragraph const & outer = it.paragraph();
48 InsetLayout const & il = getLayout();
49 docstring const & count = il.counter();
50 if (!outer.layout().intitle && cnts.hasCounter(count)) {
51 cnts.step(count, utype);
52 custom_label_= translateIfPossible(il.labelstring())
53 + ' ' + cnts.theCounter(count, outer.getParLanguage(bp)->code());
54 setLabel(custom_label_);
56 InsetCollapsable::updateBuffer(it, utype);
57 if (utype == OutputUpdate)
58 cnts.restoreLastCounter();
62 void InsetFoot::addToToc(DocIterator const & cpit)
64 DocIterator pit = cpit;
65 pit.push_back(CursorSlice(*this));
67 Toc & toc = buffer().tocBackend().toc("footnote");
69 str = custom_label_ + ": " + getNewLabel(str);
70 toc.push_back(TocItem(pit, 0, str));
71 // Proceed with the rest of the inset.
72 InsetFootlike::addToToc(cpit);
76 docstring InsetFoot::toolTip(BufferView const & bv, int x, int y) const
78 docstring default_tip = InsetCollapsable::toolTip(bv, x, y);
80 return custom_label_ + "\n" + default_tip;
85 int InsetFoot::latex(odocstream & os, OutputParams const & runparams_in) const
87 OutputParams runparams = runparams_in;
88 // footnotes in titling commands like \title have moving arguments
89 runparams.moving_arg |= runparams_in.intitle;
91 // in titling commands, \thanks should be used instead of \footnote.
92 // some classes (e.g. memoir) do not understand \footnote.
93 if (runparams_in.intitle)
96 os << "%\n\\footnote{";
98 int const i = InsetText::latex(os, runparams);
100 runparams_in.encoding = runparams.encoding;
106 int InsetFoot::plaintext(odocstream & os, OutputParams const & runparams) const
108 os << '[' << buffer().B_("footnote") << ":\n";
109 InsetText::plaintext(os, runparams);
112 return PLAINTEXT_NEWLINE + 1; // one char on a separate line
116 int InsetFoot::docbook(odocstream & os, OutputParams const & runparams) const
119 int const i = InsetText::docbook(os, runparams);