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

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Wed Jan 6 07:59:26 UTC 2021


 include/vcl/filter/PDFiumLibrary.hxx   |    3 ++-
 include/vcl/pdf/PDFObjectType.hxx      |   31 +++++++++++++++++++++++++++++++
 vcl/qa/cppunit/pdfexport/pdfexport.cxx |    4 +---
 vcl/source/pdf/PDFiumLibrary.cxx       |   25 +++++++++++++++++++++++--
 4 files changed, 57 insertions(+), 6 deletions(-)

New commits:
commit 8373d6b1dd1096d3ce1d1f1d3845b6061c365fab
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Tue Jan 5 21:02:46 2021 +0100
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Wed Jan 6 08:58:39 2021 +0100

    pdfium: add wrapper for FPDF_OBJECT_* defines
    
    So that client code doesn't have to include fpdfview.h manually.
    
    Change-Id: I0cb9569f84e85953a308519ea89bed39fe4a1390
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108817
    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 32a9a68a55cc..3509c1d77d5a 100644
--- a/include/vcl/filter/PDFiumLibrary.hxx
+++ b/include/vcl/filter/PDFiumLibrary.hxx
@@ -33,6 +33,7 @@
 #include <vcl/pdf/PDFPageObjectType.hxx>
 #include <vcl/pdf/PDFSegmentType.hxx>
 #include <vcl/pdf/PDFBitmapType.hxx>
+#include <vcl/pdf/PDFObjectType.hxx>
 
 #include <fpdf_doc.h>
 
@@ -101,7 +102,7 @@ public:
     PDFAnnotationSubType getSubType();
     basegfx::B2DRectangle getRectangle();
     bool hasKey(OString const& rKey);
-    int getValueType(OString const& rKey);
+    PDFObjectType getValueType(OString const& rKey);
     OUString getString(OString const& rKey);
     std::unique_ptr<PDFiumAnnotation> getLinked(OString const& rKey);
     int getObjectCount();
diff --git a/include/vcl/pdf/PDFObjectType.hxx b/include/vcl/pdf/PDFObjectType.hxx
new file mode 100644
index 000000000000..c3ee6c75262c
--- /dev/null
+++ b/include/vcl/pdf/PDFObjectType.hxx
@@ -0,0 +1,31 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ */
+
+#pragma once
+
+namespace vcl::pdf
+{
+enum class PDFObjectType
+{
+    Unknown = 0,
+    Boolean = 1,
+    Number = 2,
+    String = 3,
+    Name = 4,
+    Array = 5,
+    Dictionary = 6,
+    Stream = 7,
+    Nullobj = 8,
+    Reference = 9
+};
+
+} // namespace vcl::pdf
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index 0236a6e73e5d..d8679081d348 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -36,8 +36,6 @@
 #include <unotools/tempfile.hxx>
 #include <vcl/filter/pdfdocument.hxx>
 #include <tools/zcodec.hxx>
-#include <fpdf_annot.h>
-#include <fpdfview.h>
 #include <vcl/graphicfilter.hxx>
 #include <basegfx/matrix/b2dhommatrix.hxx>
 #include <unotools/streamwrap.hxx>
@@ -2242,7 +2240,7 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest, testFormFontName)
 
     // Examine the default appearance.
     CPPUNIT_ASSERT(pAnnot->hasKey("DA"));
-    CPPUNIT_ASSERT_EQUAL(FPDF_OBJECT_STRING, FPDFAnnot_GetValueType(pAnnot->getPointer(), "DA"));
+    CPPUNIT_ASSERT_EQUAL(vcl::pdf::PDFObjectType::String, pAnnot->getValueType("DA"));
     OUString aDA = pAnnot->getString("DA");
 
     // Without the accompanying fix in place, this test would have failed with:
diff --git a/vcl/source/pdf/PDFiumLibrary.cxx b/vcl/source/pdf/PDFiumLibrary.cxx
index 291e340abc40..a75b2b92d62f 100644
--- a/vcl/source/pdf/PDFiumLibrary.cxx
+++ b/vcl/source/pdf/PDFiumLibrary.cxx
@@ -62,6 +62,27 @@ static_assert(static_cast<int>(vcl::pdf::PDFBitmapType::BGRx) == FPDFBitmap_BGRx
 static_assert(static_cast<int>(vcl::pdf::PDFBitmapType::BGRA) == FPDFBitmap_BGRA,
               "PDFBitmapType::BGRA value mismatch");
 
+static_assert(static_cast<int>(vcl::pdf::PDFObjectType::Unknown) == FPDF_OBJECT_UNKNOWN,
+              "PDFObjectType::Unknown value mismatch");
+static_assert(static_cast<int>(vcl::pdf::PDFObjectType::Boolean) == FPDF_OBJECT_BOOLEAN,
+              "PDFObjectType::Boolean value mismatch");
+static_assert(static_cast<int>(vcl::pdf::PDFObjectType::Number) == FPDF_OBJECT_NUMBER,
+              "PDFObjectType::Number value mismatch");
+static_assert(static_cast<int>(vcl::pdf::PDFObjectType::String) == FPDF_OBJECT_STRING,
+              "PDFObjectType::String value mismatch");
+static_assert(static_cast<int>(vcl::pdf::PDFObjectType::Name) == FPDF_OBJECT_NAME,
+              "PDFObjectType::Name value mismatch");
+static_assert(static_cast<int>(vcl::pdf::PDFObjectType::Array) == FPDF_OBJECT_ARRAY,
+              "PDFObjectType::Array value mismatch");
+static_assert(static_cast<int>(vcl::pdf::PDFObjectType::Dictionary) == FPDF_OBJECT_DICTIONARY,
+              "PDFObjectType::Dictionary value mismatch");
+static_assert(static_cast<int>(vcl::pdf::PDFObjectType::Stream) == FPDF_OBJECT_STREAM,
+              "PDFObjectType::Stream value mismatch");
+static_assert(static_cast<int>(vcl::pdf::PDFObjectType::Nullobj) == FPDF_OBJECT_NULLOBJ,
+              "PDFObjectType::Nullobj value mismatch");
+static_assert(static_cast<int>(vcl::pdf::PDFObjectType::Reference) == FPDF_OBJECT_REFERENCE,
+              "PDFObjectType::Reference value mismatch");
+
 namespace
 {
 /// Callback class to be used with FPDF_SaveWithVersion().
@@ -849,9 +870,9 @@ bool PDFiumAnnotation::hasKey(OString const& rKey)
     return FPDFAnnot_HasKey(mpAnnotation, rKey.getStr());
 }
 
-int PDFiumAnnotation::getValueType(OString const& rKey)
+PDFObjectType PDFiumAnnotation::getValueType(OString const& rKey)
 {
-    return FPDFAnnot_GetValueType(mpAnnotation, rKey.getStr());
+    return static_cast<PDFObjectType>(FPDFAnnot_GetValueType(mpAnnotation, rKey.getStr()));
 }
 
 OUString PDFiumAnnotation::getString(OString const& rKey)


More information about the Libreoffice-commits mailing list