[Libreoffice-commits] core.git: include/vcl vcl/source
Tomaž Vajngerl (via logerrit)
logerrit at kemper.freedesktop.org
Wed Jun 3 18:11:06 UTC 2020
include/vcl/VectorGraphicSearch.hxx | 3 -
vcl/source/graphic/VectorGraphicSearch.cxx | 76 +++++++++++++++--------------
2 files changed, 40 insertions(+), 39 deletions(-)
New commits:
commit 978198a055972aff00f47b70ca79e6322a5fbac3
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Sun May 31 12:02:39 2020 +0200
Commit: Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Wed Jun 3 20:10:29 2020 +0200
vcl: VectorGraphicSearch - move SearchContext into Implementation
Change-Id: I3bbf085fd8b8b66a56e364168c1e70b4ce986467
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95392
Tested-by: Tomaž Vajngerl <quikee at gmail.com>
Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
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 e8f7484320e3..be35c736e489 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:
@@ -180,17 +163,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)
{
@@ -241,45 +245,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>();
}
More information about the Libreoffice-commits
mailing list