include/svx/sidebar/InspectorTextPanel.hxx          |   20 +++
 svx/source/sidebar/inspector/InspectorTextPanel.cxx |   77 ++++++++++++++
 svx/uiconfig/ui/inspectortextpanel.ui               |  104 ++++++++++++++++----
 3 files changed, 183 insertions(+), 18 deletions(-)

New commits:
commit 0d0e5c72e6344de48227b74846a6ff638b803c64
Author:     Karthik <m...@karthikreddy.org>
AuthorDate: Mon Mar 10 13:34:39 2025 +0530
Commit:     Heiko Tietze <heiko.tie...@documentfoundation.org>
CommitDate: Tue Apr 1 11:44:01 2025 +0200

    tdf#160194 Add 3 checkboxes in Style InspectorPanel
    
    Add functionality to enable/disable below SportLight features
    in Style InspectorPanel
    
    - Paragraph Styles
    - Character Styles
    - Direct Formatting
    
    Change-Id: I22bc988514ed28dbf309ddb148b1d029bb507b1c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182716
    Tested-by: Jenkins
    Tested-by: Heiko Tietze <heiko.tie...@documentfoundation.org>
    Reviewed-by: Heiko Tietze <heiko.tie...@documentfoundation.org>

diff --git a/include/svx/sidebar/InspectorTextPanel.hxx 
b/include/svx/sidebar/InspectorTextPanel.hxx
index f6ef0234ade1..f47babe14c62 100644
--- a/include/svx/sidebar/InspectorTextPanel.hxx
+++ b/include/svx/sidebar/InspectorTextPanel.hxx
@@ -18,6 +18,7 @@
  */
 #pragma once
 
+#include <sfx2/sidebar/ControllerItem.hxx>
 #include <sfx2/sidebar/PanelLayout.hxx>
 #include <svx/svxdllapi.h>
 
@@ -41,7 +42,9 @@ struct TreeNode
     {
     }
 };
-class SVX_DLLPUBLIC InspectorTextPanel : public PanelLayout
+class SVX_DLLPUBLIC InspectorTextPanel
+    : public PanelLayout,
+      public sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface
 {
 public:
     virtual ~InspectorTextPanel() override;
@@ -52,8 +55,23 @@ public:
 
     void updateEntries(const std::vector<TreeNode>& rStore, const sal_Int32 
nParIdx);
 
+    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:
     std::unique_ptr<weld::TreeView> mpListBoxStyles;
+
+    std::unique_ptr<weld::Toolbar> mpToolbar;
+
+    sal_uInt16 nSlotDFStyles;
+
+    sfx2::sidebar::ControllerItem mParaController;
+    sfx2::sidebar::ControllerItem mCharController;
+    sfx2::sidebar::ControllerItem mDFController;
+
+    DECL_LINK(ToolbarHdl, const OUString&, void);
 };
 
 } // end of namespace svx::sidebar
diff --git a/svx/source/sidebar/inspector/InspectorTextPanel.cxx 
b/svx/source/sidebar/inspector/InspectorTextPanel.cxx
index 4cb05d63d49f..190d95f7d4e7 100644
--- a/svx/source/sidebar/inspector/InspectorTextPanel.cxx
+++ b/svx/source/sidebar/inspector/InspectorTextPanel.cxx
@@ -17,6 +17,13 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <sfx2/dispatch.hxx>
+#include <sfx2/msg.hxx>
+#include <sfx2/sfxsids.hrc>
+#include <sfx2/viewfrm.hxx>
+#include <svl/eitem.hxx>
+#include <svl/flagitem.hxx>
+#include <svl/itemset.hxx>
 #include <o3tl/safeint.hxx>
 #include <sal/config.h>
 
@@ -45,12 +52,29 @@ std::unique_ptr<PanelLayout> 
InspectorTextPanel::Create(weld::Widget* pParent)
 InspectorTextPanel::InspectorTextPanel(weld::Widget* pParent)
     : PanelLayout(pParent, u"InspectorTextPanel"_ustr, 
u"svx/ui/inspectortextpanel.ui"_ustr)
     , mpListBoxStyles(m_xBuilder->weld_tree_view(u"listbox_fonts"_ustr))
+    , nSlotDFStyles(
+          
SfxViewFrame::Current()->GetDispatcher()->GetSlot(".uno:HighlightCharDF")->GetSlotId())
+    , mParaController(SID_SPOTLIGHT_PARASTYLES, 
SfxViewFrame::Current()->GetBindings(), *this)
+    , mCharController(SID_SPOTLIGHT_CHARSTYLES, 
SfxViewFrame::Current()->GetBindings(), *this)
+    , mDFController(nSlotDFStyles, SfxViewFrame::Current()->GetBindings(), 
*this)
 {
     mpListBoxStyles->set_size_request(MinimumPanelWidth, -1);
     float fWidth = mpListBoxStyles->get_approximate_digit_width();
     std::vector<int> aWidths{ o3tl::narrowing<int>(fWidth * 29) };
     // 2nd column will fill remaining space
     mpListBoxStyles->set_column_fixed_widths(aWidths);
+
+    mpToolbar = m_xBuilder->weld_toolbar(u"toolbar"_ustr);
+    mpToolbar->connect_clicked(LINK(this, InspectorTextPanel, ToolbarHdl));
+    mpToolbar->set_item_icon_name("paragraphstyles", "sw/res/sf01.png");
+    mpToolbar->set_item_icon_name("characterstyles", "sw/res/sf02.png");
+    mpToolbar->set_item_icon_name("directformatting", "sw/res/sr20012.png");
+
+    // Setup listening and set initial state
+    SfxBindings& pBindings = SfxViewFrame::Current()->GetBindings();
+    pBindings.Update(SID_SPOTLIGHT_PARASTYLES);
+    pBindings.Update(SID_SPOTLIGHT_CHARSTYLES);
+    pBindings.Update(nSlotDFStyles);
 }
 
 static bool GetPropertyValues(std::u16string_view rPropName, const uno::Any& 
rAny,
@@ -157,7 +181,58 @@ void InspectorTextPanel::updateEntries(const 
std::vector<TreeNode>& rStore, cons
     mpListBoxStyles->collapse_row(*pEntry);
 }
 
-InspectorTextPanel::~InspectorTextPanel() {}
+void InspectorTextPanel::NotifyItemUpdate(const sal_uInt16 nSId, const 
SfxItemState eState,
+                                          const SfxPoolItem* pState)
+{
+    if (eState >= SfxItemState::DEFAULT)
+    {
+        if (const SfxBoolItem* pItem = dynamic_cast<const 
SfxBoolItem*>(pState))
+        {
+            if (nSId == SID_SPOTLIGHT_PARASTYLES)
+            {
+                mpToolbar->set_item_active("paragraphstyles", 
pItem->GetValue());
+            }
+            else if (nSId == SID_SPOTLIGHT_CHARSTYLES)
+            {
+                mpToolbar->set_item_active("characterstyles", 
pItem->GetValue());
+            }
+            else
+            {
+                mpToolbar->set_item_active("directformatting", 
pItem->GetValue());
+            }
+        }
+    }
+}
+
+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 });
+    }
+    else if (rEntry == "characterstyles")
+    {
+        SfxBoolItem aItem(SID_SPOTLIGHT_CHARSTYLES, 
mpToolbar->get_item_active(rEntry));
+        pDispatcher->ExecuteList(SID_SPOTLIGHT_CHARSTYLES, 
SfxCallMode::SYNCHRON,
+                                 { &aItem, &aParam });
+    }
+    else
+    {
+        SfxBoolItem aItem(nSlotDFStyles, mpToolbar->get_item_active(rEntry));
+        pDispatcher->ExecuteList(nSlotDFStyles, SfxCallMode::SYNCHRON, { 
&aItem });
+    }
+}
+
+InspectorTextPanel::~InspectorTextPanel()
+{
+    mParaController.dispose();
+    mCharController.dispose();
+    mDFController.dispose();
+}
 
 } // end of namespace svx::sidebar
 
diff --git a/svx/uiconfig/ui/inspectortextpanel.ui 
b/svx/uiconfig/ui/inspectortextpanel.ui
index 11be8d3685a3..a5dcc9a6f5a3 100644
--- a/svx/uiconfig/ui/inspectortextpanel.ui
+++ b/svx/uiconfig/ui/inspectortextpanel.ui
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.20.4 -->
+<!-- Generated with glade 3.40.0 -->
 <interface domain="svx">
   <requires lib="gtk+" version="3.20"/>
   <object class="GtkTreeStore" id="liststore">
@@ -20,39 +20,39 @@
       <column type="gboolean"/>
     </columns>
   </object>
-  <!-- n-columns=1 n-rows=1 -->
+  <!-- n-columns=1 n-rows=2 -->
   <object class="GtkGrid" id="InspectorTextPanel">
     <property name="visible">True</property>
-    <property name="can_focus">False</property>
+    <property name="can-focus">False</property>
     <property name="hexpand">True</property>
     <property name="vexpand">True</property>
-    <property name="row_spacing">6</property>
-    <property name="column_spacing">6</property>
+    <property name="row-spacing">6</property>
+    <property name="column-spacing">6</property>
     <child>
       <object class="GtkBox">
         <property name="visible">True</property>
-        <property name="can_focus">False</property>
+        <property name="can-focus">False</property>
         <property name="hexpand">True</property>
         <property name="vexpand">True</property>
-        <property name="border_width">6</property>
+        <property name="border-width">6</property>
         <property name="orientation">vertical</property>
         <child>
           <object class="GtkScrolledWindow">
             <property name="visible">True</property>
-            <property name="can_focus">True</property>
+            <property name="can-focus">True</property>
             <property name="hexpand">True</property>
             <property name="vexpand">True</property>
-            <property name="shadow_type">in</property>
+            <property name="shadow-type">in</property>
             <child>
               <object class="GtkTreeView" id="listbox_fonts">
                 <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
+                <property name="can-focus">True</property>
+                <property name="receives-default">True</property>
                 <property name="hexpand">True</property>
                 <property name="vexpand">True</property>
                 <property name="model">liststore</property>
-                <property name="search_column">0</property>
-                <property name="enable_tree_lines">True</property>
+                <property name="search-column">0</property>
+                <property name="enable-tree-lines">True</property>
                 <child internal-child="selection">
                   <object class="GtkTreeSelection"/>
                 </child>
@@ -97,9 +97,81 @@
         </child>
       </object>
       <packing>
-        <property name="left_attach">0</property>
-        <property name="top_attach">0</property>
+        <property name="left-attach">0</property>
+        <property name="top-attach">1</property>
+      </packing>
+    </child>
+    <child>
+      <!-- n-columns=2 n-rows=1 -->
+      <object class="GtkGrid">
+        <property name="visible">True</property>
+        <property name="can-focus">False</property>
+        <property name="margin-start">6</property>
+        <property name="column-spacing">6</property>
+        <child>
+          <object class="GtkToolbar" id="toolbar">
+            <property name="visible">True</property>
+            <property name="can-focus">False</property>
+            <property name="toolbar-style">icons</property>
+            <child>
+              <object class="GtkToggleToolButton" id="paragraphstyles">
+                <property name="visible">True</property>
+                <property name="can-focus">False</property>
+                <property name="tooltip-text" translatable="yes" 
context="paragraph_style_toggle_btn|tooltip_text">Pragraph Styles</property>
+                <property name="use-underline">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="homogeneous">True</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkToggleToolButton" id="characterstyles">
+                <property name="visible">True</property>
+                <property name="can-focus">False</property>
+                <property name="tooltip-text" translatable="yes" 
context="character_style_toggle_btn|tooltip_text">Character Styles</property>
+                <property name="use-underline">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="homogeneous">True</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkToggleToolButton" id="directformatting">
+                <property name="visible">True</property>
+                <property name="can-focus">False</property>
+                <property name="tooltip-text" translatable="yes" 
context="direct_formatting_toggle_btn|tooltip_text">Direct Formatting</property>
+                <property name="use-underline">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="homogeneous">True</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="left-attach">1</property>
+            <property name="top-attach">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkLabel" id="label">
+            <property name="visible">True</property>
+            <property name="can-focus">False</property>
+            <property name="label" translatable="yes" 
context="spotlightfeatures|label">Spotlight:</property>
+            <property name="mnemonic-widget">toolbar</property>
+          </object>
+          <packing>
+            <property name="left-attach">0</property>
+            <property name="top-attach">0</property>
+          </packing>
+        </child>
+      </object>
+      <packing>
+        <property name="left-attach">0</property>
+        <property name="top-attach">0</property>
       </packing>
     </child>
   </object>
-</interface>
+</interface>
\ No newline at end of file

Reply via email to