summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2020-10-08 21:04:07 +0200
committerMiklos Vajna <vmiklos@collabora.com>2020-10-09 09:03:59 +0200
commit4777f5a0512655552c8803a7378926ad7c02da71 (patch)
treebf86aa413d420fd5daa45bad8f6f4fd5b8ea3edd
parentd73776daa4a0e9397a9b86b5a250b210062fd760 (diff)
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@collabora.com>
-rw-r--r--include/vcl/filter/PDFiumLibrary.hxx3
-rw-r--r--vcl/qa/cppunit/pdfexport/pdfexport.cxx11
-rw-r--r--vcl/source/pdf/PDFiumLibrary.cxx7
3 files changed, 12 insertions, 9 deletions
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)