]> git.lyx.org Git - features.git/blob - src/insets/InsetFoot.cpp
remove all trace of editMessage
[features.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 "Language.h"
20 #include "Layout.h"
21 #include "OutputParams.h"
22 #include "ParIterator.h"
23 #include "TextClass.h"
24 #include "TocBackend.h"
25
26 #include "support/debug.h"
27 #include "support/docstream.h"
28 #include "support/gettext.h"
29 #include "support/lstrings.h"
30
31 using namespace std;
32
33 namespace lyx {
34
35 using support::bformat;
36
37 InsetFoot::InsetFoot(Buffer const & buf)
38         : InsetFootlike(buf)
39 {}
40
41
42 void InsetFoot::updateLabels(ParIterator const & it)
43 {
44         BufferParams const & bp = buffer().masterBuffer()->params();
45         Counters & cnts = bp.documentClass().counters();
46         docstring const foot = from_ascii("footnote");
47         Paragraph const & outer =  it.paragraph();
48         if (!outer.layout().intitle && cnts.hasCounter(foot)) {
49                 cnts.step(foot);
50                 // FIXME: the counter should format itself.
51                 custom_label_= bformat(from_utf8("%1$s %2$s"),
52                                        translateIfPossible(getLayout().labelstring()),
53                                        cnts.theCounter(foot, outer.getParLanguage(bp)->code()));
54                 setLabel(custom_label_);
55         
56         }
57         InsetCollapsable::updateLabels(it);
58 }
59
60
61 void InsetFoot::addToToc(DocIterator const & cpit)
62 {
63         DocIterator pit = cpit;
64         pit.push_back(CursorSlice(*this));
65
66         Toc & toc = buffer().tocBackend().toc("footnote");
67         docstring str;
68         str = custom_label_ + ": " + getNewLabel(str);
69         toc.push_back(TocItem(pit, 0, str));
70         // Proceed with the rest of the inset.
71         InsetFootlike::addToToc(cpit);
72 }
73
74
75 docstring InsetFoot::toolTip(BufferView const & bv, int x, int y) const
76 {
77         docstring default_tip = InsetCollapsable::toolTip(bv, x, y);
78         if (!isOpen(bv))
79                 return custom_label_ + "\n" + default_tip;
80         return default_tip;
81 }
82
83
84 int InsetFoot::latex(odocstream & os, OutputParams const & runparams_in) const
85 {
86         OutputParams runparams = runparams_in;
87         // footnotes in titling commands like \title have moving arguments
88         runparams.moving_arg |= runparams_in.intitle;
89
90         // in titling commands, \thanks should be used instead of \footnote.
91         // some classes (e.g. memoir) do not understand \footnote.
92         if (runparams_in.intitle)
93                 os << "%\n\\thanks{";
94         else
95                 os << "%\n\\footnote{";
96
97         int const i = InsetText::latex(os, runparams);
98         os << "%\n}";
99         runparams_in.encoding = runparams.encoding;
100
101         return i + 2;
102 }
103
104
105 int InsetFoot::plaintext(odocstream & os, OutputParams const & runparams) const
106 {
107         os << '[' << buffer().B_("footnote") << ":\n";
108         InsetText::plaintext(os, runparams);
109         os << "\n]";
110
111         return PLAINTEXT_NEWLINE + 1; // one char on a separate line
112 }
113
114
115 int InsetFoot::docbook(odocstream & os, OutputParams const & runparams) const
116 {
117         os << "<footnote>";
118         int const i = InsetText::docbook(os, runparams);
119         os << "</footnote>";
120
121         return i;
122 }
123
124 } // namespace lyx