Kaydet (Commit) 69d68246 authored tarafından Miklos Vajna's avatar Miklos Vajna Kaydeden (comit) Jan Holesovsky

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
üst 665da464
...@@ -96,7 +96,7 @@ public: ...@@ -96,7 +96,7 @@ public:
// make a complete swap access to m_pCursorOverlay is needed there // make a complete swap access to m_pCursorOverlay is needed there
void swapContent(SwSelPaintRects& rSwap); void swapContent(SwSelPaintRects& rSwap);
void Show(); void Show(std::vector<OString>* pSelectionRectangles = 0);
void Hide(); void Hide();
void Invalidate( const SwRect& rRect ); void Invalidate( const SwRect& rRect );
......
...@@ -280,7 +280,7 @@ void SwShellCrsr::FillStartEnd(SwRect& rStart, SwRect& rEnd) const ...@@ -280,7 +280,7 @@ void SwShellCrsr::FillStartEnd(SwRect& rStart, SwRect& rEnd) const
rEnd = lcl_getLayoutRect(pCursor->GetEndPos(), *pCursor->End()); 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()); SdrView *const pView = const_cast<SdrView*>(m_pCursorShell->GetDrawView());
...@@ -379,7 +379,10 @@ void SwSelPaintRects::Show() ...@@ -379,7 +379,10 @@ void SwSelPaintRects::Show()
ss << rRect.SVRect().toString().getStr(); ss << rRect.SVRect().toString().getStr();
} }
OString sRect = ss.str().c_str(); 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() ...@@ -566,11 +569,31 @@ void SwShellCrsr::FillRects()
void SwShellCrsr::Show() void SwShellCrsr::Show()
{ {
std::vector<OString> aSelectionRectangles;
for(SwPaM& rPaM : GetRingContainer()) for(SwPaM& rPaM : GetRingContainer())
{ {
SwShellCrsr* pShCrsr = dynamic_cast<SwShellCrsr*>(&rPaM); SwShellCrsr* pShCrsr = dynamic_cast<SwShellCrsr*>(&rPaM);
if(pShCrsr) 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());
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment