Kaydet (Commit) 3405eb11 authored tarafından Kohei Yoshida's avatar Kohei Yoshida

Simplify_component_getFactory using the helper code from cppu.

Change-Id: I9d26b3523d4c6c22e0b26442ab3dfc479534f5bc
üst 3a959c78
......@@ -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"
......
......@@ -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: */
......@@ -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);
//----------------------------------------------------------------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment