diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-02-04 22:20:53 -0500 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-02-05 01:24:21 -0500 |
commit | 3405eb11dded8dc6c7e2463dfd83873d62528fbd (patch) | |
tree | 171d1ffae158a09bdddd0e954e0551be3c9c100a | |
parent | 3a959c78e996d5eb6125184dc76c33c8f2a25db3 (diff) |
Simplify_component_getFactory using the helper code from cppu.
Change-Id: I9d26b3523d4c6c22e0b26442ab3dfc479534f5bc
-rw-r--r-- | sc/source/ui/unoobj/detreg.cxx | 59 | ||||
-rw-r--r-- | sc/source/ui/unoobj/scdetect.cxx | 7 | ||||
-rw-r--r-- | sc/source/ui/unoobj/scdetect.hxx | 5 |
3 files changed, 24 insertions, 47 deletions
diff --git a/sc/source/ui/unoobj/detreg.cxx b/sc/source/ui/unoobj/detreg.cxx index 34e8b33fc8d0..8d7ad3118044 100644 --- a/sc/source/ui/unoobj/detreg.cxx +++ b/sc/source/ui/unoobj/detreg.cxx @@ -19,54 +19,33 @@ #include "scdetect.hxx" -#include <com/sun/star/lang/XServiceInfo.hpp> -#include <com/sun/star/registry/XRegistryKey.hpp> -#include <com/sun/star/uno/Sequence.h> -#include <sal/types.h> -#include <rtl/ustring.hxx> +#include <cppuhelper/implementationentry.hxx> -using ::rtl::OUString; -using namespace ::com::sun::star; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::lang; +namespace { -extern "C" { - -SAL_DLLPUBLIC_EXPORT void* SAL_CALL scd_component_getFactory( const sal_Char* pImplementationName, - void* pServiceManager, - void* /* pRegistryKey */ ) +static const cppu::ImplementationEntry spServices[] = { - // Set default return value for this operation - if it failed. - void* pReturn = NULL ; - - if ( - ( pImplementationName != NULL ) && - ( pServiceManager != NULL ) - ) { - // Define variables which are used in following macros. - Reference< XSingleServiceFactory > xFactory ; - Reference< XMultiServiceFactory > xServiceManager( reinterpret_cast< XMultiServiceFactory* >( pServiceManager ) ) ; + ScFilterDetect::impl_createInstance, + ScFilterDetect::impl_getStaticImplementationName, + ScFilterDetect::impl_getStaticSupportedServiceNames, + cppu::createSingleComponentFactory, + 0, 0 + }, + + { 0, 0, 0, 0, 0, 0 } +}; - if( ScFilterDetect::impl_getStaticImplementationName().equalsAscii( pImplementationName ) ) - { - xFactory.set(::cppu::createSingleFactory( xServiceManager, - ScFilterDetect::impl_getStaticImplementationName(), - ScFilterDetect::impl_createInstance, - ScFilterDetect::impl_getStaticSupportedServiceNames() )); - } +} - // Factory is valid - service was found. - if ( xFactory.is() ) - { - xFactory->acquire(); - pReturn = xFactory.get(); - } - } +extern "C" { - // Return with result of this operation. - return pReturn ; +SAL_DLLPUBLIC_EXPORT void* SAL_CALL scd_component_getFactory( + const char* pImplName, void* pServiceManager, void* pRegistryKey ) +{ + return ::cppu::component_getFactoryHelper(pImplName, pServiceManager, pRegistryKey, spServices); } + } // extern "C" diff --git a/sc/source/ui/unoobj/scdetect.cxx b/sc/source/ui/unoobj/scdetect.cxx index a871e519293b..6bacac254177 100644 --- a/sc/source/ui/unoobj/scdetect.cxx +++ b/sc/source/ui/unoobj/scdetect.cxx @@ -74,7 +74,7 @@ using namespace ::com::sun::star::lang; using namespace ::com::sun::star::ucb; using ::rtl::OUString; -ScFilterDetect::ScFilterDetect( const uno::Reference<lang::XMultiServiceFactory>& /*xFactory*/ ) +ScFilterDetect::ScFilterDetect( const uno::Reference<uno::XComponentContext>& /*xContext*/ ) { } @@ -932,10 +932,9 @@ OUString ScFilterDetect::impl_getStaticImplementationName() } uno::Reference<uno::XInterface> ScFilterDetect::impl_createInstance( - const uno::Reference<lang::XMultiServiceFactory>& xServiceManager ) throw (uno::Exception) + const uno::Reference<uno::XComponentContext>& xContext ) throw (uno::Exception) { - return static_cast< cppu::OWeakObject * >( - new ScFilterDetect( xServiceManager ) ); + return static_cast<cppu::OWeakObject*>(new ScFilterDetect(xContext)); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/unoobj/scdetect.hxx b/sc/source/ui/unoobj/scdetect.hxx index 8faeef7f8100..a248f06eabab 100644 --- a/sc/source/ui/unoobj/scdetect.hxx +++ b/sc/source/ui/unoobj/scdetect.hxx @@ -33,7 +33,6 @@ #include <sfx2/sfxuno.hxx> namespace com { namespace sun { namespace star { - namespace lang { class XMultiServiceFactory; } namespace beans { struct PropertyValue; } }}} @@ -41,7 +40,7 @@ namespace com { namespace sun { namespace star { class ScFilterDetect : public ::cppu::WeakImplHelper2< ::com::sun::star::document::XExtendedFilterDetection, ::com::sun::star::lang::XServiceInfo > { public: - ScFilterDetect( const com::sun::star::uno::Reference<com::sun::star::lang::XMultiServiceFactory>& xFactory ); + ScFilterDetect( const com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext>& xContext ); virtual ~ScFilterDetect(); /* XServiceInfo */ @@ -55,7 +54,7 @@ public: /* Helper for registry */ static com::sun::star::uno::Reference< com::sun::star::uno::XInterface > SAL_CALL - impl_createInstance( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& xServiceManager ) + impl_createInstance( const com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >& xContext ) throw (com::sun::star::uno::Exception); //---------------------------------------------------------------------------------- |