summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
Diffstat (limited to 'sw')
-rw-r--r--sw/qa/extras/tiledrendering/tiledrendering.cxx44
-rw-r--r--sw/source/uibase/inc/edtwin.hxx6
-rw-r--r--sw/source/uibase/uno/unotxdoc.cxx34
3 files changed, 56 insertions, 28 deletions
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 3111b5ca2dd1..f75ca63e1c77 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -313,6 +313,7 @@ void SwTiledRenderingTest::testPostKeyEvent()
pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'x', 0);
pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'x', 0);
+ Scheduler::ProcessEventsToIdle();
// Did we manage to insert the character after the first one?
CPPUNIT_ASSERT_EQUAL(OUString("Axaa bbb."), pShellCursor->GetPoint()->nNode.GetNode().GetTextNode()->GetText());
}
@@ -331,6 +332,7 @@ void SwTiledRenderingTest::testPostMouseEvent()
aStart.setX(aStart.getX() - 1000);
pXTextDocument->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONDOWN, aStart.getX(), aStart.getY(), 1, MOUSE_LEFT, 0);
pXTextDocument->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONUP, aStart.getX(), aStart.getY(), 1, MOUSE_LEFT, 0);
+ Scheduler::ProcessEventsToIdle();
// The new cursor position must be before the first word.
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), pShellCursor->GetPoint()->nContent.GetIndex());
comphelper::LibreOfficeKit::setActive(false);
@@ -935,20 +937,24 @@ void SwTiledRenderingTest::testShapeViewCursors()
pWrtShell2->GetView().BeginTextEdit(pObject, pView->GetSdrPageView(), pWrtShell2->GetWin());
pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'x', 0);
pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'x', 0);
-
+ Scheduler::ProcessEventsToIdle();
// Press a key in the second view, while the first one observes this.
- aView1.m_bOwnCursorInvalidated = false;
aView1.m_bViewCursorInvalidated = false;
aView2.m_bOwnCursorInvalidated = false;
- aView2.m_bViewCursorInvalidated = false;
+ const tools::Rectangle aLastOwnCursor1 = aView1.m_aOwnCursor;
+ const tools::Rectangle aLastViewCursor1 = aView1.m_aViewCursor;
+ const tools::Rectangle aLastOwnCursor2 = aView2.m_aOwnCursor;
+ const tools::Rectangle aLastViewCursor2 = aView2.m_aViewCursor;
+
pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'y', 0);
pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'y', 0);
+ Scheduler::ProcessEventsToIdle();
// Make sure that aView1 gets a view-only cursor notification, while
// aView2 gets a real cursor notification.
- CPPUNIT_ASSERT(!aView1.m_bOwnCursorInvalidated);
- CPPUNIT_ASSERT(aView1.m_bViewCursorInvalidated);
- CPPUNIT_ASSERT(aView2.m_bOwnCursorInvalidated);
- CPPUNIT_ASSERT(!aView2.m_bViewCursorInvalidated);
+ CPPUNIT_ASSERT(aView1.m_aOwnCursor == aLastOwnCursor1);
+ CPPUNIT_ASSERT(aView1.m_bViewCursorInvalidated && aLastViewCursor1 != aView1.m_aViewCursor);
+ CPPUNIT_ASSERT(aView2.m_bOwnCursorInvalidated && aLastOwnCursor2 != aView2.m_aOwnCursor);
+ CPPUNIT_ASSERT(aLastViewCursor2 == aView2.m_aViewCursor);
mxComponent->dispose();
mxComponent.clear();
@@ -1078,11 +1084,14 @@ void SwTiledRenderingTest::testTextEditViewInvalidations()
pWrtShell->GetView().BeginTextEdit(pObject, pView->GetSdrPageView(), pWrtShell->GetWin());
pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'x', 0);
pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'x', 0);
+ Scheduler::ProcessEventsToIdle();
// Assert that both views are invalidated when pressing a key while in text edit.
aView1.m_bTilesInvalidated = false;
pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'y', 0);
pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'y', 0);
+ Scheduler::ProcessEventsToIdle();
+
CPPUNIT_ASSERT(aView1.m_bTilesInvalidated);
pWrtShell->EndTextEdit();
@@ -1110,6 +1119,9 @@ void SwTiledRenderingTest::testUndoInvalidations()
pWrtShell->EndDoc();
pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'c', 0);
pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'c', 0);
+ Scheduler::ProcessEventsToIdle();
+ // ProcessEventsToIdle resets the view; set it again
+ SfxLokHelper::setView(nView1);
SwShellCursor* pShellCursor = pWrtShell->getShellCursor(false);
CPPUNIT_ASSERT_EQUAL(OUString("Aaa bbb.c"), pShellCursor->GetPoint()->nNode.GetNode().GetTextNode()->GetText());
@@ -1141,6 +1153,7 @@ void SwTiledRenderingTest::testUndoLimiting()
pWrtShell2->EndDoc();
pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'c', 0);
pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'c', 0);
+ Scheduler::ProcessEventsToIdle();
SwShellCursor* pShellCursor = pWrtShell2->getShellCursor(false);
CPPUNIT_ASSERT_EQUAL(OUString("Aaa bbb.c"), pShellCursor->GetPoint()->nNode.GetNode().GetTextNode()->GetText());
@@ -1168,6 +1181,7 @@ void SwTiledRenderingTest::testUndoShapeLimiting()
pWrtShell2->GetView().BeginTextEdit(pObject, pView->GetSdrPageView(), pWrtShell2->GetWin());
pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'x', 0);
pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'x', 0);
+ Scheduler::ProcessEventsToIdle();
// Assert that the first view can't and the second view can undo the insertion.
SwDoc* pDoc = pXTextDocument->GetDocShell()->GetDoc();
@@ -1197,6 +1211,7 @@ void SwTiledRenderingTest::testUndoDispatch()
SfxLokHelper::setView(nView1);
pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'c', 0);
pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'c', 0);
+ Scheduler::ProcessEventsToIdle();
// Click before the first word in the second view.
SfxLokHelper::setView(nView2);
@@ -1206,6 +1221,7 @@ void SwTiledRenderingTest::testUndoDispatch()
aStart.setX(aStart.getX() - 1000);
pXTextDocument->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONDOWN, aStart.getX(), aStart.getY(), 1, MOUSE_LEFT, 0);
pXTextDocument->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONUP, aStart.getX(), aStart.getY(), 1, MOUSE_LEFT, 0);
+ Scheduler::ProcessEventsToIdle();
uno::Reference<frame::XDesktop2> xDesktop = frame::Desktop::create(comphelper::getProcessComponentContext());
uno::Reference<frame::XFrame> xFrame2 = xDesktop->getActiveFrame();
@@ -1232,6 +1248,7 @@ void SwTiledRenderingTest::testUndoRepairDispatch()
SfxLokHelper::setView(nView1);
pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'c', 0);
pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'c', 0);
+ Scheduler::ProcessEventsToIdle();
// Assert that by default the second view can't undo the action.
SfxLokHelper::setView(nView2);
@@ -1272,6 +1289,7 @@ void SwTiledRenderingTest::testShapeTextUndoShells()
pWrtShell->GetView().BeginTextEdit(pObject, pView->GetSdrPageView(), pWrtShell->GetWin());
pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'x', 0);
pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'x', 0);
+ Scheduler::ProcessEventsToIdle();
// Make sure that the undo item remembers who created it.
SwDoc* pDoc = pXTextDocument->GetDocShell()->GetDoc();
@@ -1304,6 +1322,7 @@ void SwTiledRenderingTest::testShapeTextUndoGroupShells()
pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'x', 0);
pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::BACKSPACE);
pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::BACKSPACE);
+ Scheduler::ProcessEventsToIdle();
// Make sure that the undo item remembers who created it.
SwDoc* pDoc = pXTextDocument->GetDocShell()->GetDoc();
@@ -1316,6 +1335,7 @@ void SwTiledRenderingTest::testShapeTextUndoGroupShells()
EditView& rEditView = pView->GetTextEditOutlinerView()->GetEditView();
pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'x', 0);
pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'x', 0);
+ Scheduler::ProcessEventsToIdle();
// 0th para, 0th char -> 0th para, 1st char.
ESelection aWordSelection(0, 0, 0, 1);
rEditView.SetSelection(aWordSelection);
@@ -1590,22 +1610,23 @@ void SwTiledRenderingTest::testCommentEndTextEdit()
SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1);
pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'x', 0);
pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'x', 0);
+ Scheduler::ProcessEventsToIdle();
tools::Rectangle aBodyCursor = aView1.m_aOwnCursor;
// Create a comment and type a character there as well.
const int nCtrlAltC = KEY_MOD1 + KEY_MOD2 + 512 + 'c' - 'a';
pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'c', nCtrlAltC);
pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'c', nCtrlAltC);
- Scheduler::ProcessEventsToIdle();
pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'x', 0);
pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'x', 0);
-
+ Scheduler::ProcessEventsToIdle();
// End comment text edit by clicking in the body text area, and assert that
// no unexpected cursor callbacks are emitted at origin (top left corner of
// the document).
aView1.m_bOwnCursorAtOrigin = false;
pXTextDocument->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONDOWN, aBodyCursor.getX(), aBodyCursor.getY(), 1, MOUSE_LEFT, 0);
pXTextDocument->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONUP, aBodyCursor.getX(), aBodyCursor.getY(), 1, MOUSE_LEFT, 0);
+ Scheduler::ProcessEventsToIdle();
// This failed, the cursor was at 0, 0 at some point during end text edit
// of the comment.
CPPUNIT_ASSERT(!aView1.m_bOwnCursorAtOrigin);
@@ -1692,11 +1713,13 @@ void SwTiledRenderingTest::testUndoRepairResult()
SfxLokHelper::setView(nView2);
pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'b', 0);
pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'b', 0);
+ Scheduler::ProcessEventsToIdle();
// Insert a character in the first view.
SfxLokHelper::setView(nView1);
pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'a', 0);
pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'a', 0);
+ Scheduler::ProcessEventsToIdle();
// Assert that by default the second view can't undo the action.
SfxLokHelper::setView(nView2);
@@ -1725,11 +1748,14 @@ void SwTiledRenderingTest::testRedoRepairResult()
SfxLokHelper::setView(nView2);
pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'b', 0);
pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'b', 0);
+ Scheduler::ProcessEventsToIdle();
// Insert a character in the first view.
SfxLokHelper::setView(nView1);
pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'a', 0);
pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'a', 0);
+ Scheduler::ProcessEventsToIdle();
+
comphelper::dispatchCommand(".uno:Undo", {}, xListener);
CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt32>(0), pResult2->m_nDocRepair);
diff --git a/sw/source/uibase/inc/edtwin.hxx b/sw/source/uibase/inc/edtwin.hxx
index 2956783d1a7c..71e3f9a7b34d 100644
--- a/sw/source/uibase/inc/edtwin.hxx
+++ b/sw/source/uibase/inc/edtwin.hxx
@@ -284,11 +284,11 @@ public:
/// @see OutputDevice::LogicInvalidate().
void LogicInvalidate(const tools::Rectangle* pRectangle) override;
/// Same as MouseButtonDown(), but coordinates are in logic unit.
- void LogicMouseButtonDown(const MouseEvent& rMouseEvent);
+ virtual void LogicMouseButtonDown(const MouseEvent& rMouseEvent) override;
/// Same as MouseButtonUp(), but coordinates are in logic unit.
- void LogicMouseButtonUp(const MouseEvent& rMouseEvent);
+ virtual void LogicMouseButtonUp(const MouseEvent& rMouseEvent) override;
/// Same as MouseMove(), but coordinates are in logic unit.
- void LogicMouseMove(const MouseEvent& rMouseEvent);
+ virtual void LogicMouseMove(const MouseEvent& rMouseEvent) override;
/// Allows adjusting the point or mark of the selection to a document coordinate.
void SetCursorTwipPosition(const Point& rPosition, bool bPoint, bool bClearMark);
/// Allows starting or ending a graphic move or resize action.
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index c8a9b7ec7092..a0b549b11329 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3487,19 +3487,22 @@ void SwXTextDocument::postKeyEvent(int nType, int nCharCode, int nKeyCode)
if (!pWindow)
return;
- KeyEvent aEvent(nCharCode, nKeyCode, 0);
+ LOKAsyncEventData* pLOKEv = new LOKAsyncEventData;
+ pLOKEv->mpWindow = pWindow;
switch (nType)
{
case LOK_KEYEVENT_KEYINPUT:
- pWindow->KeyInput(aEvent);
+ pLOKEv->mnEvent = VclEventId::WindowKeyInput;
break;
case LOK_KEYEVENT_KEYUP:
- pWindow->KeyUp(aEvent);
+ pLOKEv->mnEvent = VclEventId::WindowKeyUp;
break;
default:
assert(false);
- break;
}
+
+ pLOKEv->maKeyEvent = KeyEvent(nCharCode, nKeyCode, 0);
+ Application::PostUserEvent(Link<void*, void>(pLOKEv, ITiledRenderable::LOKPostAsyncEvent));
}
void SwXTextDocument::postMouseEvent(int nType, int nX, int nY, int nCount, int nButtons, int nModifier)
@@ -3527,30 +3530,29 @@ void SwXTextDocument::postMouseEvent(int nType, int nX, int nY, int nCount, int
}
SwEditWin& rEditWin = pDocShell->GetView()->GetEditWin();
- Point aPos(nX , nY);
- MouseEvent aEvent(aPos, nCount, MouseEventModifiers::SIMPLECLICK, nButtons, nModifier);
+
+ LOKAsyncEventData* pLOKEv = new LOKAsyncEventData;
+ pLOKEv->mpWindow = &rEditWin;
switch (nType)
{
case LOK_MOUSEEVENT_MOUSEBUTTONDOWN:
- rEditWin.LogicMouseButtonDown(aEvent);
-
- if (nButtons & MOUSE_RIGHT)
- {
- const CommandEvent aCEvt(aPos, CommandEventId::ContextMenu, true, nullptr);
- rEditWin.Command(aCEvt);
- }
+ pLOKEv->mnEvent = VclEventId::WindowMouseButtonDown;
break;
case LOK_MOUSEEVENT_MOUSEBUTTONUP:
- rEditWin.LogicMouseButtonUp(aEvent);
+ pLOKEv->mnEvent = VclEventId::WindowMouseButtonUp;
break;
case LOK_MOUSEEVENT_MOUSEMOVE:
- rEditWin.LogicMouseMove(aEvent);
+ pLOKEv->mnEvent = VclEventId::WindowMouseMove;
break;
default:
assert(false);
- break;
}
+
+ pLOKEv->maMouseEvent = MouseEvent(Point(nX, nY), nCount,
+ MouseEventModifiers::SIMPLECLICK,
+ nButtons, nModifier);
+ Application::PostUserEvent(Link<void*, void>(pLOKEv, ITiledRenderable::LOKPostAsyncEvent));
}
void SwXTextDocument::setTextSelection(int nType, int nX, int nY)