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