From 1cabcedcff279b95635e457ef36bb4a07f7947aa Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Mon, 12 Sep 2016 11:56:02 +0200 Subject: sw: implement SdrMarkView::GetSfxViewShell() API With this, the graphic selection is no longer lost when creating a new view. That happened as the SwView ctor calls SdrMarkView::SetMarkHandles() while the new view is not yet current, which resulted clearing the graphic selection in the old view, not in the new one. A side-effect of introducing SwDrawView::GetSfxViewShell() is that now SwView::getPart() is called from the SwView dtor, guard against doing any real work there in that situation to avoid potentially reading already deleted data. Change-Id: I4fab39a907d2cbe228c0fc8d44bedc64893387d1 Reviewed-on: https://gerrit.libreoffice.org/28832 Reviewed-by: Miklos Vajna Tested-by: Jenkins (cherry picked from commit 65828fa693507d699369f0dbc3c0bfc31638d945) --- sw/qa/extras/tiledrendering/tiledrendering.cxx | 30 ++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'sw/qa') diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index 4861f128dd8e..c8dbaa493336 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -72,6 +72,7 @@ public: void testTrackChangesCallback(); void testRedlineUpdateCallback(); void testSetViewGraphicSelection(); + void testCreateViewGraphicSelection(); CPPUNIT_TEST_SUITE(SwTiledRenderingTest); CPPUNIT_TEST(testRegisterCallback); @@ -108,6 +109,7 @@ public: CPPUNIT_TEST(testTrackChangesCallback); CPPUNIT_TEST(testRedlineUpdateCallback); CPPUNIT_TEST(testSetViewGraphicSelection); + CPPUNIT_TEST(testCreateViewGraphicSelection); CPPUNIT_TEST_SUITE_END(); private: @@ -1272,6 +1274,34 @@ void SwTiledRenderingTest::testSetViewGraphicSelection() comphelper::LibreOfficeKit::setActive(false); } +void SwTiledRenderingTest::testCreateViewGraphicSelection() +{ + // Load a document. + comphelper::LibreOfficeKit::setActive(); + SwXTextDocument* pXTextDocument = createDoc("frame.odt"); + ViewCallback aView1; + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1); + + // Mark the textframe in the first view. + SwWrtShell* pWrtShell = pXTextDocument->GetDocShell()->GetWrtShell(); + SdrPage* pPage = pWrtShell->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0); + SdrObject* pObject = pPage->GetObj(0); + SdrView* pView = pWrtShell->GetDrawView(); + aView1.m_bGraphicSelection = true; + pView->MarkObj(pObject, pView->GetSdrPageView()); + CPPUNIT_ASSERT(aView1.m_bGraphicSelection); + + // Create a second view. + SfxLokHelper::createView(); + // This was false, creating a second view cleared the selection of the + // first one. + CPPUNIT_ASSERT(aView1.m_bGraphicSelection); + + mxComponent->dispose(); + mxComponent.clear(); + comphelper::LibreOfficeKit::setActive(false); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SwTiledRenderingTest); CPPUNIT_PLUGIN_IMPLEMENT(); -- cgit