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