Add .component <implementation constructor="..." feature

...to directly call constructor functions of ComponentContext-based C++
implementations of (non-single-instance) UNO services.  The case where these
calls would need to be bridged across different environments (e.g., from gcc3
to gcc3:affine) is not yet implemented.

bootstrap.component and expwrap.component are adapted accordingly as a proof-of-
concept (which had previously been adapted to use the prefix="direct" feature,
which may become unnecessary again in the end, depending on how to handle
single-instance services/singletons).  More to follow.

Change-Id: I18682d75bcd29d3d427e31331b4ce8161dbb846d
This commit is contained in:
Stephan Bergmann 2013-12-19 08:48:56 +01:00
parent 80d977b896
commit ae3a0c8da5
24 changed files with 713 additions and 893 deletions

View File

@ -11,11 +11,11 @@
extern "C" extern "C"
__attribute__ ((visibility("default"))) __attribute__ ((visibility("default")))
const lib_to_component_mapping * const lib_to_factory_mapping *
lo_get_library_map(void) lo_get_factory_map(void)
{ {
static lib_to_component_mapping map[] = { static lib_to_factory_mapping map[] = {
NON_APP_SPECIFIC_COMPONENT_MAP NON_APP_SPECIFIC_FACTORY_MAP
{ "libanimcorelo.a", animcore_component_getFactory }, { "libanimcorelo.a", animcore_component_getFactory },
{ "libavmedialo.a", avmedia_component_getFactory }, { "libavmedialo.a", avmedia_component_getFactory },
{ "libdbalo.a", dba_component_getFactory }, { "libdbalo.a", dba_component_getFactory },
@ -62,11 +62,11 @@ lo_get_library_map(void)
extern "C" extern "C"
__attribute__ ((visibility("default"))) __attribute__ ((visibility("default")))
const lib_to_component_mapping * const lib_to_constructor_mapping *
lo_get_implementation_map(void) lo_get_constructor_map(void)
{ {
static lib_to_component_mapping map[] = { static lib_to_constructor_mapping map[] = {
NON_APP_SPECIFIC_DIRECT_COMPONENT_MAP NON_APP_SPECIFIC_CONSTRUCTOR_MAP
{ NULL, NULL } { NULL, NULL }
}; };

View File

@ -11,11 +11,11 @@
extern "C" extern "C"
__attribute__ ((visibility("default"))) __attribute__ ((visibility("default")))
const lib_to_component_mapping * const lib_to_factory_mapping *
lo_get_library_map(void) lo_get_factory_map(void)
{ {
static lib_to_component_mapping map[] = { static lib_to_factory_mapping map[] = {
NON_APP_SPECIFIC_COMPONENT_MAP NON_APP_SPECIFIC_FACTORY_MAP
{ "libanimcorelo.a", animcore_component_getFactory }, { "libanimcorelo.a", animcore_component_getFactory },
{ "libavmedialo.a", avmedia_component_getFactory }, { "libavmedialo.a", avmedia_component_getFactory },
{ "libbasprov.uno.a", basprov_component_getFactory }, { "libbasprov.uno.a", basprov_component_getFactory },
@ -80,11 +80,11 @@ lo_get_library_map(void)
extern "C" extern "C"
__attribute__ ((visibility("default"))) __attribute__ ((visibility("default")))
const lib_to_component_mapping * const lib_to_constructor_mapping *
lo_get_implementation_map(void) lo_get_constructor_map(void)
{ {
static lib_to_component_mapping map[] = { static lib_to_constructor_mapping map[] = {
NON_APP_SPECIFIC_DIRECT_COMPONENT_MAP NON_APP_SPECIFIC_CONSTRUCTOR_MAP
{ NULL, NULL } { NULL, NULL }
}; };

View File

@ -11,11 +11,11 @@
extern "C" extern "C"
__attribute__ ((visibility("default"))) __attribute__ ((visibility("default")))
const lib_to_component_mapping * const lib_to_factory_mapping *
lo_get_library_map(void) lo_get_factory_map(void)
{ {
static lib_to_component_mapping map[] = { static lib_to_factory_mapping map[] = {
NON_APP_SPECIFIC_COMPONENT_MAP NON_APP_SPECIFIC_FACTORY_MAP
{ "libanimcorelo.a", animcore_component_getFactory }, { "libanimcorelo.a", animcore_component_getFactory },
{ "libavmedialo.a", avmedia_component_getFactory }, { "libavmedialo.a", avmedia_component_getFactory },
{ "libbasprovlo.a", basprov_component_getFactory }, { "libbasprovlo.a", basprov_component_getFactory },
@ -92,11 +92,11 @@ lo_get_library_map(void)
extern "C" extern "C"
__attribute__ ((visibility("default"))) __attribute__ ((visibility("default")))
const lib_to_component_mapping * const lib_to_constructor_mapping *
lo_get_implementation_map(void) lo_get_constructor_map(void)
{ {
static lib_to_component_mapping map[] = { static lib_to_constructor_mapping map[] = {
NON_APP_SPECIFIC_DIRECT_COMPONENT_MAP NON_APP_SPECIFIC_CONSTRUCTOR_MAP
{ NULL, NULL } { NULL, NULL }
}; };

View File

@ -14,18 +14,29 @@
#include <com/sun/star/uno/Reference.hxx> #include <com/sun/star/uno/Reference.hxx>
#include <servicemanager.hxx>
namespace com { namespace sun { namespace star { namespace com { namespace sun { namespace star {
namespace lang { class XMultiServiceFactory; } namespace lang { class XMultiServiceFactory; }
namespace uno { class XInterface; } namespace uno {
class Environment;
class XInterface;
}
} } } } } }
namespace rtl { class OUString; } namespace rtl { class OUString; }
namespace cppuhelper { namespace detail { namespace cppuhelper { namespace detail {
css::uno::Reference<css::uno::XInterface> loadSharedLibComponentFactory( css::uno::Environment getEnvironment(
rtl::OUString const & name, rtl::OUString const & implementation);
void loadSharedLibComponentFactory(
rtl::OUString const & uri, rtl::OUString const & environment, rtl::OUString const & uri, rtl::OUString const & environment,
rtl::OUString const & prefix, rtl::OUString const & rImplName, rtl::OUString const & prefix, rtl::OUString const & implementation,
css::uno::Reference<css::lang::XMultiServiceFactory> const & xMgr); rtl::OUString const & constructor,
css::uno::Reference<css::lang::XMultiServiceFactory> const & serviceManager,
ImplementationConstructorFn ** constructorFunction,
css::uno::Reference<css::uno::XInterface> * factory);
} } } }

View File

@ -40,6 +40,7 @@
#include "rtl/ustring.hxx" #include "rtl/ustring.hxx"
#include "rtl/strbuf.hxx" #include "rtl/strbuf.hxx"
#include "sal/log.hxx" #include "sal/log.hxx"
#include "uno/environment.hxx"
#include <loadsharedlibcomponentfactory.hxx> #include <loadsharedlibcomponentfactory.hxx>
@ -344,18 +345,76 @@ void Parser::handleComponent() {
} }
void Parser::handleImplementation() { void Parser::handleImplementation() {
OUString name(getNameAttribute()); rtl::OUString attrName;
rtl::OUString attrConstructor;
xmlreader::Span name;
int nsId;
while (reader_.nextAttribute(&nsId, &name)) {
if (nsId == xmlreader::XmlReader::NAMESPACE_NONE
&& name.equals(RTL_CONSTASCII_STRINGPARAM("name")))
{
if (!attrName.isEmpty()) {
throw css::registry::InvalidRegistryException(
(reader_.getUrl()
+ ": <implementation> has multiple \"name\" attributes"),
css::uno::Reference< css::uno::XInterface >());
}
attrName = reader_.getAttributeValue(false).convertFromUtf8();
if (attrName.isEmpty()) {
throw css::registry::InvalidRegistryException(
(reader_.getUrl()
+ ": <implementation> has empty \"name\" attribute"),
css::uno::Reference< css::uno::XInterface >());
}
} else if (nsId == xmlreader::XmlReader::NAMESPACE_NONE
&& name.equals(RTL_CONSTASCII_STRINGPARAM("constructor")))
{
if (!attrConstructor.isEmpty()) {
throw css::registry::InvalidRegistryException(
(reader_.getUrl()
+ (": <implementation> has multiple \"constructor\""
" attributes")),
css::uno::Reference< css::uno::XInterface >());
}
attrConstructor = reader_.getAttributeValue(false)
.convertFromUtf8();
if (attrConstructor.isEmpty()) {
throw css::registry::InvalidRegistryException(
(reader_.getUrl()
+ ": element has empty \"constructor\" attribute"),
css::uno::Reference< css::uno::XInterface >());
}
if (attrEnvironment_.isEmpty()) {
throw css::registry::InvalidRegistryException(
(reader_.getUrl()
+ (": <implementation> has \"constructor\" attribute but"
" <component> has no \"environment\" attribute")),
css::uno::Reference< css::uno::XInterface >());
}
} else {
throw css::registry::InvalidRegistryException(
(reader_.getUrl() + ": unexpected element attribute \""
+ name.convertFromUtf8() + "\" in <implementation>"),
css::uno::Reference< css::uno::XInterface >());
}
}
if (attrName.isEmpty()) {
throw css::registry::InvalidRegistryException(
(reader_.getUrl()
+ ": <implementation> is missing \"name\" attribute"),
css::uno::Reference< css::uno::XInterface >());
}
implementation_.reset( implementation_.reset(
new cppuhelper::ServiceManager::Data::Implementation( new cppuhelper::ServiceManager::Data::Implementation(
name, attrLoader_, attrUri_, attrEnvironment_, attrPrefix_, attrName, attrLoader_, attrUri_, attrEnvironment_, attrConstructor,
alienContext_, reader_.getUrl())); attrPrefix_, alienContext_, reader_.getUrl()));
if (!data_->namedImplementations.insert( if (!data_->namedImplementations.insert(
cppuhelper::ServiceManager::Data::NamedImplementations::value_type( cppuhelper::ServiceManager::Data::NamedImplementations::value_type(
name, implementation_)). attrName, implementation_)).
second) second)
{ {
throw css::registry::InvalidRegistryException( throw css::registry::InvalidRegistryException(
(reader_.getUrl() + ": duplicate <implementation name=\"" + name (reader_.getUrl() + ": duplicate <implementation name=\"" + attrName
+ "\">"), + "\">"),
css::uno::Reference< css::uno::XInterface >()); css::uno::Reference< css::uno::XInterface >());
} }
@ -471,7 +530,7 @@ public:
boost::shared_ptr< boost::shared_ptr<
cppuhelper::ServiceManager::Data::ImplementationInfo > const & cppuhelper::ServiceManager::Data::ImplementationInfo > const &
info): info):
manager_(manager), info_(info), loaded_(false) manager_(manager), info_(info), loaded_(false), constructor_(0)
{ assert(manager.is() && info.get() != 0); } { assert(manager.is() && info.get() != 0); }
private: private:
@ -514,6 +573,7 @@ private:
osl::Mutex mutex_; osl::Mutex mutex_;
bool loaded_; bool loaded_;
cppuhelper::ImplementationConstructorFn * constructor_;
css::uno::Reference< css::lang::XSingleComponentFactory > factory1_; css::uno::Reference< css::lang::XSingleComponentFactory > factory1_;
css::uno::Reference< css::lang::XSingleServiceFactory > factory2_; css::uno::Reference< css::lang::XSingleServiceFactory > factory2_;
}; };
@ -524,7 +584,12 @@ FactoryWrapper::createInstanceWithContext(
throw (css::uno::Exception, css::uno::RuntimeException) throw (css::uno::Exception, css::uno::RuntimeException)
{ {
loadImplementation(Context); loadImplementation(Context);
return factory1_.is() return constructor_ != 0
? css::uno::Reference<css::uno::XInterface>(
(*constructor_)(
Context.get(), css::uno::Sequence<css::uno::Any>().get()),
SAL_NO_ACQUIRE)
: factory1_.is()
? factory1_->createInstanceWithContext(Context) ? factory1_->createInstanceWithContext(Context)
: factory2_->createInstance(); : factory2_->createInstance();
} }
@ -536,7 +601,10 @@ FactoryWrapper::createInstanceWithArgumentsAndContext(
throw (css::uno::Exception, css::uno::RuntimeException) throw (css::uno::Exception, css::uno::RuntimeException)
{ {
loadImplementation(Context); loadImplementation(Context);
return factory1_.is() return constructor_ != 0
? css::uno::Reference<css::uno::XInterface>(
(*constructor_)(Context.get(), Arguments.get()), SAL_NO_ACQUIRE)
: factory1_.is()
? factory1_->createInstanceWithArgumentsAndContext(Arguments, Context) ? factory1_->createInstanceWithArgumentsAndContext(Arguments, Context)
: factory2_->createInstanceWithArguments(Arguments); : factory2_->createInstanceWithArguments(Arguments);
} }
@ -544,10 +612,7 @@ FactoryWrapper::createInstanceWithArgumentsAndContext(
css::uno::Reference< css::uno::XInterface > FactoryWrapper::createInstance() css::uno::Reference< css::uno::XInterface > FactoryWrapper::createInstance()
throw (css::uno::Exception, css::uno::RuntimeException) throw (css::uno::Exception, css::uno::RuntimeException)
{ {
loadImplementation(manager_->getContext()); return createInstanceWithContext(manager_->getContext());
return factory1_.is()
? factory1_->createInstanceWithContext(manager_->getContext())
: factory2_->createInstance();
} }
css::uno::Reference< css::uno::XInterface > css::uno::Reference< css::uno::XInterface >
@ -555,11 +620,8 @@ FactoryWrapper::createInstanceWithArguments(
css::uno::Sequence< css::uno::Any > const & Arguments) css::uno::Sequence< css::uno::Any > const & Arguments)
throw (css::uno::Exception, css::uno::RuntimeException) throw (css::uno::Exception, css::uno::RuntimeException)
{ {
loadImplementation(manager_->getContext()); return createInstanceWithArgumentsAndContext(
return factory1_.is() Arguments, manager_->getContext());
? factory1_->createInstanceWithArgumentsAndContext(
Arguments, manager_->getContext())
: factory2_->createInstanceWithArguments(Arguments);
} }
rtl::OUString FactoryWrapper::getImplementationName() rtl::OUString FactoryWrapper::getImplementationName()
@ -603,20 +665,23 @@ void FactoryWrapper::loadImplementation(
return; return;
} }
} }
cppuhelper::ImplementationConstructorFn * ctor = 0;
css::uno::Reference< css::lang::XSingleComponentFactory > f1; css::uno::Reference< css::lang::XSingleComponentFactory > f1;
css::uno::Reference< css::lang::XSingleServiceFactory > f2; css::uno::Reference< css::lang::XSingleServiceFactory > f2;
//TODO: There is a race here, as the relevant service factory can already //TODO: There is a race here, as the relevant service factory can already
// have been removed and loading can thus fail, as the entity from which to // have been removed and loading can thus fail, as the entity from which to
// load can disappear once the service factory is removed: // load can disappear once the service factory is removed:
manager_->loadImplementation(context, info_, &f1, &f2); manager_->loadImplementation(context, info_, &ctor, &f1, &f2);
if (!(f1.is() || f2.is())) { if (ctor == 0 && !f1.is() && !f2.is()) {
throw css::uno::DeploymentException( throw css::uno::DeploymentException(
"Implementation " + info_->name + " does not provide a factory", ("Implementation " + info_->name
+ " does not provide a constructor or factory"),
static_cast< cppu::OWeakObject * >(this)); static_cast< cppu::OWeakObject * >(this));
} }
osl::MutexGuard g(mutex_); osl::MutexGuard g(mutex_);
if (!loaded_) { if (!loaded_) {
loaded_ = true; loaded_ = true;
constructor_ = ctor;
factory1_ = f1; factory1_ = f1;
factory2_ = f2; factory2_ = f2;
} }
@ -647,11 +712,13 @@ void cppuhelper::ServiceManager::addSingletonContextEntries(
void cppuhelper::ServiceManager::loadImplementation( void cppuhelper::ServiceManager::loadImplementation(
css::uno::Reference< css::uno::XComponentContext > const & context, css::uno::Reference< css::uno::XComponentContext > const & context,
boost::shared_ptr< Data::ImplementationInfo > const & info, boost::shared_ptr< Data::ImplementationInfo > const & info,
ImplementationConstructorFn ** constructor,
css::uno::Reference< css::lang::XSingleComponentFactory > * factory1, css::uno::Reference< css::lang::XSingleComponentFactory > * factory1,
css::uno::Reference< css::lang::XSingleServiceFactory > * factory2) css::uno::Reference< css::lang::XSingleServiceFactory > * factory2)
{ {
assert( assert(
info.get() != 0 && factory1 != 0 && !factory1->is() && factory2 != 0 info.get() != 0 && constructor != 0 && *constructor == 0
&& factory1 != 0 && !factory1->is() && factory2 != 0
&& !factory2->is()); && !factory2->is());
rtl::OUString uri; rtl::OUString uri;
try { try {
@ -662,18 +729,38 @@ void cppuhelper::ServiceManager::loadImplementation(
static_cast< cppu::OWeakObject * >(this)); static_cast< cppu::OWeakObject * >(this));
} }
css::uno::Reference< css::uno::XInterface > f0; css::uno::Reference< css::uno::XInterface > f0;
// Shortcut loading via SharedLibrary loader, to pass in environment and // Special handling of SharedLibrary loader, with support for environment,
// prefix arguments: // constructor, and prefix arguments:
if (!info->alienContext.is() if (!info->alienContext.is()
&& info->loader == "com.sun.star.loader.SharedLibrary") && info->loader == "com.sun.star.loader.SharedLibrary")
{ {
f0 = cppuhelper::detail::loadSharedLibComponentFactory( cppuhelper::detail::loadSharedLibComponentFactory(
uri, info->environment, info->prefix, info->name, this); uri, info->environment, info->prefix, info->name, info->constructor,
this, constructor, &f0);
if (constructor != 0 && *constructor != 0) {
assert(!info->environment.isEmpty());
css::uno::Environment curEnv(css::uno::Environment::getCurrent());
css::uno::Environment env(
cppuhelper::detail::getEnvironment(
info->environment, info->name));
if (!(curEnv.is() && env.is())) {
throw css::uno::DeploymentException(
"cannot get environments",
css::uno::Reference<css::uno::XInterface>());
}
if (curEnv.get() != env.get()) {
std::abort();//TODO
}
}
} else { } else {
SAL_WARN_IF( SAL_WARN_IF(
!info->environment.isEmpty(), "cppuhelper", !info->environment.isEmpty(), "cppuhelper",
"Loader " << info->loader << " and non-empty environment " "Loader " << info->loader << " and non-empty environment "
<< info->environment); << info->environment);
SAL_WARN_IF(
!info->prefix.isEmpty(), "cppuhelper",
"Loader " << info->loader << " and non-empty constructor "
<< info->constructor);
SAL_WARN_IF( SAL_WARN_IF(
!info->prefix.isEmpty(), "cppuhelper", !info->prefix.isEmpty(), "cppuhelper",
"Loader " << info->loader << " and non-empty prefix " "Loader " << info->loader << " and non-empty prefix "
@ -810,7 +897,12 @@ cppuhelper::ServiceManager::createInstanceWithContext(
if (impl.get() == 0) { if (impl.get() == 0) {
return css::uno::Reference< css::uno::XInterface >(); return css::uno::Reference< css::uno::XInterface >();
} }
if (impl->factory1.is()) { if (impl->constructor != 0) {
return css::uno::Reference<css::uno::XInterface>(
(*impl->constructor)(
Context.get(), css::uno::Sequence<css::uno::Any>().get()),
SAL_NO_ACQUIRE);
} else if (impl->factory1.is()) {
return impl->factory1->createInstanceWithContext(Context); return impl->factory1->createInstanceWithContext(Context);
} }
if (impl->factory2.is()) { if (impl->factory2.is()) {
@ -833,7 +925,11 @@ cppuhelper::ServiceManager::createInstanceWithArgumentsAndContext(
if (impl.get() == 0) { if (impl.get() == 0) {
return css::uno::Reference< css::uno::XInterface >(); return css::uno::Reference< css::uno::XInterface >();
} }
if (impl->factory1.is()) { if (impl->constructor != 0) {
return css::uno::Reference<css::uno::XInterface>(
(*impl->constructor)(Context.get(), Arguments.get()),
SAL_NO_ACQUIRE);
} else if (impl->factory1.is()) {
return impl->factory1->createInstanceWithArgumentsAndContext( return impl->factory1->createInstanceWithArgumentsAndContext(
Arguments, Context); Arguments, Context);
} }
@ -1309,7 +1405,7 @@ bool cppuhelper::ServiceManager::readLegacyRdbFile(rtl::OUString const & uri) {
boost::shared_ptr< Data::Implementation > impl( boost::shared_ptr< Data::Implementation > impl(
new Data::Implementation( new Data::Implementation(
name, readLegacyRdbString(uri, implKey, "UNO/ACTIVATOR"), name, readLegacyRdbString(uri, implKey, "UNO/ACTIVATOR"),
readLegacyRdbString(uri, implKey, "UNO/LOCATION"), "", "", readLegacyRdbString(uri, implKey, "UNO/LOCATION"), "", "", "",
css::uno::Reference< css::uno::XComponentContext >(), uri)); css::uno::Reference< css::uno::XComponentContext >(), uri));
if (!data_.namedImplementations.insert( if (!data_.namedImplementations.insert(
Data::NamedImplementations::value_type(name, impl)). Data::NamedImplementations::value_type(name, impl)).
@ -1679,12 +1775,14 @@ cppuhelper::ServiceManager::findServiceImplementation(
// while the mutex is unlocked and loading can thus fail, as the entity from // while the mutex is unlocked and loading can thus fail, as the entity from
// which to load can disappear once the service factory is removed. // which to load can disappear once the service factory is removed.
if (!loaded) { if (!loaded) {
cppuhelper::ImplementationConstructorFn * ctor = 0;
css::uno::Reference< css::lang::XSingleComponentFactory > f1; css::uno::Reference< css::lang::XSingleComponentFactory > f1;
css::uno::Reference< css::lang::XSingleServiceFactory > f2; css::uno::Reference< css::lang::XSingleServiceFactory > f2;
loadImplementation(context, impl->info, &f1, &f2); loadImplementation(context, impl->info, &ctor, &f1, &f2);
osl::MutexGuard g(rBHelper.rMutex); osl::MutexGuard g(rBHelper.rMutex);
if (!(isDisposed() || impl->loaded)) { if (!(isDisposed() || impl->loaded)) {
impl->loaded = true; impl->loaded = true;
impl->constructor = ctor;
impl->factory1 = f1; impl->factory1 = f1;
impl->factory2 = f2; impl->factory2 = f2;
} }

View File

@ -34,10 +34,20 @@
#include "registry/registry.hxx" #include "registry/registry.hxx"
#include "rtl/ustring.hxx" #include "rtl/ustring.hxx"
namespace com { namespace sun { namespace star { namespace lang {
class XSingleComponentFactory;
} } } }
namespace cppu { struct ContextEntry_Init; } namespace cppu { struct ContextEntry_Init; }
namespace cppuhelper { namespace cppuhelper {
extern "C" {
typedef css::uno::XInterface * SAL_CALL ImplementationConstructorFn(
css::uno::XComponentContext *, uno_Sequence *);
}
typedef cppu::WeakComponentImplHelper8< typedef cppu::WeakComponentImplHelper8<
css::lang::XServiceInfo, css::lang::XMultiServiceFactory, css::lang::XServiceInfo, css::lang::XMultiServiceFactory,
css::lang::XMultiComponentFactory, css::container::XSet, css::lang::XMultiComponentFactory, css::container::XSet,
@ -55,13 +65,15 @@ public:
rtl::OUString const & theName, rtl::OUString const & theLoader, rtl::OUString const & theName, rtl::OUString const & theLoader,
rtl::OUString const & theUri, rtl::OUString const & theUri,
rtl::OUString const & theEnvironment, rtl::OUString const & theEnvironment,
rtl::OUString const & theConstructor,
rtl::OUString const & thePrefix, rtl::OUString const & thePrefix,
css::uno::Reference< css::uno::XComponentContext > const & css::uno::Reference< css::uno::XComponentContext > const &
theAlienContext, theAlienContext,
rtl::OUString const & theRdbFile): rtl::OUString const & theRdbFile):
name(theName), loader(theLoader), uri(theUri), name(theName), loader(theLoader), uri(theUri),
environment(theEnvironment), prefix(thePrefix), environment(theEnvironment), constructor(theConstructor),
alienContext(theAlienContext), rdbFile(theRdbFile) prefix(thePrefix), alienContext(theAlienContext),
rdbFile(theRdbFile)
{} {}
explicit ImplementationInfo(rtl::OUString const & theName): explicit ImplementationInfo(rtl::OUString const & theName):
@ -71,6 +83,7 @@ public:
rtl::OUString const loader; rtl::OUString const loader;
rtl::OUString const uri; rtl::OUString const uri;
rtl::OUString const environment; rtl::OUString const environment;
rtl::OUString const constructor;
rtl::OUString const prefix; rtl::OUString const prefix;
css::uno::Reference< css::uno::XComponentContext > const css::uno::Reference< css::uno::XComponentContext > const
alienContext; alienContext;
@ -83,15 +96,16 @@ public:
Implementation( Implementation(
rtl::OUString const & name, rtl::OUString const & loader, rtl::OUString const & name, rtl::OUString const & loader,
rtl::OUString const & uri, rtl::OUString const & environment, rtl::OUString const & uri, rtl::OUString const & environment,
rtl::OUString const & constructorName,
rtl::OUString const & prefix, rtl::OUString const & prefix,
css::uno::Reference< css::uno::XComponentContext > const & css::uno::Reference< css::uno::XComponentContext > const &
alienContext, alienContext,
rtl::OUString const & rdbFile): rtl::OUString const & rdbFile):
info( info(
new ImplementationInfo( new ImplementationInfo(
name, loader, uri, environment, prefix, alienContext, name, loader, uri, environment, constructorName, prefix,
rdbFile)), alienContext, rdbFile)),
loaded(false) constructor(0), loaded(false)
{} {}
Implementation( Implementation(
@ -102,11 +116,13 @@ public:
theFactory2, theFactory2,
css::uno::Reference< css::lang::XComponent > const & css::uno::Reference< css::lang::XComponent > const &
theComponent): theComponent):
info(new ImplementationInfo(name)), factory1(theFactory1), info(new ImplementationInfo(name)), constructor(0),
factory2(theFactory2), component(theComponent), loaded(true) factory1(theFactory1), factory2(theFactory2),
component(theComponent), loaded(true)
{} {}
boost::shared_ptr< ImplementationInfo > info; boost::shared_ptr< ImplementationInfo > info;
ImplementationConstructorFn * constructor;
css::uno::Reference< css::lang::XSingleComponentFactory > factory1; css::uno::Reference< css::lang::XSingleComponentFactory > factory1;
css::uno::Reference< css::lang::XSingleServiceFactory > factory2; css::uno::Reference< css::lang::XSingleServiceFactory > factory2;
css::uno::Reference< css::lang::XComponent > component; css::uno::Reference< css::lang::XComponent > component;
@ -160,6 +176,7 @@ public:
void loadImplementation( void loadImplementation(
css::uno::Reference< css::uno::XComponentContext > const & context, css::uno::Reference< css::uno::XComponentContext > const & context,
boost::shared_ptr< Data::ImplementationInfo > const & info, boost::shared_ptr< Data::ImplementationInfo > const & info,
ImplementationConstructorFn ** constructor,
css::uno::Reference< css::lang::XSingleComponentFactory > * factory1, css::uno::Reference< css::lang::XSingleComponentFactory > * factory1,
css::uno::Reference< css::lang::XSingleServiceFactory > * factory2); css::uno::Reference< css::lang::XSingleServiceFactory > * factory2);

View File

@ -17,456 +17,333 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 . * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/ */
#include "sal/config.h" #include <sal/config.h>
#include <cassert> #include <cassert>
#include <cstdlib>
#include "osl/module.hxx" #include <com/sun/star/loader/CannotActivateFactoryException.hpp>
#include "uno/environment.h" #include <cppuhelper/factory.hxx>
#include <uno/lbnames.h> #include <cppuhelper/shlib.hxx>
#include "uno/mapping.hxx" #include <osl/module.hxx>
#include "cppuhelper/factory.hxx" #include <uno/environment.hxx>
#include "cppuhelper/shlib.hxx" #include <uno/mapping.hxx>
#include "com/sun/star/beans/XPropertySet.hpp"
#include <loadsharedlibcomponentfactory.hxx> #include <loadsharedlibcomponentfactory.hxx>
#include <stdio.h> #if defined ANDROID
#ifdef ANDROID
#include <osl/detail/android-bootstrap.h> #include <osl/detail/android-bootstrap.h>
#endif #elif defined IOS
#ifdef IOS
#include <osl/detail/component-mapping.h> #include <osl/detail/component-mapping.h>
#endif #endif
using namespace ::osl; css::uno::Environment cppuhelper::detail::getEnvironment(
using namespace ::com::sun::star; rtl::OUString const & name, rtl::OUString const & implementation)
using namespace ::com::sun::star::uno; {
assert(!implementation.isEmpty());
using rtl::OString; rtl::OUString n(name);
using rtl::OUString; static char const * log = std::getenv("UNO_ENV_LOG");
if (log != 0 && *log != 0) {
rtl::OString imps(log);
for (sal_Int32 i = 0; i != -1;) {
rtl::OString imp(imps.getToken(0, ';', i));
//TODO: this assumes UNO_ENV_LOG only contains ASCII characters:
if (implementation.equalsAsciiL(imp.getStr(), imp.getLength())) {
n += ":log";
break;
}
}
}
return css::uno::Environment(n);
}
namespace { namespace {
uno::Environment getEnvironment( #if !defined DISABLE_DYNLOADING
OUString const & name, OUString const & cImplName)
css::uno::Environment getEnvironmentFromModule(
osl::Module const & module, css::uno::Environment const & target,
rtl::OUString const & implementation, rtl::OUString const & prefix)
{ {
OUString n(name); char const * name = 0;
static const char * pUNO_ENV_LOG = ::getenv( "UNO_ENV_LOG" ); css::uno::Environment env;
if (pUNO_ENV_LOG && rtl_str_getLength(pUNO_ENV_LOG) ) rtl::OUString fullPrefix(prefix);
if (!fullPrefix.isEmpty()) {
fullPrefix += "_";
}
component_getImplementationEnvironmentExtFunc fp1
= reinterpret_cast<component_getImplementationEnvironmentExtFunc>(
module.getFunctionSymbol(fullPrefix + COMPONENT_GETENVEXT));
if (fp1 != 0) {
(*fp1)(
&name, reinterpret_cast<uno_Environment **>(&env),
(rtl::OUStringToOString(implementation, RTL_TEXTENCODING_ASCII_US)
.getStr()),
target.get());
} else {
component_getImplementationEnvironmentFunc fp2
= reinterpret_cast<component_getImplementationEnvironmentFunc>(
module.getFunctionSymbol(fullPrefix + COMPONENT_GETENV));
if (fp2 != 0) {
(*fp2)(&name, reinterpret_cast<uno_Environment **>(&env));
} else {
name = CPPU_CURRENT_LANGUAGE_BINDING_NAME; //TODO: fail
}
}
if (!env.is() && name != 0) {
env = cppuhelper::detail::getEnvironment(
rtl::OUString::createFromAscii(name), implementation);
}
return env;
}
#endif
extern "C" void getFactory(va_list * args) {
component_getFactoryFunc fn = va_arg(*args, component_getFactoryFunc);
rtl::OString const * implementation = va_arg(*args, rtl::OString const *);
void * smgr = va_arg(*args, void *);
void * key = va_arg(*args, void *);
void ** factory = va_arg(*args, void **);
*factory = (*fn)(implementation->getStr(), smgr, key);
}
css::uno::Reference<css::uno::XInterface> invokeComponentFactory(
css::uno::Environment const & source, css::uno::Environment const & target,
component_getFactoryFunc function, rtl::OUString const & uri,
rtl::OUString const & implementation,
css::uno::Reference<css::lang::XMultiServiceFactory> const & serviceManager)
{ {
OString implName(OUStringToOString(cImplName, RTL_TEXTENCODING_ASCII_US)); if (!(source.is() && target.is())) {
OString aEnv( pUNO_ENV_LOG ); throw css::loader::CannotActivateFactoryException(
sal_Int32 nIndex = 0; "cannot get environments",
do css::uno::Reference<css::uno::XInterface>());
}
rtl::OString impl(
rtl::OUStringToOString(implementation, RTL_TEXTENCODING_ASCII_US));
if (source.get() == target.get()) {
return css::uno::Reference<css::uno::XInterface>(
static_cast<css::uno::XInterface *>(
(*function)(impl.getStr(), serviceManager.get(), 0)),
SAL_NO_ACQUIRE);
} else {
css::uno::Mapping mapTo(source, target);
css::uno::Mapping mapFrom(target, source);
if (!(mapTo.is() && mapFrom.is())) {
throw css::loader::CannotActivateFactoryException(
"cannot get mappings",
css::uno::Reference<css::uno::XInterface>());
}
void * smgr = mapTo.mapInterface(
serviceManager.get(),
cppu::UnoType<css::lang::XMultiServiceFactory>::get());
void * factory = 0;
target.invoke(getFactory, function, &impl, smgr, 0, &factory);
if (smgr != 0) {
(*target.get()->pExtEnv->releaseInterface)(
target.get()->pExtEnv, smgr);
}
if (factory == 0) {
throw css::loader::CannotActivateFactoryException(
("calling factory function for \"" + implementation + "\" in <"
+ uri + "> returned null"),
css::uno::Reference<css::uno::XInterface>());
}
css::uno::Reference<css::uno::XInterface> res;
mapFrom.mapInterface(
reinterpret_cast<void **>(&res), factory,
cppu::UnoType<css::uno::XInterface>::get());
(*target.get()->pExtEnv->releaseInterface)(
target.get()->pExtEnv, factory);
return res;
}
}
}
void cppuhelper::detail::loadSharedLibComponentFactory(
rtl::OUString const & uri, rtl::OUString const & environment,
rtl::OUString const & prefix, rtl::OUString const & implementation,
rtl::OUString const & constructor,
css::uno::Reference<css::lang::XMultiServiceFactory> const & serviceManager,
ImplementationConstructorFn ** constructorFunction,
css::uno::Reference<css::uno::XInterface> * factory)
{ {
const OString aStr( aEnv.getToken( 0, ';', nIndex ) ); assert(constructor.isEmpty() || !environment.isEmpty());
if ( aStr.equals(implName) ) assert(
{ (constructorFunction == 0 && constructor.isEmpty())
n += ::rtl::OUString(":log"); || *constructorFunction == 0);
assert(factory != 0 && !factory->is());
#if defined DISABLE_DYNLOADING
assert(!environment.isEmpty());
if (constructor.isEmpty()) {
css::uno::Environment curEnv(css::uno::Environment::getCurrent());
css::uno::Environment env(getEnvironment(environment, implementation));
if (!(curEnv.is() && env.is())) {
throw css::loader::CannotActivateFactoryException(
"cannot get environments",
css::uno::Reference<css::uno::XInterface>());
}
if (curEnv.get() != env.get()) {
std::abort();//TODO
}
rtl::OUString name(prefix == "direct" ? implementation : uri);
lib_to_factory_mapping const * map = lo_get_factory_map();
component_getFactoryFunc fp;
for (int i = 0; map[i].name != 0; ++i) {
if (name.equalsAscii(map[i].name)) {
fp = map[i].component_getFactory_function;
break; break;
} }
} while( nIndex != -1 );
} }
return uno::Environment(n); if (fp == 0) {
throw css::loader::CannotActivateFactoryException(
"unknown factory name \"" + name + "\"",
css::uno::Reference<css::uno::XInterface>());
} }
*factory = invokeComponentFactory(
#ifndef DISABLE_DYNLOADING css::uno::Environment::getCurrent(),
getEnvironment(environment, implementation), fp, uri,
void getLibEnv(oslModule lib, implementation, serviceManager);
uno::Environment * pEnv,
uno::Environment const & cTargetEnv,
OUString const & cImplName = OUString(),
OUString const & rPrefix = OUString())
{
sal_Char const * pEnvTypeName = NULL;
OUString aGetEnvNameExt = rPrefix + COMPONENT_GETENVEXT;
component_getImplementationEnvironmentExtFunc pGetImplEnvExt =
(component_getImplementationEnvironmentExtFunc)osl_getFunctionSymbol(lib, aGetEnvNameExt.pData);
if (pGetImplEnvExt)
{
OString implName(OUStringToOString(cImplName, RTL_TEXTENCODING_ASCII_US));
pGetImplEnvExt(&pEnvTypeName, (uno_Environment **)pEnv, implName.getStr(), cTargetEnv.get());
}
else
{
OUString aGetEnvName = rPrefix + COMPONENT_GETENV;
component_getImplementationEnvironmentFunc pGetImplEnv =
(component_getImplementationEnvironmentFunc)osl_getFunctionSymbol(
lib, aGetEnvName.pData );
if (pGetImplEnv)
pGetImplEnv(&pEnvTypeName, (uno_Environment **)pEnv);
else // this symbol used to be mandatory, but is no longer
pEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
}
if (!pEnv->is() && pEnvTypeName)
{
*pEnv = getEnvironment(
OUString::createFromAscii(pEnvTypeName), cImplName);
}
}
#endif
extern "C" void s_getFactory(va_list * pParam)
{
component_getFactoryFunc pSym = va_arg(*pParam, component_getFactoryFunc);
OString const * pImplName = va_arg(*pParam, OString const *);
void * pSMgr = va_arg(*pParam, void *);
void * pKey = va_arg(*pParam, void *);
void ** ppSSF = va_arg(*pParam, void **);
*ppSSF = pSym(pImplName->getStr(), pSMgr, pKey);
}
}
namespace cppu
{
/* For backwards compatibility */
Reference< XInterface > SAL_CALL loadSharedLibComponentFactory(
OUString const & uri, OUString const & rPath, OUString const & rImplName,
Reference< lang::XMultiServiceFactory > const & xMgr,
Reference< registry::XRegistryKey > const & xKey )
SAL_THROW( (loader::CannotActivateFactoryException) )
{
assert(rPath.isEmpty());
assert(!xKey.is());
(void) rPath;
(void) xKey;
return cppuhelper::detail::loadSharedLibComponentFactory(
uri, "", "", rImplName, xMgr);
}
}
namespace
{
Reference< XInterface > invokeComponentFactory(
uno::Environment const & env,
oslGenericFunction pGetter,
OUString const & rModulePath,
OUString const & rImplName,
Reference< ::com::sun::star::lang::XMultiServiceFactory > const & xMgr,
OUString &rExcMsg )
{
Reference< XInterface > xRet;
uno::Environment currentEnv(Environment::getCurrent());
OString aImplName(
OUStringToOString( rImplName, RTL_TEXTENCODING_ASCII_US ) );
if (env.is() && currentEnv.is())
{
#if OSL_DEBUG_LEVEL > 1
{
rtl::OString modPath(rtl::OUStringToOString(rModulePath, RTL_TEXTENCODING_ASCII_US));
rtl::OString implName(rtl::OUStringToOString(rImplName, RTL_TEXTENCODING_ASCII_US));
rtl::OString envDcp(rtl::OUStringToOString(env.getTypeName(), RTL_TEXTENCODING_ASCII_US));
fprintf(stderr, "invokeComponentFactory envDcp:%s implName:%s modPath:%s\n", envDcp.getStr(), implName.getStr(), modPath.getStr());
}
#endif
if (env.get() == currentEnv.get())
{
xRet.set(
static_cast<css::uno::XInterface *>(
(*reinterpret_cast<component_getFactoryFunc>(pGetter))(
aImplName.getStr(), xMgr.get(), 0)),
SAL_NO_ACQUIRE);
}
else
{
Mapping aCurrent2Env( currentEnv, env );
Mapping aEnv2Current( env, currentEnv );
if (aCurrent2Env.is() && aEnv2Current.is())
{
void * pSMgr = aCurrent2Env.mapInterface(
xMgr.get(), ::getCppuType( &xMgr ) );
void * pSSF = NULL;
env.invoke(s_getFactory, pGetter, &aImplName, pSMgr, 0, &pSSF);
if (pSMgr)
{
(*env.get()->pExtEnv->releaseInterface)(
env.get()->pExtEnv, pSMgr );
}
if (pSSF)
{
aEnv2Current.mapInterface(
reinterpret_cast< void ** >( &xRet ),
pSSF, ::getCppuType( &xRet ) );
(env.get()->pExtEnv->releaseInterface)(
env.get()->pExtEnv, pSSF );
}
else
{
rExcMsg = rModulePath +
": cannot get factory of " +
"demanded implementation: " +
OStringToOUString(
aImplName, RTL_TEXTENCODING_ASCII_US );
}
}
else
{
rExcMsg =
"cannot get uno mappings: C++ <=> UNO!";
}
}
}
else
{
rExcMsg = "cannot get uno environments!";
}
return xRet;
}
} // namespace
namespace cppuhelper { namespace detail {
css::uno::Reference<css::uno::XInterface> loadSharedLibComponentFactory(
OUString const & uri, OUString const & rEnvironment,
OUString const & rPrefix, OUString const & rImplName,
css::uno::Reference<css::lang::XMultiServiceFactory> const & xMgr)
{
#ifndef DISABLE_DYNLOADING
OUString moduleUri(uri);
oslModule lib = osl_loadModule(
moduleUri.pData, SAL_LOADMODULE_LAZY | SAL_LOADMODULE_GLOBAL );
if (! lib)
{
OUString const msg("loading component library failed: " + moduleUri);
SAL_WARN("cppuhelper", msg);
throw loader::CannotActivateFactoryException(msg,
Reference< XInterface >() );
}
#else
oslModule lib;
OUString moduleUri("MAIN");
if (! osl_getModuleHandle( NULL, &lib))
{
throw loader::CannotActivateFactoryException(
"osl_getModuleHandle of the executable: ",
Reference< XInterface >() );
}
#endif
Reference< XInterface > xRet;
OUString aExcMsg;
OUString aFullPrefix(rPrefix);
if (!aFullPrefix.isEmpty()) {
aFullPrefix += "_";
}
OUString aGetFactoryName = aFullPrefix + COMPONENT_GETFACTORY;
if (rPrefix == "direct")
aGetFactoryName = rImplName.replace('.', '_') + "_" + COMPONENT_GETFACTORY;
oslGenericFunction pSym = NULL;
#ifdef DISABLE_DYNLOADING
OString sName;
const lib_to_component_mapping *map = NULL;
if (rPrefix == "direct")
{
sName = OUStringToOString(rImplName, RTL_TEXTENCODING_ASCII_US);
map = lo_get_implementation_map();
}
else
{
sName = OUStringToOString(uri, RTL_TEXTENCODING_ASCII_US);
map = lo_get_library_map();
}
for (int i = 0; pSym == NULL && map[i].name != NULL; ++i)
{
if ( sName == map[i].name )
pSym = (oslGenericFunction) map[i].component_getFactory_function;
}
if ( pSym == NULL )
{
fprintf( stderr, "attempting to load unknown library %s\n", OUStringToOString( uri, RTL_TEXTENCODING_ASCII_US ).getStr() );
assert( !"Attempt to load unknown library" );
}
#else
if ( pSym == NULL )
pSym = osl_getFunctionSymbol( lib, aGetFactoryName.pData );
#endif
if (pSym != 0)
{
uno::Environment env;
if (rEnvironment.isEmpty()) {
#if defined DISABLE_DYNLOADING
//TODO: assert(false); // this cannot happen
env = getEnvironment(CPPU_CURRENT_LANGUAGE_BINDING_NAME, rImplName);
#else
getLibEnv(
lib, &env, Environment::getCurrent(), rImplName, aFullPrefix);
#endif
} else { } else {
env = getEnvironment(rEnvironment, rImplName); lib_to_constructor_mapping const * map = lo_get_constructor_map();
for (int i = 0; map[i].name != 0; ++i) {
if (constructor.equalsAscii(map[i].name)) {
*constructorFunction
= reinterpret_cast<ImplementationConstructorFn *>(
map[i].constructor_function);
return;
} }
xRet = invokeComponentFactory(
env, pSym, moduleUri, rImplName, xMgr, aExcMsg );
} }
else throw css::loader::CannotActivateFactoryException(
{ "unknown constructor name \"" + constructor + "\"",
aExcMsg = moduleUri; css::uno::Reference<css::uno::XInterface>());
aExcMsg += ": cannot get symbol: ";
aExcMsg += aGetFactoryName;
} }
#else
if (! xRet.is()) osl::Module mod(uri, SAL_LOADMODULE_LAZY | SAL_LOADMODULE_GLOBAL);
{ if (!mod.is()) {
#ifndef DISABLE_DYNLOADING throw css::loader::CannotActivateFactoryException(
osl_unloadModule( lib ); "loading component library <" + uri + "> failed",
css::uno::Reference<css::uno::XInterface>());
}
if (constructor.isEmpty()) {
rtl::OUString sym;
if (prefix == "direct") {
sym = implementation.replace('.', '_') + "_" + COMPONENT_GETFACTORY;
} else if (!prefix.isEmpty()) {
sym = prefix + "_" + COMPONENT_GETFACTORY;
} else {
sym = COMPONENT_GETFACTORY;
}
oslGenericFunction fp = mod.getFunctionSymbol(sym);
if (fp == 0) {
throw css::loader::CannotActivateFactoryException(
("no factory symbol \"" + sym + "\" in component library <"
+ uri + ">"),
css::uno::Reference<css::uno::XInterface>());
}
css::uno::Environment curEnv(css::uno::Environment::getCurrent());
*factory = invokeComponentFactory(
curEnv,
(environment.isEmpty()
? getEnvironmentFromModule(mod, curEnv, implementation, prefix)
: getEnvironment(environment, implementation)),
reinterpret_cast<component_getFactoryFunc>(fp), uri, implementation,
serviceManager);
} else {
oslGenericFunction fp = mod.getFunctionSymbol(constructor);
if (fp == 0) {
throw css::loader::CannotActivateFactoryException(
("no constructor symbol \"" + constructor
+ "\" in component library <" + uri + ">"),
css::uno::Reference<css::uno::XInterface>());
}
*constructorFunction = reinterpret_cast<ImplementationConstructorFn *>(
fp);
}
mod.release();
#endif #endif
SAL_WARN("cppuhelper", "### cannot activate factory: " << aExcMsg);
throw loader::CannotActivateFactoryException(
aExcMsg,
Reference< XInterface >() );
}
return xRet;
} }
} } #if !defined DISABLE_DYNLOADING
#ifndef DISABLE_DYNLOADING css::uno::Reference<css::uno::XInterface> cppu::loadSharedLibComponentFactory(
rtl::OUString const & uri, rtl::OUString const & rPath,
//============================================================================== rtl::OUString const & rImplName,
extern "C" { static void s_writeInfo(va_list * pParam) css::uno::Reference<css::lang::XMultiServiceFactory> const & xMgr,
css::uno::Reference<css::registry::XRegistryKey> const & xKey)
SAL_THROW((css::loader::CannotActivateFactoryException))
{ {
component_writeInfoFunc pSym = va_arg(*pParam, component_writeInfoFunc); assert(rPath.isEmpty()); (void) rPath;
void * pSMgr = va_arg(*pParam, void *); assert(!xKey.is()); (void) xKey;
void * pKey = va_arg(*pParam, void *); css::uno::Reference<css::uno::XInterface> fac;
sal_Bool * pbRet = va_arg(*pParam, sal_Bool *); cppuhelper::detail::loadSharedLibComponentFactory(
uri, "", "", rImplName, "", xMgr, 0, &fac);
return fac;
}
*pbRet = pSym(pSMgr, pKey); namespace {
}} extern "C" void writeInfo(va_list * args) {
component_writeInfoFunc fn = va_arg(*args, component_writeInfoFunc);
void * smgr = va_arg(*args, void *);
void * key = va_arg(*args, void *);
sal_Bool * ok = va_arg(*args, sal_Bool *);
*ok = (*fn)(smgr, key);
}
namespace cppu { }
void SAL_CALL writeSharedLibComponentInfo( void cppu::writeSharedLibComponentInfo(
OUString const & uri, OUString const & rPath, rtl::OUString const & uri, rtl::OUString const & rPath,
Reference< lang::XMultiServiceFactory > const & xMgr, css::uno::Reference<css::lang::XMultiServiceFactory> const & xMgr,
Reference< registry::XRegistryKey > const & xKey ) css::uno::Reference<css::registry::XRegistryKey> const & xKey)
SAL_THROW( (registry::CannotRegisterImplementationException) ) SAL_THROW((css::registry::CannotRegisterImplementationException))
{ {
(void) rPath; assert(rPath.isEmpty()); (void) rPath;
assert(rPath.isEmpty()); osl::Module mod(uri, SAL_LOADMODULE_LAZY | SAL_LOADMODULE_GLOBAL);
oslModule lib = osl_loadModule( if (!mod.is()) {
uri.pData, SAL_LOADMODULE_LAZY | SAL_LOADMODULE_GLOBAL ); throw css::registry::CannotRegisterImplementationException(
if (! lib) "loading component library <" + uri + "> failed",
{ css::uno::Reference<css::uno::XInterface>());
OUString const msg("loading component library failed: " + uri);
SAL_WARN("cppuhelper", msg);
throw registry::CannotRegisterImplementationException(msg,
Reference< XInterface >() );
} }
oslGenericFunction fp = mod.getFunctionSymbol(COMPONENT_WRITEINFO);
sal_Bool bRet = sal_False; if (fp == 0) {
throw css::registry::CannotRegisterImplementationException(
uno::Environment currentEnv(Environment::getCurrent()); ("no symbol \"" COMPONENT_WRITEINFO "\" in component library <"
uno::Environment env; + uri + ">"),
css::uno::Reference<css::uno::XInterface>());
OUString aExcMsg;
getLibEnv(lib, &env, currentEnv);
OUString aWriteInfoName = COMPONENT_WRITEINFO;
oslGenericFunction pSym = osl_getFunctionSymbol( lib, aWriteInfoName.pData );
if (pSym != 0)
{
if (env.is() && currentEnv.is())
{
Mapping aCurrent2Env( currentEnv, env );
if (aCurrent2Env.is())
{
void * pSMgr = aCurrent2Env.mapInterface(
xMgr.get(), ::getCppuType( &xMgr ) );
void * pKey = aCurrent2Env.mapInterface(
xKey.get(), ::getCppuType( &xKey ) );
if (pKey)
{
env.invoke(s_writeInfo, pSym, pSMgr, pKey, &bRet);
(*env.get()->pExtEnv->releaseInterface)(
env.get()->pExtEnv, pKey );
if (! bRet)
{
aExcMsg = uri;
aExcMsg += ": component_writeInfo() "
"returned false!";
} }
css::uno::Environment curEnv(css::uno::Environment::getCurrent());
css::uno::Environment env(getEnvironmentFromModule(mod, curEnv, "", ""));
if (!(curEnv.is() && env.is())) {
throw css::registry::CannotRegisterImplementationException(
"cannot get environments",
css::uno::Reference<css::uno::XInterface>());
} }
else css::uno::Mapping map(curEnv, env);
{ if (!map.is()) {
// key is mandatory throw css::registry::CannotRegisterImplementationException(
aExcMsg = uri; "cannot get mapping", css::uno::Reference<css::uno::XInterface>());
aExcMsg += ": registry is mandatory to invoke"
" component_writeInfo()!";
} }
void * smgr = map.mapInterface(
if (pSMgr) xMgr.get(), cppu::UnoType<css::lang::XMultiServiceFactory>::get());
{ void * key = map.mapInterface(
(*env.get()->pExtEnv->releaseInterface)( xKey.get(), cppu::UnoType<css::registry::XRegistryKey>::get());
env.get()->pExtEnv, pSMgr ); sal_Bool ok;
env.invoke(writeInfo, fp, smgr, key, &ok);
(*env.get()->pExtEnv->releaseInterface)(env.get()->pExtEnv, key);
if (smgr != 0) {
(*env.get()->pExtEnv->releaseInterface)(env.get()->pExtEnv, smgr);
} }
} if (!ok) {
else throw css::registry::CannotRegisterImplementationException(
{ ("calling \"" COMPONENT_WRITEINFO "\" in component library <" + uri
aExcMsg = "cannot get uno mapping: C++ <=> UNO!"; + "> returned false"),
} css::uno::Reference<css::uno::XInterface>());
}
else
{
aExcMsg = "cannot get uno environments!";
}
}
else
{
aExcMsg = uri;
aExcMsg += ": cannot get symbol: ";
aExcMsg += aWriteInfoName;
}
//!
//! OK: please look at #88219#
//!
//! ::osl_unloadModule( lib);
if (! bRet)
{
SAL_WARN("cppuhelper", "### cannot write component info: " << aExcMsg);
throw registry::CannotRegisterImplementationException(
aExcMsg, Reference< XInterface >() );
} }
} }
} #endif
#endif // DISABLE_DYNLOADING
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@ -29,16 +29,21 @@ extern "C" {
typedef struct { typedef struct {
const char *name; const char *name;
void * (*component_getFactory_function)(const char *, void *, void *); void * (*component_getFactory_function)(const char *, void *, void *);
} lib_to_component_mapping; } lib_to_factory_mapping;
const lib_to_component_mapping *lo_get_library_map(void); typedef struct {
const lib_to_component_mapping *lo_get_implementation_map(void); const char *name;
void * (*constructor_function)(void *, void *);
} lib_to_constructor_mapping;
const lib_to_factory_mapping *lo_get_factory_map(void);
const lib_to_constructor_mapping *lo_get_constructor_map(void);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#define NON_APP_SPECIFIC_COMPONENT_MAP \ #define NON_APP_SPECIFIC_FACTORY_MAP \
{ "libintrospectionlo.a", introspection_component_getFactory }, \ { "libintrospectionlo.a", introspection_component_getFactory }, \
{ "libreflectionlo.a", reflection_component_getFactory }, \ { "libreflectionlo.a", reflection_component_getFactory }, \
{ "libstocserviceslo.a", stocservices_component_getFactory }, \ { "libstocserviceslo.a", stocservices_component_getFactory }, \
@ -60,19 +65,19 @@ const lib_to_component_mapping *lo_get_implementation_map(void);
{ "libvcllo.a", vcl_component_getFactory }, \ { "libvcllo.a", vcl_component_getFactory }, \
{ "libxstor.a", xstor_component_getFactory }, \ { "libxstor.a", xstor_component_getFactory }, \
#define NON_APP_SPECIFIC_DIRECT_COMPONENT_MAP \ #define NON_APP_SPECIFIC_CONSTRUCTOR_MAP \
{ "com.sun.star.comp.extensions.xml.sax.ParserExpat", com_sun_star_comp_extensions_xml_sax_ParserExpat_component_getFactory }, \ { "com_sun_star_comp_extensions_xml_sax_ParserExpat", com_sun_star_comp_extensions_xml_sax_ParserExpat }, \
{ "com.sun.star.comp.extensions.xml.sax.FastParser", com_sun_star_comp_extensions_xml_sax_FastParser_component_getFactory }, \ { "com_sun_star_comp_extensions_xml_sax_FastParser", com_sun_star_comp_extensions_xml_sax_FastParser }, \
{ "com.sun.star.comp.stoc.DLLComponentLoader.component.getFactory", com_sun_star_comp_stoc_DLLComponentLoader_component_getFactory }, \ { "com_sun_star_comp_stoc_DLLComponentLoader", com_sun_star_comp_stoc_DLLComponentLoader }, \
{ "com.sun.star.comp.stoc.ImplementationRegistration.component.getFactory", com_sun_star_comp_stoc_ImplementationRegistration_component_getFactory }, \ { "com_sun_star_comp_stoc_ImplementationRegistration", com_sun_star_comp_stoc_ImplementationRegistration }, \
{ "com.sun.star.comp.stoc.NestedRegistry.component.getFactory", com_sun_star_comp_stoc_NestedRegistry_component_getFactory }, \ { "com_sun_star_comp_stoc_NestedRegistry", com_sun_star_comp_stoc_NestedRegistry }, \
{ "com.sun.star.comp.stoc.ORegistryServiceManager.component.getFactory", com_sun_star_comp_stoc_ORegistryServiceManager_component_getFactory }, \ { "com_sun_star_comp_stoc_ORegistryServiceManager", com_sun_star_comp_stoc_ORegistryServiceManager }, \
{ "com.sun.star.comp.stoc.OServiceManager.component.getFactory", com_sun_star_comp_stoc_OServiceManager_component_getFactory }, \ { "com_sun_star_comp_stoc_OServiceManager", com_sun_star_comp_stoc_OServiceManager }, \
{ "com.sun.star.comp.stoc.OServiceManagerWrapper.component.getFactory", com_sun_star_comp_stoc_OServiceManagerWrapper_component_getFactory }, \ { "com_sun_star_comp_stoc_OServiceManagerWrapper", com_sun_star_comp_stoc_OServiceManagerWrapper }, \
{ "com.sun.star.comp.stoc.SimpleRegistry.component.getFactory", com_sun_star_comp_stoc_SimpleRegistry_component_getFactory }, \ { "com_sun_star_comp_stoc_SimpleRegistry", com_sun_star_comp_stoc_SimpleRegistry }, \
{ "com.sun.star.extensions.xml.sax.Writer", com_sun_star_extensions_xml_sax_Writer_component_getFactory }, \ { "com_sun_star_extensions_xml_sax_Writer", com_sun_star_extensions_xml_sax_Writer }, \
{ "com.sun.star.security.comp.stoc.AccessController.component.getFactory", com_sun_star_security_comp_stoc_AccessController_component_getFactory }, \ { "com_sun_star_security_comp_stoc_AccessController", com_sun_star_security_comp_stoc_AccessController }, \
{ "com.sun.star.security.comp.stoc.FilePolicy.component.getFactory", com_sun_star_security_comp_stoc_FilePolicy_component_getFactory }, \ { "com_sun_star_security_comp_stoc_FilePolicy", com_sun_star_security_comp_stoc_FilePolicy }, \
#endif /* DISABLE_DYNLOADING */ #endif /* DISABLE_DYNLOADING */

View File

@ -17,11 +17,11 @@
#include <touch/touch.h> #include <touch/touch.h>
extern "C" extern "C"
const lib_to_component_mapping * const lib_to_factory_mapping *
lo_get_library_map(void) lo_get_factory_map(void)
{ {
static lib_to_component_mapping map[] = { static lib_to_factory_mapping map[] = {
NON_APP_SPECIFIC_COMPONENT_MAP NON_APP_SPECIFIC_FACTORY_MAP
{ "libanalysislo.a", analysis_component_getFactory }, { "libanalysislo.a", analysis_component_getFactory },
{ "libanimcorelo.a", animcore_component_getFactory }, { "libanimcorelo.a", animcore_component_getFactory },
{ "libavmedialo.a", avmedia_component_getFactory }, { "libavmedialo.a", avmedia_component_getFactory },
@ -82,11 +82,11 @@ lo_get_library_map(void)
} }
extern "C" extern "C"
const lib_to_component_mapping * const lib_to_constructor_mapping *
lo_get_implementation_map(void) lo_get_constructor_map(void)
{ {
static lib_to_component_mapping map[] = { static lib_to_constructor_mapping map[] = {
NON_APP_SPECIFIC_DIRECT_COMPONENT_MAP NON_APP_SPECIFIC_CONSTRUCTOR_MAP
{ NULL, NULL } { NULL, NULL }
}; };

View File

@ -17,11 +17,11 @@
#include <touch/touch.h> #include <touch/touch.h>
extern "C" extern "C"
const lib_to_component_mapping * const lib_to_factory_mapping *
lo_get_library_map(void) lo_get_libmap(void)
{ {
static lib_to_component_mapping map[] = { static lib_to_factory_mapping map[] = {
NON_APP_SPECIFIC_COMPONENT_MAP NON_APP_SPECIFIC_FACTORY_MAP
{ "libanalysislo.a", analysis_component_getFactory }, { "libanalysislo.a", analysis_component_getFactory },
{ "libanimcorelo.a", animcore_component_getFactory }, { "libanimcorelo.a", animcore_component_getFactory },
{ "libavmedialo.a", avmedia_component_getFactory }, { "libavmedialo.a", avmedia_component_getFactory },
@ -82,11 +82,11 @@ lo_get_library_map(void)
} }
extern "C" extern "C"
const lib_to_component_mapping * const lib_to_constructor_mapping *
lo_get_implementation_map(void) lo_get_constructor_map(void)
{ {
static lib_to_component_mapping map[] = { static lib_to_constructor_mapping map[] = {
NON_APP_SPECIFIC_DIRECT_COMPONENT_MAP NON_APP_SPECIFIC_CONSTRUCTOR_MAP
{ NULL, NULL } { NULL, NULL }
}; };

View File

@ -29,10 +29,10 @@ extern void * sc_component_getFactory( const char * pImplName, void * pServiceMa
extern void * scfilt_component_getFactory( const char * pImplName, void * pServiceManager, void * pRegistryKey ); extern void * scfilt_component_getFactory( const char * pImplName, void * pServiceManager, void * pRegistryKey );
extern void * unoxml_component_getFactory( const char * pImplName, void * pServiceManager, void * pRegistryKey ); extern void * unoxml_component_getFactory( const char * pImplName, void * pServiceManager, void * pRegistryKey );
const lib_to_component_mapping * const lib_to_factory_mapping *
lo_get_libmap(void) lo_get_libmap(void)
{ {
static lib_to_component_mapping map[] = { static lib_to_factory_mapping map[] = {
{ "libanalysislo.a", analysis_component_getFactory }, { "libanalysislo.a", analysis_component_getFactory },
{ "libdatelo.a", date_component_getFactory }, { "libdatelo.a", date_component_getFactory },
{ "libscfiltlo.a", scfilt_component_getFactory }, { "libscfiltlo.a", scfilt_component_getFactory },

View File

@ -23,11 +23,11 @@
#define MAP_LIB_LO_1(LIB) { "lib" #LIB "lo.a", LIB##1_component_getFactory } #define MAP_LIB_LO_1(LIB) { "lib" #LIB "lo.a", LIB##1_component_getFactory }
extern "C" extern "C"
const lib_to_component_mapping * const lib_to_factory_mapping *
lo_get_library_map(void) lo_get_factory_map(void)
{ {
static lib_to_component_mapping map[] = { static lib_to_factory_mapping map[] = {
NON_APP_SPECIFIC_COMPONENT_MAP NON_APP_SPECIFIC_FACTORY_MAP
//from IOS //from IOS
@ -74,11 +74,11 @@ lo_get_library_map(void)
} }
extern "C" extern "C"
const lib_to_component_mapping * const lib_to_constructor_mapping *
lo_get_implementation_map(void) lo_get_constructor_map(void)
{ {
static lib_to_component_mapping map[] = { static lib_to_constructor_mapping map[] = {
NON_APP_SPECIFIC_DIRECT_COMPONENT_MAP NON_APP_SPECIFIC_CONSTRUCTOR_MAP
{ NULL, NULL } { NULL, NULL }
}; };

View File

@ -18,14 +18,17 @@
--> -->
<component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@" <component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@"
prefix="direct" xmlns="http://openoffice.org/2010/uno-components"> xmlns="http://openoffice.org/2010/uno-components">
<implementation name="com.sun.star.comp.extensions.xml.sax.ParserExpat"> <implementation name="com.sun.star.comp.extensions.xml.sax.ParserExpat"
constructor="com_sun_star_comp_extensions_xml_sax_ParserExpat">
<service name="com.sun.star.xml.sax.Parser"/> <service name="com.sun.star.xml.sax.Parser"/>
</implementation> </implementation>
<implementation name="com.sun.star.extensions.xml.sax.Writer"> <implementation name="com.sun.star.extensions.xml.sax.Writer"
constructor="com_sun_star_extensions_xml_sax_Writer">
<service name="com.sun.star.xml.sax.Writer"/> <service name="com.sun.star.xml.sax.Writer"/>
</implementation> </implementation>
<implementation name="com.sun.star.comp.extensions.xml.sax.FastParser"> <implementation name="com.sun.star.comp.extensions.xml.sax.FastParser"
constructor="com_sun_star_comp_extensions_xml_sax_FastParser">
<service name="com.sun.star.xml.sax.FastParser"/> <service name="com.sun.star.xml.sax.FastParser"/>
</implementation> </implementation>
</component> </component>

View File

@ -19,6 +19,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <sal/alloca.h> #include <sal/alloca.h>
#include <cassert>
#include <vector> #include <vector>
#include <osl/diagnose.h> #include <osl/diagnose.h>
@ -30,7 +31,6 @@
#include <com/sun/star/xml/sax/SAXParseException.hpp> #include <com/sun/star/xml/sax/SAXParseException.hpp>
#include <com/sun/star/io/XSeekable.hpp> #include <com/sun/star/io/XSeekable.hpp>
#include <cppuhelper/factory.hxx>
#include <cppuhelper/weak.hxx> #include <cppuhelper/weak.hxx>
#include <cppuhelper/implbase3.hxx> #include <cppuhelper/implbase3.hxx>
#include <cppuhelper/supportsservice.hxx> #include <cppuhelper/supportsservice.hxx>
@ -42,13 +42,16 @@ using namespace ::osl;
using namespace ::cppu; using namespace ::cppu;
using namespace ::com::sun::star::uno; using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::lang; using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::registry;
using namespace ::com::sun::star::xml::sax; using namespace ::com::sun::star::xml::sax;
using namespace ::com::sun::star::io; using namespace ::com::sun::star::io;
#include "attrlistimpl.hxx" #include "attrlistimpl.hxx"
#include "xml2utf.hxx" #include "xml2utf.hxx"
namespace com { namespace sun { namespace star { namespace uno {
class XComponentContext;
} } } }
namespace { namespace {
// Useful macros for correct String conversion depending on the choosen expat-mode // Useful macros for correct String conversion depending on the choosen expat-mode
@ -129,17 +132,6 @@ OUString XmlChar2OUString( const XML_Char *p )
class SaxExpatParser_Impl; class SaxExpatParser_Impl;
OUString SaxExpatParser_getImplementationName() {
return OUString("com.sun.star.comp.extensions.xml.sax.ParserExpat");
}
Sequence< OUString > SaxExpatParser_getSupportedServiceNames(void)
{
Sequence<OUString> seq(1);
seq[0] = OUString("com.sun.star.xml.sax.Parser");
return seq;
}
// This class implements the external Parser interface // This class implements the external Parser interface
class SaxExpatParser class SaxExpatParser
: public WeakImplHelper3< XInitialization : public WeakImplHelper3< XInitialization
@ -598,7 +590,7 @@ void SaxExpatParser::setLocale( const Locale & locale ) throw (RuntimeException)
// XServiceInfo // XServiceInfo
OUString SaxExpatParser::getImplementationName() throw () OUString SaxExpatParser::getImplementationName() throw ()
{ {
return SaxExpatParser_getImplementationName(); return OUString("com.sun.star.comp.extensions.xml.sax.ParserExpat");
} }
// XServiceInfo // XServiceInfo
@ -610,7 +602,9 @@ sal_Bool SaxExpatParser::supportsService(const OUString& ServiceName) throw ()
// XServiceInfo // XServiceInfo
Sequence< OUString > SaxExpatParser::getSupportedServiceNames(void) throw () Sequence< OUString > SaxExpatParser::getSupportedServiceNames(void) throw ()
{ {
return SaxExpatParser_getSupportedServiceNames(); Sequence<OUString> seq(1);
seq[0] = "com.sun.star.xml.sax.Parser";
return seq;
} }
@ -1023,27 +1017,18 @@ void SaxExpatParser_Impl::callbackEndCDATA( void *pvThis )
CALL_ELEMENT_HANDLER_AND_CARE_FOR_EXCEPTIONS(pImpl,rExtendedDocumentHandler->endCDATA() ); CALL_ELEMENT_HANDLER_AND_CARE_FOR_EXCEPTIONS(pImpl,rExtendedDocumentHandler->endCDATA() );
} }
Reference< XInterface > SAL_CALL SaxExpatParser_CreateInstance(
SAL_UNUSED_PARAMETER const Reference<css::uno::XComponentContext> & )
SAL_THROW((css::uno::Exception))
{
SaxExpatParser *p = new SaxExpatParser;
return Reference< XInterface > ( (OWeakObject * ) p );
}
} // namespace } // namespace
extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
com_sun_star_comp_extensions_xml_sax_ParserExpat_component_getFactory( com_sun_star_comp_extensions_xml_sax_ParserExpat(
const char *, void *, void * ) SAL_UNUSED_PARAMETER css::uno::XComponentContext *,
uno_Sequence * arguments)
{ {
Reference<css::lang::XSingleComponentFactory> xFactory( assert(arguments != 0 && arguments->nElements == 0); (void) arguments;
cppu::createSingleComponentFactory( css::uno::Reference<css::uno::XInterface> x(
&SaxExpatParser_CreateInstance, static_cast<cppu::OWeakObject *>(new SaxExpatParser));
SaxExpatParser_getImplementationName(), x->acquire();
SaxExpatParser_getSupportedServiceNames())); return x.get();
xFactory->acquire();
return xFactory.get();
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@ -19,8 +19,9 @@
#include <string.h> #include <string.h>
#include <stack> #include <cassert>
#include <set> #include <set>
#include <stack>
#include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/util/XCloneable.hpp> #include <com/sun/star/util/XCloneable.hpp>
@ -31,7 +32,6 @@
#include <com/sun/star/io/XActiveDataSource.hpp> #include <com/sun/star/io/XActiveDataSource.hpp>
#include <cppuhelper/factory.hxx>
#include <cppuhelper/weak.hxx> #include <cppuhelper/weak.hxx>
#include <cppuhelper/implbase2.hxx> #include <cppuhelper/implbase2.hxx>
#include <cppuhelper/supportsservice.hxx> #include <cppuhelper/supportsservice.hxx>
@ -46,13 +46,16 @@ using namespace ::osl;
using namespace ::cppu; using namespace ::cppu;
using namespace ::com::sun::star::uno; using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::lang; using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::registry;
using namespace ::com::sun::star::xml::sax; using namespace ::com::sun::star::xml::sax;
using namespace ::com::sun::star::util; using namespace ::com::sun::star::util;
using namespace ::com::sun::star::io; using namespace ::com::sun::star::io;
#include "xml2utf.hxx" #include "xml2utf.hxx"
namespace com { namespace sun { namespace star { namespace uno {
class XComponentContext;
} } } }
#define LINEFEED 10 #define LINEFEED 10
#define SEQUENCESIZE 1024 #define SEQUENCESIZE 1024
#define MAXCOLUMNCOUNT 72 #define MAXCOLUMNCOUNT 72
@ -867,17 +870,6 @@ static inline sal_Int32 getFirstLineBreak( const OUString & str ) throw ()
return -1; return -1;
} }
OUString SAXWriter_getImplementationName() {
return OUString("com.sun.star.extensions.xml.sax.Writer");
}
Sequence< OUString > SAXWriter_getSupportedServiceNames(void) throw ()
{
Sequence<OUString> seq(1);
seq.getArray()[0] = OUString("com.sun.star.xml.sax.Writer");
return seq;
}
class SAXWriter : class SAXWriter :
public WeakImplHelper2< public WeakImplHelper2<
XWriter, XWriter,
@ -998,7 +990,7 @@ static inline sal_Bool isFirstCharWhitespace( const sal_Unicode *p ) throw()
// XServiceInfo // XServiceInfo
OUString SAXWriter::getImplementationName() throw() OUString SAXWriter::getImplementationName() throw()
{ {
return SAXWriter_getImplementationName(); return OUString("com.sun.star.extensions.xml.sax.Writer");
} }
// XServiceInfo // XServiceInfo
@ -1010,7 +1002,9 @@ sal_Bool SAXWriter::supportsService(const OUString& ServiceName) throw()
// XServiceInfo // XServiceInfo
Sequence< OUString > SAXWriter::getSupportedServiceNames(void) throw () Sequence< OUString > SAXWriter::getSupportedServiceNames(void) throw ()
{ {
return SAXWriter_getSupportedServiceNames(); Sequence<OUString> seq(1);
seq[0] = "com.sun.star.xml.sax.Writer";
return seq;
} }
void SAXWriter::startDocument() throw(SAXException, RuntimeException ) void SAXWriter::startDocument() throw(SAXException, RuntimeException )
@ -1376,26 +1370,18 @@ void SAXWriter::unknown(const OUString& sString) throw (SAXException, RuntimeExc
} }
} }
Reference < XInterface > SAL_CALL SAXWriter_CreateInstance(
SAL_UNUSED_PARAMETER const Reference<css::uno::XComponentContext> & )
SAL_THROW((css::uno::Exception))
{
SAXWriter *p = new SAXWriter;
return Reference< XInterface > ( (static_cast< OWeakObject * >(p)) );
}
} // namespace } // namespace
extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
com_sun_star_extensions_xml_sax_Writer_component_getFactory( com_sun_star_extensions_xml_sax_Writer(
const char *, void *, void * ) SAL_UNUSED_PARAMETER css::uno::XComponentContext *,
uno_Sequence * arguments)
{ {
Reference<css::lang::XSingleComponentFactory > xFactory( assert(arguments != 0 && arguments->nElements == 0); (void) arguments;
cppu::createSingleComponentFactory( css::uno::Reference<css::uno::XInterface> x(
&SAXWriter_CreateInstance, SAXWriter_getImplementationName(), static_cast<cppu::OWeakObject *>(new SAXWriter));
SAXWriter_getSupportedServiceNames())); x->acquire();
xFactory->acquire(); return x.get();
return xFactory.get();
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@ -27,7 +27,6 @@
#include <com/sun/star/xml/sax/XFastContextHandler.hpp> #include <com/sun/star/xml/sax/XFastContextHandler.hpp>
#include <com/sun/star/xml/sax/XFastDocumentHandler.hpp> #include <com/sun/star/xml/sax/XFastDocumentHandler.hpp>
#include <com/sun/star/xml/sax/XFastTokenHandler.hpp> #include <com/sun/star/xml/sax/XFastTokenHandler.hpp>
#include <cppuhelper/factory.hxx>
#include <cppuhelper/supportsservice.hxx> #include <cppuhelper/supportsservice.hxx>
#include <osl/conditn.hxx> #include <osl/conditn.hxx>
#include <osl/diagnose.h> #include <osl/diagnose.h>
@ -42,9 +41,14 @@
#include <stack> #include <stack>
#include <vector> #include <vector>
#include <queue> #include <queue>
#include <cassert>
#include <cstring> #include <cstring>
#include <expat.h> #include <expat.h>
namespace com { namespace sun { namespace star { namespace uno {
class XComponentContext;
} } } }
using namespace ::std; using namespace ::std;
using namespace ::osl; using namespace ::osl;
using namespace ::cppu; using namespace ::cppu;
@ -57,17 +61,6 @@ using namespace sax_fastparser;
namespace { namespace {
OUString FastSaxParser_getImplementationName() {
return OUString("com.sun.star.comp.extensions.xml.sax.FastParser");
}
uno::Sequence<OUString> FastSaxParser_getSupportedServiceNames()
{
Sequence<OUString> seq(1);
seq.getArray()[0] = OUString("com.sun.star.xml.sax.FastParser");
return seq;
}
struct Event; struct Event;
class FastLocatorImpl; class FastLocatorImpl;
struct NamespaceDefine; struct NamespaceDefine;
@ -1404,7 +1397,7 @@ void FastSaxParser::setLocale( const lang::Locale& rLocale )
OUString FastSaxParser::getImplementationName() OUString FastSaxParser::getImplementationName()
throw (uno::RuntimeException) throw (uno::RuntimeException)
{ {
return FastSaxParser_getImplementationName(); return OUString("com.sun.star.comp.extensions.xml.sax.FastParser");
} }
sal_Bool FastSaxParser::supportsService( const OUString& ServiceName ) sal_Bool FastSaxParser::supportsService( const OUString& ServiceName )
@ -1416,7 +1409,9 @@ sal_Bool FastSaxParser::supportsService( const OUString& ServiceName )
uno::Sequence<OUString> FastSaxParser::getSupportedServiceNames() uno::Sequence<OUString> FastSaxParser::getSupportedServiceNames()
throw (uno::RuntimeException) throw (uno::RuntimeException)
{ {
return FastSaxParser_getSupportedServiceNames(); Sequence<OUString> seq(1);
seq[0] = OUString("com.sun.star.xml.sax.FastParser");
return seq;
} }
bool FastSaxParser::hasNamespaceURL( const OUString& rPrefix ) const bool FastSaxParser::hasNamespaceURL( const OUString& rPrefix ) const
@ -1426,25 +1421,16 @@ bool FastSaxParser::hasNamespaceURL( const OUString& rPrefix ) const
} // namespace sax_fastparser } // namespace sax_fastparser
static Reference< XInterface > SAL_CALL FastSaxParser_CreateInstance( extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
SAL_UNUSED_PARAMETER const Reference<css::uno::XComponentContext> & ) com_sun_star_comp_extensions_xml_sax_FastParser(
SAL_THROW((css::uno::Exception)) SAL_UNUSED_PARAMETER css::uno::XComponentContext *,
uno_Sequence * arguments)
{ {
FastSaxParser *p = new FastSaxParser; assert(arguments != 0 && arguments->nElements == 0); (void) arguments;
return Reference< XInterface > ( (OWeakObject * ) p ); css::uno::Reference<css::uno::XInterface> x(
} static_cast<cppu::OWeakObject *>(new FastSaxParser));
x->acquire();
extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL return x.get();
com_sun_star_comp_extensions_xml_sax_FastParser_component_getFactory(
const char *, void *, void * )
{
Reference<css::lang::XSingleComponentFactory> xFactory(
cppu::createSingleComponentFactory(
&FastSaxParser_CreateInstance,
FastSaxParser_getImplementationName(),
FastSaxParser_getSupportedServiceNames()));
xFactory->acquire();
return xFactory.get();
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@ -21,7 +21,6 @@
#include <osl/diagnose.h> #include <osl/diagnose.h>
#include <cppuhelper/queryinterface.hxx> #include <cppuhelper/queryinterface.hxx>
#include <cppuhelper/weak.hxx> #include <cppuhelper/weak.hxx>
#include <cppuhelper/factory.hxx>
#include <cppuhelper/implbase1.hxx> #include <cppuhelper/implbase1.hxx>
#include <cppuhelper/implbase4.hxx> #include <cppuhelper/implbase4.hxx>
#include <cppuhelper/implbase3.hxx> #include <cppuhelper/implbase3.hxx>
@ -44,13 +43,6 @@ using namespace com::sun::star::container;
using namespace cppu; using namespace cppu;
using namespace osl; using namespace osl;
static Sequence< OUString > NestedRegistryImpl_getSupportedServiceNames()
{
Sequence< OUString > seqNames(1);
seqNames.getArray()[0] = OUString("com.sun.star.registry.NestedRegistry");
return seqNames;
}
namespace { namespace {
class NestedKeyImpl; class NestedKeyImpl;
@ -1207,7 +1199,9 @@ sal_Bool SAL_CALL NestedRegistryImpl::supportsService( const OUString& ServiceNa
Sequence<OUString> SAL_CALL NestedRegistryImpl::getSupportedServiceNames( ) Sequence<OUString> SAL_CALL NestedRegistryImpl::getSupportedServiceNames( )
throw(RuntimeException) throw(RuntimeException)
{ {
return NestedRegistryImpl_getSupportedServiceNames(); Sequence< OUString > seqNames(1);
seqNames[0] = "com.sun.star.registry.NestedRegistry";
return seqNames;
} }
//************************************************************************* //*************************************************************************
@ -1355,32 +1349,16 @@ void SAL_CALL NestedRegistryImpl::mergeKey( const OUString& aKeyName, const OUSt
} // namespace } // namespace
static Reference<XInterface> NestedRegistry_CreateInstance( extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
SAL_UNUSED_PARAMETER const Reference<XComponentContext>& ) com_sun_star_comp_stoc_NestedRegistry(
throw(Exception) SAL_UNUSED_PARAMETER css::uno::XComponentContext *,
uno_Sequence * arguments)
{ {
Reference<XInterface> xRet; assert(arguments != 0 && arguments->nElements == 0); (void) arguments;
XSimpleRegistry *pRegistry = (XSimpleRegistry*) new NestedRegistryImpl; css::uno::Reference<css::uno::XInterface> x(
static_cast<cppu::OWeakObject *>(new NestedRegistryImpl));
if (pRegistry) x->acquire();
{ return x.get();
xRet = Reference<XInterface>::query(pRegistry);
}
return xRet;
}
extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL
com_sun_star_comp_stoc_NestedRegistry_component_getFactory(
const char * , void * , void * )
{
Reference< XSingleComponentFactory > xFactory;
xFactory = createSingleComponentFactory(
NestedRegistry_CreateInstance,
"com.sun.star.comp.stoc.NestedRegistry",
NestedRegistryImpl_getSupportedServiceNames() );
xFactory->acquire();
return xFactory.get();
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@ -22,7 +22,6 @@
#include <list> #include <list>
#include <cppuhelper/queryinterface.hxx> #include <cppuhelper/queryinterface.hxx>
#include <cppuhelper/factory.hxx>
#include <cppuhelper/weak.hxx> #include <cppuhelper/weak.hxx>
#include <cppuhelper/implbase3.hxx> #include <cppuhelper/implbase3.hxx>
#include <cppuhelper/implementationentry.hxx> #include <cppuhelper/implementationentry.hxx>
@ -63,9 +62,6 @@ using namespace com::sun::star::registry;
using namespace cppu; using namespace cppu;
using namespace osl; using namespace osl;
#define IMPLNAME "com.sun.star.comp.stoc.ImplementationRegistration"
#define SERVICENAME "com.sun.star.registry.ImplementationRegistration"
namespace { namespace {
struct StringPool struct StringPool
@ -113,13 +109,6 @@ const StringPool &spool()
return *pPool; return *pPool;
} }
static Sequence< OUString > ImplementationRegistration_getSupportedServiceNames()
{
Sequence< OUString > seqNames(1);
seqNames.getArray()[0] = SERVICENAME;
return seqNames;
}
//************************************************************************* //*************************************************************************
// static deleteAllLinkReferences() // static deleteAllLinkReferences()
// //
@ -1309,7 +1298,7 @@ ImplementationRegistration::~ImplementationRegistration() {}
// XServiceInfo // XServiceInfo
OUString ImplementationRegistration::getImplementationName() throw(RuntimeException) OUString ImplementationRegistration::getImplementationName() throw(RuntimeException)
{ {
return OUString(IMPLNAME); return OUString("com.sun.star.comp.stoc.ImplementationRegistration");
} }
// XServiceInfo // XServiceInfo
@ -1321,7 +1310,9 @@ sal_Bool ImplementationRegistration::supportsService(const OUString& ServiceName
// XServiceInfo // XServiceInfo
Sequence< OUString > ImplementationRegistration::getSupportedServiceNames(void) throw(RuntimeException) Sequence< OUString > ImplementationRegistration::getSupportedServiceNames(void) throw(RuntimeException)
{ {
return ImplementationRegistration_getSupportedServiceNames(); Sequence< OUString > seqNames(1);
seqNames[0] = "com.sun.star.registry.ImplementationRegistration";
return seqNames;
} }
Reference< XSimpleRegistry > ImplementationRegistration::getRegistryFromServiceManager() Reference< XSimpleRegistry > ImplementationRegistration::getRegistryFromServiceManager()
@ -1825,23 +1816,16 @@ Reference< XSimpleRegistry > ImplementationRegistration::createTemporarySimpleRe
} }
static Reference<XInterface> ImplementationRegistration_CreateInstance( extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
const Reference<XComponentContext> & xCtx ) // throw(Exception) com_sun_star_comp_stoc_ImplementationRegistration(
css::uno::XComponentContext * context, uno_Sequence * arguments)
{ {
return (XImplementationRegistration *)new ImplementationRegistration(xCtx); assert(arguments != 0 && arguments->nElements == 0); (void) arguments;
} css::uno::Reference<css::uno::XInterface> x(
static_cast<cppu::OWeakObject *>(
extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL new ImplementationRegistration(context)));
com_sun_star_comp_stoc_ImplementationRegistration_component_getFactory( x->acquire();
const char * , void * , void * ) return x.get();
{
Reference< css::lang::XSingleComponentFactory > xFactory;
xFactory = createSingleComponentFactory(
ImplementationRegistration_CreateInstance,
IMPLNAME,
ImplementationRegistration_getSupportedServiceNames() );
xFactory->acquire();
return xFactory.get();
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@ -29,7 +29,6 @@
#include <uno/mapping.hxx> #include <uno/mapping.hxx>
#include <cppuhelper/queryinterface.hxx> #include <cppuhelper/queryinterface.hxx>
#include <cppuhelper/weak.hxx> #include <cppuhelper/weak.hxx>
#include <cppuhelper/factory.hxx>
#include <cppuhelper/shlib.hxx> #include <cppuhelper/shlib.hxx>
#include <cppuhelper/implbase3.hxx> #include <cppuhelper/implbase3.hxx>
#include <cppuhelper/implementationentry.hxx> #include <cppuhelper/implementationentry.hxx>
@ -42,10 +41,6 @@
#include <com/sun/star/lang/XInitialization.hpp> #include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/registry/XRegistryKey.hpp> #include <com/sun/star/registry/XRegistryKey.hpp>
#define SERVICENAME "com.sun.star.loader.SharedLibrary"
#define IMPLNAME "com.sun.star.comp.stoc.DLLComponentLoader"
using namespace com::sun::star; using namespace com::sun::star;
using namespace com::sun::star::uno; using namespace com::sun::star::uno;
using namespace com::sun::star::loader; using namespace com::sun::star::loader;
@ -56,13 +51,6 @@ using namespace osl;
namespace { namespace {
static Sequence< OUString > DllComponentLoader_getSupportedServiceNames()
{
Sequence< OUString > seqNames(1);
seqNames.getArray()[0] = OUString(SERVICENAME);
return seqNames;
}
class DllComponentLoader class DllComponentLoader
: public WeakImplHelper3< XImplementationLoader, : public WeakImplHelper3< XImplementationLoader,
XInitialization, XInitialization,
@ -101,7 +89,7 @@ DllComponentLoader::~DllComponentLoader() {}
OUString SAL_CALL DllComponentLoader::getImplementationName( ) OUString SAL_CALL DllComponentLoader::getImplementationName( )
throw(::com::sun::star::uno::RuntimeException) throw(::com::sun::star::uno::RuntimeException)
{ {
return OUString(IMPLNAME); return OUString("com.sun.star.comp.stoc.DLLComponentLoader");
} }
sal_Bool SAL_CALL DllComponentLoader::supportsService( const OUString& ServiceName ) sal_Bool SAL_CALL DllComponentLoader::supportsService( const OUString& ServiceName )
@ -113,7 +101,9 @@ sal_Bool SAL_CALL DllComponentLoader::supportsService( const OUString& ServiceNa
Sequence<OUString> SAL_CALL DllComponentLoader::getSupportedServiceNames( ) Sequence<OUString> SAL_CALL DllComponentLoader::getSupportedServiceNames( )
throw(::com::sun::star::uno::RuntimeException) throw(::com::sun::star::uno::RuntimeException)
{ {
return DllComponentLoader_getSupportedServiceNames(); Sequence< OUString > seqNames(1);
seqNames[0] = "com.sun.star.loader.SharedLibrary";
return seqNames;
} }
//************************************************************************* //*************************************************************************
@ -174,32 +164,15 @@ sal_Bool SAL_CALL DllComponentLoader::writeRegistryInfo(
} }
static Reference<XInterface> DllComponentLoader_CreateInstance( extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
const Reference<XComponentContext> & xCtx ) throw(Exception) com_sun_star_comp_stoc_DLLComponentLoader(
css::uno::XComponentContext * context, uno_Sequence * arguments)
{ {
Reference<XInterface> xRet; assert(arguments != 0 && arguments->nElements == 0); (void) arguments;
css::uno::Reference<css::uno::XInterface> x(
XImplementationLoader *pXLoader = (XImplementationLoader *)new DllComponentLoader(xCtx); static_cast<cppu::OWeakObject *>(new DllComponentLoader(context)));
x->acquire();
if (pXLoader) return x.get();
{
xRet = Reference<XInterface>::query(pXLoader);
}
return xRet;
}
extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL
com_sun_star_comp_stoc_DLLComponentLoader_component_getFactory(
const char * , void * , void * )
{
Reference< css::lang::XSingleComponentFactory > xFactory;
xFactory = createSingleComponentFactory(
DllComponentLoader_CreateInstance,
IMPLNAME,
DllComponentLoader_getSupportedServiceNames() );
xFactory->acquire();
return xFactory.get();
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@ -34,7 +34,6 @@
#include <cppuhelper/implbase1.hxx> #include <cppuhelper/implbase1.hxx>
#include <cppuhelper/compbase3.hxx> #include <cppuhelper/compbase3.hxx>
#include <cppuhelper/factory.hxx>
#include <cppuhelper/implementationentry.hxx> #include <cppuhelper/implementationentry.hxx>
#include <cppuhelper/supportsservice.hxx> #include <cppuhelper/supportsservice.hxx>
@ -52,7 +51,6 @@
#define SERVICE_NAME "com.sun.star.security.AccessController" #define SERVICE_NAME "com.sun.star.security.AccessController"
#define IMPL_NAME "com.sun.star.security.comp.stoc.AccessController"
#define USER_CREDS "access-control.user-credentials" #define USER_CREDS "access-control.user-credentials"
@ -962,7 +960,7 @@ Reference< security::XAccessControlContext > AccessController::getContext()
OUString AccessController::getImplementationName() OUString AccessController::getImplementationName()
throw (RuntimeException) throw (RuntimeException)
{ {
return OUString(IMPL_NAME); return OUString("com.sun.star.security.comp.stoc.AccessController");
} }
//__________________________________________________________________________________________________ //__________________________________________________________________________________________________
sal_Bool AccessController::supportsService( OUString const & serviceName ) sal_Bool AccessController::supportsService( OUString const & serviceName )
@ -971,39 +969,25 @@ sal_Bool AccessController::supportsService( OUString const & serviceName )
return cppu::supportsService(this, serviceName); return cppu::supportsService(this, serviceName);
} }
//__________________________________________________________________________________________________ //__________________________________________________________________________________________________
static Sequence< OUString > AccessController_getSupportedServiceNames()
{
Sequence< OUString > aSNS( 1 );
aSNS.getArray()[0] = OUString(SERVICE_NAME);
return aSNS;
}
Sequence< OUString > AccessController::getSupportedServiceNames() Sequence< OUString > AccessController::getSupportedServiceNames()
throw (RuntimeException) throw (RuntimeException)
{ {
return AccessController_getSupportedServiceNames(); Sequence< OUString > aSNS( 1 );
aSNS[0] = OUString(SERVICE_NAME);
return aSNS;
} }
} }
static Reference< XInterface > SAL_CALL AccessController_create( extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
Reference< XComponentContext > const & xComponentContext ) com_sun_star_security_comp_stoc_AccessController(
SAL_THROW( (Exception) ) css::uno::XComponentContext * context, uno_Sequence * arguments)
{ {
return (OWeakObject *)new AccessController( xComponentContext ); assert(arguments != 0 && arguments->nElements == 0); (void) arguments;
} css::uno::Reference<css::uno::XInterface> x(
static_cast<cppu::OWeakObject *>(new AccessController(context)));
extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL x->acquire();
com_sun_star_security_comp_stoc_AccessController_component_getFactory( return x.get();
const char * , void * , void * )
{
Reference< css::lang::XSingleComponentFactory > xFactory;
xFactory = createSingleComponentFactory(
AccessController_create,
IMPL_NAME,
AccessController_getSupportedServiceNames() );
xFactory->acquire();
return xFactory.get();
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@ -39,7 +39,6 @@
#include <com/sun/star/io/FilePermission.hpp> #include <com/sun/star/io/FilePermission.hpp>
#include <com/sun/star/connection/SocketPermission.hpp> #include <com/sun/star/connection/SocketPermission.hpp>
#define SERVICE_NAME "com.sun.star.security.Policy"
#define IMPL_NAME "com.sun.star.security.comp.stoc.FilePolicy" #define IMPL_NAME "com.sun.star.security.comp.stoc.FilePolicy"
using namespace ::osl; using namespace ::osl;
@ -532,39 +531,25 @@ sal_Bool FilePolicy::supportsService( OUString const & serviceName )
return cppu::supportsService(this, serviceName); return cppu::supportsService(this, serviceName);
} }
//__________________________________________________________________________________________________ //__________________________________________________________________________________________________
static Sequence< OUString > FilePolicy_getSupportedServiceNames() SAL_THROW(())
{
Sequence< OUString > aSNS( 1 );
aSNS.getArray()[0] = OUString(SERVICE_NAME);
return aSNS;
}
Sequence< OUString > FilePolicy::getSupportedServiceNames() Sequence< OUString > FilePolicy::getSupportedServiceNames()
throw (RuntimeException) throw (RuntimeException)
{ {
return FilePolicy_getSupportedServiceNames(); Sequence< OUString > aSNS( 1 );
aSNS[0] = OUString("com.sun.star.security.Policy");
return aSNS;
} }
} // namespace } // namespace
static Reference< XInterface > FilePolicy_CreateInstance( extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
Reference< XComponentContext > const & xComponentContext ) com_sun_star_security_comp_stoc_FilePolicy(
SAL_THROW( (Exception) ) css::uno::XComponentContext * context, uno_Sequence * arguments)
{ {
return (OWeakObject *)new FilePolicy( xComponentContext ); assert(arguments != 0 && arguments->nElements == 0); (void) arguments;
} css::uno::Reference<css::uno::XInterface> x(
static_cast<cppu::OWeakObject *>(new FilePolicy(context)));
extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL x->acquire();
com_sun_star_security_comp_stoc_FilePolicy_component_getFactory( return x.get();
const char * , void * , void * )
{
Reference< css::lang::XSingleComponentFactory > xFactory;
xFactory = createSingleComponentFactory(
FilePolicy_CreateInstance,
IMPL_NAME,
FilePolicy_getSupportedServiceNames() );
xFactory->acquire();
return xFactory.get();
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@ -28,7 +28,6 @@
#include <cppuhelper/queryinterface.hxx> #include <cppuhelper/queryinterface.hxx>
#include <cppuhelper/weakref.hxx> #include <cppuhelper/weakref.hxx>
#include <cppuhelper/component.hxx> #include <cppuhelper/component.hxx>
#include <cppuhelper/factory.hxx>
#include <cppuhelper/implbase1.hxx> #include <cppuhelper/implbase1.hxx>
#include <cppuhelper/implementationentry.hxx> #include <cppuhelper/implementationentry.hxx>
#include <cppuhelper/component_context.hxx> #include <cppuhelper/component_context.hxx>
@ -67,29 +66,6 @@ using namespace std;
namespace { namespace {
Sequence< OUString > OServiceManager_getSupportedServiceNames()
{
Sequence< OUString > seqNames(2);
seqNames.getArray()[0] = "com.sun.star.lang.MultiServiceFactory";
seqNames.getArray()[1] = "com.sun.star.lang.ServiceManager";
return seqNames;
}
Sequence< OUString > ORegistryServiceManager_getSupportedServiceNames()
{
Sequence< OUString > seqNames(2);
seqNames.getArray()[0] = "com.sun.star.lang.MultiServiceFactory";
seqNames.getArray()[1] = "com.sun.star.lang.RegistryServiceManager";
return seqNames;
}
Sequence< OUString > OServiceManagerWrapper_getSupportedServiceNames()
{
Sequence< OUString > seqNames(1);
seqNames.getArray()[0] = "com.sun.star.lang.MultiServiceFactory";
return seqNames;
}
static Sequence< OUString > retrieveAsciiValueList( static Sequence< OUString > retrieveAsciiValueList(
const Reference< XSimpleRegistry > &xReg, const OUString &keyName ) const Reference< XSimpleRegistry > &xReg, const OUString &keyName )
{ {
@ -1083,7 +1059,6 @@ void OServiceManager::initialize( Sequence< Any > const & )
OUString OServiceManager::getImplementationName() OUString OServiceManager::getImplementationName()
throw(::com::sun::star::uno::RuntimeException) throw(::com::sun::star::uno::RuntimeException)
{ {
check_undisposed();
return OUString("com.sun.star.comp.stoc.OServiceManager"); return OUString("com.sun.star.comp.stoc.OServiceManager");
} }
@ -1098,8 +1073,10 @@ sal_Bool OServiceManager::supportsService(const OUString& ServiceName)
Sequence< OUString > OServiceManager::getSupportedServiceNames() Sequence< OUString > OServiceManager::getSupportedServiceNames()
throw(::com::sun::star::uno::RuntimeException) throw(::com::sun::star::uno::RuntimeException)
{ {
check_undisposed(); Sequence< OUString > seqNames(2);
return OServiceManager_getSupportedServiceNames(); seqNames[0] = "com.sun.star.lang.MultiServiceFactory";
seqNames[1] = "com.sun.star.lang.ServiceManager";
return seqNames;
} }
@ -1601,8 +1578,10 @@ Sequence< OUString > ORegistryServiceManager::getAvailableServiceNames()
Sequence< OUString > ORegistryServiceManager::getSupportedServiceNames() Sequence< OUString > ORegistryServiceManager::getSupportedServiceNames()
throw(::com::sun::star::uno::RuntimeException) throw(::com::sun::star::uno::RuntimeException)
{ {
check_undisposed(); Sequence< OUString > seqNames(2);
return ORegistryServiceManager_getSupportedServiceNames(); seqNames[0] = "com.sun.star.lang.MultiServiceFactory";
seqNames[1] = "com.sun.star.lang.RegistryServiceManager";
return seqNames;
} }
@ -1691,67 +1670,37 @@ Any ORegistryServiceManager::getPropertyValue(const OUString& PropertyName)
} // namespace } // namespace
static Reference<XInterface > OServiceManager_CreateInstance( extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
const Reference< XComponentContext > & xContext ) com_sun_star_comp_stoc_OServiceManager(
css::uno::XComponentContext * context, uno_Sequence * arguments)
{ {
return Reference<XInterface >( assert(arguments != 0 && arguments->nElements == 0); (void) arguments;
static_cast< XInterface * >( css::uno::Reference<css::uno::XInterface> x(
static_cast< OWeakObject * >( new OServiceManager( xContext ) ) ) ); static_cast<cppu::OWeakObject *>(new OServiceManager(context)));
x->acquire();
return x.get();
} }
extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
com_sun_star_comp_stoc_OServiceManager_component_getFactory( com_sun_star_comp_stoc_ORegistryServiceManager(
const char * , void * , void * ) css::uno::XComponentContext * context, uno_Sequence * arguments)
{ {
Reference< css::lang::XSingleComponentFactory > xFactory; assert(arguments != 0 && arguments->nElements == 0); (void) arguments;
xFactory = createSingleComponentFactory( css::uno::Reference<css::uno::XInterface> x(
OServiceManager_CreateInstance, static_cast<cppu::OWeakObject *>(new ORegistryServiceManager(context)));
"com.sun.star.comp.stoc.OServiceManager", x->acquire();
OServiceManager_getSupportedServiceNames() ); return x.get();
xFactory->acquire();
return xFactory.get();
} }
static Reference<XInterface > ORegistryServiceManager_CreateInstance( extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
const Reference< XComponentContext > & xContext ) com_sun_star_comp_stoc_OServiceManagerWrapper(
throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException) css::uno::XComponentContext * context, uno_Sequence * arguments)
{ {
return Reference<XInterface >( assert(arguments != 0 && arguments->nElements == 0); (void) arguments;
static_cast< XInterface * >( css::uno::Reference<css::uno::XInterface> x(
static_cast< OWeakObject * >( new ORegistryServiceManager( xContext ) ) ) ); static_cast<cppu::OWeakObject *>(new OServiceManagerWrapper(context)));
} x->acquire();
return x.get();
extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL
com_sun_star_comp_stoc_ORegistryServiceManager_component_getFactory(
const char * , void * , void * )
{
Reference< css::lang::XSingleComponentFactory > xFactory;
xFactory = createSingleComponentFactory(
ORegistryServiceManager_CreateInstance,
"com.sun.star.comp.stoc.ORegistryServiceManager",
ORegistryServiceManager_getSupportedServiceNames() );
xFactory->acquire();
return xFactory.get();
}
static Reference<XInterface > OServiceManagerWrapper_CreateInstance(
const Reference< XComponentContext > & xContext )
throw (Exception)
{
return (OWeakObject *)new OServiceManagerWrapper( xContext );
}
extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL
com_sun_star_comp_stoc_OServiceManagerWrapper_component_getFactory(
const char * , void * , void * )
{
Reference< css::lang::XSingleComponentFactory > xFactory;
xFactory = createSingleComponentFactory(
OServiceManagerWrapper_CreateInstance,
"com.sun.star.comp.stoc.OServiceManagerWrapper",
OServiceManagerWrapper_getSupportedServiceNames() );
xFactory->acquire();
return xFactory.get();
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@ -34,9 +34,9 @@
#include "com/sun/star/uno/XComponentContext.hpp" #include "com/sun/star/uno/XComponentContext.hpp"
#include "com/sun/star/uno/XInterface.hpp" #include "com/sun/star/uno/XInterface.hpp"
#include "com/sun/star/uno/Sequence.hxx" #include "com/sun/star/uno/Sequence.hxx"
#include <cppuhelper/factory.hxx>
#include "cppuhelper/implbase1.hxx" #include "cppuhelper/implbase1.hxx"
#include "cppuhelper/implbase2.hxx" #include "cppuhelper/implbase2.hxx"
#include "cppuhelper/supportsservice.hxx"
#include "cppuhelper/weak.hxx" #include "cppuhelper/weak.hxx"
#include "osl/mutex.hxx" #include "osl/mutex.hxx"
#include "registry/registry.hxx" #include "registry/registry.hxx"
@ -52,12 +52,6 @@
namespace { namespace {
static css::uno::Sequence< OUString > SimpleRegistry_getSupportedServiceNames() {
css::uno::Sequence< OUString > names(1);
names[0] = "com.sun.star.registry.SimpleRegistry";
return names;
}
class SimpleRegistry: class SimpleRegistry:
public cppu::WeakImplHelper2< public cppu::WeakImplHelper2<
css::registry::XSimpleRegistry, css::lang::XServiceInfo > css::registry::XSimpleRegistry, css::lang::XServiceInfo >
@ -105,11 +99,15 @@ private:
virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName) virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName)
throw (css::uno::RuntimeException) throw (css::uno::RuntimeException)
{ return ServiceName == getSupportedServiceNames()[0]; } { return cppu::supportsService(this, ServiceName); }
virtual css::uno::Sequence< OUString > SAL_CALL virtual css::uno::Sequence< OUString > SAL_CALL
getSupportedServiceNames() throw (css::uno::RuntimeException) getSupportedServiceNames() throw (css::uno::RuntimeException)
{ return SimpleRegistry_getSupportedServiceNames(); } {
css::uno::Sequence< OUString > names(1);
names[0] = "com.sun.star.registry.SimpleRegistry";
return names;
}
Registry registry_; Registry registry_;
}; };
@ -1125,24 +1123,16 @@ void SimpleRegistry::mergeKey(
} }
static css::uno::Reference< css::uno::XInterface > SimpleRegistry_CreateInstance( extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
SAL_UNUSED_PARAMETER css::uno::Reference< css::uno::XComponentContext > com_sun_star_comp_stoc_SimpleRegistry(
const &) SAL_UNUSED_PARAMETER css::uno::XComponentContext *,
uno_Sequence * arguments)
{ {
return static_cast< cppu::OWeakObject * >(new SimpleRegistry); assert(arguments != 0 && arguments->nElements == 0); (void) arguments;
} css::uno::Reference<css::uno::XInterface> x(
static_cast<cppu::OWeakObject *>(new SimpleRegistry));
extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL x->acquire();
com_sun_star_comp_stoc_SimpleRegistry_component_getFactory( return x.get();
const char * , void * , void * )
{
css::uno::Reference< css::lang::XSingleComponentFactory > xFactory;
xFactory = cppu::createSingleComponentFactory(
SimpleRegistry_CreateInstance,
"com.sun.star.comp.stoc.SimpleRegistry",
SimpleRegistry_getSupportedServiceNames() );
xFactory->acquire();
return xFactory.get();
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@ -18,30 +18,39 @@
--> -->
<component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@" <component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@"
prefix="direct" xmlns="http://openoffice.org/2010/uno-components"> xmlns="http://openoffice.org/2010/uno-components">
<implementation name="com.sun.star.comp.stoc.DLLComponentLoader"> <implementation name="com.sun.star.comp.stoc.DLLComponentLoader"
constructor="com_sun_star_comp_stoc_DLLComponentLoader">
<service name="com.sun.star.loader.SharedLibrary"/> <service name="com.sun.star.loader.SharedLibrary"/>
</implementation> </implementation>
<implementation name="com.sun.star.comp.stoc.ImplementationRegistration"> <implementation name="com.sun.star.comp.stoc.ImplementationRegistration"
constructor="com_sun_star_comp_stoc_ImplementationRegistration">
<service name="com.sun.star.registry.ImplementationRegistration"/> <service name="com.sun.star.registry.ImplementationRegistration"/>
</implementation> </implementation>
<implementation name="com.sun.star.comp.stoc.NestedRegistry"> <implementation name="com.sun.star.comp.stoc.NestedRegistry"
constructor="com_sun_star_comp_stoc_NestedRegistry">
<service name="com.sun.star.registry.NestedRegistry"/> <service name="com.sun.star.registry.NestedRegistry"/>
</implementation> </implementation>
<implementation name="com.sun.star.comp.stoc.ORegistryServiceManager"> <implementation name="com.sun.star.comp.stoc.ORegistryServiceManager"
constructor="com_sun_star_comp_stoc_ORegistryServiceManager">
<service name="com.sun.star.lang.RegistryServiceManager"/> <service name="com.sun.star.lang.RegistryServiceManager"/>
</implementation> </implementation>
<implementation name="com.sun.star.comp.stoc.OServiceManager"> <implementation name="com.sun.star.comp.stoc.OServiceManager"
constructor="com_sun_star_comp_stoc_OServiceManager">
<service name="com.sun.star.lang.ServiceManager"/> <service name="com.sun.star.lang.ServiceManager"/>
</implementation> </implementation>
<implementation name="com.sun.star.comp.stoc.OServiceManagerWrapper"/> <implementation name="com.sun.star.comp.stoc.OServiceManagerWrapper"
<implementation name="com.sun.star.comp.stoc.SimpleRegistry"> constructor="com_sun_star_comp_stoc_OServiceManagerWrapper"/>
<implementation name="com.sun.star.comp.stoc.SimpleRegistry"
constructor="com_sun_star_comp_stoc_SimpleRegistry">
<service name="com.sun.star.registry.SimpleRegistry"/> <service name="com.sun.star.registry.SimpleRegistry"/>
</implementation> </implementation>
<implementation name="com.sun.star.security.comp.stoc.AccessController"> <implementation name="com.sun.star.security.comp.stoc.AccessController"
constructor="com_sun_star_security_comp_stoc_AccessController">
<service name="com.sun.star.security.AccessController"/> <service name="com.sun.star.security.AccessController"/>
</implementation> </implementation>
<implementation name="com.sun.star.security.comp.stoc.FilePolicy"> <implementation name="com.sun.star.security.comp.stoc.FilePolicy"
constructor="com_sun_star_security_comp_stoc_FilePolicy">
<service name="com.sun.star.security.Policy"/> <service name="com.sun.star.security.Policy"/>
</implementation> </implementation>
</component> </component>