]> git.lyx.org Git - lyx.git/blob - src/insets/InsetMarginal.cpp
654caca709859b87c5f8e9e8bd789c8f08f9af23
[lyx.git] / src / insets / InsetMarginal.cpp
1 /**
2  * \file InsetMarginal.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 "InsetMarginal.h"
15
16 #include "Buffer.h"
17 #include "OutputParams.h"
18 #include "TocBackend.h"
19
20 #include "support/gettext.h"
21
22 #include <ostream>
23
24
25 namespace lyx {
26
27
28 InsetMarginal::InsetMarginal(Buffer const & buf)
29         : InsetFootlike(buf)
30 {}
31
32
33 docstring InsetMarginal::editMessage() const
34 {
35         return _("Opened Marginal Note Inset");
36 }
37
38
39 int InsetMarginal::latex(odocstream & os, OutputParams const & runparams) const
40 {
41         os << "%\n\\marginpar{";
42         int const i = InsetText::latex(os, runparams);
43         os << "%\n}";
44         return i + 2;
45 }
46
47
48 int InsetMarginal::plaintext(odocstream & os,
49                              OutputParams const & runparams) const
50 {
51         os << '[' << buffer().B_("margin") << ":\n";
52         InsetText::plaintext(os, runparams);
53         os << "\n]";
54
55         return PLAINTEXT_NEWLINE + 1; // one char on a separate line
56 }
57
58
59 int InsetMarginal::docbook(odocstream & os,
60                            OutputParams const & runparams) const
61 {
62         os << "<note role=\"margin\">";
63         int const i = InsetText::docbook(os, runparams);
64         os << "</note>";
65
66         return i;
67 }
68
69
70 void InsetMarginal::addToToc(ParConstIterator const & cpit) const
71 {
72         ParConstIterator pit = cpit;
73         pit.push_back(*this);
74
75         Toc & toc = buffer().tocBackend().toc("marginalnote");
76         docstring str;
77         str = getNewLabel(str);
78         toc.push_back(TocItem(pit, 0, str));
79 }
80
81 } // namespace lyx