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"
|
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"
|
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)
|
2008-03-04 22:28:18 +00:00
|
|
|
: InsetFootlike(buf)
|
2007-11-02 17:47:51 +00:00
|
|
|
{}
|
2000-03-08 13:52:57 +00:00
|
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
2009-08-10 12:51:27 +00:00
|
|
|
Paragraph const & outer = it.paragraph();
|
2010-11-29 19:11:38 +00:00
|
|
|
if (!outer.layout().intitle) {
|
|
|
|
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, outer.getParLanguage(bp)->code());
|
|
|
|
setLabel(custom_label_);
|
2007-08-13 20:29:33 +00:00
|
|
|
}
|
2010-03-03 22:13:45 +00:00
|
|
|
InsetCollapsable::updateBuffer(it, utype);
|
2010-01-20 19:42:12 +00:00
|
|
|
if (utype == OutputUpdate)
|
2010-01-20 19:03:17 +00:00
|
|
|
cnts.restoreLastCounter();
|
2007-08-13 20:29:33 +00:00
|
|
|
}
|
|
|
|
|
2007-08-30 18:03:17 +00:00
|
|
|
|
2011-01-12 22:23:27 +00:00
|
|
|
void InsetFoot::addToToc(DocIterator const & cpit) const
|
2008-02-11 13:06:01 +00:00
|
|
|
{
|
2008-05-13 08:23:44 +00:00
|
|
|
DocIterator pit = cpit;
|
2011-01-12 22:23:27 +00:00
|
|
|
pit.push_back(CursorSlice(const_cast<InsetFoot &>(*this)));
|
2008-02-11 13:06:01 +00:00
|
|
|
|
2008-02-27 20:43:16 +00:00
|
|
|
Toc & toc = buffer().tocBackend().toc("footnote");
|
2010-12-20 21:55:09 +00:00
|
|
|
docstring str = custom_label_ + ": ";
|
|
|
|
text().forToc(str, TOC_ENTRY_LENGTH);
|
2010-12-22 01:29:17 +00:00
|
|
|
toc.push_back(TocItem(pit, 0, str, toolTipText(docstring(), 3, 60)));
|
2008-06-03 11:33:13 +00:00
|
|
|
// Proceed with the rest of the inset.
|
|
|
|
InsetFootlike::addToToc(cpit);
|
2008-02-11 13:06:01 +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
|
|
|
|
return InsetCollapsable::toolTip(bv, x, y);
|
|
|
|
return toolTipText(custom_label_);
|
2008-04-10 10:05:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
Introduce a wrapper class for odocstream to help ensuring that no
blank lines may be inadvertently output. This is achieved by using two
special iomanip-like variables (breakln and safebreakln) in the lyx::
namespace. When they are inserted in the stream, a newline is output
only if not already at the beginning of a line. The difference between
breakln and safebreakln is that, if needed, the former outputs '\n'
and the latter "%\n".
In future, the new class will also be used for counting the number of
newlines issued. Even if the infractrure for doing that is already in
place, the counting is essentially still done the old way.
There are still places in the code where the functionality of the
class could be used, most probably. ATM, it is used for InsetTabular,
InsetListings, InsetFloat, and InsetText.
The Comment and GreyedOut insets required a special treatment and a
new InsetLayout parameter (Display) has been introduced. The default
for Display is "true", meaning that the corresponding latex
environment is of "display" type, i.e., it stands on its own, whereas
"false" means that the contents appear inline with the text. The
latter is the case for both Comment and GreyedOut insets.
Mostly, the only visible effects on latex exports should be the
disappearing of some redundant % chars and the appearing/disappearing
of null {} latex groups after a comment or lyxgreyedout environments
(they are related to the presence or absence of a space immediately
after those environments), as well as the fact that math environments
are now started on their own lines.
As a last thing, only the latex code between \begin{document} and
\end{document} goes through the new class, the preamble being directly
output through odocstream, as usual.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37360 a592a061-630c-0410-9148-cb99ea01b6c8
2011-01-29 02:41:13 +00:00
|
|
|
int InsetFoot::latex(otexstream & 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
|