[Libreoffice-commits] core.git: comphelper/source comphelper/util

yeliztaneroglu yeliztaneroglu at gmail.com
Wed Feb 24 07:28:09 UTC 2016


 comphelper/source/inc/comphelper_services.hxx  |    1 
 comphelper/source/misc/comphelper_services.cxx |    1 
 comphelper/source/misc/documentiologring.cxx   |   58 ++++++++++---------------
 comphelper/source/misc/documentiologring.hxx   |   10 ----
 comphelper/util/comphelp.component             |    3 -
 5 files changed, 27 insertions(+), 46 deletions(-)

New commits:
commit 1b6a84a5a24e7e02c6066ca0fcb5a0011d2decd6
Author: yeliztaneroglu <yeliztaneroglu at gmail.com>
Date:   Tue Feb 2 11:04:49 2016 +0200

    tdf#74608: Constructor function for SimpleLogRing singleton
    
    Change-Id: Ia8c2f214b635114ecac4a2ceb06628a2f18b6411
    Reviewed-on: https://gerrit.libreoffice.org/22020
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>

diff --git a/comphelper/source/inc/comphelper_services.hxx b/comphelper/source/inc/comphelper_services.hxx
index 0f499f3..318eaa6 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 47fdf20..ef136ee 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 aaea0ca..3940d1d 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 e6974d9..5eabc8e 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 4de65e1..71ddeea 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>


More information about the Libreoffice-commits mailing list