diff options
author | Oliver Bolte <obo@openoffice.org> | 2008-10-16 06:57:26 +0000 |
---|---|---|
committer | Oliver Bolte <obo@openoffice.org> | 2008-10-16 06:57:26 +0000 |
commit | ae562e931a98e708a75e8d140cf1ff24854acfc7 (patch) | |
tree | 4ccb1ec3b4d4a9157e03f949d62b6687b8aa88eb | |
parent | 7bf29c44efa5985f59c160ba5a75dc212f955d42 (diff) |
CWS-TOOLING: integrate CWS odbmacros3
23 files changed, 373 insertions, 244 deletions
diff --git a/connectivity/qa/connectivity/tools/HsqlDatabase.java b/connectivity/qa/connectivity/tools/HsqlDatabase.java index f2b69a7d24c5..8eb59f323718 100644 --- a/connectivity/qa/connectivity/tools/HsqlDatabase.java +++ b/connectivity/qa/connectivity/tools/HsqlDatabase.java @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: HsqlDatabase.java,v $ - * $Revision: 1.5 $ + * $Revision: 1.4.50.2 $ * * This file is part of OpenOffice.org. * @@ -34,6 +34,7 @@ import com.sun.star.beans.PropertyValue; import com.sun.star.beans.XPropertySet; import com.sun.star.container.ElementExistException; import com.sun.star.frame.XStorable; +import com.sun.star.frame.XModel; import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.sdb.XOfficeDatabaseDocument; import com.sun.star.sdbc.SQLException; @@ -185,6 +186,20 @@ public class HsqlDatabase } } + /** returns the underlying database document + */ + XOfficeDatabaseDocument getDatabaseDocument() + { + return m_databaseDocument; + } + + /** returns the model interface of the underlying database document + */ + XModel getModel() + { + return (XModel)UnoRuntime.queryInterface( XModel.class, m_databaseDocument ); + } + /** drops the table with a given name @param _name diff --git a/officecfg/registry/data/org/openoffice/Office/UI/DbuCommands.xcu b/officecfg/registry/data/org/openoffice/Office/UI/DbuCommands.xcu index bf15f0076c3b..f3c3c56a4771 100644 --- a/officecfg/registry/data/org/openoffice/Office/UI/DbuCommands.xcu +++ b/officecfg/registry/data/org/openoffice/Office/UI/DbuCommands.xcu @@ -420,6 +420,11 @@ <value xml:lang="en-US">SQL...</value> </prop> </node> + <node oor:name=".uno:DBMigrateScripts" oor:op="replace"> + <prop oor:name="Label" oor:type="xs:string"> + <value xml:lang="en-US">Migrate Macros ...</value> + </prop> + </node> <node oor:name=".uno:DSBEditDoc" oor:op="replace"> <prop oor:name="Label" oor:type="xs:string"> <value xml:lang="en-US">Edit Data</value> diff --git a/scripting/java/com/sun/star/script/framework/provider/PathUtils.java b/scripting/java/com/sun/star/script/framework/provider/PathUtils.java index 5c6d8a9d6192..85c8ecfe4393 100644 --- a/scripting/java/com/sun/star/script/framework/provider/PathUtils.java +++ b/scripting/java/com/sun/star/script/framework/provider/PathUtils.java @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: PathUtils.java,v $ - * $Revision: 1.8 $ + * $Revision: 1.8.6.1 $ * * This file is part of OpenOffice.org. * @@ -76,7 +76,7 @@ public class PathUtils { { try { - Method getOid = IQueryInterface.class.getMethod("getOid", null); + Method getOid = IQueryInterface.class.getMethod("getOid", (java.lang.Class[])null); if ( getOid != null ) { oid = (String)getOid.invoke( xModel, new Object[0] ); diff --git a/scripting/java/com/sun/star/script/framework/provider/ScriptProvider.java b/scripting/java/com/sun/star/script/framework/provider/ScriptProvider.java index c3059617ebf8..c9484f55a3fe 100755 --- a/scripting/java/com/sun/star/script/framework/provider/ScriptProvider.java +++ b/scripting/java/com/sun/star/script/framework/provider/ScriptProvider.java @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: ScriptProvider.java,v $ - * $Revision: 1.13 $ + * $Revision: 1.13.6.1 $ * * This file is part of OpenOffice.org. * @@ -365,9 +365,8 @@ public abstract class ScriptProvider ScriptMetaData scriptData = m_container.findScript( details ); if ( scriptData == null ) { - // TODO specify the correct error Type throw new ScriptFrameworkErrorException( details.function + " does not exist", - null, details.function, language, ScriptFrameworkErrorType.UNKNOWN ); + null, details.function, language, ScriptFrameworkErrorType.NO_SUCH_SCRIPT ); } return scriptData; } @@ -379,9 +378,8 @@ public abstract class ScriptProvider } catch ( com.sun.star.container.NoSuchElementException nse ) { - // TODO specify the correct error Type throw new ScriptFrameworkErrorException( nse.getMessage(), - null, details.function, language, ScriptFrameworkErrorType.UNKNOWN ); + null, details.function, language, ScriptFrameworkErrorType.NO_SUCH_SCRIPT ); } catch ( com.sun.star.lang.WrappedTargetException wta ) { diff --git a/scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptProviderForBeanShell.java b/scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptProviderForBeanShell.java index 871152167b87..00f6f1c7eb75 100755 --- a/scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptProviderForBeanShell.java +++ b/scripting/java/com/sun/star/script/framework/provider/beanshell/ScriptProviderForBeanShell.java @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: ScriptProviderForBeanShell.java,v $ - * $Revision: 1.11 $ + * $Revision: 1.11.6.1 $ * * This file is part of OpenOffice.org. * @@ -244,7 +244,7 @@ class ScriptImpl implements XScript throw new ScriptFrameworkErrorException( mfu.getMessage(), null, metaData.getLanguageName(), metaData.getLanguage(), - ScriptFrameworkErrorType.UNKNOWN ); + ScriptFrameworkErrorType.MALFORMED_URL ); } catch ( NoSuitableClassLoaderException nsc ) { @@ -307,7 +307,7 @@ class ScriptImpl implements XScript throw new ScriptFrameworkErrorException( "Failed to read script", null, metaData.getLanguageName(), metaData.getLanguage(), - ScriptFrameworkErrorType.UNKNOWN ); + ScriptFrameworkErrorType.NO_SUCH_SCRIPT ); } result = interpreter.eval( source ); diff --git a/scripting/java/com/sun/star/script/framework/provider/java/ScriptProviderForJava.java b/scripting/java/com/sun/star/script/framework/provider/java/ScriptProviderForJava.java index c63fcc0c861e..d36821ece7bd 100755 --- a/scripting/java/com/sun/star/script/framework/provider/java/ScriptProviderForJava.java +++ b/scripting/java/com/sun/star/script/framework/provider/java/ScriptProviderForJava.java @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: ScriptProviderForJava.java,v $ - * $Revision: 1.10 $ + * $Revision: 1.10.6.1 $ * * This file is part of OpenOffice.org. * @@ -253,7 +253,7 @@ class ScriptImpl implements XScript throw new ScriptFrameworkErrorException( mfe.getMessage(), null, metaData.getLanguageName(), metaData.getLanguage(), - ScriptFrameworkErrorType.UNKNOWN ); + ScriptFrameworkErrorType.MALFORMED_URL ); } catch (NoSuitableClassLoaderException ncl ) { @@ -323,7 +323,7 @@ class ScriptImpl implements XScript throw new ScriptFrameworkErrorException( e.getMessage(), null, metaData.getLanguageName(), metaData.getLanguage(), - ScriptFrameworkErrorType.UNKNOWN ); + ScriptFrameworkErrorType.NO_SUCH_SCRIPT ); } } catch ( ClassNotFoundException e ) @@ -332,7 +332,7 @@ class ScriptImpl implements XScript throw new ScriptFrameworkErrorException( e.getMessage(), null, metaData.getLanguageName(), metaData.getLanguage(), - ScriptFrameworkErrorType.UNKNOWN ); + ScriptFrameworkErrorType.NO_SUCH_SCRIPT ); } LogUtils.DEBUG( "Starting Invoke on Proxy ..." ); diff --git a/scripting/java/com/sun/star/script/framework/provider/javascript/ScriptProviderForJavaScript.java b/scripting/java/com/sun/star/script/framework/provider/javascript/ScriptProviderForJavaScript.java index e70ebd7013f4..04b4a8e60990 100755 --- a/scripting/java/com/sun/star/script/framework/provider/javascript/ScriptProviderForJavaScript.java +++ b/scripting/java/com/sun/star/script/framework/provider/javascript/ScriptProviderForJavaScript.java @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: ScriptProviderForJavaScript.java,v $ - * $Revision: 1.10 $ + * $Revision: 1.10.6.1 $ * * This file is part of OpenOffice.org. * @@ -260,7 +260,7 @@ class ScriptImpl implements XScript throw new ScriptFrameworkErrorException( mfu.getMessage(), null, metaData.getLanguageName(), metaData.getLanguage(), - ScriptFrameworkErrorType.UNKNOWN ); + ScriptFrameworkErrorType.MALFORMED_URL ); } catch ( com.sun.star.script.framework.provider.NoSuitableClassLoaderException nsc ) { diff --git a/scripting/source/basprov/basprov.cxx b/scripting/source/basprov/basprov.cxx index d0a028329e7f..522df92c68d3 100644 --- a/scripting/source/basprov/basprov.cxx +++ b/scripting/source/basprov/basprov.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: basprov.cxx,v $ - * $Revision: 1.23 $ + * $Revision: 1.21.6.3 $ * * This file is part of OpenOffice.org. * @@ -365,7 +365,7 @@ namespace basprov throw provider::ScriptFrameworkErrorException( errorMsg, Reference< XInterface >(), scriptURI, OUSTR("Basic"), - provider::ScriptFrameworkErrorType::UNKNOWN ); + provider::ScriptFrameworkErrorType::MALFORMED_URL ); } @@ -440,7 +440,7 @@ namespace basprov aMessage.makeStringAndClear(), Reference< XInterface >(), scriptURI, OUSTR("Basic"), - provider::ScriptFrameworkErrorType::UNKNOWN ); + provider::ScriptFrameworkErrorType::NO_SUCH_SCRIPT ); } return xScript; diff --git a/scripting/source/basprov/basscript.cxx b/scripting/source/basprov/basscript.cxx index 2dab59a4944c..55f17a9c1725 100644 --- a/scripting/source/basprov/basscript.cxx +++ b/scripting/source/basprov/basscript.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: basscript.cxx,v $ - * $Revision: 1.16 $ + * $Revision: 1.16.6.1 $ * * This file is part of OpenOffice.org. * @@ -136,7 +136,7 @@ namespace basprov m_funcName, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Basic" ) ), - provider::ScriptFrameworkErrorType::UNKNOWN ); + provider::ScriptFrameworkErrorType::NO_SUCH_SCRIPT ); } } diff --git a/scripting/source/protocolhandler/scripthandler.cxx b/scripting/source/protocolhandler/scripthandler.cxx index 10ef25b2c4c2..e1a8ba99790f 100644 --- a/scripting/source/protocolhandler/scripthandler.cxx +++ b/scripting/source/protocolhandler/scripthandler.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: scripthandler.cxx,v $ - * $Revision: 1.29 $ + * $Revision: 1.29.6.1 $ * * This file is part of OpenOffice.org. * @@ -46,6 +46,7 @@ #include <com/sun/star/script/provider/XScriptProviderSupplier.hpp> #include <com/sun/star/script/provider/XScriptProviderFactory.hpp> +#include <com/sun/star/script/provider/ScriptFrameworkErrorType.hpp> #include <sfx2/objsh.hxx> #include <sfx2/frame.hxx> @@ -53,6 +54,7 @@ #include <vcl/abstdlg.hxx> #include <cppuhelper/factory.hxx> +#include <cppuhelper/exc_hlp.hxx> #include <util/util.hxx> #include "com/sun/star/uno/XComponentContext.hpp" @@ -207,58 +209,46 @@ void SAL_CALL ScriptProtocolHandler::dispatchWithNotification( } } } - invokeResult = xFunc->invoke( inArgs, outIndex, outArgs ); - bSuccess = sal_True; + + bSuccess = sal_False; + while ( !bSuccess ) + { + Any aFirstCaughtException; + try + { + invokeResult = xFunc->invoke( inArgs, outIndex, outArgs ); + bSuccess = sal_True; + } + catch( const provider::ScriptFrameworkErrorException& se ) + { + if ( !aFirstCaughtException.hasValue() ) + aFirstCaughtException = ::cppu::getCaughtException(); + + if ( se.errorType != provider::ScriptFrameworkErrorType::NO_SUCH_SCRIPT ) + // the only condition which allows us to retry is if there is no method with the + // given name/signature + ::cppu::throwException( aFirstCaughtException ); + + if ( inArgs.getLength() == 0 ) + // no chance to retry if we can't strip more in-args + ::cppu::throwException( aFirstCaughtException ); + + // strip one argument, then retry + inArgs.realloc( inArgs.getLength() - 1 ); + } + } } // Office doesn't handle exceptions rethrown here very well, it cores, // all we can is log them and then set fail for the dispatch event! // (if there is a listener of course) - catch ( reflection::InvocationTargetException & ite ) + catch ( const Exception & e ) { - ::rtl::OUString reason = ::rtl::OUString::createFromAscii( - "ScriptProtocolHandler::dispatch: caught InvocationTargetException: " ); + aException = ::cppu::getCaughtException(); - reason = reason.concat( ite.Message ); + ::rtl::OUString reason = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ScriptProtocolHandler::dispatch: caught " ) ); - invokeResult <<= reason; - - aException = makeAny( ite ); - bCaughtException = TRUE; - } - catch ( provider::ScriptFrameworkErrorException& se ) - { - ::rtl::OUString reason = ::rtl::OUString::createFromAscii( - "ScriptProtocolHandler::dispatch: caught ScriptFrameworkErrorException: " ); - - reason = reason.concat( se.Message ); - - invokeResult <<= reason; - - aException = makeAny( se ); - bCaughtException = TRUE; - } - catch ( ::com::sun::star::uno::RuntimeException& rte ) - { - ::rtl::OUString reason = ::rtl::OUString::createFromAscii( - "ScriptProtocolHandler::dispatch: caught RuntimeException: " ); - - reason = reason.concat( rte.Message ); - - invokeResult <<= reason; - - aException = makeAny( rte ); - bCaughtException = TRUE; - } - catch ( Exception & e ) - { - ::rtl::OUString reason = ::rtl::OUString::createFromAscii( - "ScriptProtocolHandler::dispatch: caught Exception: " ); - - reason = reason.concat( e.Message ); - - invokeResult <<= reason; + invokeResult <<= reason.concat( aException.getValueTypeName() ).concat( e.Message ); - aException = makeAny( e ); bCaughtException = TRUE; } #ifdef _DEBUG diff --git a/sfx2/inc/sfx2/docstoragemodifylistener.hxx b/sfx2/inc/sfx2/docstoragemodifylistener.hxx index 35b6465a5b58..fb5b7571a487 100644 --- a/sfx2/inc/sfx2/docstoragemodifylistener.hxx +++ b/sfx2/inc/sfx2/docstoragemodifylistener.hxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: docstoragemodifylistener.hxx,v $ - * $Revision: 1.4 $ + * $Revision: 1.4.28.1 $ * * This file is part of OpenOffice.org. * @@ -39,6 +39,11 @@ #include <cppuhelper/implbase1.hxx> +namespace vos +{ + class IMutex; +} + //........................................................................ namespace sfx2 { @@ -64,9 +69,10 @@ namespace sfx2 class SFX2_DLLPUBLIC DocumentStorageModifyListener : public DocumentStorageModifyListener_Base { IModifiableDocument* m_pDocument; + ::vos::IMutex& m_rMutex; public: - DocumentStorageModifyListener( IModifiableDocument& _rDocument ); + DocumentStorageModifyListener( IModifiableDocument& _rDocument, ::vos::IMutex& _rMutex ); void dispose(); diff --git a/sfx2/inc/sfx2/evntconf.hxx b/sfx2/inc/sfx2/evntconf.hxx index f4de5f996aff..dfed56495dd1 100644 --- a/sfx2/inc/sfx2/evntconf.hxx +++ b/sfx2/inc/sfx2/evntconf.hxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: evntconf.hxx,v $ - * $Revision: 1.3 $ + * $Revision: 1.3.28.1 $ * * This file is part of OpenOffice.org. * @@ -85,10 +85,8 @@ SV_DECL_PTRARR(SfxEventArr_Impl, SfxEvent_Impl*, 5, 5) #define PROP_EVENT_TYPE "EventType" #define PROP_LIBRARY "Library" #define PROP_SCRIPT "Script" -#define PROP_SCRIPT_URL "URL" #define PROP_MACRO_NAME "MacroName" #define STAR_BASIC "StarBasic" -#define JAVA_SCRIPT "JavaScript" // ----------------------------------------------------------------------- //#else diff --git a/sfx2/inc/sfx2/sfxbasemodel.hxx b/sfx2/inc/sfx2/sfxbasemodel.hxx index ca3af0ba2c6f..7cbd6e069d66 100644 --- a/sfx2/inc/sfx2/sfxbasemodel.hxx +++ b/sfx2/inc/sfx2/sfxbasemodel.hxx @@ -8,7 +8,7 @@ * * $RCSfile: sfxbasemodel.hxx,v $ * - * $Revision: 1.14 $ + * $Revision: 1.13.28.1 $ * * This file is part of OpenOffice.org. * diff --git a/sfx2/source/doc/docstoragemodifylistener.cxx b/sfx2/source/doc/docstoragemodifylistener.cxx index 20de2f29c28a..c6bb649488ca 100644 --- a/sfx2/source/doc/docstoragemodifylistener.cxx +++ b/sfx2/source/doc/docstoragemodifylistener.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: docstoragemodifylistener.cxx,v $ - * $Revision: 1.4 $ + * $Revision: 1.4.28.1 $ * * This file is part of OpenOffice.org. * @@ -32,7 +32,6 @@ #include "precompiled_sfx2.hxx" #include "sfx2/docstoragemodifylistener.hxx" -#include <sfx2/app.hxx> #include <vos/mutex.hxx> /** === begin UNO includes === **/ @@ -60,8 +59,9 @@ namespace sfx2 //= //==================================================================== //-------------------------------------------------------------------- - DocumentStorageModifyListener::DocumentStorageModifyListener( IModifiableDocument& _rDocument ) + DocumentStorageModifyListener::DocumentStorageModifyListener( IModifiableDocument& _rDocument, ::vos::IMutex& _rMutex ) :m_pDocument( &_rDocument ) + ,m_rMutex( _rMutex ) { } @@ -73,14 +73,14 @@ namespace sfx2 //-------------------------------------------------------------------- void DocumentStorageModifyListener::dispose() { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); + ::vos::OGuard aGuard( m_rMutex ); m_pDocument = NULL; } //-------------------------------------------------------------------- void SAL_CALL DocumentStorageModifyListener::modified( const EventObject& /*aEvent*/ ) throw (RuntimeException) { - ::vos::OGuard aGuard( Application::GetSolarMutex() ); + ::vos::OGuard aGuard( m_rMutex ); // storageIsModified must not contain any locking! if ( m_pDocument ) m_pDocument->storageIsModified(); diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx index ac1de8e525fb..b8524e8be5ab 100644 --- a/sfx2/source/doc/sfxbasemodel.cxx +++ b/sfx2/source/doc/sfxbasemodel.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: sfxbasemodel.cxx,v $ - * $Revision: 1.145 $ + * $Revision: 1.139.2.5 $ * * This file is part of OpenOffice.org. * @@ -2899,7 +2899,7 @@ void SfxBaseModel::ListenForStorage_Impl( const uno::Reference< embed::XStorage { if ( !m_pData->m_pStorageModifyListen.is() ) { - m_pData->m_pStorageModifyListen = new ::sfx2::DocumentStorageModifyListener( *m_pData ); + m_pData->m_pStorageModifyListen = new ::sfx2::DocumentStorageModifyListener( *m_pData, Application::GetSolarMutex() ); } // no need to deregister the listening for old storage since it should be disposed automatically diff --git a/sfx2/source/inc/eventsupplier.hxx b/sfx2/source/inc/eventsupplier.hxx index 907cf6ed9895..97455a9e6482 100644 --- a/sfx2/source/inc/eventsupplier.hxx +++ b/sfx2/source/inc/eventsupplier.hxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: eventsupplier.hxx,v $ - * $Revision: 1.14 $ + * $Revision: 1.14.28.1 $ * * This file is part of OpenOffice.org. * @@ -36,6 +36,8 @@ #include <com/sun/star/container/XSet.hpp> #include <com/sun/star/document/XEventListener.hpp> #include <com/sun/star/document/XEventBroadcaster.hpp> +#include <com/sun/star/document/XDocumentEventBroadcaster.hpp> +#include <com/sun/star/document/XDocumentEventListener.hpp> #include <com/sun/star/document/XEventsSupplier.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/task/XJobExecutor.hpp> @@ -48,7 +50,7 @@ #include <cppuhelper/implbase2.hxx> #include <cppuhelper/implbase3.hxx> #include <cppuhelper/implbase4.hxx> -#include <cppuhelper/implbase5.hxx> +#include <cppuhelper/implbase7.hxx> #include <comphelper/sequenceashashmap.hxx> #include <comphelper/sequenceasvector.hxx> #include <sfx2/sfxuno.hxx> @@ -178,17 +180,20 @@ class ModelCollectionEnumeration : public ModelCollectionMutexBase //============================================================================= class SfxGlobalEvents_Impl : public ModelCollectionMutexBase - , public ::cppu::WeakImplHelper5< ::com::sun::star::lang::XServiceInfo + , public ::cppu::WeakImplHelper7< ::com::sun::star::lang::XServiceInfo , ::com::sun::star::document::XEventsSupplier , ::com::sun::star::document::XEventBroadcaster + , ::com::sun::star::document::XDocumentEventBroadcaster , ::com::sun::star::document::XEventListener + , ::com::sun::star::document::XDocumentEventListener , ::com::sun::star::container::XSet > , public SfxListener { ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xSMGR; ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameReplace > m_xEvents; - ::com::sun::star::uno::WeakReference< ::com::sun::star::task::XJobExecutor > m_xJobsBinding; - OINTERFACECONTAINERHELPER m_aInterfaceContainer; + ::com::sun::star::uno::WeakReference< ::com::sun::star::document::XEventListener > m_xJobExecutorListener; + OINTERFACECONTAINERHELPER m_aLegacyListeners; + OINTERFACECONTAINERHELPER m_aDocumentListeners; TModelList m_lModels; GlobalEventConfig* pImp; @@ -210,10 +215,18 @@ public: virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XEventListener >& xListener) throw(::com::sun::star::uno::RuntimeException); + // css.document.XDocumentEventBroadcaster + virtual void SAL_CALL addDocumentEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XDocumentEventListener >& _Listener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeDocumentEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::document::XDocumentEventListener >& _Listener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL notifyDocumentEvent( const ::rtl::OUString& _EventName, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController2 >& _ViewController, const ::com::sun::star::uno::Any& _Supplement ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException); + // css.document.XEventListener virtual void SAL_CALL notifyEvent(const ::com::sun::star::document::EventObject& aEvent) throw(::com::sun::star::uno::RuntimeException); + // css.document.XDocumentEventListener + virtual void SAL_CALL documentEventOccured( const ::com::sun::star::document::DocumentEvent& Event ) throw (::com::sun::star::uno::RuntimeException); + // css.container.XSet virtual sal_Bool SAL_CALL has(const ::com::sun::star::uno::Any& aElement) throw(::com::sun::star::uno::RuntimeException); @@ -247,8 +260,8 @@ private: // threadsafe void implts_notifyJobExecution(const ::com::sun::star::document::EventObject& aEvent); - void implts_checkAndExecuteEventBindings(const ::com::sun::star::document::EventObject& aEvent); - void implts_notifyListener(const ::com::sun::star::document::EventObject& aEvent); + void implts_checkAndExecuteEventBindings(const ::com::sun::star::document::DocumentEvent& aEvent); + void implts_notifyListener(const ::com::sun::star::document::DocumentEvent& aEvent); // not threadsafe TModelList::iterator impl_searchDoc(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xModel); diff --git a/sfx2/source/notify/eventsupplier.cxx b/sfx2/source/notify/eventsupplier.cxx index 9df9a37edb7d..f6402af7b5c0 100644 --- a/sfx2/source/notify/eventsupplier.cxx +++ b/sfx2/source/notify/eventsupplier.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: eventsupplier.cxx,v $ - * $Revision: 1.36 $ + * $Revision: 1.36.12.5 $ * * This file is part of OpenOffice.org. * @@ -83,6 +83,7 @@ void SAL_CALL SfxEvents_Impl::replaceByName( const OUSTRING & aName, const ANY & { ::osl::MutexGuard aGuard( maMutex ); + bool bReset = !rElement.hasValue(); // find the event in the list and replace the data long nCount = maEventNames.getLength(); for ( long i=0; i<nCount; i++ ) @@ -90,34 +91,41 @@ void SAL_CALL SfxEvents_Impl::replaceByName( const OUSTRING & aName, const ANY & if ( maEventNames[i] == aName ) { // check for correct type of the element - if ( ::getCppuType( (const SEQUENCE < PROPERTYVALUE > *)0 ) == rElement.getValueType() ) + if ( bReset || ::getCppuType( (const SEQUENCE < PROPERTYVALUE > *)0 ) == rElement.getValueType() ) { // create Configuration at first, creation might call this method also and that would overwrite everything // we might have stored before! USHORT nID = (USHORT) SfxEventConfiguration::GetEventId_Impl( aName ); if ( nID ) { - ANY aValue; - BlowUpMacro( rElement, aValue, mpObjShell ); - // pConfig becomes the owner of the new SvxMacro if ( mpObjShell && !mpObjShell->IsLoading() ) mpObjShell->SetModified( TRUE ); - SEQUENCE < PROPERTYVALUE > aProperties; - if ( aValue >>= aProperties ) + if ( bReset ) { - ::rtl::OUString aType; - if (( aProperties[0].Name.compareToAscii( PROP_EVENT_TYPE ) == 0 ) && - ( aProperties[0].Value >>= aType ) && - aType.getLength() == 0 ) + maEventData[i] = ANY(); + } + else + { + ANY aValue; + BlowUpMacro( rElement, aValue, mpObjShell ); + + SEQUENCE < PROPERTYVALUE > aProperties; + if ( aValue >>= aProperties ) { - // An empty event type means no binding. Therefore reset data - // to reflect that state. - maEventData[i] = ANY(); + ::rtl::OUString aType; + if (( aProperties[0].Name.compareToAscii( PROP_EVENT_TYPE ) == 0 ) && + ( aProperties[0].Value >>= aType ) && + aType.getLength() == 0 ) + { + // An empty event type means no binding. Therefore reset data + // to reflect that state. + maEventData[i] = ANY(); + } + else + maEventData[i] = aValue; } - else - maEventData[i] = aValue; } } } @@ -197,7 +205,7 @@ sal_Bool SAL_CALL SfxEvents_Impl::hasElements() throw ( RUNTIMEEXCEPTION ) return sal_False; } -static void Execute( ANY& aEventData, SfxObjectShell* pDoc ) +static void Execute( ANY& aEventData, const css::document::DocumentEvent& aTrigger, SfxObjectShell* pDoc ) { SEQUENCE < PROPERTYVALUE > aProperties; if ( aEventData >>= aProperties ) @@ -284,7 +292,11 @@ static void Execute( ANY& aEventData, SfxObjectShell* pDoc ) //aArgs[0].Name = rtl::OUString::createFromAscii("Referer"); //aArs[0].Value <<= ::rtl::OUString( pDoc->GetMedium()->GetName() ); //xDisp->dispatch( aURL, aArgs ); - xDisp->dispatch( aURL, ::com::sun::star::uno::Sequence < ::com::sun::star::beans::PropertyValue >() ); + + css::beans::PropertyValue aEventParam; + aEventParam.Value <<= aTrigger; + css::uno::Sequence< css::beans::PropertyValue > aDispatchArgs( &aEventParam, 1 ); + xDisp->dispatch( aURL, aDispatchArgs ); } } } @@ -326,7 +338,7 @@ void SAL_CALL SfxEvents_Impl::notifyEvent( const DOCEVENTOBJECT& aEvent ) throw( ANY aEventData = maEventData[ nIndex ]; aGuard.clear(); - Execute( aEventData, mpObjShell ); + Execute( aEventData, css::document::DocumentEvent(aEvent.Source, aEvent.EventName, NULL, css::uno::Any()), mpObjShell ); } //-------------------------------------------------------------------------------------------------------- @@ -609,14 +621,15 @@ SFX_IMPL_ONEINSTANCEFACTORY( SfxGlobalEvents_Impl ); SfxGlobalEvents_Impl::SfxGlobalEvents_Impl( const com::sun::star::uno::Reference < ::com::sun::star::lang::XMultiServiceFactory >& xSMGR) : ModelCollectionMutexBase( ) , m_xSMGR (xSMGR ) - , m_aInterfaceContainer (m_aLock) + , m_aLegacyListeners (m_aLock) + , m_aDocumentListeners (m_aLock) , pImp (0 ) { m_refCount++; SFX_APP(); - pImp = new GlobalEventConfig(); - m_xEvents = pImp; - m_xJobsBinding = css::uno::Reference< css::task::XJobExecutor >( + pImp = new GlobalEventConfig(); + m_xEvents = pImp; + m_xJobExecutorListener = css::uno::Reference< css::document::XEventListener >( xSMGR->createInstance(::rtl::OUString::createFromAscii("com.sun.star.task.JobExecutor")), UNO_QUERY); m_refCount--; @@ -660,7 +673,7 @@ void SAL_CALL SfxGlobalEvents_Impl::addEventListener(const css::uno::Reference< throw(css::uno::RuntimeException) { // container is threadsafe - m_aInterfaceContainer.addInterface(xListener); + m_aLegacyListeners.addInterface(xListener); } //----------------------------------------------------------------------------- @@ -668,16 +681,49 @@ void SAL_CALL SfxGlobalEvents_Impl::removeEventListener(const css::uno::Referenc throw(css::uno::RuntimeException) { // container is threadsafe - m_aInterfaceContainer.removeInterface(xListener); + m_aLegacyListeners.removeInterface(xListener); +} + +//----------------------------------------------------------------------------- +void SAL_CALL SfxGlobalEvents_Impl::addDocumentEventListener( const css::uno::Reference< css::document::XDocumentEventListener >& _Listener ) + throw(css::uno::RuntimeException) +{ + m_aDocumentListeners.addInterface( _Listener ); +} + +//----------------------------------------------------------------------------- +void SAL_CALL SfxGlobalEvents_Impl::removeDocumentEventListener( const css::uno::Reference< css::document::XDocumentEventListener >& _Listener ) + throw(css::uno::RuntimeException) +{ + m_aDocumentListeners.removeInterface( _Listener ); +} + +//----------------------------------------------------------------------------- +void SAL_CALL SfxGlobalEvents_Impl::notifyDocumentEvent( const ::rtl::OUString& /*_EventName*/, + const css::uno::Reference< css::frame::XController2 >& /*_ViewController*/, const css::uno::Any& /*_Supplement*/ ) + throw (css::lang::IllegalArgumentException, css::lang::NoSupportException, css::uno::RuntimeException) +{ + // we're a multiplexer only, no change to generate artifical events here + throw css::lang::NoSupportException(::rtl::OUString(), *this); } //----------------------------------------------------------------------------- void SAL_CALL SfxGlobalEvents_Impl::notifyEvent(const css::document::EventObject& aEvent) throw(css::uno::RuntimeException) { + css::document::DocumentEvent aDocEvent(aEvent.Source, aEvent.EventName, NULL, css::uno::Any()); implts_notifyJobExecution(aEvent); - implts_checkAndExecuteEventBindings(aEvent); - implts_notifyListener(aEvent); + implts_checkAndExecuteEventBindings(aDocEvent); + implts_notifyListener(aDocEvent); +} + +//----------------------------------------------------------------------------- +void SAL_CALL SfxGlobalEvents_Impl::documentEventOccured( const ::css::document::DocumentEvent& _Event ) + throw (::css::uno::RuntimeException) +{ + implts_notifyJobExecution(css::document::EventObject(_Event.Source, _Event.EventName)); + implts_checkAndExecuteEventBindings(_Event); + implts_notifyListener(_Event); } //----------------------------------------------------------------------------- @@ -740,9 +786,16 @@ void SAL_CALL SfxGlobalEvents_Impl::insert( const css::uno::Any& aElement ) aLock.clear(); // <- SAFE - css::uno::Reference< css::document::XEventBroadcaster > xDocBroadcast(xDoc, UNO_QUERY); - if (xDocBroadcast.is()) - xDocBroadcast->addEventListener(static_cast< css::document::XEventListener* >(this)); + css::uno::Reference< css::document::XDocumentEventBroadcaster > xDocBroadcaster(xDoc, UNO_QUERY ); + if (xDocBroadcaster.is()) + xDocBroadcaster->addDocumentEventListener(this); + else + { + // try the "legacy version" of XDocumentEventBroadcaster, which is XEventBroadcaster + css::uno::Reference< css::document::XEventBroadcaster > xBroadcaster(xDoc, UNO_QUERY); + if (xBroadcaster.is()) + xBroadcaster->addEventListener(static_cast< css::document::XEventListener* >(this)); + } } //----------------------------------------------------------------------------- @@ -770,9 +823,16 @@ void SAL_CALL SfxGlobalEvents_Impl::remove( const css::uno::Any& aElement ) aLock.clear(); // <- SAFE - css::uno::Reference< css::document::XEventBroadcaster > xDocBroadcast(xDoc, UNO_QUERY); - if (xDocBroadcast.is()) - xDocBroadcast->removeEventListener(static_cast< css::document::XEventListener* >(this)); + css::uno::Reference< css::document::XDocumentEventBroadcaster > xDocBroadcaster(xDoc, UNO_QUERY ); + if (xDocBroadcaster.is()) + xDocBroadcaster->removeDocumentEventListener(this); + else + { + // try the "legacy version" of XDocumentEventBroadcaster, which is XEventBroadcaster + css::uno::Reference< css::document::XEventBroadcaster > xBroadcaster(xDoc, UNO_QUERY); + if (xBroadcaster.is()) + xBroadcaster->removeEventListener(static_cast< css::document::XEventListener* >(this)); + } } //----------------------------------------------------------------------------- @@ -816,7 +876,7 @@ void SfxGlobalEvents_Impl::implts_notifyJobExecution(const css::document::EventO { // SAFE -> ::osl::ResettableMutexGuard aLock(m_aLock); - css::uno::Reference< css::document::XEventListener > xJobExecutor(m_xJobsBinding.get(), UNO_QUERY); + css::uno::Reference< css::document::XEventListener > xJobExecutor(m_xJobExecutorListener); aLock.clear(); // <- SAFE if (xJobExecutor.is()) @@ -829,7 +889,7 @@ void SfxGlobalEvents_Impl::implts_notifyJobExecution(const css::document::EventO } //----------------------------------------------------------------------------- -void SfxGlobalEvents_Impl::implts_checkAndExecuteEventBindings(const css::document::EventObject& aEvent) +void SfxGlobalEvents_Impl::implts_checkAndExecuteEventBindings(const css::document::DocumentEvent& aEvent) { try { @@ -842,7 +902,7 @@ void SfxGlobalEvents_Impl::implts_checkAndExecuteEventBindings(const css::docume css::uno::Any aAny; if (xEvents.is()) aAny = xEvents->getByName(aEvent.EventName); - Execute(aAny, 0); + Execute(aAny, aEvent, 0); } catch(const css::uno::RuntimeException& exRun) { throw exRun; } @@ -851,19 +911,13 @@ void SfxGlobalEvents_Impl::implts_checkAndExecuteEventBindings(const css::docume } //----------------------------------------------------------------------------- -void SfxGlobalEvents_Impl::implts_notifyListener(const css::document::EventObject& aEvent) +void SfxGlobalEvents_Impl::implts_notifyListener(const css::document::DocumentEvent& aEvent) { - // container is threadsafe - ::cppu::OInterfaceIteratorHelper aIt(m_aInterfaceContainer); - while (aIt.hasMoreElements()) - { - try - { - ((css::document::XEventListener*)aIt.next())->notifyEvent(aEvent); - } - catch(const css::uno::Exception&) - { aIt.remove(); } - } + // containers are threadsafe + css::document::EventObject aLegacyEvent(aEvent.Source, aEvent.EventName); + m_aLegacyListeners.notifyEach( &css::document::XEventListener::notifyEvent, aLegacyEvent ); + + m_aDocumentListeners.notifyEach( &css::document::XDocumentEventListener::documentEventOccured, aEvent ); } //----------------------------------------------------------------------------- diff --git a/svx/inc/macropg.hxx b/svx/inc/macropg.hxx index d5af503adf20..1eba2a28f596 100644 --- a/svx/inc/macropg.hxx +++ b/svx/inc/macropg.hxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: macropg.hxx,v $ - * $Revision: 1.11 $ + * $Revision: 1.11.166.1 $ * * This file is part of OpenOffice.org. * @@ -45,9 +45,22 @@ #include "svx/svxdllapi.h" #include <hash_map> +#include <vector> typedef ::std::hash_map< ::rtl::OUString, ::std::pair< ::rtl::OUString, ::rtl::OUString >, ::rtl::OUStringHash, ::std::equal_to< ::rtl::OUString > > EventsHash; -typedef ::std::hash_map< ::rtl::OUString, ::rtl::OUString, ::rtl::OUStringHash, ::std::equal_to< ::rtl::OUString > > UIEventsStringHash; + +struct SVX_DLLPRIVATE EventDisplayName +{ + const sal_Char* pAsciiEventName; + USHORT nEventResourceID; + EventDisplayName() : pAsciiEventName( NULL ), nEventResourceID(0) { } + EventDisplayName( const sal_Char* _pAsciiName, const USHORT _nResId ) + : pAsciiEventName( _pAsciiName ) + , nEventResourceID( _nResId ) + { + } +}; +typedef ::std::vector< EventDisplayName > EventDisplayNames; class _SvxMacroTabPage; class SvStringsDtor; @@ -77,7 +90,7 @@ protected: EventsHash m_appEventsHash; EventsHash m_docEventsHash; bool bReadOnly, bDocModified, bAppEvents, bInitialized; - UIEventsStringHash aUIStrings; + EventDisplayNames aDisplayNames; _SvxMacroTabPage( Window* pParent, const ResId& rId, const SfxItemSet& rItemSet ); diff --git a/svx/source/dialog/macropg.cxx b/svx/source/dialog/macropg.cxx index 042a022d8772..9abe061693aa 100644 --- a/svx/source/dialog/macropg.cxx +++ b/svx/source/dialog/macropg.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: macropg.cxx,v $ - * $Revision: 1.22 $ + * $Revision: 1.22.166.2 $ * * This file is part of OpenOffice.org. * @@ -43,6 +43,7 @@ #ifndef _EITEM_HXX #include <svtools/eitem.hxx> #endif +#include <tools/diagnose_ex.h> #include <sfx2/app.hxx> #include <sfx2/objsh.hxx> @@ -61,6 +62,11 @@ #include "headertablistbox.hxx" #include "macropg_impl.hxx" +#include <comphelper/namedvaluecollection.hxx> + +#include <algorithm> +#include <set> + using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -255,65 +261,66 @@ _SvxMacroTabPage::~_SvxMacroTabPage() pE->SetUserData((void*)0); pE = rListBox.NextSibling( pE ); } - aUIStrings.clear(); DELETEZ( mpImpl ); } // ----------------------------------------------------------------------------- void _SvxMacroTabPage::InitResources() { + // Note: the order here controls the order in which the events are displayed in the UI! + // the event name to UI string mappings for App Events - aUIStrings.insert(UIEventsStringHash::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("OnStartApp")),String( SVX_RES( RID_SVXSTR_EVENT_STARTAPP )))); - aUIStrings.insert(UIEventsStringHash::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("OnCloseApp")),String( SVX_RES( RID_SVXSTR_EVENT_CLOSEAPP )))); - aUIStrings.insert(UIEventsStringHash::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("OnNew")),String( SVX_RES( RID_SVXSTR_EVENT_CREATEDOC )))); - aUIStrings.insert(UIEventsStringHash::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("OnUnload")),String( SVX_RES( RID_SVXSTR_EVENT_CLOSEDOC )))); - aUIStrings.insert(UIEventsStringHash::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("OnPrepareUnload")),String( SVX_RES( RID_SVXSTR_EVENT_PREPARECLOSEDOC )))); - aUIStrings.insert(UIEventsStringHash::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("OnLoad")),String( SVX_RES( RID_SVXSTR_EVENT_OPENDOC )))); - aUIStrings.insert(UIEventsStringHash::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("OnSave")),String( SVX_RES( RID_SVXSTR_EVENT_SAVEDOC )))); - aUIStrings.insert(UIEventsStringHash::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("OnSaveAs")),String( SVX_RES( RID_SVXSTR_EVENT_SAVEASDOC )))); - aUIStrings.insert(UIEventsStringHash::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("OnSaveDone")),String( SVX_RES( RID_SVXSTR_EVENT_SAVEDOCDONE )))); - aUIStrings.insert(UIEventsStringHash::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("OnSaveAsDone")),String( SVX_RES( RID_SVXSTR_EVENT_SAVEASDOCDONE )))); - aUIStrings.insert(UIEventsStringHash::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("OnFocus")),String( SVX_RES( RID_SVXSTR_EVENT_ACTIVATEDOC )))); - aUIStrings.insert(UIEventsStringHash::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("OnUnfocus")),String( SVX_RES( RID_SVXSTR_EVENT_DEACTIVATEDOC )))); - aUIStrings.insert(UIEventsStringHash::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("OnPrint")),String( SVX_RES( RID_SVXSTR_EVENT_PRINTDOC )))); - aUIStrings.insert(UIEventsStringHash::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("OnModifyChanged")),String( SVX_RES( RID_SVXSTR_EVENT_MODIFYCHANGED )))); - aUIStrings.insert(UIEventsStringHash::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("OnMailMerge")),String( SVX_RES( RID_SVXSTR_EVENT_MAILMERGE )))); - aUIStrings.insert(UIEventsStringHash::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("OnPageCountChange")),String( SVX_RES( RID_SVXSTR_EVENT_PAGECOUNTCHANGE )))); + aDisplayNames.push_back( EventDisplayName( "OnStartApp", RID_SVXSTR_EVENT_STARTAPP ) ); + aDisplayNames.push_back( EventDisplayName( "OnCloseApp", RID_SVXSTR_EVENT_CLOSEAPP ) ); + aDisplayNames.push_back( EventDisplayName( "OnNew", RID_SVXSTR_EVENT_CREATEDOC ) ); + aDisplayNames.push_back( EventDisplayName( "OnLoad", RID_SVXSTR_EVENT_OPENDOC ) ); + aDisplayNames.push_back( EventDisplayName( "OnSaveAs", RID_SVXSTR_EVENT_SAVEASDOC ) ); + aDisplayNames.push_back( EventDisplayName( "OnSaveAsDone", RID_SVXSTR_EVENT_SAVEASDOCDONE ) ); + aDisplayNames.push_back( EventDisplayName( "OnSave", RID_SVXSTR_EVENT_SAVEDOC ) ); + aDisplayNames.push_back( EventDisplayName( "OnSaveDone", RID_SVXSTR_EVENT_SAVEDOCDONE ) ); + aDisplayNames.push_back( EventDisplayName( "OnPrepareUnload", RID_SVXSTR_EVENT_PREPARECLOSEDOC ) ); + aDisplayNames.push_back( EventDisplayName( "OnUnload", RID_SVXSTR_EVENT_CLOSEDOC ) ) ; + aDisplayNames.push_back( EventDisplayName( "OnFocus", RID_SVXSTR_EVENT_ACTIVATEDOC ) ); + aDisplayNames.push_back( EventDisplayName( "OnUnfocus", RID_SVXSTR_EVENT_DEACTIVATEDOC ) ); + aDisplayNames.push_back( EventDisplayName( "OnPrint", RID_SVXSTR_EVENT_PRINTDOC ) ); + aDisplayNames.push_back( EventDisplayName( "OnModifyChanged", RID_SVXSTR_EVENT_MODIFYCHANGED ) ); + aDisplayNames.push_back( EventDisplayName( "OnMailMerge", RID_SVXSTR_EVENT_MAILMERGE ) ); + aDisplayNames.push_back( EventDisplayName( "OnPageCountChange", RID_SVXSTR_EVENT_PAGECOUNTCHANGE ) ); // the event name to UI string mappings for forms & dialogs // - aUIStrings.insert(UIEventsStringHash::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("approveAction")),String( SVX_RES( RID_SVXSTR_EVENT_APPROVEACTIONPERFORMED )))); - aUIStrings.insert(UIEventsStringHash::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("actionPerformed")),String( SVX_RES( RID_SVXSTR_EVENT_ACTIONPERFORMED )))); - aUIStrings.insert(UIEventsStringHash::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("changed")),String( SVX_RES( RID_SVXSTR_EVENT_CHANGED )))); - aUIStrings.insert(UIEventsStringHash::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("textChanged")),String( SVX_RES( RID_SVXSTR_EVENT_TEXTCHANGED )))); - aUIStrings.insert(UIEventsStringHash::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("itemStateChanged")),String( SVX_RES( RID_SVXSTR_EVENT_ITEMSTATECHANGED )))); - aUIStrings.insert(UIEventsStringHash::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("focusGained")),String( SVX_RES( RID_SVXSTR_EVENT_FOCUSGAINED )))); - aUIStrings.insert(UIEventsStringHash::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("focusLost")),String( SVX_RES( RID_SVXSTR_EVENT_FOCUSLOST )))); - aUIStrings.insert(UIEventsStringHash::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("keyPressed")),String( SVX_RES( RID_SVXSTR_EVENT_KEYTYPED )))); - aUIStrings.insert(UIEventsStringHash::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("keyReleased")),String( SVX_RES( RID_SVXSTR_EVENT_KEYUP )))); - aUIStrings.insert(UIEventsStringHash::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("mouseEntered")),String( SVX_RES( RID_SVXSTR_EVENT_MOUSEENTERED )))); - aUIStrings.insert(UIEventsStringHash::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("mouseDragged")),String( SVX_RES( RID_SVXSTR_EVENT_MOUSEDRAGGED )))); - aUIStrings.insert(UIEventsStringHash::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("mouseMoved")),String( SVX_RES( RID_SVXSTR_EVENT_MOUSEMOVED )))); - aUIStrings.insert(UIEventsStringHash::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("mousePressed")),String( SVX_RES( RID_SVXSTR_EVENT_MOUSEPRESSED )))); - aUIStrings.insert(UIEventsStringHash::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("mouseReleased")),String( SVX_RES( RID_SVXSTR_EVENT_MOUSERELEASED )))); - aUIStrings.insert(UIEventsStringHash::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("mouseExited")),String( SVX_RES( RID_SVXSTR_EVENT_MOUSEEXITED )))); - aUIStrings.insert(UIEventsStringHash::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("approveReset")),String( SVX_RES( RID_SVXSTR_EVENT_APPROVERESETTED )))); - aUIStrings.insert(UIEventsStringHash::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("resetted")),String( SVX_RES( RID_SVXSTR_EVENT_RESETTED )))); - aUIStrings.insert(UIEventsStringHash::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("approveSubmit")),String( SVX_RES( RID_SVXSTR_EVENT_SUBMITTED )))); - aUIStrings.insert(UIEventsStringHash::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("approveUpdate")),String( SVX_RES( RID_SVXSTR_EVENT_BEFOREUPDATE )))); - aUIStrings.insert(UIEventsStringHash::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("updated")),String( SVX_RES( RID_SVXSTR_EVENT_AFTERUPDATE )))); - aUIStrings.insert(UIEventsStringHash::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("loaded")),String( SVX_RES( RID_SVXSTR_EVENT_LOADED )))); - aUIStrings.insert(UIEventsStringHash::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("reloading")),String( SVX_RES( RID_SVXSTR_EVENT_RELOADING )))); - aUIStrings.insert(UIEventsStringHash::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("reloaded")),String( SVX_RES( RID_SVXSTR_EVENT_RELOADED )))); - aUIStrings.insert(UIEventsStringHash::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("unloading")),String( SVX_RES( RID_SVXSTR_EVENT_UNLOADING )))); - aUIStrings.insert(UIEventsStringHash::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("unloaded")),String( SVX_RES( RID_SVXSTR_EVENT_UNLOADED )))); - aUIStrings.insert(UIEventsStringHash::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("confirmDelete")),String( SVX_RES( RID_SVXSTR_EVENT_CONFIRMDELETE )))); - aUIStrings.insert(UIEventsStringHash::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("approveRowChange")),String( SVX_RES( RID_SVXSTR_EVENT_APPROVEROWCHANGE )))); - aUIStrings.insert(UIEventsStringHash::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("rowChanged")),String( SVX_RES( RID_SVXSTR_EVENT_ROWCHANGE )))); - aUIStrings.insert(UIEventsStringHash::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("approveCursorMove")),String( SVX_RES( RID_SVXSTR_EVENT_POSITIONING )))); - aUIStrings.insert(UIEventsStringHash::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cursorMoved")),String( SVX_RES( RID_SVXSTR_EVENT_POSITIONED )))); - aUIStrings.insert(UIEventsStringHash::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("approveParameter")),String( SVX_RES( RID_SVXSTR_EVENT_APPROVEPARAMETER )))); - aUIStrings.insert(UIEventsStringHash::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("errorOccured")),String( SVX_RES( RID_SVXSTR_EVENT_ERROROCCURED )))); - aUIStrings.insert(UIEventsStringHash::value_type(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("adjustmentValueChanged")),String( SVX_RES( RID_SVXSTR_EVENT_ADJUSTMENTVALUECHANGED )))); + aDisplayNames.push_back( EventDisplayName( "approveAction", RID_SVXSTR_EVENT_APPROVEACTIONPERFORMED ) ); + aDisplayNames.push_back( EventDisplayName( "actionPerformed", RID_SVXSTR_EVENT_ACTIONPERFORMED ) ); + aDisplayNames.push_back( EventDisplayName( "changed", RID_SVXSTR_EVENT_CHANGED ) ); + aDisplayNames.push_back( EventDisplayName( "textChanged", RID_SVXSTR_EVENT_TEXTCHANGED ) ); + aDisplayNames.push_back( EventDisplayName( "itemStateChanged", RID_SVXSTR_EVENT_ITEMSTATECHANGED ) ); + aDisplayNames.push_back( EventDisplayName( "focusGained", RID_SVXSTR_EVENT_FOCUSGAINED ) ); + aDisplayNames.push_back( EventDisplayName( "focusLost", RID_SVXSTR_EVENT_FOCUSLOST ) ); + aDisplayNames.push_back( EventDisplayName( "keyPressed", RID_SVXSTR_EVENT_KEYTYPED ) ); + aDisplayNames.push_back( EventDisplayName( "keyReleased", RID_SVXSTR_EVENT_KEYUP ) ); + aDisplayNames.push_back( EventDisplayName( "mouseEntered", RID_SVXSTR_EVENT_MOUSEENTERED ) ); + aDisplayNames.push_back( EventDisplayName( "mouseDragged", RID_SVXSTR_EVENT_MOUSEDRAGGED ) ); + aDisplayNames.push_back( EventDisplayName( "mouseMoved", RID_SVXSTR_EVENT_MOUSEMOVED ) ); + aDisplayNames.push_back( EventDisplayName( "mousePressed", RID_SVXSTR_EVENT_MOUSEPRESSED ) ); + aDisplayNames.push_back( EventDisplayName( "mouseReleased", RID_SVXSTR_EVENT_MOUSERELEASED ) ); + aDisplayNames.push_back( EventDisplayName( "mouseExited", RID_SVXSTR_EVENT_MOUSEEXITED ) ); + aDisplayNames.push_back( EventDisplayName( "approveReset", RID_SVXSTR_EVENT_APPROVERESETTED ) ); + aDisplayNames.push_back( EventDisplayName( "resetted", RID_SVXSTR_EVENT_RESETTED ) ); + aDisplayNames.push_back( EventDisplayName( "approveSubmit", RID_SVXSTR_EVENT_SUBMITTED ) ); + aDisplayNames.push_back( EventDisplayName( "approveUpdate", RID_SVXSTR_EVENT_BEFOREUPDATE ) ); + aDisplayNames.push_back( EventDisplayName( "updated", RID_SVXSTR_EVENT_AFTERUPDATE ) ); + aDisplayNames.push_back( EventDisplayName( "loaded", RID_SVXSTR_EVENT_LOADED ) ); + aDisplayNames.push_back( EventDisplayName( "reloading", RID_SVXSTR_EVENT_RELOADING ) ); + aDisplayNames.push_back( EventDisplayName( "reloaded", RID_SVXSTR_EVENT_RELOADED ) ); + aDisplayNames.push_back( EventDisplayName( "unloading", RID_SVXSTR_EVENT_UNLOADING ) ); + aDisplayNames.push_back( EventDisplayName( "unloaded", RID_SVXSTR_EVENT_UNLOADED ) ); + aDisplayNames.push_back( EventDisplayName( "confirmDelete", RID_SVXSTR_EVENT_CONFIRMDELETE ) ); + aDisplayNames.push_back( EventDisplayName( "approveRowChange", RID_SVXSTR_EVENT_APPROVEROWCHANGE ) ); + aDisplayNames.push_back( EventDisplayName( "rowChanged", RID_SVXSTR_EVENT_ROWCHANGE ) ); + aDisplayNames.push_back( EventDisplayName( "approveCursorMove", RID_SVXSTR_EVENT_POSITIONING ) ); + aDisplayNames.push_back( EventDisplayName( "cursorMoved", RID_SVXSTR_EVENT_POSITIONED ) ); + aDisplayNames.push_back( EventDisplayName( "approveParameter", RID_SVXSTR_EVENT_APPROVEPARAMETER ) ); + aDisplayNames.push_back( EventDisplayName( "errorOccured", RID_SVXSTR_EVENT_ERROROCCURED ) ); + aDisplayNames.push_back( EventDisplayName( "adjustmentValueChanged", RID_SVXSTR_EVENT_ADJUSTMENTVALUECHANGED ) ); } // the following method is called when the user clicks OK @@ -334,8 +341,10 @@ BOOL _SvxMacroTabPage::FillItemSet( SfxItemSet& /*rSet*/ ) { m_xAppEvents->replaceByName( eventName, GetPropsByName( eventName, m_appEventsHash ) ); } - catch(Exception e) - {} + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } } } if( m_xDocEvents.is() && bDocModified ) @@ -349,8 +358,10 @@ BOOL _SvxMacroTabPage::FillItemSet( SfxItemSet& /*rSet*/ ) { m_xDocEvents->replaceByName( eventName, GetPropsByName( eventName, m_docEventsHash ) ); } - catch(Exception e) - {} + catch( const Exception& ) + { + DBG_UNHANDLED_EXCEPTION(); + } } // if we have a valid XModifiable (in the case of doc events) // call setModified(true) @@ -518,33 +529,37 @@ void _SvxMacroTabPage::DisplayAppEvents( bool appEvents) { return; } + Sequence< ::rtl::OUString > eventNames = nameReplace->getElementNames(); - sal_Int32 nEventCount = eventNames.getLength(); - for(sal_Int32 nEvent = 0; nEvent < nEventCount; ++nEvent ) + ::std::set< ::rtl::OUString > aEventNamesCache; + ::std::copy( + eventNames.getConstArray(), + eventNames.getConstArray() + eventNames.getLength(), + ::std::insert_iterator< ::std::set< ::rtl::OUString > >( aEventNamesCache, aEventNamesCache.end() ) + ); + + for ( EventDisplayNames::const_iterator displayableEvent = aDisplayNames.begin(); + displayableEvent != aDisplayNames.end(); + ++displayableEvent + ) { - EventsHash::iterator h_it = eventsHash->find( eventNames[nEvent] ); - if( h_it == eventsHash->end() ) + ::rtl::OUString sEventName( ::rtl::OUString::createFromAscii( displayableEvent->pAsciiEventName ) ); + if ( !nameReplace->hasByName( sEventName ) ) continue; - ::rtl::OUString eventName = h_it->first; - ::rtl::OUString eventURL = h_it->second.second; - //DF better to add the L10N version - // might also have a hash between event name & L10N display name - //for some reason the hash seems now to be empty?? Why?? - UIEventsStringHash::iterator ui_it = aUIStrings.find(eventName); - String sTmp; - if( ui_it != aUIStrings.end() ) - { - // we have the L10N string - sTmp = ui_it->second; - } - else + + EventsHash::iterator h_it = eventsHash->find( sEventName ); + if( h_it == eventsHash->end() ) { - //no UI name => do not add + OSL_ENSURE( false, "_SvxMacroTabPage::DisplayAppEvents: something's suspicious here!" ); continue; } - sTmp += '\t'; - SvLBoxEntry* _pE = rListBox.InsertEntry( sTmp ); - ::rtl::OUString* pEventName = new ::rtl::OUString( eventName ); + + ::rtl::OUString eventURL = h_it->second.second; + String displayName( SVX_RES( displayableEvent->nEventResourceID ) ); + + displayName += '\t'; + SvLBoxEntry* _pE = rListBox.InsertEntry( displayName ); + ::rtl::OUString* pEventName = new ::rtl::OUString( sEventName ); _pE->SetUserData( (void*)pEventName ); String sNew( eventURL ); _pE->ReplaceItem( new IconLBoxString( _pE, 0, sNew, @@ -639,7 +654,13 @@ long _SvxMacroTabPage::GenericHandler_Impl( _SvxMacroTabPage* pThis, PushButton* if(!pThis->bAppEvents) pThis->bDocModified = true; } - else if( pBtn == pImpl->pAssignComponentPB || (bDoubleClick && bUNOAssigned) ) + else if ( ( ( pBtn != NULL ) + && ( pBtn == pImpl->pAssignComponentPB ) + ) + || ( bDoubleClick + && bUNOAssigned + ) + ) { AssignComponentDialog* pAssignDlg = new AssignComponentDialog( pThis, sEventURL ); @@ -773,13 +794,16 @@ Any _SvxMacroTabPage::GetPropsByName( const ::rtl::OUString& eventName, EventsHa { const ::std::pair< ::rtl::OUString, ::rtl::OUString >& rAssignedEvent( eventsHash[ eventName ] ); - Sequence< beans::PropertyValue > props(2); - props[0].Name = ::rtl::OUString::createFromAscii("EventType"); - props[0].Value <<= rAssignedEvent.first; - props[1].Name = ::rtl::OUString::createFromAscii("Script"); - props[1].Value <<= rAssignedEvent.second; + Any aReturn; + ::comphelper::NamedValueCollection aProps; + if ( rAssignedEvent.first.getLength() && rAssignedEvent.second.getLength() ) + { + aProps.put( "EventType", rAssignedEvent.first ); + aProps.put( "Script", rAssignedEvent.second ); + } + aReturn <<= aProps.getPropertyValues(); - return makeAny( props ); + return aReturn; } // converts the Any returned by GetByName into a pair which can be stored in @@ -790,14 +814,9 @@ Any _SvxMacroTabPage::GetPropsByName( const ::rtl::OUString& eventName, EventsHa ::rtl::OUString type, url; if( sal_True == ( aAny >>= props ) ) { - sal_Int32 nCount = props.getLength(); - for( sal_Int32 index = 0; index < nCount ; ++index ) - { - if ( props[ index ].Name.compareToAscii( "EventType" ) == 0 ) - props[ index ].Value >>= type; - else if ( props[ index ].Name.compareToAscii( "Script" ) == 0 ) - props[ index ].Value >>= url; - } + ::comphelper::NamedValueCollection aProps( props ); + type = aProps.getOrDefault( "EventType", type ); + url = aProps.getOrDefault( "Script", url ); } return ::std::make_pair( type, url ); } diff --git a/ucb/source/ucp/tdoc/tdoc_docmgr.cxx b/ucb/source/ucp/tdoc/tdoc_docmgr.cxx index 3ab23e20438b..51bc2ba2cb94 100644 --- a/ucb/source/ucp/tdoc/tdoc_docmgr.cxx +++ b/ucb/source/ucp/tdoc/tdoc_docmgr.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: tdoc_docmgr.cxx,v $ - * $Revision: 1.19 $ + * $Revision: 1.19.24.2 $ * * This file is part of OpenOffice.org. * @@ -188,7 +188,7 @@ void SAL_CALL OfficeDocumentsManager::notifyEvent( uno::Reference< embed::XStorage > xStorage = xDoc->getDocumentStorage(); - OSL_ENSURE( xDoc.is(), "Got no document storage!" ); + OSL_ENSURE( xStorage.is(), "Got no document storage!" ); rtl:: OUString aDocId = getDocumentId( Event.Source ); rtl:: OUString aTitle = DocumentInfo::getDocumentTitle( uno::Reference< frame::XModel >( Event.Source, uno::UNO_QUERY ) ); @@ -269,7 +269,7 @@ void SAL_CALL OfficeDocumentsManager::notifyEvent( uno::Reference< embed::XStorage > xStorage = xDoc->getDocumentStorage(); - OSL_ENSURE( xDoc.is(), "Got no document storage!" ); + OSL_ENSURE( xStorage.is(), "Got no document storage!" ); (*it).second.xStorage = xStorage; break; @@ -305,7 +305,7 @@ void SAL_CALL OfficeDocumentsManager::notifyEvent( uno::Reference< embed::XStorage > xStorage = xDoc->getDocumentStorage(); - OSL_ENSURE( xDoc.is(), "Got no document storage!" ); + OSL_ENSURE( xStorage.is(), "Got no document storage!" ); (*it).second.xStorage = xStorage; diff --git a/xmloff/source/script/XMLEventExport.cxx b/xmloff/source/script/XMLEventExport.cxx index 0047315caee4..41f8fbca526c 100644 --- a/xmloff/source/script/XMLEventExport.cxx +++ b/xmloff/source/script/XMLEventExport.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: XMLEventExport.cxx,v $ - * $Revision: 1.21 $ + * $Revision: 1.21.86.1 $ * * This file is part of OpenOffice.org. * @@ -336,6 +336,9 @@ const XMLEventNameTranslation aStandardEventTable[] = { "OnCopyToFailed", XML_NAMESPACE_OFFICE, "copy-to-failed" }, { "OnTitleChanged", XML_NAMESPACE_OFFICE, "title-changed" }, { "OnModeChanged", XML_NAMESPACE_OFFICE, "mode-changed" }, + { "OnSaveTo", XML_NAMESPACE_OFFICE, "save-to" }, + { "OnSaveToDone", XML_NAMESPACE_OFFICE, "save-to-done" }, + { "OnSaveToFailed", XML_NAMESPACE_OFFICE, "save-to-failed" }, { NULL, 0, 0 } }; diff --git a/xmlscript/source/xmlflat_imexp/xmlbas_export.cxx b/xmlscript/source/xmlflat_imexp/xmlbas_export.cxx index 32234fbe369a..d847ec891b3b 100644 --- a/xmlscript/source/xmlflat_imexp/xmlbas_export.cxx +++ b/xmlscript/source/xmlflat_imexp/xmlbas_export.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: xmlbas_export.cxx,v $ - * $Revision: 1.6 $ + * $Revision: 1.6.10.1 $ * * This file is part of OpenOffice.org. * @@ -35,13 +35,10 @@ #include "xmlscript/xml_helper.hxx" #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/lang/XMultiComponentFactory.hpp> -#ifndef _COM_SUN_STAR_SCRIPT_XLIBRYARYCONTAINER2_HPP_ #include <com/sun/star/script/XLibraryContainer2.hpp> -#endif #include <com/sun/star/script/XLibraryContainerPassword.hpp> -#ifndef _CPPUHELPER_IMPLEMENTATIONENTRY_HXX_ +#include <com/sun/star/document/XEmbeddedScripts.hpp> #include <cppuhelper/implementationentry.hxx> -#endif using namespace ::com::sun::star; using namespace ::com::sun::star::lang; @@ -253,13 +250,22 @@ sal_Bool XMLBasicExporterBase::filter( const Sequence< beans::PropertyValue >& / m_xHandler->startElement( aLibContElementName, xLibContAttribs ); Reference< script::XLibraryContainer2 > xLibContainer; - if ( m_xModel.is() ) + + // try the XEmbeddedScripts interface + Reference< document::XEmbeddedScripts > xDocumentScripts( m_xModel, UNO_QUERY ); + if ( xDocumentScripts.is() ) + xLibContainer.set( xDocumentScripts->getBasicLibraries().get() ); + + if ( !xLibContainer.is() ) { + // try the "BasicLibraries" property (old-style, for compatibility) Reference< beans::XPropertySet > xPSet( m_xModel, UNO_QUERY ); if ( xPSet.is() ) xPSet->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "BasicLibraries" ) ) ) >>= xLibContainer; } + OSL_ENSURE( xLibContainer.is(), "XMLBasicExporterBase::filter: nowhere to export to!" ); + if ( xLibContainer.is() ) { Sequence< ::rtl::OUString > aLibNames = xLibContainer->getElementNames(); diff --git a/xmlscript/source/xmlflat_imexp/xmlbas_import.cxx b/xmlscript/source/xmlflat_imexp/xmlbas_import.cxx index d801c1fc9e88..fd339440394b 100644 --- a/xmlscript/source/xmlflat_imexp/xmlbas_import.cxx +++ b/xmlscript/source/xmlflat_imexp/xmlbas_import.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: xmlbas_import.cxx,v $ - * $Revision: 1.6 $ + * $Revision: 1.6.10.1 $ * * This file is part of OpenOffice.org. * @@ -36,9 +36,8 @@ #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/lang/XMultiComponentFactory.hpp> #include <com/sun/star/script/XLibraryContainerPassword.hpp> -#ifndef _CPPUHELPER_IMPLEMENTATIONENTRY_HXX_ +#include <com/sun/star/document/XEmbeddedScripts.hpp> #include <cppuhelper/implementationentry.hxx> -#endif using namespace ::com::sun::star; using namespace ::com::sun::star::lang; @@ -582,12 +581,22 @@ void BasicImport::setDocumentLocator( const Reference< xml::sax::XLocator >& /*x else if ( rLocalName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "libraries" ) ) ) { Reference< script::XLibraryContainer2 > xLibContainer; - if ( m_xModel.is() ) + + // try the XEmbeddedScripts interface + Reference< document::XEmbeddedScripts > xDocumentScripts( m_xModel, UNO_QUERY ); + if ( xDocumentScripts.is() ) + xLibContainer.set( xDocumentScripts->getBasicLibraries().get() ); + + if ( !xLibContainer.is() ) { + // try the "BasicLibraries" property (old-style, for compatibility) Reference< beans::XPropertySet > xPSet( m_xModel, UNO_QUERY ); if ( xPSet.is() ) xPSet->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "BasicLibraries" ) ) ) >>= xLibContainer; } + + OSL_ENSURE( xLibContainer.is(), "BasicImport::startRootElement: nowhere to import to!" ); + if ( xLibContainer.is() ) { xElement.set( new BasicLibrariesElement( rLocalName, xAttributes, 0, this, xLibContainer ) ); |