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

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Thu Sep 17 18:21:25 UTC 2020


 sfx2/source/dialog/templdlg.cxx |   55 ++++++++++++++++------------------------
 sfx2/source/inc/templdgi.hxx    |    3 --
 2 files changed, 24 insertions(+), 34 deletions(-)

New commits:
commit 0df22a9e42f4b1a3d6febe309be0debaba1006df
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Thu Sep 17 12:24:10 2020 +0100
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Thu Sep 17 20:20:46 2020 +0200

    factor out the special FmtSelect with nullptr arg case
    
    as its own separate thing
    
    Change-Id: If7d576f9617e76d530f74d36a033431a1f2b0c7b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102919
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx
index 753fd6d23a9c..62d02b67aae7 100644
--- a/sfx2/source/dialog/templdlg.cxx
+++ b/sfx2/source/dialog/templdlg.cxx
@@ -911,8 +911,8 @@ void SfxCommonTemplateDialog_Impl::SelectStyle(const OUString &rStr, bool bIsCal
 
     if (!bIsCallback)
     {
-        // tdf#134598 call FmtSelect to update watercan
-        FmtSelect(nullptr, false);
+        // tdf#134598 call UpdateStyleDependents to update watercan
+        UpdateStyleDependents();
     }
 }
 
@@ -1949,41 +1949,32 @@ IMPL_LINK_NOARG(SfxCommonTemplateDialog_Impl, PreviewHdl, weld::Button&, void)
 // Selection of a template during the Watercan-Status
 IMPL_LINK(SfxCommonTemplateDialog_Impl, FmtSelectHdl, weld::TreeView&, rListBox, void)
 {
-    FmtSelect(&rListBox, true);
+    std::unique_ptr<weld::TreeIter> xHdlEntry = rListBox.make_iterator();
+    if (!rListBox.get_cursor(xHdlEntry.get()))
+        return;
+
+    if (rListBox.is_selected(*xHdlEntry))
+        UpdateStyleDependents();
+
+    SelectStyle(rListBox.get_text(*xHdlEntry), true);
 }
 
-void SfxCommonTemplateDialog_Impl::FmtSelect(weld::TreeView* pListBox, bool bIsCallback)
+void SfxCommonTemplateDialog_Impl::UpdateStyleDependents()
 {
-    std::unique_ptr<weld::TreeIter> xHdlEntry;
-    if (pListBox)
-    {
-        xHdlEntry = pListBox->make_iterator();
-        if (!pListBox->get_cursor(xHdlEntry.get()))
-            return;
-    }
-
-    // Trigger Help PI, if this is permitted of call handlers and field
-    if (!pListBox || pListBox->is_selected(*xHdlEntry))
+    // Trigger Help PI. Only when the watercan is on
+    if ( IsInitialized() &&
+         IsCheckedItem("watercan") &&
+         // only if that region is allowed
+         nullptr != pFamilyState[nActFamily-1] && (mxTreeBox || mxFmtLb->count_selected_rows() <= 1) )
     {
-        // Only when the watercan is on
-        if ( IsInitialized() &&
-             IsCheckedItem("watercan") &&
-             // only if that region is allowed
-             nullptr != pFamilyState[nActFamily-1] && (mxTreeBox || mxFmtLb->count_selected_rows() <= 1) )
-        {
-            Execute_Impl(SID_STYLE_WATERCAN,
-                         "", "", 0);
-            Execute_Impl(SID_STYLE_WATERCAN,
-                         GetSelectedEntry(), "",
-                         static_cast<sal_uInt16>(GetFamilyItem_Impl()->GetFamily()));
-        }
-        EnableItem("watercan", !bWaterDisabled);
-        EnableDelete();
+        Execute_Impl(SID_STYLE_WATERCAN,
+                     "", "", 0);
+        Execute_Impl(SID_STYLE_WATERCAN,
+                     GetSelectedEntry(), "",
+                     static_cast<sal_uInt16>(GetFamilyItem_Impl()->GetFamily()));
     }
-    if( !pListBox )
-        return;
-
-    SelectStyle(pListBox->get_text(*xHdlEntry), bIsCallback);
+    EnableItem("watercan", !bWaterDisabled);
+    EnableDelete();
 }
 
 void SfxCommonTemplateDialog_Impl::MenuSelect(const OString& rIdent)
diff --git a/sfx2/source/inc/templdgi.hxx b/sfx2/source/inc/templdgi.hxx
index 8f303fce10b5..7f7f3aba1b47 100644
--- a/sfx2/source/inc/templdgi.hxx
+++ b/sfx2/source/inc/templdgi.hxx
@@ -125,8 +125,6 @@ protected:
     bool m_bWantHierarchical :1;
     bool bBindingUpdate :1;
 
-    void FmtSelect(weld::TreeView* pTreeView, bool bIsCallback);
-
     DECL_LINK(FilterSelectHdl, weld::ComboBox&, void );
     DECL_LINK(FmtSelectHdl, weld::TreeView&, void);
     DECL_LINK(TreeListApplyHdl, weld::TreeView&, bool);
@@ -185,6 +183,7 @@ protected:
     bool IsSafeForWaterCan() const;
 
     void SelectStyle(const OUString& rStyle, bool bIsCallback);
+    void UpdateStyleDependents();
     bool HasSelectedStyle() const;
     void GetSelectedStyle() const;
     void FillTreeBox();


More information about the Libreoffice-commits mailing list