diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2024-12-23 12:02:12 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2024-12-23 15:21:59 +0100 |
commit | 807f977b389f196d17701f01ddbb40b297face95 (patch) | |
tree | ef58e61e4359949e4f0093868264b81cfc93a08b /vcl/source | |
parent | e080eebd4ebb20ddb0aff1f168096ec22b326546 (diff) |
pdfium: Log error when opening fails (useful for tests)
Change-Id: I597d82bb40c73b900c08c8b37fd303e8f5e98eed
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/179179
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl/source')
-rw-r--r-- | vcl/source/pdf/PDFiumLibrary.cxx | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/vcl/source/pdf/PDFiumLibrary.cxx b/vcl/source/pdf/PDFiumLibrary.cxx index f48d02595453..d2d91e88bb9a 100644 --- a/vcl/source/pdf/PDFiumLibrary.cxx +++ b/vcl/source/pdf/PDFiumLibrary.cxx @@ -495,6 +495,7 @@ private: PDFiumImpl& operator=(const PDFiumImpl&) = delete; OUString maLastError; + void setLastError(OUString const& rErrorString); public: PDFiumImpl(); @@ -522,10 +523,21 @@ PDFiumImpl::PDFiumImpl() PDFiumImpl::~PDFiumImpl() { FPDF_DestroyLibrary(); } +void PDFiumImpl::setLastError(OUString const& rErrorString) +{ + if (!rErrorString.isEmpty()) + { + // Report what error was set (useful in test failures) + SAL_WARN("vcl.filter", "PDFiumImpl Error: '" << rErrorString << "' Error numner: " + << sal_Int32(getLastErrorCode())); + } + maLastError = rErrorString; +} + std::unique_ptr<PDFiumDocument> PDFiumImpl::openDocument(const void* pData, int nSize, const OString& rPassword) { - maLastError = OUString(); + setLastError(u""_ustr); std::unique_ptr<PDFiumDocument> pPDFiumDocument; FPDF_BYTESTRING pPassword = nullptr; @@ -540,27 +552,28 @@ std::unique_ptr<PDFiumDocument> PDFiumImpl::openDocument(const void* pData, int switch (FPDF_GetLastError()) { case FPDF_ERR_SUCCESS: - maLastError = "Success"; + setLastError(u"Success"_ustr); break; case FPDF_ERR_UNKNOWN: - maLastError = "Unknown error"; + setLastError(u"Unknown error"_ustr); break; case FPDF_ERR_FILE: - maLastError = "File not found"; + setLastError(u"File not found"_ustr); break; case FPDF_ERR_FORMAT: - maLastError = "Input is not a PDF format"; + setLastError(u"Input is not a PDF format"_ustr); break; case FPDF_ERR_PASSWORD: - maLastError = "Incorrect password or password is required"; + setLastError(u"Incorrect password or password is required"_ustr); break; case FPDF_ERR_SECURITY: - maLastError = "Security error"; + setLastError(u"Security error"_ustr); break; case FPDF_ERR_PAGE: - maLastError = "Content error"; + setLastError(u"Content error"_ustr); break; default: + setLastError(u"Unknown error number"_ustr); break; } } @@ -605,8 +618,7 @@ std::unique_ptr<PDFiumBitmap> PDFiumImpl::createBitmap(int& nWidth, int& nHeight if (!pPdfBitmap) { - maLastError = "Failed to create bitmap"; - SAL_WARN("vcl.filter", "PDFiumImpl: " << getLastError()); + setLastError(u"Failed to create bitmap"_ustr); } else { |