From d49b60b2581a9dfd390d6aaccf5a13658489bd0d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Matox?= Date: Thu, 21 Oct 2004 22:55:04 +0000 Subject: [PATCH] Improve graphics export for docbook. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9101 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/ChangeLog | 5 ++ src/buffer.C | 7 +++ src/insets/ChangeLog | 5 ++ src/insets/insetgraphics.C | 100 ++++++++++++++++++++++++------------- 4 files changed, 83 insertions(+), 34 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 1291f118ee..caa962d769 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2004-10-18 Andreas Vox + + * buffer.C (makeDocBookFile): add dsssl stylesheet control + entities to preamble. + 2004-10-18 Georg Baum * messages.C (Pimpl): strip off translation context information diff --git a/src/buffer.C b/src/buffer.C index 00fe5ef600..999b1dd041 100644 --- a/src/buffer.C +++ b/src/buffer.C @@ -1089,6 +1089,13 @@ void Buffer::makeDocBookFile(string const & fname, ofs << " PUBLIC \"-//OASIS//DTD DocBook V4.2//EN\""; string preamble = params().preamble; + if (runparams.flavor != OutputParams::XML ) { + preamble += "\n"; + preamble += "\n"; + preamble += "\n"; + preamble += "\n"; + } + string const name = runparams.nice ? ChangeExtension(pimpl_->filename, ".sgml") : fname; preamble += features.getIncludedFiles(name); diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index 37c93c9ac1..9d6381e305 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,8 @@ +2004-10-18 Andreas Vox + + * insetgraphics.C (docbook, writeImageObject): write more than one + format of imageobjects in . + 2004-10-17 Andreas Vox * insetcite.[hC] (docbook, latex, cleanupWhitespace): implementing diff --git a/src/insets/insetgraphics.C b/src/insets/insetgraphics.C index 57a7988ef1..1d0de8708c 100644 --- a/src/insets/insetgraphics.C +++ b/src/insets/insetgraphics.C @@ -295,22 +295,22 @@ string const InsetGraphics::createLatexOptions() const // before writing it to the output stream. ostringstream options; if (!params().bb.empty()) - options << " bb=" << rtrim(params().bb) << ",\n"; + options << " bb=" << rtrim(params().bb) << ",\n"; if (params().draft) - options << " draft,\n"; + options << " draft,\n"; if (params().clip) - options << " clip,\n"; + options << " clip,\n"; if (!float_equal(params().scale, 0.0, 0.05)) { if (!float_equal(params().scale, 100.0, 0.05)) - options << " scale=" << params().scale / 100.0 + options << " scale=" << params().scale / 100.0 << ",\n"; } else { if (!params().width.zero()) - options << " width=" << params().width.asLatexString() << ",\n"; + options << " width=" << params().width.asLatexString() << ",\n"; if (!params().height.zero()) - options << " height=" << params().height.asLatexString() << ",\n"; + options << " height=" << params().height.asLatexString() << ",\n"; if (params().keepAspectRatio) - options << " keepaspectratio,\n"; + options << " keepaspectratio,\n"; } // Make sure rotation angle is not very close to zero; @@ -341,50 +341,50 @@ string const InsetGraphics::createLatexOptions() const string const InsetGraphics::toDocbookLength(LyXLength const & len) const { ostringstream result; - switch (len.unit() ) { - case LyXLength::SP: //< Scaled point (65536sp = 1pt) TeX's smallest unit. + switch (len.unit()) { + case LyXLength::SP: // Scaled point (65536sp = 1pt) TeX's smallest unit. result << len.value() * 65536.0 * 72 / 72.27 << "pt"; break; - case LyXLength::PT: //< Point = 1/72.27in = 0.351mm + case LyXLength::PT: // Point = 1/72.27in = 0.351mm result << len.value() * 72 / 72.27 << "pt"; break; - case LyXLength::BP: //< Big point (72bp = 1in), also PostScript point + case LyXLength::BP: // Big point (72bp = 1in), also PostScript point result << len.value() << "pt"; break; - case LyXLength::DD: //< Didot point = 1/72 of a French inch, = 0.376mm + case LyXLength::DD: // Didot point = 1/72 of a French inch, = 0.376mm result << len.value() * 0.376 << "mm"; break; - case LyXLength::MM: //< Millimeter = 2.845pt + case LyXLength::MM: // Millimeter = 2.845pt result << len.value() << "mm"; break; - case LyXLength::PC: //< Pica = 12pt = 4.218mm + case LyXLength::PC: // Pica = 12pt = 4.218mm result << len.value() << "pc"; break; - case LyXLength::CC: //< Cicero = 12dd = 4.531mm + case LyXLength::CC: // Cicero = 12dd = 4.531mm result << len.value() * 4.531 << "mm"; break; - case LyXLength::CM: //< Centimeter = 10mm = 2.371pc + case LyXLength::CM: // Centimeter = 10mm = 2.371pc result << len.value() << "cm"; break; - case LyXLength::IN: //< Inch = 25.4mm = 72.27pt = 6.022pc + case LyXLength::IN: // Inch = 25.4mm = 72.27pt = 6.022pc result << len.value() << "in"; break; - case LyXLength::EX: //< Height of a small "x" for the current font. + case LyXLength::EX: // Height of a small "x" for the current font. // Obviously we have to compromise here. Any better ratio than 1.5 ? result << len.value() / 1.5 << "em"; break; - case LyXLength::EM: //< Width of capital "M" in current font. + case LyXLength::EM: // Width of capital "M" in current font. result << len.value() << "em"; break; - case LyXLength::MU: //< Math unit (18mu = 1em) for positioning in math mode + case LyXLength::MU: // Math unit (18mu = 1em) for positioning in math mode result << len.value() * 18 << "em"; break; - case LyXLength::PTW: //< Percent of TextWidth - case LyXLength::PCW: //< Percent of ColumnWidth - case LyXLength::PPW: //< Percent of PageWidth - case LyXLength::PLW: //< Percent of LineWidth - case LyXLength::PTH: //< Percent of TextHeight - case LyXLength::PPH: //< Percent of Paper + case LyXLength::PTW: // Percent of TextWidth + case LyXLength::PCW: // Percent of ColumnWidth + case LyXLength::PPW: // Percent of PageWidth + case LyXLength::PLW: // Percent of LineWidth + case LyXLength::PTH: // Percent of TextHeight + case LyXLength::PPH: // Percent of Paper // Sigh, this will go wrong. result << len.value() << "%"; break; @@ -409,13 +409,13 @@ string const InsetGraphics::createDocBookAttributes() const options << " scale=\"" << static_cast( (params().scale) + 0.5 ) << "\" "; } else { - if ( ! params().width.zero()) { + if (!params().width.zero()) { options << " width=\"" << toDocbookLength(params().width) << "\" "; } - if ( ! params().height.zero()) { + if (!params().height.zero()) { options << " depth=\"" << toDocbookLength(params().height) << "\" "; } - if ( params().keepAspectRatio ) { + if (params().keepAspectRatio) { // This will be irrelevant unless both width and height are set options << "scalefit=\"1\" "; } @@ -788,6 +788,32 @@ int InsetGraphics::linuxdoc(Buffer const & buf, ostream & os, } +namespace { + +int writeImageObject(char * format, ostream& os, OutputParams const & runparams, + string const graphic_label, string const attributes) +{ + if (runparams.flavor != OutputParams::XML) { + os << "" ; + } + else { + os << " format=\"" << format << "\">" ; + } + os << ""; + if (runparams.flavor != OutputParams::XML) { + os << std::endl << "]]>" ; + } + return runparams.flavor == OutputParams::XML ? 0 : 2; +} +// end anonymous namespace +} + + // For explanation on inserting graphics into DocBook checkout: // http://en.tldp.org/LDP/LDP-Author-Guide/html/inserting-pictures.html // See also the docbook guide at http://www.docbook.org/ @@ -800,15 +826,21 @@ int InsetGraphics::docbook(Buffer const &, ostream & os, if (runparams.flavor == OutputParams::XML) { runparams.exportdata->addExternalFile("docbook-xml", params().filename.absFilename()); - os << ""; } else { runparams.exportdata->addExternalFile("docbook", params().filename.absFilename()); - os << ""; } - return 0; + os << ""; + + int r = 0; + string attributes = createDocBookAttributes(); + r += writeImageObject("png", os, runparams, graphic_label, attributes); + r += writeImageObject("pdf", os, runparams, graphic_label, attributes); + r += writeImageObject("eps", os, runparams, graphic_label, attributes); + r += writeImageObject("bmp", os, runparams, graphic_label, attributes); + + os << ""; + return r; } -- 2.39.2