sb132: #i114877# combined configmgr::Components::{init,get}Singleton
This commit is contained in:
@@ -214,7 +214,7 @@ void Components::WriteThread::run() {
|
|||||||
reference_->clear();
|
reference_->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Components::initSingleton(
|
Components & Components::getSingleton(
|
||||||
css::uno::Reference< css::uno::XComponentContext > const & context)
|
css::uno::Reference< css::uno::XComponentContext > const & context)
|
||||||
{
|
{
|
||||||
OSL_ASSERT(context.is());
|
OSL_ASSERT(context.is());
|
||||||
@@ -223,10 +223,6 @@ void Components::initSingleton(
|
|||||||
static Components theSingleton(context);
|
static Components theSingleton(context);
|
||||||
singleton = &theSingleton;
|
singleton = &theSingleton;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Components & Components::getSingleton() {
|
|
||||||
OSL_ASSERT(singletonCreated);
|
|
||||||
if (singleton == 0) {
|
if (singleton == 0) {
|
||||||
throw css::uno::RuntimeException(
|
throw css::uno::RuntimeException(
|
||||||
rtl::OUString(
|
rtl::OUString(
|
||||||
|
@@ -65,12 +65,10 @@ class RootAccess;
|
|||||||
|
|
||||||
class Components: private boost::noncopyable {
|
class Components: private boost::noncopyable {
|
||||||
public:
|
public:
|
||||||
static void initSingleton(
|
static Components & getSingleton(
|
||||||
com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >
|
com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >
|
||||||
const & context);
|
const & context);
|
||||||
|
|
||||||
static Components & getSingleton();
|
|
||||||
|
|
||||||
static bool allLocales(rtl::OUString const & locale);
|
static bool allLocales(rtl::OUString const & locale);
|
||||||
|
|
||||||
rtl::Reference< Node > resolvePathRepresentation(
|
rtl::Reference< Node > resolvePathRepresentation(
|
||||||
|
@@ -275,8 +275,7 @@ Service::createInstanceWithArguments(
|
|||||||
static_cast< cppu::OWeakObject * >(this));
|
static_cast< cppu::OWeakObject * >(this));
|
||||||
}
|
}
|
||||||
osl::MutexGuard guard(lock);
|
osl::MutexGuard guard(lock);
|
||||||
Components::initSingleton(context_);
|
Components & components = Components::getSingleton(context_);
|
||||||
Components & components = Components::getSingleton();
|
|
||||||
rtl::Reference< RootAccess > root(
|
rtl::Reference< RootAccess > root(
|
||||||
new RootAccess(components, nodepath, locale, update));
|
new RootAccess(components, nodepath, locale, update));
|
||||||
if (root->isValue()) {
|
if (root->isValue()) {
|
||||||
@@ -387,8 +386,7 @@ void Service::flushModifications() const {
|
|||||||
Components * components;
|
Components * components;
|
||||||
{
|
{
|
||||||
osl::MutexGuard guard(lock);
|
osl::MutexGuard guard(lock);
|
||||||
Components::initSingleton(context_);
|
components = &Components::getSingleton(context_);
|
||||||
components = &Components::getSingleton();
|
|
||||||
}
|
}
|
||||||
components->flushModifications();
|
components->flushModifications();
|
||||||
}
|
}
|
||||||
|
@@ -71,7 +71,11 @@ class Service:
|
|||||||
private boost::noncopyable
|
private boost::noncopyable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Service() {}
|
Service(css::uno::Reference< css::uno::XComponentContext > const context):
|
||||||
|
context_(context)
|
||||||
|
{
|
||||||
|
OSL_ASSERT(context.is());
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual ~Service() {}
|
virtual ~Service() {}
|
||||||
@@ -92,6 +96,8 @@ private:
|
|||||||
css::uno::Sequence< rtl::OUString > const & includedPaths,
|
css::uno::Sequence< rtl::OUString > const & includedPaths,
|
||||||
css::uno::Sequence< rtl::OUString > const & excludedPaths)
|
css::uno::Sequence< rtl::OUString > const & excludedPaths)
|
||||||
throw (css::uno::RuntimeException);
|
throw (css::uno::RuntimeException);
|
||||||
|
|
||||||
|
css::uno::Reference< css::uno::XComponentContext > context_;
|
||||||
};
|
};
|
||||||
|
|
||||||
void Service::insertExtensionXcsFile(
|
void Service::insertExtensionXcsFile(
|
||||||
@@ -99,7 +105,7 @@ void Service::insertExtensionXcsFile(
|
|||||||
throw (css::uno::RuntimeException)
|
throw (css::uno::RuntimeException)
|
||||||
{
|
{
|
||||||
osl::MutexGuard g(lock);
|
osl::MutexGuard g(lock);
|
||||||
Components::getSingleton().insertExtensionXcsFile(shared, fileUri);
|
Components::getSingleton(context_).insertExtensionXcsFile(shared, fileUri);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Service::insertExtensionXcuFile(
|
void Service::insertExtensionXcuFile(
|
||||||
@@ -109,10 +115,10 @@ void Service::insertExtensionXcuFile(
|
|||||||
Broadcaster bc;
|
Broadcaster bc;
|
||||||
{
|
{
|
||||||
osl::MutexGuard g(lock);
|
osl::MutexGuard g(lock);
|
||||||
|
Components & components = Components::getSingleton(context_);
|
||||||
Modifications mods;
|
Modifications mods;
|
||||||
Components::getSingleton().insertExtensionXcuFile(
|
components.insertExtensionXcuFile(shared, fileUri, &mods);
|
||||||
shared, fileUri, &mods);
|
components.initGlobalBroadcaster(
|
||||||
Components::getSingleton().initGlobalBroadcaster(
|
|
||||||
mods, rtl::Reference< RootAccess >(), &bc);
|
mods, rtl::Reference< RootAccess >(), &bc);
|
||||||
}
|
}
|
||||||
bc.send();
|
bc.send();
|
||||||
@@ -124,9 +130,10 @@ void Service::removeExtensionXcuFile(rtl::OUString const & fileUri)
|
|||||||
Broadcaster bc;
|
Broadcaster bc;
|
||||||
{
|
{
|
||||||
osl::MutexGuard g(lock);
|
osl::MutexGuard g(lock);
|
||||||
|
Components & components = Components::getSingleton(context_);
|
||||||
Modifications mods;
|
Modifications mods;
|
||||||
Components::getSingleton().removeExtensionXcuFile(fileUri, &mods);
|
components.removeExtensionXcuFile(fileUri, &mods);
|
||||||
Components::getSingleton().initGlobalBroadcaster(
|
components.initGlobalBroadcaster(
|
||||||
mods, rtl::Reference< RootAccess >(), &bc);
|
mods, rtl::Reference< RootAccess >(), &bc);
|
||||||
}
|
}
|
||||||
bc.send();
|
bc.send();
|
||||||
@@ -141,10 +148,11 @@ void Service::insertModificationXcuFile(
|
|||||||
Broadcaster bc;
|
Broadcaster bc;
|
||||||
{
|
{
|
||||||
osl::MutexGuard g(lock);
|
osl::MutexGuard g(lock);
|
||||||
|
Components & components = Components::getSingleton(context_);
|
||||||
Modifications mods;
|
Modifications mods;
|
||||||
Components::getSingleton().insertModificationXcuFile(
|
components.insertModificationXcuFile(
|
||||||
fileUri, seqToSet(includedPaths), seqToSet(excludedPaths), &mods);
|
fileUri, seqToSet(includedPaths), seqToSet(excludedPaths), &mods);
|
||||||
Components::getSingleton().initGlobalBroadcaster(
|
components.initGlobalBroadcaster(
|
||||||
mods, rtl::Reference< RootAccess >(), &bc);
|
mods, rtl::Reference< RootAccess >(), &bc);
|
||||||
}
|
}
|
||||||
bc.send();
|
bc.send();
|
||||||
@@ -153,9 +161,9 @@ void Service::insertModificationXcuFile(
|
|||||||
}
|
}
|
||||||
|
|
||||||
css::uno::Reference< css::uno::XInterface > create(
|
css::uno::Reference< css::uno::XInterface > create(
|
||||||
css::uno::Reference< css::uno::XComponentContext > const &)
|
css::uno::Reference< css::uno::XComponentContext > const & context)
|
||||||
{
|
{
|
||||||
return static_cast< cppu::OWeakObject * >(new Service);
|
return static_cast< cppu::OWeakObject * >(new Service(context));
|
||||||
}
|
}
|
||||||
|
|
||||||
rtl::OUString getImplementationName() {
|
rtl::OUString getImplementationName() {
|
||||||
|
Reference in New Issue
Block a user