[Libreoffice-commits] core.git: sw/source

Shivam Kumar Singh (via logerrit) logerrit at kemper.freedesktop.org
Mon Jul 13 09:12:33 UTC 2020


 sw/source/uibase/sidebar/SwPanelFactory.cxx           |    2 
 sw/source/uibase/sidebar/WriterInspectorTextPanel.cxx |   71 +++++++-----------
 sw/source/uibase/sidebar/WriterInspectorTextPanel.hxx |   21 +----
 3 files changed, 35 insertions(+), 59 deletions(-)

New commits:
commit 00be56d9db396d284f66ab723d6fbb898b888dfb
Author:     Shivam Kumar Singh <shivamhere247 at gmail.com>
AuthorDate: Fri Jul 10 16:00:37 2020 +0530
Commit:     Heiko Tietze <heiko.tietze at documentfoundation.org>
CommitDate: Mon Jul 13 11:11:55 2020 +0200

    tdf#134661 Issue in Inspector update
    
    This patch now uses AttrChangedNotify instead
    of NotifyItemUpdate to check for cursor change
    
    Change-Id: Ibdbd1565d72097d2f78ecb8194a201585951ce9d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98490
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
    Reviewed-by: Heiko Tietze <heiko.tietze at documentfoundation.org>

diff --git a/sw/source/uibase/sidebar/SwPanelFactory.cxx b/sw/source/uibase/sidebar/SwPanelFactory.cxx
index b3d1bbf6932f..b073b2801733 100644
--- a/sw/source/uibase/sidebar/SwPanelFactory.cxx
+++ b/sw/source/uibase/sidebar/SwPanelFactory.cxx
@@ -172,7 +172,7 @@ Reference<ui::XUIElement> SAL_CALL SwPanelFactory::createUIElement (
     }
     else if (rsResourceURL.endsWith("/WriterInspectorTextPanel"))
     {
-        VclPtr<vcl::Window> pPanel = sw::sidebar::WriterInspectorTextPanel::Create( pParentWindow, xFrame, pBindings);
+        VclPtr<vcl::Window> pPanel = sw::sidebar::WriterInspectorTextPanel::Create( pParentWindow, xFrame);
         xElement = sfx2::sidebar::SidebarPanelBase::Create(
             rsResourceURL,
             xFrame,
diff --git a/sw/source/uibase/sidebar/WriterInspectorTextPanel.cxx b/sw/source/uibase/sidebar/WriterInspectorTextPanel.cxx
index 0bfafc0a5bc9..7222c3de0989 100644
--- a/sw/source/uibase/sidebar/WriterInspectorTextPanel.cxx
+++ b/sw/source/uibase/sidebar/WriterInspectorTextPanel.cxx
@@ -35,8 +35,7 @@
 namespace sw::sidebar
 {
 VclPtr<vcl::Window> WriterInspectorTextPanel::Create(vcl::Window* pParent,
-                                                     const uno::Reference<frame::XFrame>& rxFrame,
-                                                     SfxBindings* pBindings)
+                                                     const uno::Reference<frame::XFrame>& rxFrame)
 {
     if (pParent == nullptr)
         throw lang::IllegalArgumentException(
@@ -44,20 +43,18 @@ VclPtr<vcl::Window> WriterInspectorTextPanel::Create(vcl::Window* pParent,
     if (!rxFrame.is())
         throw lang::IllegalArgumentException("no XFrame given to WriterInspectorTextPanel::Create",
                                              nullptr, 1);
-    if (pBindings == nullptr)
-        throw lang::IllegalArgumentException(
-            "no SfxBindings given to WriterInspectorTextPanel::Create", nullptr, 2);
 
-    return VclPtr<WriterInspectorTextPanel>::Create(pParent, rxFrame, pBindings);
+    return VclPtr<WriterInspectorTextPanel>::Create(pParent, rxFrame);
 }
 
 WriterInspectorTextPanel::WriterInspectorTextPanel(vcl::Window* pParent,
-                                                   const uno::Reference<frame::XFrame>& rxFrame,
-                                                   SfxBindings* pBindings)
+                                                   const uno::Reference<frame::XFrame>& rxFrame)
     : InspectorTextPanel(pParent, rxFrame)
-    , maCharStyle(SID_STYLE_FAMILY1, *pBindings, *this)
-    , maParaStyle(SID_STYLE_FAMILY2, *pBindings, *this)
 {
+    SwDocShell* pDocSh = static_cast<SwDocShell*>(SfxObjectShell::Current());
+    SwWrtShell* pShell = pDocSh->GetWrtShell();
+    if (pShell)
+        pShell->SetChgLnk(LINK(this, WriterInspectorTextPanel, AttrChangedNotify));
 }
 
 static bool GetPropertyValues(const beans::Property rProperty, const uno::Any& rAny,
@@ -229,44 +226,34 @@ static void UpdateTree(SwDocShell* pDocSh, svx::sidebar::TreeNode& pParentNode,
     std::reverse(pParentNode.children.begin(), pParentNode.children.end());
 }
 
-void WriterInspectorTextPanel::NotifyItemUpdate(const sal_uInt16 nSId,
-                                                const SfxItemState /*eState*/,
-                                                const SfxPoolItem* /*pState*/)
+IMPL_LINK_NOARG(WriterInspectorTextPanel, AttrChangedNotify, LinkParamNone*, void)
 {
     SwDocShell* pDocSh = static_cast<SwDocShell*>(SfxObjectShell::Current());
     std::vector<svx::sidebar::TreeNode> aStore;
     std::unordered_map<OUString, bool> maIsDefined;
 
-    switch (nSId)
+    if (pDocSh && pDocSh->GetDoc()->GetEditShell()->GetCursor()->GetNode().GetTextNode())
     {
-        case SID_STYLE_FAMILY1:
-        case SID_STYLE_FAMILY2:
-        {
-            if (pDocSh && pDocSh->GetDoc()->GetEditShell()->GetCursor()->GetNode().GetTextNode())
-            {
-                /*
-                First check in the property set of Character Styles
-                (as CS has higher priority over PS), then look into
-                property set of Paragraph Styles;
-                */
-                svx::sidebar::TreeNode pTempChar;
-                pTempChar.sNodeName = "CHARACTER STYLES";
-                UpdateTree(pDocSh, pTempChar, maIsDefined, CHARACTERSTYLES);
-                svx::sidebar::TreeNode pTempPara;
-                pTempPara.sNodeName = "PARAGRAPH STYLES";
-                UpdateTree(pDocSh, pTempPara, maIsDefined, PARAGRAPHSTYLES);
-
-                /*
-                Order:-
-                PARAGRAPH STYLES
-                CHARACTER STYLES
-                DEFAULT FORMATTING
-                */
-                aStore.push_back(pTempPara);
-                aStore.push_back(pTempChar);
-            }
-        }
-        break;
+        /*
+        First check in the property set of Character Styles
+        (as CS has higher priority over PS), then look into
+        property set of Paragraph Styles;
+        */
+        svx::sidebar::TreeNode pTempChar;
+        pTempChar.sNodeName = "CHARACTER STYLES";
+        UpdateTree(pDocSh, pTempChar, maIsDefined, CHARACTERSTYLES);
+        svx::sidebar::TreeNode pTempPara;
+        pTempPara.sNodeName = "PARAGRAPH STYLES";
+        UpdateTree(pDocSh, pTempPara, maIsDefined, PARAGRAPHSTYLES);
+
+        /*
+        Order:-
+        PARAGRAPH STYLES
+        CHARACTER STYLES
+        DEFAULT FORMATTING
+        */
+        aStore.push_back(pTempPara);
+        aStore.push_back(pTempChar);
     }
 
     updateEntries(aStore);
diff --git a/sw/source/uibase/sidebar/WriterInspectorTextPanel.hxx b/sw/source/uibase/sidebar/WriterInspectorTextPanel.hxx
index 2e54329b7b81..8c674e380812 100644
--- a/sw/source/uibase/sidebar/WriterInspectorTextPanel.hxx
+++ b/sw/source/uibase/sidebar/WriterInspectorTextPanel.hxx
@@ -19,7 +19,6 @@
 #pragma once
 
 #include <sfx2/weldutils.hxx>
-#include <sfx2/sidebar/ControllerItem.hxx>
 #include <docsh.hxx>
 #include <unordered_map>
 
@@ -36,29 +35,19 @@ namespace sw
 {
 namespace sidebar
 {
-class WriterInspectorTextPanel final
-    : public svx::sidebar::InspectorTextPanel,
-      public sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface
+class WriterInspectorTextPanel final : public svx::sidebar::InspectorTextPanel
 {
 public:
     static VclPtr<vcl::Window> Create(vcl::Window* pParent,
-                                      const css::uno::Reference<css::frame::XFrame>& rxFrame,
-                                      SfxBindings* pBindings);
+                                      const css::uno::Reference<css::frame::XFrame>& rxFrame);
 
     WriterInspectorTextPanel(vcl::Window* pParent,
-                             const css::uno::Reference<css::frame::XFrame>& rxFrame,
-                             SfxBindings* pBindings);
+                             const css::uno::Reference<css::frame::XFrame>& rxFrame);
 
     // virtual ~WriterInspectorTextPanel();
-    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 maCharStyle;
-    sfx2::sidebar::ControllerItem maParaStyle;
+    // attributes have changed
+    DECL_LINK(AttrChangedNotify, LinkParamNone*, void);
 };
 }
 } // end of namespace svx::sidebar


More information about the Libreoffice-commits mailing list