mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-25 10:58:52 +00:00
Improve graphics export for docbook.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9101 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
c6bf338207
commit
d49b60b258
@ -1,3 +1,8 @@
|
||||
2004-10-18 Andreas Vox <vox@isp.uni-luebeck.de>
|
||||
|
||||
* buffer.C (makeDocBookFile): add dsssl stylesheet control
|
||||
entities to preamble.
|
||||
|
||||
2004-10-18 Georg Baum <Georg.Baum@post.rwth-aachen.de>
|
||||
|
||||
* messages.C (Pimpl): strip off translation context information
|
||||
|
@ -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 += "<!ENTITY % output.print.png \"IGNORE\">\n";
|
||||
preamble += "<!ENTITY % output.print.pdf \"IGNORE\">\n";
|
||||
preamble += "<!ENTITY % output.print.eps \"IGNORE\">\n";
|
||||
preamble += "<!ENTITY % output.print.bmp \"IGNORE\">\n";
|
||||
}
|
||||
|
||||
string const name = runparams.nice ? ChangeExtension(pimpl_->filename, ".sgml")
|
||||
: fname;
|
||||
preamble += features.getIncludedFiles(name);
|
||||
|
@ -1,3 +1,8 @@
|
||||
2004-10-18 Andreas Vox <vox@isp.uni-luebeck.de>
|
||||
|
||||
* insetgraphics.C (docbook, writeImageObject): write more than one
|
||||
format of imageobjects in <mediaobject>.
|
||||
|
||||
2004-10-17 Andreas Vox <vox@isp.uni-luebeck.de>
|
||||
|
||||
* insetcite.[hC] (docbook, latex, cleanupWhitespace): implementing
|
||||
|
@ -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<int>( (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 << "<![ %output.print." << format << "; [" << std::endl;
|
||||
}
|
||||
os <<"<imageobject><imagedata fileref=\"&"
|
||||
<< graphic_label << ";." << format << "\" " << attributes ;
|
||||
if (runparams.flavor == OutputParams::XML) {
|
||||
os << " role=\"" << format << "\"/>" ;
|
||||
}
|
||||
else {
|
||||
os << " format=\"" << format << "\">" ;
|
||||
}
|
||||
os << "</imageobject>";
|
||||
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 << "<inlinemediaobject><imageobject><imagedata fileref=\"&"
|
||||
<< graphic_label << ";\" " << createDocBookAttributes()
|
||||
<< "/></imageobject></inlinemediaobject>";
|
||||
} else {
|
||||
runparams.exportdata->addExternalFile("docbook",
|
||||
params().filename.absFilename());
|
||||
os << "<inlinegraphic fileref=\"&" << graphic_label << ";\" " + createDocBookAttributes() + ">";
|
||||
}
|
||||
return 0;
|
||||
os << "<inlinemediaobject>";
|
||||
|
||||
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 << "</inlinemediaobject>";
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user