]> git.lyx.org Git - lyx.git/blob - src/insets/InsetFoot.cpp
getting rid of more superfluous lyx::support:: statements.
[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 #include "support/debug.h"
14
15 #include "InsetFoot.h"
16
17 #include "Buffer.h"
18 #include "BufferParams.h"
19 #include "Counters.h"
20 #include "support/gettext.h"
21 #include "Layout.h"
22 // FIXME: the following is needed just to get the layout of the enclosing
23 // paragraph. This seems a bit too much to me (JMarc)
24 #include "OutputParams.h"
25 #include "ParIterator.h"
26 #include "TextClass.h"
27
28 #include "support/lstrings.h"
29
30 #include <ostream>
31
32 using namespace std;
33
34 namespace lyx {
35
36
37 InsetFoot::InsetFoot(BufferParams const & bp)
38         : InsetFootlike(bp)
39 {}
40
41
42 InsetFoot::InsetFoot(InsetFoot const & in)
43         : InsetFootlike(in)
44 {}
45
46
47 Inset * InsetFoot::clone() const
48 {
49         return new InsetFoot(*this);
50 }
51
52
53 docstring const InsetFoot::editMessage() const
54 {
55         return _("Opened Footnote Inset");
56 }
57
58
59 void InsetFoot::updateLabels(Buffer const & buf, ParIterator const & it)
60 {
61         TextClass const & tclass = buf.params().getTextClass();
62         Counters & cnts = tclass.counters();
63         docstring const & foot = from_ascii("footnote");
64         Paragraph const & outer =  it.paragraph();
65         if (!outer.layout()->intitle && cnts.hasCounter(foot)) {
66                 cnts.step(foot);
67                 //FIXME: the counter should format itself.
68                 setLabel(support::bformat(from_ascii("%1$s %2$s"), 
69                                           getLayout(buf.params()).labelstring, 
70                                           cnts.theCounter(foot)));
71         
72         }
73         InsetCollapsable::updateLabels(buf, it);
74 }
75
76
77 int InsetFoot::latex(Buffer const & buf, odocstream & os,
78                      OutputParams const & runparams_in) const
79 {
80         OutputParams runparams = runparams_in;
81         // footnotes in titling commands like \title have moving arguments
82         runparams.moving_arg |= runparams_in.intitle;
83
84         // in titling commands, \thanks should be used instead of \footnote.
85         // some classes (e.g. memoir) do not understand \footnote.
86         if (runparams_in.intitle)
87                 os << "%\n\\thanks{";
88         else
89                 os << "%\n\\footnote{";
90
91         int const i = InsetText::latex(buf, os, runparams);
92         os << "%\n}";
93         runparams_in.encoding = runparams.encoding;
94
95         return i + 2;
96 }
97
98
99 int InsetFoot::plaintext(Buffer const & buf, odocstream & os,
100                          OutputParams const & runparams) const
101 {
102         os << '[' << buf.B_("footnote") << ":\n";
103         InsetText::plaintext(buf, os, runparams);
104         os << "\n]";
105
106         return PLAINTEXT_NEWLINE + 1; // one char on a separate line
107 }
108
109
110 int InsetFoot::docbook(Buffer const & buf, odocstream & os,
111                        OutputParams const & runparams) const
112 {
113         os << "<footnote>";
114         int const i = InsetText::docbook(buf, os, runparams);
115         os << "</footnote>";
116
117         return i;
118 }
119
120
121 } // namespace lyx