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/lstrings.h"
38 InsetFoot::InsetFoot(BufferParams const & bp)
43 InsetFoot::InsetFoot(InsetFoot const & in)
48 Inset * InsetFoot::clone() const
50 return new InsetFoot(*this);
54 docstring const InsetFoot::editMessage() const
56 return _("Opened Footnote Inset");
60 void InsetFoot::updateLabels(Buffer const & buf, ParIterator const & it)
62 TextClass const & tclass = buf.params().getTextClass();
63 Counters & cnts = tclass.counters();
64 docstring const foot = from_ascii("footnote");
65 Paragraph const & outer = it.paragraph();
66 if (!outer.layout()->intitle && cnts.hasCounter(foot)) {
68 //FIXME: the counter should format itself.
69 setLabel(support::bformat(from_ascii("%1$s %2$s"),
70 getLayout(buf.params()).labelstring(),
71 cnts.theCounter(foot)));
74 InsetCollapsable::updateLabels(buf, it);
78 void InsetFoot::addToToc(Buffer const & buf,
79 ParConstIterator const & cpit) const
81 ParConstIterator pit = cpit;
84 Toc & toc = buf.tocBackend().toc("footnote");
85 // FIXME: we probably want the footnote number too.
87 str = getNewLabel(str);
88 toc.push_back(TocItem(pit, 0, str));
92 int InsetFoot::latex(Buffer const & buf, odocstream & os,
93 OutputParams const & runparams_in) const
95 OutputParams runparams = runparams_in;
96 // footnotes in titling commands like \title have moving arguments
97 runparams.moving_arg |= runparams_in.intitle;
99 // in titling commands, \thanks should be used instead of \footnote.
100 // some classes (e.g. memoir) do not understand \footnote.
101 if (runparams_in.intitle)
102 os << "%\n\\thanks{";
104 os << "%\n\\footnote{";
106 int const i = InsetText::latex(buf, os, runparams);
108 runparams_in.encoding = runparams.encoding;
114 int InsetFoot::plaintext(Buffer const & buf, odocstream & os,
115 OutputParams const & runparams) const
117 os << '[' << buf.B_("footnote") << ":\n";
118 InsetText::plaintext(buf, os, runparams);
121 return PLAINTEXT_NEWLINE + 1; // one char on a separate line
125 int InsetFoot::docbook(Buffer const & buf, odocstream & os,
126 OutputParams const & runparams) const
129 int const i = InsetText::docbook(buf, os, runparams);