diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2021-02-03 21:00:58 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2021-02-04 09:11:14 +0100 |
commit | 71c32c31dab86fe9c6d5893eee6821beaa3a3f43 (patch) | |
tree | ca58250646f93ebed913a8b8ded91fe71a2122b8 /vcl | |
parent | fd6e736c20f54d253921123e5baeb75da8d248f0 (diff) |
pdfium: add PDFFindFlags wrapper
So that vcl::pdf::PDFiumTextPage::findStart() can be called without
including fpdf_text.h.
Change-Id: I6a765be6176ec77ca24f592e2e2210654debe075
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110391
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/graphic/VectorGraphicSearch.cxx | 14 | ||||
-rw-r--r-- | vcl/source/pdf/PDFiumLibrary.cxx | 11 |
2 files changed, 16 insertions, 9 deletions
diff --git a/vcl/source/graphic/VectorGraphicSearch.cxx b/vcl/source/graphic/VectorGraphicSearch.cxx index 01b76fb28b06..59e51ea795e2 100644 --- a/vcl/source/graphic/VectorGraphicSearch.cxx +++ b/vcl/source/graphic/VectorGraphicSearch.cxx @@ -101,15 +101,15 @@ public: if (mnCurrentIndex >= 0) nStartIndex = mnCurrentIndex; - // FPDF_MATCHCASE, FPDF_MATCHWHOLEWORD, FPDF_CONSECUTIVE - // FPDF_MATCHCASE - If not set, it will not match case by default. - // FPDF_MATCHWHOLEWORD - If not set, it will not match the whole word by default. - // FPDF_CONSECUTIVE - If not set, it will skip past the current match to look for the next match. - int nSearchFlags = 0; + // vcl::pdf::PDFFindFlags::MatchCase, vcl::pdf::PDFFindFlags::MatchWholeWord, vcl::pdf::PDFFindFlags::Consecutive + // vcl::pdf::PDFFindFlags::MatchCase - If not set, it will not match case by default. + // vcl::pdf::PDFFindFlags::MatchWholeWord - If not set, it will not match the whole word by default. + // vcl::pdf::PDFFindFlags::Consecutive - If not set, it will skip past the current match to look for the next match. + vcl::pdf::PDFFindFlags nSearchFlags{}; if (maOptions.mbMatchCase) - nSearchFlags |= FPDF_MATCHCASE; + nSearchFlags |= vcl::pdf::PDFFindFlags::MatchCase; if (maOptions.mbMatchWholeWord) - nSearchFlags |= FPDF_MATCHWHOLEWORD; + nSearchFlags |= vcl::pdf::PDFFindFlags::MatchWholeWord; mpSearchHandle = mpTextPage->findStart(maSearchString, nSearchFlags, nStartIndex); diff --git a/vcl/source/pdf/PDFiumLibrary.cxx b/vcl/source/pdf/PDFiumLibrary.cxx index c1571682f4b3..9a13ae930fb5 100644 --- a/vcl/source/pdf/PDFiumLibrary.cxx +++ b/vcl/source/pdf/PDFiumLibrary.cxx @@ -114,6 +114,13 @@ static_assert(static_cast<int>(vcl::pdf::PDFFillMode::Alternate) == FPDF_FILLMOD static_assert(static_cast<int>(vcl::pdf::PDFFillMode::Winding) == FPDF_FILLMODE_WINDING, "PDFFillMode::Winding value mismatch"); +static_assert(static_cast<int>(vcl::pdf::PDFFindFlags::MatchCase) == FPDF_MATCHCASE, + "PDFFindFlags::MatchCase value mismatch"); +static_assert(static_cast<int>(vcl::pdf::PDFFindFlags::MatchWholeWord) == FPDF_MATCHWHOLEWORD, + "PDFFindFlags::MatchWholeWord value mismatch"); +static_assert(static_cast<int>(vcl::pdf::PDFFindFlags::Consecutive) == FPDF_CONSECUTIVE, + "PDFFindFlags::Consecutive value mismatch"); + namespace { /// Callback class to be used with FPDF_SaveWithVersion(). @@ -1101,11 +1108,11 @@ unsigned int PDFiumTextPage::getUnicode(int index) } std::unique_ptr<PDFiumSearchHandle> -PDFiumTextPage::findStart(const OUString& rFindWhat, sal_uInt64 nFlags, sal_Int32 nStartIndex) +PDFiumTextPage::findStart(const OUString& rFindWhat, PDFFindFlags 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)); + FPDFText_FindStart(mpTextPage, pFindWhat, static_cast<sal_uInt32>(nFlags), nStartIndex)); } PDFiumSearchHandle::PDFiumSearchHandle(FPDF_SCHHANDLE pSearchHandle) |