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 /svtools | |
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 'svtools')
-rw-r--r-- | svtools/source/filter/SvFilterOptionsDialog.cxx | 4 | ||||
-rw-r--r-- | svtools/source/graphic/graphicunofactory.cxx | 17 | ||||
-rw-r--r-- | svtools/source/graphic/provider.cxx | 4 | ||||
-rw-r--r-- | svtools/source/graphic/renderer.cxx | 4 | ||||
-rw-r--r-- | svtools/source/hatchwindow/documentcloser.cxx | 20 | ||||
-rw-r--r-- | svtools/source/hatchwindow/hatchwindowfactory.cxx | 4 | ||||
-rw-r--r-- | svtools/source/uno/addrtempuno.cxx | 6 | ||||
-rw-r--r-- | svtools/source/uno/wizard/unowizard.cxx | 6 |
8 files changed, 23 insertions, 42 deletions
diff --git a/svtools/source/filter/SvFilterOptionsDialog.cxx b/svtools/source/filter/SvFilterOptionsDialog.cxx index 431d84c4b880..706ad184e55b 100644 --- a/svtools/source/filter/SvFilterOptionsDialog.cxx +++ b/svtools/source/filter/SvFilterOptionsDialog.cxx @@ -302,9 +302,9 @@ void SvFilterOptionsDialog::setSourceDocument( const uno::Reference< lang::XComp extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL com_sun_star_svtools_SvFilterOptionsDialog_get_implementation( css::uno::XComponentContext * context, - cppu::constructor_InitializationFunc &) + css::uno::Sequence<css::uno::Any> const &) { - return static_cast<cppu::OWeakObject *>(new SvFilterOptionsDialog(context)); + return cppu::acquire(new SvFilterOptionsDialog(context)); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svtools/source/graphic/graphicunofactory.cxx b/svtools/source/graphic/graphicunofactory.cxx index 6b526f918146..139ccb32a6de 100644 --- a/svtools/source/graphic/graphicunofactory.cxx +++ b/svtools/source/graphic/graphicunofactory.cxx @@ -39,9 +39,7 @@ class GObjectImpl : public GObjectAccess_BASE ::osl::Mutex m_aMutex; std::auto_ptr< GraphicObject > mpGObject; public: - GObjectImpl() throw (uno::RuntimeException); - - void SAL_CALL constructorInit( const uno::Sequence< uno::Any >& aArguments ) throw (uno::Exception, uno::RuntimeException); + GObjectImpl(uno::Sequence< uno::Any > const & args) throw (uno::RuntimeException); // XGraphicObject virtual uno::Reference< graphic::XGraphic > SAL_CALL getGraphic() throw (uno::RuntimeException); @@ -70,11 +68,7 @@ public: } }; -GObjectImpl::GObjectImpl() throw (uno::RuntimeException) -{ -} - -void GObjectImpl::constructorInit( const uno::Sequence< uno::Any >& args ) throw (uno::Exception, uno::RuntimeException) +GObjectImpl::GObjectImpl(const uno::Sequence< uno::Any >& args) throw (uno::RuntimeException) { if ( args.getLength() == 1 ) { @@ -119,12 +113,9 @@ OUString SAL_CALL GObjectImpl::getUniqueID() throw (uno::RuntimeException) extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL com_sun_star_graphic_GraphicObject_get_implementation( SAL_UNUSED_PARAMETER 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>(&GObjectImpl::constructorInit); - - return static_cast<cppu::OWeakObject *>(new GObjectImpl); + return cppu::acquire(new GObjectImpl(arguments)); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svtools/source/graphic/provider.cxx b/svtools/source/graphic/provider.cxx index ac29035aaa16..554a5558739f 100644 --- a/svtools/source/graphic/provider.cxx +++ b/svtools/source/graphic/provider.cxx @@ -859,9 +859,9 @@ void SAL_CALL GraphicProvider::storeGraphic( const uno::Reference< ::graphic::XG extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL com_sun_star_comp_graphic_GraphicProvider_get_implementation( css::uno::XComponentContext *, - cppu::constructor_InitializationFunc &) + css::uno::Sequence<css::uno::Any> const &) { - return static_cast<cppu::OWeakObject *>(new GraphicProvider); + return cppu::acquire(new GraphicProvider); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svtools/source/graphic/renderer.cxx b/svtools/source/graphic/renderer.cxx index 8e8c38b89aed..1577ba747c64 100644 --- a/svtools/source/graphic/renderer.cxx +++ b/svtools/source/graphic/renderer.cxx @@ -295,9 +295,9 @@ void SAL_CALL GraphicRendererVCL::render( const uno::Reference< graphic::XGraphi extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL com_sun_star_comp_graphic_GraphicRendererVCL_get_implementation( css::uno::XComponentContext *, - cppu::constructor_InitializationFunc &) + css::uno::Sequence<css::uno::Any> const &) { - return static_cast<cppu::OWeakObject *>(new GraphicRendererVCL); + return cppu::acquire(new GraphicRendererVCL); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svtools/source/hatchwindow/documentcloser.cxx b/svtools/source/hatchwindow/documentcloser.cxx index b92ab499c759..b4ffcc917473 100644 --- a/svtools/source/hatchwindow/documentcloser.cxx +++ b/svtools/source/hatchwindow/documentcloser.cxx @@ -54,12 +54,9 @@ class ODocumentCloser : public ::cppu::WeakImplHelper2< ::com::sun::star::lang:: sal_Bool m_bDisposed; public: - ODocumentCloser(); + ODocumentCloser(const css::uno::Sequence< css::uno::Any >& aArguments); ~ODocumentCloser(); - /// 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); - // XComponent virtual void SAL_CALL dispose() throw (::com::sun::star::uno::RuntimeException); virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); @@ -148,14 +145,10 @@ IMPL_STATIC_LINK( MainThreadFrameCloserRequest, worker, MainThreadFrameCloserReq return 0; } -ODocumentCloser::ODocumentCloser() +ODocumentCloser::ODocumentCloser(const css::uno::Sequence< css::uno::Any >& aArguments) : m_pListenersContainer( NULL ) , m_bDisposed( sal_False ) { -} - -void ODocumentCloser::constructorInit(const css::uno::Sequence< css::uno::Any >& aArguments) throw (css::uno::Exception, css::uno::RuntimeException) -{ ::osl::MutexGuard aGuard( m_aMutex ); if ( !m_refCount ) throw uno::RuntimeException(); // the object must be refcounted already! @@ -256,13 +249,10 @@ uno::Sequence< OUString > SAL_CALL ODocumentCloser::getSupportedServiceNames() extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL com_sun_star_comp_embed_DocumentCloser_get_implementation( - SAL_UNUSED_PARAMETER css::uno::XComponentContext *, - cppu::constructor_InitializationFunc &init_func) + SAL_UNUSED_PARAMETER css::uno::XComponentContext *, + css::uno::Sequence<css::uno::Any> const &arguments) { - // 2nd phase initialization needed - init_func = static_cast<cppu::constructor_InitializationFunc>(&ODocumentCloser::constructorInit); - - return static_cast<cppu::OWeakObject *>(new ODocumentCloser()); + return cppu::acquire(new ODocumentCloser(arguments)); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svtools/source/hatchwindow/hatchwindowfactory.cxx b/svtools/source/hatchwindow/hatchwindowfactory.cxx index 7f1991919f5d..27b27e283e17 100644 --- a/svtools/source/hatchwindow/hatchwindowfactory.cxx +++ b/svtools/source/hatchwindow/hatchwindowfactory.cxx @@ -87,9 +87,9 @@ uno::Sequence< OUString > SAL_CALL OHatchWindowFactory::getSupportedServiceNames extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL com_sun_star_comp_embed_HatchWindowFactory_get_implementation( css::uno::XComponentContext *, - cppu::constructor_InitializationFunc &) + css::uno::Sequence<css::uno::Any> const &) { - return static_cast<cppu::OWeakObject *>(new OHatchWindowFactory); + return cppu::acquire(new OHatchWindowFactory); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svtools/source/uno/addrtempuno.cxx b/svtools/source/uno/addrtempuno.cxx index 32219a15bf5f..85706cf350cc 100644 --- a/svtools/source/uno/addrtempuno.cxx +++ b/svtools/source/uno/addrtempuno.cxx @@ -225,10 +225,10 @@ namespace { extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL com_sun_star_comp_svtools_OAddressBookSourceDialogUno_get_implementation( - css::uno::XComponentContext * context, - cppu::constructor_InitializationFunc &) + css::uno::XComponentContext * context, + css::uno::Sequence<css::uno::Any> const &) { - return static_cast<cppu::OWeakObject *>(new OAddressBookSourceDialogUno(context)); + return cppu::acquire(new OAddressBookSourceDialogUno(context)); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svtools/source/uno/wizard/unowizard.cxx b/svtools/source/uno/wizard/unowizard.cxx index f8f440ae8d54..ae2d96b9b526 100644 --- a/svtools/source/uno/wizard/unowizard.cxx +++ b/svtools/source/uno/wizard/unowizard.cxx @@ -499,10 +499,10 @@ namespace { extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL com_sun_star_comp_svtools_uno_Wizard_get_implementation( - css::uno::XComponentContext *context, - cppu::constructor_InitializationFunc &) + css::uno::XComponentContext *context, + css::uno::Sequence<css::uno::Any> const &) { - return static_cast<cppu::OWeakObject *>(new Wizard(context)); + return cppu::acquire(new Wizard(context)); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |