[Libreoffice-commits] core.git: Branch 'libreoffice-5-0' - sw/inc sw/source

Miklos Vajna vmiklos at collabora.co.uk
Tue Jun 2 06:44:41 PDT 2015


 sw/inc/viscrs.hxx              |    2 +-
 sw/source/core/crsr/viscrs.cxx |   29 ++++++++++++++++++++++++++---
 2 files changed, 27 insertions(+), 4 deletions(-)

New commits:
commit 69d68246ea505bb89cfb5fe453a4bb7c618afc77
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Jun 2 14:47:21 2015 +0200

    sw: LOK_CALLBACK_TEXT_SELECTION should be the union of all selections
    
    E.g. if searching for a keyword and it's inside a text frame, then we
    have two cursors: one is an empty selection at the anchor point, and the
    other is the real selection. What happened is that we emitted two events
    for the two cursors, instead of merging them together.
    
    Fix the problem by not emitting the events in SwSelPaintRects::Show(),
    instead do it at once in SwShellCrsr::Show().
    
    Change-Id: Ie2c7691aaaea7ba8a32b5cfa718a45cba571f791

diff --git a/sw/inc/viscrs.hxx b/sw/inc/viscrs.hxx
index a15dbd3..159fb2f 100644
--- a/sw/inc/viscrs.hxx
+++ b/sw/inc/viscrs.hxx
@@ -96,7 +96,7 @@ public:
     // make a complete swap access to m_pCursorOverlay is needed there
     void swapContent(SwSelPaintRects& rSwap);
 
-    void Show();
+    void Show(std::vector<OString>* pSelectionRectangles = 0);
     void Hide();
     void Invalidate( const SwRect& rRect );
 
diff --git a/sw/source/core/crsr/viscrs.cxx b/sw/source/core/crsr/viscrs.cxx
index 38e6ef8..c3d591c 100644
--- a/sw/source/core/crsr/viscrs.cxx
+++ b/sw/source/core/crsr/viscrs.cxx
@@ -280,7 +280,7 @@ void SwShellCrsr::FillStartEnd(SwRect& rStart, SwRect& rEnd) const
     rEnd = lcl_getLayoutRect(pCursor->GetEndPos(), *pCursor->End());
 }
 
-void SwSelPaintRects::Show()
+void SwSelPaintRects::Show(std::vector<OString>* pSelectionRectangles)
 {
     SdrView *const pView = const_cast<SdrView*>(m_pCursorShell->GetDrawView());
 
@@ -379,7 +379,10 @@ void SwSelPaintRects::Show()
                 ss << rRect.SVRect().toString().getStr();
             }
             OString sRect = ss.str().c_str();
-            GetShell()->libreOfficeKitCallback(LOK_CALLBACK_TEXT_SELECTION, sRect.getStr());
+            if (!pSelectionRectangles)
+                GetShell()->libreOfficeKitCallback(LOK_CALLBACK_TEXT_SELECTION, sRect.getStr());
+            else
+                pSelectionRectangles->push_back(sRect);
         }
     }
 }
@@ -566,11 +569,31 @@ void SwShellCrsr::FillRects()
 
 void SwShellCrsr::Show()
 {
+    std::vector<OString> aSelectionRectangles;
     for(SwPaM& rPaM : GetRingContainer())
     {
         SwShellCrsr* pShCrsr = dynamic_cast<SwShellCrsr*>(&rPaM);
         if(pShCrsr)
-            pShCrsr->SwSelPaintRects::Show();
+            pShCrsr->SwSelPaintRects::Show(&aSelectionRectangles);
+    }
+
+    if (GetShell()->isTiledRendering())
+    {
+        std::stringstream ss;
+        bool bFirst = true;
+        for (size_t i = 0; i < aSelectionRectangles.size(); ++i)
+        {
+            const OString& rSelectionRectangle = aSelectionRectangles[i];
+            if (rSelectionRectangle.isEmpty())
+                continue;
+            if (bFirst)
+                bFirst = false;
+            else
+                ss << "; ";
+            ss << rSelectionRectangle.getStr();
+        }
+        OString sRect = ss.str().c_str();
+        GetShell()->libreOfficeKitCallback(LOK_CALLBACK_TEXT_SELECTION, sRect.getStr());
     }
 }
 


More information about the Libreoffice-commits mailing list