include/vcl/wizardmachine.hxx | 3 +++ svtools/source/uno/wizard/wizardshell.cxx | 10 ++++++++++ svtools/source/uno/wizard/wizardshell.hxx | 3 +++ vcl/source/control/roadmapwizard.cxx | 16 ++++++++-------- vcl/source/control/wizardmachine.cxx | 12 +++++++++++- 5 files changed, 35 insertions(+), 9 deletions(-)
New commits: commit e7dd0fa490c671267a4419a6c2ef8a1367114209 Author: Caolán McNamara <[email protected]> AuthorDate: Mon Feb 20 13:15:44 2023 +0000 Commit: Michael Stahl <[email protected]> CommitDate: Tue Feb 21 11:43:50 2023 +0000 tdf#132110 page ids might not be state ids Change-Id: I9f8946acbcf593e9adf6d31631b82cdafcd3f472 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147327 Tested-by: Jenkins Reviewed-by: Caolán McNamara <[email protected]> (cherry picked from commit cdf7b51229f2353376fb4e9de309fb9ee5580b3a) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147356 Reviewed-by: Michael Stahl <[email protected]> diff --git a/include/vcl/wizardmachine.hxx b/include/vcl/wizardmachine.hxx index 04698f387011..a29b03a38062 100644 --- a/include/vcl/wizardmachine.hxx +++ b/include/vcl/wizardmachine.hxx @@ -302,6 +302,9 @@ namespace vcl */ void getStateHistory(std::vector<WizardTypes::WizardState>& out_rHistory); + virtual OString getPageIdentForState(WizardTypes::WizardState nState) const; + virtual WizardTypes::WizardState getStateFromPageIdent(const OString& rIdent) const; + public: class AccessGuard { diff --git a/svtools/source/uno/wizard/wizardshell.cxx b/svtools/source/uno/wizard/wizardshell.cxx index 93113d4fd739..4b93f09eadbe 100644 --- a/svtools/source/uno/wizard/wizardshell.cxx +++ b/svtools/source/uno/wizard/wizardshell.cxx @@ -83,6 +83,16 @@ namespace svt::uno return WizardShell_Base::run(); } + OString WizardShell::getPageIdentForState(WizardState nState) const + { + return OString::number(impl_stateToPageId(nState)); + } + + WizardState WizardShell::getStateFromPageIdent(const OString& rIdent) const + { + return impl_pageIdToState(rIdent.toInt32()); + } + sal_Int16 WizardShell::convertCommitReasonToTravelType( const CommitPageReason i_eReason ) { switch ( i_eReason ) diff --git a/svtools/source/uno/wizard/wizardshell.hxx b/svtools/source/uno/wizard/wizardshell.hxx index a563ab9547a7..90e7269a18b2 100644 --- a/svtools/source/uno/wizard/wizardshell.hxx +++ b/svtools/source/uno/wizard/wizardshell.hxx @@ -106,6 +106,9 @@ namespace svt::uno PWizardPageController impl_getController(BuilderPage* i_pPage) const; + virtual OString getPageIdentForState(WizardState nState) const override; + virtual WizardState getStateFromPageIdent(const OString& rIdent) const override; + // prevent outside access to some base class members using WizardShell_Base::skip; using WizardShell_Base::skipUntil; diff --git a/vcl/source/control/roadmapwizard.cxx b/vcl/source/control/roadmapwizard.cxx index fe4c53b92e02..49c28de9bfe9 100644 --- a/vcl/source/control/roadmapwizard.cxx +++ b/vcl/source/control/roadmapwizard.cxx @@ -470,7 +470,7 @@ namespace vcl GetOrCreatePage(nState); } - OString sIdent(OString::number(nState)); + OString sIdent(getPageIdentForState(nState)); m_xAssistant->set_page_index(sIdent, nItemIndex); m_xAssistant->set_page_title(sIdent, getStateDisplayName(nState)); @@ -639,9 +639,9 @@ namespace vcl IMPL_LINK(RoadmapWizardMachine, OnRoadmapItemSelected, const OString&, rCurItemId, bool) { - int nCurItemId = rCurItemId.toInt32(); + WizardTypes::WizardState nSelectedState = getStateFromPageIdent(rCurItemId); - if ( nCurItemId == getCurrentState() ) + if (nSelectedState == getCurrentState()) // nothing to do return false; @@ -651,7 +651,7 @@ namespace vcl WizardTravelSuspension aTravelGuard( *this ); sal_Int32 nCurrentIndex = m_pImpl->getStateIndexInPath( getCurrentState(), m_pImpl->nActivePath ); - sal_Int32 nNewIndex = m_pImpl->getStateIndexInPath( nCurItemId, m_pImpl->nActivePath ); + sal_Int32 nNewIndex = m_pImpl->getStateIndexInPath( nSelectedState, m_pImpl->nActivePath ); DBG_ASSERT( ( nCurrentIndex != -1 ) && ( nNewIndex != -1 ), "RoadmapWizard::OnRoadmapItemSelected: something's wrong here!" ); @@ -663,8 +663,8 @@ namespace vcl bool bResult = true; if ( nNewIndex > nCurrentIndex ) { - bResult = skipUntil( static_cast<WizardTypes::WizardState>(nCurItemId) ); - WizardTypes::WizardState nTemp = static_cast<WizardTypes::WizardState>(nCurItemId); + bResult = skipUntil(nSelectedState); + WizardTypes::WizardState nTemp = nSelectedState; while( nTemp ) { if( m_pImpl->aDisabledStates.find( --nTemp ) != m_pImpl->aDisabledStates.end() ) @@ -672,7 +672,7 @@ namespace vcl } } else - bResult = skipBackwardUntil( static_cast<WizardTypes::WizardState>(nCurItemId) ); + bResult = skipBackwardUntil(nSelectedState); return bResult; } @@ -746,7 +746,7 @@ namespace vcl } // if the state is currently in the roadmap, reflect it's new status - m_xAssistant->set_page_sensitive(OString::number(_nState), _bEnable); + m_xAssistant->set_page_sensitive(getPageIdentForState(_nState), _bEnable); } bool RoadmapWizardMachine::knowsState( WizardTypes::WizardState i_nState ) const diff --git a/vcl/source/control/wizardmachine.cxx b/vcl/source/control/wizardmachine.cxx index 86176f2fc7ac..fc76037c5ae1 100644 --- a/vcl/source/control/wizardmachine.cxx +++ b/vcl/source/control/wizardmachine.cxx @@ -893,6 +893,16 @@ namespace vcl implUpdateTitle(); } + OString WizardMachine::getPageIdentForState(WizardTypes::WizardState nState) const + { + return OString::number(nState); + } + + WizardTypes::WizardState WizardMachine::getStateFromPageIdent(const OString& rIdent) const + { + return rIdent.toInt32(); + } + BuilderPage* WizardMachine::GetOrCreatePage( const WizardTypes::WizardState i_nState ) { if ( nullptr == GetPage( i_nState ) ) @@ -1174,7 +1184,7 @@ namespace vcl if (pOldTabPage) pOldTabPage->Deactivate(); - m_xAssistant->set_current_page(OString::number(nState)); + m_xAssistant->set_current_page(getPageIdentForState(nState)); m_pCurTabPage = GetPage(m_nCurState); m_pCurTabPage->Activate();
