diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2021-02-15 21:06:01 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2021-02-16 09:04:59 +0100 |
commit | 9487e0dff64e234169863f69b677f9616401f459 (patch) | |
tree | 7fbd8b060b80f28af2e6448ceb9abd15c52c4502 /vcl | |
parent | 7874cba9709dd0973a81d5894d6daa9570ac86bf (diff) |
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@collabora.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/graphic/VectorGraphicSearch.cxx | 16 | ||||
-rw-r--r-- | vcl/source/pdf/PDFiumLibrary.cxx | 17 |
2 files changed, 25 insertions, 8 deletions
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; |