summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2020-09-17 12:24:10 +0100
committerCaolán McNamara <caolanm@redhat.com>2020-09-17 20:20:46 +0200
commit0df22a9e42f4b1a3d6febe309be0debaba1006df (patch)
tree08c2e96a63e60638ee31ed8825cab4c3b6afcae8 /sfx2
parent429d4e1c70c71e898de293647c7623303ffe960b (diff)
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@redhat.com>
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/dialog/templdlg.cxx55
-rw-r--r--sfx2/source/inc/templdgi.hxx3
2 files changed, 24 insertions, 34 deletions
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();