filter/source/pdf/pdfexport.cxx | 8 +++++--- include/vcl/pdfwriter.hxx | 2 +- vcl/source/gdi/pdfwriter.cxx | 2 +- vcl/source/gdi/pdfwriter_impl.cxx | 4 ++-- vcl/source/gdi/pdfwriter_impl.hxx | 10 +++++----- 5 files changed, 14 insertions(+), 12 deletions(-)
New commits: commit 3a2ccb419c5face6fbf56b1a4877e675d4cd5fe8 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Thu May 25 16:37:04 2017 +0200 tdf#108056 PDF export: work with double page size Our coordinate system has the origo in the top left corner, PDF's one is at the bottom left corner. So the page height affects the coordinate of all widths and y positions. That page width is 870.25 in the case of the bugdoc, but it was handled as 870 due to the integer rounding. The coordinates and heights are now closer to the expected ones. (cherry picked from commit a05dc747caf5b8fef6bd95a999cb6098f2b4dbc7) Change-Id: I9c7d77298df3850bbc170c9ace18120900d7e3fa Reviewed-on: https://gerrit.libreoffice.org/38035 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk> diff --git a/filter/source/pdf/pdfexport.cxx b/filter/source/pdf/pdfexport.cxx index 2c4849fd9928..4fdd7a450626 100644 --- a/filter/source/pdf/pdfexport.cxx +++ b/filter/source/pdf/pdfexport.cxx @@ -1009,12 +1009,14 @@ void PDFExport::showErrors( const std::set< vcl::PDFWriter::ErrorCode >& rErrors bool PDFExport::ImplExportPage( vcl::PDFWriter& rWriter, vcl::PDFExtOutDevData& rPDFExtOutDevData, const GDIMetaFile& rMtf ) { - const Size aSizePDF( OutputDevice::LogicToLogic( rMtf.GetPrefSize(), rMtf.GetPrefMapMode(), MapUnit::MapPoint ) ); + basegfx::B2DPolygon aSize(tools::Polygon(tools::Rectangle(Point(0, 0), rMtf.GetPrefSize())).getB2DPolygon()); + basegfx::B2DPolygon aSizePDF(OutputDevice::LogicToLogic(aSize, rMtf.GetPrefMapMode(), MapUnit::MapPoint)); + basegfx::B2DRange aRangePDF(aSizePDF.getB2DRange()); Point aOrigin; tools::Rectangle aPageRect( aOrigin, rMtf.GetPrefSize() ); bool bRet = true; - rWriter.NewPage( aSizePDF.Width(), aSizePDF.Height() ); + rWriter.NewPage( aRangePDF.getWidth(), aRangePDF.getHeight() ); rWriter.SetMapMode( rMtf.GetPrefMapMode() ); vcl::PDFWriter::PlayMetafileContext aCtx; @@ -1042,7 +1044,7 @@ bool PDFExport::ImplExportPage( vcl::PDFWriter& rWriter, vcl::PDFExtOutDevData& rPDFExtOutDevData.ResetSyncData(); if (!msWatermark.isEmpty()) - ImplWriteWatermark( rWriter, aSizePDF ); + ImplWriteWatermark( rWriter, Size(aRangePDF.getWidth(), aRangePDF.getHeight()) ); return bRet; } diff --git a/include/vcl/pdfwriter.hxx b/include/vcl/pdfwriter.hxx index bc2608444714..78a28231ea10 100644 --- a/include/vcl/pdfwriter.hxx +++ b/include/vcl/pdfwriter.hxx @@ -689,7 +689,7 @@ The following structure describes the permissions used in PDF security Colors and other state information MUST be set again or are undefined. */ - void NewPage( sal_Int32 nPageWidth, sal_Int32 nPageHeight, Orientation eOrientation = Orientation::Inherit ); + void NewPage( double nPageWidth, double nPageHeight, Orientation eOrientation = Orientation::Inherit ); /** Play a metafile like an outputdevice would do */ struct PlayMetafileContext diff --git a/vcl/source/gdi/pdfwriter.cxx b/vcl/source/gdi/pdfwriter.cxx index ec612820e15d..28a176ba3c51 100644 --- a/vcl/source/gdi/pdfwriter.cxx +++ b/vcl/source/gdi/pdfwriter.cxx @@ -53,7 +53,7 @@ OutputDevice* PDFWriter::GetReferenceDevice() return xImplementation->getReferenceDevice(); } -void PDFWriter::NewPage( sal_Int32 nPageWidth, sal_Int32 nPageHeight, Orientation eOrientation ) +void PDFWriter::NewPage( double nPageWidth, double nPageHeight, Orientation eOrientation ) { xImplementation->newPage( nPageWidth, nPageHeight, eOrientation ); } diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index 3ee96131e070..a4a49436b820 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -1126,7 +1126,7 @@ void PDFWriterImpl::ResourceDict::append( OStringBuffer& rBuf, sal_Int32 nFontDi rBuf.append( "]\n>>\n" ); }; -PDFWriterImpl::PDFPage::PDFPage( PDFWriterImpl* pWriter, sal_Int32 nPageWidth, sal_Int32 nPageHeight, PDFWriter::Orientation eOrientation ) +PDFWriterImpl::PDFPage::PDFPage( PDFWriterImpl* pWriter, double nPageWidth, double nPageHeight, PDFWriter::Orientation eOrientation ) : m_pWriter( pWriter ), m_nPageWidth( nPageWidth ), @@ -2258,7 +2258,7 @@ LogicalFontInstance* PdfBuiltinFontFace::CreateFontInstance( FontSelectPattern& } -void PDFWriterImpl::newPage( sal_Int32 nPageWidth, sal_Int32 nPageHeight, PDFWriter::Orientation eOrientation ) +void PDFWriterImpl::newPage( double nPageWidth, double nPageHeight, PDFWriter::Orientation eOrientation ) { endPage(); m_nCurrentPage = m_aPages.size(); diff --git a/vcl/source/gdi/pdfwriter_impl.hxx b/vcl/source/gdi/pdfwriter_impl.hxx index c65e24075e0b..0132897f71ee 100644 --- a/vcl/source/gdi/pdfwriter_impl.hxx +++ b/vcl/source/gdi/pdfwriter_impl.hxx @@ -135,8 +135,8 @@ public: struct PDFPage { PDFWriterImpl* m_pWriter; - sal_Int32 m_nPageWidth; // in inch/72 - sal_Int32 m_nPageHeight; // in inch/72 + double m_nPageWidth; // in inch/72 + double m_nPageHeight; // in inch/72 PDFWriter::Orientation m_eOrientation; sal_Int32 m_nPageObject; sal_Int32 m_nPageIndex; @@ -150,7 +150,7 @@ public: sal_uInt32 m_nDuration; bool m_bHasWidgets; - PDFPage( PDFWriterImpl* pWriter, sal_Int32 nPageWidth, sal_Int32 nPageHeight, PDFWriter::Orientation eOrientation ); + PDFPage( PDFWriterImpl* pWriter, double nPageWidth, double nPageHeight, PDFWriter::Orientation eOrientation ); ~PDFPage(); void beginStream(); @@ -191,7 +191,7 @@ public: // appends a horizontal waveline with vertical offset (helper for drawWaveLine) void appendWaveLine( sal_Int32 nLength, sal_Int32 nYOffset, sal_Int32 nDelta, OStringBuffer& rBuffer ) const; - sal_Int32 getHeight() const { return m_nPageHeight ? m_nPageHeight : m_pWriter->m_nInheritedPageHeight; } + double getHeight() const { return m_nPageHeight ? m_nPageHeight : m_pWriter->m_nInheritedPageHeight; } }; friend struct PDFPage; @@ -1079,7 +1079,7 @@ public: OutputDevice* getReferenceDevice(); /* document structure */ - void newPage( sal_Int32 nPageWidth , sal_Int32 nPageHeight, PDFWriter::Orientation eOrientation ); + void newPage( double nPageWidth , double nPageHeight, PDFWriter::Orientation eOrientation ); bool emit(); const std::set< PDFWriter::ErrorCode > & getErrors() const { return m_aErrors;} void insertError( PDFWriter::ErrorCode eErr ) { m_aErrors.insert( eErr ); } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits