[Libreoffice-commits] core.git: include/vcl vcl/source
Miklos Vajna (via logerrit)
logerrit at kemper.freedesktop.org
Tue Feb 16 08:05:47 UTC 2021
include/vcl/filter/PDFiumLibrary.hxx | 2 ++
include/vcl/pdf/PDFErrorType.hxx | 28 ++++++++++++++++++++++++++++
vcl/source/graphic/VectorGraphicSearch.cxx | 16 ++++++++--------
vcl/source/pdf/PDFiumLibrary.cxx | 17 +++++++++++++++++
4 files changed, 55 insertions(+), 8 deletions(-)
New commits:
commit 9487e0dff64e234169863f69b677f9616401f459
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Mon Feb 15 21:06:01 2021 +0100
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Tue Feb 16 09:04:59 2021 +0100
pdfium: add a FPDF_GetLastError() wrapper
And also an enum class for its return values.
Change-Id: I9a001386831b2230a397194df3cf3b331d5242ad
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110952
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 eea1be960291..8a3e05b5b2d2 100644
--- a/include/vcl/filter/PDFiumLibrary.hxx
+++ b/include/vcl/filter/PDFiumLibrary.hxx
@@ -37,6 +37,7 @@
#include <vcl/pdf/PDFTextRenderMode.hxx>
#include <vcl/pdf/PDFFillMode.hxx>
#include <vcl/pdf/PDFFindFlags.hxx>
+#include <vcl/pdf/PDFErrorType.hxx>
#include <fpdf_doc.h>
@@ -69,6 +70,7 @@ public:
const OUString& getLastError() const { return maLastError; }
std::unique_ptr<PDFiumDocument> openDocument(const void* pData, int nSize);
+ static PDFErrorType getLastErrorCode();
std::unique_ptr<PDFiumBitmap> createBitmap(int nWidth, int nHeight, int nAlpha);
};
diff --git a/include/vcl/pdf/PDFErrorType.hxx b/include/vcl/pdf/PDFErrorType.hxx
new file mode 100644
index 000000000000..82cee9e5e744
--- /dev/null
+++ b/include/vcl/pdf/PDFErrorType.hxx
@@ -0,0 +1,28 @@
+/* -*- 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 PDFErrorType
+{
+ Success = 0,
+ Unknown = 1,
+ File = 2,
+ Format = 3,
+ Password = 4,
+ Security = 5,
+ Page = 6,
+};
+
+} // namespace vcl::pdf
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/graphic/VectorGraphicSearch.cxx b/vcl/source/graphic/VectorGraphicSearch.cxx
index 09839c3524ef..a32d7d93e5ed 100644
--- a/vcl/source/graphic/VectorGraphicSearch.cxx
+++ b/vcl/source/graphic/VectorGraphicSearch.cxx
@@ -233,21 +233,21 @@ bool VectorGraphicSearch::searchPDF(std::shared_ptr<VectorGraphicData> const& rD
if (!mpImplementation->mpPdfDocument)
{
//TODO: Handle failure to load.
- switch (FPDF_GetLastError())
+ switch (vcl::pdf::PDFium::getLastErrorCode())
{
- case FPDF_ERR_SUCCESS:
+ case vcl::pdf::PDFErrorType::Success:
break;
- case FPDF_ERR_UNKNOWN:
+ case vcl::pdf::PDFErrorType::Unknown:
break;
- case FPDF_ERR_FILE:
+ case vcl::pdf::PDFErrorType::File:
break;
- case FPDF_ERR_FORMAT:
+ case vcl::pdf::PDFErrorType::Format:
break;
- case FPDF_ERR_PASSWORD:
+ case vcl::pdf::PDFErrorType::Password:
break;
- case FPDF_ERR_SECURITY:
+ case vcl::pdf::PDFErrorType::Security:
break;
- case FPDF_ERR_PAGE:
+ case vcl::pdf::PDFErrorType::Page:
break;
default:
break;
diff --git a/vcl/source/pdf/PDFiumLibrary.cxx b/vcl/source/pdf/PDFiumLibrary.cxx
index 275b5f5e21be..29d5bb8f3ba6 100644
--- a/vcl/source/pdf/PDFiumLibrary.cxx
+++ b/vcl/source/pdf/PDFiumLibrary.cxx
@@ -122,6 +122,21 @@ static_assert(static_cast<int>(vcl::pdf::PDFFindFlags::MatchWholeWord) == FPDF_M
static_assert(static_cast<int>(vcl::pdf::PDFFindFlags::Consecutive) == FPDF_CONSECUTIVE,
"PDFFindFlags::Consecutive value mismatch");
+static_assert(static_cast<int>(vcl::pdf::PDFErrorType::Success) == FPDF_ERR_SUCCESS,
+ "PDFErrorType::Success value mismatch");
+static_assert(static_cast<int>(vcl::pdf::PDFErrorType::Unknown) == FPDF_ERR_UNKNOWN,
+ "PDFErrorType::Unknown value mismatch");
+static_assert(static_cast<int>(vcl::pdf::PDFErrorType::File) == FPDF_ERR_FILE,
+ "PDFErrorType::File value mismatch");
+static_assert(static_cast<int>(vcl::pdf::PDFErrorType::Format) == FPDF_ERR_FORMAT,
+ "PDFErrorType::Format value mismatch");
+static_assert(static_cast<int>(vcl::pdf::PDFErrorType::Password) == FPDF_ERR_PASSWORD,
+ "PDFErrorType::Password value mismatch");
+static_assert(static_cast<int>(vcl::pdf::PDFErrorType::Security) == FPDF_ERR_SECURITY,
+ "PDFErrorType::Security value mismatch");
+static_assert(static_cast<int>(vcl::pdf::PDFErrorType::Page) == FPDF_ERR_PAGE,
+ "PDFErrorType::Page value mismatch");
+
namespace
{
/// Callback class to be used with FPDF_SaveWithVersion().
@@ -406,6 +421,8 @@ std::unique_ptr<PDFiumDocument> PDFium::openDocument(const void* pData, int nSiz
return pPDFiumDocument;
}
+PDFErrorType PDFium::getLastErrorCode() { return static_cast<PDFErrorType>(FPDF_GetLastError()); }
+
std::unique_ptr<PDFiumBitmap> PDFium::createBitmap(int nWidth, int nHeight, int nAlpha)
{
std::unique_ptr<PDFiumBitmap> pPDFiumBitmap;
More information about the Libreoffice-commits
mailing list