[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.1' - 2 commits - include/svx sd/qa svx/source sw/qa sw/source

Miklos Vajna vmiklos at collabora.co.uk
Fri Sep 2 13:27:24 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 ++++++---
 sw/qa/extras/tiledrendering/data/frame.odt     |binary
 sw/qa/extras/tiledrendering/tiledrendering.cxx |   41 +++++++++++++++++++++++++
 sw/source/core/frmedt/fews.cxx                 |    7 +++-
 8 files changed, 93 insertions(+), 15 deletions(-)

New commits:
commit 3fd4c40a8706de03a56b152385551a3a9159f563
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>
    (cherry picked from commit c152008943160fa901ef8a356515a6a074370ff0)

diff --git a/include/svx/svdedxv.hxx b/include/svx/svdedxv.hxx
index 628faee..5b2d3b2 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;
@@ -159,8 +158,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 1605d6f..2706f77 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
 {
@@ -448,6 +450,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 77f4ab1..45b1034 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:
@@ -1106,6 +1108,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 5c719e1..8960aee 100644
--- a/svx/source/svdraw/svdedxv.cxx
+++ b/svx/source/svdraw/svdedxv.cxx
@@ -213,11 +213,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 df1abb7..b5c6227 100644
--- a/svx/source/svdraw/svdmrkv.cxx
+++ b/svx/source/svdraw/svdmrkv.cxx
@@ -231,7 +231,7 @@ void SdrMarkView::ModelHasChanged()
             sSelection = aSelection.toString();
         }
 
-        if(SfxViewShell* pViewShell = SfxViewShell::Current())
+        if(SfxViewShell* pViewShell = GetSfxViewShell())
             pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_INVALIDATE_TILES, sSelection.getStr());
     }
 }
@@ -714,7 +714,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");
@@ -738,7 +738,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");
@@ -771,10 +771,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);
@@ -1263,6 +1263,11 @@ void SdrMarkView::SetRef2(const Point& rPt)
     }
 }
 
+SfxViewShell* SdrMarkView::GetSfxViewShell() const
+{
+    return SfxViewShell::Current();
+}
+
 bool SdrPageView::IsObjSelectable(SdrObject *pObj) const
 {
     SdrLayerID nLay=pObj->GetLayer();
commit c7e48d8bf23e0fce7af5fa90ac173f0d477d7aac
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri Sep 2 10:52:46 2016 +0200

    sw lok: avoid hiding / showing sdr mark handles on focus change
    
    For one, this is unwanted: in the LOK case we want to switch between the
    windows without any side effect to be able to e.g. paint tiles.
    
    For another, this caused an invalidation loop when two views selected
    the text frames or images in Writer. The loop looked like:
    
    1) Press a key in view #1, so a setView(0) + paintTile() is necessary in
    view #0.
    2) SfxLokHelper::setView(0) to switch from view #1 to view #0.
    3) SwFEShell::ShellLoseFocus() on view #1, which hides sdr marks ->
    invalidate.
    4) SwFEShell::ShellGetFocus() on view #0, which shows sdr marks ->
    invalidate.
    5) paintTile() in view #0.
    6) SfxLokHelper::setView(1) to paint tiles due to 3). (Generates
    invalidations in both views.)
    7) SfxLokHelper::setView(0) to paint tiles due to 4).
    
    And so on, this way a call to SfxLokHelper::setView(0) resulted in an
    another (async) call to SfxLokHelper::setView(0) all the time.
    
    Change-Id: Ice855b9128f61bb7b823b499cad366998f297b5d
    Reviewed-on: https://gerrit.libreoffice.org/28611
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Jenkins <ci at libreoffice.org>
    (cherry picked from commit 91733eff7fba157daf88b092189d842f9d6f1b68)

diff --git a/sw/qa/extras/tiledrendering/data/frame.odt b/sw/qa/extras/tiledrendering/data/frame.odt
new file mode 100644
index 0000000..167e8f5
Binary files /dev/null and b/sw/qa/extras/tiledrendering/data/frame.odt differ
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 1eda2ad..4861f12 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -71,6 +71,7 @@ public:
     void testTrackChanges();
     void testTrackChangesCallback();
     void testRedlineUpdateCallback();
+    void testSetViewGraphicSelection();
 
     CPPUNIT_TEST_SUITE(SwTiledRenderingTest);
     CPPUNIT_TEST(testRegisterCallback);
@@ -106,6 +107,7 @@ public:
     CPPUNIT_TEST(testTrackChanges);
     CPPUNIT_TEST(testTrackChangesCallback);
     CPPUNIT_TEST(testRedlineUpdateCallback);
+    CPPUNIT_TEST(testSetViewGraphicSelection);
     CPPUNIT_TEST_SUITE_END();
 
 private:
@@ -603,6 +605,7 @@ public:
     bool m_bTilesInvalidated;
     bool m_bViewCursorVisible;
     bool m_bGraphicViewSelection;
+    bool m_bGraphicSelection;
     bool m_bViewLock;
 
     ViewCallback()
@@ -613,6 +616,7 @@ public:
           m_bTilesInvalidated(false),
           m_bViewCursorVisible(false),
           m_bGraphicViewSelection(false),
+          m_bGraphicSelection(false),
           m_bViewLock(false)
     {
     }
@@ -624,6 +628,7 @@ public:
 
     void callbackImpl(int nType, const char* pPayload)
     {
+        OString aPayload(pPayload);
         switch (nType)
         {
         case LOK_CALLBACK_INVALIDATE_TILES:
@@ -664,6 +669,11 @@ public:
             m_bGraphicViewSelection = aTree.get_child("selection").get_value<std::string>() != "EMPTY";
         }
         break;
+        case LOK_CALLBACK_GRAPHIC_SELECTION:
+        {
+            m_bGraphicSelection = aPayload != "EMPTY";
+        }
+        break;
         case LOK_CALLBACK_VIEW_LOCK:
         {
             std::stringstream aStream(pPayload);
@@ -1231,6 +1241,37 @@ void SwTiledRenderingTest::testRedlineUpdateCallback()
     comphelper::LibreOfficeKit::setActive(false);
 }
 
+void SwTiledRenderingTest::testSetViewGraphicSelection()
+{
+    // Load a document.
+    comphelper::LibreOfficeKit::setActive();
+    SwXTextDocument* pXTextDocument = createDoc("frame.odt");
+    int nView1 = SfxLokHelper::getView();
+    ViewCallback aView1;
+    SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1);
+    // Create a second view, and switch back to the first view.
+    SfxLokHelper::createView();
+    pXTextDocument->initializeForTiledRendering({});
+    SfxLokHelper::setView(nView1);
+
+    // 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();
+    pView->MarkObj(pObject, pView->GetSdrPageView());
+    CPPUNIT_ASSERT(aView1.m_bGraphicSelection);
+
+    // Now start to switch to the second view (part of setView()).
+    pWrtShell->ShellLoseFocus();
+    // This failed, mark handles were hidden in the first view.
+    CPPUNIT_ASSERT(!pView->areMarkHandlesHidden());
+
+    mxComponent->dispose();
+    mxComponent.clear();
+    comphelper::LibreOfficeKit::setActive(false);
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(SwTiledRenderingTest);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/core/frmedt/fews.cxx b/sw/source/core/frmedt/fews.cxx
index 287b94b..7f2685e 100644
--- a/sw/source/core/frmedt/fews.cxx
+++ b/sw/source/core/frmedt/fews.cxx
@@ -18,6 +18,7 @@
  */
 
 #include <svx/svdobj.hxx>
+#include <comphelper/lok.hxx>
 #include <init.hxx>
 #include <fesh.hxx>
 #include <pagefrm.hxx>
@@ -285,7 +286,8 @@ void SwFEShell::ShellGetFocus( bool bUpdate )
 
     if ( HasDrawView() )
     {
-        Imp()->GetDrawView()->showMarkHandles();
+        if (!comphelper::LibreOfficeKit::isActive())
+            Imp()->GetDrawView()->showMarkHandles();
         if ( Imp()->GetDrawView()->AreObjectsMarked() )
             FrameNotify( this, FLY_DRAG_START );
     }
@@ -297,7 +299,8 @@ void SwFEShell::ShellLoseFocus()
 
     if ( HasDrawView() && Imp()->GetDrawView()->AreObjectsMarked() )
     {
-        Imp()->GetDrawView()->hideMarkHandles();
+        if (!comphelper::LibreOfficeKit::isActive())
+            Imp()->GetDrawView()->hideMarkHandles();
         FrameNotify( this, FLY_DRAG_END );
     }
 }


More information about the Libreoffice-commits mailing list