diff options
author | Jan Holesovsky <kendy@collabora.com> | 2014-01-21 15:45:43 +0100 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2014-01-21 21:25:22 +0100 |
commit | f278397787f7b79cee8536e806e8b7113800f2ef (patch) | |
tree | 1760bce432d466cf9f3ca444c89ec8f44306ab04 /sfx2 | |
parent | 3780738154b8c3b3f9d85c64cccf621d97574886 (diff) |
Change _get_implementation()'s not to do initialization directly.
Many of the initalizations (in eg. framework) have to be done on an
acquire()'d object, so instead of doing the initialization directly, return
the initialization member function back to the createInstance() /
createInstanceWithContext() / ... and perform the initialization there.
As a sideeffect, I belive the calling initialize() from servicemanager is not
that much a hack any more - whoever converts the implementation to be
constructor-base has the choice to provide the callback, or still initialize
through XInitialization, where the callback is preferred by servicemanager
when it exists.
Change-Id: I8a87b75c54c1441ca0f184967d31ff4902fc4081
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/appl/appbaslib.cxx | 5 | ||||
-rw-r--r-- | sfx2/source/appl/appdispatchprovider.cxx | 19 | ||||
-rw-r--r-- | sfx2/source/appl/macroloader.cxx | 13 | ||||
-rw-r--r-- | sfx2/source/appl/shutdownicon.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/appl/xpackcreator.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/dialog/backingcomp.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/doc/SfxDocumentMetaData.cxx | 4 | ||||
-rw-r--r-- | sfx2/source/doc/doctemplates.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/doc/iframe.cxx | 21 | ||||
-rw-r--r-- | sfx2/source/doc/ownsubfilterservice.cxx | 20 | ||||
-rw-r--r-- | sfx2/source/doc/plugin.cxx | 2 | ||||
-rw-r--r-- | sfx2/source/inc/macroloader.hxx | 6 | ||||
-rw-r--r-- | sfx2/source/notify/globalevents.cxx | 6 | ||||
-rw-r--r-- | sfx2/source/view/frmload.cxx | 2 |
14 files changed, 74 insertions, 32 deletions
diff --git a/sfx2/source/appl/appbaslib.cxx b/sfx2/source/appl/appbaslib.cxx index df0c237c906d..39e768a8a065 100644 --- a/sfx2/source/appl/appbaslib.cxx +++ b/sfx2/source/appl/appbaslib.cxx @@ -27,6 +27,7 @@ #include <basic/basmgr.hxx> #include <tools/diagnose_ex.h> #include <comphelper/processfactory.hxx> +#include <cppuhelper/weak.hxx> using namespace ::com::sun::star::uno; using namespace ::com::sun::star::lang; @@ -158,7 +159,7 @@ SfxBasicManagerHolder::LegacyPsswdBinaryLimitExceeded( Sequence< OUString >& sMo extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL com_sun_star_comp_sfx2_ApplicationDialogLibraryContainer_get_implementation( css::uno::XComponentContext *, - css::uno::Sequence<css::uno::Any> const &) + cppu::constructor_InitializationFunc &) { SFX_APP()->GetBasicManager(); return SFX_APP()->GetDialogContainer(); @@ -170,7 +171,7 @@ com_sun_star_comp_sfx2_ApplicationDialogLibraryContainer_get_implementation( extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL com_sun_star_comp_sfx2_ApplicationScriptLibraryContainer_get_implementation( css::uno::XComponentContext *, - css::uno::Sequence<css::uno::Any> const &) + cppu::constructor_InitializationFunc &) { SFX_APP()->GetBasicManager(); return SFX_APP()->GetBasicContainer(); diff --git a/sfx2/source/appl/appdispatchprovider.cxx b/sfx2/source/appl/appdispatchprovider.cxx index c2b88af54dd4..6aa197c60df0 100644 --- a/sfx2/source/appl/appdispatchprovider.cxx +++ b/sfx2/source/appl/appdispatchprovider.cxx @@ -62,7 +62,11 @@ class SfxAppDispatchProvider : public ::cppu::WeakImplHelper2< css::frame::XAppD { css::uno::WeakReference < css::frame::XFrame > m_xFrame; public: - SfxAppDispatchProvider( const css::uno::Sequence< css::uno::Any >& aArguments ) + SfxAppDispatchProvider() + throw (css::uno::Exception, css::uno::RuntimeException); + + /// Initialization function after having acquire()'d. + void SAL_CALL constructorInit(const css::uno::Sequence< css::uno::Any >&) throw (css::uno::Exception, css::uno::RuntimeException); virtual OUString SAL_CALL getImplementationName() @@ -90,9 +94,13 @@ public: throw (css::uno::RuntimeException); }; -SfxAppDispatchProvider::SfxAppDispatchProvider( const uno::Sequence<uno::Any>& aArguments ) +SfxAppDispatchProvider::SfxAppDispatchProvider() throw (uno::Exception, uno::RuntimeException) { +} + +void SfxAppDispatchProvider::constructorInit(const css::uno::Sequence< css::uno::Any >& aArguments) throw (css::uno::Exception, css::uno::RuntimeException) +{ Reference < XFrame > xFrame; if ( aArguments.getLength() ) { @@ -253,9 +261,12 @@ throw (uno::RuntimeException) extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL com_sun_star_comp_sfx2_AppDispatchProvider_get_implementation( css::uno::XComponentContext *, - css::uno::Sequence<css::uno::Any> const &arguments) + cppu::constructor_InitializationFunc &init_func) { - return static_cast<cppu::OWeakObject *>(new SfxAppDispatchProvider(arguments)); + // 2nd phase initialization needed + init_func = static_cast<cppu::constructor_InitializationFunc>(&SfxAppDispatchProvider::constructorInit); + + return static_cast<cppu::OWeakObject *>(new SfxAppDispatchProvider()); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/appl/macroloader.cxx b/sfx2/source/appl/macroloader.cxx index ff5886148a27..d485d68ad610 100644 --- a/sfx2/source/appl/macroloader.cxx +++ b/sfx2/source/appl/macroloader.cxx @@ -44,9 +44,13 @@ using namespace ::com::sun::star::lang; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::util; -SfxMacroLoader::SfxMacroLoader( const css::uno::Sequence<css::uno::Any>& aArguments ) +SfxMacroLoader::SfxMacroLoader() throw (css::uno::Exception, css::uno::RuntimeException) { +} + +void SAL_CALL SfxMacroLoader::constructorInit(const css::uno::Sequence< css::uno::Any >& aArguments) throw (css::uno::Exception, css::uno::RuntimeException) +{ Reference < XFrame > xFrame; if ( aArguments.getLength() ) { @@ -339,9 +343,12 @@ ErrCode SfxMacroLoader::loadMacro( const OUString& rURL, com::sun::star::uno::An extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL com_sun_star_comp_sfx2_SfxMacroLoader_get_implementation( css::uno::XComponentContext *, - css::uno::Sequence<css::uno::Any> const &arguments) + cppu::constructor_InitializationFunc &init_func) { - return static_cast<cppu::OWeakObject *>(new SfxMacroLoader(arguments)); + // 2nd phase initialization needed + init_func = static_cast<cppu::constructor_InitializationFunc>(&SfxMacroLoader::constructorInit); + + return static_cast<cppu::OWeakObject *>(new SfxMacroLoader()); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/appl/shutdownicon.cxx b/sfx2/source/appl/shutdownicon.cxx index a7e2e1b67cd8..20b64490b2c5 100644 --- a/sfx2/source/appl/shutdownicon.cxx +++ b/sfx2/source/appl/shutdownicon.cxx @@ -974,7 +974,7 @@ void SAL_CALL ShutdownIcon::setFastPropertyValue( ::sal_Int32 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL com_sun_star_comp_desktop_QuickstartWrapper_get_implementation( css::uno::XComponentContext *context, - css::uno::Sequence<css::uno::Any> const &) + cppu::constructor_InitializationFunc &) { return static_cast<cppu::OWeakObject *>(new ShutdownIcon(context)); } diff --git a/sfx2/source/appl/xpackcreator.cxx b/sfx2/source/appl/xpackcreator.cxx index 6c654e77a7fe..4ff41b70f431 100644 --- a/sfx2/source/appl/xpackcreator.cxx +++ b/sfx2/source/appl/xpackcreator.cxx @@ -176,7 +176,7 @@ uno::Sequence< OUString > SAL_CALL OPackageStructureCreator::getSupportedService extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL com_sun_star_comp_embed_PackageStructureCreator_get_implementation( css::uno::XComponentContext *, - css::uno::Sequence<css::uno::Any> const &) + cppu::constructor_InitializationFunc &) { return static_cast<cppu::OWeakObject *>(new OPackageStructureCreator()); } diff --git a/sfx2/source/dialog/backingcomp.cxx b/sfx2/source/dialog/backingcomp.cxx index cadf4c3e41ae..eee5d333f863 100644 --- a/sfx2/source/dialog/backingcomp.cxx +++ b/sfx2/source/dialog/backingcomp.cxx @@ -825,7 +825,7 @@ void SAL_CALL BackingComp::removeStatusListener( const css::uno::Reference< css: extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL com_sun_star_comp_sfx2_BackingComp_get_implementation( css::uno::XComponentContext *context, - css::uno::Sequence<css::uno::Any> const &) + cppu::constructor_InitializationFunc &) { return static_cast<cppu::OWeakObject *>(new BackingComp(context)); } diff --git a/sfx2/source/doc/SfxDocumentMetaData.cxx b/sfx2/source/doc/SfxDocumentMetaData.cxx index 90bb305a80d3..d3fd3b079131 100644 --- a/sfx2/source/doc/SfxDocumentMetaData.cxx +++ b/sfx2/source/doc/SfxDocumentMetaData.cxx @@ -2317,7 +2317,7 @@ void SfxDocumentMetaData::createUserDefined() extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL CompatWriterDocPropsImpl_get_implementation( css::uno::XComponentContext *context, - css::uno::Sequence<css::uno::Any> const &) + cppu::constructor_InitializationFunc &) { return static_cast<cppu::OWeakObject *>(new CompatWriterDocPropsImpl(context)); } @@ -2325,7 +2325,7 @@ CompatWriterDocPropsImpl_get_implementation( extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL SfxDocumentMetaData_get_implementation( css::uno::XComponentContext *context, - css::uno::Sequence<css::uno::Any> const &) + cppu::constructor_InitializationFunc &) { return static_cast<cppu::OWeakObject *>(new SfxDocumentMetaData(context)); } diff --git a/sfx2/source/doc/doctemplates.cxx b/sfx2/source/doc/doctemplates.cxx index 54d2bf95409f..364564a30a24 100644 --- a/sfx2/source/doc/doctemplates.cxx +++ b/sfx2/source/doc/doctemplates.cxx @@ -2898,7 +2898,7 @@ void SfxURLRelocator_Impl::makeAbsoluteURL( OUString & rURL ) extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL com_sun_star_comp_sfx2_DocumentTemplates_get_implementation( css::uno::XComponentContext *context, - css::uno::Sequence<css::uno::Any> const &) + cppu::constructor_InitializationFunc &) { return static_cast<cppu::OWeakObject *>(new SfxDocTplService(context)); } diff --git a/sfx2/source/doc/iframe.cxx b/sfx2/source/doc/iframe.cxx index 504b2891c795..23436518bab6 100644 --- a/sfx2/source/doc/iframe.cxx +++ b/sfx2/source/doc/iframe.cxx @@ -63,11 +63,14 @@ class IFrameObject : public ::cppu::WeakImplHelper6 < SfxFrameDescriptor maFrmDescr; public: - IFrameObject( const css::uno::Reference < css::uno::XComponentContext>& rxContext, - const css::uno::Sequence< css::uno::Any >& aArguments ) + IFrameObject( const css::uno::Reference < css::uno::XComponentContext>& rxContext) throw (css::uno::Exception, css::uno::RuntimeException); ~IFrameObject(); + /// Initialization function after having acquire()'d. + void SAL_CALL constructorInit(const css::uno::Sequence< css::uno::Any >& aArguments) + throw (css::uno::Exception, css::uno::RuntimeException); + virtual OUString SAL_CALL getImplementationName() throw (css::uno::RuntimeException) { @@ -158,12 +161,15 @@ const SfxItemPropertyMapEntry* lcl_GetIFramePropertyMap_Impl() return aIFramePropertyMap_Impl; } -IFrameObject::IFrameObject( const uno::Reference < uno::XComponentContext >& rxContext, - const uno::Sequence< uno::Any >& aArguments ) +IFrameObject::IFrameObject( const uno::Reference < uno::XComponentContext >& rxContext ) throw ( uno::Exception, uno::RuntimeException ) : mxContext( rxContext ) , maPropMap( lcl_GetIFramePropertyMap_Impl() ) { +} + +void SAL_CALL IFrameObject::constructorInit(const css::uno::Sequence< css::uno::Any >& aArguments) throw (css::uno::Exception, css::uno::RuntimeException) +{ if ( aArguments.getLength() ) aArguments[0] >>= mxObj; } @@ -430,9 +436,12 @@ void SAL_CALL IFrameObject::setTitle( const OUString& ) throw (::com::sun::star: extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL com_sun_star_comp_sfx2_IFrameObject_get_implementation( css::uno::XComponentContext *context, - css::uno::Sequence<css::uno::Any> const &arguments) + cppu::constructor_InitializationFunc &init_func) { - return static_cast<cppu::OWeakObject *>(new IFrameObject(context, arguments)); + // 2nd phase initialization needed + init_func = static_cast<cppu::constructor_InitializationFunc>(&IFrameObject::constructorInit); + + return static_cast<cppu::OWeakObject *>(new IFrameObject(context)); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/doc/ownsubfilterservice.cxx b/sfx2/source/doc/ownsubfilterservice.cxx index 139f7dac587d..61d000cb48ee 100644 --- a/sfx2/source/doc/ownsubfilterservice.cxx +++ b/sfx2/source/doc/ownsubfilterservice.cxx @@ -41,8 +41,13 @@ class OwnSubFilterService : public cppu::WeakImplHelper2 < document::XFilter SfxObjectShell* m_pObjectShell; public: - OwnSubFilterService( const uno::Sequence< uno::Any >& aArguments ) + OwnSubFilterService() throw (uno::Exception, uno::RuntimeException); + + /// Initialization function after having acquire()'d. + void SAL_CALL constructorInit(const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments) + throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); + virtual ~OwnSubFilterService(); // XFilter @@ -55,10 +60,14 @@ public: virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw (uno::RuntimeException); }; -OwnSubFilterService::OwnSubFilterService( const uno::Sequence< uno::Any >& aArguments ) +OwnSubFilterService::OwnSubFilterService() throw (uno::Exception, uno::RuntimeException) : m_pObjectShell( NULL ) { +} + +void OwnSubFilterService::constructorInit( const css::uno::Sequence< css::uno::Any >& aArguments ) throw (css::uno::Exception, css::uno::RuntimeException) +{ if ( aArguments.getLength() != 2 ) throw lang::IllegalArgumentException(); @@ -124,9 +133,12 @@ uno::Sequence< OUString > SAL_CALL OwnSubFilterService::getSupportedServiceNames extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL com_sun_star_comp_document_OwnSubFilter_get_implementation( css::uno::XComponentContext *, - css::uno::Sequence<css::uno::Any> const &arguments) + cppu::constructor_InitializationFunc &init_func) { - return static_cast<cppu::OWeakObject *>(new OwnSubFilterService(arguments)); + // 2nd phase initialization needed + init_func = static_cast<cppu::constructor_InitializationFunc>(&OwnSubFilterService::constructorInit); + + return static_cast<cppu::OWeakObject *>(new OwnSubFilterService); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/doc/plugin.cxx b/sfx2/source/doc/plugin.cxx index b79219624646..60eddc1cf2a4 100644 --- a/sfx2/source/doc/plugin.cxx +++ b/sfx2/source/doc/plugin.cxx @@ -309,7 +309,7 @@ void SAL_CALL PluginObject::removeVetoableChangeListener(const OUString&, const extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL com_sun_star_comp_sfx2_PluginObject_get_implementation( css::uno::XComponentContext *, - css::uno::Sequence<css::uno::Any> const &) + cppu::constructor_InitializationFunc &) { return static_cast<cppu::OWeakObject *>(new PluginObject()); } diff --git a/sfx2/source/inc/macroloader.hxx b/sfx2/source/inc/macroloader.hxx index 8e632e5024e8..7dac814da03d 100644 --- a/sfx2/source/inc/macroloader.hxx +++ b/sfx2/source/inc/macroloader.hxx @@ -50,9 +50,13 @@ class SfxMacroLoader : public cppu::WeakImplHelper4< SfxObjectShell* GetObjectShell_Impl(); public: - SfxMacroLoader(const css::uno::Sequence< css::uno::Any >& aArguments ) + SfxMacroLoader() throw (css::uno::Exception, css::uno::RuntimeException); + /// Initialization function after having acquire()'d. + void SAL_CALL constructorInit(const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >&) + throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); + virtual OUString SAL_CALL getImplementationName() throw (css::uno::RuntimeException); diff --git a/sfx2/source/notify/globalevents.cxx b/sfx2/source/notify/globalevents.cxx index 5c8605282b52..16b7118645bd 100644 --- a/sfx2/source/notify/globalevents.cxx +++ b/sfx2/source/notify/globalevents.cxx @@ -547,11 +547,9 @@ struct Singleton: extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL com_sun_star_comp_sfx2_GlobalEventBroadcaster_get_implementation( css::uno::XComponentContext *context, - css::uno::Sequence<css::uno::Any> const &) + cppu::constructor_InitializationFunc &) { - rtl::Reference<css::uno::XInterface> x(Singleton::get(context).instance); - x->acquire(); - return x.get(); + return Singleton::get(context).instance.get(); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/view/frmload.cxx b/sfx2/source/view/frmload.cxx index daab66b976e2..c7c0ff6fb824 100644 --- a/sfx2/source/view/frmload.cxx +++ b/sfx2/source/view/frmload.cxx @@ -776,7 +776,7 @@ Sequence< OUString > SAL_CALL SfxFrameLoader_Impl::getSupportedServiceNames() th extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL com_sun_star_comp_office_FrameLoader_get_implementation( css::uno::XComponentContext *context, - css::uno::Sequence<css::uno::Any> const &) + cppu::constructor_InitializationFunc &) { return static_cast<cppu::OWeakObject *>(new SfxFrameLoader_Impl(context)); } |