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

Anshu (via logerrit) logerrit at kemper.freedesktop.org
Tue Aug 24 12:32:16 UTC 2021


 sfx2/source/dialog/StyleList.cxx |   51 +++++++++++++++++++++------------------
 sfx2/source/dialog/templdlg.cxx  |   36 ++++++++++++++++++++++++---
 sfx2/source/dialog/tplcitem.cxx  |   10 +++----
 sfx2/source/inc/StyleList.hxx    |    5 +++
 sfx2/source/inc/templdgi.hxx     |   12 ++++-----
 5 files changed, 75 insertions(+), 39 deletions(-)

New commits:
commit ed31f9818d1c1e6ba44fa8695d215697ad27713c
Author:     Anshu <anshukhare50 at gmail.com>
AuthorDate: Sun Aug 22 20:26:18 2021 +0530
Commit:     Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Tue Aug 24 14:31:40 2021 +0200

    Refactoring Patch
    
    Change-Id: Ia1fbc8cbdb1e055273e0a9058e11b43b4e0ac62f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120849
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>

diff --git a/sfx2/source/dialog/StyleList.cxx b/sfx2/source/dialog/StyleList.cxx
index 88f251046d09..9899417ec9ef 100644
--- a/sfx2/source/dialog/StyleList.cxx
+++ b/sfx2/source/dialog/StyleList.cxx
@@ -393,7 +393,7 @@ void StyleList::UpdateFamily()
 
     m_bTreeDrag = true;
     m_bCanNew = m_xTreeBox->get_visible() || m_xFmtLb->count_selected_rows() <= 1;
-    m_pParentDialog->EnableNew(m_bCanNew);
+    m_pParentDialog->EnableNew(m_bCanNew, this);
     m_bTreeDrag = true;
     if (m_pStyleSheetPool)
     {
@@ -472,7 +472,8 @@ IMPL_LINK(StyleList, ExecuteDrop, const ExecuteDropEvent&, rEvt, sal_Int8)
                 if (aDesc.maClassName == pDocShell->GetFactory().GetClassId())
                 {
                     Application::PostUserEvent(
-                        LINK(m_pParentDialog, SfxCommonTemplateDialog_Impl, OnAsyncExecuteDrop));
+                        LINK(m_pParentDialog, SfxCommonTemplateDialog_Impl, OnAsyncExecuteDrop),
+                        this);
 
                     bFormatFound = true;
                     nRet = rEvt.mnAction;
@@ -826,15 +827,15 @@ void StyleList::SelectStyle(const OUString& rStr, bool bIsCallback)
     if (pStyle)
     {
         bool bReadWrite = !(pStyle->GetMask() & SfxStyleSearchBits::ReadOnly);
-        m_pParentDialog->EnableEdit(bReadWrite);
-        m_pParentDialog->EnableHide(bReadWrite && !pStyle->IsHidden() && !pStyle->IsUsed());
-        m_pParentDialog->EnableShow(bReadWrite && pStyle->IsHidden());
+        m_pParentDialog->EnableEdit(bReadWrite, this);
+        m_pParentDialog->EnableHide(bReadWrite && !pStyle->IsHidden() && !pStyle->IsUsed(), this);
+        m_pParentDialog->EnableShow(bReadWrite && pStyle->IsHidden(), this);
     }
     else
     {
-        m_pParentDialog->EnableEdit(false);
-        m_pParentDialog->EnableHide(false);
-        m_pParentDialog->EnableShow(false);
+        m_pParentDialog->EnableEdit(false, this);
+        m_pParentDialog->EnableHide(false, this);
+        m_pParentDialog->EnableShow(false, this);
     }
 
     if (!bIsCallback)
@@ -893,9 +894,9 @@ void StyleList::SelectStyle(const OUString& rStr, bool bIsCallback)
             if (!bSelect)
             {
                 m_xFmtLb->unselect_all();
-                m_pParentDialog->EnableEdit(false);
-                m_pParentDialog->EnableHide(false);
-                m_pParentDialog->EnableShow(false);
+                m_pParentDialog->EnableEdit(false, this);
+                m_pParentDialog->EnableHide(false, this);
+                m_pParentDialog->EnableShow(false, this);
             }
         }
     }
@@ -1352,7 +1353,7 @@ IMPL_LINK_NOARG(StyleList, EnableDelete, void*, void)
             }
         }
     }
-    m_pParentDialog->EnableDel(bEnableDelete);
+    m_pParentDialog->EnableDel(bEnableDelete, this);
 }
 
 IMPL_LINK_NOARG(StyleList, Clear, void*, void)
@@ -1418,16 +1419,16 @@ void StyleList::Notify(SfxBroadcaster& /*rBC*/, const SfxHint& rHint)
                     if (pStyle)
                     {
                         bool bReadWrite = !(pStyle->GetMask() & SfxStyleSearchBits::ReadOnly);
-                        m_pParentDialog->EnableEdit(bReadWrite);
-                        m_pParentDialog->EnableHide(bReadWrite && !pStyle->IsUsed()
-                                                    && !pStyle->IsHidden());
-                        m_pParentDialog->EnableShow(bReadWrite && pStyle->IsHidden());
+                        m_pParentDialog->EnableEdit(bReadWrite, this);
+                        m_pParentDialog->EnableHide(
+                            bReadWrite && !pStyle->IsUsed() && !pStyle->IsHidden(), this);
+                        m_pParentDialog->EnableShow(bReadWrite && pStyle->IsHidden(), this);
                     }
                     else
                     {
-                        m_pParentDialog->EnableEdit(false);
-                        m_pParentDialog->EnableHide(false);
-                        m_pParentDialog->EnableShow(false);
+                        m_pParentDialog->EnableEdit(false, this);
+                        m_pParentDialog->EnableHide(false, this);
+                        m_pParentDialog->EnableShow(false, this);
                     }
                 }
             }
@@ -1753,7 +1754,7 @@ void StyleList::Update()
     const OUString aStyle(pItem->GetStyleName());
     m_pParentDialog->SelectStyle(aStyle, false, *this);
     EnableDelete(nullptr);
-    m_pParentDialog->EnableNew(m_bCanNew);
+    m_pParentDialog->EnableNew(m_bCanNew, this);
 }
 
 void StyleList::EnablePreview(bool bCustomPreview)
@@ -1784,8 +1785,8 @@ IMPL_LINK(StyleList, PopupFlatMenuHdl, const CommandEvent&, rCEvt, bool)
 
     if (m_xFmtLb->count_selected_rows() <= 0)
     {
-        m_pParentDialog->EnableEdit(false);
-        m_pParentDialog->EnableDel(false);
+        m_pParentDialog->EnableEdit(false, this);
+        m_pParentDialog->EnableDel(false, this);
     }
 
     ShowMenu(rCEvt);
@@ -1804,5 +1805,9 @@ IMPL_LINK(StyleList, PopupTreeMenuHdl, const CommandEvent&, rCEvt, bool)
 
     return true;
 }
-
+void StyleList::setVisible(bool b)
+{
+    m_xTreeBox->set_visible(b && m_bHierarchical);
+    m_xFmtLb->set_visible(b && !m_bHierarchical);
+}
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx
index c592306546c8..be5b0806b5e8 100644
--- a/sfx2/source/dialog/templdlg.cxx
+++ b/sfx2/source/dialog/templdlg.cxx
@@ -117,9 +117,11 @@ sal_Int8 SfxCommonTemplateDialog_Impl::ExecuteDrop(const ExecuteDropEvent& rEvt)
     return DND_ACTION_NONE;
 }
 
-IMPL_LINK_NOARG(SfxCommonTemplateDialog_Impl, OnAsyncExecuteDrop, void*, void)
+IMPL_LINK(SfxCommonTemplateDialog_Impl, OnAsyncExecuteDrop, void*, pStyleList, void)
 {
-    ActionSelect("new", m_aStyleList);
+    StyleList* pStyle = static_cast<StyleList*>(pStyleList);
+    if (pStyle == &m_aStyleList)
+        ActionSelect("new", m_aStyleList);
 }
 
 SfxTemplatePanelControl::SfxTemplatePanelControl(SfxBindings* pBindings, weld::Widget* pParent)
@@ -206,9 +208,10 @@ SfxCommonTemplateDialog_Impl::SfxCommonTemplateDialog_Impl(SfxBindings* pB, weld
     mxPreviewCheckbox->set_active(officecfg::Office::Common::StylesAndFormatting::Preview::get());
 }
 
-void SfxTemplateDialog_Impl::EnableEdit(bool bEnable)
+void SfxTemplateDialog_Impl::EnableEdit(bool bEnable, StyleList* rStyleList)
 {
-    SfxCommonTemplateDialog_Impl::EnableEdit( bEnable );
+    if(rStyleList == &m_aStyleList || rStyleList == nullptr)
+        SfxCommonTemplateDialog_Impl::EnableEdit( bEnable, &m_aStyleList );
     if( !bEnable || !bUpdateByExampleDisabled )
         EnableItem("update", bEnable);
 }
@@ -903,4 +906,29 @@ sal_Int8 SfxTemplateDialog_Impl::AcceptToolbarDrop(const AcceptDropEvent& rEvt,
     return nReturn;
 }
 
+void SfxCommonTemplateDialog_Impl::EnableEdit(bool b, StyleList* rStyleList)
+{
+    if (rStyleList == &m_aStyleList || rStyleList == nullptr)
+        m_aStyleList.Enableedit(b);
+}
+void SfxCommonTemplateDialog_Impl::EnableDel(bool b, StyleList* rStyleList)
+{
+    if (rStyleList == &m_aStyleList || rStyleList == nullptr)
+        m_aStyleList.Enabledel(b);
+}
+void SfxCommonTemplateDialog_Impl::EnableNew(bool b, StyleList* rStyleList)
+{
+    if (rStyleList == &m_aStyleList || rStyleList == nullptr)
+        m_aStyleList.Enablenew(b);
+}
+void SfxCommonTemplateDialog_Impl::EnableHide(bool b, StyleList* rStyleList)
+{
+    if (rStyleList == &m_aStyleList || rStyleList == nullptr)
+        m_aStyleList.Enablehide(b);
+}
+void SfxCommonTemplateDialog_Impl::EnableShow(bool b, StyleList* rStyleList)
+{
+    if (rStyleList == &m_aStyleList || rStyleList == nullptr)
+        m_aStyleList.Enableshow(b);
+}
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sfx2/source/dialog/tplcitem.cxx b/sfx2/source/dialog/tplcitem.cxx
index af86e46b9736..c86aabcd7c54 100644
--- a/sfx2/source/dialog/tplcitem.cxx
+++ b/sfx2/source/dialog/tplcitem.cxx
@@ -110,16 +110,16 @@ void SfxTemplateControllerItem::StateChangedAtToolBoxControl( sal_uInt16 nSID, S
             break;
         }
         case SID_STYLE_EDIT:
-            rTemplateDlg.EnableEdit( SfxItemState::DISABLED != eState );
+            rTemplateDlg.EnableEdit( SfxItemState::DISABLED != eState, nullptr );
             break;
         case SID_STYLE_DELETE:
-            rTemplateDlg.EnableDel( SfxItemState::DISABLED != eState );
+            rTemplateDlg.EnableDel( SfxItemState::DISABLED != eState, nullptr );
             break;
         case SID_STYLE_HIDE:
-            rTemplateDlg.EnableHide( SfxItemState::DISABLED != eState );
+            rTemplateDlg.EnableHide( SfxItemState::DISABLED != eState, nullptr );
             break;
         case SID_STYLE_SHOW:
-            rTemplateDlg.EnableShow( SfxItemState::DISABLED != eState );
+            rTemplateDlg.EnableShow( SfxItemState::DISABLED != eState, nullptr );
             break;
         case SID_STYLE_NEW_BY_EXAMPLE:
 
@@ -132,7 +132,7 @@ void SfxTemplateControllerItem::StateChangedAtToolBoxControl( sal_uInt16 nSID, S
         }
         case SID_STYLE_NEW:
         {
-            rTemplateDlg.EnableNew( SfxItemState::DISABLED != eState );
+            rTemplateDlg.EnableNew( SfxItemState::DISABLED != eState, nullptr );
             break;
         }
         case SID_STYLE_DRAGHIERARCHIE:
diff --git a/sfx2/source/inc/StyleList.hxx b/sfx2/source/inc/StyleList.hxx
index d933d8df9e07..2768f4ce18ae 100644
--- a/sfx2/source/inc/StyleList.hxx
+++ b/sfx2/source/inc/StyleList.hxx
@@ -121,6 +121,10 @@ public:
     void FamilySelect(sal_uInt16 nEntry);
     void FilterSelect(sal_uInt16 nActFilter, bool bsetFilter);
 
+    void setVisible(bool b);
+
+    DECL_LINK(NewMenuExecuteAction, void*, void);
+
 private:
     void FillTreeBox(SfxStyleFamily eFam);
 
@@ -149,7 +153,6 @@ private:
     DECL_LINK(Clear, void*, void);
     DECL_LINK(Cleanup, void*, void);
     DECL_LINK(ExecuteDrop, const ExecuteDropEvent&, sal_Int8);
-    DECL_LINK(NewMenuExecuteAction, void*, void);
     DECL_LINK(IsSafeForWaterCan, void*, bool);
     DECL_LINK(HasSelectedStyle, void*, bool);
     DECL_LINK(UpdateStyleDependents, void*, void);
diff --git a/sfx2/source/inc/templdgi.hxx b/sfx2/source/inc/templdgi.hxx
index 8575bdb49205..31a38ac294d5 100644
--- a/sfx2/source/inc/templdgi.hxx
+++ b/sfx2/source/inc/templdgi.hxx
@@ -158,11 +158,11 @@ public:
 
     // Used in StyleList::SelectStyle, StyleList::Notify, IMPL_LINK(PopupFlatMenuHdl)
     // These functions are used when a style is edited, deleted, created etc..
-    virtual void EnableEdit(bool b) { m_aStyleList.Enableedit(b); }
-    void EnableDel(bool b) { m_aStyleList.Enabledel(b); }
-    void EnableNew(bool b) { m_aStyleList.Enablenew(b); }
-    void EnableHide(bool b) { m_aStyleList.Enablehide(b); }
-    void EnableShow(bool b) { m_aStyleList.Enableshow(b); }
+    virtual void EnableEdit(bool b, StyleList* rStyleList);
+    void EnableDel(bool b, StyleList* rStyleList);
+    void EnableNew(bool b, StyleList* rStyleList);
+    void EnableHide(bool b, StyleList* rStyleList);
+    void EnableShow(bool b, StyleList* rStyleList);
 
     // Used in TreeDrag
     void EnableTreeDrag(bool b);
@@ -224,7 +224,7 @@ private:
     DECL_LINK(ToolBoxRSelect, const OString&, void);
     DECL_LINK(ToolMenuSelectHdl, const OString&, void);
 
-    virtual void EnableEdit( bool ) override;
+    virtual void EnableEdit( bool, StyleList* rStyleList) override;
     virtual void EnableItem(const OString& rMesId, bool bCheck = true) override;
     virtual void CheckItem(const OString& rMesId, bool bCheck = true) override;
     virtual bool IsCheckedItem(const OString& rMesId) override;


More information about the Libreoffice-commits mailing list