include/vcl/filter/PDFiumLibrary.hxx | 1 + vcl/source/graphic/VectorGraphicSearch.cxx | 18 +++++------------- 2 files changed, 6 insertions(+), 13 deletions(-)
New commits: commit 47fbbdaf091ea0ec0fb692340ad11f0d4c0f2d5c Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Wed Jan 20 21:14:53 2021 +0100 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Thu Jan 21 09:14:09 2021 +0100 pdfium: use PDFiumDocument in VectorGraphicSearch::Implementation Which means no need to manually close the doc in the dtor. Change-Id: Icf1357f162313a845d7694323d546a6fccad344e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109724 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/include/vcl/filter/PDFiumLibrary.hxx b/include/vcl/filter/PDFiumLibrary.hxx index 2774e1328ebf..f0ef24b348ea 100644 --- a/include/vcl/filter/PDFiumLibrary.hxx +++ b/include/vcl/filter/PDFiumLibrary.hxx @@ -242,6 +242,7 @@ private: public: PDFiumDocument(FPDF_DOCUMENT pPdfDocument); ~PDFiumDocument(); + FPDF_DOCUMENT getPointer() { return mpPdfDocument; } // Page size in points basegfx::B2DSize getPageSize(int nIndex); diff --git a/vcl/source/graphic/VectorGraphicSearch.cxx b/vcl/source/graphic/VectorGraphicSearch.cxx index c5e04060bc1b..40dcbad0da10 100644 --- a/vcl/source/graphic/VectorGraphicSearch.cxx +++ b/vcl/source/graphic/VectorGraphicSearch.cxx @@ -203,23 +203,16 @@ class VectorGraphicSearch::Implementation { public: std::shared_ptr<vcl::pdf::PDFium> mpPDFium; - FPDF_DOCUMENT mpPdfDocument; + std::unique_ptr<vcl::pdf::PDFiumDocument> mpPdfDocument; std::unique_ptr<SearchContext> mpSearchContext; Implementation() : mpPDFium(vcl::pdf::PDFiumLibrary::get()) - , mpPdfDocument(nullptr) { } - ~Implementation() - { - mpSearchContext.reset(); - - if (mpPdfDocument) - FPDF_CloseDocument(mpPdfDocument); - } + ~Implementation() { mpSearchContext.reset(); } }; VectorGraphicSearch::VectorGraphicSearch(Graphic const& rGraphic) @@ -251,9 +244,8 @@ bool VectorGraphicSearch::search(OUString const& rSearchString, bool VectorGraphicSearch::searchPDF(std::shared_ptr<VectorGraphicData> const& rData) { - mpImplementation->mpPdfDocument - = FPDF_LoadMemDocument(rData->getBinaryDataContainer().getData(), - rData->getBinaryDataContainer().getSize(), /*password=*/nullptr); + mpImplementation->mpPdfDocument = mpImplementation->mpPDFium->openDocument( + rData->getBinaryDataContainer().getData(), rData->getBinaryDataContainer().getSize()); if (!mpImplementation->mpPdfDocument) { @@ -283,7 +275,7 @@ bool VectorGraphicSearch::searchPDF(std::shared_ptr<VectorGraphicData> const& rD sal_Int32 nPageIndex = std::max(rData->getPageIndex(), sal_Int32(0)); mpImplementation->mpSearchContext.reset( - new SearchContext(mpImplementation->mpPdfDocument, nPageIndex)); + new SearchContext(mpImplementation->mpPdfDocument->getPointer(), nPageIndex)); return true; } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits