From d22d90d4c5585fdbc63bded496543e787fa38a48 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Wed, 17 Jul 2024 09:25:42 +0100 Subject: Resolves: tdf#158753 GtkAssistant loses current page on hide+show MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit gtk_assistant_unmap ... { ... priv->current_page = NULL; ... } gtk_assistant_map { page_num = 0; ... set_current_page (assistant, page_num) ... } It doesn't automatically restore itself to the page it was on when it was hidden, so do that explicitly. Change-Id: If23b255193c4a65b286e036c8796d9d8a2ffcb5e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170611 Reviewed-by: Caolán McNamara Tested-by: Jenkins (cherry picked from commit de4be295993f6bdd255475604056ad3f48478fb1) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170645 Reviewed-by: Michael Weghorn --- .../controller/dialogs/RangeSelectionListener.cxx | 18 ++++++++++++++++++ chart2/source/controller/dialogs/res_ErrorBar.cxx | 11 +++-------- chart2/source/controller/dialogs/tp_DataSource.cxx | 15 +++------------ chart2/source/controller/dialogs/tp_RangeChooser.cxx | 13 ++----------- .../source/controller/inc/RangeSelectionListener.hxx | 9 +++++++++ 5 files changed, 35 insertions(+), 31 deletions(-) (limited to 'chart2') diff --git a/chart2/source/controller/dialogs/RangeSelectionListener.cxx b/chart2/source/controller/dialogs/RangeSelectionListener.cxx index e4974ab30de0..ec5d5f0ded43 100644 --- a/chart2/source/controller/dialogs/RangeSelectionListener.cxx +++ b/chart2/source/controller/dialogs/RangeSelectionListener.cxx @@ -19,6 +19,7 @@ #include #include +#include #include using namespace ::com::sun::star; @@ -56,6 +57,23 @@ void SAL_CALL RangeSelectionListener::disposing( const lang::EventObject& /*Sour m_rParent.disposingRangeSelection(); } +void RangeSelectionListenerParent::enableRangeChoosing(bool bEnable, weld::DialogController* pDialog) +{ + if (!pDialog) + return; + weld::Dialog* pDlg = pDialog->getDialog(); + // tdf#158753 save the current page when hiding the wizard, + // and restore it on showing the wizard to workaround that + // that GtkAssistant resets to page 0 on hide+show + weld::Assistant* pAss = dynamic_cast(pDlg); + if (pAss && bEnable) + m_sRestorePageIdent = pAss->get_current_page_ident(); + pDlg->set_modal(!bEnable); + pDlg->set_visible(!bEnable); + if (pAss && !bEnable) + pAss->set_current_page(m_sRestorePageIdent); +} + } // namespace chart /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/controller/dialogs/res_ErrorBar.cxx b/chart2/source/controller/dialogs/res_ErrorBar.cxx index 82c3f3ab4acc..1b77d23dcefd 100644 --- a/chart2/source/controller/dialogs/res_ErrorBar.cxx +++ b/chart2/source/controller/dialogs/res_ErrorBar.cxx @@ -24,6 +24,7 @@ #include #include #include +#include "DialogModel.hxx" #include #include @@ -39,12 +40,6 @@ using namespace ::com::sun::star; namespace { -void lcl_enableRangeChoosing(bool bEnable, weld::DialogController* pController) -{ - weld::Window* pWeldDialog = pController->getDialog(); - pWeldDialog->set_modal(!bEnable); - pWeldDialog->set_visible(!bEnable); -} sal_uInt16 lcl_getLbEntryPosByErrorKind( SvxChartKindError eErrorKind ) { @@ -447,7 +442,7 @@ IMPL_LINK(ErrorBarResources, ChooseRange, weld::Button&, rButton, void) aUIString = m_xUIStringNeg->get_label(); } - lcl_enableRangeChoosing(true, m_pController); + enableRangeChoosing(true, m_pController); m_apRangeSelectionHelper->chooseRange( m_pCurrentRangeChoosingField->get_text(), aUIString, *this ); @@ -684,7 +679,7 @@ void ErrorBarResources::listeningFinished( m_pCurrentRangeChoosingField = nullptr; UpdateControlStates(); - lcl_enableRangeChoosing(false, m_pController); + enableRangeChoosing(false, m_pController); } void ErrorBarResources::disposingRangeSelection() diff --git a/chart2/source/controller/dialogs/tp_DataSource.cxx b/chart2/source/controller/dialogs/tp_DataSource.cxx index fdd7c9a83b62..577ef29c6b63 100644 --- a/chart2/source/controller/dialogs/tp_DataSource.cxx +++ b/chart2/source/controller/dialogs/tp_DataSource.cxx @@ -111,15 +111,6 @@ OUString lcl_GetSequenceNameForLabel(const ::chart::SeriesEntry* pEntry) return aResult; } -void lcl_enableRangeChoosing(bool bEnable, weld::DialogController* pDialog) -{ - if (!pDialog) - return; - weld::Dialog* pDlg = pDialog->getDialog(); - pDlg->set_modal(!bEnable); - pDlg->set_visible(!bEnable); -} - void lcl_addLSequenceToDataSource( const uno::Reference< chart2::data::XLabeledDataSequence > & xLSequence, const Reference< ::chart::DataSeries > & xSource ) @@ -526,7 +517,7 @@ IMPL_LINK_NOARG(DataSourceTabPage, MainRangeButtonClickedHdl, weld::Button&, voi m_xLB_SERIES->get_text(nEntry)); } - lcl_enableRangeChoosing(true, m_pDialogController); + enableRangeChoosing(true, m_pDialogController); m_rDialogModel.getRangeSelectionHelper()->chooseRange( aSelectedRolesRange, aUIStr, *this ); } else @@ -542,7 +533,7 @@ IMPL_LINK_NOARG(DataSourceTabPage, CategoriesRangeButtonClickedHdl, weld::Button return; OUString aStr(SchResId(m_xFT_CATEGORIES->get_visible() ? STR_DATA_SELECT_RANGE_FOR_CATEGORIES : STR_DATA_SELECT_RANGE_FOR_DATALABELS)); - lcl_enableRangeChoosing(true, m_pDialogController); + enableRangeChoosing(true, m_pDialogController); m_rDialogModel.getRangeSelectionHelper()->chooseRange( m_rDialogModel.getCategoriesRange(), aStr, *this ); } @@ -720,7 +711,7 @@ void DataSourceTabPage::listeningFinished( m_pCurrentRangeChoosingField = nullptr; updateControlState(); - lcl_enableRangeChoosing(false, m_pDialogController); + enableRangeChoosing(false, m_pDialogController); } void DataSourceTabPage::disposingRangeSelection() diff --git a/chart2/source/controller/dialogs/tp_RangeChooser.cxx b/chart2/source/controller/dialogs/tp_RangeChooser.cxx index d5d4a621d8cf..4977569e2c13 100644 --- a/chart2/source/controller/dialogs/tp_RangeChooser.cxx +++ b/chart2/source/controller/dialogs/tp_RangeChooser.cxx @@ -41,15 +41,6 @@ namespace } } - void lcl_enableRangeChoosing(bool bEnable, weld::DialogController* pDialog) - { - if (!pDialog) - return; - weld::Dialog* pDlg = pDialog->getDialog(); - pDlg->set_modal(!bEnable); - pDlg->set_visible(!bEnable); - } - } // anonymous namespace namespace chart @@ -337,7 +328,7 @@ IMPL_LINK_NOARG(RangeChooserTabPage, ChooseRangeHdl, weld::Button&, void) OUString aRange = m_xED_Range->get_text(); OUString aTitle = m_xFTTitle->get_label(); - lcl_enableRangeChoosing(true, m_pDialogController); + enableRangeChoosing(true, m_pDialogController); m_rDialogModel.getRangeSelectionHelper()->chooseRange( aRange, aTitle, *this ); } @@ -361,7 +352,7 @@ void RangeChooserTabPage::listeningFinished( const OUString & rNewRange ) if( isValid()) changeDialogModelAccordingToControls(); - lcl_enableRangeChoosing(false, m_pDialogController); + enableRangeChoosing(false, m_pDialogController); } void RangeChooserTabPage::disposingRangeSelection() diff --git a/chart2/source/controller/inc/RangeSelectionListener.hxx b/chart2/source/controller/inc/RangeSelectionListener.hxx index 9117b4d9b2fc..0ca4644a96ad 100644 --- a/chart2/source/controller/inc/RangeSelectionListener.hxx +++ b/chart2/source/controller/inc/RangeSelectionListener.hxx @@ -27,6 +27,10 @@ namespace com::sun::star::frame { class XModel; } +namespace weld +{ +class DialogController; +} namespace chart { @@ -38,8 +42,13 @@ public: virtual void listeningFinished(const OUString& rNewRange) = 0; virtual void disposingRangeSelection() = 0; + void enableRangeChoosing(bool bEnable, weld::DialogController* pDialog); + protected: ~RangeSelectionListenerParent() {} + +private: + OUString m_sRestorePageIdent; }; class RangeSelectionListener final -- cgit