diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2021-02-02 21:09:53 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2021-02-03 09:26:54 +0100 |
commit | 76f878e299796db2bf3f31b2519a87e6ca232609 (patch) | |
tree | 3144f737012e5586e0f960c0f37c3e6b53466727 | |
parent | 14d064cee7b76e8a2a2201d4da423336f68fe624 (diff) |
pdfium: add a FPDFText_FindStart() wrapper
Change-Id: I0bf77c116ab83ea557467da7f0c780d92db6a60e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110333
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
-rw-r--r-- | include/vcl/filter/PDFiumLibrary.hxx | 2 | ||||
-rw-r--r-- | vcl/source/graphic/VectorGraphicSearch.cxx | 5 | ||||
-rw-r--r-- | vcl/source/pdf/PDFiumLibrary.cxx | 8 |
3 files changed, 11 insertions, 4 deletions
diff --git a/include/vcl/filter/PDFiumLibrary.hxx b/include/vcl/filter/PDFiumLibrary.hxx index 418feede99b6..667fa614da70 100644 --- a/include/vcl/filter/PDFiumLibrary.hxx +++ b/include/vcl/filter/PDFiumLibrary.hxx @@ -180,6 +180,8 @@ public: int countChars(); unsigned int getUnicode(int index); + std::unique_ptr<PDFiumSearchHandle> findStart(const OUString& rFindWhat, sal_uInt64 nFlags, + sal_Int32 nStartIndex); }; class VCL_DLLPUBLIC PDFiumPage final diff --git a/vcl/source/graphic/VectorGraphicSearch.cxx b/vcl/source/graphic/VectorGraphicSearch.cxx index 3ac33db37cc3..01b76fb28b06 100644 --- a/vcl/source/graphic/VectorGraphicSearch.cxx +++ b/vcl/source/graphic/VectorGraphicSearch.cxx @@ -95,8 +95,6 @@ public: if (!mpTextPage) return false; - FPDF_WIDESTRING pString = reinterpret_cast<FPDF_WIDESTRING>(maSearchString.getStr()); - // Index where to start to search. -1 => at the end int nStartIndex = maOptions.meStartPosition == SearchStartPosition::End ? -1 : 0; @@ -113,8 +111,7 @@ public: if (maOptions.mbMatchWholeWord) nSearchFlags |= FPDF_MATCHWHOLEWORD; - mpSearchHandle = std::make_unique<vcl::pdf::PDFiumSearchHandle>( - FPDFText_FindStart(mpTextPage->getPointer(), pString, nSearchFlags, nStartIndex)); + mpSearchHandle = mpTextPage->findStart(maSearchString, nSearchFlags, nStartIndex); return mpSearchHandle != nullptr; } diff --git a/vcl/source/pdf/PDFiumLibrary.cxx b/vcl/source/pdf/PDFiumLibrary.cxx index fce8d4d539bd..c1571682f4b3 100644 --- a/vcl/source/pdf/PDFiumLibrary.cxx +++ b/vcl/source/pdf/PDFiumLibrary.cxx @@ -1100,6 +1100,14 @@ unsigned int PDFiumTextPage::getUnicode(int index) return FPDFText_GetUnicode(mpTextPage, index); } +std::unique_ptr<PDFiumSearchHandle> +PDFiumTextPage::findStart(const OUString& rFindWhat, sal_uInt64 nFlags, sal_Int32 nStartIndex) +{ + FPDF_WIDESTRING pFindWhat = reinterpret_cast<FPDF_WIDESTRING>(rFindWhat.getStr()); + return std::make_unique<vcl::pdf::PDFiumSearchHandle>( + FPDFText_FindStart(mpTextPage, pFindWhat, nFlags, nStartIndex)); +} + PDFiumSearchHandle::PDFiumSearchHandle(FPDF_SCHHANDLE pSearchHandle) : mpSearchHandle(pSearchHandle) { |