[Libreoffice-commits] .: accessibility/source cppuhelper/inc cppuhelper/Library_cppuhelper.mk cppuhelper/Package_inc.mk cppuhelper/source cppuhelper/test UnoControls/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Sep 14 10:32:52 PDT 2012


 UnoControls/source/base/basecontrol.cxx                         |   12 --
 accessibility/source/extended/AccessibleBrowseBoxBase.cxx       |   13 --
 accessibility/source/extended/AccessibleGridControlBase.cxx     |   14 --
 accessibility/source/extended/accessibleiconchoicectrl.cxx      |    9 -
 accessibility/source/extended/accessibleiconchoicectrlentry.cxx |    9 -
 accessibility/source/extended/accessiblelistbox.cxx             |    9 -
 accessibility/source/extended/accessiblelistboxentry.cxx        |    9 -
 accessibility/source/extended/accessibletabbar.cxx              |    9 -
 accessibility/source/extended/accessibletabbarpage.cxx          |    9 -
 accessibility/source/extended/accessibletabbarpagelist.cxx      |    9 -
 accessibility/source/standard/accessiblemenubasecomponent.cxx   |   10 --
 accessibility/source/standard/vclxaccessiblelistitem.cxx        |    9 -
 accessibility/source/standard/vclxaccessiblestatusbaritem.cxx   |   10 --
 accessibility/source/standard/vclxaccessibletabpage.cxx         |   10 --
 accessibility/source/standard/vclxaccessibletoolboxitem.cxx     |    9 -
 cppuhelper/Library_cppuhelper.mk                                |    1 
 cppuhelper/Package_inc.mk                                       |    1 
 cppuhelper/inc/cppuhelper/supportsservice.hxx                   |   49 ++++++++++
 cppuhelper/source/defaultbootstrap.cxx                          |   17 ---
 cppuhelper/source/factory.cxx                                   |   13 --
 cppuhelper/source/gcc3.map                                      |    5 +
 cppuhelper/source/macro_expander.cxx                            |   10 --
 cppuhelper/source/supportsservice.cxx                           |   40 ++++++++
 cppuhelper/test/cfg_test.cxx                                    |   10 --
 cppuhelper/test/testcmp/TestComponent.cxx                       |   11 --
 25 files changed, 139 insertions(+), 168 deletions(-)

New commits:
commit 2171077c0c3c43a61546ab2c0ae68ba63c5112f7
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Fri Sep 14 19:27:00 2012 +0200

    Introduce cppu::supportsService helper, adapt some call-sites
    
    ...more to follow (easy hack?)
    
    Change-Id: Icb02626495701a3905c124c7368b98c3258e91b2

diff --git a/UnoControls/source/base/basecontrol.cxx b/UnoControls/source/base/basecontrol.cxx
index f8e63f2..068317b 100644
--- a/UnoControls/source/base/basecontrol.cxx
+++ b/UnoControls/source/base/basecontrol.cxx
@@ -24,6 +24,7 @@
 #include <com/sun/star/awt/DeviceInfo.hpp>
 #include <com/sun/star/awt/WindowAttribute.hpp>
 #include <com/sun/star/awt/PosSize.hpp>
+#include <cppuhelper/supportsservice.hxx>
 #include <cppuhelper/typeprovider.hxx>
 
 //____________________________________________________________________________________________________________
@@ -246,16 +247,7 @@ OUString SAL_CALL BaseControl::getImplementationName() throw( RuntimeException )
 
 sal_Bool SAL_CALL BaseControl::supportsService( const OUString& sServiceName ) throw( RuntimeException )
 {
-    Sequence< OUString >    seqServiceNames =   getSupportedServiceNames();
-    const OUString*         pArray          =   seqServiceNames.getConstArray();
-    for ( sal_Int32 nCounter=0; nCounter<seqServiceNames.getLength(); nCounter++ )
-    {
-        if ( pArray[nCounter] == sServiceName )
-        {
-            return sal_True ;
-        }
-    }
-    return sal_False ;
+    return cppu::supportsService(this, sServiceName);
 }
 
 //____________________________________________________________________________________________________________
diff --git a/accessibility/source/extended/AccessibleBrowseBoxBase.cxx b/accessibility/source/extended/AccessibleBrowseBoxBase.cxx
index b60dc0b..3e8848f 100644
--- a/accessibility/source/extended/AccessibleBrowseBoxBase.cxx
+++ b/accessibility/source/extended/AccessibleBrowseBoxBase.cxx
@@ -29,6 +29,7 @@
 #include "accessibility/extended/AccessibleBrowseBoxBase.hxx"
 #include <svtools/accessibletableprovider.hxx>
 #include <comphelper/servicehelper.hxx>
+#include <cppuhelper/supportsservice.hxx>
 
 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
@@ -351,17 +352,7 @@ sal_Bool SAL_CALL AccessibleBrowseBoxBase::supportsService(
         const OUString& rServiceName )
     throw ( uno::RuntimeException )
 {
-    ::osl::MutexGuard aGuard( getOslMutex() );
-
-    Sequence< OUString > aSupportedServices( getSupportedServiceNames() );
-    const OUString* pArrBegin = aSupportedServices.getConstArray();
-    const OUString* pArrEnd = pArrBegin + aSupportedServices.getLength();
-    const OUString* pString = pArrBegin;
-
-    for( ; ( pString != pArrEnd ) && ( rServiceName != *pString ); ++pString )
-        ;
-
-    return pString != pArrEnd;
+    return cppu::supportsService(this, rServiceName);
 }
 
 Sequence< OUString > SAL_CALL AccessibleBrowseBoxBase::getSupportedServiceNames()
diff --git a/accessibility/source/extended/AccessibleGridControlBase.cxx b/accessibility/source/extended/AccessibleGridControlBase.cxx
index ecccf07..a5f78a4 100644
--- a/accessibility/source/extended/AccessibleGridControlBase.cxx
+++ b/accessibility/source/extended/AccessibleGridControlBase.cxx
@@ -29,7 +29,8 @@
 #include "accessibility/extended/AccessibleGridControlBase.hxx"
 #include <svtools/accessibletable.hxx>
 #include <comphelper/servicehelper.hxx>
-//
+#include <cppuhelper/supportsservice.hxx>
+
 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
 #include <unotools/accessiblerelationsethelper.hxx>
@@ -300,16 +301,7 @@ sal_Bool SAL_CALL AccessibleGridControlBase::supportsService(
         const OUString& rServiceName )
     throw ( uno::RuntimeException )
 {
-    ::osl::MutexGuard aGuard( getOslMutex() );
-
-    Sequence< OUString > aSupportedServices( getSupportedServiceNames() );
-    const OUString* pArrBegin = aSupportedServices.getConstArray();
-    const OUString* pArrEnd = pArrBegin + aSupportedServices.getLength();
-    const OUString* pString = pArrBegin;
-
-    for( ; ( pString != pArrEnd ) && ( rServiceName != *pString ); ++pString )
-        ;
-    return pString != pArrEnd;
+    return cppu::supportsService(this, rServiceName);
 }
 
 Sequence< OUString > SAL_CALL AccessibleGridControlBase::getSupportedServiceNames()
diff --git a/accessibility/source/extended/accessibleiconchoicectrl.cxx b/accessibility/source/extended/accessibleiconchoicectrl.cxx
index fd00e40..e617f42 100644
--- a/accessibility/source/extended/accessibleiconchoicectrl.cxx
+++ b/accessibility/source/extended/accessibleiconchoicectrl.cxx
@@ -34,6 +34,7 @@
 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
 #include <unotools/accessiblestatesethelper.hxx>
 #include <vcl/svapp.hxx>
+#include <cppuhelper/supportsservice.hxx>
 #include <cppuhelper/typeprovider.hxx>
 
 //........................................................................
@@ -122,13 +123,7 @@ namespace accessibility
     // -----------------------------------------------------------------------------
     sal_Bool SAL_CALL AccessibleIconChoiceCtrl::supportsService( const OUString& _rServiceName ) throw (RuntimeException)
     {
-        Sequence< OUString > aSupported( getSupportedServiceNames() );
-        const OUString* pSupported = aSupported.getConstArray();
-        const OUString* pEnd = pSupported + aSupported.getLength();
-        for ( ; pSupported != pEnd && !pSupported->equals(_rServiceName); ++pSupported )
-            ;
-
-        return pSupported != pEnd;
+        return cppu::supportsService(this, _rServiceName);
     }
     // -----------------------------------------------------------------------------
     // XServiceInfo - static methods
diff --git a/accessibility/source/extended/accessibleiconchoicectrlentry.cxx b/accessibility/source/extended/accessibleiconchoicectrlentry.cxx
index 9f847f4..f791ba2 100644
--- a/accessibility/source/extended/accessibleiconchoicectrlentry.cxx
+++ b/accessibility/source/extended/accessibleiconchoicectrlentry.cxx
@@ -40,6 +40,7 @@
 #include <toolkit/helper/convert.hxx>
 #include <unotools/accessiblestatesethelper.hxx>
 #include <unotools/accessiblerelationsethelper.hxx>
+#include <cppuhelper/supportsservice.hxx>
 #include <cppuhelper/typeprovider.hxx>
 #include <comphelper/sequence.hxx>
 #include <svtools/stringtransfer.hxx>
@@ -259,13 +260,7 @@ throw(RuntimeException)
     // -----------------------------------------------------------------------------
     sal_Bool SAL_CALL AccessibleIconChoiceCtrlEntry::supportsService( const OUString& _rServiceName ) throw (RuntimeException)
     {
-        Sequence< OUString > aSupported( getSupportedServiceNames() );
-        const OUString* pSupported = aSupported.getConstArray();
-        const OUString* pEnd = pSupported + aSupported.getLength();
-        for ( ; pSupported != pEnd && !pSupported->equals(_rServiceName); ++pSupported )
-            ;
-
-        return pSupported != pEnd;
+        return cppu::supportsService(this, _rServiceName);
     }
     // -----------------------------------------------------------------------------
     // XServiceInfo - static methods
diff --git a/accessibility/source/extended/accessiblelistbox.cxx b/accessibility/source/extended/accessiblelistbox.cxx
index e9a719c..e1a410a 100644
--- a/accessibility/source/extended/accessiblelistbox.cxx
+++ b/accessibility/source/extended/accessiblelistbox.cxx
@@ -26,6 +26,7 @@
 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
 #include <com/sun/star/accessibility/AccessibleRole.hpp>
 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
+#include <cppuhelper/supportsservice.hxx>
 #include <vcl/svapp.hxx>
 #include <toolkit/awt/vclxwindow.hxx>
 #include <toolkit/helper/convert.hxx>
@@ -188,13 +189,7 @@ namespace accessibility
     // -----------------------------------------------------------------------------
     sal_Bool SAL_CALL AccessibleListBox::supportsService( const OUString& _rServiceName ) throw (RuntimeException)
     {
-        Sequence< OUString > aSupported( getSupportedServiceNames() );
-        const OUString* pSupported = aSupported.getConstArray();
-        const OUString* pEnd = pSupported + aSupported.getLength();
-        for ( ; pSupported != pEnd && !pSupported->equals(_rServiceName); ++pSupported )
-            ;
-
-        return pSupported != pEnd;
+        return cppu::supportsService(this, _rServiceName);
     }
     // -----------------------------------------------------------------------------
     // XServiceInfo - static methods
diff --git a/accessibility/source/extended/accessiblelistboxentry.cxx b/accessibility/source/extended/accessiblelistboxentry.cxx
index 2d50812..36fc170 100644
--- a/accessibility/source/extended/accessiblelistboxentry.cxx
+++ b/accessibility/source/extended/accessiblelistboxentry.cxx
@@ -42,6 +42,7 @@
 #include <toolkit/helper/convert.hxx>
 #include <unotools/accessiblestatesethelper.hxx>
 #include <unotools/accessiblerelationsethelper.hxx>
+#include <cppuhelper/supportsservice.hxx>
 #include <cppuhelper/typeprovider.hxx>
 #include <comphelper/sequence.hxx>
 #include <comphelper/accessibleeventnotifier.hxx>
@@ -268,13 +269,7 @@ namespace accessibility
     // -----------------------------------------------------------------------------
     sal_Bool SAL_CALL AccessibleListBoxEntry::supportsService( const OUString& _rServiceName ) throw (RuntimeException)
     {
-        Sequence< OUString > aSupported( getSupportedServiceNames() );
-        const OUString* pSupported = aSupported.getConstArray();
-        const OUString* pEnd = pSupported + aSupported.getLength();
-        for ( ; pSupported != pEnd && !pSupported->equals(_rServiceName); ++pSupported )
-            ;
-
-        return pSupported != pEnd;
+        return cppu::supportsService(this, _rServiceName);
     }
     // -----------------------------------------------------------------------------
     // XServiceInfo - static methods
diff --git a/accessibility/source/extended/accessibletabbar.cxx b/accessibility/source/extended/accessibletabbar.cxx
index 0f01b16..05259f1 100644
--- a/accessibility/source/extended/accessibletabbar.cxx
+++ b/accessibility/source/extended/accessibletabbar.cxx
@@ -32,6 +32,7 @@
 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
 #include <com/sun/star/accessibility/AccessibleRole.hpp>
 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
+#include <cppuhelper/supportsservice.hxx>
 #include <unotools/accessiblestatesethelper.hxx>
 #include <unotools/accessiblerelationsethelper.hxx>
 #include <vcl/svapp.hxx>
@@ -208,13 +209,7 @@ namespace accessibility
 
     sal_Bool AccessibleTabBar::supportsService( const OUString& rServiceName ) throw (RuntimeException)
     {
-        Sequence< OUString > aNames( getSupportedServiceNames() );
-        const OUString* pNames = aNames.getConstArray();
-        const OUString* pEnd = pNames + aNames.getLength();
-        for ( ; pNames != pEnd && !pNames->equals( rServiceName ); ++pNames )
-            ;
-
-        return pNames != pEnd;
+        return cppu::supportsService(this, rServiceName);
     }
 
     // -----------------------------------------------------------------------------
diff --git a/accessibility/source/extended/accessibletabbarpage.cxx b/accessibility/source/extended/accessibletabbarpage.cxx
index b1fa819..0751ae8 100644
--- a/accessibility/source/extended/accessibletabbarpage.cxx
+++ b/accessibility/source/extended/accessibletabbarpage.cxx
@@ -31,6 +31,7 @@
 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
 #include <com/sun/star/accessibility/AccessibleRole.hpp>
 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
+#include <cppuhelper/supportsservice.hxx>
 #include <unotools/accessiblestatesethelper.hxx>
 #include <unotools/accessiblerelationsethelper.hxx>
 #include <vcl/svapp.hxx>
@@ -265,13 +266,7 @@ namespace accessibility
 
     sal_Bool AccessibleTabBarPage::supportsService( const OUString& rServiceName ) throw (RuntimeException)
     {
-        Sequence< OUString > aNames( getSupportedServiceNames() );
-        const OUString* pNames = aNames.getConstArray();
-        const OUString* pEnd = pNames + aNames.getLength();
-        for ( ; pNames != pEnd && !pNames->equals( rServiceName ); ++pNames )
-            ;
-
-        return pNames != pEnd;
+        return cppu::supportsService(this, rServiceName);
     }
 
     // -----------------------------------------------------------------------------
diff --git a/accessibility/source/extended/accessibletabbarpagelist.cxx b/accessibility/source/extended/accessibletabbarpagelist.cxx
index b85c8a8..f54616e 100644
--- a/accessibility/source/extended/accessibletabbarpagelist.cxx
+++ b/accessibility/source/extended/accessibletabbarpagelist.cxx
@@ -32,6 +32,7 @@
 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
 #include <com/sun/star/accessibility/AccessibleRole.hpp>
 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
+#include <cppuhelper/supportsservice.hxx>
 #include <unotools/accessiblestatesethelper.hxx>
 #include <unotools/accessiblerelationsethelper.hxx>
 #include <vcl/svapp.hxx>
@@ -428,13 +429,7 @@ namespace accessibility
 
     sal_Bool AccessibleTabBarPageList::supportsService( const OUString& rServiceName ) throw (RuntimeException)
     {
-        Sequence< OUString > aNames( getSupportedServiceNames() );
-        const OUString* pNames = aNames.getConstArray();
-        const OUString* pEnd = pNames + aNames.getLength();
-        for ( ; pNames != pEnd && !pNames->equals( rServiceName ); ++pNames )
-            ;
-
-        return pNames != pEnd;
+        return cppu::supportsService(this, rServiceName);
     }
 
     // -----------------------------------------------------------------------------
diff --git a/accessibility/source/standard/accessiblemenubasecomponent.cxx b/accessibility/source/standard/accessiblemenubasecomponent.cxx
index ceda5ed..48118ed 100644
--- a/accessibility/source/standard/accessiblemenubasecomponent.cxx
+++ b/accessibility/source/standard/accessiblemenubasecomponent.cxx
@@ -27,7 +27,7 @@
 #include <com/sun/star/accessibility/AccessibleEventId.hpp>
 #include <com/sun/star/accessibility/AccessibleRole.hpp>
 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
-
+#include <cppuhelper/supportsservice.hxx>
 #include <unotools/accessiblestatesethelper.hxx>
 #include <vcl/svapp.hxx>
 #include <vcl/window.hxx>
@@ -724,13 +724,7 @@ void OAccessibleMenuBaseComponent::disposing()
 
 sal_Bool OAccessibleMenuBaseComponent::supportsService( const OUString& rServiceName ) throw (RuntimeException)
 {
-    Sequence< OUString > aNames( getSupportedServiceNames() );
-    const OUString* pNames = aNames.getConstArray();
-    const OUString* pEnd = pNames + aNames.getLength();
-    for ( ; pNames != pEnd && !pNames->equals( rServiceName ); ++pNames )
-        ;
-
-    return pNames != pEnd;
+    return cppu::supportsService(this, rServiceName);
 }
 
 // -----------------------------------------------------------------------------
diff --git a/accessibility/source/standard/vclxaccessiblelistitem.cxx b/accessibility/source/standard/vclxaccessiblelistitem.cxx
index cf7c8a5..af2a57c 100644
--- a/accessibility/source/standard/vclxaccessiblelistitem.cxx
+++ b/accessibility/source/standard/vclxaccessiblelistitem.cxx
@@ -38,6 +38,7 @@
 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
 #include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
 #include <com/sun/star/datatransfer/clipboard/XFlushableClipboard.hpp>
+#include <cppuhelper/supportsservice.hxx>
 #include <vcl/svapp.hxx>
 #include <vcl/controllayout.hxx>
 #include <vcl/unohelp2.hxx>
@@ -227,13 +228,7 @@ OUString VCLXAccessibleListItem::getImplementationName() throw (RuntimeException
 // -----------------------------------------------------------------------------
 sal_Bool VCLXAccessibleListItem::supportsService( const OUString& rServiceName ) throw (RuntimeException)
 {
-    Sequence< OUString > aNames( getSupportedServiceNames() );
-    const OUString* pNames = aNames.getConstArray();
-    const OUString* pEnd = pNames + aNames.getLength();
-    for ( ; pNames != pEnd && !pNames->equals( rServiceName ); ++pNames )
-        ;
-
-    return pNames != pEnd;
+    return cppu::supportsService(this, rServiceName);
 }
 // -----------------------------------------------------------------------------
 Sequence< OUString > VCLXAccessibleListItem::getSupportedServiceNames() throw (RuntimeException)
diff --git a/accessibility/source/standard/vclxaccessiblestatusbaritem.cxx b/accessibility/source/standard/vclxaccessiblestatusbaritem.cxx
index 1d2184b..889e25b 100644
--- a/accessibility/source/standard/vclxaccessiblestatusbaritem.cxx
+++ b/accessibility/source/standard/vclxaccessiblestatusbaritem.cxx
@@ -36,7 +36,7 @@
 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
 #include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
 #include <com/sun/star/datatransfer/clipboard/XFlushableClipboard.hpp>
-
+#include <cppuhelper/supportsservice.hxx>
 #include <unotools/accessiblestatesethelper.hxx>
 #include <unotools/accessiblerelationsethelper.hxx>
 #include <vcl/svapp.hxx>
@@ -249,13 +249,7 @@ OUString VCLXAccessibleStatusBarItem::getImplementationName() throw (RuntimeExce
 
 sal_Bool VCLXAccessibleStatusBarItem::supportsService( const OUString& rServiceName ) throw (RuntimeException)
 {
-    Sequence< OUString > aNames( getSupportedServiceNames() );
-    const OUString* pNames = aNames.getConstArray();
-    const OUString* pEnd = pNames + aNames.getLength();
-    for ( ; pNames != pEnd && !pNames->equals( rServiceName ); ++pNames )
-        ;
-
-    return pNames != pEnd;
+    return cppu::supportsService(this, rServiceName);
 }
 
 // -----------------------------------------------------------------------------
diff --git a/accessibility/source/standard/vclxaccessibletabpage.cxx b/accessibility/source/standard/vclxaccessibletabpage.cxx
index 738dabf..7a1f154 100644
--- a/accessibility/source/standard/vclxaccessibletabpage.cxx
+++ b/accessibility/source/standard/vclxaccessibletabpage.cxx
@@ -36,7 +36,7 @@
 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
 #include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
 #include <com/sun/star/datatransfer/clipboard/XFlushableClipboard.hpp>
-
+#include <cppuhelper/supportsservice.hxx>
 #include <unotools/accessiblestatesethelper.hxx>
 #include <unotools/accessiblerelationsethelper.hxx>
 #include <vcl/svapp.hxx>
@@ -281,13 +281,7 @@ OUString VCLXAccessibleTabPage::getImplementationName() throw (RuntimeException)
 
 sal_Bool VCLXAccessibleTabPage::supportsService( const OUString& rServiceName ) throw (RuntimeException)
 {
-    Sequence< OUString > aNames( getSupportedServiceNames() );
-    const OUString* pNames = aNames.getConstArray();
-    const OUString* pEnd = pNames + aNames.getLength();
-    for ( ; pNames != pEnd && !pNames->equals( rServiceName ); ++pNames )
-        ;
-
-    return pNames != pEnd;
+    return cppu::supportsService(this, rServiceName);
 }
 
 // -----------------------------------------------------------------------------
diff --git a/accessibility/source/standard/vclxaccessibletoolboxitem.cxx b/accessibility/source/standard/vclxaccessibletoolboxitem.cxx
index b5f6e9a..347fcf1 100644
--- a/accessibility/source/standard/vclxaccessibletoolboxitem.cxx
+++ b/accessibility/source/standard/vclxaccessibletoolboxitem.cxx
@@ -39,6 +39,7 @@
 #include <com/sun/star/accessibility/AccessibleStateType.hpp>
 #include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
 #include <com/sun/star/datatransfer/clipboard/XFlushableClipboard.hpp>
+#include <cppuhelper/supportsservice.hxx>
 #include <vcl/svapp.hxx>
 #include <vcl/toolbox.hxx>
 #include <vcl/unohelp2.hxx>
@@ -283,13 +284,7 @@ OUString VCLXAccessibleToolBoxItem::getImplementationName() throw (RuntimeExcept
 // -----------------------------------------------------------------------------
 sal_Bool VCLXAccessibleToolBoxItem::supportsService( const OUString& rServiceName ) throw (RuntimeException)
 {
-    Sequence< OUString > aNames( getSupportedServiceNames() );
-    const OUString* pNames = aNames.getConstArray();
-    const OUString* pEnd = pNames + aNames.getLength();
-    for ( ; pNames != pEnd && !pNames->equals( rServiceName ); ++pNames )
-        ;
-
-    return pNames != pEnd;
+    return cppu::supportsService(this, rServiceName);
 }
 // -----------------------------------------------------------------------------
 Sequence< OUString > VCLXAccessibleToolBoxItem::getSupportedServiceNames() throw (RuntimeException)
diff --git a/cppuhelper/Library_cppuhelper.mk b/cppuhelper/Library_cppuhelper.mk
index aa8c3fd..964135b 100644
--- a/cppuhelper/Library_cppuhelper.mk
+++ b/cppuhelper/Library_cppuhelper.mk
@@ -74,6 +74,7 @@ $(eval $(call gb_Library_add_exception_objects,cppuhelper,\
 	cppuhelper/source/servicefactory \
 	cppuhelper/source/shlib \
 	cppuhelper/source/stdidlclass \
+	cppuhelper/source/supportsservice \
 	cppuhelper/source/tdmgr \
 	cppuhelper/source/typeprovider \
 	cppuhelper/source/unourl \
diff --git a/cppuhelper/Package_inc.mk b/cppuhelper/Package_inc.mk
index 60f9364..d164f38 100644
--- a/cppuhelper/Package_inc.mk
+++ b/cppuhelper/Package_inc.mk
@@ -77,6 +77,7 @@ $(eval $(call gb_Package_add_file,cppuhelper_inc,inc/cppuhelper/queryinterface.h
 $(eval $(call gb_Package_add_file,cppuhelper_inc,inc/cppuhelper/servicefactory.hxx,cppuhelper/servicefactory.hxx))
 $(eval $(call gb_Package_add_file,cppuhelper_inc,inc/cppuhelper/shlib.hxx,cppuhelper/shlib.hxx))
 $(eval $(call gb_Package_add_file,cppuhelper_inc,inc/cppuhelper/stdidlclass.hxx,cppuhelper/stdidlclass.hxx))
+$(eval $(call gb_Package_add_file,cppuhelper_inc,inc/cppuhelper/supportsservice.hxx,cppuhelper/supportsservice.hxx))
 $(eval $(call gb_Package_add_file,cppuhelper_inc,inc/cppuhelper/typeprovider.hxx,cppuhelper/typeprovider.hxx))
 $(eval $(call gb_Package_add_file,cppuhelper_inc,inc/cppuhelper/unourl.hxx,cppuhelper/unourl.hxx))
 $(eval $(call gb_Package_add_file,cppuhelper_inc,inc/cppuhelper/weakagg.hxx,cppuhelper/weakagg.hxx))
diff --git a/cppuhelper/inc/cppuhelper/supportsservice.hxx b/cppuhelper/inc/cppuhelper/supportsservice.hxx
new file mode 100644
index 0000000..3506e37
--- /dev/null
+++ b/cppuhelper/inc/cppuhelper/supportsservice.hxx
@@ -0,0 +1,49 @@
+/* -*- 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/.
+ */
+
+#ifndef INCLUDED_CPPUHELPER_SUPPORTSSERVICE_HXX
+#define INCLUDED_CPPUHELPER_SUPPORTSSERVICE_HXX
+
+#include "sal/config.h"
+
+#include "cppuhelper/cppuhelperdllapi.h"
+
+namespace com { namespace sun { namespace star { namespace lang {
+    class XServiceInfo;
+} } } }
+namespace rtl { class OUString; }
+
+namespace cppu {
+
+/** A helper for implementations of com.sun.star.lang.XServiceInfo.
+
+    This function is supposed to be called from implementations of
+    com::sun::star::lang::XServiceInfo::supportsService (and therefore, for
+    easier coding takes the caller's this pointer by pointer rather than by
+    com::sun::star::uno::Reference).
+
+    @param implementation points to the service implementation whose
+    getSupportedServices method is consulted; must be non-null
+
+    @param name the service name to test
+
+    @return true iff the sequence returned by the given implementation's
+    getSupportedServices method contains the given name
+
+    @since LibreOffice 3.7
+*/
+bool CPPUHELPER_DLLPUBLIC supportsService(
+    com::sun::star::lang::XServiceInfo * implementation,
+    rtl::OUString const & name);
+
+}
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cppuhelper/source/defaultbootstrap.cxx b/cppuhelper/source/defaultbootstrap.cxx
index ba558c0..ccf7447 100644
--- a/cppuhelper/source/defaultbootstrap.cxx
+++ b/cppuhelper/source/defaultbootstrap.cxx
@@ -62,6 +62,7 @@
 #include "cppuhelper/implbase1.hxx"
 #include "cppuhelper/implbase3.hxx"
 #include "cppuhelper/shlib.hxx"
+#include "cppuhelper/supportsservice.hxx"
 #include "osl/file.hxx"
 #include "registry/registry.hxx"
 #include "rtl/bootstrap.hxx"
@@ -920,13 +921,7 @@ rtl::OUString ServiceManager::getImplementationName()
 sal_Bool ServiceManager::supportsService(rtl::OUString const & ServiceName)
     throw (css::uno::RuntimeException)
 {
-    css::uno::Sequence< rtl::OUString > names(getSupportedServiceNames());
-    for (sal_Int32 i = 0; i != names.getLength(); ++i) {
-        if (ServiceName == names[i]) {
-            return true;
-        }
-    }
-    return false;
+    return cppu::supportsService(this, ServiceName);
 }
 
 css::uno::Sequence< rtl::OUString > ServiceManager::getSupportedServiceNames()
@@ -1936,13 +1931,7 @@ rtl::OUString FactoryWrapper::getImplementationName()
 sal_Bool FactoryWrapper::supportsService(rtl::OUString const & ServiceName)
     throw (css::uno::RuntimeException)
 {
-    css::uno::Sequence< rtl::OUString > names(getSupportedServiceNames());
-    for (sal_Int32 i = 0; i != names.getLength(); ++i) {
-        if (ServiceName == names[i]) {
-            return true;
-        }
-    }
-    return false;
+    return cppu::supportsService(this, ServiceName);
 }
 
 css::uno::Sequence< rtl::OUString > FactoryWrapper::getSupportedServiceNames()
diff --git a/cppuhelper/source/factory.cxx b/cppuhelper/source/factory.cxx
index dc46aa8..6747892 100644
--- a/cppuhelper/source/factory.cxx
+++ b/cppuhelper/source/factory.cxx
@@ -34,6 +34,7 @@
 #include <cppuhelper/factory.hxx>
 #include <cppuhelper/implbase3.hxx>
 #include <cppuhelper/shlib.hxx>
+#include <cppuhelper/supportsservice.hxx>
 #include <cppuhelper/typeprovider.hxx>
 #include <rtl/instance.hxx>
 #include <rtl/unload.h>
@@ -258,13 +259,7 @@ sal_Bool OSingleFactoryHelper::supportsService(
     const OUString& ServiceName )
     throw(::com::sun::star::uno::RuntimeException)
 {
-    Sequence< OUString > seqServices = getSupportedServiceNames();
-    const OUString * pServices = seqServices.getConstArray();
-    for( sal_Int32 i = 0; i < seqServices.getLength(); i++ )
-        if( pServices[i] == ServiceName )
-            return sal_True;
-
-    return sal_False;
+    return cppu::supportsService(this, ServiceName);
 }
 
 // XServiceInfo
@@ -1012,9 +1007,7 @@ sal_Bool OFactoryProxyHelper::supportsService(const OUString& ServiceName)
     throw(::com::sun::star::uno::RuntimeException)
 {
     Reference<XServiceInfo > xInfo( xFactory, UNO_QUERY  );
-    if( xInfo.is() )
-        return xInfo->supportsService( ServiceName );
-    return sal_False;
+    return xInfo.is() && xInfo->supportsService( ServiceName );
 }
 
 // XServiceInfo
diff --git a/cppuhelper/source/gcc3.map b/cppuhelper/source/gcc3.map
index 4c48f56..7840b23 100644
--- a/cppuhelper/source/gcc3.map
+++ b/cppuhelper/source/gcc3.map
@@ -408,6 +408,11 @@ global:
         _ZThn*_N4cppu19OPropertySetHelper232enableChangeListenerNotificationEh;
 } UDK_3.7;
 
+UDK_3.9 { # LibO 3.7
+global:
+    _ZN4cppu15supportsServiceEPN3com3sun4star4lang12XServiceInfoERKN3rtl8OUStringE; # cppu::supportsService(com::sun::star::lang::XServiceInfo*, rtl::OUString const&)
+} UDK_3.8;
+
 # Unique libstdc++ symbols:
 GLIBCXX_3.4 {
     global:
diff --git a/cppuhelper/source/macro_expander.cxx b/cppuhelper/source/macro_expander.cxx
index 7a82dd0..ab2124c 100644
--- a/cppuhelper/source/macro_expander.cxx
+++ b/cppuhelper/source/macro_expander.cxx
@@ -34,6 +34,7 @@
 #include <cppuhelper/factory.hxx>
 #include <cppuhelper/compbase2.hxx>
 #include <cppuhelper/component_context.hxx>
+#include <cppuhelper/supportsservice.hxx>
 
 #include <com/sun/star/lang/XServiceInfo.hpp>
 #include <com/sun/star/util/XMacroExpander.hpp>
@@ -169,14 +170,7 @@ OUString Bootstrap_MacroExpander::getImplementationName()
 sal_Bool Bootstrap_MacroExpander::supportsService( OUString const & serviceName )
     throw (RuntimeException)
 {
-    Sequence< OUString > const & service_names = s_get_service_names();
-    OUString const * p = service_names.getConstArray();
-    for ( sal_Int32 nPos = service_names.getLength(); nPos--; )
-    {
-        if (p[ nPos ].equals( serviceName ))
-            return sal_True;
-    }
-    return sal_False;
+    return cppu::supportsService(this, serviceName);
 }
 //__________________________________________________________________________________________________
 Sequence< OUString > Bootstrap_MacroExpander::getSupportedServiceNames()
diff --git a/cppuhelper/source/supportsservice.cxx b/cppuhelper/source/supportsservice.cxx
new file mode 100644
index 0000000..9a37713
--- /dev/null
+++ b/cppuhelper/source/supportsservice.cxx
@@ -0,0 +1,40 @@
+/* -*- 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/.
+ */
+
+#include "sal/config.h"
+
+#include <cassert>
+
+#include "com/sun/star/lang/XServiceInfo.hpp"
+#include "com/sun/star/uno/Sequence.hxx"
+#include "cppuhelper/supportsservice.hxx"
+#include "rtl/ustring.hxx"
+#include "sal/types.h"
+
+namespace {
+
+namespace css = com::sun::star;
+
+}
+
+bool cppu::supportsService(
+    css::lang::XServiceInfo * implementation, rtl::OUString const & name)
+{
+    assert(implementation != 0);
+    css::uno::Sequence< rtl::OUString > s(
+        implementation->getSupportedServiceNames());
+    for (sal_Int32 i = 0; i != s.getLength(); ++i) {
+        if (s[i] == name) {
+            return true;
+        }
+    }
+    return false;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cppuhelper/test/cfg_test.cxx b/cppuhelper/test/cfg_test.cxx
index ac976be..1f0830b 100644
--- a/cppuhelper/test/cfg_test.cxx
+++ b/cppuhelper/test/cfg_test.cxx
@@ -40,6 +40,7 @@
 #include <cppuhelper/implementationentry.hxx>
 #include <cppuhelper/bootstrap.hxx>
 #include <cppuhelper/implbase2.hxx>
+#include <cppuhelper/supportsservice.hxx>
 
 #include <com/sun/star/lang/XMultiComponentFactory.hpp>
 #include <com/sun/star/lang/XInitialization.hpp>
@@ -154,14 +155,7 @@ Sequence< OUString > ServiceImpl0::getSupportedServiceNames()
 sal_Bool ServiceImpl0::supportsService( const OUString & rServiceName )
     throw(::com::sun::star::uno::RuntimeException)
 {
-    const Sequence< OUString > & rSNL = getSupportedServiceNames();
-    const OUString * pArray = rSNL.getConstArray();
-    for ( sal_Int32 nPos = rSNL.getLength(); nPos--; )
-    {
-        if (pArray[nPos] == rServiceName)
-            return sal_True;
-    }
-    return sal_False;
+    return cppu::supportsService(this, rServiceName);
 }
 
 //==================================================================================================
diff --git a/cppuhelper/test/testcmp/TestComponent.cxx b/cppuhelper/test/testcmp/TestComponent.cxx
index a5f7477..e23069a 100644
--- a/cppuhelper/test/testcmp/TestComponent.cxx
+++ b/cppuhelper/test/testcmp/TestComponent.cxx
@@ -29,6 +29,7 @@
 
 #include "cppuhelper/implbase1.hxx"
 #include "cppuhelper/implementationentry.hxx"
+#include "cppuhelper/supportsservice.hxx"
 
 #include "com/sun/star/lang/XMultiComponentFactory.hpp"
 #include "com/sun/star/lang/XServiceInfo.hpp"
@@ -146,15 +147,7 @@ uno::Any SAL_CALL TestComponent::queryInterface(uno::Type const & rType ) throw
 sal_Bool SAL_CALL TestComponent::supportsService(rtl::OUString const & ServiceName)
     throw (uno::RuntimeException)
 {
-    uno::Sequence<rtl::OUString> serviceNames = getSupportedServiceNames_Static();
-
-    for (sal_Int32 n = 0; n < serviceNames.getLength(); ++n)
-    {
-        if (serviceNames[n] == ServiceName)
-            return true;
-    }
-
-    return false;
+    return cppu::supportsService(this, ServiceName);
 }
 
 uno::Sequence<rtl::OUString> SAL_CALL TestComponent::getSupportedServiceNames()


More information about the Libreoffice-commits mailing list