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

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Thu Feb 11 09:21:34 UTC 2021


 include/vcl/filter/PDFiumLibrary.hxx       |    3 +++
 vcl/source/graphic/VectorGraphicSearch.cxx |   16 +++-------------
 vcl/source/pdf/PDFiumLibrary.cxx           |   21 +++++++++++++++++++++
 3 files changed, 27 insertions(+), 13 deletions(-)

New commits:
commit ab882c0506c886eb32d8de0d2441de94920598bc
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Thu Feb 11 09:09:10 2021 +0100
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Thu Feb 11 10:20:50 2021 +0100

    pdfium: add a FPDFText_GetCharBox() wrapper
    
    Which was the last public use of PDFiumTextPage::getPointer().
    
    Change-Id: If3339f09ba38a3f10b19fe85cded718c913eb067
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110750
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
    Tested-by: Jenkins

diff --git a/include/vcl/filter/PDFiumLibrary.hxx b/include/vcl/filter/PDFiumLibrary.hxx
index 20480f1e1e26..5908f01e4ab0 100644
--- a/include/vcl/filter/PDFiumLibrary.hxx
+++ b/include/vcl/filter/PDFiumLibrary.hxx
@@ -179,6 +179,9 @@ public:
     unsigned int getUnicode(int index);
     std::unique_ptr<PDFiumSearchHandle> findStart(const OUString& rFindWhat, PDFFindFlags nFlags,
                                                   sal_Int32 nStartIndex);
+
+    /// Returned rect is no longer upside down and is in mm100.
+    basegfx::B2DRectangle getCharBox(int nIndex, double fPageHeight);
 };
 
 class VCL_DLLPUBLIC PDFiumPage final
diff --git a/vcl/source/graphic/VectorGraphicSearch.cxx b/vcl/source/graphic/VectorGraphicSearch.cxx
index aabfd220f651..09839c3524ef 100644
--- a/vcl/source/graphic/VectorGraphicSearch.cxx
+++ b/vcl/source/graphic/VectorGraphicSearch.cxx
@@ -169,20 +169,10 @@ public:
 
         for (int nCount = 0; nCount < nSize; nCount++)
         {
-            double left = 0.0;
-            double right = 0.0;
-            double bottom = 0.0;
-            double top = 0.0;
-
-            if (FPDFText_GetCharBox(mpTextPage->getPointer(), nIndex + nCount, &left, &right,
-                                    &bottom, &top))
+            basegfx::B2DRectangle aRectangle = mpTextPage->getCharBox(nIndex + nCount, fPageHeight);
+            if (!aRectangle.isEmpty())
             {
-                left = convertPointToMm100(left);
-                right = convertPointToMm100(right);
-                top = fPageHeight - convertPointToMm100(top);
-                bottom = fPageHeight - convertPointToMm100(bottom);
-
-                aRectangles.emplace_back(left, bottom, right, top);
+                aRectangles.push_back(aRectangle);
             }
         }
 
diff --git a/vcl/source/pdf/PDFiumLibrary.cxx b/vcl/source/pdf/PDFiumLibrary.cxx
index 278fb284901d..c14a73ddd469 100644
--- a/vcl/source/pdf/PDFiumLibrary.cxx
+++ b/vcl/source/pdf/PDFiumLibrary.cxx
@@ -24,6 +24,7 @@
 #include <osl/endian.h>
 #include <vcl/bitmap.hxx>
 #include <tools/stream.hxx>
+#include <tools/UnitConversion.hxx>
 
 #include <bitmap/BitmapWriteAccess.hxx>
 
@@ -1120,6 +1121,26 @@ PDFiumTextPage::~PDFiumTextPage()
 
 int PDFiumTextPage::countChars() { return FPDFText_CountChars(mpTextPage); }
 
+basegfx::B2DRectangle PDFiumTextPage::getCharBox(int nIndex, double fPageHeight)
+{
+    double left = 0.0;
+    double right = 0.0;
+    double bottom = 0.0;
+    double top = 0.0;
+
+    if (FPDFText_GetCharBox(mpTextPage, nIndex, &left, &right, &bottom, &top))
+    {
+        left = convertPointToMm100(left);
+        right = convertPointToMm100(right);
+        top = fPageHeight - convertPointToMm100(top);
+        bottom = fPageHeight - convertPointToMm100(bottom);
+
+        return basegfx::B2DRectangle(left, bottom, right, top);
+    }
+
+    return basegfx::B2DRectangle();
+}
+
 unsigned int PDFiumTextPage::getUnicode(int index)
 {
     return FPDFText_GetUnicode(mpTextPage, index);


More information about the Libreoffice-commits mailing list