diff options
author | Kurt Zenker <kz@openoffice.org> | 2004-05-19 12:37:08 +0000 |
---|---|---|
committer | Kurt Zenker <kz@openoffice.org> | 2004-05-19 12:37:08 +0000 |
commit | 38b4990621104ed383f7abb968e49fda8b34a707 (patch) | |
tree | c686a4bbd10618e8a58862958b346bfb9fd82226 | |
parent | 9f2d1f1c0326a0a41883e992d08542ab27b89841 (diff) |
INTEGRATION: CWS qwizards1 (1.6.54); FILE MERGED
2004/04/05 12:50:05 fs 1.6.54.1: #i27457# must changes in the base class
-rw-r--r-- | extensions/source/abpilot/abspilot.cxx | 171 |
1 files changed, 158 insertions, 13 deletions
diff --git a/extensions/source/abpilot/abspilot.cxx b/extensions/source/abpilot/abspilot.cxx index e779e0f8ca35..fb30319f20bf 100644 --- a/extensions/source/abpilot/abspilot.cxx +++ b/extensions/source/abpilot/abspilot.cxx @@ -2,9 +2,9 @@ * * $RCSfile: abspilot.cxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: vg $ $Date: 2003-06-02 08:03:13 $ + * last change: $Author: kz $ $Date: 2004-05-19 13:37:08 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -74,6 +74,9 @@ #ifndef _TOOLS_DEBUG_HXX #include <tools/debug.hxx> #endif +#ifndef _SVTOOLS_LOCALRESACCESS_HXX_ +#include <svtools/localresaccess.hxx> +#endif #ifndef EXTENSIONS_ABP_TYPESELECTIONPAGE_HXX #include "typeselectionpage.hxx" #endif @@ -110,6 +113,9 @@ namespace abp #define STATE_MANUAL_FIELD_MAPPING 3 #define STATE_FINAL_CONFIRM 4 +#define PATH_DYN_TABLE_SELECTION 1 // path where we dynamically decide whether we need table selection +#define PATH_LDAP 2 + using namespace ::svt; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::lang; @@ -119,7 +125,12 @@ namespace abp //===================================================================== //--------------------------------------------------------------------- OAddessBookSourcePilot::OAddessBookSourcePilot(Window* _pParent, const Reference< XMultiServiceFactory >& _rxORB) - :OAddessBookSourcePilot_Base(_pParent, ModuleRes(RID_DLG_ADDRESSBOOKSOURCEPILOT), WZB_HELP | WZB_FINISH | WZB_CANCEL | WZB_NEXT | WZB_PREVIOUS) + :OAddessBookSourcePilot_Base( _pParent, ModuleRes( RID_DLG_ADDRESSBOOKSOURCEPILOT ), +#if defined( ABP_USE_ROADMAP ) + WZB_HELP | WZB_FINISH | WZB_CANCEL | WZB_NEXT | WZB_PREVIOUS, ResId( STR_ROADMAP_TITLE ) ) +#else + WZB_HELP | WZB_FINISH | WZB_CANCEL | WZB_NEXT | WZB_PREVIOUS ) +#endif ,m_xORB(_rxORB) ,m_aNewDataSource(_rxORB) ,m_eNewDataSourceType( AST_INVALID ) @@ -128,7 +139,34 @@ namespace abp ShowButtonFixedLine(sal_True); +#if defined( ABP_USE_ROADMAP ) + // we have two paths: One with, and one without table selection + declarePath( PATH_DYN_TABLE_SELECTION, + STATE_SELECT_ABTYPE, + STATE_INVOKE_ADMIN_DIALOG, + STATE_TABLE_SELECTION, + STATE_MANUAL_FIELD_MAPPING, + STATE_FINAL_CONFIRM, + WZS_INVALID_STATE + ); + declarePath( PATH_LDAP, + STATE_SELECT_ABTYPE, + STATE_INVOKE_ADMIN_DIALOG, + STATE_FINAL_CONFIRM, + WZS_INVALID_STATE + ); + // Note that in theory, we could make only one path out of it. But, to determine whether we + // need a table selection page, we need to establish the connection. This is done immediately + // before the pre-table-selection page is left. + // As a result, if we would have only one path, then the user could click the "Table selection" + // in the roadmap, and it could happen that we only at this very moment that we do *not need* + // this page at all - which would look pretty strange to the user. + + // unless told otherwise, don't allow traveling to the last page + enableState( STATE_FINAL_CONFIRM, false ); +#else enableHeader( Bitmap( ModuleRes( BMP_HEADERIMAGE ) ) ); +#endif m_pPrevPage->SetHelpId(HID_ABSPILOT_PREVIOUS); m_pNextPage->SetHelpId(HID_ABSPILOT_NEXT); @@ -151,6 +189,32 @@ namespace abp ActivatePage(); } +#if defined( ABP_USE_ROADMAP ) + //--------------------------------------------------------------------- + String OAddessBookSourcePilot::getStateDisplayName( WizardState _nState ) + { + USHORT nResId = 0; + switch ( _nState ) + { + case STATE_SELECT_ABTYPE: nResId = STR_SELECT_ABTYPE; break; + case STATE_INVOKE_ADMIN_DIALOG: nResId = STR_INVOKE_ADMIN_DIALOG; break; + case STATE_TABLE_SELECTION: nResId = STR_TABLE_SELECTION; break; + case STATE_MANUAL_FIELD_MAPPING: nResId = STR_MANUAL_FIELD_MAPPING; break; + case STATE_FINAL_CONFIRM: nResId = STR_FINAL_CONFIRM; break; + } + DBG_ASSERT( nResId, "OAddessBookSourcePilot::getStateDisplayName: don't know this state!" ); + + String sDisplayName; + if ( nResId ) + { + svt::OLocalResourceAccess aAccess( ModuleRes( RID_DLG_ADDRESSBOOKSOURCEPILOT ), RSC_MODALDIALOG ); + sDisplayName = String( ResId( nResId ) ); + } + + return sDisplayName; + } +#endif + //--------------------------------------------------------------------- void OAddessBookSourcePilot::implCommitAll() { @@ -218,10 +282,16 @@ namespace abp } //--------------------------------------------------------------------- - void OAddessBookSourcePilot::enterState(sal_uInt16 _nState) + void OAddessBookSourcePilot::enterState( WizardState _nState ) { switch ( _nState ) { +#if defined( ABP_USE_ROADMAP ) + case STATE_SELECT_ABTYPE: + implUpdateTypeDependentStates( static_cast< TypeSelectionPage* >( getPage( STATE_SELECT_ABTYPE ) )->getSelectedType() ); + break; +#endif + case STATE_FINAL_CONFIRM: if ( !needManualFieldMapping( ) ) implDoAutoFieldMapping(); @@ -235,23 +305,72 @@ namespace abp OAddessBookSourcePilot_Base::enterState(_nState); } +#if defined( ABP_USE_ROADMAP ) //--------------------------------------------------------------------- - sal_Bool OAddessBookSourcePilot::leaveState(sal_uInt16 _nState) + sal_Bool OAddessBookSourcePilot::prepareLeaveCurrentState( CommitPageReason _eReason ) { - if (!OAddessBookSourcePilot_Base::leaveState(_nState)) + if ( !OAddessBookSourcePilot_Base::prepareLeaveCurrentState( _eReason ) ) return sal_False; - switch ( _nState ) + if ( _eReason == eTravelBackward ) + return sal_True; + + switch ( getCurrentState() ) { - case STATE_SELECT_ABTYPE: - implCreateDataSource(); - // create the data source, if necessary (in some cases, it may already have been created, 'cause it was - // needed for determining the next state) + case STATE_SELECT_ABTYPE: + implCreateDataSource(); + if ( needAdminInvokationPage() ) break; + // no break here + + case STATE_INVOKE_ADMIN_DIALOG: + if ( !connectToDataSource( sal_False ) ) + { + // connecting did not succeed -> do not allow proceeding, and do not + // allow the final page + enableState( STATE_FINAL_CONFIRM, false ); + return sal_False; + } + enableState( STATE_FINAL_CONFIRM, true ); + + if ( m_aSettings.eType == AST_LDAP ) + break; + + // ........................................................ + // now that we connected to the data source, check whether we need the "table selection" page + const StringBag& aTables = m_aNewDataSource.getTableNames(); + enableState( STATE_TABLE_SELECTION, aTables.size() > 1 ); + + bool bNeedFieldMapping = needManualFieldMapping( m_aSettings.eType ); + if ( aTables.size() == 0 ) + { + if ( _eReason == eValidateNoUI ) + // cannot ask the user + return sal_False; + + QueryBox aQuery( this, ModuleRes( RID_QRY_NOTABLES ) ); + if ( RET_YES == aQuery.Execute() ) + { // the user chose to use this data source, though there are no tables + bNeedFieldMapping = false; + } + else + return sal_False; + } + enableState( STATE_MANUAL_FIELD_MAPPING, bNeedFieldMapping ); + + // from now on, we're definately on the "dynamic table selection" path + activatePath( PATH_DYN_TABLE_SELECTION, true ); + + if ( aTables.size() == 1 ) + // remember the one and only table we have + m_aSettings.sSelectedTable = *aTables.begin(); + + break; } return sal_True; } +#endif //--------------------------------------------------------------------- void OAddessBookSourcePilot::implDefaultTableName() @@ -338,7 +457,7 @@ namespace abp } //--------------------------------------------------------------------- - OWizardPage* OAddessBookSourcePilot::createPage(sal_uInt16 _nState) + OWizardPage* OAddessBookSourcePilot::createPage(WizardState _nState) { switch (_nState) { @@ -363,8 +482,33 @@ namespace abp } } +#if defined( ABP_USE_ROADMAP ) + //--------------------------------------------------------------------- + void OAddessBookSourcePilot::implUpdateTypeDependentStates( AddressSourceType _eType ) + { + enableState( STATE_INVOKE_ADMIN_DIALOG, needAdminInvokationPage( _eType ) ); + enableState( STATE_MANUAL_FIELD_MAPPING, needManualFieldMapping( _eType ) ); + } +#endif + //--------------------------------------------------------------------- - sal_uInt16 OAddessBookSourcePilot::determineNextState(sal_uInt16 _nCurrentState) + void OAddessBookSourcePilot::typeSelectionChanged( AddressSourceType _eType ) + { +#if defined( ABP_USE_ROADMAP ) + implUpdateTypeDependentStates( _eType ); + enableState( STATE_FINAL_CONFIRM, false ); + + // for LDAP, there is no "table selection" page + if ( _eType == AST_LDAP ) + activatePath( PATH_LDAP, true ); + else + activatePath( PATH_DYN_TABLE_SELECTION, false ); +#endif + } + +#if !defined( ABP_USE_ROADMAP ) + //--------------------------------------------------------------------- + WizardTypes::WizardState OAddessBookSourcePilot::determineNextState(WizardState _nCurrentState) { switch (_nCurrentState) { @@ -437,6 +581,7 @@ namespace abp DBG_ERROR("OAddessBookSourcePilot::determineNextState: no next state available!"); return WZS_INVALID_STATE; } +#endif //......................................................................... } // namespace abp |