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

Miklos Vajna vmiklos at collabora.co.uk
Wed Sep 14 08:36:17 UTC 2016


 editeng/source/editeng/editview.cxx            |   12 +++++
 editeng/source/editeng/impedit.cxx             |   36 +++++++++++++--
 editeng/source/editeng/impedit.hxx             |    4 +
 include/editeng/editview.hxx                   |    4 +
 include/editeng/outliner.hxx                   |    2 
 include/sfx2/viewsh.hxx                        |    2 
 sfx2/source/view/viewsh.cxx                    |    9 +++
 svx/source/svdraw/svdmrkv.cxx                  |    5 +-
 sw/qa/extras/tiledrendering/tiledrendering.cxx |   57 +++++++++++++++++++++++++
 sw/source/core/crsr/crsrsh.cxx                 |   34 ++++++++++++--
 10 files changed, 153 insertions(+), 12 deletions(-)

New commits:
commit 977a0ca8c388a51ad13d51681d28b9ed986f27fa
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Wed Sep 14 09:16:56 2016 +0200

    sw draw text: emit LOK_CALLBACK_VIEW_LOCK from registerCallback()
    
    With this, in case the first view has an active text edit and a new view
    is created, then the shape text lock is instantly visible in the second
    view, even if the first view does not end + begin the text edit again
    later.
    
    Change-Id: I82d98ab1431a54a1a8897d16ce7fa0856baa2a10
    (cherry picked from commit 7b784e4e3927d91a96cd0b54fc43c9b488822e47)

diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 56f087a..c72a961 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -1210,6 +1210,7 @@ void SwTiledRenderingTest::testShapeTextUndoGroupShells()
     ViewCallback aView2;
     aView2.m_aViewCursor = Rectangle();
     aView2.m_bViewSelectionSet = false;
+    aView2.m_bViewLock = false;
     SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView2);
     // Difference was 935 twips, the new view didn't see the editeng cursor of
     // the old one. The new difference should be <1px, but here we deal with twips.
@@ -1217,6 +1218,9 @@ void SwTiledRenderingTest::testShapeTextUndoGroupShells()
     // This was false, editeng text selection of the first view wasn't noticed
     // by the second view.
     CPPUNIT_ASSERT(aView2.m_bViewSelectionSet);
+    // This was false, the new view wasn't aware of the shape text lock created
+    // by the old view.
+    CPPUNIT_ASSERT(aView2.m_bViewLock);
 
     mxComponent->dispose();
     mxComponent.clear();
diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index 3a9ebe9..99f75a4 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -1237,6 +1237,13 @@ void SwCursorShell::NotifyCursor(SfxViewShell* pOtherShell) const
         rEditView.RegisterOtherShell(nullptr);
         // Text selection, if any.
         rEditView.DrawSelection(pOtherShell);
+
+        // Shape text lock.
+        if (OutlinerView* pOutlinerView = pView->GetTextEditOutlinerView())
+        {
+            OString sRect = pOutlinerView->GetOutputArea().toString();
+            SfxLokHelper::notifyOtherView(GetSfxViewShell(), pOtherShell, LOK_CALLBACK_VIEW_LOCK, "rectangle", sRect);
+        }
     }
     else
     {
commit 1ac8217f6114943002730502ebafd8617d2fd5c1
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Sep 13 16:49:03 2016 +0200

    sw draw text: emit LOK_CALLBACK_TEXT_VIEW_SELECTION from registerCallback()
    
    With this, in case the first view has an active text edit selection and
    a new view is created, then the text selection is instantly visible in
    the second view, even if the first view's text selection does not change
    later.
    
    Change-Id: I3255febd5d65d6576ddbc57cf96836bdf0b06a72
    (cherry picked from commit 2ea385a54b53797ab3960869012f3ce3268eab2c)

diff --git a/editeng/source/editeng/editview.cxx b/editeng/source/editeng/editview.cxx
index 51d9cd4..ee6a864 100644
--- a/editeng/source/editeng/editview.cxx
+++ b/editeng/source/editeng/editview.cxx
@@ -1361,4 +1361,11 @@ void EditView::SetCursorLogicPosition(const Point& rPosition, bool bPoint, bool
     ShowCursor(/*bGotoCursor=*/false);
 }
 
+void EditView::DrawSelection(OutlinerViewShell* pOtherShell)
+{
+    pImpEditView->RegisterOtherShell(pOtherShell);
+    pImpEditView->DrawSelection();
+    pImpEditView->RegisterOtherShell(nullptr);
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/editeng/source/editeng/impedit.cxx b/editeng/source/editeng/impedit.cxx
index 3fa2b51..83a8e35 100644
--- a/editeng/source/editeng/impedit.cxx
+++ b/editeng/source/editeng/impedit.cxx
@@ -375,8 +375,8 @@ void ImpEditView::DrawSelection( EditSelection aTmpSel, vcl::Region* pRegion, Ou
                 aOrigin = pOutWin->GetMapMode().GetOrigin();
 
             OString sRectangle;
-            // If we are not in selection mode, then the exported selection should be empty.
-            if (pEditEngine->pImpEditEngine->IsInSelectionMode())
+            // If we are not in selection mode, then the exported own selection should be empty.
+            if (pEditEngine->pImpEditEngine->IsInSelectionMode() || mpOtherShell)
             {
                 std::vector<Rectangle> aRectangles;
                 pRegion->GetRegionRectangles(aRectangles);
@@ -412,8 +412,17 @@ void ImpEditView::DrawSelection( EditSelection aTmpSel, vcl::Region* pRegion, Ou
                 sRectangle = comphelper::string::join("; ", v);
             }
 
-            mpViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION, sRectangle.getStr());
-            mpViewShell->NotifyOtherViews(LOK_CALLBACK_TEXT_VIEW_SELECTION, "selection", sRectangle);
+            if (mpOtherShell)
+            {
+                // An other shell wants to know about our existing selection.
+                if (mpViewShell != mpOtherShell)
+                    mpViewShell->NotifyOtherView(mpOtherShell, LOK_CALLBACK_TEXT_VIEW_SELECTION, "selection", sRectangle);
+            }
+            else
+            {
+                mpViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_TEXT_SELECTION, sRectangle.getStr());
+                mpViewShell->NotifyOtherViews(LOK_CALLBACK_TEXT_VIEW_SELECTION, "selection", sRectangle);
+            }
 
             pOutWin->Pop();
         }
diff --git a/include/editeng/editview.hxx b/include/editeng/editview.hxx
index 92fddd2..69ef384 100644
--- a/include/editeng/editview.hxx
+++ b/include/editeng/editview.hxx
@@ -260,6 +260,8 @@ public:
                             bool bIsParaText );
     /// Allows adjusting the point or mark of the selection to a document coordinate.
     void SetCursorLogicPosition(const Point& rPosition, bool bPoint, bool bClearMark);
+    /// Trigger selection drawing callback in pOtherShell based on our shell's selection state.
+    void DrawSelection(OutlinerViewShell* pOtherShell);
 };
 
 #endif // INCLUDED_EDITENG_EDITVIEW_HXX
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 10cd61e..56f087a 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -1195,16 +1195,28 @@ void SwTiledRenderingTest::testShapeTextUndoGroupShells()
     // This was -1: the view shell id for the (top) undo list action wasn't known.
     CPPUNIT_ASSERT_EQUAL(nView1, rUndoManager.GetUndoAction()->GetViewShellId());
 
+    // Create an editeng text selection in the first view.
+    EditView& rEditView = pView->GetTextEditOutlinerView()->GetEditView();
+    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'x', 0);
+    pXTextDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'x', 0);
+    // 0th para, 0th char -> 0th para, 1st char.
+    ESelection aWordSelection(0, 0, 0, 1);
+    rEditView.SetSelection(aWordSelection);
+
     // Create a second view, and make sure that the new view sees the same
     // cursor position as the old one.
     SfxLokHelper::createView();
     pXTextDocument->initializeForTiledRendering({});
     ViewCallback aView2;
     aView2.m_aViewCursor = Rectangle();
+    aView2.m_bViewSelectionSet = false;
     SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView2);
     // Difference was 935 twips, the new view didn't see the editeng cursor of
     // the old one. The new difference should be <1px, but here we deal with twips.
     CPPUNIT_ASSERT(std::abs(aView1.m_aOwnCursor.Top() - aView2.m_aViewCursor.Top()) < 10);
+    // This was false, editeng text selection of the first view wasn't noticed
+    // by the second view.
+    CPPUNIT_ASSERT(aView2.m_bViewSelectionSet);
 
     mxComponent->dispose();
     mxComponent.clear();
diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index 4477681..3a9ebe9 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -1230,10 +1230,13 @@ void SwCursorShell::NotifyCursor(SfxViewShell* pOtherShell) const
     auto pView = const_cast<SdrView*>(GetDrawView());
     if (pView->GetTextEditObject())
     {
+        // Blinking cursor.
         EditView& rEditView = pView->GetTextEditOutlinerView()->GetEditView();
         rEditView.RegisterOtherShell(pOtherShell);
         rEditView.ShowCursor();
         rEditView.RegisterOtherShell(nullptr);
+        // Text selection, if any.
+        rEditView.DrawSelection(pOtherShell);
     }
     else
     {
commit 4d9bb7120a2ca27207b30d81d77a810a306fbe04
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Sep 13 16:48:05 2016 +0200

    sw draw text: emit LOK_CALLBACK_INVALIDATE_VIEW_CURSOR from registerCallback()
    
    With this, in case the first view has an active text edit and a new view
    is created, then the cursor position is instantly visible in the second
    view, even if the first view's cursor does not move later.
    
    (cherry picked from commit 586789fe757c0eb350c360a49cf90431a0bd5b24)
    
    Conflicts:
    	sw/source/core/crsr/crsrsh.cxx
    
    Change-Id: Ia82e7dc1ce9bb58c67a280179ecadc74d3b63026

diff --git a/editeng/source/editeng/editview.cxx b/editeng/source/editeng/editview.cxx
index 5d64e4f..51d9cd4 100644
--- a/editeng/source/editeng/editview.cxx
+++ b/editeng/source/editeng/editview.cxx
@@ -598,6 +598,11 @@ void EditView::RegisterViewShell(OutlinerViewShell* pViewShell)
     pImpEditView->RegisterViewShell(pViewShell);
 }
 
+void EditView::RegisterOtherShell(OutlinerViewShell* pOtherShell)
+{
+    pImpEditView->RegisterOtherShell(pOtherShell);
+}
+
 void EditView::SetControlWord( EVControlBits nWord )
 {
     pImpEditView->nControl = nWord;
diff --git a/editeng/source/editeng/impedit.cxx b/editeng/source/editeng/impedit.cxx
index 795a824..3fa2b51 100644
--- a/editeng/source/editeng/impedit.cxx
+++ b/editeng/source/editeng/impedit.cxx
@@ -80,6 +80,7 @@ ImpEditView::ImpEditView( EditView* pView, EditEngine* pEng, vcl::Window* pWindo
     pPointer            = nullptr;
     pBackgroundColor    = nullptr;
     mpViewShell = nullptr;
+    mpOtherShell = nullptr;
     nScrollDiffX        = 0;
     nExtraCursorFlags   = 0;
     nCursorBidiLevel    = CURSOR_BIDILEVEL_DONTKNOW;
@@ -122,6 +123,11 @@ void ImpEditView::RegisterViewShell(OutlinerViewShell* pViewShell)
     mpViewShell = pViewShell;
 }
 
+void ImpEditView::RegisterOtherShell(OutlinerViewShell* pOtherShell)
+{
+    mpOtherShell = pOtherShell;
+}
+
 const OutlinerViewShell* ImpEditView::GetViewShell() const
 {
     return mpViewShell;
@@ -1004,8 +1010,17 @@ void ImpEditView::ShowCursor( bool bGotoCursor, bool bForceVisCursor )
             aRect.setWidth(0);
 
             OString sRect = aRect.toString();
-            mpViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR, sRect.getStr());
-            mpViewShell->NotifyOtherViews(LOK_CALLBACK_INVALIDATE_VIEW_CURSOR, "rectangle", sRect);
+            if (mpOtherShell)
+            {
+                // An other shell wants to know about our existing cursor.
+                if (mpViewShell != mpOtherShell)
+                    mpViewShell->NotifyOtherView(mpOtherShell, LOK_CALLBACK_INVALIDATE_VIEW_CURSOR, "rectangle", sRect);
+            }
+            else
+            {
+                mpViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR, sRect.getStr());
+                mpViewShell->NotifyOtherViews(LOK_CALLBACK_INVALIDATE_VIEW_CURSOR, "rectangle", sRect);
+            }
         }
 
         CursorDirection nCursorDir = CursorDirection::NONE;
diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx
index b910da6..a1430c6 100644
--- a/editeng/source/editeng/impedit.hxx
+++ b/editeng/source/editeng/impedit.hxx
@@ -224,6 +224,8 @@ private:
     Color*              pBackgroundColor;
     /// Containing view shell, if any.
     OutlinerViewShell* mpViewShell;
+    /// An other shell, just listening to our state, if any.
+    OutlinerViewShell* mpOtherShell;
     EditEngine*         pEditEngine;
     VclPtr<vcl::Window> pOutWin;
     Pointer*            pPointer;
@@ -371,6 +373,8 @@ public:
     /// Informs this edit view about which view shell contains it.
     void RegisterViewShell(OutlinerViewShell* pViewShell);
     const OutlinerViewShell* GetViewShell() const;
+    /// Informs this edit view about which other shell listens to it.
+    void RegisterOtherShell(OutlinerViewShell* pViewShell);
 
     bool            IsWrongSpelledWord( const EditPaM& rPaM, bool bMarkIfWrong );
     OUString        SpellIgnoreWord();
diff --git a/include/editeng/editview.hxx b/include/editeng/editview.hxx
index 032a4e0..92fddd2 100644
--- a/include/editeng/editview.hxx
+++ b/include/editeng/editview.hxx
@@ -184,6 +184,8 @@ public:
 
     /// Informs this edit view about which view shell contains it.
     void RegisterViewShell(OutlinerViewShell* pViewShell);
+    /// Informs this edit view about which other shell listens to it.
+    void RegisterOtherShell(OutlinerViewShell* pOtherShell);
 
     void            SetControlWord( EVControlBits nWord );
     EVControlBits   GetControlWord() const;
diff --git a/include/editeng/outliner.hxx b/include/editeng/outliner.hxx
index 171b8d0..6c2b3b7 100644
--- a/include/editeng/outliner.hxx
+++ b/include/editeng/outliner.hxx
@@ -384,6 +384,8 @@ public:
     virtual sal_uInt32 GetViewShellId() const = 0;
     /// Wrapper around SfxLokHelper::notifyOtherViews().
     virtual void NotifyOtherViews(int nType, const OString& rKey, const OString& rPayload) = 0;
+    /// Wrapper around SfxLokHelper::notifyOtherView().
+    virtual void NotifyOtherView(OutlinerViewShell* pOtherShell, int nType, const OString& rKey, const OString& rPayload) = 0;
 
 protected:
     ~OutlinerViewShell() throw () {}
diff --git a/include/sfx2/viewsh.hxx b/include/sfx2/viewsh.hxx
index d74e8b7..d662e08 100644
--- a/include/sfx2/viewsh.hxx
+++ b/include/sfx2/viewsh.hxx
@@ -342,6 +342,8 @@ public:
     sal_uInt32 GetViewShellId() const override;
     /// See OutlinerViewShell::NotifyOtherViews().
     void NotifyOtherViews(int nType, const OString& rKey, const OString& rPayload) override;
+    /// See OutlinerViewShell::NotifyOtherView().
+    void NotifyOtherView(OutlinerViewShell* pOtherShell, int nType, const OString& rKey, const OString& rPayload) override;
     /// Ask this view to send its cursor position to pViewShell.
     virtual void NotifyCursor(SfxViewShell* /*pViewShell*/) const;
 };
diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx
index de2f3e8..3e557e6 100644
--- a/sfx2/source/view/viewsh.cxx
+++ b/sfx2/source/view/viewsh.cxx
@@ -1680,6 +1680,15 @@ void SfxViewShell::NotifyOtherViews(int nType, const OString& rKey, const OStrin
     SfxLokHelper::notifyOtherViews(this, nType, rKey, rPayload);
 }
 
+void SfxViewShell::NotifyOtherView(OutlinerViewShell* pOther, int nType, const OString& rKey, const OString& rPayload)
+{
+    auto pOtherShell = dynamic_cast<SfxViewShell*>(pOther);
+    if (!pOtherShell)
+        return;
+
+    SfxLokHelper::notifyOtherView(this, pOtherShell, nType, rKey, rPayload);
+}
+
 void SfxViewShell::dumpAsXml(xmlTextWriterPtr pWriter) const
 {
     xmlTextWriterStartElement(pWriter, BAD_CAST("sfxViewShell"));
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index ada126f..10cd61e 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -603,7 +603,9 @@ class ViewCallback
 {
 public:
     bool m_bOwnCursorInvalidated;
+    Rectangle m_aOwnCursor;
     bool m_bViewCursorInvalidated;
+    Rectangle m_aViewCursor;
     bool m_bOwnSelectionSet;
     bool m_bViewSelectionSet;
     OString m_aViewSelection;
@@ -644,11 +646,33 @@ public:
         case LOK_CALLBACK_INVALIDATE_VISIBLE_CURSOR:
         {
             m_bOwnCursorInvalidated = true;
+
+            uno::Sequence<OUString> aSeq = comphelper::string::convertCommaSeparated(OUString::fromUtf8(aPayload));
+            if (OString("EMPTY") == pPayload)
+                return;
+            CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(4), aSeq.getLength());
+            m_aOwnCursor.setX(aSeq[0].toInt32());
+            m_aOwnCursor.setY(aSeq[1].toInt32());
+            m_aOwnCursor.setWidth(aSeq[2].toInt32());
+            m_aOwnCursor.setHeight(aSeq[3].toInt32());
         }
         break;
         case LOK_CALLBACK_INVALIDATE_VIEW_CURSOR:
         {
             m_bViewCursorInvalidated = true;
+            std::stringstream aStream(pPayload);
+            boost::property_tree::ptree aTree;
+            boost::property_tree::read_json(aStream, aTree);
+            OString aRect = aTree.get_child("rectangle").get_value<std::string>().c_str();
+
+            uno::Sequence<OUString> aSeq = comphelper::string::convertCommaSeparated(OUString::fromUtf8(aRect));
+            if (OString("EMPTY") == pPayload)
+                return;
+            CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(4), aSeq.getLength());
+            m_aViewCursor.setX(aSeq[0].toInt32());
+            m_aViewCursor.setY(aSeq[1].toInt32());
+            m_aViewCursor.setWidth(aSeq[2].toInt32());
+            m_aViewCursor.setHeight(aSeq[3].toInt32());
         }
         break;
         case LOK_CALLBACK_TEXT_SELECTION:
@@ -1149,6 +1173,8 @@ void SwTiledRenderingTest::testShapeTextUndoGroupShells()
     // Load a document and create a view.
     comphelper::LibreOfficeKit::setActive();
     SwXTextDocument* pXTextDocument = createDoc("shape.fodt");
+    ViewCallback aView1;
+    SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1);
     sal_Int32 nView1 = SfxLokHelper::getView();
 
     // Begin text edit.
@@ -1169,6 +1195,17 @@ void SwTiledRenderingTest::testShapeTextUndoGroupShells()
     // This was -1: the view shell id for the (top) undo list action wasn't known.
     CPPUNIT_ASSERT_EQUAL(nView1, rUndoManager.GetUndoAction()->GetViewShellId());
 
+    // Create a second view, and make sure that the new view sees the same
+    // cursor position as the old one.
+    SfxLokHelper::createView();
+    pXTextDocument->initializeForTiledRendering({});
+    ViewCallback aView2;
+    aView2.m_aViewCursor = Rectangle();
+    SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView2);
+    // Difference was 935 twips, the new view didn't see the editeng cursor of
+    // the old one. The new difference should be <1px, but here we deal with twips.
+    CPPUNIT_ASSERT(std::abs(aView1.m_aOwnCursor.Top() - aView2.m_aViewCursor.Top()) < 10);
+
     mxComponent->dispose();
     mxComponent.clear();
     comphelper::LibreOfficeKit::setActive(false);
diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index d88d21c..4477681 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -66,6 +66,7 @@
 #include <comphelper/lok.hxx>
 #include <sfx2/lokhelper.hxx>
 #include <comphelper/string.hxx>
+#include <editeng/editview.hxx>
 #include <PostItMgr.hxx>
 
 using namespace com::sun::star;
@@ -1226,13 +1227,23 @@ OUString SwCursorShell::getPageRectangles()
 
 void SwCursorShell::NotifyCursor(SfxViewShell* pOtherShell) const
 {
-    // Cursor position and visibility.
-    m_pVisibleCursor->_SetPosAndShow(pOtherShell);
-    // Text selection.
-    m_pCurrentCursor->Show(pOtherShell);
-    // Graphic selection.
     auto pView = const_cast<SdrView*>(GetDrawView());
-    pView->AdjustMarkHdl(pOtherShell);
+    if (pView->GetTextEditObject())
+    {
+        EditView& rEditView = pView->GetTextEditOutlinerView()->GetEditView();
+        rEditView.RegisterOtherShell(pOtherShell);
+        rEditView.ShowCursor();
+        rEditView.RegisterOtherShell(nullptr);
+    }
+    else
+    {
+        // Cursor position and visibility.
+        m_pVisibleCursor->_SetPosAndShow(pOtherShell);
+        // Text selection.
+        m_pCurrentCursor->Show(pOtherShell);
+        // Graphic selection.
+        pView->AdjustMarkHdl(pOtherShell);
+    }
 }
 
 /// go to the next SSelection
commit ac5f21587c09f700c1cbbe33ed73edfcc53ed666
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Sep 13 10:06:52 2016 +0200

    sw: emit LOK_CALLBACK_GRAPHIC_VIEW_SELECTION as part of registerCallback()
    
    Have a Writer shape selection in the first view, create a new view, the
    second view doesn't see the selection. But the same works if the shape
    selection is created when the second view was created earlier.
    
    Emit the svx selection state as part of SwCursorShell::NotifyCursor() to
    fix the problem, but take care of not sending the status to the new view
    itself.
    
    Reviewed-on: https://gerrit.libreoffice.org/28857
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Jenkins <ci at libreoffice.org>
    (cherry picked from commit 786cc8a5a3cd34329c72b867e5fd7896b10a7351)
    
    Conflicts:
    	sw/source/core/crsr/crsrsh.cxx
    
    Change-Id: Iff3979235e1c12cc64867c3184354967f451370b

diff --git a/svx/source/svdraw/svdmrkv.cxx b/svx/source/svdraw/svdmrkv.cxx
index a153390..20ff410 100644
--- a/svx/source/svdraw/svdmrkv.cxx
+++ b/svx/source/svdraw/svdmrkv.cxx
@@ -777,9 +777,12 @@ void SdrMarkView::SetMarkHandles(SfxViewShell* pOtherShell)
             if(SfxViewShell* pViewShell = GetSfxViewShell())
             {
                 if (pOtherShell)
+                {
                     // An other shell wants to know about our existing
                     // selection.
-                    SfxLokHelper::notifyOtherView(pViewShell, pOtherShell, LOK_CALLBACK_GRAPHIC_VIEW_SELECTION, "selection", sSelection);
+                    if (pViewShell != pOtherShell)
+                        SfxLokHelper::notifyOtherView(pViewShell, pOtherShell, LOK_CALLBACK_GRAPHIC_VIEW_SELECTION, "selection", sSelection);
+                }
                 else
                 {
                     // We have a new selection, so both pViewShell and the
diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx
index 048ade6..ada126f 100644
--- a/sw/qa/extras/tiledrendering/tiledrendering.cxx
+++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx
@@ -1304,10 +1304,14 @@ void SwTiledRenderingTest::testCreateViewGraphicSelection()
     // Make sure that the hidden text cursor isn't visible in the second view, either.
     ViewCallback aView2;
     aView2.m_bViewCursorVisible = true;
+    aView2.m_bGraphicViewSelection = false;
     SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView2);
     // This was true, the second view didn't get the visibility of the text
     // cursor of the first view.
     CPPUNIT_ASSERT(!aView2.m_bViewCursorVisible);
+    // This was false, the second view didn't get the graphic selection of the
+    // first view.
+    CPPUNIT_ASSERT(aView2.m_bGraphicViewSelection);
 
     mxComponent->dispose();
     mxComponent.clear();
diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index 72ed33c..d88d21c 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -1224,12 +1224,15 @@ OUString SwCursorShell::getPageRectangles()
     return OUString::fromUtf8(comphelper::string::join("; ", v).getStr());
 }
 
-void SwCursorShell::NotifyCursor(SfxViewShell* pViewShell) const
+void SwCursorShell::NotifyCursor(SfxViewShell* pOtherShell) const
 {
     // Cursor position and visibility.
-    m_pVisibleCursor->_SetPosAndShow(pViewShell);
+    m_pVisibleCursor->_SetPosAndShow(pOtherShell);
     // Text selection.
-    m_pCurrentCursor->Show(pViewShell);
+    m_pCurrentCursor->Show(pOtherShell);
+    // Graphic selection.
+    auto pView = const_cast<SdrView*>(GetDrawView());
+    pView->AdjustMarkHdl(pOtherShell);
 }
 
 /// go to the next SSelection


More information about the Libreoffice-commits mailing list