diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-06-02 14:47:21 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-06-02 15:04:04 +0200 |
commit | 2d17cd6b03a214393755ddfed5ba50a18f0cd774 (patch) | |
tree | 1b34181d6980847c2d4084c8451c356fffadb82a /sw | |
parent | d524f3a895af04b7b359468f1e743409b2e553b5 (diff) |
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
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/viscrs.hxx | 2 | ||||
-rw-r--r-- | sw/source/core/crsr/viscrs.cxx | 29 |
2 files changed, 27 insertions, 4 deletions
diff --git a/sw/inc/viscrs.hxx b/sw/inc/viscrs.hxx index a15dbd30b04b..159fb2ffbc41 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 38e6ef867ef8..c3d591c8c215 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()); } } |