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

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Wed Sep 30 06:26:02 UTC 2020


 include/vcl/filter/PDFiumLibrary.hxx    |    1 +
 vcl/source/pdf/PDFiumLibrary.cxx        |    2 ++
 xmlsecurity/qa/unit/signing/signing.cxx |   13 ++++++-------
 3 files changed, 9 insertions(+), 7 deletions(-)

New commits:
commit 9a2357c0e2bb1d99a1816437d3862b7bd8c85898
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Tue Sep 29 21:02:39 2020 +0200
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Wed Sep 30 08:25:22 2020 +0200

    vcl: add PDFiumAnnotation::getObjectCount()
    
    And use it in xmlsecurity, instead of the upstream scopers, to
    standardize on a single set of pdfium wrappers.
    
    Change-Id: Iec4baf34a607b23f1b9de8c4b969801c5973c1ed
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103636
    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 6386441b6f39..8a8aae569e22 100644
--- a/include/vcl/filter/PDFiumLibrary.hxx
+++ b/include/vcl/filter/PDFiumLibrary.hxx
@@ -71,6 +71,7 @@ public:
     bool hasKey(OString const& rKey);
     OUString getString(OString const& rKey);
     std::unique_ptr<PDFiumAnnotation> getLinked(OString const& rKey);
+    int getObjectCount();
 };
 
 class PDFiumTextPage;
diff --git a/vcl/source/pdf/PDFiumLibrary.cxx b/vcl/source/pdf/PDFiumLibrary.cxx
index 360c88657161..6205bbbf0ea7 100644
--- a/vcl/source/pdf/PDFiumLibrary.cxx
+++ b/vcl/source/pdf/PDFiumLibrary.cxx
@@ -467,6 +467,8 @@ std::unique_ptr<PDFiumAnnotation> PDFiumAnnotation::getLinked(OString const& rKe
     return pPDFiumAnnotation;
 }
 
+int PDFiumAnnotation::getObjectCount() { return FPDFAnnot_GetObjectCount(mpAnnotation); }
+
 PDFiumTextPage::PDFiumTextPage(FPDF_TEXTPAGE pTextPage)
     : mpTextPage(pTextPage)
 {
diff --git a/xmlsecurity/qa/unit/signing/signing.cxx b/xmlsecurity/qa/unit/signing/signing.cxx
index 6f9d05b4651a..513ebcce6009 100644
--- a/xmlsecurity/qa/unit/signing/signing.cxx
+++ b/xmlsecurity/qa/unit/signing/signing.cxx
@@ -57,7 +57,6 @@
 #if HAVE_FEATURE_PDFIUM
 #include <fpdf_annot.h>
 #include <fpdfview.h>
-#include <cpp/fpdf_scopers.h>
 #endif
 
 using namespace com::sun::star;
@@ -647,16 +646,16 @@ CPPUNIT_TEST_FIXTURE(SigningTest, testPDFAddVisibleSignature)
     SvFileStream aFile(aTempFile.GetURL(), StreamMode::READ);
     SvMemoryStream aMemory;
     aMemory.WriteStream(aFile);
-    ScopedFPDFDocument pPdfDocument(
-        FPDF_LoadMemDocument(aMemory.GetData(), aMemory.GetSize(), /*password=*/nullptr));
-    ScopedFPDFPage pPdfPage(FPDF_LoadPage(pPdfDocument.get(), /*page_index=*/0));
-    CPPUNIT_ASSERT_EQUAL(1, FPDFPage_GetAnnotCount(pPdfPage.get()));
-    ScopedFPDFAnnotation pAnnot(FPDFPage_GetAnnot(pPdfPage.get(), 0));
+    std::unique_ptr<vcl::pdf::PDFiumDocument> pPdfDocument
+        = pPDFium->openDocument(aMemory.GetData(), aMemory.GetSize());
+    std::unique_ptr<vcl::pdf::PDFiumPage> pPdfPage = pPdfDocument->openPage(/*nIndex=*/0);
+    CPPUNIT_ASSERT_EQUAL(1, pPdfPage->getAnnotationCount());
+    std::unique_ptr<vcl::pdf::PDFiumAnnotation> pAnnot = pPdfPage->getAnnotation(/*nIndex=*/0);
     // Without the accompanying fix in place, this test would have failed with:
     // - Expected: 4
     // - Actual  : 0
     // i.e. the signature was there, but it was empty / not visible.
-    CPPUNIT_ASSERT_EQUAL(4, FPDFAnnot_GetObjectCount(pAnnot.get()));
+    CPPUNIT_ASSERT_EQUAL(4, pAnnot->getObjectCount());
 }
 #endif
 


More information about the Libreoffice-commits mailing list