[Libreoffice-commits] core.git: vcl/source

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Fri Jan 22 08:11:05 UTC 2021


 vcl/source/graphic/VectorGraphicSearch.cxx |   17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

New commits:
commit 497591d8e5cf664b4b85d0b464653f174a6b83e8
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Thu Jan 21 20:51:22 2021 +0100
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Fri Jan 22 09:10:18 2021 +0100

    pdfium: use PDFiumDocument in SearchContext
    
    Change-Id: Idbeff3c0bd3bd3134bbefbf6bb55b9a70fe106ce
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109768
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>

diff --git a/vcl/source/graphic/VectorGraphicSearch.cxx b/vcl/source/graphic/VectorGraphicSearch.cxx
index 40dcbad0da10..447c4638493f 100644
--- a/vcl/source/graphic/VectorGraphicSearch.cxx
+++ b/vcl/source/graphic/VectorGraphicSearch.cxx
@@ -27,7 +27,7 @@ namespace
 class SearchContext
 {
 private:
-    FPDF_DOCUMENT mpPdfDocument;
+    std::unique_ptr<vcl::pdf::PDFiumDocument>& mpPdfDocument;
     FPDF_PAGE mpPage;
     FPDF_TEXTPAGE mpTextPage;
     FPDF_SCHHANDLE mpSearchHandle;
@@ -38,7 +38,7 @@ public:
     OUString maSearchString;
     VectorGraphicSearchOptions maOptions;
 
-    SearchContext(FPDF_DOCUMENT pPdfDocument, sal_Int32 nPageIndex)
+    SearchContext(std::unique_ptr<vcl::pdf::PDFiumDocument>& pPdfDocument, sal_Int32 nPageIndex)
         : mpPdfDocument(pPdfDocument)
         , mpPage(nullptr)
         , mpTextPage(nullptr)
@@ -64,12 +64,9 @@ public:
         if (!mpPdfDocument)
             return aSize;
 
-        FS_SIZEF aPDFSize;
-        if (FPDF_GetPageSizeByIndexF(mpPdfDocument, mnPageIndex, &aPDFSize))
-        {
-            aSize = basegfx::B2DSize(convertPointToMm100(aPDFSize.width),
-                                     convertPointToMm100(aPDFSize.height));
-        }
+        basegfx::B2DSize aPDFSize = mpPdfDocument->getPageSize(mnPageIndex);
+        aSize = basegfx::B2DSize(convertPointToMm100(aPDFSize.getX()),
+                                 convertPointToMm100(aPDFSize.getY()));
         return aSize;
     }
 
@@ -93,7 +90,7 @@ public:
         maSearchString = rSearchString;
         maOptions = rOptions;
 
-        mpPage = FPDF_LoadPage(mpPdfDocument, mnPageIndex);
+        mpPage = FPDF_LoadPage(mpPdfDocument->getPointer(), mnPageIndex);
         if (!mpPage)
             return false;
 
@@ -275,7 +272,7 @@ bool VectorGraphicSearch::searchPDF(std::shared_ptr<VectorGraphicData> const& rD
     sal_Int32 nPageIndex = std::max(rData->getPageIndex(), sal_Int32(0));
 
     mpImplementation->mpSearchContext.reset(
-        new SearchContext(mpImplementation->mpPdfDocument->getPointer(), nPageIndex));
+        new SearchContext(mpImplementation->mpPdfDocument, nPageIndex));
     return true;
 }
 


More information about the Libreoffice-commits mailing list