diff options
-rw-r--r-- | filter/source/pdf/pdfexport.cxx | 3 | ||||
-rw-r--r-- | vcl/qa/cppunit/pdfexport/pdfexport.cxx | 18 |
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 628964bce664..53135e61b2f6 100644 --- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx +++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx @@ -771,6 +771,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; @@ -794,35 +802,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)); } } |