]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetMarginal.cpp
New DocBook support
[lyx.git] / src / insets / InsetMarginal.cpp
index b4e6e8b39e2a3e53c564d3ed18e68c7b4bda940b..54922fced5acec533d95d8d254c0775b7474fb6a 100644 (file)
@@ -10,6 +10,7 @@
  */
 
 #include <config.h>
+#include <output_docbook.h>
 
 #include "InsetMarginal.h"
 
 
 #include "support/docstream.h"
 #include "support/gettext.h"
+#include "support/lstrings.h"
 
 namespace lyx {
 
 
-InsetMarginal::InsetMarginal(Buffer const & buf)
+InsetMarginal::InsetMarginal(Buffer * buf)
        : InsetFootlike(buf)
 {}
 
 
-int InsetMarginal::plaintext(odocstream & os,
-                            OutputParams const & runparams) const
+int InsetMarginal::plaintext(odocstringstream & os,
+                            OutputParams const & runparams, size_t max_length) const
 {
        os << '[' << buffer().B_("margin") << ":\n";
-       InsetText::plaintext(os, runparams);
+       InsetText::plaintext(os, runparams, max_length);
        os << "\n]";
 
        return PLAINTEXT_NEWLINE + 1; // one char on a separate line
 }
 
 
-int InsetMarginal::docbook(odocstream & os,
-                          OutputParams const & runparams) const
+void InsetMarginal::docbook(XMLStream & xs, OutputParams const & runparams) const
 {
-       os << "<note role=\"margin\">";
-       int const i = InsetText::docbook(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");
 }
 
 
-void InsetMarginal::addToToc(DocIterator const & cpit)
-{
-       DocIterator pit = cpit;
-       pit.push_back(CursorSlice(*this));
-
-       Toc & toc = buffer().tocBackend().toc("marginalnote");
-       docstring str;
-       str = getNewLabel(str);
-       toc.push_back(TocItem(pit, 0, str));
-       // Proceed with the rest of the inset.
-       InsetFootlike::addToToc(cpit);
-}
-
 } // namespace lyx