]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetListings.cpp
Improve handling of top and bottom margin
[lyx.git] / src / insets / InsetListings.cpp
index 2f1462a154a6419063ec5da984c76488be6c1897..848e4ae45a6bfaf2e0e8c5bffd2304e5b1726c11 100644 (file)
@@ -27,6 +27,7 @@
 #include "LaTeXFeatures.h"
 #include "Lexer.h"
 #include "output_latex.h"
+#include "output_docbook.h"
 #include "output_xhtml.h"
 #include "OutputParams.h"
 #include "TextClass.h"
@@ -480,6 +481,45 @@ docstring InsetListings::xhtml(XMLStream & os, OutputParams const & rp) const
 }
 
 
+void InsetListings::docbook(XMLStream & xs, OutputParams const & rp) const
+{
+       InsetLayout const & il = getLayout();
+
+       // Forge the attributes.
+       string attrs;
+       if (!il.docbookattr().empty())
+               attrs += " role=\"" + il.docbookattr() + "\"";
+       string const lang = params().getParamValue("language");
+       if (!lang.empty())
+               attrs += " language=\"" + lang + "\"";
+       xs << xml::StartTag(il.docbooktag(), attrs);
+       xs.startDivision(false);
+
+       // Deal with the caption.
+       docstring caption = getCaptionDocBook(rp);
+       if (!caption.empty()) {
+               xs << xml::StartTag("bridgehead");
+               xs << XMLStream::ESCAPE_NONE;
+               xs << caption;
+               xs << xml::EndTag("bridgehead");
+       }
+
+       // Deal with the content of the listing.
+       OutputParams newrp = rp;
+       newrp.pass_thru = true;
+       newrp.docbook_make_pars = false;
+       newrp.par_begin = 0;
+       newrp.par_end = text().paragraphs().size();
+       newrp.docbook_in_listing = true;
+
+       docbookParagraphs(text(), buffer(), xs, newrp);
+
+       // Done with the listing.
+       xs.endDivision();
+       xs << xml::EndTag(il.docbooktag());
+}
+
+
 string InsetListings::contextMenuName() const
 {
        return "context-listings";