1*5900e8ecSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*5900e8ecSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*5900e8ecSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*5900e8ecSAndrew Rist * distributed with this work for additional information 6*5900e8ecSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*5900e8ecSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*5900e8ecSAndrew Rist * "License"); you may not use this file except in compliance 9*5900e8ecSAndrew Rist * with the License. You may obtain a copy of the License at 10*5900e8ecSAndrew Rist * 11*5900e8ecSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*5900e8ecSAndrew Rist * 13*5900e8ecSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*5900e8ecSAndrew Rist * software distributed under the License is distributed on an 15*5900e8ecSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*5900e8ecSAndrew Rist * KIND, either express or implied. See the License for the 17*5900e8ecSAndrew Rist * specific language governing permissions and limitations 18*5900e8ecSAndrew Rist * under the License. 19*5900e8ecSAndrew Rist * 20*5900e8ecSAndrew Rist *************************************************************/ 21*5900e8ecSAndrew Rist 22*5900e8ecSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_svtools.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <svtools/roadmapwizard.hxx> 28cdf0e10cSrcweir #include <svtools/svtools.hrc> 29cdf0e10cSrcweir #include <svtools/svtdata.hxx> 30cdf0e10cSrcweir #include <svtools/roadmap.hxx> 31cdf0e10cSrcweir #include <tools/debug.hxx> 32cdf0e10cSrcweir 33cdf0e10cSrcweir #include <stdarg.h> 34cdf0e10cSrcweir 35cdf0e10cSrcweir #include <vector> 36cdf0e10cSrcweir #include <map> 37cdf0e10cSrcweir #include <set> 38cdf0e10cSrcweir 39cdf0e10cSrcweir //........................................................................ 40cdf0e10cSrcweir namespace svt 41cdf0e10cSrcweir { 42cdf0e10cSrcweir //........................................................................ 43cdf0e10cSrcweir 44cdf0e10cSrcweir namespace 45cdf0e10cSrcweir { 46cdf0e10cSrcweir typedef ::std::set< WizardTypes::WizardState > StateSet; 47cdf0e10cSrcweir 48cdf0e10cSrcweir typedef ::std::map< 49cdf0e10cSrcweir RoadmapWizardTypes::PathId, 50cdf0e10cSrcweir RoadmapWizardTypes::WizardPath 51cdf0e10cSrcweir > Paths; 52cdf0e10cSrcweir 53cdf0e10cSrcweir typedef ::std::map< 54cdf0e10cSrcweir WizardTypes::WizardState, 55cdf0e10cSrcweir ::std::pair< 56cdf0e10cSrcweir String, 57cdf0e10cSrcweir RoadmapWizardTypes::RoadmapPageFactory 58cdf0e10cSrcweir > 59cdf0e10cSrcweir > StateDescriptions; 60cdf0e10cSrcweir } 61cdf0e10cSrcweir 62cdf0e10cSrcweir struct RoadmapWizardImpl : public RoadmapWizardTypes 63cdf0e10cSrcweir { 64cdf0e10cSrcweir ORoadmap* pRoadmap; 65cdf0e10cSrcweir Paths aPaths; 66cdf0e10cSrcweir PathId nActivePath; 67cdf0e10cSrcweir StateDescriptions aStateDescriptors; 68cdf0e10cSrcweir StateSet aDisabledStates; 69cdf0e10cSrcweir bool bActivePathIsDefinite; 70cdf0e10cSrcweir FixedLine* pFixedLine; 71cdf0e10cSrcweir RoadmapWizardImplsvt::RoadmapWizardImpl72cdf0e10cSrcweir RoadmapWizardImpl() 73cdf0e10cSrcweir :pRoadmap( NULL ) 74cdf0e10cSrcweir ,nActivePath( -1 ) 75cdf0e10cSrcweir ,bActivePathIsDefinite( false ) 76cdf0e10cSrcweir ,pFixedLine(NULL) 77cdf0e10cSrcweir { 78cdf0e10cSrcweir } 79cdf0e10cSrcweir ~RoadmapWizardImplsvt::RoadmapWizardImpl80cdf0e10cSrcweir ~RoadmapWizardImpl() 81cdf0e10cSrcweir { 82cdf0e10cSrcweir delete pRoadmap; 83cdf0e10cSrcweir delete pFixedLine; 84cdf0e10cSrcweir } 85cdf0e10cSrcweir 86cdf0e10cSrcweir /// returns the index of the current state in given path, or -1 87cdf0e10cSrcweir sal_Int32 getStateIndexInPath( WizardTypes::WizardState _nState, const WizardPath& _rPath ); 88cdf0e10cSrcweir /// returns the index of the current state in the path with the given id, or -1 89cdf0e10cSrcweir sal_Int32 getStateIndexInPath( WizardTypes::WizardState _nState, PathId _nPathId ); 90cdf0e10cSrcweir /// returns the index of the first state in which the two given paths differ 91cdf0e10cSrcweir sal_Int32 getFirstDifferentIndex( const WizardPath& _rLHS, const WizardPath& _rRHS ); 92cdf0e10cSrcweir }; 93cdf0e10cSrcweir 94cdf0e10cSrcweir //-------------------------------------------------------------------- getStateIndexInPath(WizardTypes::WizardState _nState,const WizardPath & _rPath)95cdf0e10cSrcweir sal_Int32 RoadmapWizardImpl::getStateIndexInPath( WizardTypes::WizardState _nState, const WizardPath& _rPath ) 96cdf0e10cSrcweir { 97cdf0e10cSrcweir sal_Int32 nStateIndexInPath = 0; 98cdf0e10cSrcweir WizardPath::const_iterator aPathLoop = _rPath.begin(); 99cdf0e10cSrcweir for ( ; aPathLoop != _rPath.end(); ++aPathLoop, ++nStateIndexInPath ) 100cdf0e10cSrcweir if ( *aPathLoop == _nState ) 101cdf0e10cSrcweir break; 102cdf0e10cSrcweir if ( aPathLoop == _rPath.end() ) 103cdf0e10cSrcweir nStateIndexInPath = -1; 104cdf0e10cSrcweir return nStateIndexInPath; 105cdf0e10cSrcweir } 106cdf0e10cSrcweir 107cdf0e10cSrcweir //-------------------------------------------------------------------- getStateIndexInPath(WizardTypes::WizardState _nState,PathId _nPathId)108cdf0e10cSrcweir sal_Int32 RoadmapWizardImpl::getStateIndexInPath( WizardTypes::WizardState _nState, PathId _nPathId ) 109cdf0e10cSrcweir { 110cdf0e10cSrcweir sal_Int32 nStateIndexInPath = -1; 111cdf0e10cSrcweir Paths::const_iterator aPathPos = aPaths.find( _nPathId ); 112cdf0e10cSrcweir if ( aPathPos != aPaths.end( ) ) 113cdf0e10cSrcweir nStateIndexInPath = getStateIndexInPath( _nState, aPathPos->second ); 114cdf0e10cSrcweir return nStateIndexInPath; 115cdf0e10cSrcweir } 116cdf0e10cSrcweir 117cdf0e10cSrcweir //-------------------------------------------------------------------- getFirstDifferentIndex(const WizardPath & _rLHS,const WizardPath & _rRHS)118cdf0e10cSrcweir sal_Int32 RoadmapWizardImpl::getFirstDifferentIndex( const WizardPath& _rLHS, const WizardPath& _rRHS ) 119cdf0e10cSrcweir { 120cdf0e10cSrcweir sal_Int32 nMinLength = ::std::min( _rLHS.size(), _rRHS.size() ); 121cdf0e10cSrcweir for ( sal_Int32 nCheck = 0; nCheck < nMinLength; ++nCheck ) 122cdf0e10cSrcweir { 123cdf0e10cSrcweir if ( _rLHS[ nCheck ] != _rRHS[ nCheck ] ) 124cdf0e10cSrcweir return nCheck; 125cdf0e10cSrcweir } 126cdf0e10cSrcweir return nMinLength; 127cdf0e10cSrcweir } 128cdf0e10cSrcweir 129cdf0e10cSrcweir //==================================================================== 130cdf0e10cSrcweir //= RoadmapWizard 131cdf0e10cSrcweir //==================================================================== DBG_NAME(RoadmapWizard) const132cdf0e10cSrcweir DBG_NAME( RoadmapWizard ) 133cdf0e10cSrcweir //-------------------------------------------------------------------- 134cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 0 135cdf0e10cSrcweir const char* CheckInvariants( const void* pVoid ) 136cdf0e10cSrcweir { 137cdf0e10cSrcweir return static_cast< const RoadmapWizard* >( pVoid )->checkInvariants(); 138cdf0e10cSrcweir } 139cdf0e10cSrcweir 140cdf0e10cSrcweir //-------------------------------------------------------------------- checkInvariants() const141cdf0e10cSrcweir const sal_Char* RoadmapWizard::checkInvariants() const 142cdf0e10cSrcweir { 143cdf0e10cSrcweir // all paths have to start with the same state 144cdf0e10cSrcweir WizardState nSharedFirstState = WZS_INVALID_STATE; 145cdf0e10cSrcweir for ( Paths::const_iterator aPath = m_pImpl->aPaths.begin(); 146cdf0e10cSrcweir aPath != m_pImpl->aPaths.end(); 147cdf0e10cSrcweir ++aPath 148cdf0e10cSrcweir ) 149cdf0e10cSrcweir { 150cdf0e10cSrcweir if ( aPath->second.empty() ) 151cdf0e10cSrcweir return "RoadmapWizard::checkInvariants: paths should not be empty!"; 152cdf0e10cSrcweir 153cdf0e10cSrcweir if ( nSharedFirstState == WZS_INVALID_STATE ) 154cdf0e10cSrcweir // first path 155cdf0e10cSrcweir nSharedFirstState = aPath->second[ 0 ]; 156cdf0e10cSrcweir else 157cdf0e10cSrcweir if ( nSharedFirstState != aPath->second[ 0 ] ) 158cdf0e10cSrcweir return "RoadmapWizard::checkInvariants: alls paths must start with the same state!"; 159cdf0e10cSrcweir } 160cdf0e10cSrcweir 161cdf0e10cSrcweir if ( !m_pImpl->aPaths.empty() ) 162cdf0e10cSrcweir { 163cdf0e10cSrcweir Paths::const_iterator aCurrentPathPos = m_pImpl->aPaths.find( m_pImpl->nActivePath ); 164cdf0e10cSrcweir if ( aCurrentPathPos == m_pImpl->aPaths.end() ) 165cdf0e10cSrcweir return "RoadmapWizard::checkInvariants: invalid active path!"; 166cdf0e10cSrcweir 167cdf0e10cSrcweir if ( -1 == m_pImpl->getStateIndexInPath( getCurrentState(), m_pImpl->nActivePath ) ) 168cdf0e10cSrcweir return "RoadmapWizard::checkInvariants: the current state is not part of the current path!"; 169cdf0e10cSrcweir } 170cdf0e10cSrcweir 171cdf0e10cSrcweir return NULL; 172cdf0e10cSrcweir } 173cdf0e10cSrcweir #endif 174cdf0e10cSrcweir 175cdf0e10cSrcweir //-------------------------------------------------------------------- RoadmapWizard(Window * _pParent,const ResId & _rRes,sal_uInt32 _nButtonFlags)176cdf0e10cSrcweir RoadmapWizard::RoadmapWizard( Window* _pParent, const ResId& _rRes, sal_uInt32 _nButtonFlags ) 177cdf0e10cSrcweir :OWizardMachine( _pParent, _rRes, _nButtonFlags ) 178cdf0e10cSrcweir ,m_pImpl( new RoadmapWizardImpl ) 179cdf0e10cSrcweir { 180cdf0e10cSrcweir DBG_CTOR( RoadmapWizard, CheckInvariants ); 181cdf0e10cSrcweir impl_construct(); 182cdf0e10cSrcweir } 183cdf0e10cSrcweir 184cdf0e10cSrcweir //-------------------------------------------------------------------- RoadmapWizard(Window * _pParent,const WinBits i_nStyle,sal_uInt32 _nButtonFlags)185cdf0e10cSrcweir RoadmapWizard::RoadmapWizard( Window* _pParent, const WinBits i_nStyle, sal_uInt32 _nButtonFlags ) 186cdf0e10cSrcweir :OWizardMachine( _pParent, i_nStyle, _nButtonFlags ) 187cdf0e10cSrcweir ,m_pImpl( new RoadmapWizardImpl ) 188cdf0e10cSrcweir { 189cdf0e10cSrcweir DBG_CTOR( RoadmapWizard, CheckInvariants ); 190cdf0e10cSrcweir impl_construct(); 191cdf0e10cSrcweir } 192cdf0e10cSrcweir 193cdf0e10cSrcweir //-------------------------------------------------------------------- impl_construct()194cdf0e10cSrcweir void RoadmapWizard::impl_construct() 195cdf0e10cSrcweir { 196cdf0e10cSrcweir SetLeftAlignedButtonCount( 1 ); 197cdf0e10cSrcweir SetEmptyViewMargin(); 198cdf0e10cSrcweir 199cdf0e10cSrcweir m_pImpl->pRoadmap = new ORoadmap( this, WB_TABSTOP ); 200cdf0e10cSrcweir m_pImpl->pRoadmap->SetText( SvtResId( STR_WIZDLG_ROADMAP_TITLE ) ); 201cdf0e10cSrcweir m_pImpl->pRoadmap->SetPosPixel( Point( 0, 0 ) ); 202cdf0e10cSrcweir m_pImpl->pRoadmap->SetItemSelectHdl( LINK( this, RoadmapWizard, OnRoadmapItemSelected ) ); 203cdf0e10cSrcweir 204cdf0e10cSrcweir Size aRoadmapSize =( LogicToPixel( Size( 85, 0 ), MAP_APPFONT ) ); 205cdf0e10cSrcweir aRoadmapSize.Height() = GetSizePixel().Height(); 206cdf0e10cSrcweir m_pImpl->pRoadmap->SetSizePixel( aRoadmapSize ); 207cdf0e10cSrcweir 208cdf0e10cSrcweir m_pImpl->pFixedLine = new FixedLine( this, WB_VERT ); 209cdf0e10cSrcweir m_pImpl->pFixedLine->Show(); 210cdf0e10cSrcweir m_pImpl->pFixedLine->SetPosPixel( Point( aRoadmapSize.Width() + 1, 0 ) ); 211cdf0e10cSrcweir m_pImpl->pFixedLine->SetSizePixel( Size( LogicToPixel( Size( 2, 0 ) ).Width(), aRoadmapSize.Height() ) ); 212cdf0e10cSrcweir 213cdf0e10cSrcweir SetViewWindow( m_pImpl->pRoadmap ); 214cdf0e10cSrcweir SetViewAlign( WINDOWALIGN_LEFT ); 215cdf0e10cSrcweir m_pImpl->pRoadmap->Show(); 216cdf0e10cSrcweir } 217cdf0e10cSrcweir 218cdf0e10cSrcweir //-------------------------------------------------------------------- ~RoadmapWizard()219cdf0e10cSrcweir RoadmapWizard::~RoadmapWizard() 220cdf0e10cSrcweir { 221cdf0e10cSrcweir delete m_pImpl; 222cdf0e10cSrcweir DBG_DTOR( RoadmapWizard, CheckInvariants ); 223cdf0e10cSrcweir } 224cdf0e10cSrcweir 225cdf0e10cSrcweir //-------------------------------------------------------------------- SetRoadmapBitmap(const BitmapEx & _rBitmap)226cdf0e10cSrcweir void RoadmapWizard::SetRoadmapBitmap( const BitmapEx& _rBitmap ) 227cdf0e10cSrcweir { 228cdf0e10cSrcweir m_pImpl->pRoadmap->SetRoadmapBitmap( _rBitmap ); 229cdf0e10cSrcweir } 230cdf0e10cSrcweir 231cdf0e10cSrcweir //-------------------------------------------------------------------- GetRoadmapBitmap() const232cdf0e10cSrcweir const BitmapEx& RoadmapWizard::GetRoadmapBitmap( ) const 233cdf0e10cSrcweir { 234cdf0e10cSrcweir return m_pImpl->pRoadmap->GetRoadmapBitmap(); 235cdf0e10cSrcweir } 236cdf0e10cSrcweir 237cdf0e10cSrcweir //-------------------------------------------------------------------- SetRoadmapHelpId(const rtl::OString & _rId)238cdf0e10cSrcweir void RoadmapWizard::SetRoadmapHelpId( const rtl::OString& _rId ) 239cdf0e10cSrcweir { 240cdf0e10cSrcweir m_pImpl->pRoadmap->SetHelpId( _rId ); 241cdf0e10cSrcweir } 242cdf0e10cSrcweir 243cdf0e10cSrcweir //-------------------------------------------------------------------- GetRoadmapHelpId() const244cdf0e10cSrcweir const rtl::OString& RoadmapWizard::GetRoadmapHelpId() const 245cdf0e10cSrcweir { 246cdf0e10cSrcweir return m_pImpl->pRoadmap->GetHelpId(); 247cdf0e10cSrcweir } 248cdf0e10cSrcweir 249cdf0e10cSrcweir //-------------------------------------------------------------------- SetRoadmapInteractive(sal_Bool _bInteractive)250cdf0e10cSrcweir void RoadmapWizard::SetRoadmapInteractive( sal_Bool _bInteractive ) 251cdf0e10cSrcweir { 252cdf0e10cSrcweir m_pImpl->pRoadmap->SetRoadmapInteractive( _bInteractive ); 253cdf0e10cSrcweir } 254cdf0e10cSrcweir 255cdf0e10cSrcweir //-------------------------------------------------------------------- IsRoadmapInteractive()256cdf0e10cSrcweir sal_Bool RoadmapWizard::IsRoadmapInteractive() 257cdf0e10cSrcweir { 258cdf0e10cSrcweir return m_pImpl->pRoadmap->IsRoadmapInteractive(); 259cdf0e10cSrcweir } 260cdf0e10cSrcweir 261cdf0e10cSrcweir //-------------------------------------------------------------------- declarePath(PathId _nPathId,const WizardPath & _lWizardStates)262cdf0e10cSrcweir void RoadmapWizard::declarePath( PathId _nPathId, const WizardPath& _lWizardStates) 263cdf0e10cSrcweir { 264cdf0e10cSrcweir DBG_CHKTHIS( RoadmapWizard, CheckInvariants ); 265cdf0e10cSrcweir 266cdf0e10cSrcweir m_pImpl->aPaths.insert( Paths::value_type( _nPathId, _lWizardStates ) ); 267cdf0e10cSrcweir 268cdf0e10cSrcweir if ( m_pImpl->aPaths.size() == 1 ) 269cdf0e10cSrcweir // the very first path -> activate it 270cdf0e10cSrcweir activatePath( _nPathId, false ); 271cdf0e10cSrcweir else 272cdf0e10cSrcweir implUpdateRoadmap( ); 273cdf0e10cSrcweir } 274cdf0e10cSrcweir 275cdf0e10cSrcweir //-------------------------------------------------------------------- declarePath(PathId _nPathId,WizardState _nFirstState,...)276cdf0e10cSrcweir void RoadmapWizard::declarePath( PathId _nPathId, WizardState _nFirstState, ... ) 277cdf0e10cSrcweir { 278cdf0e10cSrcweir DBG_CHKTHIS( RoadmapWizard, CheckInvariants ); 279cdf0e10cSrcweir 280cdf0e10cSrcweir DBG_ASSERT( _nFirstState != WZS_INVALID_STATE, "RoadmapWizard::declarePath: there should be at least one state in the path!" ); 281cdf0e10cSrcweir if ( _nFirstState == WZS_INVALID_STATE ) 282cdf0e10cSrcweir return; 283cdf0e10cSrcweir 284cdf0e10cSrcweir WizardPath aNewPath; 285cdf0e10cSrcweir 286cdf0e10cSrcweir // collect the elements of the path 287cdf0e10cSrcweir va_list aStateList; 288cdf0e10cSrcweir va_start( aStateList, _nFirstState ); 289cdf0e10cSrcweir 290cdf0e10cSrcweir WizardState nState = _nFirstState; 291cdf0e10cSrcweir while ( nState != WZS_INVALID_STATE ) 292cdf0e10cSrcweir { 293cdf0e10cSrcweir aNewPath.push_back( nState ); 294cdf0e10cSrcweir nState = sal::static_int_cast< WizardState >( 295cdf0e10cSrcweir va_arg( aStateList, int )); 296cdf0e10cSrcweir } 297cdf0e10cSrcweir va_end( aStateList ); 298cdf0e10cSrcweir 299cdf0e10cSrcweir DBG_ASSERT( _nFirstState == 0, "RoadmapWizard::declarePath: first state must be NULL." ); 300cdf0e10cSrcweir // The WizardDialog (our very base class) always starts with a mnCurLevel == 0 301cdf0e10cSrcweir 302cdf0e10cSrcweir declarePath( _nPathId, aNewPath ); 303cdf0e10cSrcweir } 304cdf0e10cSrcweir 305cdf0e10cSrcweir //-------------------------------------------------------------------- describeState(WizardState _nState,const String & _rStateDisplayName,RoadmapPageFactory _pPageFactory)306cdf0e10cSrcweir void RoadmapWizard::describeState( WizardState _nState, const String& _rStateDisplayName, RoadmapPageFactory _pPageFactory ) 307cdf0e10cSrcweir { 308cdf0e10cSrcweir OSL_ENSURE( m_pImpl->aStateDescriptors.find( _nState ) == m_pImpl->aStateDescriptors.end(), 309cdf0e10cSrcweir "RoadmapWizard::describeState: there already is a descriptor for this state!" ); 310cdf0e10cSrcweir m_pImpl->aStateDescriptors[ _nState ] = StateDescriptions::mapped_type( _rStateDisplayName, _pPageFactory ); 311cdf0e10cSrcweir } 312cdf0e10cSrcweir 313cdf0e10cSrcweir //-------------------------------------------------------------------- activatePath(PathId _nPathId,bool _bDecideForIt)314cdf0e10cSrcweir void RoadmapWizard::activatePath( PathId _nPathId, bool _bDecideForIt ) 315cdf0e10cSrcweir { 316cdf0e10cSrcweir DBG_CHKTHIS( RoadmapWizard, CheckInvariants ); 317cdf0e10cSrcweir 318cdf0e10cSrcweir if ( ( _nPathId == m_pImpl->nActivePath ) && ( _bDecideForIt == m_pImpl->bActivePathIsDefinite ) ) 319cdf0e10cSrcweir // nothing to do 320cdf0e10cSrcweir return; 321cdf0e10cSrcweir 322cdf0e10cSrcweir // does the given path exist? 323cdf0e10cSrcweir Paths::const_iterator aNewPathPos = m_pImpl->aPaths.find( _nPathId ); 324cdf0e10cSrcweir DBG_ASSERT( aNewPathPos != m_pImpl->aPaths.end(), "RoadmapWizard::activate: there is no such path!" ); 325cdf0e10cSrcweir if ( aNewPathPos == m_pImpl->aPaths.end() ) 326cdf0e10cSrcweir return; 327cdf0e10cSrcweir 328cdf0e10cSrcweir // determine the index of the current state in the current path 329cdf0e10cSrcweir sal_Int32 nCurrentStatePathIndex = -1; 330cdf0e10cSrcweir if ( m_pImpl->nActivePath != -1 ) 331cdf0e10cSrcweir nCurrentStatePathIndex = m_pImpl->getStateIndexInPath( getCurrentState(), m_pImpl->nActivePath ); 332cdf0e10cSrcweir 333cdf0e10cSrcweir DBG_ASSERT( (sal_Int32)aNewPathPos->second.size() > nCurrentStatePathIndex, 334cdf0e10cSrcweir "RoadmapWizard::activate: you cannot activate a path which has less states than we've already advanced!" ); 335cdf0e10cSrcweir // If this asserts, this for instance means that we are already in state number, say, 5 336cdf0e10cSrcweir // of our current path, and the caller tries to activate a path which has less than 5 337cdf0e10cSrcweir // states 338cdf0e10cSrcweir if ( (sal_Int32)aNewPathPos->second.size() <= nCurrentStatePathIndex ) 339cdf0e10cSrcweir return; 340cdf0e10cSrcweir 341cdf0e10cSrcweir // assert that the current and the new path are equal, up to nCurrentStatePathIndex 342cdf0e10cSrcweir Paths::const_iterator aActivePathPos = m_pImpl->aPaths.find( m_pImpl->nActivePath ); 343cdf0e10cSrcweir if ( aActivePathPos != m_pImpl->aPaths.end() ) 344cdf0e10cSrcweir { 345cdf0e10cSrcweir if ( m_pImpl->getFirstDifferentIndex( aActivePathPos->second, aNewPathPos->second ) <= nCurrentStatePathIndex ) 346cdf0e10cSrcweir { 347cdf0e10cSrcweir OSL_ENSURE( false, "RoadmapWizard::activate: you cannot activate a path which conflicts with the current one *before* the current state!" ); 348cdf0e10cSrcweir return; 349cdf0e10cSrcweir } 350cdf0e10cSrcweir } 351cdf0e10cSrcweir 352cdf0e10cSrcweir m_pImpl->nActivePath = _nPathId; 353cdf0e10cSrcweir m_pImpl->bActivePathIsDefinite = _bDecideForIt; 354cdf0e10cSrcweir 355cdf0e10cSrcweir implUpdateRoadmap( ); 356cdf0e10cSrcweir } 357cdf0e10cSrcweir 358cdf0e10cSrcweir //-------------------------------------------------------------------- implUpdateRoadmap()359cdf0e10cSrcweir void RoadmapWizard::implUpdateRoadmap( ) 360cdf0e10cSrcweir { 361cdf0e10cSrcweir DBG_CHKTHIS( RoadmapWizard, CheckInvariants ); 362cdf0e10cSrcweir 363cdf0e10cSrcweir DBG_ASSERT( m_pImpl->aPaths.find( m_pImpl->nActivePath ) != m_pImpl->aPaths.end(), 364cdf0e10cSrcweir "RoadmapWizard::implUpdateRoadmap: there is no such path!" ); 365cdf0e10cSrcweir const WizardPath& rActivePath( m_pImpl->aPaths[ m_pImpl->nActivePath ] ); 366cdf0e10cSrcweir 367cdf0e10cSrcweir sal_Int32 nCurrentStatePathIndex = m_pImpl->getStateIndexInPath( getCurrentState(), rActivePath ); 368cdf0e10cSrcweir 369cdf0e10cSrcweir // determine up to which index (in the new path) we have to display the items 370cdf0e10cSrcweir RoadmapTypes::ItemIndex nUpperStepBoundary = (RoadmapTypes::ItemIndex)rActivePath.size(); 371cdf0e10cSrcweir sal_Bool bIncompletePath = sal_False; 372cdf0e10cSrcweir if ( !m_pImpl->bActivePathIsDefinite ) 373cdf0e10cSrcweir { 374cdf0e10cSrcweir for ( Paths::const_iterator aPathPos = m_pImpl->aPaths.begin(); 375cdf0e10cSrcweir aPathPos != m_pImpl->aPaths.end(); 376cdf0e10cSrcweir ++aPathPos 377cdf0e10cSrcweir ) 378cdf0e10cSrcweir { 379cdf0e10cSrcweir if ( aPathPos->first == m_pImpl->nActivePath ) 380cdf0e10cSrcweir // it's the path we are just activating -> no need to check anything 381cdf0e10cSrcweir continue; 382cdf0e10cSrcweir // the index from which on both paths differ 383cdf0e10cSrcweir sal_Int32 nDivergenceIndex = m_pImpl->getFirstDifferentIndex( rActivePath, aPathPos->second ); 384cdf0e10cSrcweir if ( nDivergenceIndex <= nCurrentStatePathIndex ) 385cdf0e10cSrcweir // they differ in an index which we have already left behind us 386cdf0e10cSrcweir // -> this is no conflict anymore 387cdf0e10cSrcweir continue; 388cdf0e10cSrcweir 389cdf0e10cSrcweir // the path conflicts with our new path -> don't activate the 390cdf0e10cSrcweir // *complete* new path, but only up to the step which is unambiguous 391cdf0e10cSrcweir nUpperStepBoundary = nDivergenceIndex; 392cdf0e10cSrcweir bIncompletePath = sal_True; 393cdf0e10cSrcweir } 394cdf0e10cSrcweir } 395cdf0e10cSrcweir 396cdf0e10cSrcweir // can we advance from the current page? 397cdf0e10cSrcweir bool bCurrentPageCanAdvance = true; 398cdf0e10cSrcweir TabPage* pCurrentPage = GetPage( getCurrentState() ); 399cdf0e10cSrcweir if ( pCurrentPage ) 400cdf0e10cSrcweir { 401cdf0e10cSrcweir const IWizardPageController* pController = getPageController( GetPage( getCurrentState() ) ); 402cdf0e10cSrcweir OSL_ENSURE( pController != NULL, "RoadmapWizard::implUpdateRoadmap: no controller for the current page!" ); 403cdf0e10cSrcweir bCurrentPageCanAdvance = !pController || pController->canAdvance(); 404cdf0e10cSrcweir } 405cdf0e10cSrcweir 406cdf0e10cSrcweir // now, we have to remove all items after nCurrentStatePathIndex, and insert the items from the active 407cdf0e10cSrcweir // path, up to (excluding) nUpperStepBoundary 408cdf0e10cSrcweir RoadmapTypes::ItemIndex nLoopUntil = ::std::max( (RoadmapTypes::ItemIndex)nUpperStepBoundary, m_pImpl->pRoadmap->GetItemCount() ); 409cdf0e10cSrcweir for ( RoadmapTypes::ItemIndex nItemIndex = nCurrentStatePathIndex; nItemIndex < nLoopUntil; ++nItemIndex ) 410cdf0e10cSrcweir { 411cdf0e10cSrcweir bool bExistentItem = ( nItemIndex < m_pImpl->pRoadmap->GetItemCount() ); 412cdf0e10cSrcweir bool bNeedItem = ( nItemIndex < nUpperStepBoundary ); 413cdf0e10cSrcweir 414cdf0e10cSrcweir bool bInsertItem = false; 415cdf0e10cSrcweir if ( bExistentItem ) 416cdf0e10cSrcweir { 417cdf0e10cSrcweir if ( !bNeedItem ) 418cdf0e10cSrcweir { 419cdf0e10cSrcweir while ( nItemIndex < m_pImpl->pRoadmap->GetItemCount() ) 420cdf0e10cSrcweir m_pImpl->pRoadmap->DeleteRoadmapItem( nItemIndex ); 421cdf0e10cSrcweir break; 422cdf0e10cSrcweir } 423cdf0e10cSrcweir else 424cdf0e10cSrcweir { 425cdf0e10cSrcweir // there is an item with this index in the roadmap - does it match what is requested by 426cdf0e10cSrcweir // the respective state in the active path? 427cdf0e10cSrcweir RoadmapTypes::ItemId nPresentItemId = m_pImpl->pRoadmap->GetItemID( nItemIndex ); 428cdf0e10cSrcweir WizardState nRequiredState = rActivePath[ nItemIndex ]; 429cdf0e10cSrcweir if ( nPresentItemId != nRequiredState ) 430cdf0e10cSrcweir { 431cdf0e10cSrcweir m_pImpl->pRoadmap->DeleteRoadmapItem( nItemIndex ); 432cdf0e10cSrcweir bInsertItem = true; 433cdf0e10cSrcweir } 434cdf0e10cSrcweir } 435cdf0e10cSrcweir } 436cdf0e10cSrcweir else 437cdf0e10cSrcweir { 438cdf0e10cSrcweir DBG_ASSERT( bNeedItem, "RoadmapWizard::implUpdateRoadmap: ehm - none needed, none present - why did the loop not terminate?" ); 439cdf0e10cSrcweir bInsertItem = bNeedItem; 440cdf0e10cSrcweir } 441cdf0e10cSrcweir 442cdf0e10cSrcweir WizardState nState( rActivePath[ nItemIndex ] ); 443cdf0e10cSrcweir if ( bInsertItem ) 444cdf0e10cSrcweir { 445cdf0e10cSrcweir m_pImpl->pRoadmap->InsertRoadmapItem( 446cdf0e10cSrcweir nItemIndex, 447cdf0e10cSrcweir getStateDisplayName( nState ), 448cdf0e10cSrcweir nState 449cdf0e10cSrcweir ); 450cdf0e10cSrcweir } 451cdf0e10cSrcweir 452cdf0e10cSrcweir // if the item is *after* the current state, but the current page does not 453cdf0e10cSrcweir // allow advancing, the disable the state. This relieves derived classes 454cdf0e10cSrcweir // from disabling all future states just because the current state does not 455cdf0e10cSrcweir // (yet) allow advancing. 456cdf0e10cSrcweir const bool nUnconditionedDisable = !bCurrentPageCanAdvance && ( nItemIndex > nCurrentStatePathIndex ); 457cdf0e10cSrcweir const bool bEnable = !nUnconditionedDisable && ( m_pImpl->aDisabledStates.find( nState ) == m_pImpl->aDisabledStates.end() ); 458cdf0e10cSrcweir 459cdf0e10cSrcweir m_pImpl->pRoadmap->EnableRoadmapItem( m_pImpl->pRoadmap->GetItemID( nItemIndex ), bEnable ); 460cdf0e10cSrcweir } 461cdf0e10cSrcweir 462cdf0e10cSrcweir m_pImpl->pRoadmap->SetRoadmapComplete( !bIncompletePath ); 463cdf0e10cSrcweir } 464cdf0e10cSrcweir 465cdf0e10cSrcweir //-------------------------------------------------------------------- determineNextState(WizardState _nCurrentState) const466cdf0e10cSrcweir WizardTypes::WizardState RoadmapWizard::determineNextState( WizardState _nCurrentState ) const 467cdf0e10cSrcweir { 468cdf0e10cSrcweir DBG_CHKTHIS( RoadmapWizard, CheckInvariants ); 469cdf0e10cSrcweir 470cdf0e10cSrcweir sal_Int32 nCurrentStatePathIndex = -1; 471cdf0e10cSrcweir 472cdf0e10cSrcweir Paths::const_iterator aActivePathPos = m_pImpl->aPaths.find( m_pImpl->nActivePath ); 473cdf0e10cSrcweir if ( aActivePathPos != m_pImpl->aPaths.end() ) 474cdf0e10cSrcweir nCurrentStatePathIndex = m_pImpl->getStateIndexInPath( _nCurrentState, aActivePathPos->second ); 475cdf0e10cSrcweir 476cdf0e10cSrcweir DBG_ASSERT( nCurrentStatePathIndex != -1, "RoadmapWizard::determineNextState: ehm - how can we travel if there is no (valid) active path?" ); 477cdf0e10cSrcweir if ( nCurrentStatePathIndex == -1 ) 478cdf0e10cSrcweir return WZS_INVALID_STATE; 479cdf0e10cSrcweir 480cdf0e10cSrcweir sal_Int32 nNextStateIndex = nCurrentStatePathIndex + 1; 481cdf0e10cSrcweir 482cdf0e10cSrcweir while ( ( nNextStateIndex < (sal_Int32)aActivePathPos->second.size() ) 483cdf0e10cSrcweir && ( m_pImpl->aDisabledStates.find( aActivePathPos->second[ nNextStateIndex ] ) != m_pImpl->aDisabledStates.end() ) 484cdf0e10cSrcweir ) 485cdf0e10cSrcweir { 486cdf0e10cSrcweir ++nNextStateIndex; 487cdf0e10cSrcweir } 488cdf0e10cSrcweir 489cdf0e10cSrcweir if ( nNextStateIndex >= (sal_Int32)aActivePathPos->second.size() ) 490cdf0e10cSrcweir // there is no next state in the current path (at least none which is enabled) 491cdf0e10cSrcweir return WZS_INVALID_STATE; 492cdf0e10cSrcweir 493cdf0e10cSrcweir return aActivePathPos->second[ nNextStateIndex ]; 494cdf0e10cSrcweir } 495cdf0e10cSrcweir 496cdf0e10cSrcweir //--------------------------------------------------------------------- canAdvance() const497cdf0e10cSrcweir bool RoadmapWizard::canAdvance() const 498cdf0e10cSrcweir { 499cdf0e10cSrcweir if ( !m_pImpl->bActivePathIsDefinite ) 500cdf0e10cSrcweir { 501cdf0e10cSrcweir // check how many paths are still allowed 502cdf0e10cSrcweir const WizardPath& rActivePath( m_pImpl->aPaths[ m_pImpl->nActivePath ] ); 503cdf0e10cSrcweir sal_Int32 nCurrentStatePathIndex = m_pImpl->getStateIndexInPath( getCurrentState(), rActivePath ); 504cdf0e10cSrcweir 505cdf0e10cSrcweir size_t nPossiblePaths(0); 506cdf0e10cSrcweir for ( Paths::const_iterator aPathPos = m_pImpl->aPaths.begin(); 507cdf0e10cSrcweir aPathPos != m_pImpl->aPaths.end(); 508cdf0e10cSrcweir ++aPathPos 509cdf0e10cSrcweir ) 510cdf0e10cSrcweir { 511cdf0e10cSrcweir // the index from which on both paths differ 512cdf0e10cSrcweir sal_Int32 nDivergenceIndex = m_pImpl->getFirstDifferentIndex( rActivePath, aPathPos->second ); 513cdf0e10cSrcweir 514cdf0e10cSrcweir if ( nDivergenceIndex > nCurrentStatePathIndex ) 515cdf0e10cSrcweir // this path is still a possible path 516cdf0e10cSrcweir nPossiblePaths += 1; 517cdf0e10cSrcweir } 518cdf0e10cSrcweir 519cdf0e10cSrcweir // if we have more than one path which is still possible, then we assume 520cdf0e10cSrcweir // to always have a next state. Though there might be scenarios where this 521cdf0e10cSrcweir // is not true, but this is too sophisticated (means not really needed) right now. 522cdf0e10cSrcweir if ( nPossiblePaths > 1 ) 523cdf0e10cSrcweir return true; 524cdf0e10cSrcweir } 525cdf0e10cSrcweir 526cdf0e10cSrcweir const WizardPath& rPath = m_pImpl->aPaths[ m_pImpl->nActivePath ]; 527cdf0e10cSrcweir if ( *rPath.rbegin() == getCurrentState() ) 528cdf0e10cSrcweir return false; 529cdf0e10cSrcweir 530cdf0e10cSrcweir return true; 531cdf0e10cSrcweir } 532cdf0e10cSrcweir 533cdf0e10cSrcweir //--------------------------------------------------------------------- updateTravelUI()534cdf0e10cSrcweir void RoadmapWizard::updateTravelUI() 535cdf0e10cSrcweir { 536cdf0e10cSrcweir OWizardMachine::updateTravelUI(); 537cdf0e10cSrcweir 538cdf0e10cSrcweir // disable the "Previous" button if all states in our history are disabled 539cdf0e10cSrcweir ::std::vector< WizardState > aHistory; 540cdf0e10cSrcweir getStateHistory( aHistory ); 541cdf0e10cSrcweir bool bHaveEnabledState = false; 542cdf0e10cSrcweir for ( ::std::vector< WizardState >::const_iterator state = aHistory.begin(); 543cdf0e10cSrcweir state != aHistory.end() && !bHaveEnabledState; 544cdf0e10cSrcweir ++state 545cdf0e10cSrcweir ) 546cdf0e10cSrcweir { 547cdf0e10cSrcweir if ( isStateEnabled( *state ) ) 548cdf0e10cSrcweir bHaveEnabledState = true; 549cdf0e10cSrcweir } 550cdf0e10cSrcweir 551cdf0e10cSrcweir enableButtons( WZB_PREVIOUS, bHaveEnabledState ); 552cdf0e10cSrcweir 553cdf0e10cSrcweir implUpdateRoadmap(); 554cdf0e10cSrcweir } 555cdf0e10cSrcweir 556cdf0e10cSrcweir //-------------------------------------------------------------------- IMPL_LINK(RoadmapWizard,OnRoadmapItemSelected,void *,EMPTYARG)557cdf0e10cSrcweir IMPL_LINK( RoadmapWizard, OnRoadmapItemSelected, void*, EMPTYARG ) 558cdf0e10cSrcweir { 559cdf0e10cSrcweir DBG_CHKTHIS( RoadmapWizard, CheckInvariants ); 560cdf0e10cSrcweir 561cdf0e10cSrcweir RoadmapTypes::ItemId nCurItemId = m_pImpl->pRoadmap->GetCurrentRoadmapItemID(); 562cdf0e10cSrcweir if ( nCurItemId == getCurrentState() ) 563cdf0e10cSrcweir // nothing to do 564cdf0e10cSrcweir return 1L; 565cdf0e10cSrcweir 566cdf0e10cSrcweir if ( isTravelingSuspended() ) 567cdf0e10cSrcweir return 0; 568cdf0e10cSrcweir 569cdf0e10cSrcweir WizardTravelSuspension aTravelGuard( *this ); 570cdf0e10cSrcweir 571cdf0e10cSrcweir sal_Int32 nCurrentIndex = m_pImpl->getStateIndexInPath( getCurrentState(), m_pImpl->nActivePath ); 572cdf0e10cSrcweir sal_Int32 nNewIndex = m_pImpl->getStateIndexInPath( nCurItemId, m_pImpl->nActivePath ); 573cdf0e10cSrcweir 574cdf0e10cSrcweir DBG_ASSERT( ( nCurrentIndex != -1 ) && ( nNewIndex != -1 ), 575cdf0e10cSrcweir "RoadmapWizard::OnRoadmapItemSelected: something's wrong here!" ); 576cdf0e10cSrcweir if ( ( nCurrentIndex == -1 ) || ( nNewIndex == -1 ) ) 577cdf0e10cSrcweir { 578cdf0e10cSrcweir return 0L; 579cdf0e10cSrcweir } 580cdf0e10cSrcweir 581cdf0e10cSrcweir sal_Bool bResult = sal_True; 582cdf0e10cSrcweir if ( nNewIndex > nCurrentIndex ) 583cdf0e10cSrcweir { 584cdf0e10cSrcweir bResult = skipUntil( (WizardState)nCurItemId ); 585cdf0e10cSrcweir WizardState nTemp = (WizardState)nCurItemId; 586cdf0e10cSrcweir while( nTemp ) 587cdf0e10cSrcweir { 588cdf0e10cSrcweir if( m_pImpl->aDisabledStates.find( --nTemp ) != m_pImpl->aDisabledStates.end() ) 589cdf0e10cSrcweir removePageFromHistory( nTemp ); 590cdf0e10cSrcweir } 591cdf0e10cSrcweir } 592cdf0e10cSrcweir else 593cdf0e10cSrcweir bResult = skipBackwardUntil( (WizardState)nCurItemId ); 594cdf0e10cSrcweir 595cdf0e10cSrcweir if ( !bResult ) 596cdf0e10cSrcweir m_pImpl->pRoadmap->SelectRoadmapItemByID( getCurrentState() ); 597cdf0e10cSrcweir 598cdf0e10cSrcweir return 1L; 599cdf0e10cSrcweir } 600cdf0e10cSrcweir 601cdf0e10cSrcweir //-------------------------------------------------------------------- enterState(WizardState _nState)602cdf0e10cSrcweir void RoadmapWizard::enterState( WizardState _nState ) 603cdf0e10cSrcweir { 604cdf0e10cSrcweir DBG_CHKTHIS( RoadmapWizard, CheckInvariants ); 605cdf0e10cSrcweir 606cdf0e10cSrcweir OWizardMachine::enterState( _nState ); 607cdf0e10cSrcweir 608cdf0e10cSrcweir // synchronize the roadmap 609cdf0e10cSrcweir implUpdateRoadmap( ); 610cdf0e10cSrcweir m_pImpl->pRoadmap->SelectRoadmapItemByID( getCurrentState() ); 611cdf0e10cSrcweir } 612cdf0e10cSrcweir 613cdf0e10cSrcweir //-------------------------------------------------------------------- getStateDisplayName(WizardState _nState) const614cdf0e10cSrcweir String RoadmapWizard::getStateDisplayName( WizardState _nState ) const 615cdf0e10cSrcweir { 616cdf0e10cSrcweir String sDisplayName; 617cdf0e10cSrcweir 618cdf0e10cSrcweir StateDescriptions::const_iterator pos = m_pImpl->aStateDescriptors.find( _nState ); 619cdf0e10cSrcweir OSL_ENSURE( pos != m_pImpl->aStateDescriptors.end(), 620cdf0e10cSrcweir "RoadmapWizard::getStateDisplayName: no default implementation available for this state!" ); 621cdf0e10cSrcweir if ( pos != m_pImpl->aStateDescriptors.end() ) 622cdf0e10cSrcweir sDisplayName = pos->second.first; 623cdf0e10cSrcweir 624cdf0e10cSrcweir return sDisplayName; 625cdf0e10cSrcweir } 626cdf0e10cSrcweir 627cdf0e10cSrcweir //-------------------------------------------------------------------- createPage(WizardState _nState)628cdf0e10cSrcweir TabPage* RoadmapWizard::createPage( WizardState _nState ) 629cdf0e10cSrcweir { 630cdf0e10cSrcweir TabPage* pPage( NULL ); 631cdf0e10cSrcweir 632cdf0e10cSrcweir StateDescriptions::const_iterator pos = m_pImpl->aStateDescriptors.find( _nState ); 633cdf0e10cSrcweir OSL_ENSURE( pos != m_pImpl->aStateDescriptors.end(), 634cdf0e10cSrcweir "RoadmapWizard::createPage: no default implementation available for this state!" ); 635cdf0e10cSrcweir if ( pos != m_pImpl->aStateDescriptors.end() ) 636cdf0e10cSrcweir { 637cdf0e10cSrcweir RoadmapPageFactory pFactory = pos->second.second; 638cdf0e10cSrcweir pPage = (*pFactory)( *this ); 639cdf0e10cSrcweir } 640cdf0e10cSrcweir 641cdf0e10cSrcweir return pPage; 642cdf0e10cSrcweir } 643cdf0e10cSrcweir 644cdf0e10cSrcweir //-------------------------------------------------------------------- enableState(WizardState _nState,bool _bEnable)645cdf0e10cSrcweir void RoadmapWizard::enableState( WizardState _nState, bool _bEnable ) 646cdf0e10cSrcweir { 647cdf0e10cSrcweir DBG_CHKTHIS( RoadmapWizard, CheckInvariants ); 648cdf0e10cSrcweir 649cdf0e10cSrcweir // remember this (in case the state appears in the roadmap later on) 650cdf0e10cSrcweir if ( _bEnable ) 651cdf0e10cSrcweir m_pImpl->aDisabledStates.erase( _nState ); 652cdf0e10cSrcweir else 653cdf0e10cSrcweir { 654cdf0e10cSrcweir m_pImpl->aDisabledStates.insert( _nState ); 655cdf0e10cSrcweir removePageFromHistory( _nState ); 656cdf0e10cSrcweir } 657cdf0e10cSrcweir 658cdf0e10cSrcweir // if the state is currently in the roadmap, reflect it's new status 659cdf0e10cSrcweir m_pImpl->pRoadmap->EnableRoadmapItem( (RoadmapTypes::ItemId)_nState, _bEnable ); 660cdf0e10cSrcweir } 661cdf0e10cSrcweir 662cdf0e10cSrcweir //-------------------------------------------------------------------- knowsState(WizardState i_nState) const663cdf0e10cSrcweir bool RoadmapWizard::knowsState( WizardState i_nState ) const 664cdf0e10cSrcweir { 665cdf0e10cSrcweir for ( Paths::const_iterator path = m_pImpl->aPaths.begin(); 666cdf0e10cSrcweir path != m_pImpl->aPaths.end(); 667cdf0e10cSrcweir ++path 668cdf0e10cSrcweir ) 669cdf0e10cSrcweir { 670cdf0e10cSrcweir for ( WizardPath::const_iterator state = path->second.begin(); 671cdf0e10cSrcweir state != path->second.end(); 672cdf0e10cSrcweir ++state 673cdf0e10cSrcweir ) 674cdf0e10cSrcweir { 675cdf0e10cSrcweir if ( *state == i_nState ) 676cdf0e10cSrcweir return true; 677cdf0e10cSrcweir } 678cdf0e10cSrcweir } 679cdf0e10cSrcweir return false; 680cdf0e10cSrcweir } 681cdf0e10cSrcweir 682cdf0e10cSrcweir //-------------------------------------------------------------------- isStateEnabled(WizardState _nState) const683cdf0e10cSrcweir bool RoadmapWizard::isStateEnabled( WizardState _nState ) const 684cdf0e10cSrcweir { 685cdf0e10cSrcweir return m_pImpl->aDisabledStates.find( _nState ) == m_pImpl->aDisabledStates.end(); 686cdf0e10cSrcweir } 687cdf0e10cSrcweir 688cdf0e10cSrcweir //-------------------------------------------------------------------- Resize()689cdf0e10cSrcweir void RoadmapWizard::Resize() 690cdf0e10cSrcweir { 691cdf0e10cSrcweir OWizardMachine::Resize(); 692cdf0e10cSrcweir 693cdf0e10cSrcweir if ( IsReallyShown() && !IsInInitShow() ) 694cdf0e10cSrcweir ResizeFixedLine(); 695cdf0e10cSrcweir } 696cdf0e10cSrcweir 697cdf0e10cSrcweir 698cdf0e10cSrcweir //-------------------------------------------------------------------- StateChanged(StateChangedType nType)699cdf0e10cSrcweir void RoadmapWizard::StateChanged( StateChangedType nType ) 700cdf0e10cSrcweir { 701cdf0e10cSrcweir WizardDialog::StateChanged( nType ); 702cdf0e10cSrcweir 703cdf0e10cSrcweir if ( nType == STATE_CHANGE_INITSHOW ) 704cdf0e10cSrcweir ResizeFixedLine(); 705cdf0e10cSrcweir } 706cdf0e10cSrcweir 707cdf0e10cSrcweir //-------------------------------------------------------------------- ResizeFixedLine()708cdf0e10cSrcweir void RoadmapWizard::ResizeFixedLine() 709cdf0e10cSrcweir { 710cdf0e10cSrcweir Size aSize( m_pImpl->pRoadmap->GetSizePixel() ); 711cdf0e10cSrcweir aSize.Width() = m_pImpl->pFixedLine->GetSizePixel().Width(); 712cdf0e10cSrcweir m_pImpl->pFixedLine->SetSizePixel( aSize ); 713cdf0e10cSrcweir } 714cdf0e10cSrcweir 715cdf0e10cSrcweir //-------------------------------------------------------------------- updateRoadmapItemLabel(WizardState _nState)716cdf0e10cSrcweir void RoadmapWizard::updateRoadmapItemLabel( WizardState _nState ) 717cdf0e10cSrcweir { 718cdf0e10cSrcweir const WizardPath& rActivePath( m_pImpl->aPaths[ m_pImpl->nActivePath ] ); 719cdf0e10cSrcweir RoadmapTypes::ItemIndex nUpperStepBoundary = (RoadmapTypes::ItemIndex)rActivePath.size(); 720cdf0e10cSrcweir RoadmapTypes::ItemIndex nLoopUntil = ::std::max( (RoadmapTypes::ItemIndex)nUpperStepBoundary, m_pImpl->pRoadmap->GetItemCount() ); 721cdf0e10cSrcweir sal_Int32 nCurrentStatePathIndex = -1; 722cdf0e10cSrcweir if ( m_pImpl->nActivePath != -1 ) 723cdf0e10cSrcweir nCurrentStatePathIndex = m_pImpl->getStateIndexInPath( getCurrentState(), m_pImpl->nActivePath ); 724cdf0e10cSrcweir for ( RoadmapTypes::ItemIndex nItemIndex = nCurrentStatePathIndex; nItemIndex < nLoopUntil; ++nItemIndex ) 725cdf0e10cSrcweir { 726cdf0e10cSrcweir bool bExistentItem = ( nItemIndex < m_pImpl->pRoadmap->GetItemCount() ); 727cdf0e10cSrcweir if ( bExistentItem ) 728cdf0e10cSrcweir { 729cdf0e10cSrcweir // there is an item with this index in the roadmap - does it match what is requested by 730cdf0e10cSrcweir // the respective state in the active path? 731cdf0e10cSrcweir RoadmapTypes::ItemId nPresentItemId = m_pImpl->pRoadmap->GetItemID( nItemIndex ); 732cdf0e10cSrcweir WizardState nRequiredState = rActivePath[ nItemIndex ]; 733cdf0e10cSrcweir if ( _nState == nRequiredState ) 734cdf0e10cSrcweir { 735cdf0e10cSrcweir m_pImpl->pRoadmap->ChangeRoadmapItemLabel( nPresentItemId, getStateDisplayName( nRequiredState ) ); 736cdf0e10cSrcweir break; 737cdf0e10cSrcweir } 738cdf0e10cSrcweir } 739cdf0e10cSrcweir } 740cdf0e10cSrcweir } 741cdf0e10cSrcweir 742cdf0e10cSrcweir //........................................................................ 743cdf0e10cSrcweir } // namespace svt 744cdf0e10cSrcweir //........................................................................ 745