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"
19 #include "support/gettext.h"
21 // FIXME: the following is needed just to get the layout of the enclosing
22 // paragraph. This seems a bit too much to me (JMarc)
23 #include "OutputParams.h"
24 #include "ParIterator.h"
25 #include "TextClass.h"
26 #include "TocBackend.h"
28 #include "support/debug.h"
29 #include "support/docstream.h"
30 #include "support/lstrings.h"
37 InsetFoot::InsetFoot(Buffer const & buf)
42 docstring InsetFoot::editMessage() const
44 return _("Opened Footnote Inset");
48 void InsetFoot::updateLabels(ParIterator const & it)
50 DocumentClass const & tclass = buffer().params().documentClass();
51 Counters & cnts = tclass.counters();
52 docstring const foot = from_ascii("footnote");
53 Paragraph const & outer = it.paragraph();
54 if (!outer.layout().intitle && cnts.hasCounter(foot)) {
56 // FIXME: the counter should format itself.
57 custom_label_= support::bformat(from_utf8("%1$s %2$s"),
58 translateIfPossible(getLayout(buffer().params()).labelstring()),
59 cnts.theCounter(foot));
60 setLabel(custom_label_);
63 InsetCollapsable::updateLabels(it);
67 void InsetFoot::addToToc(DocIterator const & cpit)
69 DocIterator pit = cpit;
70 pit.push_back(CursorSlice(*this));
72 Toc & toc = buffer().tocBackend().toc("footnote");
74 str = custom_label_ + ": " + getNewLabel(str);
75 toc.push_back(TocItem(pit, 0, str));
79 docstring InsetFoot::toolTip(BufferView const & bv, int x, int y) const
81 docstring default_tip = InsetCollapsable::toolTip(bv, x, y);
83 return custom_label_ + ": " + default_tip;
88 int InsetFoot::latex(odocstream & os, OutputParams const & runparams_in) const
90 OutputParams runparams = runparams_in;
91 // footnotes in titling commands like \title have moving arguments
92 runparams.moving_arg |= runparams_in.intitle;
94 // in titling commands, \thanks should be used instead of \footnote.
95 // some classes (e.g. memoir) do not understand \footnote.
96 if (runparams_in.intitle)
99 os << "%\n\\footnote{";
101 int const i = InsetText::latex(os, runparams);
103 runparams_in.encoding = runparams.encoding;
109 int InsetFoot::plaintext(odocstream & os, OutputParams const & runparams) const
111 os << '[' << buffer().B_("footnote") << ":\n";
112 InsetText::plaintext(os, runparams);
115 return PLAINTEXT_NEWLINE + 1; // one char on a separate line
119 int InsetFoot::docbook(odocstream & os, OutputParams const & runparams) const
122 int const i = InsetText::docbook(os, runparams);