[Libreoffice-commits] core.git: 6 commits - extensions/Library_log.mk extensions/source

Matúš Kukan matus.kukan at gmail.com
Mon Dec 28 12:16:26 PST 2015


 extensions/Library_log.mk                        |    2 
 extensions/source/logging/consolehandler.cxx     |  128 ++++++----------------
 extensions/source/logging/csvformatter.cxx       |   69 ++---------
 extensions/source/logging/filehandler.cxx        |  133 +++++++----------------
 extensions/source/logging/log.component          |   17 +-
 extensions/source/logging/log_module.cxx         |   51 --------
 extensions/source/logging/log_module.hxx         |   86 --------------
 extensions/source/logging/log_services.cxx       |   47 --------
 extensions/source/logging/log_services.hxx       |   37 ------
 extensions/source/logging/logger.cxx             |  114 ++++++-------------
 extensions/source/logging/plaintextformatter.cxx |   65 ++---------
 11 files changed, 162 insertions(+), 587 deletions(-)

New commits:
commit ad7d76add51736bc035afb5c64acc35feea74c6c
Author: Matúš Kukan <matus.kukan at gmail.com>
Date:   Mon Dec 28 20:30:36 2015 +0100

    extensions: Remove recently unused logging::LogModule
    
    Change-Id: I43d1306427e32dce4ed9ea621d0abc2155bd58df

diff --git a/extensions/Library_log.mk b/extensions/Library_log.mk
index 30d109e..99f8090 100644
--- a/extensions/Library_log.mk
+++ b/extensions/Library_log.mk
@@ -21,7 +21,6 @@ $(eval $(call gb_Library_add_exception_objects,log,\
 	extensions/source/logging/consolehandler \
 	extensions/source/logging/csvformatter \
 	extensions/source/logging/filehandler \
-	extensions/source/logging/log_module \
 	extensions/source/logging/logger \
 	extensions/source/logging/loggerconfig \
 	extensions/source/logging/loghandler \
diff --git a/extensions/source/logging/log_module.cxx b/extensions/source/logging/log_module.cxx
deleted file mode 100644
index fac6e53..0000000
--- a/extensions/source/logging/log_module.cxx
+++ /dev/null
@@ -1,51 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- *   Licensed to the Apache Software Foundation (ASF) under one or more
- *   contributor license agreements. See the NOTICE file distributed
- *   with this work for additional information regarding copyright
- *   ownership. The ASF licenses this file to you under the Apache
- *   License, Version 2.0 (the "License"); you may not use this file
- *   except in compliance with the License. You may obtain a copy of
- *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include "log_module.hxx"
-#include <rtl/instance.hxx>
-
-
-namespace logging
-{
-
-
-    struct LogModuleCreator
-    {
-        LogModule m_aLogModule;
-    };
-    namespace
-    {
-        class theLogModuleInstance : public rtl::Static<LogModuleCreator, theLogModuleInstance> {};
-    }
-
-    LogModule::LogModule()
-        :BaseClass()
-    {
-    }
-
-    LogModule& LogModule::getInstance()
-    {
-        return theLogModuleInstance::get().m_aLogModule;
-    }
-
-
-} // namespace logging
-
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/logging/log_module.hxx b/extensions/source/logging/log_module.hxx
deleted file mode 100644
index f6f5397..0000000
--- a/extensions/source/logging/log_module.hxx
+++ /dev/null
@@ -1,86 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- *   Licensed to the Apache Software Foundation (ASF) under one or more
- *   contributor license agreements. See the NOTICE file distributed
- *   with this work for additional information regarding copyright
- *   ownership. The ASF licenses this file to you under the Apache
- *   License, Version 2.0 (the "License"); you may not use this file
- *   except in compliance with the License. You may obtain a copy of
- *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#ifndef INCLUDED_EXTENSIONS_SOURCE_LOGGING_LOG_MODULE_HXX
-#define INCLUDED_EXTENSIONS_SOURCE_LOGGING_LOG_MODULE_HXX
-
-#include <comphelper/componentmodule.hxx>
-
-
-namespace logging
-{
-
-
-    class LogModule : public ::comphelper::OModule
-    {
-        friend struct LogModuleCreator;
-        typedef ::comphelper::OModule BaseClass;
-
-    public:
-        static LogModule& getInstance();
-
-    private:
-        LogModule();
-    };
-
-    /* -------------------------------------------------------------------- */
-    class LogModuleClient : public ::comphelper::OModuleClient
-    {
-    private:
-        typedef ::comphelper::OModuleClient BaseClass;
-
-    public:
-        LogModuleClient() : BaseClass( LogModule::getInstance() )
-        {
-        }
-    };
-
-    /* -------------------------------------------------------------------- */
-    template < class TYPE >
-    class OAutoRegistration : public ::comphelper::OAutoRegistration< TYPE >
-    {
-    private:
-        typedef ::comphelper::OAutoRegistration< TYPE > BaseClass;
-
-    public:
-        OAutoRegistration() : BaseClass( LogModule::getInstance() )
-        {
-        }
-    };
-
-    /* -------------------------------------------------------------------- */
-    template < class TYPE >
-    class OSingletonRegistration : public ::comphelper::OSingletonRegistration< TYPE >
-    {
-    private:
-        typedef ::comphelper::OSingletonRegistration< TYPE > BaseClass;
-
-    public:
-        OSingletonRegistration() : BaseClass( LogModule::getInstance() )
-        {
-        }
-    };
-
-
-} // namespace logging
-
-
-#endif // INCLUDED_EXTENSIONS_SOURCE_LOGGING_LOG_MODULE_HXX
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit e65709245cb844205f47ab1ccc79f718fbf2d025
Author: Matúš Kukan <matus.kukan at gmail.com>
Date:   Mon Dec 28 20:29:40 2015 +0100

    tdf#74608: Ctor function for logging::PlainTextFormatter
    
    Change-Id: Ibaf362c811564cab1855fd5c863b59d90256d047

diff --git a/extensions/Library_log.mk b/extensions/Library_log.mk
index 1abd7b7..30d109e 100644
--- a/extensions/Library_log.mk
+++ b/extensions/Library_log.mk
@@ -21,7 +21,6 @@ $(eval $(call gb_Library_add_exception_objects,log,\
 	extensions/source/logging/consolehandler \
 	extensions/source/logging/csvformatter \
 	extensions/source/logging/filehandler \
-	extensions/source/logging/log_services \
 	extensions/source/logging/log_module \
 	extensions/source/logging/logger \
 	extensions/source/logging/loggerconfig \
diff --git a/extensions/source/logging/log.component b/extensions/source/logging/log.component
index 3f9ad05..2bd7f65 100644
--- a/extensions/source/logging/log.component
+++ b/extensions/source/logging/log.component
@@ -18,7 +18,7 @@
  -->
 
 <component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@"
-    prefix="log" xmlns="http://openoffice.org/2010/uno-components">
+    xmlns="http://openoffice.org/2010/uno-components">
   <implementation name="com.sun.star.comp.extensions.ConsoleHandler"
       constructor="com_sun_star_comp_extensions_ConsoleHandler">
     <service name="com.sun.star.logging.ConsoleHandler"/>
@@ -35,7 +35,8 @@
       constructor="com_sun_star_comp_extensions_LoggerPool">
     <singleton name="com.sun.star.logging.LoggerPool"/>
   </implementation>
-  <implementation name="com.sun.star.comp.extensions.PlainTextFormatter">
+  <implementation name="com.sun.star.comp.extensions.PlainTextFormatter"
+      constructor="com_sun_star_comp_extensions_PlainTextFormatter">
     <service name="com.sun.star.logging.PlainTextFormatter"/>
   </implementation>
 </component>
diff --git a/extensions/source/logging/log_services.cxx b/extensions/source/logging/log_services.cxx
deleted file mode 100644
index 09df0db..0000000
--- a/extensions/source/logging/log_services.cxx
+++ /dev/null
@@ -1,43 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- *   Licensed to the Apache Software Foundation (ASF) under one or more
- *   contributor license agreements. See the NOTICE file distributed
- *   with this work for additional information regarding copyright
- *   ownership. The ASF licenses this file to you under the Apache
- *   License, Version 2.0 (the "License"); you may not use this file
- *   except in compliance with the License. You may obtain a copy of
- *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include "log_module.hxx"
-#include "log_services.hxx"
-
-namespace logging
-{
-    static void initializeModule()
-    {
-        ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
-        createRegistryInfo_PlainTextFormatter();
-    }
-
-
-} // namespace logging
-
-
-extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL log_component_getFactory(
-    const sal_Char* pImplementationName, SAL_UNUSED_PARAMETER void*,
-    SAL_UNUSED_PARAMETER void* )
-{
-    ::logging::initializeModule();
-    return ::logging::LogModule::getInstance().getComponentFactory( pImplementationName );
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/logging/log_services.hxx b/extensions/source/logging/log_services.hxx
deleted file mode 100644
index 47d6a6c..0000000
--- a/extensions/source/logging/log_services.hxx
+++ /dev/null
@@ -1,33 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- *   Licensed to the Apache Software Foundation (ASF) under one or more
- *   contributor license agreements. See the NOTICE file distributed
- *   with this work for additional information regarding copyright
- *   ownership. The ASF licenses this file to you under the Apache
- *   License, Version 2.0 (the "License"); you may not use this file
- *   except in compliance with the License. You may obtain a copy of
- *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#ifndef INCLUDED_EXTENSIONS_SOURCE_LOGGING_LOG_SERVICES_HXX
-#define INCLUDED_EXTENSIONS_SOURCE_LOGGING_LOG_SERVICES_HXX
-
-#include <sal/config.h>
-
-namespace logging {
-
-void createRegistryInfo_PlainTextFormatter();
-
-}
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/logging/plaintextformatter.cxx b/extensions/source/logging/plaintextformatter.cxx
index 585b5e8..7712f54 100644
--- a/extensions/source/logging/plaintextformatter.cxx
+++ b/extensions/source/logging/plaintextformatter.cxx
@@ -17,11 +17,7 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-
-#include "log_module.hxx"
-#include "log_services.hxx"
-
-#include <stdio.h>
+#include <sal/config.h>
 
 #include <com/sun/star/logging/XLogFormatter.hpp>
 #include <com/sun/star/uno/XComponentContext.hpp>
@@ -31,32 +27,26 @@
 #include <cppuhelper/supportsservice.hxx>
 
 #include <rtl/ustrbuf.hxx>
-
 #include <osl/thread.h>
 
+#include <stdio.h>
 
 namespace logging
 {
-
-
-    using ::com::sun::star::logging::XLogFormatter;
     using ::com::sun::star::uno::XComponentContext;
     using ::com::sun::star::uno::Reference;
     using ::com::sun::star::uno::Sequence;
-    using ::com::sun::star::lang::XServiceInfo;
     using ::com::sun::star::uno::RuntimeException;
     using ::com::sun::star::logging::LogRecord;
     using ::com::sun::star::uno::XInterface;
 
-    typedef ::cppu::WeakImplHelper <   XLogFormatter
-                                    ,   XServiceInfo
-                                    >   PlainTextFormatter_Base;
-    class PlainTextFormatter : public PlainTextFormatter_Base
+    class PlainTextFormatter : public cppu::WeakImplHelper<css::logging::XLogFormatter, css::lang::XServiceInfo>
     {
-    protected:
+    public:
         PlainTextFormatter();
         virtual ~PlainTextFormatter();
 
+    private:
         // XLogFormatter
         virtual OUString SAL_CALL getHead(  ) throw (RuntimeException, std::exception) override;
         virtual OUString SAL_CALL format( const LogRecord& Record ) throw (RuntimeException, std::exception) override;
@@ -66,12 +56,6 @@ namespace logging
         virtual OUString SAL_CALL getImplementationName() throw(RuntimeException, std::exception) override;
         virtual sal_Bool SAL_CALL supportsService( const OUString& _rServiceName ) throw(RuntimeException, std::exception) override;
         virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() throw(RuntimeException, std::exception) override;
-
-    public:
-        // XServiceInfo - static version
-        static OUString SAL_CALL getImplementationName_static();
-        static Sequence< OUString > SAL_CALL getSupportedServiceNames_static();
-        static Reference< XInterface > Create( const Reference< XComponentContext >& _rxContext );
     };
 
     PlainTextFormatter::PlainTextFormatter()
@@ -153,42 +137,23 @@ namespace logging
 
     OUString SAL_CALL PlainTextFormatter::getImplementationName() throw(RuntimeException, std::exception)
     {
-        return getImplementationName_static();
+        return OUString("com.sun.star.comp.extensions.PlainTextFormatter");
     }
 
-
     Sequence< OUString > SAL_CALL PlainTextFormatter::getSupportedServiceNames() throw(RuntimeException, std::exception)
     {
-        return getSupportedServiceNames_static();
-    }
-
-
-    OUString SAL_CALL PlainTextFormatter::getImplementationName_static()
-    {
-        return OUString( "com.sun.star.comp.extensions.PlainTextFormatter" );
+        return { "com.sun.star.logging.PlainTextFormatter" };
     }
 
-
-    Sequence< OUString > SAL_CALL PlainTextFormatter::getSupportedServiceNames_static()
-    {
-        Sequence< OUString > aServiceNames { "com.sun.star.logging.PlainTextFormatter" };
-        return aServiceNames;
-    }
-
-
-    Reference< XInterface > PlainTextFormatter::Create( const Reference< XComponentContext >& )
-    {
-        return *( new PlainTextFormatter );
-    }
-
-
-    void createRegistryInfo_PlainTextFormatter()
-    {
-        static OAutoRegistration< PlainTextFormatter > aAutoRegistration;
-    }
-
-
 } // namespace logging
 
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
+com_sun_star_comp_extensions_PlainTextFormatter(
+    css::uno::XComponentContext *,
+    css::uno::Sequence<css::uno::Any> const &)
+{
+    return cppu::acquire(new logging::PlainTextFormatter());
+}
+
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 42ab260e502c29034d4deb0c4a5a29d7a34c7b96
Author: Matúš Kukan <matus.kukan at gmail.com>
Date:   Mon Dec 28 20:23:48 2015 +0100

    tdf#74608: Ctor function for logging::CsvFormatter
    
    Change-Id: I3383e02a7162cc8dbce3ba0b04fac6dec3492d94

diff --git a/extensions/source/logging/csvformatter.cxx b/extensions/source/logging/csvformatter.cxx
index 708dfbc..3b358d3 100644
--- a/extensions/source/logging/csvformatter.cxx
+++ b/extensions/source/logging/csvformatter.cxx
@@ -17,12 +17,7 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-
-#include "log_module.hxx"
-#include "log_services.hxx"
-
-#include <stdio.h>
-#include <string>
+#include <sal/config.h>
 
 #include <com/sun/star/logging/XCsvLogFormatter.hpp>
 #include <com/sun/star/logging/XLogFormatter.hpp>
@@ -33,40 +28,28 @@
 #include <cppuhelper/supportsservice.hxx>
 
 #include <rtl/ustrbuf.hxx>
-
 #include <osl/thread.h>
 
+#include <stdio.h>
+#include <string>
+
 namespace logging
 {
-
-    using ::com::sun::star::logging::XCsvLogFormatter;
-    using ::com::sun::star::logging::XLogFormatter;
-    using ::com::sun::star::uno::XComponentContext;
     using ::com::sun::star::uno::Reference;
     using ::com::sun::star::uno::Sequence;
-    using ::com::sun::star::lang::XServiceInfo;
     using ::com::sun::star::uno::RuntimeException;
     using ::com::sun::star::logging::LogRecord;
-    using ::com::sun::star::uno::XInterface;
 
     // formats for csv files as defined by RFC4180
-    typedef ::cppu::WeakImplHelper <   XCsvLogFormatter
-                                    ,   XServiceInfo
-                                    >   CsvFormatter_Base;
-    class CsvFormatter : public CsvFormatter_Base
+    class CsvFormatter : public cppu::WeakImplHelper<css::logging::XCsvLogFormatter, css::lang::XServiceInfo>
     {
     public:
         virtual OUString SAL_CALL formatMultiColumn(const Sequence< OUString>& column_data) throw (RuntimeException, std::exception) override;
 
-        // XServiceInfo - static version
-        static OUString SAL_CALL getImplementationName_static();
-        static Sequence< OUString > SAL_CALL getSupportedServiceNames_static();
-        static Reference< XInterface > Create( const Reference< XComponentContext >& context );
-
-    protected:
         CsvFormatter();
         virtual ~CsvFormatter();
 
+    private:
         // XCsvLogFormatter
         virtual sal_Bool SAL_CALL getLogEventNo() throw (RuntimeException, std::exception) override;
         virtual sal_Bool SAL_CALL getLogThread() throw (RuntimeException, std::exception) override;
@@ -142,12 +125,6 @@ namespace
         else
             buf.append(str);
     };
-
-    css::uno::Sequence< OUString> initialColumns()
-    {
-        css::uno::Sequence< OUString> result { "message" };
-        return result;
-    };
 }
 
 namespace logging
@@ -158,7 +135,7 @@ namespace logging
         m_LogTimestamp(true),
         m_LogSource(false),
         m_MultiColumn(false),
-        m_Columnnames(initialColumns())
+        m_Columnnames({ "message" })
     { }
 
     CsvFormatter::~CsvFormatter()
@@ -317,34 +294,22 @@ namespace logging
 
     OUString SAL_CALL CsvFormatter::getImplementationName() throw(RuntimeException, std::exception)
     {
-        return getImplementationName_static();
+        return OUString("com.sun.star.comp.extensions.CsvFormatter");
     }
 
     Sequence< OUString > SAL_CALL CsvFormatter::getSupportedServiceNames() throw(RuntimeException, std::exception)
     {
-        return getSupportedServiceNames_static();
+        return { "com.sun.star.logging.CsvFormatter" };
     }
 
-    OUString SAL_CALL CsvFormatter::getImplementationName_static()
-    {
-        return OUString( "com.sun.star.comp.extensions.CsvFormatter" );
-    }
-
-    Sequence< OUString > SAL_CALL CsvFormatter::getSupportedServiceNames_static()
-    {
-        Sequence< OUString > aServiceNames { "com.sun.star.logging.CsvFormatter" };
-        return aServiceNames;
-    }
-
-    Reference< XInterface > CsvFormatter::Create( const Reference< XComponentContext >& )
-    {
-        return *( new CsvFormatter );
-    }
-
-    void createRegistryInfo_CsvFormatter()
-    {
-        static OAutoRegistration< CsvFormatter > aAutoRegistration;
-    }
 } // namespace logging
 
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
+com_sun_star_comp_extensions_CsvFormatter(
+    css::uno::XComponentContext *,
+    css::uno::Sequence<css::uno::Any> const &)
+{
+    return cppu::acquire(new logging::CsvFormatter());
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/logging/log.component b/extensions/source/logging/log.component
index 4cd5a55..3f9ad05 100644
--- a/extensions/source/logging/log.component
+++ b/extensions/source/logging/log.component
@@ -23,7 +23,8 @@
       constructor="com_sun_star_comp_extensions_ConsoleHandler">
     <service name="com.sun.star.logging.ConsoleHandler"/>
   </implementation>
-  <implementation name="com.sun.star.comp.extensions.CsvFormatter">
+  <implementation name="com.sun.star.comp.extensions.CsvFormatter"
+      constructor="com_sun_star_comp_extensions_CsvFormatter">
     <service name="com.sun.star.logging.CsvFormatter"/>
   </implementation>
   <implementation name="com.sun.star.comp.extensions.FileHandler"
diff --git a/extensions/source/logging/log_services.cxx b/extensions/source/logging/log_services.cxx
index d2599a0..09df0db 100644
--- a/extensions/source/logging/log_services.cxx
+++ b/extensions/source/logging/log_services.cxx
@@ -26,7 +26,6 @@ namespace logging
     {
         ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
         createRegistryInfo_PlainTextFormatter();
-        createRegistryInfo_CsvFormatter();
     }
 
 
diff --git a/extensions/source/logging/log_services.hxx b/extensions/source/logging/log_services.hxx
index 17c5ec9..47d6a6c 100644
--- a/extensions/source/logging/log_services.hxx
+++ b/extensions/source/logging/log_services.hxx
@@ -25,7 +25,6 @@
 namespace logging {
 
 void createRegistryInfo_PlainTextFormatter();
-void createRegistryInfo_CsvFormatter();
 
 }
 
commit cc6ccaf922bc8cefec714b9110a7d36ae113817c
Author: Matúš Kukan <matus.kukan at gmail.com>
Date:   Mon Dec 28 20:15:06 2015 +0100

    tdf#74608: Ctor function for logging::ConsoleHandler
    
    Change-Id: I4326dcb9ae2abfaddef3b68369ee08a6296e0089

diff --git a/extensions/source/logging/consolehandler.cxx b/extensions/source/logging/consolehandler.cxx
index e5db063..be5b87c 100644
--- a/extensions/source/logging/consolehandler.cxx
+++ b/extensions/source/logging/consolehandler.cxx
@@ -17,17 +17,14 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <sal/config.h>
 
-#include "log_module.hxx"
-#include "log_services.hxx"
 #include "methodguard.hxx"
 #include "loghandler.hxx"
 
 #include <com/sun/star/logging/XConsoleHandler.hpp>
 #include <com/sun/star/lang/XServiceInfo.hpp>
 #include <com/sun/star/logging/LogLevel.hpp>
-#include <com/sun/star/lang/XInitialization.hpp>
-#include <com/sun/star/ucb/AlreadyInitializedException.hpp>
 #include <com/sun/star/lang/IllegalArgumentException.hpp>
 #include <com/sun/star/beans/NamedValue.hpp>
 
@@ -37,11 +34,8 @@
 
 #include <stdio.h>
 
-
 namespace logging
 {
-
-
     using ::com::sun::star::logging::XConsoleHandler;
     using ::com::sun::star::lang::XServiceInfo;
     using ::com::sun::star::uno::Reference;
@@ -54,16 +48,11 @@ namespace logging
     using ::com::sun::star::uno::Exception;
     using ::com::sun::star::uno::Any;
     using ::com::sun::star::uno::XInterface;
-    using ::com::sun::star::lang::XInitialization;
-    using ::com::sun::star::ucb::AlreadyInitializedException;
     using ::com::sun::star::lang::IllegalArgumentException;
     using ::com::sun::star::beans::NamedValue;
 
-    namespace LogLevel = ::com::sun::star::logging::LogLevel;
-
     typedef ::cppu::WeakComponentImplHelper    <   XConsoleHandler
                                                 ,   XServiceInfo
-                                                ,   XInitialization
                                                 >   ConsoleHandler_Base;
     class ConsoleHandler    :public ::cppu::BaseMutex
                             ,public ConsoleHandler_Base
@@ -72,10 +61,12 @@ namespace logging
         LogHandlerHelper                m_aHandlerHelper;
         sal_Int32                       m_nThreshold;
 
-    protected:
-        explicit ConsoleHandler( const Reference< XComponentContext >& _rxContext );
+    public:
+        ConsoleHandler(const Reference<XComponentContext> &context,
+            const css::uno::Sequence<css::uno::Any> &arguments);
         virtual ~ConsoleHandler();
 
+    private:
         // XConsoleHandler
         virtual ::sal_Int32 SAL_CALL getThreshold() throw (RuntimeException, std::exception) override;
         virtual void SAL_CALL setThreshold( ::sal_Int32 _threshold ) throw (RuntimeException, std::exception) override;
@@ -90,9 +81,6 @@ namespace logging
         virtual void SAL_CALL flush(  ) throw (RuntimeException, std::exception) override;
         virtual sal_Bool SAL_CALL publish( const LogRecord& Record ) throw (RuntimeException, std::exception) override;
 
-        // XInitialization
-        virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) throw (css::uno::Exception, css::uno::RuntimeException, std::exception) override;
-
         // XServiceInfo
         virtual OUString SAL_CALL getImplementationName() throw(RuntimeException, std::exception) override;
         virtual sal_Bool SAL_CALL supportsService( const OUString& _rServiceName ) throw(RuntimeException, std::exception) override;
@@ -102,24 +90,40 @@ namespace logging
         virtual void SAL_CALL disposing() override;
 
     public:
-        // XServiceInfo - static version
-        static OUString SAL_CALL getImplementationName_static();
-        static Sequence< OUString > SAL_CALL getSupportedServiceNames_static();
-        static Reference< XInterface > Create( const Reference< XComponentContext >& _rxContext );
-
-    public:
         typedef ComponentMethodGuard< ConsoleHandler > MethodGuard;
         void    enterMethod( MethodGuard::Access );
         void    leaveMethod( MethodGuard::Access );
     };
 
-    ConsoleHandler::ConsoleHandler( const Reference< XComponentContext >& _rxContext )
+    ConsoleHandler::ConsoleHandler(const Reference<XComponentContext> &context,
+            const css::uno::Sequence<css::uno::Any> &arguments)
         :ConsoleHandler_Base( m_aMutex )
-        ,m_aHandlerHelper( _rxContext, m_aMutex, rBHelper )
-        ,m_nThreshold( LogLevel::SEVERE )
+        ,m_aHandlerHelper( context, m_aMutex, rBHelper )
+        ,m_nThreshold( css::logging::LogLevel::SEVERE )
     {
-    }
+        ::osl::MutexGuard aGuard( m_aMutex );
 
+        if ( arguments.getLength() == 0 )
+        {   // create() - nothing to init
+            m_aHandlerHelper.setIsInitialized();
+            return;
+        }
+
+        if ( arguments.getLength() != 1 )
+            throw IllegalArgumentException( OUString(), *this, 1 );
+
+        Sequence< NamedValue > aSettings;
+        if ( !( arguments[0] >>= aSettings ) )
+            throw IllegalArgumentException( OUString(), *this, 1 );
+
+        // createWithSettings( [in] sequence< css::beans::NamedValue > Settings )
+        ::comphelper::NamedValueCollection aTypedSettings( aSettings );
+        m_aHandlerHelper.initFromSettings( aTypedSettings );
+
+        aTypedSettings.get_ensureType( "Threshold", m_nThreshold );
+
+        m_aHandlerHelper.setIsInitialized();
+    }
 
     ConsoleHandler::~ConsoleHandler()
     {
@@ -231,81 +235,29 @@ namespace logging
         return sal_True;
     }
 
-
-    void SAL_CALL ConsoleHandler::initialize( const Sequence< Any >& _rArguments ) throw (Exception, RuntimeException, std::exception)
-    {
-        ::osl::MutexGuard aGuard( m_aMutex );
-
-        if ( m_aHandlerHelper.getIsInitialized() )
-            throw AlreadyInitializedException();
-
-        if ( _rArguments.getLength() == 0 )
-        {   // create() - nothing to init
-            m_aHandlerHelper.setIsInitialized();
-            return;
-        }
-
-        if ( _rArguments.getLength() != 1 )
-            throw IllegalArgumentException( OUString(), *this, 1 );
-
-        Sequence< NamedValue > aSettings;
-        if ( !( _rArguments[0] >>= aSettings ) )
-            throw IllegalArgumentException( OUString(), *this, 1 );
-
-        // createWithSettings( [in] sequence< css::beans::NamedValue > Settings )
-        ::comphelper::NamedValueCollection aTypedSettings( aSettings );
-        m_aHandlerHelper.initFromSettings( aTypedSettings );
-
-        aTypedSettings.get_ensureType( "Threshold", m_nThreshold );
-
-        m_aHandlerHelper.setIsInitialized();
-    }
-
-
     OUString SAL_CALL ConsoleHandler::getImplementationName() throw(RuntimeException, std::exception)
     {
-        return getImplementationName_static();
+        return OUString("com.sun.star.comp.extensions.ConsoleHandler");
     }
 
-
     sal_Bool SAL_CALL ConsoleHandler::supportsService( const OUString& _rServiceName ) throw(RuntimeException, std::exception)
     {
         return cppu::supportsService(this, _rServiceName);
     }
 
-
     Sequence< OUString > SAL_CALL ConsoleHandler::getSupportedServiceNames() throw(RuntimeException, std::exception)
     {
-        return getSupportedServiceNames_static();
+        return { "com.sun.star.logging.ConsoleHandler" };
     }
 
-
-    OUString SAL_CALL ConsoleHandler::getImplementationName_static()
-    {
-        return OUString( "com.sun.star.comp.extensions.ConsoleHandler" );
-    }
-
-
-    Sequence< OUString > SAL_CALL ConsoleHandler::getSupportedServiceNames_static()
-    {
-        Sequence< OUString > aServiceNames { "com.sun.star.logging.ConsoleHandler" };
-        return aServiceNames;
-    }
-
-
-    Reference< XInterface > ConsoleHandler::Create( const Reference< XComponentContext >& _rxContext )
-    {
-        return *( new ConsoleHandler( _rxContext ) );
-    }
-
-
-    void createRegistryInfo_ConsoleHandler()
-    {
-        static OAutoRegistration< ConsoleHandler > aAutoRegistration;
-    }
-
-
 } // namespace logging
 
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
+com_sun_star_comp_extensions_ConsoleHandler(
+    css::uno::XComponentContext *context,
+    css::uno::Sequence<css::uno::Any> const &arguments)
+{
+    return cppu::acquire(new logging::ConsoleHandler(context, arguments));
+}
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/logging/log.component b/extensions/source/logging/log.component
index bb5f262..4cd5a55 100644
--- a/extensions/source/logging/log.component
+++ b/extensions/source/logging/log.component
@@ -19,7 +19,8 @@
 
 <component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@"
     prefix="log" xmlns="http://openoffice.org/2010/uno-components">
-  <implementation name="com.sun.star.comp.extensions.ConsoleHandler">
+  <implementation name="com.sun.star.comp.extensions.ConsoleHandler"
+      constructor="com_sun_star_comp_extensions_ConsoleHandler">
     <service name="com.sun.star.logging.ConsoleHandler"/>
   </implementation>
   <implementation name="com.sun.star.comp.extensions.CsvFormatter">
diff --git a/extensions/source/logging/log_services.cxx b/extensions/source/logging/log_services.cxx
index f20c735..d2599a0 100644
--- a/extensions/source/logging/log_services.cxx
+++ b/extensions/source/logging/log_services.cxx
@@ -25,7 +25,6 @@ namespace logging
     static void initializeModule()
     {
         ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
-        createRegistryInfo_ConsoleHandler();
         createRegistryInfo_PlainTextFormatter();
         createRegistryInfo_CsvFormatter();
     }
diff --git a/extensions/source/logging/log_services.hxx b/extensions/source/logging/log_services.hxx
index 0aca8b5..17c5ec9 100644
--- a/extensions/source/logging/log_services.hxx
+++ b/extensions/source/logging/log_services.hxx
@@ -24,7 +24,6 @@
 
 namespace logging {
 
-void createRegistryInfo_ConsoleHandler();
 void createRegistryInfo_PlainTextFormatter();
 void createRegistryInfo_CsvFormatter();
 
commit 3bda8734f88b9c86fc9d5cfa83580844eeaf2221
Author: Matúš Kukan <matus.kukan at gmail.com>
Date:   Mon Dec 28 20:06:38 2015 +0100

    tdf#74608: Ctor function for logging::FileHandler
    
    Change-Id: I3c9e0c33f63a82f9dc172adde6351abbc822fb9e

diff --git a/extensions/source/logging/filehandler.cxx b/extensions/source/logging/filehandler.cxx
index 52c4c36..686ccb6 100644
--- a/extensions/source/logging/filehandler.cxx
+++ b/extensions/source/logging/filehandler.cxx
@@ -17,16 +17,13 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <sal/config.h>
 
-#include "log_module.hxx"
-#include "log_services.hxx"
 #include "methodguard.hxx"
 #include "loghandler.hxx"
 
 #include <com/sun/star/logging/XLogHandler.hpp>
 #include <com/sun/star/lang/XServiceInfo.hpp>
-#include <com/sun/star/ucb/AlreadyInitializedException.hpp>
-#include <com/sun/star/lang/XInitialization.hpp>
 #include <com/sun/star/lang/IllegalArgumentException.hpp>
 #include <com/sun/star/util/PathSubstitution.hpp>
 #include <com/sun/star/util/XStringSubstitution.hpp>
@@ -39,16 +36,12 @@
 
 #include <osl/thread.h>
 #include <osl/file.hxx>
-
 #include <rtl/strbuf.hxx>
 
 #include <memory>
 
-
 namespace logging
 {
-
-
     using ::com::sun::star::uno::Reference;
     using ::com::sun::star::logging::LogRecord;
     using ::com::sun::star::uno::RuntimeException;
@@ -58,19 +51,14 @@ namespace logging
     using ::com::sun::star::uno::XComponentContext;
     using ::com::sun::star::logging::XLogHandler;
     using ::com::sun::star::lang::XServiceInfo;
-    using ::com::sun::star::ucb::AlreadyInitializedException;
-    using ::com::sun::star::lang::XInitialization;
-    using ::com::sun::star::uno::Any;
     using ::com::sun::star::uno::Exception;
     using ::com::sun::star::lang::IllegalArgumentException;
-    using ::com::sun::star::uno::UNO_QUERY_THROW;
     using ::com::sun::star::util::PathSubstitution;
     using ::com::sun::star::util::XStringSubstitution;
     using ::com::sun::star::beans::NamedValue;
 
     typedef ::cppu::WeakComponentImplHelper    <   XLogHandler
                                                 ,   XServiceInfo
-                                                ,   XInitialization
                                                 >   FileHandler_Base;
     class FileHandler   :public ::cppu::BaseMutex
                         ,public FileHandler_Base
@@ -86,17 +74,18 @@ namespace logging
             eInvalid
         };
 
-    private:
         Reference<XComponentContext>    m_xContext;
         LogHandlerHelper                m_aHandlerHelper;
         OUString                 m_sFileURL;
         ::std::unique_ptr< ::osl::File >  m_pFile;
         FileValidity                    m_eFileValidity;
 
-    protected:
-        explicit FileHandler( const Reference< XComponentContext >& _rxContext );
+    public:
+        FileHandler(const css::uno::Reference<XComponentContext> &context,
+                const css::uno::Sequence<css::uno::Any> &arguments);
         virtual ~FileHandler();
 
+    private:
         // XLogHandler
         virtual OUString SAL_CALL getEncoding() throw (RuntimeException, std::exception) override;
         virtual void SAL_CALL setEncoding( const OUString& _encoding ) throw (RuntimeException, std::exception) override;
@@ -107,9 +96,6 @@ namespace logging
         virtual void SAL_CALL flush(  ) throw (RuntimeException, std::exception) override;
         virtual sal_Bool SAL_CALL publish( const LogRecord& Record ) throw (RuntimeException, std::exception) override;
 
-        // XInitialization
-        virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) throw (css::uno::Exception, css::uno::RuntimeException, std::exception) override;
-
         // XServiceInfo
         virtual OUString SAL_CALL getImplementationName() throw(RuntimeException, std::exception) override;
         virtual sal_Bool SAL_CALL supportsService( const OUString& _rServiceName ) throw(RuntimeException, std::exception) override;
@@ -119,12 +105,6 @@ namespace logging
         virtual void SAL_CALL disposing() override;
 
     public:
-        // XServiceInfo - static version
-        static OUString SAL_CALL getImplementationName_static();
-        static Sequence< OUString > SAL_CALL getSupportedServiceNames_static();
-        static Reference< XInterface > Create( const Reference< XComponentContext >& _rxContext );
-
-    public:
         typedef ComponentMethodGuard< FileHandler > MethodGuard;
         void    enterMethod( MethodGuard::Access );
         void    leaveMethod( MethodGuard::Access );
@@ -142,16 +122,40 @@ namespace logging
         void    impl_doStringsubstitution_nothrow( OUString& _inout_rURL );
     };
 
-    FileHandler::FileHandler( const Reference< XComponentContext >& _rxContext )
+    FileHandler::FileHandler(const css::uno::Reference<XComponentContext> &context,
+            const css::uno::Sequence<css::uno::Any> &arguments)
         :FileHandler_Base( m_aMutex )
-        ,m_xContext( _rxContext )
-        ,m_aHandlerHelper( _rxContext, m_aMutex, rBHelper )
+        ,m_xContext( context )
+        ,m_aHandlerHelper( context, m_aMutex, rBHelper )
         ,m_sFileURL( )
         ,m_pFile( )
         ,m_eFileValidity( eUnknown )
     {
-    }
+        ::osl::MutexGuard aGuard( m_aMutex );
 
+        if ( arguments.getLength() != 1 )
+            throw IllegalArgumentException( OUString(), *this, 1 );
+
+        Sequence< NamedValue > aSettings;
+        if ( arguments[0] >>= m_sFileURL )
+        {
+            // create( [in] string URL );
+            impl_doStringsubstitution_nothrow( m_sFileURL );
+        }
+        else if ( arguments[0] >>= aSettings )
+        {
+            // createWithSettings( [in] sequence< css::beans::NamedValue > Settings )
+            ::comphelper::NamedValueCollection aTypedSettings( aSettings );
+            m_aHandlerHelper.initFromSettings( aTypedSettings );
+
+            if ( aTypedSettings.get_ensureType( "FileURL", m_sFileURL ) )
+                impl_doStringsubstitution_nothrow( m_sFileURL );
+        }
+        else
+            throw IllegalArgumentException( OUString(), *this, 1 );
+
+        m_aHandlerHelper.setIsInitialized();
+    }
 
     FileHandler::~FileHandler()
     {
@@ -328,42 +332,9 @@ namespace logging
         return sal_True;
     }
 
-
-    void SAL_CALL FileHandler::initialize( const Sequence< Any >& _rArguments ) throw (Exception, RuntimeException, std::exception)
-    {
-        ::osl::MutexGuard aGuard( m_aMutex );
-
-        if ( m_aHandlerHelper.getIsInitialized() )
-            throw AlreadyInitializedException();
-
-        if ( _rArguments.getLength() != 1 )
-            throw IllegalArgumentException( OUString(), *this, 1 );
-
-        Sequence< NamedValue > aSettings;
-        if ( _rArguments[0] >>= m_sFileURL )
-        {
-            // create( [in] string URL );
-            impl_doStringsubstitution_nothrow( m_sFileURL );
-        }
-        else if ( _rArguments[0] >>= aSettings )
-        {
-            // createWithSettings( [in] sequence< css::beans::NamedValue > Settings )
-            ::comphelper::NamedValueCollection aTypedSettings( aSettings );
-            m_aHandlerHelper.initFromSettings( aTypedSettings );
-
-            if ( aTypedSettings.get_ensureType( "FileURL", m_sFileURL ) )
-                impl_doStringsubstitution_nothrow( m_sFileURL );
-        }
-        else
-            throw IllegalArgumentException( OUString(), *this, 1 );
-
-        m_aHandlerHelper.setIsInitialized();
-    }
-
-
     OUString SAL_CALL FileHandler::getImplementationName() throw(RuntimeException, std::exception)
     {
-        return getImplementationName_static();
+        return OUString("com.sun.star.comp.extensions.FileHandler");
     }
 
     sal_Bool SAL_CALL FileHandler::supportsService( const OUString& _rServiceName ) throw(RuntimeException, std::exception)
@@ -371,39 +342,19 @@ namespace logging
         return cppu::supportsService(this, _rServiceName);
     }
 
-
     Sequence< OUString > SAL_CALL FileHandler::getSupportedServiceNames() throw(RuntimeException, std::exception)
     {
-        return getSupportedServiceNames_static();
-    }
-
-
-    OUString SAL_CALL FileHandler::getImplementationName_static()
-    {
-        return OUString( "com.sun.star.comp.extensions.FileHandler" );
+        return { "com.sun.star.logging.FileHandler" };
     }
 
-
-    Sequence< OUString > SAL_CALL FileHandler::getSupportedServiceNames_static()
-    {
-        Sequence< OUString > aServiceNames { "com.sun.star.logging.FileHandler" };
-        return aServiceNames;
-    }
-
-
-    Reference< XInterface > FileHandler::Create( const Reference< XComponentContext >& _rxContext )
-    {
-        return *( new FileHandler( _rxContext ) );
-    }
-
-
-    void createRegistryInfo_FileHandler()
-    {
-        static OAutoRegistration< FileHandler > aAutoRegistration;
-    }
-
-
 } // namespace logging
 
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
+com_sun_star_comp_extensions_FileHandler(
+    css::uno::XComponentContext *context,
+    css::uno::Sequence<css::uno::Any> const &arguments)
+{
+    return cppu::acquire(new logging::FileHandler(context, arguments));
+}
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/extensions/source/logging/log.component b/extensions/source/logging/log.component
index 38f4a73..bb5f262 100644
--- a/extensions/source/logging/log.component
+++ b/extensions/source/logging/log.component
@@ -25,7 +25,8 @@
   <implementation name="com.sun.star.comp.extensions.CsvFormatter">
     <service name="com.sun.star.logging.CsvFormatter"/>
   </implementation>
-  <implementation name="com.sun.star.comp.extensions.FileHandler">
+  <implementation name="com.sun.star.comp.extensions.FileHandler"
+      constructor="com_sun_star_comp_extensions_FileHandler">
     <service name="com.sun.star.logging.FileHandler"/>
   </implementation>
   <implementation name="com.sun.star.comp.extensions.LoggerPool"
diff --git a/extensions/source/logging/log_services.cxx b/extensions/source/logging/log_services.cxx
index f4f3e68..f20c735 100644
--- a/extensions/source/logging/log_services.cxx
+++ b/extensions/source/logging/log_services.cxx
@@ -25,7 +25,6 @@ namespace logging
     static void initializeModule()
     {
         ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
-        createRegistryInfo_FileHandler();
         createRegistryInfo_ConsoleHandler();
         createRegistryInfo_PlainTextFormatter();
         createRegistryInfo_CsvFormatter();
diff --git a/extensions/source/logging/log_services.hxx b/extensions/source/logging/log_services.hxx
index 237bea4..0aca8b5 100644
--- a/extensions/source/logging/log_services.hxx
+++ b/extensions/source/logging/log_services.hxx
@@ -24,7 +24,6 @@
 
 namespace logging {
 
-void createRegistryInfo_FileHandler();
 void createRegistryInfo_ConsoleHandler();
 void createRegistryInfo_PlainTextFormatter();
 void createRegistryInfo_CsvFormatter();
commit 11c9bad89d6582b5bf5c2d47a42afc5c2758fa63
Author: Matúš Kukan <matus.kukan at gmail.com>
Date:   Sun Dec 27 14:02:55 2015 +0100

    tdf#74608: Constructor function for LoggerPool singleton
    
    + EventLogger is not an UNO service - does not need XServiceInfo
    
    Change-Id: I1b4fed4dfe0fb5f453d521f2902cb65ace586cfb

diff --git a/extensions/source/logging/log.component b/extensions/source/logging/log.component
index 8352c91..38f4a73 100644
--- a/extensions/source/logging/log.component
+++ b/extensions/source/logging/log.component
@@ -28,7 +28,8 @@
   <implementation name="com.sun.star.comp.extensions.FileHandler">
     <service name="com.sun.star.logging.FileHandler"/>
   </implementation>
-  <implementation name="com.sun.star.comp.extensions.LoggerPool">
+  <implementation name="com.sun.star.comp.extensions.LoggerPool"
+      constructor="com_sun_star_comp_extensions_LoggerPool">
     <singleton name="com.sun.star.logging.LoggerPool"/>
   </implementation>
   <implementation name="com.sun.star.comp.extensions.PlainTextFormatter">
diff --git a/extensions/source/logging/log_services.cxx b/extensions/source/logging/log_services.cxx
index 1b667d7..f4f3e68 100644
--- a/extensions/source/logging/log_services.cxx
+++ b/extensions/source/logging/log_services.cxx
@@ -25,7 +25,6 @@ namespace logging
     static void initializeModule()
     {
         ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
-        createRegistryInfo_LoggerPool();
         createRegistryInfo_FileHandler();
         createRegistryInfo_ConsoleHandler();
         createRegistryInfo_PlainTextFormatter();
diff --git a/extensions/source/logging/log_services.hxx b/extensions/source/logging/log_services.hxx
index bdca2d5..237bea4 100644
--- a/extensions/source/logging/log_services.hxx
+++ b/extensions/source/logging/log_services.hxx
@@ -24,7 +24,6 @@
 
 namespace logging {
 
-void createRegistryInfo_LoggerPool();
 void createRegistryInfo_FileHandler();
 void createRegistryInfo_ConsoleHandler();
 void createRegistryInfo_PlainTextFormatter();
diff --git a/extensions/source/logging/logger.cxx b/extensions/source/logging/logger.cxx
index e9b2944..ee3c4b8 100644
--- a/extensions/source/logging/logger.cxx
+++ b/extensions/source/logging/logger.cxx
@@ -18,8 +18,6 @@
  */
 
 
-#include "log_module.hxx"
-#include "log_services.hxx"
 #include "logrecord.hxx"
 #include "loggerconfig.hxx"
 
@@ -34,6 +32,7 @@
 #include <cppuhelper/implbase.hxx>
 #include <cppuhelper/supportsservice.hxx>
 #include <cppuhelper/weakref.hxx>
+#include <rtl/ref.hxx>
 #include <map>
 
 
@@ -47,24 +46,17 @@ namespace logging
     using ::com::sun::star::uno::RuntimeException;
     using ::com::sun::star::uno::Sequence;
     using ::com::sun::star::uno::XInterface;
-    using ::com::sun::star::uno::UNO_QUERY_THROW;
     using ::com::sun::star::uno::Any;
     using ::com::sun::star::uno::Exception;
     using ::com::sun::star::uno::WeakReference;
     using ::com::sun::star::logging::XLogHandler;
-    using ::com::sun::star::logging::XLoggerPool;
     using ::com::sun::star::logging::LogRecord;
 
-    namespace LogLevel = ::com::sun::star::logging::LogLevel;
-
-    typedef ::cppu::WeakImplHelper <   XLogger
-                                    ,   XServiceInfo
-                                    >   EventLogger_Base;
-    class EventLogger   :public ::cppu::BaseMutex
-                        ,public EventLogger_Base
+    class EventLogger : public cppu::BaseMutex,
+                        public cppu::WeakImplHelper<css::logging::XLogger>
     {
     private:
-        ::cppu::OInterfaceContainerHelper   m_aHandlers;
+        cppu::OInterfaceContainerHelper     m_aHandlers;
         oslInterlockedCount                 m_nEventNumber;
 
         // <attributes>
@@ -75,11 +67,6 @@ namespace logging
     public:
         EventLogger( const Reference< XComponentContext >& _rxContext, const OUString& _rName );
 
-        // XServiceInfo
-        virtual OUString SAL_CALL getImplementationName() throw(RuntimeException, std::exception) override;
-        virtual sal_Bool SAL_CALL supportsService( const OUString& _rServiceName ) throw(RuntimeException, std::exception) override;
-        virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() throw(RuntimeException, std::exception) override;
-
         // XLogger
         virtual OUString SAL_CALL getName() throw (RuntimeException, std::exception) override;
         virtual ::sal_Int32 SAL_CALL getLevel() throw (RuntimeException, std::exception) override;
@@ -103,21 +90,15 @@ namespace logging
         bool    impl_nts_isLoggable_nothrow( ::sal_Int32 _nLevel );
     };
 
-    typedef ::cppu::WeakImplHelper <   XLoggerPool
-                                    ,   XServiceInfo
-                                    >   LoggerPool_Base;
     /** administrates a pool of XLogger instances, where a logger is keyed by its name,
         and subsequent requests for a logger with the same name return the same instance.
     */
-    class LoggerPool : public LoggerPool_Base
+    class LoggerPool : public cppu::WeakImplHelper<css::logging::XLoggerPool, XServiceInfo>
     {
     private:
-        typedef ::std::map< OUString, WeakReference< XLogger > > ImplPool;
-
-    private:
         ::osl::Mutex                    m_aMutex;
         Reference<XComponentContext>    m_xContext;
-        ImplPool                        m_aImpl;
+        std::map< OUString, WeakReference<XLogger> > m_aLoggerMap;
 
     public:
         explicit LoggerPool( const Reference< XComponentContext >& _rxContext );
@@ -127,12 +108,6 @@ namespace logging
         virtual sal_Bool SAL_CALL supportsService( const OUString& _rServiceName ) throw(RuntimeException, std::exception) override;
         virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() throw(RuntimeException, std::exception) override;
 
-        // helper for factories
-        static Sequence< OUString > getSupportedServiceNames_static();
-        static OUString  getImplementationName_static();
-        static OUString  getSingletonName_static();
-        static Reference< XInterface > Create( const Reference< XComponentContext >& _rxContext );
-
         // XLoggerPool
         virtual Reference< XLogger > SAL_CALL getNamedLogger( const OUString& Name ) throw (RuntimeException, std::exception) override;
         virtual Reference< XLogger > SAL_CALL getDefaultLogger(  ) throw (RuntimeException, std::exception) override;
@@ -141,7 +116,7 @@ namespace logging
     EventLogger::EventLogger( const Reference< XComponentContext >& _rxContext, const OUString& _rName )
         :m_aHandlers( m_aMutex )
         ,m_nEventNumber( 0 )
-        ,m_nLogLevel( LogLevel::OFF )
+        ,m_nLogLevel( css::logging::LogLevel::OFF )
         ,m_sName( _rName )
     {
         osl_atomic_increment( &m_refCount );
@@ -236,22 +211,6 @@ namespace logging
         ) );
     }
 
-    OUString SAL_CALL EventLogger::getImplementationName() throw(RuntimeException, std::exception)
-    {
-        return OUString( "com.sun.star.comp.extensions.EventLogger" );
-    }
-
-    sal_Bool EventLogger::supportsService( const OUString& _rServiceName ) throw(RuntimeException, std::exception)
-    {
-        return cppu::supportsService(this, _rServiceName);
-    }
-
-    Sequence< OUString > SAL_CALL EventLogger::getSupportedServiceNames() throw(RuntimeException, std::exception)
-    {
-        Sequence< OUString > aServiceNames { "com.sun.star.logging.Logger" };
-        return aServiceNames;
-    }
-
     LoggerPool::LoggerPool( const Reference< XComponentContext >& _rxContext )
         :m_xContext( _rxContext )
     {
@@ -259,7 +218,7 @@ namespace logging
 
     OUString SAL_CALL LoggerPool::getImplementationName() throw(RuntimeException, std::exception)
     {
-        return getImplementationName_static();
+        return OUString("com.sun.star.comp.extensions.LoggerPool");
     }
 
     sal_Bool SAL_CALL LoggerPool::supportsService( const OUString& _rServiceName ) throw(RuntimeException, std::exception)
@@ -269,35 +228,14 @@ namespace logging
 
     Sequence< OUString > SAL_CALL LoggerPool::getSupportedServiceNames() throw(RuntimeException, std::exception)
     {
-        return getSupportedServiceNames_static();
-    }
-
-    OUString SAL_CALL LoggerPool::getImplementationName_static()
-    {
-        return OUString( "com.sun.star.comp.extensions.LoggerPool" );
-    }
-
-    Sequence< OUString > SAL_CALL LoggerPool::getSupportedServiceNames_static()
-    {
-        Sequence< OUString > aServiceNames { getSingletonName_static() };
-        return aServiceNames;
-    }
-
-    OUString LoggerPool::getSingletonName_static()
-    {
-        return OUString( "com.sun.star.logging.LoggerPool" );
-    }
-
-    Reference< XInterface > SAL_CALL LoggerPool::Create( const Reference< XComponentContext >& _rxContext )
-    {
-        return *( new LoggerPool( _rxContext ) );
+        return { "com.sun.star.logging.LoggerPool" };
     }
 
     Reference< XLogger > SAL_CALL LoggerPool::getNamedLogger( const OUString& _rName ) throw (RuntimeException, std::exception)
     {
         ::osl::MutexGuard aGuard( m_aMutex );
 
-        WeakReference< XLogger >& rLogger( m_aImpl[ _rName ] );
+        WeakReference< XLogger >& rLogger( m_aLoggerMap[ _rName ] );
         Reference< XLogger > xLogger( rLogger );
         if ( !xLogger.is() )
         {
@@ -314,11 +252,33 @@ namespace logging
         return getNamedLogger( "org.openoffice.logging.DefaultLogger" );
     }
 
-    void createRegistryInfo_LoggerPool()
-    {
-        static OSingletonRegistration< LoggerPool > aAutoRegistration;
-    }
-
 } // namespace logging
 
+namespace {
+
+struct Instance {
+    explicit Instance(
+        css::uno::Reference<css::uno::XComponentContext> const & context):
+        instance(static_cast<cppu::OWeakObject *>(new logging::LoggerPool(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_extensions_LoggerPool(
+    css::uno::XComponentContext *context,
+    css::uno::Sequence<css::uno::Any> const &)
+{
+    return cppu::acquire(static_cast<cppu::OWeakObject *>(
+                Singleton::get(context).instance.get()));
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list