summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAron Budea <aron.budea@collabora.com>2018-07-09 00:54:53 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2018-07-11 10:59:08 +0200
commitb5035a5ec51e29851eaf6c195e7e12320baed36f (patch)
tree3e100c1da9a14cf9443b03d7939f936e9b571edc
parent6f89e62cb7d4d32ad321840bd1887e7226c62cce (diff)
tdf#112690: make page size of exported PDF closer to what is set
regression from 3a2ccb419c5face6fbf56b1a4877e675d4cd5fe8 Change-Id: Ia0fddeb112fa0867ec367c085e3682eac078d5f8 Reviewed-on: https://gerrit.libreoffice.org/57166 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk> (cherry picked from commit 9a7a419baf9a6aa9fc70d9e2a00dec3fbdeee565) Reviewed-on: https://gerrit.libreoffice.org/57184
-rw-r--r--filter/source/pdf/pdfexport.cxx3
-rw-r--r--vcl/qa/cppunit/pdfexport/pdfexport.cxx18
2 files changed, 15 insertions, 6 deletions
diff --git a/filter/source/pdf/pdfexport.cxx b/filter/source/pdf/pdfexport.cxx
index 04479fa2d9f3..c7e307f21453 100644
--- a/filter/source/pdf/pdfexport.cxx
+++ b/filter/source/pdf/pdfexport.cxx
@@ -1004,7 +1004,8 @@ void PDFExport::showErrors( const std::set< vcl::PDFWriter::ErrorCode >& rErrors
bool PDFExport::ImplExportPage( vcl::PDFWriter& rWriter, vcl::PDFExtOutDevData& rPDFExtOutDevData, const GDIMetaFile& rMtf )
{
- basegfx::B2DPolygon aSize(tools::Polygon(tools::Rectangle(Point(0, 0), rMtf.GetPrefSize())).getB2DPolygon());
+ //Rectangle(Point, Size) creates a rectangle off by 1, use Rectangle(long, long, long, long) instead
+ basegfx::B2DPolygon aSize(tools::Polygon(tools::Rectangle(0, 0, rMtf.GetPrefSize().Width(), rMtf.GetPrefSize().Height())).getB2DPolygon());
basegfx::B2DPolygon aSizePDF(OutputDevice::LogicToLogic(aSize, rMtf.GetPrefMapMode(), MapMode(MapUnit::MapPoint)));
basegfx::B2DRange aRangePDF(aSizePDF.getB2DRange());
tools::Rectangle aPageRect( Point(), rMtf.GetPrefSize() );
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index 849e87b90f4a..5d8214b898c3 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -772,6 +772,14 @@ void PdfExportTest::testTdf108963()
mpPdfPage = FPDF_LoadPage(mpPdfDocument, /*page_index=*/0);
CPPUNIT_ASSERT(mpPdfPage);
+ // Test page size (28x15.75 cm, was 1/100th mm off, tdf#112690)
+ // bad: MediaBox[0 0 793.672440944882 446.428346456693]
+ // good: MediaBox[0 0 793.700787401575 446.456692913386]
+ const double aWidth = FPDF_GetPageWidth(mpPdfPage);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(793.7, aWidth, 0.01);
+ const double aHeight = FPDF_GetPageHeight(mpPdfPage);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(446.46, aHeight, 0.01);
+
// Make sure there is a filled rectangle inside.
int nPageObjectCount = FPDFPage_CountObjects(mpPdfPage);
int nYellowPathCount = 0;
@@ -795,35 +803,35 @@ void PdfExportTest::testTdf108963()
float fY = 0;
FPDFPathSegment_GetPoint(pSegment, &fX, &fY);
CPPUNIT_ASSERT_EQUAL(245395, static_cast<int>(round(fX * 1000)));
- CPPUNIT_ASSERT_EQUAL(244233, static_cast<int>(round(fY * 1000)));
+ CPPUNIT_ASSERT_EQUAL(244261, static_cast<int>(round(fY * 1000)));
CPPUNIT_ASSERT(!FPDFPathSegment_GetClose(pSegment));
pSegment = FPDFPath_GetPathSegment(pPdfPageObject, 1);
CPPUNIT_ASSERT_EQUAL(FPDF_SEGMENT_LINETO, FPDFPathSegment_GetType(pSegment));
FPDFPathSegment_GetPoint(pSegment, &fX, &fY);
CPPUNIT_ASSERT_EQUAL(275102, static_cast<int>(round(fX * 1000)));
- CPPUNIT_ASSERT_EQUAL(267590, static_cast<int>(round(fY * 1000)));
+ CPPUNIT_ASSERT_EQUAL(267618, static_cast<int>(round(fY * 1000)));
CPPUNIT_ASSERT(!FPDFPathSegment_GetClose(pSegment));
pSegment = FPDFPath_GetPathSegment(pPdfPageObject, 2);
CPPUNIT_ASSERT_EQUAL(FPDF_SEGMENT_LINETO, FPDFPathSegment_GetType(pSegment));
FPDFPathSegment_GetPoint(pSegment, &fX, &fY);
CPPUNIT_ASSERT_EQUAL(287518, static_cast<int>(round(fX * 1000)));
- CPPUNIT_ASSERT_EQUAL(251801, static_cast<int>(round(fY * 1000)));
+ CPPUNIT_ASSERT_EQUAL(251829, static_cast<int>(round(fY * 1000)));
CPPUNIT_ASSERT(!FPDFPathSegment_GetClose(pSegment));
pSegment = FPDFPath_GetPathSegment(pPdfPageObject, 3);
CPPUNIT_ASSERT_EQUAL(FPDF_SEGMENT_LINETO, FPDFPathSegment_GetType(pSegment));
FPDFPathSegment_GetPoint(pSegment, &fX, &fY);
CPPUNIT_ASSERT_EQUAL(257839, static_cast<int>(round(fX * 1000)));
- CPPUNIT_ASSERT_EQUAL(228444, static_cast<int>(round(fY * 1000)));
+ CPPUNIT_ASSERT_EQUAL(228472, static_cast<int>(round(fY * 1000)));
CPPUNIT_ASSERT(!FPDFPathSegment_GetClose(pSegment));
pSegment = FPDFPath_GetPathSegment(pPdfPageObject, 4);
CPPUNIT_ASSERT_EQUAL(FPDF_SEGMENT_LINETO, FPDFPathSegment_GetType(pSegment));
FPDFPathSegment_GetPoint(pSegment, &fX, &fY);
CPPUNIT_ASSERT_EQUAL(245395, static_cast<int>(round(fX * 1000)));
- CPPUNIT_ASSERT_EQUAL(244233, static_cast<int>(round(fY * 1000)));
+ CPPUNIT_ASSERT_EQUAL(244261, static_cast<int>(round(fY * 1000)));
CPPUNIT_ASSERT(FPDFPathSegment_GetClose(pSegment));
}
}