Kaydet (Commit) 4db23a9d authored tarafından Matúš Kukan's avatar Matúš Kukan

tdf#74608: Constructor function for OfficeInstallationDirectories singleton

Change-Id: Ia0de503c50b6b1d568df27f6a8139fdcc8d0cfbf
üst 9e3c7725
......@@ -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();
......
......@@ -41,7 +41,6 @@ namespace comphelper { namespace module
createRegistryInfo_IndexedPropertyValuesContainer();
createRegistryInfo_NamedPropertyValuesContainer();
createRegistryInfo_AnyCompareFactory();
createRegistryInfo_OfficeInstallationDirectories();
createRegistryInfo_OInstanceLocker();
createRegistryInfo_Map();
createRegistryInfo_OSimpleLogRing();
......
......@@ -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: */
......@@ -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();
......
......@@ -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>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment