1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: roadmapwizard.cxx,v $
10 * $Revision: 1.19.10.2 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svtools.hxx"
34 #include <svtools/roadmapwizard.hxx>
35 #include <svtools/svtools.hrc>
36 #include <svtools/svtdata.hxx>
37 #include "roadmap.hxx"
38 #include <tools/debug.hxx>
46 //........................................................................
49 //........................................................................
53 typedef ::std::set
< WizardTypes::WizardState
> StateSet
;
56 RoadmapWizardTypes::PathId
,
57 RoadmapWizardTypes::WizardPath
61 WizardTypes::WizardState
,
64 RoadmapWizardTypes::RoadmapPageFactory
69 struct RoadmapWizardImpl
: public RoadmapWizardTypes
74 StateDescriptions aStateDescriptors
;
75 StateSet aDisabledStates
;
76 bool bActivePathIsDefinite
;
77 FixedLine
* pFixedLine
;
82 ,bActivePathIsDefinite( false )
93 /// returns the index of the current state in given path, or -1
94 sal_Int32
getStateIndexInPath( WizardTypes::WizardState _nState
, const WizardPath
& _rPath
);
95 /// returns the index of the current state in the path with the given id, or -1
96 sal_Int32
getStateIndexInPath( WizardTypes::WizardState _nState
, PathId _nPathId
);
97 /// returns the index of the first state in which the two given paths differ
98 sal_Int32
getFirstDifferentIndex( const WizardPath
& _rLHS
, const WizardPath
& _rRHS
);
101 //--------------------------------------------------------------------
102 sal_Int32
RoadmapWizardImpl::getStateIndexInPath( WizardTypes::WizardState _nState
, const WizardPath
& _rPath
)
104 sal_Int32 nStateIndexInPath
= 0;
105 WizardPath::const_iterator aPathLoop
= _rPath
.begin();
106 for ( ; aPathLoop
!= _rPath
.end(); ++aPathLoop
, ++nStateIndexInPath
)
107 if ( *aPathLoop
== _nState
)
109 if ( aPathLoop
== _rPath
.end() )
110 nStateIndexInPath
= -1;
111 return nStateIndexInPath
;
114 //--------------------------------------------------------------------
115 sal_Int32
RoadmapWizardImpl::getStateIndexInPath( WizardTypes::WizardState _nState
, PathId _nPathId
)
117 sal_Int32 nStateIndexInPath
= -1;
118 Paths::const_iterator aPathPos
= aPaths
.find( _nPathId
);
119 if ( aPathPos
!= aPaths
.end( ) )
120 nStateIndexInPath
= getStateIndexInPath( _nState
, aPathPos
->second
);
121 return nStateIndexInPath
;
124 //--------------------------------------------------------------------
125 sal_Int32
RoadmapWizardImpl::getFirstDifferentIndex( const WizardPath
& _rLHS
, const WizardPath
& _rRHS
)
127 sal_Int32 nMinLength
= ::std::min( _rLHS
.size(), _rRHS
.size() );
128 for ( sal_Int32 nCheck
= 0; nCheck
< nMinLength
; ++nCheck
)
130 if ( _rLHS
[ nCheck
] != _rRHS
[ nCheck
] )
136 //====================================================================
138 //====================================================================
139 DBG_NAME( RoadmapWizard
)
140 //--------------------------------------------------------------------
141 #if OSL_DEBUG_LEVEL > 0
142 const char* CheckInvariants( const void* pVoid
)
144 return static_cast< const RoadmapWizard
* >( pVoid
)->checkInvariants();
147 //--------------------------------------------------------------------
148 const sal_Char
* RoadmapWizard::checkInvariants() const
150 // all paths have to start with the same state
151 WizardState nSharedFirstState
= WZS_INVALID_STATE
;
152 for ( Paths::const_iterator aPath
= m_pImpl
->aPaths
.begin();
153 aPath
!= m_pImpl
->aPaths
.end();
157 if ( aPath
->second
.empty() )
158 return "RoadmapWizard::checkInvariants: paths should not be empty!";
160 if ( nSharedFirstState
== WZS_INVALID_STATE
)
162 nSharedFirstState
= aPath
->second
[ 0 ];
164 if ( nSharedFirstState
!= aPath
->second
[ 0 ] )
165 return "RoadmapWizard::checkInvariants: alls paths must start with the same state!";
168 if ( !m_pImpl
->aPaths
.empty() )
170 Paths::const_iterator aCurrentPathPos
= m_pImpl
->aPaths
.find( m_pImpl
->nActivePath
);
171 if ( aCurrentPathPos
== m_pImpl
->aPaths
.end() )
172 return "RoadmapWizard::checkInvariants: invalid active path!";
174 if ( -1 == m_pImpl
->getStateIndexInPath( getCurrentState(), m_pImpl
->nActivePath
) )
175 return "RoadmapWizard::checkInvariants: the current state is not part of the current path!";
182 //--------------------------------------------------------------------
183 RoadmapWizard::RoadmapWizard( Window
* _pParent
, const ResId
& _rRes
, sal_uInt32 _nButtonFlags
)
184 :OWizardMachine( _pParent
, _rRes
, _nButtonFlags
)
185 ,m_pImpl( new RoadmapWizardImpl
)
187 DBG_CTOR( RoadmapWizard
, CheckInvariants
);
189 SetLeftAlignedButtonCount( 1 );
190 SetEmptyViewMargin();
192 m_pImpl
->pRoadmap
= new ORoadmap( this, WB_TABSTOP
);
193 m_pImpl
->pRoadmap
->SetText( SvtResId( STR_WIZDLG_ROADMAP_TITLE
) );
194 m_pImpl
->pRoadmap
->SetPosPixel( Point( 0, 0 ) );
195 m_pImpl
->pRoadmap
->SetItemSelectHdl( LINK( this, RoadmapWizard
, OnRoadmapItemSelected
) );
197 Size aRoadmapSize
=( LogicToPixel( Size( 85, 0 ), MAP_APPFONT
) );
198 aRoadmapSize
.Height() = GetSizePixel().Height();
199 m_pImpl
->pRoadmap
->SetSizePixel( aRoadmapSize
);
201 m_pImpl
->pFixedLine
= new FixedLine( this, WB_VERT
);
202 m_pImpl
->pFixedLine
->Show();
203 m_pImpl
->pFixedLine
->SetPosPixel( Point( aRoadmapSize
.Width() + 1, 0 ) );
204 m_pImpl
->pFixedLine
->SetSizePixel( Size( LogicToPixel( Size( 2, 0 ) ).Width(), aRoadmapSize
.Height() ) );
206 SetViewWindow( m_pImpl
->pRoadmap
);
207 SetViewAlign( WINDOWALIGN_LEFT
);
208 m_pImpl
->pRoadmap
->Show();
211 //--------------------------------------------------------------------
212 RoadmapWizard::~RoadmapWizard()
215 DBG_DTOR( RoadmapWizard
, CheckInvariants
);
218 //--------------------------------------------------------------------
219 void RoadmapWizard::SetRoadmapBitmap( const BitmapEx
& _rBitmap
)
221 m_pImpl
->pRoadmap
->SetRoadmapBitmap( _rBitmap
);
224 //--------------------------------------------------------------------
225 const BitmapEx
& RoadmapWizard::GetRoadmapBitmap( ) const
227 return m_pImpl
->pRoadmap
->GetRoadmapBitmap();
230 //--------------------------------------------------------------------
231 void RoadmapWizard::SetRoadmapSmartHelpId( const SmartId
& _rId
, SmartIdUpdateMode _aMode
)
233 m_pImpl
->pRoadmap
->SetSmartHelpId( _rId
, _aMode
);
236 //--------------------------------------------------------------------
237 SmartId
RoadmapWizard::GetRoadmapSmartHelpId() const
239 return m_pImpl
->pRoadmap
->GetSmartHelpId();
242 //--------------------------------------------------------------------
243 void RoadmapWizard::SetRoadmapInteractive( sal_Bool _bInteractive
)
245 m_pImpl
->pRoadmap
->SetRoadmapInteractive( _bInteractive
);
248 //--------------------------------------------------------------------
249 sal_Bool
RoadmapWizard::IsRoadmapInteractive()
251 return m_pImpl
->pRoadmap
->IsRoadmapInteractive();
254 //--------------------------------------------------------------------
255 void RoadmapWizard::declarePath( PathId _nPathId
, const WizardPath
& _lWizardStates
)
257 DBG_CHKTHIS( RoadmapWizard
, CheckInvariants
);
259 m_pImpl
->aPaths
.insert( Paths::value_type( _nPathId
, _lWizardStates
) );
261 if ( m_pImpl
->aPaths
.size() == 1 )
262 // the very first path -> activate it
263 activatePath( _nPathId
, false );
265 implUpdateRoadmap( );
268 //--------------------------------------------------------------------
269 void RoadmapWizard::declarePath( PathId _nPathId
, WizardState _nFirstState
, ... )
271 DBG_CHKTHIS( RoadmapWizard
, CheckInvariants
);
273 DBG_ASSERT( _nFirstState
!= WZS_INVALID_STATE
, "RoadmapWizard::declarePath: there should be at least one state in the path!" );
274 if ( _nFirstState
== WZS_INVALID_STATE
)
279 // collect the elements of the path
281 va_start( aStateList
, _nFirstState
);
283 WizardState nState
= _nFirstState
;
284 while ( nState
!= WZS_INVALID_STATE
)
286 aNewPath
.push_back( nState
);
287 nState
= sal::static_int_cast
< WizardState
>(
288 va_arg( aStateList
, int ));
290 va_end( aStateList
);
292 DBG_ASSERT( _nFirstState
== 0, "RoadmapWizard::declarePath: first state must be NULL." );
293 // The WizardDialog (our very base class) always starts with a mnCurLevel == 0
295 declarePath( _nPathId
, aNewPath
);
298 //--------------------------------------------------------------------
299 void RoadmapWizard::describeState( WizardState _nState
, const String
& _rStateDisplayName
, RoadmapPageFactory _pPageFactory
)
301 OSL_ENSURE( m_pImpl
->aStateDescriptors
.find( _nState
) == m_pImpl
->aStateDescriptors
.end(),
302 "RoadmapWizard::describeState: there already is a descriptor for this state!" );
303 m_pImpl
->aStateDescriptors
[ _nState
] = StateDescriptions::mapped_type( _rStateDisplayName
, _pPageFactory
);
306 //--------------------------------------------------------------------
307 void RoadmapWizard::activatePath( PathId _nPathId
, bool _bDecideForIt
)
309 DBG_CHKTHIS( RoadmapWizard
, CheckInvariants
);
311 if ( ( _nPathId
== m_pImpl
->nActivePath
) && ( _bDecideForIt
== m_pImpl
->bActivePathIsDefinite
) )
315 // does the given path exist?
316 Paths::const_iterator aNewPathPos
= m_pImpl
->aPaths
.find( _nPathId
);
317 DBG_ASSERT( aNewPathPos
!= m_pImpl
->aPaths
.end(), "RoadmapWizard::activate: there is no such path!" );
318 if ( aNewPathPos
== m_pImpl
->aPaths
.end() )
321 // determine the index of the current state in the current path
322 sal_Int32 nCurrentStatePathIndex
= -1;
323 if ( m_pImpl
->nActivePath
!= -1 )
324 nCurrentStatePathIndex
= m_pImpl
->getStateIndexInPath( getCurrentState(), m_pImpl
->nActivePath
);
326 DBG_ASSERT( (sal_Int32
)aNewPathPos
->second
.size() > nCurrentStatePathIndex
,
327 "RoadmapWizard::activate: you cannot activate a path which has less states than we've already advanced!" );
328 // If this asserts, this for instance means that we are already in state number, say, 5
329 // of our current path, and the caller tries to activate a path which has less than 5
331 if ( (sal_Int32
)aNewPathPos
->second
.size() <= nCurrentStatePathIndex
)
334 #if OSL_DEBUG_LEVEL > 0
335 // assert that the current and the new path are equal, up to nCurrentStatePathIndex
336 Paths::const_iterator aActivePathPos
= m_pImpl
->aPaths
.find( m_pImpl
->nActivePath
);
337 if ( aActivePathPos
!= m_pImpl
->aPaths
.end() )
339 DBG_ASSERT( m_pImpl
->getFirstDifferentIndex( aActivePathPos
->second
, aNewPathPos
->second
) > nCurrentStatePathIndex
,
340 "RoadmapWizard::activate: you cannot activate a path which conflicts with the current one *before* the current state!" );
344 m_pImpl
->nActivePath
= _nPathId
;
345 m_pImpl
->bActivePathIsDefinite
= _bDecideForIt
;
347 implUpdateRoadmap( );
350 //--------------------------------------------------------------------
351 void RoadmapWizard::implUpdateRoadmap( )
353 DBG_CHKTHIS( RoadmapWizard
, CheckInvariants
);
355 DBG_ASSERT( m_pImpl
->aPaths
.find( m_pImpl
->nActivePath
) != m_pImpl
->aPaths
.end(),
356 "RoadmapWizard::implUpdateRoadmap: there is no such path!" );
357 const WizardPath
& rActivePath( m_pImpl
->aPaths
[ m_pImpl
->nActivePath
] );
359 sal_Int32 nCurrentStatePathIndex
= m_pImpl
->getStateIndexInPath( getCurrentState(), rActivePath
);
361 // determine up to which index (in the new path) we have to display the items
362 RoadmapTypes::ItemIndex nUpperStepBoundary
= (RoadmapTypes::ItemIndex
)rActivePath
.size();
363 sal_Bool bIncompletePath
= sal_False
;
364 if ( !m_pImpl
->bActivePathIsDefinite
)
366 for ( Paths::const_iterator aPathPos
= m_pImpl
->aPaths
.begin();
367 aPathPos
!= m_pImpl
->aPaths
.end();
371 if ( aPathPos
->first
== m_pImpl
->nActivePath
)
372 // it's the path we are just activating -> no need to check anything
374 // the index from which on both paths differ
375 sal_Int32 nDivergenceIndex
= m_pImpl
->getFirstDifferentIndex( rActivePath
, aPathPos
->second
);
376 if ( nDivergenceIndex
<= nCurrentStatePathIndex
)
377 // they differ in an index which we have already left behind us
378 // -> this is no conflict anymore
381 // the path conflicts with our new path -> don't activate the
382 // *complete* new path, but only up to the step which is unambiguous
383 nUpperStepBoundary
= nDivergenceIndex
;
384 bIncompletePath
= sal_True
;
388 // can we advance from the current page?
389 const OWizardPage
* pCurrentPage
= dynamic_cast< const OWizardPage
* >( GetPage( getCurrentState() ) );
390 const bool bCurrentPageCanAdvance
= !pCurrentPage
|| pCurrentPage
->canAdvance();
392 // now, we have to remove all items after nCurrentStatePathIndex, and insert the items from the active
393 // path, up to (excluding) nUpperStepBoundary
394 RoadmapTypes::ItemIndex nLoopUntil
= ::std::max( (RoadmapTypes::ItemIndex
)nUpperStepBoundary
, m_pImpl
->pRoadmap
->GetItemCount() );
395 for ( RoadmapTypes::ItemIndex nItemIndex
= nCurrentStatePathIndex
; nItemIndex
< nLoopUntil
; ++nItemIndex
)
397 bool bExistentItem
= ( nItemIndex
< m_pImpl
->pRoadmap
->GetItemCount() );
398 bool bNeedItem
= ( nItemIndex
< nUpperStepBoundary
);
400 bool bInsertItem
= false;
405 while ( nItemIndex
< m_pImpl
->pRoadmap
->GetItemCount() )
406 m_pImpl
->pRoadmap
->DeleteRoadmapItem( nItemIndex
);
411 // there is an item with this index in the roadmap - does it match what is requested by
412 // the respective state in the active path?
413 RoadmapTypes::ItemId nPresentItemId
= m_pImpl
->pRoadmap
->GetItemID( nItemIndex
);
414 WizardState nRequiredState
= rActivePath
[ nItemIndex
];
415 if ( nPresentItemId
!= nRequiredState
)
417 m_pImpl
->pRoadmap
->DeleteRoadmapItem( nItemIndex
);
424 DBG_ASSERT( bNeedItem
, "RoadmapWizard::implUpdateRoadmap: ehm - none needed, none present - why did the loop not terminate?" );
425 bInsertItem
= bNeedItem
;
428 WizardState
nState( rActivePath
[ nItemIndex
] );
431 m_pImpl
->pRoadmap
->InsertRoadmapItem(
433 getStateDisplayName( nState
),
438 // if the item is *after* the current state, but the current page does not
439 // allow advancing, the disable the state. This relieves derived classes
440 // from disabling all future states just because the current state does not
441 // (yet) allow advancing.
442 const bool nUnconditionedDisable
= !bCurrentPageCanAdvance
&& ( nItemIndex
> nCurrentStatePathIndex
);
443 const bool bEnable
= !nUnconditionedDisable
&& ( m_pImpl
->aDisabledStates
.find( nState
) == m_pImpl
->aDisabledStates
.end() );
445 m_pImpl
->pRoadmap
->EnableRoadmapItem( m_pImpl
->pRoadmap
->GetItemID( nItemIndex
), bEnable
);
448 m_pImpl
->pRoadmap
->SetRoadmapComplete( !bIncompletePath
);
451 //--------------------------------------------------------------------
452 WizardTypes::WizardState
RoadmapWizard::determineNextState( WizardState _nCurrentState
) const
454 DBG_CHKTHIS( RoadmapWizard
, CheckInvariants
);
456 sal_Int32 nCurrentStatePathIndex
= -1;
458 Paths::const_iterator aActivePathPos
= m_pImpl
->aPaths
.find( m_pImpl
->nActivePath
);
459 if ( aActivePathPos
!= m_pImpl
->aPaths
.end() )
460 nCurrentStatePathIndex
= m_pImpl
->getStateIndexInPath( _nCurrentState
, aActivePathPos
->second
);
462 DBG_ASSERT( nCurrentStatePathIndex
!= -1, "RoadmapWizard::determineNextState: ehm - how can we travel if there is no (valid) active path?" );
463 if ( nCurrentStatePathIndex
== -1 )
464 return WZS_INVALID_STATE
;
466 sal_Int32 nNextStateIndex
= nCurrentStatePathIndex
+ 1;
468 while ( ( nNextStateIndex
< (sal_Int32
)aActivePathPos
->second
.size() )
469 && ( m_pImpl
->aDisabledStates
.find( aActivePathPos
->second
[ nNextStateIndex
] ) != m_pImpl
->aDisabledStates
.end() )
475 if ( nNextStateIndex
>= (sal_Int32
)aActivePathPos
->second
.size() )
476 // there is no next state in the current path (at least none which is enabled)
477 return WZS_INVALID_STATE
;
479 return aActivePathPos
->second
[ nNextStateIndex
];
482 //---------------------------------------------------------------------
483 bool RoadmapWizard::canAdvance() const
485 if ( !m_pImpl
->bActivePathIsDefinite
)
487 // check how many paths are still allowed
488 const WizardPath
& rActivePath( m_pImpl
->aPaths
[ m_pImpl
->nActivePath
] );
489 sal_Int32 nCurrentStatePathIndex
= m_pImpl
->getStateIndexInPath( getCurrentState(), rActivePath
);
491 size_t nPossiblePaths(0);
492 for ( Paths::const_iterator aPathPos
= m_pImpl
->aPaths
.begin();
493 aPathPos
!= m_pImpl
->aPaths
.end();
497 // the index from which on both paths differ
498 sal_Int32 nDivergenceIndex
= m_pImpl
->getFirstDifferentIndex( rActivePath
, aPathPos
->second
);
500 if ( nDivergenceIndex
> nCurrentStatePathIndex
)
501 // this path is still a possible path
505 // if we have more than one path which is still possible, then we assume
506 // to always have a next state. Though there might be scenarios where this
507 // is not true, but this is too sophisticated (means not really needed) right now.
508 if ( nPossiblePaths
> 1 )
512 const WizardPath
& rPath
= m_pImpl
->aPaths
[ m_pImpl
->nActivePath
];
513 if ( *rPath
.rbegin() == getCurrentState() )
519 //---------------------------------------------------------------------
520 void RoadmapWizard::updateTravelUI()
522 OWizardMachine::updateTravelUI();
524 // disable the "Previous" button if all states in our history are disabled
525 ::std::vector
< WizardState
> aHistory
;
526 getStateHistory( aHistory
);
527 bool bHaveEnabledState
= false;
528 for ( ::std::vector
< WizardState
>::const_iterator state
= aHistory
.begin();
529 state
!= aHistory
.end() && !bHaveEnabledState
;
533 if ( isStateEnabled( *state
) )
534 bHaveEnabledState
= true;
537 enableButtons( WZB_PREVIOUS
, bHaveEnabledState
);
542 //--------------------------------------------------------------------
543 IMPL_LINK( RoadmapWizard
, OnRoadmapItemSelected
, void*, EMPTYARG
)
545 DBG_CHKTHIS( RoadmapWizard
, CheckInvariants
);
547 RoadmapTypes::ItemId nCurItemId
= m_pImpl
->pRoadmap
->GetCurrentRoadmapItemID();
548 if ( nCurItemId
== getCurrentState() )
552 if ( isTravelingSuspended() )
555 WizardTravelSuspension
aTravelGuard( *this );
557 sal_Int32 nCurrentIndex
= m_pImpl
->getStateIndexInPath( getCurrentState(), m_pImpl
->nActivePath
);
558 sal_Int32 nNewIndex
= m_pImpl
->getStateIndexInPath( nCurItemId
, m_pImpl
->nActivePath
);
560 DBG_ASSERT( ( nCurrentIndex
!= -1 ) && ( nNewIndex
!= -1 ),
561 "RoadmapWizard::OnRoadmapItemSelected: something's wrong here!" );
562 if ( ( nCurrentIndex
== -1 ) || ( nNewIndex
== -1 ) )
567 sal_Bool bResult
= sal_True
;
568 if ( nNewIndex
> nCurrentIndex
)
570 bResult
= skipUntil( (WizardState
)nCurItemId
);
571 WizardState nTemp
= (WizardState
)nCurItemId
;
574 if( m_pImpl
->aDisabledStates
.find( --nTemp
) != m_pImpl
->aDisabledStates
.end() )
575 removePageFromHistory( nTemp
);
579 bResult
= skipBackwardUntil( (WizardState
)nCurItemId
);
582 m_pImpl
->pRoadmap
->SelectRoadmapItemByID( getCurrentState() );
587 //--------------------------------------------------------------------
588 void RoadmapWizard::enterState( WizardState _nState
)
590 DBG_CHKTHIS( RoadmapWizard
, CheckInvariants
);
592 OWizardMachine::enterState( _nState
);
594 // synchronize the roadmap
595 implUpdateRoadmap( );
596 m_pImpl
->pRoadmap
->SelectRoadmapItemByID( getCurrentState() );
599 //--------------------------------------------------------------------
600 String
RoadmapWizard::getStateDisplayName( WizardState _nState
) const
604 StateDescriptions::const_iterator pos
= m_pImpl
->aStateDescriptors
.find( _nState
);
605 OSL_ENSURE( pos
!= m_pImpl
->aStateDescriptors
.end(),
606 "RoadmapWizard::getStateDisplayName: no default implementation available for this state!" );
607 if ( pos
!= m_pImpl
->aStateDescriptors
.end() )
608 sDisplayName
= pos
->second
.first
;
613 //--------------------------------------------------------------------
614 TabPage
* RoadmapWizard::createPage( WizardState _nState
)
616 TabPage
* pPage( NULL
);
618 StateDescriptions::const_iterator pos
= m_pImpl
->aStateDescriptors
.find( _nState
);
619 OSL_ENSURE( pos
!= m_pImpl
->aStateDescriptors
.end(),
620 "RoadmapWizard::createPage: no default implementation available for this state!" );
621 if ( pos
!= m_pImpl
->aStateDescriptors
.end() )
623 RoadmapPageFactory pFactory
= pos
->second
.second
;
624 pPage
= (*pFactory
)( *this );
630 //--------------------------------------------------------------------
631 void RoadmapWizard::enableState( WizardState _nState
, bool _bEnable
)
633 DBG_CHKTHIS( RoadmapWizard
, CheckInvariants
);
635 // remember this (in case the state appears in the roadmap later on)
637 m_pImpl
->aDisabledStates
.erase( _nState
);
640 m_pImpl
->aDisabledStates
.insert( _nState
);
641 removePageFromHistory( _nState
);
644 // if the state is currently in the roadmap, reflect it's new status
645 m_pImpl
->pRoadmap
->EnableRoadmapItem( (RoadmapTypes::ItemId
)_nState
, _bEnable
);
647 //--------------------------------------------------------------------
648 bool RoadmapWizard::isStateEnabled( WizardState _nState
) const
650 return m_pImpl
->aDisabledStates
.find( _nState
) == m_pImpl
->aDisabledStates
.end();
652 //--------------------------------------------------------------------
653 void RoadmapWizard::Resize()
655 OWizardMachine::Resize();
657 if ( IsReallyShown() && !IsInInitShow() )
662 //--------------------------------------------------------------------
663 void RoadmapWizard::StateChanged( StateChangedType nType
)
665 WizardDialog::StateChanged( nType
);
667 if ( nType
== STATE_CHANGE_INITSHOW
)
671 //--------------------------------------------------------------------
672 void RoadmapWizard::ResizeFixedLine()
674 Size
aSize( m_pImpl
->pRoadmap
->GetSizePixel() );
675 aSize
.Width() = m_pImpl
->pFixedLine
->GetSizePixel().Width();
676 m_pImpl
->pFixedLine
->SetSizePixel( aSize
);
679 //--------------------------------------------------------------------
680 void RoadmapWizard::updateRoadmapItemLabel( WizardState _nState
)
682 const WizardPath
& rActivePath( m_pImpl
->aPaths
[ m_pImpl
->nActivePath
] );
683 RoadmapTypes::ItemIndex nUpperStepBoundary
= (RoadmapTypes::ItemIndex
)rActivePath
.size();
684 RoadmapTypes::ItemIndex nLoopUntil
= ::std::max( (RoadmapTypes::ItemIndex
)nUpperStepBoundary
, m_pImpl
->pRoadmap
->GetItemCount() );
685 sal_Int32 nCurrentStatePathIndex
= -1;
686 if ( m_pImpl
->nActivePath
!= -1 )
687 nCurrentStatePathIndex
= m_pImpl
->getStateIndexInPath( getCurrentState(), m_pImpl
->nActivePath
);
688 for ( RoadmapTypes::ItemIndex nItemIndex
= nCurrentStatePathIndex
; nItemIndex
< nLoopUntil
; ++nItemIndex
)
690 bool bExistentItem
= ( nItemIndex
< m_pImpl
->pRoadmap
->GetItemCount() );
693 // there is an item with this index in the roadmap - does it match what is requested by
694 // the respective state in the active path?
695 RoadmapTypes::ItemId nPresentItemId
= m_pImpl
->pRoadmap
->GetItemID( nItemIndex
);
696 WizardState nRequiredState
= rActivePath
[ nItemIndex
];
697 if ( _nState
== nRequiredState
)
699 m_pImpl
->pRoadmap
->ChangeRoadmapItemLabel( nPresentItemId
, getStateDisplayName( nRequiredState
) );
706 //........................................................................
708 //........................................................................