summaryrefslogtreecommitdiff
path: root/sw/qa/extras
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-09-27 13:24:38 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-09-28 12:24:49 +0200
commitd44e2743ecda9bed183673812c6a2c1574061f15 (patch)
tree230bed43de3dad4a8463be04101ef7f9d02d7f55 /sw/qa/extras
parent69e7adc64ae3834213896f73c286848b1108d32a (diff)
sw: avoid emitting invalid cursor pos during end text edit of comment
A comment text edit (provided by editeng) works with relative twip coordinates, conversion of the cursor position to absolute twips happens in ImpEditView::ShowCursor(), provided that the pOutWin member has a map mode origin that respresents the offset correctly. This is not true during SwSidebarWin::DeactivatePostIt(), the map mode origin is already reset back to 0, so just don't emit callbacks during shutdown, the sw body text cursor will be shown later anyway. (cherry picked from commit 45fa73f87258f51bf37c92052723c4b99c49dc2d) Conflicts: include/sfx2/viewsh.hxx Change-Id: I02c15bb9fad99db8e43fd2f37df770dd165be788
Diffstat (limited to 'sw/qa/extras')
-rw-r--r--sw/qa/extras/tiledrendering/tiledrendering.cxx47
1 files changed, 45 insertions, 2 deletions
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index b61a11013d12..9da36aade9d1 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -76,6 +76,7 @@ public:
void testCreateViewGraphicSelection();
void testCreateViewTextSelection();
void testRedlineColors();
+ void testCommentEndTextEdit();
CPPUNIT_TEST_SUITE(SwTiledRenderingTest);
CPPUNIT_TEST(testRegisterCallback);
@@ -115,10 +116,11 @@ public:
CPPUNIT_TEST(testCreateViewGraphicSelection);
CPPUNIT_TEST(testCreateViewTextSelection);
CPPUNIT_TEST(testRedlineColors);
+ CPPUNIT_TEST(testCommentEndTextEdit);
CPPUNIT_TEST_SUITE_END();
private:
- SwXTextDocument* createDoc(const char* pName);
+ SwXTextDocument* createDoc(const char* pName = nullptr);
static void callback(int nType, const char* pPayload, void* pData);
void callbackImpl(int nType, const char* pPayload);
Rectangle m_aInvalidation;
@@ -148,7 +150,10 @@ SwTiledRenderingTest::SwTiledRenderingTest()
SwXTextDocument* SwTiledRenderingTest::createDoc(const char* pName)
{
- load(DATA_DIRECTORY, pName);
+ if (!pName)
+ loadURL("private:factory/swriter", nullptr);
+ else
+ load(DATA_DIRECTORY, pName);
SwXTextDocument* pTextDocument = dynamic_cast<SwXTextDocument*>(mxComponent.get());
CPPUNIT_ASSERT(pTextDocument);
@@ -622,6 +627,7 @@ class ViewCallback
{
public:
bool m_bOwnCursorInvalidated;
+ bool m_bOwnCursorAtOrigin;
Rectangle m_aOwnCursor;
bool m_bViewCursorInvalidated;
Rectangle m_aViewCursor;
@@ -636,6 +642,7 @@ public:
ViewCallback()
: m_bOwnCursorInvalidated(false),
+ m_bOwnCursorAtOrigin(false),
m_bViewCursorInvalidated(false),
m_bOwnSelectionSet(false),
m_bViewSelectionSet(false),
@@ -674,6 +681,8 @@ public:
m_aOwnCursor.setY(aSeq[1].toInt32());
m_aOwnCursor.setWidth(aSeq[2].toInt32());
m_aOwnCursor.setHeight(aSeq[3].toInt32());
+ if (m_aOwnCursor.getX() == 0 && m_aOwnCursor.getY() == 0)
+ m_bOwnCursorAtOrigin = true;
}
break;
case LOK_CALLBACK_INVALIDATE_VIEW_CURSOR:
@@ -1461,6 +1470,40 @@ void SwTiledRenderingTest::testRedlineColors()
comphelper::LibreOfficeKit::setActive(false);
}
+void SwTiledRenderingTest::testCommentEndTextEdit()
+{
+ // Create a document, type a character and remember the cursor position.
+ comphelper::LibreOfficeKit::setActive();
+ SwXTextDocument* pXTextDocument = createDoc();
+ ViewCallback aView1;
+ SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1);
+ pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'x', 0);
+ pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'x', 0);
+ 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);
+
+ // 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);
+ // This failed, the cursor was at 0, 0 at some point during end text edit
+ // of the comment.
+ CPPUNIT_ASSERT(!aView1.m_bOwnCursorAtOrigin);
+
+ mxComponent->dispose();
+ mxComponent.clear();
+ comphelper::LibreOfficeKit::setActive(false);
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SwTiledRenderingTest);
CPPUNIT_PLUGIN_IMPLEMENT();