[Libreoffice-commits] core.git: Branch 'distro/collabora/co-2021' - 8 commits - desktop/source include/sfx2 sc/source sd/source sfx2/source svx/source sw/source

Tamás Zolnai (via logerrit) logerrit at kemper.freedesktop.org
Thu Apr 1 15:05:30 UTC 2021


 desktop/source/lib/init.cxx                             |    1 
 include/sfx2/sidebar/SidebarController.hxx              |    5 
 sc/source/ui/app/inputhdl.cxx                           |   15 +-
 sc/source/ui/drawfunc/chartsh.cxx                       |   45 ++++++
 sc/source/ui/inc/chartsh.hxx                            |    4 
 sc/source/ui/view/tabvwsh4.cxx                          |   24 +++
 sd/source/ui/slidesorter/shell/SlideSorterViewShell.cxx |   31 ++++
 sd/source/ui/view/drawview.cxx                          |    7 -
 sfx2/source/sidebar/SidebarController.cxx               |   31 ++++
 svx/source/svdraw/svdedxv.cxx                           |    1 
 sw/source/core/crsr/bookmrk.cxx                         |  104 +++++-----------
 sw/source/core/doc/docbm.cxx                            |   35 +++++
 sw/source/core/inc/MarkManager.hxx                      |    2 
 sw/source/core/inc/bookmrk.hxx                          |    7 -
 sw/source/uibase/inc/olesh.hxx                          |    4 
 sw/source/uibase/shells/olesh.cxx                       |   49 +++++++
 sw/source/uibase/shells/textsh1.cxx                     |    4 
 17 files changed, 282 insertions(+), 87 deletions(-)

New commits:
commit db749f20bf499353fa662020c10563f83080a043
Author:     Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Wed Feb 17 15:53:08 2021 +0100
Commit:     Andras Timar <andras.timar at collabora.com>
CommitDate: Thu Apr 1 16:30:43 2021 +0200

    Better fix for tdf#125824: switch page only for the current view.
    
    First workaround was avoiding undoing:
    9dca7c2fac5c6b83a6910aa61b1a2a316f36d948
    
    Second workaround was forcing all views to exit text editing:
    e6c7a018a0cfee395ce2886d41c908a2447ef5cc
    
    Instead of these solutions, we allow to continue text editing
    in other views. What we do is avoiding jumping to the object
    location in all views while undoing. In theory, the two views
    / windows should be able to edit the document's different parts
    independently. So one view should not jump to the location where
    the other view edits something / does an undo.
    
    It works both with multi-window and Collabora Online's collaborative
    editing.
    
    Change-Id: I7ffe29bf175b8f855fe3e92b3d7e11ca6bcd3f5f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111073
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
    (cherry picked from commit 7db8c3d36db3ed727ade2609b7c1017cc813a560)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111112
    Tested-by: Jenkins

diff --git a/sd/source/ui/view/drawview.cxx b/sd/source/ui/view/drawview.cxx
index 74af5d1223b6..55ed74d5181e 100644
--- a/sd/source/ui/view/drawview.cxx
+++ b/sd/source/ui/view/drawview.cxx
@@ -424,8 +424,13 @@ void DrawView::Notify(SfxBroadcaster& rBC, const SfxHint& rHint)
         // switch to that page when it's not a master page
         if(SdrHintKind::SwitchToPage == eHintKind)
         {
-            const SdrPage* pPage = static_cast<const SdrHint&>(rHint).GetPage();
+            // We switch page only in the current view, which triggered this event
+            // and keep other views ontouched.
+            SfxViewShell* pViewShell = SfxViewShell::Current();
+            if(pViewShell && pViewShell != &mpDrawViewShell->GetViewShellBase())
+                return;
 
+            const SdrPage* pPage = static_cast<const SdrHint&>(rHint).GetPage();
             if(pPage && !pPage->IsMasterPage())
             {
                 if(mpDrawViewShell->GetActualPage() != pPage)
diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx
index 8220b4c59b03..0957eb9519b4 100644
--- a/svx/source/svdraw/svdedxv.cxx
+++ b/svx/source/svdraw/svdedxv.cxx
@@ -1521,7 +1521,6 @@ SdrEndTextEditKind SdrObjEditView::SdrEndTextEdit(bool bDontDeleteReally)
             const bool bUndo = IsUndoEnabled();
             if (bUndo)
             {
-                EndTextEditAllViews();
                 OUString aObjName(pTEObj->TakeObjNameSingul());
                 BegUndo(SvxResId(STR_UndoObjSetText), aObjName);
             }
commit ec0ad30084ae2469d5f9f4afbbeec9bf1e86c108
Author:     Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Wed Feb 10 15:07:08 2021 +0100
Commit:     Andras Timar <andras.timar at collabora.com>
CommitDate: Thu Apr 1 16:30:22 2021 +0200

    LOK: form field button: split SendLOKMessage() method.
    
    Hiding form fiel button can be static. We don't need to
    know which fieldmark has the actual button.
    
    Change-Id: I3f7d52c0f11c7dfbb0b4f50bc0c7c0302f50d815
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110711
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
    (cherry picked from commit c591ae91b25fd69e6424434b92894c57671253ca)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110760
    Tested-by: Jenkins

diff --git a/sw/source/core/crsr/bookmrk.cxx b/sw/source/core/crsr/bookmrk.cxx
index 8043fb93fac7..8e965fa51601 100644
--- a/sw/source/core/crsr/bookmrk.cxx
+++ b/sw/source/core/crsr/bookmrk.cxx
@@ -691,7 +691,7 @@ namespace sw::mark
         }
     }
 
-    void DropDownFieldmark::SendLOKMessage(SfxViewShell* pViewShell, std::string_view sAction)
+    void DropDownFieldmark::SendLOKShowMessage(SfxViewShell* pViewShell)
     {
         if (!comphelper::LibreOfficeKit::isActive())
             return;
@@ -699,51 +699,49 @@ namespace sw::mark
         if (!pViewShell || pViewShell->isLOKMobilePhone())
             return;
 
+        if (m_aPortionPaintArea.IsEmpty())
+            return;
+
         OStringBuffer sPayload;
-        if (sAction == "show")
+        sPayload = OStringLiteral("{\"action\": \"show\","
+                   " \"type\": \"drop-down\", \"textArea\": \"") +
+                   m_aPortionPaintArea.SVRect().toString() + "\",";
+        // Add field params to the message
+        sPayload.append(" \"params\": { \"items\": [");
+
+        // List items
+        auto pParameters = this->GetParameters();
+        auto pListEntriesIter = pParameters->find(ODF_FORMDROPDOWN_LISTENTRY);
+        css::uno::Sequence<OUString> vListEntries;
+        if (pListEntriesIter != pParameters->end())
         {
-            if (m_aPortionPaintArea.IsEmpty())
-                return;
-
-            sPayload = OStringLiteral("{\"action\": \"show\","
-                       " \"type\": \"drop-down\", \"textArea\": \"") +
-                       m_aPortionPaintArea.SVRect().toString() + "\",";
-            // Add field params to the message
-            sPayload.append(" \"params\": { \"items\": [");
-
-            // List items
-            auto pParameters = this->GetParameters();
-            auto pListEntriesIter = pParameters->find(ODF_FORMDROPDOWN_LISTENTRY);
-            css::uno::Sequence<OUString> vListEntries;
-            if (pListEntriesIter != pParameters->end())
-            {
-                pListEntriesIter->second >>= vListEntries;
-                for (const OUString& sItem : std::as_const(vListEntries))
-                    sPayload.append("\"" + OUStringToOString(sItem, RTL_TEXTENCODING_UTF8) + "\", ");
-                sPayload.setLength(sPayload.getLength() - 2);
-            }
-            sPayload.append("], ");
-
-            // Selected item
-            auto pSelectedItemIter = pParameters->find(ODF_FORMDROPDOWN_RESULT);
-            sal_Int32 nSelection = -1;
-            if (pSelectedItemIter != pParameters->end())
-            {
-                pSelectedItemIter->second >>= nSelection;
-            }
-            sPayload.append("\"selected\": \"" + OString::number(nSelection) + "\", ");
-
-            // Placeholder text
-            sPayload.append("\"placeholderText\": \"" + OUStringToOString(SwResId(STR_DROP_DOWN_EMPTY_LIST), RTL_TEXTENCODING_UTF8) + "\"}}");
+            pListEntriesIter->second >>= vListEntries;
+            for (const OUString& sItem : std::as_const(vListEntries))
+                sPayload.append("\"" + OUStringToOString(sItem, RTL_TEXTENCODING_UTF8) + "\", ");
+            sPayload.setLength(sPayload.getLength() - 2);
         }
-        else
+        sPayload.append("], ");
+
+        // Selected item
+        auto pSelectedItemIter = pParameters->find(ODF_FORMDROPDOWN_RESULT);
+        sal_Int32 nSelection = -1;
+        if (pSelectedItemIter != pParameters->end())
         {
-            assert(sAction == "hide");
-            sPayload = "{\"action\": \"hide\", \"type\": \"drop-down\"}";
+            pSelectedItemIter->second >>= nSelection;
         }
+        sPayload.append("\"selected\": \"" + OString::number(nSelection) + "\", ");
+
+        // Placeholder text
+        sPayload.append("\"placeholderText\": \"" + OUStringToOString(SwResId(STR_DROP_DOWN_EMPTY_LIST), RTL_TEXTENCODING_UTF8) + "\"}}");
         pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_FORM_FIELD_BUTTON, sPayload.toString().getStr());
     }
 
+    void DropDownFieldmark::SendLOKHideMessage(SfxViewShell* pViewShell)
+    {
+        OString sPayload = "{\"action\": \"hide\", \"type\": \"drop-down\"}";
+        pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_FORM_FIELD_BUTTON, sPayload.getStr());
+    }
+
     DateFieldmark::DateFieldmark(const SwPaM& rPaM)
         : FieldmarkWithDropDownButton(rPaM)
         , m_pNumberFormatter(nullptr)
diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index 2532406f9b1f..a62c371377f4 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -1540,25 +1540,25 @@ namespace sw::mark
             if (m_pLastActiveFieldmark->GetFieldname() == ODF_FORMDROPDOWN)
             {
                 auto pDrowDown = dynamic_cast<::sw::mark::DropDownFieldmark*>(m_pLastActiveFieldmark);
-                pDrowDown->SendLOKMessage(pViewShell, "show");
+                pDrowDown->SendLOKShowMessage(pViewShell);
             }
         }
         else
         {
             // Check whether we have any drop down fieldmark at all.
-            ::sw::mark::DropDownFieldmark* pDrowDown = nullptr;
+            bool bDropDownFieldExist = false;
             for (auto aIter = m_vFieldmarks.begin(); aIter != m_vFieldmarks.end(); ++aIter)
             {
                 IFieldmark *pMark = dynamic_cast<IFieldmark*>(*aIter);
                 if (pMark && pMark->GetFieldname() == ODF_FORMDROPDOWN)
                 {
-                    pDrowDown = dynamic_cast<::sw::mark::DropDownFieldmark*>(pMark);
+                    bDropDownFieldExist = true;
                     break;
                 }
             }
 
-            if (pDrowDown)
-                pDrowDown->SendLOKMessage(pViewShell, "hide");
+            if (bDropDownFieldExist)
+                ::sw::mark::DropDownFieldmark::SendLOKHideMessage(pViewShell);
         }
     }
 
diff --git a/sw/source/core/inc/bookmrk.hxx b/sw/source/core/inc/bookmrk.hxx
index d8bd5fb88976..64567d276aaf 100644
--- a/sw/source/core/inc/bookmrk.hxx
+++ b/sw/source/core/inc/bookmrk.hxx
@@ -292,7 +292,8 @@ namespace sw::mark {
             // This method should be called only by the portion so we can now the portion's painting area
             void SetPortionPaintArea(const SwRect& rPortionPaintArea);
 
-            void SendLOKMessage(SfxViewShell* pViewShell, std::string_view sAction);
+            void SendLOKShowMessage(SfxViewShell* pViewShell);
+            static void SendLOKHideMessage(SfxViewShell* pViewShell);
 
         private:
             SwRect m_aPortionPaintArea;
commit 6d241d6253c3a0f8bdaa203a7635b4ba2a3ef29d
Author:     Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Wed Feb 10 12:23:52 2021 +0100
Commit:     Andras Timar <andras.timar at collabora.com>
CommitDate: Thu Apr 1 16:30:04 2021 +0200

    lok: rework form field button message handling.
    
    To make it work properly with more users editing
    the same document.
    
    Change-Id: I1f3d8ef9fc9c25b440a3dc36a40709723ed342f2
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110710
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
    (cherry picked from commit 20335d5ed549af25f02467c7da21df10c8df956a)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110759
    Tested-by: Tamás Zolnai <tamas.zolnai at collabora.com>

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index cf8503bf136d..2c2fbfa0be36 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1543,6 +1543,7 @@ void CallbackFlushHandler::queue(const int type, const char* data)
             case LOK_CALLBACK_VIEW_CURSOR_VISIBLE:
             case LOK_CALLBACK_CALC_FUNCTION_LIST:
             case LOK_CALLBACK_JSDIALOG:
+            case LOK_CALLBACK_FORM_FIELD_BUTTON:
             {
                 // deleting the duplicate of visible cursor message can cause hyperlink popup not to show up on second/or more click on the same place.
                 // If the hyperlink is not empty we can bypass that to show the popup
diff --git a/sw/source/core/crsr/bookmrk.cxx b/sw/source/core/crsr/bookmrk.cxx
index cfce78f8f93d..8043fb93fac7 100644
--- a/sw/source/core/crsr/bookmrk.cxx
+++ b/sw/source/core/crsr/bookmrk.cxx
@@ -663,7 +663,6 @@ namespace sw::mark
 
     DropDownFieldmark::~DropDownFieldmark()
     {
-        SendLOKMessage("hide");
     }
 
     void DropDownFieldmark::ShowButton(SwEditWin* pEditWin)
@@ -674,13 +673,11 @@ namespace sw::mark
                 m_pButton = VclPtr<DropDownFormFieldButton>::Create(pEditWin, *this);
             m_pButton->CalcPosAndSize(m_aPortionPaintArea);
             m_pButton->Show();
-            SendLOKMessage("show");
         }
     }
 
     void DropDownFieldmark::RemoveButton()
     {
-        SendLOKMessage("hide");
         FieldmarkWithDropDownButton::RemoveButton();
     }
 
@@ -691,32 +688,21 @@ namespace sw::mark
         {
             m_pButton->Show();
             m_pButton->CalcPosAndSize(m_aPortionPaintArea);
-            SendLOKMessage("show");
         }
     }
 
-    void DropDownFieldmark::SendLOKMessage(const OString& sAction)
+    void DropDownFieldmark::SendLOKMessage(SfxViewShell* pViewShell, std::string_view sAction)
     {
-        const SfxViewShell* pViewShell = SfxViewShell::Current();
-        if (!pViewShell || pViewShell->isLOKMobilePhone())
-        {
-              return;
-        }
-
         if (!comphelper::LibreOfficeKit::isActive())
             return;
 
-        if (!m_pButton)
-          return;
-
-        SwEditWin* pEditWin = dynamic_cast<SwEditWin*>(m_pButton->GetParent());
-        if (!pEditWin)
+        if (!pViewShell || pViewShell->isLOKMobilePhone())
             return;
 
         OStringBuffer sPayload;
         if (sAction == "show")
         {
-            if(m_aPortionPaintArea.IsEmpty())
+            if (m_aPortionPaintArea.IsEmpty())
                 return;
 
             sPayload = OStringLiteral("{\"action\": \"show\","
@@ -752,12 +738,10 @@ namespace sw::mark
         }
         else
         {
+            assert(sAction == "hide");
             sPayload = "{\"action\": \"hide\", \"type\": \"drop-down\"}";
         }
-        if (sPayload.toString() != m_sLastSentLOKMsg) {
-            m_sLastSentLOKMsg = sPayload.toString();
-            pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_FORM_FIELD_BUTTON, m_sLastSentLOKMsg.getStr());
-        }
+        pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_FORM_FIELD_BUTTON, sPayload.toString().getStr());
     }
 
     DateFieldmark::DateFieldmark(const SwPaM& rPaM)
diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index c71178e1f005..2532406f9b1f 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -47,6 +47,7 @@
 
 #include <libxml/xmlstring.h>
 #include <libxml/xmlwriter.h>
+#include <comphelper/lok.hxx>
 
 using namespace ::sw::mark;
 
@@ -1517,6 +1518,8 @@ namespace sw::mark
             if(pNewActiveFieldmark)
                 pNewActiveFieldmark->ShowButton(&rEditWin);
         }
+
+        LOKUpdateActiveField(pSwView);
     }
 
     void MarkManager::ClearFieldActivation()
@@ -1527,6 +1530,38 @@ namespace sw::mark
         m_pLastActiveFieldmark = nullptr;
     }
 
+    void MarkManager::LOKUpdateActiveField(SfxViewShell* pViewShell)
+    {
+        if (!comphelper::LibreOfficeKit::isActive())
+            return;
+
+        if (m_pLastActiveFieldmark)
+        {
+            if (m_pLastActiveFieldmark->GetFieldname() == ODF_FORMDROPDOWN)
+            {
+                auto pDrowDown = dynamic_cast<::sw::mark::DropDownFieldmark*>(m_pLastActiveFieldmark);
+                pDrowDown->SendLOKMessage(pViewShell, "show");
+            }
+        }
+        else
+        {
+            // Check whether we have any drop down fieldmark at all.
+            ::sw::mark::DropDownFieldmark* pDrowDown = nullptr;
+            for (auto aIter = m_vFieldmarks.begin(); aIter != m_vFieldmarks.end(); ++aIter)
+            {
+                IFieldmark *pMark = dynamic_cast<IFieldmark*>(*aIter);
+                if (pMark && pMark->GetFieldname() == ODF_FORMDROPDOWN)
+                {
+                    pDrowDown = dynamic_cast<::sw::mark::DropDownFieldmark*>(pMark);
+                    break;
+                }
+            }
+
+            if (pDrowDown)
+                pDrowDown->SendLOKMessage(pViewShell, "hide");
+        }
+    }
+
     IFieldmark* MarkManager::getDropDownFor(const SwPosition& rPos) const
     {
         IFieldmark *pMark = getFieldmarkAt(rPos);
diff --git a/sw/source/core/inc/MarkManager.hxx b/sw/source/core/inc/MarkManager.hxx
index a25e414f8aa2..2a66528093e0 100644
--- a/sw/source/core/inc/MarkManager.hxx
+++ b/sw/source/core/inc/MarkManager.hxx
@@ -26,6 +26,7 @@
 #include <memory>
 
 class SwCursorShell;
+class SfxViewShell;
 
 namespace sw::mark {
     typedef std::unordered_map<OUString, sal_Int32> MarkBasenameMapUniqueOffset_t;
@@ -100,6 +101,7 @@ namespace sw::mark {
 
             virtual void NotifyCursorUpdate(const SwCursorShell& rCursorShell) override;
             virtual void ClearFieldActivation() override;
+            virtual void LOKUpdateActiveField(SfxViewShell* pViewShell);
 
             void dumpAsXml(xmlTextWriterPtr pWriter) const;
 
diff --git a/sw/source/core/inc/bookmrk.hxx b/sw/source/core/inc/bookmrk.hxx
index 245beff3a708..d8bd5fb88976 100644
--- a/sw/source/core/inc/bookmrk.hxx
+++ b/sw/source/core/inc/bookmrk.hxx
@@ -37,6 +37,7 @@ class SwDoc;
 class SwEditWin;
 class SwServerObject;
 class SvNumberFormatter;
+class SfxViewShell;
 
 namespace sw::mark {
         class MarkBase
@@ -291,11 +292,10 @@ namespace sw::mark {
             // This method should be called only by the portion so we can now the portion's painting area
             void SetPortionPaintArea(const SwRect& rPortionPaintArea);
 
-            void SendLOKMessage(const OString& sAction);
+            void SendLOKMessage(SfxViewShell* pViewShell, std::string_view sAction);
 
         private:
             SwRect m_aPortionPaintArea;
-            OString m_sLastSentLOKMsg;
         };
 
         /// Fieldmark representing a date form field.
commit 5014368643cbc98246320cbffac7b6055b60a639
Author:     Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Wed Feb 10 11:04:25 2021 +0100
Commit:     Andras Timar <andras.timar at collabora.com>
CommitDate: Thu Apr 1 16:26:06 2021 +0200

    Dropdown form field: don't increase code compexity for gen backend.
    
    It's just an internal thing, we don't really need to
    optimize the code for it. This HideButton() function is
    not use anywhere else.
    
    Change-Id: I2e5fff73f6d50a0dedbd8d5f7eea748d09de6330
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110709
    Tested-by: Tamás Zolnai <tamas.zolnai at collabora.com>
    Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
    (cherry picked from commit e8d1504ba7299d78dd825a512e8f04ef33900997)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110758
    Tested-by: Jenkins

diff --git a/sw/source/core/crsr/bookmrk.cxx b/sw/source/core/crsr/bookmrk.cxx
index d76b43cebf2a..cfce78f8f93d 100644
--- a/sw/source/core/crsr/bookmrk.cxx
+++ b/sw/source/core/crsr/bookmrk.cxx
@@ -650,12 +650,6 @@ namespace sw::mark
         m_pButton.disposeAndClear();
     }
 
-    void FieldmarkWithDropDownButton::HideButton()
-    {
-        if(m_pButton)
-            m_pButton->Show(false);
-    }
-
     void FieldmarkWithDropDownButton::RemoveButton()
     {
         if(m_pButton)
@@ -684,12 +678,6 @@ namespace sw::mark
         }
     }
 
-    void DropDownFieldmark::HideButton()
-    {
-        SendLOKMessage("hide");
-        FieldmarkWithDropDownButton::HideButton();
-    }
-
     void DropDownFieldmark::RemoveButton()
     {
         SendLOKMessage("hide");
diff --git a/sw/source/core/inc/bookmrk.hxx b/sw/source/core/inc/bookmrk.hxx
index 766791f772e1..245beff3a708 100644
--- a/sw/source/core/inc/bookmrk.hxx
+++ b/sw/source/core/inc/bookmrk.hxx
@@ -271,7 +271,6 @@ namespace sw::mark {
             virtual ~FieldmarkWithDropDownButton() override;
 
             virtual void ShowButton(SwEditWin* pEditWin) = 0;
-            virtual void HideButton();
             virtual void RemoveButton();
 
         protected:
@@ -287,7 +286,6 @@ namespace sw::mark {
             virtual ~DropDownFieldmark() override;
 
             virtual void ShowButton(SwEditWin* pEditWin) override;
-            virtual void HideButton() override;
             virtual void RemoveButton() override;
 
             // This method should be called only by the portion so we can now the portion's painting area
diff --git a/sw/source/uibase/shells/textsh1.cxx b/sw/source/uibase/shells/textsh1.cxx
index a41c9e9d3d9c..c5e7389be77c 100644
--- a/sw/source/uibase/shells/textsh1.cxx
+++ b/sw/source/uibase/shells/textsh1.cxx
@@ -1429,8 +1429,6 @@ void SwTextShell::Execute(SfxRequest &rReq)
                 pFieldBM->Invalidate();
                 rWrtSh.InvalidateWindows( rWrtSh.GetView().GetVisArea() );
                 rWrtSh.UpdateCursor(); // cursor position might be invalid
-                // Hide the button here and make it visible later, to make transparent background work with SAL_USE_VCLPLUGIN=gen
-                dynamic_cast<::sw::mark::DropDownFieldmark&>(*pFieldBM).HideButton();
             }
         }
         else if ( pFieldBM && pFieldBM->GetFieldname() == ODF_FORMDATE )
@@ -1443,8 +1441,6 @@ void SwTextShell::Execute(SfxRequest &rReq)
                 rDateField.Invalidate();
                 rWrtSh.InvalidateWindows( rWrtSh.GetView().GetVisArea() );
                 rWrtSh.UpdateCursor(); // cursor position might be invalid
-                // Hide the button here and make it visible later, to make transparent background work with SAL_USE_VCLPLUGIN=gen
-                rDateField.HideButton();
             }
         }
         else
commit f74cd30781be33d428f2b04bec2382256fbe9277
Author:     Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Fri Jan 22 11:55:25 2021 +0100
Commit:     Andras Timar <andras.timar at collabora.com>
CommitDate: Thu Apr 1 16:25:33 2021 +0200

    tdf#139830: keep the right context for chart after view switch (writer).
    
    Change-Id: Id4829e4bf8f52e2348ebd7874c77e245b18a2bb9
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109812
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109899
    Tested-by: Jenkins

diff --git a/sw/source/uibase/inc/olesh.hxx b/sw/source/uibase/inc/olesh.hxx
index 4f21b2a0396a..a5c9eb28d051 100644
--- a/sw/source/uibase/inc/olesh.hxx
+++ b/sw/source/uibase/inc/olesh.hxx
@@ -30,6 +30,10 @@ private:
     /// SfxInterface initializer.
     static void InitInterface_Impl();
 
+protected:
+    virtual void Activate(bool bMDI) override;
+    virtual void Deactivate(bool bMDI) override;
+
 public:
     SwOleShell(SwView& rView);
 };
diff --git a/sw/source/uibase/shells/olesh.cxx b/sw/source/uibase/shells/olesh.cxx
index b8207d200c94..b823d9a1e6b4 100644
--- a/sw/source/uibase/shells/olesh.cxx
+++ b/sw/source/uibase/shells/olesh.cxx
@@ -23,10 +23,29 @@
 #include <frmsh.hxx>
 #include <olesh.hxx>
 
+#include <sfx2/sidebar/SidebarController.hxx>
+#include <view.hxx>
+
 #define ShellClass_SwOleShell
 #include <sfx2/msg.hxx>
 #include <swslots.hxx>
 
+using namespace css::uno;
+using namespace sfx2::sidebar;
+
+namespace {
+
+bool inChartContext(SwView& rViewShell)
+{
+    SidebarController* pSidebar = SidebarController::GetSidebarControllerForView(&rViewShell);
+    if (pSidebar)
+        return pSidebar->hasChartContextCurrently();
+
+    return false;
+}
+
+} // anonymous namespace
+
 SFX_IMPL_INTERFACE(SwOleShell, SwFrameShell)
 
 void SwOleShell::InitInterface_Impl()
@@ -36,6 +55,36 @@ void SwOleShell::InitInterface_Impl()
     GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_OBJECT, SfxVisibilityFlags::Invisible, ToolbarId::Ole_Toolbox);
 }
 
+void SwOleShell::Activate(bool bMDI)
+{
+    if(!inChartContext(GetView()))
+        SwFrameShell::Activate(bMDI);
+    else
+    {
+        // Avoid context changes for chart during activation / deactivation.
+        const bool bIsContextBroadcasterEnabled (SfxShell::SetContextBroadcasterEnabled(false));
+
+        SwFrameShell::Activate(bMDI);
+
+        SfxShell::SetContextBroadcasterEnabled(bIsContextBroadcasterEnabled);
+    }
+}
+
+void SwOleShell::Deactivate(bool bMDI)
+{
+    if(!inChartContext(GetView()))
+        SwFrameShell::Deactivate(bMDI);
+    else
+    {
+        // Avoid context changes for chart during activation / deactivation.
+        const bool bIsContextBroadcasterEnabled (SfxShell::SetContextBroadcasterEnabled(false));
+
+        SwFrameShell::Deactivate(bMDI);
+
+        SfxShell::SetContextBroadcasterEnabled(bIsContextBroadcasterEnabled);
+    }
+}
+
 SwOleShell::SwOleShell(SwView &_rView) :
     SwFrameShell(_rView)
 
commit ac79ef13d64795009c972fb167bb754f48f94ec3
Author:     Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Fri Jan 22 11:55:06 2021 +0100
Commit:     Andras Timar <andras.timar at collabora.com>
CommitDate: Thu Apr 1 16:25:19 2021 +0200

    tdf#139830: keep the right context for chart after view switch (impress).
    
    Change-Id: Ida345dd884a09b88e35e0df6f9520528c910d9d8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109791
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109898
    Tested-by: Jenkins

diff --git a/sd/source/ui/slidesorter/shell/SlideSorterViewShell.cxx b/sd/source/ui/slidesorter/shell/SlideSorterViewShell.cxx
index 9a4a5608fc5c..a02b445c547d 100644
--- a/sd/source/ui/slidesorter/shell/SlideSorterViewShell.cxx
+++ b/sd/source/ui/slidesorter/shell/SlideSorterViewShell.cxx
@@ -55,6 +55,7 @@
 #include <vcl/EnumContext.hxx>
 #include <svx/sidebar/ContextChangeEventMultiplexer.hxx>
 #include <tools/diagnose_ex.h>
+#include <sfx2/sidebar/SidebarController.hxx>
 
 using namespace ::sd::slidesorter;
 #define ShellClass_SlideSorterViewShell
@@ -66,9 +67,28 @@ using namespace ::com::sun::star::drawing::framework;
 
 using ::sd::framework::FrameworkHelper;
 using ::vcl::EnumContext;
+using namespace sfx2::sidebar;
 
 namespace sd::slidesorter {
 
+namespace {
+
+bool inChartContext(sd::View* pView)
+{
+    if (!pView)
+        return false;
+
+    SfxViewShell* pViewShell = pView->GetSfxViewShell();
+    SidebarController* pSidebar = SidebarController::GetSidebarControllerForView(pViewShell);
+    if (pSidebar)
+        return pSidebar->hasChartContextCurrently();
+
+    return false;
+}
+
+} // anonymous namespace
+
+
 SFX_IMPL_INTERFACE(SlideSorterViewShell, SfxShell)
 
 void SlideSorterViewShell::InitInterface_Impl()
@@ -439,6 +459,17 @@ void SlideSorterViewShell::ArrangeGUIElements()
 
 void SlideSorterViewShell::Activate (bool bIsMDIActivate)
 {
+    if(inChartContext(GetView()))
+    {
+        // Avoid context changes for chart during activation / deactivation.
+        const bool bIsContextBroadcasterEnabled (SfxShell::SetContextBroadcasterEnabled(false));
+
+        ViewShell::Activate(bIsMDIActivate);
+
+        SfxShell::SetContextBroadcasterEnabled(bIsContextBroadcasterEnabled);
+        return;
+    }
+
     ViewShell::Activate(bIsMDIActivate);
     if (mbIsArrangeGUIElementsPending)
         ArrangeGUIElements();
commit 65f0898866b305bb42e893fff57bd74012e25d90
Author:     Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Thu Jan 21 12:12:53 2021 +0100
Commit:     Andras Timar <andras.timar at collabora.com>
CommitDate: Thu Apr 1 16:25:04 2021 +0200

    tdf#139830: keep the right sidebar context for chart after view switch (calc).
    
    There is a general behavior to switch to the default sidebar context
    by view deactivation and switch back to the right context by view
    activation. See SfxShell::Activate() and SfxShell::Deactivate().
    By activation, we use the selection to find out the right sidebar
    context. See GetContextForSelection_SC() method for example. However,
    for charts, this does not work, because the chart window is a separate
    environment and the shell does not know what is selected inside the
    chart window. So let's avoid context switches when we have a chart
    window active. Let the chart controller handle sidebar context changes.
    
    Change-Id: I272ee5c35ac30221eed2930201c4710a9a5877c4
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109790
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109897
    Tested-by: Jenkins

diff --git a/include/sfx2/sidebar/SidebarController.hxx b/include/sfx2/sidebar/SidebarController.hxx
index cd4f329e99d9..2fb2c0e9721e 100644
--- a/include/sfx2/sidebar/SidebarController.hxx
+++ b/include/sfx2/sidebar/SidebarController.hxx
@@ -52,6 +52,7 @@ typedef cppu::WeakComponentImplHelper <
     > SidebarControllerInterfaceBase;
 
 class SfxSplitWindow;
+class SfxViewShell;
 
 namespace sfx2::sidebar {
 
@@ -171,6 +172,10 @@ public:
 
     void SyncUpdate();
 
+    bool hasChartContextCurrently() const;
+
+    static SidebarController* GetSidebarControllerForView(SfxViewShell* pViewShell);
+
 private:
     SidebarController(SidebarDockingWindow* pParentWindow, const SfxViewFrame* pViewFrame);
 
diff --git a/sc/source/ui/drawfunc/chartsh.cxx b/sc/source/ui/drawfunc/chartsh.cxx
index 25b66b0fb7e2..95b06385335e 100644
--- a/sc/source/ui/drawfunc/chartsh.cxx
+++ b/sc/source/ui/drawfunc/chartsh.cxx
@@ -29,14 +29,30 @@
 #include <viewdata.hxx>
 #include <drawview.hxx>
 #include <gridwin.hxx>
+#include <sfx2/sidebar/SidebarController.hxx>
+#include <tabvwsh.hxx>
 
 #define ShellClass_ScChartShell
 #include <scslots.hxx>
 
 using namespace css::uno;
+using namespace sfx2::sidebar;
 
 namespace drawing = com::sun::star::drawing;
 
+namespace {
+
+bool inChartContext(ScTabViewShell* pViewShell)
+{
+    SidebarController* pSidebar = SidebarController::GetSidebarControllerForView(pViewShell);
+    if (pSidebar)
+        return pSidebar->hasChartContextCurrently();
+
+    return false;
+}
+
+} // anonymous namespace
+
 SFX_IMPL_INTERFACE(ScChartShell, ScDrawShell)
 
 void ScChartShell::InitInterface_Impl()
@@ -48,6 +64,35 @@ void ScChartShell::InitInterface_Impl()
     GetStaticInterface()->RegisterPopupMenu("oleobject");
 }
 
+void ScChartShell::Activate(bool bMDI)
+{
+    if(!inChartContext(GetViewData().GetViewShell()))
+        ScDrawShell::Activate(bMDI);
+    else
+    {
+        // Avoid context changes for chart during activation / deactivation.
+        const bool bIsContextBroadcasterEnabled (SfxShell::SetContextBroadcasterEnabled(false));
+
+        SfxShell::Activate(bMDI);
+
+        SfxShell::SetContextBroadcasterEnabled(bIsContextBroadcasterEnabled);
+    }
+}
+
+void ScChartShell::Deactivate(bool bMDI)
+{
+    if(!inChartContext(GetViewData().GetViewShell()))
+        ScDrawShell::Deactivate(bMDI);
+    else
+    {
+        // Avoid context changes for chart during activation / deactivation.
+        const bool bIsContextBroadcasterEnabled (SfxShell::SetContextBroadcasterEnabled(false));
+
+        SfxShell::Deactivate(bMDI);
+
+        SfxShell::SetContextBroadcasterEnabled(bIsContextBroadcasterEnabled);
+    }
+}
 
 ScChartShell::ScChartShell(ScViewData& rData) :
     ScDrawShell(rData)
diff --git a/sc/source/ui/inc/chartsh.hxx b/sc/source/ui/inc/chartsh.hxx
index fc2ee32b0d0e..44000af245da 100644
--- a/sc/source/ui/inc/chartsh.hxx
+++ b/sc/source/ui/inc/chartsh.hxx
@@ -36,6 +36,10 @@ private:
     /// SfxInterface initializer.
     static void InitInterface_Impl();
 
+protected:
+    virtual void Activate(bool bMDI) override;
+    virtual void Deactivate(bool bMDI) override;
+
 public:
     ScChartShell(ScViewData& rData);
     virtual ~ScChartShell() override;
diff --git a/sc/source/ui/view/tabvwsh4.cxx b/sc/source/ui/view/tabvwsh4.cxx
index 68a76c329007..34a11e3f8e6e 100644
--- a/sc/source/ui/view/tabvwsh4.cxx
+++ b/sc/source/ui/view/tabvwsh4.cxx
@@ -86,8 +86,23 @@
 #include <comphelper/flagguard.hxx>
 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
 #include <comphelper/lok.hxx>
+#include <sfx2/sidebar/SidebarController.hxx>
 
 using namespace com::sun::star;
+using namespace sfx2::sidebar;
+
+namespace {
+
+bool inChartContext(ScTabViewShell* pViewShell)
+{
+    SidebarController* pSidebar = SidebarController::GetSidebarControllerForView(pViewShell);
+    if (pSidebar)
+        return pSidebar->hasChartContextCurrently();
+
+    return false;
+}
+
+} // anonymous namespace
 
 void ScTabViewShell::Activate(bool bMDI)
 {
@@ -204,9 +219,12 @@ void ScTabViewShell::Activate(bool bMDI)
     //  don't call CheckSelectionTransfer here - activating a view should not change the
     //  primary selection (may be happening just because the mouse was moved over the window)
 
-    ContextChangeEventMultiplexer::NotifyContextChange(
-        GetController(),
-        vcl::EnumContext::Context::Default);
+    if (!inChartContext(this))
+    {
+        ContextChangeEventMultiplexer::NotifyContextChange(
+            GetController(),
+            vcl::EnumContext::Context::Default);
+    }
 }
 
 void ScTabViewShell::Deactivate(bool bMDI)
diff --git a/sfx2/source/sidebar/SidebarController.cxx b/sfx2/source/sidebar/SidebarController.cxx
index 98c8acbc6c67..b78e8e41d0ae 100644
--- a/sfx2/source/sidebar/SidebarController.cxx
+++ b/sfx2/source/sidebar/SidebarController.cxx
@@ -28,6 +28,8 @@
 #include <sfx2/sidebar/SidebarChildWindow.hxx>
 #include <sidebar/Tools.hxx>
 #include <sfx2/sidebar/SidebarDockingWindow.hxx>
+#include <com/sun/star/ui/XSidebarProvider.hpp>
+#include <com/sun/star/frame/XController2.hpp>
 #include <sfx2/sidebar/Context.hxx>
 
 
@@ -1593,6 +1595,35 @@ void SidebarController::saveDeckState()
     }
 }
 
+bool SidebarController::hasChartContextCurrently() const
+{
+    return GetCurrentContext().msApplication == "com.sun.star.chart2.ChartDocument";
+}
+
+sfx2::sidebar::SidebarController* SidebarController::GetSidebarControllerForView(SfxViewShell* pViewShell)
+{
+    if (!pViewShell)
+        return nullptr;
+
+    Reference<css::frame::XController2> xController(pViewShell->GetController(), UNO_QUERY);
+    if (!xController.is())
+        return nullptr;
+
+    // Make sure there is a model behind the controller, otherwise getSidebar() can crash.
+    if (!xController->getModel().is())
+        return nullptr;
+
+    Reference<css::ui::XSidebarProvider> xSidebarProvider = xController->getSidebar();
+    if (!xSidebarProvider.is())
+        return nullptr;
+
+    Reference<css::ui::XSidebar> xSidebar = xSidebarProvider->getSidebar();
+    if (!xSidebar.is())
+        return nullptr;
+
+    return dynamic_cast<sfx2::sidebar::SidebarController*>(xSidebar.get());
+}
+
 } // end of namespace sfx2::sidebar
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 3067e05cacda4d1427282801480a4860fee10a61
Author:     Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Wed Jan 13 05:30:53 2021 +0100
Commit:     Andras Timar <andras.timar at collabora.com>
CommitDate: Thu Apr 1 16:24:44 2021 +0200

    lok: don't turn off online spelling by view change.
    
    Since we don't exit editing for LOK inside this NotifyChange()
    method, we should keep also spelling functionality alive. See
    also the comment we have here: "As long as the content is not
    edited, turn off online spelling." So it seems a good idea
    to make this spelling modification dependent of bStopEditing flag.
    This causes issues, during view switches.
    
    Change-Id: Ic684073d129c1cac4b6f4d11f34cd64cb5db3295
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109206
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109209
    Tested-by: Jenkins

diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index 5b236f0394ea..277bc2d53406 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -4135,16 +4135,17 @@ void ScInputHandler::NotifyChange( const ScInputHdlState* pState,
                         pActiveViewSh->libreOfficeKitViewCallback(LOK_CALLBACK_CELL_ADDRESS, aPosStr.toUtf8().getStr());
                 }
 
-                if (bStopEditing)
+                if (bStopEditing) {
                     SfxGetpApp()->Broadcast( SfxHint( SfxHintId::ScKillEditView ) );
 
-                //  As long as the content is not edited, turn off online spelling.
-                //  Online spelling is turned back on in StartTable, after setting
-                //  the right language from cell attributes.
+                    //  As long as the content is not edited, turn off online spelling.
+                    //  Online spelling is turned back on in StartTable, after setting
+                    //  the right language from cell attributes.
 
-                EEControlBits nCntrl = mpEditEngine->GetControlWord();
-                if ( nCntrl & EEControlBits::ONLINESPELLING )
-                    mpEditEngine->SetControlWord( nCntrl & ~EEControlBits::ONLINESPELLING );
+                    EEControlBits nCntrl = mpEditEngine->GetControlWord();
+                    if ( nCntrl & EEControlBits::ONLINESPELLING )
+                        mpEditEngine->SetControlWord( nCntrl & ~EEControlBits::ONLINESPELLING );
+                }
 
                 bModified = false;
                 bSelIsRef = false;


More information about the Libreoffice-commits mailing list