]> git.lyx.org Git - lyx.git/blob - src/insets/InsetMarginal.cpp
Fix length of hfills
[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 * buf)
28         : InsetFootlike(buf)
29 {}
30
31
32 int InsetMarginal::plaintext(odocstringstream & os,
33                              OutputParams const & runparams, size_t max_length) const
34 {
35         os << '[' << buffer().B_("margin") << ":\n";
36         InsetText::plaintext(os, runparams, max_length);
37         os << "\n]";
38
39         return PLAINTEXT_NEWLINE + 1; // one char on a separate line
40 }
41
42
43 int InsetMarginal::docbook(odocstream & os,
44                            OutputParams const & runparams) const
45 {
46         os << "<note role=\"margin\">";
47         int const i = InsetText::docbook(os, runparams);
48         os << "</note>";
49
50         return i;
51 }
52
53
54 void InsetMarginal::addToToc(DocIterator const & cpit, bool output_active,
55                                   UpdateType utype) const
56 {
57         DocIterator pit = cpit;
58         pit.push_back(CursorSlice(const_cast<InsetMarginal &>(*this)));
59
60         shared_ptr<Toc> toc = buffer().tocBackend().toc("marginalnote");
61         docstring str;
62         text().forOutliner(str, TOC_ENTRY_LENGTH);
63         toc->push_back(TocItem(pit, 0, str, output_active, toolTipText(docstring(), 3, 60)));
64         // Proceed with the rest of the inset.
65         InsetFootlike::addToToc(cpit, output_active, utype);
66 }
67
68 } // namespace lyx