diff options
author | Thorsten Behrens <tbehrens@novell.com> | 2011-04-28 00:12:58 +0200 |
---|---|---|
committer | Thorsten Behrens <tbehrens@novell.com> | 2011-04-28 00:12:58 +0200 |
commit | f51c3f66b1034c9f15171678d1239c25d64341ba (patch) | |
tree | 438eb4b3d4da31d276dcb227da6afce76e165f00 /basic/source/uno | |
parent | b8502c8251b0760f1bf03c968974f1fe3f288ae2 (diff) | |
parent | 86e7ed8c72184b7a04b836848743979aa3f5fd3d (diff) |
Merge commit 'ooo/DEV300_m106' into integration/dev300_m106
Conflicts:
avmedia/source/gstreamer/gstframegrabber.cxx
avmedia/source/gstreamer/gstplayer.cxx
avmedia/source/gstreamer/gstplayer.hxx
basic/inc/basic/sbxdef.hxx
basic/source/classes/sbxmod.cxx
basic/source/comp/makefile.mk
basic/source/comp/sbcomp.cxx
basic/source/inc/namecont.hxx
basic/source/inc/scriptcont.hxx
basic/source/runtime/methods.cxx
basic/source/runtime/runtime.cxx
basic/source/runtime/stdobj.cxx
basic/source/runtime/step1.cxx
basic/source/uno/namecont.cxx
basic/util/makefile.mk
connectivity/source/commontools/predicateinput.cxx
connectivity/source/drivers/dbase/DNoException.cxx
connectivity/source/drivers/dbase/DTable.cxx
connectivity/source/drivers/file/fcomp.cxx
connectivity/source/drivers/jdbc/JConnection.cxx
connectivity/source/drivers/odbcbase/OResultSet.cxx
connectivity/source/drivers/odbcbase/OStatement.cxx
connectivity/source/parse/sqlnode.cxx
desktop/source/app/app.cxx
drawinglayer/inc/drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx
drawinglayer/source/processor2d/vclprocessor2d.cxx
formula/inc/formula/token.hxx
formula/source/core/api/token.cxx
fpicker/source/win32/filepicker/VistaFilePickerImpl.hxx
fpicker/source/win32/filepicker/platform_vista.h
framework/source/helper/persistentwindowstate.cxx
framework/source/uielement/menubarmanager.cxx
oovbaapi/ooo/vba/XFoundFiles.idl
oovbaapi/ooo/vba/excel/XApplication.idl
oovbaapi/ooo/vba/msforms/XCheckBox.idl
oovbaapi/ooo/vba/msforms/XComboBox.idl
oovbaapi/ooo/vba/msforms/XControl.idl
oovbaapi/ooo/vba/msforms/XGroupBox.idl
oovbaapi/ooo/vba/msforms/XLabel.idl
oovbaapi/ooo/vba/msforms/XListBox.idl
oovbaapi/ooo/vba/msforms/XNewFont.idl
oovbaapi/ooo/vba/msforms/XRadioButton.idl
oovbaapi/ooo/vba/msforms/XTextBox.idl
oovbaapi/ooo/vba/msforms/XToggleButton.idl
scripting/source/dlgprov/dlgevtatt.cxx
sfx2/source/control/unoctitm.cxx
sfx2/source/doc/objstor.cxx
sfx2/source/doc/objxtor.cxx
svx/inc/svx/svdograf.hxx
svx/source/form/fmpage.cxx
svx/source/form/fmpgeimp.cxx
svx/source/svdraw/svdedtv.cxx
svx/source/svdraw/svdfmtf.cxx
svx/source/svdraw/svdograf.cxx
svx/source/svdraw/svdouno.cxx
svx/source/xml/xmlgrhlp.cxx
uui/source/iahndl-ssl.cxx
vbahelper/Library_msforms.mk
vbahelper/Library_vbahelper.mk
vbahelper/inc/vbahelper/vbahelper.hxx
vbahelper/prj/build.lst
vbahelper/source/msforms/vbacombobox.cxx
vbahelper/source/msforms/vbacontrol.cxx
vbahelper/source/msforms/vbacontrols.cxx
vbahelper/source/msforms/vbaframe.cxx
vbahelper/source/msforms/vbaframe.hxx
vbahelper/source/msforms/vbalabel.cxx
vbahelper/source/msforms/vbalabel.hxx
vbahelper/source/msforms/vbalistbox.cxx
vbahelper/source/msforms/vbalistbox.hxx
vbahelper/source/msforms/vbamultipage.cxx
vbahelper/source/msforms/vbatogglebutton.cxx
vbahelper/source/msforms/vbauserform.cxx
vbahelper/source/vbahelper/vbacommandbar.cxx
vbahelper/source/vbahelper/vbacommandbarcontrol.cxx
vbahelper/source/vbahelper/vbacommandbarcontrols.hxx
vbahelper/source/vbahelper/vbahelper.cxx
vbahelper/source/vbahelper/vbawindowbase.cxx
xmloff/source/meta/xmlmetai.cxx
xmloff/source/style/PageMasterExportPropMapper.cxx
xmloff/source/style/PageMasterStyleMap.cxx
xmloff/source/text/txtexppr.cxx
xmloff/source/text/txtprmap.cxx
Diffstat (limited to 'basic/source/uno')
-rw-r--r-- | basic/source/uno/namecont.cxx | 233 |
1 files changed, 165 insertions, 68 deletions
diff --git a/basic/source/uno/namecont.cxx b/basic/source/uno/namecont.cxx index e1e7fd3cf5f6..72208e516350 100644 --- a/basic/source/uno/namecont.cxx +++ b/basic/source/uno/namecont.cxx @@ -35,9 +35,7 @@ #include <com/sun/star/lang/XServiceInfo.hpp> #include <vcl/svapp.hxx> #include <osl/mutex.hxx> -#ifndef __RSC //autogen #include <tools/errinf.hxx> -#endif #include <osl/mutex.hxx> #include <osl/diagnose.h> #include <rtl/uri.hxx> @@ -64,7 +62,8 @@ #include <com/sun/star/uno/DeploymentException.hpp> #include <com/sun/star/lang/DisposedException.hpp> #include <com/sun/star/script/LibraryNotLoadedException.hpp> -#include "com/sun/star/deployment/ExtensionManager.hpp" +#include <com/sun/star/script/vba/VBAScriptEventId.hpp> +#include <com/sun/star/deployment/ExtensionManager.hpp> #include <comphelper/storagehelper.hxx> #include <comphelper/anytostring.hxx> #include <cppuhelper/exc_hlp.hxx> @@ -167,25 +166,29 @@ void NameContainer::replaceByName( const OUString& aName, const Any& aElement ) // Fire event - ContainerEvent aEvent; - aEvent.Source = mpxEventSource; - aEvent.Accessor <<= aName; - aEvent.Element = aElement; - aEvent.ReplacedElement = aOldElement; + if( maContainerListeners.getLength() > 0 ) + { + ContainerEvent aEvent; + aEvent.Source = mpxEventSource; + aEvent.Accessor <<= aName; + aEvent.Element = aElement; + aEvent.ReplacedElement = aOldElement; + maContainerListeners.notifyEach( &XContainerListener::elementReplaced, aEvent ); + } - OInterfaceIteratorHelper aIterator( maListenerContainer ); - while( aIterator.hasMoreElements() ) + /* After the container event has been fired (one listener will update the + core Basic manager), fire change event. Listeners can rely that the + Basic source code of the core Basic manager is up-to-date. */ + if( maChangesListeners.getLength() > 0 ) { - Reference< XInterface > xIface = aIterator.next(); - Reference< XContainerListener > xListener( xIface, UNO_QUERY ); - try - { - xListener->elementReplaced( aEvent ); - } - catch(RuntimeException&) - { - aIterator.remove(); - } + ChangesEvent aEvent; + aEvent.Source = mpxEventSource; + aEvent.Base <<= aEvent.Source; + aEvent.Changes.realloc( 1 ); + aEvent.Changes[ 0 ].Accessor <<= aName; + aEvent.Changes[ 0 ].Element <<= aElement; + aEvent.Changes[ 0 ].ReplacedElement = aOldElement; + maChangesListeners.notifyEach( &XChangesListener::changesOccurred, aEvent ); } } @@ -213,33 +216,35 @@ void NameContainer::insertByName( const OUString& aName, const Any& aElement ) mHashMap[ aName ] = nCount; mnElementCount++; - // Fire event - ContainerEvent aEvent; - aEvent.Source = mpxEventSource; - aEvent.Accessor <<= aName; - aEvent.Element = aElement; + if( maContainerListeners.getLength() > 0 ) + { + ContainerEvent aEvent; + aEvent.Source = mpxEventSource; + aEvent.Accessor <<= aName; + aEvent.Element = aElement; + maContainerListeners.notifyEach( &XContainerListener::elementInserted, aEvent ); + } - OInterfaceIteratorHelper aIterator( maListenerContainer ); - while( aIterator.hasMoreElements() ) + /* After the container event has been fired (one listener will update the + core Basic manager), fire change event. Listeners can rely that the + Basic source code of the core Basic manager is up-to-date. */ + if( maChangesListeners.getLength() > 0 ) { - Reference< XInterface > xIface = aIterator.next(); - Reference< XContainerListener > xListener( xIface, UNO_QUERY ); - try - { - xListener->elementInserted( aEvent ); - } - catch(RuntimeException&) - { - aIterator.remove(); - } + ChangesEvent aEvent; + aEvent.Source = mpxEventSource; + aEvent.Base <<= aEvent.Source; + aEvent.Changes.realloc( 1 ); + aEvent.Changes[ 0 ].Accessor <<= aName; + aEvent.Changes[ 0 ].Element <<= aElement; + maChangesListeners.notifyEach( &XChangesListener::changesOccurred, aEvent ); } } -void NameContainer::removeByName( const OUString& Name ) +void NameContainer::removeByName( const OUString& aName ) throw(NoSuchElementException, WrappedTargetException, RuntimeException) { - NameContainerNameMap::iterator aIt = mHashMap.find( Name ); + NameContainerNameMap::iterator aIt = mHashMap.find( aName ); if( aIt == mHashMap.end() ) { throw NoSuchElementException(); @@ -261,26 +266,29 @@ void NameContainer::removeByName( const OUString& Name ) mValues.realloc( iLast ); mnElementCount--; - // Fire event - ContainerEvent aEvent; - aEvent.Source = mpxEventSource; - aEvent.Accessor <<= Name; - aEvent.Element = aOldElement; + if( maContainerListeners.getLength() > 0 ) + { + ContainerEvent aEvent; + aEvent.Source = mpxEventSource; + aEvent.Accessor <<= aName; + aEvent.Element = aOldElement; + maContainerListeners.notifyEach( &XContainerListener::elementRemoved, aEvent ); + } - OInterfaceIteratorHelper aIterator( maListenerContainer ); - while( aIterator.hasMoreElements() ) + /* After the container event has been fired (one listener will update the + core Basic manager), fire change event. Listeners can rely that the + Basic source code of the core Basic manager is up-to-date. */ + if( maChangesListeners.getLength() > 0 ) { - Reference< XInterface > xIface = aIterator.next(); - Reference< XContainerListener > xListener( xIface, UNO_QUERY ); - try - { - xListener->elementRemoved( aEvent ); - } - catch(RuntimeException&) - { - aIterator.remove(); - } + ChangesEvent aEvent; + aEvent.Source = mpxEventSource; + aEvent.Base <<= aEvent.Source; + aEvent.Changes.realloc( 1 ); + aEvent.Changes[ 0 ].Accessor <<= aName; + // aEvent.Changes[ 0 ].Element remains empty (meaning "replaced with nothing") + aEvent.Changes[ 0 ].ReplacedElement = aOldElement; + maChangesListeners.notifyEach( &XChangesListener::changesOccurred, aEvent ); } } @@ -292,7 +300,7 @@ void SAL_CALL NameContainer::addContainerListener( const Reference< XContainerLi if( !xListener.is() ) throw RuntimeException(); Reference< XInterface > xIface( xListener, UNO_QUERY ); - maListenerContainer.addInterface( xIface ); + maContainerListeners.addInterface( xIface ); } void SAL_CALL NameContainer::removeContainerListener( const Reference< XContainerListener >& xListener ) @@ -301,7 +309,26 @@ void SAL_CALL NameContainer::removeContainerListener( const Reference< XContaine if( !xListener.is() ) throw RuntimeException(); Reference< XInterface > xIface( xListener, UNO_QUERY ); - maListenerContainer.removeInterface( xIface ); + maContainerListeners.removeInterface( xIface ); +} + +// Methods XChangesNotifier +void SAL_CALL NameContainer::addChangesListener( const Reference< XChangesListener >& xListener ) + throw (RuntimeException) +{ + if( !xListener.is() ) + throw RuntimeException(); + Reference< XInterface > xIface( xListener, UNO_QUERY ); + maChangesListeners.addInterface( xIface ); +} + +void SAL_CALL NameContainer::removeChangesListener( const Reference< XChangesListener >& xListener ) + throw (RuntimeException) +{ + if( !xListener.is() ) + throw RuntimeException(); + Reference< XInterface > xIface( xListener, UNO_QUERY ); + maChangesListeners.removeInterface( xIface ); } //============================================================================ @@ -322,12 +349,28 @@ void ModifiableHelper::setModified( sal_Bool _bModified ) //============================================================================ +VBAScriptListenerContainer::VBAScriptListenerContainer( ::osl::Mutex& rMutex ) : + VBAScriptListenerContainer_BASE( rMutex ) +{ +} + +bool VBAScriptListenerContainer::implTypedNotify( const Reference< vba::XVBAScriptListener >& rxListener, const vba::VBAScriptEvent& rEvent ) throw (Exception) +{ + rxListener->notifyVBAScriptEvent( rEvent ); + return true; // notify all other listeners too +} + +//============================================================================ + // Implementation class SfxLibraryContainer DBG_NAME( SfxLibraryContainer ) // Ctor SfxLibraryContainer::SfxLibraryContainer( void ) - : LibraryContainerHelper( maMutex ) + : SfxLibraryContainer_BASE( maMutex ) + + , maVBAScriptListeners( maMutex ) + , mnRunningVBAScripts( 0 ) , mbVBACompat( sal_False ) , maModifiable( *this, maMutex ) , maNameContainer( getCppuType( (Reference< XNameAccess >*) NULL ) ) @@ -2628,6 +2671,9 @@ void SfxLibraryContainer::_disposing( const EventObject& _rSource ) // OComponentHelper void SAL_CALL SfxLibraryContainer::disposing() { + Reference< XModel > xModel = mxOwnerDocument; + EventObject aEvent( xModel.get() ); + maVBAScriptListeners.disposing( aEvent ); stopAllComponentListening(); mxOwnerDocument = WeakReference< XModel >(); } @@ -2817,7 +2863,7 @@ void SAL_CALL SfxLibraryContainer::setVBACompatibilityMode( ::sal_Bool _vbacompa */ if( mbVBACompat ) try { - Reference< frame::XModel > xModel( mxOwnerDocument ); // weak-ref -> ref + Reference< XModel > xModel( mxOwnerDocument ); // weak-ref -> ref Reference< XMultiServiceFactory > xFactory( xModel, UNO_QUERY_THROW ); xFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooo.vba.VBAGlobals" ) ) ); } @@ -2839,6 +2885,43 @@ void SAL_CALL SfxLibraryContainer::setProjectName( const ::rtl::OUString& _proje pBasMgr->SetName( msProjectName ); } +sal_Int32 SAL_CALL SfxLibraryContainer::getRunningVBAScripts() throw (RuntimeException) +{ + LibraryContainerMethodGuard aGuard( *this ); + return mnRunningVBAScripts; +} + +void SAL_CALL SfxLibraryContainer::addVBAScriptListener( const Reference< vba::XVBAScriptListener >& rxListener ) throw (RuntimeException) +{ + maVBAScriptListeners.addTypedListener( rxListener ); +} + +void SAL_CALL SfxLibraryContainer::removeVBAScriptListener( const Reference< vba::XVBAScriptListener >& rxListener ) throw (RuntimeException) +{ + maVBAScriptListeners.removeTypedListener( rxListener ); +} + +void SAL_CALL SfxLibraryContainer::broadcastVBAScriptEvent( sal_Int32 nIdentifier, const ::rtl::OUString& rModuleName ) throw (RuntimeException) +{ + // own lock for accessing the number of running scripts + enterMethod(); + switch( nIdentifier ) + { + case vba::VBAScriptEventId::SCRIPT_STARTED: + ++mnRunningVBAScripts; + break; + case vba::VBAScriptEventId::SCRIPT_STOPPED: + --mnRunningVBAScripts; + break; + } + leaveMethod(); + + Reference< XModel > xModel = mxOwnerDocument; // weak-ref -> ref + Reference< XInterface > xSender( xModel, UNO_QUERY_THROW ); + vba::VBAScriptEvent aEvent( xSender, nIdentifier, rModuleName ); + maVBAScriptListeners.notify( aEvent ); +} + // Methods XServiceInfo ::sal_Bool SAL_CALL SfxLibraryContainer::supportsService( const ::rtl::OUString& _rServiceName ) throw (RuntimeException) @@ -2919,11 +3002,14 @@ Any SAL_CALL SfxLibrary::queryInterface( const Type& rType ) { Any aRet; - aRet = Any( ::cppu::queryInterface( rType, - static_cast< XContainer * >( this ), - static_cast< XNameContainer * >( this ), - static_cast< XNameAccess * >( this ) ) ); - + aRet = Any( + ::cppu::queryInterface( + rType, + static_cast< XContainer * >( this ), + static_cast< XNameContainer * >( this ), + static_cast< XNameAccess * >( this ), + static_cast< XElementAccess * >( this ), + static_cast< XChangesNotifier * >( this ) ) ); if( !aRet.hasValue() ) aRet = OComponentHelper::queryInterface( rType ); return aRet; @@ -3064,6 +3150,7 @@ Sequence< Type > SfxLibrary::getTypes() static OTypeCollection s_aTypes_NameContainer( ::getCppuType( (const Reference< XNameContainer > *)0 ), ::getCppuType( (const Reference< XContainer > *)0 ), + ::getCppuType( (const Reference< XChangesNotifier > *)0 ), OComponentHelper::getTypes() ); s_pTypes_NameContainer = &s_aTypes_NameContainer; } @@ -3091,9 +3178,6 @@ Sequence< sal_Int8 > SfxLibrary::getImplementationId() } } - -//============================================================================ - // Methods XContainer void SAL_CALL SfxLibrary::addContainerListener( const Reference< XContainerListener >& xListener ) throw (RuntimeException) @@ -3108,6 +3192,19 @@ void SAL_CALL SfxLibrary::removeContainerListener( const Reference< XContainerLi maNameContainer.removeContainerListener( xListener ); } +// Methods XChangesNotifier +void SAL_CALL SfxLibrary::addChangesListener( const Reference< XChangesListener >& xListener ) + throw (RuntimeException) +{ + maNameContainer.setEventSource( static_cast< XInterface* >( (OWeakObject*)this ) ); + maNameContainer.addChangesListener( xListener ); +} + +void SAL_CALL SfxLibrary::removeChangesListener( const Reference< XChangesListener >& xListener ) + throw (RuntimeException) +{ + maNameContainer.removeChangesListener( xListener ); +} //============================================================================ // Implementation class ScriptExtensionIterator |