]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetMarginal.cpp
New DocBook support
[lyx.git] / src / insets / InsetMarginal.cpp
index 27e9a0a1a06c48cc85d31d35402786320255ab47..54922fced5acec533d95d8d254c0775b7474fb6a 100644 (file)
@@ -3,83 +3,54 @@
  * 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
+ * \author Jürgen Vigna
+ * \author Lars Gullik Bjønnes
  *
  * Full author contact details are available in file CREDITS.
  */
 
 #include <config.h>
+#include <output_docbook.h>
 
 #include "InsetMarginal.h"
 
 #include "Buffer.h"
-#include "gettext.h"
+#include "BufferParams.h"
 #include "OutputParams.h"
+#include "TocBackend.h"
 
-#include "support/std_ostream.h"
-
+#include "support/docstream.h"
+#include "support/gettext.h"
+#include "support/lstrings.h"
 
 namespace lyx {
 
-using std::string;
-using std::auto_ptr;
-using std::ostream;
-
-
-InsetMarginal::InsetMarginal(BufferParams const & bp)
-       : InsetFootlike(bp)
-{
-       setLayout(bp);
-}
-
 
-InsetMarginal::InsetMarginal(InsetMarginal const & in)
-       : InsetFootlike(in)
+InsetMarginal::InsetMarginal(Buffer * buf)
+       : InsetFootlike(buf)
 {}
 
 
-auto_ptr<Inset> InsetMarginal::doClone() const
-{
-       return auto_ptr<Inset>(new InsetMarginal(*this));
-}
-
-
-docstring const InsetMarginal::editMessage() const
+int InsetMarginal::plaintext(odocstringstream & os,
+                            OutputParams const & runparams, size_t max_length) const
 {
-       return _("Opened Marginal Note Inset");
-}
-
-
-int InsetMarginal::latex(Buffer const & buf, odocstream & os,
-                        OutputParams const & runparams) const
-{
-       os << "%\n\\marginpar{";
-       int const i = InsetText::latex(buf, os, runparams);
-       os << "%\n}";
-       return i + 2;
-}
-
-
-int InsetMarginal::plaintext(Buffer const & buf, odocstream & os,
-                            OutputParams const & runparams) const
-{
-       os << '[' << buf.B_("margin") << ":\n";
-       InsetText::plaintext(buf, os, runparams);
+       os << '[' << buffer().B_("margin") << ":\n";
+       InsetText::plaintext(os, runparams, max_length);
        os << "\n]";
 
        return PLAINTEXT_NEWLINE + 1; // one char on a separate line
 }
 
 
-int InsetMarginal::docbook(Buffer const & buf, odocstream & os,
-                          OutputParams const & runparams) const
+void InsetMarginal::docbook(XMLStream & xs, OutputParams const & runparams) const
 {
-       os << "<note role=\"margin\">";
-       int const i = InsetText::docbook(buf, os, runparams);
-       os << "</note>";
-
-       return i;
+       // Implementation as per http://www.sagehill.net/docbookxsl/SideFloats.html
+       // Unfortunately, only for XSL-FO output with the default style sheets, hence the role.
+       xs << xml::StartTag("sidebar", "role=\"margin\"");
+       xs << xml::CR();
+       xs << "<?dbfo float-type=\"margin.note\"?>";
+       InsetText::docbook(xs, runparams);
+       xs << xml::EndTag("sidebar");
 }