]> git.lyx.org Git - lyx.git/blob - src/insets/InsetFoot.cpp
remove unneeded includes.
[lyx.git] / src / insets / InsetFoot.cpp
1 /**
2  * \file InsetFoot.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Jürgen Vigna
7  * \author Lars Gullik Bjønnes
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #include <config.h>
13
14 #include "InsetFoot.h"
15
16 #include "Buffer.h"
17 #include "BufferParams.h"
18 #include "Counters.h"
19 #include "support/gettext.h"
20 #include "Layout.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"
27
28 #include "support/debug.h"
29 #include "support/docstream.h"
30 #include "support/lstrings.h"
31
32 using namespace std;
33
34 namespace lyx {
35
36
37 InsetFoot::InsetFoot(Buffer const & buf)
38         : InsetFootlike(buf)
39 {}
40
41
42 docstring InsetFoot::editMessage() const
43 {
44         return _("Opened Footnote Inset");
45 }
46
47
48 void InsetFoot::updateLabels(ParIterator const & it)
49 {
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)) {
55                 cnts.step(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_);
61         
62         }
63         InsetCollapsable::updateLabels(it);
64 }
65
66
67 void InsetFoot::addToToc(ParConstIterator const & cpit) const
68 {
69         ParConstIterator pit = cpit;
70         pit.push_back(*this);
71
72         Toc & toc = buffer().tocBackend().toc("footnote");
73         // FIXME: we probably want the footnote number too.
74         docstring str;
75         str = custom_label_ + ": " + getNewLabel(str);
76         toc.push_back(TocItem(pit, 0, str));
77 }
78
79
80 docstring InsetFoot::toolTip(BufferView const & bv, int x, int y) const
81 {
82         docstring default_tip = InsetCollapsable::toolTip(bv, x, y);
83         if (!isOpen())
84                 return custom_label_ + ": " + default_tip;
85         return default_tip;
86 }
87
88
89 int InsetFoot::latex(odocstream & os, OutputParams const & runparams_in) const
90 {
91         OutputParams runparams = runparams_in;
92         // footnotes in titling commands like \title have moving arguments
93         runparams.moving_arg |= runparams_in.intitle;
94
95         // in titling commands, \thanks should be used instead of \footnote.
96         // some classes (e.g. memoir) do not understand \footnote.
97         if (runparams_in.intitle)
98                 os << "%\n\\thanks{";
99         else
100                 os << "%\n\\footnote{";
101
102         int const i = InsetText::latex(os, runparams);
103         os << "%\n}";
104         runparams_in.encoding = runparams.encoding;
105
106         return i + 2;
107 }
108
109
110 int InsetFoot::plaintext(odocstream & os, OutputParams const & runparams) const
111 {
112         os << '[' << buffer().B_("footnote") << ":\n";
113         InsetText::plaintext(os, runparams);
114         os << "\n]";
115
116         return PLAINTEXT_NEWLINE + 1; // one char on a separate line
117 }
118
119
120 int InsetFoot::docbook(odocstream & os, OutputParams const & runparams) const
121 {
122         os << "<footnote>";
123         int const i = InsetText::docbook(os, runparams);
124         os << "</footnote>";
125
126         return i;
127 }
128
129
130 } // namespace lyx