[Libreoffice-commits] core.git: filter/source vcl/qa

Aron Budea aron.budea at collabora.com
Mon Jul 9 14:21:23 UTC 2018


 filter/source/pdf/pdfexport.cxx        |    3 ++-
 vcl/qa/cppunit/pdfexport/pdfexport.cxx |   18 +++++++++++++-----
 2 files changed, 15 insertions(+), 6 deletions(-)

New commits:
commit 9a7a419baf9a6aa9fc70d9e2a00dec3fbdeee565
Author: Aron Budea <aron.budea at collabora.com>
Date:   Mon Jul 9 00:54:53 2018 +0200

    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 at collabora.co.uk>

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));
         }
     }


More information about the Libreoffice-commits mailing list