2 * \file InsetMarginal.cpp
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
7 * \author Lars Gullik Bjønnes
9 * Full author contact details are available in file CREDITS.
14 #include "InsetMarginal.h"
17 #include "BufferParams.h"
18 #include "OutputParams.h"
19 #include "TocBackend.h"
21 #include "support/docstream.h"
22 #include "support/gettext.h"
30 InsetMarginal::InsetMarginal(Buffer const & buf)
35 docstring InsetMarginal::editMessage() const
37 return _("Opened Marginal Note Inset");
41 docstring InsetMarginal::toolTip(BufferView const & bv, int x, int y) const
43 docstring default_tip = InsetCollapsable::toolTip(bv, x, y);
44 OutputParams rp(&buffer().params().encoding());
46 InsetText::plaintext(ods, rp);
47 docstring margin_tip = ods.str();
48 // shorten it if necessary
49 if (margin_tip.size() > 200)
50 margin_tip = margin_tip.substr(0, 200) + "...";
51 if (!isOpen() && !margin_tip.empty())
52 return margin_tip + '\n' + default_tip;
57 int InsetMarginal::latex(odocstream & os, OutputParams const & runparams) const
59 os << "%\n\\marginpar{";
60 int const i = InsetText::latex(os, runparams);
66 int InsetMarginal::plaintext(odocstream & os,
67 OutputParams const & runparams) const
69 os << '[' << buffer().B_("margin") << ":\n";
70 InsetText::plaintext(os, runparams);
73 return PLAINTEXT_NEWLINE + 1; // one char on a separate line
77 int InsetMarginal::docbook(odocstream & os,
78 OutputParams const & runparams) const
80 os << "<note role=\"margin\">";
81 int const i = InsetText::docbook(os, runparams);
88 void InsetMarginal::addToToc(ParConstIterator const & cpit) const
90 ParConstIterator pit = cpit;
93 Toc & toc = buffer().tocBackend().toc("marginalnote");
95 str = getNewLabel(str);
96 toc.push_back(TocItem(pit, 0, str));