diff options
author | Caolán McNamara <caolan.mcnamara@collabora.com> | 2024-07-17 09:25:42 +0100 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2024-08-23 11:17:11 +0200 |
commit | 9bdde672e56c533b56fdd316d1f6cd5cbacfea63 (patch) | |
tree | 3042ded4aa91da9860c085d52e25f9601036552c /chart2 | |
parent | 6973eb0c83f1da135220afcf9f6a97e70649618c (diff) |
Resolves: tdf#158753 GtkAssistant loses current page on hide+show
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 <caolan.mcnamara@collabora.com>
Tested-by: Jenkins
(cherry picked from commit de4be295993f6bdd255475604056ad3f48478fb1)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170646
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Diffstat (limited to 'chart2')
5 files changed, 35 insertions, 31 deletions
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 <RangeSelectionListener.hxx> #include <ChartModel.hxx> +#include <vcl/weld.hxx> #include <utility> 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<weld::Assistant*>(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 3eb875098b46..fce2ed92a8f0 100644 --- a/chart2/source/controller/dialogs/res_ErrorBar.cxx +++ b/chart2/source/controller/dialogs/res_ErrorBar.cxx @@ -24,6 +24,7 @@ #include <chartview/ChartSfxItemIds.hxx> #include <vcl/weld.hxx> #include <ChartModel.hxx> +#include "DialogModel.hxx" #include <rtl/math.hxx> #include <comphelper/diagnose_ex.hxx> @@ -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 c30ce8afaedd..63e075a1b267 100644 --- a/chart2/source/controller/dialogs/tp_DataSource.cxx +++ b/chart2/source/controller/dialogs/tp_DataSource.cxx @@ -112,15 +112,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 ) @@ -527,7 +518,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 @@ -543,7 +534,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 ); } @@ -721,7 +712,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 a88f6a826e0b..f2dfac3c8d87 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 |