Tag: cws_dev300_dba31c User: fs Date: 2008-09-03 11:56:18+0000 Modified: dba/dbaccess/inc/genericcontroller.hxx dba/dbaccess/source/ui/app/AppController.cxx dba/dbaccess/source/ui/app/AppDetailPageHelper.cxx dba/dbaccess/source/ui/browser/genericcontroller.cxx dba/dbaccess/source/ui/control/dbtreelistbox.cxx
Log: copying the fix for #i92508# into this CWS, to be able to fix #i93424# based on this File Changes: Directory: /dba/dbaccess/inc/ ============================= File [changed]: genericcontroller.hxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/inc/genericcontroller.hxx?r1=1.13&r2=1.13.38.1 Delta lines: +19 -15 --------------------- --- genericcontroller.hxx 2008-06-25 14:51:16+0000 1.13 +++ genericcontroller.hxx 2008-09-03 11:56:14+0000 1.13.38.1 @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: genericcontroller.hxx,v $ - * $Revision: 1.13 $ + * $Revision: 1.13.38.1 $ * * This file is part of OpenOffice.org. * @@ -77,7 +77,7 @@ // ==================================================================== // = optional // ==================================================================== - /** convenience wrapper around boost::optional, allowing type assignments + /** convenience wrapper around boost::optional, allowing typed assignments */ template < typename T > class optional : public ::boost::optional< T > @@ -134,21 +134,20 @@ // = helper // ==================================================================== - // -------------------------------------------------------------------- // .................................................................... struct ControllerFeature : public ::com::sun::star::frame::DispatchInformation { sal_uInt16 nFeatureId; }; + // .................................................................... typedef ::std::map < ::rtl::OUString , ControllerFeature , ::std::less< ::rtl::OUString > > SupportedFeatures; - /// binary_function Functor object for class SupportedFeatures::value_type returntype is bool // .................................................................... - struct SupportedFeaturesEqualId : ::std::binary_function< SupportedFeatures::value_type, sal_Int32, bool > + struct CompareFeatureById : ::std::binary_function< SupportedFeatures::value_type, sal_Int32, bool > { // ................................................................ inline bool operator()( const SupportedFeatures::value_type& _aType, const sal_Int32& _nId ) const @@ -157,30 +156,29 @@ } }; - // -------------------------------------------------------------------- // .................................................................... - typedef struct FeatureStruct + struct FeatureListener { ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener > xListener; sal_Int32 nId; sal_Bool bForceBroadcast; - } FeaturePair; + }; // .................................................................... - typedef ::std::deque< FeaturePair > FeaturePairDeque; + typedef ::std::deque< FeatureListener > FeatureListeners; - /// binary_function Functor object for class FeaturePair returntype is bool // .................................................................... - struct FeaturePairFunctor : ::std::binary_function< FeaturePair, ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >, bool > + struct FindFeatureListener : ::std::binary_function< FeatureListener, ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >, bool > { // ................................................................ - inline bool operator()( const FeaturePair& lhs, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& rhs ) const + inline bool operator()( const FeatureListener& lhs, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& rhs ) const { return !!( lhs.xListener == rhs ); } }; + // .................................................................... typedef ::comphelper::OBaseMutex OGenericUnoController_MBASE; typedef ::cppu::WeakComponentImplHelper11 < ::com::sun::star::frame::XDispatch @@ -230,7 +228,7 @@ DECLARE_STL_MAP( sal_uInt16, FeatureState, ::std::less< sal_uInt16 >, StateCache ); DECLARE_STL_VECTOR( DispatchTarget, Dispatch); - FeaturePairDeque m_aFeaturesToInvalidate; + FeatureListeners m_aFeaturesToInvalidate; ::osl::Mutex m_aFeatureMutex; // locked when features are append to or remove from deque StateCache m_aStateCache; // save the current status of feature state @@ -339,7 +337,13 @@ @see IController::registerCommandURL */ - bool isUserDefinedFeature( const sal_uInt16 nFeatureId ); + bool isUserDefinedFeature( const sal_uInt16 nFeatureId ) const; + + /** determines whether the given feature URL denotes a user-defined feature + + @see IController::registerCommandURL + */ + bool isUserDefinedFeature( const ::rtl::OUString& _rFeatureURL ) const; // connect to a datasource ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > connect( Directory: /dba/dbaccess/source/ui/app/ ======================================= File [changed]: AppController.cxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/app/AppController.cxx?r1=1.65&r2=1.65.2.1 Delta lines: +5 -3 ------------------- --- AppController.cxx 2008-08-19 09:54:27+0000 1.65 +++ AppController.cxx 2008-09-03 11:56:14+0000 1.65.2.1 @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: AppController.cxx,v $ - * $Revision: 1.65 $ + * $Revision: 1.65.2.1 $ * * This file is part of OpenOffice.org. * @@ -3032,7 +3032,9 @@ ::osl::MutexGuard aGuard(m_aMutex); Sequence< NamedDatabaseObject > aCurrentSelection; - getContainer()->describeCurrentSelectionForType( getContainer()->getElementType(), aCurrentSelection ); + const ElementType eType( getContainer()->getElementType() ); + if ( eType != E_NONE ) + getContainer()->describeCurrentSelectionForType( eType, aCurrentSelection ); return makeAny( aCurrentSelection ); } // ----------------------------------------------------------------------------- File [changed]: AppDetailPageHelper.cxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/app/AppDetailPageHelper.cxx?r1=1.33&r2=1.33.38.1 Delta lines: +3 -3 ------------------- --- AppDetailPageHelper.cxx 2008-06-25 12:36:31+0000 1.33 +++ AppDetailPageHelper.cxx 2008-09-03 11:56:14+0000 1.33.38.1 @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: AppDetailPageHelper.cxx,v $ - * $Revision: 1.33 $ + * $Revision: 1.33.38.1 $ * * This file is part of OpenOffice.org. * @@ -473,7 +473,7 @@ void OAppDetailPageHelper::describeCurrentSelectionForType( const ElementType _eType, Sequence< NamedDatabaseObject >& _out_rSelectedObjects ) { OSL_ENSURE( _eType < E_ELEMENT_TYPE_COUNT, "OAppDetailPageHelper::describeCurrentSelectionForType: invalid type!" ); - DBTreeListBox* pList = m_pLists[ _eType ]; + DBTreeListBox* pList = ( _eType < E_ELEMENT_TYPE_COUNT ) ? m_pLists[ _eType ] : NULL; OSL_ENSURE( pList, "OAppDetailPageHelper::describeCurrentSelectionForType: " "You really should ensure this type has already been viewed before!" ); if ( !pList ) Directory: /dba/dbaccess/source/ui/browser/ =========================================== File [changed]: genericcontroller.cxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/browser/genericcontroller.cxx?r1=1.94&r2=1.94.38.1 Delta lines: +109 -52 ---------------------- --- genericcontroller.cxx 2008-06-26 11:43:10+0000 1.94 +++ genericcontroller.cxx 2008-09-03 11:56:15+0000 1.94.38.1 @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: genericcontroller.cxx,v $ - * $Revision: 1.94 $ + * $Revision: 1.94.38.1 $ * * This file is part of OpenOffice.org. * @@ -170,14 +170,76 @@ { //========================================================================== +//= UserDefinedFeatures +//========================================================================== +class UserDefinedFeatures +{ +public: + UserDefinedFeatures( const Reference< XController >& _rxController ); + + FeatureState getState( const URL& _rFeatureURL ); + void execute( const URL& _rFeatureURL, const Sequence< PropertyValue>& _rArgs ); + +private: + ::com::sun::star::uno::WeakReference< XController > m_aController; +}; + +//-------------------------------------------------------------------------- +UserDefinedFeatures::UserDefinedFeatures( const Reference< XController >& _rxController ) + :m_aController( _rxController ) +{ +} + +//-------------------------------------------------------------------------- +FeatureState UserDefinedFeatures::getState( const URL& /*_rFeatureURL*/ ) +{ + // for now, enable all the time + // TODO: we should ask the dispatcher. However, this is laborious, since you cannot ask a dispatcher + // directly, but need to add a status listener. + FeatureState aState; + aState.bEnabled = sal_True; + return aState; +} + +//-------------------------------------------------------------------------- +void UserDefinedFeatures::execute( const URL& _rFeatureURL, const Sequence< PropertyValue>& _rArgs ) +{ + try + { + Reference< XController > xController( (Reference< XController >)m_aController, UNO_SET_THROW ); + Reference< XDispatchProvider > xDispatchProvider( xController->getFrame(), UNO_QUERY_THROW ); + Reference< XDispatch > xDispatch( xDispatchProvider->queryDispatch( + _rFeatureURL, + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "_self" ) ), + FrameSearchFlag::AUTO + ) ); + + if ( xDispatch == xController ) + { + OSL_ENSURE( false, "UserDefinedFeatures::execute: the controller shouldn't be the dispatcher here!" ); + xDispatch.clear(); + } + + if ( xDispatch.is() ) + xDispatch->dispatch( _rFeatureURL, _rArgs ); + } + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } +} + +//========================================================================== //= OGenericUnoController_Data //========================================================================== struct OGenericUnoController_Data { ::sfx2::UserInputInterception m_aUserInputInterception; + UserDefinedFeatures m_aUserDefinedFeatures; OGenericUnoController_Data( OGenericUnoController& _rController, ::osl::Mutex& _rMutex ) :m_aUserInputInterception( _rController, _rMutex ) + ,m_aUserDefinedFeatures( _rController.getXController() ) { } }; @@ -189,7 +251,6 @@ // ------------------------------------------------------------------------- OGenericUnoController::OGenericUnoController(const Reference< XMultiServiceFactory >& _rM) :OGenericUnoController_Base(m_aMutex) - ,m_pData( new OGenericUnoController_Data( *this, m_aMutex ) ) #ifdef DBG_UTIL ,m_bDescribingSupportedFeatures( false ) #endif @@ -203,6 +264,12 @@ ,m_bCurrentlyModified(sal_False) ,m_bExternalTitle(sal_False) { + osl_incrementInterlockedCount( &m_refCount ); + { + m_pData.reset( new OGenericUnoController_Data( *this, m_aMutex ) ); + } + osl_decrementInterlockedCount( &m_refCount ); + DBG_CTOR(OGenericUnoController,NULL); try @@ -218,7 +285,6 @@ // ----------------------------------------------------------------------------- OGenericUnoController::OGenericUnoController() :OGenericUnoController_Base(m_aMutex) - ,m_pData( new OGenericUnoController_Data( *this, m_aMutex ) ) #ifdef DBG_UTIL ,m_bDescribingSupportedFeatures( false ) #endif @@ -559,7 +625,7 @@ SupportedFeatures::iterator aFeaturePos = ::std::find_if( m_aSupportedFeatures.begin(), m_aSupportedFeatures.end(), - ::std::bind2nd( SupportedFeaturesEqualId(), _nId ) + ::std::bind2nd( CompareFeatureById(), _nId ) ); return ( m_aSupportedFeatures.end() != aFeaturePos && aFeaturePos->first.getLength()); @@ -580,7 +646,7 @@ #endif sal_Bool bEmpty = sal_True; - FeaturePair aNextFeature; + FeatureListener aNextFeature; { ::osl::MutexGuard aGuard( m_aFeatureMutex); bEmpty = m_aFeaturesToInvalidate.empty(); @@ -599,7 +665,7 @@ SupportedFeatures::iterator aFeaturePos = ::std::find_if( m_aSupportedFeatures.begin(), m_aSupportedFeatures.end(), - ::std::bind2nd( SupportedFeaturesEqualId(), aNextFeature.nId ) + ::std::bind2nd( CompareFeatureById(), aNextFeature.nId ) ); #if OSL_DEBUG_LEVEL > 0 @@ -631,16 +697,16 @@ // ----------------------------------------------------------------------- void OGenericUnoController::ImplInvalidateFeature( sal_Int32 _nId, const Reference< XStatusListener >& _xListener, sal_Bool _bForceBroadcast ) { - FeaturePair aPair; - aPair.nId = _nId; - aPair.xListener = _xListener; - aPair.bForceBroadcast = _bForceBroadcast; + FeatureListener aListener; + aListener.nId = _nId; + aListener.xListener = _xListener; + aListener.bForceBroadcast = _bForceBroadcast; sal_Bool bWasEmpty; { - ::osl::MutexGuard aGuard( m_aFeatureMutex); + ::osl::MutexGuard aGuard( m_aFeatureMutex ); bWasEmpty = m_aFeaturesToInvalidate.empty(); - m_aFeaturesToInvalidate.push_back(aPair); + m_aFeaturesToInvalidate.push_back( aListener ); } if ( bWasEmpty ) @@ -691,7 +757,9 @@ // URL's we can handle ourself? if ( aURL.Complete.equals( getConfirmDeletionURL() ) - || ( m_aSupportedFeatures.find( aURL.Complete ) != m_aSupportedFeatures.end() ) + || ( ( m_aSupportedFeatures.find( aURL.Complete ) != m_aSupportedFeatures.end() ) + && !isUserDefinedFeature( aURL.Complete ) + ) ) { xReturn = this; @@ -825,11 +893,11 @@ } // now remove the listener from the deque - ::osl::MutexGuard aGuard( m_aFeatureMutex); + ::osl::MutexGuard aGuard( m_aFeatureMutex ); m_aFeaturesToInvalidate.erase( ::std::remove_if( m_aFeaturesToInvalidate.begin(), m_aFeaturesToInvalidate.end(), - ::std::bind2nd(FeaturePairFunctor(),aListener)) + ::std::bind2nd(FindFeatureListener(),aListener)) ,m_aFeaturesToInvalidate.end()); } @@ -932,24 +1000,20 @@ } //------------------------------------------------------------------------------ -FeatureState OGenericUnoController::GetState(sal_uInt16 nId) const +FeatureState OGenericUnoController::GetState( sal_uInt16 _nId ) const { FeatureState aReturn; // (disabled automatically) - try - { - switch (nId) + switch ( _nId ) { case ID_BROWSER_UNDO: case ID_BROWSER_SAVEDOC: aReturn.bEnabled = sal_True; break; - } - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); + default: + aReturn = m_pData->m_aUserDefinedFeatures.getState( getURLForId( _nId ) ); + break; } return aReturn; @@ -960,27 +1024,10 @@ { OSL_ENSURE( isUserDefinedFeature( _nId ), "OGenericUnoController::Execute: responsible for user defined features only!" ); - URL aFeatureURL( getURLForId( _nId ) ); - - // user defined features can be handled by dispatch interceptors only. So, we need to do - // a queryDispatch, and dispatch the URL - try - { - Reference< XDispatch > xDispatch( queryDispatch( - aFeatureURL, - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "_self" ) ), - FrameSearchFlag::AUTO - ) ); - if ( xDispatch == *this ) - xDispatch.clear(); - if ( xDispatch.is() ) - xDispatch->dispatch( aFeatureURL, _rArgs ); - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION(); - } + // user defined features can be handled by dispatch interceptors resp. protocol handlers only. + // So, we need to do a queryDispatch, and dispatch the URL + m_pData->m_aUserDefinedFeatures.execute( getURLForId( _nId ), _rArgs ); } //------------------------------------------------------------------------------ @@ -992,7 +1039,7 @@ SupportedFeatures::const_iterator aIter = ::std::find_if( m_aSupportedFeatures.begin(), m_aSupportedFeatures.end(), - ::std::bind2nd( SupportedFeaturesEqualId(), _nId ) + ::std::bind2nd( CompareFeatureById(), _nId ) ); if ( m_aSupportedFeatures.end() != aIter && aIter->first.getLength() ) @@ -1005,12 +1052,22 @@ } //------------------------------------------------------------------------- -bool OGenericUnoController::isUserDefinedFeature( const sal_uInt16 _nFeatureId ) +bool OGenericUnoController::isUserDefinedFeature( const sal_uInt16 _nFeatureId ) const { return ( _nFeatureId >= FIRST_USER_DEFINED_FEATURE ) && ( _nFeatureId < LAST_USER_DEFINED_FEATURE ); } //------------------------------------------------------------------------- +bool OGenericUnoController::isUserDefinedFeature( const ::rtl::OUString& _rFeatureURL ) const +{ + SupportedFeatures::const_iterator pos = m_aSupportedFeatures.find( _rFeatureURL ); + OSL_PRECOND( pos != m_aSupportedFeatures.end(), + "OGenericUnoController::isUserDefinedFeature: this is no supported feature at all!" ); + + return ( pos != m_aSupportedFeatures.end() ) ? isUserDefinedFeature( pos->second.nFeatureId ) : false; +} + +//------------------------------------------------------------------------- sal_Bool SAL_CALL OGenericUnoController::supportsService(const ::rtl::OUString& ServiceName) throw(RuntimeException) { Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames()); Directory: /dba/dbaccess/source/ui/control/ =========================================== File [changed]: dbtreelistbox.cxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/control/dbtreelistbox.cxx?r1=1.20&r2=1.20.40.1 Delta lines: +17 -4 -------------------- --- dbtreelistbox.cxx 2008-06-25 12:43:33+0000 1.20 +++ dbtreelistbox.cxx 2008-09-03 11:56:15+0000 1.20.40.1 @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: dbtreelistbox.cxx,v $ - * $Revision: 1.20 $ + * $Revision: 1.20.40.1 $ * * This file is part of OpenOffice.org. * @@ -562,6 +562,10 @@ USHORT nCount = _rMenu.GetItemCount(); for ( USHORT pos = 0; pos < nCount; ++pos ) { + // do not adjust separators + if ( _rMenu.GetItemType( pos ) == MENUITEM_SEPARATOR ) + continue; + USHORT nId = _rMenu.GetItemId(pos); String aCommand = _rMenu.GetItemCommand( nId ); PopupMenu* pPopup = _rMenu.GetPopupMenu( nId ); @@ -572,7 +576,16 @@ } USHORT nCommandId = _rCommandController.registerCommandURL( aCommand ); - _rMenu.InsertItem( nCommandId, _rMenu.GetItemText( nId ), _rMenu.GetItemBits( nId ), pos ); + _rMenu.InsertItem( nCommandId, _rMenu.GetItemText( nId ), _rMenu.GetItemImage( nId ), + _rMenu.GetItemBits( nId ), pos ); + + // more things to preserve: + // - the help command + ::rtl::OUString sHelpURL = _rMenu.GetHelpCommand( nId ); + if ( sHelpURL.getLength() ) + _rMenu.SetHelpCommand( nCommandId, sHelpURL ); + + // remove the "old" item _rMenu.RemoveItem( pos+1 ); } } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
