diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2012-09-14 19:27:00 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2012-09-14 19:32:30 +0200 |
commit | 2171077c0c3c43a61546ab2c0ae68ba63c5112f7 (patch) | |
tree | 09461b7faec131f25b223b4bcbb2bf5b2a701763 /cppuhelper/source | |
parent | 3ed834ae87eca0f6c486666699112a95edb74abb (diff) |
Introduce cppu::supportsService helper, adapt some call-sites
...more to follow (easy hack?)
Change-Id: Icb02626495701a3905c124c7368b98c3258e91b2
Diffstat (limited to 'cppuhelper/source')
-rw-r--r-- | cppuhelper/source/defaultbootstrap.cxx | 17 | ||||
-rw-r--r-- | cppuhelper/source/factory.cxx | 13 | ||||
-rw-r--r-- | cppuhelper/source/gcc3.map | 5 | ||||
-rw-r--r-- | cppuhelper/source/macro_expander.cxx | 10 | ||||
-rw-r--r-- | cppuhelper/source/supportsservice.cxx | 40 |
5 files changed, 53 insertions, 32 deletions
diff --git a/cppuhelper/source/defaultbootstrap.cxx b/cppuhelper/source/defaultbootstrap.cxx index ba558c0b5909..ccf744769d4b 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 dc46aa8a09f5..6747892e3efc 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 4c48f5626eb0..7840b2370f5f 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 7a82dd0ce888..ab2124cda742 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 000000000000..9a3771384d28 --- /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: */ |