sw/inc/view.hxx                  |    4 +++-
 sw/source/uibase/uiview/view.cxx |   24 +++++++++++++++++++++---
 2 files changed, 24 insertions(+), 4 deletions(-)

New commits:
commit 2c98976f2be2ea7d66836650061ae8ad847175f2
Author:     Tibor Nagy <tibor.nagy.ext...@allotropia.de>
AuthorDate: Wed Jan 29 11:46:56 2025 +0100
Commit:     Nagy Tibor <tibor.nagy.ext...@allotropia.de>
CommitDate: Sat Feb 1 04:24:37 2025 +0100

    tdf#146549 sw: Make the formatting toolbar visible
    
    when moving the cursor to an editable section in read-only mode.
    
    Change-Id: I7ed5837eb627a3db00b1b64516b790cc7a3aea01
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180890
    Tested-by: Jenkins
    Reviewed-by: Thorsten Behrens <thorsten.behr...@allotropia.de>
    (cherry picked from commit 5f81c84e9b5d4bc9eb5ba05aa1aad5eeaa4eb89a)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180990
    Reviewed-by: Nagy Tibor <tibor.nagy.ext...@allotropia.de>
    Tested-by: allotropia jenkins <jenk...@allotropia.de>

diff --git a/sw/inc/view.hxx b/sw/inc/view.hxx
index 1ce11c33bda6..a39b38510183 100644
--- a/sw/inc/view.hxx
+++ b/sw/inc/view.hxx
@@ -642,8 +642,10 @@ public:
     const OUString& GetRedlineAuthor() const;
     /// See SfxViewShell::NotifyCursor().
     void NotifyCursor(SfxViewShell* pViewShell) const override;
-    void ShowUIElement(const OUString& sElementURL) const;
 
+    void SetUIElementVisibility(const OUString& sElementURL, bool bShow) const;
+    void ShowUIElement(const OUString& sElementURL) const;
+    void HideUIElement(const OUString& sElementURL) const;
 
     enum CachedStringID
     {
diff --git a/sw/source/uibase/uiview/view.cxx b/sw/source/uibase/uiview/view.cxx
index 03df8259d09f..50e339fb5641 100644
--- a/sw/source/uibase/uiview/view.cxx
+++ b/sw/source/uibase/uiview/view.cxx
@@ -245,18 +245,30 @@ uno::Reference<frame::XLayoutManager> 
getLayoutManager(const SfxViewFrame& rView
 }
 }
 
-void SwView::ShowUIElement(const OUString& sElementURL) const
+void SwView::SetUIElementVisibility(const OUString& sElementURL, bool bShow) 
const
 {
     if (auto xLayoutManager = getLayoutManager(*GetViewFrame()))
     {
         if (!xLayoutManager->getElement(sElementURL).is())
-        {
             xLayoutManager->createElement(sElementURL);
+
+        if (bShow)
             xLayoutManager->showElement(sElementURL);
-        }
+        else
+            xLayoutManager->hideElement(sElementURL);
     }
 }
 
+void SwView::ShowUIElement(const OUString& sElementURL) const
+{
+    SetUIElementVisibility(sElementURL, true);
+}
+
+void SwView::HideUIElement(const OUString& sElementURL) const
+{
+    SetUIElementVisibility(sElementURL, false);
+}
+
 void SwView::SelectShell()
 {
     // Attention: Maintain the SelectShell for the WebView additionally
@@ -634,6 +646,9 @@ void SwView::CheckReadonlyState()
         }
         if ( SfxItemState::DISABLED == eStateRO )
         {
+            if (m_pWrtShell->GetViewOptions()->IsReadonly())
+                ShowUIElement("private:resource/toolbar/drawtextobjectbar");
+
             rDis.SetSlotFilter( SfxSlotFilterState::ENABLED_READONLY, aROIds );
             bChgd = true;
         }
@@ -656,6 +671,9 @@ void SwView::CheckReadonlyState()
     else if ( SfxItemState::DISABLED != eStateRO ||
                 SfxItemState::DISABLED != eStateProtAll )
     {
+        if (m_pWrtShell->GetViewOptions()->IsReadonly())
+            HideUIElement("private:resource/toolbar/drawtextobjectbar");
+
         bChgd = true;
         rDis.SetSlotFilter();
     }

Reply via email to