diff options
author | Caolán McNamara <caolanm@redhat.com> | 2019-07-27 21:39:17 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2019-07-28 22:14:00 +0200 |
commit | afe99a508e78abbf7e3d97730b7abfc8fdbec77c (patch) | |
tree | 5197426b7947259daad466ec519a280d70a74d72 /sc/source/ui/optdlg/tpdefaults.cxx | |
parent | 9ece9fdd33d17e88768dd96ac347938e57bc7918 (diff) |
weld ScTpDefaultsOptions
Change-Id: I2a4a053b38229b971fbf6fc8205680ce02132234
Reviewed-on: https://gerrit.libreoffice.org/76486
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sc/source/ui/optdlg/tpdefaults.cxx')
-rw-r--r-- | sc/source/ui/optdlg/tpdefaults.cxx | 80 |
1 files changed, 32 insertions, 48 deletions
diff --git a/sc/source/ui/optdlg/tpdefaults.cxx b/sc/source/ui/optdlg/tpdefaults.cxx index cc4642d61bd9..9fd4e9155721 100644 --- a/sc/source/ui/optdlg/tpdefaults.cxx +++ b/sc/source/ui/optdlg/tpdefaults.cxx @@ -14,33 +14,23 @@ #include <defaultsoptions.hxx> #include <document.hxx> -ScTpDefaultsOptions::ScTpDefaultsOptions(vcl::Window *pParent, const SfxItemSet &rCoreSet) : - SfxTabPage(pParent, "OptDefaultPage", "modules/scalc/ui/optdefaultpage.ui", &rCoreSet) - +ScTpDefaultsOptions::ScTpDefaultsOptions(TabPageParent pParent, const SfxItemSet &rCoreSet) + : SfxTabPage(pParent, "modules/scalc/ui/optdefaultpage.ui", "OptDefaultPage", &rCoreSet) + , m_xEdNSheets(m_xBuilder->weld_spin_button("sheetsnumber")) + , m_xEdSheetPrefix(m_xBuilder->weld_entry("sheetprefix")) { - get( m_pEdNSheets, "sheetsnumber"); - get( m_pEdSheetPrefix, "sheetprefix"); - - m_pEdNSheets->SetModifyHdl( LINK(this, ScTpDefaultsOptions, NumModifiedHdl) ); - m_pEdSheetPrefix->SetModifyHdl( LINK(this, ScTpDefaultsOptions, PrefixModifiedHdl) ); - m_pEdSheetPrefix->SetGetFocusHdl( LINK(this, ScTpDefaultsOptions, PrefixEditOnFocusHdl) ); + m_xEdNSheets->connect_changed( LINK(this, ScTpDefaultsOptions, NumModifiedHdl) ); + m_xEdSheetPrefix->connect_changed( LINK(this, ScTpDefaultsOptions, PrefixModifiedHdl) ); + m_xEdSheetPrefix->connect_focus_in( LINK(this, ScTpDefaultsOptions, PrefixEditOnFocusHdl) ); } ScTpDefaultsOptions::~ScTpDefaultsOptions() { - disposeOnce(); -} - -void ScTpDefaultsOptions::dispose() -{ - m_pEdNSheets.clear(); - m_pEdSheetPrefix.clear(); - SfxTabPage::dispose(); } VclPtr<SfxTabPage> ScTpDefaultsOptions::Create(TabPageParent pParent, const SfxItemSet *rCoreAttrs) { - return VclPtr<ScTpDefaultsOptions>::Create(pParent.pParent, *rCoreAttrs); + return VclPtr<ScTpDefaultsOptions>::Create(pParent, *rCoreAttrs); } bool ScTpDefaultsOptions::FillItemSet(SfxItemSet *rCoreSet) @@ -48,11 +38,11 @@ bool ScTpDefaultsOptions::FillItemSet(SfxItemSet *rCoreSet) bool bRet = false; ScDefaultsOptions aOpt; - SCTAB nTabCount = static_cast<SCTAB>(m_pEdNSheets->GetValue()); - OUString aSheetPrefix = m_pEdSheetPrefix->GetText(); + SCTAB nTabCount = static_cast<SCTAB>(m_xEdNSheets->get_value()); + OUString aSheetPrefix = m_xEdSheetPrefix->get_text(); - if ( m_pEdNSheets->IsValueChangedFromSaved() - || m_pEdSheetPrefix->GetSavedValue() != aSheetPrefix ) + if ( m_xEdNSheets->get_value_changed_from_saved() + || m_xEdSheetPrefix->get_saved_value() != aSheetPrefix ) { aOpt.SetInitTabCount( nTabCount ); aOpt.SetInitTabPrefix( aSheetPrefix ); @@ -71,10 +61,10 @@ void ScTpDefaultsOptions::Reset(const SfxItemSet* rCoreSet) if(SfxItemState::SET == rCoreSet->GetItemState(SID_SCDEFAULTSOPTIONS, false , &pItem)) aOpt = static_cast<const ScTpDefaultsItem*>(pItem)->GetDefaultsOptions(); - m_pEdNSheets->SetValue( static_cast<sal_uInt16>( aOpt.GetInitTabCount()) ); - m_pEdSheetPrefix->SetText( aOpt.GetInitTabPrefix() ); - m_pEdNSheets->SaveValue(); - m_pEdSheetPrefix->SaveValue(); + m_xEdNSheets->set_value(aOpt.GetInitTabCount()); + m_xEdSheetPrefix->set_text( aOpt.GetInitTabPrefix() ); + m_xEdNSheets->save_value(); + m_xEdSheetPrefix->save_value(); } DeactivateRC ScTpDefaultsOptions::DeactivatePage(SfxItemSet* /*pSet*/) @@ -84,55 +74,49 @@ DeactivateRC ScTpDefaultsOptions::DeactivatePage(SfxItemSet* /*pSet*/) void ScTpDefaultsOptions::CheckNumSheets() { - sal_Int64 nVal = m_pEdNSheets->GetValue(); + auto nVal = m_xEdNSheets->get_value(); if (nVal > MAXINITTAB) - m_pEdNSheets->SetValue(MAXINITTAB); + m_xEdNSheets->set_value(MAXINITTAB); if (nVal < MININITTAB) - m_pEdNSheets->SetValue(MININITTAB); + m_xEdNSheets->set_value(MININITTAB); } -void ScTpDefaultsOptions::CheckPrefix(Edit* pEdit) +void ScTpDefaultsOptions::CheckPrefix() { - if (!pEdit) - return; - - OUString aSheetPrefix = pEdit->GetText(); + OUString aSheetPrefix = m_xEdSheetPrefix->get_text(); - if ( !aSheetPrefix.isEmpty() && !ScDocument::ValidTabName( aSheetPrefix ) ) + if (!aSheetPrefix.isEmpty() && !ScDocument::ValidTabName(aSheetPrefix)) { // Revert to last good Prefix and also select it to // indicate something illegal was typed - Selection aSel( 0, maOldPrefixValue.getLength() ); - pEdit->SetText( maOldPrefixValue, aSel ); + m_xEdSheetPrefix->set_text(maOldPrefixValue); + m_xEdSheetPrefix->select_region(0, -1); } else { - OnFocusPrefixInput(pEdit); + OnFocusPrefixInput(); } } -void ScTpDefaultsOptions::OnFocusPrefixInput(const Edit* pEdit) +void ScTpDefaultsOptions::OnFocusPrefixInput() { - if (!pEdit) - return; - // Store Prefix in case we need to revert - maOldPrefixValue = pEdit->GetText(); + maOldPrefixValue = m_xEdSheetPrefix->get_text(); } -IMPL_LINK_NOARG(ScTpDefaultsOptions, NumModifiedHdl, Edit&, void) +IMPL_LINK_NOARG(ScTpDefaultsOptions, NumModifiedHdl, weld::Entry&, void) { CheckNumSheets(); } -IMPL_LINK( ScTpDefaultsOptions, PrefixModifiedHdl, Edit&, rEdit, void ) +IMPL_LINK_NOARG(ScTpDefaultsOptions, PrefixModifiedHdl, weld::Entry&, void) { - CheckPrefix(&rEdit); + CheckPrefix(); } -IMPL_LINK( ScTpDefaultsOptions, PrefixEditOnFocusHdl, Control&, rControl, void ) +IMPL_LINK_NOARG(ScTpDefaultsOptions, PrefixEditOnFocusHdl, weld::Widget&, void) { - OnFocusPrefixInput(static_cast<Edit*>(&rControl)); + OnFocusPrefixInput(); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |