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 using support::bformat;
37 InsetFoot::InsetFoot(Buffer const & buf)
42 void InsetFoot::updateLabels(ParIterator const & it)
44 BufferParams const & bp = buffer().masterBuffer()->params();
45 Counters & cnts = bp.documentClass().counters();
46 docstring const foot = from_ascii("footnote");
47 Paragraph const & outer = it.paragraph();
48 if (!outer.layout().intitle && cnts.hasCounter(foot)) {
50 // FIXME: the counter should format itself.
51 custom_label_= bformat(from_utf8("%1$s %2$s"),
52 translateIfPossible(getLayout().labelstring()),
53 cnts.theCounter(foot, outer.getParLanguage(bp)->code()));
54 setLabel(custom_label_);
57 InsetCollapsable::updateLabels(it);
61 void InsetFoot::addToToc(DocIterator const & cpit)
63 DocIterator pit = cpit;
64 pit.push_back(CursorSlice(*this));
66 Toc & toc = buffer().tocBackend().toc("footnote");
68 str = custom_label_ + ": " + getNewLabel(str);
69 toc.push_back(TocItem(pit, 0, str));
70 // Proceed with the rest of the inset.
71 InsetFootlike::addToToc(cpit);
75 docstring InsetFoot::toolTip(BufferView const & bv, int x, int y) const
77 docstring default_tip = InsetCollapsable::toolTip(bv, x, y);
79 return custom_label_ + "\n" + default_tip;
84 int InsetFoot::latex(odocstream & os, OutputParams const & runparams_in) const
86 OutputParams runparams = runparams_in;
87 // footnotes in titling commands like \title have moving arguments
88 runparams.moving_arg |= runparams_in.intitle;
90 // in titling commands, \thanks should be used instead of \footnote.
91 // some classes (e.g. memoir) do not understand \footnote.
92 if (runparams_in.intitle)
95 os << "%\n\\footnote{";
97 int const i = InsetText::latex(os, runparams);
99 runparams_in.encoding = runparams.encoding;
105 int InsetFoot::plaintext(odocstream & os, OutputParams const & runparams) const
107 os << '[' << buffer().B_("footnote") << ":\n";
108 InsetText::plaintext(os, runparams);
111 return PLAINTEXT_NEWLINE + 1; // one char on a separate line
115 int InsetFoot::docbook(odocstream & os, OutputParams const & runparams) const
118 int const i = InsetText::docbook(os, runparams);