fdo#54938: Convert sd to use cppu::supportsService

Change-Id: I1aaecbc9f7b5ca0ca2009caf38013054f84cbecc
Signed-off-by: Stephan Bergmann <sbergman@redhat.com>
This commit is contained in:
Marcos Paulo de Souza
2013-12-05 19:18:01 -02:00
committed by Stephan Bergmann
parent 326aa3ff4d
commit cccc6c4ebc
9 changed files with 26 additions and 125 deletions

View File

@@ -19,6 +19,7 @@
#include <com/sun/star/lang/DisposedException.hpp> #include <com/sun/star/lang/DisposedException.hpp>
#include <cppuhelper/supportsservice.hxx>
#include <editeng/eeitem.hxx> #include <editeng/eeitem.hxx>
#include <editeng/fhgtitem.hxx> #include <editeng/fhgtitem.hxx>
#include <editeng/colritem.hxx> #include <editeng/colritem.hxx>
@@ -1117,36 +1118,24 @@ void SdStyleSheetPool::throwIfDisposed() throw(::com::sun::star::uno::RuntimeExc
throw DisposedException(); throw DisposedException();
} }
// --------------------------------------------------------------------
// XServiceInfo // XServiceInfo
// --------------------------------------------------------------------
OUString SAL_CALL SdStyleSheetPool::getImplementationName() throw(RuntimeException) OUString SAL_CALL SdStyleSheetPool::getImplementationName() throw(RuntimeException)
{ {
return OUString( "SdStyleSheetPool" ); return OUString( "SdStyleSheetPool" );
} }
// --------------------------------------------------------------------
static const sal_Char* gpServiceName = "com.sun.star.style.StyleFamilies";
sal_Bool SAL_CALL SdStyleSheetPool::supportsService( const OUString& ServiceName ) throw(RuntimeException) sal_Bool SAL_CALL SdStyleSheetPool::supportsService( const OUString& ServiceName ) throw(RuntimeException)
{ {
return ServiceName.equalsAscii( gpServiceName ); return cppu::supportsService(this, ServiceName);
} }
// --------------------------------------------------------------------
Sequence< OUString > SAL_CALL SdStyleSheetPool::getSupportedServiceNames() throw(RuntimeException) Sequence< OUString > SAL_CALL SdStyleSheetPool::getSupportedServiceNames() throw(RuntimeException)
{ {
OUString aStr( OUString::createFromAscii( gpServiceName ) ); OUString aStr("com.sun.star.style.StyleFamilies");
return Sequence< OUString >( &aStr, 1 ); return Sequence< OUString >( &aStr, 1 );
} }
// --------------------------------------------------------------------
// XNameAccess // XNameAccess
// --------------------------------------------------------------------
Any SAL_CALL SdStyleSheetPool::getByName( const OUString& aName ) throw(NoSuchElementException, WrappedTargetException, RuntimeException) Any SAL_CALL SdStyleSheetPool::getByName( const OUString& aName ) throw(NoSuchElementException, WrappedTargetException, RuntimeException)
{ {
throwIfDisposed(); throwIfDisposed();

View File

@@ -17,7 +17,6 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 . * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/ */
#include <osl/file.hxx> #include <osl/file.hxx>
#include <osl/module.hxx> #include <osl/module.hxx>
#include <com/sun/star/frame/XModel.hpp> #include <com/sun/star/frame/XModel.hpp>
@@ -32,6 +31,7 @@
#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp> #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
#include <com/sun/star/document/XExporter.hpp> #include <com/sun/star/document/XExporter.hpp>
#include <cppuhelper/implbase5.hxx> #include <cppuhelper/implbase5.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <vcl/svapp.hxx> #include <vcl/svapp.hxx>
using namespace com::sun::star::uno; using namespace com::sun::star::uno;
@@ -94,10 +94,7 @@ public:
}; };
// -------------------------
// - SdHtmlOptionsDialog - // - SdHtmlOptionsDialog -
// -------------------------
Reference< XInterface > Reference< XInterface >
SAL_CALL SdHtmlOptionsDialog_CreateInstance( SAL_CALL SdHtmlOptionsDialog_CreateInstance(
SAL_UNUSED_PARAMETER const Reference< XMultiServiceFactory > & ) SAL_UNUSED_PARAMETER const Reference< XMultiServiceFactory > & )
@@ -111,12 +108,6 @@ OUString SdHtmlOptionsDialog_getImplementationName()
return OUString( "com.sun.star.comp.draw.SdHtmlOptionsDialog" ); return OUString( "com.sun.star.comp.draw.SdHtmlOptionsDialog" );
} }
sal_Bool SAL_CALL SdHtmlOptionsDialog_supportsService( const OUString& ServiceName )
throw( RuntimeException )
{
return ServiceName.equals("com.sun.star.ui.dialog.FilterOptionsDialog");
}
Sequence< OUString > SAL_CALL SdHtmlOptionsDialog_getSupportedServiceNames() Sequence< OUString > SAL_CALL SdHtmlOptionsDialog_getSupportedServiceNames()
throw( RuntimeException ) throw( RuntimeException )
{ {
@@ -167,7 +158,7 @@ OUString SAL_CALL SdHtmlOptionsDialog::getImplementationName()
sal_Bool SAL_CALL SdHtmlOptionsDialog::supportsService( const OUString& rServiceName ) sal_Bool SAL_CALL SdHtmlOptionsDialog::supportsService( const OUString& rServiceName )
throw( RuntimeException ) throw( RuntimeException )
{ {
return SdHtmlOptionsDialog_supportsService( rServiceName ); return cppu::supportsService(this, rServiceName);
} }
Sequence< OUString > SAL_CALL SdHtmlOptionsDialog::getSupportedServiceNames() Sequence< OUString > SAL_CALL SdHtmlOptionsDialog::getSupportedServiceNames()
throw ( RuntimeException ) throw ( RuntimeException )

View File

@@ -32,6 +32,7 @@
#include <com/sun/star/accessibility/AccessibleRole.hpp> #include <com/sun/star/accessibility/AccessibleRole.hpp>
#include <com/sun/star/accessibility/AccessibleStateType.hpp> #include <com/sun/star/accessibility/AccessibleStateType.hpp>
#include <comphelper/accessibleeventnotifier.hxx> #include <comphelper/accessibleeventnotifier.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <unotools/accessiblestatesethelper.hxx> #include <unotools/accessiblestatesethelper.hxx>
#include "sdpage.hxx" #include "sdpage.hxx"
@@ -485,12 +486,7 @@ sal_Int32 SAL_CALL AccessibleSlideSorterObject::getBackground (void)
return static_cast<sal_Int32>(nColor); return static_cast<sal_Int32>(nColor);
} }
//===== XServiceInfo ======================================================== //===== XServiceInfo ========================================================
OUString SAL_CALL OUString SAL_CALL
AccessibleSlideSorterObject::getImplementationName (void) AccessibleSlideSorterObject::getImplementationName (void)
throw (::com::sun::star::uno::RuntimeException) throw (::com::sun::star::uno::RuntimeException)
@@ -498,28 +494,12 @@ OUString SAL_CALL
return OUString("AccessibleSlideSorterObject"); return OUString("AccessibleSlideSorterObject");
} }
sal_Bool SAL_CALL AccessibleSlideSorterObject::supportsService (const OUString& sServiceName)
sal_Bool SAL_CALL
AccessibleSlideSorterObject::supportsService (const OUString& sServiceName)
throw (::com::sun::star::uno::RuntimeException) throw (::com::sun::star::uno::RuntimeException)
{ {
ThrowIfDisposed (); return cppu::supportsService(this, sServiceName);
// Iterate over all supported service names and return true if on of them
// matches the given name.
uno::Sequence< OUString> aSupportedServices (
getSupportedServiceNames ());
for (int i=0; i<aSupportedServices.getLength(); i++)
if (sServiceName == aSupportedServices[i])
return sal_True;
return sal_False;
} }
uno::Sequence< OUString> SAL_CALL uno::Sequence< OUString> SAL_CALL
AccessibleSlideSorterObject::getSupportedServiceNames (void) AccessibleSlideSorterObject::getSupportedServiceNames (void)
throw (::com::sun::star::uno::RuntimeException) throw (::com::sun::star::uno::RuntimeException)
@@ -533,9 +513,6 @@ uno::Sequence< OUString> SAL_CALL
return uno::Sequence<OUString> (sServiceNames, 2); return uno::Sequence<OUString> (sServiceNames, 2);
} }
void AccessibleSlideSorterObject::ThrowIfDisposed (void) void AccessibleSlideSorterObject::ThrowIfDisposed (void)
throw (lang::DisposedException) throw (lang::DisposedException)
{ {

View File

@@ -41,6 +41,7 @@
#include <com/sun/star/accessibility/AccessibleEventId.hpp> #include <com/sun/star/accessibility/AccessibleEventId.hpp>
#include <com/sun/star/accessibility/AccessibleStateType.hpp> #include <com/sun/star/accessibility/AccessibleStateType.hpp>
#include <comphelper/accessibleeventnotifier.hxx> #include <comphelper/accessibleeventnotifier.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <unotools/accessiblestatesethelper.hxx> #include <unotools/accessiblestatesethelper.hxx>
#include <rtl/ref.hxx> #include <rtl/ref.hxx>
#include <vcl/svapp.hxx> #include <vcl/svapp.hxx>
@@ -711,11 +712,7 @@ void SAL_CALL AccessibleSlideSorterView::deselectAccessibleChild (sal_Int32 nChi
throw lang::IndexOutOfBoundsException(); throw lang::IndexOutOfBoundsException();
} }
//===== XServiceInfo ======================================================== //===== XServiceInfo ========================================================
OUString SAL_CALL OUString SAL_CALL
AccessibleSlideSorterView::getImplementationName (void) AccessibleSlideSorterView::getImplementationName (void)
throw (::com::sun::star::uno::RuntimeException) throw (::com::sun::star::uno::RuntimeException)
@@ -723,28 +720,12 @@ OUString SAL_CALL
return OUString("AccessibleSlideSorterView"); return OUString("AccessibleSlideSorterView");
} }
sal_Bool SAL_CALL AccessibleSlideSorterView::supportsService (const OUString& sServiceName)
sal_Bool SAL_CALL
AccessibleSlideSorterView::supportsService (const OUString& sServiceName)
throw (::com::sun::star::uno::RuntimeException) throw (::com::sun::star::uno::RuntimeException)
{ {
ThrowIfDisposed (); return cppu::supportsService(this, sServiceName);
// Iterate over all supported service names and return true if on of them
// matches the given name.
uno::Sequence< OUString> aSupportedServices (
getSupportedServiceNames ());
for (int i=0; i<aSupportedServices.getLength(); i++)
if (sServiceName == aSupportedServices[i])
return sal_True;
return sal_False;
} }
uno::Sequence< OUString> SAL_CALL uno::Sequence< OUString> SAL_CALL
AccessibleSlideSorterView::getSupportedServiceNames (void) AccessibleSlideSorterView::getSupportedServiceNames (void)
throw (::com::sun::star::uno::RuntimeException) throw (::com::sun::star::uno::RuntimeException)
@@ -759,9 +740,6 @@ uno::Sequence< OUString> SAL_CALL
return uno::Sequence<OUString> (sServiceNames, 3); return uno::Sequence<OUString> (sServiceNames, 3);
} }
void AccessibleSlideSorterView::ThrowIfDisposed (void) void AccessibleSlideSorterView::ThrowIfDisposed (void)
throw (lang::DisposedException) throw (lang::DisposedException)
{ {

View File

@@ -34,6 +34,7 @@
#include <comphelper/servicehelper.hxx> #include <comphelper/servicehelper.hxx>
#include <cppuhelper/exc_hlp.hxx> #include <cppuhelper/exc_hlp.hxx>
#include <cppuhelper/bootstrap.hxx> #include <cppuhelper/bootstrap.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/beans/PropertyAttribute.hpp>
#include <com/sun/star/drawing/framework/ConfigurationController.hpp> #include <com/sun/star/drawing/framework/ConfigurationController.hpp>
@@ -222,9 +223,7 @@ void SAL_CALL DrawController::removeEventListener (
return SfxBaseController::suspend( Suspend ); return SfxBaseController::suspend( Suspend );
} }
// XServiceInfo // XServiceInfo
OUString SAL_CALL DrawController::getImplementationName( ) throw(RuntimeException) OUString SAL_CALL DrawController::getImplementationName( ) throw(RuntimeException)
{ {
// Do not throw an excepetion at the moment. This leads to a crash // Do not throw an excepetion at the moment. This leads to a crash
@@ -233,23 +232,14 @@ OUString SAL_CALL DrawController::getImplementationName( ) throw(RuntimeExcepti
return OUString("DrawController") ; return OUString("DrawController") ;
} }
static OUString ssServiceName( "com.sun.star.drawing.DrawingDocumentDrawView"); static OUString ssServiceName( "com.sun.star.drawing.DrawingDocumentDrawView");
sal_Bool SAL_CALL DrawController::supportsService ( sal_Bool SAL_CALL DrawController::supportsService (const OUString& rsServiceName)
const OUString& rsServiceName)
throw(RuntimeException) throw(RuntimeException)
{ {
// Do not throw an exception at the moment. This leads to a crash return cppu::supportsService(this, rsServiceName);
// under Solaris on relead. See issue i70929 for details.
// ThrowIfDisposed();
return rsServiceName.equals(ssServiceName);
} }
Sequence<OUString> SAL_CALL DrawController::getSupportedServiceNames (void) Sequence<OUString> SAL_CALL DrawController::getSupportedServiceNames (void)
throw(RuntimeException) throw(RuntimeException)
{ {
@@ -260,11 +250,7 @@ Sequence<OUString> SAL_CALL DrawController::getSupportedServiceNames (void)
return aSupportedServices; return aSupportedServices;
} }
//------ XSelectionSupplier -------------------------------------------- //------ XSelectionSupplier --------------------------------------------
sal_Bool SAL_CALL DrawController::select (const Any& aSelection) sal_Bool SAL_CALL DrawController::select (const Any& aSelection)
throw(lang::IllegalArgumentException, RuntimeException) throw(lang::IllegalArgumentException, RuntimeException)
{ {

View File

@@ -31,6 +31,7 @@
#include <comphelper/processfactory.hxx> #include <comphelper/processfactory.hxx>
#include <cppuhelper/implbase5.hxx> #include <cppuhelper/implbase5.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <osl/mutex.hxx> #include <osl/mutex.hxx>
#include "CustomAnimationPreset.hxx" #include "CustomAnimationPreset.hxx"
@@ -153,11 +154,6 @@ private:
// -------------------------------------------------------------------- // --------------------------------------------------------------------
static const sal_Char* pSN1 = "com.sun.star.animations.ParallelTimeContainer";
static const sal_Char* pSN2 = "com.sun.star.comp.sd.RandomAnimationNode";
// --------------------------------------------------------------------
SD_DLLPUBLIC Reference< XInterface > RandomAnimationNode_createInstance( sal_Int16 nPresetClass ) SD_DLLPUBLIC Reference< XInterface > RandomAnimationNode_createInstance( sal_Int16 nPresetClass )
{ {
Reference< XInterface > xInt( static_cast<XWeak*>( new RandomAnimationNode( nPresetClass ) ) ); Reference< XInterface > xInt( static_cast<XWeak*>( new RandomAnimationNode( nPresetClass ) ) );
@@ -183,8 +179,9 @@ OUString RandomNode__getImplementationName() throw( RuntimeException )
Sequence< OUString > SAL_CALL RandomNode_getSupportedServiceNames() throw( RuntimeException ) Sequence< OUString > SAL_CALL RandomNode_getSupportedServiceNames() throw( RuntimeException )
{ {
static const OUString aSN2( OUString::createFromAscii( pSN2 ) ); Sequence< OUString > aSeq( 2 );
Sequence< OUString > aSeq( &aSN2, 1 ); aSeq[0] = "com.sun.star.animations.ParallelTimeContainer";
aSeq[1] = "com.sun.star.comp.sd.RandomAnimationNode";
return aSeq; return aSeq;
} }
@@ -671,7 +668,7 @@ OUString RandomAnimationNode::getImplementationName() throw()
// XServiceInfo // XServiceInfo
sal_Bool RandomAnimationNode::supportsService(const OUString& ServiceName) throw() sal_Bool RandomAnimationNode::supportsService(const OUString& ServiceName) throw()
{ {
return ServiceName.equalsAscii( pSN1 ) || ServiceName.equalsAscii( pSN2 ); return cppu::supportsService(this, ServiceName);
} }
// XServiceInfo // XServiceInfo

View File

@@ -28,6 +28,7 @@
#include <com/sun/star/awt/XWindow.hpp> #include <com/sun/star/awt/XWindow.hpp>
#include <com/sun/star/lang/XUnoTunnel.hpp> #include <com/sun/star/lang/XUnoTunnel.hpp>
#include <comphelper/processfactory.hxx> #include <comphelper/processfactory.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <com/sun/star/container/XNameAccess.hpp> #include <com/sun/star/container/XNameAccess.hpp>
#include <com/sun/star/io/XInputStream.hpp> #include <com/sun/star/io/XInputStream.hpp>
#include <com/sun/star/task/XInteractionHandler.hpp> #include <com/sun/star/task/XInteractionHandler.hpp>
@@ -511,16 +512,7 @@ OUString SAL_CALL SdFilterDetect::getImplementationName() throw( RuntimeExceptio
/* XServiceInfo */ /* XServiceInfo */
sal_Bool SAL_CALL SdFilterDetect::supportsService( const OUString& sServiceName ) throw( RuntimeException ) sal_Bool SAL_CALL SdFilterDetect::supportsService( const OUString& sServiceName ) throw( RuntimeException )
{ {
Sequence< OUString > seqServiceNames = getSupportedServiceNames(); return cppu::supportsService(this, sServiceName);
const OUString* pArray = seqServiceNames.getConstArray();
for ( sal_Int32 nCounter=0; nCounter<seqServiceNames.getLength(); nCounter++ )
{
if ( pArray[nCounter] == sServiceName )
{
return sal_True ;
}
}
return sal_False ;
} }
/* XServiceInfo */ /* XServiceInfo */

View File

@@ -1173,17 +1173,7 @@ OUString SAL_CALL SdXImpressDocument::getImplementationName()
sal_Bool SAL_CALL SdXImpressDocument::supportsService( const OUString& ServiceName ) sal_Bool SAL_CALL SdXImpressDocument::supportsService( const OUString& ServiceName )
throw(uno::RuntimeException) throw(uno::RuntimeException)
{ {
::SolarMutexGuard aGuard; return cppu::supportsService(this, ServiceName);
if ( ServiceName == "com.sun.star.document.OfficeDocument"
|| ServiceName == "com.sun.star.drawing.GenericDrawingDocument"
|| ServiceName == "com.sun.star.drawing.DrawingDocumentFactory" )
{
return sal_True;
}
return ( ( mbImpressDoc && ServiceName == "com.sun.star.presentation.PresentationDocument" )
|| ( !mbImpressDoc && ServiceName == "com.sun.star.drawing.DrawingDocument" ) );
} }
uno::Sequence< OUString > SAL_CALL SdXImpressDocument::getSupportedServiceNames() throw(uno::RuntimeException) uno::Sequence< OUString > SAL_CALL SdXImpressDocument::getSupportedServiceNames() throw(uno::RuntimeException)
@@ -2569,7 +2559,7 @@ OUString SAL_CALL SdDrawPagesAccess::getImplementationName( ) throw(uno::Runtim
sal_Bool SAL_CALL SdDrawPagesAccess::supportsService( const OUString& ServiceName ) throw(uno::RuntimeException) sal_Bool SAL_CALL SdDrawPagesAccess::supportsService( const OUString& ServiceName ) throw(uno::RuntimeException)
{ {
return ServiceName == pSdDrawPagesAccessService; return cppu::supportsService(this, ServiceName);
} }
uno::Sequence< OUString > SAL_CALL SdDrawPagesAccess::getSupportedServiceNames( ) throw(uno::RuntimeException) uno::Sequence< OUString > SAL_CALL SdDrawPagesAccess::getSupportedServiceNames( ) throw(uno::RuntimeException)
@@ -2837,7 +2827,7 @@ OUString SAL_CALL SdMasterPagesAccess::getImplementationName( ) throw(uno::Runt
sal_Bool SAL_CALL SdMasterPagesAccess::supportsService( const OUString& ServiceName ) throw(uno::RuntimeException) sal_Bool SAL_CALL SdMasterPagesAccess::supportsService( const OUString& ServiceName ) throw(uno::RuntimeException)
{ {
return ServiceName == pSdMasterPagesAccessService; return cppu::supportsService(this, ServiceName);
} }
uno::Sequence< OUString > SAL_CALL SdMasterPagesAccess::getSupportedServiceNames( ) throw(uno::RuntimeException) uno::Sequence< OUString > SAL_CALL SdMasterPagesAccess::getSupportedServiceNames( ) throw(uno::RuntimeException)

View File

@@ -39,6 +39,7 @@
#include <sfx2/bindings.hxx> #include <sfx2/bindings.hxx>
#include <sfx2/sfxsids.hrc> #include <sfx2/sfxsids.hrc>
#include <comphelper/extract.hxx> #include <comphelper/extract.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <svx/unoprov.hxx> #include <svx/unoprov.hxx>
#include <svx/unoshape.hxx> #include <svx/unoshape.hxx>
#include <svx/svditer.hxx> #include <svx/svditer.hxx>
@@ -1699,7 +1700,7 @@ OUString SAL_CALL SdUnoEventsAccess::getImplementationName( )
sal_Bool SAL_CALL SdUnoEventsAccess::supportsService( const OUString& ServiceName ) sal_Bool SAL_CALL SdUnoEventsAccess::supportsService( const OUString& ServiceName )
throw(uno::RuntimeException) throw(uno::RuntimeException)
{ {
return ServiceName == maStrServiceName; return cppu::supportsService(this, ServiceName);
} }
uno::Sequence< OUString > SAL_CALL SdUnoEventsAccess::getSupportedServiceNames( ) uno::Sequence< OUString > SAL_CALL SdUnoEventsAccess::getSupportedServiceNames( )