diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2021-01-28 21:04:35 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2021-01-29 08:56:23 +0100 |
commit | 4f3987e0b1a995431478769c898b5ef151745254 (patch) | |
tree | 4d0ca726a5e7229a041c85109206dfab778ac010 /vcl/source/graphic/VectorGraphicSearch.cxx | |
parent | 977f66ccd6161da8ec37d4eac0f85515e0cf1df0 (diff) |
pdfium: add wrapper for FPDFText_FindClose()
So we can call it in the dtor, so we can't forget calling it.
Change-Id: I9cea58ca53763d85a4c239fd90611ac1c398564d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110092
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'vcl/source/graphic/VectorGraphicSearch.cxx')
-rw-r--r-- | vcl/source/graphic/VectorGraphicSearch.cxx | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/vcl/source/graphic/VectorGraphicSearch.cxx b/vcl/source/graphic/VectorGraphicSearch.cxx index 083dc6cf2741..3ac33db37cc3 100644 --- a/vcl/source/graphic/VectorGraphicSearch.cxx +++ b/vcl/source/graphic/VectorGraphicSearch.cxx @@ -30,7 +30,7 @@ private: std::unique_ptr<vcl::pdf::PDFiumDocument>& mpPdfDocument; std::unique_ptr<vcl::pdf::PDFiumPage> mpPage; std::unique_ptr<vcl::pdf::PDFiumTextPage> mpTextPage; - FPDF_SCHHANDLE mpSearchHandle; + std::unique_ptr<vcl::pdf::PDFiumSearchHandle> mpSearchHandle; public: sal_Int32 mnPageIndex; @@ -40,7 +40,6 @@ public: SearchContext(std::unique_ptr<vcl::pdf::PDFiumDocument>& pPdfDocument, sal_Int32 nPageIndex) : mpPdfDocument(pPdfDocument) - , mpSearchHandle(nullptr) , mnPageIndex(nPageIndex) , mnCurrentIndex(-1) { @@ -49,7 +48,7 @@ public: ~SearchContext() { if (mpSearchHandle) - FPDFText_FindClose(mpSearchHandle); + mpSearchHandle.reset(); if (mpTextPage) mpTextPage.reset(); if (mpPage) @@ -77,7 +76,7 @@ public: return true; if (mpSearchHandle) - FPDFText_FindClose(mpSearchHandle); + mpSearchHandle.reset(); if (mpTextPage) mpTextPage.reset(); @@ -114,15 +113,15 @@ public: if (maOptions.mbMatchWholeWord) nSearchFlags |= FPDF_MATCHWHOLEWORD; - mpSearchHandle - = FPDFText_FindStart(mpTextPage->getPointer(), pString, nSearchFlags, nStartIndex); + mpSearchHandle = std::make_unique<vcl::pdf::PDFiumSearchHandle>( + FPDFText_FindStart(mpTextPage->getPointer(), pString, nSearchFlags, nStartIndex)); return mpSearchHandle != nullptr; } bool next() { - if (mpSearchHandle && FPDFText_FindNext(mpSearchHandle)) + if (mpSearchHandle && FPDFText_FindNext(mpSearchHandle->getPointer())) { mnCurrentIndex = index(); return true; @@ -132,7 +131,7 @@ public: bool previous() { - if (mpSearchHandle && FPDFText_FindPrev(mpSearchHandle)) + if (mpSearchHandle && FPDFText_FindPrev(mpSearchHandle->getPointer())) { mnCurrentIndex = index(); return true; @@ -143,14 +142,14 @@ public: int index() { if (mpSearchHandle) - return FPDFText_GetSchResultIndex(mpSearchHandle); + return FPDFText_GetSchResultIndex(mpSearchHandle->getPointer()); return -1; } int size() { if (mpSearchHandle) - return FPDFText_GetSchCount(mpSearchHandle); + return FPDFText_GetSchCount(mpSearchHandle->getPointer()); return -1; } |