2004-05-19 13:01:33 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2005-09-08 14:19:12 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2004-05-19 13:01:33 +00:00
|
|
|
*
|
2005-09-08 14:19:12 +00:00
|
|
|
* $RCSfile: roadmapwizard.cxx,v $
|
2004-05-19 13:01:33 +00:00
|
|
|
*
|
2005-09-08 14:19:12 +00:00
|
|
|
* $Revision: 1.9 $
|
2004-05-19 13:01:33 +00:00
|
|
|
*
|
2005-09-08 14:19:12 +00:00
|
|
|
* last change: $Author: rt $ $Date: 2005-09-08 15:19:12 $
|
2004-05-19 13:01:33 +00:00
|
|
|
*
|
2005-09-08 14:19:12 +00:00
|
|
|
* The Contents of this file are made available subject to
|
|
|
|
* the terms of GNU Lesser General Public License Version 2.1.
|
2004-05-19 13:01:33 +00:00
|
|
|
*
|
|
|
|
*
|
2005-09-08 14:19:12 +00:00
|
|
|
* GNU Lesser General Public License Version 2.1
|
|
|
|
* =============================================
|
|
|
|
* Copyright 2005 by Sun Microsystems, Inc.
|
|
|
|
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
2004-05-19 13:01:33 +00:00
|
|
|
*
|
2005-09-08 14:19:12 +00:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License version 2.1, as published by the Free Software Foundation.
|
2004-05-19 13:01:33 +00:00
|
|
|
*
|
2005-09-08 14:19:12 +00:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
2004-05-19 13:01:33 +00:00
|
|
|
*
|
2005-09-08 14:19:12 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
* MA 02111-1307 USA
|
2004-05-19 13:01:33 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
#ifndef SVTOOLS_INC_ROADMAPWIZARD_HXX
|
|
|
|
#include "roadmapwizard.hxx"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _SVTOOLS_ROADMAP_HXX
|
|
|
|
#include "roadmap.hxx"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _TOOLS_DEBUG_HXX
|
|
|
|
#include <tools/debug.hxx>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include <map>
|
|
|
|
#include <set>
|
|
|
|
|
|
|
|
//........................................................................
|
|
|
|
namespace svt
|
|
|
|
{
|
|
|
|
//........................................................................
|
|
|
|
|
|
|
|
namespace
|
|
|
|
{
|
|
|
|
typedef ::std::vector< WizardTypes::WizardState > Path;
|
|
|
|
typedef ::std::map< RoadmapWizardTypes::PathId, Path > Paths;
|
|
|
|
typedef ::std::set< WizardTypes::WizardState > StateSet;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct RoadmapWizardImpl : public RoadmapWizardTypes
|
|
|
|
{
|
|
|
|
ORoadmap* pRoadmap;
|
|
|
|
|
|
|
|
Paths aPaths;
|
|
|
|
PathId nActivePath;
|
|
|
|
bool bActivePathIsDefinite;
|
2004-10-27 12:23:22 +00:00
|
|
|
FixedLine* pFixedLine;
|
|
|
|
|
2004-05-19 13:01:33 +00:00
|
|
|
|
|
|
|
StateSet aDisabledStates;
|
|
|
|
|
|
|
|
RoadmapWizardImpl()
|
|
|
|
:pRoadmap( NULL )
|
2004-10-27 12:23:22 +00:00
|
|
|
,pFixedLine(NULL)
|
2004-05-19 13:01:33 +00:00
|
|
|
,nActivePath( -1 )
|
|
|
|
,bActivePathIsDefinite( false )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
~RoadmapWizardImpl()
|
|
|
|
{
|
|
|
|
delete pRoadmap;
|
2004-10-27 12:23:22 +00:00
|
|
|
delete pFixedLine;
|
2004-05-19 13:01:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// returns the index of the current state in given path, or -1
|
|
|
|
sal_Int32 getStateIndexInPath( WizardTypes::WizardState _nState, const Path& _rPath );
|
|
|
|
/// returns the index of the current state in the path with the given id, or -1
|
|
|
|
sal_Int32 getStateIndexInPath( WizardTypes::WizardState _nState, PathId _nPathId );
|
|
|
|
/// returns the index of the first state in which the two given paths differ
|
|
|
|
sal_Int32 getFirstDifferentIndex( const Path& _rLHS, const Path& _rRHS );
|
|
|
|
};
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
sal_Int32 RoadmapWizardImpl::getStateIndexInPath( WizardTypes::WizardState _nState, const Path& _rPath )
|
|
|
|
{
|
|
|
|
sal_Int32 nStateIndexInPath = 0;
|
|
|
|
Path::const_iterator aPathLoop = _rPath.begin();
|
|
|
|
for ( ; aPathLoop != _rPath.end(); ++aPathLoop, ++nStateIndexInPath )
|
|
|
|
if ( *aPathLoop == _nState )
|
|
|
|
break;
|
|
|
|
if ( aPathLoop == _rPath.end() )
|
|
|
|
nStateIndexInPath = -1;
|
|
|
|
return nStateIndexInPath;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
sal_Int32 RoadmapWizardImpl::getStateIndexInPath( WizardTypes::WizardState _nState, PathId _nPathId )
|
|
|
|
{
|
|
|
|
sal_Int32 nStateIndexInPath = -1;
|
|
|
|
Paths::const_iterator aPathPos = aPaths.find( _nPathId );
|
|
|
|
if ( aPathPos != aPaths.end( ) )
|
|
|
|
nStateIndexInPath = getStateIndexInPath( _nState, aPathPos->second );
|
|
|
|
return nStateIndexInPath;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
sal_Int32 RoadmapWizardImpl::getFirstDifferentIndex( const Path& _rLHS, const Path& _rRHS )
|
|
|
|
{
|
|
|
|
sal_Int32 nMinLength = ::std::min( _rLHS.size(), _rRHS.size() );
|
|
|
|
for ( sal_Int32 nCheck = 0; nCheck < nMinLength; ++nCheck )
|
|
|
|
{
|
|
|
|
if ( _rLHS[ nCheck ] != _rRHS[ nCheck ] )
|
|
|
|
return nCheck;
|
|
|
|
}
|
|
|
|
return nMinLength;
|
|
|
|
}
|
|
|
|
|
|
|
|
//====================================================================
|
|
|
|
//= RoadmapWizard
|
|
|
|
//====================================================================
|
|
|
|
DBG_NAME( RoadmapWizard )
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
#if OSL_DEBUG_LEVEL > 0
|
|
|
|
const char* CheckInvariants( const void* pVoid )
|
|
|
|
{
|
|
|
|
return static_cast< const RoadmapWizard* >( pVoid )->checkInvariants();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
const sal_Char* RoadmapWizard::checkInvariants() const
|
|
|
|
{
|
|
|
|
// all paths have to start with the same state
|
|
|
|
WizardState nSharedFirstState = WZS_INVALID_STATE;
|
|
|
|
for ( Paths::const_iterator aPath = m_pImpl->aPaths.begin();
|
|
|
|
aPath != m_pImpl->aPaths.end();
|
|
|
|
++aPath
|
|
|
|
)
|
|
|
|
{
|
|
|
|
if ( aPath->second.empty() )
|
|
|
|
return "RoadmapWizard::checkInvariants: paths should not be empty!";
|
|
|
|
|
|
|
|
if ( nSharedFirstState == WZS_INVALID_STATE )
|
|
|
|
// first path
|
|
|
|
nSharedFirstState = aPath->second[ 0 ];
|
|
|
|
else
|
|
|
|
if ( nSharedFirstState != aPath->second[ 0 ] )
|
|
|
|
return "RoadmapWizard::checkInvariants: alls paths must start with the same state!";
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !m_pImpl->aPaths.empty() )
|
|
|
|
{
|
|
|
|
Paths::const_iterator aCurrentPathPos = m_pImpl->aPaths.find( m_pImpl->nActivePath );
|
|
|
|
if ( aCurrentPathPos == m_pImpl->aPaths.end() )
|
|
|
|
return "RoadmapWizard::checkInvariants: invalid active path!";
|
|
|
|
|
|
|
|
if ( -1 == m_pImpl->getStateIndexInPath( getCurrentState(), m_pImpl->nActivePath ) )
|
|
|
|
return "RoadmapWizard::checkInvariants: the current state is not part of the current path!";
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
2004-10-27 12:23:22 +00:00
|
|
|
RoadmapWizard::RoadmapWizard( Window* _pParent, const ResId& _rRes, sal_uInt32 _nButtonFlags, const ResId& _rRoadmapTitleResource, sal_Bool _bCheckButtonStates )
|
|
|
|
:OWizardMachine( _pParent, _rRes, _nButtonFlags, _bCheckButtonStates, sal_True, 1 )
|
2004-05-19 13:01:33 +00:00
|
|
|
,m_pImpl( new RoadmapWizardImpl )
|
|
|
|
{
|
|
|
|
DBG_CTOR( RoadmapWizard, CheckInvariants );
|
|
|
|
|
2005-02-17 10:16:10 +00:00
|
|
|
m_pImpl->pRoadmap = new ORoadmap( this, WB_TABSTOP );
|
2004-05-19 13:01:33 +00:00
|
|
|
m_pImpl->pRoadmap->SetText( String( _rRoadmapTitleResource ) );
|
|
|
|
m_pImpl->pRoadmap->SetPosPixel( Point( 0, 0 ) );
|
|
|
|
m_pImpl->pRoadmap->SetItemSelectHdl( LINK( this, RoadmapWizard, OnRoadmapItemSelected ) );
|
|
|
|
|
2004-10-27 12:23:22 +00:00
|
|
|
Size aRoadmapSize =( LogicToPixel( Size( 85, 0 ), MAP_APPFONT ) );
|
2004-05-19 13:01:33 +00:00
|
|
|
aRoadmapSize.Height() = GetSizePixel().Height();
|
|
|
|
m_pImpl->pRoadmap->SetSizePixel( aRoadmapSize );
|
|
|
|
|
2005-02-17 10:16:10 +00:00
|
|
|
m_pImpl->pFixedLine = new FixedLine( this, WB_VERT );
|
|
|
|
m_pImpl->pFixedLine->Show();
|
|
|
|
m_pImpl->pFixedLine->SetPosPixel( Point( aRoadmapSize.Width() + 1, 0 ) );
|
|
|
|
m_pImpl->pFixedLine->SetSizePixel( Size( LogicToPixel( Size( 2, 0 ) ).Width(), aRoadmapSize.Height() ) );
|
|
|
|
|
2004-05-19 13:01:33 +00:00
|
|
|
SetViewWindow( m_pImpl->pRoadmap );
|
|
|
|
SetViewAlign( WINDOWALIGN_LEFT );
|
|
|
|
m_pImpl->pRoadmap->Show();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
RoadmapWizard::~RoadmapWizard()
|
|
|
|
{
|
|
|
|
delete m_pImpl;
|
|
|
|
DBG_DTOR( RoadmapWizard, CheckInvariants );
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
void RoadmapWizard::SetRoadmapBitmap( const BitmapEx& _rBitmap )
|
|
|
|
{
|
|
|
|
m_pImpl->pRoadmap->SetRoadmapBitmap( _rBitmap );
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
const BitmapEx& RoadmapWizard::GetRoadmapBitmap( ) const
|
|
|
|
{
|
|
|
|
return m_pImpl->pRoadmap->GetRoadmapBitmap();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
void RoadmapWizard::SetRoadmapInteractive( sal_Bool _bInteractive )
|
|
|
|
{
|
|
|
|
m_pImpl->pRoadmap->SetRoadmapInteractive( _bInteractive );
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
sal_Bool RoadmapWizard::IsRoadmapInteractive()
|
|
|
|
{
|
|
|
|
return m_pImpl->pRoadmap->IsRoadmapInteractive();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
void RoadmapWizard::declarePath( PathId _nPathId, WizardState _nFirstState, ... )
|
|
|
|
{
|
|
|
|
DBG_CHKTHIS( RoadmapWizard, CheckInvariants );
|
|
|
|
|
|
|
|
DBG_ASSERT( _nFirstState != WZS_INVALID_STATE, "RoadmapWizard::declarePath: there should be at least one state in the path!" );
|
|
|
|
if ( _nFirstState == WZS_INVALID_STATE )
|
|
|
|
return;
|
|
|
|
|
|
|
|
Path aNewPath;
|
|
|
|
|
|
|
|
// collect the elements of the path
|
|
|
|
va_list aStateList;
|
|
|
|
va_start( aStateList, _nFirstState );
|
|
|
|
|
|
|
|
WizardState nState = _nFirstState;
|
|
|
|
while ( nState != WZS_INVALID_STATE )
|
|
|
|
{
|
|
|
|
aNewPath.push_back( nState );
|
2004-08-02 13:37:06 +00:00
|
|
|
nState = va_arg( aStateList, int );
|
2004-05-19 13:01:33 +00:00
|
|
|
}
|
|
|
|
va_end( aStateList );
|
|
|
|
|
|
|
|
DBG_ASSERT( _nFirstState == 0, "RoadmapWizard::declarePath: first state must be NULL." );
|
|
|
|
// The WizardDialog (our very base class) always starts with a mnCurLevel == 0
|
|
|
|
|
|
|
|
m_pImpl->aPaths.insert( Paths::value_type( _nPathId, aNewPath ) );
|
|
|
|
|
|
|
|
if ( m_pImpl->aPaths.size() == 1 )
|
|
|
|
// the very first path -> activate it
|
|
|
|
activatePath( _nPathId, false );
|
|
|
|
else
|
|
|
|
implUpdateRoadmap( );
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
void RoadmapWizard::activatePath( PathId _nPathId, bool _bDecideForIt )
|
|
|
|
{
|
|
|
|
DBG_CHKTHIS( RoadmapWizard, CheckInvariants );
|
|
|
|
|
|
|
|
if ( ( _nPathId == m_pImpl->nActivePath ) && ( _bDecideForIt == m_pImpl->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() )
|
|
|
|
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 );
|
|
|
|
|
|
|
|
DBG_ASSERT( (sal_Int32)aNewPathPos->second.size() > nCurrentStatePathIndex,
|
|
|
|
"RoadmapWizard::activate: you cannot activate a path which has less states than we've already advanced!" );
|
|
|
|
// If this asserts, this for instance means that we are already in state number, say, 5
|
|
|
|
// of our current path, and the caller tries to activate a path which has less than 5
|
|
|
|
// states
|
|
|
|
if ( (sal_Int32)aNewPathPos->second.size() <= nCurrentStatePathIndex )
|
|
|
|
return;
|
|
|
|
|
|
|
|
#if OSL_DEBUG_LEVEL > 0
|
|
|
|
// 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() )
|
|
|
|
DBG_ASSERT( m_pImpl->getFirstDifferentIndex( aActivePathPos->second, aNewPathPos->second ) > nCurrentStatePathIndex,
|
|
|
|
"RoadmapWizard::activate: you cannot activate a path which conflicts with the current one *before* the current state!" );
|
|
|
|
#endif
|
|
|
|
|
|
|
|
m_pImpl->nActivePath = _nPathId;
|
|
|
|
m_pImpl->bActivePathIsDefinite = _bDecideForIt;
|
|
|
|
|
|
|
|
implUpdateRoadmap( );
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
void RoadmapWizard::implInsertState( WizardState _nState, sal_Int32 _nIndex )
|
|
|
|
{
|
|
|
|
// is this state enabled?
|
|
|
|
sal_Bool bEnabled = m_pImpl->aDisabledStates.find( _nState ) == m_pImpl->aDisabledStates.end();
|
|
|
|
|
|
|
|
m_pImpl->pRoadmap->InsertRoadmapItem(
|
|
|
|
_nIndex,
|
|
|
|
getStateDisplayName( _nState ),
|
|
|
|
_nState,
|
|
|
|
bEnabled
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
void RoadmapWizard::implUpdateRoadmap( )
|
|
|
|
{
|
|
|
|
DBG_CHKTHIS( RoadmapWizard, CheckInvariants );
|
|
|
|
|
|
|
|
Paths::const_iterator aActivePathPos = m_pImpl->aPaths.find( m_pImpl->nActivePath );
|
|
|
|
DBG_ASSERT( aActivePathPos != m_pImpl->aPaths.end(), "RoadmapWizard::implUpdateRoadmap: there is no such path!" );
|
|
|
|
|
|
|
|
sal_Int32 nCurrentStatePathIndex = m_pImpl->getStateIndexInPath( getCurrentState(), aActivePathPos->second );
|
|
|
|
|
|
|
|
// determine up to which index (in the new path) we have to display the items
|
|
|
|
RoadmapTypes::ItemIndex nUpperStepBoundary = (RoadmapTypes::ItemIndex)aActivePathPos->second.size();
|
|
|
|
sal_Bool bIncompletePath = sal_False;
|
|
|
|
if ( !m_pImpl->bActivePathIsDefinite )
|
|
|
|
{
|
|
|
|
for ( Paths::const_iterator aPathPos = m_pImpl->aPaths.begin();
|
|
|
|
aPathPos != m_pImpl->aPaths.end();
|
|
|
|
++aPathPos
|
|
|
|
)
|
|
|
|
{
|
|
|
|
if ( aPathPos->first == m_pImpl->nActivePath )
|
|
|
|
// it's the path we are just activating -> no need to check anything
|
|
|
|
continue;
|
|
|
|
// the index from which on both paths differ
|
|
|
|
sal_Int32 nDivergenceIndex = m_pImpl->getFirstDifferentIndex( aActivePathPos->second, aPathPos->second );
|
|
|
|
if ( nDivergenceIndex <= nCurrentStatePathIndex )
|
|
|
|
// they differ in an index which we have already left behind us
|
|
|
|
// -> this is no conflict anymore
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// the path conflicts with our new path -> don't activate the
|
|
|
|
// *complete* new path, but only up to the step which is unambiguous
|
|
|
|
nUpperStepBoundary = nDivergenceIndex;
|
|
|
|
bIncompletePath = sal_True;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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( (RoadmapTypes::ItemIndex)nUpperStepBoundary, m_pImpl->pRoadmap->GetItemCount() );
|
|
|
|
for ( RoadmapTypes::ItemIndex nItemIndex = nCurrentStatePathIndex; nItemIndex < nLoopUntil; ++nItemIndex )
|
|
|
|
{
|
|
|
|
bool bExistentItem = ( nItemIndex < m_pImpl->pRoadmap->GetItemCount() );
|
|
|
|
bool bNeedItem = nItemIndex < nUpperStepBoundary;
|
|
|
|
|
|
|
|
if ( bExistentItem )
|
|
|
|
{
|
|
|
|
if ( !bNeedItem )
|
|
|
|
{
|
|
|
|
while ( nItemIndex < m_pImpl->pRoadmap->GetItemCount() )
|
|
|
|
m_pImpl->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 );
|
|
|
|
WizardState nRequiredState = aActivePathPos->second[ nItemIndex ];
|
|
|
|
if ( nPresentItemId != nRequiredState )
|
|
|
|
{
|
2004-10-27 12:23:22 +00:00
|
|
|
m_pImpl->pRoadmap->ChangeRoadmapItemLabel( nPresentItemId, getStateDisplayName( nRequiredState ), nItemIndex );
|
|
|
|
m_pImpl->pRoadmap->EnableRoadmapItem( nPresentItemId, m_pImpl->aDisabledStates.find( nRequiredState ) == m_pImpl->aDisabledStates.end(), nItemIndex );
|
|
|
|
m_pImpl->pRoadmap->ChangeRoadmapItemID( nPresentItemId, (RoadmapTypes::ItemId)nRequiredState, nItemIndex );
|
2004-05-19 13:01:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DBG_ASSERT( bNeedItem, "RoadmapWizard::implUpdateRoadmap: ehm - none needed, none present - why did the loop not terminate?" );
|
|
|
|
if ( bNeedItem )
|
|
|
|
implInsertState( aActivePathPos->second[ nItemIndex ], nItemIndex );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
// remove all old roadmap items
|
|
|
|
RoadmapTypes::ItemIndex nDeleteIndex = nCurrentStatePathIndex;
|
|
|
|
++nDeleteIndex;
|
|
|
|
while ( nDeleteIndex < m_pImpl->pRoadmap->GetItemCount() )
|
|
|
|
m_pImpl->pRoadmap->DeleteRoadmapItem( nDeleteIndex );
|
|
|
|
|
|
|
|
// insert new roadmap items
|
|
|
|
for ( Path::const_iterator aStateLoop = aNewPathPos->second.begin() + nCurrentStatePathIndex + 1;
|
|
|
|
aStateLoop != aNewPathPos->second.begin() + nUpperStepBoundary;
|
|
|
|
++aStateLoop
|
|
|
|
)
|
|
|
|
{
|
|
|
|
implInsertState( *aStateLoop, aStateLoop - aNewPathPos->second.begin() );
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
m_pImpl->pRoadmap->SetRoadmapComplete( !bIncompletePath );
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
WizardTypes::WizardState RoadmapWizard::determineNextState( WizardState _nCurrentState )
|
|
|
|
{
|
|
|
|
DBG_CHKTHIS( RoadmapWizard, CheckInvariants );
|
|
|
|
|
|
|
|
sal_Int32 nCurrentStatePathIndex = -1;
|
|
|
|
|
|
|
|
Paths::const_iterator aActivePathPos = m_pImpl->aPaths.find( m_pImpl->nActivePath );
|
|
|
|
if ( aActivePathPos != m_pImpl->aPaths.end() )
|
|
|
|
nCurrentStatePathIndex = m_pImpl->getStateIndexInPath( _nCurrentState, aActivePathPos->second );
|
|
|
|
|
|
|
|
DBG_ASSERT( nCurrentStatePathIndex != -1, "RoadmapWizard::determineNextState: ehm - how can we travel if there is no (valid) active path?" );
|
|
|
|
if ( nCurrentStatePathIndex == -1 )
|
|
|
|
return WZS_INVALID_STATE;
|
|
|
|
|
|
|
|
sal_Int32 nNextStateIndex = nCurrentStatePathIndex + 1;
|
|
|
|
|
|
|
|
while ( ( nNextStateIndex < (sal_Int32)aActivePathPos->second.size() )
|
|
|
|
&& ( m_pImpl->aDisabledStates.find( aActivePathPos->second[ nNextStateIndex ] ) != m_pImpl->aDisabledStates.end() )
|
|
|
|
)
|
|
|
|
{
|
|
|
|
++nNextStateIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( nNextStateIndex >= (sal_Int32)aActivePathPos->second.size() )
|
|
|
|
// there is no next state in the current path (at least none which is enabled)
|
|
|
|
return WZS_INVALID_STATE;
|
|
|
|
|
|
|
|
return aActivePathPos->second[ nNextStateIndex ];
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
IMPL_LINK( RoadmapWizard, OnRoadmapItemSelected, void*, _pNotInterestedIn )
|
|
|
|
{
|
|
|
|
DBG_CHKTHIS( RoadmapWizard, CheckInvariants );
|
|
|
|
|
|
|
|
RoadmapTypes::ItemId nCurItemId = m_pImpl->pRoadmap->GetCurrentRoadmapItemID();
|
|
|
|
if ( nCurItemId == getCurrentState() )
|
|
|
|
// nothing to do
|
|
|
|
return 1L;
|
|
|
|
|
2005-03-11 09:42:03 +00:00
|
|
|
if(IsInCallOfLink())
|
|
|
|
return 0;
|
|
|
|
SetInCallOfLink( true );
|
|
|
|
|
2004-05-19 13:01:33 +00:00
|
|
|
sal_Int32 nCurrentIndex = m_pImpl->getStateIndexInPath( getCurrentState(), m_pImpl->nActivePath );
|
|
|
|
sal_Int32 nNewIndex = m_pImpl->getStateIndexInPath( nCurItemId, m_pImpl->nActivePath );
|
|
|
|
|
|
|
|
DBG_ASSERT( ( nCurrentIndex != -1 ) && ( nNewIndex != -1 ),
|
|
|
|
"RoadmapWizard::OnRoadmapItemSelected: something's wrong here!" );
|
|
|
|
if ( ( nCurrentIndex == -1 ) || ( nNewIndex == -1 ) )
|
2005-03-11 09:42:03 +00:00
|
|
|
{
|
|
|
|
SetInCallOfLink( false );
|
2004-05-19 13:01:33 +00:00
|
|
|
return 0L;
|
2005-03-11 09:42:03 +00:00
|
|
|
}
|
2004-05-19 13:01:33 +00:00
|
|
|
|
|
|
|
sal_Bool bResult = sal_True;
|
|
|
|
if ( nNewIndex > nCurrentIndex )
|
2004-09-20 12:38:02 +00:00
|
|
|
{
|
2004-05-19 13:01:33 +00:00
|
|
|
bResult = skipUntil( (WizardState)nCurItemId );
|
2004-09-20 12:38:02 +00:00
|
|
|
WizardState nTemp = (WizardState)nCurItemId;
|
|
|
|
while( nTemp )
|
|
|
|
{
|
|
|
|
if( m_pImpl->aDisabledStates.find( --nTemp ) != m_pImpl->aDisabledStates.end() )
|
|
|
|
removePageFromHistory( nTemp );
|
|
|
|
}
|
|
|
|
}
|
2004-05-19 13:01:33 +00:00
|
|
|
else
|
|
|
|
bResult = skipBackwardUntil( (WizardState)nCurItemId );
|
|
|
|
|
|
|
|
if ( !bResult )
|
|
|
|
m_pImpl->pRoadmap->SelectRoadmapItemByID( getCurrentState() );
|
|
|
|
|
2005-03-11 09:42:03 +00:00
|
|
|
SetInCallOfLink( false );
|
2004-05-19 13:01:33 +00:00
|
|
|
return 1L;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
void RoadmapWizard::enterState( WizardState _nState )
|
|
|
|
{
|
|
|
|
DBG_CHKTHIS( RoadmapWizard, CheckInvariants );
|
|
|
|
|
|
|
|
OWizardMachine::enterState( _nState );
|
|
|
|
|
|
|
|
// synchronize the roadmap
|
|
|
|
implUpdateRoadmap( );
|
|
|
|
m_pImpl->pRoadmap->SelectRoadmapItemByID( getCurrentState() );
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
void RoadmapWizard::enableState( WizardState _nState, bool _bEnable )
|
|
|
|
{
|
|
|
|
DBG_CHKTHIS( RoadmapWizard, CheckInvariants );
|
|
|
|
|
|
|
|
// remember this (in case the state appears in the roadmap later on)
|
|
|
|
if ( _bEnable )
|
|
|
|
m_pImpl->aDisabledStates.erase( _nState );
|
|
|
|
else
|
2004-09-20 12:38:02 +00:00
|
|
|
{
|
2004-05-19 13:01:33 +00:00
|
|
|
m_pImpl->aDisabledStates.insert( _nState );
|
2004-09-20 12:38:02 +00:00
|
|
|
removePageFromHistory( _nState );
|
|
|
|
}
|
2004-05-19 13:01:33 +00:00
|
|
|
|
|
|
|
// if the state is currently in the roadmap, reflect it's new status
|
|
|
|
m_pImpl->pRoadmap->EnableRoadmapItem( (RoadmapTypes::ItemId)_nState, _bEnable );
|
|
|
|
}
|
2004-10-27 12:23:22 +00:00
|
|
|
|
2005-02-17 10:16:10 +00:00
|
|
|
//--------------------------------------------------------------------
|
2004-10-27 12:23:22 +00:00
|
|
|
void RoadmapWizard::Resize()
|
|
|
|
{
|
|
|
|
OWizardMachine::Resize();
|
2005-02-17 10:16:10 +00:00
|
|
|
|
|
|
|
if ( IsReallyShown() && !IsInInitShow() )
|
|
|
|
ResizeFixedLine();
|
2004-10-27 12:23:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-02-17 10:16:10 +00:00
|
|
|
//--------------------------------------------------------------------
|
2004-11-26 19:41:03 +00:00
|
|
|
void RoadmapWizard::StateChanged( StateChangedType nType )
|
|
|
|
{
|
|
|
|
WizardDialog::StateChanged( nType );
|
2005-02-17 10:16:10 +00:00
|
|
|
|
|
|
|
if ( nType == STATE_CHANGE_INITSHOW )
|
|
|
|
ResizeFixedLine();
|
2004-11-26 19:41:03 +00:00
|
|
|
}
|
2004-10-27 12:23:22 +00:00
|
|
|
|
2005-02-17 10:16:10 +00:00
|
|
|
//--------------------------------------------------------------------
|
2004-11-26 19:41:03 +00:00
|
|
|
void RoadmapWizard::ResizeFixedLine()
|
2004-10-27 12:23:22 +00:00
|
|
|
{
|
2005-02-17 10:16:10 +00:00
|
|
|
Size aSize( m_pImpl->pRoadmap->GetSizePixel() );
|
|
|
|
aSize.Width() = m_pImpl->pFixedLine->GetSizePixel().Width();
|
|
|
|
m_pImpl->pFixedLine->SetSizePixel( aSize );
|
2004-10-27 12:23:22 +00:00
|
|
|
}
|
|
|
|
|
2004-09-20 12:38:02 +00:00
|
|
|
//--------------------------------------------------------------------
|
|
|
|
void RoadmapWizard::updateRoadmapItemLabel( WizardState _nState )
|
|
|
|
{
|
|
|
|
Paths::const_iterator aActivePathPos = m_pImpl->aPaths.find( m_pImpl->nActivePath );
|
|
|
|
RoadmapTypes::ItemIndex nUpperStepBoundary = (RoadmapTypes::ItemIndex)aActivePathPos->second.size();
|
|
|
|
RoadmapTypes::ItemIndex nLoopUntil = ::std::max( (RoadmapTypes::ItemIndex)nUpperStepBoundary, m_pImpl->pRoadmap->GetItemCount() );
|
|
|
|
sal_Int32 nCurrentStatePathIndex = -1;
|
|
|
|
if ( m_pImpl->nActivePath != -1 )
|
|
|
|
nCurrentStatePathIndex = m_pImpl->getStateIndexInPath( getCurrentState(), m_pImpl->nActivePath );
|
|
|
|
for ( RoadmapTypes::ItemIndex nItemIndex = nCurrentStatePathIndex; nItemIndex < nLoopUntil; ++nItemIndex )
|
|
|
|
{
|
|
|
|
bool bExistentItem = ( nItemIndex < m_pImpl->pRoadmap->GetItemCount() );
|
|
|
|
if ( bExistentItem )
|
|
|
|
{
|
|
|
|
// 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 );
|
|
|
|
WizardState nRequiredState = aActivePathPos->second[ nItemIndex ];
|
|
|
|
if ( _nState == nRequiredState )
|
|
|
|
{
|
|
|
|
m_pImpl->pRoadmap->ChangeRoadmapItemLabel( nPresentItemId, getStateDisplayName( nRequiredState ) );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-05-19 13:01:33 +00:00
|
|
|
|
|
|
|
//........................................................................
|
|
|
|
} // namespace svt
|
|
|
|
//........................................................................
|