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 if (!outer.layout().intitle) {
49 InsetLayout const & il = getLayout();
50 docstring const & count = il.counter();
51 custom_label_ = translateIfPossible(il.labelstring()) + ' ';
52 if (cnts.hasCounter(count))
53 cnts.step(count, utype);
55 cnts.theCounter(count, outer.getParLanguage(bp)->code());
56 setLabel(custom_label_);
58 InsetCollapsable::updateBuffer(it, utype);
59 if (utype == OutputUpdate)
60 cnts.restoreLastCounter();
64 void InsetFoot::addToToc(DocIterator const & cpit) const
66 DocIterator pit = cpit;
67 pit.push_back(CursorSlice(const_cast<InsetFoot &>(*this)));
69 Toc & toc = buffer().tocBackend().toc("footnote");
70 docstring str = custom_label_ + ": ";
71 text().forToc(str, TOC_ENTRY_LENGTH);
72 toc.push_back(TocItem(pit, 0, str, toolTipText(docstring(), 3, 60)));
73 // Proceed with the rest of the inset.
74 InsetFootlike::addToToc(cpit);
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 void InsetFoot::latex(otexstream & os, OutputParams const & runparams_in) const
89 OutputParams runparams = runparams_in;
90 // footnotes in titling commands like \title have moving arguments
91 runparams.moving_arg |= runparams_in.intitle;
94 if (runparams.lastid != -1)
95 os.texrow().start(runparams.lastid, runparams.lastpos);
97 // in titling commands, \thanks should be used instead of \footnote.
98 // some classes (e.g. memoir) do not understand \footnote.
99 if (runparams_in.intitle)
104 InsetText::latex(os, runparams);
106 runparams_in.encoding = runparams.encoding;
110 int InsetFoot::plaintext(odocstream & os, OutputParams const & runparams) const
112 os << '[' << buffer().B_("footnote") << ":\n";
113 InsetText::plaintext(os, runparams);
116 return PLAINTEXT_NEWLINE + 1; // one char on a separate line
120 int InsetFoot::docbook(odocstream & os, OutputParams const & runparams) const
123 int const i = InsetText::docbook(os, runparams);