-/* This file is part of
- * ======================================================
- *
- * LyX, The Document Processor
- *
- * Copyright 1998 The LyX Team.
+/**
+ * \file insetfoot.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
*
- *======================================================*/
+ * \author Jürgen Vigna
+ * \author Lars Gullik Bjønnes
+ *
+ * Full author contact details are available in file CREDITS
+ */
#include <config.h>
-#ifdef __GNUG__
-#pragma implementation
-#endif
-
#include "insetfoot.h"
#include "gettext.h"
#include "lyxfont.h"
#include "BufferView.h"
-#include "lyxscreen.h"
-#include "Painter.h"
+#include "latexrunparams.h"
+#include "lyxtext.h"
+#include "insets/insettext.h"
#include "support/LOstream.h"
+#include "debug.h"
+// the following are needed just to get the layout of the enclosing
+// paragraph. This seems a bit too much to me (JMarc)
+#include "lyxlayout.h"
+#include "buffer.h"
+#include "paragraph.h"
-using std::ostream;
-InsetFoot::InsetFoot(Buffer * bf)
- : InsetCollapsable(bf)
-{
- setLabel(_("foot"));
- LyXFont font(LyXFont::ALL_SANE);
- font.decSize();
- font.decSize();
- font.setColor(LColor::footnote);
- setLabelFont(font);
- setAutoCollapse(false);
-}
+using std::ostream;
+using std::auto_ptr;
-Inset * InsetFoot::Clone() const
+InsetFoot::InsetFoot(BufferParams const & bp)
+ : InsetFootlike(bp)
{
- InsetFoot * result = new InsetFoot(buffer);
- result->init(buffer, this);
-
- result->collapsed = collapsed;
- return result;
+ setLabel(_("foot"));
+ setInsetName("Foot");
}
-char const * InsetFoot::EditMessage() const
+InsetFoot::InsetFoot(InsetFoot const & in)
+ : InsetFootlike(in)
{
- return _("Opened Footnote Inset");
+ setLabel(_("foot"));
+ setInsetName("Foot");
}
-int InsetFoot::Latex(ostream & os, signed char fragile, bool fp) const
+auto_ptr<InsetBase> InsetFoot::clone() const
{
- if (fragile)
- os << "\\footnote{"; // was footnotemark but that won't work
- else
- os << "\\footnote{";
-
- int i = InsetText::Latex(os, fragile, fp);
- os << "}";
-
- return i;
+ return auto_ptr<InsetBase>(new InsetFoot(*this));
}
-void InsetFoot::Write(ostream & os) const
+string const InsetFoot::editMessage() const
{
- os << "Foot\n"
- << "\ncollapsed ";
- if (display())
- os << "false\n";
- else
- os << "true\n";
- WriteParagraphData(os);
+ return _("Opened Footnote Inset");
}
-void InsetFoot::Read(LyXLex & lex)
+int InsetFoot::latex(Buffer const * buf, ostream & os,
+ LatexRunParams const & runparams_in) const
{
- if (lex.IsOK()) {
- lex.next();
- string token = lex.GetString();
- if (token == "collapsed") {
- lex.next();
- collapsed = lex.GetBool();
+ LatexRunParams runparams = runparams_in;
+ if (buf && parOwner()) {
+ LyXLayout_ptr const & layout = parOwner()->layout();
+ runparams.moving_arg |= layout->intitle;
}
- }
- InsetText::Read(lex);
-}
+ os << "%\n\\footnote{";
-bool InsetFoot::InsertInset(BufferView * bv, Inset * inset)
-{
- if (!InsertInsetAllowed(inset))
- return false;
+ int const i = inset.latex(buf, os, runparams);
+ os << "%\n}";
- return InsetText::InsertInset(bv, inset);
+ return i + 2;
}
-bool InsetFoot::InsertInsetAllowed(Inset * inset) const
-{
- if ((inset->LyxCode() == Inset::FOOT_CODE) ||
- (inset->LyxCode() == Inset::MARGIN_CODE)) {
- return false;
- }
- return true;
-}
-LyXFont InsetFoot::GetDrawFont(LyXParagraph * par, int pos) const
+int InsetFoot::docbook(Buffer const * buf, ostream & os, bool mixcont) const
{
- LyXFont fn = InsetCollapsable::GetDrawFont(par, pos);
- fn.decSize();
- fn.decSize();
- return fn;
+ os << "<footnote>";
+ int const i = inset.docbook(buf, os, mixcont);
+ os << "</footnote>";
+
+ return i;
}