Kaydet (Commit) 2d17cd6b authored tarafından Miklos Vajna's avatar Miklos Vajna

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 d524f3a8
......@@ -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 );
......
......@@ -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());
}
}
......
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