diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2020-05-31 12:02:39 +0200 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2020-06-09 15:28:53 +0200 |
commit | 044cfb405e44c5df25bccd6e421a1a228262a963 (patch) | |
tree | 96e096ec4f23c8ec0f48d3ef4ab36e589f61814d /vcl | |
parent | 3538b83c8d83e66f63c745bd769d118117704026 (diff) |
vcl: VectorGraphicSearch - move SearchContext into Implementation
Change-Id: I3bbf085fd8b8b66a56e364168c1e70b4ce986467
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95392
Tested-by: Tomaž Vajngerl <quikee@gmail.com>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
(cherry picked from commit 978198a055972aff00f47b70ca79e6322a5fbac3)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95934
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/graphic/VectorGraphicSearch.cxx | 76 |
1 files changed, 40 insertions, 36 deletions
diff --git a/vcl/source/graphic/VectorGraphicSearch.cxx b/vcl/source/graphic/VectorGraphicSearch.cxx index 5c4022685f71..911c19cebd38 100644 --- a/vcl/source/graphic/VectorGraphicSearch.cxx +++ b/vcl/source/graphic/VectorGraphicSearch.cxx @@ -17,25 +17,8 @@ #include <fpdf_doc.h> #include <fpdf_text.h> -class VectorGraphicSearch::Implementation +namespace { -public: - std::shared_ptr<vcl::pdf::PDFium> mpPDFium; - FPDF_DOCUMENT mpPdfDocument; - - Implementation() - : mpPDFium(vcl::pdf::PDFiumLibrary::get()) - , mpPdfDocument(nullptr) - { - } - - ~Implementation() - { - if (mpPdfDocument) - FPDF_CloseDocument(mpPdfDocument); - } -}; - class SearchContext { private: @@ -181,17 +164,38 @@ public: } }; +} // end anonymous namespace + +class VectorGraphicSearch::Implementation +{ +public: + std::shared_ptr<vcl::pdf::PDFium> mpPDFium; + FPDF_DOCUMENT mpPdfDocument; + + std::unique_ptr<SearchContext> mpSearchContext; + + Implementation() + : mpPDFium(vcl::pdf::PDFiumLibrary::get()) + , mpPdfDocument(nullptr) + { + } + + ~Implementation() + { + mpSearchContext.reset(); + + if (mpPdfDocument) + FPDF_CloseDocument(mpPdfDocument); + } +}; + VectorGraphicSearch::VectorGraphicSearch(Graphic const& rGraphic) : mpImplementation(std::make_unique<VectorGraphicSearch::Implementation>()) , maGraphic(rGraphic) { } -VectorGraphicSearch::~VectorGraphicSearch() -{ - mpSearchContext.reset(); - mpImplementation.reset(); -} +VectorGraphicSearch::~VectorGraphicSearch() { mpImplementation.reset(); } bool VectorGraphicSearch::search(OUString const& rSearchString, SearchStartPosition eStartPosition) { @@ -242,45 +246,45 @@ bool VectorGraphicSearch::searchPDF(std::shared_ptr<VectorGraphicData> const& rD sal_Int32 nPageIndex = std::max(rData->getPageIndex(), sal_Int32(0)); - mpSearchContext.reset(new SearchContext(mpImplementation->mpPdfDocument, nPageIndex, - rSearchString, eStartPosition)); + mpImplementation->mpSearchContext.reset(new SearchContext( + mpImplementation->mpPdfDocument, nPageIndex, rSearchString, eStartPosition)); - return mpSearchContext->initialize(); + return mpImplementation->mpSearchContext->initialize(); } basegfx::B2DSize VectorGraphicSearch::pageSize() { basegfx::B2DSize aSize; - if (mpSearchContext) - aSize = mpSearchContext->getPageSize(); + if (mpImplementation->mpSearchContext) + aSize = mpImplementation->mpSearchContext->getPageSize(); return aSize; } bool VectorGraphicSearch::next() { - if (mpSearchContext) - return mpSearchContext->next(); + if (mpImplementation->mpSearchContext) + return mpImplementation->mpSearchContext->next(); return false; } bool VectorGraphicSearch::previous() { - if (mpSearchContext) - return mpSearchContext->previous(); + if (mpImplementation->mpSearchContext) + return mpImplementation->mpSearchContext->previous(); return false; } int VectorGraphicSearch::index() { - if (mpSearchContext) - return mpSearchContext->index(); + if (mpImplementation->mpSearchContext) + return mpImplementation->mpSearchContext->index(); return -1; } std::vector<basegfx::B2DRectangle> VectorGraphicSearch::getTextRectangles() { - if (mpSearchContext) - return mpSearchContext->getTextRectangles(); + if (mpImplementation->mpSearchContext) + return mpImplementation->mpSearchContext->getTextRectangles(); return std::vector<basegfx::B2DRectangle>(); } |