cui/source/inc/treeopt.hxx | 5 +-- cui/source/options/treeopt.cxx | 65 +++++++++++++++++------------------------ 2 files changed, 30 insertions(+), 40 deletions(-)
New commits: commit 5f154a342583540a7bbac3a135d29114ef16aacb Author: Mike Kaganski <[email protected]> AuthorDate: Tue Mar 28 11:07:31 2023 +0300 Commit: Mike Kaganski <[email protected]> CommitDate: Tue Mar 28 10:12:43 2023 +0000 Simplify OfaTreeOptionsDialog ctors by delegation Change-Id: Iea1487bde1c5a15934c5678a53648f3597df5cf3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149643 Tested-by: Jenkins Reviewed-by: Mike Kaganski <[email protected]> diff --git a/cui/source/inc/treeopt.hxx b/cui/source/inc/treeopt.hxx index a4d90e6e912d..69278a1b5349 100644 --- a/cui/source/inc/treeopt.hxx +++ b/cui/source/inc/treeopt.hxx @@ -147,9 +147,7 @@ private: std::optional<SfxItemSet> CreateItemSet( sal_uInt16 nId ); static void ApplyItemSet( sal_uInt16 nId, const SfxItemSet& rSet ); - void InitTreeAndHandler(); void Initialize( const css::uno::Reference< css::frame::XFrame >& _xFrame ); - void InitWidgets(); void LoadExtensionOptions( std::u16string_view rExtensionId ); static OUString GetModuleIdentifier( const css::uno::Reference< @@ -174,6 +172,9 @@ private: virtual weld::Button& GetOKButton() const override { return *xOkPB; } virtual const SfxItemSet* GetExampleSet() const override { return nullptr; } + // Common initialization + OfaTreeOptionsDialog(weld::Window* pParent, bool fromExtensionManager); + public: OfaTreeOptionsDialog(weld::Window* pParent, const css::uno::Reference< css::frame::XFrame >& _xFrame, diff --git a/cui/source/options/treeopt.cxx b/cui/source/options/treeopt.cxx index 37d7f745dd80..93f4432d16ee 100644 --- a/cui/source/options/treeopt.cxx +++ b/cui/source/options/treeopt.cxx @@ -438,22 +438,22 @@ struct OptionsGroupInfo m_pModule( pMod ), m_nDialogId( nId ) {} }; -#define INI_LIST() \ - , m_pParent ( pParent )\ - , sTitle ( m_xDialog->get_title() )\ - , bForgetSelection ( false )\ - , bIsFromExtensionManager( false ) \ - , bIsForSetDocumentLanguage( false ) \ - , bNeedsRestart ( false ) \ - , eRestartReason( svtools::RESTART_REASON_NONE ) - -void OfaTreeOptionsDialog::InitWidgets() +// Basic ctor with common initialization +OfaTreeOptionsDialog::OfaTreeOptionsDialog(weld::Window* pParent, bool fromExtensionManager) + : SfxOkDialogController(pParent, "cui/ui/optionsdialog.ui", "OptionsDialog") + , xOkPB(m_xBuilder->weld_button("ok")) + , xApplyPB(m_xBuilder->weld_button("apply")) + , xBackPB(m_xBuilder->weld_button("revert")) + , xTreeLB(m_xBuilder->weld_tree_view("pages")) + , xTabBox(m_xBuilder->weld_container("box")) + , m_pParent(pParent) + , sTitle(m_xDialog->get_title()) + , bForgetSelection(false) + , bIsFromExtensionManager(fromExtensionManager) + , bIsForSetDocumentLanguage(false) + , bNeedsRestart(false) + , eRestartReason(svtools::RESTART_REASON_NONE) { - xOkPB = m_xBuilder->weld_button("ok"); - xApplyPB = m_xBuilder->weld_button("apply"); - xBackPB = m_xBuilder->weld_button("revert"); - xTreeLB = m_xBuilder->weld_tree_view("pages"); - xTabBox = m_xBuilder->weld_container("box"); Size aSize(xTreeLB->get_approximate_digit_width() * 82, xTreeLB->get_height_rows(30)); #if HAVE_FEATURE_GPGME // tdf#115015: make enough space for crypto settings (approx. 14 text edits + padding) @@ -461,33 +461,32 @@ void OfaTreeOptionsDialog::InitWidgets() #endif xTabBox->set_size_request(aSize.Width(), aSize.Height()); xTreeLB->set_size_request(xTreeLB->get_approximate_digit_width() * 35, aSize.Height()); + + // Init tree and handler + xTreeLB->set_help_id(HID_OFADLG_TREELISTBOX); + xTreeLB->connect_changed(LINK(this, OfaTreeOptionsDialog, ShowPageHdl_Impl)); + xBackPB->connect_clicked(LINK(this, OfaTreeOptionsDialog, BackHdl_Impl)); + xApplyPB->connect_clicked(LINK(this, OfaTreeOptionsDialog, ApplyHdl_Impl)); + xOkPB->connect_clicked(LINK(this, OfaTreeOptionsDialog, ApplyHdl_Impl)); + m_xDialog->connect_help(LINK(this, OfaTreeOptionsDialog, HelpHdl_Impl)); + + xTreeLB->set_accessible_name(sTitle); } // Ctor() with Frame ----------------------------------------------------- OfaTreeOptionsDialog::OfaTreeOptionsDialog(weld::Window* pParent, const Reference< XFrame >& _xFrame, bool bActivateLastSelection) - : SfxOkDialogController(pParent, "cui/ui/optionsdialog.ui", "OptionsDialog") - INI_LIST() + : OfaTreeOptionsDialog(pParent, false) { - InitWidgets(); - - InitTreeAndHandler(); Initialize( _xFrame ); LoadExtensionOptions( u"" ); if (bActivateLastSelection) ActivateLastSelection(); - - xTreeLB->set_accessible_name(m_xDialog->get_title()); } // Ctor() with ExtensionId ----------------------------------------------- OfaTreeOptionsDialog::OfaTreeOptionsDialog(weld::Window* pParent, std::u16string_view rExtensionId) - : SfxOkDialogController(pParent, "cui/ui/optionsdialog.ui", "OptionsDialog") - INI_LIST() + : OfaTreeOptionsDialog(pParent, !rExtensionId.empty()) { - InitWidgets(); - - bIsFromExtensionManager = ( !rExtensionId.empty() ); - InitTreeAndHandler(); LoadExtensionOptions( rExtensionId ); ActivateLastSelection(); } @@ -761,16 +760,6 @@ void OfaTreeOptionsDialog::ApplyItemSets() } } -void OfaTreeOptionsDialog::InitTreeAndHandler() -{ - xTreeLB->set_help_id(HID_OFADLG_TREELISTBOX); - xTreeLB->connect_changed( LINK( this, OfaTreeOptionsDialog, ShowPageHdl_Impl ) ); - xBackPB->connect_clicked( LINK( this, OfaTreeOptionsDialog, BackHdl_Impl ) ); - xApplyPB->connect_clicked( LINK( this, OfaTreeOptionsDialog, ApplyHdl_Impl ) ); - xOkPB->connect_clicked( LINK( this, OfaTreeOptionsDialog, ApplyHdl_Impl ) ); - m_xDialog->connect_help( LINK( this, OfaTreeOptionsDialog, HelpHdl_Impl ) ); -} - void OfaTreeOptionsDialog::ActivatePage( sal_uInt16 nResId ) { bIsForSetDocumentLanguage = false;
