sb132: #i115142# component factories should implement XServiceInfo

This commit is contained in:
sb
2010-10-25 14:43:41 +02:00
parent cc065c4937
commit 7e5eda3334
8 changed files with 66 additions and 215 deletions

View File

@@ -55,7 +55,7 @@
#include "cppu/unotype.hxx"
#include "cppuhelper/compbase5.hxx"
#include "cppuhelper/factory.hxx"
#include "cppuhelper/implbase1.hxx"
#include "cppuhelper/implbase2.hxx"
#include "cppuhelper/interfacecontainer.hxx"
#include "cppuhelper/weak.hxx"
#include "osl/diagnose.h"
@@ -127,7 +127,6 @@ private:
virtual css::uno::Sequence< rtl::OUString > SAL_CALL
getSupportedServiceNames() throw (css::uno::RuntimeException)
{ return configuration_provider::getSupportedServiceNames(); }
//TODO: DefaultProvider?
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstance(
rtl::OUString const & aServiceSpecifier)
@@ -395,7 +394,8 @@ void Service::flushModifications() const {
}
class Factory:
public cppu::WeakImplHelper1< css::lang::XSingleComponentFactory >,
public cppu::WeakImplHelper2<
css::lang::XSingleComponentFactory, css::lang::XServiceInfo >,
private boost::noncopyable
{
public:
@@ -414,6 +414,18 @@ private:
css::uno::Sequence< css::uno::Any > const & Arguments,
css::uno::Reference< css::uno::XComponentContext > const & Context)
throw (css::uno::Exception, css::uno::RuntimeException);
virtual rtl::OUString SAL_CALL getImplementationName()
throw (css::uno::RuntimeException)
{ return configuration_provider::getImplementationName(); }
virtual sal_Bool SAL_CALL supportsService(rtl::OUString const & ServiceName)
throw (css::uno::RuntimeException)
{ return ServiceName == getSupportedServiceNames()[0]; } //TODO
virtual css::uno::Sequence< rtl::OUString > SAL_CALL
getSupportedServiceNames() throw (css::uno::RuntimeException)
{ return configuration_provider::getSupportedServiceNames(); }
};
css::uno::Reference< css::uno::XInterface > Factory::createInstanceWithContext(

View File

@@ -36,7 +36,6 @@
#include "com/sun/star/lang/XMultiComponentFactory.hpp"
#include "com/sun/star/lang/XMultiServiceFactory.hpp"
#include "com/sun/star/lang/XServiceInfo.hpp"
#include "com/sun/star/lang/XSingleComponentFactory.hpp"
#include "com/sun/star/registry/InvalidRegistryException.hpp"
#include "com/sun/star/registry/InvalidValueException.hpp"
#include "com/sun/star/registry/MergeConflictException.hpp"
@@ -56,13 +55,11 @@
#include "com/sun/star/uno/XInterface.hpp"
#include "com/sun/star/util/XFlushable.hpp"
#include "cppu/unotype.hxx"
#include "cppuhelper/factory.hxx"
#include "cppuhelper/implbase1.hxx"
#include "cppuhelper/implbase3.hxx"
#include "cppuhelper/weak.hxx"
#include "osl/diagnose.h"
#include "osl/mutex.hxx"
#include "rtl/unload.h"
#include "rtl/ustring.h"
#include "rtl/ustring.hxx"
#include "sal/types.h"
@@ -877,53 +874,12 @@ rtl::OUString RegistryKey::getResolvedName(rtl::OUString const & aKeyName)
return aKeyName;
}
class Factory:
public cppu::WeakImplHelper1< css::lang::XSingleComponentFactory >,
private boost::noncopyable
{
public:
Factory() {}
private:
virtual ~Factory() {}
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL
createInstanceWithContext(
css::uno::Reference< css::uno::XComponentContext > const & Context)
throw (css::uno::Exception, css::uno::RuntimeException);
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL
createInstanceWithArgumentsAndContext(
css::uno::Sequence< css::uno::Any > const & Arguments,
css::uno::Reference< css::uno::XComponentContext > const & Context)
throw (css::uno::Exception, css::uno::RuntimeException);
};
css::uno::Reference< css::uno::XInterface > Factory::createInstanceWithContext(
css::uno::Reference< css::uno::XComponentContext > const & Context)
throw (css::uno::Exception, css::uno::RuntimeException)
{
return createInstanceWithArgumentsAndContext(
css::uno::Sequence< css::uno::Any >(), Context);
}
css::uno::Reference< css::uno::XInterface >
Factory::createInstanceWithArgumentsAndContext(
css::uno::Sequence< css::uno::Any > const & Arguments,
css::uno::Reference< css::uno::XComponentContext > const & Context)
throw (css::uno::Exception, css::uno::RuntimeException)
css::uno::Reference< css::uno::XInterface > create(
css::uno::Reference< css::uno::XComponentContext > const & context)
{
if (Arguments.getLength() != 0) {
throw css::uno::Exception(
rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM(
"com.sun.star.configuration.ConfigurationRegistry must be"
" instantiated without arguments")),
static_cast< cppu::OWeakObject * >(this));
}
return static_cast< cppu::OWeakObject * >(new Service(Context));
}
return static_cast< cppu::OWeakObject * >(new Service(context));
}
rtl::OUString getImplementationName() {
@@ -939,12 +895,4 @@ css::uno::Sequence< rtl::OUString > getSupportedServiceNames() {
return css::uno::Sequence< rtl::OUString >(&name, 1);
}
css::uno::Reference< css::lang::XSingleComponentFactory > createFactory(
cppu::ComponentFactoryFunc, rtl::OUString const &,
css::uno::Sequence< rtl::OUString > const &, rtl_ModuleCount *)
SAL_THROW(())
{
return new Factory;
}
} }

View File

@@ -30,28 +30,28 @@
#include "com/sun/star/uno/Reference.hxx"
#include "com/sun/star/uno/Sequence.hxx"
#include "cppuhelper/factory.hxx"
#include "rtl/unload.h"
#include "sal/types.h"
namespace com { namespace sun { namespace star { namespace lang {
class XSingleComponentFactory;
} } } }
namespace com { namespace sun { namespace star {
namespace uno {
class XComponentContext;
class XInterface;
}
} } }
namespace rtl { class OUString; }
namespace configmgr { namespace configuration_registry {
com::sun::star::uno::Reference< com::sun::star::uno::XInterface > SAL_CALL
create(
com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >
const & context);
rtl::OUString SAL_CALL getImplementationName();
com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL
getSupportedServiceNames();
com::sun::star::uno::Reference< com::sun::star::lang::XSingleComponentFactory >
SAL_CALL createFactory(
cppu::ComponentFactoryFunc, rtl::OUString const &,
com::sun::star::uno::Sequence< rtl::OUString > const &, rtl_ModuleCount *)
SAL_THROW(());
} }
#endif

View File

@@ -28,24 +28,16 @@
#include "precompiled_configmgr.hxx"
#include "sal/config.h"
#include "boost/noncopyable.hpp"
#include "com/sun/star/lang/XSingleComponentFactory.hpp"
#include "com/sun/star/uno/Any.hxx"
#include "com/sun/star/uno/Exception.hpp"
#include "com/sun/star/uno/Reference.hxx"
#include "com/sun/star/uno/RuntimeException.hpp"
#include "com/sun/star/uno/Sequence.hxx"
#include "com/sun/star/uno/XComponentContext.hpp"
#include "com/sun/star/uno/XInterface.hpp"
#include "cppuhelper/factory.hxx"
#include "cppuhelper/implbase1.hxx"
#include "cppuhelper/weak.hxx"
#include "sal/types.h"
#include "rtl/unload.h"
#include "osl/mutex.hxx"
#include "rtl/ustring.h"
#include "rtl/ustring.hxx"
#include "configurationprovider.hxx"
#include "defaultprovider.hxx"
#include "lock.hxx"
namespace configmgr { namespace default_provider {
@@ -54,58 +46,17 @@ namespace {
namespace css = com::sun::star;
class Factory:
public cppu::WeakImplHelper1< css::lang::XSingleComponentFactory >,
private boost::noncopyable
{
public:
Factory() {}
private:
virtual ~Factory() {}
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL
createInstanceWithContext(
css::uno::Reference< css::uno::XComponentContext > const & Context)
throw (css::uno::Exception, css::uno::RuntimeException);
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL
createInstanceWithArgumentsAndContext(
css::uno::Sequence< css::uno::Any > const & Arguments,
css::uno::Reference< css::uno::XComponentContext > const & Context)
throw (css::uno::Exception, css::uno::RuntimeException);
};
css::uno::Reference< css::uno::XInterface > Factory::createInstanceWithContext(
css::uno::Reference< css::uno::XComponentContext > const & Context)
throw (css::uno::Exception, css::uno::RuntimeException)
{
return createInstanceWithArgumentsAndContext(
css::uno::Sequence< css::uno::Any >(), Context);
}
css::uno::Reference< css::uno::XInterface >
Factory::createInstanceWithArgumentsAndContext(
css::uno::Sequence< css::uno::Any > const & Arguments,
css::uno::Reference< css::uno::XComponentContext > const & Context)
throw (css::uno::Exception, css::uno::RuntimeException)
css::uno::Reference< css::uno::XInterface > create(
css::uno::Reference< css::uno::XComponentContext > const & context)
{
if (Arguments.getLength() != 0) {
throw css::uno::Exception(
rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM(
"com.sun.star.configuration.DefaultProvider must be"
" instantiated without arguments")),
static_cast< cppu::OWeakObject * >(this));
}
osl::MutexGuard guard(lock);
static css::uno::Reference< css::uno::XInterface > singleton(
configuration_provider::createDefault(Context));
configuration_provider::createDefault(context));
return singleton;
}
}
rtl::OUString getImplementationName() {
return rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM(
@@ -119,13 +70,4 @@ css::uno::Sequence< rtl::OUString > getSupportedServiceNames() {
return css::uno::Sequence< rtl::OUString >(&name, 1);
}
css::uno::Reference< css::lang::XSingleComponentFactory >
SAL_CALL createFactory(
cppu::ComponentFactoryFunc, rtl::OUString const &,
css::uno::Sequence< rtl::OUString > const &, rtl_ModuleCount *)
SAL_THROW(())
{
return new Factory;
}
} }

View File

@@ -32,28 +32,28 @@
#include "com/sun/star/uno/Reference.hxx"
#include "com/sun/star/uno/Sequence.hxx"
#include "cppuhelper/factory.hxx"
#include "rtl/unload.h"
#include "sal/types.h"
namespace com { namespace sun { namespace star { namespace lang {
class XSingleComponentFactory;
} } } }
namespace com { namespace sun { namespace star {
namespace uno {
class XComponentContext;
class XInterface;
}
} } }
namespace rtl { class OUString; }
namespace configmgr { namespace default_provider {
com::sun::star::uno::Reference< com::sun::star::uno::XInterface > SAL_CALL
create(
com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >
const & context);
rtl::OUString SAL_CALL getImplementationName();
com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL
getSupportedServiceNames();
com::sun::star::uno::Reference< com::sun::star::lang::XSingleComponentFactory >
SAL_CALL createFactory(
cppu::ComponentFactoryFunc, rtl::OUString const &,
com::sun::star::uno::Sequence< rtl::OUString > const &, rtl_ModuleCount *)
SAL_THROW(());
} }
#endif

View File

@@ -32,6 +32,7 @@
#include "com/sun/star/uno/Reference.hxx"
#include "com/sun/star/uno/XComponentContext.hpp"
#include "com/sun/star/uno/XInterface.hpp"
#include "cppuhelper/factory.hxx"
#include "cppuhelper/implementationentry.hxx"
#include "osl/diagnose.h"
#include "uno/lbnames.h"
@@ -58,15 +59,17 @@ static cppu::ImplementationEntry const services[] = {
{ &dummy, &configmgr::configuration_provider::getImplementationName,
&configmgr::configuration_provider::getSupportedServiceNames,
&configmgr::configuration_provider::createFactory, 0, 0 },
{ &dummy, &configmgr::default_provider::getImplementationName,
{ &configmgr::default_provider::create,
&configmgr::default_provider::getImplementationName,
&configmgr::default_provider::getSupportedServiceNames,
&configmgr::default_provider::createFactory, 0, 0 },
{ &dummy, &configmgr::configuration_registry::getImplementationName,
&cppu::createSingleComponentFactory, 0, 0 },
{ &configmgr::configuration_registry::create,
&configmgr::configuration_registry::getImplementationName,
&configmgr::configuration_registry::getSupportedServiceNames,
&configmgr::configuration_registry::createFactory, 0, 0 },
{ &dummy, &configmgr::update::getImplementationName,
&cppu::createSingleComponentFactory, 0, 0 },
{ &configmgr::update::create, &configmgr::update::getImplementationName,
&configmgr::update::getSupportedServiceNames,
&configmgr::update::createFactory, 0, 0 },
&cppu::createSingleComponentFactory, 0, 0 },
{ 0, 0, 0, 0, 0, 0 }
};

View File

@@ -32,20 +32,15 @@
#include "boost/noncopyable.hpp"
#include "com/sun/star/configuration/XUpdate.hpp"
#include "com/sun/star/lang/XSingleComponentFactory.hpp"
#include "com/sun/star/uno/Any.hxx"
#include "com/sun/star/uno/Exception.hpp"
#include "com/sun/star/uno/Reference.hxx"
#include "com/sun/star/uno/RuntimeException.hpp"
#include "com/sun/star/uno/Sequence.hxx"
#include "com/sun/star/uno/XComponentContext.hpp"
#include "com/sun/star/uno/XInterface.hpp"
#include "cppuhelper/factory.hxx"
#include "cppuhelper/implbase1.hxx"
#include "cppuhelper/weak.hxx"
#include "osl/mutex.hxx"
#include "rtl/ref.hxx"
#include "rtl/unload.h"
#include "rtl/ustring.h"
#include "rtl/ustring.hxx"
#include "sal/types.h"
@@ -155,55 +150,14 @@ void Service::insertModificationXcuFile(
bc.send();
}
class Factory:
public cppu::WeakImplHelper1< css::lang::XSingleComponentFactory >,
private boost::noncopyable
{
public:
Factory() {}
private:
virtual ~Factory() {}
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL
createInstanceWithContext(
css::uno::Reference< css::uno::XComponentContext > const & Context)
throw (css::uno::Exception, css::uno::RuntimeException);
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL
createInstanceWithArgumentsAndContext(
css::uno::Sequence< css::uno::Any > const & Arguments,
css::uno::Reference< css::uno::XComponentContext > const & Context)
throw (css::uno::Exception, css::uno::RuntimeException);
};
css::uno::Reference< css::uno::XInterface > Factory::createInstanceWithContext(
css::uno::Reference< css::uno::XComponentContext > const & Context)
throw (css::uno::Exception, css::uno::RuntimeException)
{
return createInstanceWithArgumentsAndContext(
css::uno::Sequence< css::uno::Any >(), Context);
}
css::uno::Reference< css::uno::XInterface >
Factory::createInstanceWithArgumentsAndContext(
css::uno::Sequence< css::uno::Any > const & Arguments,
css::uno::Reference< css::uno::XInterface > create(
css::uno::Reference< css::uno::XComponentContext > const &)
throw (css::uno::Exception, css::uno::RuntimeException)
{
if (Arguments.getLength() != 0) {
throw css::uno::Exception(
rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM(
"com.sun.star.comp.configuration.Update must be"
" instantiated without arguments")),
static_cast< cppu::OWeakObject * >(this));
}
return static_cast< cppu::OWeakObject * >(new Service);
}
}
rtl::OUString getImplementationName() {
return rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.configuration.Update"));
@@ -216,12 +170,4 @@ css::uno::Sequence< rtl::OUString > getSupportedServiceNames() {
return css::uno::Sequence< rtl::OUString >(&name, 1);
}
css::uno::Reference< css::lang::XSingleComponentFactory > createFactory(
cppu::ComponentFactoryFunc, rtl::OUString const &,
css::uno::Sequence< rtl::OUString > const &, rtl_ModuleCount *)
SAL_THROW(())
{
return new Factory;
}
} }

View File

@@ -32,28 +32,28 @@
#include "com/sun/star/uno/Reference.hxx"
#include "com/sun/star/uno/Sequence.hxx"
#include "cppuhelper/factory.hxx"
#include "rtl/unload.h"
#include "sal/types.h"
namespace com { namespace sun { namespace star { namespace lang {
class XSingleComponentFactory;
} } } }
namespace com { namespace sun { namespace star {
namespace uno {
class XComponentContext;
class XInterface;
}
} } }
namespace rtl { class OUString; }
namespace configmgr { namespace update {
com::sun::star::uno::Reference< com::sun::star::uno::XInterface > SAL_CALL
create(
com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >
const &);
rtl::OUString SAL_CALL getImplementationName();
com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL
getSupportedServiceNames();
com::sun::star::uno::Reference< com::sun::star::lang::XSingleComponentFactory >
SAL_CALL createFactory(
cppu::ComponentFactoryFunc, rtl::OUString const &,
com::sun::star::uno::Sequence< rtl::OUString > const &, rtl_ModuleCount *)
SAL_THROW(());
} }
#endif