1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <svtools/roadmapwizard.hxx>
22 #include <svtools/svtools.hrc>
23 #include <svtools/svtresid.hxx>
24 #include <svtools/roadmap.hxx>
25 #include <tools/debug.hxx>
33 //........................................................................
36 //........................................................................
40 typedef ::std::set
< WizardTypes::WizardState
> StateSet
;
43 RoadmapWizardTypes::PathId
,
44 RoadmapWizardTypes::WizardPath
48 WizardTypes::WizardState
,
51 RoadmapWizardTypes::RoadmapPageFactory
56 struct RoadmapWizardImpl
: public RoadmapWizardTypes
61 StateDescriptions aStateDescriptors
;
62 StateSet aDisabledStates
;
63 bool bActivePathIsDefinite
;
64 FixedLine
* pFixedLine
;
69 ,bActivePathIsDefinite( false )
80 /// returns the index of the current state in given path, or -1
81 sal_Int32
getStateIndexInPath( WizardTypes::WizardState _nState
, const WizardPath
& _rPath
);
82 /// returns the index of the current state in the path with the given id, or -1
83 sal_Int32
getStateIndexInPath( WizardTypes::WizardState _nState
, PathId _nPathId
);
84 /// returns the index of the first state in which the two given paths differ
85 sal_Int32
getFirstDifferentIndex( const WizardPath
& _rLHS
, const WizardPath
& _rRHS
);
88 //--------------------------------------------------------------------
89 sal_Int32
RoadmapWizardImpl::getStateIndexInPath( WizardTypes::WizardState _nState
, const WizardPath
& _rPath
)
91 sal_Int32 nStateIndexInPath
= 0;
92 WizardPath::const_iterator aPathLoop
= _rPath
.begin();
93 for ( ; aPathLoop
!= _rPath
.end(); ++aPathLoop
, ++nStateIndexInPath
)
94 if ( *aPathLoop
== _nState
)
96 if ( aPathLoop
== _rPath
.end() )
97 nStateIndexInPath
= -1;
98 return nStateIndexInPath
;
101 //--------------------------------------------------------------------
102 sal_Int32
RoadmapWizardImpl::getStateIndexInPath( WizardTypes::WizardState _nState
, PathId _nPathId
)
104 sal_Int32 nStateIndexInPath
= -1;
105 Paths::const_iterator aPathPos
= aPaths
.find( _nPathId
);
106 if ( aPathPos
!= aPaths
.end( ) )
107 nStateIndexInPath
= getStateIndexInPath( _nState
, aPathPos
->second
);
108 return nStateIndexInPath
;
111 //--------------------------------------------------------------------
112 sal_Int32
RoadmapWizardImpl::getFirstDifferentIndex( const WizardPath
& _rLHS
, const WizardPath
& _rRHS
)
114 sal_Int32 nMinLength
= ::std::min( _rLHS
.size(), _rRHS
.size() );
115 for ( sal_Int32 nCheck
= 0; nCheck
< nMinLength
; ++nCheck
)
117 if ( _rLHS
[ nCheck
] != _rRHS
[ nCheck
] )
123 //====================================================================
125 //====================================================================
126 DBG_NAME( RoadmapWizard
)
127 //--------------------------------------------------------------------
129 const char* CheckInvariants( const void* pVoid
)
131 return static_cast< const RoadmapWizard
* >( pVoid
)->checkInvariants();
134 //--------------------------------------------------------------------
135 const sal_Char
* RoadmapWizard::checkInvariants() const
137 // all paths have to start with the same state
138 WizardState nSharedFirstState
= WZS_INVALID_STATE
;
139 for ( Paths::const_iterator aPath
= m_pImpl
->aPaths
.begin();
140 aPath
!= m_pImpl
->aPaths
.end();
144 if ( aPath
->second
.empty() )
145 return "RoadmapWizard::checkInvariants: paths should not be empty!";
147 if ( nSharedFirstState
== WZS_INVALID_STATE
)
149 nSharedFirstState
= aPath
->second
[ 0 ];
151 if ( nSharedFirstState
!= aPath
->second
[ 0 ] )
152 return "RoadmapWizard::checkInvariants: alls paths must start with the same state!";
155 if ( !m_pImpl
->aPaths
.empty() )
157 Paths::const_iterator aCurrentPathPos
= m_pImpl
->aPaths
.find( m_pImpl
->nActivePath
);
158 if ( aCurrentPathPos
== m_pImpl
->aPaths
.end() )
159 return "RoadmapWizard::checkInvariants: invalid active path!";
161 if ( -1 == m_pImpl
->getStateIndexInPath( getCurrentState(), m_pImpl
->nActivePath
) )
162 return "RoadmapWizard::checkInvariants: the current state is not part of the current path!";
169 //--------------------------------------------------------------------
170 RoadmapWizard::RoadmapWizard( Window
* _pParent
, const ResId
& _rRes
, sal_uInt32 _nButtonFlags
)
171 :OWizardMachine( _pParent
, _rRes
, _nButtonFlags
)
172 ,m_pImpl( new RoadmapWizardImpl
)
174 DBG_CTOR( RoadmapWizard
, CheckInvariants
);
178 //--------------------------------------------------------------------
179 RoadmapWizard::RoadmapWizard( Window
* _pParent
, const WinBits i_nStyle
, sal_uInt32 _nButtonFlags
)
180 :OWizardMachine( _pParent
, i_nStyle
, _nButtonFlags
)
181 ,m_pImpl( new RoadmapWizardImpl
)
183 DBG_CTOR( RoadmapWizard
, CheckInvariants
);
187 //--------------------------------------------------------------------
188 void RoadmapWizard::impl_construct()
190 SetLeftAlignedButtonCount( 1 );
191 SetEmptyViewMargin();
193 m_pImpl
->pRoadmap
= new ORoadmap( this, WB_TABSTOP
);
194 m_pImpl
->pRoadmap
->SetText( SVT_RESSTR( STR_WIZDLG_ROADMAP_TITLE
) );
195 m_pImpl
->pRoadmap
->SetPosPixel( Point( 0, 0 ) );
196 m_pImpl
->pRoadmap
->SetItemSelectHdl( LINK( this, RoadmapWizard
, OnRoadmapItemSelected
) );
198 Size aRoadmapSize
=( LogicToPixel( Size( 85, 0 ), MAP_APPFONT
) );
199 aRoadmapSize
.Height() = GetSizePixel().Height();
200 m_pImpl
->pRoadmap
->SetSizePixel( aRoadmapSize
);
202 m_pImpl
->pFixedLine
= new FixedLine( this, WB_VERT
);
203 m_pImpl
->pFixedLine
->Show();
204 m_pImpl
->pFixedLine
->SetPosPixel( Point( aRoadmapSize
.Width() + 1, 0 ) );
205 m_pImpl
->pFixedLine
->SetSizePixel( Size( LogicToPixel( Size( 2, 0 ) ).Width(), aRoadmapSize
.Height() ) );
207 SetViewWindow( m_pImpl
->pRoadmap
);
208 SetViewAlign( WINDOWALIGN_LEFT
);
209 m_pImpl
->pRoadmap
->Show();
212 //--------------------------------------------------------------------
213 RoadmapWizard::~RoadmapWizard()
216 DBG_DTOR( RoadmapWizard
, CheckInvariants
);
219 //--------------------------------------------------------------------
220 void RoadmapWizard::SetRoadmapHelpId( const OString
& _rId
)
222 m_pImpl
->pRoadmap
->SetHelpId( _rId
);
225 //--------------------------------------------------------------------
226 void RoadmapWizard::SetRoadmapInteractive( sal_Bool _bInteractive
)
228 m_pImpl
->pRoadmap
->SetRoadmapInteractive( _bInteractive
);
231 //--------------------------------------------------------------------
232 void RoadmapWizard::declarePath( PathId _nPathId
, const WizardPath
& _lWizardStates
)
234 DBG_CHKTHIS( RoadmapWizard
, CheckInvariants
);
236 m_pImpl
->aPaths
.insert( Paths::value_type( _nPathId
, _lWizardStates
) );
238 if ( m_pImpl
->aPaths
.size() == 1 )
239 // the very first path -> activate it
240 activatePath( _nPathId
, false );
242 implUpdateRoadmap( );
245 //--------------------------------------------------------------------
246 void RoadmapWizard::declarePath( PathId _nPathId
, WizardState _nFirstState
, ... )
248 DBG_CHKTHIS( RoadmapWizard
, CheckInvariants
);
250 DBG_ASSERT( _nFirstState
!= WZS_INVALID_STATE
, "RoadmapWizard::declarePath: there should be at least one state in the path!" );
251 if ( _nFirstState
== WZS_INVALID_STATE
)
256 // collect the elements of the path
258 va_start( aStateList
, _nFirstState
);
260 WizardState nState
= _nFirstState
;
261 while ( nState
!= WZS_INVALID_STATE
)
263 aNewPath
.push_back( nState
);
264 nState
= sal::static_int_cast
< WizardState
>(
265 va_arg( aStateList
, int ));
267 va_end( aStateList
);
269 DBG_ASSERT( _nFirstState
== 0, "RoadmapWizard::declarePath: first state must be NULL." );
270 // The WizardDialog (our very base class) always starts with a mnCurLevel == 0
272 declarePath( _nPathId
, aNewPath
);
275 //--------------------------------------------------------------------
276 void RoadmapWizard::describeState( WizardState _nState
, const OUString
& _rStateDisplayName
, RoadmapPageFactory _pPageFactory
)
278 OSL_ENSURE( m_pImpl
->aStateDescriptors
.find( _nState
) == m_pImpl
->aStateDescriptors
.end(),
279 "RoadmapWizard::describeState: there already is a descriptor for this state!" );
280 m_pImpl
->aStateDescriptors
[ _nState
] = StateDescriptions::mapped_type( _rStateDisplayName
, _pPageFactory
);
283 //--------------------------------------------------------------------
284 void RoadmapWizard::activatePath( PathId _nPathId
, bool _bDecideForIt
)
286 DBG_CHKTHIS( RoadmapWizard
, CheckInvariants
);
288 if ( ( _nPathId
== m_pImpl
->nActivePath
) && ( _bDecideForIt
== m_pImpl
->bActivePathIsDefinite
) )
292 // does the given path exist?
293 Paths::const_iterator aNewPathPos
= m_pImpl
->aPaths
.find( _nPathId
);
294 DBG_ASSERT( aNewPathPos
!= m_pImpl
->aPaths
.end(), "RoadmapWizard::activate: there is no such path!" );
295 if ( aNewPathPos
== m_pImpl
->aPaths
.end() )
298 // determine the index of the current state in the current path
299 sal_Int32 nCurrentStatePathIndex
= -1;
300 if ( m_pImpl
->nActivePath
!= -1 )
301 nCurrentStatePathIndex
= m_pImpl
->getStateIndexInPath( getCurrentState(), m_pImpl
->nActivePath
);
303 DBG_ASSERT( (sal_Int32
)aNewPathPos
->second
.size() > nCurrentStatePathIndex
,
304 "RoadmapWizard::activate: you cannot activate a path which has less states than we've already advanced!" );
305 // If this asserts, this for instance means that we are already in state number, say, 5
306 // of our current path, and the caller tries to activate a path which has less than 5
308 if ( (sal_Int32
)aNewPathPos
->second
.size() <= nCurrentStatePathIndex
)
311 // assert that the current and the new path are equal, up to nCurrentStatePathIndex
312 Paths::const_iterator aActivePathPos
= m_pImpl
->aPaths
.find( m_pImpl
->nActivePath
);
313 if ( aActivePathPos
!= m_pImpl
->aPaths
.end() )
315 if ( m_pImpl
->getFirstDifferentIndex( aActivePathPos
->second
, aNewPathPos
->second
) <= nCurrentStatePathIndex
)
317 OSL_FAIL( "RoadmapWizard::activate: you cannot activate a path which conflicts with the current one *before* the current state!" );
322 m_pImpl
->nActivePath
= _nPathId
;
323 m_pImpl
->bActivePathIsDefinite
= _bDecideForIt
;
325 implUpdateRoadmap( );
328 //--------------------------------------------------------------------
329 void RoadmapWizard::implUpdateRoadmap( )
331 DBG_CHKTHIS( RoadmapWizard
, CheckInvariants
);
333 DBG_ASSERT( m_pImpl
->aPaths
.find( m_pImpl
->nActivePath
) != m_pImpl
->aPaths
.end(),
334 "RoadmapWizard::implUpdateRoadmap: there is no such path!" );
335 const WizardPath
& rActivePath( m_pImpl
->aPaths
[ m_pImpl
->nActivePath
] );
337 sal_Int32 nCurrentStatePathIndex
= m_pImpl
->getStateIndexInPath( getCurrentState(), rActivePath
);
339 // determine up to which index (in the new path) we have to display the items
340 RoadmapTypes::ItemIndex nUpperStepBoundary
= (RoadmapTypes::ItemIndex
)rActivePath
.size();
341 sal_Bool bIncompletePath
= sal_False
;
342 if ( !m_pImpl
->bActivePathIsDefinite
)
344 for ( Paths::const_iterator aPathPos
= m_pImpl
->aPaths
.begin();
345 aPathPos
!= m_pImpl
->aPaths
.end();
349 if ( aPathPos
->first
== m_pImpl
->nActivePath
)
350 // it's the path we are just activating -> no need to check anything
352 // the index from which on both paths differ
353 sal_Int32 nDivergenceIndex
= m_pImpl
->getFirstDifferentIndex( rActivePath
, aPathPos
->second
);
354 if ( nDivergenceIndex
<= nCurrentStatePathIndex
)
355 // they differ in an index which we have already left behind us
356 // -> this is no conflict anymore
359 // the path conflicts with our new path -> don't activate the
360 // *complete* new path, but only up to the step which is unambiguous
361 nUpperStepBoundary
= nDivergenceIndex
;
362 bIncompletePath
= sal_True
;
366 // can we advance from the current page?
367 bool bCurrentPageCanAdvance
= true;
368 TabPage
* pCurrentPage
= GetPage( getCurrentState() );
371 const IWizardPageController
* pController
= getPageController( GetPage( getCurrentState() ) );
372 OSL_ENSURE( pController
!= NULL
, "RoadmapWizard::implUpdateRoadmap: no controller for the current page!" );
373 bCurrentPageCanAdvance
= !pController
|| pController
->canAdvance();
376 // now, we have to remove all items after nCurrentStatePathIndex, and insert the items from the active
377 // path, up to (excluding) nUpperStepBoundary
378 RoadmapTypes::ItemIndex nLoopUntil
= ::std::max( (RoadmapTypes::ItemIndex
)nUpperStepBoundary
, m_pImpl
->pRoadmap
->GetItemCount() );
379 for ( RoadmapTypes::ItemIndex nItemIndex
= nCurrentStatePathIndex
; nItemIndex
< nLoopUntil
; ++nItemIndex
)
381 bool bExistentItem
= ( nItemIndex
< m_pImpl
->pRoadmap
->GetItemCount() );
382 bool bNeedItem
= ( nItemIndex
< nUpperStepBoundary
);
384 bool bInsertItem
= false;
389 while ( nItemIndex
< m_pImpl
->pRoadmap
->GetItemCount() )
390 m_pImpl
->pRoadmap
->DeleteRoadmapItem( nItemIndex
);
395 // there is an item with this index in the roadmap - does it match what is requested by
396 // the respective state in the active path?
397 RoadmapTypes::ItemId nPresentItemId
= m_pImpl
->pRoadmap
->GetItemID( nItemIndex
);
398 WizardState nRequiredState
= rActivePath
[ nItemIndex
];
399 if ( nPresentItemId
!= nRequiredState
)
401 m_pImpl
->pRoadmap
->DeleteRoadmapItem( nItemIndex
);
408 DBG_ASSERT( bNeedItem
, "RoadmapWizard::implUpdateRoadmap: ehm - none needed, none present - why did the loop not terminate?" );
409 bInsertItem
= bNeedItem
;
412 WizardState
nState( rActivePath
[ nItemIndex
] );
415 m_pImpl
->pRoadmap
->InsertRoadmapItem(
417 getStateDisplayName( nState
),
422 // if the item is *after* the current state, but the current page does not
423 // allow advancing, the disable the state. This relieves derived classes
424 // from disabling all future states just because the current state does not
425 // (yet) allow advancing.
426 const bool nUnconditionedDisable
= !bCurrentPageCanAdvance
&& ( nItemIndex
> nCurrentStatePathIndex
);
427 const bool bEnable
= !nUnconditionedDisable
&& ( m_pImpl
->aDisabledStates
.find( nState
) == m_pImpl
->aDisabledStates
.end() );
429 m_pImpl
->pRoadmap
->EnableRoadmapItem( m_pImpl
->pRoadmap
->GetItemID( nItemIndex
), bEnable
);
432 m_pImpl
->pRoadmap
->SetRoadmapComplete( !bIncompletePath
);
435 //--------------------------------------------------------------------
436 WizardTypes::WizardState
RoadmapWizard::determineNextState( WizardState _nCurrentState
) const
438 DBG_CHKTHIS( RoadmapWizard
, CheckInvariants
);
440 sal_Int32 nCurrentStatePathIndex
= -1;
442 Paths::const_iterator aActivePathPos
= m_pImpl
->aPaths
.find( m_pImpl
->nActivePath
);
443 if ( aActivePathPos
!= m_pImpl
->aPaths
.end() )
444 nCurrentStatePathIndex
= m_pImpl
->getStateIndexInPath( _nCurrentState
, aActivePathPos
->second
);
446 DBG_ASSERT( nCurrentStatePathIndex
!= -1, "RoadmapWizard::determineNextState: ehm - how can we travel if there is no (valid) active path?" );
447 if ( nCurrentStatePathIndex
== -1 )
448 return WZS_INVALID_STATE
;
450 sal_Int32 nNextStateIndex
= nCurrentStatePathIndex
+ 1;
452 while ( ( nNextStateIndex
< (sal_Int32
)aActivePathPos
->second
.size() )
453 && ( m_pImpl
->aDisabledStates
.find( aActivePathPos
->second
[ nNextStateIndex
] ) != m_pImpl
->aDisabledStates
.end() )
459 if ( nNextStateIndex
>= (sal_Int32
)aActivePathPos
->second
.size() )
460 // there is no next state in the current path (at least none which is enabled)
461 return WZS_INVALID_STATE
;
463 return aActivePathPos
->second
[ nNextStateIndex
];
466 //---------------------------------------------------------------------
467 bool RoadmapWizard::canAdvance() const
469 if ( !m_pImpl
->bActivePathIsDefinite
)
471 // check how many paths are still allowed
472 const WizardPath
& rActivePath( m_pImpl
->aPaths
[ m_pImpl
->nActivePath
] );
473 sal_Int32 nCurrentStatePathIndex
= m_pImpl
->getStateIndexInPath( getCurrentState(), rActivePath
);
475 size_t nPossiblePaths(0);
476 for ( Paths::const_iterator aPathPos
= m_pImpl
->aPaths
.begin();
477 aPathPos
!= m_pImpl
->aPaths
.end();
481 // the index from which on both paths differ
482 sal_Int32 nDivergenceIndex
= m_pImpl
->getFirstDifferentIndex( rActivePath
, aPathPos
->second
);
484 if ( nDivergenceIndex
> nCurrentStatePathIndex
)
485 // this path is still a possible path
489 // if we have more than one path which is still possible, then we assume
490 // to always have a next state. Though there might be scenarios where this
491 // is not true, but this is too sophisticated (means not really needed) right now.
492 if ( nPossiblePaths
> 1 )
496 const WizardPath
& rPath
= m_pImpl
->aPaths
[ m_pImpl
->nActivePath
];
497 if ( *rPath
.rbegin() == getCurrentState() )
503 //---------------------------------------------------------------------
504 void RoadmapWizard::updateTravelUI()
506 OWizardMachine::updateTravelUI();
508 // disable the "Previous" button if all states in our history are disabled
509 ::std::vector
< WizardState
> aHistory
;
510 getStateHistory( aHistory
);
511 bool bHaveEnabledState
= false;
512 for ( ::std::vector
< WizardState
>::const_iterator state
= aHistory
.begin();
513 state
!= aHistory
.end() && !bHaveEnabledState
;
517 if ( isStateEnabled( *state
) )
518 bHaveEnabledState
= true;
521 enableButtons( WZB_PREVIOUS
, bHaveEnabledState
);
526 //--------------------------------------------------------------------
527 IMPL_LINK_NOARG(RoadmapWizard
, OnRoadmapItemSelected
)
529 DBG_CHKTHIS( RoadmapWizard
, CheckInvariants
);
531 RoadmapTypes::ItemId nCurItemId
= m_pImpl
->pRoadmap
->GetCurrentRoadmapItemID();
532 if ( nCurItemId
== getCurrentState() )
536 if ( isTravelingSuspended() )
539 WizardTravelSuspension
aTravelGuard( *this );
541 sal_Int32 nCurrentIndex
= m_pImpl
->getStateIndexInPath( getCurrentState(), m_pImpl
->nActivePath
);
542 sal_Int32 nNewIndex
= m_pImpl
->getStateIndexInPath( nCurItemId
, m_pImpl
->nActivePath
);
544 DBG_ASSERT( ( nCurrentIndex
!= -1 ) && ( nNewIndex
!= -1 ),
545 "RoadmapWizard::OnRoadmapItemSelected: something's wrong here!" );
546 if ( ( nCurrentIndex
== -1 ) || ( nNewIndex
== -1 ) )
551 sal_Bool bResult
= sal_True
;
552 if ( nNewIndex
> nCurrentIndex
)
554 bResult
= skipUntil( (WizardState
)nCurItemId
);
555 WizardState nTemp
= (WizardState
)nCurItemId
;
558 if( m_pImpl
->aDisabledStates
.find( --nTemp
) != m_pImpl
->aDisabledStates
.end() )
559 removePageFromHistory( nTemp
);
563 bResult
= skipBackwardUntil( (WizardState
)nCurItemId
);
566 m_pImpl
->pRoadmap
->SelectRoadmapItemByID( getCurrentState() );
571 //--------------------------------------------------------------------
572 void RoadmapWizard::enterState( WizardState _nState
)
574 DBG_CHKTHIS( RoadmapWizard
, CheckInvariants
);
576 OWizardMachine::enterState( _nState
);
578 // synchronize the roadmap
579 implUpdateRoadmap( );
580 m_pImpl
->pRoadmap
->SelectRoadmapItemByID( getCurrentState() );
583 //--------------------------------------------------------------------
584 OUString
RoadmapWizard::getStateDisplayName( WizardState _nState
) const
586 OUString sDisplayName
;
588 StateDescriptions::const_iterator pos
= m_pImpl
->aStateDescriptors
.find( _nState
);
589 OSL_ENSURE( pos
!= m_pImpl
->aStateDescriptors
.end(),
590 "RoadmapWizard::getStateDisplayName: no default implementation available for this state!" );
591 if ( pos
!= m_pImpl
->aStateDescriptors
.end() )
592 sDisplayName
= pos
->second
.first
;
597 //--------------------------------------------------------------------
598 TabPage
* RoadmapWizard::createPage( WizardState _nState
)
600 TabPage
* pPage( NULL
);
602 StateDescriptions::const_iterator pos
= m_pImpl
->aStateDescriptors
.find( _nState
);
603 OSL_ENSURE( pos
!= m_pImpl
->aStateDescriptors
.end(),
604 "RoadmapWizard::createPage: no default implementation available for this state!" );
605 if ( pos
!= m_pImpl
->aStateDescriptors
.end() )
607 RoadmapPageFactory pFactory
= pos
->second
.second
;
608 pPage
= (*pFactory
)( *this );
614 //--------------------------------------------------------------------
615 void RoadmapWizard::enableState( WizardState _nState
, bool _bEnable
)
617 DBG_CHKTHIS( RoadmapWizard
, CheckInvariants
);
619 // remember this (in case the state appears in the roadmap later on)
621 m_pImpl
->aDisabledStates
.erase( _nState
);
624 m_pImpl
->aDisabledStates
.insert( _nState
);
625 removePageFromHistory( _nState
);
628 // if the state is currently in the roadmap, reflect it's new status
629 m_pImpl
->pRoadmap
->EnableRoadmapItem( (RoadmapTypes::ItemId
)_nState
, _bEnable
);
632 //--------------------------------------------------------------------
633 bool RoadmapWizard::knowsState( WizardState i_nState
) const
635 for ( Paths::const_iterator path
= m_pImpl
->aPaths
.begin();
636 path
!= m_pImpl
->aPaths
.end();
640 for ( WizardPath::const_iterator state
= path
->second
.begin();
641 state
!= path
->second
.end();
645 if ( *state
== i_nState
)
652 //--------------------------------------------------------------------
653 bool RoadmapWizard::isStateEnabled( WizardState _nState
) const
655 return m_pImpl
->aDisabledStates
.find( _nState
) == m_pImpl
->aDisabledStates
.end();
658 //--------------------------------------------------------------------
659 void RoadmapWizard::Resize()
661 OWizardMachine::Resize();
663 if ( IsReallyShown() && !IsInInitShow() )
668 //--------------------------------------------------------------------
669 void RoadmapWizard::StateChanged( StateChangedType nType
)
671 WizardDialog::StateChanged( nType
);
673 if ( nType
== STATE_CHANGE_INITSHOW
)
677 //--------------------------------------------------------------------
678 void RoadmapWizard::ResizeFixedLine()
680 Size
aSize( m_pImpl
->pRoadmap
->GetSizePixel() );
681 aSize
.Width() = m_pImpl
->pFixedLine
->GetSizePixel().Width();
682 m_pImpl
->pFixedLine
->SetSizePixel( aSize
);
685 //--------------------------------------------------------------------
686 void RoadmapWizard::updateRoadmapItemLabel( WizardState _nState
)
688 const WizardPath
& rActivePath( m_pImpl
->aPaths
[ m_pImpl
->nActivePath
] );
689 RoadmapTypes::ItemIndex nUpperStepBoundary
= (RoadmapTypes::ItemIndex
)rActivePath
.size();
690 RoadmapTypes::ItemIndex nLoopUntil
= ::std::max( (RoadmapTypes::ItemIndex
)nUpperStepBoundary
, m_pImpl
->pRoadmap
->GetItemCount() );
691 sal_Int32 nCurrentStatePathIndex
= -1;
692 if ( m_pImpl
->nActivePath
!= -1 )
693 nCurrentStatePathIndex
= m_pImpl
->getStateIndexInPath( getCurrentState(), m_pImpl
->nActivePath
);
694 for ( RoadmapTypes::ItemIndex nItemIndex
= nCurrentStatePathIndex
; nItemIndex
< nLoopUntil
; ++nItemIndex
)
696 bool bExistentItem
= ( nItemIndex
< m_pImpl
->pRoadmap
->GetItemCount() );
699 // there is an item with this index in the roadmap - does it match what is requested by
700 // the respective state in the active path?
701 RoadmapTypes::ItemId nPresentItemId
= m_pImpl
->pRoadmap
->GetItemID( nItemIndex
);
702 WizardState nRequiredState
= rActivePath
[ nItemIndex
];
703 if ( _nState
== nRequiredState
)
705 m_pImpl
->pRoadmap
->ChangeRoadmapItemLabel( nPresentItemId
, getStateDisplayName( nRequiredState
) );
712 //........................................................................
714 //........................................................................
716 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */