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
|
|
|
*
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author Jürgen Vigna
|
|
|
|
* \author Lars Gullik Bjø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"
|
2009-07-12 20:09:53 +00:00
|
|
|
#include "Language.h"
|
2017-11-19 07:57:58 +00:00
|
|
|
#include "LaTeXFeatures.h"
|
2007-09-29 20:02:32 +00:00
|
|
|
#include "Layout.h"
|
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"
|
2008-06-18 18:54:31 +00:00
|
|
|
#include "support/gettext.h"
|
2015-11-26 20:21:21 +00:00
|
|
|
#include "support/lstrings.h"
|
2006-10-21 00:16:43 +00:00
|
|
|
|
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
|
|
|
|
2009-11-08 15:53:21 +00:00
|
|
|
InsetFoot::InsetFoot(Buffer * buf)
|
2014-11-14 13:53:11 +00:00
|
|
|
: InsetFootlike(buf), intitle_(false)
|
2007-11-02 17:47:51 +00:00
|
|
|
{}
|
2000-03-08 13:52:57 +00:00
|
|
|
|
|
|
|
|
2014-11-14 13:53:11 +00:00
|
|
|
docstring InsetFoot::layoutName() const
|
|
|
|
{
|
|
|
|
return intitle_ ? from_ascii("Foot:InTitle") : from_ascii("Foot");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-03-03 22:13:45 +00:00
|
|
|
void InsetFoot::updateBuffer(ParIterator const & it, UpdateType utype)
|
2007-08-13 20:29:33 +00:00
|
|
|
{
|
2009-07-12 20:09:53 +00:00
|
|
|
BufferParams const & bp = buffer().masterBuffer()->params();
|
|
|
|
Counters & cnts = bp.documentClass().counters();
|
2010-01-20 19:42:12 +00:00
|
|
|
if (utype == OutputUpdate) {
|
2010-01-20 19:03:17 +00:00
|
|
|
// the footnote counter is local to this inset
|
|
|
|
cnts.saveLastCounter();
|
|
|
|
}
|
2014-11-14 13:53:11 +00:00
|
|
|
|
|
|
|
intitle_ = false;
|
|
|
|
for (size_type sl = 0 ; sl < it.depth() ; ++ sl) {
|
|
|
|
if (it[sl].text() && it[sl].paragraph().layout().intitle) {
|
|
|
|
intitle_ = true;
|
|
|
|
break;
|
|
|
|
}
|
2007-08-13 20:29:33 +00:00
|
|
|
}
|
2014-11-14 13:53:11 +00:00
|
|
|
|
|
|
|
Language const * lang = it.paragraph().getParLanguage(bp);
|
|
|
|
InsetLayout const & il = getLayout();
|
|
|
|
docstring const & count = il.counter();
|
|
|
|
custom_label_ = translateIfPossible(il.labelstring());
|
|
|
|
if (cnts.hasCounter(count))
|
|
|
|
cnts.step(count, utype);
|
|
|
|
custom_label_ += ' ' + cnts.theCounter(count, lang->code());
|
|
|
|
setLabel(custom_label_);
|
|
|
|
|
2017-10-16 08:12:21 +00:00
|
|
|
InsetCollapsible::updateBuffer(it, utype);
|
2010-01-20 19:42:12 +00:00
|
|
|
if (utype == OutputUpdate)
|
2014-11-14 13:53:11 +00:00
|
|
|
cnts.restoreLastCounter();
|
2007-08-13 20:29:33 +00:00
|
|
|
}
|
|
|
|
|
2007-08-30 18:03:17 +00:00
|
|
|
|
2008-04-10 10:05:00 +00:00
|
|
|
docstring InsetFoot::toolTip(BufferView const & bv, int x, int y) const
|
|
|
|
{
|
2010-11-17 17:25:22 +00:00
|
|
|
if (isOpen(bv))
|
|
|
|
// this will give us something useful if there is no button
|
2017-10-16 08:12:21 +00:00
|
|
|
return InsetCollapsible::toolTip(bv, x, y);
|
2013-11-26 15:08:35 +00:00
|
|
|
return toolTipText(custom_label_+ ": ");
|
2008-04-10 10:05:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-03-08 19:52:18 +00:00
|
|
|
int InsetFoot::plaintext(odocstringstream & os,
|
|
|
|
OutputParams const & runparams, size_t max_length) const
|
2007-02-15 16:07:36 +00:00
|
|
|
{
|
2008-02-27 20:43:16 +00:00
|
|
|
os << '[' << buffer().B_("footnote") << ":\n";
|
2013-03-08 19:52:18 +00:00
|
|
|
InsetText::plaintext(os, runparams, max_length);
|
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
|
|
|
|
2017-11-19 07:57:58 +00:00
|
|
|
|
|
|
|
void InsetFoot::validate(LaTeXFeatures & features) const
|
|
|
|
{
|
|
|
|
if (!features.saveNoteEnv().empty()) {
|
|
|
|
features.require("footnote");
|
|
|
|
features.addPreambleSnippet(
|
|
|
|
from_ascii("\\makesavenoteenv{"
|
|
|
|
+ features.saveNoteEnv()
|
|
|
|
+ "}\n"));
|
|
|
|
}
|
|
|
|
|
|
|
|
InsetText::validate(features);
|
|
|
|
}
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
} // namespace lyx
|