2002-09-25 14:26:13 +00:00
|
|
|
|
/**
|
2007-04-25 01:24:38 +00:00
|
|
|
|
* \file InsetMarginal.cpp
|
2002-09-25 14:26:13 +00:00
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-03-21 17:09:55 +00:00
|
|
|
|
*
|
2002-09-25 14:26:13 +00:00
|
|
|
|
* \author J<EFBFBD>rgen Vigna
|
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
2002-03-21 17:09:55 +00:00
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* Full author contact details are available in file CREDITS.
|
2000-06-28 16:03:01 +00:00
|
|
|
|
*/
|
2000-06-26 18:48:45 +00:00
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
2007-04-25 01:24:38 +00:00
|
|
|
|
#include "InsetMarginal.h"
|
2003-09-05 09:01:27 +00:00
|
|
|
|
|
2007-05-01 08:26:40 +00:00
|
|
|
|
#include "Buffer.h"
|
2008-04-10 10:05:00 +00:00
|
|
|
|
#include "BufferParams.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "OutputParams.h"
|
2008-02-13 13:33:56 +00:00
|
|
|
|
#include "TocBackend.h"
|
|
|
|
|
|
2008-04-10 10:05:00 +00:00
|
|
|
|
#include "support/docstream.h"
|
2008-02-13 13:33:56 +00:00
|
|
|
|
#include "support/gettext.h"
|
2000-06-26 18:48:45 +00:00
|
|
|
|
|
2007-11-06 21:45:24 +00:00
|
|
|
|
#include <ostream>
|
2000-06-26 18:48:45 +00:00
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
namespace lyx {
|
2003-10-06 15:43:21 +00:00
|
|
|
|
|
2002-02-16 15:59:55 +00:00
|
|
|
|
|
2008-03-04 22:28:18 +00:00
|
|
|
|
InsetMarginal::InsetMarginal(Buffer const & buf)
|
|
|
|
|
: InsetFootlike(buf)
|
2007-11-02 17:47:51 +00:00
|
|
|
|
{}
|
2000-06-28 13:35:52 +00:00
|
|
|
|
|
|
|
|
|
|
2008-02-27 20:43:16 +00:00
|
|
|
|
docstring InsetMarginal::editMessage() const
|
2000-06-26 18:48:45 +00:00
|
|
|
|
{
|
2006-09-09 18:52:00 +00:00
|
|
|
|
return _("Opened Marginal Note Inset");
|
2000-06-26 18:48:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-04-10 10:05:00 +00:00
|
|
|
|
docstring InsetMarginal::toolTip(BufferView const & bv, int x, int y) const
|
|
|
|
|
{
|
|
|
|
|
docstring default_tip = InsetCollapsable::toolTip(bv, x, y);
|
|
|
|
|
OutputParams rp(&buffer().params().encoding());
|
|
|
|
|
odocstringstream ods;
|
|
|
|
|
InsetText::plaintext(ods, rp);
|
|
|
|
|
docstring margin_tip = ods.str();
|
|
|
|
|
// shorten it if necessary
|
|
|
|
|
if (margin_tip.size() > 200)
|
|
|
|
|
margin_tip = margin_tip.substr(0, 200) + "...";
|
|
|
|
|
if (!isOpen() && !margin_tip.empty())
|
|
|
|
|
return margin_tip + '\n' + default_tip;
|
|
|
|
|
return default_tip;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-02-27 20:43:16 +00:00
|
|
|
|
int InsetMarginal::latex(odocstream & os, OutputParams const & runparams) const
|
2000-06-26 18:48:45 +00:00
|
|
|
|
{
|
2001-06-29 14:01:29 +00:00
|
|
|
|
os << "%\n\\marginpar{";
|
2008-02-27 20:43:16 +00:00
|
|
|
|
int const i = InsetText::latex(os, runparams);
|
2001-06-29 14:01:29 +00:00
|
|
|
|
os << "%\n}";
|
2000-07-15 23:51:46 +00:00
|
|
|
|
return i + 2;
|
2000-06-26 18:48:45 +00:00
|
|
|
|
}
|
2005-02-28 13:14:48 +00:00
|
|
|
|
|
2007-02-16 08:15:16 +00:00
|
|
|
|
|
2008-02-27 20:43:16 +00:00
|
|
|
|
int InsetMarginal::plaintext(odocstream & os,
|
2007-05-28 22:27:45 +00:00
|
|
|
|
OutputParams const & runparams) const
|
2007-02-16 08:15:16 +00:00
|
|
|
|
{
|
2008-02-27 20:43:16 +00:00
|
|
|
|
os << '[' << buffer().B_("margin") << ":\n";
|
|
|
|
|
InsetText::plaintext(os, runparams);
|
2007-02-16 08:15:16 +00:00
|
|
|
|
os << "\n]";
|
|
|
|
|
|
2007-02-20 17:52:41 +00:00
|
|
|
|
return PLAINTEXT_NEWLINE + 1; // one char on a separate line
|
2007-02-16 08:15:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-02-27 20:43:16 +00:00
|
|
|
|
int InsetMarginal::docbook(odocstream & os,
|
2007-05-28 22:27:45 +00:00
|
|
|
|
OutputParams const & runparams) const
|
2005-02-28 13:14:48 +00:00
|
|
|
|
{
|
|
|
|
|
os << "<note role=\"margin\">";
|
2008-02-27 20:43:16 +00:00
|
|
|
|
int const i = InsetText::docbook(os, runparams);
|
2005-02-28 13:14:48 +00:00
|
|
|
|
os << "</note>";
|
|
|
|
|
|
|
|
|
|
return i;
|
|
|
|
|
}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
2008-02-27 20:43:16 +00:00
|
|
|
|
void InsetMarginal::addToToc(ParConstIterator const & cpit) const
|
2008-02-13 13:33:56 +00:00
|
|
|
|
{
|
2008-02-15 08:39:58 +00:00
|
|
|
|
ParConstIterator pit = cpit;
|
|
|
|
|
pit.push_back(*this);
|
2008-02-13 13:33:56 +00:00
|
|
|
|
|
2008-02-27 20:43:16 +00:00
|
|
|
|
Toc & toc = buffer().tocBackend().toc("marginalnote");
|
2008-02-13 13:33:56 +00:00
|
|
|
|
docstring str;
|
|
|
|
|
str = getNewLabel(str);
|
|
|
|
|
toc.push_back(TocItem(pit, 0, str));
|
|
|
|
|
}
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
} // namespace lyx
|