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