2002-09-25 14:26:13 +00:00
|
|
|
|
/**
|
2007-04-25 01:24:38 +00:00
|
|
|
|
* \file InsetFoot.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-03-08 13:52:57 +00:00
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
2007-04-25 01:24:38 +00:00
|
|
|
|
#include "InsetFoot.h"
|
2003-09-05 09:01:27 +00:00
|
|
|
|
|
2007-05-01 08:26:40 +00:00
|
|
|
|
#include "Buffer.h"
|
2007-08-13 20:29:33 +00:00
|
|
|
|
#include "BufferParams.h"
|
|
|
|
|
#include "Counters.h"
|
2007-11-29 07:04:28 +00:00
|
|
|
|
#include "support/gettext.h"
|
2007-09-29 20:02:32 +00:00
|
|
|
|
#include "Layout.h"
|
|
|
|
|
// FIXME: the following is needed just to get the layout of the enclosing
|
2002-05-14 14:22:11 +00:00
|
|
|
|
// paragraph. This seems a bit too much to me (JMarc)
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "OutputParams.h"
|
2007-08-13 20:29:33 +00:00
|
|
|
|
#include "ParIterator.h"
|
2007-11-07 23:25:08 +00:00
|
|
|
|
#include "TextClass.h"
|
2008-02-11 13:06:01 +00:00
|
|
|
|
#include "TocBackend.h"
|
2000-03-08 13:52:57 +00:00
|
|
|
|
|
2008-02-18 07:14:42 +00:00
|
|
|
|
#include "support/debug.h"
|
2008-04-10 10:05:00 +00:00
|
|
|
|
#include "support/docstream.h"
|
2007-08-13 20:29:33 +00:00
|
|
|
|
#include "support/lstrings.h"
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
2007-11-06 21:45:24 +00:00
|
|
|
|
#include <ostream>
|
|
|
|
|
|
2007-12-12 10:16:00 +00:00
|
|
|
|
using namespace std;
|
2003-10-06 15:43:21 +00:00
|
|
|
|
|
2007-12-12 10:16:00 +00:00
|
|
|
|
namespace lyx {
|
2002-02-16 15:59:55 +00:00
|
|
|
|
|
|
|
|
|
|
2008-03-04 22:28:18 +00:00
|
|
|
|
InsetFoot::InsetFoot(Buffer const & buf)
|
|
|
|
|
: InsetFootlike(buf)
|
2007-11-02 17:47:51 +00:00
|
|
|
|
{}
|
2000-03-08 13:52:57 +00:00
|
|
|
|
|
|
|
|
|
|
2008-02-27 20:43:16 +00:00
|
|
|
|
docstring InsetFoot::editMessage() const
|
2000-03-08 13:52:57 +00:00
|
|
|
|
{
|
2006-09-09 18:52:00 +00:00
|
|
|
|
return _("Opened Footnote Inset");
|
2000-03-08 13:52:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-02-27 20:43:16 +00:00
|
|
|
|
void InsetFoot::updateLabels(ParIterator const & it)
|
2007-08-13 20:29:33 +00:00
|
|
|
|
{
|
2008-02-28 01:42:02 +00:00
|
|
|
|
DocumentClass const & tclass = buffer().params().documentClass();
|
2007-08-13 20:29:33 +00:00
|
|
|
|
Counters & cnts = tclass.counters();
|
2008-02-15 09:41:53 +00:00
|
|
|
|
docstring const foot = from_ascii("footnote");
|
2007-08-13 20:29:33 +00:00
|
|
|
|
Paragraph const & outer = it.paragraph();
|
2008-03-06 21:31:27 +00:00
|
|
|
|
if (!outer.layout().intitle && cnts.hasCounter(foot)) {
|
2007-08-13 20:29:33 +00:00
|
|
|
|
cnts.step(foot);
|
2008-02-27 20:43:16 +00:00
|
|
|
|
// FIXME: the counter should format itself.
|
2008-04-10 10:05:00 +00:00
|
|
|
|
custom_label_= support::bformat(from_ascii("%1$s %2$s"),
|
|
|
|
|
getLayout(buffer().params()).labelstring(),
|
|
|
|
|
cnts.theCounter(foot));
|
|
|
|
|
setLabel(custom_label_);
|
2007-08-13 20:29:33 +00:00
|
|
|
|
|
|
|
|
|
}
|
2008-02-27 20:43:16 +00:00
|
|
|
|
InsetCollapsable::updateLabels(it);
|
2007-08-13 20:29:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-08-30 18:03:17 +00:00
|
|
|
|
|
2008-02-27 20:43:16 +00:00
|
|
|
|
void InsetFoot::addToToc(ParConstIterator const & cpit) const
|
2008-02-11 13:06:01 +00:00
|
|
|
|
{
|
2008-02-15 08:39:58 +00:00
|
|
|
|
ParConstIterator pit = cpit;
|
|
|
|
|
pit.push_back(*this);
|
2008-02-11 13:06:01 +00:00
|
|
|
|
|
2008-02-27 20:43:16 +00:00
|
|
|
|
Toc & toc = buffer().tocBackend().toc("footnote");
|
2008-02-11 13:06:01 +00:00
|
|
|
|
// FIXME: we probably want the footnote number too.
|
|
|
|
|
docstring str;
|
2008-04-10 10:05:00 +00:00
|
|
|
|
str = custom_label_ + ": " + getNewLabel(str);
|
2008-02-11 13:06:01 +00:00
|
|
|
|
toc.push_back(TocItem(pit, 0, str));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-04-10 10:05:00 +00:00
|
|
|
|
docstring InsetFoot::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 foot_tip = custom_label_ + ": " + ods.str();
|
|
|
|
|
// shorten it if necessary
|
|
|
|
|
if (foot_tip.size() > 200)
|
|
|
|
|
foot_tip = foot_tip.substr(0, 200) + "...";
|
|
|
|
|
if (!isOpen() && !foot_tip.empty())
|
|
|
|
|
return foot_tip + '\n' + default_tip;
|
|
|
|
|
return default_tip;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-02-27 20:43:16 +00:00
|
|
|
|
int InsetFoot::latex(odocstream & os, OutputParams const & runparams_in) const
|
2000-03-08 13:52:57 +00:00
|
|
|
|
{
|
2003-11-05 12:06:20 +00:00
|
|
|
|
OutputParams runparams = runparams_in;
|
2004-08-05 09:18:54 +00:00
|
|
|
|
// footnotes in titling commands like \title have moving arguments
|
|
|
|
|
runparams.moving_arg |= runparams_in.intitle;
|
2004-10-26 21:16:44 +00:00
|
|
|
|
|
2004-10-25 09:11:12 +00:00
|
|
|
|
// in titling commands, \thanks should be used instead of \footnote.
|
|
|
|
|
// some classes (e.g. memoir) do not understand \footnote.
|
|
|
|
|
if (runparams_in.intitle)
|
|
|
|
|
os << "%\n\\thanks{";
|
|
|
|
|
else
|
|
|
|
|
os << "%\n\\footnote{";
|
2002-03-21 17:09:55 +00:00
|
|
|
|
|
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}";
|
2007-03-18 10:59:16 +00:00
|
|
|
|
runparams_in.encoding = runparams.encoding;
|
2002-03-21 17:09:55 +00:00
|
|
|
|
|
2001-04-02 14:02:58 +00:00
|
|
|
|
return i + 2;
|
2000-03-08 13:52:57 +00:00
|
|
|
|
}
|
2002-04-03 17:44:05 +00:00
|
|
|
|
|
|
|
|
|
|
2008-02-27 20:43:16 +00:00
|
|
|
|
int InsetFoot::plaintext(odocstream & os, OutputParams const & runparams) const
|
2007-02-15 16:07:36 +00:00
|
|
|
|
{
|
2008-02-27 20:43:16 +00:00
|
|
|
|
os << '[' << buffer().B_("footnote") << ":\n";
|
|
|
|
|
InsetText::plaintext(os, runparams);
|
2007-02-15 16:07:36 +00:00
|
|
|
|
os << "\n]";
|
|
|
|
|
|
2007-02-20 17:52:41 +00:00
|
|
|
|
return PLAINTEXT_NEWLINE + 1; // one char on a separate line
|
2007-02-15 16:07:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-02-27 20:43:16 +00:00
|
|
|
|
int InsetFoot::docbook(odocstream & os, OutputParams const & runparams) const
|
2002-04-03 17:44:05 +00:00
|
|
|
|
{
|
|
|
|
|
os << "<footnote>";
|
2008-02-27 20:43:16 +00:00
|
|
|
|
int const i = InsetText::docbook(os, runparams);
|
2002-04-03 17:44:05 +00:00
|
|
|
|
os << "</footnote>";
|
|
|
|
|
|
|
|
|
|
return i;
|
|
|
|
|
}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace lyx
|