diff options
author | Jan Holesovsky <kendy@collabora.com> | 2014-01-22 11:54:19 +0100 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2014-01-22 15:09:28 +0100 |
commit | c2c530da69152ff9192b9726aa95961803ce9b29 (patch) | |
tree | 15e514573f35d9f376520fc2c015634dc4ee8c25 /sfx2 | |
parent | 219a2939c9f58690356b2a3f64c580a0865fdc64 (diff) |
Introduce static inline cppu::acquire(), and make use of that.
This is much better approach compared to the callback function, as it allows
passing arguments to the c++ constructor directly, while still allowing some
additional initialization after having acquired the instance.
Change-Id: I5a0f981915dd58f1522ee6054e53a3550b29d624
Diffstat (limited to 'sfx2')
-rw-r--r-- | sfx2/source/appl/appbaslib.cxx | 4 | ||||
-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 | 4 | ||||
-rw-r--r-- | sfx2/source/appl/xpackcreator.cxx | 4 | ||||
-rw-r--r-- | sfx2/source/dialog/backingcomp.cxx | 4 | ||||
-rw-r--r-- | sfx2/source/doc/SfxDocumentMetaData.cxx | 8 | ||||
-rw-r--r-- | sfx2/source/doc/doctemplates.cxx | 4 | ||||
-rw-r--r-- | sfx2/source/doc/iframe.cxx | 19 | ||||
-rw-r--r-- | sfx2/source/doc/ownsubfilterservice.cxx | 19 | ||||
-rw-r--r-- | sfx2/source/doc/plugin.cxx | 4 | ||||
-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 | 4 |
14 files changed, 38 insertions, 80 deletions
diff --git a/sfx2/source/appl/appbaslib.cxx b/sfx2/source/appl/appbaslib.cxx index 39e768a8a065..7d295cdef8cc 100644 --- a/sfx2/source/appl/appbaslib.cxx +++ b/sfx2/source/appl/appbaslib.cxx @@ -159,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 *, - cppu::constructor_InitializationFunc &) + css::uno::Sequence<css::uno::Any> const &) { SFX_APP()->GetBasicManager(); return SFX_APP()->GetDialogContainer(); @@ -171,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 *, - cppu::constructor_InitializationFunc &) + css::uno::Sequence<css::uno::Any> const &) { SFX_APP()->GetBasicManager(); return SFX_APP()->GetBasicContainer(); diff --git a/sfx2/source/appl/appdispatchprovider.cxx b/sfx2/source/appl/appdispatchprovider.cxx index 6aa197c60df0..da2a6fd8d9c4 100644 --- a/sfx2/source/appl/appdispatchprovider.cxx +++ b/sfx2/source/appl/appdispatchprovider.cxx @@ -62,11 +62,7 @@ class SfxAppDispatchProvider : public ::cppu::WeakImplHelper2< css::frame::XAppD { css::uno::WeakReference < css::frame::XFrame > m_xFrame; public: - 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 >&) + SfxAppDispatchProvider(const css::uno::Sequence< css::uno::Any >&aArguments) throw (css::uno::Exception, css::uno::RuntimeException); virtual OUString SAL_CALL getImplementationName() @@ -94,13 +90,9 @@ public: throw (css::uno::RuntimeException); }; -SfxAppDispatchProvider::SfxAppDispatchProvider() +SfxAppDispatchProvider::SfxAppDispatchProvider(const css::uno::Sequence< css::uno::Any >& aArguments) 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() ) { @@ -261,12 +253,9 @@ throw (uno::RuntimeException) extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL com_sun_star_comp_sfx2_AppDispatchProvider_get_implementation( css::uno::XComponentContext *, - cppu::constructor_InitializationFunc &init_func) + css::uno::Sequence<css::uno::Any> const &arguments) { - // 2nd phase initialization needed - init_func = static_cast<cppu::constructor_InitializationFunc>(&SfxAppDispatchProvider::constructorInit); - - return static_cast<cppu::OWeakObject *>(new SfxAppDispatchProvider()); + return cppu::acquire(new SfxAppDispatchProvider(arguments)); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/appl/macroloader.cxx b/sfx2/source/appl/macroloader.cxx index d485d68ad610..9291e7016700 100644 --- a/sfx2/source/appl/macroloader.cxx +++ b/sfx2/source/appl/macroloader.cxx @@ -44,13 +44,9 @@ using namespace ::com::sun::star::lang; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::util; -SfxMacroLoader::SfxMacroLoader() +SfxMacroLoader::SfxMacroLoader(const css::uno::Sequence< css::uno::Any >& aArguments) 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() ) { @@ -343,12 +339,9 @@ 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 *, - cppu::constructor_InitializationFunc &init_func) + css::uno::Sequence<css::uno::Any> const &arguments) { - // 2nd phase initialization needed - init_func = static_cast<cppu::constructor_InitializationFunc>(&SfxMacroLoader::constructorInit); - - return static_cast<cppu::OWeakObject *>(new SfxMacroLoader()); + return cppu::acquire(new SfxMacroLoader(arguments)); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/appl/shutdownicon.cxx b/sfx2/source/appl/shutdownicon.cxx index 20b64490b2c5..5614f494df34 100644 --- a/sfx2/source/appl/shutdownicon.cxx +++ b/sfx2/source/appl/shutdownicon.cxx @@ -974,9 +974,9 @@ 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, - cppu::constructor_InitializationFunc &) + css::uno::Sequence<css::uno::Any> const &) { - return static_cast<cppu::OWeakObject *>(new ShutdownIcon(context)); + return cppu::acquire(new ShutdownIcon(context)); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/appl/xpackcreator.cxx b/sfx2/source/appl/xpackcreator.cxx index 4ff41b70f431..6229c61f7130 100644 --- a/sfx2/source/appl/xpackcreator.cxx +++ b/sfx2/source/appl/xpackcreator.cxx @@ -176,9 +176,9 @@ 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 *, - cppu::constructor_InitializationFunc &) + css::uno::Sequence<css::uno::Any> const &) { - return static_cast<cppu::OWeakObject *>(new OPackageStructureCreator()); + return cppu::acquire(new OPackageStructureCreator()); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/dialog/backingcomp.cxx b/sfx2/source/dialog/backingcomp.cxx index eee5d333f863..d79c545266bf 100644 --- a/sfx2/source/dialog/backingcomp.cxx +++ b/sfx2/source/dialog/backingcomp.cxx @@ -825,9 +825,9 @@ 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, - cppu::constructor_InitializationFunc &) + css::uno::Sequence<css::uno::Any> const &) { - return static_cast<cppu::OWeakObject *>(new BackingComp(context)); + return cppu::acquire(new BackingComp(context)); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/doc/SfxDocumentMetaData.cxx b/sfx2/source/doc/SfxDocumentMetaData.cxx index d3fd3b079131..4618ac93d517 100644 --- a/sfx2/source/doc/SfxDocumentMetaData.cxx +++ b/sfx2/source/doc/SfxDocumentMetaData.cxx @@ -2317,17 +2317,17 @@ void SfxDocumentMetaData::createUserDefined() extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL CompatWriterDocPropsImpl_get_implementation( css::uno::XComponentContext *context, - cppu::constructor_InitializationFunc &) + css::uno::Sequence<css::uno::Any> const &) { - return static_cast<cppu::OWeakObject *>(new CompatWriterDocPropsImpl(context)); + return cppu::acquire(new CompatWriterDocPropsImpl(context)); } extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL SfxDocumentMetaData_get_implementation( css::uno::XComponentContext *context, - cppu::constructor_InitializationFunc &) + css::uno::Sequence<css::uno::Any> const &) { - return static_cast<cppu::OWeakObject *>(new SfxDocumentMetaData(context)); + return cppu::acquire(new SfxDocumentMetaData(context)); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/doc/doctemplates.cxx b/sfx2/source/doc/doctemplates.cxx index 364564a30a24..e61eeac6d896 100644 --- a/sfx2/source/doc/doctemplates.cxx +++ b/sfx2/source/doc/doctemplates.cxx @@ -2898,9 +2898,9 @@ 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, - cppu::constructor_InitializationFunc &) + css::uno::Sequence<css::uno::Any> const &) { - return static_cast<cppu::OWeakObject *>(new SfxDocTplService(context)); + return cppu::acquire(new SfxDocTplService(context)); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/doc/iframe.cxx b/sfx2/source/doc/iframe.cxx index 23436518bab6..9e41641e68ec 100644 --- a/sfx2/source/doc/iframe.cxx +++ b/sfx2/source/doc/iframe.cxx @@ -63,14 +63,10 @@ class IFrameObject : public ::cppu::WeakImplHelper6 < SfxFrameDescriptor maFrmDescr; public: - IFrameObject( const css::uno::Reference < css::uno::XComponentContext>& rxContext) + IFrameObject(const css::uno::Reference < css::uno::XComponentContext>& rxContext, const css::uno::Sequence< css::uno::Any >& aArguments) 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) { @@ -161,15 +157,11 @@ const SfxItemPropertyMapEntry* lcl_GetIFramePropertyMap_Impl() return aIFramePropertyMap_Impl; } -IFrameObject::IFrameObject( const uno::Reference < uno::XComponentContext >& rxContext ) +IFrameObject::IFrameObject(const uno::Reference < uno::XComponentContext >& rxContext, const css::uno::Sequence< css::uno::Any >& aArguments) 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; } @@ -436,12 +428,9 @@ 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, - cppu::constructor_InitializationFunc &init_func) + css::uno::Sequence<css::uno::Any> const &arguments) { - // 2nd phase initialization needed - init_func = static_cast<cppu::constructor_InitializationFunc>(&IFrameObject::constructorInit); - - return static_cast<cppu::OWeakObject *>(new IFrameObject(context)); + return cppu::acquire(new IFrameObject(context, arguments)); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/doc/ownsubfilterservice.cxx b/sfx2/source/doc/ownsubfilterservice.cxx index 61d000cb48ee..4529730f7d05 100644 --- a/sfx2/source/doc/ownsubfilterservice.cxx +++ b/sfx2/source/doc/ownsubfilterservice.cxx @@ -41,13 +41,9 @@ class OwnSubFilterService : public cppu::WeakImplHelper2 < document::XFilter SfxObjectShell* m_pObjectShell; public: - OwnSubFilterService() + OwnSubFilterService(const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments) 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 @@ -60,14 +56,10 @@ public: virtual uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw (uno::RuntimeException); }; -OwnSubFilterService::OwnSubFilterService() +OwnSubFilterService::OwnSubFilterService(const css::uno::Sequence< css::uno::Any >& aArguments) 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(); @@ -133,12 +125,9 @@ 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 *, - cppu::constructor_InitializationFunc &init_func) + css::uno::Sequence<css::uno::Any> const &arguments) { - // 2nd phase initialization needed - init_func = static_cast<cppu::constructor_InitializationFunc>(&OwnSubFilterService::constructorInit); - - return static_cast<cppu::OWeakObject *>(new OwnSubFilterService); + return cppu::acquire(new OwnSubFilterService(arguments)); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/doc/plugin.cxx b/sfx2/source/doc/plugin.cxx index 60eddc1cf2a4..43f73973382d 100644 --- a/sfx2/source/doc/plugin.cxx +++ b/sfx2/source/doc/plugin.cxx @@ -309,9 +309,9 @@ 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 *, - cppu::constructor_InitializationFunc &) + css::uno::Sequence<css::uno::Any> const &) { - return static_cast<cppu::OWeakObject *>(new PluginObject()); + return cppu::acquire(new PluginObject()); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/inc/macroloader.hxx b/sfx2/source/inc/macroloader.hxx index 7dac814da03d..f0a775787d7e 100644 --- a/sfx2/source/inc/macroloader.hxx +++ b/sfx2/source/inc/macroloader.hxx @@ -50,13 +50,9 @@ class SfxMacroLoader : public cppu::WeakImplHelper4< SfxObjectShell* GetObjectShell_Impl(); public: - SfxMacroLoader() + SfxMacroLoader(const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments) 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 16b7118645bd..de482dcd0746 100644 --- a/sfx2/source/notify/globalevents.cxx +++ b/sfx2/source/notify/globalevents.cxx @@ -547,9 +547,11 @@ struct Singleton: extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL com_sun_star_comp_sfx2_GlobalEventBroadcaster_get_implementation( css::uno::XComponentContext *context, - cppu::constructor_InitializationFunc &) + css::uno::Sequence<css::uno::Any> const &) { - return Singleton::get(context).instance.get(); + css::uno::XInterface *inst = Singleton::get(context).instance.get(); + inst->acquire(); + return inst; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sfx2/source/view/frmload.cxx b/sfx2/source/view/frmload.cxx index c7c0ff6fb824..9e4f71696659 100644 --- a/sfx2/source/view/frmload.cxx +++ b/sfx2/source/view/frmload.cxx @@ -776,9 +776,9 @@ 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, - cppu::constructor_InitializationFunc &) + css::uno::Sequence<css::uno::Any> const &) { - return static_cast<cppu::OWeakObject *>(new SfxFrameLoader_Impl(context)); + return cppu::acquire(new SfxFrameLoader_Impl(context)); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |