summaryrefslogtreecommitdiff
path: root/comphelper
diff options
context:
space:
mode:
authorMatúš Kukan <matus.kukan@gmail.com>2015-12-26 22:39:08 +0100
committerMatúš Kukan <matus.kukan@gmail.com>2015-12-27 13:55:29 +0100
commit4db23a9d17cccc2103b72506e3837a3b6576c181 (patch)
tree2c6463600747d9629e210060c012034ba6d7c0e3 /comphelper
parent9e3c7725909ebce86e30f1e774d5f9e1d761c16a (diff)
tdf#74608: Constructor function for OfficeInstallationDirectories singleton
Change-Id: Ia0de503c50b6b1d568df27f6a8139fdcc8d0cfbf
Diffstat (limited to 'comphelper')
-rw-r--r--comphelper/source/inc/comphelper_services.hxx1
-rw-r--r--comphelper/source/misc/comphelper_services.cxx1
-rw-r--r--comphelper/source/officeinstdir/officeinstallationdirectories.cxx83
-rw-r--r--comphelper/source/officeinstdir/officeinstallationdirectories.hxx8
-rw-r--r--comphelper/util/comphelp.component3
5 files changed, 33 insertions, 63 deletions
diff --git a/comphelper/source/inc/comphelper_services.hxx b/comphelper/source/inc/comphelper_services.hxx
index 08ed94d31d2c..d62a16a0d8e0 100644
--- a/comphelper/source/inc/comphelper_services.hxx
+++ b/comphelper/source/inc/comphelper_services.hxx
@@ -29,7 +29,6 @@ void createRegistryInfo_NamedPropertyValuesContainer();
void createRegistryInfo_OInstanceLocker();
void createRegistryInfo_OPropertyBag();
void createRegistryInfo_OSimpleLogRing();
-void createRegistryInfo_OfficeInstallationDirectories();
void createRegistryInfo_SequenceInputStream();
void createRegistryInfo_SequenceOutputStream();
void createRegistryInfo_UNOMemoryStream();
diff --git a/comphelper/source/misc/comphelper_services.cxx b/comphelper/source/misc/comphelper_services.cxx
index 122f192cdd94..979cd366731b 100644
--- a/comphelper/source/misc/comphelper_services.cxx
+++ b/comphelper/source/misc/comphelper_services.cxx
@@ -41,7 +41,6 @@ namespace comphelper { namespace module
createRegistryInfo_IndexedPropertyValuesContainer();
createRegistryInfo_NamedPropertyValuesContainer();
createRegistryInfo_AnyCompareFactory();
- createRegistryInfo_OfficeInstallationDirectories();
createRegistryInfo_OInstanceLocker();
createRegistryInfo_Map();
createRegistryInfo_OSimpleLogRing();
diff --git a/comphelper/source/officeinstdir/officeinstallationdirectories.cxx b/comphelper/source/officeinstdir/officeinstallationdirectories.cxx
index ca2aa0da4228..6342182b8c6b 100644
--- a/comphelper/source/officeinstdir/officeinstallationdirectories.cxx
+++ b/comphelper/source/officeinstdir/officeinstallationdirectories.cxx
@@ -19,8 +19,6 @@
#include <config_folders.h>
-#include "comphelper_module.hxx"
-#include "comphelper_services.hxx"
#include <cppuhelper/supportsservice.hxx>
/**************************************************************************
@@ -30,7 +28,7 @@
*************************************************************************/
#include <osl/file.hxx>
-#include <com/sun/star/beans/XPropertySet.hpp>
+#include <rtl/ref.hxx>
#include <com/sun/star/util/theMacroExpander.hpp>
#include <comphelper/fileurl.hxx>
@@ -38,13 +36,6 @@
using namespace com::sun::star;
-using namespace comphelper;
-
-
-// helpers
-
-
-
static bool makeCanonicalFileURL( OUString & rURL )
{
OSL_ENSURE(comphelper::isFileUrl(rURL), "File URL expected!");
@@ -82,13 +73,7 @@ static bool makeCanonicalFileURL( OUString & rURL )
return false;
}
-
-
-
-// OfficeInstallationDirectories Implementation.
-
-
-
+namespace comphelper {
OfficeInstallationDirectories::OfficeInstallationDirectories(
const uno::Reference< uno::XComponentContext > & xCtx )
@@ -212,7 +197,7 @@ OUString SAL_CALL
OfficeInstallationDirectories::getImplementationName()
throw ( uno::RuntimeException, std::exception )
{
- return getImplementationName_static();
+ return OUString("com.sun.star.comp.util.OfficeInstallationDirectories");
}
// virtual
@@ -228,40 +213,9 @@ uno::Sequence< OUString > SAL_CALL
OfficeInstallationDirectories::getSupportedServiceNames()
throw ( uno::RuntimeException, std::exception )
{
- return getSupportedServiceNames_static();
-}
-
-
-// static
-OUString SAL_CALL
-OfficeInstallationDirectories::getImplementationName_static()
-{
- return OUString("com.sun.star.comp.util.OfficeInstallationDirectories");
-}
-
-
-// static
-uno::Sequence< OUString > SAL_CALL
-OfficeInstallationDirectories::getSupportedServiceNames_static()
-{
- const OUString aServiceName("com.sun.star.util.OfficeInstallationDirectories");
- return uno::Sequence< OUString >( &aServiceName, 1 );
-}
-
-
-// static
-uno::Reference< uno::XInterface > SAL_CALL
-OfficeInstallationDirectories::Create(
- const uno::Reference< uno::XComponentContext > & rxContext )
-{
- return static_cast< cppu::OWeakObject * >(
- new OfficeInstallationDirectories( rxContext ) );
+ return { "com.sun.star.util.OfficeInstallationDirectories" };
}
-
-// non-UNO
-
-
void OfficeInstallationDirectories::initDirs()
{
if ( m_pOfficeBrandDir == nullptr )
@@ -293,9 +247,34 @@ void OfficeInstallationDirectories::initDirs()
}
}
-void createRegistryInfo_OfficeInstallationDirectories()
+}
+
+namespace {
+
+struct Instance {
+ explicit Instance(
+ css::uno::Reference<css::uno::XComponentContext> const & context):
+ instance(static_cast<cppu::OWeakObject *>(
+ new comphelper::OfficeInstallationDirectories(context)))
+ {}
+
+ rtl::Reference<css::uno::XInterface> instance;
+};
+
+struct Singleton:
+ public rtl::StaticWithArg<
+ Instance, css::uno::Reference<css::uno::XComponentContext>, Singleton>
+{};
+
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
+com_sun_star_comp_util_OfficeInstallationDirectories(
+ css::uno::XComponentContext *context,
+ css::uno::Sequence<css::uno::Any> const &)
{
- static ::comphelper::module::OSingletonRegistration< OfficeInstallationDirectories > aAutoRegistration;
+ return cppu::acquire(static_cast<cppu::OWeakObject *>(
+ Singleton::get(context).instance.get()));
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/comphelper/source/officeinstdir/officeinstallationdirectories.hxx b/comphelper/source/officeinstdir/officeinstallationdirectories.hxx
index 40c3fd0c41a6..88e8341f0039 100644
--- a/comphelper/source/officeinstdir/officeinstallationdirectories.hxx
+++ b/comphelper/source/officeinstdir/officeinstallationdirectories.hxx
@@ -72,14 +72,6 @@ public:
getSupportedServiceNames()
throw (css::uno::RuntimeException, std::exception) override;
- // XServiceInfo - static versions (used for component registration)
- static OUString SAL_CALL
- getImplementationName_static();
- static css::uno::Sequence< OUString > SAL_CALL
- getSupportedServiceNames_static();
- static css::uno::Reference< css::uno::XInterface > SAL_CALL
- Create( const css::uno::Reference< css::uno::XComponentContext >& );
-
private:
void initDirs();
diff --git a/comphelper/util/comphelp.component b/comphelper/util/comphelp.component
index 95432c655704..3a6803f37e24 100644
--- a/comphelper/util/comphelp.component
+++ b/comphelper/util/comphelp.component
@@ -52,7 +52,8 @@
<service name="com.sun.star.comp.task.OfficeRestartManager"/>
<singleton name="com.sun.star.task.OfficeRestartManager"/>
</implementation>
- <implementation name="com.sun.star.comp.util.OfficeInstallationDirectories">
+ <implementation name="com.sun.star.comp.util.OfficeInstallationDirectories"
+ constructor="com_sun_star_comp_util_OfficeInstallationDirectories">
<service name="com.sun.star.util.OfficeInstallationDirectories"/>
<singleton name="com.sun.star.util.theOfficeInstallationDirectories"/>
</implementation>