sfx2/source/dialog/StyleList.cxx                    |   23 +------
 sfx2/source/dialog/templdlg.cxx                     |    9 +-
 svx/source/sidebar/inspector/InspectorTextPanel.cxx |    9 --
 sw/source/uibase/uiview/view0.cxx                   |   62 +++++++++++++++-----
 4 files changed, 62 insertions(+), 41 deletions(-)

New commits:
commit b5e366c97d813c65d477941d45ae55f7dff954ad
Author:     Jim Raykowski <rayk...@gmail.com>
AuthorDate: Thu Apr 3 13:10:20 2025 -0800
Commit:     Jim Raykowski <rayk...@gmail.com>
CommitDate: Sat Apr 5 20:47:21 2025 +0200

    tdf#165998 Spotlight switches the view to the Stylist
    
    * Makes turning on spotlight not switch to the Styles deck unless the
    sidebar is not currently open.
    
    * Makes turning off spotlight not switch to the Styles deck.
    
    * Fixes incorrect spotlight checkbutton state in the Styles deck when
    the state is changed in the Styles Inspector deck.
    
    * Fixes spotlight not turning on using the Styles Inspector deck
    spotlight buttons before visiting the Styles deck once.
    
    Change-Id: I6d2dea05c0ba47fbe3bf63d3caed8d87960df7ac
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183694
    Reviewed-by: Jim Raykowski <rayk...@gmail.com>
    Tested-by: Jenkins

diff --git a/sfx2/source/dialog/StyleList.cxx b/sfx2/source/dialog/StyleList.cxx
index 6643cc8e2981..0d35c0152319 100644
--- a/sfx2/source/dialog/StyleList.cxx
+++ b/sfx2/source/dialog/StyleList.cxx
@@ -438,13 +438,8 @@ void StyleList::UpdateFamily()
     m_bTreeDrag = true;
     if (m_pStyleSheetPool)
     {
-        if (!m_xTreeBox->get_visible())
-            UpdateStyles(StyleFlags::UpdateFamily | 
StyleFlags::UpdateFamilyList);
-        else
-        {
-            UpdateStyles(StyleFlags::UpdateFamily);
-            FillTreeBox(GetActualFamily());
-        }
+        UpdateStyles(StyleFlags::UpdateFamily | StyleFlags::UpdateFamilyList);
+        FillTreeBox(GetActualFamily());
     }
 
     InvalidateBindings();
@@ -1935,12 +1930,8 @@ void StyleList::Update()
         }
 
         m_nAppFilter = pItem->GetValue();
-        if (!m_xTreeBox->get_visible())
-        {
-            UpdateStyles(StyleFlags::UpdateFamilyList);
-        }
-        else
-            FillTreeBox(GetActualFamily());
+        UpdateStyles(StyleFlags::UpdateFamilyList);
+        FillTreeBox(GetActualFamily());
     }
     else
     {
@@ -1952,10 +1943,8 @@ void StyleList::Update()
             && m_nAppFilter != pItem->GetValue())
         {
             m_nAppFilter = pItem->GetValue();
-            if (!m_xTreeBox->get_visible())
-                UpdateStyles(StyleFlags::UpdateFamilyList);
-            else
-                FillTreeBox(GetActualFamily());
+            UpdateStyles(StyleFlags::UpdateFamilyList);
+            FillTreeBox(GetActualFamily());
         }
         else
         {
diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx
index 9204e8779478..f03c8b78b3ee 100644
--- a/sfx2/source/dialog/templdlg.cxx
+++ b/sfx2/source/dialog/templdlg.cxx
@@ -420,6 +420,7 @@ 
SfxCommonTemplateDialog_Impl::~SfxCommonTemplateDialog_Impl()
         m_pDeletionWatcher->signal();
     mxPreviewCheckbox.reset();
     mxFilterLb.reset();
+    mxSpotlightCheckbox.reset();
 }
 
 /**
@@ -618,9 +619,11 @@ void SfxCommonTemplateDialog_Impl::FamilySelect(sal_uInt16 
nEntry, StyleList&, b
         m_aStyleList.FamilySelect(nEntry, bRefresh);
 
         SfxStyleFamily eFam = SfxTemplate::NIdToSfxFamilyId(nActFamily);
-        
mxSpotlightCheckbox->set_visible(m_aStyleList.HasStylesSpotlightFeature()
-                                && (eFam == SfxStyleFamily::Para || eFam == 
SfxStyleFamily::Char));
-        if (mxSpotlightCheckbox->is_visible())
+        bool bShowSpotlightCheckbox
+            = m_aStyleList.HasStylesSpotlightFeature()
+              && (eFam == SfxStyleFamily::Para || eFam == 
SfxStyleFamily::Char);
+        mxSpotlightCheckbox->set_visible(bShowSpotlightCheckbox);
+        if (bShowSpotlightCheckbox)
         {
             bool bActive = false;
             if (eFam == SfxStyleFamily::Para)
diff --git a/svx/source/sidebar/inspector/InspectorTextPanel.cxx 
b/svx/source/sidebar/inspector/InspectorTextPanel.cxx
index 79f718f9eb19..4ec0f39f97ba 100644
--- a/svx/source/sidebar/inspector/InspectorTextPanel.cxx
+++ b/svx/source/sidebar/inspector/InspectorTextPanel.cxx
@@ -206,18 +206,13 @@ void InspectorTextPanel::NotifyItemUpdate(const 
sal_uInt16 nSId, const SfxItemSt
 IMPL_LINK(InspectorTextPanel, ToolbarHdl, const OUString&, rEntry, void)
 {
     SfxDispatcher* pDispatcher = SfxViewFrame::Current()->GetDispatcher();
-    SfxFlagItem aParam(FN_PARAM_1);
     if (rEntry == "paragraphstyles")
     {
-        SfxBoolItem aItem(SID_SPOTLIGHT_PARASTYLES, 
mpToolbar->get_item_active(rEntry));
-        pDispatcher->ExecuteList(SID_SPOTLIGHT_PARASTYLES, 
SfxCallMode::SYNCHRON,
-                                 { &aItem, &aParam });
+        pDispatcher->Execute(SID_SPOTLIGHT_PARASTYLES, SfxCallMode::SYNCHRON);
     }
     else if (rEntry == "characterstyles")
     {
-        SfxBoolItem aItem(SID_SPOTLIGHT_CHARSTYLES, 
mpToolbar->get_item_active(rEntry));
-        pDispatcher->ExecuteList(SID_SPOTLIGHT_CHARSTYLES, 
SfxCallMode::SYNCHRON,
-                                 { &aItem, &aParam });
+        pDispatcher->Execute(SID_SPOTLIGHT_CHARSTYLES, SfxCallMode::SYNCHRON);
     }
     else
     {
diff --git a/sw/source/uibase/uiview/view0.cxx 
b/sw/source/uibase/uiview/view0.cxx
index a3ed716038da..420f90bee2eb 100644
--- a/sw/source/uibase/uiview/view0.cxx
+++ b/sw/source/uibase/uiview/view0.cxx
@@ -71,6 +71,8 @@
 #include <memory>
 #include <swabstdlg.hxx>
 
+#include <sfx2/sidebar/SidebarController.hxx>
+
 using namespace ::com::sun::star;
 
 SFX_IMPL_NAMED_VIEWFACTORY(SwView, "Default")
@@ -576,32 +578,64 @@ void SwView::ExecViewOptions(SfxRequest &rReq)
         break;
 
     case SID_SPOTLIGHT_PARASTYLES:
-        if (!comphelper::LibreOfficeKit::isActive())
-        {
-            if (!pArgs || !pArgs->HasItem(FN_PARAM_1))
-            {
-                const SfxStringItem sDeckName(SID_SIDEBAR_DECK, 
u"StyleListDeck"_ustr);
-                GetDispatcher().ExecuteList(SID_SIDEBAR_DECK, 
SfxCallMode::SYNCHRON, { &sDeckName });
-            }
-        }
+    {
         if (STATE_TOGGLE == eState)
             bFlag = !m_bIsSpotlightParaStyles;
         m_bIsSpotlightParaStyles = bFlag;
-        break;
 
-    case SID_SPOTLIGHT_CHARSTYLES:
-        if (!comphelper::LibreOfficeKit::isActive())
+        if (!comphelper::LibreOfficeKit::isActive() && 
m_bIsSpotlightParaStyles)
         {
             if (!pArgs || !pArgs->HasItem(FN_PARAM_1))
             {
-                const SfxStringItem sDeckName(SID_SIDEBAR_DECK, 
u"StyleListDeck"_ustr);
-                GetDispatcher().ExecuteList(SID_SIDEBAR_DECK, 
SfxCallMode::SYNCHRON, { &sDeckName });
+                // If the sidebar isn't open, open it to the styles deck.
+                sfx2::sidebar::SidebarController* pController
+                    = 
sfx2::sidebar::SidebarController::GetSidebarControllerForFrame(
+                        GetViewFrame().GetFrame().GetFrameInterface());
+                if (!pController)
+                {
+                    const SfxStringItem sDeckName(SID_SIDEBAR_DECK, 
u"StyleListDeck"_ustr);
+                    GetDispatcher().ExecuteList(SID_SIDEBAR_DECK, 
SfxCallMode::SYNCHRON,
+                                                { &sDeckName });
+                }
+                else
+                {
+                    // assure the styles panel is filled
+                    pController->CreateDeck(u"StyleListDeck");
+                }
             }
         }
+    }
+    break;
+
+    case SID_SPOTLIGHT_CHARSTYLES:
+    {
         if (STATE_TOGGLE == eState)
             bFlag = !m_bIsSpotlightCharStyles;
         m_bIsSpotlightCharStyles = bFlag;
-        break;
+
+        if (!comphelper::LibreOfficeKit::isActive() && 
m_bIsSpotlightCharStyles)
+        {
+            if (!pArgs || !pArgs->HasItem(FN_PARAM_1))
+            {
+                // If the sidebar isn't open, open it to the styles deck.
+                sfx2::sidebar::SidebarController* pController
+                    = 
sfx2::sidebar::SidebarController::GetSidebarControllerForFrame(
+                        GetViewFrame().GetFrame().GetFrameInterface());
+                if (!pController)
+                {
+                    const SfxStringItem sDeckName(SID_SIDEBAR_DECK, 
u"StyleListDeck"_ustr);
+                    GetDispatcher().ExecuteList(SID_SIDEBAR_DECK, 
SfxCallMode::SYNCHRON,
+                                                { &sDeckName });
+                }
+                else
+                {
+                    // assure the styles panel is filled
+                    pController->CreateDeck(u"StyleListDeck");
+                }
+            }
+        }
+    }
+    break;
 
     case FN_VIEW_META_CHARS:
         if( STATE_TOGGLE == eState )

Reply via email to