diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2017-12-18 17:28:53 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2017-12-19 09:02:11 +0100 |
commit | fadd9d449719a97dc8d99d96b0ee663ae92759f8 (patch) | |
tree | bc8f201f8646ac8d2796939a4ae49941e9db8124 /writerperfect/source | |
parent | 87ada8fe44c6caf21f1fd9a0f78aa2c26f1607f2 (diff) |
EPUB export, fixed layout: fix mm size of SVG pages
The preferred map unit was pixel, but SVGExport::writeMtf() expects the
map unit is always a logical one, given that it calls
OutputDevice::LogicToLogic() for it.
Change-Id: Id1f311eb14423a76a82886ca848c90ab48c6eb49
Reviewed-on: https://gerrit.libreoffice.org/46733
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'writerperfect/source')
-rw-r--r-- | writerperfect/source/writer/EPUBExportFilter.cxx | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/writerperfect/source/writer/EPUBExportFilter.cxx b/writerperfect/source/writer/EPUBExportFilter.cxx index eb65c0ee5098..42652719684f 100644 --- a/writerperfect/source/writer/EPUBExportFilter.cxx +++ b/writerperfect/source/writer/EPUBExportFilter.cxx @@ -140,15 +140,23 @@ void EPUBExportFilter::CreateMetafiles(std::vector<std::pair<uno::Sequence<sal_I for (sal_Int16 nPage = 1; nPage <= nPages; ++nPage) { Size aDocumentSizePixel = aRenderer.getDocumentSizeInPixels(nPage); - Graphic aGraphic = aRenderer.renderToGraphic(nPage, aDocumentSizePixel, aDocumentSizePixel, COL_WHITE); - const GDIMetaFile &rGDIMetaFile = aGraphic.GetGDIMetaFile(); - SvMemoryStream aMemoryStream; - const_cast<GDIMetaFile &>(rGDIMetaFile).Write(aMemoryStream); - uno::Sequence<sal_Int8> aSequence(static_cast<const sal_Int8 *>(aMemoryStream.GetData()), aMemoryStream.Tell()); - Size aLogic = aRenderer.getDocumentSizeIn100mm(nPage); // Get the CSS pixel size of the page (mm100 -> pixel using 96 DPI, independent from system DPI). Size aCss(static_cast<double>(aLogic.getWidth()) / 26.4583, static_cast<double>(aLogic.getHeight()) / 26.4583); + Graphic aGraphic = aRenderer.renderToGraphic(nPage, aDocumentSizePixel, aCss, COL_WHITE); + GDIMetaFile &rGDIMetaFile = const_cast<GDIMetaFile &>(aGraphic.GetGDIMetaFile()); + + // Set preferred map unit and size on the metafile, so the SVG size + // will be correct in MM. + MapMode aMapMode; + aMapMode.SetMapUnit(MapUnit::Map100thMM); + rGDIMetaFile.SetPrefMapMode(aMapMode); + rGDIMetaFile.SetPrefSize(aLogic); + + SvMemoryStream aMemoryStream; + rGDIMetaFile.Write(aMemoryStream); + uno::Sequence<sal_Int8> aSequence(static_cast<const sal_Int8 *>(aMemoryStream.GetData()), aMemoryStream.Tell()); + rPageMetafiles.emplace_back(aSequence, aCss); } } |