summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2016-09-14 12:51:05 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-09-14 19:48:53 +0200
commit80fc0074689d657fbbf479da534f782bb9cc3cca (patch)
treec5367391094479b50af6f3db5ecf3058367b2fee
parent5f81b7a3a2db50b1ead2b07f86be94613b781c67 (diff)
sd lok draw text: make sure watching views have no cursors
These additional views are only created to follow the updates done in the editing view, not to contribute additional cursors. With this, if the first view edits a shape text and the second view is created, then no unwanted text view cursor is created in the first view for the shape text from the second view. Be precise in the unit test and make sure that cursors from all views are hidden, because even without a fix the cursor of view #2 is hidden, but not from view #3, so the test wouldn't fail without the fix. (But hardcoding the 0-1 and 2-3 view IDs exposed by Impress before/after initializeForRendering() would be ugly.) Change-Id: Idf64f7bfcc35c98a5eada9a0a523a9b45b65a211 (cherry picked from commit eefccb4a103729e73ba7dcb512c615bc161d7b2b)
-rw-r--r--sd/qa/unit/tiledrendering/tiledrendering.cxx69
-rw-r--r--svx/source/svdraw/svdedxv.cxx2
2 files changed, 71 insertions, 0 deletions
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index e9208a74bad3..38c79b411081 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -71,6 +71,7 @@ public:
void testViewLock();
void testUndoLimiting();
void testCreateViewGraphicSelection();
+ void testCreateViewTextCursor();
CPPUNIT_TEST_SUITE(SdTiledRenderingTest);
CPPUNIT_TEST(testRegisterCallback);
@@ -97,6 +98,7 @@ public:
CPPUNIT_TEST(testViewLock);
CPPUNIT_TEST(testUndoLimiting);
CPPUNIT_TEST(testCreateViewGraphicSelection);
+ CPPUNIT_TEST(testCreateViewTextCursor);
CPPUNIT_TEST_SUITE_END();
private:
@@ -866,6 +868,8 @@ public:
bool m_bCursorVisibleChanged;
bool m_bViewLock;
bool m_bTilesInvalidated;
+ std::map<int, bool> m_aViewCursorInvalidations;
+ std::map<int, bool> m_aViewCursorVisibilities;
ViewCallback()
: m_bGraphicSelectionInvalidated(false),
@@ -919,6 +923,24 @@ public:
m_bViewLock = aTree.get_child("rectangle").get_value<std::string>() != "EMPTY";
}
break;
+ case LOK_CALLBACK_INVALIDATE_VIEW_CURSOR:
+ {
+ std::stringstream aStream(pPayload);
+ boost::property_tree::ptree aTree;
+ boost::property_tree::read_json(aStream, aTree);
+ int nViewId = aTree.get_child("viewId").get_value<int>();
+ m_aViewCursorInvalidations[nViewId] = true;
+ }
+ break;
+ case LOK_CALLBACK_VIEW_CURSOR_VISIBLE:
+ {
+ std::stringstream aStream(pPayload);
+ boost::property_tree::ptree aTree;
+ boost::property_tree::read_json(aStream, aTree);
+ int nViewId = aTree.get_child("viewId").get_value<int>();
+ m_aViewCursorVisibilities[nViewId] = OString("true") == pPayload;
+ }
+ break;
}
}
};
@@ -1148,6 +1170,53 @@ void SdTiledRenderingTest::testCreateViewGraphicSelection()
comphelper::LibreOfficeKit::setActive(false);
}
+void SdTiledRenderingTest::testCreateViewTextCursor()
+{
+ comphelper::LibreOfficeKit::setActive();
+
+ // Load a document and register a callback.
+ SdXImpressDocument* pXImpressDocument = createDoc("title-shape.odp");
+ ViewCallback aView1;
+ SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1);
+
+ // Begin text edit.
+ pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 0, awt::Key::TAB);
+ pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 0, awt::Key::TAB);
+ pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'x', 0);
+ pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'x', 0);
+ Scheduler::ProcessEventsToIdle();
+ sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
+ SdrView* pSdrView = pViewShell->GetView();
+ CPPUNIT_ASSERT(pSdrView->IsTextEdit());
+
+ // Make sure that creating a new view either doesn't affect the previous
+ // one, or at least the effect is not visible at the end.
+ aView1.m_aViewCursorInvalidations.clear();
+ aView1.m_aViewCursorVisibilities.clear();
+ SfxLokHelper::createView();
+ pXImpressDocument->initializeForTiledRendering({});
+ ViewCallback aView2;
+ SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView2);
+ bool bFoundCursor = false;
+ for (const auto& rInvalidation : aView1.m_aViewCursorInvalidations)
+ {
+ auto itVisibility = aView1.m_aViewCursorVisibilities.find(rInvalidation.first);
+ // For each cursor invalidation: if there is no visibility or the visibility is true, that's a problem.
+ if (itVisibility == aView1.m_aViewCursorVisibilities.end() || (itVisibility != aView1.m_aViewCursorVisibilities.end() && itVisibility->second))
+ {
+ bFoundCursor = true;
+ break;
+ }
+ }
+ // This failed: the second view created an unexpected view cursor in the
+ // first view.
+ CPPUNIT_ASSERT(!bFoundCursor);
+
+ mxComponent->dispose();
+ mxComponent.clear();
+ comphelper::LibreOfficeKit::setActive(false);
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SdTiledRenderingTest);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx
index 8960aeed10ca..eca77eccd38a 100644
--- a/svx/source/svdraw/svdedxv.cxx
+++ b/svx/source/svdraw/svdedxv.cxx
@@ -159,6 +159,7 @@ SdrPageView* SdrObjEditView::ShowSdrPage(SdrPage* pPage)
// registers the view shell of this draw view, and not the view
// shell of pView.
OutlinerView* pOutlinerView = pView->ImpMakeOutlinerView(static_cast<vcl::Window*>(pOutDev), !bEmpty, nullptr, GetSfxViewShell());
+ pOutlinerView->HideCursor();
pView->GetTextEditOutliner()->InsertView(pOutlinerView);
}
}
@@ -912,6 +913,7 @@ bool SdrObjEditView::SdrBeginTextEdit(
if(&rOutDev != pWin && OUTDEV_WINDOW == rOutDev.GetOutDevType())
{
OutlinerView* pOutlView = ImpMakeOutlinerView(static_cast<vcl::Window*>(&rOutDev), !bEmpty, nullptr);
+ pOutlView->HideCursor();
pTextEditOutliner->InsertView(pOutlView);
}
}