diff options
author | Caolán McNamara <caolanm@redhat.com> | 2019-09-14 18:40:21 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2019-09-15 16:25:57 +0200 |
commit | 04f326cee7678be86db3bb826f6f83918d7a239a (patch) | |
tree | 1f5093dab1883203594800325b01c694792395f3 /vcl/source/control | |
parent | bcaeebd98a697d6bcf891990c3b13de5da1790e7 (diff) |
merge RoadmapWizard and OWizardMachine
Change-Id: Ib8c68cb5e96f8bfa9b2398946b87f3b451b3a37e
Reviewed-on: https://gerrit.libreoffice.org/78912
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl/source/control')
-rw-r--r-- | vcl/source/control/roadmapwizard.cxx | 219 | ||||
-rw-r--r-- | vcl/source/control/wizardmachine.cxx | 366 | ||||
-rw-r--r-- | vcl/source/control/wizimpldata.hxx | 64 |
3 files changed, 311 insertions, 338 deletions
diff --git a/vcl/source/control/roadmapwizard.cxx b/vcl/source/control/roadmapwizard.cxx index f1c49d546866..2e66d2ed4027 100644 --- a/vcl/source/control/roadmapwizard.cxx +++ b/vcl/source/control/roadmapwizard.cxx @@ -30,6 +30,7 @@ #include <map> #include <set> +#include "wizimpldata.hxx" namespace vcl { @@ -119,10 +120,20 @@ namespace vcl } //= RoadmapWizard - RoadmapWizard::RoadmapWizard( Window* _pParent ) - :OWizardMachine( _pParent, WizardButtonFlags::NEXT | WizardButtonFlags::PREVIOUS | WizardButtonFlags::FINISH | WizardButtonFlags::CANCEL | WizardButtonFlags::HELP ) - ,m_pImpl( new RoadmapWizardImpl ) + RoadmapWizard::RoadmapWizard(vcl::Window* pParent) + :ModalDialog(pParent, "WizardDialog", "svt/ui/wizarddialog.ui") + ,m_pFinish(nullptr) + ,m_pCancel(nullptr) + ,m_pNextPage(nullptr) + ,m_pPrevPage(nullptr) + ,m_pHelp(nullptr) + ,m_xWizardImpl(new WizardMachineImplData) + ,m_xRoadmapImpl(new RoadmapWizardImpl) { + ImplInitData(); + + implConstruct(WizardButtonFlags::NEXT | WizardButtonFlags::PREVIOUS | WizardButtonFlags::FINISH | WizardButtonFlags::CANCEL | WizardButtonFlags::HELP); + impl_construct(); } @@ -138,23 +149,23 @@ namespace vcl SetLeftAlignedButtonCount( 1 ); SetEmptyViewMargin(); - m_pImpl->pRoadmap.disposeAndReset( VclPtr<ORoadmap>::Create( this, WB_TABSTOP ) ); - m_pImpl->pRoadmap->SetText( VclResId( STR_WIZDLG_ROADMAP_TITLE ) ); - m_pImpl->pRoadmap->SetPosPixel( Point( 0, 0 ) ); - m_pImpl->pRoadmap->SetItemSelectHdl( LINK( this, RoadmapWizard, OnRoadmapItemSelected ) ); + m_xRoadmapImpl->pRoadmap.disposeAndReset( VclPtr<ORoadmap>::Create( this, WB_TABSTOP ) ); + m_xRoadmapImpl->pRoadmap->SetText( VclResId( STR_WIZDLG_ROADMAP_TITLE ) ); + m_xRoadmapImpl->pRoadmap->SetPosPixel( Point( 0, 0 ) ); + m_xRoadmapImpl->pRoadmap->SetItemSelectHdl( LINK( this, RoadmapWizard, OnRoadmapItemSelected ) ); Size aRoadmapSize = LogicToPixel(Size(85, 0), MapMode(MapUnit::MapAppFont)); aRoadmapSize.setHeight( GetSizePixel().Height() ); - m_pImpl->pRoadmap->SetSizePixel( aRoadmapSize ); + m_xRoadmapImpl->pRoadmap->SetSizePixel( aRoadmapSize ); - SetViewWindow( m_pImpl->pRoadmap ); + SetViewWindow( m_xRoadmapImpl->pRoadmap ); SetViewAlign( WindowAlign::Left ); - m_pImpl->pRoadmap->Show(); + m_xRoadmapImpl->pRoadmap->Show(); } void RoadmapWizard::ShowRoadmap(bool bShow) { - m_pImpl->pRoadmap->Show(bShow); + m_xRoadmapImpl->pRoadmap->Show(bShow); CalcAndSetSize(); } @@ -169,13 +180,45 @@ namespace vcl void RoadmapWizard::dispose() { - m_pImpl.reset(); - OWizardMachine::dispose(); + m_xRoadmapImpl.reset(); + + m_pFinish.disposeAndClear(); + m_pCancel.disposeAndClear(); + m_pNextPage.disposeAndClear(); + m_pPrevPage.disposeAndClear(); + m_pHelp.disposeAndClear(); + + if (m_xWizardImpl) + { + for (WizardTypes::WizardState i = 0; i < m_xWizardImpl->nFirstUnknownPage; ++i) + { + TabPage *pPage = GetPage(i); + if (pPage) + pPage->disposeOnce(); + } + m_xWizardImpl.reset(); + } + + maWizardLayoutIdle.Stop(); + + // Remove all buttons + while ( mpFirstBtn ) + RemoveButton( mpFirstBtn->mpButton ); + + // Remove all pages + while ( mpFirstPage ) + RemovePage( mpFirstPage->mpPage ); + + mpCurTabPage.clear(); + mpPrevBtn.clear(); + mpNextBtn.clear(); + mpViewWindow.clear(); + ModalDialog::dispose(); } void RoadmapWizard::SetRoadmapHelpId( const OString& _rId ) { - m_pImpl->pRoadmap->SetHelpId( _rId ); + m_xRoadmapImpl->pRoadmap->SetHelpId( _rId ); } void RoadmapWizardMachine::SetRoadmapHelpId(const OString& rId) @@ -185,15 +228,15 @@ namespace vcl void RoadmapWizard::SetRoadmapInteractive( bool _bInteractive ) { - m_pImpl->pRoadmap->SetRoadmapInteractive( _bInteractive ); + m_xRoadmapImpl->pRoadmap->SetRoadmapInteractive( _bInteractive ); } void RoadmapWizard::declarePath( PathId _nPathId, const WizardPath& _lWizardStates) { - m_pImpl->aPaths.emplace( _nPathId, _lWizardStates ); + m_xRoadmapImpl->aPaths.emplace( _nPathId, _lWizardStates ); - if ( m_pImpl->aPaths.size() == 1 ) + if ( m_xRoadmapImpl->aPaths.size() == 1 ) // the very first path -> activate it activatePath( _nPathId ); else @@ -202,7 +245,6 @@ namespace vcl void RoadmapWizardMachine::declarePath( PathId _nPathId, const WizardPath& _lWizardStates) { - m_pImpl->aPaths.emplace( _nPathId, _lWizardStates ); if ( m_pImpl->aPaths.size() == 1 ) @@ -215,20 +257,20 @@ namespace vcl void RoadmapWizard::activatePath( PathId _nPathId, bool _bDecideForIt ) { - if ( ( _nPathId == m_pImpl->nActivePath ) && ( _bDecideForIt == m_pImpl->bActivePathIsDefinite ) ) + if ( ( _nPathId == m_xRoadmapImpl->nActivePath ) && ( _bDecideForIt == m_xRoadmapImpl->bActivePathIsDefinite ) ) // nothing to do return; // does the given path exist? - Paths::const_iterator aNewPathPos = m_pImpl->aPaths.find( _nPathId ); - DBG_ASSERT( aNewPathPos != m_pImpl->aPaths.end(), "RoadmapWizard::activate: there is no such path!" ); - if ( aNewPathPos == m_pImpl->aPaths.end() ) + Paths::const_iterator aNewPathPos = m_xRoadmapImpl->aPaths.find( _nPathId ); + DBG_ASSERT( aNewPathPos != m_xRoadmapImpl->aPaths.end(), "RoadmapWizard::activate: there is no such path!" ); + if ( aNewPathPos == m_xRoadmapImpl->aPaths.end() ) return; // determine the index of the current state in the current path sal_Int32 nCurrentStatePathIndex = -1; - if ( m_pImpl->nActivePath != -1 ) - nCurrentStatePathIndex = m_pImpl->getStateIndexInPath( getCurrentState(), m_pImpl->nActivePath ); + if ( m_xRoadmapImpl->nActivePath != -1 ) + nCurrentStatePathIndex = m_xRoadmapImpl->getStateIndexInPath( getCurrentState(), m_xRoadmapImpl->nActivePath ); DBG_ASSERT( static_cast<sal_Int32>(aNewPathPos->second.size()) > nCurrentStatePathIndex, "RoadmapWizard::activate: you cannot activate a path which has less states than we've already advanced!" ); @@ -239,8 +281,8 @@ namespace vcl return; // assert that the current and the new path are equal, up to nCurrentStatePathIndex - Paths::const_iterator aActivePathPos = m_pImpl->aPaths.find( m_pImpl->nActivePath ); - if ( aActivePathPos != m_pImpl->aPaths.end() ) + Paths::const_iterator aActivePathPos = m_xRoadmapImpl->aPaths.find( m_xRoadmapImpl->nActivePath ); + if ( aActivePathPos != m_xRoadmapImpl->aPaths.end() ) { if ( RoadmapWizardImpl::getFirstDifferentIndex( aActivePathPos->second, aNewPathPos->second ) <= nCurrentStatePathIndex ) { @@ -249,8 +291,8 @@ namespace vcl } } - m_pImpl->nActivePath = _nPathId; - m_pImpl->bActivePathIsDefinite = _bDecideForIt; + m_xRoadmapImpl->nActivePath = _nPathId; + m_xRoadmapImpl->bActivePathIsDefinite = _bDecideForIt; implUpdateRoadmap( ); } @@ -299,10 +341,9 @@ namespace vcl void RoadmapWizard::implUpdateRoadmap( ) { - - DBG_ASSERT( m_pImpl->aPaths.find( m_pImpl->nActivePath ) != m_pImpl->aPaths.end(), + DBG_ASSERT( m_xRoadmapImpl->aPaths.find( m_xRoadmapImpl->nActivePath ) != m_xRoadmapImpl->aPaths.end(), "RoadmapWizard::implUpdateRoadmap: there is no such path!" ); - const WizardPath& rActivePath( m_pImpl->aPaths[ m_pImpl->nActivePath ] ); + const WizardPath& rActivePath( m_xRoadmapImpl->aPaths[ m_xRoadmapImpl->nActivePath ] ); sal_Int32 nCurrentStatePathIndex = RoadmapWizardImpl::getStateIndexInPath( getCurrentState(), rActivePath ); if (nCurrentStatePathIndex < 0) @@ -311,11 +352,11 @@ namespace vcl // determine up to which index (in the new path) we have to display the items RoadmapTypes::ItemIndex nUpperStepBoundary = static_cast<RoadmapTypes::ItemIndex>(rActivePath.size()); bool bIncompletePath = false; - if ( !m_pImpl->bActivePathIsDefinite ) + if ( !m_xRoadmapImpl->bActivePathIsDefinite ) { - for (auto const& path : m_pImpl->aPaths) + for (auto const& path : m_xRoadmapImpl->aPaths) { - if ( path.first == m_pImpl->nActivePath ) + if ( path.first == m_xRoadmapImpl->nActivePath ) // it's the path we are just activating -> no need to check anything continue; // the index from which on both paths differ @@ -344,10 +385,10 @@ namespace vcl // now, we have to remove all items after nCurrentStatePathIndex, and insert the items from the active // path, up to (excluding) nUpperStepBoundary - RoadmapTypes::ItemIndex nLoopUntil = ::std::max( nUpperStepBoundary, m_pImpl->pRoadmap->GetItemCount() ); + RoadmapTypes::ItemIndex nLoopUntil = ::std::max( nUpperStepBoundary, m_xRoadmapImpl->pRoadmap->GetItemCount() ); for ( RoadmapTypes::ItemIndex nItemIndex = nCurrentStatePathIndex; nItemIndex < nLoopUntil; ++nItemIndex ) { - bool bExistentItem = ( nItemIndex < m_pImpl->pRoadmap->GetItemCount() ); + bool bExistentItem = ( nItemIndex < m_xRoadmapImpl->pRoadmap->GetItemCount() ); bool bNeedItem = ( nItemIndex < nUpperStepBoundary ); bool bInsertItem = false; @@ -355,19 +396,19 @@ namespace vcl { if ( !bNeedItem ) { - while ( nItemIndex < m_pImpl->pRoadmap->GetItemCount() ) - m_pImpl->pRoadmap->DeleteRoadmapItem( nItemIndex ); + while ( nItemIndex < m_xRoadmapImpl->pRoadmap->GetItemCount() ) + m_xRoadmapImpl->pRoadmap->DeleteRoadmapItem( nItemIndex ); break; } else { // there is an item with this index in the roadmap - does it match what is requested by // the respective state in the active path? - RoadmapTypes::ItemId nPresentItemId = m_pImpl->pRoadmap->GetItemID( nItemIndex ); + RoadmapTypes::ItemId nPresentItemId = m_xRoadmapImpl->pRoadmap->GetItemID( nItemIndex ); WizardTypes::WizardState nRequiredState = rActivePath[ nItemIndex ]; if ( nPresentItemId != nRequiredState ) { - m_pImpl->pRoadmap->DeleteRoadmapItem( nItemIndex ); + m_xRoadmapImpl->pRoadmap->DeleteRoadmapItem( nItemIndex ); bInsertItem = true; } } @@ -381,7 +422,7 @@ namespace vcl WizardTypes::WizardState nState( rActivePath[ nItemIndex ] ); if ( bInsertItem ) { - m_pImpl->pRoadmap->InsertRoadmapItem( + m_xRoadmapImpl->pRoadmap->InsertRoadmapItem( nItemIndex, getStateDisplayName( nState ), nState, @@ -394,12 +435,12 @@ namespace vcl // from disabling all future states just because the current state does not // (yet) allow advancing. const bool bUnconditionedDisable = !bCurrentPageCanAdvance && ( nItemIndex > nCurrentStatePathIndex ); - const bool bEnable = !bUnconditionedDisable && ( m_pImpl->aDisabledStates.find( nState ) == m_pImpl->aDisabledStates.end() ); + const bool bEnable = !bUnconditionedDisable && ( m_xRoadmapImpl->aDisabledStates.find( nState ) == m_xRoadmapImpl->aDisabledStates.end() ); - m_pImpl->pRoadmap->EnableRoadmapItem( m_pImpl->pRoadmap->GetItemID( nItemIndex ), bEnable ); + m_xRoadmapImpl->pRoadmap->EnableRoadmapItem( m_xRoadmapImpl->pRoadmap->GetItemID( nItemIndex ), bEnable ); } - m_pImpl->pRoadmap->SetRoadmapComplete( !bIncompletePath ); + m_xRoadmapImpl->pRoadmap->SetRoadmapComplete( !bIncompletePath ); } void RoadmapWizardMachine::implUpdateRoadmap( ) @@ -509,11 +550,10 @@ namespace vcl WizardTypes::WizardState RoadmapWizard::determineNextState( WizardTypes::WizardState _nCurrentState ) const { - sal_Int32 nCurrentStatePathIndex = -1; - Paths::const_iterator aActivePathPos = m_pImpl->aPaths.find( m_pImpl->nActivePath ); - if ( aActivePathPos != m_pImpl->aPaths.end() ) + Paths::const_iterator aActivePathPos = m_xRoadmapImpl->aPaths.find( m_xRoadmapImpl->nActivePath ); + if ( aActivePathPos != m_xRoadmapImpl->aPaths.end() ) nCurrentStatePathIndex = RoadmapWizardImpl::getStateIndexInPath( _nCurrentState, aActivePathPos->second ); DBG_ASSERT( nCurrentStatePathIndex != -1, "RoadmapWizard::determineNextState: ehm - how can we travel if there is no (valid) active path?" ); @@ -523,7 +563,7 @@ namespace vcl sal_Int32 nNextStateIndex = nCurrentStatePathIndex + 1; while ( ( nNextStateIndex < static_cast<sal_Int32>(aActivePathPos->second.size()) ) - && ( m_pImpl->aDisabledStates.find( aActivePathPos->second[ nNextStateIndex ] ) != m_pImpl->aDisabledStates.end() ) + && ( m_xRoadmapImpl->aDisabledStates.find( aActivePathPos->second[ nNextStateIndex ] ) != m_xRoadmapImpl->aDisabledStates.end() ) ) { ++nNextStateIndex; @@ -566,14 +606,14 @@ namespace vcl bool RoadmapWizard::canAdvance() const { - if ( !m_pImpl->bActivePathIsDefinite ) + if ( !m_xRoadmapImpl->bActivePathIsDefinite ) { // check how many paths are still allowed - const WizardPath& rActivePath( m_pImpl->aPaths[ m_pImpl->nActivePath ] ); + const WizardPath& rActivePath( m_xRoadmapImpl->aPaths[ m_xRoadmapImpl->nActivePath ] ); sal_Int32 nCurrentStatePathIndex = RoadmapWizardImpl::getStateIndexInPath( getCurrentState(), rActivePath ); size_t nPossiblePaths(0); - for (auto const& path : m_pImpl->aPaths) + for (auto const& path : m_xRoadmapImpl->aPaths) { // the index from which on both paths differ sal_Int32 nDivergenceIndex = RoadmapWizardImpl::getFirstDifferentIndex( rActivePath, path.second ); @@ -590,7 +630,7 @@ namespace vcl return true; } - const WizardPath& rPath = m_pImpl->aPaths[ m_pImpl->nActivePath ]; + const WizardPath& rPath = m_xRoadmapImpl->aPaths[ m_xRoadmapImpl->nActivePath ]; return *rPath.rbegin() != getCurrentState(); } @@ -626,7 +666,13 @@ namespace vcl void RoadmapWizard::updateTravelUI() { - OWizardMachine::updateTravelUI(); + const IWizardPageController* pController = getPageController( GetPage( getCurrentState() ) ); + OSL_ENSURE( pController != nullptr, "RoadmapWizard::updateTravelUI: no controller for the current page!" ); + + bool bCanAdvance = + ( !pController || pController->canAdvance() ) // the current page allows to advance + && canAdvance(); // the dialog as a whole allows to advance + enableButtons( WizardButtonFlags::NEXT, bCanAdvance ); // disable the "Previous" button if all states in our history are disabled std::vector< WizardTypes::WizardState > aHistory; @@ -670,8 +716,7 @@ namespace vcl IMPL_LINK_NOARG(RoadmapWizard, OnRoadmapItemSelected, LinkParamNone*, void) { - - RoadmapTypes::ItemId nCurItemId = m_pImpl->pRoadmap->GetCurrentRoadmapItemID(); + RoadmapTypes::ItemId nCurItemId = m_xRoadmapImpl->pRoadmap->GetCurrentRoadmapItemID(); if ( nCurItemId == getCurrentState() ) // nothing to do return; @@ -679,10 +724,10 @@ namespace vcl if ( isTravelingSuspended() ) return; - WizardTravelSuspension aTravelGuard( *this ); + RoadmapWizardTravelSuspension aTravelGuard( *this ); - sal_Int32 nCurrentIndex = m_pImpl->getStateIndexInPath( getCurrentState(), m_pImpl->nActivePath ); - sal_Int32 nNewIndex = m_pImpl->getStateIndexInPath( nCurItemId, m_pImpl->nActivePath ); + sal_Int32 nCurrentIndex = m_xRoadmapImpl->getStateIndexInPath( getCurrentState(), m_xRoadmapImpl->nActivePath ); + sal_Int32 nNewIndex = m_xRoadmapImpl->getStateIndexInPath( nCurItemId, m_xRoadmapImpl->nActivePath ); DBG_ASSERT( ( nCurrentIndex != -1 ) && ( nNewIndex != -1 ), "RoadmapWizard::OnRoadmapItemSelected: something's wrong here!" ); @@ -698,7 +743,7 @@ namespace vcl WizardTypes::WizardState nTemp = static_cast<WizardTypes::WizardState>(nCurItemId); while( nTemp ) { - if( m_pImpl->aDisabledStates.find( --nTemp ) != m_pImpl->aDisabledStates.end() ) + if( m_xRoadmapImpl->aDisabledStates.find( --nTemp ) != m_xRoadmapImpl->aDisabledStates.end() ) removePageFromHistory( nTemp ); } } @@ -706,7 +751,7 @@ namespace vcl bResult = skipBackwardUntil( static_cast<WizardTypes::WizardState>(nCurItemId) ); if ( !bResult ) - m_pImpl->pRoadmap->SelectRoadmapItemByID( getCurrentState() ); + m_xRoadmapImpl->pRoadmap->SelectRoadmapItemByID( getCurrentState() ); } IMPL_LINK(RoadmapWizardMachine, OnRoadmapItemSelected, const OString&, rCurItemId, bool) @@ -749,13 +794,26 @@ namespace vcl return bResult; } - void RoadmapWizard::enterState( WizardTypes::WizardState _nState ) + void RoadmapWizard::enterState(WizardTypes::WizardState nState) { - OWizardMachine::enterState( _nState ); + // tell the page + IWizardPageController* pController = getPageController( GetPage( nState ) ); + if (pController) + { + pController->initializePage(); + + if ( isAutomaticNextButtonStateEnabled() ) + enableButtons( WizardButtonFlags::NEXT, canAdvance() ); + + enableButtons( WizardButtonFlags::PREVIOUS, !m_xWizardImpl->aStateHistory.empty() ); + + // set the new title - it depends on the current page (i.e. state) + implUpdateTitle(); + } // synchronize the roadmap implUpdateRoadmap( ); - m_pImpl->pRoadmap->SelectRoadmapItemByID( getCurrentState() ); + m_xRoadmapImpl->pRoadmap->SelectRoadmapItemByID( getCurrentState() ); } void RoadmapWizardMachine::enterState( WizardTypes::WizardState _nState ) @@ -770,10 +828,10 @@ namespace vcl { OUString sDisplayName; - StateDescriptions::const_iterator pos = m_pImpl->aStateDescriptors.find( _nState ); - OSL_ENSURE( pos != m_pImpl->aStateDescriptors.end(), + StateDescriptions::const_iterator pos = m_xRoadmapImpl->aStateDescriptors.find( _nState ); + OSL_ENSURE( pos != m_xRoadmapImpl->aStateDescriptors.end(), "RoadmapWizard::getStateDisplayName: no default implementation available for this state!" ); - if ( pos != m_pImpl->aStateDescriptors.end() ) + if ( pos != m_xRoadmapImpl->aStateDescriptors.end() ) sDisplayName = pos->second.first; return sDisplayName; @@ -796,10 +854,10 @@ namespace vcl { VclPtr<TabPage> pPage; - StateDescriptions::const_iterator pos = m_pImpl->aStateDescriptors.find( _nState ); - OSL_ENSURE( pos != m_pImpl->aStateDescriptors.end(), + StateDescriptions::const_iterator pos = m_xRoadmapImpl->aStateDescriptors.find( _nState ); + OSL_ENSURE( pos != m_xRoadmapImpl->aStateDescriptors.end(), "RoadmapWizard::createPage: no default implementation available for this state!" ); - if ( pos != m_pImpl->aStateDescriptors.end() ) + if ( pos != m_xRoadmapImpl->aStateDescriptors.end() ) { RoadmapPageFactory pFactory = pos->second.second; pPage = (*pFactory)( *this ); @@ -810,18 +868,17 @@ namespace vcl void RoadmapWizard::enableState( WizardTypes::WizardState _nState, bool _bEnable ) { - // remember this (in case the state appears in the roadmap later on) if ( _bEnable ) - m_pImpl->aDisabledStates.erase( _nState ); + m_xRoadmapImpl->aDisabledStates.erase( _nState ); else { - m_pImpl->aDisabledStates.insert( _nState ); + m_xRoadmapImpl->aDisabledStates.insert( _nState ); removePageFromHistory( _nState ); } // if the state is currently in the roadmap, reflect it's new status - m_pImpl->pRoadmap->EnableRoadmapItem( static_cast<RoadmapTypes::ItemId>(_nState), _bEnable ); + m_xRoadmapImpl->pRoadmap->EnableRoadmapItem( static_cast<RoadmapTypes::ItemId>(_nState), _bEnable ); } void RoadmapWizardMachine::enableState( WizardTypes::WizardState _nState, bool _bEnable ) @@ -841,7 +898,7 @@ namespace vcl bool RoadmapWizard::knowsState( WizardTypes::WizardState i_nState ) const { - for (auto const& path : m_pImpl->aPaths) + for (auto const& path : m_xRoadmapImpl->aPaths) { for (auto const& state : path.second) { @@ -854,7 +911,7 @@ namespace vcl bool RoadmapWizard::isStateEnabled( WizardTypes::WizardState _nState ) const { - return m_pImpl->aDisabledStates.find( _nState ) == m_pImpl->aDisabledStates.end(); + return m_xRoadmapImpl->aDisabledStates.find( _nState ) == m_xRoadmapImpl->aDisabledStates.end(); } bool RoadmapWizardMachine::isStateEnabled( WizardTypes::WizardState _nState ) const @@ -864,28 +921,28 @@ namespace vcl void RoadmapWizard::InsertRoadmapItem(int nItemIndex, const OUString& rText, int nItemId, bool bEnable) { - m_pImpl->pRoadmap->InsertRoadmapItem(nItemIndex, rText, nItemId, bEnable); + m_xRoadmapImpl->pRoadmap->InsertRoadmapItem(nItemIndex, rText, nItemId, bEnable); } void RoadmapWizard::SelectRoadmapItemByID(int nItemId) { - m_pImpl->pRoadmap->SelectRoadmapItemByID(nItemId); + m_xRoadmapImpl->pRoadmap->SelectRoadmapItemByID(nItemId); } void RoadmapWizard::DeleteRoadmapItems() { - while (m_pImpl->pRoadmap->GetItemCount()) - m_pImpl->pRoadmap->DeleteRoadmapItem(0); + while (m_xRoadmapImpl->pRoadmap->GetItemCount()) + m_xRoadmapImpl->pRoadmap->DeleteRoadmapItem(0); } void RoadmapWizard::SetItemSelectHdl( const Link<LinkParamNone*,void>& _rHdl ) { - m_pImpl->pRoadmap->SetItemSelectHdl(_rHdl); + m_xRoadmapImpl->pRoadmap->SetItemSelectHdl(_rHdl); } int RoadmapWizard::GetCurrentRoadmapItemID() const { - return m_pImpl->pRoadmap->GetCurrentRoadmapItemID(); + return m_xRoadmapImpl->pRoadmap->GetCurrentRoadmapItemID(); } } // namespace vcl diff --git a/vcl/source/control/wizardmachine.cxx b/vcl/source/control/wizardmachine.cxx index e620fe731838..f8f6753074cd 100644 --- a/vcl/source/control/wizardmachine.cxx +++ b/vcl/source/control/wizardmachine.cxx @@ -19,12 +19,13 @@ #include <vcl/event.hxx> #include <vcl/svapp.hxx> -#include <vcl/wizardmachine.hxx> +#include <vcl/roadmapwizard.hxx> #include <tools/debug.hxx> #include <tools/diagnose_ex.h> #include <strings.hrc> #include <svdata.hxx> #include <stack> +#include "wizimpldata.hxx" #define HID_WIZARD_NEXT "SVT_HID_WIZARD_NEXT" #define HID_WIZARD_PREVIOUS "SVT_HID_WIZARD_PREVIOUS" @@ -34,19 +35,6 @@ #define WIZARDDIALOG_VIEW_DLGOFFSET_X 6 #define WIZARDDIALOG_VIEW_DLGOFFSET_Y 6 -struct ImplWizPageData -{ - ImplWizPageData* mpNext; - VclPtr<TabPage> mpPage; -}; - -struct ImplWizButtonData -{ - ImplWizButtonData* mpNext; - VclPtr<Button> mpButton; - long mnOffset; -}; - namespace vcl { //= WizardPageImplData @@ -87,7 +75,7 @@ namespace vcl void OWizardPage::updateDialogTravelUI() { - OWizardMachine* pWizardMachine = dynamic_cast< OWizardMachine* >( GetParent() ); + RoadmapWizard* pWizardMachine = dynamic_cast<RoadmapWizard*>(GetParent()); if ( pWizardMachine ) pWizardMachine->updateTravelUI(); } @@ -102,28 +90,7 @@ namespace vcl return true; } - struct WizardMachineImplData - { - OUString sTitleBase; // the base for the title - std::stack<WizardTypes::WizardState> aStateHistory; // the history of all states (used for implementing "Back") - - WizardTypes::WizardState nFirstUnknownPage; - // the WizardDialog does not allow non-linear transitions (e.g. it's - // not possible to add pages in a non-linear order), so we need some own maintenance data - - bool m_bAutoNextButtonState; - - bool m_bTravelingSuspended; - - WizardMachineImplData() - :nFirstUnknownPage( 0 ) - ,m_bAutoNextButtonState( false ) - ,m_bTravelingSuspended( false ) - { - } - }; - - void OWizardMachine::ImplInitData() + void RoadmapWizard::ImplInitData() { mpFirstPage = nullptr; mpFirstBtn = nullptr; @@ -137,20 +104,20 @@ namespace vcl mnLeftAlignCount = 0; maWizardLayoutIdle.SetPriority(TaskPriority::RESIZE); - maWizardLayoutIdle.SetInvokeHandler( LINK( this, OWizardMachine, ImplHandleWizardLayoutTimerHdl ) ); + maWizardLayoutIdle.SetInvokeHandler( LINK( this, RoadmapWizard, ImplHandleWizardLayoutTimerHdl ) ); } - void OWizardMachine::SetLeftAlignedButtonCount( sal_Int16 _nCount ) + void RoadmapWizard::SetLeftAlignedButtonCount( sal_Int16 _nCount ) { mnLeftAlignCount = _nCount; } - void OWizardMachine::SetEmptyViewMargin() + void RoadmapWizard::SetEmptyViewMargin() { mbEmptyViewMargin = true; } - void OWizardMachine::ImplCalcSize( Size& rSize ) + void RoadmapWizard::ImplCalcSize( Size& rSize ) { // calculate ButtonBar height long nMaxHeight = 0; @@ -181,7 +148,7 @@ namespace vcl } } - void OWizardMachine::queue_resize(StateChangedType /*eReason*/) + void RoadmapWizard::queue_resize(StateChangedType /*eReason*/) { if (maWizardLayoutIdle.IsActive()) return; @@ -190,13 +157,13 @@ namespace vcl maWizardLayoutIdle.Start(); } - IMPL_LINK_NOARG(OWizardMachine, ImplHandleWizardLayoutTimerHdl, Timer*, void) + IMPL_LINK_NOARG(RoadmapWizard, ImplHandleWizardLayoutTimerHdl, Timer*, void) { ImplPosCtrls(); ImplPosTabPage(); } - void OWizardMachine::ImplPosCtrls() + void RoadmapWizard::ImplPosCtrls() { Size aDlgSize = GetOutputSizePixel(); long nBtnWidth = 0; @@ -304,13 +271,13 @@ namespace vcl nViewPosFlags ); } - long OWizardMachine::LogicalCoordinateToPixel(int iCoordinate){ + long RoadmapWizard::LogicalCoordinateToPixel(int iCoordinate){ Size aLocSize = LogicToPixel(Size(iCoordinate, 0), MapMode(MapUnit::MapAppFont)); int iPixelCoordinate = aLocSize.Width(); return iPixelCoordinate; } - void OWizardMachine::ImplPosTabPage() + void RoadmapWizard::ImplPosTabPage() { if ( !mpCurTabPage ) return; @@ -364,7 +331,7 @@ namespace vcl mpCurTabPage->SetPosSizePixel( aPos, aDlgSize ); } - void OWizardMachine::ImplShowTabPage( TabPage* pTabPage ) + void RoadmapWizard::ImplShowTabPage( TabPage* pTabPage ) { if ( mpCurTabPage == pTabPage ) return; @@ -385,7 +352,7 @@ namespace vcl pOldTabPage->Hide(); } - TabPage* OWizardMachine::ImplGetPage( sal_uInt16 nLevel ) const + TabPage* RoadmapWizard::ImplGetPage( sal_uInt16 nLevel ) const { sal_uInt16 nTempLevel = 0; ImplWizPageData* pPageData = mpFirstPage; @@ -403,23 +370,9 @@ namespace vcl return nullptr; } - OWizardMachine::OWizardMachine(vcl::Window* pParent, WizardButtonFlags _nButtonFlags) - :ModalDialog(pParent, "WizardDialog", "svt/ui/wizarddialog.ui") - ,m_pFinish(nullptr) - ,m_pCancel(nullptr) - ,m_pNextPage(nullptr) - ,m_pPrevPage(nullptr) - ,m_pHelp(nullptr) - ,m_pImpl( new WizardMachineImplData ) - { - ImplInitData(); - - implConstruct( _nButtonFlags ); - } - - void OWizardMachine::implConstruct( const WizardButtonFlags _nButtonFlags ) + void RoadmapWizard::implConstruct( const WizardButtonFlags _nButtonFlags ) { - m_pImpl->sTitleBase = GetText(); + m_xWizardImpl->sTitleBase = GetText(); // create the buttons according to the wizard button flags // the help button @@ -446,7 +399,7 @@ namespace vcl else AddButton( m_pPrevPage, WIZARDDIALOG_BUTTON_STDOFFSET_X ); SetPrevButton( m_pPrevPage ); - m_pPrevPage->SetClickHdl( LINK( this, OWizardMachine, OnPrevPage ) ); + m_pPrevPage->SetClickHdl( LINK( this, RoadmapWizard, OnPrevPage ) ); } // the next button @@ -461,7 +414,7 @@ namespace vcl AddButton( m_pNextPage, WIZARDDIALOG_BUTTON_STDOFFSET_X ); SetNextButton( m_pNextPage ); - m_pNextPage->SetClickHdl( LINK( this, OWizardMachine, OnNextPage ) ); + m_pNextPage->SetClickHdl( LINK( this, RoadmapWizard, OnNextPage ) ); } // the finish button @@ -474,7 +427,7 @@ namespace vcl m_pFinish->set_id("finish"); AddButton( m_pFinish, WIZARDDIALOG_BUTTON_STDOFFSET_X ); - m_pFinish->SetClickHdl( LINK( this, OWizardMachine, OnFinish ) ); + m_pFinish->SetClickHdl( LINK( this, RoadmapWizard, OnFinish ) ); } // the cancel button @@ -488,49 +441,7 @@ namespace vcl } } - - OWizardMachine::~OWizardMachine() - { - disposeOnce(); - } - - void OWizardMachine::dispose() - { - m_pFinish.disposeAndClear(); - m_pCancel.disposeAndClear(); - m_pNextPage.disposeAndClear(); - m_pPrevPage.disposeAndClear(); - m_pHelp.disposeAndClear(); - - if (m_pImpl) - { - for (WizardTypes::WizardState i = 0; i < m_pImpl->nFirstUnknownPage; ++i) - { - TabPage *pPage = GetPage(i); - if (pPage) - pPage->disposeOnce(); - } - m_pImpl.reset(); - } - - maWizardLayoutIdle.Stop(); - - // Remove all buttons - while ( mpFirstBtn ) - RemoveButton( mpFirstBtn->mpButton ); - - // Remove all pages - while ( mpFirstPage ) - RemovePage( mpFirstPage->mpPage ); - - mpCurTabPage.clear(); - mpPrevBtn.clear(); - mpNextBtn.clear(); - mpViewWindow.clear(); - ModalDialog::dispose(); - } - - void OWizardMachine::Resize() + void RoadmapWizard::Resize() { if ( IsReallyShown() && !IsInInitShow() ) { @@ -541,9 +452,9 @@ namespace vcl ModalDialog::Resize(); } - void OWizardMachine::implUpdateTitle() + void RoadmapWizard::implUpdateTitle() { - OUString sCompleteTitle(m_pImpl->sTitleBase); + OUString sCompleteTitle(m_xWizardImpl->sTitleBase); // append the page title TabPage* pCurrentPage = GetPage(getCurrentState()); @@ -555,7 +466,7 @@ namespace vcl SetText(sCompleteTitle); } - void OWizardMachine::CalcAndSetSize() + void RoadmapWizard::CalcAndSetSize() { Size aDlgSize = GetPageSizePixel(); if ( !aDlgSize.Width() || !aDlgSize.Height() ) @@ -579,7 +490,7 @@ namespace vcl SetOutputSizePixel( aDlgSize ); } - void OWizardMachine::StateChanged( StateChangedType nType ) + void RoadmapWizard::StateChanged( StateChangedType nType ) { if ( nType == StateChangedType::InitShow ) { @@ -596,7 +507,7 @@ namespace vcl ModalDialog::StateChanged( nType ); } - bool OWizardMachine::EventNotify( NotifyEvent& rNEvt ) + bool RoadmapWizard::EventNotify( NotifyEvent& rNEvt ) { if ( (rNEvt.GetType() == MouseNotifyEvent::KEYINPUT) && mpPrevBtn && mpNextBtn ) { @@ -640,32 +551,31 @@ namespace vcl return ModalDialog::EventNotify( rNEvt ); } - void OWizardMachine::setTitleBase(const OUString& _rTitleBase) + void RoadmapWizard::setTitleBase(const OUString& _rTitleBase) { - m_pImpl->sTitleBase = _rTitleBase; + m_xWizardImpl->sTitleBase = _rTitleBase; implUpdateTitle(); } - - TabPage* OWizardMachine::GetOrCreatePage( const WizardTypes::WizardState i_nState ) + TabPage* RoadmapWizard::GetOrCreatePage( const WizardTypes::WizardState i_nState ) { if ( nullptr == GetPage( i_nState ) ) { VclPtr<TabPage> pNewPage = createPage( i_nState ); - DBG_ASSERT( pNewPage, "OWizardMachine::GetOrCreatePage: invalid new page (NULL)!" ); + DBG_ASSERT( pNewPage, "RoadmapWizard::GetOrCreatePage: invalid new page (NULL)!" ); // fill up the page sequence of our base class (with dummies) - while ( m_pImpl->nFirstUnknownPage < i_nState ) + while ( m_xWizardImpl->nFirstUnknownPage < i_nState ) { AddPage( nullptr ); - ++m_pImpl->nFirstUnknownPage; + ++m_xWizardImpl->nFirstUnknownPage; } - if ( m_pImpl->nFirstUnknownPage == i_nState ) + if ( m_xWizardImpl->nFirstUnknownPage == i_nState ) { // encountered this page number the first time AddPage( pNewPage ); - ++m_pImpl->nFirstUnknownPage; + ++m_xWizardImpl->nFirstUnknownPage; } else // already had this page - just change it @@ -674,7 +584,7 @@ namespace vcl return GetPage( i_nState ); } - void OWizardMachine::ActivatePage() + void RoadmapWizard::ActivatePage() { maActivateHdl.Call( this ); @@ -684,13 +594,13 @@ namespace vcl enterState( nCurrentLevel ); } - bool OWizardMachine::DeactivatePage() + bool RoadmapWizard::DeactivatePage() { WizardTypes::WizardState nCurrentState = getCurrentState(); return leaveState(nCurrentState); } - void OWizardMachine::defaultButton(WizardButtonFlags _nWizardButtonFlags) + void RoadmapWizard::defaultButton(WizardButtonFlags _nWizardButtonFlags) { // the new default button PushButton* pNewDefButton = nullptr; @@ -711,19 +621,19 @@ namespace vcl implResetDefault( this ); } - bool OWizardMachine::ShowNextPage() + bool RoadmapWizard::ShowNextPage() { return ShowPage( mnCurLevel+1 ); } - bool OWizardMachine::ShowPrevPage() + bool RoadmapWizard::ShowPrevPage() { if ( !mnCurLevel ) return false; return ShowPage( mnCurLevel-1 ); } - bool OWizardMachine::ShowPage( sal_uInt16 nLevel ) + bool RoadmapWizard::ShowPage( sal_uInt16 nLevel ) { if ( DeactivatePage() ) { @@ -736,7 +646,7 @@ namespace vcl return false; } - bool OWizardMachine::Finish( long nResult ) + bool RoadmapWizard::Finish( long nResult ) { if ( DeactivatePage() ) { @@ -753,7 +663,7 @@ namespace vcl return false; } - void OWizardMachine::AddPage( TabPage* pPage ) + void RoadmapWizard::AddPage( TabPage* pPage ) { ImplWizPageData* pNewPageData = new ImplWizPageData; pNewPageData->mpNext = nullptr; @@ -770,7 +680,7 @@ namespace vcl } } - void OWizardMachine::RemovePage( TabPage* pPage ) + void RoadmapWizard::RemovePage( TabPage* pPage ) { ImplWizPageData* pPrevPageData = nullptr; ImplWizPageData* pPageData = mpFirstPage; @@ -792,10 +702,10 @@ namespace vcl pPageData = pPageData->mpNext; } - OSL_FAIL( "OWizardMachine::RemovePage() - Page not in list" ); + OSL_FAIL( "RoadmapWizard::RemovePage() - Page not in list" ); } - void OWizardMachine::SetPage( sal_uInt16 nLevel, TabPage* pPage ) + void RoadmapWizard::SetPage( sal_uInt16 nLevel, TabPage* pPage ) { sal_uInt16 nTempLevel = 0; ImplWizPageData* pPageData = mpFirstPage; @@ -816,7 +726,7 @@ namespace vcl } } - TabPage* OWizardMachine::GetPage( sal_uInt16 nLevel ) const + TabPage* RoadmapWizard::GetPage( sal_uInt16 nLevel ) const { sal_uInt16 nTempLevel = 0; @@ -831,7 +741,7 @@ namespace vcl return nullptr; } - void OWizardMachine::AddButton( Button* pButton, long nOffset ) + void RoadmapWizard::AddButton( Button* pButton, long nOffset ) { ImplWizButtonData* pNewBtnData = new ImplWizButtonData; pNewBtnData->mpNext = nullptr; @@ -849,7 +759,7 @@ namespace vcl } } - void OWizardMachine::RemoveButton( Button* pButton ) + void RoadmapWizard::RemoveButton( Button* pButton ) { ImplWizButtonData* pPrevBtnData = nullptr; ImplWizButtonData* pBtnData = mpFirstBtn; @@ -869,10 +779,10 @@ namespace vcl pBtnData = pBtnData->mpNext; } - OSL_FAIL( "OWizardMachine::RemoveButton() - Button not in list" ); + OSL_FAIL( "RoadmapWizard::RemoveButton() - Button not in list" ); } - void OWizardMachine::implResetDefault(vcl::Window const * _pWindow) + void RoadmapWizard::implResetDefault(vcl::Window const * _pWindow) { vcl::Window* pChildLoop = _pWindow->GetWindow(GetWindowType::FirstChild); while (pChildLoop) @@ -900,8 +810,7 @@ namespace vcl } } - - void OWizardMachine::defaultButton(PushButton* _pNewDefButton) + void RoadmapWizard::defaultButton(PushButton* _pNewDefButton) { // loop through all (direct and indirect) descendants which participate in our tabbing order, and // reset the WB_DEFBUTTON for every window which is a button @@ -912,8 +821,7 @@ namespace vcl _pNewDefButton->SetStyle(_pNewDefButton->GetStyle() | WB_DEFBUTTON); } - - void OWizardMachine::enableButtons(WizardButtonFlags _nWizardButtonFlags, bool _bEnable) + void RoadmapWizard::enableButtons(WizardButtonFlags _nWizardButtonFlags, bool _bEnable) { if (m_pFinish && (_nWizardButtonFlags & WizardButtonFlags::FINISH)) m_pFinish->Enable(_bEnable); @@ -927,24 +835,7 @@ namespace vcl m_pCancel->Enable(_bEnable); } - void OWizardMachine::enterState(WizardTypes::WizardState nState) - { - // tell the page - IWizardPageController* pController = getPageController( GetPage( nState ) ); - if (!pController) - return; - pController->initializePage(); - - if ( isAutomaticNextButtonStateEnabled() ) - enableButtons( WizardButtonFlags::NEXT, canAdvance() ); - - enableButtons( WizardButtonFlags::PREVIOUS, !m_pImpl->aStateHistory.empty() ); - - // set the new title - it depends on the current page (i.e. state) - implUpdateTitle(); - } - - bool OWizardMachine::leaveState(WizardTypes::WizardState) + bool RoadmapWizard::leaveState(WizardTypes::WizardState) { // no need to ask the page here. // If we reach this point, we already gave the current page the chance to commit it's data, @@ -953,18 +844,16 @@ namespace vcl return true; } - - bool OWizardMachine::onFinish() + bool RoadmapWizard::onFinish() { return Finish( RET_OK ); } - - IMPL_LINK_NOARG(OWizardMachine, OnFinish, Button*, void) + IMPL_LINK_NOARG(RoadmapWizard, OnFinish, Button*, void) { if ( isTravelingSuspended() ) return; - WizardTravelSuspension aTravelGuard( *this ); + RoadmapWizardTravelSuspension aTravelGuard( *this ); if (!prepareLeaveCurrentState(WizardTypes::eFinish)) { return; @@ -972,47 +861,40 @@ namespace vcl onFinish(); } - WizardTypes::WizardState OWizardMachine::determineNextState( WizardTypes::WizardState _nCurrentState ) const - { - return _nCurrentState + 1; - } - - bool OWizardMachine::prepareLeaveCurrentState( WizardTypes::CommitPageReason _eReason ) + bool RoadmapWizard::prepareLeaveCurrentState( WizardTypes::CommitPageReason _eReason ) { IWizardPageController* pController = getPageController( GetPage( getCurrentState() ) ); - ENSURE_OR_RETURN( pController != nullptr, "OWizardMachine::prepareLeaveCurrentState: no controller for the current page!", true ); + ENSURE_OR_RETURN( pController != nullptr, "RoadmapWizard::prepareLeaveCurrentState: no controller for the current page!", true ); return pController->commitPage( _eReason ); } - - bool OWizardMachine::skipBackwardUntil( WizardTypes::WizardState _nTargetState ) + bool RoadmapWizard::skipBackwardUntil( WizardTypes::WizardState _nTargetState ) { // allowed to leave the current page? if (!prepareLeaveCurrentState(WizardTypes::eTravelBackward)) return false; - // don't travel directly on m_pImpl->aStateHistory, in case something goes wrong - std::stack< WizardTypes::WizardState > aTravelVirtually = m_pImpl->aStateHistory; - std::stack< WizardTypes::WizardState > aOldStateHistory = m_pImpl->aStateHistory; + // don't travel directly on m_xWizardImpl->aStateHistory, in case something goes wrong + std::stack< WizardTypes::WizardState > aTravelVirtually = m_xWizardImpl->aStateHistory; + std::stack< WizardTypes::WizardState > aOldStateHistory = m_xWizardImpl->aStateHistory; WizardTypes::WizardState nCurrentRollbackState = getCurrentState(); while ( nCurrentRollbackState != _nTargetState ) { - DBG_ASSERT( !aTravelVirtually.empty(), "OWizardMachine::skipBackwardUntil: this target state does not exist in the history!" ); + DBG_ASSERT( !aTravelVirtually.empty(), "RoadmapWizard::skipBackwardUntil: this target state does not exist in the history!" ); nCurrentRollbackState = aTravelVirtually.top(); aTravelVirtually.pop(); } - m_pImpl->aStateHistory = aTravelVirtually; + m_xWizardImpl->aStateHistory = aTravelVirtually; if ( !ShowPage( _nTargetState ) ) { - m_pImpl->aStateHistory = aOldStateHistory; + m_xWizardImpl->aStateHistory = aOldStateHistory; return false; } return true; } - - bool OWizardMachine::skipUntil( WizardTypes::WizardState _nTargetState ) + bool RoadmapWizard::skipUntil( WizardTypes::WizardState _nTargetState ) { WizardTypes::WizardState nCurrentState = getCurrentState(); @@ -1020,15 +902,15 @@ namespace vcl if ( !prepareLeaveCurrentState( nCurrentState < _nTargetState ? WizardTypes::eTravelForward : WizardTypes::eTravelBackward ) ) return false; - // don't travel directly on m_pImpl->aStateHistory, in case something goes wrong - std::stack< WizardTypes::WizardState > aTravelVirtually = m_pImpl->aStateHistory; - std::stack< WizardTypes::WizardState > aOldStateHistory = m_pImpl->aStateHistory; + // don't travel directly on m_xWizardImpl->aStateHistory, in case something goes wrong + std::stack< WizardTypes::WizardState > aTravelVirtually = m_xWizardImpl->aStateHistory; + std::stack< WizardTypes::WizardState > aOldStateHistory = m_xWizardImpl->aStateHistory; while ( nCurrentState != _nTargetState ) { WizardTypes::WizardState nNextState = determineNextState( nCurrentState ); if ( WZS_INVALID_STATE == nNextState ) { - OSL_FAIL( "OWizardMachine::skipUntil: the given target state does not exist!" ); + OSL_FAIL( "RoadmapWizard::skipUntil: the given target state does not exist!" ); return false; } @@ -1038,21 +920,20 @@ namespace vcl // get the next state nCurrentState = nNextState; } - m_pImpl->aStateHistory = aTravelVirtually; + m_xWizardImpl->aStateHistory = aTravelVirtually; // show the target page if ( !ShowPage( nCurrentState ) ) { // argh! prepareLeaveCurrentPage succeeded, determineNextState succeeded, // but ShowPage doesn't? Somebody behaves very strange here... - OSL_FAIL( "OWizardMachine::skipUntil: very unpolite..." ); - m_pImpl->aStateHistory = aOldStateHistory; + OSL_FAIL( "RoadmapWizard::skipUntil: very unpolite..." ); + m_xWizardImpl->aStateHistory = aOldStateHistory; return false; } return true; } - - void OWizardMachine::skip() + void RoadmapWizard::skip() { // allowed to leave the current page? if ( !prepareLeaveCurrentState( WizardTypes::eTravelForward ) ) @@ -1065,7 +946,7 @@ namespace vcl return; // remember the skipped state in the history - m_pImpl->aStateHistory.push(nCurrentState); + m_xWizardImpl->aStateHistory.push(nCurrentState); // get the next state nCurrentState = nNextState; @@ -1075,7 +956,7 @@ namespace vcl { // TODO: this leaves us in a state where we have no current page and an inconsistent state history. // Perhaps we should rollback the skipping here... - OSL_FAIL("OWizardMachine::skip: very unpolite..."); + OSL_FAIL("RoadmapWizard::skip: very unpolite..."); // if somebody does a skip and then does not allow to leave... // (can't be a commit error, as we've already committed the current page. So if ShowPage fails here, // somebody behaves really strange...) @@ -1085,7 +966,7 @@ namespace vcl // all fine } - bool OWizardMachine::travelNext() + bool RoadmapWizard::travelNext() { // allowed to leave the current page? if ( !prepareLeaveCurrentState( WizardTypes::eTravelForward ) ) @@ -1099,34 +980,33 @@ namespace vcl // the state history is used by the enterState method // all fine - m_pImpl->aStateHistory.push(nCurrentState); + m_xWizardImpl->aStateHistory.push(nCurrentState); if (!ShowPage(nNextState)) { - m_pImpl->aStateHistory.pop(); + m_xWizardImpl->aStateHistory.pop(); return false; } return true; } - - bool OWizardMachine::travelPrevious() + bool RoadmapWizard::travelPrevious() { - DBG_ASSERT(!m_pImpl->aStateHistory.empty(), "OWizardMachine::travelPrevious: have no previous page!"); + DBG_ASSERT(!m_xWizardImpl->aStateHistory.empty(), "RoadmapWizard::travelPrevious: have no previous page!"); // allowed to leave the current page? if ( !prepareLeaveCurrentState( WizardTypes::eTravelBackward ) ) return false; // the next state to switch to - WizardTypes::WizardState nPreviousState = m_pImpl->aStateHistory.top(); + WizardTypes::WizardState nPreviousState = m_xWizardImpl->aStateHistory.top(); // the state history is used by the enterState method - m_pImpl->aStateHistory.pop(); + m_xWizardImpl->aStateHistory.pop(); // show this page if (!ShowPage(nPreviousState)) { - m_pImpl->aStateHistory.push(nPreviousState); + m_xWizardImpl->aStateHistory.push(nPreviousState); return false; } @@ -1134,15 +1014,14 @@ namespace vcl return true; } - - void OWizardMachine::removePageFromHistory( WizardTypes::WizardState nToRemove ) + void RoadmapWizard::removePageFromHistory( WizardTypes::WizardState nToRemove ) { std::stack< WizardTypes::WizardState > aTemp; - while(!m_pImpl->aStateHistory.empty()) + while(!m_xWizardImpl->aStateHistory.empty()) { - WizardTypes::WizardState nPreviousState = m_pImpl->aStateHistory.top(); - m_pImpl->aStateHistory.pop(); + WizardTypes::WizardState nPreviousState = m_xWizardImpl->aStateHistory.top(); + m_xWizardImpl->aStateHistory.pop(); if(nPreviousState != nToRemove) aTemp.push( nPreviousState ); else @@ -1150,52 +1029,46 @@ namespace vcl } while(!aTemp.empty()) { - m_pImpl->aStateHistory.push( aTemp.top() ); + m_xWizardImpl->aStateHistory.push( aTemp.top() ); aTemp.pop(); } } - - void OWizardMachine::enableAutomaticNextButtonState() + void RoadmapWizard::enableAutomaticNextButtonState() { - m_pImpl->m_bAutoNextButtonState = true; + m_xWizardImpl->m_bAutoNextButtonState = true; } - - bool OWizardMachine::isAutomaticNextButtonStateEnabled() const + bool RoadmapWizard::isAutomaticNextButtonStateEnabled() const { - return m_pImpl->m_bAutoNextButtonState; + return m_xWizardImpl->m_bAutoNextButtonState; } - - IMPL_LINK_NOARG(OWizardMachine, OnPrevPage, Button*, void) + IMPL_LINK_NOARG(RoadmapWizard, OnPrevPage, Button*, void) { if ( isTravelingSuspended() ) return; - WizardTravelSuspension aTravelGuard( *this ); + RoadmapWizardTravelSuspension aTravelGuard( *this ); travelPrevious(); } - - IMPL_LINK_NOARG(OWizardMachine, OnNextPage, Button*, void) + IMPL_LINK_NOARG(RoadmapWizard, OnNextPage, Button*, void) { if ( isTravelingSuspended() ) return; - WizardTravelSuspension aTravelGuard( *this ); + RoadmapWizardTravelSuspension aTravelGuard( *this ); travelNext(); } - - IWizardPageController* OWizardMachine::getPageController( TabPage* _pCurrentPage ) const + IWizardPageController* RoadmapWizard::getPageController( TabPage* _pCurrentPage ) const { IWizardPageController* pController = dynamic_cast< IWizardPageController* >( _pCurrentPage ); return pController; } - - void OWizardMachine::getStateHistory( std::vector< WizardTypes::WizardState >& _out_rHistory ) + void RoadmapWizard::getStateHistory( std::vector< WizardTypes::WizardState >& _out_rHistory ) { - std::stack< WizardTypes::WizardState > aHistoryCopy( m_pImpl->aStateHistory ); + std::stack< WizardTypes::WizardState > aHistoryCopy( m_xWizardImpl->aStateHistory ); while ( !aHistoryCopy.empty() ) { _out_rHistory.push_back( aHistoryCopy.top() ); @@ -1203,42 +1076,21 @@ namespace vcl } } - - bool OWizardMachine::canAdvance() const - { - return WZS_INVALID_STATE != determineNextState( getCurrentState() ); - } - - - void OWizardMachine::updateTravelUI() - { - const IWizardPageController* pController = getPageController( GetPage( getCurrentState() ) ); - OSL_ENSURE( pController != nullptr, "RoadmapWizard::updateTravelUI: no controller for the current page!" ); - - bool bCanAdvance = - ( !pController || pController->canAdvance() ) // the current page allows to advance - && canAdvance(); // the dialog as a whole allows to advance - enableButtons( WizardButtonFlags::NEXT, bCanAdvance ); - } - - - bool OWizardMachine::isTravelingSuspended() const + bool RoadmapWizard::isTravelingSuspended() const { - return m_pImpl->m_bTravelingSuspended; + return m_xWizardImpl->m_bTravelingSuspended; } - - void OWizardMachine::suspendTraveling( AccessGuard ) + void RoadmapWizard::suspendTraveling( AccessGuard ) { - DBG_ASSERT( !m_pImpl->m_bTravelingSuspended, "OWizardMachine::suspendTraveling: already suspended!" ); - m_pImpl->m_bTravelingSuspended = true; + DBG_ASSERT( !m_xWizardImpl->m_bTravelingSuspended, "RoadmapWizard::suspendTraveling: already suspended!" ); + m_xWizardImpl->m_bTravelingSuspended = true; } - - void OWizardMachine::resumeTraveling( AccessGuard ) + void RoadmapWizard::resumeTraveling( AccessGuard ) { - DBG_ASSERT( m_pImpl->m_bTravelingSuspended, "OWizardMachine::resumeTraveling: nothing to resume!" ); - m_pImpl->m_bTravelingSuspended = false; + DBG_ASSERT( m_xWizardImpl->m_bTravelingSuspended, "RoadmapWizard::resumeTraveling: nothing to resume!" ); + m_xWizardImpl->m_bTravelingSuspended = false; } WizardMachine::WizardMachine(weld::Window* pParent, WizardButtonFlags nButtonFlags) @@ -1579,7 +1431,7 @@ namespace vcl { // TODO: this leaves us in a state where we have no current page and an inconsistent state history. // Perhaps we should rollback the skipping here... - OSL_FAIL("OWizardMachine::skip: very unpolite..."); + OSL_FAIL("RoadmapWizard::skip: very unpolite..."); // if somebody does a skip and then does not allow to leave... // (can't be a commit error, as we've already committed the current page. So if ShowPage fails here, // somebody behaves really strange ...) diff --git a/vcl/source/control/wizimpldata.hxx b/vcl/source/control/wizimpldata.hxx new file mode 100644 index 000000000000..d61805167576 --- /dev/null +++ b/vcl/source/control/wizimpldata.hxx @@ -0,0 +1,64 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_VCL_SOURCE_CONTROL_WIZIMPLDATA_HXX +#define INCLUDED_VCL_SOURCE_CONTROL_WIZIMPLDATA_HXX + +#include <stack> + +struct ImplWizPageData +{ + ImplWizPageData* mpNext; + VclPtr<TabPage> mpPage; +}; + +struct ImplWizButtonData +{ + ImplWizButtonData* mpNext; + VclPtr<Button> mpButton; + long mnOffset; +}; + +namespace vcl +{ + struct WizardMachineImplData + { + OUString sTitleBase; // the base for the title + std::stack<WizardTypes::WizardState> aStateHistory; // the history of all states (used for implementing "Back") + + WizardTypes::WizardState nFirstUnknownPage; + // the WizardDialog does not allow non-linear transitions (e.g. it's + // not possible to add pages in a non-linear order), so we need some own maintenance data + + bool m_bAutoNextButtonState; + + bool m_bTravelingSuspended; + + WizardMachineImplData() + :nFirstUnknownPage( 0 ) + ,m_bAutoNextButtonState( false ) + ,m_bTravelingSuspended( false ) + { + } + }; +} // namespace svt + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |