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

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Fri Oct 9 07:04:37 UTC 2020


 include/vcl/filter/PDFiumLibrary.hxx   |    3 +--
 vcl/qa/cppunit/pdfexport/pdfexport.cxx |   11 ++++-------
 vcl/source/pdf/PDFiumLibrary.cxx       |    7 +++++++
 3 files changed, 12 insertions(+), 9 deletions(-)

New commits:
commit 4777f5a0512655552c8803a7378926ad7c02da71
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Thu Oct 8 21:04:07 2020 +0200
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Fri Oct 9 09:03:59 2020 +0200

    vcl: PDFiumLibrary: add PDFiumDocument::getFileVersion()
    
    Allows not exposing the underlying FPDF_DOCUMENT in PDFiumDocument.
    
    Change-Id: Icff455af406405aff9099e950c26ce824517b57a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104097
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>

diff --git a/include/vcl/filter/PDFiumLibrary.hxx b/include/vcl/filter/PDFiumLibrary.hxx
index 6f3d94925122..2664d2bccb39 100644
--- a/include/vcl/filter/PDFiumLibrary.hxx
+++ b/include/vcl/filter/PDFiumLibrary.hxx
@@ -207,10 +207,9 @@ public:
     // Page size in points
     basegfx::B2DSize getPageSize(int nIndex);
     int getPageCount();
+    int getFileVersion();
 
     std::unique_ptr<PDFiumPage> openPage(int nIndex);
-
-    FPDF_DOCUMENT getPointer() { return mpPdfDocument; }
 };
 
 struct PDFiumLibrary final : public rtl::StaticWithInit<std::shared_ptr<PDFium>, PDFiumLibrary>
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index 3525199e4b07..d4195b1844ce 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -1930,13 +1930,12 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testLargePage)
     // The document has 1 page.
     CPPUNIT_ASSERT_EQUAL(1, pPdfDocument->getPageCount());
     // Check the value (not the unit) of the page size.
-    FS_SIZEF aSize;
-    FPDF_GetPageSizeByIndexF(pPdfDocument->getPointer(), 0, &aSize);
+    basegfx::B2DSize aSize = pPdfDocument->getPageSize(0);
     // Without the accompanying fix in place, this test would have failed with:
     // - Expected: 8503.94
     // - Actual  : 17007.875
     // i.e. the value for 600 cm was larger than the 14 400 limit set in the spec.
-    CPPUNIT_ASSERT_DOUBLES_EQUAL(8503.94, static_cast<double>(aSize.width), 0.01);
+    CPPUNIT_ASSERT_DOUBLES_EQUAL(8503.94, aSize.getX(), 0.01);
 }
 
 CPPUNIT_TEST_FIXTURE(PdfExportTest, testPdfImageResourceInlineXObjectRef)
@@ -2033,8 +2032,7 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testDefaultVersion)
     std::unique_ptr<vcl::pdf::PDFiumDocument> pPdfDocument
         = pPDFium->openDocument(maMemory.GetData(), maMemory.GetSize());
     CPPUNIT_ASSERT(pPdfDocument);
-    int nFileVersion = 0;
-    FPDF_GetFileVersion(pPdfDocument->getPointer(), &nFileVersion);
+    int nFileVersion = pPdfDocument->getFileVersion();
     CPPUNIT_ASSERT_EQUAL(16, nFileVersion);
 }
 
@@ -2060,8 +2058,7 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testVersion15)
     std::unique_ptr<vcl::pdf::PDFiumDocument> pPdfDocument
         = pPDFium->openDocument(maMemory.GetData(), maMemory.GetSize());
     CPPUNIT_ASSERT(pPdfDocument);
-    int nFileVersion = 0;
-    FPDF_GetFileVersion(pPdfDocument->getPointer(), &nFileVersion);
+    int nFileVersion = pPdfDocument->getFileVersion();
     CPPUNIT_ASSERT_EQUAL(15, nFileVersion);
 }
 
diff --git a/vcl/source/pdf/PDFiumLibrary.cxx b/vcl/source/pdf/PDFiumLibrary.cxx
index d790fb1b9c01..a0668d0c6048 100644
--- a/vcl/source/pdf/PDFiumLibrary.cxx
+++ b/vcl/source/pdf/PDFiumLibrary.cxx
@@ -174,6 +174,13 @@ basegfx::B2DSize PDFiumDocument::getPageSize(int nIndex)
 
 int PDFiumDocument::getPageCount() { return FPDF_GetPageCount(mpPdfDocument); }
 
+int PDFiumDocument::getFileVersion()
+{
+    int nFileVersion = 0;
+    FPDF_GetFileVersion(mpPdfDocument, &nFileVersion);
+    return nFileVersion;
+}
+
 int PDFiumPage::getObjectCount() { return FPDFPage_CountObjects(mpPage); }
 
 std::unique_ptr<PDFiumPageObject> PDFiumPage::getObject(int nIndex)


More information about the Libreoffice-commits mailing list