[Libreoffice-commits] core.git: sw/qa sw/source

Miklos Vajna vmiklos at collabora.co.uk
Mon Sep 12 10:31:37 UTC 2016


 sw/qa/extras/tiledrendering/tiledrendering.cxx |   30 +++++++++++++++++++++++++
 sw/source/core/draw/dview.cxx                  |    5 ++++
 sw/source/core/inc/dview.hxx                   |    3 ++
 sw/source/uibase/uiview/viewprt.cxx            |    2 -
 4 files changed, 39 insertions(+), 1 deletion(-)

New commits:
commit 65828fa693507d699369f0dbc3c0bfc31638d945
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Mon Sep 12 11:56:02 2016 +0200

    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 <vmiklos at collabora.co.uk>
    Tested-by: Jenkins <ci at libreoffice.org>

diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index f46136e..6b86cb6 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -71,6 +71,7 @@ public:
     void testTrackChangesCallback();
     void testRedlineUpdateCallback();
     void testSetViewGraphicSelection();
+    void testCreateViewGraphicSelection();
 
     CPPUNIT_TEST_SUITE(SwTiledRenderingTest);
     CPPUNIT_TEST(testRegisterCallback);
@@ -107,6 +108,7 @@ public:
     CPPUNIT_TEST(testTrackChangesCallback);
     CPPUNIT_TEST(testRedlineUpdateCallback);
     CPPUNIT_TEST(testSetViewGraphicSelection);
+    CPPUNIT_TEST(testCreateViewGraphicSelection);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -1271,6 +1273,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();
diff --git a/sw/source/core/draw/dview.cxx b/sw/source/core/draw/dview.cxx
index 763652f..ae40150 100644
--- a/sw/source/core/draw/dview.cxx
+++ b/sw/source/core/draw/dview.cxx
@@ -920,6 +920,11 @@ void SwDrawView::ReplaceMarkedDrawVirtObjs( SdrMarkView& _rMarkView )
     }
 }
 
+SfxViewShell* SwDrawView::GetSfxViewShell() const
+{
+    return rImp.GetShell()->GetSfxViewShell();
+}
+
 void SwDrawView::DeleteMarked()
 {
     SwDoc* pDoc = Imp().GetShell()->GetDoc();
diff --git a/sw/source/core/inc/dview.hxx b/sw/source/core/inc/dview.hxx
index 0242d9d..1b66f6f 100644
--- a/sw/source/core/inc/dview.hxx
+++ b/sw/source/core/inc/dview.hxx
@@ -112,6 +112,9 @@ public:
     // method to replace marked/selected <SwDrawVirtObj>
     // by its reference object for delete of selection and group selection
     static void ReplaceMarkedDrawVirtObjs( SdrMarkView& _rMarkView );
+
+    /// See SdrMarkView::GetSfxViewShell().
+    SfxViewShell* GetSfxViewShell() const override;
 };
 
 #endif
diff --git a/sw/source/uibase/uiview/viewprt.cxx b/sw/source/uibase/uiview/viewprt.cxx
index 2f401a0..213e0f9 100644
--- a/sw/source/uibase/uiview/viewprt.cxx
+++ b/sw/source/uibase/uiview/viewprt.cxx
@@ -250,7 +250,7 @@ void SwView::ExecutePrint(SfxRequest& rReq)
 
 int SwView::getPart() const
 {
-    if (!m_pWrtShell)
+    if (m_bInDtor || !m_pWrtShell)
         return 0;
 
     sal_uInt16 nPage, nLogPage;


More information about the Libreoffice-commits mailing list