[Libreoffice-commits] core.git: include/svx sd/qa svx/source

Miklos Vajna vmiklos at collabora.co.uk
Fri Sep 2 12:54:58 UTC 2016


 include/svx/svdedxv.hxx                      |    3 --
 include/svx/svdmrkv.hxx                      |    4 +++
 sd/qa/unit/tiledrendering/tiledrendering.cxx |   33 +++++++++++++++++++++++++++
 svx/source/svdraw/svdedxv.cxx                |    5 ----
 svx/source/svdraw/svdmrkv.cxx                |   15 ++++++++----
 5 files changed, 47 insertions(+), 13 deletions(-)

New commits:
commit c152008943160fa901ef8a356515a6a074370ff0
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri Sep 2 14:21:18 2016 +0200

    svx: move GetSfxViewShell() to SdrMarkView
    
    ... from SdrObjEditView. This way SdrMarkView can avoid
    SfxViewShell::Current() calls, and it can avoid clearing the LOK graphic
    selection of the old view when constructing a new view.
    
    With this, an existing graphic selection in an Impress LOK view is no
    longer cleared when creating a new view, thanks to the
    sd::View::GetSfxViewShell() override.
    
    Change-Id: I70a287aa9c2265bf59a9fb18e0c3839b8f119bbc
    Reviewed-on: https://gerrit.libreoffice.org/28618
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Jenkins <ci at libreoffice.org>

diff --git a/include/svx/svdedxv.hxx b/include/svx/svdedxv.hxx
index 0e48c22..a22f5b5 100644
--- a/include/svx/svdedxv.hxx
+++ b/include/svx/svdedxv.hxx
@@ -35,7 +35,6 @@ class ImpSdrEditPara;
 struct PasteOrDropInfos;
 class SdrUndoManager;
 class TextChainCursorManager;
-class SfxViewShell;
 
 namespace com { namespace sun { namespace star { namespace uno {
     class Any;
@@ -160,8 +159,6 @@ public:
 
     SdrPageView* ShowSdrPage(SdrPage* pPage) override;
     void HideSdrPage() override;
-    /// Get access to the view shell owning this draw view, if any.
-    virtual SfxViewShell* GetSfxViewShell() const;
 
     virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override;
     virtual void ModelHasChanged() override;
diff --git a/include/svx/svdmrkv.hxx b/include/svx/svdmrkv.hxx
index dc4f739..1c851ec 100644
--- a/include/svx/svdmrkv.hxx
+++ b/include/svx/svdmrkv.hxx
@@ -27,6 +27,8 @@
 #include <svx/svxdllapi.h>
 #include <o3tl/typed_flags_set.hxx>
 
+class SfxViewShell;
+
 // The following is not yet implemented, or just partially:
 enum class SdrSearchOptions
 {
@@ -437,6 +439,8 @@ public:
     // End point of the axis of reflextion
     const Point& GetRef2() const { return maRef1; }
     void SetRef2(const Point& rPt);
+    /// Get access to the view shell owning this draw view, if any.
+    virtual SfxViewShell* GetSfxViewShell() const;
 };
 
 
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index 268692e..b5ba3ae 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -70,6 +70,7 @@ public:
     void testCursorViews();
     void testViewLock();
     void testUndoLimiting();
+    void testCreateViewGraphicSelection();
 
     CPPUNIT_TEST_SUITE(SdTiledRenderingTest);
     CPPUNIT_TEST(testRegisterCallback);
@@ -95,6 +96,7 @@ public:
     CPPUNIT_TEST(testCursorViews);
     CPPUNIT_TEST(testViewLock);
     CPPUNIT_TEST(testUndoLimiting);
+    CPPUNIT_TEST(testCreateViewGraphicSelection);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -1110,6 +1112,37 @@ void SdTiledRenderingTest::testUndoLimiting()
     comphelper::LibreOfficeKit::setActive(false);
 }
 
+void SdTiledRenderingTest::testCreateViewGraphicSelection()
+{
+    comphelper::LibreOfficeKit::setActive();
+
+    // Load a document and register a callback.
+    SdXImpressDocument* pXImpressDocument = createDoc("shape.odp");
+    pXImpressDocument->initializeForTiledRendering({});
+    ViewCallback aView1;
+    SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1);
+
+    // Select the only shape in the document and assert that the graphic selection is changed.
+    sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
+    SdPage* pActualPage = pViewShell->GetActualPage();
+    SdrObject* pObject = pActualPage->GetObj(0);
+    SdrView* pView = pViewShell->GetView();
+    aView1.m_bGraphicSelectionInvalidated = false;
+    pView->MarkObj(pObject, pView->GetSdrPageView());
+    CPPUNIT_ASSERT(aView1.m_bGraphicSelectionInvalidated);
+
+    // Now create a new view.
+    aView1.m_bGraphicSelectionInvalidated = false;
+    SfxLokHelper::createView();
+    // This failed, creating a new view affected the graphic selection of an
+    // existing view.
+    CPPUNIT_ASSERT(!aView1.m_bGraphicSelectionInvalidated);
+
+    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 735cbc1..323b4a8 100644
--- a/svx/source/svdraw/svdedxv.cxx
+++ b/svx/source/svdraw/svdedxv.cxx
@@ -212,11 +212,6 @@ void SdrObjEditView::TakeActionRect(Rectangle& rRect) const
     }
 }
 
-SfxViewShell* SdrObjEditView::GetSfxViewShell() const
-{
-    return nullptr;
-}
-
 void SdrObjEditView::Notify(SfxBroadcaster& rBC, const SfxHint& rHint)
 {
     SdrGlueEditView::Notify(rBC,rHint);
diff --git a/svx/source/svdraw/svdmrkv.cxx b/svx/source/svdraw/svdmrkv.cxx
index 9e4bdd2..a4a7916 100644
--- a/svx/source/svdraw/svdmrkv.cxx
+++ b/svx/source/svdraw/svdmrkv.cxx
@@ -228,7 +228,7 @@ void SdrMarkView::ModelHasChanged()
             sSelection = aSelection.toString();
         }
 
-        if(SfxViewShell* pViewShell = SfxViewShell::Current())
+        if(SfxViewShell* pViewShell = GetSfxViewShell())
             pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_INVALIDATE_TILES, sSelection.getStr());
     }
 }
@@ -705,7 +705,7 @@ void SdrMarkView::SetMarkHandles()
                     if (bTiledRendering)
                     {
                         // Suppress handles -> empty graphic selection.
-                        if(SfxViewShell* pViewShell = SfxViewShell::Current())
+                        if(SfxViewShell* pViewShell = GetSfxViewShell())
                         {
                             pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_GRAPHIC_SELECTION, "EMPTY");
                             SfxLokHelper::notifyOtherViews(pViewShell, LOK_CALLBACK_GRAPHIC_VIEW_SELECTION, "selection", "EMPTY");
@@ -729,7 +729,7 @@ void SdrMarkView::SetMarkHandles()
                 if (xController.is() && xController->hasSelectedCells())
                 {
                     // The table shape has selected cells, which provide text selection already -> no graphic selection.
-                    if(SfxViewShell* pViewShell = SfxViewShell::Current())
+                    if(SfxViewShell* pViewShell = GetSfxViewShell())
                     {
                         pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_GRAPHIC_SELECTION, "EMPTY");
                         SfxLokHelper::notifyOtherViews(pViewShell, LOK_CALLBACK_GRAPHIC_VIEW_SELECTION, "selection", "EMPTY");
@@ -762,10 +762,10 @@ void SdrMarkView::SetMarkHandles()
                 sSelection = aSelection.toString();
 
                 // hide the text selection too
-                if(SfxViewShell* pViewShell = SfxViewShell::Current())
+                if(SfxViewShell* pViewShell = GetSfxViewShell())
                     pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION, "");
             }
-            if(SfxViewShell* pViewShell = SfxViewShell::Current())
+            if(SfxViewShell* pViewShell = GetSfxViewShell())
             {
                 pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_GRAPHIC_SELECTION, sSelection.getStr());
                 SfxLokHelper::notifyOtherViews(pViewShell, LOK_CALLBACK_GRAPHIC_VIEW_SELECTION, "selection", sSelection);
@@ -1254,6 +1254,11 @@ void SdrMarkView::SetRef2(const Point& rPt)
     }
 }
 
+SfxViewShell* SdrMarkView::GetSfxViewShell() const
+{
+    return SfxViewShell::Current();
+}
+
 bool SdrPageView::IsObjSelectable(SdrObject *pObj) const
 {
     SdrLayerID nLay=pObj->GetLayer();


More information about the Libreoffice-commits mailing list