-/* This file is part of
- * ======================================================
- *
- * LyX, The Document Processor
- *
- * Copyright (C) 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"
-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)
{
- Inset * result = new InsetFoot(buffer);
- return result;
+ setLabel(_("foot"));
+ setInsetName("Foot");
}
-const char * InsetFoot::EditMessage() const
+InsetFoot::InsetFoot(InsetFoot const & in)
+ : InsetFootlike(in)
{
- return _("Opened Footnote Inset");
+ setLabel(_("foot"));
+ setInsetName("Foot");
}
-#ifndef USE_OSTREAM_ONLY
-int InsetFoot::Latex(string & l, signed char fragile) const
+
+auto_ptr<InsetBase> InsetFoot::clone() const
{
- int i;
-
- if (fragile)
- l += "\\footnotetext{";
- else
- l += "\\footnote{";
+ return auto_ptr<InsetBase>(new InsetFoot(*this));
+}
- i = InsetText::Latex(l, fragile);
- l += "}";
- return i;
+string const InsetFoot::editMessage() const
+{
+ return _("Opened Footnote Inset");
}
-#endif
-int InsetFoot::Latex(ostream & os, signed char fragile, bool fp) const
+
+int InsetFoot::latex(Buffer const * buf, ostream & os,
+ LatexRunParams const & runparams_in) const
{
- int i;
-
- if (fragile)
- os << "\\footnotetext{";
- else
- os << "\\footnote{";
+ LatexRunParams runparams = runparams_in;
+ if (buf && parOwner()) {
+ LyXLayout_ptr const & layout = parOwner()->layout();
+ runparams.moving_arg |= layout->intitle;
+ }
- i = InsetText::Latex(os, fragile, fp);
- os << "}";
+ os << "%\n\\footnote{";
- return i;
-}
+ int const i = inset.latex(buf, os, runparams);
+ os << "%\n}";
-void InsetFoot::Write(ostream & os) const
-{
- os << "Foot\n";
- os << "\ncollapsed ";
- if (display())
- os << "false";
- else
- os << "true";
- os << "\n";
- WriteParagraphData(os);
+ return i + 2;
}
-void InsetFoot::Read(LyXLex & lex)
-{
- if (lex.IsOK()) {
- string token, tmptok;
-
- lex.next();
- token = lex.GetString();
- if (token == "collapsed") {
- lex.next();
- collapsed = lex.GetBool();
- }
- }
- InsetText::Read(lex);
-}
-bool InsetFoot::InsertInset(BufferView *bv, Inset * inset)
+int InsetFoot::docbook(Buffer const * buf, ostream & os, bool mixcont) const
{
- if ((inset->LyxCode() == Inset::FOOT_CODE) ||
- (inset->LyxCode() == Inset::MARGIN_CODE)) {
- return false;
- }
- return InsetText::InsertInset(bv, inset);
+ os << "<footnote>";
+ int const i = inset.docbook(buf, os, mixcont);
+ os << "</footnote>";
+
+ return i;
}