[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - sd/source

Tomaž Vajngerl (via logerrit) logerrit at kemper.freedesktop.org
Tue Jun 9 13:24:37 UTC 2020


 sd/source/ui/view/Outliner.cxx |   36 +++++++++++++++++++++++-------------
 1 file changed, 23 insertions(+), 13 deletions(-)

New commits:
commit 42cfe2309bd9731d0e5b497356af5834757521bb
Author:     Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
AuthorDate: Fri May 29 08:33:42 2020 +0200
Commit:     Tomaž Vajngerl <quikee at gmail.com>
CommitDate: Tue Jun 9 15:23:38 2020 +0200

    sd: remove code dupl. when getting PDF text selection for LOK
    
    Change-Id: I61d0a9851e9cfe60e9672acec38946b0b25f310f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95349
    Tested-by: Jenkins
    Reviewed-by: Tomaž Vajngerl <quikee at gmail.com>
    (cherry picked from commit 06ddbd4a7a15b80b0286b359bd0a05812fd7ee75)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95924
    Tested-by: Tomaž Vajngerl <quikee at gmail.com>

diff --git a/sd/source/ui/view/Outliner.cxx b/sd/source/ui/view/Outliner.cxx
index 0d69cf872090..f60748bb13a5 100644
--- a/sd/source/ui/view/Outliner.cxx
+++ b/sd/source/ui/view/Outliner.cxx
@@ -704,11 +704,16 @@ basegfx::B2DRange b2DRectangleFromRectangle( const ::tools::Rectangle& rRect )
                                  rRect.IsHeightEmpty() ? rRect.Top() : rRect.Bottom());
 }
 
-void getPDFSelections(std::vector<basegfx::B2DRectangle> & rSubSelections,
-                      std::unique_ptr<VectorGraphicSearch> & rVectorGraphicSearch,
-                      SdrObject* pObject)
+basegfx::B2DRectangle getPDFSelection(std::unique_ptr<VectorGraphicSearch> & rVectorGraphicSearch,
+                                       SdrObject* pObject)
 {
-    basegfx::B2DSize aPdfPageSize = rVectorGraphicSearch->pageSize();
+    basegfx::B2DRectangle aSelection;
+
+    auto const & rTextRectangles = rVectorGraphicSearch->getTextRectangles();
+    if (rTextRectangles.empty())
+        return aSelection;
+
+    basegfx::B2DSize aPdfPageSizeHMM = rVectorGraphicSearch->pageSize();
 
     basegfx::B2DRectangle aObjectB2DRectHMM(b2DRectangleFromRectangle(pObject->GetLogicRect()));
 
@@ -716,24 +721,24 @@ void getPDFSelections(std::vector<basegfx::B2DRectangle> & rSubSelections,
     // coordinates to the page relative coordinates
     basegfx::B2DHomMatrix aB2DMatrix;
 
-    aB2DMatrix.scale(aObjectB2DRectHMM.getWidth() / aPdfPageSize.getX(),
-                     aObjectB2DRectHMM.getHeight() / aPdfPageSize.getY());
+    aB2DMatrix.scale(aObjectB2DRectHMM.getWidth() / aPdfPageSizeHMM.getX(),
+                     aObjectB2DRectHMM.getHeight() / aPdfPageSizeHMM.getY());
 
     aB2DMatrix.translate(aObjectB2DRectHMM.getMinX(), aObjectB2DRectHMM.getMinY());
 
-    basegfx::B2DRectangle aCombined;
 
     for (auto const & rRectangle : rVectorGraphicSearch->getTextRectangles())
     {
         basegfx::B2DRectangle aRectangle(rRectangle);
         aRectangle *= aB2DMatrix;
-        if (aCombined.isEmpty())
-            aCombined = aRectangle;
+
+        if (aSelection.isEmpty())
+            aSelection = aRectangle;
         else
-            aCombined.expand(aRectangle);
+            aSelection.expand(aRectangle);
     }
 
-    rSubSelections.push_back(aCombined);
+    return aSelection;
 }
 
 } // end namespace
@@ -862,7 +867,9 @@ bool SdOutliner::SearchAndReplaceOnce(std::vector<sd::SearchSelection>* pSelecti
                     mpView->UnmarkAllObj(pPageView);
 
                     std::vector<basegfx::B2DRectangle> aSubSelections;
-                    getPDFSelections(aSubSelections, mpImpl->mpVectorGraphicSearch, mpObj);
+                    basegfx::B2DRectangle aSubSelection = getPDFSelection(mpImpl->mpVectorGraphicSearch, mpObj);
+                    if (!aSubSelection.isEmpty())
+                        aSubSelections.push_back(aSubSelection);
                     mpView->MarkObj(mpObj, pPageView, false, false, aSubSelections);
                 }
             }
@@ -1263,7 +1270,10 @@ void SdOutliner::ProvideNextTextObject()
                             mpView->UnmarkAllObj(pPageView);
 
                             std::vector<basegfx::B2DRectangle> aSubSelections;
-                            getPDFSelections(aSubSelections, mpImpl->mpVectorGraphicSearch, mpObj);
+                            basegfx::B2DRectangle aSubSelection = getPDFSelection(mpImpl->mpVectorGraphicSearch, mpObj);
+                            if (!aSubSelection.isEmpty())
+                                aSubSelections.push_back(aSubSelection);
+
                             mpView->MarkObj(mpObj, pPageView, false, false, aSubSelections);
 
                             mpDrawDocument->GetDocSh()->SetWaitCursor( false );


More information about the Libreoffice-commits mailing list