summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2020-05-31 12:02:39 +0200
committerTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2020-07-30 15:24:11 +0200
commit272cd803e4b63eeca1e6689f5c6147141a365ccb (patch)
tree33824f45b35d01cd34d79d7963f2b2555ef4ac96
parentpdfium: only init pdfium library one and destroy on LO exit (diff)
downloadcore-272cd803e4b63eeca1e6689f5c6147141a365ccb.tar.gz
core-272cd803e4b63eeca1e6689f5c6147141a365ccb.zip
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 (cherry picked from commit 044cfb405e44c5df25bccd6e421a1a228262a963)
-rw-r--r--include/vcl/VectorGraphicSearch.hxx3
-rw-r--r--vcl/source/graphic/VectorGraphicSearch.cxx76
2 files changed, 40 insertions, 39 deletions
diff --git a/include/vcl/VectorGraphicSearch.hxx b/include/vcl/VectorGraphicSearch.hxx
index b67c63a844d8..2dc8cca3b76a 100644
--- a/include/vcl/VectorGraphicSearch.hxx
+++ b/include/vcl/VectorGraphicSearch.hxx
@@ -19,8 +19,6 @@
#include <memory>
-class SearchContext;
-
enum class SearchStartPosition
{
Begin,
@@ -33,7 +31,6 @@ private:
class Implementation;
std::unique_ptr<Implementation> mpImplementation;
Graphic maGraphic;
- std::unique_ptr<SearchContext> mpSearchContext;
bool searchPDF(std::shared_ptr<VectorGraphicData> const& rData, OUString const& rSearchString,
SearchStartPosition eStartPosition);
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>();
}