From 42ab260e502c29034d4deb0c4a5a29d7a34c7b96 Mon Sep 17 00:00:00 2001 From: Matúš Kukan Date: Mon, 28 Dec 2015 20:23:48 +0100 Subject: tdf#74608: Ctor function for logging::CsvFormatter Change-Id: I3383e02a7162cc8dbce3ba0b04fac6dec3492d94 --- extensions/source/logging/csvformatter.cxx | 69 ++++++++---------------------- extensions/source/logging/log.component | 3 +- extensions/source/logging/log_services.cxx | 1 - extensions/source/logging/log_services.hxx | 1 - 4 files changed, 19 insertions(+), 55 deletions(-) (limited to 'extensions') diff --git a/extensions/source/logging/csvformatter.cxx b/extensions/source/logging/csvformatter.cxx index 708dfbc71726..3b358d3d7ab6 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 -#include +#include #include #include @@ -33,40 +28,28 @@ #include #include - #include +#include +#include + 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 { 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 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 4cd5a553be2d..3f9ad05e073d 100644 --- a/extensions/source/logging/log.component +++ b/extensions/source/logging/log.component @@ -23,7 +23,8 @@ constructor="com_sun_star_comp_extensions_ConsoleHandler"> - +