include/sfx2/sfxsids.hrc                                            |    3 
 include/sfx2/templdlg.hxx                                           |   14 +
 officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu |   33 +++
 sfx2/source/dialog/templdlg.cxx                                     |   88 
++++++++--
 sw/inc/view.hxx                                                     |    2 
 sw/sdi/_viewsh.sdi                                                  |   12 +
 sw/sdi/swriter.sdi                                                  |   34 +++
 sw/source/uibase/uiview/view0.cxx                                   |   28 +++
 sw/uiconfig/swriter/menubar/menubar.xml                             |    8 
 9 files changed, 204 insertions(+), 18 deletions(-)

New commits:
commit 6320a4c21cf54d32c778417ee077d67fd0bad050
Author:     Jim Raykowski <rayk...@gmail.com>
AuthorDate: Mon Oct 16 06:48:35 2023 -0800
Commit:     Jim Raykowski <rayk...@gmail.com>
CommitDate: Wed Oct 18 04:13:55 2023 +0200

    tdf#156114 UNO commands / menu entries to enable PS/CS spotlight
    
    Change-Id: I2796b595ef961c477dea85c337ad343599aea7cf
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158055
    Tested-by: Jenkins
    Reviewed-by: Jim Raykowski <rayk...@gmail.com>

diff --git a/include/sfx2/sfxsids.hrc b/include/sfx2/sfxsids.hrc
index 9789cc8a0ac1..55327feb0034 100644
--- a/include/sfx2/sfxsids.hrc
+++ b/include/sfx2/sfxsids.hrc
@@ -388,6 +388,9 @@ class SvxZoomItem;
 #define SID_STYLE_UPD_BY_EX_NAME            
TypedWhichId<SfxStringItem>(SID_SFX_START + 1585)
 #define SID_STYLE_REFERENCE                 
TypedWhichId<SfxStringItem>(SID_SFX_START + 1602)
 
+#define SID_SPOTLIGHT_PARASTYLES            
TypedWhichId<SfxBoolItem>(SID_SFX_START + 1605)
+#define SID_SPOTLIGHT_CHARSTYLES            
TypedWhichId<SfxBoolItem>(SID_SFX_START + 1606)
+
 #define SID_TEMPLATE_NAME                   
TypedWhichId<SfxStringItem>(SID_SFX_START + 660)
 #define SID_TEMPLATE_REGIONNAME             
TypedWhichId<SfxStringItem>(SID_SFX_START + 662)
 #define SID_TEMPLATE_LOAD                   
TypedWhichId<SfxInt32Item>(SID_SFX_START + 663)
diff --git a/include/sfx2/templdlg.hxx b/include/sfx2/templdlg.hxx
index 5dd5b8b6b178..254fcc790fb0 100644
--- a/include/sfx2/templdlg.hxx
+++ b/include/sfx2/templdlg.hxx
@@ -24,11 +24,14 @@
 #include <sal/config.h>
 #include <sfx2/dllapi.h>
 #include <sfx2/sidebar/PanelLayout.hxx>
+#include <sfx2/sidebar/ControllerItem.hxx>
 
 class SfxBindings;
 class SfxTemplateDialog_Impl;
 
-class UNLESS_MERGELIBS(SFX2_DLLPUBLIC) SfxTemplatePanelControl final : public 
PanelLayout
+class UNLESS_MERGELIBS(SFX2_DLLPUBLIC) SfxTemplatePanelControl final
+    : public PanelLayout,
+      public ::sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface
 {
 public:
     SfxTemplatePanelControl(SfxBindings* pBindings, weld::Widget* pParent);
@@ -37,7 +40,16 @@ public:
     weld::Builder* get_builder() { return m_xBuilder.get(); }
     weld::Container* get_container() { return m_xContainer.get(); }
 
+    virtual void NotifyItemUpdate(const sal_uInt16 nSId, const SfxItemState 
eState,
+                                  const SfxPoolItem* pState) override;
+
+    virtual void GetControlState(const sal_uInt16 /*nSId*/,
+                                 boost::property_tree::ptree& /*rState*/) 
override{};
+
 private:
+    ::sfx2::sidebar::ControllerItem m_aSpotlightParaStyles;
+    ::sfx2::sidebar::ControllerItem m_aSpotlightCharStyles;
+
     std::unique_ptr<SfxTemplateDialog_Impl> pImpl;
 };
 
diff --git 
a/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu 
b/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu
index c0d820c0e43b..44a98e183ccc 100644
--- a/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu
+++ b/officecfg/registry/data/org/openoffice/Office/UI/WriterCommands.xcu
@@ -429,6 +429,31 @@
         <prop oor:name="Label" oor:type="xs:string">
           <value xml:lang="en-US">Spotlight Character Direct Formatting</value>
         </prop>
+        <prop oor:name="ContextLabel" oor:type="xs:string">
+          <value xml:lang="en-US">Character Direct Formatting</value>
+        </prop>
+        <prop oor:name="Properties" oor:type="xs:int">
+          <value>1</value>
+        </prop>
+      </node>
+      <node oor:name=".uno:SpotlightParaStyles" oor:op="replace">
+        <prop oor:name="Label" oor:type="xs:string">
+          <value xml:lang="en-US">Spotlight Paragraph Styles</value>
+        </prop>
+        <prop oor:name="ContextLabel" oor:type="xs:string">
+          <value xml:lang="en-US">Paragraph Styles</value>
+        </prop>
+        <prop oor:name="Properties" oor:type="xs:int">
+          <value>1</value>
+        </prop>
+      </node>
+      <node oor:name=".uno:SpotlightCharStyles" oor:op="replace">
+        <prop oor:name="Label" oor:type="xs:string">
+          <value xml:lang="en-US">Spotlight Character Styles</value>
+        </prop>
+        <prop oor:name="ContextLabel" oor:type="xs:string">
+          <value xml:lang="en-US">Character Styles</value>
+        </prop>
         <prop oor:name="Properties" oor:type="xs:int">
           <value>1</value>
         </prop>
@@ -4214,6 +4239,14 @@
           <value xml:lang="en-US">Open the Accessibility Check Deck</value>
         </prop>
       </node>
+      <node oor:name=".uno:SpotlightMenu" oor:op="replace">
+        <prop oor:name="Label" oor:type="xs:string">
+          <value xml:lang="en-US">Spotlight</value>
+        </prop>
+        <prop oor:name="Properties" oor:type="xs:int">
+          <value>1</value>
+        </prop>
+      </node>
     </node>
   </node>
 </oor:component-data>
diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx
index 7f44bf64d366..db21ee720c2d 100644
--- a/sfx2/source/dialog/templdlg.cxx
+++ b/sfx2/source/dialog/templdlg.cxx
@@ -107,17 +107,6 @@ IMPL_LINK(SfxCommonTemplateDialog_Impl, 
OnAsyncExecuteDrop, void*, pStyleList, v
         ActionSelect("new", m_aStyleList);
 }
 
-SfxTemplatePanelControl::SfxTemplatePanelControl(SfxBindings* pBindings, 
weld::Widget* pParent)
-    : PanelLayout(pParent, "TemplatePanel", "sfx/ui/templatepanel.ui")
-    , pImpl(new SfxTemplateDialog_Impl(pBindings, this))
-{
-    OSL_ASSERT(pBindings!=nullptr);
-}
-
-SfxTemplatePanelControl::~SfxTemplatePanelControl()
-{
-}
-
 namespace SfxTemplate
 {
     // converts from SFX_STYLE_FAMILY Ids to 1-6
@@ -157,6 +146,61 @@ namespace SfxTemplate
     }
 }
 
+SfxTemplatePanelControl::SfxTemplatePanelControl(SfxBindings* pBindings, 
weld::Widget* pParent)
+    : PanelLayout(pParent, "TemplatePanel", "sfx/ui/templatepanel.ui")
+    , m_aSpotlightParaStyles(SID_SPOTLIGHT_PARASTYLES, *pBindings, *this)
+    , m_aSpotlightCharStyles(SID_SPOTLIGHT_CHARSTYLES, *pBindings, *this)
+    , pImpl(new SfxTemplateDialog_Impl(pBindings, this))
+{
+    OSL_ASSERT(pBindings!=nullptr);
+}
+
+SfxTemplatePanelControl::~SfxTemplatePanelControl()
+{
+    m_aSpotlightParaStyles.dispose();
+    m_aSpotlightCharStyles.dispose();
+}
+
+void SfxTemplatePanelControl::NotifyItemUpdate(const sal_uInt16 nSId, const 
SfxItemState eState,
+                                               const SfxPoolItem* pState)
+{
+    switch (nSId)
+    {
+        case SID_SPOTLIGHT_PARASTYLES:
+            if (eState >= SfxItemState::DEFAULT)
+            {
+                const SfxBoolItem* pItem = dynamic_cast<const 
SfxBoolItem*>(pState);
+                if (pItem)
+                {
+                    bool bValue = pItem->GetValue();
+                    if (bValue || (!bValue && 
pImpl->m_aStyleList.IsHighlightParaStyles()))
+                    {
+                        pImpl->m_aStyleList.SetHighlightParaStyles(bValue);
+                        
pImpl->FamilySelect(SfxTemplate::SfxFamilyIdToNId(SfxStyleFamily::Para),
+                                            pImpl->m_aStyleList, true);
+                    }
+                }
+            }
+            break;
+        case SID_SPOTLIGHT_CHARSTYLES:
+            if (eState >= SfxItemState::DEFAULT)
+            {
+                const SfxBoolItem* pItem = dynamic_cast<const 
SfxBoolItem*>(pState);
+                if (pItem)
+                {
+                    bool bValue = pItem->GetValue();
+                    if (bValue || (!bValue && 
pImpl->m_aStyleList.IsHighlightCharStyles()))
+                    {
+                        pImpl->m_aStyleList.SetHighlightCharStyles(bValue);
+                        
pImpl->FamilySelect(SfxTemplate::SfxFamilyIdToNId(SfxStyleFamily::Char),
+                                            pImpl->m_aStyleList, true);
+                    }
+                }
+            }
+            break;
+    }
+}
+
 void SfxCommonTemplateDialog_Impl::connect_stylelist_execute_drop(
     const Link<const ExecuteDropEvent&, sal_Int8>& rLink)
 {
@@ -348,6 +392,21 @@ IMPL_LINK(SfxCommonTemplateDialog_Impl, UpdateStyles_Hdl, 
StyleFlags, nFlags, vo
 
 SfxCommonTemplateDialog_Impl::~SfxCommonTemplateDialog_Impl()
 {
+    // Set the UNO's in an 'off' state. FN_PARAM_1 is used to prevent the 
sidebar from trying to
+    // reopen while it is being closed here.
+    if (m_aStyleList.IsHighlightParaStyles())
+    {
+        SfxDispatcher &rDispatcher = *SfxGetpApp()->GetDispatcher_Impl();
+        SfxFlagItem aParam(FN_PARAM_1);
+        rDispatcher.ExecuteList(SID_SPOTLIGHT_PARASTYLES, 
SfxCallMode::SYNCHRON, { &aParam });
+    }
+    if (m_aStyleList.IsHighlightCharStyles())
+    {
+        SfxDispatcher &rDispatcher = *SfxGetpApp()->GetDispatcher_Impl();
+        SfxFlagItem aParam(FN_PARAM_1);
+        rDispatcher.ExecuteList(SID_SPOTLIGHT_CHARSTYLES, 
SfxCallMode::SYNCHRON, { &aParam });
+    }
+
     if ( bIsWater )
         Execute_Impl(SID_STYLE_WATERCAN, "", "", 0, m_aStyleList);
     m_aStyleListClear.Call(nullptr);
@@ -677,13 +736,12 @@ IMPL_LINK_NOARG(SfxCommonTemplateDialog_Impl, PreviewHdl, 
weld::Toggleable&, voi
 
 IMPL_LINK_NOARG(SfxCommonTemplateDialog_Impl, HighlightHdl, weld::Toggleable&, 
void)
 {
-    bool bActive = mxHighlightCheckbox->get_active();
+    SfxDispatcher &rDispatcher = *SfxGetpApp()->GetDispatcher_Impl();
     SfxStyleFamily eFam = SfxTemplate::NIdToSfxFamilyId(nActFamily);
     if (eFam == SfxStyleFamily::Para)
-        m_aStyleList.SetHighlightParaStyles(bActive);
+       rDispatcher.Execute(SID_SPOTLIGHT_PARASTYLES, SfxCallMode::SYNCHRON);
     else if (eFam == SfxStyleFamily::Char)
-        m_aStyleList.SetHighlightCharStyles(bActive);
-    FamilySelect(nActFamily, m_aStyleList, true);
+       rDispatcher.Execute(SID_SPOTLIGHT_CHARSTYLES, SfxCallMode::SYNCHRON);
 }
 
 IMPL_LINK_NOARG(SfxCommonTemplateDialog_Impl, UpdateStyleDependents_Hdl, 
void*, void)
diff --git a/sw/inc/view.hxx b/sw/inc/view.hxx
index 523f86cc8468..bf96007db6b4 100644
--- a/sw/inc/view.hxx
+++ b/sw/inc/view.hxx
@@ -274,6 +274,8 @@ class SW_DLLPUBLIC SwView: public SfxViewShell
     int m_nMaxOutlineLevelShown = 10;
 
     bool m_bIsHighlightCharDF = false;
+    bool m_bIsSpotlightParaStyles = false;
+    bool m_bIsSpotlightCharStyles = false;
 
     static constexpr sal_uInt16 MAX_ZOOM_PERCENT = 600;
     static constexpr sal_uInt16 MIN_ZOOM_PERCENT = 20;
diff --git a/sw/sdi/_viewsh.sdi b/sw/sdi/_viewsh.sdi
index a3b2e5e3cdcc..0a9e92dea48f 100644
--- a/sw/sdi/_viewsh.sdi
+++ b/sw/sdi/_viewsh.sdi
@@ -918,6 +918,18 @@ interface BaseTextEditView
         StateMethod = StateViewOptions ;
     ]
 
+    SID_SPOTLIGHT_PARASTYLES
+    [
+        ExecMethod = ExecViewOptions ;
+        StateMethod = StateViewOptions ;
+    ]
+
+    SID_SPOTLIGHT_CHARSTYLES
+    [
+        ExecMethod = ExecViewOptions ;
+        StateMethod = StateViewOptions ;
+    ]
+
     FN_VIEW_META_CHARS // status()
     [
         ExecMethod = ExecViewOptions ;
diff --git a/sw/sdi/swriter.sdi b/sw/sdi/swriter.sdi
index 56b381881939..bf3de167741e 100644
--- a/sw/sdi/swriter.sdi
+++ b/sw/sdi/swriter.sdi
@@ -4102,7 +4102,39 @@ SfxBoolItem HighlightCharDF FN_HIGHLIGHT_CHAR_DF
     AccelConfig = TRUE,
     MenuConfig = TRUE,
     ToolBoxConfig = TRUE,
-    GroupId = SfxGroupId::View;
+    GroupId = SfxGroupId::Format;
+]
+
+SfxBoolItem SpotlightParaStyles SID_SPOTLIGHT_PARASTYLES
+[
+    AutoUpdate = FALSE,
+    FastCall = FALSE,
+    ReadOnlyDoc = TRUE,
+    Toggle = TRUE,
+    Container = FALSE,
+    RecordAbsolute = FALSE,
+    RecordPerSet;
+
+    AccelConfig = TRUE,
+    MenuConfig = TRUE,
+    ToolBoxConfig = TRUE,
+    GroupId = SfxGroupId::Format;
+]
+
+SfxBoolItem SpotlightCharStyles SID_SPOTLIGHT_CHARSTYLES
+[
+    AutoUpdate = FALSE,
+    FastCall = FALSE,
+    ReadOnlyDoc = TRUE,
+    Toggle = TRUE,
+    Container = FALSE,
+    RecordAbsolute = FALSE,
+    RecordPerSet;
+
+    AccelConfig = TRUE,
+    MenuConfig = TRUE,
+    ToolBoxConfig = TRUE,
+    GroupId = SfxGroupId::Format;
 ]
 
 SfxVoidItem MergeCells FN_TABLE_MERGE_CELLS
diff --git a/sw/source/uibase/uiview/view0.cxx 
b/sw/source/uibase/uiview/view0.cxx
index 1aff6af42f8d..66d8c66597ae 100644
--- a/sw/source/uibase/uiview/view0.cxx
+++ b/sw/source/uibase/uiview/view0.cxx
@@ -361,6 +361,12 @@ void SwView::StateViewOptions(SfxItemSet &rSet)
             case FN_HIGHLIGHT_CHAR_DF:
               aBool.SetValue(m_bIsHighlightCharDF);
             break;
+            case SID_SPOTLIGHT_PARASTYLES:
+                aBool.SetValue(m_bIsSpotlightParaStyles);
+            break;
+            case SID_SPOTLIGHT_CHARSTYLES:
+                aBool.SetValue(m_bIsSpotlightCharStyles);
+            break;
         }
 
         if( nWhich )
@@ -557,6 +563,28 @@ void SwView::ExecViewOptions(SfxRequest &rReq)
         m_bIsHighlightCharDF = bFlag;
         break;
 
+    case SID_SPOTLIGHT_PARASTYLES:
+        if (!pArgs || (pArgs && !pArgs->HasItem(FN_PARAM_1)))
+        {
+            const SfxStringItem sDeckName(SID_SIDEBAR_DECK, "StyleListDeck");
+            GetDispatcher().ExecuteList(SID_SIDEBAR_DECK, 
SfxCallMode::SYNCHRON, { &sDeckName });
+        }
+        if (STATE_TOGGLE == eState)
+            bFlag = !m_bIsSpotlightParaStyles;
+        m_bIsSpotlightParaStyles = bFlag;
+        break;
+
+    case SID_SPOTLIGHT_CHARSTYLES:
+        if (!pArgs || (pArgs && !pArgs->HasItem(FN_PARAM_1)))
+        {
+            const SfxStringItem sDeckName(SID_SIDEBAR_DECK, "StyleListDeck");
+            GetDispatcher().ExecuteList(SID_SIDEBAR_DECK, 
SfxCallMode::SYNCHRON, { &sDeckName });
+        }
+        if (STATE_TOGGLE == eState)
+            bFlag = !m_bIsSpotlightCharStyles;
+        m_bIsSpotlightCharStyles = bFlag;
+        break;
+
     case FN_VIEW_META_CHARS:
         if( STATE_TOGGLE == eState )
             bFlag = !pOpt->IsViewMetaChars();
diff --git a/sw/uiconfig/swriter/menubar/menubar.xml 
b/sw/uiconfig/swriter/menubar/menubar.xml
index bc9b8751b016..5e8fe23f7107 100644
--- a/sw/uiconfig/swriter/menubar/menubar.xml
+++ b/sw/uiconfig/swriter/menubar/menubar.xml
@@ -426,7 +426,13 @@
       <menu:menuseparator/>
       <menu:menuitem menu:id=".uno:FormatPaintbrush"/>
       <menu:menuitem menu:id=".uno:ResetAttributes"/>
-      <menu:menuitem menu:id=".uno:HighlightCharDF"/>
+      <menu:menu menu:id=".uno:SpotlightMenu">
+        <menu:menupopup>
+          <menu:menuitem menu:id=".uno:HighlightCharDF"/>
+          <menu:menuitem menu:id=".uno:SpotlightParaStyles"/>
+          <menu:menuitem menu:id=".uno:SpotlightCharStyles"/>
+        </menu:menupopup>
+      </menu:menu>
       <menu:menuseparator/>
       <menu:menuitem menu:id=".uno:FontDialog"/>
       <menu:menuitem menu:id=".uno:ParagraphDialog"/>

Reply via email to