summaryrefslogtreecommitdiff
path: root/comphelper
diff options
context:
space:
mode:
authoryeliztaneroglu <yeliztaneroglu@gmail.com>2016-02-02 11:04:49 +0200
committerStephan Bergmann <sbergman@redhat.com>2016-02-24 07:27:42 +0000
commit1b6a84a5a24e7e02c6066ca0fcb5a0011d2decd6 (patch)
tree64562f5fbff8bb5ee080f1ffebcc33e12be899a0 /comphelper
parentf84b8c03462238b821724b7f504ad141c83fcf8f (diff)
tdf#74608: Constructor function for SimpleLogRing singleton
Change-Id: Ia8c2f214b635114ecac4a2ceb06628a2f18b6411 Reviewed-on: https://gerrit.libreoffice.org/22020 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
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/misc/documentiologring.cxx58
-rw-r--r--comphelper/source/misc/documentiologring.hxx10
-rw-r--r--comphelper/util/comphelp.component3
5 files changed, 27 insertions, 46 deletions
diff --git a/comphelper/source/inc/comphelper_services.hxx b/comphelper/source/inc/comphelper_services.hxx
index 0f499f33dbd6..318eaa65f996 100644
--- a/comphelper/source/inc/comphelper_services.hxx
+++ b/comphelper/source/inc/comphelper_services.hxx
@@ -25,7 +25,6 @@
void createRegistryInfo_Map();
void createRegistryInfo_OInstanceLocker();
void createRegistryInfo_OPropertyBag();
-void createRegistryInfo_OSimpleLogRing();
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 47fdf2047225..ef136eede5f9 100644
--- a/comphelper/source/misc/comphelper_services.cxx
+++ b/comphelper/source/misc/comphelper_services.cxx
@@ -40,7 +40,6 @@ namespace comphelper { namespace module
createRegistryInfo_UNOMemoryStream();
createRegistryInfo_OInstanceLocker();
createRegistryInfo_Map();
- createRegistryInfo_OSimpleLogRing();
}
};
diff --git a/comphelper/source/misc/documentiologring.cxx b/comphelper/source/misc/documentiologring.cxx
index aaea0caea8fe..3940d1da4fa9 100644
--- a/comphelper/source/misc/documentiologring.cxx
+++ b/comphelper/source/misc/documentiologring.cxx
@@ -20,12 +20,11 @@
#include <com/sun/star/frame/DoubleInitializationException.hpp>
#include <com/sun/star/lang/IllegalArgumentException.hpp>
-
-#include <comphelper_module.hxx>
-#include <comphelper_services.hxx>
+#include <com/sun/star/uno/XComponentContext.hpp>
#include <cppuhelper/supportsservice.hxx>
#include "documentiologring.hxx"
+#include <rtl/ref.hxx>
using namespace ::com::sun::star;
@@ -46,31 +45,6 @@ OSimpleLogRing::~OSimpleLogRing()
{
}
-
-uno::Sequence< OUString > SAL_CALL OSimpleLogRing::getSupportedServiceNames_static()
-{
- uno::Sequence<OUString> aResult { getServiceName_static() };
- return aResult;
-}
-
-
-OUString SAL_CALL OSimpleLogRing::getImplementationName_static()
-{
- return OUString( "com.sun.star.comp.logging.SimpleLogRing" );
-}
-
-
-OUString SAL_CALL OSimpleLogRing::getServiceName_static()
-{
- return OUString( "com.sun.star.logging.SimpleLogRing" );
-}
-
-
-uno::Reference< uno::XInterface > SAL_CALL OSimpleLogRing::Create( SAL_UNUSED_PARAMETER const uno::Reference< uno::XComponentContext >& )
-{
- return static_cast< cppu::OWeakObject* >( new OSimpleLogRing );
-}
-
// XSimpleLogRing
void SAL_CALL OSimpleLogRing::logString( const OUString& aMessage ) throw (uno::RuntimeException, std::exception)
@@ -135,7 +109,7 @@ void SAL_CALL OSimpleLogRing::initialize( const uno::Sequence< uno::Any >& aArgu
// XServiceInfo
OUString SAL_CALL OSimpleLogRing::getImplementationName() throw (uno::RuntimeException, std::exception)
{
- return getImplementationName_static();
+ return OUString("com.sun.star.comp.logging.SimpleLogRing");
}
sal_Bool SAL_CALL OSimpleLogRing::supportsService( const OUString& aServiceName ) throw (uno::RuntimeException, std::exception)
@@ -145,15 +119,33 @@ sal_Bool SAL_CALL OSimpleLogRing::supportsService( const OUString& aServiceName
uno::Sequence< OUString > SAL_CALL OSimpleLogRing::getSupportedServiceNames() throw (uno::RuntimeException, std::exception)
{
- return getSupportedServiceNames_static();
+ return { "com.sun.star.logging.SimpleLogRing" };
}
} // namespace comphelper
-void createRegistryInfo_OSimpleLogRing()
+namespace {
+
+struct Instance {
+ explicit Instance():
+ instance(new comphelper::OSimpleLogRing())
+ {}
+
+ css::uno::Reference<cppu::OWeakObject> instance;
+};
+
+struct Singleton:
+ public rtl::Static<Instance, Singleton>
+{};
+
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
+com_sun_star_comp_logging_SimpleLogRing(
+ css::uno::XComponentContext *,
+ css::uno::Sequence<css::uno::Any> const &)
{
- static ::comphelper::module::OAutoRegistration< ::comphelper::OSimpleLogRing > aAutoRegistration;
- static ::comphelper::module::OSingletonRegistration< ::comphelper::OSimpleLogRing > aSingletonRegistration;
+ return cppu::acquire(Singleton::get().instance.get());
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/comphelper/source/misc/documentiologring.hxx b/comphelper/source/misc/documentiologring.hxx
index e6974d988caa..5eabc8e56598 100644
--- a/comphelper/source/misc/documentiologring.hxx
+++ b/comphelper/source/misc/documentiologring.hxx
@@ -48,16 +48,6 @@ public:
OSimpleLogRing();
virtual ~OSimpleLogRing();
- static css::uno::Sequence< OUString > SAL_CALL
- getSupportedServiceNames_static();
-
- static OUString SAL_CALL getImplementationName_static();
-
- static OUString SAL_CALL getServiceName_static();
-
- static css::uno::Reference< css::uno::XInterface > SAL_CALL
- Create( const css::uno::Reference< css::uno::XComponentContext >& rxContext );
-
// XSimpleLogRing
virtual void SAL_CALL logString( const OUString& aMessage ) throw (css::uno::RuntimeException, std::exception) override;
virtual css::uno::Sequence< OUString > SAL_CALL getCollectedLog() throw (css::uno::RuntimeException, std::exception) override;
diff --git a/comphelper/util/comphelp.component b/comphelper/util/comphelp.component
index 4de65e1c2c75..71ddeea1d261 100644
--- a/comphelper/util/comphelp.component
+++ b/comphelper/util/comphelp.component
@@ -46,7 +46,8 @@
<implementation name="com.sun.star.comp.embed.InstanceLocker">
<service name="com.sun.star.embed.InstanceLocker"/>
</implementation>
- <implementation name="com.sun.star.comp.logging.SimpleLogRing">
+ <implementation name="com.sun.star.comp.logging.SimpleLogRing"
+ constructor="com_sun_star_comp_logging_SimpleLogRing">
<service name="com.sun.star.logging.SimpleLogRing"/>
<singleton name="com.sun.star.logging.DocumentIOLogRing"/>
</implementation>