Kaydet (Commit) 8ef77fc6 authored tarafından Alexandre Vicenzi's avatar Alexandre Vicenzi Kaydeden (comit) Marcos Souza

fdo#54938 Convert extensions to cppu::supportsService

Change-Id: If3675c28a204168d7385b1421dbb70b2a9b719e2
Reviewed-on: https://gerrit.libreoffice.org/7648Tested-by: 's avatarLibreOffice gerrit bot <gerrit@libreoffice.org>
Reviewed-by: 's avatarMarcos Souza <marcos.souza.org@gmail.com>
Tested-by: 's avatarMarcos Souza <marcos.souza.org@gmail.com>
üst cd20baf4
...@@ -28,19 +28,17 @@ ...@@ -28,19 +28,17 @@
#include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/logging/XLoggerPool.hpp> #include <com/sun/star/logging/XLoggerPool.hpp>
#include <boost/bind.hpp>
#include <cppuhelper/basemutex.hxx> #include <cppuhelper/basemutex.hxx>
#include <cppuhelper/interfacecontainer.hxx> #include <cppuhelper/interfacecontainer.hxx>
#include <cppuhelper/implbase2.hxx> #include <cppuhelper/implbase2.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <cppuhelper/weakref.hxx> #include <cppuhelper/weakref.hxx>
#include <boost/bind.hpp>
#include <map> #include <map>
//........................................................................
namespace logging namespace logging
{ {
//........................................................................
using ::com::sun::star::logging::XLogger; using ::com::sun::star::logging::XLogger;
using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Reference;
...@@ -59,27 +57,6 @@ namespace logging ...@@ -59,27 +57,6 @@ namespace logging
namespace LogLevel = ::com::sun::star::logging::LogLevel; namespace LogLevel = ::com::sun::star::logging::LogLevel;
//====================================================================
//= helper
//====================================================================
namespace
{
sal_Bool lcl_supportsService_nothrow( XServiceInfo& _rSI, const OUString& _rServiceName )
{
const Sequence< OUString > aServiceNames( _rSI.getSupportedServiceNames() );
for ( const OUString* pServiceNames = aServiceNames.getConstArray();
pServiceNames != aServiceNames.getConstArray() + aServiceNames.getLength();
++pServiceNames
)
if ( _rServiceName == *pServiceNames )
return sal_True;
return sal_False;
}
}
//====================================================================
//= EventLogger - declaration
//====================================================================
typedef ::cppu::WeakImplHelper2 < XLogger typedef ::cppu::WeakImplHelper2 < XLogger
, XServiceInfo , XServiceInfo
> EventLogger_Base; > EventLogger_Base;
...@@ -126,9 +103,6 @@ namespace logging ...@@ -126,9 +103,6 @@ namespace logging
bool impl_nts_isLoggable_nothrow( ::sal_Int32 _nLevel ); bool impl_nts_isLoggable_nothrow( ::sal_Int32 _nLevel );
}; };
//====================================================================
//= LoggerPool - declaration
//====================================================================
typedef ::cppu::WeakImplHelper2 < XLoggerPool typedef ::cppu::WeakImplHelper2 < XLoggerPool
, XServiceInfo , XServiceInfo
> LoggerPool_Base; > LoggerPool_Base;
...@@ -164,10 +138,6 @@ namespace logging ...@@ -164,10 +138,6 @@ namespace logging
virtual Reference< XLogger > SAL_CALL getDefaultLogger( ) throw (RuntimeException); virtual Reference< XLogger > SAL_CALL getDefaultLogger( ) throw (RuntimeException);
}; };
//====================================================================
//= EventLogger - implementation
//====================================================================
//--------------------------------------------------------------------
EventLogger::EventLogger( const Reference< XComponentContext >& _rxContext, const OUString& _rName ) EventLogger::EventLogger( const Reference< XComponentContext >& _rxContext, const OUString& _rName )
:m_aHandlers( m_aMutex ) :m_aHandlers( m_aMutex )
,m_nEventNumber( 0 ) ,m_nEventNumber( 0 )
...@@ -181,12 +151,10 @@ namespace logging ...@@ -181,12 +151,10 @@ namespace logging
osl_atomic_decrement( &m_refCount ); osl_atomic_decrement( &m_refCount );
} }
//--------------------------------------------------------------------
EventLogger::~EventLogger() EventLogger::~EventLogger()
{ {
} }
//--------------------------------------------------------------------
bool EventLogger::impl_nts_isLoggable_nothrow( ::sal_Int32 _nLevel ) bool EventLogger::impl_nts_isLoggable_nothrow( ::sal_Int32 _nLevel )
{ {
if ( _nLevel < m_nLogLevel ) if ( _nLevel < m_nLogLevel )
...@@ -198,7 +166,6 @@ namespace logging ...@@ -198,7 +166,6 @@ namespace logging
return true; return true;
} }
//--------------------------------------------------------------------
void EventLogger::impl_ts_logEvent_nothrow( const LogRecord& _rRecord ) void EventLogger::impl_ts_logEvent_nothrow( const LogRecord& _rRecord )
{ {
::osl::MutexGuard aGuard( m_aMutex ); ::osl::MutexGuard aGuard( m_aMutex );
...@@ -212,48 +179,41 @@ namespace logging ...@@ -212,48 +179,41 @@ namespace logging
::boost::bind( &XLogHandler::flush, _1 ) ); ::boost::bind( &XLogHandler::flush, _1 ) );
} }
//--------------------------------------------------------------------
OUString SAL_CALL EventLogger::getName() throw (RuntimeException) OUString SAL_CALL EventLogger::getName() throw (RuntimeException)
{ {
return m_sName; return m_sName;
} }
//--------------------------------------------------------------------
::sal_Int32 SAL_CALL EventLogger::getLevel() throw (RuntimeException) ::sal_Int32 SAL_CALL EventLogger::getLevel() throw (RuntimeException)
{ {
::osl::MutexGuard aGuard( m_aMutex ); ::osl::MutexGuard aGuard( m_aMutex );
return m_nLogLevel; return m_nLogLevel;
} }
//--------------------------------------------------------------------
void SAL_CALL EventLogger::setLevel( ::sal_Int32 _level ) throw (RuntimeException) void SAL_CALL EventLogger::setLevel( ::sal_Int32 _level ) throw (RuntimeException)
{ {
::osl::MutexGuard aGuard( m_aMutex ); ::osl::MutexGuard aGuard( m_aMutex );
m_nLogLevel = _level; m_nLogLevel = _level;
} }
//--------------------------------------------------------------------
void SAL_CALL EventLogger::addLogHandler( const Reference< XLogHandler >& _rxLogHandler ) throw (RuntimeException) void SAL_CALL EventLogger::addLogHandler( const Reference< XLogHandler >& _rxLogHandler ) throw (RuntimeException)
{ {
if ( _rxLogHandler.is() ) if ( _rxLogHandler.is() )
m_aHandlers.addInterface( _rxLogHandler ); m_aHandlers.addInterface( _rxLogHandler );
} }
//--------------------------------------------------------------------
void SAL_CALL EventLogger::removeLogHandler( const Reference< XLogHandler >& _rxLogHandler ) throw (RuntimeException) void SAL_CALL EventLogger::removeLogHandler( const Reference< XLogHandler >& _rxLogHandler ) throw (RuntimeException)
{ {
if ( _rxLogHandler.is() ) if ( _rxLogHandler.is() )
m_aHandlers.removeInterface( _rxLogHandler ); m_aHandlers.removeInterface( _rxLogHandler );
} }
//--------------------------------------------------------------------
::sal_Bool SAL_CALL EventLogger::isLoggable( ::sal_Int32 _nLevel ) throw (RuntimeException) ::sal_Bool SAL_CALL EventLogger::isLoggable( ::sal_Int32 _nLevel ) throw (RuntimeException)
{ {
::osl::MutexGuard aGuard( m_aMutex ); ::osl::MutexGuard aGuard( m_aMutex );
return impl_nts_isLoggable_nothrow( _nLevel ); return impl_nts_isLoggable_nothrow( _nLevel );
} }
//--------------------------------------------------------------------
void SAL_CALL EventLogger::log( ::sal_Int32 _nLevel, const OUString& _rMessage ) throw (RuntimeException) void SAL_CALL EventLogger::log( ::sal_Int32 _nLevel, const OUString& _rMessage ) throw (RuntimeException)
{ {
impl_ts_logEvent_nothrow( createLogRecord( impl_ts_logEvent_nothrow( createLogRecord(
...@@ -264,7 +224,6 @@ namespace logging ...@@ -264,7 +224,6 @@ namespace logging
) ); ) );
} }
//--------------------------------------------------------------------
void SAL_CALL EventLogger::logp( ::sal_Int32 _nLevel, const OUString& _rSourceClass, const OUString& _rSourceMethod, const OUString& _rMessage ) throw (RuntimeException) void SAL_CALL EventLogger::logp( ::sal_Int32 _nLevel, const OUString& _rSourceClass, const OUString& _rSourceMethod, const OUString& _rMessage ) throw (RuntimeException)
{ {
impl_ts_logEvent_nothrow( createLogRecord( impl_ts_logEvent_nothrow( createLogRecord(
...@@ -277,19 +236,16 @@ namespace logging ...@@ -277,19 +236,16 @@ namespace logging
) ); ) );
} }
//--------------------------------------------------------------------
OUString SAL_CALL EventLogger::getImplementationName() throw(RuntimeException) OUString SAL_CALL EventLogger::getImplementationName() throw(RuntimeException)
{ {
return OUString( "com.sun.star.comp.extensions.EventLogger" ); return OUString( "com.sun.star.comp.extensions.EventLogger" );
} }
//--------------------------------------------------------------------
::sal_Bool EventLogger::supportsService( const OUString& _rServiceName ) throw(RuntimeException) ::sal_Bool EventLogger::supportsService( const OUString& _rServiceName ) throw(RuntimeException)
{ {
return lcl_supportsService_nothrow( *this, _rServiceName ); return cppu::supportsService(this, _rServiceName);
} }
//--------------------------------------------------------------------
Sequence< OUString > SAL_CALL EventLogger::getSupportedServiceNames() throw(RuntimeException) Sequence< OUString > SAL_CALL EventLogger::getSupportedServiceNames() throw(RuntimeException)
{ {
Sequence< OUString > aServiceNames(1); Sequence< OUString > aServiceNames(1);
...@@ -297,40 +253,31 @@ namespace logging ...@@ -297,40 +253,31 @@ namespace logging
return aServiceNames; return aServiceNames;
} }
//====================================================================
//= LoggerPool - implementation
//====================================================================
//--------------------------------------------------------------------
LoggerPool::LoggerPool( const Reference< XComponentContext >& _rxContext ) LoggerPool::LoggerPool( const Reference< XComponentContext >& _rxContext )
:m_xContext( _rxContext ) :m_xContext( _rxContext )
{ {
} }
//--------------------------------------------------------------------
OUString SAL_CALL LoggerPool::getImplementationName() throw(RuntimeException) OUString SAL_CALL LoggerPool::getImplementationName() throw(RuntimeException)
{ {
return getImplementationName_static(); return getImplementationName_static();
} }
//--------------------------------------------------------------------
::sal_Bool SAL_CALL LoggerPool::supportsService( const OUString& _rServiceName ) throw(RuntimeException) ::sal_Bool SAL_CALL LoggerPool::supportsService( const OUString& _rServiceName ) throw(RuntimeException)
{ {
return lcl_supportsService_nothrow( *this, _rServiceName ); return cppu::supportsService(this, _rServiceName);
} }
//--------------------------------------------------------------------
Sequence< OUString > SAL_CALL LoggerPool::getSupportedServiceNames() throw(RuntimeException) Sequence< OUString > SAL_CALL LoggerPool::getSupportedServiceNames() throw(RuntimeException)
{ {
return getSupportedServiceNames_static(); return getSupportedServiceNames_static();
} }
//--------------------------------------------------------------------
OUString SAL_CALL LoggerPool::getImplementationName_static() OUString SAL_CALL LoggerPool::getImplementationName_static()
{ {
return OUString( "com.sun.star.comp.extensions.LoggerPool" ); return OUString( "com.sun.star.comp.extensions.LoggerPool" );
} }
//--------------------------------------------------------------------
Sequence< OUString > SAL_CALL LoggerPool::getSupportedServiceNames_static() Sequence< OUString > SAL_CALL LoggerPool::getSupportedServiceNames_static()
{ {
Sequence< OUString > aServiceNames(1); Sequence< OUString > aServiceNames(1);
...@@ -338,19 +285,16 @@ namespace logging ...@@ -338,19 +285,16 @@ namespace logging
return aServiceNames; return aServiceNames;
} }
//--------------------------------------------------------------------
OUString LoggerPool::getSingletonName_static() OUString LoggerPool::getSingletonName_static()
{ {
return OUString( "com.sun.star.logging.LoggerPool" ); return OUString( "com.sun.star.logging.LoggerPool" );
} }
//--------------------------------------------------------------------
Reference< XInterface > SAL_CALL LoggerPool::Create( const Reference< XComponentContext >& _rxContext ) Reference< XInterface > SAL_CALL LoggerPool::Create( const Reference< XComponentContext >& _rxContext )
{ {
return *( new LoggerPool( _rxContext ) ); return *( new LoggerPool( _rxContext ) );
} }
//--------------------------------------------------------------------
Reference< XLogger > SAL_CALL LoggerPool::getNamedLogger( const OUString& _rName ) throw (RuntimeException) Reference< XLogger > SAL_CALL LoggerPool::getNamedLogger( const OUString& _rName ) throw (RuntimeException)
{ {
::osl::MutexGuard aGuard( m_aMutex ); ::osl::MutexGuard aGuard( m_aMutex );
...@@ -367,20 +311,16 @@ namespace logging ...@@ -367,20 +311,16 @@ namespace logging
return xLogger; return xLogger;
} }
//--------------------------------------------------------------------
Reference< XLogger > SAL_CALL LoggerPool::getDefaultLogger( ) throw (RuntimeException) Reference< XLogger > SAL_CALL LoggerPool::getDefaultLogger( ) throw (RuntimeException)
{ {
return getNamedLogger( OUString( "org.openoffice.logging.DefaultLogger" ) ); return getNamedLogger( OUString( "org.openoffice.logging.DefaultLogger" ) );
} }
//--------------------------------------------------------------------
void createRegistryInfo_LoggerPool() void createRegistryInfo_LoggerPool()
{ {
static OSingletonRegistration< LoggerPool > aAutoRegistration; static OSingletonRegistration< LoggerPool > aAutoRegistration;
} }
//........................................................................
} // namespace logging } // namespace logging
//........................................................................
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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