diff options
Diffstat (limited to 'cppuhelper')
134 files changed, 33509 insertions, 0 deletions
diff --git a/cppuhelper/inc/cppuhelper/access_control.hxx b/cppuhelper/inc/cppuhelper/access_control.hxx new file mode 100644 index 000000000000..acd5008b83de --- /dev/null +++ b/cppuhelper/inc/cppuhelper/access_control.hxx @@ -0,0 +1,127 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CPPUHELPER_ACCESS_CONTROL_HXX_ +#define _CPPUHELPER_ACCESS_CONTROL_HXX_ + +#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/security/XAccessController.hpp> + + +namespace cppu +{ + +/** Helper class retriving access controller singleton from component context. +*/ +class AccessControl +{ + ::com::sun::star::uno::Reference< ::com::sun::star::security::XAccessController > m_xController; + +public: + /** Ctor. + + @param xContext component context to retrieve access controller singleton + */ + AccessControl( + ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XComponentContext > const & xContext ) + SAL_THROW( (::com::sun::star::uno::RuntimeException) ); + /** Ctor. + + @param xController access controller + */ + AccessControl( + ::com::sun::star::uno::Reference< + ::com::sun::star::security::XAccessController > const & xController ) + SAL_THROW( (::com::sun::star::uno::RuntimeException) ); + /** Copy ctor. + + @param another object + */ + AccessControl( ::cppu::AccessControl const & ac ) + SAL_THROW( (::com::sun::star::uno::RuntimeException) ); + + /** Clears the access controller reference being used. + */ + inline void SAL_CALL clear() SAL_THROW( () ) + { m_xController.clear(); } + + /** Returns access to the access controller reference being used. + + @return access controller + */ + inline ::com::sun::star::uno::Reference< + ::com::sun::star::security::XAccessController > const & SAL_CALL get() const SAL_THROW( () ) + { return m_xController; } + + /** Returns access to the access controller reference being used. + + @return access controller + */ + inline ::com::sun::star::security::XAccessController * SAL_CALL operator -> () const SAL_THROW( () ) + { return m_xController.get(); } + + + /** A com.sun.star.security.RuntimePermission is for runtime permissions. + A RuntimePermission contains a name (also referred to as a "target name") but no + actions list; you either have the named permission or you don't. + + @param name name of permission + */ + void SAL_CALL checkRuntimePermission( + ::rtl::OUString const & name ) + SAL_THROW( (::com::sun::star::uno::RuntimeException) ); + + /** A com.sun.star.io.FilePermission represents access to a file or directory. + A FilePermission consists of a file url and a set of actions valid for that pathname. + + @param url file url + @param actions actions list + */ + void SAL_CALL checkFilePermission( + ::rtl::OUString const & url, + ::rtl::OUString const & actions ) + SAL_THROW( (::com::sun::star::uno::RuntimeException) ); + + /** A com.sun.star.connection.SocketPermission represents access to a network via sockets. + A SocketPermission consists of a host specification and a set of "actions" + specifying ways to connect to that host. + + @param host host and optional portrange + @param actions actions list + */ + void SAL_CALL checkSocketPermission( + ::rtl::OUString const & host, + ::rtl::OUString const & actions ) + SAL_THROW( (::com::sun::star::uno::RuntimeException) ); +}; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/inc/cppuhelper/basemutex.hxx b/cppuhelper/inc/cppuhelper/basemutex.hxx new file mode 100644 index 000000000000..0b94deda0174 --- /dev/null +++ b/cppuhelper/inc/cppuhelper/basemutex.hxx @@ -0,0 +1,52 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _CPPUHELPER_BASEMUTEX_HXX_ +#define _CPPUHELPER_BASEMUTEX_HXX_ + +#include <osl/mutex.hxx> + +namespace cppu +{ + /** base class for all classes who want derive from + ::cppu::WeakComponentImplHelperXX. + + Implmentation classes have first to derive from BaseMutex and then from + ::cppu::WeakComponentImplHelperXX to ensure that the BaseMutex is completely + initialized when the mutex is used to intialize the + ::cppu::WeakComponentImplHelperXX + */ + class BaseMutex + { + protected: + mutable ::osl::Mutex m_aMutex; + }; +} +#endif // _CPPUHELPER_BASEMUTEX_HXX_ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/inc/cppuhelper/bootstrap.hxx b/cppuhelper/inc/cppuhelper/bootstrap.hxx new file mode 100644 index 000000000000..76a0c32a4905 --- /dev/null +++ b/cppuhelper/inc/cppuhelper/bootstrap.hxx @@ -0,0 +1,226 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CPPUHELPER_BOOTSTRAP_HXX_ +#define _CPPUHELPER_BOOTSTRAP_HXX_ + +#include "sal/config.h" +#include "com/sun/star/uno/Exception.hpp" +#include "com/sun/star/uno/Reference.hxx" +#include "rtl/ustring.hxx" +#include "sal/types.h" + +namespace com { namespace sun { namespace star { + namespace container { class XHierarchicalNameAccess; } + namespace registry { class XSimpleRegistry; } + namespace uno { class XComponentContext; } +} } } + +namespace cppu +{ + +/** Creates a simple registry service instance. + + @rBootstrapPath optional bootstrap path for initial components + @return simple registry service instance +*/ +::com::sun::star::uno::Reference< ::com::sun::star::registry::XSimpleRegistry > +SAL_CALL createSimpleRegistry( + const ::rtl::OUString & rBootstrapPath = ::rtl::OUString() ) + SAL_THROW( () ); + +/** Creates a nested registry service instance. + + @rBootstrapPath optional bootstrap path for initial components + @return nested registry service instance +*/ +::com::sun::star::uno::Reference< ::com::sun::star::registry::XSimpleRegistry > +SAL_CALL createNestedRegistry( + const ::rtl::OUString & rBootstrapPath = ::rtl::OUString() ) + SAL_THROW( () ); + +/** Installs type description manager instance, i.e. registers a callback at cppu core. + + @param xTDMgr manager instance + @return true, if successfully registered +*/ +sal_Bool SAL_CALL installTypeDescriptionManager( + ::com::sun::star::uno::Reference< ::com::sun::star::container::XHierarchicalNameAccess > const & xTDMgr ) + SAL_THROW( () ); + +/** Bootstraps an initial component context with service manager upon a given registry. + This includes insertion of initial services: + - (registry) service manager, shared lib loader, + - simple registry, nested registry, + - implementation registration + - registry typedescription provider, typedescription manager (also installs it into cppu core) + + @param xRegistry registry for service manager and singleton objects of context (may be null) + @param rBootstrapPath optional bootstrap path for initial components + @return component context +*/ +::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > SAL_CALL +bootstrap_InitialComponentContext( + ::com::sun::star::uno::Reference< ::com::sun::star::registry::XSimpleRegistry > const & xRegistry, + ::rtl::OUString const & rBootstrapPath = ::rtl::OUString() ) + SAL_THROW( (::com::sun::star::uno::Exception) ); + + +/** Bootstraps an initial component context with service manager upon default types and + services registry. + This includes insertion of initial services: + - (registry) service manager, shared lib loader, + - simple registry, nested registry, + - implementation registration + - registry typedescription provider, typedescription manager (also installs it into cppu core) + + This function tries to find its parameters via these bootstrap variables: + + - UNO_TYPES -- a space separated list of file urls of type rdbs + - UNO_SERVICES -- a space separated list of file urls of service rdbs + - UNO_WRITERDB -- a file url of a write rdb (e.g. user.rdb) + + Please look at http://udk.openoffice.org/common/man/concept/uno_default_bootstrapping.html + for further info. + + @return component context +*/ +::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > SAL_CALL +defaultBootstrap_InitialComponentContext() SAL_THROW( (::com::sun::star::uno::Exception) ); + + +/** Bootstraps an initial component context with service manager upon default types and + services registry. + This includes insertion of initial services: + - (registry) service manager, shared lib loader, + - simple registry, nested registry, + - implementation registration + - registry typedescription provider, typedescription manager (also installs it into cppu core) + + This function tries to find its parameters via these bootstrap variables: + + - UNO_TYPES -- a space separated list of file urls of type rdbs + - UNO_SERVICES -- a space separated list of file urls of service rdbs + - UNO_WRITERDB -- a file url of a write rdb (e.g. user.rdb) + + Please look at http://udk.openoffice.org/common/man/concept/uno_default_bootstrapping.html + for further info. + + @param iniFile ini filename to get bootstrap variables + @return component context +*/ +::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > SAL_CALL +defaultBootstrap_InitialComponentContext(const ::rtl::OUString & iniFile) SAL_THROW( (::com::sun::star::uno::Exception) ); + +/** + * An exception indicating a bootstrap error. + * + * @since UDK 3.2.0 + */ +class BootstrapException +{ +public: + /** + * Constructs a BootstrapException. + */ + BootstrapException(); + + /** + * Constructs a BootstrapException with the specified detail message. + * + * @param rMessage + * A message containing any details about the exception. + */ + BootstrapException( const ::rtl::OUString & rMessage ); + + /** + * Copy constructs a BootstrapException. + */ + BootstrapException( const BootstrapException & e ); + + /** + * Destructs a BootstrapException. + */ + virtual ~BootstrapException(); + + /** + * Assigns a BootstrapException. + */ + BootstrapException & operator=( const BootstrapException & e ); + + /** Gets the message. + + @return + A reference to the message. The reference is valid for the lifetime of + this BootstrapException. + */ + const ::rtl::OUString & getMessage() const; + +private: + ::rtl::OUString m_aMessage; +}; + +/** + * Bootstraps the component context from a UNO installation. + * + * @return a bootstrapped component context + * @exception BootstrapException + * Thrown in case bootstrap() signals an exception due to a + * bootstrap error. + * + * @since UDK 3.2.0 + */ +::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > +SAL_CALL bootstrap(); + +/** + * Helper function to expand vnd.sun.star.expand URLs in contexts where no + * properly bootstrapped UNO is (yet) available. + * + * @internal + * + * @param uri + * Some URI (but not a URI reference). + * + * @return + * If uri is a vnd.sun.star.expand URL, then the expansion of that URL is + * returned; expansion may lead to a string that is not a legal URI. Otherwise, + * the uri is returned unchanged. + * + * @exception com::sun::star::lang::IllegalArgumentException + * If uri is a vnd.sun.star.expand URL that contains unknown macros. + * + * @since UDK 3.2.8 + */ +::rtl::OUString +SAL_CALL bootstrap_expandUri(::rtl::OUString const & uri); + +} // end namespace cppu + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/inc/cppuhelper/compbase.hxx b/cppuhelper/inc/cppuhelper/compbase.hxx new file mode 100644 index 000000000000..54db23a4e5d3 --- /dev/null +++ b/cppuhelper/inc/cppuhelper/compbase.hxx @@ -0,0 +1,118 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CPPUHELPER_COMPBASE_HXX_ +#define _CPPUHELPER_COMPBASE_HXX_ + +#include <cppuhelper/compbase_ex.hxx> +#include <cppuhelper/implbase.hxx> + +/* This header should not be used anymore. + @deprecated +*/ + +//================================================================================================== +/** @internal */ +#define __DEF_COMPIMPLHELPER_A( N ) \ +namespace cppu \ +{ \ +template< __CLASS_IFC##N > \ +class SAL_NO_VTABLE WeakComponentImplHelper##N \ + : public ::cppu::WeakComponentImplHelperBase \ + , public ImplHelperBase##N< __IFC##N > \ +{ \ + static ClassData##N s_aCD; \ +public: \ + WeakComponentImplHelper##N( ::osl::Mutex & rMutex ) SAL_THROW( () ) \ + : WeakComponentImplHelperBase( rMutex ) \ + {} \ + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) \ + { \ + ::com::sun::star::uno::Any aRet( getClassData( s_aCD ).query( rType, (ImplHelperBase##N< __IFC##N > *)this ) ); \ + if (aRet.hasValue()) \ + return aRet; \ + return WeakComponentImplHelperBase::queryInterface( rType ); \ + } \ + virtual void SAL_CALL acquire() throw () \ + { WeakComponentImplHelperBase::acquire(); } \ + virtual void SAL_CALL release() throw () \ + { WeakComponentImplHelperBase::release(); } \ + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) \ + { return getClassData( s_aCD ).getTypes(); } \ + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) \ + { return getClassData( s_aCD ).getImplementationId(); } \ +}; \ +template< __CLASS_IFC##N > \ +class SAL_NO_VTABLE WeakAggComponentImplHelper##N \ + : public ::cppu::WeakAggComponentImplHelperBase \ + , public ImplHelperBase##N< __IFC##N > \ +{ \ + static ClassData##N s_aCD; \ +public: \ + WeakAggComponentImplHelper##N( ::osl::Mutex & rMutex ) SAL_THROW( () ) \ + : WeakAggComponentImplHelperBase( rMutex ) \ + {} \ + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) \ + { return WeakAggComponentImplHelperBase::queryInterface( rType ); } \ + virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) \ + { \ + ::com::sun::star::uno::Any aRet( getClassData( s_aCD ).query( rType, (ImplHelperBase##N< __IFC##N > *)this ) ); \ + if (aRet.hasValue()) \ + return aRet; \ + return WeakAggComponentImplHelperBase::queryAggregation( rType ); \ + } \ + virtual void SAL_CALL acquire() throw () \ + { WeakAggComponentImplHelperBase::acquire(); } \ + virtual void SAL_CALL release() throw () \ + { WeakAggComponentImplHelperBase::release(); } \ + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) \ + { return getClassData( s_aCD ).getTypes(); } \ + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) \ + { return getClassData( s_aCD ).getImplementationId(); } \ +}; + +//================================================================================================== +/** @internal */ +#define __DEF_COMPIMPLHELPER_B( N ) \ +template< __CLASS_IFC##N > \ +ClassData##N WeakComponentImplHelper##N< __IFC##N >::s_aCD = ClassData##N( 4 ); \ +template< __CLASS_IFC##N > \ +ClassData##N WeakAggComponentImplHelper##N< __IFC##N >::s_aCD = ClassData##N( 3 ); +//================================================================================================== +/** @internal */ +#define __DEF_COMPIMPLHELPER_C( N ) \ +} +//================================================================================================== +/** @internal */ +#define __DEF_COMPIMPLHELPER( N ) \ +__DEF_COMPIMPLHELPER_A( N ) \ +__DEF_COMPIMPLHELPER_B( N ) \ +__DEF_COMPIMPLHELPER_C( N ) + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/inc/cppuhelper/compbase1.hxx b/cppuhelper/inc/cppuhelper/compbase1.hxx new file mode 100644 index 000000000000..0f146f4eafc9 --- /dev/null +++ b/cppuhelper/inc/cppuhelper/compbase1.hxx @@ -0,0 +1,140 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CPPUHELPER_COMPBASE1_HXX_ +#define _CPPUHELPER_COMPBASE1_HXX_ + +#include <cppuhelper/implbase1.hxx> +#include <cppuhelper/compbase_ex.hxx> +/* +__DEF_COMPIMPLHELPER_EX( 1 ) +*/ + +namespace cppu +{ + +// Suppress warnings about hidden functions in case any of the IfcN has +// functions named dispose, addEventListener, or removeEventListener: +#if defined __SUNPRO_CC +#pragma disable_warn +#endif + + /** Implementation helper supporting ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::lang::XComponent. + + Upon disposing objects of this class, sub-classes receive a disposing() + call. Objects of this class can be held weakly, i.e. by a + ::com::sun::star::uno::WeakReference. + + @attention + The life-cycle of the passed mutex reference has to be longer than objects of this class. + + @derive + Inherit from this class giving your interface(s) to be implemented as template argument(s). + Your sub class defines method implementations for these interface(s). + */ + template< class Ifc1 > + class SAL_NO_VTABLE WeakComponentImplHelper1 + : public WeakComponentImplHelperBase + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData1< Ifc1, WeakComponentImplHelper1< Ifc1 > > > {}; + public: + inline WeakComponentImplHelper1( ::osl::Mutex & rMutex ) throw () + : WeakComponentImplHelperBase( rMutex ) + {} + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return WeakComponentImplHelper_query( rType, cd::get(), this, (WeakComponentImplHelperBase *)this ); } + virtual void SAL_CALL acquire() throw () + { WeakComponentImplHelperBase::acquire(); } + virtual void SAL_CALL release() throw () + { WeakComponentImplHelperBase::release(); } + virtual void SAL_CALL dispose()throw (::com::sun::star::uno::RuntimeException) + { WeakComponentImplHelperBase::dispose(); } + virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener)throw (::com::sun::star::uno::RuntimeException) + { WeakComponentImplHelperBase::addEventListener(xListener); } + virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener)throw (::com::sun::star::uno::RuntimeException) + { WeakComponentImplHelperBase::removeEventListener(xListener); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return WeakComponentImplHelper_getTypes( cd::get() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; + +#if defined __SUNPRO_CC +#pragma enable_warn +#endif + + /** Implementation helper supporting ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::lang::XComponent. + + Upon disposing objects of this class, sub-classes receive a disposing() + call. Objects of this class can be held weakly, i.e. by a + ::com::sun::star::uno::WeakReference. Object of this class can be + aggregated, i.e. incoming queryInterface() calls are delegated. + + @attention + The life-cycle of the passed mutex reference has to be longer than objects of this class. + + @derive + Inherit from this class giving your interface(s) to be implemented as template argument(s). + Your sub class defines method implementations for these interface(s). + + @deprecated + */ + template< class Ifc1 > + class SAL_NO_VTABLE WeakAggComponentImplHelper1 + : public WeakAggComponentImplHelperBase + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData1< Ifc1, WeakAggComponentImplHelper1< Ifc1 > > > {}; + public: + inline WeakAggComponentImplHelper1( ::osl::Mutex & rMutex ) throw () + : WeakAggComponentImplHelperBase( rMutex ) + {} + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return WeakAggComponentImplHelperBase::queryInterface( rType ); } + virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return WeakAggComponentImplHelper_queryAgg( rType, cd::get(), this, (WeakAggComponentImplHelperBase *)this ); } + virtual void SAL_CALL acquire() throw () + { WeakAggComponentImplHelperBase::acquire(); } + virtual void SAL_CALL release() throw () + { WeakAggComponentImplHelperBase::release(); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return WeakAggComponentImplHelper_getTypes( cd::get() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/inc/cppuhelper/compbase10.hxx b/cppuhelper/inc/cppuhelper/compbase10.hxx new file mode 100644 index 000000000000..9c3fd193af1f --- /dev/null +++ b/cppuhelper/inc/cppuhelper/compbase10.hxx @@ -0,0 +1,140 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CPPUHELPER_COMPBASE10_HXX_ +#define _CPPUHELPER_COMPBASE10_HXX_ + +#include <cppuhelper/implbase10.hxx> +#include <cppuhelper/compbase_ex.hxx> +/* +__DEF_COMPIMPLHELPER_EX( 10 ) +*/ + +namespace cppu +{ + +// Suppress warnings about hidden functions in case any of the IfcN has +// functions named dispose, addEventListener, or removeEventListener: +#if defined __SUNPRO_CC +#pragma disable_warn +#endif + + /** Implementation helper supporting ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::lang::XComponent. + + Upon disposing objects of this class, sub-classes receive a disposing() + call. Objects of this class can be held weakly, i.e. by a + ::com::sun::star::uno::WeakReference. + + @attention + The life-cycle of the passed mutex reference has to be longer than objects of this class. + + @derive + Inherit from this class giving your interface(s) to be implemented as template argument(s). + Your sub class defines method implementations for these interface(s). + */ + template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9, class Ifc10 > + class SAL_NO_VTABLE WeakComponentImplHelper10 + : public WeakComponentImplHelperBase + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9, public Ifc10 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData10< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, WeakComponentImplHelper10<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10> > > {}; + public: + inline WeakComponentImplHelper10( ::osl::Mutex & rMutex ) throw () + : WeakComponentImplHelperBase( rMutex ) + {} + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return WeakComponentImplHelper_query( rType, cd::get(), this, (WeakComponentImplHelperBase *)this ); } + virtual void SAL_CALL acquire() throw () + { WeakComponentImplHelperBase::acquire(); } + virtual void SAL_CALL release() throw () + { WeakComponentImplHelperBase::release(); } + virtual void SAL_CALL dispose()throw (::com::sun::star::uno::RuntimeException) + { WeakComponentImplHelperBase::dispose(); } + virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener)throw (::com::sun::star::uno::RuntimeException) + { WeakComponentImplHelperBase::addEventListener(xListener); } + virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener)throw (::com::sun::star::uno::RuntimeException) + { WeakComponentImplHelperBase::removeEventListener(xListener); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return WeakComponentImplHelper_getTypes( cd::get() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; + +#if defined __SUNPRO_CC +#pragma enable_warn +#endif + + /** Implementation helper supporting ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::lang::XComponent. + + Upon disposing objects of this class, sub-classes receive a disposing() + call. Objects of this class can be held weakly, i.e. by a + ::com::sun::star::uno::WeakReference. Object of this class can be + aggregated, i.e. incoming queryInterface() calls are delegated. + + @attention + The life-cycle of the passed mutex reference has to be longer than objects of this class. + + @derive + Inherit from this class giving your interface(s) to be implemented as template argument(s). + Your sub class defines method implementations for these interface(s). + + @deprecated + */ + template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9, class Ifc10 > + class SAL_NO_VTABLE WeakAggComponentImplHelper10 + : public WeakAggComponentImplHelperBase + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9, public Ifc10 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData10< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, WeakAggComponentImplHelper10<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10> > > {}; + public: + inline WeakAggComponentImplHelper10( ::osl::Mutex & rMutex ) throw () + : WeakAggComponentImplHelperBase( rMutex ) + {} + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return WeakAggComponentImplHelperBase::queryInterface( rType ); } + virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return WeakAggComponentImplHelper_queryAgg( rType, cd::get(), this, (WeakAggComponentImplHelperBase *)this ); } + virtual void SAL_CALL acquire() throw () + { WeakAggComponentImplHelperBase::acquire(); } + virtual void SAL_CALL release() throw () + { WeakAggComponentImplHelperBase::release(); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return WeakAggComponentImplHelper_getTypes( cd::get() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/inc/cppuhelper/compbase11.hxx b/cppuhelper/inc/cppuhelper/compbase11.hxx new file mode 100644 index 000000000000..efb9a9f6b321 --- /dev/null +++ b/cppuhelper/inc/cppuhelper/compbase11.hxx @@ -0,0 +1,140 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CPPUHELPER_COMPBASE11_HXX_ +#define _CPPUHELPER_COMPBASE11_HXX_ + +#include <cppuhelper/implbase11.hxx> +#include <cppuhelper/compbase_ex.hxx> +/* +__DEF_COMPIMPLHELPER_EX( 11 ) +*/ + +namespace cppu +{ + +// Suppress warnings about hidden functions in case any of the IfcN has +// functions named dispose, addEventListener, or removeEventListener: +#if defined __SUNPRO_CC +#pragma disable_warn +#endif + + /** Implementation helper supporting ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::lang::XComponent. + + Upon disposing objects of this class, sub-classes receive a disposing() + call. Objects of this class can be held weakly, i.e. by a + ::com::sun::star::uno::WeakReference. + + @attention + The life-cycle of the passed mutex reference has to be longer than objects of this class. + + @derive + Inherit from this class giving your interface(s) to be implemented as template argument(s). + Your sub class defines method implementations for these interface(s). + */ + template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9, class Ifc10, class Ifc11 > + class SAL_NO_VTABLE WeakComponentImplHelper11 + : public WeakComponentImplHelperBase + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9, public Ifc10, public Ifc11 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData11< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, WeakComponentImplHelper11<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11> > > {}; + public: + inline WeakComponentImplHelper11( ::osl::Mutex & rMutex ) throw () + : WeakComponentImplHelperBase( rMutex ) + {} + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return WeakComponentImplHelper_query( rType, cd::get(), this, (WeakComponentImplHelperBase *)this ); } + virtual void SAL_CALL acquire() throw () + { WeakComponentImplHelperBase::acquire(); } + virtual void SAL_CALL release() throw () + { WeakComponentImplHelperBase::release(); } + virtual void SAL_CALL dispose()throw (::com::sun::star::uno::RuntimeException) + { WeakComponentImplHelperBase::dispose(); } + virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener)throw (::com::sun::star::uno::RuntimeException) + { WeakComponentImplHelperBase::addEventListener(xListener); } + virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener)throw (::com::sun::star::uno::RuntimeException) + { WeakComponentImplHelperBase::removeEventListener(xListener); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return WeakComponentImplHelper_getTypes( cd::get() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; + +#if defined __SUNPRO_CC +#pragma enable_warn +#endif + + /** Implementation helper supporting ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::lang::XComponent. + + Upon disposing objects of this class, sub-classes receive a disposing() + call. Objects of this class can be held weakly, i.e. by a + ::com::sun::star::uno::WeakReference. Object of this class can be + aggregated, i.e. incoming queryInterface() calls are delegated. + + @attention + The life-cycle of the passed mutex reference has to be longer than objects of this class. + + @derive + Inherit from this class giving your interface(s) to be implemented as template argument(s). + Your sub class defines method implementations for these interface(s). + + @deprecated + */ + template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9, class Ifc10, class Ifc11 > + class SAL_NO_VTABLE WeakAggComponentImplHelper11 + : public WeakAggComponentImplHelperBase + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9, public Ifc10, public Ifc11 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData11< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, WeakAggComponentImplHelper11<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11> > > {}; + public: + inline WeakAggComponentImplHelper11( ::osl::Mutex & rMutex ) throw () + : WeakAggComponentImplHelperBase( rMutex ) + {} + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return WeakAggComponentImplHelperBase::queryInterface( rType ); } + virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return WeakAggComponentImplHelper_queryAgg( rType, cd::get(), this, (WeakAggComponentImplHelperBase *)this ); } + virtual void SAL_CALL acquire() throw () + { WeakAggComponentImplHelperBase::acquire(); } + virtual void SAL_CALL release() throw () + { WeakAggComponentImplHelperBase::release(); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return WeakAggComponentImplHelper_getTypes( cd::get() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/inc/cppuhelper/compbase12.hxx b/cppuhelper/inc/cppuhelper/compbase12.hxx new file mode 100644 index 000000000000..8a43f50098a1 --- /dev/null +++ b/cppuhelper/inc/cppuhelper/compbase12.hxx @@ -0,0 +1,140 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CPPUHELPER_COMPBASE12_HXX_ +#define _CPPUHELPER_COMPBASE12_HXX_ + +#include <cppuhelper/implbase12.hxx> +#include <cppuhelper/compbase_ex.hxx> +/* +__DEF_COMPIMPLHELPER_EX( 12 ) +*/ + +namespace cppu +{ + +// Suppress warnings about hidden functions in case any of the IfcN has +// functions named dispose, addEventListener, or removeEventListener: +#if defined __SUNPRO_CC +#pragma disable_warn +#endif + + /** Implementation helper supporting ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::lang::XComponent. + + Upon disposing objects of this class, sub-classes receive a disposing() + call. Objects of this class can be held weakly, i.e. by a + ::com::sun::star::uno::WeakReference. + + @attention + The life-cycle of the passed mutex reference has to be longer than objects of this class. + + @derive + Inherit from this class giving your interface(s) to be implemented as template argument(s). + Your sub class defines method implementations for these interface(s). + */ + template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9, class Ifc10, class Ifc11, class Ifc12 > + class SAL_NO_VTABLE WeakComponentImplHelper12 + : public WeakComponentImplHelperBase + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9, public Ifc10, public Ifc11, public Ifc12 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData12< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, Ifc12, WeakComponentImplHelper12<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, Ifc12> > > {}; + public: + inline WeakComponentImplHelper12( ::osl::Mutex & rMutex ) throw () + : WeakComponentImplHelperBase( rMutex ) + {} + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return WeakComponentImplHelper_query( rType, cd::get(), this, (WeakComponentImplHelperBase *)this ); } + virtual void SAL_CALL acquire() throw () + { WeakComponentImplHelperBase::acquire(); } + virtual void SAL_CALL release() throw () + { WeakComponentImplHelperBase::release(); } + virtual void SAL_CALL dispose()throw (::com::sun::star::uno::RuntimeException) + { WeakComponentImplHelperBase::dispose(); } + virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener)throw (::com::sun::star::uno::RuntimeException) + { WeakComponentImplHelperBase::addEventListener(xListener); } + virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener)throw (::com::sun::star::uno::RuntimeException) + { WeakComponentImplHelperBase::removeEventListener(xListener); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return WeakComponentImplHelper_getTypes( cd::get() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; + +#if defined __SUNPRO_CC +#pragma enable_warn +#endif + + /** Implementation helper supporting ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::lang::XComponent. + + Upon disposing objects of this class, sub-classes receive a disposing() + call. Objects of this class can be held weakly, i.e. by a + ::com::sun::star::uno::WeakReference. Object of this class can be + aggregated, i.e. incoming queryInterface() calls are delegated. + + @attention + The life-cycle of the passed mutex reference has to be longer than objects of this class. + + @derive + Inherit from this class giving your interface(s) to be implemented as template argument(s). + Your sub class defines method implementations for these interface(s). + + @deprecated + */ + template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9, class Ifc10, class Ifc11, class Ifc12 > + class SAL_NO_VTABLE WeakAggComponentImplHelper12 + : public WeakAggComponentImplHelperBase + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9, public Ifc10, public Ifc11, public Ifc12 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData12< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, Ifc12, WeakAggComponentImplHelper12<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, Ifc12> > > {}; + public: + inline WeakAggComponentImplHelper12( ::osl::Mutex & rMutex ) throw () + : WeakAggComponentImplHelperBase( rMutex ) + {} + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return WeakAggComponentImplHelperBase::queryInterface( rType ); } + virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return WeakAggComponentImplHelper_queryAgg( rType, cd::get(), this, (WeakAggComponentImplHelperBase *)this ); } + virtual void SAL_CALL acquire() throw () + { WeakAggComponentImplHelperBase::acquire(); } + virtual void SAL_CALL release() throw () + { WeakAggComponentImplHelperBase::release(); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return WeakAggComponentImplHelper_getTypes( cd::get() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/inc/cppuhelper/compbase2.hxx b/cppuhelper/inc/cppuhelper/compbase2.hxx new file mode 100644 index 000000000000..c102f9726367 --- /dev/null +++ b/cppuhelper/inc/cppuhelper/compbase2.hxx @@ -0,0 +1,140 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CPPUHELPER_COMPBASE2_HXX_ +#define _CPPUHELPER_COMPBASE2_HXX_ + +#include <cppuhelper/implbase2.hxx> +#include <cppuhelper/compbase_ex.hxx> +/* +__DEF_COMPIMPLHELPER_EX( 2 ) +*/ + +namespace cppu +{ + +// Suppress warnings about hidden functions in case any of the IfcN has +// functions named dispose, addEventListener, or removeEventListener: +#if defined __SUNPRO_CC +#pragma disable_warn +#endif + + /** Implementation helper supporting ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::lang::XComponent. + + Upon disposing objects of this class, sub-classes receive a disposing() + call. Objects of this class can be held weakly, i.e. by a + ::com::sun::star::uno::WeakReference. + + @attention + The life-cycle of the passed mutex reference has to be longer than objects of this class. + + @derive + Inherit from this class giving your interface(s) to be implemented as template argument(s). + Your sub class defines method implementations for these interface(s). + */ + template< class Ifc1, class Ifc2 > + class SAL_NO_VTABLE WeakComponentImplHelper2 + : public WeakComponentImplHelperBase + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData2 < Ifc1, Ifc2, WeakComponentImplHelper2<Ifc1, Ifc2> > > {}; + public: + inline WeakComponentImplHelper2( ::osl::Mutex & rMutex ) throw () + : WeakComponentImplHelperBase( rMutex ) + {} + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return WeakComponentImplHelper_query( rType, cd::get(), this, (WeakComponentImplHelperBase *)this ); } + virtual void SAL_CALL acquire() throw () + { WeakComponentImplHelperBase::acquire(); } + virtual void SAL_CALL release() throw () + { WeakComponentImplHelperBase::release(); } + virtual void SAL_CALL dispose()throw (::com::sun::star::uno::RuntimeException) + { WeakComponentImplHelperBase::dispose(); } + virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener)throw (::com::sun::star::uno::RuntimeException) + { WeakComponentImplHelperBase::addEventListener(xListener); } + virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener)throw (::com::sun::star::uno::RuntimeException) + { WeakComponentImplHelperBase::removeEventListener(xListener); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return WeakComponentImplHelper_getTypes( cd::get() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; + +#if defined __SUNPRO_CC +#pragma enable_warn +#endif + + /** Implementation helper supporting ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::lang::XComponent. + + Upon disposing objects of this class, sub-classes receive a disposing() + call. Objects of this class can be held weakly, i.e. by a + ::com::sun::star::uno::WeakReference. Object of this class can be + aggregated, i.e. incoming queryInterface() calls are delegated. + + @attention + The life-cycle of the passed mutex reference has to be longer than objects of this class. + + @derive + Inherit from this class giving your interface(s) to be implemented as template argument(s). + Your sub class defines method implementations for these interface(s). + + @deprecated + */ + template< class Ifc1, class Ifc2 > + class SAL_NO_VTABLE WeakAggComponentImplHelper2 + : public WeakAggComponentImplHelperBase + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData2 < Ifc1, Ifc2, WeakAggComponentImplHelper2<Ifc1, Ifc2> > > {}; + public: + inline WeakAggComponentImplHelper2( ::osl::Mutex & rMutex ) throw () + : WeakAggComponentImplHelperBase( rMutex ) + {} + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return WeakAggComponentImplHelperBase::queryInterface( rType ); } + virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return WeakAggComponentImplHelper_queryAgg( rType, cd::get(), this, (WeakAggComponentImplHelperBase *)this ); } + virtual void SAL_CALL acquire() throw () + { WeakAggComponentImplHelperBase::acquire(); } + virtual void SAL_CALL release() throw () + { WeakAggComponentImplHelperBase::release(); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return WeakAggComponentImplHelper_getTypes( cd::get() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/inc/cppuhelper/compbase3.hxx b/cppuhelper/inc/cppuhelper/compbase3.hxx new file mode 100644 index 000000000000..9e8c18e754a2 --- /dev/null +++ b/cppuhelper/inc/cppuhelper/compbase3.hxx @@ -0,0 +1,140 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CPPUHELPER_COMPBASE3_HXX_ +#define _CPPUHELPER_COMPBASE3_HXX_ + +#include <cppuhelper/implbase3.hxx> +#include <cppuhelper/compbase_ex.hxx> +/* +__DEF_COMPIMPLHELPER_EX( 3 ) +*/ + +namespace cppu +{ + +// Suppress warnings about hidden functions in case any of the IfcN has +// functions named dispose, addEventListener, or removeEventListener: +#if defined __SUNPRO_CC +#pragma disable_warn +#endif + + /** Implementation helper supporting ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::lang::XComponent. + + Upon disposing objects of this class, sub-classes receive a disposing() + call. Objects of this class can be held weakly, i.e. by a + ::com::sun::star::uno::WeakReference. + + @attention + The life-cycle of the passed mutex reference has to be longer than objects of this class. + + @derive + Inherit from this class giving your interface(s) to be implemented as template argument(s). + Your sub class defines method implementations for these interface(s). + */ + template< class Ifc1, class Ifc2, class Ifc3 > + class SAL_NO_VTABLE WeakComponentImplHelper3 + : public WeakComponentImplHelperBase + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData3 < Ifc1, Ifc2, Ifc3, WeakComponentImplHelper3<Ifc1, Ifc2, Ifc3> > > {}; + public: + inline WeakComponentImplHelper3( ::osl::Mutex & rMutex ) throw () + : WeakComponentImplHelperBase( rMutex ) + {} + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return WeakComponentImplHelper_query( rType, cd::get(), this, (WeakComponentImplHelperBase *)this ); } + virtual void SAL_CALL acquire() throw () + { WeakComponentImplHelperBase::acquire(); } + virtual void SAL_CALL release() throw () + { WeakComponentImplHelperBase::release(); } + virtual void SAL_CALL dispose()throw (::com::sun::star::uno::RuntimeException) + { WeakComponentImplHelperBase::dispose(); } + virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener)throw (::com::sun::star::uno::RuntimeException) + { WeakComponentImplHelperBase::addEventListener(xListener); } + virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener)throw (::com::sun::star::uno::RuntimeException) + { WeakComponentImplHelperBase::removeEventListener(xListener); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return WeakComponentImplHelper_getTypes( cd::get() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; + +#if defined __SUNPRO_CC +#pragma enable_warn +#endif + + /** Implementation helper supporting ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::lang::XComponent. + + Upon disposing objects of this class, sub-classes receive a disposing() + call. Objects of this class can be held weakly, i.e. by a + ::com::sun::star::uno::WeakReference. Object of this class can be + aggregated, i.e. incoming queryInterface() calls are delegated. + + @attention + The life-cycle of the passed mutex reference has to be longer than objects of this class. + + @derive + Inherit from this class giving your interface(s) to be implemented as template argument(s). + Your sub class defines method implementations for these interface(s). + + @deprecated + */ + template< class Ifc1, class Ifc2, class Ifc3 > + class SAL_NO_VTABLE WeakAggComponentImplHelper3 + : public WeakAggComponentImplHelperBase + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData3 < Ifc1, Ifc2, Ifc3, WeakAggComponentImplHelper3<Ifc1, Ifc2, Ifc3> > > {}; + public: + inline WeakAggComponentImplHelper3( ::osl::Mutex & rMutex ) throw () + : WeakAggComponentImplHelperBase( rMutex ) + {} + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return WeakAggComponentImplHelperBase::queryInterface( rType ); } + virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return WeakAggComponentImplHelper_queryAgg( rType, cd::get(), this, (WeakAggComponentImplHelperBase *)this ); } + virtual void SAL_CALL acquire() throw () + { WeakAggComponentImplHelperBase::acquire(); } + virtual void SAL_CALL release() throw () + { WeakAggComponentImplHelperBase::release(); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return WeakAggComponentImplHelper_getTypes( cd::get() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/inc/cppuhelper/compbase4.hxx b/cppuhelper/inc/cppuhelper/compbase4.hxx new file mode 100644 index 000000000000..8f7bb7634fdb --- /dev/null +++ b/cppuhelper/inc/cppuhelper/compbase4.hxx @@ -0,0 +1,140 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CPPUHELPER_COMPBASE4_HXX_ +#define _CPPUHELPER_COMPBASE4_HXX_ + +#include <cppuhelper/implbase4.hxx> +#include <cppuhelper/compbase_ex.hxx> +/* +__DEF_COMPIMPLHELPER_EX( 4 ) +*/ + +namespace cppu +{ + +// Suppress warnings about hidden functions in case any of the IfcN has +// functions named dispose, addEventListener, or removeEventListener: +#if defined __SUNPRO_CC +#pragma disable_warn +#endif + + /** Implementation helper supporting ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::lang::XComponent. + + Upon disposing objects of this class, sub-classes receive a disposing() + call. Objects of this class can be held weakly, i.e. by a + ::com::sun::star::uno::WeakReference. + + @attention + The life-cycle of the passed mutex reference has to be longer than objects of this class. + + @derive + Inherit from this class giving your interface(s) to be implemented as template argument(s). + Your sub class defines method implementations for these interface(s). + */ + template< class Ifc1, class Ifc2, class Ifc3, class Ifc4 > + class SAL_NO_VTABLE WeakComponentImplHelper4 + : public WeakComponentImplHelperBase + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData4 < Ifc1, Ifc2, Ifc3, Ifc4, WeakComponentImplHelper4<Ifc1, Ifc2, Ifc3, Ifc4> > > {}; + public: + inline WeakComponentImplHelper4( ::osl::Mutex & rMutex ) throw () + : WeakComponentImplHelperBase( rMutex ) + {} + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return WeakComponentImplHelper_query( rType, cd::get(), this, (WeakComponentImplHelperBase *)this ); } + virtual void SAL_CALL acquire() throw () + { WeakComponentImplHelperBase::acquire(); } + virtual void SAL_CALL release() throw () + { WeakComponentImplHelperBase::release(); } + virtual void SAL_CALL dispose()throw (::com::sun::star::uno::RuntimeException) + { WeakComponentImplHelperBase::dispose(); } + virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener)throw (::com::sun::star::uno::RuntimeException) + { WeakComponentImplHelperBase::addEventListener(xListener); } + virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener)throw (::com::sun::star::uno::RuntimeException) + { WeakComponentImplHelperBase::removeEventListener(xListener); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return WeakComponentImplHelper_getTypes( cd::get() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; + +#if defined __SUNPRO_CC +#pragma enable_warn +#endif + + /** Implementation helper supporting ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::lang::XComponent. + + Upon disposing objects of this class, sub-classes receive a disposing() + call. Objects of this class can be held weakly, i.e. by a + ::com::sun::star::uno::WeakReference. Object of this class can be + aggregated, i.e. incoming queryInterface() calls are delegated. + + @attention + The life-cycle of the passed mutex reference has to be longer than objects of this class. + + @derive + Inherit from this class giving your interface(s) to be implemented as template argument(s). + Your sub class defines method implementations for these interface(s). + + @deprecated + */ + template< class Ifc1, class Ifc2, class Ifc3, class Ifc4 > + class SAL_NO_VTABLE WeakAggComponentImplHelper4 + : public WeakAggComponentImplHelperBase + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData4 < Ifc1, Ifc2, Ifc3, Ifc4, WeakAggComponentImplHelper4<Ifc1, Ifc2, Ifc3, Ifc4> > > {}; + public: + inline WeakAggComponentImplHelper4( ::osl::Mutex & rMutex ) throw () + : WeakAggComponentImplHelperBase( rMutex ) + {} + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return WeakAggComponentImplHelperBase::queryInterface( rType ); } + virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return WeakAggComponentImplHelper_queryAgg( rType, cd::get(), this, (WeakAggComponentImplHelperBase *)this ); } + virtual void SAL_CALL acquire() throw () + { WeakAggComponentImplHelperBase::acquire(); } + virtual void SAL_CALL release() throw () + { WeakAggComponentImplHelperBase::release(); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return WeakAggComponentImplHelper_getTypes( cd::get() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/inc/cppuhelper/compbase5.hxx b/cppuhelper/inc/cppuhelper/compbase5.hxx new file mode 100644 index 000000000000..dfdbe976eff8 --- /dev/null +++ b/cppuhelper/inc/cppuhelper/compbase5.hxx @@ -0,0 +1,140 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CPPUHELPER_COMPBASE5_HXX_ +#define _CPPUHELPER_COMPBASE5_HXX_ + +#include <cppuhelper/implbase5.hxx> +#include <cppuhelper/compbase_ex.hxx> +/* +__DEF_COMPIMPLHELPER_EX( 5 ) +*/ + +namespace cppu +{ + +// Suppress warnings about hidden functions in case any of the IfcN has +// functions named dispose, addEventListener, or removeEventListener: +#if defined __SUNPRO_CC +#pragma disable_warn +#endif + + /** Implementation helper supporting ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::lang::XComponent. + + Upon disposing objects of this class, sub-classes receive a disposing() + call. Objects of this class can be held weakly, i.e. by a + ::com::sun::star::uno::WeakReference. + + @attention + The life-cycle of the passed mutex reference has to be longer than objects of this class. + + @derive + Inherit from this class giving your interface(s) to be implemented as template argument(s). + Your sub class defines method implementations for these interface(s). + */ + template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5 > + class SAL_NO_VTABLE WeakComponentImplHelper5 + : public WeakComponentImplHelperBase + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData5 < Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, WeakComponentImplHelper5<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5> > > {}; + public: + inline WeakComponentImplHelper5( ::osl::Mutex & rMutex ) throw () + : WeakComponentImplHelperBase( rMutex ) + {} + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return WeakComponentImplHelper_query( rType, cd::get(), this, (WeakComponentImplHelperBase *)this ); } + virtual void SAL_CALL acquire() throw () + { WeakComponentImplHelperBase::acquire(); } + virtual void SAL_CALL release() throw () + { WeakComponentImplHelperBase::release(); } + virtual void SAL_CALL dispose()throw (::com::sun::star::uno::RuntimeException) + { WeakComponentImplHelperBase::dispose(); } + virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener)throw (::com::sun::star::uno::RuntimeException) + { WeakComponentImplHelperBase::addEventListener(xListener); } + virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener)throw (::com::sun::star::uno::RuntimeException) + { WeakComponentImplHelperBase::removeEventListener(xListener); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return WeakComponentImplHelper_getTypes( cd::get() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; + +#if defined __SUNPRO_CC +#pragma enable_warn +#endif + + /** Implementation helper supporting ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::lang::XComponent. + + Upon disposing objects of this class, sub-classes receive a disposing() + call. Objects of this class can be held weakly, i.e. by a + ::com::sun::star::uno::WeakReference. Object of this class can be + aggregated, i.e. incoming queryInterface() calls are delegated. + + @attention + The life-cycle of the passed mutex reference has to be longer than objects of this class. + + @derive + Inherit from this class giving your interface(s) to be implemented as template argument(s). + Your sub class defines method implementations for these interface(s). + + @deprecated + */ + template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5 > + class SAL_NO_VTABLE WeakAggComponentImplHelper5 + : public WeakAggComponentImplHelperBase + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData5 < Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, WeakAggComponentImplHelper5<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5> > > {}; + public: + inline WeakAggComponentImplHelper5( ::osl::Mutex & rMutex ) throw () + : WeakAggComponentImplHelperBase( rMutex ) + {} + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return WeakAggComponentImplHelperBase::queryInterface( rType ); } + virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return WeakAggComponentImplHelper_queryAgg( rType, cd::get(), this, (WeakAggComponentImplHelperBase *)this ); } + virtual void SAL_CALL acquire() throw () + { WeakAggComponentImplHelperBase::acquire(); } + virtual void SAL_CALL release() throw () + { WeakAggComponentImplHelperBase::release(); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return WeakAggComponentImplHelper_getTypes( cd::get() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/inc/cppuhelper/compbase6.hxx b/cppuhelper/inc/cppuhelper/compbase6.hxx new file mode 100644 index 000000000000..c871e06e3fb7 --- /dev/null +++ b/cppuhelper/inc/cppuhelper/compbase6.hxx @@ -0,0 +1,140 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CPPUHELPER_COMPBASE6_HXX_ +#define _CPPUHELPER_COMPBASE6_HXX_ + +#include <cppuhelper/implbase6.hxx> +#include <cppuhelper/compbase_ex.hxx> +/* +__DEF_COMPIMPLHELPER_EX( 6 ) +*/ + +namespace cppu +{ + +// Suppress warnings about hidden functions in case any of the IfcN has +// functions named dispose, addEventListener, or removeEventListener: +#if defined __SUNPRO_CC +#pragma disable_warn +#endif + + /** Implementation helper supporting ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::lang::XComponent. + + Upon disposing objects of this class, sub-classes receive a disposing() + call. Objects of this class can be held weakly, i.e. by a + ::com::sun::star::uno::WeakReference. + + @attention + The life-cycle of the passed mutex reference has to be longer than objects of this class. + + @derive + Inherit from this class giving your interface(s) to be implemented as template argument(s). + Your sub class defines method implementations for these interface(s). + */ + template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6 > + class SAL_NO_VTABLE WeakComponentImplHelper6 + : public WeakComponentImplHelperBase + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData6 < Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, WeakComponentImplHelper6<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6> > > {}; + public: + inline WeakComponentImplHelper6( ::osl::Mutex & rMutex ) throw () + : WeakComponentImplHelperBase( rMutex ) + {} + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return WeakComponentImplHelper_query( rType, cd::get(), this, (WeakComponentImplHelperBase *)this ); } + virtual void SAL_CALL acquire() throw () + { WeakComponentImplHelperBase::acquire(); } + virtual void SAL_CALL release() throw () + { WeakComponentImplHelperBase::release(); } + virtual void SAL_CALL dispose()throw (::com::sun::star::uno::RuntimeException) + { WeakComponentImplHelperBase::dispose(); } + virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener)throw (::com::sun::star::uno::RuntimeException) + { WeakComponentImplHelperBase::addEventListener(xListener); } + virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener)throw (::com::sun::star::uno::RuntimeException) + { WeakComponentImplHelperBase::removeEventListener(xListener); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return WeakComponentImplHelper_getTypes( cd::get() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; + +#if defined __SUNPRO_CC +#pragma enable_warn +#endif + + /** Implementation helper supporting ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::lang::XComponent. + + Upon disposing objects of this class, sub-classes receive a disposing() + call. Objects of this class can be held weakly, i.e. by a + ::com::sun::star::uno::WeakReference. Object of this class can be + aggregated, i.e. incoming queryInterface() calls are delegated. + + @attention + The life-cycle of the passed mutex reference has to be longer than objects of this class. + + @derive + Inherit from this class giving your interface(s) to be implemented as template argument(s). + Your sub class defines method implementations for these interface(s). + + @deprecated + */ + template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6 > + class SAL_NO_VTABLE WeakAggComponentImplHelper6 + : public WeakAggComponentImplHelperBase + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData6 < Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, WeakAggComponentImplHelper6<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6> > > {}; + public: + inline WeakAggComponentImplHelper6( ::osl::Mutex & rMutex ) throw () + : WeakAggComponentImplHelperBase( rMutex ) + {} + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return WeakAggComponentImplHelperBase::queryInterface( rType ); } + virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return WeakAggComponentImplHelper_queryAgg( rType, cd::get(), this, (WeakAggComponentImplHelperBase *)this ); } + virtual void SAL_CALL acquire() throw () + { WeakAggComponentImplHelperBase::acquire(); } + virtual void SAL_CALL release() throw () + { WeakAggComponentImplHelperBase::release(); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return WeakAggComponentImplHelper_getTypes( cd::get() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/inc/cppuhelper/compbase7.hxx b/cppuhelper/inc/cppuhelper/compbase7.hxx new file mode 100644 index 000000000000..42c3c040ccff --- /dev/null +++ b/cppuhelper/inc/cppuhelper/compbase7.hxx @@ -0,0 +1,140 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CPPUHELPER_COMPBASE7_HXX_ +#define _CPPUHELPER_COMPBASE7_HXX_ + +#include <cppuhelper/implbase7.hxx> +#include <cppuhelper/compbase_ex.hxx> +/* +__DEF_COMPIMPLHELPER_EX( 7 ) +*/ + +namespace cppu +{ + +// Suppress warnings about hidden functions in case any of the IfcN has +// functions named dispose, addEventListener, or removeEventListener: +#if defined __SUNPRO_CC +#pragma disable_warn +#endif + + /** Implementation helper supporting ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::lang::XComponent. + + Upon disposing objects of this class, sub-classes receive a disposing() + call. Objects of this class can be held weakly, i.e. by a + ::com::sun::star::uno::WeakReference. + + @attention + The life-cycle of the passed mutex reference has to be longer than objects of this class. + + @derive + Inherit from this class giving your interface(s) to be implemented as template argument(s). + Your sub class defines method implementations for these interface(s). + */ + template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7 > + class SAL_NO_VTABLE WeakComponentImplHelper7 + : public WeakComponentImplHelperBase + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData7< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, WeakComponentImplHelper7<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7> > > {}; + public: + inline WeakComponentImplHelper7( ::osl::Mutex & rMutex ) throw () + : WeakComponentImplHelperBase( rMutex ) + {} + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return WeakComponentImplHelper_query( rType, cd::get(), this, (WeakComponentImplHelperBase *)this ); } + virtual void SAL_CALL acquire() throw () + { WeakComponentImplHelperBase::acquire(); } + virtual void SAL_CALL release() throw () + { WeakComponentImplHelperBase::release(); } + virtual void SAL_CALL dispose()throw (::com::sun::star::uno::RuntimeException) + { WeakComponentImplHelperBase::dispose(); } + virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener)throw (::com::sun::star::uno::RuntimeException) + { WeakComponentImplHelperBase::addEventListener(xListener); } + virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener)throw (::com::sun::star::uno::RuntimeException) + { WeakComponentImplHelperBase::removeEventListener(xListener); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return WeakComponentImplHelper_getTypes( cd::get() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; + +#if defined __SUNPRO_CC +#pragma enable_warn +#endif + + /** Implementation helper supporting ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::lang::XComponent. + + Upon disposing objects of this class, sub-classes receive a disposing() + call. Objects of this class can be held weakly, i.e. by a + ::com::sun::star::uno::WeakReference. Object of this class can be + aggregated, i.e. incoming queryInterface() calls are delegated. + + @attention + The life-cycle of the passed mutex reference has to be longer than objects of this class. + + @derive + Inherit from this class giving your interface(s) to be implemented as template argument(s). + Your sub class defines method implementations for these interface(s). + + @deprecated + */ + template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7 > + class SAL_NO_VTABLE WeakAggComponentImplHelper7 + : public WeakAggComponentImplHelperBase + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData7< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, WeakAggComponentImplHelper7<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7> > > {}; + public: + inline WeakAggComponentImplHelper7( ::osl::Mutex & rMutex ) throw () + : WeakAggComponentImplHelperBase( rMutex ) + {} + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return WeakAggComponentImplHelperBase::queryInterface( rType ); } + virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return WeakAggComponentImplHelper_queryAgg( rType, cd::get(), this, (WeakAggComponentImplHelperBase *)this ); } + virtual void SAL_CALL acquire() throw () + { WeakAggComponentImplHelperBase::acquire(); } + virtual void SAL_CALL release() throw () + { WeakAggComponentImplHelperBase::release(); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return WeakAggComponentImplHelper_getTypes( cd::get() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/inc/cppuhelper/compbase8.hxx b/cppuhelper/inc/cppuhelper/compbase8.hxx new file mode 100644 index 000000000000..3742753e1986 --- /dev/null +++ b/cppuhelper/inc/cppuhelper/compbase8.hxx @@ -0,0 +1,140 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CPPUHELPER_COMPBASE8_HXX_ +#define _CPPUHELPER_COMPBASE8_HXX_ + +#include <cppuhelper/implbase8.hxx> +#include <cppuhelper/compbase_ex.hxx> +/* +__DEF_COMPIMPLHELPER_EX( 8 ) +*/ + +namespace cppu +{ + +// Suppress warnings about hidden functions in case any of the IfcN has +// functions named dispose, addEventListener, or removeEventListener: +#if defined __SUNPRO_CC +#pragma disable_warn +#endif + + /** Implementation helper supporting ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::lang::XComponent. + + Upon disposing objects of this class, sub-classes receive a disposing() + call. Objects of this class can be held weakly, i.e. by a + ::com::sun::star::uno::WeakReference. + + @attention + The life-cycle of the passed mutex reference has to be longer than objects of this class. + + @derive + Inherit from this class giving your interface(s) to be implemented as template argument(s). + Your sub class defines method implementations for these interface(s). + */ + template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8 > + class SAL_NO_VTABLE WeakComponentImplHelper8 + : public WeakComponentImplHelperBase + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData8< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, WeakComponentImplHelper8<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8> > > {}; + public: + inline WeakComponentImplHelper8( ::osl::Mutex & rMutex ) throw () + : WeakComponentImplHelperBase( rMutex ) + {} + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return WeakComponentImplHelper_query( rType, cd::get(), this, (WeakComponentImplHelperBase *)this ); } + virtual void SAL_CALL acquire() throw () + { WeakComponentImplHelperBase::acquire(); } + virtual void SAL_CALL release() throw () + { WeakComponentImplHelperBase::release(); } + virtual void SAL_CALL dispose()throw (::com::sun::star::uno::RuntimeException) + { WeakComponentImplHelperBase::dispose(); } + virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener)throw (::com::sun::star::uno::RuntimeException) + { WeakComponentImplHelperBase::addEventListener(xListener); } + virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener)throw (::com::sun::star::uno::RuntimeException) + { WeakComponentImplHelperBase::removeEventListener(xListener); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return WeakComponentImplHelper_getTypes( cd::get() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; + +#if defined __SUNPRO_CC +#pragma enable_warn +#endif + + /** Implementation helper supporting ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::lang::XComponent. + + Upon disposing objects of this class, sub-classes receive a disposing() + call. Objects of this class can be held weakly, i.e. by a + ::com::sun::star::uno::WeakReference. Object of this class can be + aggregated, i.e. incoming queryInterface() calls are delegated. + + @attention + The life-cycle of the passed mutex reference has to be longer than objects of this class. + + @derive + Inherit from this class giving your interface(s) to be implemented as template argument(s). + Your sub class defines method implementations for these interface(s). + + @deprecated + */ + template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8 > + class SAL_NO_VTABLE WeakAggComponentImplHelper8 + : public WeakAggComponentImplHelperBase + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData8< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, WeakAggComponentImplHelper8<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8> > > {}; + public: + inline WeakAggComponentImplHelper8( ::osl::Mutex & rMutex ) throw () + : WeakAggComponentImplHelperBase( rMutex ) + {} + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return WeakAggComponentImplHelperBase::queryInterface( rType ); } + virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return WeakAggComponentImplHelper_queryAgg( rType, cd::get(), this, (WeakAggComponentImplHelperBase *)this ); } + virtual void SAL_CALL acquire() throw () + { WeakAggComponentImplHelperBase::acquire(); } + virtual void SAL_CALL release() throw () + { WeakAggComponentImplHelperBase::release(); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return WeakAggComponentImplHelper_getTypes( cd::get() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/inc/cppuhelper/compbase9.hxx b/cppuhelper/inc/cppuhelper/compbase9.hxx new file mode 100644 index 000000000000..7ca131ae2be9 --- /dev/null +++ b/cppuhelper/inc/cppuhelper/compbase9.hxx @@ -0,0 +1,139 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CPPUHELPER_COMPBASE9_HXX_ +#define _CPPUHELPER_COMPBASE9_HXX_ + +#include <cppuhelper/implbase9.hxx> +#include <cppuhelper/compbase_ex.hxx> +/* +__DEF_COMPIMPLHELPER_EX( 9 ) +*/ + +namespace cppu +{ + +// Suppress warnings about hidden functions in case any of the IfcN has +// functions named dispose, addEventListener, or removeEventListener: +#if defined __SUNPRO_CC +#pragma disable_warn +#endif + + /** Implementation helper supporting ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::lang::XComponent. + + Upon disposing objects of this class, sub-classes receive a disposing() + call. Objects of this class can be held weakly, i.e. by a + ::com::sun::star::uno::WeakReference. + + @attention + The life-cycle of the passed mutex reference has to be longer than objects of this class. + + @derive + Inherit from this class giving your interface(s) to be implemented as template argument(s). + Your sub class defines method implementations for these interface(s). + */ + template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9 > + class SAL_NO_VTABLE WeakComponentImplHelper9 + : public WeakComponentImplHelperBase + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData9< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, WeakComponentImplHelper9<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9> > > {}; + public: + inline WeakComponentImplHelper9( ::osl::Mutex & rMutex ) throw () + : WeakComponentImplHelperBase( rMutex ) + {} + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return WeakComponentImplHelper_query( rType, cd::get(), this, (WeakComponentImplHelperBase *)this ); } + virtual void SAL_CALL acquire() throw () + { WeakComponentImplHelperBase::acquire(); } + virtual void SAL_CALL release() throw () + { WeakComponentImplHelperBase::release(); } + virtual void SAL_CALL dispose()throw (::com::sun::star::uno::RuntimeException) + { WeakComponentImplHelperBase::dispose(); } + virtual void SAL_CALL addEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener)throw (::com::sun::star::uno::RuntimeException) + { WeakComponentImplHelperBase::addEventListener(xListener); } + virtual void SAL_CALL removeEventListener(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > & xListener)throw (::com::sun::star::uno::RuntimeException) + { WeakComponentImplHelperBase::removeEventListener(xListener); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return WeakComponentImplHelper_getTypes( cd::get() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; + +#if defined __SUNPRO_CC +#pragma enable_warn +#endif + + /** Implementation helper supporting ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::lang::XComponent. + Upon disposing objects of this class, sub-classes receive a disposing() + call. Objects of this class can be held weakly, i.e. by a + ::com::sun::star::uno::WeakReference. Object of this class can be + aggregated, i.e. incoming queryInterface() calls are delegated. + + @attention + The life-cycle of the passed mutex reference has to be longer than objects of this class. + + @derive + Inherit from this class giving your interface(s) to be implemented as template argument(s). + Your sub class defines method implementations for these interface(s). + + @deprecated + */ + template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9 > + class SAL_NO_VTABLE WeakAggComponentImplHelper9 + : public WeakAggComponentImplHelperBase + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData9< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, WeakAggComponentImplHelper9<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9> > > {}; + public: + inline WeakAggComponentImplHelper9( ::osl::Mutex & rMutex ) throw () + : WeakAggComponentImplHelperBase( rMutex ) + {} + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return WeakAggComponentImplHelperBase::queryInterface( rType ); } + virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return WeakAggComponentImplHelper_queryAgg( rType, cd::get(), this, (WeakAggComponentImplHelperBase *)this ); } + virtual void SAL_CALL acquire() throw () + { WeakAggComponentImplHelperBase::acquire(); } + virtual void SAL_CALL release() throw () + { WeakAggComponentImplHelperBase::release(); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return WeakAggComponentImplHelper_getTypes( cd::get() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/inc/cppuhelper/compbase_ex.hxx b/cppuhelper/inc/cppuhelper/compbase_ex.hxx new file mode 100644 index 000000000000..7d79304b2f2f --- /dev/null +++ b/cppuhelper/inc/cppuhelper/compbase_ex.hxx @@ -0,0 +1,179 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CPPUHELPER_COMPBASE_EX_HXX_ +#define _CPPUHELPER_COMPBASE_EX_HXX_ + +#include <osl/mutex.hxx> +#include <cppuhelper/implbase_ex.hxx> +#include <cppuhelper/interfacecontainer.hxx> +#include <com/sun/star/lang/XComponent.hpp> + + +namespace cppu +{ + +/** Implementation helper base class for components. Inherits from ::cppu::OWeakObject and + ::com::sun::star::lang::XComponent. + @internal +*/ +class SAL_NO_VTABLE WeakComponentImplHelperBase + : public ::cppu::OWeakObject + , public ::com::sun::star::lang::XComponent +{ +protected: + /** broadcast helper for disposing events + */ + ::cppu::OBroadcastHelper rBHelper; + + /** this function is called upon disposing the component + */ + virtual void SAL_CALL disposing(); + + /** This is the one and only constructor that is called from derived implementations. + + @param rMutex mutex to sync upon disposing + */ + WeakComponentImplHelperBase( ::osl::Mutex & rMutex ) SAL_THROW( () ); +public: + /** Destructor + */ + virtual ~WeakComponentImplHelperBase() SAL_THROW( () ); + + // these are here to force memory de/allocation to sal lib. + inline static void * SAL_CALL operator new( size_t nSize ) SAL_THROW( () ) + { return ::rtl_allocateMemory( nSize ); } + inline static void SAL_CALL operator delete( void * pMem ) SAL_THROW( () ) + { ::rtl_freeMemory( pMem ); } + inline static void * SAL_CALL operator new( size_t, void * pMem ) SAL_THROW( () ) + { return pMem; } + inline static void SAL_CALL operator delete( void *, void * ) SAL_THROW( () ) + {} + + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( + ::com::sun::star::uno::Type const & rType ) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL acquire() + throw (); + virtual void SAL_CALL release() + throw (); + virtual void SAL_CALL dispose() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addEventListener( + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > const & xListener ) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeEventListener( + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > const & xListener ) + throw (::com::sun::star::uno::RuntimeException); +}; + +/** Implementation helper base class for components. Inherits from ::cppu::OWeakAggObject and + ::com::sun::star::lang::XComponent. + @internal +*/ +class SAL_NO_VTABLE WeakAggComponentImplHelperBase + : public ::cppu::OWeakAggObject + , public ::com::sun::star::lang::XComponent +{ +protected: + ::cppu::OBroadcastHelper rBHelper; + + /** Is called upon disposing the component. + */ + virtual void SAL_CALL disposing(); + + WeakAggComponentImplHelperBase( ::osl::Mutex & rMutex ) SAL_THROW( () ); +public: + virtual ~WeakAggComponentImplHelperBase() SAL_THROW( () ); + + // these are here to force memory de/allocation to sal lib. + inline static void * SAL_CALL operator new( size_t nSize ) SAL_THROW( () ) + { return ::rtl_allocateMemory( nSize ); } + inline static void SAL_CALL operator delete( void * pMem ) SAL_THROW( () ) + { ::rtl_freeMemory( pMem ); } + inline static void * SAL_CALL operator new( size_t, void * pMem ) SAL_THROW( () ) + { return pMem; } + inline static void SAL_CALL operator delete( void *, void * ) SAL_THROW( () ) + {} + + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( + ::com::sun::star::uno::Type const & rType ) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( + ::com::sun::star::uno::Type const & rType ) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL acquire() + throw (); + virtual void SAL_CALL release() + throw (); + virtual void SAL_CALL dispose() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addEventListener( + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > const & xListener ) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeEventListener( + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener > const & xListener ) + throw (::com::sun::star::uno::RuntimeException); +}; + +/** WeakComponentImplHelper + @internal +*/ +::com::sun::star::uno::Any SAL_CALL WeakComponentImplHelper_query( + ::com::sun::star::uno::Type const & rType, + class_data * cd, + void * that, + ::cppu::WeakComponentImplHelperBase * pBase ) + SAL_THROW( (::com::sun::star::uno::RuntimeException) ); +/** WeakComponentImplHelper + @internal +*/ +::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL WeakComponentImplHelper_getTypes( + class_data * cd ) + SAL_THROW( (::com::sun::star::uno::RuntimeException) ); + +/** WeakAggComponentImplHelper + @internal +*/ +::com::sun::star::uno::Any SAL_CALL WeakAggComponentImplHelper_queryAgg( + ::com::sun::star::uno::Type const & rType, + class_data * cd, + void * that, + ::cppu::WeakAggComponentImplHelperBase * pBase ) + SAL_THROW( (::com::sun::star::uno::RuntimeException) ); +/** WeakAggComponentImplHelper + @internal +*/ +::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL WeakAggComponentImplHelper_getTypes( + class_data * cd ) + SAL_THROW( (::com::sun::star::uno::RuntimeException) ); + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/inc/cppuhelper/component.hxx b/cppuhelper/inc/cppuhelper/component.hxx new file mode 100644 index 000000000000..92eb60389afb --- /dev/null +++ b/cppuhelper/inc/cppuhelper/component.hxx @@ -0,0 +1,121 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CPPUHELPER_COMPONENT_HXX_ +#define _CPPUHELPER_COMPONENT_HXX_ + +#include <osl/mutex.hxx> +#include <cppuhelper/weakagg.hxx> +#include <cppuhelper/interfacecontainer.hxx> + +#include <cppuhelper/implbase1.hxx> + +#include <com/sun/star/lang/XComponent.hpp> +#include <com/sun/star/lang/XEventListener.hpp> + + +namespace cppu +{ + +/** Deprecated. Helper for implementing ::com::sun::star::lang::XComponent. + Upon disposing objects of this class, sub-classes receive a disposing() call. Objects of + this class can be held weakly, i.e. by a ::com::sun::star::uno::WeakReference. Object of + this class can be aggregated, i.e. incoming queryInterface() calls are delegated. + + @attention + The life-cycle of the passed mutex reference has to be longer than objects of this class. + @deprecated +*/ +class OComponentHelper + : public ::cppu::OWeakAggObject + , public ::com::sun::star::lang::XTypeProvider + , public ::com::sun::star::lang::XComponent +{ +public: + /** Constructor. + + @param rMutex + the mutex used to protect multi-threaded access; + lifetime must be longer than the lifetime of this object. + */ + OComponentHelper( ::osl::Mutex & rMutex ) SAL_THROW( () ); + /** Dewstructor. If this object was not disposed previously, object will be disposed manually. + */ + virtual ~OComponentHelper() SAL_THROW( (::com::sun::star::uno::RuntimeException) ); + + // XAggregation + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( + ::com::sun::star::uno::Type const & rType ) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( + ::com::sun::star::uno::Type const & rType ) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL acquire() + throw (); + virtual void SAL_CALL release() + throw (); + + /** @attention + XTypeProvider::getImplementationId() has to be implemented separately! + */ + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() + throw(::com::sun::star::uno::RuntimeException) = 0; + /** @attention + XTypeProvider::getTypes() has to be re-implemented! + */ + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() + throw (::com::sun::star::uno::RuntimeException); + + // XComponent + virtual void SAL_CALL dispose() + throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addEventListener( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) + throw(::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeEventListener( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) + throw(::com::sun::star::uno::RuntimeException); + +protected: + /** Called in dispose method after the listeners were notified. + */ + virtual void SAL_CALL disposing(); + + /** @internal */ + OBroadcastHelper rBHelper; +private: + /** @internal */ + inline OComponentHelper( const OComponentHelper & ) SAL_THROW( () ); + /** @internal */ + inline OComponentHelper & operator = ( const OComponentHelper & ) SAL_THROW( () ); +}; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/inc/cppuhelper/component_context.hxx b/cppuhelper/inc/cppuhelper/component_context.hxx new file mode 100644 index 000000000000..2ab6a0cf25cf --- /dev/null +++ b/cppuhelper/inc/cppuhelper/component_context.hxx @@ -0,0 +1,99 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CPPUHELPER_COMPONENT_CONTEXT_HXX_ +#define _CPPUHELPER_COMPONENT_CONTEXT_HXX_ + +#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/lang/XSingleComponentFactory.hpp> + + +namespace cppu +{ + +/** Context entries init struct calling createComponentContext(). +*/ +struct ContextEntry_Init +{ + /** late init denotes a object that will be raised when first get() is calling for it + + The context implementation expects either a ::com::sun::star::lang::XSingleComponentFactory + object as value (to instanciate the object) or a string as value for raising + a service via the used service manager. + */ + bool bLateInitService; + /** name of context value + */ + ::rtl::OUString name; + /** context value + */ + ::com::sun::star::uno::Any value; + + /** Default ctor. + */ + inline ContextEntry_Init() SAL_THROW( () ) + : bLateInitService( false ) + {} + /** Ctor. + + @param name_ + name of entry + @param value_ + value of entry + @param bLateInitService_ + whether this entry is a late-init named object entry + (value is object factory or service string) + */ + inline ContextEntry_Init( + ::rtl::OUString const & name_, + ::com::sun::star::uno::Any const & value_, + bool bLateInitService_ = false ) SAL_THROW( () ) + : bLateInitService( bLateInitService_ ), + name( name_ ), + value( value_ ) + {} +}; + +/** Creates a component context with the given entries. + + @param pEntries array of entries + @param nEntries number of entries + @param xDelegate delegation to further context, if value was not found + @return new context object +*/ +::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > +SAL_CALL createComponentContext( + ContextEntry_Init const * pEntries, sal_Int32 nEntries, + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xDelegate = + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >() ) + SAL_THROW( () ); + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/inc/cppuhelper/exc_hlp.hxx b/cppuhelper/inc/cppuhelper/exc_hlp.hxx new file mode 100644 index 000000000000..3d70b9eb6a4d --- /dev/null +++ b/cppuhelper/inc/cppuhelper/exc_hlp.hxx @@ -0,0 +1,100 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _CPPUHELPER_EXC_HLP_HXX_ +#define _CPPUHELPER_EXC_HLP_HXX_ + +#include <com/sun/star/uno/Any.hxx> + +namespace cppu +{ + +/** This function throws the exception given by rExc. The given value has to + be of typeclass EXCEPTION and must be dervived from or of + type com.sun.star.uno.Exception. + + @param rExc + exception to be thrown. +*/ +void SAL_CALL throwException( const ::com::sun::star::uno::Any & rExc ) + SAL_THROW( (::com::sun::star::uno::Exception) ); + +/** Use this function to get the dynamic type of a caught C++-UNO exception; + completes the above function throwing exceptions generically. + + try + { + ... + } + catch (::com::sun::star::uno::RuntimeException &) + { + // you ought not handle RuntimeExceptions: + throw; + } + catch (::com::sun::star::uno::Exception &) + { + ::com::sun::star::uno::Any caught( ::cppu::getCaughtException() ); + ... + } + + Restrictions: + - use only for caught C++-UNO exceptions (UNOIDL defined) + - only as first statement in a catch block! + - don't do a C++ rethrow (throw;) after you have called this function + - call getCaughtException() just once in your catch block! + (function internally uses a C++ rethrow) + + @return + caught UNO exception + + @attention Caution! + This function is limited to the same C++ compiler runtime library. + E.g. for MSVC, this means that the catch handler code (the one + that calls getCaughtException()) needs to use the very same + C++ runtime library, e.g. msvcrt.dll as cppuhelper, e.g. + cppuhelper3MSC.dll and the bridge library, e.g. msci_uno.dll. + This is the case if all of them are compiled with the same + compiler version. + Background: The msci_uno.dll gets a rethrown exception out + of the internal msvcrt.dll thread local storage (tls). + Thus you _must_ not use this function if your code needs to run + in newer UDK versions without being recompiled, because those + newer UDK (-> OOo versions) potentially use newer C++ runtime + libraries which most often become incompatible! + + But this function ought to be usable for most OOo internal C++-UNO + development, because the whole OOo code base is compiled using the + same C++ compiler (and linking against one runtime library). +*/ +::com::sun::star::uno::Any SAL_CALL getCaughtException(); + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/inc/cppuhelper/factory.hxx b/cppuhelper/inc/cppuhelper/factory.hxx new file mode 100644 index 000000000000..538d85c51e85 --- /dev/null +++ b/cppuhelper/inc/cppuhelper/factory.hxx @@ -0,0 +1,278 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CPPUHELPER_FACTORY_HXX_ +#define _CPPUHELPER_FACTORY_HXX_ + +#include <rtl/ustring.hxx> +#include <uno/dispatcher.h> +#include <rtl/unload.h> + +#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/lang/XSingleComponentFactory.hpp> +#include <com/sun/star/lang/XSingleServiceFactory.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/registry/XRegistryKey.hpp> + +//################################################################################################## + +#define COMPONENT_GETENV "component_getImplementationEnvironment" +#define COMPONENT_GETENVEXT "component_getImplementationEnvironmentExt" +#define COMPONENT_GETDESCRIPTION "component_getDescription" +#define COMPONENT_WRITEINFO "component_writeInfo" +#define COMPONENT_GETFACTORY "component_getFactory" + +typedef struct _uno_Environment uno_Environment; + +/** Function pointer declaration. + Function determines the environment of the component implementation, i.e. which compiler + compiled it. If the environment is NOT session specific (needs no additional context), + then this function should return the environment type name and leave ppEnv (to 0). + + @paramppEnvTypeName environment type name; string must be constant + @param ppEnv function returns its environment if the environment is session specific, + i.e. has special context +*/ +typedef void (SAL_CALL * component_getImplementationEnvironmentFunc)( + const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv ); + +/** Function pointer declaration. + Function determines the environment of the component implementation, i.e. the compiler. + If the environment is NOT session specific (needs no additional context), + then this function should return the environment type name and leave ppEnv (to 0). + + @param ppEnvTypeName environment type name; string must be a constant + @param ppEnv function returns an environment if the environment is session specific, + i.e. has special context + @param pImplName +*/ +typedef void (SAL_CALL * component_getImplementationEnvironmentExtFunc)( + sal_Char const ** ppEnvTypeName, + uno_Environment ** ppEnv, + sal_Char const * pImplName, + uno_Environment * pTargetEnv +); + +/** Function pointer declaration. + Function retrieves a component description. + + @return an XML formatted string containing a short component description + @deprecated +*/ +typedef const sal_Char * (SAL_CALL * component_getDescriptionFunc)(void); + +/** Function pointer declaration. + Function writes component registry info, at least writing the supported service names. + + @param pServiceManager + a service manager (the type is an XMultiServiceFactory that can be used + by the environment returned by component_getImplementationEnvironment) + @param pRegistryKey a registry key + (the type is XRegistryKey that can be used by the environment + returned by component_getImplementationEnvironment) + @return true if everything went fine +*/ +typedef sal_Bool (SAL_CALL * component_writeInfoFunc)( + void * pServiceManager, void * pRegistryKey ); + +/** Function pointer declaration. + Retrieves a factory to create component instances. + + @param pImplName + desired implementation name + @param pServiceManager + a service manager (the type is XMultiServiceFactory that can be used by the environment + returned by component_getImplementationEnvironment) + @param pRegistryKey + a registry key (the type is XRegistryKey that can be used by the environment + returned by component_getImplementationEnvironment) + @return acquired component factory + (the type is lang::XSingleComponentFactory or lang::XSingleServiceFactory to be used by the + environment returned by component_getImplementationEnvironment) +*/ +typedef void * (SAL_CALL * component_getFactoryFunc)( + const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey ); + +//################################################################################################## + +namespace cppu +{ + +/** Function pointer declaration. + Function creates component instance passing the component context to be used. + + @param xContext component context to be used + @return component instance +*/ +typedef ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >( + SAL_CALL * ComponentFactoryFunc)( + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xContext ) + SAL_THROW( (::com::sun::star::uno::Exception) ); + +/** Creates a single component factory supporting the XSingleComponentFactory interface. + + @param fptr function pointer for instanciating the object + @param rImplementationName implementation name of service + @param rServiceNames supported services + @param pModCount for future extension (library unloading concept). +*/ +::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleComponentFactory > +SAL_CALL createSingleComponentFactory( + ComponentFactoryFunc fptr, + ::rtl::OUString const & rImplementationName, + ::com::sun::star::uno::Sequence< ::rtl::OUString > const & rServiceNames, + rtl_ModuleCount * pModCount = 0 ) + SAL_THROW( () ); + +/** Creates a single service factory which holds the instance created only once. + + @param fptr function pointer for instanciating the object + @param rImplementationName implementation name of service + @param rServiceNames supported services + @param pModCount for future extension (library unloading concept). + + @see createSingleComponentFactory +*/ +::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleComponentFactory > SAL_CALL +createOneInstanceComponentFactory( + ComponentFactoryFunc fptr, + ::rtl::OUString const & rImplementationName, + ::com::sun::star::uno::Sequence< ::rtl::OUString > const & rServiceNames, + rtl_ModuleCount * pModCount = 0 ) + SAL_THROW( () ); + +/** Deprecated. The type of the instanciate function used as argument of the create*Fcatory functions. + + @see createSingleFactory + @see createOneInstanceFactory + @deprecated +*/ +typedef ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >(SAL_CALL * ComponentInstantiation)( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rServiceManager ); + +/** Deprecated. Creates a single service factory. + + @param rServiceManager the service manager used by the implementation. + @param rImplementationName the implementation name. An empty string is possible. + @param ComponentInstantiation the function pointer to create an object. + @param rServiceNames the service supported by the implementation. + @param pModCount for future extension (library unloading concept). + @return a factory that support the interfaces XServiceProvider, XServiceInfo + XSingleServiceFactory and XComponent. + + @see createOneInstanceFactory + @deprecated +*/ +::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > SAL_CALL +createSingleFactory( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rServiceManager, + const ::rtl::OUString & rImplementationName, + ComponentInstantiation pCreateFunction, + const ::com::sun::star::uno::Sequence< ::rtl::OUString > & rServiceNames, + rtl_ModuleCount * pModCount = 0 ) + SAL_THROW( () ); + +/** Deprecated. Creates a factory wrapping another one. + This means the methods of the interfaces XServiceProvider, XServiceInfo and + XSingleServiceFactory are forwarded. + @attention + The XComponent interface is not supported! + + @param rServiceManager the service manager used by the implementation. + @param xSingleServiceFactory the wrapped service factory. + @return a factory that support the interfaces XServiceProvider, XServiceInfo + XSingleServiceFactory. + + @see createSingleFactory + @deprecated +*/ +::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > SAL_CALL +createFactoryProxy( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rServiceManager, + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > & rFactory ) + SAL_THROW( () ); + +/** Deprecated. Creates a single service factory which holds the instance created only once. + + @param rServiceManager the service manager used by the implementation. + @param rImplementationName the implementation name. An empty string is possible. + @param ComponentInstantiation the function pointer to create an object. + @param rServiceNames the service supported by the implementation. + @param pModCount for future extension (library unloading concept). + @return a factory that support the interfaces XServiceProvider, XServiceInfo + XSingleServiceFactory and XComponent. + + @see createSingleFactory + @deprecated +*/ +::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > SAL_CALL +createOneInstanceFactory( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rServiceManager, + const ::rtl::OUString & rComponentName, + ComponentInstantiation pCreateFunction, + const ::com::sun::star::uno::Sequence< ::rtl::OUString > & rServiceNames, + rtl_ModuleCount * pModCount = 0 ) + SAL_THROW( () ); + +/** Deprecated. Creates a single service factory based on a registry. + + @param rServiceManager the service manager used by the implementation. + @param rImplementationName the implementation name. An empty string is possible. + @param rImplementationKey the registry key of the implementation section. + @return a factory that support the interfaces XServiceProvider, XServiceInfo + XSingleServiceFactory and XComponent. + @deprecated +*/ +::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > SAL_CALL createSingleRegistryFactory( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rServiceManager, + const ::rtl::OUString & rImplementationName, + const ::com::sun::star::uno::Reference< ::com::sun::star::registry::XRegistryKey > & rImplementationKey ) + SAL_THROW( () ); + +/** Deprecated. Creates a single service factory which holds the instance created only once + based on a registry. + + @param rServiceManager the service manager used by the implementation. + @param rImplementationName the implementation name. An empty string is possible. + @param rImplementationKey the registry key of the implementation section. + @return a factory that support the interfaces XServiceProvider, XServiceInfo + XSingleServiceFactory and XComponent. + + @see createSingleRegistryFactory + @deprecated +*/ +::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleServiceFactory > SAL_CALL createOneInstanceRegistryFactory( + const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & rServiceManager, + const ::rtl::OUString & rComponentName, + const ::com::sun::star::uno::Reference< ::com::sun::star::registry::XRegistryKey > & rImplementationKey ) + SAL_THROW( () ); + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/inc/cppuhelper/findsofficepath.h b/cppuhelper/inc/cppuhelper/findsofficepath.h new file mode 100644 index 000000000000..8a7027ebf906 --- /dev/null +++ b/cppuhelper/inc/cppuhelper/findsofficepath.h @@ -0,0 +1,48 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef INCLUDED_CPPUHELPER_FINDSOFFICEPATH_H +#define INCLUDED_CPPUHELPER_FINDSOFFICEPATH_H + +#include "sal/config.h" + +#if defined __cplusplus +extern "C" { +#endif + +/* Internal function to find an soffice installation. + Not to be called by client code */ +char const* cppuhelper_detail_findSofficePath(void); + +#if defined __cplusplus +} +#endif + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/inc/cppuhelper/implbase.hxx b/cppuhelper/inc/cppuhelper/implbase.hxx new file mode 100644 index 000000000000..9d56d4c5f51b --- /dev/null +++ b/cppuhelper/inc/cppuhelper/implbase.hxx @@ -0,0 +1,300 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CPPUHELPER_IMPLBASE_HXX_ +#define _CPPUHELPER_IMPLBASE_HXX_ + +#include <osl/mutex.hxx> +#include <cppuhelper/weak.hxx> +#include <cppuhelper/weakagg.hxx> +#include <rtl/instance.hxx> + +#include <com/sun/star/lang/XTypeProvider.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> + +/* This header should not be used anymore. + @deprecated +*/ + +namespace cppu +{ + +/** Struct used for inline template implementation helpers: type entries. + Not for public use. + @internal +*/ +struct Type_Offset +{ + /** binary offset of vtable pointer from object base + */ + sal_Int32 nOffset; + /** interface type description of interface entry + */ + typelib_InterfaceTypeDescription * pTD; +}; +/** Struct used for inline template implementation helpers: class data of implementation. + Not for public use. + @internal +*/ +struct ClassDataBase +{ + /** determines whether the class data has been statically initialized + */ + sal_Bool bOffsetsInit; + /** length of static array ClassDataN + */ + sal_Int32 nType2Offset; + + /** class code determines which standard types are supported (and returned on + com.sun.star.lang.XTypeProvider::getTypes()) by the helper: + + - 1 -- com.sun.star.uno.XWeak + - 2 -- com.sun.star.uno.XWeak, com.sun.star.uno.XAggregation + - 3 -- com.sun.star.uno.XWeak, com.sun.star.uno.XAggregation, com.sun.star.lang.XComponent + - 4 -- com.sun.star.uno.XWeak, com.sun.star.lang.XComponent + */ + sal_Int32 nClassCode; + + /** pointer to types sequence (com.sun.star.lang.XTypeProvider) + */ + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > * pTypes; + /** pointer to class id (com.sun.star.lang.XTypeProvider) + */ + ::com::sun::star::uno::Sequence< sal_Int8 > * pId; + + /** def ctor + */ + ClassDataBase() SAL_THROW( () ); + /** class code ctor + + @param nClassCode class code, see ClassDataBase::nClassCode + */ + ClassDataBase( sal_Int32 nClassCode ) SAL_THROW( () ); + /** dtor + */ + ~ClassDataBase() SAL_THROW( () ); +}; +/** Struct used for inline template implementation helpers: + There will be versions of this struct with varying arType2Offset[] array sizes, each of which + is binary compatible with this one to be casted and used uniform. The size of the varying array + is set in ClassDataBase::nType2Offset (base class). + Not for public use. + @internal +*/ +struct ClassData : public ClassDataBase +{ + /** type entries array + */ + Type_Offset arType2Offset[1]; + + /** init call for supporting com.sun.star.lang.XTypeProvider + */ + void SAL_CALL initTypeProvider() SAL_THROW( () ); + /** initial writing type offsets for vtables + + @param rType type of interface + @param nOffset offset to vtable entry + */ + void SAL_CALL writeTypeOffset( const ::com::sun::star::uno::Type & rType, sal_Int32 nOffset ) + SAL_THROW( () ); + + /** Queries for an interface. + + @param rType demanded interface type + @pBase base this pointer related when writing type offsets (writeTypeOffset()) + @return demanded interface or empty any + */ + ::com::sun::star::uno::Any SAL_CALL query( + const ::com::sun::star::uno::Type & rType, ::com::sun::star::lang::XTypeProvider * pBase ) + SAL_THROW( () ); + /** Gets the types for supporting com.sun.star.lang.XTypeProvider + + @return sequence of types supported + */ + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() + SAL_THROW( () ); + /** Gets the class id of implementation supporting com.sun.star.lang.XTypeProvider + + @return class identifier (sequence< byte >) + */ + ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() + SAL_THROW( () ); +}; + +/** Shared mutex for implementation helper initialization. + Not for public use. + @internal +*/ +::osl::Mutex & SAL_CALL getImplHelperInitMutex(void) SAL_THROW( () ); +} + +// +// settle down beavis, here comes the macro template hell :] +// + +//================================================================================================== + +/** Implementation helper macros + Not for common use. There are expanded forms of the macro usage in implbaseN.hxx/compbaseN.hxx. + So there is commonly no need to use these macros. Though, you may need to implement more than + 12 interfaces. Then you have to declare something like the following in your headers + (where N is your demanded number of interfaces): + + #define __IFC3 Ifc1, Ifc2, Ifc3, ... up to N + #define __CLASS_IFC3 class Ifc1, class Ifc2, class Ifc3, ... up to N + #define __PUBLIC_IFC3 public Ifc1, public Ifc2, public Ifc3, ... up to N + __DEF_IMPLHELPER_PRE( N ) + __IFC_WRITEOFFSET( 1 ) __IFC_WRITEOFFSET( 2 ) __IFC_WRITEOFFSET( 3 ), ... up to N + __DEF_IMPLHELPER_POST( N ) + + @internal +*/ +#define __DEF_IMPLHELPER_PRE( N ) \ +namespace cppu \ +{ \ +struct ClassData##N : public ClassDataBase \ +{ \ + Type_Offset arType2Offset[ N ]; \ + ClassData##N( sal_Int32 nClassCode ) SAL_THROW( () ) \ + : ClassDataBase( nClassCode ) \ + {} \ +}; \ +template< __CLASS_IFC##N > \ +class SAL_NO_VTABLE ImplHelperBase##N \ + : public ::com::sun::star::lang::XTypeProvider \ + , __PUBLIC_IFC##N \ +{ \ +protected: \ + ClassData & SAL_CALL getClassData( ClassDataBase & s_aCD ) SAL_THROW( () ) \ + { \ + ClassData & rCD = * static_cast< ClassData * >( &s_aCD ); \ + if (! rCD.bOffsetsInit) \ + { \ + ::osl::MutexGuard aGuard( getImplHelperInitMutex() ); \ + if (! rCD.bOffsetsInit) \ + { \ + char * pBase = (char *)this; +/** Implementation helper macro: have a look at __DEF_IMPLHELPER_PRE + @internal +*/ +#define __IFC_WRITEOFFSET( N ) \ + rCD.writeTypeOffset( ::getCppuType( (const ::com::sun::star::uno::Reference< Ifc##N > *)0 ), \ + (char *)(Ifc##N *)this - pBase ); +/** Implementation helper macro: have a look at __DEF_IMPLHELPER_PRE + @internal +*/ +#define __DEF_IMPLHELPER_POST_A( N ) \ + rCD.bOffsetsInit = sal_True; \ + } \ + } \ + return rCD; \ + } \ +}; \ +template< __CLASS_IFC##N > \ +class SAL_NO_VTABLE ImplHelper##N \ + : public ImplHelperBase##N< __IFC##N > \ +{ \ + static ClassData##N s_aCD; \ +public: \ + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw (::com::sun::star::uno::RuntimeException) \ + { return this->getClassData( s_aCD ).query( rType, (ImplHelperBase##N< __IFC##N > *)this ); } \ + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) \ + { return this->getClassData( s_aCD ).getTypes(); } \ + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) \ + { return this->getClassData( s_aCD ).getImplementationId(); } \ +}; \ +template< __CLASS_IFC##N > \ +class SAL_NO_VTABLE WeakImplHelper##N \ + : public ::cppu::OWeakObject \ + , public ImplHelperBase##N< __IFC##N > \ +{ \ + static ClassData##N s_aCD; \ +public: \ + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw (::com::sun::star::uno::RuntimeException) \ + { \ + ::com::sun::star::uno::Any aRet( this->getClassData( s_aCD ).query( rType, (ImplHelperBase##N< __IFC##N > *)this ) ); \ + return (aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType )); \ + } \ + virtual void SAL_CALL acquire() throw () \ + { OWeakObject::acquire(); } \ + virtual void SAL_CALL release() throw () \ + { OWeakObject::release(); } \ + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) \ + { return this->getClassData( s_aCD ).getTypes(); } \ + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) \ + { return this->getClassData( s_aCD ).getImplementationId(); } \ +}; \ +template< __CLASS_IFC##N > \ +class SAL_NO_VTABLE WeakAggImplHelper##N \ + : public ::cppu::OWeakAggObject \ + , public ImplHelperBase##N< __IFC##N > \ +{ \ + static ClassData##N s_aCD; \ +public: \ + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw (::com::sun::star::uno::RuntimeException) \ + { return OWeakAggObject::queryInterface( rType ); } \ + virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type & rType ) throw (::com::sun::star::uno::RuntimeException) \ + { \ + ::com::sun::star::uno::Any aRet( this->getClassData( s_aCD ).query( rType, (ImplHelperBase##N< __IFC##N > *)this ) ); \ + return (aRet.hasValue() ? aRet : OWeakAggObject::queryAggregation( rType )); \ + } \ + virtual void SAL_CALL acquire() throw () \ + { OWeakAggObject::acquire(); } \ + virtual void SAL_CALL release() throw () \ + { OWeakAggObject::release(); } \ + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) \ + { return this->getClassData( s_aCD ).getTypes(); } \ + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) \ + { return this->getClassData( s_aCD ).getImplementationId(); } \ +}; + +/** Implementation helper macro: have a look at __DEF_IMPLHELPER_PRE + @internal +*/ +#define __DEF_IMPLHELPER_POST_B( N ) \ +template< __CLASS_IFC##N > \ +ClassData##N ImplHelper##N< __IFC##N >::s_aCD = ClassData##N( 0 ); \ +template< __CLASS_IFC##N > \ +ClassData##N WeakImplHelper##N< __IFC##N >::s_aCD = ClassData##N( 1 ); \ +template< __CLASS_IFC##N > \ +ClassData##N WeakAggImplHelper##N< __IFC##N >::s_aCD = ClassData##N( 2 ); +/** Implementation helper macro: have a look at __DEF_IMPLHELPER_PRE + @internal +*/ +#define __DEF_IMPLHELPER_POST_C( N ) \ +} +//================================================================================================== +/** Implementation helper macro: have a look at __DEF_IMPLHELPER_PRE + @internal +*/ +#define __DEF_IMPLHELPER_POST( N ) \ +__DEF_IMPLHELPER_POST_A( N ) \ +__DEF_IMPLHELPER_POST_B( N ) \ +__DEF_IMPLHELPER_POST_C( N ) +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/inc/cppuhelper/implbase1.hxx b/cppuhelper/inc/cppuhelper/implbase1.hxx new file mode 100644 index 000000000000..c7de4ad26e0b --- /dev/null +++ b/cppuhelper/inc/cppuhelper/implbase1.hxx @@ -0,0 +1,302 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CPPUHELPER_IMPLBASE1_HXX_ +#define _CPPUHELPER_IMPLBASE1_HXX_ + +#include <cppuhelper/implbase_ex.hxx> +#include <rtl/instance.hxx> +#include <com/sun/star/uno/XComponentContext.hpp> + +namespace cppu +{ + /** @internal */ + struct class_data1 + { + sal_Int16 m_nTypes; + sal_Bool m_storedTypeRefs; + sal_Bool m_storedId; + sal_Int8 m_id[ 16 ]; + type_entry m_typeEntries[ 1 + 1 ]; + }; + + /** @internal */ + template< typename Ifc1, typename Impl > struct ImplClassData1 + { + class_data* operator ()() + { + static class_data1 s_cd = + { + 1 +1, sal_False, sal_False, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { + { { Ifc1::static_type }, ((sal_IntPtr)(Ifc1 *) (Impl *) 16) - 16 }, + { { ::com::sun::star::lang::XTypeProvider::static_type }, ((sal_IntPtr)(::com::sun::star::lang::XTypeProvider *) (Impl *) 16) - 16 } + } + }; + return reinterpret_cast< class_data * >(&s_cd); + } + }; + + /** Implementation helper implementing interface ::com::sun::star::lang::XTypeProvider + and method XInterface::queryInterface(), but no reference counting. + + @derive + Inherit from this class giving your interface(s) to be implemented as template argument(s). + Your sub class defines method implementations for these interface(s) including acquire()/ + release() and delegates incoming queryInterface() calls to this base class. + */ + template< class Ifc1 > + class SAL_NO_VTABLE ImplHelper1 + : public ::com::sun::star::lang::XTypeProvider + , public Ifc1 + { + struct cd : public rtl::StaticAggregate< class_data, ImplClassData1 < Ifc1, ImplHelper1<Ifc1> > > {}; + public: + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_query( rType, cd::get(), this ); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getTypes( cd::get() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; + /** Implementation helper implementing interfaces ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::uno::XInterface which supports weak mechanism to be held weakly + (supporting ::com::sun::star::uno::XWeak thru ::cppu::OWeakObject). + + @derive + Inherit from this class giving your interface(s) to be implemented as template argument(s). + Your sub class defines method implementations for these interface(s). + + These classes are used when you implement your UNO component. + WeakImplHelper1 till WeakImplHelper12 can be used when you want + to implement 1 till 12 interfaces in your component. + */ + template< class Ifc1 > + class SAL_NO_VTABLE WeakImplHelper1 + : public OWeakObject + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData1< Ifc1, WeakImplHelper1< Ifc1 > > > {}; + public: + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return WeakImplHelper_query( rType, cd::get(), this, (OWeakObject *)this ); } + virtual void SAL_CALL acquire() throw () + { OWeakObject::acquire(); } + virtual void SAL_CALL release() throw () + { OWeakObject::release(); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return WeakImplHelper_getTypes( cd::get() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; + /** Implementation helper implementing interfaces ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::uno::XInterface which supports weak mechanism to be held weakly + (supporting ::com::sun::star::uno::XWeak thru ::cppu::OWeakAggObject). + In addition, it supports also aggregation meaning object of this class can be aggregated + (::com::sun::star::uno::XAggregation thru ::cppu::OWeakAggObject). + If a delegator is set (this object is aggregated), then incoming queryInterface() + calls are delegated to the delegator object. If the delegator does not support the + demanded interface, it calls queryAggregation() on its aggregated objects. + + @derive + Inherit from this class giving your interface(s) to be implemented as template argument(s). + Your sub class defines method implementations for these interface(s). + */ + template< class Ifc1 > + class SAL_NO_VTABLE WeakAggImplHelper1 + : public OWeakAggObject + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData1< Ifc1, WeakAggImplHelper1< Ifc1 > > > {}; + public: + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return OWeakAggObject::queryInterface( rType ); } + virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return WeakAggImplHelper_queryAgg( rType, cd::get(), this, (OWeakAggObject *)this ); } + virtual void SAL_CALL acquire() throw () + { OWeakAggObject::acquire(); } + virtual void SAL_CALL release() throw () + { OWeakAggObject::release(); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return WeakAggImplHelper_getTypes( cd::get() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; + /** Implementation helper implementing interfaces ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::uno::XInterface inherting from a BaseClass. + All acquire() and release() calls are delegated to the BaseClass. Upon queryInterface(), + if a demanded interface is not supported by this class directly, the request is + delegated to the BaseClass. + + @attention + The BaseClass has to be complete in a sense, that ::com::sun::star::uno::XInterface + and ::com::sun::star::lang::XTypeProvider are implemented properly. The + BaseClass must have at least one ctor that can be called with six or + fewer arguments, of which none is of non-const reference type. + + @derive + Inherit from this class giving your additional interface(s) to be implemented as + template argument(s). Your sub class defines method implementations for these interface(s). + */ + template< class BaseClass, class Ifc1 > + class SAL_NO_VTABLE ImplInheritanceHelper1 + : public BaseClass + , public Ifc1 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData1< Ifc1, ImplInheritanceHelper1< BaseClass, Ifc1 > > > {}; + protected: +#if (defined __SUNPRO_CC && __SUNPRO_CC <= 0x550) + // Hack, to get comphelper::service_decl to work for non-trivial impl classes + ImplInheritanceHelper1( com::sun::star::uno::Sequence<com::sun::star::uno::Any> const& args, + com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const& xContext ) : BaseClass(args,xContext) {} +#endif + template< typename T1 > + explicit ImplInheritanceHelper1(T1 const & arg1): BaseClass(arg1) {} + template< typename T1, typename T2 > + ImplInheritanceHelper1(T1 const & arg1, T2 const & arg2): + BaseClass(arg1, arg2) {} + template< typename T1, typename T2, typename T3 > + ImplInheritanceHelper1( + T1 const & arg1, T2 const & arg2, T3 const & arg3): + BaseClass(arg1, arg2, arg3) {} + template< typename T1, typename T2, typename T3, typename T4 > + ImplInheritanceHelper1( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4): + BaseClass(arg1, arg2, arg3, arg4) {} + template< + typename T1, typename T2, typename T3, typename T4, typename T5 > + ImplInheritanceHelper1( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4, + T5 const & arg5): + BaseClass(arg1, arg2, arg3, arg4, arg5) {} + template< + typename T1, typename T2, typename T3, typename T4, typename T5, + typename T6 > + ImplInheritanceHelper1( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4, + T5 const & arg5, T6 const & arg6): + BaseClass(arg1, arg2, arg3, arg4, arg5, arg6) {} + public: + ImplInheritanceHelper1() {} + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { + ::com::sun::star::uno::Any aRet( ImplHelper_queryNoXInterface( rType, cd::get(), this ) ); + if (aRet.hasValue()) + return aRet; + return BaseClass::queryInterface( rType ); + } + virtual void SAL_CALL acquire() throw () + { BaseClass::acquire(); } + virtual void SAL_CALL release() throw () + { BaseClass::release(); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; + /** Implementation helper implementing interfaces ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::uno::XInterface inherting from a BaseClass. + All acquire(), release() and queryInterface() calls are delegated to the BaseClass. + Upon queryAggregation(), if a demanded interface is not supported by this class directly, + the request is delegated to the BaseClass. + + @attention + The BaseClass has to be complete in a sense, that ::com::sun::star::uno::XInterface, + ::com::sun::star::uno::XAggregation and ::com::sun::star::lang::XTypeProvider + are implemented properly. The BaseClass must have at least one ctor + that can be called with six or fewer arguments, of which none is of + non-const reference type. + + @derive + Inherit from this class giving your additional interface(s) to be implemented as + template argument(s). Your sub class defines method implementations for these interface(s). + */ + template< class BaseClass, class Ifc1 > + class SAL_NO_VTABLE AggImplInheritanceHelper1 + : public BaseClass + , public Ifc1 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData1< Ifc1, AggImplInheritanceHelper1< BaseClass, Ifc1 > > > {}; + protected: + template< typename T1 > + explicit AggImplInheritanceHelper1(T1 const & arg1): BaseClass(arg1) {} + template< typename T1, typename T2 > + AggImplInheritanceHelper1(T1 const & arg1, T2 const & arg2): + BaseClass(arg1, arg2) {} + template< typename T1, typename T2, typename T3 > + AggImplInheritanceHelper1( + T1 const & arg1, T2 const & arg2, T3 const & arg3): + BaseClass(arg1, arg2, arg3) {} + template< typename T1, typename T2, typename T3, typename T4 > + AggImplInheritanceHelper1( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4): + BaseClass(arg1, arg2, arg3, arg4) {} + template< + typename T1, typename T2, typename T3, typename T4, typename T5 > + AggImplInheritanceHelper1( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4, + T5 const & arg5): + BaseClass(arg1, arg2, arg3, arg4, arg5) {} + template< + typename T1, typename T2, typename T3, typename T4, typename T5, + typename T6 > + AggImplInheritanceHelper1( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4, + T5 const & arg5, T6 const & arg6): + BaseClass(arg1, arg2, arg3, arg4, arg5, arg6) {} + public: + AggImplInheritanceHelper1() {} + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return BaseClass::queryInterface( rType ); } + virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { + ::com::sun::star::uno::Any aRet( ImplHelper_queryNoXInterface( rType, cd::get(), this ) ); + if (aRet.hasValue()) + return aRet; + return BaseClass::queryAggregation( rType ); + } + virtual void SAL_CALL acquire() throw () + { BaseClass::acquire(); } + virtual void SAL_CALL release() throw () + { BaseClass::release(); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/inc/cppuhelper/implbase10.hxx b/cppuhelper/inc/cppuhelper/implbase10.hxx new file mode 100644 index 000000000000..26ea7525732d --- /dev/null +++ b/cppuhelper/inc/cppuhelper/implbase10.hxx @@ -0,0 +1,303 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CPPUHELPER_IMPLBASE10_HXX_ +#define _CPPUHELPER_IMPLBASE10_HXX_ + +#include <cppuhelper/implbase_ex.hxx> +#include <rtl/instance.hxx> + +namespace cppu +{ + /** @internal */ + struct class_data10 + { + sal_Int16 m_nTypes; + sal_Bool m_storedTypeRefs; + sal_Bool m_storedId; + sal_Int8 m_id[ 16 ]; + type_entry m_typeEntries[ 10 + 1 ]; + }; + + /** @internal */ + template< typename Ifc1, typename Ifc2, typename Ifc3, typename Ifc4, typename Ifc5, typename Ifc6, typename Ifc7, typename Ifc8, typename Ifc9, typename Ifc10, typename Impl > + struct ImplClassData10 + { + class_data* operator ()() + { + static class_data10 s_cd = + { + 10 +1, sal_False, sal_False, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { + { { Ifc1::static_type }, ((sal_IntPtr)(Ifc1 *) (Impl *) 16) - 16 }, + { { Ifc2::static_type }, ((sal_IntPtr)(Ifc2 *) (Impl *) 16) - 16 }, + { { Ifc3::static_type }, ((sal_IntPtr)(Ifc3 *) (Impl *) 16) - 16 }, + { { Ifc4::static_type }, ((sal_IntPtr)(Ifc4 *) (Impl *) 16) - 16 }, + { { Ifc5::static_type }, ((sal_IntPtr)(Ifc5 *) (Impl *) 16) - 16 }, + { { Ifc6::static_type }, ((sal_IntPtr)(Ifc6 *) (Impl *) 16) - 16 }, + { { Ifc7::static_type }, ((sal_IntPtr)(Ifc7 *) (Impl *) 16) - 16 }, + { { Ifc8::static_type }, ((sal_IntPtr)(Ifc8 *) (Impl *) 16) - 16 }, + { { Ifc9::static_type }, ((sal_IntPtr)(Ifc9 *) (Impl *) 16) - 16 }, + { { Ifc10::static_type }, ((sal_IntPtr)(Ifc10 *) (Impl *) 16) - 16 }, + { { ::com::sun::star::lang::XTypeProvider::static_type }, ((sal_IntPtr)(::com::sun::star::lang::XTypeProvider *) (Impl *) 16) - 16 } + } + }; + return reinterpret_cast< class_data * >(&s_cd); + } + }; + + /** Implementation helper implementing interface ::com::sun::star::lang::XTypeProvider + and method XInterface::queryInterface(), but no reference counting. + + @derive + Inherit from this class giving your interface(s) to be implemented as template argument(s). + Your sub class defines method implementations for these interface(s) including acquire()/ + release() and delegates incoming queryInterface() calls to this base class. + */ + template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9, class Ifc10 > + class SAL_NO_VTABLE ImplHelper10 + : public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9, public Ifc10 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData10< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, ImplHelper10<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10> > > {}; + public: + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_query( rType, cd::get(), this ); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getTypes( cd::get() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; + /** Implementation helper implementing interfaces ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::uno::XInterface which supports weak mechanism to be held weakly + (supporting ::com::sun::star::uno::XWeak thru ::cppu::OWeakObject). + + @derive + Inherit from this class giving your interface(s) to be implemented as template argument(s). + Your sub class defines method implementations for these interface(s). + */ + template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9, class Ifc10 > + class SAL_NO_VTABLE WeakImplHelper10 + : public OWeakObject + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9, public Ifc10 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData10< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, WeakImplHelper10<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10> > > {}; + public: + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return WeakImplHelper_query( rType, cd::get(), this, (OWeakObject *)this ); } + virtual void SAL_CALL acquire() throw () + { OWeakObject::acquire(); } + virtual void SAL_CALL release() throw () + { OWeakObject::release(); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return WeakImplHelper_getTypes( cd::get() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; + /** Implementation helper implementing interfaces ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::uno::XInterface which supports weak mechanism to be held weakly + (supporting ::com::sun::star::uno::XWeak thru ::cppu::OWeakAggObject). + In addition, it supports also aggregation meaning object of this class can be aggregated + (::com::sun::star::uno::XAggregation thru ::cppu::OWeakAggObject). + If a delegator is set (this object is aggregated), then incoming queryInterface() + calls are delegated to the delegator object. If the delegator does not support the + demanded interface, it calls queryAggregation() on its aggregated objects. + + @derive + Inherit from this class giving your interface(s) to be implemented as template argument(s). + Your sub class defines method implementations for these interface(s). + */ + template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9, class Ifc10 > + class SAL_NO_VTABLE WeakAggImplHelper10 + : public OWeakAggObject + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9, public Ifc10 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData10< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, WeakAggImplHelper10<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10> > > {}; + public: + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return OWeakAggObject::queryInterface( rType ); } + virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return WeakAggImplHelper_queryAgg( rType, cd::get(), this, (OWeakAggObject *)this ); } + virtual void SAL_CALL acquire() throw () + { OWeakAggObject::acquire(); } + virtual void SAL_CALL release() throw () + { OWeakAggObject::release(); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return WeakAggImplHelper_getTypes( cd::get() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; + /** Implementation helper implementing interfaces ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::uno::XInterface inherting from a BaseClass. + All acquire() and release() calls are delegated to the BaseClass. Upon queryInterface(), + if a demanded interface is not supported by this class directly, the request is + delegated to the BaseClass. + + @attention + The BaseClass has to be complete in a sense, that ::com::sun::star::uno::XInterface + and ::com::sun::star::lang::XTypeProvider are implemented properly. The + BaseClass must have at least one ctor that can be called with six or + fewer arguments, of which none is of non-const reference type. + + @derive + Inherit from this class giving your additional interface(s) to be implemented as + template argument(s). Your sub class defines method implementations for these interface(s). + */ + template< class BaseClass, class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9, class Ifc10 > + class SAL_NO_VTABLE ImplInheritanceHelper10 + : public BaseClass + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9, public Ifc10 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData10< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, ImplInheritanceHelper10<BaseClass, Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10> > > {}; + protected: + template< typename T1 > + explicit ImplInheritanceHelper10(T1 const & arg1): BaseClass(arg1) {} + template< typename T1, typename T2 > + ImplInheritanceHelper10(T1 const & arg1, T2 const & arg2): + BaseClass(arg1, arg2) {} + template< typename T1, typename T2, typename T3 > + ImplInheritanceHelper10( + T1 const & arg1, T2 const & arg2, T3 const & arg3): + BaseClass(arg1, arg2, arg3) {} + template< typename T1, typename T2, typename T3, typename T4 > + ImplInheritanceHelper10( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4): + BaseClass(arg1, arg2, arg3, arg4) {} + template< + typename T1, typename T2, typename T3, typename T4, typename T5 > + ImplInheritanceHelper10( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4, + T5 const & arg5): + BaseClass(arg1, arg2, arg3, arg4, arg5) {} + template< + typename T1, typename T2, typename T3, typename T4, typename T5, + typename T6 > + ImplInheritanceHelper10( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4, + T5 const & arg5, T6 const & arg6): + BaseClass(arg1, arg2, arg3, arg4, arg5, arg6) {} + public: + ImplInheritanceHelper10() {} + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { + ::com::sun::star::uno::Any aRet( ImplHelper_queryNoXInterface( rType, cd::get(), this ) ); + if (aRet.hasValue()) + return aRet; + return BaseClass::queryInterface( rType ); + } + virtual void SAL_CALL acquire() throw () + { BaseClass::acquire(); } + virtual void SAL_CALL release() throw () + { BaseClass::release(); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; + /** Implementation helper implementing interfaces ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::uno::XInterface inherting from a BaseClass. + All acquire(), release() and queryInterface() calls are delegated to the BaseClass. + Upon queryAggregation(), if a demanded interface is not supported by this class directly, + the request is delegated to the BaseClass. + + @attention + The BaseClass has to be complete in a sense, that ::com::sun::star::uno::XInterface, + ::com::sun::star::uno::XAggregation and ::com::sun::star::lang::XTypeProvider + are implemented properly. The BaseClass must have at least one ctor + that can be called with six or fewer arguments, of which none is of + non-const reference type. + + @derive + Inherit from this class giving your additional interface(s) to be implemented as + template argument(s). Your sub class defines method implementations for these interface(s). + */ + template< class BaseClass, class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9, class Ifc10 > + class SAL_NO_VTABLE AggImplInheritanceHelper10 + : public BaseClass + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9, public Ifc10 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData10< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, AggImplInheritanceHelper10<BaseClass, Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10> > > {}; + protected: + template< typename T1 > + explicit AggImplInheritanceHelper10(T1 const & arg1): BaseClass(arg1) {} + template< typename T1, typename T2 > + AggImplInheritanceHelper10(T1 const & arg1, T2 const & arg2): + BaseClass(arg1, arg2) {} + template< typename T1, typename T2, typename T3 > + AggImplInheritanceHelper10( + T1 const & arg1, T2 const & arg2, T3 const & arg3): + BaseClass(arg1, arg2, arg3) {} + template< typename T1, typename T2, typename T3, typename T4 > + AggImplInheritanceHelper10( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4): + BaseClass(arg1, arg2, arg3, arg4) {} + template< + typename T1, typename T2, typename T3, typename T4, typename T5 > + AggImplInheritanceHelper10( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4, + T5 const & arg5): + BaseClass(arg1, arg2, arg3, arg4, arg5) {} + template< + typename T1, typename T2, typename T3, typename T4, typename T5, + typename T6 > + AggImplInheritanceHelper10( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4, + T5 const & arg5, T6 const & arg6): + BaseClass(arg1, arg2, arg3, arg4, arg5, arg6) {} + public: + AggImplInheritanceHelper10() {} + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return BaseClass::queryInterface( rType ); } + virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { + ::com::sun::star::uno::Any aRet( ImplHelper_queryNoXInterface( rType, cd::get(), this ) ); + if (aRet.hasValue()) + return aRet; + return BaseClass::queryAggregation( rType ); + } + virtual void SAL_CALL acquire() throw () + { BaseClass::acquire(); } + virtual void SAL_CALL release() throw () + { BaseClass::release(); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/inc/cppuhelper/implbase11.hxx b/cppuhelper/inc/cppuhelper/implbase11.hxx new file mode 100644 index 000000000000..c262cd6ae5b0 --- /dev/null +++ b/cppuhelper/inc/cppuhelper/implbase11.hxx @@ -0,0 +1,304 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CPPUHELPER_IMPLBASE11_HXX_ +#define _CPPUHELPER_IMPLBASE11_HXX_ + +#include <cppuhelper/implbase_ex.hxx> +#include <rtl/instance.hxx> + +namespace cppu +{ + /** @internal */ + struct class_data11 + { + sal_Int16 m_nTypes; + sal_Bool m_storedTypeRefs; + sal_Bool m_storedId; + sal_Int8 m_id[ 16 ]; + type_entry m_typeEntries[ 11 + 1 ]; + }; + + /** @internal */ + template< typename Ifc1, typename Ifc2, typename Ifc3, typename Ifc4, typename Ifc5, typename Ifc6, typename Ifc7, typename Ifc8, typename Ifc9, typename Ifc10, typename Ifc11, typename Impl > + struct ImplClassData11 + { + class_data* operator ()() + { + static class_data11 s_cd = + { + 11 +1, sal_False, sal_False, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { + { { Ifc1::static_type }, ((sal_IntPtr)(Ifc1 *) (Impl *) 16) - 16 }, + { { Ifc2::static_type }, ((sal_IntPtr)(Ifc2 *) (Impl *) 16) - 16 }, + { { Ifc3::static_type }, ((sal_IntPtr)(Ifc3 *) (Impl *) 16) - 16 }, + { { Ifc4::static_type }, ((sal_IntPtr)(Ifc4 *) (Impl *) 16) - 16 }, + { { Ifc5::static_type }, ((sal_IntPtr)(Ifc5 *) (Impl *) 16) - 16 }, + { { Ifc6::static_type }, ((sal_IntPtr)(Ifc6 *) (Impl *) 16) - 16 }, + { { Ifc7::static_type }, ((sal_IntPtr)(Ifc7 *) (Impl *) 16) - 16 }, + { { Ifc8::static_type }, ((sal_IntPtr)(Ifc8 *) (Impl *) 16) - 16 }, + { { Ifc9::static_type }, ((sal_IntPtr)(Ifc9 *) (Impl *) 16) - 16 }, + { { Ifc10::static_type }, ((sal_IntPtr)(Ifc10 *) (Impl *) 16) - 16 }, + { { Ifc11::static_type }, ((sal_IntPtr)(Ifc11 *) (Impl *) 16) - 16 }, + { { ::com::sun::star::lang::XTypeProvider::static_type }, ((sal_IntPtr)(::com::sun::star::lang::XTypeProvider *) (Impl *) 16) - 16 } + } + }; + return reinterpret_cast< class_data * >(&s_cd); + } + }; + + /** Implementation helper implementing interface ::com::sun::star::lang::XTypeProvider + and method XInterface::queryInterface(), but no reference counting. + + @derive + Inherit from this class giving your interface(s) to be implemented as template argument(s). + Your sub class defines method implementations for these interface(s) including acquire()/ + release() and delegates incoming queryInterface() calls to this base class. + */ + template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9, class Ifc10, class Ifc11 > + class SAL_NO_VTABLE ImplHelper11 + : public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9, public Ifc10, public Ifc11 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData11< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, ImplHelper11<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11> > > {}; + public: + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_query( rType, cd::get(), this ); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getTypes( cd::get() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; + /** Implementation helper implementing interfaces ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::uno::XInterface which supports weak mechanism to be held weakly + (supporting ::com::sun::star::uno::XWeak thru ::cppu::OWeakObject). + + @derive + Inherit from this class giving your interface(s) to be implemented as template argument(s). + Your sub class defines method implementations for these interface(s). + */ + template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9, class Ifc10, class Ifc11 > + class SAL_NO_VTABLE WeakImplHelper11 + : public OWeakObject + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9, public Ifc10, public Ifc11 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData11< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, WeakImplHelper11<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11> > > {}; + public: + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return WeakImplHelper_query( rType, cd::get(), this, (OWeakObject *)this ); } + virtual void SAL_CALL acquire() throw () + { OWeakObject::acquire(); } + virtual void SAL_CALL release() throw () + { OWeakObject::release(); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return WeakImplHelper_getTypes( cd::get() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; + /** Implementation helper implementing interfaces ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::uno::XInterface which supports weak mechanism to be held weakly + (supporting ::com::sun::star::uno::XWeak thru ::cppu::OWeakAggObject). + In addition, it supports also aggregation meaning object of this class can be aggregated + (::com::sun::star::uno::XAggregation thru ::cppu::OWeakAggObject). + If a delegator is set (this object is aggregated), then incoming queryInterface() + calls are delegated to the delegator object. If the delegator does not support the + demanded interface, it calls queryAggregation() on its aggregated objects. + + @derive + Inherit from this class giving your interface(s) to be implemented as template argument(s). + Your sub class defines method implementations for these interface(s). + */ + template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9, class Ifc10, class Ifc11 > + class SAL_NO_VTABLE WeakAggImplHelper11 + : public OWeakAggObject + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9, public Ifc10, public Ifc11 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData11< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, WeakAggImplHelper11<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11> > > {}; + public: + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return OWeakAggObject::queryInterface( rType ); } + virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return WeakAggImplHelper_queryAgg( rType, cd::get(), this, (OWeakAggObject *)this ); } + virtual void SAL_CALL acquire() throw () + { OWeakAggObject::acquire(); } + virtual void SAL_CALL release() throw () + { OWeakAggObject::release(); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return WeakAggImplHelper_getTypes( cd::get() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; + /** Implementation helper implementing interfaces ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::uno::XInterface inherting from a BaseClass. + All acquire() and release() calls are delegated to the BaseClass. Upon queryInterface(), + if a demanded interface is not supported by this class directly, the request is + delegated to the BaseClass. + + @attention + The BaseClass has to be complete in a sense, that ::com::sun::star::uno::XInterface + and ::com::sun::star::lang::XTypeProvider are implemented properly. The + BaseClass must have at least one ctor that can be called with six or + fewer arguments, of which none is of non-const reference type. + + @derive + Inherit from this class giving your additional interface(s) to be implemented as + template argument(s). Your sub class defines method implementations for these interface(s). + */ + template< class BaseClass, class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9, class Ifc10, class Ifc11 > + class SAL_NO_VTABLE ImplInheritanceHelper11 + : public BaseClass + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9, public Ifc10, public Ifc11 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData11< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, ImplInheritanceHelper11<BaseClass, Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11> > > {}; + protected: + template< typename T1 > + explicit ImplInheritanceHelper11(T1 const & arg1): BaseClass(arg1) {} + template< typename T1, typename T2 > + ImplInheritanceHelper11(T1 const & arg1, T2 const & arg2): + BaseClass(arg1, arg2) {} + template< typename T1, typename T2, typename T3 > + ImplInheritanceHelper11( + T1 const & arg1, T2 const & arg2, T3 const & arg3): + BaseClass(arg1, arg2, arg3) {} + template< typename T1, typename T2, typename T3, typename T4 > + ImplInheritanceHelper11( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4): + BaseClass(arg1, arg2, arg3, arg4) {} + template< + typename T1, typename T2, typename T3, typename T4, typename T5 > + ImplInheritanceHelper11( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4, + T5 const & arg5): + BaseClass(arg1, arg2, arg3, arg4, arg5) {} + template< + typename T1, typename T2, typename T3, typename T4, typename T5, + typename T6 > + ImplInheritanceHelper11( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4, + T5 const & arg5, T6 const & arg6): + BaseClass(arg1, arg2, arg3, arg4, arg5, arg6) {} + public: + ImplInheritanceHelper11() {} + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { + ::com::sun::star::uno::Any aRet( ImplHelper_queryNoXInterface( rType, cd::get(), this ) ); + if (aRet.hasValue()) + return aRet; + return BaseClass::queryInterface( rType ); + } + virtual void SAL_CALL acquire() throw () + { BaseClass::acquire(); } + virtual void SAL_CALL release() throw () + { BaseClass::release(); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; + /** Implementation helper implementing interfaces ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::uno::XInterface inherting from a BaseClass. + All acquire(), release() and queryInterface() calls are delegated to the BaseClass. + Upon queryAggregation(), if a demanded interface is not supported by this class directly, + the request is delegated to the BaseClass. + + @attention + The BaseClass has to be complete in a sense, that ::com::sun::star::uno::XInterface, + ::com::sun::star::uno::XAggregation and ::com::sun::star::lang::XTypeProvider + are implemented properly. The BaseClass must have at least one ctor + that can be called with six or fewer arguments, of which none is of + non-const reference type. + + @derive + Inherit from this class giving your additional interface(s) to be implemented as + template argument(s). Your sub class defines method implementations for these interface(s). + */ + template< class BaseClass, class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9, class Ifc10, class Ifc11 > + class SAL_NO_VTABLE AggImplInheritanceHelper11 + : public BaseClass + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9, public Ifc10, public Ifc11 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData11< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, AggImplInheritanceHelper11<BaseClass, Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11> > > {}; + protected: + template< typename T1 > + explicit AggImplInheritanceHelper11(T1 const & arg1): BaseClass(arg1) {} + template< typename T1, typename T2 > + AggImplInheritanceHelper11(T1 const & arg1, T2 const & arg2): + BaseClass(arg1, arg2) {} + template< typename T1, typename T2, typename T3 > + AggImplInheritanceHelper11( + T1 const & arg1, T2 const & arg2, T3 const & arg3): + BaseClass(arg1, arg2, arg3) {} + template< typename T1, typename T2, typename T3, typename T4 > + AggImplInheritanceHelper11( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4): + BaseClass(arg1, arg2, arg3, arg4) {} + template< + typename T1, typename T2, typename T3, typename T4, typename T5 > + AggImplInheritanceHelper11( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4, + T5 const & arg5): + BaseClass(arg1, arg2, arg3, arg4, arg5) {} + template< + typename T1, typename T2, typename T3, typename T4, typename T5, + typename T6 > + AggImplInheritanceHelper11( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4, + T5 const & arg5, T6 const & arg6): + BaseClass(arg1, arg2, arg3, arg4, arg5, arg6) {} + public: + AggImplInheritanceHelper11() {} + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return BaseClass::queryInterface( rType ); } + virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { + ::com::sun::star::uno::Any aRet( ImplHelper_queryNoXInterface( rType, cd::get(), this ) ); + if (aRet.hasValue()) + return aRet; + return BaseClass::queryAggregation( rType ); + } + virtual void SAL_CALL acquire() throw () + { BaseClass::acquire(); } + virtual void SAL_CALL release() throw () + { BaseClass::release(); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/inc/cppuhelper/implbase12.hxx b/cppuhelper/inc/cppuhelper/implbase12.hxx new file mode 100644 index 000000000000..a4ef396c0bd6 --- /dev/null +++ b/cppuhelper/inc/cppuhelper/implbase12.hxx @@ -0,0 +1,305 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CPPUHELPER_IMPLBASE12_HXX_ +#define _CPPUHELPER_IMPLBASE12_HXX_ + +#include <cppuhelper/implbase_ex.hxx> +#include <rtl/instance.hxx> + +namespace cppu +{ + /** @internal */ + struct class_data12 + { + sal_Int16 m_nTypes; + sal_Bool m_storedTypeRefs; + sal_Bool m_storedId; + sal_Int8 m_id[ 16 ]; + type_entry m_typeEntries[ 12 + 1 ]; + }; + + /** @internal */ + template< typename Ifc1, typename Ifc2, typename Ifc3, typename Ifc4, typename Ifc5, typename Ifc6, typename Ifc7, typename Ifc8, typename Ifc9, typename Ifc10, typename Ifc11, typename Ifc12, typename Impl > + struct ImplClassData12 + { + class_data* operator ()() + { + static class_data12 s_cd = + { + 12 +1, sal_False, sal_False, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { + { { Ifc1::static_type }, ((sal_IntPtr)(Ifc1 *) (Impl *) 16) - 16 }, + { { Ifc2::static_type }, ((sal_IntPtr)(Ifc2 *) (Impl *) 16) - 16 }, + { { Ifc3::static_type }, ((sal_IntPtr)(Ifc3 *) (Impl *) 16) - 16 }, + { { Ifc4::static_type }, ((sal_IntPtr)(Ifc4 *) (Impl *) 16) - 16 }, + { { Ifc5::static_type }, ((sal_IntPtr)(Ifc5 *) (Impl *) 16) - 16 }, + { { Ifc6::static_type }, ((sal_IntPtr)(Ifc6 *) (Impl *) 16) - 16 }, + { { Ifc7::static_type }, ((sal_IntPtr)(Ifc7 *) (Impl *) 16) - 16 }, + { { Ifc8::static_type }, ((sal_IntPtr)(Ifc8 *) (Impl *) 16) - 16 }, + { { Ifc9::static_type }, ((sal_IntPtr)(Ifc9 *) (Impl *) 16) - 16 }, + { { Ifc10::static_type }, ((sal_IntPtr)(Ifc10 *) (Impl *) 16) - 16 }, + { { Ifc11::static_type }, ((sal_IntPtr)(Ifc11 *) (Impl *) 16) - 16 }, + { { Ifc12::static_type }, ((sal_IntPtr)(Ifc12 *) (Impl *) 16) - 16 }, + { { ::com::sun::star::lang::XTypeProvider::static_type }, ((sal_IntPtr)(::com::sun::star::lang::XTypeProvider *) (Impl *) 16) - 16 } + } + }; + return reinterpret_cast< class_data * >(&s_cd); + } + }; + + /** Implementation helper implementing interface ::com::sun::star::lang::XTypeProvider + and method XInterface::queryInterface(), but no reference counting. + + @derive + Inherit from this class giving your interface(s) to be implemented as template argument(s). + Your sub class defines method implementations for these interface(s) including acquire()/ + release() and delegates incoming queryInterface() calls to this base class. + */ + template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9, class Ifc10, class Ifc11, class Ifc12 > + class SAL_NO_VTABLE ImplHelper12 + : public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9, public Ifc10, public Ifc11, public Ifc12 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData12< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, Ifc12, ImplHelper12<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, Ifc12> > > {}; + public: + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_query( rType, cd::get(), this ); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getTypes( cd::get() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; + /** Implementation helper implementing interfaces ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::uno::XInterface which supports weak mechanism to be held weakly + (supporting ::com::sun::star::uno::XWeak thru ::cppu::OWeakObject). + + @derive + Inherit from this class giving your interface(s) to be implemented as template argument(s). + Your sub class defines method implementations for these interface(s). + */ + template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9, class Ifc10, class Ifc11, class Ifc12 > + class SAL_NO_VTABLE WeakImplHelper12 + : public OWeakObject + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9, public Ifc10, public Ifc11, public Ifc12 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData12< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, Ifc12, WeakImplHelper12<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, Ifc12> > > {}; + public: + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return WeakImplHelper_query( rType, cd::get(), this, (OWeakObject *)this ); } + virtual void SAL_CALL acquire() throw () + { OWeakObject::acquire(); } + virtual void SAL_CALL release() throw () + { OWeakObject::release(); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return WeakImplHelper_getTypes( cd::get() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; + /** Implementation helper implementing interfaces ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::uno::XInterface which supports weak mechanism to be held weakly + (supporting ::com::sun::star::uno::XWeak thru ::cppu::OWeakAggObject). + In addition, it supports also aggregation meaning object of this class can be aggregated + (::com::sun::star::uno::XAggregation thru ::cppu::OWeakAggObject). + If a delegator is set (this object is aggregated), then incoming queryInterface() + calls are delegated to the delegator object. If the delegator does not support the + demanded interface, it calls queryAggregation() on its aggregated objects. + + @derive + Inherit from this class giving your interface(s) to be implemented as template argument(s). + Your sub class defines method implementations for these interface(s). + */ + template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9, class Ifc10, class Ifc11, class Ifc12 > + class SAL_NO_VTABLE WeakAggImplHelper12 + : public OWeakAggObject + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9, public Ifc10, public Ifc11, public Ifc12 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData12< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, Ifc12, WeakAggImplHelper12<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, Ifc12> > > {}; + public: + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return OWeakAggObject::queryInterface( rType ); } + virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return WeakAggImplHelper_queryAgg( rType, cd::get(), this, (OWeakAggObject *)this ); } + virtual void SAL_CALL acquire() throw () + { OWeakAggObject::acquire(); } + virtual void SAL_CALL release() throw () + { OWeakAggObject::release(); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return WeakAggImplHelper_getTypes( cd::get() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; + /** Implementation helper implementing interfaces ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::uno::XInterface inherting from a BaseClass. + All acquire() and release() calls are delegated to the BaseClass. Upon queryInterface(), + if a demanded interface is not supported by this class directly, the request is + delegated to the BaseClass. + + @attention + The BaseClass has to be complete in a sense, that ::com::sun::star::uno::XInterface + and ::com::sun::star::lang::XTypeProvider are implemented properly. The + BaseClass must have at least one ctor that can be called with six or + fewer arguments, of which none is of non-const reference type. + + @derive + Inherit from this class giving your additional interface(s) to be implemented as + template argument(s). Your sub class defines method implementations for these interface(s). + */ + template< class BaseClass, class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9, class Ifc10, class Ifc11, class Ifc12 > + class SAL_NO_VTABLE ImplInheritanceHelper12 + : public BaseClass + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9, public Ifc10, public Ifc11, public Ifc12 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData12< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, Ifc12, ImplInheritanceHelper12<BaseClass, Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, Ifc12> > > {}; + protected: + template< typename T1 > + explicit ImplInheritanceHelper12(T1 const & arg1): BaseClass(arg1) {} + template< typename T1, typename T2 > + ImplInheritanceHelper12(T1 const & arg1, T2 const & arg2): + BaseClass(arg1, arg2) {} + template< typename T1, typename T2, typename T3 > + ImplInheritanceHelper12( + T1 const & arg1, T2 const & arg2, T3 const & arg3): + BaseClass(arg1, arg2, arg3) {} + template< typename T1, typename T2, typename T3, typename T4 > + ImplInheritanceHelper12( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4): + BaseClass(arg1, arg2, arg3, arg4) {} + template< + typename T1, typename T2, typename T3, typename T4, typename T5 > + ImplInheritanceHelper12( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4, + T5 const & arg5): + BaseClass(arg1, arg2, arg3, arg4, arg5) {} + template< + typename T1, typename T2, typename T3, typename T4, typename T5, + typename T6 > + ImplInheritanceHelper12( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4, + T5 const & arg5, T6 const & arg6): + BaseClass(arg1, arg2, arg3, arg4, arg5, arg6) {} + public: + ImplInheritanceHelper12() {} + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { + ::com::sun::star::uno::Any aRet( ImplHelper_queryNoXInterface( rType, cd::get(), this ) ); + if (aRet.hasValue()) + return aRet; + return BaseClass::queryInterface( rType ); + } + virtual void SAL_CALL acquire() throw () + { BaseClass::acquire(); } + virtual void SAL_CALL release() throw () + { BaseClass::release(); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; + /** Implementation helper implementing interfaces ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::uno::XInterface inherting from a BaseClass. + All acquire(), release() and queryInterface() calls are delegated to the BaseClass. + Upon queryAggregation(), if a demanded interface is not supported by this class directly, + the request is delegated to the BaseClass. + + @attention + The BaseClass has to be complete in a sense, that ::com::sun::star::uno::XInterface, + ::com::sun::star::uno::XAggregation and ::com::sun::star::lang::XTypeProvider + are implemented properly. The BaseClass must have at least one ctor + that can be called with six or fewer arguments, of which none is of + non-const reference type. + + @derive + Inherit from this class giving your additional interface(s) to be implemented as + template argument(s). Your sub class defines method implementations for these interface(s). + */ + template< class BaseClass, class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9, class Ifc10, class Ifc11, class Ifc12 > + class SAL_NO_VTABLE AggImplInheritanceHelper12 + : public BaseClass + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9, public Ifc10, public Ifc11, public Ifc12 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData12< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, Ifc12, AggImplInheritanceHelper12<BaseClass, Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, Ifc12> > > {}; + protected: + template< typename T1 > + explicit AggImplInheritanceHelper12(T1 const & arg1): BaseClass(arg1) {} + template< typename T1, typename T2 > + AggImplInheritanceHelper12(T1 const & arg1, T2 const & arg2): + BaseClass(arg1, arg2) {} + template< typename T1, typename T2, typename T3 > + AggImplInheritanceHelper12( + T1 const & arg1, T2 const & arg2, T3 const & arg3): + BaseClass(arg1, arg2, arg3) {} + template< typename T1, typename T2, typename T3, typename T4 > + AggImplInheritanceHelper12( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4): + BaseClass(arg1, arg2, arg3, arg4) {} + template< + typename T1, typename T2, typename T3, typename T4, typename T5 > + AggImplInheritanceHelper12( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4, + T5 const & arg5): + BaseClass(arg1, arg2, arg3, arg4, arg5) {} + template< + typename T1, typename T2, typename T3, typename T4, typename T5, + typename T6 > + AggImplInheritanceHelper12( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4, + T5 const & arg5, T6 const & arg6): + BaseClass(arg1, arg2, arg3, arg4, arg5, arg6) {} + public: + AggImplInheritanceHelper12() {} + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return BaseClass::queryInterface( rType ); } + virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { + ::com::sun::star::uno::Any aRet( ImplHelper_queryNoXInterface( rType, cd::get(), this ) ); + if (aRet.hasValue()) + return aRet; + return BaseClass::queryAggregation( rType ); + } + virtual void SAL_CALL acquire() throw () + { BaseClass::acquire(); } + virtual void SAL_CALL release() throw () + { BaseClass::release(); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/inc/cppuhelper/implbase2.hxx b/cppuhelper/inc/cppuhelper/implbase2.hxx new file mode 100644 index 000000000000..8aa6fb4ceeda --- /dev/null +++ b/cppuhelper/inc/cppuhelper/implbase2.hxx @@ -0,0 +1,294 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CPPUHELPER_IMPLBASE2_HXX_ +#define _CPPUHELPER_IMPLBASE2_HXX_ + +#include <cppuhelper/implbase_ex.hxx> +#include <rtl/instance.hxx> + +namespace cppu +{ + /** @internal */ + struct class_data2 + { + sal_Int16 m_nTypes; + sal_Bool m_storedTypeRefs; + sal_Bool m_storedId; + sal_Int8 m_id[ 16 ]; + type_entry m_typeEntries[ 2 + 1 ]; + }; + + /** @internal */ + template< typename Ifc1, typename Ifc2, typename Impl > struct ImplClassData2 + { + class_data* operator ()() + { + static class_data2 s_cd = + { + 2 +1, sal_False, sal_False, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { + { { Ifc1::static_type }, ((sal_IntPtr)(Ifc1 *) (Impl *) 16) - 16 }, + { { Ifc2::static_type }, ((sal_IntPtr)(Ifc2 *) (Impl *) 16) - 16 }, + { { ::com::sun::star::lang::XTypeProvider::static_type }, ((sal_IntPtr)(::com::sun::star::lang::XTypeProvider *) (Impl *) 16) - 16 } + } + }; + return reinterpret_cast< class_data * >(&s_cd); + } + }; + + /** Implementation helper implementing interface ::com::sun::star::lang::XTypeProvider + and queryInterface(), but no reference counting. + + @derive + Inherit from this class giving your interface(s) to be implemented as template argument(s). + Your base class defines method implementations, acquire(), release() and delegates incoming + queryInterface() calls to this base class. + */ + template< class Ifc1, class Ifc2 > + class SAL_NO_VTABLE ImplHelper2 + : public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData2 < Ifc1, Ifc2, ImplHelper2<Ifc1, Ifc2> > > {}; + public: + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_query( rType, cd::get(), this ); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getTypes( cd::get() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; + /** Implementation helper implementing interfaces ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::uno::XInterface which supports weak mechanism to be held weakly + (supporting ::com::sun::star::uno::XWeak thru ::cppu::OWeakObject). + + @derive + Inherit from this class giving your interface(s) to be implemented as template argument(s). + Your sub class defines method implementations for these interface(s). + */ + template< class Ifc1, class Ifc2 > + class SAL_NO_VTABLE WeakImplHelper2 + : public OWeakObject + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData2 < Ifc1, Ifc2, WeakImplHelper2<Ifc1, Ifc2> > > {}; + public: + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return WeakImplHelper_query( rType, cd::get(), this, (OWeakObject *)this ); } + virtual void SAL_CALL acquire() throw () + { OWeakObject::acquire(); } + virtual void SAL_CALL release() throw () + { OWeakObject::release(); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return WeakImplHelper_getTypes( cd::get() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; + /** Implementation helper implementing interfaces ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::uno::XInterface which supports weak mechanism to be held weakly + (supporting ::com::sun::star::uno::XWeak thru ::cppu::OWeakAggObject). + In addition, it supports also aggregation meaning object of this class can be aggregated + (::com::sun::star::uno::XAggregation thru ::cppu::OWeakAggObject). + If a delegator is set (this object is aggregated), then incoming queryInterface() + calls are delegated to the delegator object. If the delegator does not support the + demanded interface, it calls queryAggregation() on its aggregated objects. + + @derive + Inherit from this class giving your interface(s) to be implemented as template argument(s). + Your sub class defines method implementations for these interface(s). + */ + template< class Ifc1, class Ifc2 > + class SAL_NO_VTABLE WeakAggImplHelper2 + : public OWeakAggObject + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData2 < Ifc1, Ifc2, WeakAggImplHelper2<Ifc1, Ifc2> > > {}; + public: + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return OWeakAggObject::queryInterface( rType ); } + virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return WeakAggImplHelper_queryAgg( rType, cd::get(), this, (OWeakAggObject *)this ); } + virtual void SAL_CALL acquire() throw () + { OWeakAggObject::acquire(); } + virtual void SAL_CALL release() throw () + { OWeakAggObject::release(); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return WeakAggImplHelper_getTypes( cd::get() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; + /** Implementation helper implementing interfaces ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::uno::XInterface inherting from a BaseClass. + All acquire() and release() calls are delegated to the BaseClass. Upon queryInterface(), + if a demanded interface is not supported by this class directly, the request is + delegated to the BaseClass. + + @attention + The BaseClass has to be complete in a sense, that ::com::sun::star::uno::XInterface + and ::com::sun::star::lang::XTypeProvider are implemented properly. The + BaseClass must have at least one ctor that can be called with six or + fewer arguments, of which none is of non-const reference type. + + @derive + Inherit from this class giving your additional interface(s) to be implemented as + template argument(s). Your sub class defines method implementations for these interface(s). + */ + template< class BaseClass, class Ifc1, class Ifc2 > + class SAL_NO_VTABLE ImplInheritanceHelper2 + : public BaseClass + , public Ifc1, public Ifc2 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData2 < Ifc1, Ifc2, ImplInheritanceHelper2<BaseClass, Ifc1, Ifc2> > > {}; + protected: + template< typename T1 > + explicit ImplInheritanceHelper2(T1 const & arg1): BaseClass(arg1) {} + template< typename T1, typename T2 > + ImplInheritanceHelper2(T1 const & arg1, T2 const & arg2): + BaseClass(arg1, arg2) {} + template< typename T1, typename T2, typename T3 > + ImplInheritanceHelper2( + T1 const & arg1, T2 const & arg2, T3 const & arg3): + BaseClass(arg1, arg2, arg3) {} + template< typename T1, typename T2, typename T3, typename T4 > + ImplInheritanceHelper2( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4): + BaseClass(arg1, arg2, arg3, arg4) {} + template< + typename T1, typename T2, typename T3, typename T4, typename T5 > + ImplInheritanceHelper2( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4, + T5 const & arg5): + BaseClass(arg1, arg2, arg3, arg4, arg5) {} + template< + typename T1, typename T2, typename T3, typename T4, typename T5, + typename T6 > + ImplInheritanceHelper2( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4, + T5 const & arg5, T6 const & arg6): + BaseClass(arg1, arg2, arg3, arg4, arg5, arg6) {} + public: + ImplInheritanceHelper2() {} + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { + ::com::sun::star::uno::Any aRet( ImplHelper_queryNoXInterface( rType, cd::get(), this ) ); + if (aRet.hasValue()) + return aRet; + return BaseClass::queryInterface( rType ); + } + virtual void SAL_CALL acquire() throw () + { BaseClass::acquire(); } + virtual void SAL_CALL release() throw () + { BaseClass::release(); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; + /** Implementation helper implementing interfaces ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::uno::XInterface inherting from a BaseClass. + All acquire(), release() and queryInterface() calls are delegated to the BaseClass. + Upon queryAggregation(), if a demanded interface is not supported by this class directly, + the request is delegated to the BaseClass. + + @attention + The BaseClass has to be complete in a sense, that ::com::sun::star::uno::XInterface, + ::com::sun::star::uno::XAggregation and ::com::sun::star::lang::XTypeProvider + are implemented properly. The BaseClass must have at least one ctor + that can be called with six or fewer arguments, of which none is of + non-const reference type. + + @derive + Inherit from this class giving your additional interface(s) to be implemented as + template argument(s). Your sub class defines method implementations for these interface(s). + */ + template< class BaseClass, class Ifc1, class Ifc2 > + class SAL_NO_VTABLE AggImplInheritanceHelper2 + : public BaseClass + , public Ifc1, public Ifc2 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData2 < Ifc1, Ifc2, AggImplInheritanceHelper2<BaseClass, Ifc1, Ifc2> > > {}; + protected: + template< typename T1 > + explicit AggImplInheritanceHelper2(T1 const & arg1): BaseClass(arg1) {} + template< typename T1, typename T2 > + AggImplInheritanceHelper2(T1 const & arg1, T2 const & arg2): + BaseClass(arg1, arg2) {} + template< typename T1, typename T2, typename T3 > + AggImplInheritanceHelper2( + T1 const & arg1, T2 const & arg2, T3 const & arg3): + BaseClass(arg1, arg2, arg3) {} + template< typename T1, typename T2, typename T3, typename T4 > + AggImplInheritanceHelper2( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4): + BaseClass(arg1, arg2, arg3, arg4) {} + template< + typename T1, typename T2, typename T3, typename T4, typename T5 > + AggImplInheritanceHelper2( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4, + T5 const & arg5): + BaseClass(arg1, arg2, arg3, arg4, arg5) {} + template< + typename T1, typename T2, typename T3, typename T4, typename T5, + typename T6 > + AggImplInheritanceHelper2( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4, + T5 const & arg5, T6 const & arg6): + BaseClass(arg1, arg2, arg3, arg4, arg5, arg6) {} + public: + AggImplInheritanceHelper2() {} + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return BaseClass::queryInterface( rType ); } + virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { + ::com::sun::star::uno::Any aRet( ImplHelper_queryNoXInterface( rType, cd::get(), this ) ); + if (aRet.hasValue()) + return aRet; + return BaseClass::queryAggregation( rType ); + } + virtual void SAL_CALL acquire() throw () + { BaseClass::acquire(); } + virtual void SAL_CALL release() throw () + { BaseClass::release(); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/inc/cppuhelper/implbase3.hxx b/cppuhelper/inc/cppuhelper/implbase3.hxx new file mode 100644 index 000000000000..e3cca581febd --- /dev/null +++ b/cppuhelper/inc/cppuhelper/implbase3.hxx @@ -0,0 +1,296 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CPPUHELPER_IMPLBASE3_HXX_ +#define _CPPUHELPER_IMPLBASE3_HXX_ + +#include <cppuhelper/implbase_ex.hxx> +#include <rtl/instance.hxx> + +namespace cppu +{ + /** @internal */ + struct class_data3 + { + sal_Int16 m_nTypes; + sal_Bool m_storedTypeRefs; + sal_Bool m_storedId; + sal_Int8 m_id[ 16 ]; + type_entry m_typeEntries[ 3 + 1 ]; + }; + + /** @internal */ + template< typename Ifc1, typename Ifc2, typename Ifc3, typename Impl > struct ImplClassData3 + { + class_data* operator ()() + { + static class_data3 s_cd = + { + 3 +1, sal_False, sal_False, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { + { { Ifc1::static_type }, ((sal_IntPtr)(Ifc1 *) (Impl *) 16) - 16 }, + { { Ifc2::static_type }, ((sal_IntPtr)(Ifc2 *) (Impl *) 16) - 16 }, + { { Ifc3::static_type }, ((sal_IntPtr)(Ifc3 *) (Impl *) 16) - 16 }, + { { ::com::sun::star::lang::XTypeProvider::static_type }, ((sal_IntPtr)(::com::sun::star::lang::XTypeProvider *) (Impl *) 16) - 16 } + } + }; + return reinterpret_cast< class_data * >(&s_cd); + } + }; + + /** Implementation helper implementing interface ::com::sun::star::lang::XTypeProvider + and method XInterface::queryInterface(), but no reference counting. + + @derive + Inherit from this class giving your interface(s) to be implemented as template argument(s). + Your sub class defines method implementations for these interface(s) including acquire()/ + release() and delegates incoming queryInterface() calls to this base class. + */ + template< class Ifc1, class Ifc2, class Ifc3 > + class SAL_NO_VTABLE ImplHelper3 + : public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData3 < Ifc1, Ifc2, Ifc3, ImplHelper3<Ifc1, Ifc2, Ifc3> > > {}; + public: + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_query( rType, cd::get(), this ); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getTypes( cd::get() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; + /** Implementation helper implementing interfaces ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::uno::XInterface which supports weak mechanism to be held weakly + (supporting ::com::sun::star::uno::XWeak thru ::cppu::OWeakObject). + + @derive + Inherit from this class giving your interface(s) to be implemented as template argument(s). + Your sub class defines method implementations for these interface(s). + */ + template< class Ifc1, class Ifc2, class Ifc3 > + class SAL_NO_VTABLE WeakImplHelper3 + : public OWeakObject + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData3 < Ifc1, Ifc2, Ifc3, WeakImplHelper3<Ifc1, Ifc2, Ifc3> > > {}; + public: + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return WeakImplHelper_query( rType, cd::get(), this, (OWeakObject *)this ); } + virtual void SAL_CALL acquire() throw () + { OWeakObject::acquire(); } + virtual void SAL_CALL release() throw () + { OWeakObject::release(); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return WeakImplHelper_getTypes( cd::get() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; + /** Implementation helper implementing interfaces ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::uno::XInterface which supports weak mechanism to be held weakly + (supporting ::com::sun::star::uno::XWeak thru ::cppu::OWeakAggObject). + In addition, it supports also aggregation meaning object of this class can be aggregated + (::com::sun::star::uno::XAggregation thru ::cppu::OWeakAggObject). + If a delegator is set (this object is aggregated), then incoming queryInterface() + calls are delegated to the delegator object. If the delegator does not support the + demanded interface, it calls queryAggregation() on its aggregated objects. + + @derive + Inherit from this class giving your interface(s) to be implemented as template argument(s). + Your sub class defines method implementations for these interface(s). + */ + template< class Ifc1, class Ifc2, class Ifc3 > + class SAL_NO_VTABLE WeakAggImplHelper3 + : public OWeakAggObject + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData3 < Ifc1, Ifc2, Ifc3, WeakAggImplHelper3<Ifc1, Ifc2, Ifc3> > > {}; + public: + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return OWeakAggObject::queryInterface( rType ); } + virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return WeakAggImplHelper_queryAgg( rType, cd::get(), this, (OWeakAggObject *)this ); } + virtual void SAL_CALL acquire() throw () + { OWeakAggObject::acquire(); } + virtual void SAL_CALL release() throw () + { OWeakAggObject::release(); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return WeakAggImplHelper_getTypes( cd::get() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; + /** Implementation helper implementing interfaces ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::uno::XInterface inherting from a BaseClass. + All acquire() and release() calls are delegated to the BaseClass. Upon queryInterface(), + if a demanded interface is not supported by this class directly, the request is + delegated to the BaseClass. + + @attention + The BaseClass has to be complete in a sense, that ::com::sun::star::uno::XInterface + and ::com::sun::star::lang::XTypeProvider are implemented properly. The + BaseClass must have at least one ctor that can be called with six or + fewer arguments, of which none is of non-const reference type. + also has to have a default ctor. + + @derive + Inherit from this class giving your additional interface(s) to be implemented as + template argument(s). Your sub class defines method implementations for these interface(s). + */ + template< class BaseClass, class Ifc1, class Ifc2, class Ifc3 > + class SAL_NO_VTABLE ImplInheritanceHelper3 + : public BaseClass + , public Ifc1, public Ifc2, public Ifc3 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData3 < Ifc1, Ifc2, Ifc3, ImplInheritanceHelper3<BaseClass, Ifc1, Ifc2, Ifc3> > > {}; + protected: + template< typename T1 > + explicit ImplInheritanceHelper3(T1 const & arg1): BaseClass(arg1) {} + template< typename T1, typename T2 > + ImplInheritanceHelper3(T1 const & arg1, T2 const & arg2): + BaseClass(arg1, arg2) {} + template< typename T1, typename T2, typename T3 > + ImplInheritanceHelper3( + T1 const & arg1, T2 const & arg2, T3 const & arg3): + BaseClass(arg1, arg2, arg3) {} + template< typename T1, typename T2, typename T3, typename T4 > + ImplInheritanceHelper3( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4): + BaseClass(arg1, arg2, arg3, arg4) {} + template< + typename T1, typename T2, typename T3, typename T4, typename T5 > + ImplInheritanceHelper3( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4, + T5 const & arg5): + BaseClass(arg1, arg2, arg3, arg4, arg5) {} + template< + typename T1, typename T2, typename T3, typename T4, typename T5, + typename T6 > + ImplInheritanceHelper3( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4, + T5 const & arg5, T6 const & arg6): + BaseClass(arg1, arg2, arg3, arg4, arg5, arg6) {} + public: + ImplInheritanceHelper3() {} + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { + ::com::sun::star::uno::Any aRet( ImplHelper_queryNoXInterface( rType, cd::get(), this ) ); + if (aRet.hasValue()) + return aRet; + return BaseClass::queryInterface( rType ); + } + virtual void SAL_CALL acquire() throw () + { BaseClass::acquire(); } + virtual void SAL_CALL release() throw () + { BaseClass::release(); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; + /** Implementation helper implementing interfaces ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::uno::XInterface inherting from a BaseClass. + All acquire(), release() and queryInterface() calls are delegated to the BaseClass. + Upon queryAggregation(), if a demanded interface is not supported by this class directly, + the request is delegated to the BaseClass. + + @attention + The BaseClass has to be complete in a sense, that ::com::sun::star::uno::XInterface, + ::com::sun::star::uno::XAggregation and ::com::sun::star::lang::XTypeProvider + are implemented properly. The BaseClass must have at least one ctor + that can be called with six or fewer arguments, of which none is of + non-const reference type. + + @derive + Inherit from this class giving your additional interface(s) to be implemented as + template argument(s). Your sub class defines method implementations for these interface(s). + */ + template< class BaseClass, class Ifc1, class Ifc2, class Ifc3 > + class SAL_NO_VTABLE AggImplInheritanceHelper3 + : public BaseClass + , public Ifc1, public Ifc2, public Ifc3 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData3 < Ifc1, Ifc2, Ifc3, AggImplInheritanceHelper3<BaseClass, Ifc1, Ifc2, Ifc3> > > {}; + protected: + template< typename T1 > + explicit AggImplInheritanceHelper3(T1 const & arg1): BaseClass(arg1) {} + template< typename T1, typename T2 > + AggImplInheritanceHelper3(T1 const & arg1, T2 const & arg2): + BaseClass(arg1, arg2) {} + template< typename T1, typename T2, typename T3 > + AggImplInheritanceHelper3( + T1 const & arg1, T2 const & arg2, T3 const & arg3): + BaseClass(arg1, arg2, arg3) {} + template< typename T1, typename T2, typename T3, typename T4 > + AggImplInheritanceHelper3( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4): + BaseClass(arg1, arg2, arg3, arg4) {} + template< + typename T1, typename T2, typename T3, typename T4, typename T5 > + AggImplInheritanceHelper3( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4, + T5 const & arg5): + BaseClass(arg1, arg2, arg3, arg4, arg5) {} + template< + typename T1, typename T2, typename T3, typename T4, typename T5, + typename T6 > + AggImplInheritanceHelper3( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4, + T5 const & arg5, T6 const & arg6): + BaseClass(arg1, arg2, arg3, arg4, arg5, arg6) {} + public: + AggImplInheritanceHelper3() {} + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return BaseClass::queryInterface( rType ); } + virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { + ::com::sun::star::uno::Any aRet( ImplHelper_queryNoXInterface( rType, cd::get(), this ) ); + if (aRet.hasValue()) + return aRet; + return BaseClass::queryAggregation( rType ); + } + virtual void SAL_CALL acquire() throw () + { BaseClass::acquire(); } + virtual void SAL_CALL release() throw () + { BaseClass::release(); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/inc/cppuhelper/implbase4.hxx b/cppuhelper/inc/cppuhelper/implbase4.hxx new file mode 100644 index 000000000000..c982fca2a9ca --- /dev/null +++ b/cppuhelper/inc/cppuhelper/implbase4.hxx @@ -0,0 +1,297 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CPPUHELPER_IMPLBASE4_HXX_ +#define _CPPUHELPER_IMPLBASE4_HXX_ + +#include <cppuhelper/implbase_ex.hxx> +#include <rtl/instance.hxx> + +namespace cppu +{ + /** @internal */ + struct class_data4 + { + sal_Int16 m_nTypes; + sal_Bool m_storedTypeRefs; + sal_Bool m_storedId; + sal_Int8 m_id[ 16 ]; + type_entry m_typeEntries[ 4 + 1 ]; + }; + + /** @internal */ + template< typename Ifc1, typename Ifc2, typename Ifc3, typename Ifc4, typename Impl > + struct ImplClassData4 + { + class_data* operator ()() + { + static class_data4 s_cd = + { + 4 +1, sal_False, sal_False, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { + { { Ifc1::static_type }, ((sal_IntPtr)(Ifc1 *) (Impl *) 16) - 16 }, + { { Ifc2::static_type }, ((sal_IntPtr)(Ifc2 *) (Impl *) 16) - 16 }, + { { Ifc3::static_type }, ((sal_IntPtr)(Ifc3 *) (Impl *) 16) - 16 }, + { { Ifc4::static_type }, ((sal_IntPtr)(Ifc4 *) (Impl *) 16) - 16 }, + { { ::com::sun::star::lang::XTypeProvider::static_type }, ((sal_IntPtr)(::com::sun::star::lang::XTypeProvider *) (Impl *) 16) - 16 } + } + }; + return reinterpret_cast< class_data * >(&s_cd); + } + }; + + /** Implementation helper implementing interface ::com::sun::star::lang::XTypeProvider + and method XInterface::queryInterface(), but no reference counting. + + @derive + Inherit from this class giving your interface(s) to be implemented as template argument(s). + Your sub class defines method implementations for these interface(s) including acquire()/ + release() and delegates incoming queryInterface() calls to this base class. + */ + template< class Ifc1, class Ifc2, class Ifc3, class Ifc4 > + class SAL_NO_VTABLE ImplHelper4 + : public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData4 < Ifc1, Ifc2, Ifc3, Ifc4, ImplHelper4<Ifc1, Ifc2, Ifc3, Ifc4> > > {}; + public: + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_query( rType, cd::get(), this ); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getTypes( cd::get() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; + /** Implementation helper implementing interfaces ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::uno::XInterface which supports weak mechanism to be held weakly + (supporting ::com::sun::star::uno::XWeak thru ::cppu::OWeakObject). + + @derive + Inherit from this class giving your interface(s) to be implemented as template argument(s). + Your sub class defines method implementations for these interface(s). + */ + template< class Ifc1, class Ifc2, class Ifc3, class Ifc4 > + class SAL_NO_VTABLE WeakImplHelper4 + : public OWeakObject + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData4 < Ifc1, Ifc2, Ifc3, Ifc4, WeakImplHelper4<Ifc1, Ifc2, Ifc3, Ifc4> > > {}; + public: + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return WeakImplHelper_query( rType, cd::get(), this, (OWeakObject *)this ); } + virtual void SAL_CALL acquire() throw () + { OWeakObject::acquire(); } + virtual void SAL_CALL release() throw () + { OWeakObject::release(); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return WeakImplHelper_getTypes( cd::get() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; + /** Implementation helper implementing interfaces ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::uno::XInterface which supports weak mechanism to be held weakly + (supporting ::com::sun::star::uno::XWeak thru ::cppu::OWeakAggObject). + In addition, it supports also aggregation meaning object of this class can be aggregated + (::com::sun::star::uno::XAggregation thru ::cppu::OWeakAggObject). + If a delegator is set (this object is aggregated), then incoming queryInterface() + calls are delegated to the delegator object. If the delegator does not support the + demanded interface, it calls queryAggregation() on its aggregated objects. + + @derive + Inherit from this class giving your interface(s) to be implemented as template argument(s). + Your sub class defines method implementations for these interface(s). + */ + template< class Ifc1, class Ifc2, class Ifc3, class Ifc4 > + class SAL_NO_VTABLE WeakAggImplHelper4 + : public OWeakAggObject + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData4 < Ifc1, Ifc2, Ifc3, Ifc4, WeakAggImplHelper4<Ifc1, Ifc2, Ifc3, Ifc4> > > {}; + public: + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return OWeakAggObject::queryInterface( rType ); } + virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return WeakAggImplHelper_queryAgg( rType, cd::get(), this, (OWeakAggObject *)this ); } + virtual void SAL_CALL acquire() throw () + { OWeakAggObject::acquire(); } + virtual void SAL_CALL release() throw () + { OWeakAggObject::release(); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return WeakAggImplHelper_getTypes( cd::get() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; + /** Implementation helper implementing interfaces ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::uno::XInterface inherting from a BaseClass. + All acquire() and release() calls are delegated to the BaseClass. Upon queryInterface(), + if a demanded interface is not supported by this class directly, the request is + delegated to the BaseClass. + + @attention + The BaseClass has to be complete in a sense, that ::com::sun::star::uno::XInterface + and ::com::sun::star::lang::XTypeProvider are implemented properly. The + BaseClass must have at least one ctor that can be called with six or + fewer arguments, of which none is of non-const reference type. + + @derive + Inherit from this class giving your additional interface(s) to be implemented as + template argument(s). Your sub class defines method implementations for these interface(s). + */ + template< class BaseClass, class Ifc1, class Ifc2, class Ifc3, class Ifc4 > + class SAL_NO_VTABLE ImplInheritanceHelper4 + : public BaseClass + , public Ifc1, public Ifc2, public Ifc3, public Ifc4 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData4 < Ifc1, Ifc2, Ifc3, Ifc4, ImplInheritanceHelper4<BaseClass, Ifc1, Ifc2, Ifc3, Ifc4> > > {}; + protected: + template< typename T1 > + explicit ImplInheritanceHelper4(T1 const & arg1): BaseClass(arg1) {} + template< typename T1, typename T2 > + ImplInheritanceHelper4(T1 const & arg1, T2 const & arg2): + BaseClass(arg1, arg2) {} + template< typename T1, typename T2, typename T3 > + ImplInheritanceHelper4( + T1 const & arg1, T2 const & arg2, T3 const & arg3): + BaseClass(arg1, arg2, arg3) {} + template< typename T1, typename T2, typename T3, typename T4 > + ImplInheritanceHelper4( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4): + BaseClass(arg1, arg2, arg3, arg4) {} + template< + typename T1, typename T2, typename T3, typename T4, typename T5 > + ImplInheritanceHelper4( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4, + T5 const & arg5): + BaseClass(arg1, arg2, arg3, arg4, arg5) {} + template< + typename T1, typename T2, typename T3, typename T4, typename T5, + typename T6 > + ImplInheritanceHelper4( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4, + T5 const & arg5, T6 const & arg6): + BaseClass(arg1, arg2, arg3, arg4, arg5, arg6) {} + public: + ImplInheritanceHelper4() {} + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { + ::com::sun::star::uno::Any aRet( ImplHelper_queryNoXInterface( rType, cd::get(), this ) ); + if (aRet.hasValue()) + return aRet; + return BaseClass::queryInterface( rType ); + } + virtual void SAL_CALL acquire() throw () + { BaseClass::acquire(); } + virtual void SAL_CALL release() throw () + { BaseClass::release(); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; + /** Implementation helper implementing interfaces ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::uno::XInterface inherting from a BaseClass. + All acquire(), release() and queryInterface() calls are delegated to the BaseClass. + Upon queryAggregation(), if a demanded interface is not supported by this class directly, + the request is delegated to the BaseClass. + + @attention + The BaseClass has to be complete in a sense, that ::com::sun::star::uno::XInterface, + ::com::sun::star::uno::XAggregation and ::com::sun::star::lang::XTypeProvider + are implemented properly. The BaseClass must have at least one ctor + that can be called with six or fewer arguments, of which none is of + non-const reference type. + + @derive + Inherit from this class giving your additional interface(s) to be implemented as + template argument(s). Your sub class defines method implementations for these interface(s). + */ + template< class BaseClass, class Ifc1, class Ifc2, class Ifc3, class Ifc4 > + class SAL_NO_VTABLE AggImplInheritanceHelper4 + : public BaseClass + , public Ifc1, public Ifc2, public Ifc3, public Ifc4 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData4 < Ifc1, Ifc2, Ifc3, Ifc4, AggImplInheritanceHelper4<BaseClass, Ifc1, Ifc2, Ifc3, Ifc4> > > {}; + protected: + template< typename T1 > + explicit AggImplInheritanceHelper4(T1 const & arg1): BaseClass(arg1) {} + template< typename T1, typename T2 > + AggImplInheritanceHelper4(T1 const & arg1, T2 const & arg2): + BaseClass(arg1, arg2) {} + template< typename T1, typename T2, typename T3 > + AggImplInheritanceHelper4( + T1 const & arg1, T2 const & arg2, T3 const & arg3): + BaseClass(arg1, arg2, arg3) {} + template< typename T1, typename T2, typename T3, typename T4 > + AggImplInheritanceHelper4( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4): + BaseClass(arg1, arg2, arg3, arg4) {} + template< + typename T1, typename T2, typename T3, typename T4, typename T5 > + AggImplInheritanceHelper4( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4, + T5 const & arg5): + BaseClass(arg1, arg2, arg3, arg4, arg5) {} + template< + typename T1, typename T2, typename T3, typename T4, typename T5, + typename T6 > + AggImplInheritanceHelper4( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4, + T5 const & arg5, T6 const & arg6): + BaseClass(arg1, arg2, arg3, arg4, arg5, arg6) {} + public: + AggImplInheritanceHelper4() {} + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return BaseClass::queryInterface( rType ); } + virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { + ::com::sun::star::uno::Any aRet( ImplHelper_queryNoXInterface( rType, cd::get(), this ) ); + if (aRet.hasValue()) + return aRet; + return BaseClass::queryAggregation( rType ); + } + virtual void SAL_CALL acquire() throw () + { BaseClass::acquire(); } + virtual void SAL_CALL release() throw () + { BaseClass::release(); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/inc/cppuhelper/implbase5.hxx b/cppuhelper/inc/cppuhelper/implbase5.hxx new file mode 100644 index 000000000000..c2eff30c0df1 --- /dev/null +++ b/cppuhelper/inc/cppuhelper/implbase5.hxx @@ -0,0 +1,298 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CPPUHELPER_IMPLBASE5_HXX_ +#define _CPPUHELPER_IMPLBASE5_HXX_ + +#include <cppuhelper/implbase_ex.hxx> +#include <rtl/instance.hxx> + +namespace cppu +{ + /** @internal */ + struct class_data5 + { + sal_Int16 m_nTypes; + sal_Bool m_storedTypeRefs; + sal_Bool m_storedId; + sal_Int8 m_id[ 16 ]; + type_entry m_typeEntries[ 5 + 1 ]; + }; + + /** @internal */ + template< typename Ifc1, typename Ifc2, typename Ifc3, typename Ifc4, typename Ifc5, typename Impl > + struct ImplClassData5 + { + class_data* operator ()() + { + static class_data5 s_cd = + { + 5 +1, sal_False, sal_False, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { + { { Ifc1::static_type }, ((sal_IntPtr)(Ifc1 *) (Impl *) 16) - 16 }, + { { Ifc2::static_type }, ((sal_IntPtr)(Ifc2 *) (Impl *) 16) - 16 }, + { { Ifc3::static_type }, ((sal_IntPtr)(Ifc3 *) (Impl *) 16) - 16 }, + { { Ifc4::static_type }, ((sal_IntPtr)(Ifc4 *) (Impl *) 16) - 16 }, + { { Ifc5::static_type }, ((sal_IntPtr)(Ifc5 *) (Impl *) 16) - 16 }, + { { ::com::sun::star::lang::XTypeProvider::static_type }, ((sal_IntPtr)(::com::sun::star::lang::XTypeProvider *) (Impl *) 16) - 16 } + } + }; + return reinterpret_cast< class_data * >(&s_cd); + } + }; + + /** Implementation helper implementing interface ::com::sun::star::lang::XTypeProvider + and method XInterface::queryInterface(), but no reference counting. + + @derive + Inherit from this class giving your interface(s) to be implemented as template argument(s). + Your sub class defines method implementations for these interface(s) including acquire()/ + release() and delegates incoming queryInterface() calls to this base class. + */ + template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5 > + class SAL_NO_VTABLE ImplHelper5 + : public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData5 < Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, ImplHelper5<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5> > > {}; + public: + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_query( rType, cd::get(), this ); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getTypes( cd::get() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; + /** Implementation helper implementing interfaces ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::uno::XInterface which supports weak mechanism to be held weakly + (supporting ::com::sun::star::uno::XWeak thru ::cppu::OWeakObject). + + @derive + Inherit from this class giving your interface(s) to be implemented as template argument(s). + Your sub class defines method implementations for these interface(s). + */ + template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5 > + class SAL_NO_VTABLE WeakImplHelper5 + : public OWeakObject + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData5 < Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, WeakImplHelper5<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5> > > {}; + public: + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return WeakImplHelper_query( rType, cd::get(), this, (OWeakObject *)this ); } + virtual void SAL_CALL acquire() throw () + { OWeakObject::acquire(); } + virtual void SAL_CALL release() throw () + { OWeakObject::release(); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return WeakImplHelper_getTypes( cd::get() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; + /** Implementation helper implementing interfaces ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::uno::XInterface which supports weak mechanism to be held weakly + (supporting ::com::sun::star::uno::XWeak thru ::cppu::OWeakAggObject). + In addition, it supports also aggregation meaning object of this class can be aggregated + (::com::sun::star::uno::XAggregation thru ::cppu::OWeakAggObject). + If a delegator is set (this object is aggregated), then incoming queryInterface() + calls are delegated to the delegator object. If the delegator does not support the + demanded interface, it calls queryAggregation() on its aggregated objects. + + @derive + Inherit from this class giving your interface(s) to be implemented as template argument(s). + Your sub class defines method implementations for these interface(s). + */ + template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5 > + class SAL_NO_VTABLE WeakAggImplHelper5 + : public OWeakAggObject + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData5 < Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, WeakAggImplHelper5<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5> > > {}; + public: + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return OWeakAggObject::queryInterface( rType ); } + virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return WeakAggImplHelper_queryAgg( rType, cd::get(), this, (OWeakAggObject *)this ); } + virtual void SAL_CALL acquire() throw () + { OWeakAggObject::acquire(); } + virtual void SAL_CALL release() throw () + { OWeakAggObject::release(); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return WeakAggImplHelper_getTypes( cd::get() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; + /** Implementation helper implementing interfaces ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::uno::XInterface inherting from a BaseClass. + All acquire() and release() calls are delegated to the BaseClass. Upon queryInterface(), + if a demanded interface is not supported by this class directly, the request is + delegated to the BaseClass. + + @attention + The BaseClass has to be complete in a sense, that ::com::sun::star::uno::XInterface + and ::com::sun::star::lang::XTypeProvider are implemented properly. The + BaseClass must have at least one ctor that can be called with six or + fewer arguments, of which none is of non-const reference type. + + @derive + Inherit from this class giving your additional interface(s) to be implemented as + template argument(s). Your sub class defines method implementations for these interface(s). + */ + template< class BaseClass, class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5 > + class SAL_NO_VTABLE ImplInheritanceHelper5 + : public BaseClass + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData5 < Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, ImplInheritanceHelper5<BaseClass, Ifc1, Ifc2, Ifc3, Ifc4, Ifc5> > > {}; + protected: + template< typename T1 > + explicit ImplInheritanceHelper5(T1 const & arg1): BaseClass(arg1) {} + template< typename T1, typename T2 > + ImplInheritanceHelper5(T1 const & arg1, T2 const & arg2): + BaseClass(arg1, arg2) {} + template< typename T1, typename T2, typename T3 > + ImplInheritanceHelper5( + T1 const & arg1, T2 const & arg2, T3 const & arg3): + BaseClass(arg1, arg2, arg3) {} + template< typename T1, typename T2, typename T3, typename T4 > + ImplInheritanceHelper5( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4): + BaseClass(arg1, arg2, arg3, arg4) {} + template< + typename T1, typename T2, typename T3, typename T4, typename T5 > + ImplInheritanceHelper5( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4, + T5 const & arg5): + BaseClass(arg1, arg2, arg3, arg4, arg5) {} + template< + typename T1, typename T2, typename T3, typename T4, typename T5, + typename T6 > + ImplInheritanceHelper5( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4, + T5 const & arg5, T6 const & arg6): + BaseClass(arg1, arg2, arg3, arg4, arg5, arg6) {} + public: + ImplInheritanceHelper5() {} + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { + ::com::sun::star::uno::Any aRet( ImplHelper_queryNoXInterface( rType, cd::get(), this ) ); + if (aRet.hasValue()) + return aRet; + return BaseClass::queryInterface( rType ); + } + virtual void SAL_CALL acquire() throw () + { BaseClass::acquire(); } + virtual void SAL_CALL release() throw () + { BaseClass::release(); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; + /** Implementation helper implementing interfaces ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::uno::XInterface inherting from a BaseClass. + All acquire(), release() and queryInterface() calls are delegated to the BaseClass. + Upon queryAggregation(), if a demanded interface is not supported by this class directly, + the request is delegated to the BaseClass. + + @attention + The BaseClass has to be complete in a sense, that ::com::sun::star::uno::XInterface, + ::com::sun::star::uno::XAggregation and ::com::sun::star::lang::XTypeProvider + are implemented properly. The BaseClass must have at least one ctor + that can be called with six or fewer arguments, of which none is of + non-const reference type. + + @derive + Inherit from this class giving your additional interface(s) to be implemented as + template argument(s). Your sub class defines method implementations for these interface(s). + */ + template< class BaseClass, class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5 > + class SAL_NO_VTABLE AggImplInheritanceHelper5 + : public BaseClass + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData5 < Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, AggImplInheritanceHelper5<BaseClass, Ifc1, Ifc2, Ifc3, Ifc4, Ifc5> > > {}; + protected: + template< typename T1 > + explicit AggImplInheritanceHelper5(T1 const & arg1): BaseClass(arg1) {} + template< typename T1, typename T2 > + AggImplInheritanceHelper5(T1 const & arg1, T2 const & arg2): + BaseClass(arg1, arg2) {} + template< typename T1, typename T2, typename T3 > + AggImplInheritanceHelper5( + T1 const & arg1, T2 const & arg2, T3 const & arg3): + BaseClass(arg1, arg2, arg3) {} + template< typename T1, typename T2, typename T3, typename T4 > + AggImplInheritanceHelper5( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4): + BaseClass(arg1, arg2, arg3, arg4) {} + template< + typename T1, typename T2, typename T3, typename T4, typename T5 > + AggImplInheritanceHelper5( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4, + T5 const & arg5): + BaseClass(arg1, arg2, arg3, arg4, arg5) {} + template< + typename T1, typename T2, typename T3, typename T4, typename T5, + typename T6 > + AggImplInheritanceHelper5( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4, + T5 const & arg5, T6 const & arg6): + BaseClass(arg1, arg2, arg3, arg4, arg5, arg6) {} + public: + AggImplInheritanceHelper5() {} + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return BaseClass::queryInterface( rType ); } + virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { + ::com::sun::star::uno::Any aRet( ImplHelper_queryNoXInterface( rType, cd::get(), this ) ); + if (aRet.hasValue()) + return aRet; + return BaseClass::queryAggregation( rType ); + } + virtual void SAL_CALL acquire() throw () + { BaseClass::acquire(); } + virtual void SAL_CALL release() throw () + { BaseClass::release(); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/inc/cppuhelper/implbase6.hxx b/cppuhelper/inc/cppuhelper/implbase6.hxx new file mode 100644 index 000000000000..ca11813140aa --- /dev/null +++ b/cppuhelper/inc/cppuhelper/implbase6.hxx @@ -0,0 +1,299 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CPPUHELPER_IMPLBASE6_HXX_ +#define _CPPUHELPER_IMPLBASE6_HXX_ + +#include <cppuhelper/implbase_ex.hxx> +#include <rtl/instance.hxx> + +namespace cppu +{ + /** @internal */ + struct class_data6 + { + sal_Int16 m_nTypes; + sal_Bool m_storedTypeRefs; + sal_Bool m_storedId; + sal_Int8 m_id[ 16 ]; + type_entry m_typeEntries[ 6 + 1 ]; + }; + + /** @internal */ + template< typename Ifc1, typename Ifc2, typename Ifc3, typename Ifc4, typename Ifc5, typename Ifc6, typename Impl > + struct ImplClassData6 + { + class_data* operator ()() + { + static class_data6 s_cd = + { + 6 +1, sal_False, sal_False, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { + { { Ifc1::static_type }, ((sal_IntPtr)(Ifc1 *) (Impl *) 16) - 16 }, + { { Ifc2::static_type }, ((sal_IntPtr)(Ifc2 *) (Impl *) 16) - 16 }, + { { Ifc3::static_type }, ((sal_IntPtr)(Ifc3 *) (Impl *) 16) - 16 }, + { { Ifc4::static_type }, ((sal_IntPtr)(Ifc4 *) (Impl *) 16) - 16 }, + { { Ifc5::static_type }, ((sal_IntPtr)(Ifc5 *) (Impl *) 16) - 16 }, + { { Ifc6::static_type }, ((sal_IntPtr)(Ifc6 *) (Impl *) 16) - 16 }, + { { ::com::sun::star::lang::XTypeProvider::static_type }, ((sal_IntPtr)(::com::sun::star::lang::XTypeProvider *) (Impl *) 16) - 16 } + } + }; + return reinterpret_cast< class_data * >(&s_cd); + } + }; + + /** Implementation helper implementing interface ::com::sun::star::lang::XTypeProvider + and method XInterface::queryInterface(), but no reference counting. + + @derive + Inherit from this class giving your interface(s) to be implemented as template argument(s). + Your sub class defines method implementations for these interface(s) including acquire()/ + release() and delegates incoming queryInterface() calls to this base class. + */ + template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6 > + class SAL_NO_VTABLE ImplHelper6 + : public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData6 < Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, ImplHelper6<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6> > > {}; + public: + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_query( rType, cd::get(), this ); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getTypes( cd::get() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; + /** Implementation helper implementing interfaces ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::uno::XInterface which supports weak mechanism to be held weakly + (supporting ::com::sun::star::uno::XWeak thru ::cppu::OWeakObject). + + @derive + Inherit from this class giving your interface(s) to be implemented as template argument(s). + Your sub class defines method implementations for these interface(s). + */ + template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6 > + class SAL_NO_VTABLE WeakImplHelper6 + : public OWeakObject + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData6 < Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, WeakImplHelper6<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6> > > {}; + public: + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return WeakImplHelper_query( rType, cd::get(), this, (OWeakObject *)this ); } + virtual void SAL_CALL acquire() throw () + { OWeakObject::acquire(); } + virtual void SAL_CALL release() throw () + { OWeakObject::release(); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return WeakImplHelper_getTypes( cd::get() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; + /** Implementation helper implementing interfaces ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::uno::XInterface which supports weak mechanism to be held weakly + (supporting ::com::sun::star::uno::XWeak thru ::cppu::OWeakAggObject). + In addition, it supports also aggregation meaning object of this class can be aggregated + (::com::sun::star::uno::XAggregation thru ::cppu::OWeakAggObject). + If a delegator is set (this object is aggregated), then incoming queryInterface() + calls are delegated to the delegator object. If the delegator does not support the + demanded interface, it calls queryAggregation() on its aggregated objects. + + @derive + Inherit from this class giving your interface(s) to be implemented as template argument(s). + Your sub class defines method implementations for these interface(s). + */ + template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6 > + class SAL_NO_VTABLE WeakAggImplHelper6 + : public OWeakAggObject + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData6 < Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, WeakAggImplHelper6<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6> > > {}; + public: + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return OWeakAggObject::queryInterface( rType ); } + virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return WeakAggImplHelper_queryAgg( rType, cd::get(), this, (OWeakAggObject *)this ); } + virtual void SAL_CALL acquire() throw () + { OWeakAggObject::acquire(); } + virtual void SAL_CALL release() throw () + { OWeakAggObject::release(); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return WeakAggImplHelper_getTypes( cd::get() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; + /** Implementation helper implementing interfaces ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::uno::XInterface inherting from a BaseClass. + All acquire() and release() calls are delegated to the BaseClass. Upon queryInterface(), + if a demanded interface is not supported by this class directly, the request is + delegated to the BaseClass. + + @attention + The BaseClass has to be complete in a sense, that ::com::sun::star::uno::XInterface + and ::com::sun::star::lang::XTypeProvider are implemented properly. The + BaseClass must have at least one ctor that can be called with six or + fewer arguments, of which none is of non-const reference type. + + @derive + Inherit from this class giving your additional interface(s) to be implemented as + template argument(s). Your sub class defines method implementations for these interface(s). + */ + template< class BaseClass, class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6 > + class SAL_NO_VTABLE ImplInheritanceHelper6 + : public BaseClass + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData6 < Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, ImplInheritanceHelper6<BaseClass, Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6> > > {}; + protected: + template< typename T1 > + explicit ImplInheritanceHelper6(T1 const & arg1): BaseClass(arg1) {} + template< typename T1, typename T2 > + ImplInheritanceHelper6(T1 const & arg1, T2 const & arg2): + BaseClass(arg1, arg2) {} + template< typename T1, typename T2, typename T3 > + ImplInheritanceHelper6( + T1 const & arg1, T2 const & arg2, T3 const & arg3): + BaseClass(arg1, arg2, arg3) {} + template< typename T1, typename T2, typename T3, typename T4 > + ImplInheritanceHelper6( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4): + BaseClass(arg1, arg2, arg3, arg4) {} + template< + typename T1, typename T2, typename T3, typename T4, typename T5 > + ImplInheritanceHelper6( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4, + T5 const & arg5): + BaseClass(arg1, arg2, arg3, arg4, arg5) {} + template< + typename T1, typename T2, typename T3, typename T4, typename T5, + typename T6 > + ImplInheritanceHelper6( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4, + T5 const & arg5, T6 const & arg6): + BaseClass(arg1, arg2, arg3, arg4, arg5, arg6) {} + public: + ImplInheritanceHelper6() {} + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { + ::com::sun::star::uno::Any aRet( ImplHelper_queryNoXInterface( rType, cd::get(), this ) ); + if (aRet.hasValue()) + return aRet; + return BaseClass::queryInterface( rType ); + } + virtual void SAL_CALL acquire() throw () + { BaseClass::acquire(); } + virtual void SAL_CALL release() throw () + { BaseClass::release(); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; + /** Implementation helper implementing interfaces ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::uno::XInterface inherting from a BaseClass. + All acquire(), release() and queryInterface() calls are delegated to the BaseClass. + Upon queryAggregation(), if a demanded interface is not supported by this class directly, + the request is delegated to the BaseClass. + + @attention + The BaseClass has to be complete in a sense, that ::com::sun::star::uno::XInterface, + ::com::sun::star::uno::XAggregation and ::com::sun::star::lang::XTypeProvider + are implemented properly. The BaseClass must have at least one ctor + that can be called with six or fewer arguments, of which none is of + non-const reference type. + + @derive + Inherit from this class giving your additional interface(s) to be implemented as + template argument(s). Your sub class defines method implementations for these interface(s). + */ + template< class BaseClass, class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6 > + class SAL_NO_VTABLE AggImplInheritanceHelper6 + : public BaseClass + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData6 < Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, AggImplInheritanceHelper6<BaseClass, Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6> > > {}; + protected: + template< typename T1 > + explicit AggImplInheritanceHelper6(T1 const & arg1): BaseClass(arg1) {} + template< typename T1, typename T2 > + AggImplInheritanceHelper6(T1 const & arg1, T2 const & arg2): + BaseClass(arg1, arg2) {} + template< typename T1, typename T2, typename T3 > + AggImplInheritanceHelper6( + T1 const & arg1, T2 const & arg2, T3 const & arg3): + BaseClass(arg1, arg2, arg3) {} + template< typename T1, typename T2, typename T3, typename T4 > + AggImplInheritanceHelper6( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4): + BaseClass(arg1, arg2, arg3, arg4) {} + template< + typename T1, typename T2, typename T3, typename T4, typename T5 > + AggImplInheritanceHelper6( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4, + T5 const & arg5): + BaseClass(arg1, arg2, arg3, arg4, arg5) {} + template< + typename T1, typename T2, typename T3, typename T4, typename T5, + typename T6 > + AggImplInheritanceHelper6( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4, + T5 const & arg5, T6 const & arg6): + BaseClass(arg1, arg2, arg3, arg4, arg5, arg6) {} + public: + AggImplInheritanceHelper6() {} + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return BaseClass::queryInterface( rType ); } + virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { + ::com::sun::star::uno::Any aRet( ImplHelper_queryNoXInterface( rType, cd::get(), this ) ); + if (aRet.hasValue()) + return aRet; + return BaseClass::queryAggregation( rType ); + } + virtual void SAL_CALL acquire() throw () + { BaseClass::acquire(); } + virtual void SAL_CALL release() throw () + { BaseClass::release(); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/inc/cppuhelper/implbase7.hxx b/cppuhelper/inc/cppuhelper/implbase7.hxx new file mode 100644 index 000000000000..620e0e0a583c --- /dev/null +++ b/cppuhelper/inc/cppuhelper/implbase7.hxx @@ -0,0 +1,301 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CPPUHELPER_IMPLBASE7_HXX_ +#define _CPPUHELPER_IMPLBASE7_HXX_ + +#include <cppuhelper/implbase_ex.hxx> +#include <rtl/instance.hxx> + +namespace cppu +{ + /** @internal */ + struct class_data7 + { + sal_Int16 m_nTypes; + sal_Bool m_storedTypeRefs; + sal_Bool m_storedId; + sal_Int8 m_id[ 16 ]; + type_entry m_typeEntries[ 7 + 1 ]; + }; + + /** @internal */ + template< typename Ifc1, typename Ifc2, typename Ifc3, typename Ifc4, typename Ifc5, typename Ifc6, typename Ifc7, typename Impl > + struct ImplClassData7 + { + class_data* operator ()() + { + static class_data7 s_cd = + { + 7 +1, sal_False, sal_False, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { + { { Ifc1::static_type }, ((sal_IntPtr)(Ifc1 *) (Impl *) 16) - 16 }, + { { Ifc2::static_type }, ((sal_IntPtr)(Ifc2 *) (Impl *) 16) - 16 }, + { { Ifc3::static_type }, ((sal_IntPtr)(Ifc3 *) (Impl *) 16) - 16 }, + { { Ifc4::static_type }, ((sal_IntPtr)(Ifc4 *) (Impl *) 16) - 16 }, + { { Ifc5::static_type }, ((sal_IntPtr)(Ifc5 *) (Impl *) 16) - 16 }, + { { Ifc6::static_type }, ((sal_IntPtr)(Ifc6 *) (Impl *) 16) - 16 }, + { { Ifc7::static_type }, ((sal_IntPtr)(Ifc7 *) (Impl *) 16) - 16 }, + { { ::com::sun::star::lang::XTypeProvider::static_type }, ((sal_IntPtr)(::com::sun::star::lang::XTypeProvider *) (Impl *) 16) - 16 } + } + }; + return reinterpret_cast< class_data * >(&s_cd); + } + }; + + + /** Implementation helper implementing interface ::com::sun::star::lang::XTypeProvider + and method XInterface::queryInterface(), but no reference counting. + + @derive + Inherit from this class giving your interface(s) to be implemented as template argument(s). + Your sub class defines method implementations for these interface(s) including acquire()/ + release() and delegates incoming queryInterface() calls to this base class. + */ + template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7 > + class SAL_NO_VTABLE ImplHelper7 + : public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData7< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, ImplHelper7<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7> > > {}; + public: + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_query( rType, cd::get(), this ); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getTypes( cd::get() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; + /** Implementation helper implementing interfaces ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::uno::XInterface which supports weak mechanism to be held weakly + (supporting ::com::sun::star::uno::XWeak thru ::cppu::OWeakObject). + + @derive + Inherit from this class giving your interface(s) to be implemented as template argument(s). + Your sub class defines method implementations for these interface(s). + */ + template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7 > + class SAL_NO_VTABLE WeakImplHelper7 + : public OWeakObject + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData7< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, WeakImplHelper7<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7> > > {}; + public: + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return WeakImplHelper_query( rType, cd::get(), this, (OWeakObject *)this ); } + virtual void SAL_CALL acquire() throw () + { OWeakObject::acquire(); } + virtual void SAL_CALL release() throw () + { OWeakObject::release(); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return WeakImplHelper_getTypes( cd::get() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; + /** Implementation helper implementing interfaces ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::uno::XInterface which supports weak mechanism to be held weakly + (supporting ::com::sun::star::uno::XWeak thru ::cppu::OWeakAggObject). + In addition, it supports also aggregation meaning object of this class can be aggregated + (::com::sun::star::uno::XAggregation thru ::cppu::OWeakAggObject). + If a delegator is set (this object is aggregated), then incoming queryInterface() + calls are delegated to the delegator object. If the delegator does not support the + demanded interface, it calls queryAggregation() on its aggregated objects. + + @derive + Inherit from this class giving your interface(s) to be implemented as template argument(s). + Your sub class defines method implementations for these interface(s). + */ + template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7 > + class SAL_NO_VTABLE WeakAggImplHelper7 + : public OWeakAggObject + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData7< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, WeakAggImplHelper7<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7> > > {}; + public: + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return OWeakAggObject::queryInterface( rType ); } + virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return WeakAggImplHelper_queryAgg( rType, cd::get(), this, (OWeakAggObject *)this ); } + virtual void SAL_CALL acquire() throw () + { OWeakAggObject::acquire(); } + virtual void SAL_CALL release() throw () + { OWeakAggObject::release(); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return WeakAggImplHelper_getTypes( cd::get() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; + /** Implementation helper implementing interfaces ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::uno::XInterface inherting from a BaseClass. + All acquire() and release() calls are delegated to the BaseClass. Upon queryInterface(), + if a demanded interface is not supported by this class directly, the request is + delegated to the BaseClass. + + @attention + The BaseClass has to be complete in a sense, that ::com::sun::star::uno::XInterface + and ::com::sun::star::lang::XTypeProvider are implemented properly. The + BaseClass must have at least one ctor that can be called with six or + fewer arguments, of which none is of non-const reference type. + + @derive + Inherit from this class giving your additional interface(s) to be implemented as + template argument(s). Your sub class defines method implementations for these interface(s). + */ + template< class BaseClass, class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7 > + class SAL_NO_VTABLE ImplInheritanceHelper7 + : public BaseClass + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData7< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, ImplInheritanceHelper7<BaseClass, Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7> > > {}; + protected: + template< typename T1 > + explicit ImplInheritanceHelper7(T1 const & arg1): BaseClass(arg1) {} + template< typename T1, typename T2 > + ImplInheritanceHelper7(T1 const & arg1, T2 const & arg2): + BaseClass(arg1, arg2) {} + template< typename T1, typename T2, typename T3 > + ImplInheritanceHelper7( + T1 const & arg1, T2 const & arg2, T3 const & arg3): + BaseClass(arg1, arg2, arg3) {} + template< typename T1, typename T2, typename T3, typename T4 > + ImplInheritanceHelper7( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4): + BaseClass(arg1, arg2, arg3, arg4) {} + template< + typename T1, typename T2, typename T3, typename T4, typename T5 > + ImplInheritanceHelper7( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4, + T5 const & arg5): + BaseClass(arg1, arg2, arg3, arg4, arg5) {} + template< + typename T1, typename T2, typename T3, typename T4, typename T5, + typename T6 > + ImplInheritanceHelper7( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4, + T5 const & arg5, T6 const & arg6): + BaseClass(arg1, arg2, arg3, arg4, arg5, arg6) {} + public: + ImplInheritanceHelper7() {} + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { + ::com::sun::star::uno::Any aRet( ImplHelper_queryNoXInterface( rType, cd::get(), this ) ); + if (aRet.hasValue()) + return aRet; + return BaseClass::queryInterface( rType ); + } + virtual void SAL_CALL acquire() throw () + { BaseClass::acquire(); } + virtual void SAL_CALL release() throw () + { BaseClass::release(); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; + /** Implementation helper implementing interfaces ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::uno::XInterface inherting from a BaseClass. + All acquire(), release() and queryInterface() calls are delegated to the BaseClass. + Upon queryAggregation(), if a demanded interface is not supported by this class directly, + the request is delegated to the BaseClass. + + @attention + The BaseClass has to be complete in a sense, that ::com::sun::star::uno::XInterface, + ::com::sun::star::uno::XAggregation and ::com::sun::star::lang::XTypeProvider + are implemented properly. The BaseClass must have at least one ctor + that can be called with six or fewer arguments, of which none is of + non-const reference type. + + @derive + Inherit from this class giving your additional interface(s) to be implemented as + template argument(s). Your sub class defines method implementations for these interface(s). + */ + template< class BaseClass, class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7 > + class SAL_NO_VTABLE AggImplInheritanceHelper7 + : public BaseClass + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData7< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, AggImplInheritanceHelper7<BaseClass, Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7> > > {}; + protected: + template< typename T1 > + explicit AggImplInheritanceHelper7(T1 const & arg1): BaseClass(arg1) {} + template< typename T1, typename T2 > + AggImplInheritanceHelper7(T1 const & arg1, T2 const & arg2): + BaseClass(arg1, arg2) {} + template< typename T1, typename T2, typename T3 > + AggImplInheritanceHelper7( + T1 const & arg1, T2 const & arg2, T3 const & arg3): + BaseClass(arg1, arg2, arg3) {} + template< typename T1, typename T2, typename T3, typename T4 > + AggImplInheritanceHelper7( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4): + BaseClass(arg1, arg2, arg3, arg4) {} + template< + typename T1, typename T2, typename T3, typename T4, typename T5 > + AggImplInheritanceHelper7( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4, + T5 const & arg5): + BaseClass(arg1, arg2, arg3, arg4, arg5) {} + template< + typename T1, typename T2, typename T3, typename T4, typename T5, + typename T6 > + AggImplInheritanceHelper7( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4, + T5 const & arg5, T6 const & arg6): + BaseClass(arg1, arg2, arg3, arg4, arg5, arg6) {} + public: + AggImplInheritanceHelper7() {} + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return BaseClass::queryInterface( rType ); } + virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { + ::com::sun::star::uno::Any aRet( ImplHelper_queryNoXInterface( rType, cd::get(), this ) ); + if (aRet.hasValue()) + return aRet; + return BaseClass::queryAggregation( rType ); + } + virtual void SAL_CALL acquire() throw () + { BaseClass::acquire(); } + virtual void SAL_CALL release() throw () + { BaseClass::release(); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/inc/cppuhelper/implbase8.hxx b/cppuhelper/inc/cppuhelper/implbase8.hxx new file mode 100644 index 000000000000..31bda399bc61 --- /dev/null +++ b/cppuhelper/inc/cppuhelper/implbase8.hxx @@ -0,0 +1,301 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CPPUHELPER_IMPLBASE8_HXX_ +#define _CPPUHELPER_IMPLBASE8_HXX_ + +#include <cppuhelper/implbase_ex.hxx> +#include <rtl/instance.hxx> + +namespace cppu +{ + /** @internal */ + struct class_data8 + { + sal_Int16 m_nTypes; + sal_Bool m_storedTypeRefs; + sal_Bool m_storedId; + sal_Int8 m_id[ 16 ]; + type_entry m_typeEntries[ 8 + 1 ]; + }; + + /** @internal */ + template< typename Ifc1, typename Ifc2, typename Ifc3, typename Ifc4, typename Ifc5, typename Ifc6, typename Ifc7, typename Ifc8, typename Impl > + struct ImplClassData8 + { + class_data* operator ()() + { + static class_data8 s_cd = + { + 8 +1, sal_False, sal_False, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { + { { Ifc1::static_type }, ((sal_IntPtr)(Ifc1 *) (Impl *) 16) - 16 }, + { { Ifc2::static_type }, ((sal_IntPtr)(Ifc2 *) (Impl *) 16) - 16 }, + { { Ifc3::static_type }, ((sal_IntPtr)(Ifc3 *) (Impl *) 16) - 16 }, + { { Ifc4::static_type }, ((sal_IntPtr)(Ifc4 *) (Impl *) 16) - 16 }, + { { Ifc5::static_type }, ((sal_IntPtr)(Ifc5 *) (Impl *) 16) - 16 }, + { { Ifc6::static_type }, ((sal_IntPtr)(Ifc6 *) (Impl *) 16) - 16 }, + { { Ifc7::static_type }, ((sal_IntPtr)(Ifc7 *) (Impl *) 16) - 16 }, + { { Ifc8::static_type }, ((sal_IntPtr)(Ifc8 *) (Impl *) 16) - 16 }, + { { ::com::sun::star::lang::XTypeProvider::static_type }, ((sal_IntPtr)(::com::sun::star::lang::XTypeProvider *) (Impl *) 16) - 16 } + } + }; + return reinterpret_cast< class_data * >(&s_cd); + } + }; + + /** Implementation helper implementing interface ::com::sun::star::lang::XTypeProvider + and method XInterface::queryInterface(), but no reference counting. + + @derive + Inherit from this class giving your interface(s) to be implemented as template argument(s). + Your sub class defines method implementations for these interface(s) including acquire()/ + release() and delegates incoming queryInterface() calls to this base class. + */ + template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8 > + class SAL_NO_VTABLE ImplHelper8 + : public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData8< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, ImplHelper8<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8> > > {}; + public: + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_query( rType, cd::get(), this ); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getTypes( cd::get() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; + /** Implementation helper implementing interfaces ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::uno::XInterface which supports weak mechanism to be held weakly + (supporting ::com::sun::star::uno::XWeak thru ::cppu::OWeakObject). + + @derive + Inherit from this class giving your interface(s) to be implemented as template argument(s). + Your sub class defines method implementations for these interface(s). + */ + template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8 > + class SAL_NO_VTABLE WeakImplHelper8 + : public OWeakObject + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData8< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, WeakImplHelper8<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8> > > {}; + public: + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return WeakImplHelper_query( rType, cd::get(), this, (OWeakObject *)this ); } + virtual void SAL_CALL acquire() throw () + { OWeakObject::acquire(); } + virtual void SAL_CALL release() throw () + { OWeakObject::release(); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return WeakImplHelper_getTypes( cd::get() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; + /** Implementation helper implementing interfaces ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::uno::XInterface which supports weak mechanism to be held weakly + (supporting ::com::sun::star::uno::XWeak thru ::cppu::OWeakAggObject). + In addition, it supports also aggregation meaning object of this class can be aggregated + (::com::sun::star::uno::XAggregation thru ::cppu::OWeakAggObject). + If a delegator is set (this object is aggregated), then incoming queryInterface() + calls are delegated to the delegator object. If the delegator does not support the + demanded interface, it calls queryAggregation() on its aggregated objects. + + @derive + Inherit from this class giving your interface(s) to be implemented as template argument(s). + Your sub class defines method implementations for these interface(s). + */ + template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8 > + class SAL_NO_VTABLE WeakAggImplHelper8 + : public OWeakAggObject + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData8< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, WeakAggImplHelper8<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8> > > {}; + public: + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return OWeakAggObject::queryInterface( rType ); } + virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return WeakAggImplHelper_queryAgg( rType, cd::get(), this, (OWeakAggObject *)this ); } + virtual void SAL_CALL acquire() throw () + { OWeakAggObject::acquire(); } + virtual void SAL_CALL release() throw () + { OWeakAggObject::release(); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return WeakAggImplHelper_getTypes( cd::get() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; + /** Implementation helper implementing interfaces ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::uno::XInterface inherting from a BaseClass. + All acquire() and release() calls are delegated to the BaseClass. Upon queryInterface(), + if a demanded interface is not supported by this class directly, the request is + delegated to the BaseClass. + + @attention + The BaseClass has to be complete in a sense, that ::com::sun::star::uno::XInterface + and ::com::sun::star::lang::XTypeProvider are implemented properly. The + BaseClass must have at least one ctor that can be called with six or + fewer arguments, of which none is of non-const reference type. + + @derive + Inherit from this class giving your additional interface(s) to be implemented as + template argument(s). Your sub class defines method implementations for these interface(s). + */ + template< class BaseClass, class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8 > + class SAL_NO_VTABLE ImplInheritanceHelper8 + : public BaseClass + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData8< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, ImplInheritanceHelper8<BaseClass, Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8> > > {}; + protected: + template< typename T1 > + explicit ImplInheritanceHelper8(T1 const & arg1): BaseClass(arg1) {} + template< typename T1, typename T2 > + ImplInheritanceHelper8(T1 const & arg1, T2 const & arg2): + BaseClass(arg1, arg2) {} + template< typename T1, typename T2, typename T3 > + ImplInheritanceHelper8( + T1 const & arg1, T2 const & arg2, T3 const & arg3): + BaseClass(arg1, arg2, arg3) {} + template< typename T1, typename T2, typename T3, typename T4 > + ImplInheritanceHelper8( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4): + BaseClass(arg1, arg2, arg3, arg4) {} + template< + typename T1, typename T2, typename T3, typename T4, typename T5 > + ImplInheritanceHelper8( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4, + T5 const & arg5): + BaseClass(arg1, arg2, arg3, arg4, arg5) {} + template< + typename T1, typename T2, typename T3, typename T4, typename T5, + typename T6 > + ImplInheritanceHelper8( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4, + T5 const & arg5, T6 const & arg6): + BaseClass(arg1, arg2, arg3, arg4, arg5, arg6) {} + public: + ImplInheritanceHelper8() {} + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { + ::com::sun::star::uno::Any aRet( ImplHelper_queryNoXInterface( rType, cd::get(), this ) ); + if (aRet.hasValue()) + return aRet; + return BaseClass::queryInterface( rType ); + } + virtual void SAL_CALL acquire() throw () + { BaseClass::acquire(); } + virtual void SAL_CALL release() throw () + { BaseClass::release(); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; + /** Implementation helper implementing interfaces ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::uno::XInterface inherting from a BaseClass. + All acquire(), release() and queryInterface() calls are delegated to the BaseClass. + Upon queryAggregation(), if a demanded interface is not supported by this class directly, + the request is delegated to the BaseClass. + + @attention + The BaseClass has to be complete in a sense, that ::com::sun::star::uno::XInterface, + ::com::sun::star::uno::XAggregation and ::com::sun::star::lang::XTypeProvider + are implemented properly. The BaseClass must have at least one ctor + that can be called with six or fewer arguments, of which none is of + non-const reference type. + + @derive + Inherit from this class giving your additional interface(s) to be implemented as + template argument(s). Your sub class defines method implementations for these interface(s). + */ + template< class BaseClass, class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8 > + class SAL_NO_VTABLE AggImplInheritanceHelper8 + : public BaseClass + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData8< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, AggImplInheritanceHelper8<BaseClass, Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8> > > {}; + protected: + template< typename T1 > + explicit AggImplInheritanceHelper8(T1 const & arg1): BaseClass(arg1) {} + template< typename T1, typename T2 > + AggImplInheritanceHelper8(T1 const & arg1, T2 const & arg2): + BaseClass(arg1, arg2) {} + template< typename T1, typename T2, typename T3 > + AggImplInheritanceHelper8( + T1 const & arg1, T2 const & arg2, T3 const & arg3): + BaseClass(arg1, arg2, arg3) {} + template< typename T1, typename T2, typename T3, typename T4 > + AggImplInheritanceHelper8( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4): + BaseClass(arg1, arg2, arg3, arg4) {} + template< + typename T1, typename T2, typename T3, typename T4, typename T5 > + AggImplInheritanceHelper8( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4, + T5 const & arg5): + BaseClass(arg1, arg2, arg3, arg4, arg5) {} + template< + typename T1, typename T2, typename T3, typename T4, typename T5, + typename T6 > + AggImplInheritanceHelper8( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4, + T5 const & arg5, T6 const & arg6): + BaseClass(arg1, arg2, arg3, arg4, arg5, arg6) {} + public: + AggImplInheritanceHelper8() {} + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return BaseClass::queryInterface( rType ); } + virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { + ::com::sun::star::uno::Any aRet( ImplHelper_queryNoXInterface( rType, cd::get(), this ) ); + if (aRet.hasValue()) + return aRet; + return BaseClass::queryAggregation( rType ); + } + virtual void SAL_CALL acquire() throw () + { BaseClass::acquire(); } + virtual void SAL_CALL release() throw () + { BaseClass::release(); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/inc/cppuhelper/implbase9.hxx b/cppuhelper/inc/cppuhelper/implbase9.hxx new file mode 100644 index 000000000000..911caac08ae6 --- /dev/null +++ b/cppuhelper/inc/cppuhelper/implbase9.hxx @@ -0,0 +1,303 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CPPUHELPER_IMPLBASE9_HXX_ +#define _CPPUHELPER_IMPLBASE9_HXX_ + +#include <cppuhelper/implbase_ex.hxx> +#include <rtl/instance.hxx> + +namespace cppu +{ + /** @internal */ + struct class_data9 + { + sal_Int16 m_nTypes; + sal_Bool m_storedTypeRefs; + sal_Bool m_storedId; + sal_Int8 m_id[ 16 ]; + type_entry m_typeEntries[ 9 + 1 ]; + }; + + /** @internal */ + template< typename Ifc1, typename Ifc2, typename Ifc3, typename Ifc4, typename Ifc5, typename Ifc6, typename Ifc7, typename Ifc8, typename Ifc9, typename Impl > + struct ImplClassData9 + { + class_data* operator ()() + { + static class_data9 s_cd = + { + 9 +1, sal_False, sal_False, + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { + { { Ifc1::static_type }, ((sal_IntPtr)(Ifc1 *) (Impl *) 16) - 16 }, + { { Ifc2::static_type }, ((sal_IntPtr)(Ifc2 *) (Impl *) 16) - 16 }, + { { Ifc3::static_type }, ((sal_IntPtr)(Ifc3 *) (Impl *) 16) - 16 }, + { { Ifc4::static_type }, ((sal_IntPtr)(Ifc4 *) (Impl *) 16) - 16 }, + { { Ifc5::static_type }, ((sal_IntPtr)(Ifc5 *) (Impl *) 16) - 16 }, + { { Ifc6::static_type }, ((sal_IntPtr)(Ifc6 *) (Impl *) 16) - 16 }, + { { Ifc7::static_type }, ((sal_IntPtr)(Ifc7 *) (Impl *) 16) - 16 }, + { { Ifc8::static_type }, ((sal_IntPtr)(Ifc8 *) (Impl *) 16) - 16 }, + { { Ifc9::static_type }, ((sal_IntPtr)(Ifc9 *) (Impl *) 16) - 16 }, + { { ::com::sun::star::lang::XTypeProvider::static_type }, ((sal_IntPtr)(::com::sun::star::lang::XTypeProvider *) (Impl *) 16) - 16 } + } + }; + return reinterpret_cast< class_data * >(&s_cd); + } + }; + + + /** Implementation helper implementing interface ::com::sun::star::lang::XTypeProvider + and method XInterface::queryInterface(), but no reference counting. + + @derive + Inherit from this class giving your interface(s) to be implemented as template argument(s). + Your sub class defines method implementations for these interface(s) including acquire()/ + release() and delegates incoming queryInterface() calls to this base class. + */ + template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9 > + class SAL_NO_VTABLE ImplHelper9 + : public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData9< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, ImplHelper9<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9> > > {}; + public: + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_query( rType, cd::get(), this ); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getTypes( cd::get() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; + /** Implementation helper implementing interfaces ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::uno::XInterface which supports weak mechanism to be held weakly + (supporting ::com::sun::star::uno::XWeak thru ::cppu::OWeakObject). + + @derive + Inherit from this class giving your interface(s) to be implemented as template argument(s). + Your sub class defines method implementations for these interface(s). + */ + template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9 > + class SAL_NO_VTABLE WeakImplHelper9 + : public OWeakObject + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData9< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, WeakImplHelper9<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9> > > {}; + public: + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return WeakImplHelper_query( rType, cd::get(), this, (OWeakObject *)this ); } + virtual void SAL_CALL acquire() throw () + { OWeakObject::acquire(); } + virtual void SAL_CALL release() throw () + { OWeakObject::release(); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return WeakImplHelper_getTypes( cd::get() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; + /** Implementation helper implementing interfaces ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::uno::XInterface which supports weak mechanism to be held weakly + (supporting ::com::sun::star::uno::XWeak thru ::cppu::OWeakAggObject). + In addition, it supports also aggregation meaning object of this class can be aggregated + (::com::sun::star::uno::XAggregation thru ::cppu::OWeakAggObject). + If a delegator is set (this object is aggregated), then incoming queryInterface() + calls are delegated to the delegator object. If the delegator does not support the + demanded interface, it calls queryAggregation() on its aggregated objects. + + @derive + Inherit from this class giving your interface(s) to be implemented as template argument(s). + Your sub class defines method implementations for these interface(s). + */ + template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9 > + class SAL_NO_VTABLE WeakAggImplHelper9 + : public OWeakAggObject + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData9< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, WeakAggImplHelper9<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9> > > {}; + public: + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return OWeakAggObject::queryInterface( rType ); } + virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return WeakAggImplHelper_queryAgg( rType, cd::get(), this, (OWeakAggObject *)this ); } + virtual void SAL_CALL acquire() throw () + { OWeakAggObject::acquire(); } + virtual void SAL_CALL release() throw () + { OWeakAggObject::release(); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return WeakAggImplHelper_getTypes( cd::get() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; + /** Implementation helper implementing interfaces ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::uno::XInterface inherting from a BaseClass. + All acquire() and release() calls are delegated to the BaseClass. Upon queryInterface(), + if a demanded interface is not supported by this class directly, the request is + delegated to the BaseClass. + + @attention + The BaseClass has to be complete in a sense, that ::com::sun::star::uno::XInterface + and ::com::sun::star::lang::XTypeProvider are implemented properly. The + BaseClass must have at least one ctor that can be called with six or + fewer arguments, of which none is of non-const reference type. + + @derive + Inherit from this class giving your additional interface(s) to be implemented as + template argument(s). Your sub class defines method implementations for these interface(s). + */ + template< class BaseClass, class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9 > + class SAL_NO_VTABLE ImplInheritanceHelper9 + : public BaseClass + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData9< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, ImplInheritanceHelper9<BaseClass, Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9> > > {}; + protected: + template< typename T1 > + explicit ImplInheritanceHelper9(T1 const & arg1): BaseClass(arg1) {} + template< typename T1, typename T2 > + ImplInheritanceHelper9(T1 const & arg1, T2 const & arg2): + BaseClass(arg1, arg2) {} + template< typename T1, typename T2, typename T3 > + ImplInheritanceHelper9( + T1 const & arg1, T2 const & arg2, T3 const & arg3): + BaseClass(arg1, arg2, arg3) {} + template< typename T1, typename T2, typename T3, typename T4 > + ImplInheritanceHelper9( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4): + BaseClass(arg1, arg2, arg3, arg4) {} + template< + typename T1, typename T2, typename T3, typename T4, typename T5 > + ImplInheritanceHelper9( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4, + T5 const & arg5): + BaseClass(arg1, arg2, arg3, arg4, arg5) {} + template< + typename T1, typename T2, typename T3, typename T4, typename T5, + typename T6 > + ImplInheritanceHelper9( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4, + T5 const & arg5, T6 const & arg6): + BaseClass(arg1, arg2, arg3, arg4, arg5, arg6) {} + public: + ImplInheritanceHelper9() {} + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { + ::com::sun::star::uno::Any aRet( ImplHelper_queryNoXInterface( rType, cd::get(), this ) ); + if (aRet.hasValue()) + return aRet; + return BaseClass::queryInterface( rType ); + } + virtual void SAL_CALL acquire() throw () + { BaseClass::acquire(); } + virtual void SAL_CALL release() throw () + { BaseClass::release(); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; + /** Implementation helper implementing interfaces ::com::sun::star::lang::XTypeProvider and + ::com::sun::star::uno::XInterface inherting from a BaseClass. + All acquire(), release() and queryInterface() calls are delegated to the BaseClass. + Upon queryAggregation(), if a demanded interface is not supported by this class directly, + the request is delegated to the BaseClass. + + @attention + The BaseClass has to be complete in a sense, that ::com::sun::star::uno::XInterface, + ::com::sun::star::uno::XAggregation and ::com::sun::star::lang::XTypeProvider + are implemented properly. The BaseClass must have at least one ctor + that can be called with six or fewer arguments, of which none is of + non-const reference type. + + @derive + Inherit from this class giving your additional interface(s) to be implemented as + template argument(s). Your sub class defines method implementations for these interface(s). + */ + template< class BaseClass, class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9 > + class SAL_NO_VTABLE AggImplInheritanceHelper9 + : public BaseClass + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9 + { + /** @internal */ + struct cd : public rtl::StaticAggregate< class_data, ImplClassData9< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, AggImplInheritanceHelper9<BaseClass, Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9> > > {}; + protected: + template< typename T1 > + explicit AggImplInheritanceHelper9(T1 const & arg1): BaseClass(arg1) {} + template< typename T1, typename T2 > + AggImplInheritanceHelper9(T1 const & arg1, T2 const & arg2): + BaseClass(arg1, arg2) {} + template< typename T1, typename T2, typename T3 > + AggImplInheritanceHelper9( + T1 const & arg1, T2 const & arg2, T3 const & arg3): + BaseClass(arg1, arg2, arg3) {} + template< typename T1, typename T2, typename T3, typename T4 > + AggImplInheritanceHelper9( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4): + BaseClass(arg1, arg2, arg3, arg4) {} + template< + typename T1, typename T2, typename T3, typename T4, typename T5 > + AggImplInheritanceHelper9( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4, + T5 const & arg5): + BaseClass(arg1, arg2, arg3, arg4, arg5) {} + template< + typename T1, typename T2, typename T3, typename T4, typename T5, + typename T6 > + AggImplInheritanceHelper9( + T1 const & arg1, T2 const & arg2, T3 const & arg3, T4 const & arg4, + T5 const & arg5, T6 const & arg6): + BaseClass(arg1, arg2, arg3, arg4, arg5, arg6) {} + public: + AggImplInheritanceHelper9() {} + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { return BaseClass::queryInterface( rType ); } + virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) + { + ::com::sun::star::uno::Any aRet( ImplHelper_queryNoXInterface( rType, cd::get(), this ) ); + if (aRet.hasValue()) + return aRet; + return BaseClass::queryAggregation( rType ); + } + virtual void SAL_CALL acquire() throw () + { BaseClass::acquire(); } + virtual void SAL_CALL release() throw () + { BaseClass::release(); } + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) + { return ImplInhHelper_getTypes( cd::get(), BaseClass::getTypes() ); } + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) + { return ImplHelper_getImplementationId( cd::get() ); } + }; +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/inc/cppuhelper/implbase_ex.hxx b/cppuhelper/inc/cppuhelper/implbase_ex.hxx new file mode 100644 index 000000000000..056bb3760f8a --- /dev/null +++ b/cppuhelper/inc/cppuhelper/implbase_ex.hxx @@ -0,0 +1,177 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CPPUHELPER_IMPLBASE_EX_HXX_ +#define _CPPUHELPER_IMPLBASE_EX_HXX_ + +#include <cppuhelper/weak.hxx> +#include <cppuhelper/weakagg.hxx> +#include <com/sun/star/lang/XTypeProvider.hpp> + +// Despite the fact that the following include is not used in this header, it has to remain, +// because it is expected by files including cppuhelper/implbaseN.hxx. +// So maybe we can omit it some time in the future... +#include <com/sun/star/lang/XMultiServiceFactory.hpp> + +/* If you need to define implementation helper classes that deal with more than + 12 interfaces, then use macros as follows, e.g. for 3 interfaces: + +#include <cppuhelper/implbase_ex_pre.hxx> +#define __IFC_EX_TYPE_INIT3( class_cast ) \ + __IFC_EX_TYPE_INIT( class_cast, 1 ), __IFC_EX_TYPE_INIT( class_cast, 2 ), \ + __IFC_EX_TYPE_INIT( class_cast, 3 ) +#include <cppuhelper/implbase_ex_post.hxx> +__DEF_IMPLHELPER_EX( 3 ) +*/ + + +namespace cppu +{ + +/** function pointer signature for getCppuType + @internal +*/ +typedef ::com::sun::star::uno::Type const & (SAL_CALL * fptr_getCppuType)( void * ) SAL_THROW( () ); + +/** single type + object offset + @internal +*/ +struct type_entry +{ + /** the type_entry is initialized with function pointer to ::getCppuType() function first, + but holds an unacquired typelib_TypeDescriptionReference * after initialization, + thus reusing the memory. Flag class_data::m_storedTypeRefs + */ + union + { + fptr_getCppuType getCppuType; + typelib_TypeDescriptionReference * typeRef; + } m_type; + /** offset for interface pointer + */ + sal_IntPtr m_offset; +}; + +/** identical dummy struct for casting class_dataN to class_data + @internal +*/ +struct class_data +{ + /** number of supported types in m_typeEntries + */ + sal_Int16 m_nTypes; + + /** determines whether m_typeEntries is initialized and carries unacquired type refs + */ + sal_Bool m_storedTypeRefs; + + /** determines whether an implementation id was created in m_id + */ + sal_Bool m_createdId; + + /** implementation id + */ + sal_Int8 m_id[ 16 ]; + + /** type, object offset + */ + type_entry m_typeEntries[ 1 ]; +}; + +/** ImplHelper + @internal +*/ +::com::sun::star::uno::Any SAL_CALL ImplHelper_query( + ::com::sun::star::uno::Type const & rType, + class_data * cd, + void * that ) + SAL_THROW( (::com::sun::star::uno::RuntimeException) ); +/** ImplHelper + @internal +*/ +::com::sun::star::uno::Any SAL_CALL ImplHelper_queryNoXInterface( + ::com::sun::star::uno::Type const & rType, + class_data * cd, + void * that ) + SAL_THROW( (::com::sun::star::uno::RuntimeException) ); +/** ImplHelper + @internal +*/ +::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL ImplHelper_getTypes( + class_data * cd ) + SAL_THROW( (::com::sun::star::uno::RuntimeException) ); +/** ImplHelper + @internal +*/ +::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL ImplInhHelper_getTypes( + class_data * cd, + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > const & rAddTypes ) + SAL_THROW( (::com::sun::star::uno::RuntimeException) ); +/** ImplHelper + @internal +*/ +::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL ImplHelper_getImplementationId( + class_data * cd ) + SAL_THROW( (::com::sun::star::uno::RuntimeException) ); + +/** WeakImplHelper + @internal +*/ +::com::sun::star::uno::Any SAL_CALL WeakImplHelper_query( + ::com::sun::star::uno::Type const & rType, + class_data * cd, + void * that, + ::cppu::OWeakObject * pBase ) + SAL_THROW( (::com::sun::star::uno::RuntimeException) ); +/** WeakImplHelper + @internal +*/ +::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL WeakImplHelper_getTypes( + class_data * cd ) + SAL_THROW( (::com::sun::star::uno::RuntimeException) ); + +/** WeakAggImplHelper + @internal +*/ +::com::sun::star::uno::Any SAL_CALL WeakAggImplHelper_queryAgg( + ::com::sun::star::uno::Type const & rType, + class_data * cd, + void * that, + ::cppu::OWeakAggObject * pBase ) + SAL_THROW( (::com::sun::star::uno::RuntimeException) ); +/** WeakAggImplHelper + @internal +*/ +::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL WeakAggImplHelper_getTypes( + class_data * cd ) + SAL_THROW( (::com::sun::star::uno::RuntimeException) ); + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/inc/cppuhelper/implbase_ex_post.hxx b/cppuhelper/inc/cppuhelper/implbase_ex_post.hxx new file mode 100644 index 000000000000..3a2f4ca4ad6c --- /dev/null +++ b/cppuhelper/inc/cppuhelper/implbase_ex_post.hxx @@ -0,0 +1,234 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CPPUHELPER_IMPLBASE_EX_POST_HXX_ +#define _CPPUHELPER_IMPLBASE_EX_POST_HXX_ + + +/** @internal */ +#define __DEF_CLASS_DATA_INIT_EX( N, class_cast ) \ +{ \ +N +1, sal_False, sal_False, \ +{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, \ +{ \ +__IFC_EX_TYPE_INIT##N( class_cast ), \ +__IFC_EX_TYPE_INIT_NAME( class_cast, ::com::sun::star::lang::XTypeProvider ) \ +} \ +} + +/** @internal */ +#define __DEF_IMPLHELPER_EX( N ) \ +namespace cppu \ +{ \ +struct class_data##N \ +{ \ + sal_Int16 m_nTypes; \ + sal_Bool m_storedTypeRefs; \ + sal_Bool m_storedId; \ + sal_Int8 m_id[ 16 ]; \ + type_entry m_typeEntries[ N + 1 ]; \ +}; \ +template< __CLASS_IFC##N > \ +class SAL_NO_VTABLE ImplHelper##N \ + : public ::com::sun::star::lang::XTypeProvider \ + , __PUBLIC_IFC##N \ +{ \ + static class_data##N s_cd; \ +public: \ + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) \ + { return ImplHelper_query( rType, (class_data *)&s_cd, this ); } \ + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) \ + { return ImplHelper_getTypes( (class_data *)&s_cd ); } \ + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) \ + { return ImplHelper_getImplementationId( (class_data *)&s_cd ); } \ +}; \ +template< __CLASS_IFC##N > \ +class_data##N ImplHelper##N< __IFC##N >::s_cd = \ +__DEF_CLASS_DATA_INIT_EX( N, (ImplHelper##N< __IFC##N > *) ); \ +template< __CLASS_IFC##N > \ +class SAL_NO_VTABLE WeakImplHelper##N \ + : public OWeakObject \ + , public ::com::sun::star::lang::XTypeProvider \ + , __PUBLIC_IFC##N \ +{ \ + static class_data##N s_cd; \ +public: \ + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) \ + { return WeakImplHelper_query( rType, (class_data *)&s_cd, this, (OWeakObject *)this ); } \ + virtual void SAL_CALL acquire() throw () \ + { OWeakObject::acquire(); } \ + virtual void SAL_CALL release() throw () \ + { OWeakObject::release(); } \ + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) \ + { return WeakImplHelper_getTypes( (class_data *)&s_cd ); } \ + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) \ + { return ImplHelper_getImplementationId( (class_data *)&s_cd ); } \ +}; \ +template< __CLASS_IFC##N > \ +class_data##N WeakImplHelper##N< __IFC##N >::s_cd = \ +__DEF_CLASS_DATA_INIT_EX( N, (WeakImplHelper##N< __IFC##N > *) ); \ +template< __CLASS_IFC##N > \ +class SAL_NO_VTABLE WeakAggImplHelper##N \ + : public OWeakAggObject \ + , public ::com::sun::star::lang::XTypeProvider \ + , __PUBLIC_IFC##N \ +{ \ + static class_data##N s_cd; \ +public: \ + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) \ + { return OWeakAggObject::queryInterface( rType ); } \ + virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) \ + { return WeakAggImplHelper_queryAgg( rType, (class_data *)&s_cd, this, (OWeakAggObject *)this ); } \ + virtual void SAL_CALL acquire() throw () \ + { OWeakAggObject::acquire(); } \ + virtual void SAL_CALL release() throw () \ + { OWeakAggObject::release(); } \ + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) \ + { return WeakAggImplHelper_getTypes( (class_data *)&s_cd ); } \ + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) \ + { return ImplHelper_getImplementationId( (class_data *)&s_cd ); } \ +}; \ +template< __CLASS_IFC##N > \ +class_data##N WeakAggImplHelper##N< __IFC##N >::s_cd = \ +__DEF_CLASS_DATA_INIT_EX( N, (WeakAggImplHelper##N< __IFC##N > *) ); \ +template< class BaseClass, __CLASS_IFC##N > \ +class SAL_NO_VTABLE ImplInheritanceHelper##N \ + : public BaseClass \ + , __PUBLIC_IFC##N \ +{ \ + static class_data##N s_cd; \ +public: \ + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) \ + { \ + ::com::sun::star::uno::Any aRet( ImplHelper_queryNoXInterface( rType, (class_data *)&s_cd, this ) ); \ + if (aRet.hasValue()) \ + return aRet; \ + return BaseClass::queryInterface( rType ); \ + } \ + virtual void SAL_CALL acquire() throw () \ + { BaseClass::acquire(); } \ + virtual void SAL_CALL release() throw () \ + { BaseClass::release(); } \ + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) \ + { return ImplInhHelper_getTypes( (class_data *)&s_cd, BaseClass::getTypes() ); } \ + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) \ + { return ImplHelper_getImplementationId( (class_data *)&s_cd ); } \ +}; \ +template< class BaseClass, __CLASS_IFC##N > \ +class_data##N ImplInheritanceHelper##N< BaseClass, __IFC##N >::s_cd = \ +__DEF_CLASS_DATA_INIT_EX( N, (ImplInheritanceHelper##N< BaseClass, __IFC##N > *) ); \ +template< class BaseClass, __CLASS_IFC##N > \ +class SAL_NO_VTABLE AggImplInheritanceHelper##N \ + : public BaseClass \ + , __PUBLIC_IFC##N \ +{ \ + static class_data##N s_cd; \ +public: \ + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) \ + { return BaseClass::queryInterface( rType ); } \ + virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) \ + { \ + ::com::sun::star::uno::Any aRet( ImplHelper_queryNoXInterface( rType, (class_data *)&s_cd, this ) ); \ + if (aRet.hasValue()) \ + return aRet; \ + return BaseClass::queryAggregation( rType ); \ + } \ + virtual void SAL_CALL acquire() throw () \ + { BaseClass::acquire(); } \ + virtual void SAL_CALL release() throw () \ + { BaseClass::release(); } \ + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) \ + { return ImplInhHelper_getTypes( (class_data *)&s_cd, BaseClass::getTypes() ); } \ + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) \ + { return ImplHelper_getImplementationId( (class_data *)&s_cd ); } \ +}; \ +template< class BaseClass, __CLASS_IFC##N > \ +class_data##N AggImplInheritanceHelper##N< BaseClass, __IFC##N >::s_cd = \ +__DEF_CLASS_DATA_INIT_EX( N, (AggImplInheritanceHelper##N< BaseClass, __IFC##N > *) ); \ +} + +/** @internal */ +#define __DEF_COMPIMPLHELPER_EX( N ) \ +namespace cppu \ +{ \ +template< __CLASS_IFC##N > \ +class SAL_NO_VTABLE WeakComponentImplHelper##N \ + : public WeakComponentImplHelperBase \ + , public ::com::sun::star::lang::XTypeProvider \ + , __PUBLIC_IFC##N \ +{ \ + static class_data##N s_cd; \ +public: \ + inline WeakComponentImplHelper##N( ::osl::Mutex & rMutex ) SAL_THROW( () ) \ + : WeakComponentImplHelperBase( rMutex ) \ + {} \ + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) \ + { return WeakComponentImplHelper_query( rType, (class_data *)&s_cd, this, (WeakComponentImplHelperBase *)this ); } \ + virtual void SAL_CALL acquire() throw () \ + { WeakComponentImplHelperBase::acquire(); } \ + virtual void SAL_CALL release() throw () \ + { WeakComponentImplHelperBase::release(); } \ + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) \ + { return WeakComponentImplHelper_getTypes( (class_data *)&s_cd ); } \ + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) \ + { return ImplHelper_getImplementationId( (class_data *)&s_cd ); } \ +}; \ +template< __CLASS_IFC##N > \ +class_data##N WeakComponentImplHelper##N< __IFC##N >::s_cd = \ +__DEF_CLASS_DATA_INIT_EX( N, (WeakComponentImplHelper##N< __IFC##N > *) ); \ +template< __CLASS_IFC##N > \ +class SAL_NO_VTABLE WeakAggComponentImplHelper##N \ + : public WeakAggComponentImplHelperBase \ + , public ::com::sun::star::lang::XTypeProvider \ + , __PUBLIC_IFC##N \ +{ \ + static class_data##N s_cd; \ +public: \ + inline WeakAggComponentImplHelper##N( ::osl::Mutex & rMutex ) SAL_THROW( () ) \ + : WeakAggComponentImplHelperBase( rMutex ) \ + {} \ + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) \ + { return WeakAggComponentImplHelperBase::queryInterface( rType ); } \ + virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) \ + { return WeakAggComponentImplHelper_queryAgg( rType, (class_data *)&s_cd, this, (WeakAggComponentImplHelperBase *)this ); } \ + virtual void SAL_CALL acquire() throw () \ + { WeakAggComponentImplHelperBase::acquire(); } \ + virtual void SAL_CALL release() throw () \ + { WeakAggComponentImplHelperBase::release(); } \ + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException) \ + { return WeakAggComponentImplHelper_getTypes( (class_data *)&s_cd ); } \ + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw (::com::sun::star::uno::RuntimeException) \ + { return ImplHelper_getImplementationId( (class_data *)&s_cd ); } \ +}; \ +template< __CLASS_IFC##N > \ +class_data##N WeakAggComponentImplHelper##N< __IFC##N >::s_cd = \ +__DEF_CLASS_DATA_INIT_EX( N, (WeakAggComponentImplHelper##N< __IFC##N > *) ); \ +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/inc/cppuhelper/implbase_ex_pre.hxx b/cppuhelper/inc/cppuhelper/implbase_ex_pre.hxx new file mode 100644 index 000000000000..7eee744cd4c0 --- /dev/null +++ b/cppuhelper/inc/cppuhelper/implbase_ex_pre.hxx @@ -0,0 +1,39 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CPPUHELPER_IMPLBASE_EX_PRE_HXX_ +#define _CPPUHELPER_IMPLBASE_EX_PRE_HXX_ + +/** @internal */ +#define __IFC_EX_TYPE_INIT_NAME( class_cast, ifc_name ) \ +{ { ifc_name::static_type }, ((sal_IntPtr)(ifc_name *) class_cast 16) - 16 } +/** @internal */ +#define __IFC_EX_TYPE_INIT( class_cast, N ) __IFC_EX_TYPE_INIT_NAME( class_cast, Ifc##N ) + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/inc/cppuhelper/implementationentry.hxx b/cppuhelper/inc/cppuhelper/implementationentry.hxx new file mode 100644 index 000000000000..eb49075d1350 --- /dev/null +++ b/cppuhelper/inc/cppuhelper/implementationentry.hxx @@ -0,0 +1,114 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CPPUHELPER_IMPLEMENTATIONENTRY_HXX_ +#define _CPPUHELPER_IMPLEMENTATIONENTRY_HXX_ + +#include <cppuhelper/factory.hxx> + +namespace cppu +{ +/** One struct instance represents all data necessary for registering one service implementation. + + */ +struct ImplementationEntry +{ + /** Function that creates an instance of the implementation + */ + ComponentFactoryFunc create; + + /** Function that returns the implementation-name of the implementation + (same as XServiceInfo.getImplementationName() ). + */ + rtl::OUString ( SAL_CALL * getImplementationName )(); + + /** Function that returns all supported servicenames of the implementation + ( same as XServiceInfo.getSupportedServiceNames() ). + */ + com::sun::star::uno::Sequence< rtl::OUString > ( SAL_CALL * getSupportedServiceNames ) (); + + /** Function that creates a SingleComponentFactory. + */ + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleComponentFactory > + ( SAL_CALL * createFactory )( + ComponentFactoryFunc fptr, + ::rtl::OUString const & rImplementationName, + ::com::sun::star::uno::Sequence< ::rtl::OUString > const & rServiceNames, + rtl_ModuleCount * pModCount ); + + /** The shared-library module-counter of the implementation. Maybe 0. The module-counter + is used during by the createFactory()-function. + */ + rtl_ModuleCount * moduleCounter; + + /** Must be set to 0 ! + For future extensions. + */ + sal_Int32 nFlags; +}; + +/** Helper function for implementation of the component_writeInfo()-function. + + @param pServiceManager The first parameter passed to component_writeInfo()-function + (This is an instance of the service manager, that creates the factory). + @param pRegistryKey The second parameter passed to the component_writeInfo()-function. + This is a reference to the registry key, into which the implementation + data shall be written to. + @param entries Each element of the entries-array must contains a function pointer + table for registering an implementation. The end of the array + must be marked with a 0 entry in the create-function. + @return sal_True, if all implementations could be registered, otherwise sal_False. + */ +sal_Bool component_writeInfoHelper( + void *pServiceManager, void *pRegistryKey , const struct ImplementationEntry entries[] ); + +/** Helper function for implementation of the component_getFactory()-function, + that must be implemented by every shared library component. + + @param pImplName The implementation-name to be instantiated ( This is the + first parameter passed to the component_getFactory + @param pServiceManager The first parameter passed to component_writeInfo()-function + (This is a of the service manager, that creates the factory). + @param pRegistryKey The second parameter passed to the component_writeInfo()-function. + This is a reference to the registry key, where the implementation + data has been written to. + @param entries Each element of the entries-array must contains a function pointer + table for creating a factor of the implementation. The end of the array + must be marked with a 0 entry in the create-function. + @return 0 if the helper failed to instantiate a factory, otherwise an acquired pointer + to a factory. + */ +void *component_getFactoryHelper( + const sal_Char * pImplName, + void * pServiceManager, + void * pRegistryKey, + const struct ImplementationEntry entries[] ); + +} +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/inc/cppuhelper/interfacecontainer.h b/cppuhelper/inc/cppuhelper/interfacecontainer.h new file mode 100644 index 000000000000..6242de88b6d8 --- /dev/null +++ b/cppuhelper/inc/cppuhelper/interfacecontainer.h @@ -0,0 +1,619 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CPPUHELPER_INTERFACECONTAINER_H_ +#define _CPPUHELPER_INTERFACECONTAINER_H_ + +#include <vector> +#include <osl/mutex.hxx> +#include <rtl/alloc.h> +#include <com/sun/star/uno/Sequence.hxx> +#include <com/sun/star/uno/XInterface.hpp> +#ifndef _COM_SUN_STAR_LANG_EVENTOBJECT_HXX_ +#include <com/sun/star/lang/EventObject.hpp> +#endif + +#ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HXX_ +#include "com/sun/star/lang/DisposedException.hpp" +#endif + +/** */ //for docpp +namespace cppu +{ + +namespace detail { + + union element_alias + { + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > > *pAsSequence; + ::com::sun::star::uno::XInterface * pAsInterface; + element_alias() : pAsInterface(0) {} + }; + +} + +//=================================================================== +class OInterfaceContainerHelper; +/** + This is the iterator of a InterfaceContainerHelper. Typically + one constructs an instance on the stack for one firing session. + It is not allowed to assign or copy an instance of this class. + + @see OInterfaceContainerHelper + */ +class OInterfaceIteratorHelper +{ +public: + /** + Create an iterator over the elements of the container. The iterator + copies the elements of the conatainer. A change to the container + during the lifetime of an iterator is allowed and does not + affect the iterator-instance. The iterator and the container take cares + themself for concurrent access, no additional guarding is necessary. + + Remark: The copy is on demand. The iterator copy the elements only if the container + change the contents. It is not allowed to destroy the container as long + as an iterator exist. + + @param rCont the container of the elements. + */ + OInterfaceIteratorHelper( OInterfaceContainerHelper & rCont ) SAL_THROW( () ); + + /** + Releases the connection to the container. + */ + ~OInterfaceIteratorHelper() SAL_THROW( () ); + + /** Return sal_True, if there are more elements in the iterator. */ + sal_Bool SAL_CALL hasMoreElements() const SAL_THROW( () ) + { return nRemain != 0; } + /** Return the next element of the iterator. Calling this method if + hasMoreElements() has returned sal_False, is an error. Cast the + returned pointer to the + */ + ::com::sun::star::uno::XInterface * SAL_CALL next() SAL_THROW( () ); + + /** Removes the current element (the last one returned by next()) + from the underlying container. Calling this method before + next() has been called or calling it twice with no next() + inbetween is an error. + */ + void SAL_CALL remove() SAL_THROW( () ); + +private: + OInterfaceContainerHelper & rCont; + sal_Bool bIsList; + + detail::element_alias aData; + + sal_Int32 nRemain; + + OInterfaceIteratorHelper( const OInterfaceIteratorHelper & ) SAL_THROW( () ); + OInterfaceIteratorHelper & operator = ( const OInterfaceIteratorHelper & ) SAL_THROW( () ); +}; + +//=================================================================== +/** + A container of interfaces. To access the elements use an iterator. + This implementation is thread save. + + @see OInterfaceIteratorHelper + */ +class OInterfaceContainerHelper +{ +public: + // these are here to force memory de/allocation to sal lib. + inline static void * SAL_CALL operator new( size_t nSize ) SAL_THROW( () ) + { return ::rtl_allocateMemory( nSize ); } + inline static void SAL_CALL operator delete( void * pMem ) SAL_THROW( () ) + { ::rtl_freeMemory( pMem ); } + inline static void * SAL_CALL operator new( size_t, void * pMem ) SAL_THROW( () ) + { return pMem; } + inline static void SAL_CALL operator delete( void *, void * ) SAL_THROW( () ) + {} + + /** + Create an interface container. + + @param rMutex the mutex to protect multi thread access. + The lifetime must be longer than the lifetime + of this object. + */ + OInterfaceContainerHelper( ::osl::Mutex & rMutex ) SAL_THROW( () ); + /** + Release all interfaces. All iterators must be destroyed before + the container is destructed. + */ + ~OInterfaceContainerHelper() SAL_THROW( () ); + /** + Return the number of Elements in the container. Only useful if you have acquired + the mutex. + */ + sal_Int32 SAL_CALL getLength() const SAL_THROW( () ); + + /** + Return all interfaces added to this container. + **/ + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > > SAL_CALL getElements() const SAL_THROW( () ); + + /** Inserts an element into the container. The position is not specified, thus it is not + specified in which order events are fired. + + @attention + If you add the same interface more than once, then it will be added to the elements list + more than once and thus if you want to remove that interface from the list, you have to call + removeInterface() the same number of times. + In the latter case, you will also get events fired more than once (if the interface is a + listener interface). + + @param rxIFace + interface to be added; it is allowed to insert null or + the same interface more than once + @return + the new count of elements in the container + */ + sal_Int32 SAL_CALL addInterface( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & rxIFace ) SAL_THROW( () ); + /** Removes an element from the container. It uses interface equality to remove the interface. + + @param rxIFace + interface to be removed + @return + the new count of elements in the container + */ + sal_Int32 SAL_CALL removeInterface( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & rxIFace ) SAL_THROW( () ); + /** + Call disposing on all object in the container that + support XEventListener. Than clear the container. + */ + void SAL_CALL disposeAndClear( const ::com::sun::star::lang::EventObject & rEvt ) SAL_THROW( () ); + /** + Clears the container without calling disposing(). + */ + void SAL_CALL clear() SAL_THROW( () ); + + /** Executes a functor for each contained listener of specified type, e.g. + <code>forEach<awt::XPaintListener>(...</code>. + + If a com::sun::star::lang::DisposedException occurs which relates to + the called listener, then that listener is removed from the container. + + @tpl ListenerT listener type + @tpl FuncT unary functor type, let your compiler deduce this for you + @param func unary functor object expecting an argument of type + ::com::sun::star::uno::Reference<ListenerT> + */ + template <typename ListenerT, typename FuncT> + inline void forEach( FuncT const& func ); + + /** Calls a UNO listener method for each contained listener. + + The listener method must take a single argument of type EventT, + and return <code>void</code>. + + If a com::sun::star::lang::DisposedException occurs which relates to + the called listener, then that listener is removed from the container. + + @tpl ListenerT UNO event listener type, let your compiler deduce this for you + @tpl EventT event type, let your compiler deduce this for you + @param NotificationMethod + Pointer to a method of a ListenerT interface. + @param Event + Event to notify to all contained listeners + + @example +<pre> + awt::PaintEvent aEvent( static_cast< ::cppu::OWeakObject* >( this ), ... ); + listeners.notifyEach( &XPaintListener::windowPaint, aEvent ); +</pre> + */ + template< typename ListenerT, typename EventT > + inline void notifyEach( void ( SAL_CALL ListenerT::*NotificationMethod )( const EventT& ), const EventT& Event ); + +private: +friend class OInterfaceIteratorHelper; + /** + bIsList == TRUE -> aData.pAsSequence of type Sequence< XInterfaceSequence >, + otherwise aData.pAsInterface == of type (XEventListener *) + */ + detail::element_alias aData; + ::osl::Mutex & rMutex; + /** TRUE -> used by an iterator. */ + sal_Bool bInUse; + /** TRUE -> aData.pAsSequence is of type Sequence< XInterfaceSequence >. */ + sal_Bool bIsList; + + OInterfaceContainerHelper( const OInterfaceContainerHelper & ) SAL_THROW( () ); + OInterfaceContainerHelper & operator = ( const OInterfaceContainerHelper & ) SAL_THROW( () ); + + /* + Dulicate content of the conaitner and release the old one without destroying. + The mutex must be locked and the memberbInUse must be true. + */ + void copyAndResetInUse() SAL_THROW( () ); + +private: + template< typename ListenerT, typename EventT > + class NotifySingleListener + { + private: + typedef void ( SAL_CALL ListenerT::*NotificationMethod )( const EventT& ); + NotificationMethod m_pMethod; + const EventT& m_rEvent; + public: + NotifySingleListener( NotificationMethod method, const EventT& event ) : m_pMethod( method ), m_rEvent( event ) { } + + void operator()( const ::com::sun::star::uno::Reference<ListenerT>& listener ) const + { + (listener.get()->*m_pMethod)( m_rEvent ); + } + }; +}; + +template <typename ListenerT, typename FuncT> +inline void OInterfaceContainerHelper::forEach( FuncT const& func ) +{ + OInterfaceIteratorHelper iter( *this ); + while (iter.hasMoreElements()) { + ::com::sun::star::uno::Reference<ListenerT> const xListener( + iter.next(), ::com::sun::star::uno::UNO_QUERY ); + if (xListener.is()) { +#if defined(EXCEPTIONS_OFF) + func( xListener ); +#else + try { + func( xListener ); + } + catch (::com::sun::star::lang::DisposedException const& exc) { + if (exc.Context == xListener) + iter.remove(); + } +#endif + } + } +} + +template< typename ListenerT, typename EventT > +inline void OInterfaceContainerHelper::notifyEach( void ( SAL_CALL ListenerT::*NotificationMethod )( const EventT& ), const EventT& Event ) +{ + forEach< ListenerT, NotifySingleListener< ListenerT, EventT > >( NotifySingleListener< ListenerT, EventT >( NotificationMethod, Event ) ); +} + +//=================================================================== +/** + A helper class to store interface references of different types. + + @see OInterfaceIteratorHelper + @see OInterfaceContainerHelper + */ +template< class key , class hashImpl , class equalImpl > +class OMultiTypeInterfaceContainerHelperVar +{ +public: + // these are here to force memory de/allocation to sal lib. + inline static void * SAL_CALL operator new( size_t nSize ) SAL_THROW( () ) + { return ::rtl_allocateMemory( nSize ); } + inline static void SAL_CALL operator delete( void * pMem ) SAL_THROW( () ) + { ::rtl_freeMemory( pMem ); } + inline static void * SAL_CALL operator new( size_t, void * pMem ) SAL_THROW( () ) + { return pMem; } + inline static void SAL_CALL operator delete( void *, void * ) SAL_THROW( () ) + {} + + /** + Create a container of interface containers. + + @param rMutex the mutex to protect multi thread access. + The lifetime must be longer than the lifetime + of this object. + */ + inline OMultiTypeInterfaceContainerHelperVar( ::osl::Mutex & ) SAL_THROW( () ); + /** + Deletes all containers. + */ + inline ~OMultiTypeInterfaceContainerHelperVar() SAL_THROW( () ); + + /** + Return all id's under which at least one interface is added. + */ + inline ::com::sun::star::uno::Sequence< key > SAL_CALL getContainedTypes() const SAL_THROW( () ); + + /** + Return the container created under this key. + The InterfaceContainerHelper exists until the whole MultiTypeContainer is destroyed. + @return the container created under this key. If the container + was not created, null was returned. + */ + inline OInterfaceContainerHelper * SAL_CALL getContainer( const key & ) const SAL_THROW( () ); + + /** Inserts an element into the container with the specified key. + The position is not specified, thus it is not specified in which order events are fired. + + @attention + If you add the same interface more than once, then it will be added to the elements list + more than once and thus if you want to remove that interface from the list, you have to call + removeInterface() the same number of times. + In the latter case, you will also get events fired more than once (if the interface is a + listener interface). + + @param rKey + the id of the container + @param r + interface to be added; it is allowed, to insert null or + the same interface more than once + @return + the new count of elements in the container + */ + inline sal_Int32 SAL_CALL addInterface( + const key & rKey, + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & r ) + SAL_THROW( () ); + + /** Removes an element from the container with the specified key. + It uses interface equality to remove the interface. + + @param rKey + the id of the container + @param rxIFace + interface to be removed + @return + the new count of elements in the container + */ + inline sal_Int32 SAL_CALL removeInterface( + const key & rKey, + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & rxIFace ) + SAL_THROW( () ); + + /** + Call disposing on all references in the container, that + support XEventListener. Then clears the container. + @param rEvt the event object which is passed during disposing() call + */ + inline void SAL_CALL disposeAndClear( const ::com::sun::star::lang::EventObject & rEvt ) SAL_THROW( () ); + /** + Remove all elements of all containers. Does not delete the container. + */ + inline void SAL_CALL clear() SAL_THROW( () ); + + typedef key keyType; +private: + typedef ::std::vector< std::pair < key , void* > > InterfaceMap; + InterfaceMap *m_pMap; + ::osl::Mutex & rMutex; + + inline typename InterfaceMap::iterator find(const key &rKey) const + { + typename InterfaceMap::iterator iter = m_pMap->begin(); + typename InterfaceMap::iterator end = m_pMap->end(); + + while( iter != end ) + { + equalImpl equal; + if( equal( iter->first, rKey ) ) + break; + iter++; + } + return iter; + } + + inline OMultiTypeInterfaceContainerHelperVar( const OMultiTypeInterfaceContainerHelperVar & ) SAL_THROW( () ); + inline OMultiTypeInterfaceContainerHelperVar & operator = ( const OMultiTypeInterfaceContainerHelperVar & ) SAL_THROW( () ); +}; + + + + +/** + This struct contains the standard variables of a broadcaster. Helper + classes only know a reference to this struct instead of references + to the four members. The access to the members must be guarded with + rMutex. + + The additional template parameter keyType has been added, because gcc + can't compile addListener( const container::keyType &key ). + */ +template < class container , class keyType > +struct OBroadcastHelperVar +{ + /** The shared mutex. */ + ::osl::Mutex & rMutex; + /** ListenerContainer class is thread save. */ + container aLC; + /** Dispose call ready. */ + sal_Bool bDisposed; + /** In dispose call. */ + sal_Bool bInDispose; + + /** + Initialize the structur. bDispose and bInDispose are set to false. + @param rMutex the mutex reference. + */ + OBroadcastHelperVar( ::osl::Mutex & rMutex_ ) SAL_THROW( () ) + : rMutex( rMutex_ ) + , aLC( rMutex_ ) + , bDisposed( sal_False ) + , bInDispose( sal_False ) + {} + + /** + adds a listener threadsafe. + **/ + inline void addListener( + const keyType &key, + const ::com::sun::star::uno::Reference < ::com::sun::star::uno::XInterface > &r ) + SAL_THROW( () ) + { + ::osl::MutexGuard guard( rMutex ); + OSL_ENSURE( !bInDispose, "do not add listeners in the dispose call" ); + OSL_ENSURE( !bDisposed, "object is disposed" ); + if( ! bInDispose && ! bDisposed ) + aLC.addInterface( key , r ); + } + + /** + removes a listener threadsafe + **/ + inline void removeListener( + const keyType &key, + const ::com::sun::star::uno::Reference < ::com::sun::star::uno::XInterface > & r ) + SAL_THROW( () ) + { + ::osl::MutexGuard guard( rMutex ); + OSL_ENSURE( !bDisposed, "object is disposed" ); + if( ! bInDispose && ! bDisposed ) + aLC.removeInterface( key , r ); + } + + /** + Return the container created under this key. + @return the container created under this key. If the container + was not created, null was returned. This can be used to optimize + performance ( construction of an event object can be avoided ). + ***/ + inline OInterfaceContainerHelper * SAL_CALL getContainer( const keyType &key ) const SAL_THROW( () ) + { return aLC.getContainer( key ); } +}; + +/*------------------------------------------ +* +* In general, the above templates are used with a Type as key. +* Therefore a default declaration is given ( OMultiTypeInterfaceContainerHelper and OBroadcastHelper ) +* +*------------------------------------------*/ + +// helper function call class +struct hashType_Impl +{ + size_t operator()(const ::com::sun::star::uno::Type & s) const SAL_THROW( () ) + { return s.getTypeName().hashCode(); } +}; + + +/** Specialized class for key type com::sun::star::uno::Type, + without explicit usage of STL symbols. +*/ +class OMultiTypeInterfaceContainerHelper +{ +public: + // these are here to force memory de/allocation to sal lib. + inline static void * SAL_CALL operator new( size_t nSize ) SAL_THROW( () ) + { return ::rtl_allocateMemory( nSize ); } + inline static void SAL_CALL operator delete( void * pMem ) SAL_THROW( () ) + { ::rtl_freeMemory( pMem ); } + inline static void * SAL_CALL operator new( size_t, void * pMem ) SAL_THROW( () ) + { return pMem; } + inline static void SAL_CALL operator delete( void *, void * ) SAL_THROW( () ) + {} + + /** + Create a container of interface containers. + + @param rMutex the mutex to protect multi thread access. + The lifetime must be longer than the lifetime + of this object. + */ + OMultiTypeInterfaceContainerHelper( ::osl::Mutex & ) SAL_THROW( () ); + /** + Delete all containers. + */ + ~OMultiTypeInterfaceContainerHelper() SAL_THROW( () ); + + /** + Return all id's under which at least one interface is added. + */ + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getContainedTypes() const SAL_THROW( () ); + + /** + Return the container created under this key. + @return the container created under this key. If the container + was not created, null was returned. + */ + OInterfaceContainerHelper * SAL_CALL getContainer( const ::com::sun::star::uno::Type & rKey ) const SAL_THROW( () ); + + /** Inserts an element into the container with the specified key. + The position is not specified, thus it is not specified in which order events are fired. + + @attention + If you add the same interface more than once, then it will be added to the elements list + more than once and thus if you want to remove that interface from the list, you have to call + removeInterface() the same number of times. + In the latter case, you will also get events fired more than once (if the interface is a + listener interface). + + @param rKey + the id of the container + @param r + interface to be added; it is allowed, to insert null or + the same interface more than once + @return + the new count of elements in the container + */ + sal_Int32 SAL_CALL addInterface( + const ::com::sun::star::uno::Type & rKey, + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & r ) + SAL_THROW( () ); + + /** Removes an element from the container with the specified key. + It uses interface equality to remove the interface. + + @param rKey + the id of the container + @param rxIFace + interface to be removed + @return + the new count of elements in the container + */ + sal_Int32 SAL_CALL removeInterface( + const ::com::sun::star::uno::Type & rKey, + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & rxIFace ) + SAL_THROW( () ); + + /** + Call disposing on all object in the container that + support XEventListener. Than clear the container. + */ + void SAL_CALL disposeAndClear( const ::com::sun::star::lang::EventObject & rEvt ) SAL_THROW( () ); + /** + Remove all elements of all containers. Does not delete the container. + */ + void SAL_CALL clear() SAL_THROW( () ); + + typedef ::com::sun::star::uno::Type keyType; +private: + void *m_pMap; + ::osl::Mutex & rMutex; + + inline OMultiTypeInterfaceContainerHelper( const OMultiTypeInterfaceContainerHelper & ) SAL_THROW( () ); + inline OMultiTypeInterfaceContainerHelper & operator = ( const OMultiTypeInterfaceContainerHelper & ) SAL_THROW( () ); +}; + +typedef OBroadcastHelperVar< OMultiTypeInterfaceContainerHelper , OMultiTypeInterfaceContainerHelper::keyType > OBroadcastHelper; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/inc/cppuhelper/interfacecontainer.hxx b/cppuhelper/inc/cppuhelper/interfacecontainer.hxx new file mode 100644 index 000000000000..68781c9d5ac1 --- /dev/null +++ b/cppuhelper/inc/cppuhelper/interfacecontainer.hxx @@ -0,0 +1,204 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CPPUHELPER_INTERFACECONTAINER_HXX_ +#define _CPPUHELPER_INTERFACECONTAINER_HXX_ + +#include <cppuhelper/interfacecontainer.h> + + +namespace cppu +{ + +template< class key , class hashImpl , class equalImpl > +inline OMultiTypeInterfaceContainerHelperVar< key , hashImpl , equalImpl >::OMultiTypeInterfaceContainerHelperVar( ::osl::Mutex & rMutex_ ) + SAL_THROW( () ) + : rMutex( rMutex_ ) +{ + m_pMap = new InterfaceMap; +} + +//=================================================================== +template< class key , class hashImpl , class equalImpl > +inline OMultiTypeInterfaceContainerHelperVar< key , hashImpl , equalImpl >::~OMultiTypeInterfaceContainerHelperVar() + SAL_THROW( () ) +{ + typename InterfaceMap::iterator iter = m_pMap->begin(); + typename InterfaceMap::iterator end = m_pMap->end(); + + while( iter != end ) + { + delete (OInterfaceContainerHelper*)(*iter).second; + (*iter).second = 0; + ++iter; + } + delete m_pMap; +} + +//=================================================================== +template< class key , class hashImpl , class equalImpl > +inline ::com::sun::star::uno::Sequence< key > OMultiTypeInterfaceContainerHelperVar< key , hashImpl , equalImpl >::getContainedTypes() const + SAL_THROW( () ) +{ + ::osl::MutexGuard aGuard( rMutex ); + typename InterfaceMap::size_type nSize = m_pMap->size(); + if( nSize != 0 ) + { + ::com::sun::star::uno::Sequence< key > aInterfaceTypes( nSize ); + key * pArray = aInterfaceTypes.getArray(); + + typename InterfaceMap::iterator iter = m_pMap->begin(); + typename InterfaceMap::iterator end = m_pMap->end(); + + sal_uInt32 i = 0; + while( iter != end ) + { + // are interfaces added to this container? + if( ((OInterfaceContainerHelper*)(*iter).second)->getLength() ) + // yes, put the type in the array + pArray[i++] = (*iter).first; + iter++; + } + if( i != nSize ) { + // may be empty container, reduce the sequence to the right size + aInterfaceTypes = ::com::sun::star::uno::Sequence<key>( pArray, i ); + } + return aInterfaceTypes; + } + return ::com::sun::star::uno::Sequence<key>(); +} + +//=================================================================== +template< class key , class hashImpl , class equalImpl > +OInterfaceContainerHelper * OMultiTypeInterfaceContainerHelperVar< key , hashImpl , equalImpl >::getContainer( + const key & rKey ) const SAL_THROW( () ) +{ + ::osl::MutexGuard aGuard( rMutex ); + + typename InterfaceMap::iterator iter = find( rKey ); + if( iter != m_pMap->end() ) + return (OInterfaceContainerHelper*) (*iter).second; + return 0; +} + +//=================================================================== +template< class key , class hashImpl , class equalImpl > +sal_Int32 OMultiTypeInterfaceContainerHelperVar< key , hashImpl , equalImpl >::addInterface( + const key & rKey, + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & rListener ) + SAL_THROW( () ) +{ + ::osl::MutexGuard aGuard( rMutex ); + typename InterfaceMap::iterator iter = find( rKey ); + if( iter == m_pMap->end() ) + { + OInterfaceContainerHelper * pLC = new OInterfaceContainerHelper( rMutex ); + m_pMap->push_back(std::pair<key, void*>(rKey, pLC)); + return pLC->addInterface( rListener ); + } + else + return ((OInterfaceContainerHelper*)(*iter).second)->addInterface( rListener ); +} + +//=================================================================== +template< class key , class hashImpl , class equalImpl > +inline sal_Int32 OMultiTypeInterfaceContainerHelperVar< key , hashImpl , equalImpl >::removeInterface( + const key & rKey, + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & rListener ) + SAL_THROW( () ) +{ + ::osl::MutexGuard aGuard( rMutex ); + + // search container with id nUik + typename InterfaceMap::iterator iter = find( rKey ); + // container found? + if( iter != m_pMap->end() ) + return ((OInterfaceContainerHelper*)(*iter).second)->removeInterface( rListener ); + + // no container with this id. Always return 0 + return 0; +} + +//=================================================================== +template< class key , class hashImpl , class equalImpl > +void OMultiTypeInterfaceContainerHelperVar< key , hashImpl , equalImpl >::disposeAndClear( + const ::com::sun::star::lang::EventObject & rEvt ) + SAL_THROW( () ) +{ + typename InterfaceMap::size_type nSize = 0; + OInterfaceContainerHelper ** ppListenerContainers = NULL; + { + ::osl::MutexGuard aGuard( rMutex ); + nSize = m_pMap->size(); + if( nSize ) + { + typedef OInterfaceContainerHelper* ppp; + ppListenerContainers = new ppp[nSize]; + + typename InterfaceMap::iterator iter = m_pMap->begin(); + typename InterfaceMap::iterator end = m_pMap->end(); + + typename InterfaceMap::size_type i = 0; + while( iter != end ) + { + ppListenerContainers[i++] = (OInterfaceContainerHelper*)(*iter).second; + ++iter; + } + } + } + + // create a copy, because do not fire event in a guarded section + for( typename InterfaceMap::size_type i = 0; i < nSize; i++ ) + { + if( ppListenerContainers[i] ) + ppListenerContainers[i]->disposeAndClear( rEvt ); + } + + delete [] ppListenerContainers; +} + +//=================================================================== +template< class key , class hashImpl , class equalImpl > +void OMultiTypeInterfaceContainerHelperVar< key , hashImpl , equalImpl >::clear() SAL_THROW( () ) +{ + ::osl::MutexGuard aGuard( rMutex ); + typename InterfaceMap::iterator iter = m_pMap->begin(); + typename InterfaceMap::iterator end = m_pMap->end(); + + while( iter != end ) + { + ((OInterfaceContainerHelper*)(*iter).second)->clear(); + ++iter; + } +} + + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/inc/cppuhelper/propertysetmixin.hxx b/cppuhelper/inc/cppuhelper/propertysetmixin.hxx new file mode 100644 index 000000000000..41a9f1ae4785 --- /dev/null +++ b/cppuhelper/inc/cppuhelper/propertysetmixin.hxx @@ -0,0 +1,491 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef INCLUDED_CPPUHELPER_PROPERTYSETMIXIN_HXX +#define INCLUDED_CPPUHELPER_PROPERTYSETMIXIN_HXX \ + INCLUDED_CPPUHELPER_PROPERTYSETMIXIN_HXX + +#include "sal/config.h" +#include "com/sun/star/beans/PropertyVetoException.hpp" +#include "com/sun/star/beans/UnknownPropertyException.hpp" +#include "com/sun/star/beans/XFastPropertySet.hpp" +#include "com/sun/star/beans/XPropertyAccess.hpp" +#include "com/sun/star/beans/XPropertySet.hpp" +#include "com/sun/star/lang/IllegalArgumentException.hpp" +#include "com/sun/star/lang/WrappedTargetException.hpp" +#include "com/sun/star/uno/Reference.hxx" +#include "com/sun/star/uno/RuntimeException.hpp" +#include "com/sun/star/uno/Sequence.hxx" +#include "sal/types.h" + +/// @HTML + +namespace com { namespace sun { namespace star { + namespace beans { + class XPropertyChangeListener; + class XPropertySetInfo; + class XVetoableChangeListener; + struct PropertyValue; + } + namespace uno { + class Any; + class Type; + class XComponentContext; + } +} } } +namespace rtl { class OUString; } + +namespace cppu { + +template< typename T > class PropertySetMixin; + +// Suppress warnings about virtual functions but non-virtual destructor: +#if defined _MSC_VER +#pragma warning(push) +#pragma warning(disable: 4265) +#endif + +/** + @short A helper base class for <code>cppu::PropertySetMixin</code>. + + @descr See the documentation of <code>cppu::PropertySetMixin</code> for + further details. + + @descr That <code>cppu::PropertySetMixin</code> is derived from this + base class should be considered an implementation detail. The functionality + of <code>cppu::PropertySetMixin</code> that is inherited from this base + class and is visible to subclasses of + <code>cppu::PropertySetMixin</code> should be treated by such + subclasses as being provided by <code>cppu::PropertySetMixin</code> + directly (e.g., in such subclasses, use + “<code>PropertySetMixin::Implements</code>” instead of + “<code>PropertySetMixinImpl::Implements</code>”). + + @since UDK 3.2.1 +*/ +class PropertySetMixinImpl: + public com::sun::star::beans::XPropertySet, + public com::sun::star::beans::XFastPropertySet, + public com::sun::star::beans::XPropertyAccess +{ +protected: + /** + @short Flags used by subclasses of + <code>cppu::PropertySetMixin</code> to specify what UNO interface + types shall be supported. + */ + enum Implements { + /** + @short Flag specifying that the UNO interface type + <code>com::sun::star::beans::XPropertySet</code> shall be supported. + */ + IMPLEMENTS_PROPERTY_SET = 1, + + /** + @short Flag specifying that the UNO interface type + <code>com::sun::star::beans::XFastPropertySet</code> shall be + supported. + */ + IMPLEMENTS_FAST_PROPERTY_SET = 2, + + /** + @short Flag specifying that the UNO interface type + <code>com::sun::star::beans::XPropertyAccess</code> shall be + supported. + */ + IMPLEMENTS_PROPERTY_ACCESS = 4 + }; + + /** + @short A class used by subclasses of + <code>cppu::PropertySetMixin</code> when implementing UNO interface + type attribute setter functions. + + @descr This class is not thread safe; that is, the constructor, + <code>notify</code>, and the destructor must be called from the same + thread. + + @descr See <code>cppu::PropertySetMixinImpl::prepareSet</code> for + further details. + */ + class BoundListeners { + public: + /** + @short The constructor. + + @descr May throw <code>std::bad_alloc</code>. + */ + BoundListeners(); + + /** + @short The destructor. + + @descr Does not throw. + */ + ~BoundListeners(); + + /** + @short Notifies any + <code>com::sun::star::beans::XPropertyChangeListener</code>s. + + @descr May throw <code>com::sun::star::uno::RuntimeException</code> + and <code>std::bad_alloc</code>. + + @descr See <code>cppu::PropertySetMixinImpl::prepareSet</code> + for further details. + */ + void notify() const; + + private: + BoundListeners(BoundListeners &); // not defined + void operator =(BoundListeners); // not defined + + class Impl; + Impl * m_impl; + + friend class PropertySetMixinImpl; + }; + + /** + @short A function used by subclasses of + <code>cppu::PropertySetMixin</code> when implementing UNO interface + type attribute setter functions. + + @descr First, this function checks whether this instance has already been + disposed (see <code>cppu::PropertySetMixinImpl::dispose</code>), + and throws a <code>com::sun::star::lang::DisposedException</code> if + applicable. For a constrained attribute (whose setter can explicitly + raise <code>com::sun::star::beans::PropertyVetoException</code>), this + function notifies any + <code>com::sun::star::beans::XVetoableChangeListener</code>s. For a + bound attribute, this function modifies the passed-in + <code>boundListeners</code> so that it can afterwards be used to notify + any <code>com::sun::star::beans::XPropertyChangeListener</code>s. This + function should be called before storing the new attribute value, and + <code>boundListeners->notify()</code> should be called exactly once after + storing the new attribute value (in case the attribute is bound; + otherwise, calling <code>boundListeners->notify()</code> is ignored). + Furthermore, <code>boundListeners->notify()</code> and this function have + to be called from the same thread. + + @descr May throw + <code>com::sun::star::beans::PropertyVetoException</code>, + <code>com::sun::star::uno::RuntimeException</code> (and + <code>com::sun::star::lang::DisposedException</code> in particular), and + <code>std::bad_alloc</code>. + + @param propertyName the name of the property (which is the same as the + name of the attribute that is going to be set) + + @param oldValue the property value corresponding to the old attribute + value. This is only used as + <code>com::sun::star::beans::PropertyChangeEvent::OldValue</code>, which + is rather useless, anyway (see “Using the Observer Pattern” + in <a href="http://tools.openoffice.org/CodingGuidelines.sxw"> + <cite>OpenOffice.org Coding Guidelines</cite></a>). If the attribute + that is going to be set is neither bound nor constrained, or if + <code>com::sun::star::beans::PropertyChangeEvent::OldValue</code> should + not be set, a <code>VOID</code> <code>Any</code> can be used instead. + + @param newValue the property value corresponding to the new + attribute value. This is only used as + <code>com::sun::star::beans::PropertyChangeEvent::NewValue</code>, which + is rather useless, anyway (see “Using the Observer Pattern” + in <a href="http://tools.openoffice.org/CodingGuidelines.sxw"> + <cite>OpenOffice.org Coding Guidelines</cite></a>), <em>unless</em> the + attribute that is going to be set is constrained. If the attribute + that is going to be set is neither bound nor constrained, or if it is + only bound but + <code>com::sun::star::beans::PropertyChangeEvent::NewValue</code> should + not be set, a <code>VOID</code> <code>Any</code> can be used instead. + + @param boundListeners a pointer to a fresh + <code>cppu::PropertySetMixinImpl::BoundListeners</code> instance + (which has not been passed to this function before, and on which + <code>notify</code> has not yet been called); may only be null if the + attribute that is going to be set is not bound + */ + void prepareSet( + rtl::OUString const & propertyName, + com::sun::star::uno::Any const & oldValue, + com::sun::star::uno::Any const & newValue, + BoundListeners * boundListeners); + + /** + @short Mark this instance as being disposed. + + @descr See <code>com::sun::star::lang::XComponent</code> for the general + concept of disposing UNO objects. On the first call to this function, + all registered listeners + (<code>com::sun::star::beans::XPropertyChangeListener</code>s and + <code>com::sun::star::beans::XVetoableChangeListener</code>s) are + notified of the disposing source. Any subsequent calls to this function + are ignored. + + @descr May throw <code>com::sun::star::uno::RuntimeException</code> and + <code>std::bad_alloc</code>. + */ + void dispose(); + + /** + @short A function used by subclasses of + <code>cppu::PropertySetMixin</code> when implementing + <code>com::sun::star::uno::XInterface::queryInterface</code>. + + @descr This function checks for support of any of the UNO interface types + specified in the call of the <code>cppu::PropertySetMixin</code> + constructor. It does not check for any other UNO interface types (not + even for <code>com::sun::star::uno::XInterface</code>), and should not + be used directly as the implementation of + <code>com::sun::star::uno::XInterface::queryInterface</code> of this UNO + object. + */ + virtual com::sun::star::uno::Any SAL_CALL queryInterface( + com::sun::star::uno::Type const & type) + throw (com::sun::star::uno::RuntimeException); + + // @see com::sun::star::beans::XPropertySet::getPropertySetInfo + virtual + com::sun::star::uno::Reference< com::sun::star::beans::XPropertySetInfo > + SAL_CALL getPropertySetInfo() throw (com::sun::star::uno::RuntimeException); + + // @see com::sun::star::beans::XPropertySet::setPropertyValue + virtual void SAL_CALL setPropertyValue( + rtl::OUString const & propertyName, + com::sun::star::uno::Any const & value) + throw ( + com::sun::star::beans::UnknownPropertyException, + com::sun::star::beans::PropertyVetoException, + com::sun::star::lang::IllegalArgumentException, + com::sun::star::lang::WrappedTargetException, + com::sun::star::uno::RuntimeException); + + // @see com::sun::star::beans::XPropertySet::getPropertyValue + virtual com::sun::star::uno::Any SAL_CALL getPropertyValue( + rtl::OUString const & propertyName) + throw ( + com::sun::star::beans::UnknownPropertyException, + com::sun::star::lang::WrappedTargetException, + com::sun::star::uno::RuntimeException); + + /** + @short Adds a + <code>com::sun::star::beans::XPropertyChangeListener</code>. + + @descr If a listener is added more than once, it will receive all + relevant notifications multiple times. + + @see com::sun::star::beans::XPropertySet::addPropertyChangeListener + */ + virtual void SAL_CALL addPropertyChangeListener( + rtl::OUString const & propertyName, + com::sun::star::uno::Reference< + com::sun::star::beans::XPropertyChangeListener > const & listener) + throw ( + com::sun::star::beans::UnknownPropertyException, + com::sun::star::lang::WrappedTargetException, + com::sun::star::uno::RuntimeException); + + // @see com::sun::star::beans::XPropertySet::removePropertyChangeListener + virtual void SAL_CALL removePropertyChangeListener( + rtl::OUString const & propertyName, + com::sun::star::uno::Reference< + com::sun::star::beans::XPropertyChangeListener > const & listener) + throw ( + com::sun::star::beans::UnknownPropertyException, + com::sun::star::lang::WrappedTargetException, + com::sun::star::uno::RuntimeException); + + /** + @short Adds a + <code>com::sun::star::beans::XVetoableChangeListener</code>. + + @descr If a listener is added more than once, it will receive all + relevant notifications multiple times. + + @see com::sun::star::beans::XPropertySet::addVetoableChangeListener + */ + virtual void SAL_CALL addVetoableChangeListener( + rtl::OUString const & propertyName, + com::sun::star::uno::Reference< + com::sun::star::beans::XVetoableChangeListener > const & listener) + throw ( + com::sun::star::beans::UnknownPropertyException, + com::sun::star::lang::WrappedTargetException, + com::sun::star::uno::RuntimeException); + + // @see com::sun::star::beans::XPropertySet::removeVetoableChangeListener + virtual void SAL_CALL removeVetoableChangeListener( + rtl::OUString const & propertyName, + com::sun::star::uno::Reference< + com::sun::star::beans::XVetoableChangeListener > const & listener) + throw ( + com::sun::star::beans::UnknownPropertyException, + com::sun::star::lang::WrappedTargetException, + com::sun::star::uno::RuntimeException); + + // @see com::sun::star::beans::XFastPropertySet::setFastPropertyValue + virtual void SAL_CALL setFastPropertyValue( + sal_Int32 handle, com::sun::star::uno::Any const & value) + throw ( + com::sun::star::beans::UnknownPropertyException, + com::sun::star::beans::PropertyVetoException, + com::sun::star::lang::IllegalArgumentException, + com::sun::star::lang::WrappedTargetException, + com::sun::star::uno::RuntimeException); + + // @see com::sun::star::beans::XFastPropertySet::getFastPropertyValue + virtual com::sun::star::uno::Any SAL_CALL getFastPropertyValue( + sal_Int32 handle) + throw ( + com::sun::star::beans::UnknownPropertyException, + com::sun::star::lang::WrappedTargetException, + com::sun::star::uno::RuntimeException); + + // @see com::sun::star::beans::XPropertyAccess::getPropertyValues + virtual + com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > + SAL_CALL getPropertyValues() throw (com::sun::star::uno::RuntimeException); + + // @see com::sun::star::beans::XPropertyAccess::setPropertyValues + virtual void SAL_CALL setPropertyValues( + com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > + const & props) + throw ( + com::sun::star::beans::UnknownPropertyException, + com::sun::star::beans::PropertyVetoException, + com::sun::star::lang::IllegalArgumentException, + com::sun::star::lang::WrappedTargetException, + com::sun::star::uno::RuntimeException); + +private: + PropertySetMixinImpl(PropertySetMixinImpl &); // not defined + void operator =(PropertySetMixinImpl &); // not defined + + PropertySetMixinImpl( + com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > + const & context, + Implements implements, + com::sun::star::uno::Sequence< rtl::OUString > const & absentOptional, + com::sun::star::uno::Type const & type); + + class Impl; + Impl * m_impl; + + friend class Impl; + template< typename T > friend class PropertySetMixin; + + ~PropertySetMixinImpl(); + + void checkUnknown(rtl::OUString const & propertyName); +}; + +/** + @short A helper mixin to implement certain UNO interfaces related to property + set handling on top of the attributes of a given UNO interface type. + + @descr The UNO interface type is specified by the type parameter + <code>T</code> (which must correspond to a UNO interface type). + + @descr No specializations of this class template should be added by client + code. + + @since UDK 3.2.1 +*/ +template< typename T > class PropertySetMixin: public PropertySetMixinImpl { +protected: + /** + @short The constructor. + + @descr May throw <code>com::sun::star::uno::RuntimeException</code> and + <code>std::bad_alloc</code>. + + @param context the component context used by this class template; must + not be null, and must supply the service + <code>com.sun.star.reflection.CoreReflection</code> and the singleton + <code>com.sun.star.reflection.theTypeDescriptionManager</code> + + @param implements a combination of zero or more flags specifying what + UNO interface types shall be supported + + @param absentOptional a list of optional properties that are not + present, and should thus not be visible via + <code>com::sun::star::beans::XPropertySet::getPropertySetInfo</code>, + <code>com::sun::star::beans::XPropertySet::addPropertyChangeListener<!-- + --></code>, <code>com::sun::star::beans::XPropertySet::<!-- + -->removePropertyChangeListener</code>, + <code>com::sun::star::beans::XPropertySet::addVetoableChangeListener<!-- + --></code>, and <code>com::sun::star::beans::XPropertySet::<!-- + -->removeVetoableChangeListener</code>. For consistency reasons, the + given <code>absentOptional</code> should only contain the names of + attributes that represent optional properties that are not present (that + is, the attribute getters and setters always throw a + <code>com::sun::star::beans::UnknownPropertyException</code>), and should + contain each such name only once. If an optional property is not present + (that is, the corresponding attribute getter and setter always throw a + <code>com::sun::star::beans::UnknownPropertyException</code>) but is not + contained in the given <code>absentOptional</code>, then it will be + visible via + <code>com::sun::star::beans::XPropertySet::getPropertySetInfo</code> as a + <code>com::sun::star::beans::Property</code> with a set + <code>com::sun::star::beans::PropertyAttribute::OPTIONAL</code>. If the + given <code>implements</code> specifies that + <code>com::sun::star::beans::XPropertySet</code> is not supported, then + the given <code>absentOptional</code> is effectively ignored and can be + empty. + */ + PropertySetMixin( + com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > + const & context, + Implements implements, + com::sun::star::uno::Sequence< rtl::OUString > const & absentOptional): + PropertySetMixinImpl( + context, implements, absentOptional, T::static_type()) + {} + + /** + @short The destructor. + + @descr Does not throw. + */ + ~PropertySetMixin() {} + +private: + PropertySetMixin(PropertySetMixin &); // not defined + void operator =(PropertySetMixin); // not defined +}; + +#if defined _MSC_VER +#pragma warning(pop) +#endif + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/inc/cppuhelper/propshlp.hxx b/cppuhelper/inc/cppuhelper/propshlp.hxx new file mode 100644 index 000000000000..0beca5ab0bad --- /dev/null +++ b/cppuhelper/inc/cppuhelper/propshlp.hxx @@ -0,0 +1,642 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _CPPUHELPER_PROPSHLP_HXX +#define _CPPUHELPER_PROPSHLP_HXX + +#include <rtl/alloc.h> + +#include <cppuhelper/interfacecontainer.hxx> + +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/beans/XMultiPropertySet.hpp> +#include <com/sun/star/beans/XFastPropertySet.hpp> + +#include <memory> + + +namespace cppu +{ + + +/************************************************************************* +*************************************************************************/ + + +/** + This interface is used by the OPropertyHelper, to access the property description. + */ +class IPropertyArrayHelper +{ +public: + // these are here to force memory de/allocation to sal lib. + inline static void * SAL_CALL operator new( size_t nSize ) SAL_THROW( () ) + { return ::rtl_allocateMemory( nSize ); } + inline static void SAL_CALL operator delete( void * pMem ) SAL_THROW( () ) + { ::rtl_freeMemory( pMem ); } + inline static void * SAL_CALL operator new( size_t, void * pMem ) SAL_THROW( () ) + { return pMem; } + inline static void SAL_CALL operator delete( void *, void * ) SAL_THROW( () ) + {} + + /** + Folowing the rule, the first virtual method impies the virtual destructor. + */ + virtual ~IPropertyArrayHelper(); + + /** + Return the property members Name and Attribute from the handle nHandle. + @param nHandle the handle of a property. If the values of the handles + are sorted in the same way as the names and the highest handle value + is getCount() -1, than it must be an indexed acces to the property array. + @param pPropName is an out parameter filled with property name of the property with the + handle nHandle. May be NULL. + @param rAttributes is an out parameter filled with attributes of the property with the + handle nHandle. May be NULL. + @return True, if the handle exist, otherwise false. + */ + virtual sal_Bool SAL_CALL fillPropertyMembersByHandle( + ::rtl::OUString * pPropName, sal_Int16 * pAttributes, sal_Int32 nHandle ) = 0; + /** + Return the sequence of properties. The sequence is sorted by name. + */ + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > SAL_CALL getProperties(void) = 0; + /** + Return the property with the name rPropertyName. + @param rPropertyName the name of the property. + @exception UnknownPropertyException thrown if the property name is unknown. + */ + virtual ::com::sun::star::beans::Property SAL_CALL getPropertyByName( + const ::rtl::OUString& rPropertyName ) + throw (::com::sun::star::beans::UnknownPropertyException) = 0; + /** + Return true if the property with the name rPropertyName exist, otherwise false. + @param rPropertyName the name of the property. + */ + virtual sal_Bool SAL_CALL hasPropertyByName(const ::rtl::OUString& rPropertyName) = 0; + /** + Return the handle of the property with the name rPropertyName. + If the property does not exist -1 is returned. + @param rPropertyName the name of the property. + */ + virtual sal_Int32 SAL_CALL getHandleByName( const ::rtl::OUString & rPropertyName ) = 0; + /** + Fill the array with the handles of the properties. + @return the handles of the names from the pHandles array. -1 + indicates an unknown property name. + */ + virtual sal_Int32 SAL_CALL fillHandles( + /*out*/ sal_Int32 * pHandles, const ::com::sun::star::uno::Sequence< ::rtl::OUString > & rPropNames ) = 0; +}; + +/** + You can use this helper class to map a XPropertySet-Interface to a XFast- + or a XMultiPropertySet interface. + */ +class OPropertyArrayHelper : public IPropertyArrayHelper +{ +public: + /** + Create an object which supports the common property interfaces. + + @param pProps array of properties + The array pProps should be sorted. + @param nElements is the number of properties in the pProps structure. + @param bSorted indicates that the elements are sorted. + *********/ + OPropertyArrayHelper( + ::com::sun::star::beans::Property *pProps, + sal_Int32 nElements , + sal_Bool bSorted = sal_True ) + SAL_THROW( () ); + + /** + Create an object which supports the common property interfaces. + @param aProps sequence of properties which are supported by this helper. + The sequence aProps should be sorted. + @param bSorted indicates that the elements are sorted. + */ + OPropertyArrayHelper( + const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > & aProps, + sal_Bool bSorted = sal_True ) + SAL_THROW( () ); + + /** + Return the number of properties. + */ + sal_Int32 SAL_CALL getCount() const SAL_THROW( () ); + /** + Return the property members Name and Attribute from the handle nHandle. + @param nHandle the handle of a property. If the values of the handles + are sorted in the same way as the names and the highest handle value + is getCount() -1, than it is only an indexed acces to the property array. + Otherwise it is a linear search through the array. + @param pPropName is an out parameter filled with property name of the property with the + handle nHandle. May be NULL. + @param rAttributes is an out parameter filled with attributes of the property with the + handle nHandle. May be NULL. + @return True, if the handle exist, otherwise false. + */ + virtual sal_Bool SAL_CALL fillPropertyMembersByHandle( + ::rtl::OUString * pPropName, sal_Int16 * pAttributes, sal_Int32 nHandle ); + /** + Return the sequence of properties. The sequence is sorted by name. + */ + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > SAL_CALL getProperties(void); + /** + Return the property with the name rPropertyName. + @param rPropertyName the name of the property. + @exception UnknownPropertyException thrown if the property name is unknown. + */ + virtual ::com::sun::star::beans::Property SAL_CALL getPropertyByName( + const ::rtl::OUString& rPropertyName ) + throw (::com::sun::star::beans::UnknownPropertyException); + /** + Return true if the property with the name rPropertyName exist, otherwise false. + @param rPropertyName the name of the property. + */ + virtual sal_Bool SAL_CALL hasPropertyByName(const ::rtl::OUString& rPropertyName); + /** + Return the handle of the property with the name rPropertyName. + If the property does not exist -1 is returned. + @param rPropertyName the name of the property. + */ + virtual sal_Int32 SAL_CALL getHandleByName( const ::rtl::OUString & rPropertyName ); + /** + Fill the array with the handles of the properties. + @return the handles of the names from the pHandles array. -1 + indicates an unknown property name. + */ + virtual sal_Int32 SAL_CALL fillHandles( + /*out*/sal_Int32 * pHandles, const ::com::sun::star::uno::Sequence< ::rtl::OUString > & rPropNames ); + +protected: + /** reserved for future use. do not use. + */ + void * m_pReserved; + +private: + void init( sal_Bool bSorted ) SAL_THROW( () ); + + /** The sequence generated from the pProperties array. */ + ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property > aInfos; + + /** + True, If the values of the handles are sorted in the same way as the names + and the highest handle value is getCount() -1, otherwise false. + */ + sal_Bool bRightOrdered; +}; + + +//----------------------------------------------------------------------------- +// helper defines needed for an interface container with a 32 bit key values + +struct equalInt32_Impl +{ + bool operator()(const sal_Int32 & i1 , const sal_Int32 & i2) const SAL_THROW( () ) + { return i1 == i2; } +}; + +struct hashInt32_Impl +{ + size_t operator()(const sal_Int32 & i) const SAL_THROW( () ) + { return i; } +}; +/** Specialized class for key type sal_Int32, + without explicit usage of STL symbols. +*/ +class OMultiTypeInterfaceContainerHelperInt32 +{ +public: + // these are here to force memory de/allocation to sal lib. + inline static void * SAL_CALL operator new( size_t nSize ) SAL_THROW( () ) + { return ::rtl_allocateMemory( nSize ); } + inline static void SAL_CALL operator delete( void * pMem ) SAL_THROW( () ) + { ::rtl_freeMemory( pMem ); } + inline static void * SAL_CALL operator new( size_t, void * pMem ) SAL_THROW( () ) + { return pMem; } + inline static void SAL_CALL operator delete( void *, void * ) SAL_THROW( () ) + {} + + /** + Create a container of interface containers. + + @param rMutex the mutex to protect multi thread access. + The lifetime must be longer than the lifetime + of this object. + */ + OMultiTypeInterfaceContainerHelperInt32( ::osl::Mutex & ) SAL_THROW( () ); + /** + Delete all containers. + */ + ~OMultiTypeInterfaceContainerHelperInt32() SAL_THROW( () ); + + /** + Return all id's under which at least one interface is added. + */ + ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL getContainedTypes() const SAL_THROW( () ); + + /** + Return the container created under this key. + @return the container created under this key. If the container + was not created, null was returned. + */ + OInterfaceContainerHelper * SAL_CALL getContainer( const sal_Int32 & rKey ) const SAL_THROW( () ); + + /** + Insert an element in the container specified with the key. The position is not specified. + @param rKey the id of the container. + @param rxIFace the added interface. It is allowed to insert null or + the same pointer more than once. + @return the new count of elements in the container. + */ + sal_Int32 SAL_CALL addInterface( + const sal_Int32 & rKey, + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & r ) + SAL_THROW( () ); + + /** + Remove an element from the container specified with the key. + It uses the equal definition of uno objects to remove the interfaces. + @param rKey the id of the container. + @param rxIFace the removed interface. + @return the new count of elements in the container. + */ + sal_Int32 SAL_CALL removeInterface( + const sal_Int32 & rKey, + const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & rxIFace ) + SAL_THROW( () ); + + /** + Call disposing on all objects in the container that + support XEventListener. Then clear the container. + */ + void SAL_CALL disposeAndClear( const ::com::sun::star::lang::EventObject & rEvt ) SAL_THROW( () ); + /** + Remove all elements of all containers. Does not delete the container. + */ + void SAL_CALL clear() SAL_THROW( () ); + + typedef sal_Int32 keyType; +private: + void *m_pMap; + ::osl::Mutex & rMutex; + + inline OMultiTypeInterfaceContainerHelperInt32( const OMultiTypeInterfaceContainerHelperInt32 & ) SAL_THROW( () ); + inline OMultiTypeInterfaceContainerHelperInt32 & operator = ( const OMultiTypeInterfaceContainerHelperInt32 & ) SAL_THROW( () ); +}; + + +/** An interface to extend event notification actions. + */ +class IEventNotificationHook +{ +public: + /** + Method to be called by OPropertySetHelper::fire. + + @param bIgnoreRuntimeExceptionsWhileFiring + indicates whether occuring RuntimeExceptions shall be + ignored when firing notifications + + @see OPropertySetHelper::fire + */ + virtual void fireEvents( + sal_Int32 * pnHandles, + sal_Int32 nCount, + sal_Bool bVetoable, + bool bIgnoreRuntimeExceptionsWhileFiring) = 0; +}; + + + +/** + This abstract class maps the methods of the interfaces XMultiPropertySet, XFastPropertySet + and XPropertySet to the methods getInfoHelper, convertFastPropertyValue, + setFastPropertyValue_NoBroadcast and getFastPropertyValue. You must derive from + this class and overload the methods. + It provides a standard implementation of the XPropertySetInfo. + The XPropertiesChangeListener are inserted in the rBHelper.aLC structure. + The XPropertyChangeListener and XVetoableChangeListener with no names are inserted + in the rBHelper.aLC structure. So it is possible to advise property listeners with + the connection point interfaces. But only listeners that listen to all property changes. + + */ +class OPropertySetHelper : public ::com::sun::star::beans::XMultiPropertySet, + public ::com::sun::star::beans::XFastPropertySet, + public ::com::sun::star::beans::XPropertySet +{ +public: + /** + @param rBHelper this structure contains the basic members of + a broadcaster. + The lifetime must be longer than the lifetime + of this object. Stored in the variable rBHelper. + */ + OPropertySetHelper( OBroadcastHelper & rBHelper ) SAL_THROW( () ); + + /** Constructor. + + @param rBHelper + this structure contains the basic members of + a broadcaster. + The lifetime must be longer than the lifetime + of this object. Stored in the variable rBHelper. + + @param bIgnoreRuntimeExceptionsWhileFiring + indicates whether occuring RuntimeExceptions will be + ignored when firing notifications (vetoableChange((), + propertyChange()) to listeners. + PropertyVetoExceptions may still be thrown. + This flag is useful in a inter-process scenarios when + remote bridges may break down + (firing DisposedExceptions). + */ + OPropertySetHelper( + OBroadcastHelper & rBHelper, bool bIgnoreRuntimeExceptionsWhileFiring ); + + /** Constructor. + + @param rBHelper + this structure contains the basic members of + a broadcaster. + The lifetime must be longer than the lifetime + of this object. Stored in the variable rBHelper. + + @param i_pFireEvents + additional event notifier + + @param bIgnoreRuntimeExceptionsWhileFiring + indicates whether occuring RuntimeExceptions will be + ignored when firing notifications (vetoableChange((), + propertyChange()) to listeners. + PropertyVetoExceptions may still be thrown. + This flag is useful in a inter-process scenarios when + remote bridges may break down + (firing DisposedExceptions). + */ + OPropertySetHelper( + OBroadcastHelper & rBHelper, + IEventNotificationHook *i_pFireEvents, + bool bIgnoreRuntimeExceptionsWhileFiring = false); + + /** + Only returns a reference to XMultiPropertySet, XFastPropertySet, XPropertySet and + XEventListener. + */ + ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) + throw (::com::sun::star::uno::RuntimeException); + + /** eases implementing XTypeProvider::getTypes, returns the types of XMultiPropertySet, XFastPropertySet, XPropertySet + */ + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > getTypes() + throw(::com::sun::star::uno::RuntimeException); + + /** + Send a disposing notification to the listeners in the conatiners aBoundLC + and aVetoableLC. + + @see OComponentHelper + */ + void SAL_CALL disposing() SAL_THROW( () ); + + /** + Throw UnknownPropertyException or PropertyVetoException if the property with the name + rPropertyName does not exist or is readonly. Otherwise rPropertyName is changed to its handle + value and setFastPropertyValue is called. + */ + virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& rPropertyName, const ::com::sun::star::uno::Any& aValue ) + throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + /** + Throw UnknownPropertyException if the property with the name + rPropertyName does not exist. + */ + virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue(const ::rtl::OUString& aPropertyName) + throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + /** Ignored if the property is not bound. */ + virtual void SAL_CALL addPropertyChangeListener( + const ::rtl::OUString& aPropertyName, + const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener) + throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + /** Ignored if the property is not bound. */ + virtual void SAL_CALL removePropertyChangeListener( + const ::rtl::OUString& aPropertyName, + const ::com::sun::star::uno::Reference < ::com::sun::star::beans::XPropertyChangeListener >& aListener) + throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + /** Ignored if the property is not constrained. */ + virtual void SAL_CALL addVetoableChangeListener( + const ::rtl::OUString& aPropertyName, + const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener) + throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + /** Ignored if the property is not constrained. */ + virtual void SAL_CALL removeVetoableChangeListener( + const ::rtl::OUString& aPropertyName, + const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener > & aListener ) + throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + /** + Throw UnknownPropertyException or PropertyVetoException if the property with the name + rPropertyName does not exist or is readonly. Otherwise the method convertFastPropertyValue + is called, then the vetoable listeners are notified. After this the value of the property + is changed with the setFastPropertyValue_NoBroadcast method and the bound listeners are + notified. + */ + virtual void SAL_CALL setFastPropertyValue( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ) + throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + /** + @exception com::sun::star::beans::UnknownPropertyException + if the property with the handle nHandle does not exist. + */ + virtual ::com::sun::star::uno::Any SAL_CALL getFastPropertyValue( sal_Int32 nHandle ) + throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + // XMultiPropertySet + virtual void SAL_CALL setPropertyValues( + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& PropertyNames, + const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& Values ) + throw(::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL getPropertyValues( + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& PropertyNames ) + throw(::com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL addPropertiesChangeListener( + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& PropertyNames, + const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& Listener ) + throw(::com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL removePropertiesChangeListener( + const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& Listener ) + throw(::com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL firePropertiesChangeEvent( + const ::com::sun::star::uno::Sequence< ::rtl::OUString >& PropertyNames, + const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener > & Listener ) + throw(::com::sun::star::uno::RuntimeException); + /** + The property sequence is created in the call. The interface isn't used after the call. + */ + static ::com::sun::star::uno::Reference < ::com::sun::star::beans::XPropertySetInfo > SAL_CALL + createPropertySetInfo( IPropertyArrayHelper & rProperties ) SAL_THROW( () ); +protected: + /** + This method fire events to all registered property listeners. + @param pnHandles the id's of the properties that changed. + @param pNewValues the new values of the properties. + @param pOldValues the old values of the properties. + @param nCount the number of elements in the arrays pnHandles, pNewValues and pOldValues. + @param bVetoable true means fire to VetoableChangeListener, false means fire to + XPropertyChangedListener and XMultiPropertyChangedListener. + */ + void SAL_CALL fire( + sal_Int32 * pnHandles, + const ::com::sun::star::uno::Any * pNewValues, + const ::com::sun::star::uno::Any * pOldValues, + sal_Int32 nCount, + sal_Bool bVetoable ); + + /** + Set multiple properties with the handles. + @param nSeqLen the length of the arrays pHandles and Values. + @param pHandles the handles of the properties. The number of elements + in the Values sequence is the length of the handle array. A value of -1 + of a handle means invalid property. These are ignored. + @param pValues the values of the properties. + @param nHitCount the number of valid entries in the handle array. + */ + void SAL_CALL setFastPropertyValues( + sal_Int32 nSeqLen, + sal_Int32 * pHandles, + const ::com::sun::star::uno::Any * pValues, + sal_Int32 nHitCount ) + SAL_THROW( (::com::sun::star::uno::Exception) ); + + /** + This abstract method must return the name to index table. This table contains all property + names and types of this object. The method is not implemented in this class. + */ + virtual IPropertyArrayHelper & SAL_CALL getInfoHelper() = 0; + + /** + Converted the value rValue and return the result in rConvertedValue and the + old value in rOldValue. A IllegalArgumentException is thrown. + The method is not implemented in this class. After this call the vetoable + listeners are notified. + + @param rConvertedValue the converted value. Only set if return is true. + @param rOldValue the old value. Only set if return is true. + @param nHandle the handle of the proberty. + @return true if the value converted. + */ + virtual sal_Bool SAL_CALL convertFastPropertyValue( + ::com::sun::star::uno::Any & rConvertedValue, + ::com::sun::star::uno::Any & rOldValue, + sal_Int32 nHandle, + const ::com::sun::star::uno::Any& rValue ) + throw (::com::sun::star::lang::IllegalArgumentException) = 0; + + /** The same as setFastProperyValue; nHandle is always valid. + The changes must not be broadcasted in this method. + The method is implemented in a derived class. + + @attention + Although you are permitted to throw any UNO exception, only the following + are valid for usage: + -- ::com::sun::star::beans::UnknownPropertyException + -- ::com::sun::star::beans::PropertyVetoException + -- ::com::sun::star::lang::IllegalArgumentException + -- ::com::sun::star::lang::WrappedTargetException + -- ::com::sun::star::uno::RuntimeException + + @param nHandle + handle + @param rValue + value + */ + virtual void SAL_CALL setFastPropertyValue_NoBroadcast( + sal_Int32 nHandle, + const ::com::sun::star::uno::Any& rValue ) + throw (::com::sun::star::uno::Exception) = 0; + /** + The same as getFastProperyValue, but return the value through rValue and nHandle + is always valid. + The method is not implemented in this class. + */ + virtual void SAL_CALL getFastPropertyValue( + ::com::sun::star::uno::Any& rValue, + sal_Int32 nHandle ) const = 0; + + /** The common data of a broadcaster. Use the mutex, disposing state and the listener container. */ + OBroadcastHelper &rBHelper; + /** + Container for the XProperyChangedListener. The listeners are inserted by handle. + */ + OMultiTypeInterfaceContainerHelperInt32 aBoundLC; + /** + Container for the XPropertyVetoableListener. The listeners are inserted by handle. + */ + OMultiTypeInterfaceContainerHelperInt32 aVetoableLC; + + class Impl; + + /** reserved for future use. finally, the future has arrived... + */ + const std::auto_ptr<const Impl> m_pReserved; + +private: + OPropertySetHelper( const OPropertySetHelper & ) SAL_THROW( () ); + OPropertySetHelper & operator = ( const OPropertySetHelper & ) SAL_THROW( () ); + +public: +// Suppress warning about virtual functions but non-virtual destructor: +#if defined __GNUC__ +#pragma GCC system_header +#elif defined _MSC_VER +#pragma warning(push) +#pragma warning(disable: 4265) +#endif + /** + You must call disposing before destruction. + */ + ~OPropertySetHelper() SAL_THROW( () ); +}; +#if defined _MSC_VER +#pragma warning(pop) +#endif + +} // end namespace cppuhelper +#endif // + + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/inc/cppuhelper/proptypehlp.h b/cppuhelper/inc/cppuhelper/proptypehlp.h new file mode 100644 index 000000000000..a7c1210319d6 --- /dev/null +++ b/cppuhelper/inc/cppuhelper/proptypehlp.h @@ -0,0 +1,79 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CPPUHELPER_PROPTYPEHLP_H +#define _CPPUHELPER_PROPTYPEHLP_H + +#include <com/sun/star/lang/IllegalArgumentException.hpp> +#include <com/sun/star/uno/TypeClass.hpp> + + +namespace cppu { + +/** Converts the value stored in an any to a concrete C++ type. + The function does the same as the operator >>= () at the + Any class, except that it throws an IllegalArgumentException in case of + failures (the value cannot be extracted without data loss ) + + @exception com::sun::star::lang::IllegalArgumentException when the type could not be converted. + */ +template < class target > +inline void SAL_CALL convertPropertyValue( target &value , const ::com::sun::star::uno::Any & a); + +template < class target > +inline void SAL_CALL convertPropertyValue( target &value , ::com::sun::star::uno::Any & a); + +/** + conversion of basic types +*/ +inline void SAL_CALL convertPropertyValue( sal_Int64 & target , const ::com::sun::star::uno::Any & source ) + SAL_THROW( (::com::sun::star::lang::IllegalArgumentException) ); +inline void SAL_CALL convertPropertyValue( sal_uInt64 & target, const ::com::sun::star::uno::Any & source ) + SAL_THROW( (::com::sun::star::lang::IllegalArgumentException) ); +inline void SAL_CALL convertPropertyValue( sal_Int32 & target , const ::com::sun::star::uno::Any & source ) + SAL_THROW( (::com::sun::star::lang::IllegalArgumentException) ); +inline void SAL_CALL convertPropertyValue( sal_uInt32 & target, const ::com::sun::star::uno::Any & source ) + SAL_THROW( (::com::sun::star::lang::IllegalArgumentException) ); +inline void SAL_CALL convertPropertyValue( sal_Int16 & target , const ::com::sun::star::uno::Any & source ) + SAL_THROW( (::com::sun::star::lang::IllegalArgumentException) ); +inline void SAL_CALL convertPropertyValue( sal_uInt16 & target, const ::com::sun::star::uno::Any & source ) + SAL_THROW( (::com::sun::star::lang::IllegalArgumentException) ); +inline void SAL_CALL convertPropertyValue( sal_Int8 & target , const ::com::sun::star::uno::Any & source ) + SAL_THROW( (::com::sun::star::lang::IllegalArgumentException) ); +inline void SAL_CALL convertPropertyValue( float & target , const ::com::sun::star::uno::Any & source ) + SAL_THROW( (::com::sun::star::lang::IllegalArgumentException) ); +inline void SAL_CALL convertPropertyValue( double &target , const ::com::sun::star::uno::Any &source ) + SAL_THROW( (::com::sun::star::lang::IllegalArgumentException) ); +inline void SAL_CALL convertPropertyValue( ::rtl::OUString &target , const ::com::sun::star::uno::Any &source ) + SAL_THROW( (::com::sun::star::lang::IllegalArgumentException) ); + +} // end namespace cppu + + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/inc/cppuhelper/proptypehlp.hxx b/cppuhelper/inc/cppuhelper/proptypehlp.hxx new file mode 100644 index 000000000000..b7a14e8bcbae --- /dev/null +++ b/cppuhelper/inc/cppuhelper/proptypehlp.hxx @@ -0,0 +1,532 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CPPUHELPER_PROPTYPEHLP_HXX +#define _CPPUHELPER_PROPTYPEHLP_HXX + +#include <cppuhelper/proptypehlp.h> + +namespace cppu +{ + +/** Converts the value stored in an any to a concrete C++ type. + The function does the same as the operator >>= () at the + Any class, except that it throws an IllegalArgumentException in case of + failures (the value cannot be extracted without data loss ) + + @exception com::sun::star::lang::IllegalArgumentException when the type could not be converted. + */ +template < class target > +inline void SAL_CALL convertPropertyValue( target &value , const ::com::sun::star::uno::Any & a) +{ + + if( !( a >>= value ) ) { + throw ::com::sun::star::lang::IllegalArgumentException(); + } +} + + +// This template is needed at least for msci4 compiler +template < class target > +inline void SAL_CALL convertPropertyValue( target &value , ::com::sun::star::uno::Any & a) +{ + convertPropertyValue( value , (const ::com::sun::star::uno::Any & ) a ); +} + +/** + conversion of basic types +*/ +inline void SAL_CALL convertPropertyValue( sal_Bool & b , const ::com::sun::star::uno::Any & a ) + SAL_THROW( (::com::sun::star::lang::IllegalArgumentException) ) +{ + const enum ::com::sun::star::uno::TypeClass tc = a.getValueType().getTypeClass(); + + if( ::com::sun::star::uno::TypeClass_LONG == tc ) { + sal_Int32 i32 = 0; + a >>= i32; + b = ( sal_Bool )i32; + } + else if ( ::com::sun::star::uno::TypeClass_CHAR == tc ) { + sal_Unicode c = *(sal_Unicode*) a.getValue(); + b = ( sal_Bool ) c; + } + else if ( ::com::sun::star::uno::TypeClass_SHORT == tc ) { + sal_Int16 i16 = 0; + a >>= i16; + b = ( sal_Bool ) i16; + } + else if ( ::com::sun::star::uno::TypeClass_BOOLEAN == tc ) { + b = *((sal_Bool*)a.getValue()); + } + else if ( ::com::sun::star::uno::TypeClass_BYTE == tc ) { + sal_Int8 i8 = 0; + a >>= i8; + b = ( sal_Bool ) i8; + } + else if ( ::com::sun::star::uno::TypeClass_UNSIGNED_SHORT == tc ) { + sal_uInt16 i16 = 0; + a >>= i16; + b = ( sal_Bool ) i16; + } + else if ( ::com::sun::star::uno::TypeClass_UNSIGNED_LONG == tc ) { + sal_uInt32 i32 = 0; + a >>= i32; + b = ( sal_Bool ) i32; + } + else { + throw ::com::sun::star::lang::IllegalArgumentException(); + } +} + +inline void SAL_CALL convertPropertyValue( sal_Int64 & i , const ::com::sun::star::uno::Any & a ) + SAL_THROW( (::com::sun::star::lang::IllegalArgumentException) ) +{ + const enum ::com::sun::star::uno::TypeClass tc = a.getValueType().getTypeClass(); + + if( ::com::sun::star::uno::TypeClass_HYPER == tc ) { + a >>= i; + } + else if( ::com::sun::star::uno::TypeClass_UNSIGNED_HYPER == tc ) { + sal_uInt64 i64 = 0; + a >>= i64; + i = ( sal_Int64 ) i64; + } + else if( ::com::sun::star::uno::TypeClass_LONG == tc ) { + sal_Int32 i32 = 0; + a >>= i32; + i = ( sal_Int64 )i32; + } + else if ( ::com::sun::star::uno::TypeClass_CHAR == tc ) { + sal_Unicode c; + c = *(sal_Unicode *)a.getValue(); + i = ( sal_Int64 ) c; + } + else if ( ::com::sun::star::uno::TypeClass_SHORT == tc ) { + sal_Int16 i16 = 0; + a >>= i16; + i = ( sal_Int64 ) i16; + } + else if ( ::com::sun::star::uno::TypeClass_BOOLEAN == tc ) { + sal_Bool b; + b = *((sal_Bool * )a.getValue()); + i = ( sal_Int64 ) b; + } + else if ( ::com::sun::star::uno::TypeClass_BYTE == tc ) { + sal_Int8 i8 = 0; + a >>= i8; + i = ( sal_Int64 ) i8; + } + else if ( ::com::sun::star::uno::TypeClass_UNSIGNED_SHORT == tc ) { + sal_uInt16 i16 = 0; + a >>= i16; + i = ( sal_Int64 ) i16; + } + else if ( ::com::sun::star::uno::TypeClass_UNSIGNED_LONG == tc ) { + sal_uInt32 i32 = 0; + a >>= i32; + i = ( sal_Int64 ) i32; + } + else { + throw ::com::sun::star::lang::IllegalArgumentException(); + } +} + + +inline void SAL_CALL convertPropertyValue( sal_uInt64 & i , const ::com::sun::star::uno::Any & a ) + SAL_THROW( (::com::sun::star::lang::IllegalArgumentException) ) +{ + const enum ::com::sun::star::uno::TypeClass tc = a.getValueType().getTypeClass(); + + if( ::com::sun::star::uno::TypeClass_UNSIGNED_HYPER == tc ) { + a >>= i; + } + if( ::com::sun::star::uno::TypeClass_HYPER == tc ) { + sal_Int64 i64; + a >>= i64; + i = ( sal_uInt64 ) i64; + } + else if( ::com::sun::star::uno::TypeClass_LONG == tc ) { + sal_Int32 i32; + a >>= i32; + i = ( sal_uInt64 )i32; + } + else if ( ::com::sun::star::uno::TypeClass_CHAR == tc ) { + sal_Unicode c; + c = *( sal_Unicode * ) a.getValue() ; + i = ( sal_uInt64 ) c; + } + else if ( ::com::sun::star::uno::TypeClass_SHORT == tc ) { + sal_Int16 i16; + a >>= i16; + i = ( sal_uInt64 ) i16; + } + else if ( ::com::sun::star::uno::TypeClass_BOOLEAN == tc ) { + sal_Bool b; + b = *((sal_Bool * )a.getValue()); + i = ( sal_uInt64 ) b; + } + else if ( ::com::sun::star::uno::TypeClass_BYTE == tc ) { + sal_Int8 i8; + a >>= i8; + i = ( sal_uInt64 ) i8; + } + else if ( ::com::sun::star::uno::TypeClass_UNSIGNED_SHORT == tc ) { + sal_uInt16 i16; + a >>= i16; + i = ( sal_uInt64 ) i16; + } + else if ( ::com::sun::star::uno::TypeClass_UNSIGNED_LONG == tc ) { + sal_uInt32 i32; + a >>= i32; + i = ( sal_uInt64 ) i32; + } + else { + throw ::com::sun::star::lang::IllegalArgumentException(); + } +} + +// the basic types +// sal_Int32 +inline void SAL_CALL convertPropertyValue( sal_Int32 & i , const ::com::sun::star::uno::Any & a ) + SAL_THROW( (::com::sun::star::lang::IllegalArgumentException) ) +{ + const enum ::com::sun::star::uno::TypeClass tc = a.getValueType().getTypeClass(); + + if( ::com::sun::star::uno::TypeClass_LONG == tc ) { + a >>= i; + } + else if ( ::com::sun::star::uno::TypeClass_CHAR == tc ) { + sal_Unicode c; + c = *(sal_Unicode*) a.getValue(); + i = ( sal_Int32 ) c; + } + else if ( ::com::sun::star::uno::TypeClass_SHORT == tc ) { + sal_Int16 i16 = 0; + a >>= i16; + i = ( sal_Int32 ) i16; + } + else if ( ::com::sun::star::uno::TypeClass_BOOLEAN == tc ) { + sal_Bool b; + b = *((sal_Bool * )a.getValue()); + i = ( sal_Int32 ) b; + } + else if ( ::com::sun::star::uno::TypeClass_BYTE == tc ) { + sal_Int8 i8 = 0; + a >>= i8; + i = ( sal_Int32 ) i8; + } + else if ( ::com::sun::star::uno::TypeClass_UNSIGNED_SHORT == tc ) { + sal_uInt16 i16 = 0; + a >>= i16; + i = ( sal_Int32 ) i16; + } + else if ( ::com::sun::star::uno::TypeClass_UNSIGNED_LONG == tc ) { + sal_uInt32 i32 = 0; + a >>= i32; + i = ( sal_Int32 ) i32; + } + else { + throw ::com::sun::star::lang::IllegalArgumentException(); + } +} + +inline void SAL_CALL convertPropertyValue( sal_uInt32 & i , const ::com::sun::star::uno::Any & a ) + SAL_THROW( (::com::sun::star::lang::IllegalArgumentException) ) +{ + const enum ::com::sun::star::uno::TypeClass tc = a.getValueType().getTypeClass(); + + if ( ::com::sun::star::uno::TypeClass_UNSIGNED_LONG == tc ) { + a >>= i; + } + else if( ::com::sun::star::uno::TypeClass_LONG == tc ) { + sal_Int32 i32; + a >>= i32; + i = (sal_uInt32 ) i32; + } + else if ( ::com::sun::star::uno::TypeClass_CHAR == tc ) { + sal_Unicode c; + c = *(sal_Unicode*) a.getValue(); + i = ( sal_uInt32 ) c; + } + else if ( ::com::sun::star::uno::TypeClass_SHORT == tc ) { + sal_Int16 i16; + a >>= i16; + i = ( sal_uInt32 ) i16; + } + else if ( ::com::sun::star::uno::TypeClass_BOOLEAN == tc ) { + sal_Bool b; + b = *((sal_Bool * )a.getValue()); + i = ( sal_uInt32 ) b; + } + else if ( ::com::sun::star::uno::TypeClass_BYTE == tc ) { + sal_Int8 i8; + a >>= i8; + i = ( sal_uInt32 ) i8; + } + else if ( ::com::sun::star::uno::TypeClass_UNSIGNED_SHORT == tc ) { + sal_uInt16 i16; + a >>= i16; + i = ( sal_uInt32 ) i16; + } + else { + throw ::com::sun::star::lang::IllegalArgumentException(); + } +} + + +inline void SAL_CALL convertPropertyValue( sal_Int16 & i , const ::com::sun::star::uno::Any & a ) + SAL_THROW( (::com::sun::star::lang::IllegalArgumentException) ) +{ + const enum ::com::sun::star::uno::TypeClass tc = a.getValueType().getTypeClass(); + + if ( ::com::sun::star::uno::TypeClass_SHORT == tc ) { + a >>= i; + } + else if ( ::com::sun::star::uno::TypeClass_CHAR == tc ) { + sal_Unicode c; + c = *(sal_Unicode*) a.getValue(); + i = ( sal_Int16 ) c; + } + else if ( ::com::sun::star::uno::TypeClass_BOOLEAN == tc ) { + sal_Bool b; + b = *((sal_Bool * )a.getValue()); + i = ( sal_Int16 ) b; + } + else if ( ::com::sun::star::uno::TypeClass_BYTE == tc ) { + sal_Int8 i8 = 0; + a >>= i8; + i = ( sal_Int16 ) i8; + } + else if ( ::com::sun::star::uno::TypeClass_UNSIGNED_SHORT == tc ) { + sal_uInt16 i16 = 0; + a >>= i16; + i = ( sal_Int16 ) i16; + } + else { + throw ::com::sun::star::lang::IllegalArgumentException(); + } +} + +inline void SAL_CALL convertPropertyValue( sal_uInt16 & i , const ::com::sun::star::uno::Any & a ) + SAL_THROW( (::com::sun::star::lang::IllegalArgumentException) ) +{ + const enum ::com::sun::star::uno::TypeClass tc = a.getValueType().getTypeClass(); + + if ( ::com::sun::star::uno::TypeClass_UNSIGNED_SHORT == tc ) { + a >>= i; + } + else if ( ::com::sun::star::uno::TypeClass_CHAR == tc ) { + sal_Unicode c; + c = *(sal_Unicode *) a.getValue(); + i = ( sal_Int16 ) c; + } + else if ( ::com::sun::star::uno::TypeClass_BOOLEAN == tc ) { + sal_Bool b; + b = *((sal_Bool * )a.getValue()); + i = ( sal_Int16 ) b; + } + else if ( ::com::sun::star::uno::TypeClass_BYTE == tc ) { + sal_Int8 i8 = 0; + a >>= i8; + i = ( sal_Int16 ) i8; + } + else if ( ::com::sun::star::uno::TypeClass_SHORT == tc ) { + sal_Int16 i16 = 0; + a >>= i16; + i = ( sal_Int16 ) i16; + } + else { + throw ::com::sun::star::lang::IllegalArgumentException(); + } +} + +inline void SAL_CALL convertPropertyValue( sal_Int8 & i , const ::com::sun::star::uno::Any & a ) + SAL_THROW( (::com::sun::star::lang::IllegalArgumentException) ) +{ + const enum ::com::sun::star::uno::TypeClass tc = a.getValueType().getTypeClass(); + + if ( ::com::sun::star::uno::TypeClass_BYTE == tc ) { + a >>= i; + } + else if ( ::com::sun::star::uno::TypeClass_BOOLEAN == tc ) { + sal_Bool b; + b = *((sal_Bool * )a.getValue()); + i = ( sal_Int8 ) b; + } + else { + throw ::com::sun::star::lang::IllegalArgumentException(); + } +} + +inline void SAL_CALL convertPropertyValue( float &f , const ::com::sun::star::uno::Any &a ) + SAL_THROW( (::com::sun::star::lang::IllegalArgumentException) ) +{ + const enum ::com::sun::star::uno::TypeClass tc = a.getValueType().getTypeClass(); + + if ( ::com::sun::star::uno::TypeClass_FLOAT == tc ) { + a >>= f; + } + else if( ::com::sun::star::uno::TypeClass_DOUBLE == tc ) { + double d = 0; + a >>= d; + f = ( float ) d; + } + else if( ::com::sun::star::uno::TypeClass_HYPER == tc ) { + sal_Int64 i64 = 0; + a >>= i64; + f = ( float ) i64; + } + // msci 4 does not support this conversion +/* else if( ::com::sun::star::uno::TypeClass_UNSIGNED_HYPER == tc ) { + sal_uInt64 i64; + a >>= i64; + f = ( float ) i64; + } +*/ else if( ::com::sun::star::uno::TypeClass_LONG == tc ) { + sal_Int32 i32 = 0; + a >>= i32; + f = ( float )i32; + } + else if ( ::com::sun::star::uno::TypeClass_CHAR == tc ) { + sal_Unicode c; + c = *(sal_Unicode*) a.getValue(); + f = ( float ) c; + } + else if ( ::com::sun::star::uno::TypeClass_SHORT == tc ) { + sal_Int16 i16 = 0; + a >>= i16; + f = ( float ) i16; + } + else if ( ::com::sun::star::uno::TypeClass_BOOLEAN == tc ) { + sal_Bool b; + b = *((sal_Bool * )a.getValue()); + f = ( float ) b; + } + else if ( ::com::sun::star::uno::TypeClass_BYTE == tc ) { + sal_Int8 i8 = 0; + a >>= i8; + f = ( float ) i8; + } + else if ( ::com::sun::star::uno::TypeClass_UNSIGNED_SHORT == tc ) { + sal_uInt16 i16 = 0; + a >>= i16; + f = ( float ) i16; + } + else if ( ::com::sun::star::uno::TypeClass_UNSIGNED_LONG == tc ) { + sal_uInt32 i32 = 0; + a >>= i32; + f = ( float ) i32; + } + else { + throw ::com::sun::star::lang::IllegalArgumentException(); + } +} + + +inline void SAL_CALL convertPropertyValue( double &d , const ::com::sun::star::uno::Any &a ) + SAL_THROW( (::com::sun::star::lang::IllegalArgumentException) ) +{ + const enum ::com::sun::star::uno::TypeClass tc = a.getValueType().getTypeClass(); + + if( ::com::sun::star::uno::TypeClass_DOUBLE == tc ) { + float f; + a >>= f; + d = ( double ) f; + } + else if ( ::com::sun::star::uno::TypeClass_FLOAT == tc ) { + float f; + a >>= f; + d = (double) f; + } + else if( ::com::sun::star::uno::TypeClass_HYPER == tc ) { + sal_Int64 i64; + a >>= i64; + d = (double) i64; + } + // msci 4 does not support this +/* else if( ::com::sun::star::uno::TypeClass_UNSIGNED_HYPER == tc ) { + sal_uInt64 i64; + a >>= i64; + d = (double) i64; + } +*/ else if( ::com::sun::star::uno::TypeClass_LONG == tc ) { + sal_Int32 i32; + a >>= i32; + d = (double)i32; + } + else if ( ::com::sun::star::uno::TypeClass_CHAR == tc ) { + sal_Unicode c; + c = *(sal_Unicode*) a.getValue(); + d = (double) c; + } + else if ( ::com::sun::star::uno::TypeClass_SHORT == tc ) { + sal_Int16 i16; + a >>= i16; + d = (double) i16; + } + else if ( ::com::sun::star::uno::TypeClass_BOOLEAN == tc ) { + sal_Bool b; + b = *((sal_Bool * )a.getValue()); + d = (double) b; + } + else if ( ::com::sun::star::uno::TypeClass_BYTE == tc ) { + sal_Int8 i8; + a >>= i8; + d = (double) i8; + } + else if ( ::com::sun::star::uno::TypeClass_UNSIGNED_SHORT == tc ) { + sal_uInt16 i16; + a >>= i16; + d = (double) i16; + } + else if ( ::com::sun::star::uno::TypeClass_UNSIGNED_LONG == tc ) { + sal_uInt32 i32; + a >>= i32; + d = (double) i32; + } + else { + throw ::com::sun::star::lang::IllegalArgumentException(); + } +} + +inline void SAL_CALL convertPropertyValue( ::rtl::OUString &ow , const ::com::sun::star::uno::Any &a ) + SAL_THROW( (::com::sun::star::lang::IllegalArgumentException) ) +{ + if( ::com::sun::star::uno::TypeClass_STRING == a.getValueType().getTypeClass() ) { + a >>= ow; + } + else { + throw ::com::sun::star::lang::IllegalArgumentException(); + } +} + +} // end namespace cppu + +#endif + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/inc/cppuhelper/queryinterface.hxx b/cppuhelper/inc/cppuhelper/queryinterface.hxx new file mode 100644 index 000000000000..4efc77ae88a9 --- /dev/null +++ b/cppuhelper/inc/cppuhelper/queryinterface.hxx @@ -0,0 +1,543 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _CPPUHELPER_QUERYINTERFACE_HXX_ +#define _CPPUHELPER_QUERYINTERFACE_HXX_ + +#include "sal/config.h" +#include "com/sun/star/uno/Any.hxx" +#include "com/sun/star/uno/Type.hxx" +#include "sal/types.h" + +namespace cppu +{ + +/** Compares demanded type to given template argument types. + + @tplparam Interface1 interface type + @param rType demanded type + @param p1 interface pointer + @return acquired interface of demanded type or empty Any +*/ +template< class Interface1 > +inline ::com::sun::star::uno::Any SAL_CALL queryInterface( + const ::com::sun::star::uno::Type & rType, + Interface1 * p1 ) + SAL_THROW( () ) +{ + if (rType == Interface1::static_type()) + return ::com::sun::star::uno::Any( &p1, rType ); + else + return ::com::sun::star::uno::Any(); +} +/** Compares demanded type to given template argument types. + + @tplparam Interface1 interface type + @tplparam Interface2 interface type + @param rType demanded type + @param p1 interface pointer + @param p2 interface pointer + @return acquired interface of demanded type or empty Any +*/ +template< class Interface1, class Interface2 > +inline ::com::sun::star::uno::Any SAL_CALL queryInterface( + const ::com::sun::star::uno::Type & rType, + Interface1 * p1, Interface2 * p2 ) + SAL_THROW( () ) +{ + if (rType == Interface1::static_type()) + return ::com::sun::star::uno::Any( &p1, rType ); + else if (rType == Interface2::static_type()) + return ::com::sun::star::uno::Any( &p2, rType ); + else + return ::com::sun::star::uno::Any(); +} +/** Compares demanded type to given template argument types. + + @tplparam Interface1 interface type + @tplparam Interface2 interface type + @tplparam Interface3 interface type + @param rType demanded type + @param p1 interface pointer + @param p2 interface pointer + @param p3 interface pointer + @return acquired interface of demanded type or empty Any +*/ +template< class Interface1, class Interface2, class Interface3 > +inline ::com::sun::star::uno::Any SAL_CALL queryInterface( + const ::com::sun::star::uno::Type & rType, + Interface1 * p1, Interface2 * p2, Interface3 * p3 ) + SAL_THROW( () ) +{ + if (rType == Interface1::static_type()) + return ::com::sun::star::uno::Any( &p1, rType ); + else if (rType == Interface2::static_type()) + return ::com::sun::star::uno::Any( &p2, rType ); + else if (rType == Interface3::static_type()) + return ::com::sun::star::uno::Any( &p3, rType ); + else + return ::com::sun::star::uno::Any(); +} +/** Compares demanded type to given template argument types. + + @tplparam Interface1 interface type + @tplparam Interface2 interface type + @tplparam Interface3 interface type + @tplparam Interface4 interface type + @param rType demanded type + @param p1 interface pointer + @param p2 interface pointer + @param p3 interface pointer + @param p4 interface pointer + @return acquired interface of demanded type or empty Any +*/ +template< class Interface1, class Interface2, class Interface3, class Interface4 > +inline ::com::sun::star::uno::Any SAL_CALL queryInterface( + const ::com::sun::star::uno::Type & rType, + Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4 ) + SAL_THROW( () ) +{ + if (rType == Interface1::static_type()) + return ::com::sun::star::uno::Any( &p1, rType ); + else if (rType == Interface2::static_type()) + return ::com::sun::star::uno::Any( &p2, rType ); + else if (rType == Interface3::static_type()) + return ::com::sun::star::uno::Any( &p3, rType ); + else if (rType == Interface4::static_type()) + return ::com::sun::star::uno::Any( &p4, rType ); + else + return ::com::sun::star::uno::Any(); +} +/** Compares demanded type to given template argument types. + + @tplparam Interface1 interface type + @tplparam Interface2 interface type + @tplparam Interface3 interface type + @tplparam Interface4 interface type + @tplparam Interface5 interface type + @param rType demanded type + @param p1 interface pointer + @param p2 interface pointer + @param p3 interface pointer + @param p4 interface pointer + @param p5 interface pointer + @return acquired interface of demanded type or empty Any +*/ +template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5 > +inline ::com::sun::star::uno::Any SAL_CALL queryInterface( + const ::com::sun::star::uno::Type & rType, + Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5 ) + SAL_THROW( () ) +{ + if (rType == Interface1::static_type()) + return ::com::sun::star::uno::Any( &p1, rType ); + else if (rType == Interface2::static_type()) + return ::com::sun::star::uno::Any( &p2, rType ); + else if (rType == Interface3::static_type()) + return ::com::sun::star::uno::Any( &p3, rType ); + else if (rType == Interface4::static_type()) + return ::com::sun::star::uno::Any( &p4, rType ); + else if (rType == Interface5::static_type()) + return ::com::sun::star::uno::Any( &p5, rType ); + else + return ::com::sun::star::uno::Any(); +} +/** Compares demanded type to given template argument types. + + @tplparam Interface1 interface type + @tplparam Interface2 interface type + @tplparam Interface3 interface type + @tplparam Interface4 interface type + @tplparam Interface5 interface type + @tplparam Interface6 interface type + @param rType demanded type + @param p1 interface pointer + @param p2 interface pointer + @param p3 interface pointer + @param p4 interface pointer + @param p5 interface pointer + @param p6 interface pointer + @return acquired interface of demanded type or empty Any +*/ +template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5, + class Interface6 > +inline ::com::sun::star::uno::Any SAL_CALL queryInterface( + const ::com::sun::star::uno::Type & rType, + Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5, + Interface6 * p6 ) + SAL_THROW( () ) +{ + if (rType == Interface1::static_type()) + return ::com::sun::star::uno::Any( &p1, rType ); + else if (rType == Interface2::static_type()) + return ::com::sun::star::uno::Any( &p2, rType ); + else if (rType == Interface3::static_type()) + return ::com::sun::star::uno::Any( &p3, rType ); + else if (rType == Interface4::static_type()) + return ::com::sun::star::uno::Any( &p4, rType ); + else if (rType == Interface5::static_type()) + return ::com::sun::star::uno::Any( &p5, rType ); + else if (rType == Interface6::static_type()) + return ::com::sun::star::uno::Any( &p6, rType ); + else + return ::com::sun::star::uno::Any(); +} +/** Compares demanded type to given template argument types. + + @tplparam Interface1 interface type + @tplparam Interface2 interface type + @tplparam Interface3 interface type + @tplparam Interface4 interface type + @tplparam Interface5 interface type + @tplparam Interface6 interface type + @tplparam Interface7 interface type + @param rType demanded type + @param p1 interface pointer + @param p2 interface pointer + @param p3 interface pointer + @param p4 interface pointer + @param p5 interface pointer + @param p6 interface pointer + @param p7 interface pointer + @return acquired interface of demanded type or empty Any +*/ +template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5, + class Interface6, class Interface7 > +inline ::com::sun::star::uno::Any SAL_CALL queryInterface( + const ::com::sun::star::uno::Type & rType, + Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5, + Interface6 * p6, Interface7 * p7 ) + SAL_THROW( () ) +{ + if (rType == Interface1::static_type()) + return ::com::sun::star::uno::Any( &p1, rType ); + else if (rType == Interface2::static_type()) + return ::com::sun::star::uno::Any( &p2, rType ); + else if (rType == Interface3::static_type()) + return ::com::sun::star::uno::Any( &p3, rType ); + else if (rType == Interface4::static_type()) + return ::com::sun::star::uno::Any( &p4, rType ); + else if (rType == Interface5::static_type()) + return ::com::sun::star::uno::Any( &p5, rType ); + else if (rType == Interface6::static_type()) + return ::com::sun::star::uno::Any( &p6, rType ); + else if (rType == Interface7::static_type()) + return ::com::sun::star::uno::Any( &p7, rType ); + else + return ::com::sun::star::uno::Any(); +} +/** Compares demanded type to given template argument types. + + @tplparam Interface1 interface type + @tplparam Interface2 interface type + @tplparam Interface3 interface type + @tplparam Interface4 interface type + @tplparam Interface5 interface type + @tplparam Interface6 interface type + @tplparam Interface7 interface type + @tplparam Interface8 interface type + @param rType demanded type + @param p1 interface pointer + @param p2 interface pointer + @param p3 interface pointer + @param p4 interface pointer + @param p5 interface pointer + @param p6 interface pointer + @param p7 interface pointer + @param p8 interface pointer + @return acquired interface of demanded type or empty Any +*/ +template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5, + class Interface6, class Interface7, class Interface8 > +inline ::com::sun::star::uno::Any SAL_CALL queryInterface( + const ::com::sun::star::uno::Type & rType, + Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5, + Interface6 * p6, Interface7 * p7, Interface8 * p8 ) + SAL_THROW( () ) +{ + if (rType == Interface1::static_type()) + return ::com::sun::star::uno::Any( &p1, rType ); + else if (rType == Interface2::static_type()) + return ::com::sun::star::uno::Any( &p2, rType ); + else if (rType == Interface3::static_type()) + return ::com::sun::star::uno::Any( &p3, rType ); + else if (rType == Interface4::static_type()) + return ::com::sun::star::uno::Any( &p4, rType ); + else if (rType == Interface5::static_type()) + return ::com::sun::star::uno::Any( &p5, rType ); + else if (rType == Interface6::static_type()) + return ::com::sun::star::uno::Any( &p6, rType ); + else if (rType == Interface7::static_type()) + return ::com::sun::star::uno::Any( &p7, rType ); + else if (rType == Interface8::static_type()) + return ::com::sun::star::uno::Any( &p8, rType ); + else + return ::com::sun::star::uno::Any(); +} +/** Compares demanded type to given template argument types. + + @tplparam Interface1 interface type + @tplparam Interface2 interface type + @tplparam Interface3 interface type + @tplparam Interface4 interface type + @tplparam Interface5 interface type + @tplparam Interface6 interface type + @tplparam Interface7 interface type + @tplparam Interface8 interface type + @tplparam Interface9 interface type + @param rType demanded type + @param p1 interface pointer + @param p2 interface pointer + @param p3 interface pointer + @param p4 interface pointer + @param p5 interface pointer + @param p6 interface pointer + @param p7 interface pointer + @param p8 interface pointer + @param p9 interface pointer + @return acquired interface of demanded type or empty Any +*/ +template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5, + class Interface6, class Interface7, class Interface8, class Interface9 > +inline ::com::sun::star::uno::Any SAL_CALL queryInterface( + const ::com::sun::star::uno::Type & rType, + Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5, + Interface6 * p6, Interface7 * p7, Interface8 * p8, Interface9 * p9 ) + SAL_THROW( () ) +{ + if (rType == Interface1::static_type()) + return ::com::sun::star::uno::Any( &p1, rType ); + else if (rType == Interface2::static_type()) + return ::com::sun::star::uno::Any( &p2, rType ); + else if (rType == Interface3::static_type()) + return ::com::sun::star::uno::Any( &p3, rType ); + else if (rType == Interface4::static_type()) + return ::com::sun::star::uno::Any( &p4, rType ); + else if (rType == Interface5::static_type()) + return ::com::sun::star::uno::Any( &p5, rType ); + else if (rType == Interface6::static_type()) + return ::com::sun::star::uno::Any( &p6, rType ); + else if (rType == Interface7::static_type()) + return ::com::sun::star::uno::Any( &p7, rType ); + else if (rType == Interface8::static_type()) + return ::com::sun::star::uno::Any( &p8, rType ); + else if (rType == Interface9::static_type()) + return ::com::sun::star::uno::Any( &p9, rType ); + else + return ::com::sun::star::uno::Any(); +} +/** Compares demanded type to given template argument types. + + @tplparam Interface1 interface type + @tplparam Interface2 interface type + @tplparam Interface3 interface type + @tplparam Interface4 interface type + @tplparam Interface5 interface type + @tplparam Interface6 interface type + @tplparam Interface7 interface type + @tplparam Interface8 interface type + @tplparam Interface9 interface type + @tplparam Interface10 interface type + @param rType demanded type + @param p1 interface pointer + @param p2 interface pointer + @param p3 interface pointer + @param p4 interface pointer + @param p5 interface pointer + @param p6 interface pointer + @param p7 interface pointer + @param p8 interface pointer + @param p9 interface pointer + @param p10 interface pointer + @return acquired interface of demanded type or empty Any +*/ +template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5, + class Interface6, class Interface7, class Interface8, class Interface9, class Interface10 > +inline ::com::sun::star::uno::Any SAL_CALL queryInterface( + const ::com::sun::star::uno::Type & rType, + Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5, + Interface6 * p6, Interface7 * p7, Interface8 * p8, Interface9 * p9, Interface10 * p10 ) + SAL_THROW( () ) +{ + if (rType == Interface1::static_type()) + return ::com::sun::star::uno::Any( &p1, rType ); + else if (rType == Interface2::static_type()) + return ::com::sun::star::uno::Any( &p2, rType ); + else if (rType == Interface3::static_type()) + return ::com::sun::star::uno::Any( &p3, rType ); + else if (rType == Interface4::static_type()) + return ::com::sun::star::uno::Any( &p4, rType ); + else if (rType == Interface5::static_type()) + return ::com::sun::star::uno::Any( &p5, rType ); + else if (rType == Interface6::static_type()) + return ::com::sun::star::uno::Any( &p6, rType ); + else if (rType == Interface7::static_type()) + return ::com::sun::star::uno::Any( &p7, rType ); + else if (rType == Interface8::static_type()) + return ::com::sun::star::uno::Any( &p8, rType ); + else if (rType == Interface9::static_type()) + return ::com::sun::star::uno::Any( &p9, rType ); + else if (rType == Interface10::static_type()) + return ::com::sun::star::uno::Any( &p10, rType ); + else + return ::com::sun::star::uno::Any(); +} +/** Compares demanded type to given template argument types. + + @tplparam Interface1 interface type + @tplparam Interface2 interface type + @tplparam Interface3 interface type + @tplparam Interface4 interface type + @tplparam Interface5 interface type + @tplparam Interface6 interface type + @tplparam Interface7 interface type + @tplparam Interface8 interface type + @tplparam Interface9 interface type + @tplparam Interface10 interface type + @tplparam Interface11 interface type + @param rType demanded type + @param p1 interface pointer + @param p2 interface pointer + @param p3 interface pointer + @param p4 interface pointer + @param p5 interface pointer + @param p6 interface pointer + @param p7 interface pointer + @param p8 interface pointer + @param p9 interface pointer + @param p10 interface pointer + @param p11 interface pointer + @return acquired interface of demanded type or empty Any +*/ +template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5, + class Interface6, class Interface7, class Interface8, class Interface9, class Interface10, + class Interface11 > +inline ::com::sun::star::uno::Any SAL_CALL queryInterface( + const ::com::sun::star::uno::Type & rType, + Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5, + Interface6 * p6, Interface7 * p7, Interface8 * p8, Interface9 * p9, Interface10 * p10, + Interface11 * p11 ) + SAL_THROW( () ) +{ + if (rType == Interface1::static_type()) + return ::com::sun::star::uno::Any( &p1, rType ); + else if (rType == Interface2::static_type()) + return ::com::sun::star::uno::Any( &p2, rType ); + else if (rType == Interface3::static_type()) + return ::com::sun::star::uno::Any( &p3, rType ); + else if (rType == Interface4::static_type()) + return ::com::sun::star::uno::Any( &p4, rType ); + else if (rType == Interface5::static_type()) + return ::com::sun::star::uno::Any( &p5, rType ); + else if (rType == Interface6::static_type()) + return ::com::sun::star::uno::Any( &p6, rType ); + else if (rType == Interface7::static_type()) + return ::com::sun::star::uno::Any( &p7, rType ); + else if (rType == Interface8::static_type()) + return ::com::sun::star::uno::Any( &p8, rType ); + else if (rType == Interface9::static_type()) + return ::com::sun::star::uno::Any( &p9, rType ); + else if (rType == Interface10::static_type()) + return ::com::sun::star::uno::Any( &p10, rType ); + else if (rType == Interface11::static_type()) + return ::com::sun::star::uno::Any( &p11, rType ); + else + return ::com::sun::star::uno::Any(); +} +/** Compares demanded type to given template argument types. + + @tplparam Interface1 interface type + @tplparam Interface2 interface type + @tplparam Interface3 interface type + @tplparam Interface4 interface type + @tplparam Interface5 interface type + @tplparam Interface6 interface type + @tplparam Interface7 interface type + @tplparam Interface8 interface type + @tplparam Interface9 interface type + @tplparam Interface10 interface type + @tplparam Interface11 interface type + @tplparam Interface12 interface type + @param rType demanded type + @param p1 interface pointer + @param p2 interface pointer + @param p3 interface pointer + @param p4 interface pointer + @param p5 interface pointer + @param p6 interface pointer + @param p7 interface pointer + @param p8 interface pointer + @param p9 interface pointer + @param p10 interface pointer + @param p11 interface pointer + @param p12 interface pointer + @return acquired interface of demanded type or empty Any +*/ +template< class Interface1, class Interface2, class Interface3, class Interface4, class Interface5, + class Interface6, class Interface7, class Interface8, class Interface9, class Interface10, + class Interface11, class Interface12 > +inline ::com::sun::star::uno::Any SAL_CALL queryInterface( + const ::com::sun::star::uno::Type & rType, + Interface1 * p1, Interface2 * p2, Interface3 * p3, Interface4 * p4, Interface5 * p5, + Interface6 * p6, Interface7 * p7, Interface8 * p8, Interface9 * p9, Interface10 * p10, + Interface11 * p11, Interface12 * p12 ) + SAL_THROW( () ) +{ + if (rType == Interface1::static_type()) + return ::com::sun::star::uno::Any( &p1, rType ); + else if (rType == Interface2::static_type()) + return ::com::sun::star::uno::Any( &p2, rType ); + else if (rType == Interface3::static_type()) + return ::com::sun::star::uno::Any( &p3, rType ); + else if (rType == Interface4::static_type()) + return ::com::sun::star::uno::Any( &p4, rType ); + else if (rType == Interface5::static_type()) + return ::com::sun::star::uno::Any( &p5, rType ); + else if (rType == Interface6::static_type()) + return ::com::sun::star::uno::Any( &p6, rType ); + else if (rType == Interface7::static_type()) + return ::com::sun::star::uno::Any( &p7, rType ); + else if (rType == Interface8::static_type()) + return ::com::sun::star::uno::Any( &p8, rType ); + else if (rType == Interface9::static_type()) + return ::com::sun::star::uno::Any( &p9, rType ); + else if (rType == Interface10::static_type()) + return ::com::sun::star::uno::Any( &p10, rType ); + else if (rType == Interface11::static_type()) + return ::com::sun::star::uno::Any( &p11, rType ); + else if (rType == Interface12::static_type()) + return ::com::sun::star::uno::Any( &p12, rType ); + else + return ::com::sun::star::uno::Any(); +} + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/inc/cppuhelper/servicefactory.hxx b/cppuhelper/inc/cppuhelper/servicefactory.hxx new file mode 100644 index 000000000000..bdf9f9e6bce7 --- /dev/null +++ b/cppuhelper/inc/cppuhelper/servicefactory.hxx @@ -0,0 +1,124 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CPPUHELPER_SERVICEFACTORY_HXX_ +#define _CPPUHELPER_SERVICEFACTORY_HXX_ + +#include <rtl/ustring.hxx> + +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/lang/XMultiComponentFactory.hpp> + + +namespace cppu +{ + +/** Deprecated. Use cppuhelper/bootstrap.hxx functions instead. + + This bootstraps an initial service factory working on a registry. If the first or both + parameters contain a value then the service factory is initialized with a simple registry + or a nested registry. Otherwise the service factory must be initialized later with a valid + registry. + + @param rWriteRegistryFile + file name of the simple registry or the first registry file of + the nested registry which will be opened with read/write rights. This + file will be created if necessary. + @param rReadRegistryFile + file name of the second registry file of the nested registry + which will be opened with readonly rights. + @param bReadOnly + flag which specify that the first registry file will be opened with + readonly rights. Default is FALSE. If this flag is used the registry + will not be created if not exist. + @param rBootstrapPath + specifies a path where the bootstrap components could be find. If this + parameter is an empty string the compoents will be searched in the system + path. + @deprecated +*/ +::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > SAL_CALL +createRegistryServiceFactory( + const ::rtl::OUString & rWriteRegistryFile, + const ::rtl::OUString & rReadRegistryFile, + sal_Bool bReadOnly = sal_False, + const ::rtl::OUString & rBootstrapPath = ::rtl::OUString() ) + SAL_THROW( (::com::sun::star::uno::Exception) ); + + +/** Deprecated. Use cppuhelper/bootstrap.hxx functions instead. + + This bootstraps an initial service factory working on a registry file. + + @param rRegistryFile + file name of the registry to use/ create; if this is an empty + string, the default registry is used instead + @param bReadOnly + flag which specify that the registry file will be opened with + readonly rights. Default is FALSE. If this flag is used the registry + will not be created if not exist. + @param rBootstrapPath + specifies a path where the bootstrap components could be find. If this + parameter is an empty string the compoents will be searched in the system + path. + @deprecated +*/ +inline ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > SAL_CALL +createRegistryServiceFactory( + const ::rtl::OUString & rRegistryFile, + sal_Bool bReadOnly = sal_False, + const ::rtl::OUString & rBootstrapPath = ::rtl::OUString() ) + SAL_THROW( (::com::sun::star::uno::Exception) ) +{ + return ::cppu::createRegistryServiceFactory( + rRegistryFile, ::rtl::OUString(), bReadOnly, rBootstrapPath ); +} + +/** Deprecated. Use cppuhelper/bootstrap.hxx functions instead. + + This bootstraps a service factory without initialize a registry. + + @param rBootstrapPath + specifies a path where the bootstrap components could be find. If this + parameter is an empty string the compoents will be searched in the system + path. + @deprecated +*/ +inline ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > SAL_CALL +createServiceFactory( + const ::rtl::OUString & rBootstrapPath = ::rtl::OUString() ) + SAL_THROW( (::com::sun::star::uno::Exception) ) +{ + return ::cppu::createRegistryServiceFactory( + ::rtl::OUString(), ::rtl::OUString(), sal_False, rBootstrapPath ); +} + +} // end namespace cppu + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/inc/cppuhelper/shlib.hxx b/cppuhelper/inc/cppuhelper/shlib.hxx new file mode 100644 index 000000000000..a4f52ca94eb5 --- /dev/null +++ b/cppuhelper/inc/cppuhelper/shlib.hxx @@ -0,0 +1,85 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CPPUHELPER_SHLIB_HXX_ +#define _CPPUHELPER_SHLIB_HXX_ + +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/registry/XRegistryKey.hpp> +#include <com/sun/star/loader/CannotActivateFactoryException.hpp> +#include <com/sun/star/registry/CannotRegisterImplementationException.hpp> + + +namespace cppu +{ + +/** Loads a shared library component and gets the factory out of it. You can give either a + fully qualified libname or single lib name. The libname need not be pre/postfixed + (e.g. xxx.dll). You can give parameter rPath to force lookup of the library in a specific + directory. The resulting path of the library will be checked against environment variable + CPLD_ACCESSPATH if set. + + @param rLibName name of the library + @param rPath optional path + @param rImplName implementation to be retrieved from the library + @param xMgr service manager to be provided to the component + @param xKey registry key to be provided to the component + @return + factory instance (::com::sun::star::lang::XSingleComponentFactory or + ::com::sun::star::lang::XSingleComponentFactory) +*/ +::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > +SAL_CALL loadSharedLibComponentFactory( + ::rtl::OUString const & rLibName, ::rtl::OUString const & rPath, + ::rtl::OUString const & rImplName, + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > const & xMgr, + ::com::sun::star::uno::Reference< ::com::sun::star::registry::XRegistryKey > const & xKey ) + SAL_THROW( (::com::sun::star::loader::CannotActivateFactoryException) ); + +/** Invokes component_writeInfo() function of specified component library. You can give either + a fully qualified libname or single lib name. The libname need not be pre/postfixed + (e.g. xxx.dll). You can give parameter rPath to force lookup of the library in a specific + directory. The resulting path of the library will be checked against environment variable + CPLD_ACCESSPATH if set. + + @param rLibName name of the library + @param rPath optional path + @param xMgr service manager to be provided to the component + @param xKey registry key to be provided to the component +*/ +void +SAL_CALL writeSharedLibComponentInfo( + ::rtl::OUString const & rLibName, ::rtl::OUString const & rPath, + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > const & xMgr, + ::com::sun::star::uno::Reference< ::com::sun::star::registry::XRegistryKey > const & xKey ) + SAL_THROW( (::com::sun::star::registry::CannotRegisterImplementationException) ); + +} // end namespace cppu + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/inc/cppuhelper/stdidlclass.hxx b/cppuhelper/inc/cppuhelper/stdidlclass.hxx new file mode 100644 index 000000000000..576378b104b7 --- /dev/null +++ b/cppuhelper/inc/cppuhelper/stdidlclass.hxx @@ -0,0 +1,392 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CPPUHELPER_STDIDLCLASS_HXX_ +#define _CPPUHELPER_STDIDLCLASS_HXX_ + +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/reflection/XIdlClass.hpp> + + +namespace cppu { + +/* + @deprecated +*/ +::com::sun::star::reflection::XIdlClass * SAL_CALL createStandardClassWithSequence( + const ::com::sun::star::uno::Reference < ::com::sun::star::lang::XMultiServiceFactory > &rSMgr , + const ::rtl::OUString & sImplementationName , + const ::com::sun::star::uno::Reference < ::com::sun::star::reflection::XIdlClass > & rSuperClass, + const ::com::sun::star::uno::Sequence < ::rtl::OUString > &seq ) + SAL_THROW( () ); + + + +/** + Standard function to create an XIdlClass for a component. + There is a function for each number of supported interfaces up to 10. + + Since the switch to the final component model, there are no use cases anymore where + these functions should be used. Instead use the implementation helpers directly + (see cppuhelper/implbase1.hxx). + + @see OTypeCollection + + @deprecated + */ +template < class Interface1 > +inline ::com::sun::star::reflection::XIdlClass * SAL_CALL +//inline ::com::sun::star::uno::Reference < ::com::sun::star::reflection::XIdlClass > +createStandardClass( const ::com::sun::star::uno::Reference < ::com::sun::star::lang::XMultiServiceFactory > &rSMgr, + const ::rtl::OUString &sImplementationName , + const ::com::sun::star::uno::Reference < ::com::sun::star::reflection::XIdlClass > &rSuperClass , + const Interface1 * + ) + SAL_THROW( () ) +{ + ::com::sun::star::uno::Sequence < ::rtl::OUString > seqInterface(1); + seqInterface.getArray()[0] = Interface1::static_type().getTypeName(); + return createStandardClassWithSequence( + rSMgr, + sImplementationName, + rSuperClass, + seqInterface + ); +} + + + +template < class Interface1, class Interface2 > +inline ::com::sun::star::reflection::XIdlClass * SAL_CALL +//inline ::com::sun::star::uno::Reference < ::com::sun::star::reflection::XIdlClass > +createStandardClass( const ::com::sun::star::uno::Reference < ::com::sun::star::lang::XMultiServiceFactory > &rSMgr, + const ::rtl::OUString &sImplementationName , + const ::com::sun::star::uno::Reference < ::com::sun::star::reflection::XIdlClass > &rSuperClass , + const Interface1 *, + const Interface2 * + ) + SAL_THROW( () ) +{ + ::com::sun::star::uno::Sequence < ::rtl::OUString > seqInterface(2); + seqInterface.getArray()[0] = Interface1::static_type().getTypeName(); + seqInterface.getArray()[1] = Interface2::static_type().getTypeName(); + return createStandardClassWithSequence( + rSMgr, + sImplementationName, + rSuperClass, + seqInterface + ); +} + + + + + +template < class Interface1, class Interface2 , class Interface3 > +inline ::com::sun::star::reflection::XIdlClass * SAL_CALL +//inline ::com::sun::star::uno::Reference < ::com::sun::star::reflection::XIdlClass > +createStandardClass( const ::com::sun::star::uno::Reference < ::com::sun::star::lang::XMultiServiceFactory > &rSMgr, + const ::rtl::OUString &sImplementationName , + const ::com::sun::star::uno::Reference < ::com::sun::star::reflection::XIdlClass > &rSuperClass , + const Interface1 *, + const Interface2 *, + const Interface3 * + ) + SAL_THROW( () ) +{ + ::com::sun::star::uno::Sequence < ::rtl::OUString > seqInterface(3); + seqInterface.getArray()[0] = Interface1::static_type().getTypeName(); + seqInterface.getArray()[1] = Interface2::static_type().getTypeName(); + seqInterface.getArray()[2] = Interface3::static_type().getTypeName(); + return createStandardClassWithSequence( + rSMgr, + sImplementationName, + rSuperClass, + seqInterface + ); +} + + + + + +template < class Interface1, class Interface2 , class Interface3 , class Interface4 > +inline ::com::sun::star::reflection::XIdlClass * SAL_CALL +//inline ::com::sun::star::uno::Reference < ::com::sun::star::reflection::XIdlClass > +createStandardClass( const ::com::sun::star::uno::Reference < ::com::sun::star::lang::XMultiServiceFactory > &rSMgr, + const ::rtl::OUString &sImplementationName , + const ::com::sun::star::uno::Reference < ::com::sun::star::reflection::XIdlClass > &rSuperClass , + const Interface1 *, + const Interface2 *, + const Interface3 *, + const Interface4 * + ) + SAL_THROW( () ) +{ + ::com::sun::star::uno::Sequence < ::rtl::OUString > seqInterface(4); + seqInterface.getArray()[0] = Interface1::static_type().getTypeName(); + seqInterface.getArray()[1] = Interface2::static_type().getTypeName(); + seqInterface.getArray()[2] = Interface3::static_type().getTypeName(); + seqInterface.getArray()[3] = Interface4::static_type().getTypeName(); + return createStandardClassWithSequence( + rSMgr, + sImplementationName, + rSuperClass, + seqInterface + ); +} + + + + + + + +template < class Interface1, class Interface2 , class Interface3 , class Interface4 , class Interface5 > +inline ::com::sun::star::reflection::XIdlClass * SAL_CALL +//inline ::com::sun::star::uno::Reference < ::com::sun::star::reflection::XIdlClass > +createStandardClass( const ::com::sun::star::uno::Reference < ::com::sun::star::lang::XMultiServiceFactory > &rSMgr, + const ::rtl::OUString &sImplementationName , + const ::com::sun::star::uno::Reference < ::com::sun::star::reflection::XIdlClass > &rSuperClass , + const Interface1 *, + const Interface2 *, + const Interface3 *, + const Interface4 *, + const Interface5 * + ) + SAL_THROW( () ) +{ + ::com::sun::star::uno::Sequence < ::rtl::OUString > seqInterface(5); + seqInterface.getArray()[0] = Interface1::static_type().getTypeName(); + seqInterface.getArray()[1] = Interface2::static_type().getTypeName(); + seqInterface.getArray()[2] = Interface3::static_type().getTypeName(); + seqInterface.getArray()[3] = Interface4::static_type().getTypeName(); + seqInterface.getArray()[4] = Interface5::static_type().getTypeName(); + return createStandardClassWithSequence( + rSMgr, + sImplementationName, + rSuperClass, + seqInterface + ); +} + + + + +template < class Interface1, class Interface2 , class Interface3 , class Interface4 , class Interface5 , + class Interface6 > +inline ::com::sun::star::reflection::XIdlClass * SAL_CALL +//inline ::com::sun::star::uno::Reference < ::com::sun::star::reflection::XIdlClass > +createStandardClass( const ::com::sun::star::uno::Reference < ::com::sun::star::lang::XMultiServiceFactory > &rSMgr, + const ::rtl::OUString &sImplementationName , + const ::com::sun::star::uno::Reference < ::com::sun::star::reflection::XIdlClass > &rSuperClass , + const Interface1 *, + const Interface2 *, + const Interface3 *, + const Interface4 *, + const Interface5 *, + const Interface6 * + ) + SAL_THROW( () ) +{ + ::com::sun::star::uno::Sequence < ::rtl::OUString > seqInterface(6); + seqInterface.getArray()[0] = Interface1::static_type().getTypeName(); + seqInterface.getArray()[1] = Interface2::static_type().getTypeName(); + seqInterface.getArray()[2] = Interface3::static_type().getTypeName(); + seqInterface.getArray()[3] = Interface4::static_type().getTypeName(); + seqInterface.getArray()[4] = Interface5::static_type().getTypeName(); + seqInterface.getArray()[5] = Interface6::static_type().getTypeName(); + return createStandardClassWithSequence( + rSMgr, + sImplementationName, + rSuperClass, + seqInterface + ); +} + + + + + +template < class Interface1, class Interface2 , class Interface3 , class Interface4 , class Interface5 , + class Interface6, class Interface7 > +inline ::com::sun::star::reflection::XIdlClass * SAL_CALL +//inline ::com::sun::star::uno::Reference < ::com::sun::star::reflection::XIdlClass > +createStandardClass( const ::com::sun::star::uno::Reference < ::com::sun::star::lang::XMultiServiceFactory > &rSMgr, + const ::rtl::OUString &sImplementationName , + const ::com::sun::star::uno::Reference < ::com::sun::star::reflection::XIdlClass > &rSuperClass , + const Interface1 *, + const Interface2 *, + const Interface3 *, + const Interface4 *, + const Interface5 *, + const Interface6 *, + const Interface7 * + ) + SAL_THROW( () ) +{ + ::com::sun::star::uno::Sequence < ::rtl::OUString > seqInterface(7); + seqInterface.getArray()[0] = Interface1::static_type().getTypeName(); + seqInterface.getArray()[1] = Interface2::static_type().getTypeName(); + seqInterface.getArray()[2] = Interface3::static_type().getTypeName(); + seqInterface.getArray()[3] = Interface4::static_type().getTypeName(); + seqInterface.getArray()[4] = Interface5::static_type().getTypeName(); + seqInterface.getArray()[5] = Interface6::static_type().getTypeName(); + seqInterface.getArray()[6] = Interface7::static_type().getTypeName(); + return createStandardClassWithSequence( + rSMgr, + sImplementationName, + rSuperClass, + seqInterface + ); +} + + + + + + +template < class Interface1, class Interface2, class Interface3 , class Interface4 , class Interface5 , + class Interface6, class Interface7, class Interface8 > +inline ::com::sun::star::reflection::XIdlClass * SAL_CALL +//inline ::com::sun::star::uno::Reference < ::com::sun::star::reflection::XIdlClass > +createStandardClass( const ::com::sun::star::uno::Reference < ::com::sun::star::lang::XMultiServiceFactory > &rSMgr, + const ::rtl::OUString &sImplementationName , + const ::com::sun::star::uno::Reference < ::com::sun::star::reflection::XIdlClass > &rSuperClass , + const Interface1 *, + const Interface2 *, + const Interface3 *, + const Interface4 *, + const Interface5 *, + const Interface6 *, + const Interface7 *, + const Interface8 * + ) + SAL_THROW( () ) +{ + ::com::sun::star::uno::Sequence < ::rtl::OUString > seqInterface(8); + seqInterface.getArray()[0] = Interface1::static_type().getTypeName(); + seqInterface.getArray()[1] = Interface2::static_type().getTypeName(); + seqInterface.getArray()[2] = Interface3::static_type().getTypeName(); + seqInterface.getArray()[3] = Interface4::static_type().getTypeName(); + seqInterface.getArray()[4] = Interface5::static_type().getTypeName(); + seqInterface.getArray()[5] = Interface6::static_type().getTypeName(); + seqInterface.getArray()[6] = Interface7::static_type().getTypeName(); + seqInterface.getArray()[7] = Interface8::static_type().getTypeName(); + return createStandardClassWithSequence( + rSMgr, + sImplementationName, + rSuperClass, + seqInterface + ); +} + + + + +template < class Interface1, class Interface2, class Interface3 , class Interface4 , class Interface5 , + class Interface6, class Interface7, class Interface8 , class Interface9 > +inline ::com::sun::star::reflection::XIdlClass * SAL_CALL +//inline ::com::sun::star::uno::Reference < ::com::sun::star::reflection::XIdlClass > +createStandardClass( const ::com::sun::star::uno::Reference < ::com::sun::star::lang::XMultiServiceFactory > &rSMgr, + const ::rtl::OUString &sImplementationName , + const ::com::sun::star::uno::Reference < ::com::sun::star::reflection::XIdlClass > &rSuperClass , + const Interface1 *, + const Interface2 *, + const Interface3 *, + const Interface4 *, + const Interface5 *, + const Interface6 *, + const Interface7 *, + const Interface8 *, + const Interface9 * + ) + SAL_THROW( () ) +{ + ::com::sun::star::uno::Sequence < ::rtl::OUString > seqInterface(9); + seqInterface.getArray()[0] = Interface1::static_type().getTypeName(); + seqInterface.getArray()[1] = Interface2::static_type().getTypeName(); + seqInterface.getArray()[2] = Interface3::static_type().getTypeName(); + seqInterface.getArray()[3] = Interface4::static_type().getTypeName(); + seqInterface.getArray()[4] = Interface5::static_type().getTypeName(); + seqInterface.getArray()[5] = Interface6::static_type().getTypeName(); + seqInterface.getArray()[6] = Interface7::static_type().getTypeName(); + seqInterface.getArray()[7] = Interface8::static_type().getTypeName(); + seqInterface.getArray()[8] = Interface9::static_type().getTypeName(); + return createStandardClassWithSequence( + rSMgr, + sImplementationName, + rSuperClass, + seqInterface + ); +} + + +template < class Interface1, class Interface2, class Interface3 , class Interface4 , class Interface5 , + class Interface6, class Interface7, class Interface8 , class Interface9 , class Interface10 > +inline ::com::sun::star::reflection::XIdlClass * SAL_CALL +//inline ::com::sun::star::uno::Reference < ::com::sun::star::reflection::XIdlClass > +createStandardClass( const ::com::sun::star::uno::Reference < ::com::sun::star::lang::XMultiServiceFactory > &rSMgr, + const ::rtl::OUString &sImplementationName , + const ::com::sun::star::uno::Reference < ::com::sun::star::reflection::XIdlClass > &rSuperClass , + const Interface1 *, + const Interface2 *, + const Interface3 *, + const Interface4 *, + const Interface5 *, + const Interface6 *, + const Interface7 *, + const Interface8 *, + const Interface9 *, + const Interface10 * + ) + SAL_THROW( () ) +{ + ::com::sun::star::uno::Sequence < ::rtl::OUString > seqInterface(10); + seqInterface.getArray()[0] = Interface1::static_type().getTypeName(); + seqInterface.getArray()[1] = Interface2::static_type().getTypeName(); + seqInterface.getArray()[2] = Interface3::static_type().getTypeName(); + seqInterface.getArray()[3] = Interface4::static_type().getTypeName(); + seqInterface.getArray()[4] = Interface5::static_type().getTypeName(); + seqInterface.getArray()[5] = Interface6::static_type().getTypeName(); + seqInterface.getArray()[6] = Interface7::static_type().getTypeName(); + seqInterface.getArray()[7] = Interface8::static_type().getTypeName(); + seqInterface.getArray()[8] = Interface9::static_type().getTypeName(); + seqInterface.getArray()[9] = Interface10::static_type().getTypeName(); + return createStandardClassWithSequence( + rSMgr, + sImplementationName, + rSuperClass, + seqInterface + ); +} + +} // end namespace cppu + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/inc/cppuhelper/typeprovider.hxx b/cppuhelper/inc/cppuhelper/typeprovider.hxx new file mode 100644 index 000000000000..4e01bb5ac80a --- /dev/null +++ b/cppuhelper/inc/cppuhelper/typeprovider.hxx @@ -0,0 +1,245 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_ +#define _CPPUHELPER_TYPEPROVIDER_HXX_ + +#include <rtl/alloc.h> +#include <rtl/uuid.h> +#include <com/sun/star/uno/Sequence.hxx> + + +namespace cppu +{ + +/** Helper class to implement ::com::sun::star::lang::XTypeProvider. Construct a static object + of this class with your UNO object's supported types. +*/ +class OTypeCollection +{ + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > _aTypes; + +public: + // these are here to force memory de/allocation to sal lib. + /** @internal */ + inline static void * SAL_CALL operator new( size_t nSize ) SAL_THROW( () ) + { return ::rtl_allocateMemory( nSize ); } + /** @internal */ + inline static void SAL_CALL operator delete( void * pMem ) SAL_THROW( () ) + { ::rtl_freeMemory( pMem ); } + /** @internal */ + inline static void * SAL_CALL operator new( size_t, void * pMem ) SAL_THROW( () ) + { return pMem; } + /** @internal */ + inline static void SAL_CALL operator delete( void *, void * ) SAL_THROW( () ) + {} + + inline OTypeCollection( const OTypeCollection & rCollection ) + SAL_THROW( () ) + : _aTypes( rCollection._aTypes ) + {} + OTypeCollection( + const ::com::sun::star::uno::Type & rType1, + const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > & rAddTypes = ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >() ) + SAL_THROW( () ); + OTypeCollection( + const ::com::sun::star::uno::Type & rType1, + const ::com::sun::star::uno::Type & rType2, + const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > & rAddTypes = ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >() ) + SAL_THROW( () ); + OTypeCollection( + const ::com::sun::star::uno::Type & rType1, + const ::com::sun::star::uno::Type & rType2, + const ::com::sun::star::uno::Type & rType3, + const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > & rAddTypes = ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >() ) + SAL_THROW( () ); + OTypeCollection( + const ::com::sun::star::uno::Type & rType1, + const ::com::sun::star::uno::Type & rType2, + const ::com::sun::star::uno::Type & rType3, + const ::com::sun::star::uno::Type & rType4, + const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > & rAddTypes = ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >() ) + SAL_THROW( () ); + OTypeCollection( + const ::com::sun::star::uno::Type & rType1, + const ::com::sun::star::uno::Type & rType2, + const ::com::sun::star::uno::Type & rType3, + const ::com::sun::star::uno::Type & rType4, + const ::com::sun::star::uno::Type & rType5, + const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > & rAddTypes = ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >() ) + SAL_THROW( () ); + OTypeCollection( + const ::com::sun::star::uno::Type & rType1, + const ::com::sun::star::uno::Type & rType2, + const ::com::sun::star::uno::Type & rType3, + const ::com::sun::star::uno::Type & rType4, + const ::com::sun::star::uno::Type & rType5, + const ::com::sun::star::uno::Type & rType6, + const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > & rAddTypes = ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >() ) + SAL_THROW( () ); + OTypeCollection( + const ::com::sun::star::uno::Type & rType1, + const ::com::sun::star::uno::Type & rType2, + const ::com::sun::star::uno::Type & rType3, + const ::com::sun::star::uno::Type & rType4, + const ::com::sun::star::uno::Type & rType5, + const ::com::sun::star::uno::Type & rType6, + const ::com::sun::star::uno::Type & rType7, + const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > & rAddTypes = ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >() ) + SAL_THROW( () ); + OTypeCollection( + const ::com::sun::star::uno::Type & rType1, + const ::com::sun::star::uno::Type & rType2, + const ::com::sun::star::uno::Type & rType3, + const ::com::sun::star::uno::Type & rType4, + const ::com::sun::star::uno::Type & rType5, + const ::com::sun::star::uno::Type & rType6, + const ::com::sun::star::uno::Type & rType7, + const ::com::sun::star::uno::Type & rType8, + const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > & rAddTypes = ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >() ) + SAL_THROW( () ); + OTypeCollection( + const ::com::sun::star::uno::Type & rType1, + const ::com::sun::star::uno::Type & rType2, + const ::com::sun::star::uno::Type & rType3, + const ::com::sun::star::uno::Type & rType4, + const ::com::sun::star::uno::Type & rType5, + const ::com::sun::star::uno::Type & rType6, + const ::com::sun::star::uno::Type & rType7, + const ::com::sun::star::uno::Type & rType8, + const ::com::sun::star::uno::Type & rType9, + const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > & rAddTypes = ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >() ) + SAL_THROW( () ); + OTypeCollection( + const ::com::sun::star::uno::Type & rType1, + const ::com::sun::star::uno::Type & rType2, + const ::com::sun::star::uno::Type & rType3, + const ::com::sun::star::uno::Type & rType4, + const ::com::sun::star::uno::Type & rType5, + const ::com::sun::star::uno::Type & rType6, + const ::com::sun::star::uno::Type & rType7, + const ::com::sun::star::uno::Type & rType8, + const ::com::sun::star::uno::Type & rType9, + const ::com::sun::star::uno::Type & rType10, + const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > & rAddTypes = ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >() ) + SAL_THROW( () ); + OTypeCollection( + const ::com::sun::star::uno::Type & rType1, + const ::com::sun::star::uno::Type & rType2, + const ::com::sun::star::uno::Type & rType3, + const ::com::sun::star::uno::Type & rType4, + const ::com::sun::star::uno::Type & rType5, + const ::com::sun::star::uno::Type & rType6, + const ::com::sun::star::uno::Type & rType7, + const ::com::sun::star::uno::Type & rType8, + const ::com::sun::star::uno::Type & rType9, + const ::com::sun::star::uno::Type & rType10, + const ::com::sun::star::uno::Type & rType11, + const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > & rAddTypes = ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >() ) + SAL_THROW( () ); + OTypeCollection( + const ::com::sun::star::uno::Type & rType1, + const ::com::sun::star::uno::Type & rType2, + const ::com::sun::star::uno::Type & rType3, + const ::com::sun::star::uno::Type & rType4, + const ::com::sun::star::uno::Type & rType5, + const ::com::sun::star::uno::Type & rType6, + const ::com::sun::star::uno::Type & rType7, + const ::com::sun::star::uno::Type & rType8, + const ::com::sun::star::uno::Type & rType9, + const ::com::sun::star::uno::Type & rType10, + const ::com::sun::star::uno::Type & rType11, + const ::com::sun::star::uno::Type & rType12, + const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > & rAddTypes = ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >() ) + SAL_THROW( () ); + + /** Called upon XTypeProvider::getTypes(). + + @return type collection + */ + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() SAL_THROW( () ) + { return _aTypes; } +}; + +/** Helper class to implement ::com::sun::star::lang::XTypeProvider. Construct a static object + of this class for your UNO object's implementation id. +*/ +class OImplementationId +{ + /** @internal */ + mutable ::com::sun::star::uno::Sequence< sal_Int8 > * _pSeq; + /** @internal */ + sal_Bool _bUseEthernetAddress; + +public: + // these are here to force memory de/allocation to sal lib. + /** @internal */ + inline static void * SAL_CALL operator new( size_t nSize ) SAL_THROW( () ) + { return ::rtl_allocateMemory( nSize ); } + /** @internal */ + inline static void SAL_CALL operator delete( void * pMem ) SAL_THROW( () ) + { ::rtl_freeMemory( pMem ); } + /** @internal */ + inline static void * SAL_CALL operator new( size_t, void * pMem ) SAL_THROW( () ) + { return pMem; } + /** @internal */ + inline static void SAL_CALL operator delete( void *, void * ) SAL_THROW( () ) + {} + + /** @internal */ + ~OImplementationId() SAL_THROW( () ); + /** Constructor. + + @param bUseEthernetAddress whether an ethernet mac address should be taken into account + */ + inline OImplementationId( sal_Bool bUseEthernetAddress = sal_True ) SAL_THROW( () ) + : _pSeq( 0 ) + , _bUseEthernetAddress( bUseEthernetAddress ) + {} + /** Constructor giving implementation id. + + @param rSeq implementation id + */ + inline OImplementationId( const ::com::sun::star::uno::Sequence< sal_Int8 > & rSeq ) SAL_THROW( () ) + : _pSeq( new ::com::sun::star::uno::Sequence< sal_Int8 >( rSeq ) ) + {} + inline OImplementationId( const OImplementationId & rId ) SAL_THROW( () ) + : _pSeq( new ::com::sun::star::uno::Sequence< sal_Int8 >( rId.getImplementationId() ) ) + {} + + /** Called upon XTypeProvider::getImplementationId(). + + @return implementation id + */ + ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() const SAL_THROW( () ); +}; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/inc/cppuhelper/unourl.hxx b/cppuhelper/inc/cppuhelper/unourl.hxx new file mode 100644 index 000000000000..55127ed84134 --- /dev/null +++ b/cppuhelper/inc/cppuhelper/unourl.hxx @@ -0,0 +1,195 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#if !defined INCLUDED_CPPUHELPER_UNOURL_HXX +#define INCLUDED_CPPUHELPER_UNOURL_HXX + +#include <memory> + +namespace rtl { class OUString; } + +namespace cppu { + +/** A descriptor as part of a UNO URL (connection descriptor or protocol + descriptor). + + Such a descriptor can also be useful outside the context of a full UNO URL. + For example, some functions take a string representing a connection or + protocol descriptor as input, and can use this class to parse the string. + */ +class UnoUrlDescriptor +{ +public: + /** @internal + */ + class Impl; + + /** Construct a descriptor from a string representation. + + @param rDescriptor + The string representation of a descriptor. + + @exception rtl::MalformedUriException + Thrown when the given string representation is invalid. + */ + explicit UnoUrlDescriptor(rtl::OUString const & rDescriptor); + + /** @internal + */ + explicit UnoUrlDescriptor(std::auto_ptr< Impl > & rImpl); + + UnoUrlDescriptor(UnoUrlDescriptor const & rOther); + + ~UnoUrlDescriptor(); + + UnoUrlDescriptor & operator =(UnoUrlDescriptor const & rOther); + + /** Return the string representation of the descriptor. + + @return + A reference to the string representation used to construct this + descriptor, without any modifications. The reference is valid for the + lifetime of this URL object. + */ + rtl::OUString const & getDescriptor() const; + + /** Return the name component of the descriptor. + + @return + A reference to the (case insensitive) name, in lower case form. The + reference is valid for the lifetime of this URL object. + */ + rtl::OUString const & getName() const; + + /** Test whether the parameters contain a key. + + @param + A (case insensitive) key. + + @return + True if the parameters contain a matching key/value pair. + */ + bool hasParameter(rtl::OUString const & rKey) const; + + /** Return the parameter value for a key. + + @param + A (case insensitive) key. + + @return + The (case sensitive) value associated with the given key, or an empty + string if there is no matching key/value pair. + */ + rtl::OUString getParameter(rtl::OUString const & rKey) const; + +private: + std::auto_ptr< Impl > m_xImpl; +}; + +/** Parse UNO URLs into their components. + + The ABNF for UNO URLs is as follows (see RFCs 2234, 2396, also see + <http://udk.openoffice.org/common/man/spec/uno-url.html>): + + uno-url = "UNO:" connection ";" protocol ";" object-name + connection = descriptor + protocol = descriptor + descriptor = name *("," parameter) + name = 1*alphanum + parameter = key "=" value + key = 1*alphanum + value = *vchar + valchar = unreserved / escaped / "$" / "&" / "+" / "/" / ":" / "?" / "@" + object-name = 1*ochar + ochar = unreserved / "$" / "&" / "+" / "," / "/" / ":" / "=" / "?" / "@" + + Within a descriptor, the name and the keys are case insensitive, and within + the parameter list all keys must be distinct. + + Parameter values are encoded using UTF-8. Note that parsing of parameter + values as done by UnoUrl and UnoUrlDescriptor is not strict: Invalid UTF-16 + entities in the input, as well as broken escape sequences ("%" not followed + by two hex digits) are copied verbatim to the output, invalid bytes in the + converted UTF-8 data are considered individual Unicode characters, and + invalid UTF-16 entities in the resulting output (e.g., a high surrogate not + followed by a low surrogate) are not detected. + */ +class UnoUrl +{ +public: + /** Construct a UNO URL from a string representation. + + @param rUrl + The string representation of a UNO URL. + + @exception rtl::MalformedUriException + Thrown when the given string representation is invalid. + */ + explicit UnoUrl(rtl::OUString const & rUrl); + + UnoUrl(UnoUrl const & rOther); + + ~UnoUrl(); + + UnoUrl & operator =(UnoUrl const & rOther); + + /** Return the connection descriptor component of the URL. + + @return + A reference to the connection descriptor. The reference is valid for + the lifetime of this URL object. + */ + UnoUrlDescriptor const & getConnection() const; + + /** Return the protocol descriptor component of the URL. + + @return + A reference to the protocol descriptor. The reference is valid for the + lifetime of this URL object. + */ + UnoUrlDescriptor const & getProtocol() const; + + /** Return the object-name component of the URL. + + @return + A reference to the (case sensitive) object-name. The reference is valid + for the lifetime of this URL object. + */ + rtl::OUString const & getObjectName() const; + +private: + class Impl; + + std::auto_ptr< Impl > m_xImpl; +}; + +} + +#endif // INCLUDED_RTL_UNOURL_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/inc/cppuhelper/weak.hxx b/cppuhelper/inc/cppuhelper/weak.hxx new file mode 100644 index 000000000000..2000557ea079 --- /dev/null +++ b/cppuhelper/inc/cppuhelper/weak.hxx @@ -0,0 +1,172 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CPPUHELPER_WEAK_HXX_ +#define _CPPUHELPER_WEAK_HXX_ + +#include <osl/interlck.h> +#include <rtl/alloc.h> +#include <cppuhelper/weakref.hxx> +#include <cppuhelper/queryinterface.hxx> +#include <com/sun/star/uno/XWeak.hpp> + + +namespace cppu +{ + +/** @internal */ +class OWeakConnectionPoint; + +/** Base class to implement an UNO object supporting weak references, i.e. the object can be held + weakly (by a ::com::sun::star::uno::WeakReference). + This implementation copes with reference counting. Upon last release(), the virtual dtor + is called. + + @derive + Inherit from this class and delegate acquire()/ release() calls. +*/ +class OWeakObject : public ::com::sun::star::uno::XWeak +{ + /** @internal */ + friend class OWeakConnectionPoint; + +protected: + /** Virtual dtor. + + @attention + Despite the fact that a RuntimeException is allowed to be thrown, you must not throw any + exception upon destruction! + */ + virtual ~OWeakObject() SAL_THROW( (::com::sun::star::uno::RuntimeException) ); + + /** disposes and resets m_pWeakConnectionPoint + @precond + m_refCount equals 0 + */ + void disposeWeakConnectionPoint(); + + /** reference count. + + @attention + Don't modify manually! Use acquire() and release(). + */ + oslInterlockedCount m_refCount; + + /** Container of all weak reference listeners and the connection point from the weak reference. + @internal + */ + OWeakConnectionPoint * m_pWeakConnectionPoint; + + /** reserved for future use. do not use. + @internal + */ + void * m_pReserved; + +public: + // these are here to force memory de/allocation to sal lib. + /** @internal */ + inline static void * SAL_CALL operator new( size_t nSize ) SAL_THROW( () ) + { return ::rtl_allocateMemory( nSize ); } + /** @internal */ + inline static void SAL_CALL operator delete( void * pMem ) SAL_THROW( () ) + { ::rtl_freeMemory( pMem ); } + /** @internal */ + inline static void * SAL_CALL operator new( size_t, void * pMem ) SAL_THROW( () ) + { return pMem; } + /** @internal */ + inline static void SAL_CALL operator delete( void *, void * ) SAL_THROW( () ) + {} + +#ifdef _MSC_VER + /** Default Constructor. Sets the reference count to zero. + Accidentally occurs in msvc mapfile = > had to be outlined. + */ + OWeakObject() SAL_THROW( () ); +#else + /** Default Constructor. Sets the reference count to zero. + */ + inline OWeakObject() SAL_THROW( () ) + : m_refCount( 0 ) + , m_pWeakConnectionPoint( 0 ) + {} +#endif + /** Dummy copy constructor. Set the reference count to zero. + + @param rObj dummy param + */ + inline OWeakObject( const OWeakObject & ) SAL_THROW( () ) + : com::sun::star::uno::XWeak() + , m_refCount( 0 ) + , m_pWeakConnectionPoint( 0 ) + {} + /** Dummy assignment operator. Does not affect reference count. + + @return this OWeakObject + */ + inline OWeakObject & SAL_CALL operator = ( const OWeakObject &) + SAL_THROW( () ) + { return *this; } + + /** Basic queryInterface() implementation supporting ::com::sun::star::uno::XWeak and + ::com::sun::star::uno::XInterface. + + @param rType demanded type + @return demanded type or empty any + */ + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( + const ::com::sun::star::uno::Type & rType ) + throw (::com::sun::star::uno::RuntimeException); + /** increasing m_refCount + */ + virtual void SAL_CALL acquire() + throw (); + /** decreasing m_refCount + */ + virtual void SAL_CALL release() + throw (); + + /** XWeak::queryAdapter() implementation + + @return a ::com::sun::star::uno::XAdapter reference + */ + virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XAdapter > SAL_CALL queryAdapter() + throw (::com::sun::star::uno::RuntimeException); + + /** Cast operator to XInterface reference. + + @return XInterface reference + */ + inline SAL_CALL operator ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > () SAL_THROW( () ) + { return this; } +}; + +} + +#endif + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/inc/cppuhelper/weakagg.hxx b/cppuhelper/inc/cppuhelper/weakagg.hxx new file mode 100644 index 000000000000..aac14997e5a7 --- /dev/null +++ b/cppuhelper/inc/cppuhelper/weakagg.hxx @@ -0,0 +1,114 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CPPUHELPER_WEAKAGG_HXX_ +#define _CPPUHELPER_WEAKAGG_HXX_ + +#include <cppuhelper/weak.hxx> +#include <com/sun/star/uno/XAggregation.hpp> + + +namespace cppu +{ + +/** Base class to implement an UNO object supporting weak references, i.e. the object can be held + weakly (by a ::com::sun::star::uno::WeakReference) and aggregation, i.e. the object can be + aggregated by another (delegator). + This implementation copes with reference counting. Upon last release(), the virtual dtor + is called. + + @derive + Inherit from this class and delegate acquire()/ release() calls. Re-implement + XAggregation::queryInterface(). +*/ +class OWeakAggObject + : public ::cppu::OWeakObject + , public ::com::sun::star::uno::XAggregation +{ +public: + /** Constructor. No delegator set. + */ + inline OWeakAggObject() SAL_THROW( () ) + {} + + /** If a delegator is set, then the delegators gets acquired. Otherwise call is delegated to + base class ::cppu::OWeakObject. + */ + virtual void SAL_CALL acquire() throw(); + /** If a delegator is set, then the delegators gets released. Otherwise call is delegated to + base class ::cppu::OWeakObject. + */ + virtual void SAL_CALL release() throw(); + /** If a delegator is set, then the delegator is queried for the demanded interface. If the + delegator cannot provide the demanded interface, it calls queryAggregation() on its + aggregated objects. + + @param rType demanded interface type + @return demanded type or empty any + @see queryAggregation. + */ + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) + throw(::com::sun::star::uno::RuntimeException); + + /** Set the delegator. The delegator member reference is a weak reference. + + @param Delegator the object that delegate its queryInterface to this aggregate. + */ + virtual void SAL_CALL setDelegator( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & Delegator ) + throw(::com::sun::star::uno::RuntimeException); + /** Called by the delegator or queryInterface. Re-implement this method instead of + queryInterface. + + @see queryInterface + */ + virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type & rType ) + throw(::com::sun::star::uno::RuntimeException); + +protected: + /** Virtual dtor. Called when reference count is 0. + + @attention + Despite the fact that a RuntimeException is allowed to be thrown, you must not throw any + exception upon destruction! + */ + virtual ~OWeakAggObject() SAL_THROW( (::com::sun::star::uno::RuntimeException) ); + + /** weak reference to delegator. + */ + ::com::sun::star::uno::WeakReferenceHelper xDelegator; +private: + /** @internal */ + OWeakAggObject( const OWeakAggObject & rObj ) SAL_THROW( () ); + /** @internal */ + OWeakAggObject & operator = ( const OWeakAggObject & rObj ) SAL_THROW( () ); +}; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/inc/cppuhelper/weakref.hxx b/cppuhelper/inc/cppuhelper/weakref.hxx new file mode 100644 index 000000000000..54a313b2d5df --- /dev/null +++ b/cppuhelper/inc/cppuhelper/weakref.hxx @@ -0,0 +1,172 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CPPUHELPER_WEAKREF_HXX_ +#define _CPPUHELPER_WEAKREF_HXX_ + +#include <com/sun/star/uno/XInterface.hpp> + + +namespace com +{ +namespace sun +{ +namespace star +{ +namespace uno +{ + +/** @internal */ +class OWeakRefListener; + +/** The WeakReferenceHelper holds a weak reference to an object. This object must implement + the ::com::sun::star::uno::XWeak interface. The implementation is thread safe. +*/ +class WeakReferenceHelper +{ +public: + /** Default ctor. Creates an empty weak reference. + */ + inline WeakReferenceHelper() SAL_THROW( () ) + : m_pImpl( 0 ) + {} + + /** Copy ctor. Initialize this reference with the same interface as in rWeakRef. + + @param rWeakRef another weak ref + */ + WeakReferenceHelper( const WeakReferenceHelper & rWeakRef ) SAL_THROW( () ); + /** Initialize this reference with the hard interface reference xInt. If the implementation + behind xInt does not support XWeak or XInt is null then this reference will be null. + + @param xInt another hard interface reference + */ + WeakReferenceHelper( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > & xInt ) + SAL_THROW( () ); + /** Releases this reference. + */ + ~WeakReferenceHelper() SAL_THROW( () ); + + /** Releases this reference and takes over rWeakRef. + + @param rWeakRef another weak ref + */ + WeakReferenceHelper & SAL_CALL operator = ( const WeakReferenceHelper & rWeakRef ) SAL_THROW( () ); + + /** Releases this reference and takes over hard reference xInt. + If the implementation behind xInt does not support XWeak + or XInt is null, then this reference is null. + + @param xInt another hard reference + */ + WeakReferenceHelper & SAL_CALL operator = ( + const ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XInterface > & xInt ) SAL_THROW( () ); + + /** Returns true if both weak refs reference to the same object. + + @param rObj another weak ref + @return true, if both weak refs reference to the same object. + */ + inline sal_Bool SAL_CALL operator == ( const WeakReferenceHelper & rObj ) const SAL_THROW( () ) + { return (get() == rObj.get()); } + + /** Gets a hard reference to the object. + + @return hard reference or null, if the weakly referenced interface has gone + */ + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL get() const SAL_THROW( () ); + /** Gets a hard reference to the object. + + @return hard reference or null, if the weakly referenced interface has gone + */ + inline SAL_CALL operator Reference< XInterface > () const SAL_THROW( () ) + { return get(); } + + /** Releases this reference. + + @since UDK 3.2.12 + */ + void SAL_CALL clear() SAL_THROW( () ); + +protected: + /** @internal */ + OWeakRefListener * m_pImpl; +}; + +/** The WeakReference<> holds a weak reference to an object. This object must implement + the ::com::sun::star::uno::XWeak interface. The implementation is thread safe. + + @tplparam interface_type type of interface +*/ +template< class interface_type > +class WeakReference : public WeakReferenceHelper +{ +public: + /** Default ctor. Creates an empty weak reference. + */ + inline WeakReference() SAL_THROW( () ) + : WeakReferenceHelper() + {} + + /** Copy ctor. Initialize this reference with a hard reference. + + @param rRef another hard ref + */ + inline WeakReference( const Reference< interface_type > & rRef ) SAL_THROW( () ) + : WeakReferenceHelper( rRef ) + {} + + /** Releases this reference and takes over hard reference xInt. + If the implementation behind xInt does not support XWeak + or XInt is null, then this reference is null. + + @param xInt another hard reference + + @since UDK 3.2.12 + */ + WeakReference & SAL_CALL operator = ( + const ::com::sun::star::uno::Reference< interface_type > & xInt ) + SAL_THROW( () ) + { WeakReferenceHelper::operator=(xInt); return *this; } + + /** Gets a hard reference to the object. + + @return hard reference or null, if the weakly referenced interface has gone + */ + inline SAL_CALL operator Reference< interface_type > () const SAL_THROW( () ) + { return Reference< interface_type >::query( get() ); } +}; + +} +} +} +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/inc/makefile.mk b/cppuhelper/inc/makefile.mk new file mode 100644 index 000000000000..0208c0dbf93d --- /dev/null +++ b/cppuhelper/inc/makefile.mk @@ -0,0 +1,47 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* +PRJ=.. + +PRJNAME=cppuhelper +TARGET=inc + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk + +# --- Files -------------------------------------------------------- +# --- Targets ------------------------------------------------------- + +.INCLUDE : target.mk + +.IF "$(ENABLE_PCH)"!="" +ALLTAR : \ + $(SLO)$/precompiled.pch \ + $(SLO)$/precompiled_ex.pch + +.ENDIF # "$(ENABLE_PCH)"!="" + diff --git a/cppuhelper/inc/pch/precompiled_cppuhelper.cxx b/cppuhelper/inc/pch/precompiled_cppuhelper.cxx new file mode 100644 index 000000000000..d8090977e1ff --- /dev/null +++ b/cppuhelper/inc/pch/precompiled_cppuhelper.cxx @@ -0,0 +1,31 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "precompiled_cppuhelper.hxx" + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/inc/pch/precompiled_cppuhelper.hxx b/cppuhelper/inc/pch/precompiled_cppuhelper.hxx new file mode 100644 index 000000000000..b1a1df1a14f3 --- /dev/null +++ b/cppuhelper/inc/pch/precompiled_cppuhelper.hxx @@ -0,0 +1,34 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): Generated on 2006-09-01 17:49:37.342833 + +#ifdef PRECOMPILED_HEADERS +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/prj/build.lst b/cppuhelper/prj/build.lst new file mode 100644 index 000000000000..de66b2d61a4b --- /dev/null +++ b/cppuhelper/prj/build.lst @@ -0,0 +1,6 @@ +ch cppuhelper : BOOST:boost codemaker cppu offuh NULL +ch cppuhelper usr1 - all ch_mkout NULL +ch cppuhelper\inc nmake - all ch_include NULL +ch cppuhelper\source nmake - all ch_source ch_unotypes ch_include NULL +ch cppuhelper\unotypes nmake - all ch_unotypes NULL +ch cppuhelper\qa\propertysetmixin nmake - all ch_qa_propertysetmixin ch_source NULL diff --git a/cppuhelper/prj/d.lst b/cppuhelper/prj/d.lst new file mode 100644 index 000000000000..0707a7609b56 --- /dev/null +++ b/cppuhelper/prj/d.lst @@ -0,0 +1,74 @@ +mkdir: %_DEST%\inc%_EXT%\cppuhelper + +..\inc\cppuhelper\implbase.hxx %_DEST%\inc%_EXT%\cppuhelper\implbase.hxx +..\inc\cppuhelper\implbase_ex.hxx %_DEST%\inc%_EXT%\cppuhelper\implbase_ex.hxx +..\inc\cppuhelper\implbase_ex_pre.hxx %_DEST%\inc%_EXT%\cppuhelper\implbase_ex_pre.hxx +..\inc\cppuhelper\implbase_ex_post.hxx %_DEST%\inc%_EXT%\cppuhelper\implbase_ex_post.hxx +..\inc\cppuhelper\implbase1.hxx %_DEST%\inc%_EXT%\cppuhelper\implbase1.hxx +..\inc\cppuhelper\implbase2.hxx %_DEST%\inc%_EXT%\cppuhelper\implbase2.hxx +..\inc\cppuhelper\implbase3.hxx %_DEST%\inc%_EXT%\cppuhelper\implbase3.hxx +..\inc\cppuhelper\implbase4.hxx %_DEST%\inc%_EXT%\cppuhelper\implbase4.hxx +..\inc\cppuhelper\implbase5.hxx %_DEST%\inc%_EXT%\cppuhelper\implbase5.hxx +..\inc\cppuhelper\implbase6.hxx %_DEST%\inc%_EXT%\cppuhelper\implbase6.hxx +..\inc\cppuhelper\implbase7.hxx %_DEST%\inc%_EXT%\cppuhelper\implbase7.hxx +..\inc\cppuhelper\implbase8.hxx %_DEST%\inc%_EXT%\cppuhelper\implbase8.hxx +..\inc\cppuhelper\implbase9.hxx %_DEST%\inc%_EXT%\cppuhelper\implbase9.hxx +..\inc\cppuhelper\implbase10.hxx %_DEST%\inc%_EXT%\cppuhelper\implbase10.hxx +..\inc\cppuhelper\implbase11.hxx %_DEST%\inc%_EXT%\cppuhelper\implbase11.hxx +..\inc\cppuhelper\implbase12.hxx %_DEST%\inc%_EXT%\cppuhelper\implbase12.hxx + +..\inc\cppuhelper\compbase.hxx %_DEST%\inc%_EXT%\cppuhelper\compbase.hxx +..\inc\cppuhelper\compbase_ex.hxx %_DEST%\inc%_EXT%\cppuhelper\compbase_ex.hxx +..\inc\cppuhelper\compbase1.hxx %_DEST%\inc%_EXT%\cppuhelper\compbase1.hxx +..\inc\cppuhelper\compbase2.hxx %_DEST%\inc%_EXT%\cppuhelper\compbase2.hxx +..\inc\cppuhelper\compbase3.hxx %_DEST%\inc%_EXT%\cppuhelper\compbase3.hxx +..\inc\cppuhelper\compbase4.hxx %_DEST%\inc%_EXT%\cppuhelper\compbase4.hxx +..\inc\cppuhelper\compbase5.hxx %_DEST%\inc%_EXT%\cppuhelper\compbase5.hxx +..\inc\cppuhelper\compbase6.hxx %_DEST%\inc%_EXT%\cppuhelper\compbase6.hxx +..\inc\cppuhelper\compbase7.hxx %_DEST%\inc%_EXT%\cppuhelper\compbase7.hxx +..\inc\cppuhelper\compbase8.hxx %_DEST%\inc%_EXT%\cppuhelper\compbase8.hxx +..\inc\cppuhelper\compbase9.hxx %_DEST%\inc%_EXT%\cppuhelper\compbase9.hxx +..\inc\cppuhelper\compbase10.hxx %_DEST%\inc%_EXT%\cppuhelper\compbase10.hxx +..\inc\cppuhelper\compbase11.hxx %_DEST%\inc%_EXT%\cppuhelper\compbase11.hxx +..\inc\cppuhelper\compbase12.hxx %_DEST%\inc%_EXT%\cppuhelper\compbase12.hxx + +..\inc\cppuhelper\shlib.hxx %_DEST%\inc%_EXT%\cppuhelper\shlib.hxx +..\inc\cppuhelper\basemutex.hxx %_DEST%\inc%_EXT%\cppuhelper\basemutex.hxx +..\inc\cppuhelper\bootstrap.hxx %_DEST%\inc%_EXT%\cppuhelper\bootstrap.hxx +..\inc\cppuhelper\exc_hlp.hxx %_DEST%\inc%_EXT%\cppuhelper\exc_hlp.hxx +..\inc\cppuhelper\typeprovider.hxx %_DEST%\inc%_EXT%\cppuhelper\typeprovider.hxx +..\inc\cppuhelper\factory.hxx %_DEST%\inc%_EXT%\cppuhelper\factory.hxx +..\inc\cppuhelper\component_context.hxx %_DEST%\inc%_EXT%\cppuhelper\component_context.hxx +..\inc\cppuhelper\interfacecontainer.hxx %_DEST%\inc%_EXT%\cppuhelper\interfacecontainer.hxx +..\inc\cppuhelper\interfacecontainer.h %_DEST%\inc%_EXT%\cppuhelper\interfacecontainer.h +..\inc\cppuhelper\component.hxx %_DEST%\inc%_EXT%\cppuhelper\component.hxx +..\inc\cppuhelper\propshlp.hxx %_DEST%\inc%_EXT%\cppuhelper\propshlp.hxx +..\inc\cppuhelper\proptypehlp.hxx %_DEST%\inc%_EXT%\cppuhelper\proptypehlp.hxx +..\inc\cppuhelper\propertysetmixin.hxx %_DEST%\inc%_EXT%\cppuhelper\propertysetmixin.hxx +..\inc\cppuhelper\proptypehlp.h %_DEST%\inc%_EXT%\cppuhelper\proptypehlp.h +..\inc\cppuhelper\stdidlclass.hxx %_DEST%\inc%_EXT%\cppuhelper\stdidlclass.hxx +..\inc\cppuhelper\weak.hxx %_DEST%\inc%_EXT%\cppuhelper\weak.hxx +..\inc\cppuhelper\weakagg.hxx %_DEST%\inc%_EXT%\cppuhelper\weakagg.hxx +..\inc\cppuhelper\queryinterface.hxx %_DEST%\inc%_EXT%\cppuhelper\queryinterface.hxx +..\inc\cppuhelper\weakref.hxx %_DEST%\inc%_EXT%\cppuhelper\weakref.hxx +..\inc\cppuhelper\servicefactory.hxx %_DEST%\inc%_EXT%\cppuhelper\servicefactory.hxx +..\inc\cppuhelper\implementationentry.hxx %_DEST%\inc%_EXT%\cppuhelper\implementationentry.hxx +..\inc\cppuhelper\access_control.hxx %_DEST%\inc%_EXT%\cppuhelper\access_control.hxx +..\inc\cppuhelper\unourl.hxx %_DEST%\inc%_EXT%\cppuhelper\unourl.hxx + +..\%__SRC%\bin\cppuh*.dll %_DEST%\bin%_EXT%\cppuh*.dll +..\%__SRC%\lib\*cppuhelper*.lib %_DEST%\lib%_EXT%\* + +..\%__SRC%\lib\libuno_cppuhelper*.*.* %_DEST%\lib%_EXT%\* + +..\%__SRC%\lib\libcppuhelper*.a %_DEST%\lib%_EXT%\* +..\%__SRC%\lib\cppuhelper*.lib %_DEST%\lib%_EXT%\* + +..\source\unorc %_DEST%\bin%_EXT%\uno.ini +..\source\unorc %_DEST%\lib%_EXT%\unorc + +..\inc\cppuhelper\findsofficepath.h %_DEST%\inc%_EXT%\cppuhelper\findsofficepath.h +..\%__SRC%\obj\findsofficepath.o %_DEST%\lib%_EXT%\findsofficepath.o +..\%__SRC%\obj\findsofficepath.obj %_DEST%\lib%_EXT%\findsofficepath.obj + +linklib: libuno_cppuhelper*.*.* diff --git a/cppuhelper/qa/ifcontainer/cppu_ifcontainer.cxx b/cppuhelper/qa/ifcontainer/cppu_ifcontainer.cxx new file mode 100644 index 000000000000..4f47fd449a87 --- /dev/null +++ b/cppuhelper/qa/ifcontainer/cppu_ifcontainer.cxx @@ -0,0 +1,286 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <testshl/simpleheader.hxx> + +#include "com/sun/star/lang/XEventListener.hpp" +#include "cppuhelper/interfacecontainer.hxx" +#include "cppuhelper/queryinterface.hxx" +#include "cppuhelper/implbase1.hxx" +#include "cppuhelper/propshlp.hxx" + +using namespace com::sun::star; +using namespace com::sun::star::uno; +using namespace com::sun::star::lang; + + +struct equalStr +{ + bool operator()( + const char * const &rA, + const char * const &rB) const + { return !strcmp(rA, rB); } +}; +struct hashStr +{ + size_t operator()( const char * &rName ) const + { + return rtl::OString(rName).hashCode(); + } +}; + +class ContainerListener; + +struct ContainerStats { + int m_nAlive; + int m_nDisposed; + ContainerStats() : m_nAlive(0), m_nDisposed(0) {} +}; + +class ContainerListener : public ::cppu::WeakImplHelper1< XEventListener > +{ + ContainerStats *m_pStats; +public: + ContainerListener(ContainerStats *pStats) + : m_pStats(pStats) { m_pStats->m_nAlive++; } + virtual ~ContainerListener() { m_pStats->m_nAlive--; } + virtual void SAL_CALL disposing( const EventObject& ) + throw (RuntimeException) + { + m_pStats->m_nDisposed++; + } +}; + +namespace cppu_ifcontainer +{ + class IfTest : public CppUnit::TestFixture + { + osl::Mutex m_aGuard; + static const int nTests = 10; + public: + void testCreateDispose() + { + ContainerStats aStats; + cppu::OInterfaceContainerHelper *pContainer; + + pContainer = new cppu::OInterfaceContainerHelper(m_aGuard); + + CPPUNIT_ASSERT_MESSAGE("Empty container not empty", + pContainer->getLength() == 0); + + int i; + for (i = 0; i < nTests; i++) + { + Reference<XEventListener> xRef = new ContainerListener(&aStats); + int nNewLen = pContainer->addInterface(xRef); + + CPPUNIT_ASSERT_MESSAGE("addition length mismatch", + nNewLen == i + 1); + CPPUNIT_ASSERT_MESSAGE("addition length mismatch", + pContainer->getLength() == i + 1); + } + CPPUNIT_ASSERT_MESSAGE("alive count mismatch", + aStats.m_nAlive == nTests); + + EventObject aObj; + pContainer->disposeAndClear(aObj); + + CPPUNIT_ASSERT_MESSAGE("dispose count mismatch", + aStats.m_nDisposed == nTests); + CPPUNIT_ASSERT_MESSAGE("leaked container left alive", + aStats.m_nAlive == 0); + + delete pContainer; + } + + void testEnumerate() + { + int i; + ContainerStats aStats; + cppu::OInterfaceContainerHelper *pContainer; + pContainer = new cppu::OInterfaceContainerHelper(m_aGuard); + + std::vector< Reference< XEventListener > > aListeners; + for (i = 0; i < nTests; i++) + { + Reference<XEventListener> xRef = new ContainerListener(&aStats); + int nNewLen = pContainer->addInterface(xRef); + aListeners.push_back(xRef); + } + Sequence< Reference< XInterface > > aElements; + aElements = pContainer->getElements(); + + CPPUNIT_ASSERT_MESSAGE("query contents", + (int)aElements.getLength() == nTests); + if ((int)aElements.getLength() == nTests) + { + for (i = 0; i < nTests; i++) + { + CPPUNIT_ASSERT_MESSAGE("mismatching elements", + aElements[i] == aListeners[i]); + } + } + pContainer->clear(); + + CPPUNIT_ASSERT_MESSAGE("non-empty container post clear", + pContainer->getLength() == 0); + delete pContainer; + } + + template < typename ContainerType, typename ContainedType > + void doContainerTest(const ContainedType *pTypes) + { + ContainerStats aStats; + ContainerType *pContainer; + pContainer = new ContainerType(m_aGuard); + + int i; + Reference<XEventListener> xRefs[nTests * 2]; + + // add these interfaces + for (i = 0; i < nTests * 2; i++) + { + xRefs[i] = new ContainerListener(&aStats); + pContainer->addInterface(pTypes[i / 2], xRefs[i]); + } + + // check it is all there + for (i = 0; i < nTests; i++) + { + cppu::OInterfaceContainerHelper *pHelper; + + pHelper = pContainer->getContainer(pTypes[i]); + + CPPUNIT_ASSERT_MESSAGE("no helper", pHelper != NULL); + Sequence<Reference< XInterface > > aSeq = pHelper->getElements(); + CPPUNIT_ASSERT_MESSAGE("wrong num elements", aSeq.getLength() == 2); + CPPUNIT_ASSERT_MESSAGE("match", aSeq[0] == xRefs[i*2]); + CPPUNIT_ASSERT_MESSAGE("match", aSeq[1] == xRefs[i*2+1]); + } + + // remove every other interface + for (i = 0; i < nTests; i++) + pContainer->removeInterface(pTypes[i], xRefs[i*2+1]); + + // check it is half there + for (i = 0; i < nTests; i++) + { + cppu::OInterfaceContainerHelper *pHelper; + + pHelper = pContainer->getContainer(pTypes[i]); + + CPPUNIT_ASSERT_MESSAGE("no helper", pHelper != NULL); + Sequence<Reference< XInterface > > aSeq = pHelper->getElements(); + CPPUNIT_ASSERT_MESSAGE("wrong num elements", aSeq.getLength() == 1); + CPPUNIT_ASSERT_MESSAGE("match", aSeq[0] == xRefs[i*2]); + } + + // remove the 1st half of the rest + for (i = 0; i < nTests / 2; i++) + pContainer->removeInterface(pTypes[i], xRefs[i*2]); + + // check it is half there + for (i = 0; i < nTests / 2; i++) + { + cppu::OInterfaceContainerHelper *pHelper; + + pHelper = pContainer->getContainer(pTypes[i]); + CPPUNIT_ASSERT_MESSAGE("no helper", pHelper != NULL); + Sequence<Reference< XInterface > > aSeq = pHelper->getElements(); + CPPUNIT_ASSERT_MESSAGE("wrong num elements", aSeq.getLength() == 0); + } + + delete pContainer; + } + + void testOMultiTypeInterfaceContainerHelper() + { + uno::Type pTypes[nTests] = + { + ::cppu::UnoType< bool >::get(), + ::cppu::UnoType< float >::get(), + ::cppu::UnoType< double >::get(), + ::cppu::UnoType< ::sal_uInt64 >::get(), + ::cppu::UnoType< ::sal_Int64 >::get(), + ::cppu::UnoType< ::sal_uInt32 >::get(), + ::cppu::UnoType< ::sal_Int32 >::get(), + ::cppu::UnoType< ::sal_Int16 >::get(), + ::cppu::UnoType< ::rtl::OUString >::get(), + ::cppu::UnoType< ::sal_Int8 >::get() + }; + doContainerTest< cppu::OMultiTypeInterfaceContainerHelper, + uno::Type> (pTypes); + } + + void testOMultiTypeInterfaceContainerHelperInt32() + { + sal_Int32 pTypes[nTests] = + { + 0, + -1, + 1, + 256, + 1024, + 3, + 7, + 8, + 9, + 10 + }; + doContainerTest< cppu::OMultiTypeInterfaceContainerHelperInt32, sal_Int32> (pTypes); + } + + void testOMultiTypeInterfaceContainerHelperVar() + { + typedef ::cppu::OMultiTypeInterfaceContainerHelperVar< + const char *,hashStr,equalStr> StrContainer; + + const char *pTypes[nTests] = + { + "this_is", "such", "fun", "writing", "unit", "tests", "when", "it", "works", "anyway" + }; + doContainerTest< StrContainer, const char *> (pTypes); + } + + // Automatic registration code + CPPUNIT_TEST_SUITE(IfTest); + CPPUNIT_TEST(testCreateDispose); + CPPUNIT_TEST(testEnumerate); + CPPUNIT_TEST(testOMultiTypeInterfaceContainerHelper); + CPPUNIT_TEST(testOMultiTypeInterfaceContainerHelperVar); + CPPUNIT_TEST(testOMultiTypeInterfaceContainerHelperInt32); + CPPUNIT_TEST_SUITE_END(); + }; +} // namespace cppu_ifcontainer + +CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(cppu_ifcontainer::IfTest, + "cppu_ifcontainer"); + +NOADDITIONAL; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/qa/ifcontainer/export.map b/cppuhelper/qa/ifcontainer/export.map new file mode 100644 index 000000000000..879fa8953788 --- /dev/null +++ b/cppuhelper/qa/ifcontainer/export.map @@ -0,0 +1,7 @@ +UDK_3_0_0 { + global: + registerAllTestFunction; + + local: + *; +}; diff --git a/cppuhelper/qa/ifcontainer/makefile.mk b/cppuhelper/qa/ifcontainer/makefile.mk new file mode 100644 index 000000000000..3277b4c204ea --- /dev/null +++ b/cppuhelper/qa/ifcontainer/makefile.mk @@ -0,0 +1,61 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +PRJ=..$/.. +PRJNAME=cppuhelper +TARGET=cppu_ifcontainer + +ENABLE_EXCEPTIONS=TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk + +CFLAGSCXX += $(CPPUNIT_CFLAGS) + +# BEGIN ---------------------------------------------------------------- +# auto generated Target:joblist by codegen.pl +SHL1OBJS= \ + $(SLO)$/cppu_ifcontainer.obj +SHL1TARGET= cppu_ifcontainer +SHL1STDLIBS=\ + $(CPPUHELPERLIB) \ + $(SALLIB) \ + $(CPPULIB) \ + $(TESTSHL2LIB)\ + $(CPPUNITLIB) +SHL1IMPLIB= i$(SHL1TARGET) +DEF1NAME =$(SHL1TARGET) +SHL1VERSIONMAP= export.map +# auto generated Target:joblist +# END ------------------------------------------------------------------ + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk +.INCLUDE : _cppunit.mk + diff --git a/cppuhelper/qa/propertysetmixin/JavaSupplier.java b/cppuhelper/qa/propertysetmixin/JavaSupplier.java new file mode 100644 index 000000000000..513f207aba14 --- /dev/null +++ b/cppuhelper/qa/propertysetmixin/JavaSupplier.java @@ -0,0 +1,322 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package test.cppuhelper.propertysetmixin.comp; + +import com.sun.star.beans.Ambiguous; +import com.sun.star.beans.Defaulted; +import com.sun.star.beans.Optional; +import com.sun.star.beans.UnknownPropertyException; +import com.sun.star.beans.PropertyValue; +import com.sun.star.beans.PropertyVetoException; +import com.sun.star.beans.XFastPropertySet; +import com.sun.star.beans.XPropertyAccess; +import com.sun.star.beans.XPropertyChangeListener; +import com.sun.star.beans.XPropertySet; +import com.sun.star.beans.XPropertySetInfo; +import com.sun.star.beans.XVetoableChangeListener; +import com.sun.star.comp.loader.FactoryHelper; +import com.sun.star.lang.WrappedTargetException; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XEventListener; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.lang.XSingleServiceFactory; +import com.sun.star.lib.uno.helper.WeakBase; +import com.sun.star.lib.uno.helper.PropertySetMixin; +import com.sun.star.registry.XRegistryKey; +import com.sun.star.uno.Any; +import com.sun.star.uno.IQueryInterface; +import com.sun.star.uno.Type; +import com.sun.star.uno.XComponentContext; +import test.cppuhelper.propertysetmixin.XSupplier; +import test.cppuhelper.propertysetmixin.XTest3; + +public final class JavaSupplier extends WeakBase implements XSupplier { + public JavaSupplier(XComponentContext context) { + this.context = context; + } + + public XComponent getEmpty1() { return new Empty1(); } + + public XComponent getEmpty2() { return new Empty2(); } + + public XTest3 getFull() { return new Full(); } + + public static XSingleServiceFactory __getServiceFactory( + String implName, XMultiServiceFactory multiFactory, XRegistryKey regKey) + { + return implName.equals(implementationName) + ? FactoryHelper.getServiceFactory( + JavaSupplier.class, serviceName, multiFactory, regKey) + : null; + } + + public static boolean __writeRegistryServiceInfo(XRegistryKey regKey) { + return FactoryHelper.writeRegistryServiceInfo( + implementationName, serviceName, regKey); + } + + private static final String implementationName + = JavaSupplier.class.getName(); + private static final String serviceName + = "test.cppuhelper.propertysetmixin.JavaSupplier"; + + private final class Empty1 extends WeakBase implements XComponent { + public Empty1() {} + + public void dispose() { + prop.dispose(); + } + + public void addEventListener(XEventListener listener) {} + + public void removeEventListener(XEventListener listener) {} + + private final PropertySetMixin prop = new PropertySetMixin( + context, this, new Type(XComponent.class), null); + } + + private final class Empty2 extends WeakBase + implements XComponent, XPropertySet, XFastPropertySet, XPropertyAccess + { + public Empty2() {} + + public void dispose() { + prop.dispose(); + } + + public void addEventListener(XEventListener listener) {} + + public void removeEventListener(XEventListener listener) {} + + public com.sun.star.beans.XPropertySetInfo getPropertySetInfo() { + return prop.getPropertySetInfo(); + } + + public void setPropertyValue(String propertyName, Object value) + throws UnknownPropertyException, PropertyVetoException, + com.sun.star.lang.IllegalArgumentException, WrappedTargetException + { + prop.setPropertyValue(propertyName, value); + } + + public Object getPropertyValue(String propertyName) + throws UnknownPropertyException, WrappedTargetException + { + return prop.getPropertyValue(propertyName); + } + + public void addPropertyChangeListener( + String propertyName, XPropertyChangeListener listener) + throws UnknownPropertyException, WrappedTargetException + { + prop.addPropertyChangeListener(propertyName, listener); + } + + public void removePropertyChangeListener( + String propertyName, XPropertyChangeListener listener) + throws UnknownPropertyException, WrappedTargetException + { + prop.removePropertyChangeListener(propertyName, listener); + } + + public void addVetoableChangeListener( + String propertyName, XVetoableChangeListener listener) + throws UnknownPropertyException, WrappedTargetException + { + prop.addVetoableChangeListener(propertyName, listener); + } + + public void removeVetoableChangeListener( + String propertyName, XVetoableChangeListener listener) + throws UnknownPropertyException, WrappedTargetException + { + prop.removeVetoableChangeListener(propertyName, listener); + } + + public void setFastPropertyValue(int handle, Object value) + throws UnknownPropertyException, PropertyVetoException, + com.sun.star.lang.IllegalArgumentException, WrappedTargetException + { + prop.setFastPropertyValue(handle, value); + } + + public Object getFastPropertyValue(int handle) + throws UnknownPropertyException, WrappedTargetException + { + return prop.getFastPropertyValue(handle); + } + + public PropertyValue[] getPropertyValues() { + return prop.getPropertyValues(); + } + + public void setPropertyValues(PropertyValue[] props) + throws UnknownPropertyException, PropertyVetoException, + com.sun.star.lang.IllegalArgumentException, WrappedTargetException + { + prop.setPropertyValues(props); + } + + private final PropertySetMixin prop = new PropertySetMixin( + context, this, new Type(XComponent.class), null); + } + + private final class Full extends WeakBase + implements XTest3, XPropertySet, XFastPropertySet, XPropertyAccess + { + public Full() {} + + public synchronized int getFirst() { + return a1; + } + + public void setFirst(int value) { + prop.prepareSet("First", null); + synchronized (this) { + a1 = value; + } + } + + public synchronized Ambiguous getSecond() + throws UnknownPropertyException + { + return a2; + } + + public void setSecond(Ambiguous value) + throws PropertyVetoException, UnknownPropertyException + { + PropertySetMixin.BoundListeners l + = new PropertySetMixin.BoundListeners(); + prop.prepareSet( + "Second", Any.VOID, + (((Optional) ((Defaulted) value.Value).Value).IsPresent + ? ((Optional) ((Defaulted) value.Value).Value).Value + : Any.VOID), + l); + synchronized (this) { + a2 = value; + } + l.notifyListeners(); + } + + public int getThird() throws UnknownPropertyException { + throw new UnknownPropertyException("Third", this); + } + + public void setThird(int value) throws UnknownPropertyException { + throw new UnknownPropertyException("Third", this); + } + + public int getFourth() throws UnknownPropertyException { + throw new UnknownPropertyException("Fourth", this); + } + + public void setFourth(int value) throws UnknownPropertyException { + throw new UnknownPropertyException("Fourth", this); + } + + public com.sun.star.beans.XPropertySetInfo getPropertySetInfo() { + return prop.getPropertySetInfo(); + } + + public void setPropertyValue(String propertyName, Object value) + throws UnknownPropertyException, PropertyVetoException, + com.sun.star.lang.IllegalArgumentException, WrappedTargetException + { + prop.setPropertyValue(propertyName, value); + } + + public Object getPropertyValue(String propertyName) + throws UnknownPropertyException, WrappedTargetException + { + return prop.getPropertyValue(propertyName); + } + + public void addPropertyChangeListener( + String propertyName, XPropertyChangeListener listener) + throws UnknownPropertyException, WrappedTargetException + { + prop.addPropertyChangeListener(propertyName, listener); + } + + public void removePropertyChangeListener( + String propertyName, XPropertyChangeListener listener) + throws UnknownPropertyException, WrappedTargetException + { + prop.removePropertyChangeListener(propertyName, listener); + } + + public void addVetoableChangeListener( + String propertyName, XVetoableChangeListener listener) + throws UnknownPropertyException, WrappedTargetException + { + prop.addVetoableChangeListener(propertyName, listener); + } + + public void removeVetoableChangeListener( + String propertyName, XVetoableChangeListener listener) + throws UnknownPropertyException, WrappedTargetException + { + prop.removeVetoableChangeListener(propertyName, listener); + } + + public void setFastPropertyValue(int handle, Object value) + throws UnknownPropertyException, PropertyVetoException, + com.sun.star.lang.IllegalArgumentException, WrappedTargetException + { + prop.setFastPropertyValue(handle, value); + } + + public Object getFastPropertyValue(int handle) + throws UnknownPropertyException, WrappedTargetException + { + return prop.getFastPropertyValue(handle); + } + + public PropertyValue[] getPropertyValues() { + return prop.getPropertyValues(); + } + + public void setPropertyValues(PropertyValue[] props) + throws UnknownPropertyException, PropertyVetoException, + com.sun.star.lang.IllegalArgumentException, WrappedTargetException + { + prop.setPropertyValues(props); + } + + private final PropertySetMixin prop = new PropertySetMixin( + context, this, new Type(XTest3.class), new String[] { "Third" }); + + private int a1 = 0; + private Ambiguous a2 = new Ambiguous( + new Defaulted(new Optional(), true), false); + } + + private final XComponentContext context; +} diff --git a/cppuhelper/qa/propertysetmixin/comp_propertysetmixin.cxx b/cppuhelper/qa/propertysetmixin/comp_propertysetmixin.cxx new file mode 100644 index 000000000000..adf161083398 --- /dev/null +++ b/cppuhelper/qa/propertysetmixin/comp_propertysetmixin.cxx @@ -0,0 +1,439 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_cppuhelper.hxx" + +#include "sal/config.h" + +#include "test/cppuhelper/propertysetmixin/XSupplier.hpp" +#include "test/cppuhelper/propertysetmixin/XTest3.hpp" + +#include "com/sun/star/beans/Ambiguous.hpp" +#include "com/sun/star/beans/Defaulted.hpp" +#include "com/sun/star/beans/Optional.hpp" +#include "com/sun/star/beans/PropertyVetoException.hpp" +#include "com/sun/star/beans/UnknownPropertyException.hpp" +#include "com/sun/star/lang/XComponent.hpp" +#include "cppuhelper/propertysetmixin.hxx" +#include "cppuhelper/factory.hxx" +#include "cppuhelper/implbase1.hxx" +#include "cppuhelper/implementationentry.hxx" +#include "cppuhelper/queryinterface.hxx" +#include "cppuhelper/weak.hxx" +#include "com/sun/star/uno/Any.hxx" +#include "com/sun/star/uno/Exception.hpp" +#include "com/sun/star/uno/Reference.hxx" +#include "com/sun/star/uno/RuntimeException.hpp" +#include "com/sun/star/uno/Sequence.hxx" +#include "com/sun/star/uno/Type.hxx" +#include "com/sun/star/uno/XComponentContext.hpp" +#include "com/sun/star/uno/XInterface.hpp" +#include "osl/mutex.hxx" +#include "rtl/ustring.h" +#include "rtl/ustring.hxx" +#include "sal/types.h" +#include "uno/lbnames.h" + +namespace com { namespace sun { namespace star { + class XEventListener; +} } } + +namespace css = com::sun::star; + +namespace { + +class Empty1: + public cppu::OWeakObject, public css::lang::XComponent, + public cppu::PropertySetMixin< css::lang::XComponent > +{ +public: + explicit Empty1( + css::uno::Reference< css::uno::XComponentContext > const & context): + cppu::PropertySetMixin< css::lang::XComponent >( + context, static_cast< Implements >(0), + css::uno::Sequence< rtl::OUString >()) + {} + + virtual css::uno::Any SAL_CALL queryInterface(css::uno::Type const & type) + throw (css::uno::RuntimeException); + + virtual void SAL_CALL acquire() throw () { OWeakObject::acquire(); } + + virtual void SAL_CALL release() throw () { OWeakObject::release(); } + + virtual void SAL_CALL dispose() throw (css::uno::RuntimeException) { + cppu::PropertySetMixin< css::lang::XComponent >::dispose(); + } + + virtual void SAL_CALL addEventListener( + css::uno::Reference< css::lang::XEventListener > const &) + throw (css::uno::RuntimeException) + {} + + virtual void SAL_CALL removeEventListener( + css::uno::Reference< css::lang::XEventListener > const &) + throw (css::uno::RuntimeException) + {} + +private: + Empty1(Empty1 &); // not defined + void operator =(Empty1 &); // not defined + + virtual ~Empty1() {} +}; + +css::uno::Any Empty1::queryInterface(css::uno::Type const & type) + throw (css::uno::RuntimeException) +{ + css::uno::Any a(OWeakObject::queryInterface(type)); + if (a.hasValue()) { + return a; + } + a = cppu::queryInterface( + type, static_cast< css::lang::XComponent * >(this)); + return a.hasValue() + ? a + : cppu::PropertySetMixin< css::lang::XComponent >::queryInterface( + type); +} + +class Empty2: + public cppu::OWeakObject, public css::lang::XComponent, + public cppu::PropertySetMixin< css::lang::XComponent > +{ +public: + explicit Empty2( + css::uno::Reference< css::uno::XComponentContext > const & context): + cppu::PropertySetMixin< css::lang::XComponent >( + context, + static_cast< Implements >( + IMPLEMENTS_PROPERTY_SET | IMPLEMENTS_FAST_PROPERTY_SET + | IMPLEMENTS_PROPERTY_ACCESS), + css::uno::Sequence< rtl::OUString >()) + {} + + virtual css::uno::Any SAL_CALL queryInterface(css::uno::Type const & type) + throw (css::uno::RuntimeException); + + virtual void SAL_CALL acquire() throw () { OWeakObject::acquire(); } + + virtual void SAL_CALL release() throw () { OWeakObject::release(); } + + virtual void SAL_CALL dispose() throw (css::uno::RuntimeException) { + cppu::PropertySetMixin< css::lang::XComponent >::dispose(); + } + + virtual void SAL_CALL addEventListener( + css::uno::Reference< css::lang::XEventListener > const &) + throw (css::uno::RuntimeException) + {} + + virtual void SAL_CALL removeEventListener( + css::uno::Reference< css::lang::XEventListener > const &) + throw (css::uno::RuntimeException) + {} + +private: + Empty2(Empty2 &); // not defined + void operator =(Empty2 &); // not defined + + virtual ~Empty2() {} +}; + +css::uno::Any Empty2::queryInterface(css::uno::Type const & type) + throw (css::uno::RuntimeException) +{ + css::uno::Any a(OWeakObject::queryInterface(type)); + if (a.hasValue()) { + return a; + } + a = cppu::queryInterface( + type, static_cast< css::lang::XComponent * >(this)); + return a.hasValue() + ? a + : cppu::PropertySetMixin< css::lang::XComponent >::queryInterface( + type); +} + +css::uno::Sequence< rtl::OUString > sequenceThird() { + css::uno::Sequence< rtl::OUString > s(1); + s[0] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Third")); + return s; +} + +class Full: + public cppu::OWeakObject, public test::cppuhelper::propertysetmixin::XTest3, + public cppu::PropertySetMixin< + test::cppuhelper::propertysetmixin::XTest3 > +{ +public: + explicit Full( + css::uno::Reference< css::uno::XComponentContext > const & context): + cppu::PropertySetMixin< + test::cppuhelper::propertysetmixin::XTest3 >( + context, + static_cast< Implements >( + IMPLEMENTS_PROPERTY_SET | IMPLEMENTS_FAST_PROPERTY_SET + | IMPLEMENTS_PROPERTY_ACCESS), + sequenceThird()), + m_a1(0), + m_a2( + css::beans::Defaulted< css::beans::Optional< sal_Int32 > >( + css::beans::Optional< sal_Int32 >(), true), + false) + {} + + virtual css::uno::Any SAL_CALL queryInterface(css::uno::Type const & type) + throw (css::uno::RuntimeException); + + virtual void SAL_CALL acquire() throw () { OWeakObject::acquire(); } + + virtual void SAL_CALL release() throw () { OWeakObject::release(); } + + virtual sal_Int32 SAL_CALL getFirst() throw (css::uno::RuntimeException); + + virtual void SAL_CALL setFirst(sal_Int32 value) + throw (css::uno::RuntimeException); + + virtual + css::beans::Ambiguous< + css::beans::Defaulted< css::beans::Optional< sal_Int32 > > > + SAL_CALL getSecond() + throw ( + css::beans::UnknownPropertyException, css::uno::RuntimeException); + + virtual void SAL_CALL setSecond( + css::beans::Ambiguous< + css::beans::Defaulted< css::beans::Optional< ::sal_Int32 > > > const & + value) + throw ( + css::beans::PropertyVetoException, + css::beans::UnknownPropertyException, css::uno::RuntimeException); + + virtual sal_Int32 SAL_CALL getThird() + throw ( + css::beans::UnknownPropertyException, css::uno::RuntimeException); + + virtual void SAL_CALL setThird(sal_Int32 value) + throw ( + css::beans::UnknownPropertyException, css::uno::RuntimeException); + + virtual sal_Int32 SAL_CALL getFourth() + throw ( + css::beans::UnknownPropertyException, css::uno::RuntimeException); + + virtual void SAL_CALL setFourth(sal_Int32 value) + throw ( + css::beans::UnknownPropertyException, css::uno::RuntimeException); + +private: + Full(Full &); // not defined + void operator =(Full &); // not defined + + virtual ~Full() {} + + osl::Mutex m_mutex; + sal_Int32 m_a1; + css::beans::Ambiguous< + css::beans::Defaulted< css::beans::Optional< sal_Int32 > > > m_a2; +}; + +css::uno::Any Full::queryInterface(css::uno::Type const & type) + throw (css::uno::RuntimeException) +{ + css::uno::Any a(OWeakObject::queryInterface(type)); + if (a.hasValue()) { + return a; + } + a = cppu::queryInterface( + type, + static_cast< test::cppuhelper::propertysetmixin::XTest3 * >(this)); + return a.hasValue() + ? a + : (cppu::PropertySetMixin< + test::cppuhelper::propertysetmixin::XTest3 >::queryInterface( + type)); +} + +sal_Int32 Full::getFirst() throw (css::uno::RuntimeException) { + osl::MutexGuard g(m_mutex); + return m_a1; +} + +void Full::setFirst(sal_Int32 value) throw (css::uno::RuntimeException) { + prepareSet( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("First")), css::uno::Any(), + css::uno::Any(), 0); + osl::MutexGuard g(m_mutex); + m_a1 = value; +} + +css::beans::Ambiguous< + css::beans::Defaulted< css::beans::Optional< sal_Int32 > > > +Full::getSecond() + throw (css::beans::UnknownPropertyException, css::uno::RuntimeException) +{ + osl::MutexGuard g(m_mutex); + return m_a2; +} + +void Full::setSecond( + css::beans::Ambiguous< + css::beans::Defaulted< css::beans::Optional< ::sal_Int32 > > > const & + value) + throw ( + css::beans::PropertyVetoException, css::beans::UnknownPropertyException, + css::uno::RuntimeException) +{ + css::uno::Any v; + if (value.Value.Value.IsPresent) { + v <<= value.Value.Value.Value; + } + BoundListeners l; + prepareSet( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Second")), css::uno::Any(), + v, &l); + { + osl::MutexGuard g(m_mutex); + m_a2 = value; + } + l.notify(); +} + +sal_Int32 Full::getThird() + throw (css::beans::UnknownPropertyException, css::uno::RuntimeException) +{ + throw css::beans::UnknownPropertyException( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Third")), + static_cast< cppu::OWeakObject * >(this)); +} + +void Full::setThird(sal_Int32) + throw (css::beans::UnknownPropertyException, css::uno::RuntimeException) +{ + throw css::beans::UnknownPropertyException( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Third")), + static_cast< cppu::OWeakObject * >(this)); +} + +sal_Int32 Full::getFourth() + throw (css::beans::UnknownPropertyException, css::uno::RuntimeException) +{ + throw css::beans::UnknownPropertyException( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Fourth")), + static_cast< cppu::OWeakObject * >(this)); +} + +void Full::setFourth(sal_Int32) + throw (css::beans::UnknownPropertyException, css::uno::RuntimeException) +{ + throw css::beans::UnknownPropertyException( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Fourth")), + static_cast< cppu::OWeakObject * >(this)); +} + +class Supplier: + public cppu::WeakImplHelper1< + test::cppuhelper::propertysetmixin::XSupplier > +{ +public: + explicit Supplier( + css::uno::Reference< css::uno::XComponentContext > const & context): + m_context(context) {} + + virtual css::uno::Reference< css::lang::XComponent > SAL_CALL getEmpty1() + throw (css::uno::RuntimeException) + { return new Empty1(m_context); } + + virtual css::uno::Reference< css::lang::XComponent > SAL_CALL getEmpty2() + throw (css::uno::RuntimeException) + { return new Empty2(m_context); } + + virtual css::uno::Reference< test::cppuhelper::propertysetmixin::XTest3 > + SAL_CALL getFull() throw (css::uno::RuntimeException) + { return new Full(m_context); } + +private: + Supplier(Supplier &); // not defined + void operator =(Supplier &); // not defined + + virtual ~Supplier() {} + + css::uno::Reference< css::uno::XComponentContext > m_context; +}; + +css::uno::Reference< css::uno::XInterface > SAL_CALL create( + css::uno::Reference< css::uno::XComponentContext > const & context) + SAL_THROW((css::uno::Exception)) +{ + return static_cast< cppu::OWeakObject * >(new Supplier(context)); +} + +rtl::OUString SAL_CALL getImplementationName() { + return rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "test.cppuhelper.propertysetmixin.comp.CppSupplier")); +} + +css::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames() { + css::uno::Sequence< rtl::OUString > s(1); + s[0] = rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "test.cppuhelper.propertysetmixin.CppSupplier")); + return s; +} + +cppu::ImplementationEntry entries[] = { + { &create, &getImplementationName, &getSupportedServiceNames, + &cppu::createSingleComponentFactory, 0, 0 }, + { 0, 0, 0, 0, 0, 0 } }; + +} + +extern "C" void * SAL_CALL component_getFactory( + char const * implName, void * serviceManager, void * registryKey) +{ + return cppu::component_getFactoryHelper( + implName, serviceManager, registryKey, entries); +} + +extern "C" void SAL_CALL component_getImplementationEnvironment( + char const ** envTypeName, uno_Environment **) +{ + *envTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; +} + +extern "C" sal_Bool SAL_CALL component_writeInfo( + void * serviceManager, void * registryKey) +{ + return cppu::component_writeInfoHelper( + serviceManager, registryKey, entries); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/qa/propertysetmixin/makefile.mk b/cppuhelper/qa/propertysetmixin/makefile.mk new file mode 100644 index 000000000000..edd4795fc115 --- /dev/null +++ b/cppuhelper/qa/propertysetmixin/makefile.mk @@ -0,0 +1,125 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +.IF "$(OOO_SUBSEQUENT_TESTS)" == "" +nothing .PHONY: +.ELSE + +PRJ := ../.. +PRJNAME := cppuhelper + +TARGET := qa_propertysetmixin +PACKAGE = test/cppuhelper/propertysetmixin/comp + +ENABLE_EXCEPTIONS := TRUE + +.INCLUDE: settings.mk + +.IF "$(OS)" == "WNT" +my_file = file:/// +.ELSE +my_file = file:// +.END + +DLLPRE = # no leading "lib" on .so files +INCPRE += -I$(MISC)/$(TARGET)/inc +CFLAGSCXX += $(CPPUNIT_CFLAGS) + +SHL1TARGET = $(TARGET) +SHL1OBJS = $(SLO)/test_propertysetmixin.obj +SHL1VERSIONMAP = test.map +SHL1STDLIBS = $(CPPULIB) $(CPPUHELPERLIB) $(CPPUNITLIB) $(SALLIB) +SHL1IMPLIB = i$(SHL1TARGET) +SHL1RPATH = NONE +DEF1NAME = $(SHL1TARGET) + +SHL2TARGET = $(TARGET).uno +SHL2OBJS = $(SLO)/comp_propertysetmixin.obj +SHL2VERSIONMAP = $(SOLARENV)/src/component.map +SHL2STDLIBS = $(CPPULIB) $(CPPUHELPERLIB) $(SALLIB) +SHL2IMPLIB = i$(SHL2TARGET) +SH21RPATH = NONE +DEF2NAME = $(SHL2TARGET) + +SLOFILES = $(SHL1OBJS) $(SHL2OBJS) + +JAVAFILES = JavaSupplier.java +JARFILES = java_uno.jar juh.jar jurt.jar ridl.jar + +.INCLUDE: target.mk + +ALLTAR: test + +$(MISC)/$(TARGET)/types.urd: types.idl + - $(MKDIR) $(@:d) + $(IDLC) -O$(@:d) -I$(SOLARIDLDIR) -cid -we $< + +$(MISC)/$(TARGET)/types.rdb: $(MISC)/$(TARGET)/types.urd + - $(RM) $@ + $(REGMERGE) $@ /UCR $< + +$(MISC)/$(TARGET)/uno.rdb: $(MISC)/$(TARGET)/types.rdb $(SHL2TARGETN) \ + $(MISC)/$(TARGET)/$(TARGET).uno.jar $(MISC)/$(TARGET)/bootstrap.rdb + - $(MKDIR) $(@:d) + $(COPY) $(SOLARBINDIR)/types.rdb $@ + $(REGMERGE) $@ / $(MISC)/$(TARGET)/types.rdb + $(REGCOMP) -register -r $@ -wop -c javaloader.uno -c javavm.uno \ + -c reflection.uno -c stocservices.uno -c $(SHL2TARGETN) + $(REGCOMP) -register -br $(MISC)/$(TARGET)/bootstrap.rdb -r $@ \ + -c $(my_file)$(PWD)/$(MISC)/$(TARGET)/$(TARGET).uno.jar \ + -env:URE_INTERNAL_JAVA_DIR=$(my_file)$(SOLARBINDIR) + +$(MISC)/$(TARGET)/bootstrap.rdb: + - $(MKDIR) $(@:d) + $(COPY) $(SOLARBINDIR)/types.rdb $@ + $(REGCOMP) -register -r $@ -wop -c javaloader.uno -c javavm.uno \ + -c stocservices.uno + +$(MISC)/$(TARGET)/cppumaker.flag: $(MISC)/$(TARGET)/types.rdb + $(CPPUMAKER) -O$(MISC)/$(TARGET)/inc -BUCR -Gc \ + -X$(SOLARBINDIR)/types.rdb $< + $(TOUCH) $@ + +$(SLOFILES): $(MISC)/$(TARGET)/cppumaker.flag + +$(MISC)/$(TARGET)/javamaker.flag: $(MISC)/$(TARGET)/types.rdb + $(JAVAMAKER) -O$(CLASSDIR) -BUCR -nD -Gc -X$(SOLARBINDIR)/types.rdb $< + $(TOUCH) $@ + +$(JAVATARGET): $(MISC)/$(TARGET)/javamaker.flag + +$(MISC)/$(TARGET)/$(TARGET).uno.jar: $(JAVATARGET) \ + $(MISC)/$(TARGET)/javamaker.flag manifest + jar cfm $@ manifest -C $(CLASSDIR) test/cppuhelper/propertysetmixin + +test .PHONY: $(SHL1TARGETN) $(MISC)/$(TARGET)/uno.rdb + $(CPPUNITTESTER) $(SHL1TARGETN) \ + -env:URE_INTERNAL_JAVA_DIR=$(my_file)$(SOLARBINDIR) \ + -env:URE_INTERNAL_LIB_DIR=$(my_file)$(SOLARSHAREDBIN) \ + -env:arg-reg=$(MISC)/$(TARGET)/uno.rdb -env:arg-path=$(SOLARSHAREDBIN) + +.END diff --git a/cppuhelper/qa/propertysetmixin/manifest b/cppuhelper/qa/propertysetmixin/manifest new file mode 100644 index 000000000000..168f4bc1927d --- /dev/null +++ b/cppuhelper/qa/propertysetmixin/manifest @@ -0,0 +1,2 @@ +Manifest-Version: 1.0 +RegistrationClassName: test.cppuhelper.propertysetmixin.comp.JavaSupplier diff --git a/cppuhelper/qa/propertysetmixin/test.map b/cppuhelper/qa/propertysetmixin/test.map new file mode 100644 index 000000000000..0dbbcc5a7372 --- /dev/null +++ b/cppuhelper/qa/propertysetmixin/test.map @@ -0,0 +1,34 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +UDK_3_0_0 { + global: + cppunitTestPlugIn; + + local: + *; +}; diff --git a/cppuhelper/qa/propertysetmixin/test_propertysetmixin.cxx b/cppuhelper/qa/propertysetmixin/test_propertysetmixin.cxx new file mode 100644 index 000000000000..3b05dc3f3eb2 --- /dev/null +++ b/cppuhelper/qa/propertysetmixin/test_propertysetmixin.cxx @@ -0,0 +1,683 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_cppuhelper.hxx" + +#include "sal/config.h" + +#include "test/cppuhelper/propertysetmixin/CppSupplier.hpp" +#include "test/cppuhelper/propertysetmixin/JavaSupplier.hpp" +#include "test/cppuhelper/propertysetmixin/XSupplier.hpp" +#include "test/cppuhelper/propertysetmixin/XTest3.hpp" + +#include "com/sun/star/beans/Ambiguous.hpp" +#include "com/sun/star/beans/Defaulted.hpp" +#include "com/sun/star/beans/Optional.hpp" +#include "com/sun/star/beans/Property.hpp" +#include "com/sun/star/beans/PropertyAttribute.hpp" +#include "com/sun/star/beans/PropertyChangeEvent.hpp" +#include "com/sun/star/beans/PropertyState.hpp" +#include "com/sun/star/beans/PropertyValue.hpp" +#include "com/sun/star/beans/PropertyVetoException.hpp" +#include "com/sun/star/beans/UnknownPropertyException.hpp" +#include "com/sun/star/beans/XFastPropertySet.hpp" +#include "com/sun/star/beans/XPropertyAccess.hpp" +#include "com/sun/star/beans/XPropertyChangeListener.hpp" +#include "com/sun/star/beans/XPropertySet.hpp" +#include "com/sun/star/beans/XPropertySetInfo.hpp" +#include "com/sun/star/beans/XVetoableChangeListener.hpp" +#include "com/sun/star/lang/XComponent.hpp" +#include "com/sun/star/lang/XMultiComponentFactory.hpp" +#include "com/sun/star/uno/Any.hxx" +#include "com/sun/star/uno/Reference.hxx" +#include "com/sun/star/uno/RuntimeException.hpp" +#include "com/sun/star/uno/Sequence.hxx" +#include "com/sun/star/uno/Type.hxx" +#include "com/sun/star/uno/XComponentContext.hpp" +#include "cppuhelper/implbase1.hxx" +#include "cppuhelper/servicefactory.hxx" +#include "cppunit/TestAssert.h" +#include "cppunit/TestFixture.h" +#include "cppunit/extensions/HelperMacros.h" +#include "cppunit/plugin/TestPlugIn.h" +#include "osl/mutex.hxx" +#include "rtl/bootstrap.hxx" +#include "rtl/ref.hxx" +#include "rtl/string.h" +#include "rtl/textenc.h" +#include "rtl/ustring.h" +#include "rtl/ustring.hxx" +#include "sal/types.h" + +#include <limits> +#include <ostream> + +namespace com { namespace sun { namespace star { + struct EventObject; +} } } + +namespace css = com::sun::star; + +namespace { + +std::ostream & operator <<(std::ostream & out, rtl::OUString const & value) { + return out << rtl::OUStringToOString(value, RTL_TEXTENCODING_UTF8).getStr(); +} + +std::ostream & operator <<(std::ostream & out, css::uno::Type const & value) { + return out << "com::sun::star::uno::Type[" << value.getTypeName() << ']'; +} + +std::ostream & operator <<(std::ostream & out, css::uno::Any const & value) { + return + out << "com::sun::star::uno::Any[" << value.getValueType() << ", ...]"; +} + +rtl::OUString getArgument(rtl::OUString const & name) { + rtl::OUString val; + CPPUNIT_ASSERT( + rtl::Bootstrap::get( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("arg-")) + name, val)); + return val; +} + +class BoundListener: + public cppu::WeakImplHelper1< css::beans::XPropertyChangeListener > +{ +public: + BoundListener(): m_count(0) {} + + int count() const { + osl::MutexGuard g(m_mutex); + return m_count; + } + + virtual void SAL_CALL disposing(css::lang::EventObject const &) + throw (css::uno::RuntimeException) + { + osl::MutexGuard g(m_mutex); + CPPUNIT_ASSERT(m_count < std::numeric_limits< int >::max()); + ++m_count; + } + + virtual void SAL_CALL propertyChange( + css::beans::PropertyChangeEvent const &) + throw (css::uno::RuntimeException) + { CPPUNIT_FAIL("BoundListener::propertyChange called"); } + +private: + BoundListener(BoundListener &); // not defined + void operator =(BoundListener &); // not defined + + virtual ~BoundListener() {} + + mutable osl::Mutex m_mutex; + int m_count; +}; + +class VetoListener: + public cppu::WeakImplHelper1< css::beans::XVetoableChangeListener > +{ +public: + VetoListener(): m_count(0) {} + + int count() const { + osl::MutexGuard g(m_mutex); + return m_count; + } + + virtual void SAL_CALL disposing(css::lang::EventObject const &) + throw (css::uno::RuntimeException) + { + osl::MutexGuard g(m_mutex); + CPPUNIT_ASSERT(m_count < std::numeric_limits< int >::max()); + ++m_count; + } + + virtual void SAL_CALL vetoableChange( + css::beans::PropertyChangeEvent const &) + throw (css::beans::PropertyVetoException, css::uno::RuntimeException) + { CPPUNIT_FAIL("VetoListener::vetoableChange called"); } + +private: + VetoListener(VetoListener &); // not defined + void operator =(VetoListener &); // not defined + + virtual ~VetoListener() {} + + mutable osl::Mutex m_mutex; + int m_count; +}; + +class Test: public CppUnit::TestFixture { +public: + virtual void setUp(); + + void finish(); + + void testCppEmpty1() { testEmpty1(getCppSupplier()); } + + void testCppEmpty2() { testEmpty2(getCppSupplier()); } + + void testCppFull() { testFull(getCppSupplier()); } + + void testJavaEmpty1() { testEmpty1(getJavaSupplier()); } + + void testJavaEmpty2() { testEmpty2(getJavaSupplier()); } + + void testJavaFull() { testFull(getJavaSupplier()); } + + CPPUNIT_TEST_SUITE(Test); + CPPUNIT_TEST(testCppEmpty1); + CPPUNIT_TEST(testCppEmpty2); + CPPUNIT_TEST(testCppFull); + CPPUNIT_TEST(testJavaEmpty1); + CPPUNIT_TEST(testJavaEmpty2); + CPPUNIT_TEST(testJavaFull); + CPPUNIT_TEST(finish); + CPPUNIT_TEST_SUITE_END(); + +private: + css::uno::Reference< test::cppuhelper::propertysetmixin::XSupplier > + getCppSupplier() const; + + css::uno::Reference< test::cppuhelper::propertysetmixin::XSupplier > + getJavaSupplier() const; + + void testEmpty1( + css::uno::Reference< test::cppuhelper::propertysetmixin::XSupplier > + const & supplier) const; + + void testEmpty2( + css::uno::Reference< test::cppuhelper::propertysetmixin::XSupplier > + const & supplier) const; + + void testFull( + css::uno::Reference< test::cppuhelper::propertysetmixin::XSupplier > + const & supplier) const; + + static css::uno::Reference< css::uno::XComponentContext > m_context; +}; + +void Test::setUp() { + // For whatever reason, on W32 it does not work to create/destroy a fresh + // component context for each test in Test::setUp/tearDown; therefore, a + // single component context is used for all tests and destroyed in the last + // pseudo-test "finish": + if (!m_context.is()) { + css::uno::Reference< css::lang::XMultiComponentFactory > factory( + cppu::createRegistryServiceFactory( + getArgument(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("reg"))), + sal_False, + getArgument( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("path")))), + css::uno::UNO_QUERY_THROW); + css::uno::Reference< css::beans::XPropertySet >( + factory, css::uno::UNO_QUERY_THROW)->getPropertyValue( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext"))) + >>= m_context; + } +} + +void Test::finish() { + css::uno::Reference< css::lang::XComponent >( + m_context, css::uno::UNO_QUERY_THROW)->dispose(); +} + +css::uno::Reference< test::cppuhelper::propertysetmixin::XSupplier > +Test::getCppSupplier() const +{ + return test::cppuhelper::propertysetmixin::CppSupplier::create(m_context); +} + +css::uno::Reference< test::cppuhelper::propertysetmixin::XSupplier > +Test::getJavaSupplier() const +{ + return test::cppuhelper::propertysetmixin::JavaSupplier::create(m_context); +} + +void Test::testEmpty1( + css::uno::Reference< test::cppuhelper::propertysetmixin::XSupplier > + const & supplier) const +{ + css::uno::Reference< css::lang::XComponent > empty1( + supplier->getEmpty1(), css::uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT( + !css::uno::Reference< css::beans::XPropertySet >( + empty1, css::uno::UNO_QUERY).is()); + CPPUNIT_ASSERT( + !css::uno::Reference< css::beans::XFastPropertySet >( + empty1, css::uno::UNO_QUERY).is()); + CPPUNIT_ASSERT( + !css::uno::Reference< css::beans::XPropertyAccess >( + empty1, css::uno::UNO_QUERY).is()); + empty1->dispose(); +} + +void Test::testEmpty2( + css::uno::Reference< test::cppuhelper::propertysetmixin::XSupplier > + const & supplier) const +{ + css::uno::Reference< css::lang::XComponent > empty2( + supplier->getEmpty2(), css::uno::UNO_QUERY_THROW); + css::uno::Reference< css::beans::XPropertySet > empty2p( + empty2, css::uno::UNO_QUERY); + CPPUNIT_ASSERT(empty2p.is()); + css::uno::Reference< css::beans::XPropertySetInfo > info( + empty2p->getPropertySetInfo()); + CPPUNIT_ASSERT(info.is()); + CPPUNIT_ASSERT_EQUAL( + static_cast< sal_Int32 >(0), info->getProperties().getLength()); + try { + info->getPropertyByName( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("any"))); + CPPUNIT_FAIL("exception expected"); + } catch (css::beans::UnknownPropertyException &) {} + CPPUNIT_ASSERT( + !info->hasPropertyByName( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("any")))); + try { + empty2p->setPropertyValue( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("any")), css::uno::Any()); + CPPUNIT_FAIL("exception expected"); + } catch (css::beans::UnknownPropertyException &) {} + try { + empty2p->getPropertyValue( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("any"))); + CPPUNIT_FAIL("exception expected"); + } catch (css::beans::UnknownPropertyException &) {} + rtl::Reference< BoundListener > boundListener1(new BoundListener); + empty2p->addPropertyChangeListener(rtl::OUString(), boundListener1.get()); + empty2p->addPropertyChangeListener(rtl::OUString(), boundListener1.get()); + rtl::Reference< BoundListener > boundListener2(new BoundListener); + empty2p->removePropertyChangeListener( + rtl::OUString(), boundListener2.get()); + rtl::Reference< VetoListener > vetoListener1(new VetoListener); + empty2p->addVetoableChangeListener(rtl::OUString(), vetoListener1.get()); + empty2p->addVetoableChangeListener(rtl::OUString(), vetoListener1.get()); + rtl::Reference< VetoListener > vetoListener2(new VetoListener); + empty2p->addVetoableChangeListener(rtl::OUString(), vetoListener2.get()); + empty2p->removeVetoableChangeListener(rtl::OUString(), vetoListener2.get()); + css::uno::Reference< css::beans::XFastPropertySet > empty2f( + empty2, css::uno::UNO_QUERY); + CPPUNIT_ASSERT(empty2f.is()); + try { + empty2f->setFastPropertyValue(-1, css::uno::Any()); + CPPUNIT_FAIL("exception expected"); + } catch (css::beans::UnknownPropertyException &) {} + try { + empty2f->setFastPropertyValue(0, css::uno::Any()); + CPPUNIT_FAIL("exception expected"); + } catch (css::beans::UnknownPropertyException &) {} + try { + empty2f->getFastPropertyValue(-1); + CPPUNIT_FAIL("exception expected"); + } catch (css::beans::UnknownPropertyException &) {} + try { + empty2f->getFastPropertyValue(0); + CPPUNIT_FAIL("exception expected"); + } catch (css::beans::UnknownPropertyException &) {} + css::uno::Reference< css::beans::XPropertyAccess > empty2a( + empty2, css::uno::UNO_QUERY); + CPPUNIT_ASSERT(empty2a.is()); + CPPUNIT_ASSERT_EQUAL( + static_cast< sal_Int32 >(0), empty2a->getPropertyValues().getLength()); + empty2a->setPropertyValues( + css::uno::Sequence< css::beans::PropertyValue >()); + css::uno::Sequence< css::beans::PropertyValue > vs(2); + vs[0].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("any1")); + vs[0].Handle = -1; + vs[0].State = css::beans::PropertyState_DIRECT_VALUE; + vs[0].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("any2")); + vs[0].Handle = -1; + vs[0].State = css::beans::PropertyState_DIRECT_VALUE; + try { + empty2a->setPropertyValues(vs); + CPPUNIT_FAIL("exception expected"); + } catch (css::beans::UnknownPropertyException &) {} + CPPUNIT_ASSERT_EQUAL(0, boundListener1->count()); + CPPUNIT_ASSERT_EQUAL(0, boundListener2->count()); + CPPUNIT_ASSERT_EQUAL(0, vetoListener1->count()); + CPPUNIT_ASSERT_EQUAL(0, vetoListener2->count()); + empty2->dispose(); + CPPUNIT_ASSERT_EQUAL(2, boundListener1->count()); + CPPUNIT_ASSERT_EQUAL(0, boundListener2->count()); + CPPUNIT_ASSERT_EQUAL(2, vetoListener1->count()); + CPPUNIT_ASSERT_EQUAL(0, vetoListener2->count()); + empty2p->removePropertyChangeListener( + rtl::OUString(), boundListener1.get()); + empty2p->removePropertyChangeListener( + rtl::OUString(), boundListener2.get()); + empty2p->removeVetoableChangeListener(rtl::OUString(), vetoListener1.get()); + empty2p->removeVetoableChangeListener(rtl::OUString(), vetoListener2.get()); + empty2p->addPropertyChangeListener(rtl::OUString(), boundListener1.get()); + empty2p->addPropertyChangeListener(rtl::OUString(), boundListener2.get()); + empty2p->addVetoableChangeListener(rtl::OUString(), vetoListener1.get()); + empty2p->addVetoableChangeListener(rtl::OUString(), vetoListener2.get()); + try { + empty2p->addPropertyChangeListener( + rtl::OUString(), + css::uno::Reference< css::beans::XPropertyChangeListener >()); + } catch (css::uno::RuntimeException &) {} + try { + empty2p->addVetoableChangeListener( + rtl::OUString(), + css::uno::Reference< css::beans::XVetoableChangeListener >()); + } catch (css::uno::RuntimeException &) {} + CPPUNIT_ASSERT_EQUAL(3, boundListener1->count()); + CPPUNIT_ASSERT_EQUAL(1, boundListener2->count()); + CPPUNIT_ASSERT_EQUAL(3, vetoListener1->count()); + CPPUNIT_ASSERT_EQUAL(1, vetoListener2->count()); +} + +void Test::testFull( + css::uno::Reference< test::cppuhelper::propertysetmixin::XSupplier > + const & supplier) const +{ + css::uno::Reference< test::cppuhelper::propertysetmixin::XTest3 > full( + supplier->getFull(), css::uno::UNO_QUERY_THROW); + css::uno::Reference< css::beans::XPropertySet > fullp( + full, css::uno::UNO_QUERY); + CPPUNIT_ASSERT(fullp.is()); + css::uno::Reference< css::beans::XPropertySetInfo > info( + fullp->getPropertySetInfo()); + CPPUNIT_ASSERT(info.is()); + CPPUNIT_ASSERT_EQUAL( + static_cast< sal_Int32 >(3), info->getProperties().getLength()); + css::beans::Property prop( + info->getPropertyByName( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("First")))); + CPPUNIT_ASSERT_EQUAL( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("First")), prop.Name); + CPPUNIT_ASSERT_EQUAL(static_cast< sal_Int32 >(0), prop.Handle); + CPPUNIT_ASSERT_EQUAL(getCppuType(static_cast< sal_Int32 * >(0)), prop.Type); + CPPUNIT_ASSERT_EQUAL(static_cast< sal_Int16 >(0), prop.Attributes); + prop = info->getPropertyByName( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Second"))); + CPPUNIT_ASSERT_EQUAL( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Second")), prop.Name); + CPPUNIT_ASSERT_EQUAL(static_cast< sal_Int32 >(1), prop.Handle); + CPPUNIT_ASSERT_EQUAL(getCppuType(static_cast< sal_Int32 * >(0)), prop.Type); + CPPUNIT_ASSERT_EQUAL( + static_cast< sal_Int16 >( + css::beans::PropertyAttribute::MAYBEVOID + | css::beans::PropertyAttribute::BOUND + | css::beans::PropertyAttribute::CONSTRAINED + | css::beans::PropertyAttribute::MAYBEAMBIGUOUS + | css::beans::PropertyAttribute::MAYBEDEFAULT + | css::beans::PropertyAttribute::OPTIONAL), + prop.Attributes); + try { + info->getPropertyByName( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Third"))); + CPPUNIT_FAIL("exception expected"); + } catch (css::beans::UnknownPropertyException &) {} + prop = info->getPropertyByName( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Fourth"))); + CPPUNIT_ASSERT_EQUAL( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Fourth")), prop.Name); + CPPUNIT_ASSERT_EQUAL(static_cast< sal_Int32 >(3), prop.Handle); + CPPUNIT_ASSERT_EQUAL(getCppuType(static_cast< sal_Int32 * >(0)), prop.Type); + CPPUNIT_ASSERT_EQUAL( + static_cast< sal_Int16 >(css::beans::PropertyAttribute::OPTIONAL), + prop.Attributes); + try { + info->getPropertyByName( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("first"))); + CPPUNIT_FAIL("exception expected"); + } catch (css::beans::UnknownPropertyException &) {} + CPPUNIT_ASSERT( + info->hasPropertyByName( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("First")))); + CPPUNIT_ASSERT( + info->hasPropertyByName( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Second")))); + CPPUNIT_ASSERT( + !info->hasPropertyByName( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Third")))); + CPPUNIT_ASSERT( + info->hasPropertyByName( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Fourth")))); + CPPUNIT_ASSERT( + !info->hasPropertyByName( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("first")))); + CPPUNIT_ASSERT_EQUAL( + css::uno::makeAny(static_cast< sal_Int32 >(0)), + fullp->getPropertyValue( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("First")))); + fullp->setPropertyValue( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("First")), + css::uno::makeAny(static_cast< sal_Int32 >(-100))); + CPPUNIT_ASSERT_EQUAL( + css::uno::makeAny(static_cast< sal_Int32 >(-100)), + fullp->getPropertyValue( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("First")))); + css::uno::Any voidAny; + CPPUNIT_ASSERT_EQUAL( + voidAny, + fullp->getPropertyValue( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Second")))); + fullp->setPropertyValue( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Second")), + css::uno::makeAny(static_cast< sal_Int32 >(100))); + CPPUNIT_ASSERT_EQUAL( + css::uno::makeAny(static_cast< sal_Int32 >(100)), + fullp->getPropertyValue( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Second")))); + CPPUNIT_ASSERT(full->getSecond().Value.Value.IsPresent); + CPPUNIT_ASSERT_EQUAL( + static_cast< sal_Int32 >(100), full->getSecond().Value.Value.Value); + CPPUNIT_ASSERT(!full->getSecond().Value.IsDefaulted); + CPPUNIT_ASSERT(!full->getSecond().IsAmbiguous); + fullp->setPropertyValue( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Second")), + css::uno::Any()); + CPPUNIT_ASSERT_EQUAL( + voidAny, + fullp->getPropertyValue( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Second")))); + CPPUNIT_ASSERT(!full->getSecond().Value.Value.IsPresent); + CPPUNIT_ASSERT(!full->getSecond().Value.IsDefaulted); + CPPUNIT_ASSERT(!full->getSecond().IsAmbiguous); + try { + fullp->setPropertyValue( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Third")), + css::uno::makeAny(static_cast< sal_Int32 >(100))); + CPPUNIT_FAIL("exception expected"); + } catch (css::beans::UnknownPropertyException &) {} + try { + fullp->getPropertyValue( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Third"))); + CPPUNIT_FAIL("exception expected"); + } catch (css::beans::UnknownPropertyException &) {} + try { + fullp->setPropertyValue( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Fourth")), + css::uno::makeAny(static_cast< sal_Int32 >(100))); + CPPUNIT_FAIL("exception expected"); + } catch (css::beans::UnknownPropertyException &) {} + try { + fullp->getPropertyValue( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Fourth"))); + CPPUNIT_FAIL("exception expected"); + } catch (css::beans::UnknownPropertyException &) {} + try { + fullp->setPropertyValue( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("first")), + css::uno::Any()); + CPPUNIT_FAIL("exception expected"); + } catch (css::beans::UnknownPropertyException &) {} + try { + fullp->getPropertyValue( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("first"))); + CPPUNIT_FAIL("exception expected"); + } catch (css::beans::UnknownPropertyException &) {} + css::uno::Reference< css::beans::XFastPropertySet > fullf( + full, css::uno::UNO_QUERY); + CPPUNIT_ASSERT(fullf.is()); + CPPUNIT_ASSERT_EQUAL( + css::uno::makeAny(static_cast< sal_Int32 >(-100)), + fullf->getFastPropertyValue(0)); + fullf->setFastPropertyValue( + 0, css::uno::makeAny(static_cast< sal_Int32 >(0))); + CPPUNIT_ASSERT_EQUAL( + css::uno::makeAny(static_cast< sal_Int32 >(0)), + fullf->getFastPropertyValue(0)); + try { + fullf->getFastPropertyValue(-1); + } catch (css::beans::UnknownPropertyException &) {} + try { + fullf->setFastPropertyValue(-1, css::uno::Any()); + } catch (css::beans::UnknownPropertyException &) {} + css::uno::Reference< css::beans::XPropertyAccess > fulla( + full, css::uno::UNO_QUERY); + CPPUNIT_ASSERT(fulla.is()); + css::uno::Sequence< css::beans::PropertyValue > vs( + fulla->getPropertyValues()); + CPPUNIT_ASSERT_EQUAL(static_cast< sal_Int32 >(2), vs.getLength()); + CPPUNIT_ASSERT_EQUAL( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("First")), vs[0].Name); + CPPUNIT_ASSERT_EQUAL(static_cast< sal_Int32 >(0), vs[0].Handle); + CPPUNIT_ASSERT_EQUAL( + css::uno::makeAny(static_cast< sal_Int32 >(0)), vs[0].Value); + CPPUNIT_ASSERT_EQUAL(css::beans::PropertyState_DIRECT_VALUE, vs[0].State); + CPPUNIT_ASSERT_EQUAL( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Second")), vs[1].Name); + CPPUNIT_ASSERT_EQUAL(static_cast< sal_Int32 >(1), vs[1].Handle); + CPPUNIT_ASSERT_EQUAL(voidAny, vs[1].Value); + CPPUNIT_ASSERT_EQUAL(css::beans::PropertyState_DIRECT_VALUE, vs[1].State); + vs[0].Value <<= static_cast< sal_Int32 >(-100); + vs[1].Value <<= static_cast< sal_Int32 >(100); + vs[1].State = css::beans::PropertyState_AMBIGUOUS_VALUE; + fulla->setPropertyValues(vs); + vs = fulla->getPropertyValues(); + CPPUNIT_ASSERT_EQUAL(static_cast< sal_Int32 >(2), vs.getLength()); + CPPUNIT_ASSERT_EQUAL( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("First")), vs[0].Name); + CPPUNIT_ASSERT_EQUAL( + css::uno::makeAny(static_cast< sal_Int32 >(-100)), vs[0].Value); + CPPUNIT_ASSERT_EQUAL(css::beans::PropertyState_DIRECT_VALUE, vs[0].State); + CPPUNIT_ASSERT_EQUAL( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Second")), vs[1].Name); + CPPUNIT_ASSERT_EQUAL( + css::uno::makeAny(static_cast< sal_Int32 >(100)), vs[1].Value); + CPPUNIT_ASSERT_EQUAL( + css::beans::PropertyState_AMBIGUOUS_VALUE, vs[1].State); + CPPUNIT_ASSERT(full->getSecond().Value.Value.IsPresent); + CPPUNIT_ASSERT_EQUAL( + static_cast< sal_Int32 >(100), full->getSecond().Value.Value.Value); + CPPUNIT_ASSERT(!full->getSecond().Value.IsDefaulted); + CPPUNIT_ASSERT(full->getSecond().IsAmbiguous); + css::uno::Reference< css::beans::XPropertyChangeListener > boundListener( + new BoundListener); + fullp->addPropertyChangeListener( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("First")), boundListener); + fullp->removePropertyChangeListener( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("First")), boundListener); + fullp->addPropertyChangeListener( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Second")), boundListener); + fullp->removePropertyChangeListener( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Second")), boundListener); + try { + fullp->addPropertyChangeListener( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Third")), + boundListener); + CPPUNIT_FAIL("exception expected"); + } catch (css::beans::UnknownPropertyException &) {} + try { + fullp->removePropertyChangeListener( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Third")), + boundListener); + CPPUNIT_FAIL("exception expected"); + } catch (css::beans::UnknownPropertyException &) {} + fullp->addPropertyChangeListener( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Fourth")), boundListener); + fullp->removePropertyChangeListener( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Fourth")), boundListener); + try { + fullp->addPropertyChangeListener( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Fifth")), + boundListener); + CPPUNIT_FAIL("exception expected"); + } catch (css::beans::UnknownPropertyException &) {} + try { + fullp->removePropertyChangeListener( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Fifth")), + boundListener); + CPPUNIT_FAIL("exception expected"); + } catch (css::beans::UnknownPropertyException &) {} + css::uno::Reference< css::beans::XVetoableChangeListener > vetoListener( + new VetoListener); + fullp->addVetoableChangeListener( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("First")), vetoListener); + fullp->removeVetoableChangeListener( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("First")), vetoListener); + fullp->addVetoableChangeListener( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Second")), vetoListener); + fullp->removeVetoableChangeListener( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Second")), vetoListener); + try { + fullp->addVetoableChangeListener( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Third")), + vetoListener); + CPPUNIT_FAIL("exception expected"); + } catch (css::beans::UnknownPropertyException &) {} + try { + fullp->removeVetoableChangeListener( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Third")), + vetoListener); + CPPUNIT_FAIL("exception expected"); + } catch (css::beans::UnknownPropertyException &) {} + fullp->addVetoableChangeListener( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Fourth")), vetoListener); + fullp->removeVetoableChangeListener( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Fourth")), vetoListener); + try { + fullp->addVetoableChangeListener( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Fifth")), + vetoListener); + CPPUNIT_FAIL("exception expected"); + } catch (css::beans::UnknownPropertyException &) {} + try { + fullp->removeVetoableChangeListener( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Fifth")), + vetoListener); + CPPUNIT_FAIL("exception expected"); + } catch (css::beans::UnknownPropertyException &) {} +} + +css::uno::Reference< css::uno::XComponentContext > Test::m_context; + +CPPUNIT_TEST_SUITE_REGISTRATION(Test); + +} + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/qa/propertysetmixin/types.idl b/cppuhelper/qa/propertysetmixin/types.idl new file mode 100644 index 000000000000..cd8659362367 --- /dev/null +++ b/cppuhelper/qa/propertysetmixin/types.idl @@ -0,0 +1,85 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __testtools_servicetests_TestService1_idl__ +#define __testtools_servicetests_TestService1_idl__ + +#include <com/sun/star/beans/Ambiguous.idl> +#include <com/sun/star/beans/Defaulted.idl> +#include <com/sun/star/beans/Optional.idl> +#include <com/sun/star/beans/PropertyVetoException.idl> +#include <com/sun/star/beans/UnknownPropertyException.idl> +#include <com/sun/star/lang/XComponent.idl> +#include <com/sun/star/uno/XInterface.idl> + +module test { module cppuhelper { module propertysetmixin { + +interface XTest1 { + [attribute] long First; +}; + +interface XTest2 { + [attribute, bound] + com::sun::star::beans::Ambiguous< + com::sun::star::beans::Defaulted< + com::sun::star::beans::Optional< long > > > Second + { + get raises (com::sun::star::beans::UnknownPropertyException); + set raises ( + com::sun::star::beans::PropertyVetoException, + com::sun::star::beans::UnknownPropertyException); + }; +}; + +interface XTest3 { + interface XTest1; + interface XTest2; + [attribute] long Third { + get raises (com::sun::star::beans::UnknownPropertyException); + set raises (com::sun::star::beans::UnknownPropertyException); + }; + [attribute] long Fourth { + get raises (com::sun::star::beans::UnknownPropertyException); + set raises (com::sun::star::beans::UnknownPropertyException); + }; +}; + +interface XSupplier { + com::sun::star::lang::XComponent getEmpty1(); + + com::sun::star::lang::XComponent getEmpty2(); + + XTest3 getFull(); +}; + +service CppSupplier: XSupplier; + +service JavaSupplier: XSupplier; + +}; }; }; + +#endif diff --git a/cppuhelper/qa/sce/test_unourl.sce b/cppuhelper/qa/sce/test_unourl.sce new file mode 100644 index 000000000000..d937ca31161d --- /dev/null +++ b/cppuhelper/qa/sce/test_unourl.sce @@ -0,0 +1 @@ +UnoUrl diff --git a/cppuhelper/qa/unourl/cppu_unourl.cxx b/cppuhelper/qa/unourl/cppu_unourl.cxx new file mode 100644 index 000000000000..c37d08a28a24 --- /dev/null +++ b/cppuhelper/qa/unourl/cppu_unourl.cxx @@ -0,0 +1,483 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <testshl/simpleheader.hxx> + +#include "cppuhelper/unourl.hxx" +#include "rtl/malformeduriexception.hxx" +#include "rtl/strbuf.hxx" +#include "rtl/string.h" +#include "rtl/textenc.h" +#include "rtl/ustring.hxx" +#include "sal/types.h" + +namespace cppu_unourl +{ + class UrlTest : public CppUnit::TestFixture + { + public: + void testDescriptorParsing() + { + struct Test + { + char const * pInput; + bool bValid; + }; + static Test const aTests[] + = { { "", false }, + { "abc", true }, + { "Abc", true }, + { "aBC", true }, + { "ABC", true }, + { "1abc", true }, + { "123", true }, + { "abc-1", false }, + { "ab%63", false }, + { "abc,", false }, + { "abc,def=", true }, + { "abc,Def=", true }, + { "abc,DEF=", true }, + { "abc,1def=", true }, + { "abc,123=", true }, + { "abc,def-1=", false }, + { "abc,def", false }, + { "abc,def=xxx,def=xxx", false }, + { "abc,def=xxx,ghi=xxx", true }, + { "abc,,def=xxx", false }, + { "abc,def=xxx,,ghi=xxx", false }, + { "abc,def=xxx,ghi=xxx,", false }, + { "abc,def=%", true }, + { "abc,def=%1", true }, + { "abc,def=%00", true }, + { "abc,def=%22", true }, + { "abc,def=\"", true }, + { "abc,def=%ed%a0%80", true } }; + for (int i = 0; i < sizeof aTests / sizeof (Test); ++i) + { + bool bValid = false; + try + { + cppu::UnoUrlDescriptor aDescriptor(rtl::OUString::createFromAscii( + aTests[i].pInput)); + bValid = true; + } + catch (rtl::MalformedUriException &) + {} + + if (aTests[i].bValid) + { + CPPUNIT_ASSERT_MESSAGE("Valid uri parsed as invalid", bValid); + } + else + { + CPPUNIT_ASSERT_MESSAGE("Invalid uri parsed as valid", !bValid); + } + } + } + + void testDescriptorDescriptor() + { + struct Test + { + char const * pInput; + char const * pDescriptor; + }; + static Test const aTests[] + = {{ "abc", "abc" }, + { "Abc", "Abc" }, + { "aBC", "aBC" }, + { "ABC", "ABC" }, + { "1abc", "1abc" }, + { "123", "123" }, + { "abc,def=", "abc,def=" }, + { "abc,Def=", "abc,Def=" }, + { "abc,DEF=", "abc,DEF=" }, + { "abc,1def=", "abc,1def=" }, + { "abc,123=", "abc,123=" }, + { "abc,def=xxx,ghi=xxx", "abc,def=xxx,ghi=xxx" }, + { "abc,def=%", "abc,def=%" }, + { "abc,def=%1", "abc,def=%1" }, + { "abc,def=%00", "abc,def=%00" }, + { "abc,def=%22", "abc,def=%22" }, + { "abc,def=\"", "abc,def=\"" }, + { "abc,def=%ed%a0%80", "abc,def=%ed%a0%80" } }; + bool bResult = true; + for (int i = 0; i < sizeof aTests / sizeof (Test); ++i) + { + bool bValid = false; + rtl::OUString aDescriptor; + try + { + aDescriptor = cppu::UnoUrlDescriptor(rtl::OUString::createFromAscii( + aTests[i].pInput)). + getDescriptor(); + bValid = true; + } + catch (rtl::MalformedUriException &) + {} + + CPPUNIT_ASSERT_MESSAGE("Failed to parse URI", bValid); + CPPUNIT_ASSERT_MESSAGE("Failed to parse URI correctly", + aDescriptor.equalsAscii( + aTests[i].pDescriptor)); + } + } + + + void testDescriptorName() + { + struct Test + { + char const * pInput; + char const * pName; + }; + static Test const aTests[] + = { { "abc", "abc" }, + { "Abc", "abc" }, + { "aBC", "abc" }, + { "ABC", "abc" }, + { "1abc", "1abc" }, + { "123", "123" }, + { "abc,def=", "abc" }, + { "abc,Def=", "abc" }, + { "abc,DEF=", "abc" }, + { "abc,1def=", "abc" }, + { "abc,123=", "abc" }, + { "abc,def=xxx,ghi=xxx", "abc" }, + { "abc,def=%", "abc" }, + { "abc,def=%1", "abc" }, + { "abc,def=%00", "abc" }, + { "abc,def=%22", "abc" }, + { "abc,def=\"", "abc" }, + { "abc,def=%ed%a0%80", "abc" } }; + for (int i = 0; i < sizeof aTests / sizeof (Test); ++i) + { + bool bValid = false; + rtl::OUString aName; + try + { + aName = cppu::UnoUrlDescriptor(rtl::OUString::createFromAscii( + aTests[i].pInput)).getName(); + bValid = true; + } + catch (rtl::MalformedUriException &) + {} + + CPPUNIT_ASSERT_MESSAGE("Failed to parse URI", bValid); + CPPUNIT_ASSERT_MESSAGE("Failed to parse URI correctly", + aName.equalsAscii(aTests[i].pName)); + } + } + + void testDescriptorKey(void) + { + struct Test + { + char const * pInput; + char const * pKey; + bool bPresent; + }; + static Test const aTests[] + = { { "abc", "abc", false }, + { "abc", "def", false }, + { "1abc", "def", false }, + { "123", "def", false }, + { "abc,def=", "abc", false }, + { "abc,def=", "def", true }, + { "abc,def=", "defg", false }, + { "abc,def=", "de", false }, + { "abc,def=", "ghi", false }, + { "abc,Def=", "def", true }, + { "abc,Def=", "Def", true }, + { "abc,Def=", "dEF", true }, + { "abc,Def=", "DEF", true }, + { "abc,def=xxx,ghi=xxx", "abc", false }, + { "abc,def=xxx,ghi=xxx", "def", true }, + { "abc,def=xxx,ghi=xxx", "ghi", true }, + { "abc,def=xxx,ghi=xxx", "jkl", false } }; + for (int i = 0; i < sizeof aTests / sizeof (Test); ++i) + { + bool bValid = false; + bool bPresent = false; + try + { + bPresent = cppu::UnoUrlDescriptor(rtl::OUString::createFromAscii( + aTests[i].pInput)). + hasParameter(rtl::OUString::createFromAscii(aTests[i].pKey)); + bValid = true; + } + catch (rtl::MalformedUriException &) + {} + + CPPUNIT_ASSERT_MESSAGE("Failed to parse URI", bValid); + CPPUNIT_ASSERT_MESSAGE("Failed to detect parameter correctly", + bPresent == aTests[i].bPresent); + } + } + + void testDescriptorValue() + { + struct Test + { + char const * pInput; + char const * pKey; + char const * pValue; + }; + static Test const aTests[] + = { { "abc", "abc", "" }, + { "abc", "def", "" }, + { "1abc", "def", "" }, + { "123", "def", "" }, + { "abc,def=", "abc", "" }, + { "abc,def=", "def", "" }, + { "abc,def=", "defg", "" }, + { "abc,def=", "de", "" }, + { "abc,def=", "ghi", "" }, + { "abc,Def=", "def", "" }, + { "abc,Def=", "Def", "" }, + { "abc,Def=", "dEF", "" }, + { "abc,Def=", "DEF", "" }, + { "abc,def=xxx,ghi=xxx", "abc", "" }, + { "abc,def=xxx,ghi=xxx", "def", "xxx" }, + { "abc,def=xxx,ghi=xxx", "ghi", "xxx" }, + { "abc,def=xxx,ghi=xxx", "jkl", "" }, + { "abc,def=%", "def", "%" }, + { "abc,def=%1", "def", "%1" }, + { "abc,def=%22", "def", "\"" }, + { "abc,def=\"", "def", "\"" }, + { "abc,def=abc", "def", "abc" }, + { "abc,def=Abc", "def", "Abc" }, + { "abc,def=aBC", "def", "aBC" }, + { "abc,def=ABC", "def", "ABC" }, + { "abc,def=%,ghi=", "def", "%" }, + { "abc,def=%1,ghi=", "def", "%1" }, + { "abc,def=%22,ghi=", "def", "\"" }, + { "abc,def=\",ghi=", "def", "\"" }, + { "abc,def=abc,ghi=", "def", "abc" }, + { "abc,def=Abc,ghi=", "def", "Abc" }, + { "abc,def=aBC,ghi=", "def", "aBC" }, + { "abc,def=ABC,ghi=", "def", "ABC" }, + { "abc,abc=,def=%", "def", "%" }, + { "abc,abc=,def=%1", "def", "%1" }, + { "abc,abc=,def=%22", "def", "\"" }, + { "abc,abc=,def=\"", "def", "\"" }, + { "abc,abc=,def=abc", "def", "abc" }, + { "abc,abc=,def=Abc", "def", "Abc" }, + { "abc,abc=,def=aBC", "def", "aBC" }, + { "abc,abc=,def=ABC", "def", "ABC" } }; + for (int i = 0; i < sizeof aTests / sizeof (Test); ++i) + { + bool bValid = false; + rtl::OUString aValue; + try + { + aValue = cppu::UnoUrlDescriptor(rtl::OUString::createFromAscii( + aTests[i].pInput)). + getParameter(rtl::OUString::createFromAscii(aTests[i].pKey)); + bValid = true; + } + catch (rtl::MalformedUriException &) + {} + CPPUNIT_ASSERT_MESSAGE("Failed to parse URI", bValid); + CPPUNIT_ASSERT_MESSAGE("Failed to get param correctly", + aValue.equalsAscii(aTests[i].pValue)); + } + } + + void testUrlParsing() + { + struct Test + { + char const * pInput; + bool bValid; + }; + static Test const aTests[] + = { { "", false }, + { "abc", false }, + { "uno", false }, + { "uno:", false }, + { "uno:abc;def;ghi", true }, + { "Uno:abc;def;ghi", true }, + { "uNO:abc;def;ghi", true }, + { "UNO:abc;def;ghi", true }, + { "uno:abc,def=xxx,ghi=xxx;def,ghi=xxx,jkl=xxx;ghi", true }, + { "uno:abc,def=xxx,ghi=xxx;def,ghi=xxx,jkl=xxx,;ghi", false }, + { "uno:abc;def;", false }, + { "uno:abc;def;a", true }, + { "uno:abc;def;A", true }, + { "uno:abc;def;1", true }, + { "uno:abc;def;$&+,/:=?@", true }, + { "uno:abc;def;%24&+,/:=?@", false } }; + for (int i = 0; i < sizeof aTests / sizeof (Test); ++i) + { + bool bValid = false; + try + { + cppu::UnoUrl aUrl(rtl::OUString::createFromAscii(aTests[i].pInput)); + bValid = true; + } + catch (rtl::MalformedUriException &) + {} + + if (aTests[i].bValid) + { + CPPUNIT_ASSERT_MESSAGE("Valid uri parsed as invalid", bValid); + } + else + { + CPPUNIT_ASSERT_MESSAGE("Invalid uri parsed as valid", !bValid); + } + + } + } + + void testUrlConnection() + { + struct Test + { + char const * pInput; + char const * pConnection; + }; + static Test const aTests[] + = { { "uno:abc;def;ghi", "abc" }, + { "uno:Abc;def;ghi", "Abc" }, + { "uno:aBC;def;ghi", "aBC" }, + { "uno:ABC;def;ghi", "ABC" }, + { "uno:abc,def=xxx,ghi=xxx;def,ghi=xxx,jkl=xxx;ghi", + "abc,def=xxx,ghi=xxx" } }; + for (int i = 0; i < sizeof aTests / sizeof (Test); ++i) + { + bool bValid = false; + rtl::OUString aConnection; + try + { + aConnection = cppu::UnoUrl(rtl::OUString::createFromAscii( + aTests[i].pInput)). + getConnection().getDescriptor(); + bValid = true; + } + catch (rtl::MalformedUriException &) + {} + CPPUNIT_ASSERT_MESSAGE("Failed to parse URI", bValid); + CPPUNIT_ASSERT_MESSAGE("Failed to get param correctly", + aConnection.equalsAscii( + aTests[i].pConnection)); + } + } + + void testUrlProtocol() + { + struct Test + { + char const * pInput; + char const * pProtocol; + }; + static Test const aTests[] + = { { "uno:abc;def;ghi", "def" }, + { "uno:abc;Def;ghi", "Def" }, + { "uno:abc;dEF;ghi", "dEF" }, + { "uno:abc;DEF;ghi", "DEF" }, + { "uno:abc,def=xxx,ghi=xxx;def,ghi=xxx,jkl=xxx;ghi", + "def,ghi=xxx,jkl=xxx" } }; + for (int i = 0; i < sizeof aTests / sizeof (Test); ++i) + { + bool bValid = false; + rtl::OUString aProtocol; + try + { + aProtocol = cppu::UnoUrl(rtl::OUString::createFromAscii( + aTests[i].pInput)). + getProtocol().getDescriptor(); + bValid = true; + } + catch (rtl::MalformedUriException &) + {} + CPPUNIT_ASSERT_MESSAGE("Failed to parse URI", bValid); + CPPUNIT_ASSERT_MESSAGE("Failed to get protocol correctly", + aProtocol.equalsAscii( + aTests[i].pProtocol)); + } + } + + void testUrlObjectName() + { + struct Test + { + char const * pInput; + char const * pObjectName; + }; + static Test const aTests[] + = { { "uno:abc;def;ghi", "ghi" }, + { "uno:abc;def;Ghi", "Ghi" }, + { "uno:abc;def;gHI", "gHI" }, + { "uno:abc;def;GHI", "GHI" }, + { "uno:abc,def=xxx,ghi=xxx;def,ghi=xxx,jkl=xxx;ghi", "ghi" }, + { "uno:abc;def;a", "a" }, + { "uno:abc;def;A", "A" }, + { "uno:abc;def;1", "1" }, + { "uno:abc;def;$&+,/:=?@", "$&+,/:=?@" } }; + for (int i = 0; i < sizeof aTests / sizeof (Test); ++i) + { + bool bValid = false; + rtl::OUString aObjectName; + try + { + aObjectName = cppu::UnoUrl(rtl::OUString::createFromAscii( + aTests[i].pInput)).getObjectName(); + bValid = true; + } + catch (rtl::MalformedUriException &) + {} + CPPUNIT_ASSERT_MESSAGE("Failed to parse URI", bValid); + CPPUNIT_ASSERT_MESSAGE("Failed to get protocol correctly", + aObjectName.equalsAscii( + aTests[i].pObjectName)); + } + } + + // Automatic registration code + CPPUNIT_TEST_SUITE(UrlTest); + CPPUNIT_TEST(testDescriptorParsing); + CPPUNIT_TEST(testDescriptorDescriptor); + CPPUNIT_TEST(testDescriptorName); + CPPUNIT_TEST(testDescriptorKey); + CPPUNIT_TEST(testDescriptorValue); + CPPUNIT_TEST(testUrlParsing); + CPPUNIT_TEST(testUrlConnection); + CPPUNIT_TEST(testUrlProtocol); + CPPUNIT_TEST(testUrlObjectName); + CPPUNIT_TEST_SUITE_END(); + }; +} // namespace cppu_ifcontainer + +CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(cppu_unourl::UrlTest, + "cppu_unourl"); + +NOADDITIONAL; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/qa/unourl/export.map b/cppuhelper/qa/unourl/export.map new file mode 100644 index 000000000000..879fa8953788 --- /dev/null +++ b/cppuhelper/qa/unourl/export.map @@ -0,0 +1,7 @@ +UDK_3_0_0 { + global: + registerAllTestFunction; + + local: + *; +}; diff --git a/cppuhelper/qa/unourl/makefile.mk b/cppuhelper/qa/unourl/makefile.mk new file mode 100644 index 000000000000..de2c05d40bc1 --- /dev/null +++ b/cppuhelper/qa/unourl/makefile.mk @@ -0,0 +1,61 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +PRJ=..$/.. +PRJNAME=cppuhelper +TARGET=cppu_unourl + +ENABLE_EXCEPTIONS=TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk + +CFLAGSCXX += $(CPPUNIT_CFLAGS) + +# BEGIN ---------------------------------------------------------------- +# auto generated Target:joblist by codegen.pl +SHL1OBJS= \ + $(SLO)$/cppu_unourl.obj +SHL1TARGET= cppu_unourl +SHL1STDLIBS=\ + $(CPPUHELPERLIB) \ + $(SALLIB) \ + $(CPPULIB) \ + $(TESTSHL2LIB)\ + $(CPPUNITLIB) +SHL1IMPLIB= i$(SHL1TARGET) +DEF1NAME =$(SHL1TARGET) +SHL1VERSIONMAP= export.map +# auto generated Target:joblist +# END ------------------------------------------------------------------ + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk +.INCLUDE : _cppunit.mk + diff --git a/cppuhelper/qa/weak/makefile.mk b/cppuhelper/qa/weak/makefile.mk new file mode 100644 index 000000000000..543e87118a75 --- /dev/null +++ b/cppuhelper/qa/weak/makefile.mk @@ -0,0 +1,53 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +PRJ := ..$/.. +PRJNAME := cppuhelper +TARGET := qa_weak + +ENABLE_EXCEPTIONS := TRUE + +.INCLUDE: settings.mk + +CFLAGSCXX += $(CPPUNIT_CFLAGS) +DLLPRE = # no leading "lib" on .so files + +SHL1TARGET = $(TARGET) +SHL1OBJS = $(SLO)$/test_weak.obj +SHL1STDLIBS = $(CPPULIB) $(CPPUHELPERLIB) $(CPPUNITLIB) $(SALLIB) $(TESTSHL2LIB) +SHL1VERSIONMAP = version.map +SHL1IMPLIB = i$(SHL1TARGET) +DEF1NAME = $(SHL1TARGET) + +SLOFILES = $(SHL1OBJS) + +.INCLUDE: target.mk + +ALLTAR: test + +test .PHONY: $(SHL1TARGETN) + $(TESTSHL2) $(SHL1TARGETN) diff --git a/cppuhelper/qa/weak/test_weak.cxx b/cppuhelper/qa/weak/test_weak.cxx new file mode 100644 index 000000000000..9e0040b55666 --- /dev/null +++ b/cppuhelper/qa/weak/test_weak.cxx @@ -0,0 +1,112 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_cppuhelper.hxx" + +#include "sal/config.h" + +#include "com/sun/star/lang/DisposedException.hpp" +#include "com/sun/star/uno/Reference.hxx" +#include "com/sun/star/uno/RuntimeException.hpp" +#include "com/sun/star/uno/XAdapter.hpp" +#include "com/sun/star/uno/XReference.hpp" +#include "com/sun/star/uno/XWeak.hpp" +#include "cppuhelper/implbase1.hxx" +#include "cppuhelper/weak.hxx" +#include "testshl/simpleheader.hxx" +#include "rtl/ref.hxx" +#include "sal/types.h" + +namespace { + +namespace css = com::sun::star; + +class Reference: public cppu::WeakImplHelper1< css::uno::XReference > { +public: + Reference(): m_disposed(false) {} + + virtual void SAL_CALL dispose() throw (css::uno::RuntimeException) { + m_disposed = true; + handleDispose(); + } + + bool isDisposed() const { return m_disposed; } + +protected: + virtual void handleDispose() {}; + +private: + bool m_disposed; +}; + +class RuntimeExceptionReference: public Reference { +protected: + virtual void handleDispose() { + throw css::uno::RuntimeException(); + } +}; + +class DisposedExceptionReference: public Reference { +protected: + virtual void handleDispose() { + throw css::lang::DisposedException(); + } +}; + +class Test: public ::CppUnit::TestFixture { +public: + void testReferenceDispose(); + + CPPUNIT_TEST_SUITE(Test); + CPPUNIT_TEST(testReferenceDispose); + CPPUNIT_TEST_SUITE_END(); +}; + +void Test::testReferenceDispose() { + css::uno::Reference< css::uno::XWeak > w(new ::cppu::OWeakObject); + css::uno::Reference< css::uno::XAdapter > a(w->queryAdapter()); + ::rtl::Reference< Reference > r1(new RuntimeExceptionReference); + ::rtl::Reference< Reference > r2(new Reference); + ::rtl::Reference< Reference > r3(new DisposedExceptionReference); + a->addReference(r1.get()); + a->addReference(r2.get()); + a->addReference(r3.get()); + w.clear(); + CPPUNIT_ASSERT(r1->isDisposed()); + CPPUNIT_ASSERT(r2->isDisposed()); + CPPUNIT_ASSERT(r3->isDisposed()); +} + +CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(Test, "alltests"); + +} + +NOADDITIONAL; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/qa/weak/version.map b/cppuhelper/qa/weak/version.map new file mode 100644 index 000000000000..f313c44bd7ad --- /dev/null +++ b/cppuhelper/qa/weak/version.map @@ -0,0 +1,34 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +UDK_3_0_0 { + global: + registerAllTestFunction; + + local: + *; +}; diff --git a/cppuhelper/source/access_control.cxx b/cppuhelper/source/access_control.cxx new file mode 100644 index 000000000000..f71e6b217726 --- /dev/null +++ b/cppuhelper/source/access_control.cxx @@ -0,0 +1,152 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_cppuhelper.hxx" + +#include <cppuhelper/access_control.hxx> + +#include <com/sun/star/security/XAccessController.hpp> +#include <com/sun/star/security/RuntimePermission.hpp> +#include <com/sun/star/io/FilePermission.hpp> +#include <com/sun/star/connection/SocketPermission.hpp> + +#define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) ) + + +using namespace ::rtl; +using namespace ::osl; +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; + +namespace +{ + inline OUString str_ac_singleton() + { + return OUSTR("/singletons/com.sun.star.security.theAccessController"); + } +} + +namespace cppu +{ +//__________________________________________________________________________________________________ +AccessControl::AccessControl( Reference< XComponentContext > const & xContext ) + SAL_THROW( (RuntimeException) ) +{ + if (! (xContext->getValueByName( str_ac_singleton() ) >>= m_xController)) + { + throw SecurityException( + OUSTR("no access controller!"), Reference< XInterface >() ); + } +} +//__________________________________________________________________________________________________ +AccessControl::AccessControl( + Reference< security::XAccessController > const & xController ) + SAL_THROW( (RuntimeException) ) + : m_xController( xController ) +{ + if (! m_xController.is()) + { + throw SecurityException( + OUSTR("no access controller!"), Reference< XInterface >() ); + } +} +//__________________________________________________________________________________________________ +AccessControl::AccessControl( AccessControl const & ac ) + SAL_THROW( (RuntimeException) ) + : m_xController( ac.m_xController ) +{ + if (! m_xController.is()) + { + throw SecurityException( + OUSTR("no access controller!"), Reference< XInterface >() ); + } +} + +#ifdef SAL_W32 +#pragma pack(push, 8) +#endif + // binary comp. to all Permission structs + struct __permission + { + rtl_uString * m_str1; + rtl_uString * m_str2; + }; +#ifdef SAL_W32 +#pragma pack(pop) +#endif + +//-------------------------------------------------------------------------------------------------- +inline void __checkPermission( + Reference< security::XAccessController > const & xController, + Type const & type, rtl_uString * str1, rtl_uString * str2 ) + SAL_THROW( (RuntimeException) ) +{ + __permission perm; + perm.m_str1 = str1; + perm.m_str2 = str2; + + uno_Any a; + a.pType = type.getTypeLibType(); + a.pData = &perm; + + xController->checkPermission( * static_cast< Any * >( &a ) ); +} +//__________________________________________________________________________________________________ +void AccessControl::checkRuntimePermission( + OUString const & name ) + SAL_THROW( (RuntimeException) ) +{ + __checkPermission( + m_xController, + ::getCppuType( (security::RuntimePermission *)0 ), name.pData, 0 ); +} +//__________________________________________________________________________________________________ +void AccessControl::checkFilePermission( + OUString const & url, + OUString const & actions ) + SAL_THROW( (RuntimeException) ) +{ + __checkPermission( + m_xController, + ::getCppuType( (io::FilePermission *)0 ), url.pData, actions.pData ); +} +//__________________________________________________________________________________________________ +void AccessControl::checkSocketPermission( + OUString const & host, + OUString const & actions ) + SAL_THROW( (RuntimeException) ) +{ + __checkPermission( + m_xController, + ::getCppuType( (connection::SocketPermission *)0 ), host.pData, actions.pData ); +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/source/bootstrap.cxx b/cppuhelper/source/bootstrap.cxx new file mode 100644 index 000000000000..1a73a1d4d4fe --- /dev/null +++ b/cppuhelper/source/bootstrap.cxx @@ -0,0 +1,667 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_cppuhelper.hxx" + +#include <string.h> +#include <vector> + +#include "rtl/process.h" +#include "rtl/bootstrap.hxx" +#include "rtl/random.h" +#include "rtl/string.hxx" +#include "rtl/ustrbuf.hxx" +#include "rtl/uri.hxx" +#if OSL_DEBUG_LEVEL > 0 +#include "rtl/strbuf.hxx" +#endif +#include "osl/diagnose.h" +#include "osl/file.hxx" +#include "osl/module.hxx" +#include "osl/security.hxx" +#include "osl/thread.hxx" + +#include "cppuhelper/shlib.hxx" +#include "cppuhelper/bootstrap.hxx" +#include "cppuhelper/component_context.hxx" +#include "cppuhelper/access_control.hxx" +#include "cppuhelper/findsofficepath.h" + +#include "com/sun/star/uno/XComponentContext.hpp" +#include "com/sun/star/uno/XCurrentContext.hpp" + +#include "com/sun/star/lang/XSingleServiceFactory.hpp" +#include "com/sun/star/lang/XSingleComponentFactory.hpp" +#include "com/sun/star/lang/XInitialization.hpp" +#include "com/sun/star/lang/XServiceInfo.hpp" +#include "com/sun/star/registry/XSimpleRegistry.hpp" +#include "com/sun/star/container/XSet.hpp" +#include "com/sun/star/beans/PropertyValue.hpp" +#include "com/sun/star/io/IOException.hpp" +#include "com/sun/star/bridge/UnoUrlResolver.hpp" +#include "com/sun/star/bridge/XUnoUrlResolver.hpp" + +#include "macro_expander.hxx" + +#define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) ) +#define ARLEN(x) sizeof (x) / sizeof *(x) + + +using namespace ::rtl; +using namespace ::osl; +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; + +namespace cppu +{ + +OUString const & get_this_libpath() +{ + static OUString s_path; + if (0 == s_path.getLength()) + { + OUString path; + Module::getUrlFromAddress( reinterpret_cast<oslGenericFunction>(get_this_libpath), path ); + path = path.copy( 0, path.lastIndexOf( '/' ) ); + MutexGuard guard( Mutex::getGlobalMutex() ); + if (0 == s_path.getLength()) + s_path = path; + } + return s_path; +} + +Bootstrap const & get_unorc() SAL_THROW( () ) +{ + static rtlBootstrapHandle s_bstrap = 0; + if (! s_bstrap) + { + OUString iniName( + get_this_libpath() + OUSTR("/" SAL_CONFIGFILE("uno")) ); + rtlBootstrapHandle bstrap = rtl_bootstrap_args_open( iniName.pData ); + + ClearableMutexGuard guard( Mutex::getGlobalMutex() ); + if (s_bstrap) + { + guard.clear(); + rtl_bootstrap_args_close( bstrap ); + } + else + { + s_bstrap = bstrap; + } + } + return *(Bootstrap const *)&s_bstrap; +} + + +void addFactories( + char const * const * ppNames /* lib, implname, ..., 0 */, + OUString const & bootstrapPath, + Reference< lang::XMultiComponentFactory > const & xMgr, + Reference< registry::XRegistryKey > const & xKey ) + SAL_THROW( (Exception) ) +{ + Reference< container::XSet > xSet( xMgr, UNO_QUERY ); + OSL_ASSERT( xSet.is() ); + Reference< lang::XMultiServiceFactory > xSF( xMgr, UNO_QUERY ); + + while (*ppNames) + { + OUString lib( OUString::createFromAscii( *ppNames++ ) ); + OUString implName( OUString::createFromAscii( *ppNames++ ) ); + + Any aFac( makeAny( loadSharedLibComponentFactory( + lib, bootstrapPath, implName, xSF, xKey ) ) ); + xSet->insert( aFac ); +#if OSL_DEBUG_LEVEL > 1 + if (xSet->has( aFac )) + { + Reference< lang::XServiceInfo > xInfo; + if (aFac >>= xInfo) + { + ::fprintf( + stderr, "> implementation %s supports: ", ppNames[ -1 ] ); + Sequence< OUString > supported( + xInfo->getSupportedServiceNames() ); + for ( sal_Int32 nPos = supported.getLength(); nPos--; ) + { + OString str( OUStringToOString( + supported[ nPos ], RTL_TEXTENCODING_ASCII_US ) ); + ::fprintf( stderr, nPos ? "%s, " : "%s\n", str.getStr() ); + } + } + else + { + ::fprintf( + stderr, + "> implementation %s provides NO lang::XServiceInfo!!!\n", + ppNames[ -1 ] ); + } + } +#endif +#if OSL_DEBUG_LEVEL > 0 + if (! xSet->has( aFac )) + { + OStringBuffer buf( 64 ); + buf.append( "### failed inserting shared lib \"" ); + buf.append( ppNames[ -2 ] ); + buf.append( "\"!!!" ); + OString str( buf.makeStringAndClear() ); + OSL_ENSURE( 0, str.getStr() ); + } +#endif + } +} + +// private forward decl +Reference< lang::XMultiComponentFactory > bootstrapInitialSF( + OUString const & rBootstrapPath ) + SAL_THROW( (Exception) ); + +Reference< XComponentContext > bootstrapInitialContext( + Reference< lang::XMultiComponentFactory > const & xSF, + Reference< registry::XSimpleRegistry > const & types_xRegistry, + Reference< registry::XSimpleRegistry > const & services_xRegistry, + OUString const & rBootstrapPath, Bootstrap const & bootstrap ) + SAL_THROW( (Exception) ); + +Reference< XComponentContext > SAL_CALL createInitialCfgComponentContext( + ContextEntry_Init const * pEntries, sal_Int32 nEntries, + Reference< XComponentContext > const & xDelegate ) + SAL_THROW( () ); + +Reference< registry::XSimpleRegistry > SAL_CALL createRegistryWrapper( + const Reference< XComponentContext >& xContext ); + +namespace { + +template< class T > +inline beans::PropertyValue createPropertyValue( + OUString const & name, T const & value ) + SAL_THROW( () ) +{ + return beans::PropertyValue( + name, -1, makeAny( value ), beans::PropertyState_DIRECT_VALUE ); +} + +OUString findBoostrapArgument( + const Bootstrap & bootstrap, + const OUString & arg_name, + sal_Bool * pFallenBack ) + SAL_THROW(()) +{ + OUString result; + + OUString prefixed_arg_name = OUSTR("UNO_"); + prefixed_arg_name += arg_name.toAsciiUpperCase(); + + // environment not set -> try relative to executable + if(!bootstrap.getFrom(prefixed_arg_name, result)) + { + if(pFallenBack) + *pFallenBack = sal_True; + + OUString fileName; + bootstrap.getIniName(fileName); + + // cut the rc extension + OUStringBuffer result_buf( 64 ); + result_buf.append( + fileName.copy( + 0, fileName.getLength() - strlen(SAL_CONFIGFILE(""))) ); + result_buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("_") ); + result_buf.append( arg_name.toAsciiLowerCase() ); + result_buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(".rdb") ); + result = result_buf.makeStringAndClear(); + +#if OSL_DEBUG_LEVEL > 1 + OString result_dbg = + OUStringToOString(result, RTL_TEXTENCODING_ASCII_US); + OString arg_name_dbg = + OUStringToOString(arg_name, RTL_TEXTENCODING_ASCII_US); + OSL_TRACE( + "cppuhelper::findBoostrapArgument - " + "setting %s relative to executable: %s\n", + arg_name_dbg.getStr(), + result_dbg.getStr() ); +#endif + } + else + { + if(pFallenBack) + *pFallenBack = sal_False; + +#if OSL_DEBUG_LEVEL > 1 + OString prefixed_arg_name_dbg = OUStringToOString( + prefixed_arg_name, RTL_TEXTENCODING_ASCII_US ); + OString result_dbg = OUStringToOString( + result, RTL_TEXTENCODING_ASCII_US ); + OSL_TRACE( + "cppuhelper::findBoostrapArgument - found %s in env: %s", + prefixed_arg_name_dbg.getStr(), + result_dbg.getStr() ); +#endif + } + + return result; +} + +Reference< registry::XSimpleRegistry > nestRegistries( + const OUString baseDir, + const Reference< lang::XSingleServiceFactory > & xSimRegFac, + const Reference< lang::XSingleServiceFactory > & xNesRegFac, + OUString csl_rdbs, + const OUString & write_rdb, + sal_Bool forceWrite_rdb, + sal_Bool bFallenBack ) + SAL_THROW((Exception)) +{ + sal_Int32 index; + Reference< registry::XSimpleRegistry > lastRegistry; + + if(write_rdb.getLength()) // is there a write registry given? + { + lastRegistry.set(xSimRegFac->createInstance(), UNO_QUERY); + + try + { + lastRegistry->open(write_rdb, sal_False, forceWrite_rdb); + } + catch (registry::InvalidRegistryException & invalidRegistryException) + { + (void) invalidRegistryException; +#if OSL_DEBUG_LEVEL > 1 + OString rdb_name_tmp = OUStringToOString( + write_rdb, RTL_TEXTENCODING_ASCII_US); + OString message_dbg = OUStringToOString( + invalidRegistryException.Message, RTL_TEXTENCODING_ASCII_US); + OSL_TRACE( + "warning: couldn't open %s cause of %s", + rdb_name_tmp.getStr(), message_dbg.getStr() ); +#endif + } + + if(!lastRegistry->isValid()) + lastRegistry.clear(); + } + + do + { + index = csl_rdbs.indexOf((sal_Unicode)' '); + OUString rdb_name = (index == -1) ? csl_rdbs : csl_rdbs.copy(0, index); + csl_rdbs = (index == -1) ? OUString() : csl_rdbs.copy(index + 1); + + if (! rdb_name.getLength()) + continue; + + bool optional = ('?' == rdb_name[ 0 ]); + if (optional) + rdb_name = rdb_name.copy( 1 ); + + try + { + Reference<registry::XSimpleRegistry> simpleRegistry( + xSimRegFac->createInstance(), UNO_QUERY_THROW ); + + osl::FileBase::getAbsoluteFileURL(baseDir, rdb_name, rdb_name); + simpleRegistry->open(rdb_name, sal_True, sal_False); + + if(lastRegistry.is()) + { + Reference< registry::XSimpleRegistry > nestedRegistry( + xNesRegFac->createInstance(), UNO_QUERY ); + Reference< lang::XInitialization > nestedRegistry_xInit( + nestedRegistry, UNO_QUERY ); + + Sequence<Any> aArgs(2); + aArgs[0] <<= lastRegistry; + aArgs[1] <<= simpleRegistry; + + nestedRegistry_xInit->initialize(aArgs); + + lastRegistry = nestedRegistry; + } + else + lastRegistry = simpleRegistry; + } + catch(registry::InvalidRegistryException & invalidRegistryException) + { + if (! optional) + { + // if a registry was explicitly given, the exception shall fly + if( ! bFallenBack ) + throw; + } + + (void) invalidRegistryException; +#if OSL_DEBUG_LEVEL > 1 + OString rdb_name_tmp = OUStringToOString( + rdb_name, RTL_TEXTENCODING_ASCII_US ); + OString message_dbg = OUStringToOString( + invalidRegistryException.Message, RTL_TEXTENCODING_ASCII_US ); + OSL_TRACE( + "warning: couldn't open %s cause of %s", + rdb_name_tmp.getStr(), message_dbg.getStr() ); +#endif + } + } + while(index != -1 && csl_rdbs.getLength()); // are there more rdbs in list? + + return lastRegistry; +} + +Reference< XComponentContext > +SAL_CALL defaultBootstrap_InitialComponentContext( + Bootstrap const & bootstrap ) + SAL_THROW( (Exception) ) +{ + OUString bootstrapPath( get_this_libpath() ); + OUString iniDir; + + osl_getProcessWorkingDir(&iniDir.pData); + + Reference<lang::XMultiComponentFactory> smgr_XMultiComponentFactory( + bootstrapInitialSF(bootstrapPath) ); + Reference<lang::XMultiServiceFactory> smgr_XMultiServiceFactory( + smgr_XMultiComponentFactory, UNO_QUERY ); + + Reference<registry::XRegistryKey> xEmptyKey; + Reference<lang::XSingleServiceFactory> xSimRegFac( + loadSharedLibComponentFactory( + OUSTR("bootstrap.uno" SAL_DLLEXTENSION), bootstrapPath, + OUSTR("com.sun.star.comp.stoc.SimpleRegistry"), + smgr_XMultiServiceFactory, + xEmptyKey), + UNO_QUERY); + + Reference<lang::XSingleServiceFactory> xNesRegFac( + loadSharedLibComponentFactory( + OUSTR("bootstrap.uno" SAL_DLLEXTENSION), bootstrapPath, + OUSTR("com.sun.star.comp.stoc.NestedRegistry"), + smgr_XMultiServiceFactory, + xEmptyKey), + UNO_QUERY); + + sal_Bool bFallenback_types; + OUString cls_uno_types = + findBoostrapArgument( bootstrap, OUSTR("TYPES"), &bFallenback_types ); + + Reference<registry::XSimpleRegistry> types_xRegistry = + nestRegistries( + iniDir, xSimRegFac, xNesRegFac, cls_uno_types, + OUString(), sal_False, bFallenback_types ); + + // ==== bootstrap from services registry ==== + + sal_Bool bFallenback_services; + OUString cls_uno_services = findBoostrapArgument( + bootstrap, OUSTR("SERVICES"), &bFallenback_services ); + + sal_Bool fallenBackWriteRegistry; + OUString write_rdb = findBoostrapArgument( + bootstrap, OUSTR("WRITERDB"), &fallenBackWriteRegistry ); + if (fallenBackWriteRegistry) + { + // no standard write rdb anymore + write_rdb = OUString(); + } + + Reference<registry::XSimpleRegistry> services_xRegistry = nestRegistries( + iniDir, xSimRegFac, xNesRegFac, cls_uno_services, write_rdb, + !fallenBackWriteRegistry, bFallenback_services ); + + Reference< XComponentContext > xContext( + bootstrapInitialContext( + smgr_XMultiComponentFactory, types_xRegistry, services_xRegistry, + bootstrapPath, bootstrap ) ); + + // initialize sf + Reference< lang::XInitialization > xInit( + smgr_XMultiComponentFactory, UNO_QUERY ); + OSL_ASSERT( xInit.is() ); + Sequence< Any > aSFInit( 1 ); + aSFInit[ 0 ] <<= services_xRegistry; + xInit->initialize( aSFInit ); + + return xContext; +} + +} + +Reference< XComponentContext > +SAL_CALL defaultBootstrap_InitialComponentContext( + OUString const & iniFile ) + SAL_THROW( (Exception) ) +{ + Bootstrap bootstrap( iniFile ); + if (bootstrap.getHandle() == 0) + throw io::IOException(OUSTR("Cannot open for reading: ") + iniFile, 0); + return defaultBootstrap_InitialComponentContext( bootstrap ); +} + +Reference< XComponentContext > +SAL_CALL defaultBootstrap_InitialComponentContext() + SAL_THROW( (Exception) ) +{ + return defaultBootstrap_InitialComponentContext( get_unorc() ); +} + +BootstrapException::BootstrapException() +{ +} + +BootstrapException::BootstrapException( const ::rtl::OUString & rMessage ) + :m_aMessage( rMessage ) +{ +} + +BootstrapException::BootstrapException( const BootstrapException & e ) +{ + m_aMessage = e.m_aMessage; +} + +BootstrapException::~BootstrapException() +{ +} + +BootstrapException & BootstrapException::operator=( const BootstrapException & e ) +{ + m_aMessage = e.m_aMessage; + return *this; +} + +const ::rtl::OUString & BootstrapException::getMessage() const +{ + return m_aMessage; +} + +Reference< XComponentContext > SAL_CALL bootstrap() +{ + Reference< XComponentContext > xRemoteContext; + + try + { + char const * p1 = cppuhelper_detail_findSofficePath(); + if (p1 == NULL) { + throw BootstrapException( + OUSTR("no soffice installation found!")); + } + rtl::OUString p2; + if (!rtl_convertStringToUString( + &p2.pData, p1, strlen(p1), osl_getThreadTextEncoding(), + (RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR | + RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR | + RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR))) + { + throw BootstrapException( + OUSTR("bad characters in soffice installation path!")); + } + OUString path; + if (osl::FileBase::getFileURLFromSystemPath(p2, path) != + osl::FileBase::E_None) + { + throw BootstrapException( + OUSTR("cannot convert soffice installation path to URL!")); + } + if (path.getLength() > 0 && path[path.getLength() - 1] != '/') { + path += OUSTR("/"); + } + + OUString uri; + if (!Bootstrap::get(OUSTR("URE_BOOTSTRAP"), uri)) { + Bootstrap::set( + OUSTR("URE_BOOTSTRAP"), + Bootstrap::encode(path + OUSTR(SAL_CONFIGFILE("fundamental")))); + } + + // create default local component context + Reference< XComponentContext > xLocalContext( + defaultBootstrap_InitialComponentContext() ); + if ( !xLocalContext.is() ) + throw BootstrapException( OUSTR( "no local component context!" ) ); + + // create a random pipe name + rtlRandomPool hPool = rtl_random_createPool(); + if ( hPool == 0 ) + throw BootstrapException( OUSTR( "cannot create random pool!" ) ); + sal_uInt8 bytes[ 16 ]; + if ( rtl_random_getBytes( hPool, bytes, ARLEN( bytes ) ) + != rtl_Random_E_None ) + throw BootstrapException( OUSTR( "random pool error!" ) ); + rtl_random_destroyPool( hPool ); + ::rtl::OUStringBuffer buf; + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "uno" ) ); + for ( sal_uInt32 i = 0; i < ARLEN( bytes ); ++i ) + buf.append( static_cast< sal_Int32 >( bytes[ i ] ) ); + OUString sPipeName( buf.makeStringAndClear() ); + + // accept string + OSL_ASSERT( buf.getLength() == 0 ); + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "-accept=pipe,name=" ) ); + buf.append( sPipeName ); + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( ";urp;" ) ); + + // arguments + OUString args [] = { + OUSTR( "-nologo" ), + OUSTR( "-nodefault" ), + OUSTR( "-norestore" ), + OUSTR( "-nocrashreport" ), + OUSTR( "-nolockcheck" ), + buf.makeStringAndClear() + }; + rtl_uString * ar_args [] = { + args[ 0 ].pData, + args[ 1 ].pData, + args[ 2 ].pData, + args[ 3 ].pData, + args[ 4 ].pData, + args[ 5 ].pData + }; + ::osl::Security sec; + + // start office process + oslProcess hProcess = 0; + oslProcessError rc = osl_executeProcess( + (path + OUSTR("soffice")).pData, ar_args, ARLEN( ar_args ), + osl_Process_DETACHED, + sec.getHandle(), + 0, // => current working dir + 0, 0, // => no env vars + &hProcess ); + switch ( rc ) + { + case osl_Process_E_None: + osl_freeProcessHandle( hProcess ); + break; + case osl_Process_E_NotFound: + throw BootstrapException( OUSTR( "image not found!" ) ); + case osl_Process_E_TimedOut: + throw BootstrapException( OUSTR( "timout occured!" ) ); + case osl_Process_E_NoPermission: + throw BootstrapException( OUSTR( "permission denied!" ) ); + case osl_Process_E_Unknown: + throw BootstrapException( OUSTR( "unknown error!" ) ); + case osl_Process_E_InvalidError: + default: + throw BootstrapException( OUSTR( "unmapped error!" ) ); + } + + // create a URL resolver + Reference< bridge::XUnoUrlResolver > xUrlResolver( + bridge::UnoUrlResolver::create( xLocalContext ) ); + + // connection string + OSL_ASSERT( buf.getLength() == 0 ); + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "uno:pipe,name=" ) ); + buf.append( sPipeName ); + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( + ";urp;StarOffice.ComponentContext" ) ); + OUString sConnectString( buf.makeStringAndClear() ); + + // wait until office is started + for ( ; ; ) + { + try + { + // try to connect to office + xRemoteContext.set( + xUrlResolver->resolve( sConnectString ), UNO_QUERY_THROW ); + break; + } + catch ( connection::NoConnectException & ) + { + // wait 500 ms, then try to connect again + TimeValue tv = { 0 /* secs */, 500000000 /* nanosecs */ }; + ::osl::Thread::wait( tv ); + } + } + } + catch ( Exception & e ) + { + throw BootstrapException( + OUSTR( "unexpected UNO exception caught: " ) + e.Message ); + } + + return xRemoteContext; +} + +OUString bootstrap_expandUri(OUString const & uri) { + static char const PREFIX[] = "vnd.sun.star.expand:"; + return uri.matchAsciiL(RTL_CONSTASCII_STRINGPARAM(PREFIX)) + ? cppuhelper::detail::expandMacros( + rtl::Uri::decode( + uri.copy(RTL_CONSTASCII_LENGTH(PREFIX)), + rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8)) + : uri; +} + +} // namespace cppu + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/source/cc5_solaris_sparc.map b/cppuhelper/source/cc5_solaris_sparc.map new file mode 100755 index 000000000000..090f8a1cca2e --- /dev/null +++ b/cppuhelper/source/cc5_solaris_sparc.map @@ -0,0 +1,389 @@ +UDK_3_0_0 { + global: +GetVersionInfo; +_DYNAMIC; +_GLOBAL_OFFSET_TABLE_; +_PROCEDURE_LINKAGE_TABLE_; +__1cDcomDsunEstarDunoTWeakReferenceHelper2G6Mrk4_r4_; +__1cDcomDsunEstarDunoTWeakReferenceHelper2T5B6M_v_; +__1cDcomDsunEstarDunoTWeakReferenceHelper2T6M_v_; +__1cDcomDsunEstarDunoTWeakReferenceHelper2t5B6Mrk4_v_; +__1cDcomDsunEstarDunoTWeakReferenceHelper2t5B6Mrkn0DJReference4n0DKXInterface____v_; +__1cDcomDsunEstarDunoTWeakReferenceHelper2t6Mrk4_v_; +__1cDcomDsunEstarDunoTWeakReferenceHelper2t6Mrkn0DJReference4n0DKXInterface____v_; +__1cDcomDsunEstarDunoTWeakReferenceHelperDget6kM_n0DJReference4n0DKXInterface____; +__1cEcppuJClassDataFquery6MrknDcomDsunEstarDunoEType_pn0EElangNXTypeProvider__n0FDAny__; +__1cEcppuJClassDataIgetTypes6M_nDcomDsunEstarDunoISequence4n0FEType____; +__1cEcppuJClassDataPwriteTypeOffset6MrknDcomDsunEstarDunoEType_l_v_; #S-ILP32 +__1cEcppuJClassDataPwriteTypeOffset6MrknDcomDsunEstarDunoEType_i_v_; #S-LP64 +__1cEcppuJClassDataQinitTypeProvider6M_v_; +__1cEcppuJClassDataTgetImplementationId6M_nDcomDsunEstarDunoISequence4CW___; +__1cEcppuLOWeakObject2T5B6M_v_; +__1cEcppuLOWeakObject2T6M_v_; +__1cEcppuLOWeakObjectG__vtbl_; +__1cEcppuLOWeakObjectHacquire6M_v_; +__1cEcppuLOWeakObjectHrelease6M_v_; +__1cEcppuLOWeakObjectMqueryAdapter6M_nDcomDsunEstarDunoJReference4n0FIXAdapter____; +__1cEcppuLOWeakObjectOqueryInterface6MrknDcomDsunEstarDunoEType__n0FDAny__; +__1cEcppuNClassDataBase2T5B6M_v_; +__1cEcppuNClassDataBase2T6M_v_; +__1cEcppuNClassDataBase2t5B6M_v_; +__1cEcppuNClassDataBase2t5B6Ml_v_; #S-ILP32 +__1cEcppuNClassDataBase2t5B6Mi_v_; #S-LP64 +__1cEcppuNClassDataBase2t6M_v_; +__1cEcppuNClassDataBase2t6Ml_v_; #S-ILP32 +__1cEcppuNClassDataBase2t6Mi_v_; #S-LP64 +__1cEcppuOOWeakAggObject2T5B6M_v_; +__1cEcppuOOWeakAggObject2T6M_v_; +__1cEcppuOOWeakAggObjectG__vtbl_; +__1cEcppuOOWeakAggObjectHacquire6M_v_; +__1cEcppuOOWeakAggObjectHrelease6M_v_; +__1cEcppuOOWeakAggObjectMsetDelegator6MrknDcomDsunEstarDunoJReference4n0FKXInterface____v_; +__1cEcppuOOWeakAggObjectOqueryInterface6MrknDcomDsunEstarDunoEType__n0FDAny__; +__1cEcppuOOWeakAggObjectQqueryAggregation6MrknDcomDsunEstarDunoEType__n0FDAny__; +__1cEcppuOthrowException6FrknDcomDsunEstarDunoDAny__v_; +__1cEcppuPOTypeCollection2t5B6MrknDcomDsunEstarDunoEType_88888888888rkn0FISequence4n0G____v_; +__1cEcppuPOTypeCollection2t5B6MrknDcomDsunEstarDunoEType_8888888888rkn0FISequence4n0G____v_; +__1cEcppuPOTypeCollection2t5B6MrknDcomDsunEstarDunoEType_888888888rkn0FISequence4n0G____v_; +__1cEcppuPOTypeCollection2t5B6MrknDcomDsunEstarDunoEType_88888888rkn0FISequence4n0G____v_; +__1cEcppuPOTypeCollection2t5B6MrknDcomDsunEstarDunoEType_8888888rkn0FISequence4n0G____v_; +__1cEcppuPOTypeCollection2t5B6MrknDcomDsunEstarDunoEType_888888rkn0FISequence4n0G____v_; +__1cEcppuPOTypeCollection2t5B6MrknDcomDsunEstarDunoEType_88888rkn0FISequence4n0G____v_; +__1cEcppuPOTypeCollection2t5B6MrknDcomDsunEstarDunoEType_8888rkn0FISequence4n0G____v_; +__1cEcppuPOTypeCollection2t5B6MrknDcomDsunEstarDunoEType_888rkn0FISequence4n0G____v_; +__1cEcppuPOTypeCollection2t5B6MrknDcomDsunEstarDunoEType_88rkn0FISequence4n0G____v_; +__1cEcppuPOTypeCollection2t5B6MrknDcomDsunEstarDunoEType_8rkn0FISequence4n0G____v_; +__1cEcppuPOTypeCollection2t5B6MrknDcomDsunEstarDunoEType_rkn0FISequence4n0G____v_; +__1cEcppuPOTypeCollection2t6MrknDcomDsunEstarDunoEType_88888888888rkn0FISequence4n0G____v_; +__1cEcppuPOTypeCollection2t6MrknDcomDsunEstarDunoEType_8888888888rkn0FISequence4n0G____v_; +__1cEcppuPOTypeCollection2t6MrknDcomDsunEstarDunoEType_888888888rkn0FISequence4n0G____v_; +__1cEcppuPOTypeCollection2t6MrknDcomDsunEstarDunoEType_88888888rkn0FISequence4n0G____v_; +__1cEcppuPOTypeCollection2t6MrknDcomDsunEstarDunoEType_8888888rkn0FISequence4n0G____v_; +__1cEcppuPOTypeCollection2t6MrknDcomDsunEstarDunoEType_888888rkn0FISequence4n0G____v_; +__1cEcppuPOTypeCollection2t6MrknDcomDsunEstarDunoEType_88888rkn0FISequence4n0G____v_; +__1cEcppuPOTypeCollection2t6MrknDcomDsunEstarDunoEType_8888rkn0FISequence4n0G____v_; +__1cEcppuPOTypeCollection2t6MrknDcomDsunEstarDunoEType_888rkn0FISequence4n0G____v_; +__1cEcppuPOTypeCollection2t6MrknDcomDsunEstarDunoEType_88rkn0FISequence4n0G____v_; +__1cEcppuPOTypeCollection2t6MrknDcomDsunEstarDunoEType_8rkn0FISequence4n0G____v_; +__1cEcppuPOTypeCollection2t6MrknDcomDsunEstarDunoEType_rkn0FISequence4n0G____v_; +__1cEcppuQOComponentHelper2T5B6M_v_; +__1cEcppuQOComponentHelper2T6M_v_; +__1cEcppuQOComponentHelper2t5B6MrnDoslFMutex__v_; +__1cEcppuQOComponentHelper2t6MrnDoslFMutex__v_; +__1cEcppuQOComponentHelperG__vtbl_; +__1cEcppuQOComponentHelperHacquire6M_v_; +__1cEcppuQOComponentHelperHdispose6M_v_; +__1cEcppuQOComponentHelperHrelease6M_v_; +__1cEcppuQOComponentHelperIgetTypes6M_nDcomDsunEstarDunoISequence4n0FEType____; +__1cEcppuQOComponentHelperJdisposing6M_v_; +__1cEcppuQOComponentHelperOqueryInterface6MrknDcomDsunEstarDunoEType__n0FDAny__; +__1cEcppuQOComponentHelperQaddEventListener6MrknDcomDsunEstarDunoJReference4n0EElangOXEventListener____v_; +__1cEcppuQOComponentHelperQqueryAggregation6MrknDcomDsunEstarDunoEType__n0FDAny__; +__1cEcppuQOComponentHelperTremoveEventListener6MrknDcomDsunEstarDunoJReference4n0EElangOXEventListener____v_; +__1cEcppuROImplementationId2T5B6M_v_; +__1cEcppuROImplementationId2T6M_v_; +__1cEcppuROImplementationIdTgetImplementationId6kM_nDcomDsunEstarDunoISequence4CW___; +__1cEcppuSOPropertySetHelper2T5B6M_v_; +__1cEcppuSOPropertySetHelper2T6M_v_; +__1cEcppuSOPropertySetHelper2t5B6Mrn0ATOBroadcastHelperVar4n0AbIOMultiTypeInterfaceContainerHelper_nDcomDsunEstarDunoEType____v_; +__1cEcppuSOPropertySetHelper2t6Mrn0ATOBroadcastHelperVar4n0AbIOMultiTypeInterfaceContainerHelper_nDcomDsunEstarDunoEType____v_; +__1cEcppuSOPropertySetHelperEfire6MplpknDcomDsunEstarDunoDAny_9AlC_v_; #S-ILP32 +__1cEcppuSOPropertySetHelperEfire6MpipknDcomDsunEstarDunoDAny_9AiC_v_; #S-LP64 +__1cEcppuSOPropertySetHelperG__vtbl_; +__1cEcppuSOPropertySetHelperJdisposing6M_v_; +__1cEcppuSOPropertySetHelperOqueryInterface6MrknDcomDsunEstarDunoEType__n0FDAny__; +__1cEcppuSOPropertySetHelperQgetPropertyValue6MrknDrtlIOUString__nDcomDsunEstarDunoDAny__; +__1cEcppuSOPropertySetHelperQsetPropertyValue6MrknDrtlIOUString_rknDcomDsunEstarDunoDAny__v_; +__1cEcppuSOPropertySetHelperRgetPropertyValues6MrknDcomDsunEstarDunoISequence4nDrtlIOUString____n0FISequence4n0FDAny____; +__1cEcppuSOPropertySetHelperRsetPropertyValues6MrknDcomDsunEstarDunoISequence4nDrtlIOUString___rkn0FISequence4n0FDAny____v_; +__1cEcppuSOPropertySetHelperUgetFastPropertyValue6Ml_nDcomDsunEstarDunoDAny__; #S-ILP32 +__1cEcppuSOPropertySetHelperUgetFastPropertyValue6Mi_nDcomDsunEstarDunoDAny__; #S-LP64 +__1cEcppuSOPropertySetHelperUsetFastPropertyValue6MlrknDcomDsunEstarDunoDAny__v_; #S-ILP32 +__1cEcppuSOPropertySetHelperUsetFastPropertyValue6MirknDcomDsunEstarDunoDAny__v_; #S-LP64 +__1cEcppuSOPropertySetHelperVcreatePropertySetInfo6Frn0AUIPropertyArrayHelper__nDcomDsunEstarDunoJReference4n0FFbeansQXPropertySetInfo____; +__1cEcppuSOPropertySetHelperVsetFastPropertyValues6MlplpknDcomDsunEstarDunoDAny_l_v_; #S-ILP32 +__1cEcppuSOPropertySetHelperVsetFastPropertyValues6MipipknDcomDsunEstarDunoDAny_i_v_; #S-LP64 +__1cEcppuSOPropertySetHelperZaddPropertyChangeListener6MrknDrtlIOUString_rknDcomDsunEstarDunoJReference4n0GFbeansXXPropertyChangeListener____v_; +__1cEcppuSOPropertySetHelperZaddVetoableChangeListener6MrknDrtlIOUString_rknDcomDsunEstarDunoJReference4n0GFbeansXXVetoableChangeListener____v_; +__1cEcppuSOPropertySetHelperZfirePropertiesChangeEvent6MrknDcomDsunEstarDunoISequence4nDrtlIOUString___rkn0FJReference4n0EFbeansZXPropertiesChangeListener____v_; +__1cEcppuSOPropertySetHelperbBaddPropertiesChangeListener6MrknDcomDsunEstarDunoISequence4nDrtlIOUString___rkn0FJReference4n0EFbeansZXPropertiesChangeListener____v_; +__1cEcppuSOPropertySetHelperbCremovePropertyChangeListener6MrknDrtlIOUString_rknDcomDsunEstarDunoJReference4n0GFbeansXXPropertyChangeListener____v_; +__1cEcppuSOPropertySetHelperbCremoveVetoableChangeListener6MrknDrtlIOUString_rknDcomDsunEstarDunoJReference4n0GFbeansXXVetoableChangeListener____v_; +__1cEcppuSOPropertySetHelperbEremovePropertiesChangeListener6MrknDcomDsunEstarDunoJReference4n0EFbeansZXPropertiesChangeListener____v_; +__1cEcppuScreateFactoryProxy6FrknDcomDsunEstarDunoJReference4n0DElangUXMultiServiceFactory___rkn0EJReference4n0FVXSingleServiceFactory____9A_; +__1cEcppuTcreateSingleFactory6FrknDcomDsunEstarDunoJReference4n0DElangUXMultiServiceFactory___rknDrtlIOUString_pF8_n0EJReference4n0EKXInterface___rkn0EISequence4n0J___pnQ_rtl_ModuleCount__n0EJReference4n0FVXSingleServiceFactory____; +__1cEcppuUIPropertyArrayHelper2T5B6M_v_; +__1cEcppuUIPropertyArrayHelper2T6M_v_; +__1cEcppuUIPropertyArrayHelperG__vtbl_; +__1cEcppuUOPropertyArrayHelper2t5B6MpnDcomDsunEstarFbeansIProperty_lC_v_; #S-ILP32 +__1cEcppuUOPropertyArrayHelper2t5B6MpnDcomDsunEstarFbeansIProperty_iC_v_; #S-LP64 +__1cEcppuUOPropertyArrayHelper2t5B6MrknDcomDsunEstarDunoISequence4n0EFbeansIProperty___C_v_; +__1cEcppuUOPropertyArrayHelper2t6MpnDcomDsunEstarFbeansIProperty_lC_v_; #S-ILP32 +__1cEcppuUOPropertyArrayHelper2t6MpnDcomDsunEstarFbeansIProperty_iC_v_; #S-LP64 +__1cEcppuUOPropertyArrayHelper2t6MrknDcomDsunEstarDunoISequence4n0EFbeansIProperty___C_v_; +__1cEcppuUOPropertyArrayHelperEinit6MC_v_; +__1cEcppuUOPropertyArrayHelperG__vtbl_; +__1cEcppuUOPropertyArrayHelperIgetCount6kM_l_; #S-ILP32 +__1cEcppuUOPropertyArrayHelperIgetCount6kM_i_; #S-LP64 +__1cEcppuUOPropertyArrayHelperLfillHandles6MplrknDcomDsunEstarDunoISequence4nDrtlIOUString____l_; #S-ILP32 +__1cEcppuUOPropertyArrayHelperLfillHandles6MpirknDcomDsunEstarDunoISequence4nDrtlIOUString____i_; #S-LP64 +__1cEcppuUOPropertyArrayHelperNgetProperties6M_nDcomDsunEstarDunoISequence4n0EFbeansIProperty____; +__1cEcppuUOPropertyArrayHelperPgetHandleByName6MrknDrtlIOUString__l_; #S-ILP32 +__1cEcppuUOPropertyArrayHelperPgetHandleByName6MrknDrtlIOUString__i_; #S-LP64 +__1cEcppuUOPropertyArrayHelperRgetPropertyByName6MrknDrtlIOUString__nDcomDsunEstarFbeansIProperty__; +__1cEcppuUOPropertyArrayHelperRhasPropertyByName6MrknDrtlIOUString__C_; +__1cEcppuUOPropertyArrayHelperbBfillPropertyMembersByHandle6MpnDrtlIOUString_phl_C_; #S-ILP32 +__1cEcppuUOPropertyArrayHelperbBfillPropertyMembersByHandle6MpnDrtlIOUString_phi_C_; #S-LP64 +__1cEcppuUcreateNestedRegistry6FrknDrtlIOUString__nDcomDsunEstarDunoJReference4n0FIregistryPXSimpleRegistry____; +__1cEcppuUcreateSimpleRegistry6FrknDrtlIOUString__nDcomDsunEstarDunoJReference4n0FIregistryPXSimpleRegistry____; +__1cEcppuWcreateComponentContext6Fpkn0ARContextEntry_Init_lrknDcomDsunEstarDunoJReference4n0FRXComponentContext____8_; #S-ILP32 +__1cEcppuWcreateComponentContext6Fpkn0ARContextEntry_Init_irknDcomDsunEstarDunoJReference4n0FRXComponentContext____8_; #S-LP64 +__1cEcppuWgetImplHelperInitMutex6F_rnDoslFMutex__; +__1cEcppuYOInterfaceIteratorHelper2T5B6M_v_; +__1cEcppuYOInterfaceIteratorHelper2T6M_v_; +__1cEcppuYOInterfaceIteratorHelper2t5B6Mrn0AZOInterfaceContainerHelper__v_; +__1cEcppuYOInterfaceIteratorHelper2t6Mrn0AZOInterfaceContainerHelper__v_; +__1cEcppuYOInterfaceIteratorHelperEnext6M_pnDcomDsunEstarDunoKXInterface__; +__1cEcppuYOInterfaceIteratorHelperGremove6M_v_; +__1cEcppuYcreateOneInstanceFactory6FrknDcomDsunEstarDunoJReference4n0DElangUXMultiServiceFactory___rknDrtlIOUString_pF8_n0EJReference4n0EKXInterface___rkn0EISequence4n0J___pnQ_rtl_ModuleCount__n0EJReference4n0FVXSingleServiceFactory____; +__1cEcppuZOInterfaceContainerHelper2T5B6M_v_; +__1cEcppuZOInterfaceContainerHelper2T6M_v_; +__1cEcppuZOInterfaceContainerHelper2t5B6MrnDoslFMutex__v_; +__1cEcppuZOInterfaceContainerHelper2t6MrnDoslFMutex__v_; +__1cEcppuZOInterfaceContainerHelperFclear6M_v_; +__1cEcppuZOInterfaceContainerHelperJgetLength6kM_l_; #S-ILP32 +__1cEcppuZOInterfaceContainerHelperJgetLength6kM_i_; #S-LP64 +__1cEcppuZOInterfaceContainerHelperLgetElements6kM_nDcomDsunEstarDunoISequence4n0FJReference4n0FKXInterface______; +__1cEcppuZOInterfaceContainerHelperMaddInterface6MrknDcomDsunEstarDunoJReference4n0FKXInterface____l_; #S-ILP32 +__1cEcppuZOInterfaceContainerHelperMaddInterface6MrknDcomDsunEstarDunoJReference4n0FKXInterface____i_; #S-LP64 +__1cEcppuZOInterfaceContainerHelperPdisposeAndClear6MrknDcomDsunEstarElangLEventObject__v_; +__1cEcppuZOInterfaceContainerHelperPremoveInterface6MrknDcomDsunEstarDunoJReference4n0FKXInterface____l_; #S-ILP32 +__1cEcppuZOInterfaceContainerHelperPremoveInterface6MrknDcomDsunEstarDunoJReference4n0FKXInterface____i_; #S-LP64 +__1cEcppuZOInterfaceContainerHelperRcopyAndResetInUse6M_v_; +__1cEcppubBWeakComponentImplHelperBase2T5B6M_v_; +__1cEcppubBWeakComponentImplHelperBase2T6M_v_; +__1cEcppubBWeakComponentImplHelperBase2t5B6MrnDoslFMutex__v_; +__1cEcppubBWeakComponentImplHelperBase2t6MrnDoslFMutex__v_; +__1cEcppubBWeakComponentImplHelperBaseG__vtbl_; +__1cEcppubBWeakComponentImplHelperBaseHacquire6M_v_; +__1cEcppubBWeakComponentImplHelperBaseHdispose6M_v_; +__1cEcppubBWeakComponentImplHelperBaseHrelease6M_v_; +__1cEcppubBWeakComponentImplHelperBaseJdisposing6M_v_; +__1cEcppubBWeakComponentImplHelperBaseOqueryInterface6MrknDcomDsunEstarDunoEType__n0FDAny__; +__1cEcppubBWeakComponentImplHelperBaseQaddEventListener6MrknDcomDsunEstarDunoJReference4n0EElangOXEventListener____v_; +__1cEcppubBWeakComponentImplHelperBaseTremoveEventListener6MrknDcomDsunEstarDunoJReference4n0EElangOXEventListener____v_; +__1cEcppubBcreateSingleRegistryFactory6FrknDcomDsunEstarDunoJReference4n0DElangUXMultiServiceFactory___rknDrtlIOUString_rkn0EJReference4n0DIregistryMXRegistryKey____n0EJReference4n0FVXSingleServiceFactory____; +__1cEcppubBwriteSharedLibComponentInfo6FrknDrtlIOUString_4rknDcomDsunEstarDunoJReference4n0FElangUXMultiServiceFactory___rkn0GJReference4n0FIregistryMXRegistryKey____v_; +__1cEcppubCcreateRegistryServiceFactory6FrknDrtlIOUString_4C4_nDcomDsunEstarDunoJReference4n0FElangUXMultiServiceFactory____; +__1cEcppubCcreateSingleComponentFactory6FpFrknDcomDsunEstarDunoJReference4n0ERXComponentContext____n0EJReference4n0EKXInterface___rknDrtlIOUString_rkn0EISequence4n0K___pnQ_rtl_ModuleCount__n0EJReference4n0DElangXXSingleComponentFactory____; +__1cEcppubDinstallTypeDescriptionManager6FrknDcomDsunEstarDunoJReference4n0DJcontainerXXHierarchicalNameAccess____C_; +__1cEcppubDloadSharedLibComponentFactory6FrknDrtlIOUString_44rknDcomDsunEstarDunoJReference4n0FElangUXMultiServiceFactory___rkn0GJReference4n0FIregistryMXRegistryKey____n0GJReference4n0GKXInterface____; +__1cEcppubEWeakAggComponentImplHelperBase2T5B6M_v_; +__1cEcppubEWeakAggComponentImplHelperBase2T6M_v_; +__1cEcppubEWeakAggComponentImplHelperBase2t5B6MrnDoslFMutex__v_; +__1cEcppubEWeakAggComponentImplHelperBase2t6MrnDoslFMutex__v_; +__1cEcppubEWeakAggComponentImplHelperBaseG__vtbl_; +__1cEcppubEWeakAggComponentImplHelperBaseHacquire6M_v_; +__1cEcppubEWeakAggComponentImplHelperBaseHdispose6M_v_; +__1cEcppubEWeakAggComponentImplHelperBaseHrelease6M_v_; +__1cEcppubEWeakAggComponentImplHelperBaseJdisposing6M_v_; +__1cEcppubEWeakAggComponentImplHelperBaseOqueryInterface6MrknDcomDsunEstarDunoEType__n0FDAny__; +__1cEcppubEWeakAggComponentImplHelperBaseQaddEventListener6MrknDcomDsunEstarDunoJReference4n0EElangOXEventListener____v_; +__1cEcppubEWeakAggComponentImplHelperBaseQqueryAggregation6MrknDcomDsunEstarDunoEType__n0FDAny__; +__1cEcppubEWeakAggComponentImplHelperBaseTremoveEventListener6MrknDcomDsunEstarDunoJReference4n0EElangOXEventListener____v_; +__1cEcppubE__RTTI__1CpnEcppuLOWeakObject__; +__1cEcppubF__RTTI__1CpknEcppuLOWeakObject__; +__1cEcppubFcreateStandardClassWithSequence6FrknDcomDsunEstarDunoJReference4n0DElangUXMultiServiceFactory___rknDrtlIOUString_rkn0EJReference4n0DKreflectionJXIdlClass___rkn0EISequence4n0J____pn0L__; +__1cEcppubGcreateOneInstanceRegistryFactory6FrknDcomDsunEstarDunoJReference4n0DElangUXMultiServiceFactory___rknDrtlIOUString_rkn0EJReference4n0DIregistryMXRegistryKey____n0EJReference4n0FVXSingleServiceFactory____; +__1cEcppubH__RTTI__1CpnEcppuOOWeakAggObject__; +__1cEcppubHbootstrap_InitialComponentContext6FrknDcomDsunEstarDunoJReference4n0DIregistryPXSimpleRegistry___rknDrtlIOUString__n0EJReference4n0ERXComponentContext____; +__1cEcppubIOMultiTypeInterfaceContainerHelper2T5B6M_v_; +__1cEcppubIOMultiTypeInterfaceContainerHelper2T6M_v_; +__1cEcppubIOMultiTypeInterfaceContainerHelper2t5B6MrnDoslFMutex__v_; +__1cEcppubIOMultiTypeInterfaceContainerHelper2t6MrnDoslFMutex__v_; +__1cEcppubIOMultiTypeInterfaceContainerHelperFclear6M_v_; +__1cEcppubIOMultiTypeInterfaceContainerHelperMaddInterface6MrknDcomDsunEstarDunoEType_rkn0FJReference4n0FKXInterface____l_; #S-ILP32 +__1cEcppubIOMultiTypeInterfaceContainerHelperMaddInterface6MrknDcomDsunEstarDunoEType_rkn0FJReference4n0FKXInterface____i_; #S-LP64 +__1cEcppubIOMultiTypeInterfaceContainerHelperMgetContainer6kMrknDcomDsunEstarDunoEType__pn0AZOInterfaceContainerHelper__; +__1cEcppubIOMultiTypeInterfaceContainerHelperPdisposeAndClear6MrknDcomDsunEstarElangLEventObject__v_; +__1cEcppubIOMultiTypeInterfaceContainerHelperPremoveInterface6MrknDcomDsunEstarDunoEType_rkn0FJReference4n0FKXInterface____l_; #S-ILP32 +__1cEcppubIOMultiTypeInterfaceContainerHelperPremoveInterface6MrknDcomDsunEstarDunoEType_rkn0FJReference4n0FKXInterface____i_; #S-LP64 +__1cEcppubIOMultiTypeInterfaceContainerHelperRgetContainedTypes6kM_nDcomDsunEstarDunoISequence4n0FEType____; +__1cEcppubI__RTTI__1CpknEcppuOOWeakAggObject__; +__1cEcppubJ__RTTI__1CpnEcppuQdDOComponentHelper__; +__1cEcppubK__RTTI__1CpknEcppuQdDOComponentHelper__; +__1cEcppubL__RTTI__1CpnEcppuSOPropertySetHelper__; +__1cEcppubM__RTTI__1CpknEcppuSOPropertySetHelper__; +__1cEcppubNOMultiTypeInterfaceContainerHelperInt322T5B6M_v_; +__1cEcppubNOMultiTypeInterfaceContainerHelperInt322T6M_v_; +__1cEcppubNOMultiTypeInterfaceContainerHelperInt322t5B6MrnDoslFMutex__v_; +__1cEcppubNOMultiTypeInterfaceContainerHelperInt322t6MrnDoslFMutex__v_; +__1cEcppubNOMultiTypeInterfaceContainerHelperInt32Fclear6M_v_; +__1cEcppubNOMultiTypeInterfaceContainerHelperInt32MaddInterface6MrklrknDcomDsunEstarDunoJReference4n0FKXInterface____l_; #S-ILP32 +__1cEcppubNOMultiTypeInterfaceContainerHelperInt32MaddInterface6MrkirknDcomDsunEstarDunoJReference4n0FKXInterface____i_; #S-LP64 +__1cEcppubNOMultiTypeInterfaceContainerHelperInt32MgetContainer6kMrkl_pn0AZOInterfaceContainerHelper__; #S-ILP32 +__1cEcppubNOMultiTypeInterfaceContainerHelperInt32MgetContainer6kMrki_pn0AZOInterfaceContainerHelper__; #S-LP64 +__1cEcppubNOMultiTypeInterfaceContainerHelperInt32PdisposeAndClear6MrknDcomDsunEstarElangLEventObject__v_; +__1cEcppubNOMultiTypeInterfaceContainerHelperInt32PremoveInterface6MrklrknDcomDsunEstarDunoJReference4n0FKXInterface____l_; #S-ILP32 +__1cEcppubNOMultiTypeInterfaceContainerHelperInt32PremoveInterface6MrkirknDcomDsunEstarDunoJReference4n0FKXInterface____i_; #S-LP64 +__1cEcppubNOMultiTypeInterfaceContainerHelperInt32RgetContainedTypes6kM_nDcomDsunEstarDunoISequence4Cl___; #S-ILP32 +__1cEcppubNOMultiTypeInterfaceContainerHelperInt32RgetContainedTypes6kM_nDcomDsunEstarDunoISequence4Ci___; #S-LP64 +__1cEcppubN__RTTI__1CpnEcppuUIPropertyArrayHelper__; +__1cEcppubN__RTTI__1CpnEcppuUOPropertyArrayHelper__; +__1cEcppubO__RTTI__1CpknEcppuUIPropertyArrayHelper__; +__1cEcppubO__RTTI__1CpknEcppuUOPropertyArrayHelper__; +__1cEcppubOdefaultBootstrap_InitialComponentContext6F_nDcomDsunEstarDunoJReference4n0ERXComponentContext____; +__1cEcppubV__RTTI__1CpnEcppubBWeakComponentImplHelperBase__; +__1cEcppubW__RTTI__1CpknEcppubBWeakComponentImplHelperBase__; +__1cEcppubY__RTTI__1CpnEcppubEWeakAggComponentImplHelperBase__; +__1cEcppubZ__RTTI__1CpknEcppubEWeakAggComponentImplHelperBase__; +_edata; +_end; +_etext; +_fini; +_init; +__1cDcomDsunEstarDunobM__RTTI__1nDcomDsunEstarDunoJException__; +__1cDcomDsunEstarDunobT__RTTI__1nDcomDsunEstarDunoQdDRuntimeException__; +__1cDcomDsunEstarElangcA__RTTI__1nDcomDsunEstarElangWWrappedTargetException__; +__1cDcomDsunEstarElangcC__RTTI__1nDcomDsunEstarElangYIllegalArgumentException__; +__1cDcomDsunEstarFbeanscA__RTTI__1nDcomDsunEstarFbeansVPropertyVetoException__; +__1cDcomDsunEstarFbeanscD__RTTI__1nDcomDsunEstarFbeansYUnknownPropertyException__; +__1cDcomDsunEstarGloadercL__RTTI__1nDcomDsunEstarGloaderbECannotActivateFactoryException__; +__1cDcomDsunEstarIregistrycG__RTTI__1nDcomDsunEstarIregistryYInvalidRegistryException__; +__1cDcomDsunEstarIregistrycU__RTTI__1nDcomDsunEstarIregistrybLCannotRegisterImplementationException__; +__1cEcppuZcomponent_writeInfoHelper6Fpv1pkn0ATImplementationEntry__C_; +__1cEcppubAcomponent_getFactoryHelper6Fpkcpv3pkn0ATImplementationEntry__3_; +__1cEcppuQImplHelper_query6FrknDcomDsunEstarDunoEType_pn0AKclass_data_pv_n0EDAny__; +__1cEcppuUWeakImplHelper_query6FrknDcomDsunEstarDunoEType_pn0AKclass_data_pvpn0ALOWeakObject__n0EDAny__; +__1cEcppubAWeakAggImplHelper_queryAgg6FrknDcomDsunEstarDunoEType_pn0AKclass_data_pvpn0AOOWeakAggObject__n0EDAny__; +__1cEcppubCImplHelper_queryNoXInterface6FrknDcomDsunEstarDunoEType_pn0AKclass_data_pv_n0EDAny__; +__1cEcppubDWeakComponentImplHelper_query6FrknDcomDsunEstarDunoEType_pn0AKclass_data_pvpn0AbBWeakComponentImplHelperBase__n0EDAny__; +__1cEcppubJWeakAggComponentImplHelper_queryAgg6FrknDcomDsunEstarDunoEType_pn0AKclass_data_pvpn0AbEWeakAggComponentImplHelperBase__n0EDAny__; +__1cEcppuTImplHelper_getTypes6Fpn0AKclass_data__nDcomDsunEstarDunoISequence4n0FEType____; +__1cEcppuWImplInhHelper_getTypes6Fpn0AKclass_data_rknDcomDsunEstarDunoISequence4n0FEType____7_; +__1cEcppuXWeakImplHelper_getTypes6Fpn0AKclass_data__nDcomDsunEstarDunoISequence4n0FEType____; +__1cEcppubAWeakAggImplHelper_getTypes6Fpn0AKclass_data__nDcomDsunEstarDunoISequence4n0FEType____; +__1cEcppubGWeakComponentImplHelper_getTypes6Fpn0AKclass_data__nDcomDsunEstarDunoISequence4n0FEType____; +__1cEcppubJWeakAggComponentImplHelper_getTypes6Fpn0AKclass_data__nDcomDsunEstarDunoISequence4n0FEType____; +__1cEcppubEImplHelper_getImplementationId6Fpn0AKclass_data__nDcomDsunEstarDunoISequence4CW___; +__1cEcppubOdefaultBootstrap_InitialComponentContext6FrknDrtlIOUString__nDcomDsunEstarDunoJReference4n0GRXComponentContext____; + +__1cEcppuNAccessControl2t5B6MrknDcomDsunEstarDunoJReference4n0EIsecurityRXAccessController____v_; +__1cEcppuNAccessControl2t5B6MrknDcomDsunEstarDunoJReference4n0FRXComponentContext____v_; +__1cEcppuNAccessControl2t5B6Mrk1_v_; +__1cEcppuNAccessControl2t6Mrk1_v_; +__1cEcppuNAccessControl2t6MrknDcomDsunEstarDunoJReference4n0EIsecurityRXAccessController____v_; +__1cEcppuNAccessControl2t6MrknDcomDsunEstarDunoJReference4n0FRXComponentContext____v_; +__1cEcppuNAccessControlTcheckFilePermission6MrknDrtlIOUString_5_v_; +__1cEcppuNAccessControlVcheckSocketPermission6MrknDrtlIOUString_5_v_; +__1cEcppuNAccessControlWcheckRuntimePermission6MrknDrtlIOUString__v_; + +__1cEcppuQUnoUrlDescriptor2t5B6MrknDrtlIOUString__v_; +__1cEcppuQUnoUrlDescriptor2t6MrknDrtlIOUString__v_; +__1cEcppuQUnoUrlDescriptor2t5B6Mrk1_v_; +__1cEcppuQUnoUrlDescriptor2t6Mrk1_v_; +__1cEcppuQUnoUrlDescriptor2T5B6M_v_; +__1cEcppuQUnoUrlDescriptor2T6M_v_; +__1cEcppuGUnoUrl2t5B6MrknDrtlIOUString__v_; +__1cEcppuGUnoUrl2t6MrknDrtlIOUString__v_; +__1cEcppuGUnoUrl2t5B6Mrk1_v_; +__1cEcppuGUnoUrl2t6Mrk1_v_; +__1cEcppuGUnoUrl2T5B6M_v_; +__1cEcppuGUnoUrl2T6M_v_; +__1cEcppuQUnoUrlDescriptor2G6Mrk1_r1_; +__1cEcppuQUnoUrlDescriptorNgetDescriptor6kM_rknDrtlIOUString__; +__1cEcppuQUnoUrlDescriptorHgetName6kM_rknDrtlIOUString__; +__1cEcppuQUnoUrlDescriptorMhasParameter6kMrknDrtlIOUString__b_; +__1cEcppuQUnoUrlDescriptorMgetParameter6kMrknDrtlIOUString__3_; +__1cEcppuGUnoUrl2G6Mrk1_r1_; +__1cEcppuGUnoUrlNgetConnection6kM_rkn0AQUnoUrlDescriptor__; +__1cEcppuGUnoUrlLgetProtocol6kM_rkn0AQUnoUrlDescriptor__; +__1cEcppuGUnoUrlNgetObjectName6kM_rknDrtlIOUString__; + + local: + *; +}; + +UDK_3.1 { + global: + __1cEcppuSgetCaughtException6F_nDcomDsunEstarDunoDAny__; + + __1cEcppuSOPropertySetHelper2t6Mrn0ATOBroadcastHelperVar4n0AbIOMultiTypeInterfaceContainerHelper_nDcomDsunEstarDunoEType___b_v_; + __1cEcppuSOPropertySetHelper2t5B6Mrn0ATOBroadcastHelperVar4n0AbIOMultiTypeInterfaceContainerHelper_nDcomDsunEstarDunoEType___b_v_; + + __1cEcppuJbootstrap6F_nDcomDsunEstarDunoJReference4n0ERXComponentContext____; + __1cEcppuSBootstrapException2t6M_v_; + __1cEcppuSBootstrapException2t5B6M_v_; + __1cEcppuSBootstrapException2t6MrknDrtlIOUString__v_; + __1cEcppuSBootstrapException2t5B6MrknDrtlIOUString__v_; + __1cEcppuSBootstrapException2t6Mrk1_v_; + __1cEcppuSBootstrapException2t5B6Mrk1_v_; + __1cEcppuSBootstrapException2T6M_v_; + __1cEcppuSBootstrapException2T5B6M_v_; + __1cEcppuSBootstrapException2G6Mrk1_r1_; + __1cEcppuSBootstrapExceptionKgetMessage6kM_rknDrtlIOUString__; + __1cEcppubJ__RTTI__1nEcppuSBootstrapException__; + __1cEcppubL__RTTI__1CpnEcppuSBootstrapException__; + __1cEcppubM__RTTI__1CpknEcppuSBootstrapException__; +} UDK_3_0_0; + +UDK_3.2 { + global: + __1cEcppubL__RTTI__1nEcppuUPropertySetMixinImpl__; + __1cEcppubN__RTTI__1CpnEcppuUPropertySetMixinImpl__; + __1cEcppubO__RTTI__1CpknEcppuUPropertySetMixinImpl__; + __1cEcppuUPropertySetMixinImpl2t5B6MrknDcomDsunEstarDunoJReference4n0FRXComponentContext___n0BKImplements_rkn0FISequence4nDrtlIOUString___rkn0FEType__v_; + __1cEcppuUPropertySetMixinImpl2T5B6M_v_; + __1cEcppuUPropertySetMixinImpl2t6MrknDcomDsunEstarDunoJReference4n0FRXComponentContext___n0BKImplements_rkn0FISequence4nDrtlIOUString___rkn0FEType__v_; + __1cEcppuUPropertySetMixinImpl2T6M_v_; + __1cEcppuUPropertySetMixinImplbCremovePropertyChangeListener6MrknDrtlIOUString_rknDcomDsunEstarDunoJReference4n0GFbeansXXPropertyChangeListener____v_; + __1cEcppuUPropertySetMixinImplbCremoveVetoableChangeListener6MrknDrtlIOUString_rknDcomDsunEstarDunoJReference4n0GFbeansXXVetoableChangeListener____v_; + __1cEcppuUPropertySetMixinImplHdispose6M_v_; + __1cEcppuUPropertySetMixinImplKprepareSet6MrknDrtlIOUString_rknDcomDsunEstarDunoDAny_9Dpn0BOBoundListeners__v_; + __1cEcppuUPropertySetMixinImplOBoundListeners2T5B6M_v_; + __1cEcppuUPropertySetMixinImplOBoundListeners2t5B6M_v_; + __1cEcppuUPropertySetMixinImplOBoundListeners2T6M_v_; + __1cEcppuUPropertySetMixinImplOBoundListeners2t6M_v_; + __1cEcppuUPropertySetMixinImplOBoundListenersGnotify6kM_v_; + __1cEcppuUPropertySetMixinImplOqueryInterface6MrknDcomDsunEstarDunoEType__n0FDAny__; + __1cEcppuUPropertySetMixinImplQgetPropertyValue6MrknDrtlIOUString__nDcomDsunEstarDunoDAny__; + __1cEcppuUPropertySetMixinImplQsetPropertyValue6MrknDrtlIOUString_rknDcomDsunEstarDunoDAny__v_; + __1cEcppuUPropertySetMixinImplRgetPropertyValues6M_nDcomDsunEstarDunoISequence4n0EFbeansNPropertyValue____; + __1cEcppuUPropertySetMixinImplRsetPropertyValues6MrknDcomDsunEstarDunoISequence4n0EFbeansNPropertyValue____v_; + __1cEcppuUPropertySetMixinImplSgetPropertySetInfo6M_nDcomDsunEstarDunoJReference4n0EFbeansQXPropertySetInfo____; + __1cEcppuUPropertySetMixinImplUgetFastPropertyValue6Ml_nDcomDsunEstarDunoDAny__; #S-ILP32 + __1cEcppuUPropertySetMixinImplUgetFastPropertyValue6Mi_nDcomDsunEstarDunoDAny__; #S-LP64 + __1cEcppuUPropertySetMixinImplUsetFastPropertyValue6MlrknDcomDsunEstarDunoDAny__v_; #S-ILP32 + __1cEcppuUPropertySetMixinImplUsetFastPropertyValue6MirknDcomDsunEstarDunoDAny__v_; #S-LP64 + __1cEcppuUPropertySetMixinImplZaddPropertyChangeListener6MrknDrtlIOUString_rknDcomDsunEstarDunoJReference4n0GFbeansXXPropertyChangeListener____v_; + __1cEcppuUPropertySetMixinImplZaddVetoableChangeListener6MrknDrtlIOUString_rknDcomDsunEstarDunoJReference4n0GFbeansXXVetoableChangeListener____v_; +} UDK_3.1; + +UDK_3.3 { # OOo 2.0.4 + global: + __1cEcppubC__RTTI__1nEcppuLOWeakObject__; +} UDK_3.2; + +UDK_3.4 { # OOo 2.3 + global: + __1cEcppuSOPropertySetHelperIgetTypes6M_nDcomDsunEstarDunoISequence4n0FEType____; +} UDK_3.3; + +UDK_3.5 { # OOo 2.4 + global: + __1cEcppuTbootstrap_expandUri6FrknDrtlIOUString__2_; # rtl::OUString cppu::bootstrap_expandUri(rtl::OUString const &) +} UDK_3.4; + +UDK_3.6 { # OOo 3.0 + global: + __1cEcppuSOPropertySetHelper2t5B6Mrn0ATOBroadcastHelperVar4n0AbIOMultiTypeInterfaceContainerHelper_nDcomDsunEstarDunoEType___pn0AWIEventNotificationHook_b_v_; + __1cEcppuSOPropertySetHelper2t6Mrn0ATOBroadcastHelperVar4n0AbIOMultiTypeInterfaceContainerHelper_nDcomDsunEstarDunoEType___pn0AWIEventNotificationHook_b_v_; +} UDK_3.5; + +UDK_3.7 { # OOo 3.3 + global: + __1cEcppuLOWeakObjectbAdisposeWeakConnectionPoint6M_v_; + __1cDcomDsunEstarDunoTWeakReferenceHelper2G6Mrkn0DJReference4n0DKXInterface____r4_; + __1cDcomDsunEstarDunoTWeakReferenceHelperFclear6M_v_; + __1cEcppubHcreateOneInstanceComponentFactory6FpFrknDcomDsunEstarDunoJReference4n0ERXComponentContext____n0EJReference4n0EKXInterface___rknDrtlIOUString_rkn0EISequence4n0K___pnQ_rtl_ModuleCount__n0EJReference4n0DElangXXSingleComponentFactory____; +} UDK_3.6; diff --git a/cppuhelper/source/component.cxx b/cppuhelper/source/component.cxx new file mode 100644 index 000000000000..2add1357b5cf --- /dev/null +++ b/cppuhelper/source/component.cxx @@ -0,0 +1,250 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_cppuhelper.hxx" +#include <rtl/string.hxx> +#include <osl/diagnose.h> +#include <cppuhelper/component.hxx> +#include <cppuhelper/queryinterface.hxx> +#include <cppuhelper/typeprovider.hxx> +#include "com/sun/star/uno/RuntimeException.hpp" + +using namespace osl; +using namespace rtl; +using namespace com::sun::star; +using namespace com::sun::star::uno; +using namespace com::sun::star::lang; + +namespace cppu +{ + +// ---------------------------------------------------- +// class OComponentHelper +// ---------------------------------------------------- + +OComponentHelper::OComponentHelper( Mutex & rMutex ) SAL_THROW( () ) + : rBHelper( rMutex ) +{ +} +OComponentHelper::~OComponentHelper() SAL_THROW( (RuntimeException) ) +{ +} + +Any OComponentHelper::queryInterface( Type const & rType ) throw (RuntimeException) +{ + return OWeakAggObject::queryInterface( rType ); +} +Any OComponentHelper::queryAggregation( Type const & rType ) throw (RuntimeException) +{ + if (rType == ::getCppuType( (Reference< lang::XComponent > const *)0 )) + { + void * p = static_cast< lang::XComponent * >( this ); + return Any( &p, rType ); + } + else if (rType == ::getCppuType( (Reference< lang::XTypeProvider > const *)0 )) + { + void * p = static_cast< lang::XTypeProvider * >( this ); + return Any( &p, rType ); + } + return OWeakAggObject::queryAggregation( rType ); +} +void OComponentHelper::acquire() throw () +{ + OWeakAggObject::acquire(); +} + +void OComponentHelper::release() throw() +{ + Reference<XInterface > x( xDelegator ); + if (! x.is()) + { + if (osl_decrementInterlockedCount( &m_refCount ) == 0) + { + if (! rBHelper.bDisposed) + { + // *before* again incrementing our ref count, ensure that our weak connection point + // will not create references to us anymore (via XAdapter::queryAdapted) + disposeWeakConnectionPoint(); + + Reference<XInterface > xHoldAlive( *this ); + // First dispose + try + { + dispose(); + } + catch (::com::sun::star::uno::RuntimeException & exc) + { + // release should not throw exceptions +#if OSL_DEBUG_LEVEL > 0 + OString msg( OUStringToOString( exc.Message, RTL_TEXTENCODING_ASCII_US ) ); + OSL_ENSURE( 0, msg.getStr() ); +#else + (void) exc; // avoid warning about unused variable +#endif + } + + // only the alive ref holds the object + OSL_ASSERT( m_refCount == 1 ); + // destroy the object if xHoldAlive decrement the refcount to 0 + return; + } + } + // restore the reference count + osl_incrementInterlockedCount( &m_refCount ); + } + OWeakAggObject::release(); +} + +Sequence< Type > OComponentHelper::getTypes() throw (RuntimeException) +{ + static OTypeCollection * s_pTypes = 0; + if (! s_pTypes) + { + MutexGuard aGuard( Mutex::getGlobalMutex() ); + if (! s_pTypes) + { + static OTypeCollection s_aTypes( + ::getCppuType( (const Reference< lang::XComponent > *)0 ), + ::getCppuType( (const Reference< lang::XTypeProvider > *)0 ), + ::getCppuType( (const Reference< XAggregation > *)0 ), + ::getCppuType( (const Reference< XWeak > *)0 ) ); + s_pTypes = &s_aTypes; + } + } + return s_pTypes->getTypes(); +} + +// XComponent +void OComponentHelper::disposing() +{ +} + +// XComponent +void OComponentHelper::dispose() + throw(::com::sun::star::uno::RuntimeException) +{ + // An frequently programming error is to release the last + // reference to this object in the disposing message. + // Make it rubust, hold a self Reference. + Reference<XComponent > xSelf( this ); + + // Guard dispose against multible threading + // Remark: It is an error to call dispose more than once + sal_Bool bDoDispose = sal_False; + { + MutexGuard aGuard( rBHelper.rMutex ); + if( !rBHelper.bDisposed && !rBHelper.bInDispose ) + { + // only one call go into this section + rBHelper.bInDispose = sal_True; + bDoDispose = sal_True; + } + } + + // Do not hold the mutex because we are broadcasting + if( bDoDispose ) + { + // Create an event with this as sender + try + { + try + { + Reference<XInterface > xSource( + Reference<XInterface >::query( (XComponent *)this ) ); + EventObject aEvt; + aEvt.Source = xSource; + // inform all listeners to release this object + // The listener container are automaticly cleared + rBHelper.aLC.disposeAndClear( aEvt ); + // notify subclasses to do their dispose + disposing(); + } + catch (...) + { + MutexGuard aGuard( rBHelper.rMutex ); + // bDispose and bInDisposing must be set in this order: + rBHelper.bDisposed = sal_True; + rBHelper.bInDispose = sal_False; + throw; + } + MutexGuard aGuard( rBHelper.rMutex ); + // bDispose and bInDisposing must be set in this order: + rBHelper.bDisposed = sal_True; + rBHelper.bInDispose = sal_False; + } + catch (RuntimeException &) + { + throw; + } + catch (Exception & exc) + { + throw RuntimeException( + OUString( RTL_CONSTASCII_USTRINGPARAM( + "unexpected UNO exception caught: ") ) + + exc.Message, Reference< XInterface >() ); + } + } + else + { + // in a multithreaded environment, it can't be avoided + // that dispose is called twice. + // However this condition is traced, because it MAY indicate an error. + OSL_TRACE( "OComponentHelper::dispose() - dispose called twice" ); + } +} + +// XComponent +void OComponentHelper::addEventListener( + const Reference<XEventListener > & rxListener ) + throw(::com::sun::star::uno::RuntimeException) +{ + ClearableMutexGuard aGuard( rBHelper.rMutex ); + if (rBHelper.bDisposed || rBHelper.bInDispose) + { + aGuard.clear(); + Reference< XInterface > x( (XComponent *)this, UNO_QUERY ); + rxListener->disposing( EventObject( x ) ); + } + else + { + rBHelper.addListener( ::getCppuType( &rxListener ) , rxListener ); + } +} + +// XComponent +void OComponentHelper::removeEventListener( + const Reference<XEventListener > & rxListener ) + throw(::com::sun::star::uno::RuntimeException) +{ + rBHelper.removeListener( ::getCppuType( &rxListener ) , rxListener ); +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/source/component_context.cxx b/cppuhelper/source/component_context.cxx new file mode 100644 index 000000000000..306490aa1616 --- /dev/null +++ b/cppuhelper/source/component_context.cxx @@ -0,0 +1,902 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ + /************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_cppuhelper.hxx" + +#ifdef DIAG +#define CONTEXT_DIAG +#endif + +#if OSL_DEBUG_LEVEL > 0 +#include <stdio.h> +#endif + +#include <vector> +#include <hash_map> +#ifdef CONTEXT_DIAG +#include <map> +#endif + +#include <osl/diagnose.h> +#include <osl/mutex.hxx> + +#include <rtl/ustrbuf.hxx> + +#include <uno/mapping.hxx> + +#include <cppuhelper/implbase1.hxx> +#include <cppuhelper/compbase2.hxx> +#include <cppuhelper/component_context.hxx> +#include <cppuhelper/exc_hlp.hxx> + +#include <com/sun/star/container/XNameContainer.hpp> +#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp> +#include <com/sun/star/lang/XSingleServiceFactory.hpp> +#include <com/sun/star/lang/XSingleComponentFactory.hpp> +#include <com/sun/star/lang/XMultiComponentFactory.hpp> +#include <com/sun/star/lang/XComponent.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include "com/sun/star/uno/RuntimeException.hpp" + +#include <hash_map> +#include <memory> + +#define SMGR_SINGLETON "/singletons/com.sun.star.lang.theServiceManager" +#define TDMGR_SINGLETON "/singletons/com.sun.star.reflection.theTypeDescriptionManager" +#define AC_SINGLETON "/singletons/com.sun.star.security.theAccessController" +#define AC_POLICY "/singletons/com.sun.star.security.thePolicy" +#define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) ) + + +using namespace ::osl; +using namespace ::rtl; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star; + +namespace cppu +{ + +#ifdef CONTEXT_DIAG +//-------------------------------------------------------------------------------------------------- +static OUString val2str( void const * pVal, typelib_TypeDescriptionReference * pTypeRef ) +{ + OSL_ASSERT( pVal ); + if (pTypeRef->eTypeClass == typelib_TypeClass_VOID) + return OUSTR("void"); + + OUStringBuffer buf( 64 ); + buf.append( (sal_Unicode)'(' ); + buf.append( pTypeRef->pTypeName ); + buf.append( (sal_Unicode)')' ); + + switch (pTypeRef->eTypeClass) + { + case typelib_TypeClass_INTERFACE: + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("0x") ); + buf.append( (sal_Int64)*(void **)pVal, 16 ); + break; + case typelib_TypeClass_STRUCT: + case typelib_TypeClass_EXCEPTION: + { + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("{ ") ); + typelib_TypeDescription * pTypeDescr = 0; + ::typelib_typedescriptionreference_getDescription( &pTypeDescr, pTypeRef ); + OSL_ASSERT( pTypeDescr ); + if (! pTypeDescr->bComplete) + ::typelib_typedescription_complete( &pTypeDescr ); + + typelib_CompoundTypeDescription * pCompType = (typelib_CompoundTypeDescription *)pTypeDescr; + sal_Int32 nDescr = pCompType->nMembers; + + if (pCompType->pBaseTypeDescription) + { + buf.append( val2str( pVal, ((typelib_TypeDescription *)pCompType->pBaseTypeDescription)->pWeakRef ) ); + if (nDescr) + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(", ") ); + } + + typelib_TypeDescriptionReference ** ppTypeRefs = pCompType->ppTypeRefs; + sal_Int32 * pMemberOffsets = pCompType->pMemberOffsets; + rtl_uString ** ppMemberNames = pCompType->ppMemberNames; + + for ( sal_Int32 nPos = 0; nPos < nDescr; ++nPos ) + { + buf.append( ppMemberNames[ nPos ] ); + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(" = ") ); + typelib_TypeDescription * pMemberType = 0; + TYPELIB_DANGER_GET( &pMemberType, ppTypeRefs[ nPos ] ); + buf.append( val2str( (char *)pVal + pMemberOffsets[ nPos ], pMemberType->pWeakRef ) ); + TYPELIB_DANGER_RELEASE( pMemberType ); + if (nPos < (nDescr -1)) + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(", ") ); + } + + ::typelib_typedescription_release( pTypeDescr ); + + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(" }") ); + break; + } + case typelib_TypeClass_SEQUENCE: + { + typelib_TypeDescription * pTypeDescr = 0; + TYPELIB_DANGER_GET( &pTypeDescr, pTypeRef ); + + uno_Sequence * pSequence = *(uno_Sequence **)pVal; + typelib_TypeDescription * pElementTypeDescr = 0; + TYPELIB_DANGER_GET( &pElementTypeDescr, ((typelib_IndirectTypeDescription *)pTypeDescr)->pType ); + + sal_Int32 nElementSize = pElementTypeDescr->nSize; + sal_Int32 nElements = pSequence->nElements; + + if (nElements) + { + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("{ ") ); + char * pElements = pSequence->elements; + for ( sal_Int32 nPos = 0; nPos < nElements; ++nPos ) + { + buf.append( val2str( pElements + (nElementSize * nPos), pElementTypeDescr->pWeakRef ) ); + if (nPos < (nElements -1)) + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(", ") ); + } + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(" }") ); + } + else + { + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("{}") ); + } + TYPELIB_DANGER_RELEASE( pElementTypeDescr ); + TYPELIB_DANGER_RELEASE( pTypeDescr ); + break; + } + case typelib_TypeClass_ANY: + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("{ ") ); + buf.append( val2str( ((uno_Any *)pVal)->pData, + ((uno_Any *)pVal)->pType ) ); + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(" }") ); + break; + case typelib_TypeClass_TYPE: + buf.append( (*(typelib_TypeDescriptionReference **)pVal)->pTypeName ); + break; + case typelib_TypeClass_STRING: + buf.append( (sal_Unicode)'\"' ); + buf.append( *(rtl_uString **)pVal ); + buf.append( (sal_Unicode)'\"' ); + break; + case typelib_TypeClass_ENUM: + { + typelib_TypeDescription * pTypeDescr = 0; + ::typelib_typedescriptionreference_getDescription( &pTypeDescr, pTypeRef ); + OSL_ASSERT( pTypeDescr ); + if (! pTypeDescr->bComplete) + ::typelib_typedescription_complete( &pTypeDescr ); + + sal_Int32 * pValues = ((typelib_EnumTypeDescription *)pTypeDescr)->pEnumValues; + sal_Int32 nPos = ((typelib_EnumTypeDescription *)pTypeDescr)->nEnumValues; + while (nPos--) + { + if (pValues[ nPos ] == *(sal_Int32 *)pVal) + break; + } + if (nPos >= 0) + buf.append( ((typelib_EnumTypeDescription *)pTypeDescr)->ppEnumNames[ nPos ] ); + else + buf.append( (sal_Unicode)'?' ); + + ::typelib_typedescription_release( pTypeDescr ); + break; + } + case typelib_TypeClass_BOOLEAN: + if (*(sal_Bool *)pVal) + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("true") ); + else + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("false") ); + break; + case typelib_TypeClass_CHAR: + buf.append( (sal_Unicode)'\'' ); + buf.append( *(sal_Unicode *)pVal ); + buf.append( (sal_Unicode)'\'' ); + break; + case typelib_TypeClass_FLOAT: + buf.append( *(float *)pVal ); + break; + case typelib_TypeClass_DOUBLE: + buf.append( *(double *)pVal ); + break; + case typelib_TypeClass_BYTE: + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("0x") ); + buf.append( (sal_Int32)*(sal_Int8 *)pVal, 16 ); + break; + case typelib_TypeClass_SHORT: + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("0x") ); + buf.append( (sal_Int32)*(sal_Int16 *)pVal, 16 ); + break; + case typelib_TypeClass_UNSIGNED_SHORT: + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("0x") ); + buf.append( (sal_Int32)*(sal_uInt16 *)pVal, 16 ); + break; + case typelib_TypeClass_LONG: + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("0x") ); + buf.append( *(sal_Int32 *)pVal, 16 ); + break; + case typelib_TypeClass_UNSIGNED_LONG: + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("0x") ); + buf.append( (sal_Int64)*(sal_uInt32 *)pVal, 16 ); + break; + case typelib_TypeClass_HYPER: + case typelib_TypeClass_UNSIGNED_HYPER: + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("0x") ); +#if defined(GCC) && defined(SPARC) + { + sal_Int64 aVal; + *(sal_Int32 *)&aVal = *(sal_Int32 *)pVal; + *((sal_Int32 *)&aVal +1)= *((sal_Int32 *)pVal +1); + buf.append( aVal, 16 ); + } +#else + buf.append( *(sal_Int64 *)pVal, 16 ); +#endif + break; + default: + buf.append( (sal_Unicode)'?' ); + } + + return buf.makeStringAndClear(); +} +//-------------------------------------------------------------------------------------------------- +static void dumpEntry( OUString const & key, Any const & value ) +{ + OUString val( val2str( value.getValue(), value.getValueTypeRef() ) ); + OString key_str( OUStringToOString( key, RTL_TEXTENCODING_ASCII_US ) ); + OString val_str( OUStringToOString( val, RTL_TEXTENCODING_ASCII_US ) ); + ::fprintf( stderr, "| %s = %s\n", key_str.getStr(), val_str.getStr() ); +} +#endif +//-------------------------------------------------------------------------------------------------- +static inline void try_dispose( Reference< XInterface > const & xInstance ) + SAL_THROW( (RuntimeException) ) +{ + Reference< lang::XComponent > xComp( xInstance, UNO_QUERY ); + if (xComp.is()) + { + xComp->dispose(); + } +} +//-------------------------------------------------------------------------------------------------- +static inline void try_dispose( Reference< lang::XComponent > const & xComp ) + SAL_THROW( (RuntimeException) ) +{ + if (xComp.is()) + { + xComp->dispose(); + } +} + +//================================================================================================== + +class DisposingForwarder + : public WeakImplHelper1< lang::XEventListener > +{ + Reference< lang::XComponent > m_xTarget; + + inline DisposingForwarder( Reference< lang::XComponent > const & xTarget ) + SAL_THROW( () ) + : m_xTarget( xTarget ) + { OSL_ASSERT( m_xTarget.is() ); } +public: + // listens at source for disposing, then disposes target + static inline void listen( + Reference< lang::XComponent > const & xSource, + Reference< lang::XComponent > const & xTarget ) + SAL_THROW( (RuntimeException) ); + + virtual void SAL_CALL disposing( lang::EventObject const & rSource ) + throw (RuntimeException); +}; +//__________________________________________________________________________________________________ +inline void DisposingForwarder::listen( + Reference< lang::XComponent > const & xSource, + Reference< lang::XComponent > const & xTarget ) + SAL_THROW( (RuntimeException) ) +{ + if (xSource.is()) + { + xSource->addEventListener( new DisposingForwarder( xTarget ) ); + } +} +//__________________________________________________________________________________________________ +void DisposingForwarder::disposing( lang::EventObject const & ) + throw (RuntimeException) +{ + m_xTarget->dispose(); + m_xTarget.clear(); +} + +//================================================================================================== +struct MutexHolder +{ +protected: + Mutex m_mutex; +}; +//================================================================================================== + +class ComponentContext + : private MutexHolder + , public WeakComponentImplHelper2< XComponentContext, + container::XNameContainer > +{ +protected: + Reference< XComponentContext > m_xDelegate; + + struct ContextEntry + { + Any value; + bool lateInit; + + inline ContextEntry( Any const & value_, bool lateInit_ ) + : value( value_ ) + , lateInit( lateInit_ ) + {} + }; + typedef ::std::hash_map< OUString, ContextEntry * , OUStringHash > t_map; + t_map m_map; + + Reference< lang::XMultiComponentFactory > m_xSMgr; + +protected: + Any lookupMap( OUString const & rName ) + SAL_THROW( (RuntimeException) ); + + virtual void SAL_CALL disposing(); +public: + ComponentContext( + ContextEntry_Init const * pEntries, sal_Int32 nEntries, + Reference< XComponentContext > const & xDelegate ); + virtual ~ComponentContext() + SAL_THROW( () ); + + // XComponentContext + virtual Any SAL_CALL getValueByName( OUString const & rName ) + throw (RuntimeException); + virtual Reference<lang::XMultiComponentFactory> SAL_CALL getServiceManager() + throw (RuntimeException); + + // XNameContainer + virtual void SAL_CALL insertByName( + OUString const & name, Any const & element ) + throw (lang::IllegalArgumentException, container::ElementExistException, + lang::WrappedTargetException, RuntimeException); + virtual void SAL_CALL removeByName( OUString const & name ) + throw (container::NoSuchElementException, + lang::WrappedTargetException, RuntimeException); + // XNameReplace + virtual void SAL_CALL replaceByName( + OUString const & name, Any const & element ) + throw (lang::IllegalArgumentException,container::NoSuchElementException, + lang::WrappedTargetException, RuntimeException); + // XNameAccess + virtual Any SAL_CALL getByName( OUString const & name ) + throw (container::NoSuchElementException, + lang::WrappedTargetException, RuntimeException); + virtual Sequence<OUString> SAL_CALL getElementNames() + throw (RuntimeException); + virtual sal_Bool SAL_CALL hasByName( OUString const & name ) + throw (RuntimeException); + // XElementAccess + virtual Type SAL_CALL getElementType() throw (RuntimeException); + virtual sal_Bool SAL_CALL hasElements() throw (RuntimeException); +}; + +// XNameContainer +//______________________________________________________________________________ +void ComponentContext::insertByName( + OUString const & name, Any const & element ) + throw (lang::IllegalArgumentException, container::ElementExistException, + lang::WrappedTargetException, RuntimeException) +{ + t_map::mapped_type entry( + new ContextEntry( + element, + /* lateInit_: */ + name.matchAsciiL( RTL_CONSTASCII_STRINGPARAM("/singletons/") ) && + !element.hasValue() ) ); + MutexGuard guard( m_mutex ); + ::std::pair<t_map::iterator, bool> insertion( m_map.insert( + t_map::value_type( name, entry ) ) ); + if (! insertion.second) + throw container::ElementExistException( + OUSTR("element already exists: ") + name, + static_cast<OWeakObject *>(this) ); +} + +//______________________________________________________________________________ +void ComponentContext::removeByName( OUString const & name ) + throw (container::NoSuchElementException, + lang::WrappedTargetException, RuntimeException) +{ + MutexGuard guard( m_mutex ); + t_map::iterator iFind( m_map.find( name ) ); + if (iFind == m_map.end()) + throw container::NoSuchElementException( + OUSTR("no such element: ") + name, + static_cast<OWeakObject *>(this) ); + + delete iFind->second; + m_map.erase(iFind); +} + +// XNameReplace +//______________________________________________________________________________ +void ComponentContext::replaceByName( + OUString const & name, Any const & element ) + throw (lang::IllegalArgumentException,container::NoSuchElementException, + lang::WrappedTargetException, RuntimeException) +{ + MutexGuard guard( m_mutex ); + t_map::const_iterator const iFind( m_map.find( name ) ); + if (iFind == m_map.end()) + throw container::NoSuchElementException( + OUSTR("no such element: ") + name, + static_cast<OWeakObject *>(this) ); + if (name.matchAsciiL( RTL_CONSTASCII_STRINGPARAM("/singletons/") ) && + !element.hasValue()) + { + iFind->second->value.clear(); + iFind->second->lateInit = true; + } + else + { + iFind->second->value = element; + iFind->second->lateInit = false; + } +} + +// XNameAccess +//______________________________________________________________________________ +Any ComponentContext::getByName( OUString const & name ) + throw (container::NoSuchElementException, + lang::WrappedTargetException, RuntimeException) +{ + return getValueByName( name ); +} + +//______________________________________________________________________________ +Sequence<OUString> ComponentContext::getElementNames() + throw (RuntimeException) +{ + MutexGuard guard( m_mutex ); + Sequence<OUString> ret( m_map.size() ); + OUString * pret = ret.getArray(); + sal_Int32 pos = 0; + t_map::const_iterator iPos( m_map.begin() ); + t_map::const_iterator const iEnd( m_map.end() ); + for ( ; iPos != iEnd; ++iPos ) + pret[pos++] = iPos->first; + return ret; +} + +//______________________________________________________________________________ +sal_Bool ComponentContext::hasByName( OUString const & name ) + throw (RuntimeException) +{ + MutexGuard guard( m_mutex ); + return m_map.find( name ) != m_map.end(); +} + +// XElementAccess +//______________________________________________________________________________ +Type ComponentContext::getElementType() throw (RuntimeException) +{ + return ::getVoidCppuType(); +} + +//______________________________________________________________________________ +sal_Bool ComponentContext::hasElements() throw (RuntimeException) +{ + MutexGuard guard( m_mutex ); + return ! m_map.empty(); +} + +//__________________________________________________________________________________________________ +Any ComponentContext::lookupMap( OUString const & rName ) + SAL_THROW( (RuntimeException) ) +{ +#ifdef CONTEXT_DIAG + if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("dump_maps") )) + { + ::fprintf( stderr, ">>> dumping out ComponentContext %p m_map:\n", this ); + typedef ::std::map< OUString, ContextEntry * > t_sorted; // sorted map + t_sorted sorted; + for ( t_map::const_iterator iPos( m_map.begin() ); iPos != m_map.end(); ++iPos ) + { + sorted[ iPos->first ] = iPos->second; + } + { + for ( t_sorted::const_iterator iPos( sorted.begin() ); iPos != sorted.end(); ++iPos ) + { + dumpEntry( iPos->first, iPos->second->value ); + } + } + return Any(); + } +#endif + + ResettableMutexGuard guard( m_mutex ); + t_map::const_iterator iFind( m_map.find( rName ) ); + if (iFind == m_map.end()) + return Any(); + + t_map::mapped_type pEntry = iFind->second; + if (! pEntry->lateInit) + return pEntry->value; + + // late init singleton entry + Reference< XInterface > xInstance; + guard.clear(); + + try + { + Any usesService( getValueByName( rName + OUSTR("/service") ) ); + Any args_( getValueByName( rName + OUSTR("/arguments") ) ); + Sequence<Any> args; + if (args_.hasValue() && !(args_ >>= args)) + { + args.realloc( 1 ); + args[ 0 ] = args_; + } + + Reference< lang::XSingleComponentFactory > xFac; + if (usesService >>= xFac) // try via factory + { + xInstance = args.getLength() + ? xFac->createInstanceWithArgumentsAndContext( args, this ) + : xFac->createInstanceWithContext( this ); + } + else + { + Reference< lang::XSingleServiceFactory > xFac2; + if (usesService >>= xFac2) + { + // try via old XSingleServiceFactory +#if OSL_DEBUG_LEVEL > 0 + ::fprintf( + stderr, + "### omitting context for service instanciation!\n" ); +#endif + xInstance = args.getLength() + ? xFac2->createInstanceWithArguments( args ) + : xFac2->createInstance(); + } + else if (m_xSMgr.is()) // optionally service name + { + OUString serviceName; + if ((usesService >>= serviceName) && + serviceName.getLength()) + { + xInstance = args.getLength() + ? m_xSMgr->createInstanceWithArgumentsAndContext( + serviceName, args, this ) + : m_xSMgr->createInstanceWithContext( + serviceName, this ); + } + } + } + } + catch (RuntimeException &) + { + throw; + } + catch (Exception & exc) // rethrow as WrappedTargetRuntimeException + { + Any caught( getCaughtException() ); + OUStringBuffer buf; + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( + "exception occured raising singleton \"") ); + buf.append( rName ); + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("\": ") ); + buf.append( exc.Message ); + throw lang::WrappedTargetRuntimeException( + buf.makeStringAndClear(), static_cast<OWeakObject *>(this),caught ); + } + + if (! xInstance.is()) + { + throw RuntimeException( + OUSTR("no service object raising singleton ") + rName, + static_cast<OWeakObject *>(this) ); + } + + Any ret; + guard.reset(); + iFind = m_map.find( rName ); + if (iFind != m_map.end()) + { + pEntry = iFind->second; + if (pEntry->lateInit) + { + pEntry->value <<= xInstance; + pEntry->lateInit = false; + return pEntry->value; + } + else + ret = pEntry->value; + } + guard.clear(); + try_dispose( xInstance ); + return ret; +} + +//__________________________________________________________________________________________________ +Any ComponentContext::getValueByName( OUString const & rName ) + throw (RuntimeException) +{ + // to determine the root context: + if (rName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("_root") )) + { + if (m_xDelegate.is()) + return m_xDelegate->getValueByName( rName ); + else + return makeAny( Reference<XComponentContext>(this) ); + } + + Any ret( lookupMap( rName ) ); + if (!ret.hasValue() && m_xDelegate.is()) + { + return m_xDelegate->getValueByName( rName ); + } + return ret; +} +//__________________________________________________________________________________________________ +Reference< lang::XMultiComponentFactory > ComponentContext::getServiceManager() + throw (RuntimeException) +{ + return m_xSMgr; +} +//__________________________________________________________________________________________________ +ComponentContext::~ComponentContext() + SAL_THROW( () ) +{ +#ifdef CONTEXT_DIAG + ::fprintf( stderr, "> destructed context %p\n", this ); +#endif + t_map::const_iterator iPos( m_map.begin() ); + t_map::const_iterator const iEnd( m_map.end() ); + for ( ; iPos != iEnd; ++iPos ) + delete iPos->second; + m_map.clear(); +} +//__________________________________________________________________________________________________ +void ComponentContext::disposing() +{ +#ifdef CONTEXT_DIAG + ::fprintf( stderr, "> disposing context %p\n", this ); +#endif + + Reference< lang::XComponent > xTDMgr, xAC, xPolicy; // to be disposed separately + + // dispose all context objects + t_map::const_iterator iPos( m_map.begin() ); + t_map::const_iterator const iEnd( m_map.end() ); + for ( ; iPos != iEnd; ++iPos ) + { + t_map::mapped_type pEntry = iPos->second; + + // service manager disposed separately + if (!m_xSMgr.is() || + !iPos->first.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(SMGR_SINGLETON) )) + { + if (pEntry->lateInit) + { + // late init + MutexGuard guard( m_mutex ); + if (pEntry->lateInit) + { + pEntry->value.clear(); // release factory + pEntry->lateInit = false; + continue; + } + } + + Reference< lang::XComponent > xComp; + pEntry->value >>= xComp; + if (xComp.is()) + { + if (iPos->first.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(TDMGR_SINGLETON) )) + { + xTDMgr = xComp; + } + else if (iPos->first.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(AC_SINGLETON) )) + { + xAC = xComp; + } + else if (iPos->first.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(AC_POLICY) )) + { + xPolicy = xComp; + } + else // dispose immediately + { + xComp->dispose(); + } + } + } + } + + // dispose service manager + try_dispose( m_xSMgr ); + m_xSMgr.clear(); + // dispose ac + try_dispose( xAC ); + // dispose policy + try_dispose( xPolicy ); + // dispose tdmgr; revokes callback from cppu runtime + try_dispose( xTDMgr ); + + iPos = m_map.begin(); + for ( ; iPos != iEnd; ++iPos ) + delete iPos->second; + m_map.clear(); +} +//__________________________________________________________________________________________________ +ComponentContext::ComponentContext( + ContextEntry_Init const * pEntries, sal_Int32 nEntries, + Reference< XComponentContext > const & xDelegate ) + : WeakComponentImplHelper2< XComponentContext, container::XNameContainer >( + m_mutex ), + m_xDelegate( xDelegate ) +{ + for ( sal_Int32 nPos = 0; nPos < nEntries; ++nPos ) + { + ContextEntry_Init const & rEntry = pEntries[ nPos ]; + + if (rEntry.name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(SMGR_SINGLETON) )) + { + rEntry.value >>= m_xSMgr; + } + + if (rEntry.bLateInitService) + { + // singleton entry + m_map[ rEntry.name ] = new ContextEntry( Any(), true ); + // /service + m_map[ rEntry.name + OUSTR("/service") ] = new ContextEntry( rEntry.value, false ); + // /initial-arguments are provided as optional context entry + } + else + { + // only value, no late init factory nor string + m_map[ rEntry.name ] = new ContextEntry( rEntry.value, false ); + } + } + + if (!m_xSMgr.is() && m_xDelegate.is()) + { + // wrap delegate's smgr XPropertySet into new smgr + Reference< lang::XMultiComponentFactory > xMgr( m_xDelegate->getServiceManager() ); + if (xMgr.is()) + { + osl_incrementInterlockedCount( &m_refCount ); + try + { + // create new smgr based on delegate's one + m_xSMgr.set( + xMgr->createInstanceWithContext( + OUSTR("com.sun.star.comp.stoc.OServiceManagerWrapper"), xDelegate ), + UNO_QUERY ); + // patch DefaultContext property of new one + Reference< beans::XPropertySet > xProps( m_xSMgr, UNO_QUERY ); + OSL_ASSERT( xProps.is() ); + if (xProps.is()) + { + Reference< XComponentContext > xThis( this ); + xProps->setPropertyValue( OUSTR("DefaultContext"), makeAny( xThis ) ); + } + } + catch (...) + { + osl_decrementInterlockedCount( &m_refCount ); + throw; + } + osl_decrementInterlockedCount( &m_refCount ); + OSL_ASSERT( m_xSMgr.is() ); + } + } +} + + +//################################################################################################## +extern "C" { static void s_createComponentContext_v(va_list * pParam) +{ + ContextEntry_Init const * pEntries = va_arg(*pParam, ContextEntry_Init const *); + sal_Int32 nEntries = va_arg(*pParam, sal_Int32); + XComponentContext * pDelegatee = va_arg(*pParam, XComponentContext *); + void ** ppContext = va_arg(*pParam, void **); + uno::Mapping * pTarget2curr = va_arg(*pParam, uno::Mapping *); + + Reference<XComponentContext> xDelegate(pDelegatee, SAL_NO_ACQUIRE); + Reference<XComponentContext> xContext; + + if (nEntries > 0) + { + try + { + ComponentContext * p = new ComponentContext( pEntries, nEntries, xDelegate ); + xContext.set(p); + // listen delegate for disposing, to dispose this (wrapping) context first. + DisposingForwarder::listen( Reference< lang::XComponent >::query( xDelegate ), p ); + } + catch (Exception & exc) + { + (void) exc; // avoid warning about unused variable + OSL_ENSURE( 0, OUStringToOString( + exc.Message, RTL_TEXTENCODING_ASCII_US ).getStr() ); + xContext.clear(); + } + } + else + { + xContext = xDelegate; + } + + delete[] pEntries; + + *ppContext = pTarget2curr->mapInterface(xContext.get(), ::getCppuType(&xContext)); +}} + +Reference< XComponentContext > SAL_CALL createComponentContext( + ContextEntry_Init const * pEntries, sal_Int32 nEntries, + Reference< XComponentContext > const & xDelegate ) + SAL_THROW( () ) +{ + uno::Environment curr_env(Environment::getCurrent()); + uno::Environment source_env(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(CPPU_STRINGIFY(CPPU_ENV)))); + + uno::Mapping curr2source(curr_env, source_env); + uno::Mapping source2curr(source_env, curr_env); + + ContextEntry_Init * mapped_entries = new ContextEntry_Init[nEntries]; + for (sal_Int32 nPos = 0; nPos < nEntries; ++ nPos) + { + mapped_entries[nPos].bLateInitService = pEntries[nPos].bLateInitService; + mapped_entries[nPos].name = pEntries[nPos].name; + + uno_type_any_constructAndConvert(&mapped_entries[nPos].value, + const_cast<void *>(pEntries[nPos].value.getValue()), + pEntries[nPos].value.getValueTypeRef(), + curr2source.get()); + } + + void * mapped_delegate = curr2source.mapInterface(xDelegate.get(), ::getCppuType(&xDelegate)); + XComponentContext * pXComponentContext = NULL; + source_env.invoke(s_createComponentContext_v, mapped_entries, nEntries, mapped_delegate, &pXComponentContext, &source2curr); + + return Reference<XComponentContext>(pXComponentContext, SAL_NO_ACQUIRE); +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/source/exc_thrower.cxx b/cppuhelper/source/exc_thrower.cxx new file mode 100644 index 000000000000..dd5c5bd12c40 --- /dev/null +++ b/cppuhelper/source/exc_thrower.cxx @@ -0,0 +1,301 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_cppuhelper.hxx" + +#include "osl/diagnose.h" +#include "osl/doublecheckedlocking.h" +#include "osl/mutex.hxx" +#include "uno/dispatcher.hxx" +#include "uno/mapping.hxx" +#include "cppuhelper/detail/XExceptionThrower.hpp" +#include "com/sun/star/uno/RuntimeException.hpp" + +#include "cppuhelper/exc_hlp.hxx" + +#define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) ) + + +using namespace ::rtl; +using namespace ::osl; +using namespace ::cppu; +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; + +namespace +{ + +using cppuhelper::detail::XExceptionThrower; + +//============================================================================== +struct ExceptionThrower : public uno_Interface, XExceptionThrower +{ + inline ExceptionThrower(); + +public: + static ExceptionThrower * get(); + static inline Type const & getCppuType() + { + return ::getCppuType( + reinterpret_cast< Reference< XExceptionThrower > const * >(0) ); + } + + // XInterface + virtual Any SAL_CALL queryInterface( Type const & type ) + throw (RuntimeException); + virtual void SAL_CALL acquire() throw (); + virtual void SAL_CALL release() throw (); + + // XExceptionThrower + virtual void SAL_CALL throwException( Any const & exc ) throw (Exception); + virtual void SAL_CALL rethrowException() throw (Exception); +}; + +extern "C" +{ + +//------------------------------------------------------------------------------ +static void SAL_CALL ExceptionThrower_acquire_release_nop( uno_Interface * ) +{ +} + +//------------------------------------------------------------------------------ +static void SAL_CALL ExceptionThrower_dispatch( + uno_Interface * pUnoI, typelib_TypeDescription const * pMemberType, + void * pReturn, void * pArgs [], uno_Any ** ppException ) +{ + OSL_ASSERT( pMemberType->eTypeClass == typelib_TypeClass_INTERFACE_METHOD ); + + switch (reinterpret_cast< typelib_InterfaceMemberTypeDescription * >( + const_cast< typelib_TypeDescription * >( pMemberType ) )-> + nPosition) + { + case 0: // queryInterace() + { + Type const & rType_demanded = + *reinterpret_cast< Type const * >( pArgs[ 0 ] ); + if (rType_demanded.equals( + ::getCppuType( reinterpret_cast< + Reference< XInterface > const * >(0) ) ) || + rType_demanded.equals( ExceptionThrower::getCppuType() )) + { + typelib_TypeDescription * pTD = 0; + TYPELIB_DANGER_GET( &pTD, rType_demanded.getTypeLibType() ); + uno_any_construct( + reinterpret_cast< uno_Any * >( pReturn ), &pUnoI, pTD, 0 ); + TYPELIB_DANGER_RELEASE( pTD ); + } + else + { + uno_any_construct( + reinterpret_cast< uno_Any * >( pReturn ), 0, 0, 0 ); + } + *ppException = 0; + break; + } + case 1: // acquire() + case 2: // release() + *ppException = 0; + break; + case 3: // throwException() + { + uno_Any * pAny = reinterpret_cast< uno_Any * >( pArgs[ 0 ] ); + OSL_ASSERT( pAny->pType->eTypeClass == typelib_TypeClass_EXCEPTION ); + uno_type_any_construct( *ppException, pAny->pData, pAny->pType, 0 ); + break; + } + default: + { + OSL_ASSERT( 0 ); + RuntimeException exc( + OUSTR("not implemented!"), Reference< XInterface >() ); + uno_type_any_construct( + *ppException, &exc, ::getCppuType( &exc ).getTypeLibType(), 0 ); + break; + } + } +} + +} // extern "C" + +//______________________________________________________________________________ +Any ExceptionThrower::queryInterface( Type const & type ) + throw (RuntimeException) +{ + if (type.equals( ::getCppuType( reinterpret_cast< + Reference< XInterface > const * >(0) ) ) || + type.equals( ExceptionThrower::getCppuType() )) + { + XExceptionThrower * that = static_cast< XExceptionThrower * >( this ); + return Any( &that, type ); + } + return Any(); +} + +//______________________________________________________________________________ +void ExceptionThrower::acquire() throw () +{ +} +//______________________________________________________________________________ +void ExceptionThrower::release() throw () +{ +} + +//______________________________________________________________________________ +void ExceptionThrower::throwException( Any const & exc ) throw (Exception) +{ + OSL_ENSURE( 0, "unexpected!" ); + throwException( exc ); +} + +//______________________________________________________________________________ +void ExceptionThrower::rethrowException() throw (Exception) +{ + throw; +} + +//______________________________________________________________________________ +inline ExceptionThrower::ExceptionThrower() +{ + uno_Interface::acquire = ExceptionThrower_acquire_release_nop; + uno_Interface::release = ExceptionThrower_acquire_release_nop; + uno_Interface::pDispatcher = ExceptionThrower_dispatch; +} + +//______________________________________________________________________________ +ExceptionThrower * ExceptionThrower::get() +{ + ExceptionThrower * s_pThrower = 0; + if (s_pThrower == 0) + { + MutexGuard guard( Mutex::getGlobalMutex() ); + static ExceptionThrower s_thrower; + OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER(); + s_pThrower = &s_thrower; + } + else + { + OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER(); + } + return s_pThrower; +} + +} // anonymous namespace + + +namespace cppu +{ + +//============================================================================== +void SAL_CALL throwException( Any const & exc ) SAL_THROW( (Exception) ) +{ + if (exc.getValueTypeClass() != TypeClass_EXCEPTION) + { + throw RuntimeException( + OUSTR("no UNO exception given " + "(must be derived from com::sun::star::uno::Exception)!"), + Reference< XInterface >() ); + } + + Mapping uno2cpp(Environment(OUSTR(UNO_LB_UNO)), Environment::getCurrent()); + if (! uno2cpp.is()) + { + throw RuntimeException( + OUSTR("cannot get binary UNO to C++ mapping!"), + Reference< XInterface >() ); + } + + Reference< XExceptionThrower > xThrower; + uno2cpp.mapInterface( + reinterpret_cast< void ** >( &xThrower ), + static_cast< uno_Interface * >( ExceptionThrower::get() ), + ExceptionThrower::getCppuType() ); + OSL_ASSERT( xThrower.is() ); + xThrower->throwException( exc ); +} + +//============================================================================== +Any SAL_CALL getCaughtException() +{ + Mapping cpp2uno(Environment::getCurrent(), Environment(OUSTR(UNO_LB_UNO))); + if (! cpp2uno.is()) + { + throw RuntimeException( + OUSTR("cannot get C++ to binary UNO mapping!"), + Reference< XInterface >() ); + } + Mapping uno2cpp(Environment(OUSTR(UNO_LB_UNO)), Environment::getCurrent()); + if (! uno2cpp.is()) + { + throw RuntimeException( + OUSTR("cannot get binary UNO to C++ mapping!"), + Reference< XInterface >() ); + } + + typelib_TypeDescription * pTD = 0; + TYPELIB_DANGER_GET( + &pTD, ExceptionThrower::getCppuType().getTypeLibType() ); + + UnoInterfaceReference unoI; + cpp2uno.mapInterface( + reinterpret_cast< void ** >( &unoI.m_pUnoI ), + static_cast< XExceptionThrower * >( ExceptionThrower::get() ), pTD ); + OSL_ASSERT( unoI.is() ); + + typelib_TypeDescription * pMemberTD = 0; + TYPELIB_DANGER_GET( + &pMemberTD, + reinterpret_cast< typelib_InterfaceTypeDescription * >( pTD )-> + ppMembers[ 1 ] /* rethrowException() */ ); + + uno_Any exc_mem; + uno_Any * exc = &exc_mem; + unoI.dispatch( pMemberTD, 0, 0, &exc ); + + TYPELIB_DANGER_RELEASE( pMemberTD ); + TYPELIB_DANGER_RELEASE( pTD ); + + if (exc == 0) + { + throw RuntimeException( + OUSTR("rethrowing C++ exception failed!"), + Reference< XInterface >() ); + } + + Any ret; + uno_any_destruct( &ret, reinterpret_cast< uno_ReleaseFunc >(cpp_release) ); + uno_type_any_constructAndConvert( + &ret, exc->pData, exc->pType, uno2cpp.get() ); + uno_any_destruct( exc, 0 ); + return ret; +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/source/factory.cxx b/cppuhelper/source/factory.cxx new file mode 100644 index 000000000000..214258816577 --- /dev/null +++ b/cppuhelper/source/factory.cxx @@ -0,0 +1,1138 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_cppuhelper.hxx" +#include <osl/diagnose.h> +#include <osl/mutex.hxx> +#include <cppuhelper/weak.hxx> +#include <cppuhelper/component.hxx> +#include <cppuhelper/factory.hxx> +#include <cppuhelper/implbase3.hxx> +#include <cppuhelper/typeprovider.hxx> +#include <rtl/unload.h> + +#include "cppuhelper/propshlp.hxx" + +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/lang/XSingleServiceFactory.hpp> +#include <com/sun/star/lang/XSingleComponentFactory.hpp> +#include <com/sun/star/lang/XInitialization.hpp> +#include <com/sun/star/loader/XImplementationLoader.hpp> +#include <com/sun/star/lang/XComponent.hpp> +#include <com/sun/star/lang/IllegalArgumentException.hpp> +#include <com/sun/star/uno/XUnloadingPreference.hpp> +#include "com/sun/star/beans/PropertyAttribute.hpp" + +#include <memory> + +#define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) ) + + +using namespace osl; +using namespace rtl; +using namespace com::sun::star; +using namespace com::sun::star::uno; +using namespace com::sun::star::lang; +using namespace com::sun::star::loader; +using namespace com::sun::star::registry; + +namespace cppu +{ + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +class OSingleFactoryHelper + : public XServiceInfo + , public XSingleServiceFactory + , public lang::XSingleComponentFactory + , public XUnloadingPreference +{ +public: + OSingleFactoryHelper( + const Reference<XMultiServiceFactory > & rServiceManager, + const OUString & rImplementationName_, + ComponentInstantiation pCreateFunction_, + ComponentFactoryFunc fptr, + const Sequence< OUString > * pServiceNames_ ) + SAL_THROW( () ) + : xSMgr( rServiceManager ) + , pCreateFunction( pCreateFunction_ ) + , m_fptr( fptr ) + , aImplementationName( rImplementationName_ ) + { + if( pServiceNames_ ) + aServiceNames = *pServiceNames_; + } + + // old function, only for backward compatibility + OSingleFactoryHelper( + const Reference<XMultiServiceFactory > & rServiceManager, + const OUString & rImplementationName_ ) + SAL_THROW( () ) + : xSMgr( rServiceManager ) + , pCreateFunction( NULL ) + , m_fptr( 0 ) + , aImplementationName( rImplementationName_ ) + {} + + virtual ~OSingleFactoryHelper(); + + // XInterface + Any SAL_CALL queryInterface( const Type & rType ) + throw(::com::sun::star::uno::RuntimeException); + + // XSingleServiceFactory + Reference<XInterface > SAL_CALL createInstance() + throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); + virtual Reference<XInterface > SAL_CALL createInstanceWithArguments(const Sequence<Any>& Arguments) + throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); + // XSingleComponentFactory + virtual Reference< XInterface > SAL_CALL createInstanceWithContext( + Reference< XComponentContext > const & xContext ) + throw (Exception, RuntimeException); + virtual Reference< XInterface > SAL_CALL createInstanceWithArgumentsAndContext( + Sequence< Any > const & rArguments, + Reference< XComponentContext > const & xContext ) + throw (Exception, RuntimeException); + + // XServiceInfo + OUString SAL_CALL getImplementationName() + throw(::com::sun::star::uno::RuntimeException); + sal_Bool SAL_CALL supportsService(const OUString& ServiceName) + throw(::com::sun::star::uno::RuntimeException); + Sequence< OUString > SAL_CALL getSupportedServiceNames(void) + throw(::com::sun::star::uno::RuntimeException); + +protected: + /** + * Create an instance specified by the factory. The one instance logic is implemented + * in the createInstance and createInstanceWithArguments methods. + * @return the newly created instance. Do not return a previous (one instance) instance. + */ + virtual Reference<XInterface > createInstanceEveryTime( + Reference< XComponentContext > const & xContext ) + throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); + + Reference<XMultiServiceFactory > xSMgr; + ComponentInstantiation pCreateFunction; + ComponentFactoryFunc m_fptr; + Sequence< OUString > aServiceNames; + OUString aImplementationName; +}; +OSingleFactoryHelper::~OSingleFactoryHelper() +{ +} + + +//----------------------------------------------------------------------------- +Any OSingleFactoryHelper::queryInterface( const Type & rType ) + throw(::com::sun::star::uno::RuntimeException) +{ + return ::cppu::queryInterface( + rType, + static_cast< XSingleComponentFactory * >( this ), + static_cast< XSingleServiceFactory * >( this ), + static_cast< XServiceInfo * >( this ) , + static_cast< XUnloadingPreference * >( this )); +} + +// OSingleFactoryHelper +Reference<XInterface > OSingleFactoryHelper::createInstanceEveryTime( + Reference< XComponentContext > const & xContext ) + throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException) +{ + if (m_fptr) + { + return (*m_fptr)( xContext ); + } + else if( pCreateFunction ) + { + if (xContext.is()) + { + Reference< lang::XMultiServiceFactory > xContextMgr( + xContext->getServiceManager(), UNO_QUERY ); + if (xContextMgr.is()) + return (*pCreateFunction)( xContextMgr ); + } + return (*pCreateFunction)( xSMgr ); + } + else + { + return Reference< XInterface >(); + } +} + +// XSingleServiceFactory +Reference<XInterface > OSingleFactoryHelper::createInstance() + throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException) +{ + return createInstanceWithContext( Reference< XComponentContext >() ); +} + +// XSingleServiceFactory +Reference<XInterface > OSingleFactoryHelper::createInstanceWithArguments( + const Sequence<Any>& Arguments ) + throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException) +{ + return createInstanceWithArgumentsAndContext( + Arguments, Reference< XComponentContext >() ); +} + +// XSingleComponentFactory +//__________________________________________________________________________________________________ +Reference< XInterface > OSingleFactoryHelper::createInstanceWithContext( + Reference< XComponentContext > const & xContext ) + throw (Exception, RuntimeException) +{ + return createInstanceEveryTime( xContext ); +} +//__________________________________________________________________________________________________ +Reference< XInterface > OSingleFactoryHelper::createInstanceWithArgumentsAndContext( + Sequence< Any > const & rArguments, + Reference< XComponentContext > const & xContext ) + throw (Exception, RuntimeException) +{ + Reference< XInterface > xRet( createInstanceWithContext( xContext ) ); + + Reference< lang::XInitialization > xInit( xRet, UNO_QUERY ); + // always call initialize, even if there are no arguments. + // #i63511# / 2006-03-27 / frank.schoenheit@sun.com + if (xInit.is()) + { + xInit->initialize( rArguments ); + } + else + { + if ( rArguments.getLength() ) + throw lang::IllegalArgumentException( + OUString( RTL_CONSTASCII_USTRINGPARAM("cannot pass arguments to component => no XInitialization implemented!") ), + Reference< XInterface >(), 0 ); + } + + return xRet; +} + +// XServiceInfo +OUString OSingleFactoryHelper::getImplementationName() + throw(::com::sun::star::uno::RuntimeException) +{ + return aImplementationName; +} + +// XServiceInfo +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; +} + +// XServiceInfo +Sequence< OUString > OSingleFactoryHelper::getSupportedServiceNames(void) + throw(::com::sun::star::uno::RuntimeException) +{ + return aServiceNames; +} + + +//---------------------------------------------------------------------- +//---------------------------------------------------------------------- +//---------------------------------------------------------------------- +struct OFactoryComponentHelper_Mutex +{ + Mutex aMutex; +}; + +class OFactoryComponentHelper + : public OFactoryComponentHelper_Mutex + , public OComponentHelper + , public OSingleFactoryHelper +{ +public: + OFactoryComponentHelper( + const Reference<XMultiServiceFactory > & rServiceManager, + const OUString & rImplementationName_, + ComponentInstantiation pCreateFunction_, + ComponentFactoryFunc fptr, + const Sequence< OUString > * pServiceNames_, + sal_Bool bOneInstance_ = sal_False ) + SAL_THROW( () ) + : OComponentHelper( aMutex ) + , OSingleFactoryHelper( rServiceManager, rImplementationName_, pCreateFunction_, fptr, pServiceNames_ ) + , bOneInstance( bOneInstance_ ) + , pModuleCount(0) + { + } + + // Used by the createXXXFactory functions. The argument pModCount is used to prevent the unloading of the module + // which contains pCreateFunction_ + OFactoryComponentHelper( + const Reference<XMultiServiceFactory > & rServiceManager, + const OUString & rImplementationName_, + ComponentInstantiation pCreateFunction_, + ComponentFactoryFunc fptr, + const Sequence< OUString > * pServiceNames_, + rtl_ModuleCount * pModCount, + sal_Bool bOneInstance_ = sal_False ) + SAL_THROW( () ) + : OComponentHelper( aMutex ) + , OSingleFactoryHelper( rServiceManager, rImplementationName_, pCreateFunction_, fptr, pServiceNames_ ) + , bOneInstance( bOneInstance_ ) + , pModuleCount(pModCount) + { + if(pModuleCount) + pModuleCount->acquire( pModuleCount); + } + + // old function, only for backward compatibility + OFactoryComponentHelper( + const Reference<XMultiServiceFactory > & rServiceManager, + const OUString & rImplementationName_, + sal_Bool bOneInstance_ = sal_False ) + SAL_THROW( () ) + : OComponentHelper( aMutex ) + , OSingleFactoryHelper( rServiceManager, rImplementationName_ ) + , bOneInstance( bOneInstance_ ) + , pModuleCount(0) + { + } + + ~OFactoryComponentHelper() + { + if(pModuleCount) + pModuleCount->release( pModuleCount); + } + + // XInterface + Any SAL_CALL queryInterface( const Type & rType ) + throw(::com::sun::star::uno::RuntimeException); + void SAL_CALL acquire() throw() + { OComponentHelper::acquire(); } + void SAL_CALL release() throw() + { OComponentHelper::release(); } + + // XSingleServiceFactory + Reference<XInterface > SAL_CALL createInstance() + throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); + Reference<XInterface > SAL_CALL createInstanceWithArguments( const Sequence<Any>& Arguments ) + throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); + // XSingleComponentFactory + virtual Reference< XInterface > SAL_CALL createInstanceWithContext( + Reference< XComponentContext > const & xContext ) + throw (Exception, RuntimeException); + virtual Reference< XInterface > SAL_CALL createInstanceWithArgumentsAndContext( + Sequence< Any > const & rArguments, + Reference< XComponentContext > const & xContext ) + throw (Exception, RuntimeException); + + // XTypeProvider + virtual Sequence< Type > SAL_CALL getTypes() throw (::com::sun::star::uno::RuntimeException); + virtual Sequence< sal_Int8 > SAL_CALL getImplementationId() throw(::com::sun::star::uno::RuntimeException); + + // XAggregation + Any SAL_CALL queryAggregation( const Type & rType ) + throw(::com::sun::star::uno::RuntimeException); + + // XUnloadingPreference + virtual sal_Bool SAL_CALL releaseOnNotification() + throw(::com::sun::star::uno::RuntimeException); + + // OComponentHelper + void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException); + +private: + Reference<XInterface > xTheInstance; + sal_Bool bOneInstance; + rtl_ModuleCount * pModuleCount; +protected: + // needed for implementing XUnloadingPreference in inheriting classes + sal_Bool isOneInstance() {return bOneInstance;} + sal_Bool isInstance() {return xTheInstance.is();} +}; + + +Any SAL_CALL OFactoryComponentHelper::queryInterface( const Type & rType ) + throw(::com::sun::star::uno::RuntimeException) +{ + if( rType == ::getCppuType( (Reference<XUnloadingPreference>*)0)) + { + return makeAny( + Reference< XUnloadingPreference >( + static_cast< XUnloadingPreference * >(this) ) ); + } + return OComponentHelper::queryInterface( rType ); +} + +// XAggregation +Any OFactoryComponentHelper::queryAggregation( const Type & rType ) + throw(::com::sun::star::uno::RuntimeException) +{ + Any aRet( OComponentHelper::queryAggregation( rType ) ); + return (aRet.hasValue() ? aRet : OSingleFactoryHelper::queryInterface( rType )); +} + +// XTypeProvider +Sequence< Type > OFactoryComponentHelper::getTypes() + throw (::com::sun::star::uno::RuntimeException) +{ + Type ar[ 4 ]; + ar[ 0 ] = ::getCppuType( (const Reference< XSingleServiceFactory > *)0 ); + ar[ 1 ] = ::getCppuType( (const Reference< XServiceInfo > *)0 ); + ar[ 2 ] = ::getCppuType( (const Reference< XUnloadingPreference > *)0 ); + + if (m_fptr) + ar[ 3 ] = ::getCppuType( (const Reference< XSingleComponentFactory > *)0 ); + + return Sequence< Type >( ar, m_fptr ? 4 : 3 ); +} + +Sequence< sal_Int8 > OFactoryComponentHelper::getImplementationId() + throw (::com::sun::star::uno::RuntimeException) +{ + static OImplementationId * pId = 0; + if (! pId) + { + MutexGuard aGuard( Mutex::getGlobalMutex() ); + if (! pId) + { + static OImplementationId aId; + pId = &aId; + } + } + return pId->getImplementationId(); +} + +// XSingleServiceFactory +Reference<XInterface > OFactoryComponentHelper::createInstance() + throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException) +{ + if( bOneInstance ) + { + if( !xTheInstance.is() ) + { + MutexGuard aGuard( aMutex ); + if( !xTheInstance.is() ) + xTheInstance = OSingleFactoryHelper::createInstance(); + } + return xTheInstance; + } + return OSingleFactoryHelper::createInstance(); +} + +Reference<XInterface > OFactoryComponentHelper::createInstanceWithArguments( + const Sequence<Any>& Arguments ) + throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException) +{ + if( bOneInstance ) + { + if( !xTheInstance.is() ) + { + MutexGuard aGuard( aMutex ); +// OSL_ENSURE( !xTheInstance.is(), "### arguments will be ignored!" ); + if( !xTheInstance.is() ) + xTheInstance = OSingleFactoryHelper::createInstanceWithArguments( Arguments ); + } + return xTheInstance; + } + return OSingleFactoryHelper::createInstanceWithArguments( Arguments ); +} + +// XSingleComponentFactory +//__________________________________________________________________________________________________ +Reference< XInterface > OFactoryComponentHelper::createInstanceWithContext( + Reference< XComponentContext > const & xContext ) + throw (Exception, RuntimeException) +{ + if( bOneInstance ) + { + if( !xTheInstance.is() ) + { + MutexGuard aGuard( aMutex ); +// OSL_ENSURE( !xTheInstance.is(), "### context will be ignored!" ); + if( !xTheInstance.is() ) + xTheInstance = OSingleFactoryHelper::createInstanceWithContext( xContext ); + } + return xTheInstance; + } + return OSingleFactoryHelper::createInstanceWithContext( xContext ); +} +//__________________________________________________________________________________________________ +Reference< XInterface > OFactoryComponentHelper::createInstanceWithArgumentsAndContext( + Sequence< Any > const & rArguments, + Reference< XComponentContext > const & xContext ) + throw (Exception, RuntimeException) +{ + if( bOneInstance ) + { + if( !xTheInstance.is() ) + { + MutexGuard aGuard( aMutex ); +// OSL_ENSURE( !xTheInstance.is(), "### context and arguments will be ignored!" ); + if( !xTheInstance.is() ) + xTheInstance = OSingleFactoryHelper::createInstanceWithArgumentsAndContext( rArguments, xContext ); + } + return xTheInstance; + } + return OSingleFactoryHelper::createInstanceWithArgumentsAndContext( rArguments, xContext ); +} + + +// OComponentHelper +void OFactoryComponentHelper::dispose() + throw(::com::sun::star::uno::RuntimeException) +{ + OComponentHelper::dispose(); + + Reference<XInterface > x; + { + // do not delete in the guard section + MutexGuard aGuard( aMutex ); + x = xTheInstance; + xTheInstance = Reference<XInterface >(); + } + // if it is a component call dispose at the component + Reference<XComponent > xComp( x, UNO_QUERY ); + if( xComp.is() ) + xComp->dispose(); +} + +// XUnloadingPreference +// This class is used for single factories, component factories and +// one-instance factories. Depending on the usage this function has +// to return different values. +// one-instance factory: sal_False +// single factory: sal_True +// component factory: sal_True +sal_Bool SAL_CALL OFactoryComponentHelper::releaseOnNotification() throw(::com::sun::star::uno::RuntimeException) +{ + if( bOneInstance) + return sal_False; + return sal_True; +} + + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +class ORegistryFactoryHelper : public OFactoryComponentHelper, + public OPropertySetHelper + +{ +public: + ORegistryFactoryHelper( + const Reference<XMultiServiceFactory > & rServiceManager, + const OUString & rImplementationName_, + const Reference<XRegistryKey > & xImplementationKey_, + sal_Bool bOneInstance_ = sal_False ) SAL_THROW( () ) + : OFactoryComponentHelper( + rServiceManager, rImplementationName_, 0, 0, 0, bOneInstance_ ), + OPropertySetHelper( OComponentHelper::rBHelper ), + xImplementationKey( xImplementationKey_ ) + {} + + // XInterface + virtual Any SAL_CALL queryInterface( Type const & type ) + throw (RuntimeException); + virtual void SAL_CALL acquire() throw (); + virtual void SAL_CALL release() throw (); + // XTypeProvider + virtual Sequence< Type > SAL_CALL getTypes() + throw (RuntimeException); + // XPropertySet + virtual Reference< beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() + throw (RuntimeException); + + // OPropertySetHelper + virtual IPropertyArrayHelper & SAL_CALL getInfoHelper(); + virtual sal_Bool SAL_CALL convertFastPropertyValue( + Any & rConvertedValue, Any & rOldValue, + sal_Int32 nHandle, Any const & rValue ) + throw (lang::IllegalArgumentException); + virtual void SAL_CALL setFastPropertyValue_NoBroadcast( + sal_Int32 nHandle, Any const & rValue ) + throw (Exception); + using OPropertySetHelper::getFastPropertyValue; + virtual void SAL_CALL getFastPropertyValue( + Any & rValue, sal_Int32 nHandle ) const; + + // OSingleFactoryHelper + Reference<XInterface > createInstanceEveryTime( + Reference< XComponentContext > const & xContext ) + throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); + + // XSingleServiceFactory + Reference<XInterface > SAL_CALL createInstanceWithArguments(const Sequence<Any>& Arguments) + throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); + // XSingleComponentFactory + Reference< XInterface > SAL_CALL createInstanceWithArgumentsAndContext( + Sequence< Any > const & rArguments, + Reference< XComponentContext > const & xContext ) + throw (Exception, RuntimeException); + + // XServiceInfo + Sequence< OUString > SAL_CALL getSupportedServiceNames(void) + throw(::com::sun::star::uno::RuntimeException); + // XUnloadingPreference + sal_Bool SAL_CALL releaseOnNotification() + throw( RuntimeException); + + +private: + Reference< XInterface > createModuleFactory() + throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); + + /** The registry key of the implementation section */ + Reference<XRegistryKey > xImplementationKey; + /** The factory created with the loader. */ + Reference<XSingleComponentFactory > xModuleFactory; + Reference<XSingleServiceFactory > xModuleFactoryDepr; + Reference< beans::XPropertySetInfo > m_xInfo; + ::std::auto_ptr< IPropertyArrayHelper > m_property_array_helper; +protected: + using OPropertySetHelper::getTypes; +}; + +// XInterface +//______________________________________________________________________________ +Any SAL_CALL ORegistryFactoryHelper::queryInterface( + Type const & type ) throw (RuntimeException) +{ + Any ret( OFactoryComponentHelper::queryInterface( type ) ); + if (ret.hasValue()) + return ret; + else + return OPropertySetHelper::queryInterface( type ); +} + +//______________________________________________________________________________ +void ORegistryFactoryHelper::acquire() throw () +{ + OFactoryComponentHelper::acquire(); +} + +//______________________________________________________________________________ +void ORegistryFactoryHelper::release() throw () +{ + OFactoryComponentHelper::release(); +} + +// XTypeProvider +//______________________________________________________________________________ +Sequence< Type > ORegistryFactoryHelper::getTypes() throw (RuntimeException) +{ + Sequence< Type > types( OFactoryComponentHelper::getTypes() ); + sal_Int32 pos = types.getLength(); + types.realloc( pos + 3 ); + Type * p = types.getArray(); + p[ pos++ ] = ::getCppuType( + reinterpret_cast< Reference< beans::XMultiPropertySet > const * >(0) ); + p[ pos++ ] = ::getCppuType( + reinterpret_cast< Reference< beans::XFastPropertySet > const * >(0) ); + p[ pos++ ] = ::getCppuType( + reinterpret_cast< Reference< beans::XPropertySet > const * >(0) ); + return types; +} + +// XPropertySet +//______________________________________________________________________________ +Reference< beans::XPropertySetInfo > +ORegistryFactoryHelper::getPropertySetInfo() throw (RuntimeException) +{ + ::osl::MutexGuard guard( aMutex ); + if (! m_xInfo.is()) + m_xInfo = createPropertySetInfo( getInfoHelper() ); + return m_xInfo; +} + +// OPropertySetHelper +//______________________________________________________________________________ +IPropertyArrayHelper & ORegistryFactoryHelper::getInfoHelper() +{ + ::osl::MutexGuard guard( aMutex ); + if (m_property_array_helper.get() == 0) + { + beans::Property prop( + OUSTR("ImplementationKey") /* name */, + 0 /* handle */, + ::getCppuType( &xImplementationKey ), + beans::PropertyAttribute::READONLY | + beans::PropertyAttribute::OPTIONAL ); + m_property_array_helper.reset( + new ::cppu::OPropertyArrayHelper( &prop, 1 ) ); + } + return *m_property_array_helper.get(); +} + +//______________________________________________________________________________ +sal_Bool ORegistryFactoryHelper::convertFastPropertyValue( + Any &, Any &, sal_Int32, Any const & ) + throw (lang::IllegalArgumentException) +{ + OSL_ENSURE( 0, "unexpected!" ); + return false; +} + +//______________________________________________________________________________ +void ORegistryFactoryHelper::setFastPropertyValue_NoBroadcast( + sal_Int32, Any const & ) + throw (Exception) +{ + throw beans::PropertyVetoException( + OUSTR("unexpected: only readonly properties!"), + static_cast< OWeakObject * >(this) ); +} + +//______________________________________________________________________________ +void ORegistryFactoryHelper::getFastPropertyValue( + Any & rValue, sal_Int32 nHandle ) const +{ + if (nHandle == 0) + { + rValue <<= xImplementationKey; + } + else + { + rValue.clear(); + throw beans::UnknownPropertyException( + OUSTR("unknown property!"), static_cast< OWeakObject * >( + const_cast< ORegistryFactoryHelper * >(this) ) ); + } +} + +Reference<XInterface > ORegistryFactoryHelper::createInstanceEveryTime( + Reference< XComponentContext > const & xContext ) + throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException) +{ + if( !xModuleFactory.is() && !xModuleFactoryDepr.is() ) + { + Reference< XInterface > x( createModuleFactory() ); + if (x.is()) + { + MutexGuard aGuard( aMutex ); + if( !xModuleFactory.is() && !xModuleFactoryDepr.is() ) + { + xModuleFactory.set( x, UNO_QUERY ); + xModuleFactoryDepr.set( x, UNO_QUERY ); + } + } + } + if( xModuleFactory.is() ) + { + return xModuleFactory->createInstanceWithContext( xContext ); + } + else if( xModuleFactoryDepr.is() ) + { + return xModuleFactoryDepr->createInstance(); + } + + return Reference<XInterface >(); +} + +Reference<XInterface > SAL_CALL ORegistryFactoryHelper::createInstanceWithArguments( + const Sequence<Any>& Arguments ) + throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException) +{ + if( !xModuleFactory.is() && !xModuleFactoryDepr.is() ) + { + Reference< XInterface > x( createModuleFactory() ); + if (x.is()) + { + MutexGuard aGuard( aMutex ); + if( !xModuleFactory.is() && !xModuleFactoryDepr.is() ) + { + xModuleFactory.set( x, UNO_QUERY ); + xModuleFactoryDepr.set( x, UNO_QUERY ); + } + } + } + if( xModuleFactoryDepr.is() ) + { + return xModuleFactoryDepr->createInstanceWithArguments( Arguments ); + } + else if( xModuleFactory.is() ) + { +#if OSL_DEBUG_LEVEL > 1 + OSL_TRACE( "### no context ORegistryFactoryHelper::createInstanceWithArgumentsAndContext()!\n" ); +#endif + return xModuleFactory->createInstanceWithArgumentsAndContext( Arguments, Reference< XComponentContext >() ); + } + + return Reference<XInterface >(); +} + +Reference< XInterface > ORegistryFactoryHelper::createInstanceWithArgumentsAndContext( + Sequence< Any > const & rArguments, + Reference< XComponentContext > const & xContext ) + throw (Exception, RuntimeException) +{ + if( !xModuleFactory.is() && !xModuleFactoryDepr.is() ) + { + Reference< XInterface > x( createModuleFactory() ); + if (x.is()) + { + MutexGuard aGuard( aMutex ); + if( !xModuleFactory.is() && !xModuleFactoryDepr.is() ) + { + xModuleFactory.set( x, UNO_QUERY ); + xModuleFactoryDepr.set( x, UNO_QUERY ); + } + } + } + if( xModuleFactory.is() ) + { + return xModuleFactory->createInstanceWithArgumentsAndContext( rArguments, xContext ); + } + else if( xModuleFactoryDepr.is() ) + { +#if OSL_DEBUG_LEVEL > 1 + if (xContext.is()) + { + OSL_TRACE( "### ignoring context calling ORegistryFactoryHelper::createInstanceWithArgumentsAndContext()!\n" ); + } +#endif + return xModuleFactoryDepr->createInstanceWithArguments( rArguments ); + } + + return Reference<XInterface >(); +} + + +// OSingleFactoryHelper +Reference< XInterface > ORegistryFactoryHelper::createModuleFactory() + throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException) +{ + OUString aActivatorUrl; + OUString aActivatorName; + OUString aLocation; + + Reference<XRegistryKey > xActivatorKey = xImplementationKey->openKey( + OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/ACTIVATOR") ) ); + if( xActivatorKey.is() && xActivatorKey->getValueType() == RegistryValueType_ASCII ) + { + aActivatorUrl = xActivatorKey->getAsciiValue(); + + OUString tmpActivator(aActivatorUrl.getStr()); + sal_Int32 nIndex = 0; + aActivatorName = tmpActivator.getToken(0, ':', nIndex ); + + Reference<XRegistryKey > xLocationKey = xImplementationKey->openKey( + OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/LOCATION") ) ); + if( xLocationKey.is() && xLocationKey->getValueType() == RegistryValueType_ASCII ) + aLocation = xLocationKey->getAsciiValue(); + } + else + { + // old style"url" + // the location of the program code of the implementation + Reference<XRegistryKey > xLocationKey = xImplementationKey->openKey( + OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/URL") ) ); + // is the the key of the right type ? + if( xLocationKey.is() && xLocationKey->getValueType() == RegistryValueType_ASCII ) + { + // one implementation found -> try to activate + aLocation = xLocationKey->getAsciiValue(); + + // search protocol delimiter + sal_Int32 nPos = aLocation.indexOf( + OUString( RTL_CONSTASCII_USTRINGPARAM("://") ) ); + if( nPos != -1 ) + { + aActivatorName = aLocation.copy( 0, nPos ); + if( aActivatorName.compareToAscii( "java" ) == 0 ) + aActivatorName = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.loader.Java") ); + else if( aActivatorName.compareToAscii( "module" ) == 0 ) + aActivatorName = OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.loader.SharedLibrary") ); + aLocation = aLocation.copy( nPos + 3 ); + } + } + } + + Reference< XInterface > xFactory; + if( aActivatorName.getLength() != 0 ) + { + Reference<XInterface > x = xSMgr->createInstance( aActivatorName ); + Reference<XImplementationLoader > xLoader( x, UNO_QUERY ); + Reference<XInterface > xMF; + if (xLoader.is()) + { + xFactory = xLoader->activate( aImplementationName, aActivatorUrl, aLocation, xImplementationKey ); + } + } + return xFactory; +} + +// XServiceInfo +Sequence< OUString > ORegistryFactoryHelper::getSupportedServiceNames(void) + throw(::com::sun::star::uno::RuntimeException) +{ + MutexGuard aGuard( aMutex ); + if( aServiceNames.getLength() == 0 ) + { + // not yet loaded + try + { + Reference<XRegistryKey > xKey = xImplementationKey->openKey( + OUString( RTL_CONSTASCII_USTRINGPARAM("UNO/SERVICES") ) ); + + if (xKey.is()) + { + // length of prefix. +1 for the '/' at the end + sal_Int32 nPrefixLen = xKey->getKeyName().getLength() + 1; + + // Full qualified names like "IMPLEMENTATIONS/TEST/UNO/SERVICES/com.sun.star..." + Sequence<OUString> seqKeys = xKey->getKeyNames(); + OUString* pKeys = seqKeys.getArray(); + for( sal_Int32 i = 0; i < seqKeys.getLength(); i++ ) + pKeys[i] = pKeys[i].copy(nPrefixLen); + + aServiceNames = seqKeys; + } + } + catch (InvalidRegistryException &) + { + } + } + return aServiceNames; +} + +sal_Bool SAL_CALL ORegistryFactoryHelper::releaseOnNotification() throw(::com::sun::star::uno::RuntimeException) +{ + sal_Bool retVal= sal_True; + if( isOneInstance() && isInstance()) + { + retVal= sal_False; + } + else if( ! isOneInstance()) + { + // try to delegate + if( xModuleFactory.is()) + { + Reference<XUnloadingPreference> xunloading( xModuleFactory, UNO_QUERY); + if( xunloading.is()) + retVal= xunloading->releaseOnNotification(); + } + else if( xModuleFactoryDepr.is()) + { + Reference<XUnloadingPreference> xunloading( xModuleFactoryDepr, UNO_QUERY); + if( xunloading.is()) + retVal= xunloading->releaseOnNotification(); + } + } + return retVal; +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +class OFactoryProxyHelper : public WeakImplHelper3< XServiceInfo, XSingleServiceFactory, + XUnloadingPreference > +{ + Reference<XSingleServiceFactory > xFactory; + +public: + + OFactoryProxyHelper( + const Reference<XMultiServiceFactory > & /*rServiceManager*/, + const Reference<XSingleServiceFactory > & rFactory ) + SAL_THROW( () ) + : xFactory( rFactory ) + {} + + // XSingleServiceFactory + Reference<XInterface > SAL_CALL createInstance() + throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); + Reference<XInterface > SAL_CALL createInstanceWithArguments(const Sequence<Any>& Arguments) + throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); + + // XServiceInfo + OUString SAL_CALL getImplementationName() + throw(::com::sun::star::uno::RuntimeException); + sal_Bool SAL_CALL supportsService(const OUString& ServiceName) + throw(::com::sun::star::uno::RuntimeException); + Sequence< OUString > SAL_CALL getSupportedServiceNames(void) + throw(::com::sun::star::uno::RuntimeException); + //XUnloadingPreference + sal_Bool SAL_CALL releaseOnNotification() + throw(::com::sun::star::uno::RuntimeException); + +}; + +// XSingleServiceFactory +Reference<XInterface > OFactoryProxyHelper::createInstance() + throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException) +{ + return xFactory->createInstance(); +} + +// XSingleServiceFactory +Reference<XInterface > OFactoryProxyHelper::createInstanceWithArguments +( + const Sequence<Any>& Arguments +) + throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException) +{ + return xFactory->createInstanceWithArguments( Arguments ); +} + +// XServiceInfo +OUString OFactoryProxyHelper::getImplementationName() + throw(::com::sun::star::uno::RuntimeException) +{ + Reference<XServiceInfo > xInfo( xFactory, UNO_QUERY ); + if( xInfo.is() ) + return xInfo->getImplementationName(); + return OUString(); +} + +// XServiceInfo +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; +} + +// XServiceInfo +Sequence< OUString > OFactoryProxyHelper::getSupportedServiceNames(void) + throw(::com::sun::star::uno::RuntimeException) +{ + Reference<XServiceInfo > xInfo( xFactory, UNO_QUERY ); + if( xInfo.is() ) + return xInfo->getSupportedServiceNames(); + return Sequence< OUString >(); +} + +sal_Bool SAL_CALL OFactoryProxyHelper::releaseOnNotification() throw(::com::sun::star::uno::RuntimeException) +{ + + Reference<XUnloadingPreference> pref( xFactory, UNO_QUERY); + if( pref.is()) + return pref->releaseOnNotification(); + return sal_True; +} + + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +// global function +Reference<XSingleServiceFactory > SAL_CALL createSingleFactory( + const Reference<XMultiServiceFactory > & rServiceManager, + const OUString & rImplementationName, + ComponentInstantiation pCreateFunction, + const Sequence< OUString > & rServiceNames, + rtl_ModuleCount *pModCount ) + SAL_THROW( () ) +{ + return new OFactoryComponentHelper( + rServiceManager, rImplementationName, pCreateFunction, 0, &rServiceNames, pModCount, sal_False ); +} + +// global function +Reference<XSingleServiceFactory > SAL_CALL createFactoryProxy( + const Reference<XMultiServiceFactory > & rServiceManager, + const Reference<XSingleServiceFactory > & rFactory ) + SAL_THROW( () ) +{ + return new OFactoryProxyHelper( + rServiceManager, rFactory ); +} + +// global function +Reference<XSingleServiceFactory > SAL_CALL createOneInstanceFactory( + const Reference<XMultiServiceFactory > & rServiceManager, + const OUString & rImplementationName, + ComponentInstantiation pCreateFunction, + const Sequence< OUString > & rServiceNames, + rtl_ModuleCount *pModCount ) + SAL_THROW( () ) +{ + return new OFactoryComponentHelper( + rServiceManager, rImplementationName, pCreateFunction, 0, &rServiceNames, pModCount, sal_True ); +} + +// global function +Reference<XSingleServiceFactory > SAL_CALL createSingleRegistryFactory( + const Reference<XMultiServiceFactory > & rServiceManager, + const OUString & rImplementationName, + const Reference<XRegistryKey > & rImplementationKey ) + SAL_THROW( () ) +{ + return new ORegistryFactoryHelper( + rServiceManager, rImplementationName, rImplementationKey, sal_False ); +} + +// global function +Reference<XSingleServiceFactory > SAL_CALL createOneInstanceRegistryFactory( + const Reference<XMultiServiceFactory > & rServiceManager, + const OUString & rImplementationName, + const Reference<XRegistryKey > & rImplementationKey ) + SAL_THROW( () ) +{ + return new ORegistryFactoryHelper( + rServiceManager, rImplementationName, rImplementationKey, sal_True ); +} + +//################################################################################################## +Reference< lang::XSingleComponentFactory > SAL_CALL createSingleComponentFactory( + ComponentFactoryFunc fptr, + OUString const & rImplementationName, + Sequence< OUString > const & rServiceNames, + rtl_ModuleCount * pModCount) + SAL_THROW( () ) +{ + return new OFactoryComponentHelper( + Reference< XMultiServiceFactory >(), rImplementationName, 0, fptr, &rServiceNames, pModCount, sal_False ); +} + +Reference< lang::XSingleComponentFactory > SAL_CALL createOneInstanceComponentFactory( + ComponentFactoryFunc fptr, + OUString const & rImplementationName, + Sequence< OUString > const & rServiceNames, + rtl_ModuleCount * pModCount) + SAL_THROW( () ) +{ + return new OFactoryComponentHelper( + Reference< XMultiServiceFactory >(), rImplementationName, 0, fptr, &rServiceNames, pModCount, sal_True ); +} + +} + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/source/findsofficepath.c b/cppuhelper/source/findsofficepath.c new file mode 100644 index 000000000000..e1fe9bb6abd7 --- /dev/null +++ b/cppuhelper/source/findsofficepath.c @@ -0,0 +1,208 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "precompiled_cppuhelper.hxx" +#include "sal/config.h" + +#include <stdlib.h> +#include <string.h> + +#if defined WNT + +#define WIN32_LEAN_AND_MEAN +#include <windows.h> + +/* + * Gets the installation path from the Windows Registry for the specified + * registry key. + * + * @param hroot open handle to predefined root registry key + * @param subKeyName name of the subkey to open + * + * @return the installation path or NULL, if no installation was found or + * if an error occured + */ +static char* getPathFromRegistryKey( HKEY hroot, const char* subKeyName ) +{ + HKEY hkey; + DWORD type; + char* data = NULL; + DWORD size; + + /* open the specified registry key */ + if ( RegOpenKeyEx( hroot, subKeyName, 0, KEY_READ, &hkey ) != ERROR_SUCCESS ) + { + return NULL; + } + + /* find the type and size of the default value */ + if ( RegQueryValueEx( hkey, NULL, NULL, &type, NULL, &size) != ERROR_SUCCESS ) + { + RegCloseKey( hkey ); + return NULL; + } + + /* get memory to hold the default value */ + data = (char*) malloc( size ); + + /* read the default value */ + if ( RegQueryValueEx( hkey, NULL, NULL, &type, (LPBYTE) data, &size ) != ERROR_SUCCESS ) + { + RegCloseKey( hkey ); + return NULL; + } + + /* release registry key handle */ + RegCloseKey( hkey ); + + return data; +} + +/* + * Gets the installation path from the Windows Registry. + * + * @return the installation path or NULL, if no installation was found or + * if an error occured + */ +static char* platformSpecific() +{ + const char* SUBKEYNAME = "Software\\LibreOffice\\UNO\\InstallPath"; + + char* path = NULL; + + /* read the key's default value from HKEY_CURRENT_USER */ + path = getPathFromRegistryKey( HKEY_CURRENT_USER, SUBKEYNAME ); + + if ( path == NULL ) + { + /* read the key's default value from HKEY_LOCAL_MACHINE */ + path = getPathFromRegistryKey( HKEY_LOCAL_MACHINE, SUBKEYNAME ); + } + + return path; +} + +#else + +#include <unistd.h> +#include <limits.h> + +/* + * Gets the installation path from the PATH environment variable. + * + * <p>An installation is found, if the executable 'soffice' or a symbolic link + * is in one of the directories listed in the PATH environment variable.</p> + * + * @return the installation path or NULL, if no installation was found or + * if an error occured + */ +static char* platformSpecific() +{ + const int SEPARATOR = '/'; + const char* PATHSEPARATOR = ":"; + const char* PATHVARNAME = "PATH"; + const char* APPENDIX = "/soffice"; + + char* path = NULL; + char* env = NULL; + char* str = NULL; + char* dir = NULL; + char* file = NULL; + char* resolved = NULL; + char* sep = NULL; + + char buffer[PATH_MAX]; + int pos; + + /* get the value of the PATH environment variable */ + env = getenv( PATHVARNAME ); + str = (char*) malloc( strlen( env ) + 1 ); + strcpy( str, env ); + + /* get the tokens separated by ':' */ + dir = strtok( str, PATHSEPARATOR ); + + while ( dir ) + { + /* construct soffice file path */ + file = (char*) malloc( strlen( dir ) + strlen( APPENDIX ) + 1 ); + strcpy( file, dir ); + strcat( file, APPENDIX ); + + /* check existence of soffice file */ + if ( !access( file, F_OK ) ) + { + /* resolve symbolic link */ + resolved = realpath( file, buffer ); + + if ( resolved != NULL ) + { + /* get path to program directory */ + sep = strrchr( resolved, SEPARATOR ); + + if ( sep != NULL ) + { + pos = sep - resolved; + path = (char*) malloc( pos + 1 ); + strncpy( path, resolved, pos ); + path[ pos ] = '\0'; + free( file ); + break; + } + } + } + + dir = strtok( NULL, PATHSEPARATOR ); + free( file ); + } + + free( str ); + + return path; +} + +#endif + +char const* cppuhelper_detail_findSofficePath() +{ + const char* UNOPATHVARNAME = "UNO_PATH"; + + char* path = NULL; + + /* get the installation path from the UNO_PATH environment variable */ + path = getenv( UNOPATHVARNAME ); + + if ( path == NULL || strlen( path ) == 0 ) + { + path = platformSpecific(); + } + + return path; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/source/gcc3.map b/cppuhelper/source/gcc3.map new file mode 100644 index 000000000000..88e58df6551b --- /dev/null +++ b/cppuhelper/source/gcc3.map @@ -0,0 +1,384 @@ +UDK_3_0_0 { + global: +GetVersionInfo; +_ZN3com3sun4star3uno19WeakReferenceHelperC1ERKNS2_9ReferenceINS2_10XInterfaceEEE; +_ZN3com3sun4star3uno19WeakReferenceHelperC1ERKS3_; +_ZN3com3sun4star3uno19WeakReferenceHelperC2ERKNS2_9ReferenceINS2_10XInterfaceEEE; +_ZN3com3sun4star3uno19WeakReferenceHelperC2ERKS3_; +_ZN3com3sun4star3uno19WeakReferenceHelperaSERKS3_; +_ZN3com3sun4star3uno19WeakReferenceHelperD1Ev; +_ZN3com3sun4star3uno19WeakReferenceHelperD2Ev; +_ZN4cppu11OWeakObject12queryAdapterEv; +_ZN4cppu11OWeakObject14queryInterfaceERKN3com3sun4star3uno4TypeE; +_ZN4cppu11OWeakObject7acquireEv; +_ZN4cppu11OWeakObject7releaseEv; +_ZN4cppu11OWeakObjectD0Ev; +_ZN4cppu11OWeakObjectD1Ev; +_ZN4cppu11OWeakObjectD2Ev; +_ZN4cppu13ClassDataBaseC1E?; +_ZN4cppu13ClassDataBaseC1Ev; +_ZN4cppu13ClassDataBaseC2E?; +_ZN4cppu13ClassDataBaseC2Ev; +_ZN4cppu13ClassDataBaseD1Ev; +_ZN4cppu13ClassDataBaseD2Ev; +_ZN4cppu14OWeakAggObject12setDelegatorERKN3com3sun4star3uno9ReferenceINS4_10XInterfaceEEE; +_ZN4cppu14OWeakAggObject14queryInterfaceERKN3com3sun4star3uno4TypeE; +_ZN4cppu14OWeakAggObject16queryAggregationERKN3com3sun4star3uno4TypeE; +_ZN4cppu14OWeakAggObject7acquireEv; +_ZN4cppu14OWeakAggObject7releaseEv; +_ZN4cppu14OWeakAggObjectD0Ev; +_ZN4cppu14OWeakAggObjectD1Ev; +_ZN4cppu14OWeakAggObjectD2Ev; +_ZN4cppu14throwExceptionERKN3com3sun4star3uno3AnyE; +_ZN4cppu15OTypeCollectionC1ERKN3com3sun4star3uno4TypeERKNS4_8SequenceIS5_EE; +_ZN4cppu15OTypeCollectionC1ERKN3com3sun4star3uno4TypeES7_RKNS4_8SequenceIS5_EE; +_ZN4cppu15OTypeCollectionC1ERKN3com3sun4star3uno4TypeES7_S7_RKNS4_8SequenceIS5_EE; +_ZN4cppu15OTypeCollectionC1ERKN3com3sun4star3uno4TypeES7_S7_S7_RKNS4_8SequenceIS5_EE; +_ZN4cppu15OTypeCollectionC1ERKN3com3sun4star3uno4TypeES7_S7_S7_S7_RKNS4_8SequenceIS5_EE; +_ZN4cppu15OTypeCollectionC1ERKN3com3sun4star3uno4TypeES7_S7_S7_S7_S7_RKNS4_8SequenceIS5_EE; +_ZN4cppu15OTypeCollectionC1ERKN3com3sun4star3uno4TypeES7_S7_S7_S7_S7_S7_RKNS4_8SequenceIS5_EE; +_ZN4cppu15OTypeCollectionC1ERKN3com3sun4star3uno4TypeES7_S7_S7_S7_S7_S7_S7_RKNS4_8SequenceIS5_EE; +_ZN4cppu15OTypeCollectionC1ERKN3com3sun4star3uno4TypeES7_S7_S7_S7_S7_S7_S7_S7_RKNS4_8SequenceIS5_EE; +_ZN4cppu15OTypeCollectionC1ERKN3com3sun4star3uno4TypeES7_S7_S7_S7_S7_S7_S7_S7_S7_RKNS4_8SequenceIS5_EE; +_ZN4cppu15OTypeCollectionC1ERKN3com3sun4star3uno4TypeES7_S7_S7_S7_S7_S7_S7_S7_S7_S7_RKNS4_8SequenceIS5_EE; +_ZN4cppu15OTypeCollectionC1ERKN3com3sun4star3uno4TypeES7_S7_S7_S7_S7_S7_S7_S7_S7_S7_S7_RKNS4_8SequenceIS5_EE; +_ZN4cppu15OTypeCollectionC2ERKN3com3sun4star3uno4TypeERKNS4_8SequenceIS5_EE; +_ZN4cppu15OTypeCollectionC2ERKN3com3sun4star3uno4TypeES7_RKNS4_8SequenceIS5_EE; +_ZN4cppu15OTypeCollectionC2ERKN3com3sun4star3uno4TypeES7_S7_RKNS4_8SequenceIS5_EE; +_ZN4cppu15OTypeCollectionC2ERKN3com3sun4star3uno4TypeES7_S7_S7_RKNS4_8SequenceIS5_EE; +_ZN4cppu15OTypeCollectionC2ERKN3com3sun4star3uno4TypeES7_S7_S7_S7_RKNS4_8SequenceIS5_EE; +_ZN4cppu15OTypeCollectionC2ERKN3com3sun4star3uno4TypeES7_S7_S7_S7_S7_RKNS4_8SequenceIS5_EE; +_ZN4cppu15OTypeCollectionC2ERKN3com3sun4star3uno4TypeES7_S7_S7_S7_S7_S7_RKNS4_8SequenceIS5_EE; +_ZN4cppu15OTypeCollectionC2ERKN3com3sun4star3uno4TypeES7_S7_S7_S7_S7_S7_S7_RKNS4_8SequenceIS5_EE; +_ZN4cppu15OTypeCollectionC2ERKN3com3sun4star3uno4TypeES7_S7_S7_S7_S7_S7_S7_S7_RKNS4_8SequenceIS5_EE; +_ZN4cppu15OTypeCollectionC2ERKN3com3sun4star3uno4TypeES7_S7_S7_S7_S7_S7_S7_S7_S7_RKNS4_8SequenceIS5_EE; +_ZN4cppu15OTypeCollectionC2ERKN3com3sun4star3uno4TypeES7_S7_S7_S7_S7_S7_S7_S7_S7_S7_RKNS4_8SequenceIS5_EE; +_ZN4cppu15OTypeCollectionC2ERKN3com3sun4star3uno4TypeES7_S7_S7_S7_S7_S7_S7_S7_S7_S7_S7_RKNS4_8SequenceIS5_EE; +_ZN4cppu16ImplHelper_queryERKN3com3sun4star3uno4TypeEPNS_10class_dataEPv; +_ZN4cppu16OComponentHelper14queryInterfaceERKN3com3sun4star3uno4TypeE; +_ZN4cppu16OComponentHelper16addEventListenerERKN3com3sun4star3uno9ReferenceINS3_4lang14XEventListenerEEE; +_ZN4cppu16OComponentHelper16queryAggregationERKN3com3sun4star3uno4TypeE; +_ZN4cppu16OComponentHelper19removeEventListenerERKN3com3sun4star3uno9ReferenceINS3_4lang14XEventListenerEEE; +_ZN4cppu16OComponentHelper7acquireEv; +_ZN4cppu16OComponentHelper7disposeEv; +_ZN4cppu16OComponentHelper7releaseEv; +_ZN4cppu16OComponentHelper8getTypesEv; +_ZN4cppu16OComponentHelper9disposingEv; +_ZN4cppu16OComponentHelperC1ERN3osl5MutexE; +_ZN4cppu16OComponentHelperC2ERN3osl5MutexE; +_ZN4cppu16OComponentHelperD0Ev; +_ZN4cppu16OComponentHelperD1Ev; +_ZN4cppu16OComponentHelperD2Ev; +_ZN4cppu17OImplementationIdD1Ev; +_ZN4cppu17OImplementationIdD2Ev; +_ZN4cppu18OPropertySetHelper14queryInterfaceERKN3com3sun4star3uno4TypeE; +_ZN4cppu18OPropertySetHelper16getPropertyValueERKN3rtl8OUStringE; +_ZN4cppu18OPropertySetHelper16setPropertyValueERKN3rtl8OUStringERKN3com3sun4star3uno3AnyE; +_ZN4cppu18OPropertySetHelper17getPropertyValuesERKN3com3sun4star3uno8SequenceIN3rtl8OUStringEEE; +_ZN4cppu18OPropertySetHelper17setPropertyValuesERKN3com3sun4star3uno8SequenceIN3rtl8OUStringEEERKNS5_INS4_3AnyEEE; +_ZN4cppu18OPropertySetHelper20getFastPropertyValueE?; +_ZN4cppu18OPropertySetHelper20setFastPropertyValueE?RKN3com3sun4star3uno3AnyE; +_ZN4cppu18OPropertySetHelper21createPropertySetInfoERNS_20IPropertyArrayHelperE; +_ZN4cppu18OPropertySetHelper21setFastPropertyValuesE?P?PKN3com3sun4star3uno3AnyE?; +_ZN4cppu18OPropertySetHelper25addPropertyChangeListenerERKN3rtl8OUStringERKN3com3sun4star3uno9ReferenceINS7_5beans23XPropertyChangeListenerEEE; +_ZN4cppu18OPropertySetHelper25addVetoableChangeListenerERKN3rtl8OUStringERKN3com3sun4star3uno9ReferenceINS7_5beans23XVetoableChangeListenerEEE; +_ZN4cppu18OPropertySetHelper25firePropertiesChangeEventERKN3com3sun4star3uno8SequenceIN3rtl8OUStringEEERKNS4_9ReferenceINS3_5beans25XPropertiesChangeListenerEEE; +_ZN4cppu18OPropertySetHelper27addPropertiesChangeListenerERKN3com3sun4star3uno8SequenceIN3rtl8OUStringEEERKNS4_9ReferenceINS3_5beans25XPropertiesChangeListenerEEE; +_ZN4cppu18OPropertySetHelper28removePropertyChangeListenerERKN3rtl8OUStringERKN3com3sun4star3uno9ReferenceINS7_5beans23XPropertyChangeListenerEEE; +_ZN4cppu18OPropertySetHelper28removeVetoableChangeListenerERKN3rtl8OUStringERKN3com3sun4star3uno9ReferenceINS7_5beans23XVetoableChangeListenerEEE; +_ZN4cppu18OPropertySetHelper30removePropertiesChangeListenerERKN3com3sun4star3uno9ReferenceINS3_5beans25XPropertiesChangeListenerEEE; +_ZN4cppu18OPropertySetHelper4fireEP?PKN3com3sun4star3uno3AnyES8_?h; +_ZN4cppu18OPropertySetHelper9disposingEv; +_ZN4cppu18OPropertySetHelperC1ERNS_19OBroadcastHelperVarINS_34OMultiTypeInterfaceContainerHelperEN3com3sun4star3uno4TypeEEE; +_ZN4cppu18OPropertySetHelperC2ERNS_19OBroadcastHelperVarINS_34OMultiTypeInterfaceContainerHelperEN3com3sun4star3uno4TypeEEE; +_ZN4cppu18OPropertySetHelperD1Ev; +_ZN4cppu18OPropertySetHelperD2Ev; +_ZN4cppu18bootstrapInitialSFERKN3rtl8OUStringE; +_ZN4cppu18createFactoryProxyERKN3com3sun4star3uno9ReferenceINS2_4lang20XMultiServiceFactoryEEERKNS4_INS5_21XSingleServiceFactoryEEE; +_ZN4cppu19ImplHelper_getTypesEPNS_10class_dataE; +_ZN4cppu19createSingleFactoryERKN3com3sun4star3uno9ReferenceINS2_4lang20XMultiServiceFactoryEEERKN3rtl8OUStringEPFNS4_INS3_10XInterfaceEEES9_ERKNS3_8SequenceISB_EEP16_rtl_ModuleCount; +_ZN4cppu20IPropertyArrayHelperD0Ev; +_ZN4cppu20IPropertyArrayHelperD1Ev; +_ZN4cppu20IPropertyArrayHelperD2Ev; +_ZN4cppu20OPropertyArrayHelper11fillHandlesEP?RKN3com3sun4star3uno8SequenceIN3rtl8OUStringEEE; +_ZN4cppu20OPropertyArrayHelper13getPropertiesEv; +_ZN4cppu20OPropertyArrayHelper15getHandleByNameERKN3rtl8OUStringE; +_ZN4cppu20OPropertyArrayHelper17getPropertyByNameERKN3rtl8OUStringE; +_ZN4cppu20OPropertyArrayHelper17hasPropertyByNameERKN3rtl8OUStringE; +_ZN4cppu20OPropertyArrayHelper27fillPropertyMembersByHandleEPN3rtl8OUStringEPs?; +_ZN4cppu20OPropertyArrayHelper4initEh; +_ZN4cppu20OPropertyArrayHelperC1EPN3com3sun4star5beans8PropertyE?h; +_ZN4cppu20OPropertyArrayHelperC1ERKN3com3sun4star3uno8SequenceINS3_5beans8PropertyEEEh; +_ZN4cppu20OPropertyArrayHelperC2EPN3com3sun4star5beans8PropertyE?h; +_ZN4cppu20OPropertyArrayHelperC2ERKN3com3sun4star3uno8SequenceINS3_5beans8PropertyEEEh; +_ZN4cppu20WeakImplHelper_queryERKN3com3sun4star3uno4TypeEPNS_10class_dataEPvPNS_11OWeakObjectE; +_ZN4cppu20createNestedRegistryERKN3rtl8OUStringE; +_ZN4cppu20createSimpleRegistryERKN3rtl8OUStringE; +_ZN4cppu22ImplInhHelper_getTypesEPNS_10class_dataERKN3com3sun4star3uno8SequenceINS5_4TypeEEE; +_ZN4cppu22createComponentContextEPKNS_17ContextEntry_InitE?RKN3com3sun4star3uno9ReferenceINS6_17XComponentContextEEE; +_ZN4cppu22getImplHelperInitMutexEv; +_ZN4cppu23WeakImplHelper_getTypesEPNS_10class_dataE; +_ZN4cppu24OInterfaceIteratorHelper4nextEv; +_ZN4cppu24OInterfaceIteratorHelper6removeEv; +_ZN4cppu24OInterfaceIteratorHelperC1ERNS_25OInterfaceContainerHelperE; +_ZN4cppu24OInterfaceIteratorHelperC2ERNS_25OInterfaceContainerHelperE; +_ZN4cppu24OInterfaceIteratorHelperD1Ev; +_ZN4cppu24OInterfaceIteratorHelperD2Ev; +_ZN4cppu24createOneInstanceFactoryERKN3com3sun4star3uno9ReferenceINS2_4lang20XMultiServiceFactoryEEERKN3rtl8OUStringEPFNS4_INS3_10XInterfaceEEES9_ERKNS3_8SequenceISB_EEP16_rtl_ModuleCount; +_ZN4cppu25OInterfaceContainerHelper12addInterfaceERKN3com3sun4star3uno9ReferenceINS4_10XInterfaceEEE; +_ZN4cppu25OInterfaceContainerHelper15disposeAndClearERKN3com3sun4star4lang11EventObjectE; +_ZN4cppu25OInterfaceContainerHelper15removeInterfaceERKN3com3sun4star3uno9ReferenceINS4_10XInterfaceEEE; +_ZN4cppu25OInterfaceContainerHelper17copyAndResetInUseEv; +_ZN4cppu25OInterfaceContainerHelper5clearEv; +_ZN4cppu25OInterfaceContainerHelperC1ERN3osl5MutexE; +_ZN4cppu25OInterfaceContainerHelperC2ERN3osl5MutexE; +_ZN4cppu25OInterfaceContainerHelperD1Ev; +_ZN4cppu25OInterfaceContainerHelperD2Ev; +_ZN4cppu25component_writeInfoHelperEPvS0_PKNS_19ImplementationEntryE; +_ZN4cppu26WeakAggImplHelper_getTypesEPNS_10class_dataE; +_ZN4cppu26WeakAggImplHelper_queryAggERKN3com3sun4star3uno4TypeEPNS_10class_dataEPvPNS_14OWeakAggObjectE; +_ZN4cppu26component_getFactoryHelperEPKcPvS2_PKNS_19ImplementationEntryE; +_ZN4cppu27WeakComponentImplHelperBase14queryInterfaceERKN3com3sun4star3uno4TypeE; +_ZN4cppu27WeakComponentImplHelperBase16addEventListenerERKN3com3sun4star3uno9ReferenceINS3_4lang14XEventListenerEEE; +_ZN4cppu27WeakComponentImplHelperBase19removeEventListenerERKN3com3sun4star3uno9ReferenceINS3_4lang14XEventListenerEEE; +_ZN4cppu27WeakComponentImplHelperBase7acquireEv; +_ZN4cppu27WeakComponentImplHelperBase7disposeEv; +_ZN4cppu27WeakComponentImplHelperBase7releaseEv; +_ZN4cppu27WeakComponentImplHelperBase9disposingEv; +_ZN4cppu27WeakComponentImplHelperBaseC1ERN3osl5MutexE; +_ZN4cppu27WeakComponentImplHelperBaseC2ERN3osl5MutexE; +_ZN4cppu27WeakComponentImplHelperBaseD0Ev; +_ZN4cppu27WeakComponentImplHelperBaseD1Ev; +_ZN4cppu27WeakComponentImplHelperBaseD2Ev; +_ZN4cppu27createSingleRegistryFactoryERKN3com3sun4star3uno9ReferenceINS2_4lang20XMultiServiceFactoryEEERKN3rtl8OUStringERKNS4_INS2_8registry12XRegistryKeyEEE; +_ZN4cppu27writeSharedLibComponentInfoERKN3rtl8OUStringES3_RKN3com3sun4star3uno9ReferenceINS6_4lang20XMultiServiceFactoryEEERKNS8_INS6_8registry12XRegistryKeyEEE; +_ZN4cppu28ImplHelper_queryNoXInterfaceERKN3com3sun4star3uno4TypeEPNS_10class_dataEPv; +_ZN4cppu28createRegistryServiceFactoryERKN3rtl8OUStringES3_hS3_; +_ZN4cppu28createSingleComponentFactoryEPFN3com3sun4star3uno9ReferenceINS3_10XInterfaceEEERKNS4_INS3_17XComponentContextEEEERKN3rtl8OUStringERKNS3_8SequenceISE_EEP16_rtl_ModuleCount; +_ZN4cppu29WeakComponentImplHelper_queryERKN3com3sun4star3uno4TypeEPNS_10class_dataEPvPNS_27WeakComponentImplHelperBaseE; +_ZN4cppu29installTypeDescriptionManagerERKN3com3sun4star3uno9ReferenceINS2_9container23XHierarchicalNameAccessEEE; +_ZN4cppu29loadSharedLibComponentFactoryERKN3rtl8OUStringES3_S3_RKN3com3sun4star3uno9ReferenceINS6_4lang20XMultiServiceFactoryEEERKNS8_INS6_8registry12XRegistryKeyEEE; +_ZN4cppu30ImplHelper_getImplementationIdEPNS_10class_dataE; +_ZN4cppu30WeakAggComponentImplHelperBase14queryInterfaceERKN3com3sun4star3uno4TypeE; +_ZN4cppu30WeakAggComponentImplHelperBase16addEventListenerERKN3com3sun4star3uno9ReferenceINS3_4lang14XEventListenerEEE; +_ZN4cppu30WeakAggComponentImplHelperBase16queryAggregationERKN3com3sun4star3uno4TypeE; +_ZN4cppu30WeakAggComponentImplHelperBase19removeEventListenerERKN3com3sun4star3uno9ReferenceINS3_4lang14XEventListenerEEE; +_ZN4cppu30WeakAggComponentImplHelperBase7acquireEv; +_ZN4cppu30WeakAggComponentImplHelperBase7disposeEv; +_ZN4cppu30WeakAggComponentImplHelperBase7releaseEv; +_ZN4cppu30WeakAggComponentImplHelperBase9disposingEv; +_ZN4cppu30WeakAggComponentImplHelperBaseC1ERN3osl5MutexE; +_ZN4cppu30WeakAggComponentImplHelperBaseC2ERN3osl5MutexE; +_ZN4cppu30WeakAggComponentImplHelperBaseD0Ev; +_ZN4cppu30WeakAggComponentImplHelperBaseD1Ev; +_ZN4cppu30WeakAggComponentImplHelperBaseD2Ev; +_ZN4cppu31createStandardClassWithSequenceERKN3com3sun4star3uno9ReferenceINS2_4lang20XMultiServiceFactoryEEERKN3rtl8OUStringERKNS4_INS2_10reflection9XIdlClassEEERKNS3_8SequenceISB_EE; +_ZN4cppu32WeakComponentImplHelper_getTypesEPNS_10class_dataE; +_ZN4cppu32createOneInstanceRegistryFactoryERKN3com3sun4star3uno9ReferenceINS2_4lang20XMultiServiceFactoryEEERKN3rtl8OUStringERKNS4_INS2_8registry12XRegistryKeyEEE; +_ZN4cppu33bootstrap_InitialComponentContextERKN3com3sun4star3uno9ReferenceINS2_8registry15XSimpleRegistryEEERKN3rtl8OUStringE; +_ZN4cppu34OMultiTypeInterfaceContainerHelper12addInterfaceERKN3com3sun4star3uno4TypeERKNS4_9ReferenceINS4_10XInterfaceEEE; +_ZN4cppu34OMultiTypeInterfaceContainerHelper15disposeAndClearERKN3com3sun4star4lang11EventObjectE; +_ZN4cppu34OMultiTypeInterfaceContainerHelper15removeInterfaceERKN3com3sun4star3uno4TypeERKNS4_9ReferenceINS4_10XInterfaceEEE; +_ZN4cppu34OMultiTypeInterfaceContainerHelper5clearEv; +_ZN4cppu34OMultiTypeInterfaceContainerHelperC1ERN3osl5MutexE; +_ZN4cppu34OMultiTypeInterfaceContainerHelperC2ERN3osl5MutexE; +_ZN4cppu34OMultiTypeInterfaceContainerHelperD1Ev; +_ZN4cppu34OMultiTypeInterfaceContainerHelperD2Ev; +_ZN4cppu35WeakAggComponentImplHelper_getTypesEPNS_10class_dataE; +_ZN4cppu35WeakAggComponentImplHelper_queryAggERKN3com3sun4star3uno4TypeEPNS_10class_dataEPvPNS_30WeakAggComponentImplHelperBaseE; +_ZN4cppu39OMultiTypeInterfaceContainerHelperInt3212addInterfaceERK?RKN3com3sun4star3uno9ReferenceINS6_10XInterfaceEEE; +_ZN4cppu39OMultiTypeInterfaceContainerHelperInt3215disposeAndClearERKN3com3sun4star4lang11EventObjectE; +_ZN4cppu39OMultiTypeInterfaceContainerHelperInt3215removeInterfaceERK?RKN3com3sun4star3uno9ReferenceINS6_10XInterfaceEEE; +_ZN4cppu39OMultiTypeInterfaceContainerHelperInt325clearEv; +_ZN4cppu39OMultiTypeInterfaceContainerHelperInt32C1ERN3osl5MutexE; +_ZN4cppu39OMultiTypeInterfaceContainerHelperInt32C2ERN3osl5MutexE; +_ZN4cppu39OMultiTypeInterfaceContainerHelperInt32D1Ev; +_ZN4cppu39OMultiTypeInterfaceContainerHelperInt32D2Ev; +_ZN4cppu40defaultBootstrap_InitialComponentContextERKN3rtl8OUStringE; +_ZN4cppu40defaultBootstrap_InitialComponentContextEv; +_ZN4cppu9ClassData15writeTypeOffsetERKN3com3sun4star3uno4TypeE?; +_ZN4cppu9ClassData16initTypeProviderEv; +_ZN4cppu9ClassData19getImplementationIdEv; +_ZN4cppu9ClassData5queryERKN3com3sun4star3uno4TypeEPNS3_4lang13XTypeProviderE; +_ZN4cppu9ClassData8getTypesEv; +_ZNK3com3sun4star3uno19WeakReferenceHelper3getEv; +_ZNK4cppu17OImplementationId19getImplementationIdEv; +_ZNK4cppu20OPropertyArrayHelper8getCountEv; +_ZNK4cppu25OInterfaceContainerHelper11getElementsEv; +_ZNK4cppu25OInterfaceContainerHelper9getLengthEv; +_ZNK4cppu34OMultiTypeInterfaceContainerHelper12getContainerERKN3com3sun4star3uno4TypeE; +_ZNK4cppu34OMultiTypeInterfaceContainerHelper17getContainedTypesEv; +_ZNK4cppu39OMultiTypeInterfaceContainerHelperInt3212getContainerERK?; +_ZNK4cppu39OMultiTypeInterfaceContainerHelperInt3217getContainedTypesEv; +_ZTVN4cppu11OWeakObjectE; +_ZTVN4cppu14OWeakAggObjectE; +_ZTVN4cppu16OComponentHelperE; +_ZTVN4cppu18OPropertySetHelperE; +_ZTVN4cppu20IPropertyArrayHelperE; +_ZTVN4cppu20OPropertyArrayHelperE; +_ZTVN4cppu27WeakComponentImplHelperBaseE; +_ZTVN4cppu30WeakAggComponentImplHelperBaseE; +_ZN4cppu20OPropertyArrayHelperD0Ev; +_ZN4cppu20OPropertyArrayHelperD1Ev; +_ZThn*_N4cppu14OWeakAggObject12setDelegatorERKN3com3sun4star3uno9ReferenceINS4_10XInterfaceEEE; +_ZThn*_N4cppu14OWeakAggObject14queryInterfaceERKN3com3sun4star3uno4TypeE; +_ZThn*_N4cppu14OWeakAggObject16queryAggregationERKN3com3sun4star3uno4TypeE; +_ZThn*_N4cppu14OWeakAggObject7acquireEv; +_ZThn*_N4cppu14OWeakAggObject7releaseEv; +_ZThn*_N4cppu16OComponentHelper14queryInterfaceERKN3com3sun4star3uno4TypeE; +_ZThn*_N4cppu16OComponentHelper16queryAggregationERKN3com3sun4star3uno4TypeE; +_ZThn*_N4cppu16OComponentHelper7acquireEv; +_ZThn*_N4cppu16OComponentHelper7releaseEv; +_ZThn*_N4cppu27WeakComponentImplHelperBase14queryInterfaceERKN3com3sun4star3uno4TypeE; +_ZThn*_N4cppu27WeakComponentImplHelperBase16addEventListenerERKN3com3sun4star3uno9ReferenceINS3_4lang14XEventListenerEEE; +_ZThn*_N4cppu27WeakComponentImplHelperBase19removeEventListenerERKN3com3sun4star3uno9ReferenceINS3_4lang14XEventListenerEEE; +_ZThn*_N4cppu27WeakComponentImplHelperBase7acquireEv; +_ZThn*_N4cppu27WeakComponentImplHelperBase7disposeEv; +_ZThn*_N4cppu27WeakComponentImplHelperBase7releaseEv; +_ZThn*_N4cppu30WeakAggComponentImplHelperBase14queryInterfaceERKN3com3sun4star3uno4TypeE; +_ZThn*_N4cppu30WeakAggComponentImplHelperBase16queryAggregationERKN3com3sun4star3uno4TypeE; +_ZThn*_N4cppu30WeakAggComponentImplHelperBase7acquireEv; +_ZThn*_N4cppu30WeakAggComponentImplHelperBase7releaseEv; +_ZThn*_N4cppu16OComponentHelper14queryInterfaceERKN3com3sun4star3uno4TypeE; +_ZThn*_N4cppu16OComponentHelper7acquireEv; +_ZThn*_N4cppu16OComponentHelper7releaseEv; +_ZThn*_N4cppu16OComponentHelper8getTypesEv; +_ZThn*_N4cppu30WeakAggComponentImplHelperBase14queryInterfaceERKN3com3sun4star3uno4TypeE; +_ZThn*_N4cppu30WeakAggComponentImplHelperBase16addEventListenerERKN3com3sun4star3uno9ReferenceINS3_4lang14XEventListenerEEE; +_ZThn*_N4cppu30WeakAggComponentImplHelperBase19removeEventListenerERKN3com3sun4star3uno9ReferenceINS3_4lang14XEventListenerEEE; +_ZThn*_N4cppu30WeakAggComponentImplHelperBase7acquireEv; +_ZThn*_N4cppu30WeakAggComponentImplHelperBase7disposeEv; +_ZThn*_N4cppu30WeakAggComponentImplHelperBase7releaseEv; +_ZThn*_N4cppu16OComponentHelper14queryInterfaceERKN3com3sun4star3uno4TypeE; +_ZThn*_N4cppu16OComponentHelper16addEventListenerERKN3com3sun4star3uno9ReferenceINS3_4lang14XEventListenerEEE; +_ZThn*_N4cppu16OComponentHelper19removeEventListenerERKN3com3sun4star3uno9ReferenceINS3_4lang14XEventListenerEEE; +_ZThn*_N4cppu16OComponentHelper7acquireEv; +_ZThn*_N4cppu16OComponentHelper7disposeEv; +_ZThn*_N4cppu16OComponentHelper7releaseEv; +_ZThn*_N4cppu18OPropertySetHelper14queryInterfaceERKN3com3sun4star3uno4TypeE; +_ZThn*_N4cppu18OPropertySetHelper20getFastPropertyValueE?; +_ZThn*_N4cppu18OPropertySetHelper20setFastPropertyValueE?RKN3com3sun4star3uno3AnyE; +_ZThn*_N4cppu18OPropertySetHelper14queryInterfaceERKN3com3sun4star3uno4TypeE; +_ZThn*_N4cppu18OPropertySetHelper16getPropertyValueERKN3rtl8OUStringE; +_ZThn*_N4cppu18OPropertySetHelper16setPropertyValueERKN3rtl8OUStringERKN3com3sun4star3uno3AnyE; +_ZThn*_N4cppu18OPropertySetHelper25addPropertyChangeListenerERKN3rtl8OUStringERKN3com3sun4star3uno9ReferenceINS7_5beans23XPropertyChangeListenerEEE; +_ZThn*_N4cppu18OPropertySetHelper25addVetoableChangeListenerERKN3rtl8OUStringERKN3com3sun4star3uno9ReferenceINS7_5beans23XVetoableChangeListenerEEE; +_ZThn*_N4cppu18OPropertySetHelper28removePropertyChangeListenerERKN3rtl8OUStringERKN3com3sun4star3uno9ReferenceINS7_5beans23XPropertyChangeListenerEEE; +_ZThn*_N4cppu18OPropertySetHelper28removeVetoableChangeListenerERKN3rtl8OUStringERKN3com3sun4star3uno9ReferenceINS7_5beans23XVetoableChangeListenerEEE; + +_ZN4cppu13AccessControl19checkFilePermissionERKN3rtl8OUStringES4_; +_ZN4cppu13AccessControl21checkSocketPermissionERKN3rtl8OUStringES4_; +_ZN4cppu13AccessControl22checkRuntimePermissionERKN3rtl8OUStringE; +_ZN4cppu13AccessControlC1ERKN3com3sun4star3uno9ReferenceINS3_8security17XAccessControllerEEE; +_ZN4cppu13AccessControlC2ERKN3com3sun4star3uno9ReferenceINS3_8security17XAccessControllerEEE; +_ZN4cppu13AccessControlC1ERKN3com3sun4star3uno9ReferenceINS4_17XComponentContextEEE; +_ZN4cppu13AccessControlC2ERKN3com3sun4star3uno9ReferenceINS4_17XComponentContextEEE; +_ZN4cppu13AccessControlC1ERKS0_; +_ZN4cppu13AccessControlC2ERKS0_; + +_ZN4cppu16UnoUrlDescriptorC1ERKN3rtl8OUStringE; +_ZN4cppu16UnoUrlDescriptorC1ERKS0_; +_ZN4cppu16UnoUrlDescriptorC2ERKN3rtl8OUStringE; +_ZN4cppu16UnoUrlDescriptorC2ERKS0_; +_ZN4cppu16UnoUrlDescriptorD1Ev; +_ZN4cppu16UnoUrlDescriptorD2Ev; +_ZN4cppu16UnoUrlDescriptoraSERKS0_; +_ZN4cppu6UnoUrlC1ERKN3rtl8OUStringE; +_ZN4cppu6UnoUrlC1ERKS0_; +_ZN4cppu6UnoUrlC2ERKN3rtl8OUStringE; +_ZN4cppu6UnoUrlC2ERKS0_; +_ZN4cppu6UnoUrlD1Ev; +_ZN4cppu6UnoUrlD2Ev; +_ZN4cppu6UnoUrlaSERKS0_; +_ZNK4cppu16UnoUrlDescriptor12getParameterERKN3rtl8OUStringE; +_ZNK4cppu16UnoUrlDescriptor12hasParameterERKN3rtl8OUStringE; +_ZNK4cppu16UnoUrlDescriptor13getDescriptorEv; +_ZNK4cppu16UnoUrlDescriptor7getNameEv; +_ZNK4cppu6UnoUrl11getProtocolEv; +_ZNK4cppu6UnoUrl13getConnectionEv; +_ZNK4cppu6UnoUrl13getObjectNameEv; + + local: + *; +}; + +UDK_3.1 { + global: + _ZN4cppu18getCaughtExceptionEv; + + _ZN4cppu18OPropertySetHelperC1ERNS_19OBroadcastHelperVarINS_34OMultiTypeInterfaceContainerHelperEN3com3sun4star3uno4TypeEEEb; + _ZN4cppu18OPropertySetHelperC2ERNS_19OBroadcastHelperVarINS_34OMultiTypeInterfaceContainerHelperEN3com3sun4star3uno4TypeEEEb; + + _ZN4cppu9bootstrapEv; + _ZN4cppu18BootstrapExceptionC1Ev; + _ZN4cppu18BootstrapExceptionC2Ev; + _ZN4cppu18BootstrapExceptionC1ERKN3rtl8OUStringE; + _ZN4cppu18BootstrapExceptionC2ERKN3rtl8OUStringE; + _ZN4cppu18BootstrapExceptionC1ERKS0_; + _ZN4cppu18BootstrapExceptionC2ERKS0_; + _ZN4cppu18BootstrapExceptionD0Ev; + _ZN4cppu18BootstrapExceptionD1Ev; + _ZN4cppu18BootstrapExceptionD2Ev; + _ZN4cppu18BootstrapExceptionaSERKS0_; + _ZNK4cppu18BootstrapException10getMessageEv; + # _ZTIN4cppu18BootstrapExceptionE; + # _ZTSN4cppu18BootstrapExceptionE; +} UDK_3_0_0; + +UDK_3.2 { + global: + _ZN4cppu20PropertySetMixinImpl10prepareSetERKN3rtl8OUStringERKN3com3sun4star3uno3AnyESB_PNS0_14BoundListenersE; + _ZN4cppu20PropertySetMixinImpl14BoundListenersC1Ev; + _ZN4cppu20PropertySetMixinImpl14BoundListenersC2Ev; + _ZN4cppu20PropertySetMixinImpl14BoundListenersD1Ev; + _ZN4cppu20PropertySetMixinImpl14BoundListenersD2Ev; + _ZN4cppu20PropertySetMixinImpl14queryInterfaceERKN3com3sun4star3uno4TypeE; + _ZN4cppu20PropertySetMixinImpl16getPropertyValueERKN3rtl8OUStringE; + _ZN4cppu20PropertySetMixinImpl16setPropertyValueERKN3rtl8OUStringERKN3com3sun4star3uno3AnyE; + _ZN4cppu20PropertySetMixinImpl17getPropertyValuesEv; + _ZN4cppu20PropertySetMixinImpl17setPropertyValuesERKN3com3sun4star3uno8SequenceINS3_5beans13PropertyValueEEE; + _ZN4cppu20PropertySetMixinImpl18getPropertySetInfoEv; + _ZN4cppu20PropertySetMixinImpl20getFastPropertyValueE?; + _ZN4cppu20PropertySetMixinImpl20setFastPropertyValueE?RKN3com3sun4star3uno3AnyE; + _ZN4cppu20PropertySetMixinImpl25addPropertyChangeListenerERKN3rtl8OUStringERKN3com3sun4star3uno9ReferenceINS7_5beans23XPropertyChangeListenerEEE; + _ZN4cppu20PropertySetMixinImpl25addVetoableChangeListenerERKN3rtl8OUStringERKN3com3sun4star3uno9ReferenceINS7_5beans23XVetoableChangeListenerEEE; + _ZN4cppu20PropertySetMixinImpl28removePropertyChangeListenerERKN3rtl8OUStringERKN3com3sun4star3uno9ReferenceINS7_5beans23XPropertyChangeListenerEEE; + _ZN4cppu20PropertySetMixinImpl28removeVetoableChangeListenerERKN3rtl8OUStringERKN3com3sun4star3uno9ReferenceINS7_5beans23XVetoableChangeListenerEEE; + _ZN4cppu20PropertySetMixinImpl7disposeEv; + _ZN4cppu20PropertySetMixinImplC1ERKN3com3sun4star3uno9ReferenceINS4_17XComponentContextEEENS0_10ImplementsERKNS4_8SequenceIN3rtl8OUStringEEERKNS4_4TypeE; + _ZN4cppu20PropertySetMixinImplC2ERKN3com3sun4star3uno9ReferenceINS4_17XComponentContextEEENS0_10ImplementsERKNS4_8SequenceIN3rtl8OUStringEEERKNS4_4TypeE; + _ZN4cppu20PropertySetMixinImplD1Ev; + _ZN4cppu20PropertySetMixinImplD2Ev; + _ZNK4cppu20PropertySetMixinImpl14BoundListeners6notifyEv; + _ZThn*_N4cppu20PropertySetMixinImpl14queryInterfaceERKN3com3sun4star3uno4TypeE; + _ZThn*_N4cppu20PropertySetMixinImpl20getFastPropertyValueE?; + _ZThn*_N4cppu20PropertySetMixinImpl20setFastPropertyValueE?RKN3com3sun4star3uno3AnyE; + _ZThn*_N4cppu20PropertySetMixinImpl14queryInterfaceERKN3com3sun4star3uno4TypeE; + _ZThn*_N4cppu20PropertySetMixinImpl17getPropertyValuesEv; + _ZThn*_N4cppu20PropertySetMixinImpl17setPropertyValuesERKN3com3sun4star3uno8SequenceINS3_5beans13PropertyValueEEE; +} UDK_3.1; + +UDK_3.3 { # OOo 2.3 + global: + _ZN4cppu18OPropertySetHelper8getTypesEv; +} UDK_3.2; + +UDK_3.4 { # OOo 2.4 + global: + _ZN4cppu19bootstrap_expandUriERKN3rtl8OUStringE; # rtl::OUString cppu::bootstrap_expandUri(rtl::OUString const &) +} UDK_3.3; + +UDK_3.5 { # OOo 3.0 + global: + _ZN4cppu18OPropertySetHelperC1ERNS_19OBroadcastHelperVarINS_34OMultiTypeInterfaceContainerHelperEN3com3sun4star3uno4TypeEEEPNS_22IEventNotificationHookEb; + _ZN4cppu18OPropertySetHelperC2ERNS_19OBroadcastHelperVarINS_34OMultiTypeInterfaceContainerHelperEN3com3sun4star3uno4TypeEEEPNS_22IEventNotificationHookEb; +} UDK_3.4; + +UDK_3.6 { # OOo 3.3 + global: + _ZN4cppu11OWeakObject26disposeWeakConnectionPointEv; + _ZN3com3sun4star3uno19WeakReferenceHelperaSERKNS2_9ReferenceINS2_10XInterfaceEEE; + _ZN3com3sun4star3uno19WeakReferenceHelper5clearEv; + _ZN4cppu33createOneInstanceComponentFactoryEPFN3com3sun4star3uno9ReferenceINS3_10XInterfaceEEERKNS4_INS3_17XComponentContextEEEERKN3rtl8OUStringERKNS3_8SequenceISE_EEP16_rtl_ModuleCount; +} UDK_3.5; + diff --git a/cppuhelper/source/gcc3os2.map b/cppuhelper/source/gcc3os2.map new file mode 100644 index 000000000000..2c3bd2d64b5c --- /dev/null +++ b/cppuhelper/source/gcc3os2.map @@ -0,0 +1,377 @@ +UDK_3_0_0 { + global: +GetVersionInfo; +_ZN3com3sun4star3uno19WeakReferenceHelperC1ERKNS2_9ReferenceINS2_10XInterfaceEEE; +_ZN3com3sun4star3uno19WeakReferenceHelperC1ERKS3_; +_ZN3com3sun4star3uno19WeakReferenceHelperC2ERKNS2_9ReferenceINS2_10XInterfaceEEE; +_ZN3com3sun4star3uno19WeakReferenceHelperC2ERKS3_; +_ZN3com3sun4star3uno19WeakReferenceHelperaSERKS3_; +_ZN3com3sun4star3uno19WeakReferenceHelperD1Ev; +_ZN3com3sun4star3uno19WeakReferenceHelperD2Ev; +_ZN4cppu11OWeakObject12queryAdapterEv; +_ZN4cppu11OWeakObject14queryInterfaceERKN3com3sun4star3uno4TypeE; +_ZN4cppu11OWeakObject7acquireEv; +_ZN4cppu11OWeakObject7releaseEv; +_ZN4cppu11OWeakObjectD0Ev; +_ZN4cppu11OWeakObjectD1Ev; +_ZN4cppu11OWeakObjectD2Ev; +_ZN4cppu13ClassDataBaseC1El; +_ZN4cppu13ClassDataBaseC1Ev; +_ZN4cppu13ClassDataBaseC2El; +_ZN4cppu13ClassDataBaseC2Ev; +_ZN4cppu13ClassDataBaseD1Ev; +_ZN4cppu13ClassDataBaseD2Ev; +_ZN4cppu14OWeakAggObject12setDelegatorERKN3com3sun4star3uno9ReferenceINS4_10XInterfaceEEE; +_ZN4cppu14OWeakAggObject14queryInterfaceERKN3com3sun4star3uno4TypeE; +_ZN4cppu14OWeakAggObject16queryAggregationERKN3com3sun4star3uno4TypeE; +_ZN4cppu14OWeakAggObject7acquireEv; +_ZN4cppu14OWeakAggObject7releaseEv; +_ZN4cppu14OWeakAggObjectD0Ev; +_ZN4cppu14OWeakAggObjectD1Ev; +_ZN4cppu14OWeakAggObjectD2Ev; +_ZN4cppu14throwExceptionERKN3com3sun4star3uno3AnyE; +_ZN4cppu15OTypeCollectionC1ERKN3com3sun4star3uno4TypeERKNS4_8SequenceIS5_EE; +_ZN4cppu15OTypeCollectionC1ERKN3com3sun4star3uno4TypeES7_RKNS4_8SequenceIS5_EE; +_ZN4cppu15OTypeCollectionC1ERKN3com3sun4star3uno4TypeES7_S7_RKNS4_8SequenceIS5_EE; +_ZN4cppu15OTypeCollectionC1ERKN3com3sun4star3uno4TypeES7_S7_S7_RKNS4_8SequenceIS5_EE; +_ZN4cppu15OTypeCollectionC1ERKN3com3sun4star3uno4TypeES7_S7_S7_S7_RKNS4_8SequenceIS5_EE; +_ZN4cppu15OTypeCollectionC1ERKN3com3sun4star3uno4TypeES7_S7_S7_S7_S7_RKNS4_8SequenceIS5_EE; +_ZN4cppu15OTypeCollectionC1ERKN3com3sun4star3uno4TypeES7_S7_S7_S7_S7_S7_RKNS4_8SequenceIS5_EE; +_ZN4cppu15OTypeCollectionC1ERKN3com3sun4star3uno4TypeES7_S7_S7_S7_S7_S7_S7_RKNS4_8SequenceIS5_EE; +_ZN4cppu15OTypeCollectionC1ERKN3com3sun4star3uno4TypeES7_S7_S7_S7_S7_S7_S7_S7_RKNS4_8SequenceIS5_EE; +_ZN4cppu15OTypeCollectionC1ERKN3com3sun4star3uno4TypeES7_S7_S7_S7_S7_S7_S7_S7_S7_RKNS4_8SequenceIS5_EE; +_ZN4cppu15OTypeCollectionC1ERKN3com3sun4star3uno4TypeES7_S7_S7_S7_S7_S7_S7_S7_S7_S7_RKNS4_8SequenceIS5_EE; +_ZN4cppu15OTypeCollectionC1ERKN3com3sun4star3uno4TypeES7_S7_S7_S7_S7_S7_S7_S7_S7_S7_S7_RKNS4_8SequenceIS5_EE; +_ZN4cppu15OTypeCollectionC2ERKN3com3sun4star3uno4TypeERKNS4_8SequenceIS5_EE; +_ZN4cppu15OTypeCollectionC2ERKN3com3sun4star3uno4TypeES7_RKNS4_8SequenceIS5_EE; +_ZN4cppu15OTypeCollectionC2ERKN3com3sun4star3uno4TypeES7_S7_RKNS4_8SequenceIS5_EE; +_ZN4cppu15OTypeCollectionC2ERKN3com3sun4star3uno4TypeES7_S7_S7_RKNS4_8SequenceIS5_EE; +_ZN4cppu15OTypeCollectionC2ERKN3com3sun4star3uno4TypeES7_S7_S7_S7_RKNS4_8SequenceIS5_EE; +_ZN4cppu15OTypeCollectionC2ERKN3com3sun4star3uno4TypeES7_S7_S7_S7_S7_RKNS4_8SequenceIS5_EE; +_ZN4cppu15OTypeCollectionC2ERKN3com3sun4star3uno4TypeES7_S7_S7_S7_S7_S7_RKNS4_8SequenceIS5_EE; +_ZN4cppu15OTypeCollectionC2ERKN3com3sun4star3uno4TypeES7_S7_S7_S7_S7_S7_S7_RKNS4_8SequenceIS5_EE; +_ZN4cppu15OTypeCollectionC2ERKN3com3sun4star3uno4TypeES7_S7_S7_S7_S7_S7_S7_S7_RKNS4_8SequenceIS5_EE; +_ZN4cppu15OTypeCollectionC2ERKN3com3sun4star3uno4TypeES7_S7_S7_S7_S7_S7_S7_S7_S7_RKNS4_8SequenceIS5_EE; +_ZN4cppu15OTypeCollectionC2ERKN3com3sun4star3uno4TypeES7_S7_S7_S7_S7_S7_S7_S7_S7_S7_RKNS4_8SequenceIS5_EE; +_ZN4cppu15OTypeCollectionC2ERKN3com3sun4star3uno4TypeES7_S7_S7_S7_S7_S7_S7_S7_S7_S7_S7_RKNS4_8SequenceIS5_EE; +_ZN4cppu16ImplHelper_queryERKN3com3sun4star3uno4TypeEPNS_10class_dataEPv; +_ZN4cppu16OComponentHelper14queryInterfaceERKN3com3sun4star3uno4TypeE; +_ZN4cppu16OComponentHelper16addEventListenerERKN3com3sun4star3uno9ReferenceINS3_4lang14XEventListenerEEE; +_ZN4cppu16OComponentHelper16queryAggregationERKN3com3sun4star3uno4TypeE; +_ZN4cppu16OComponentHelper19removeEventListenerERKN3com3sun4star3uno9ReferenceINS3_4lang14XEventListenerEEE; +_ZN4cppu16OComponentHelper7acquireEv; +_ZN4cppu16OComponentHelper7disposeEv; +_ZN4cppu16OComponentHelper7releaseEv; +_ZN4cppu16OComponentHelper8getTypesEv; +_ZN4cppu16OComponentHelper9disposingEv; +_ZN4cppu16OComponentHelperC1ERN3osl5MutexE; +_ZN4cppu16OComponentHelperC2ERN3osl5MutexE; +_ZN4cppu16OComponentHelperD0Ev; +_ZN4cppu16OComponentHelperD1Ev; +_ZN4cppu16OComponentHelperD2Ev; +_ZN4cppu17OImplementationIdD1Ev; +_ZN4cppu17OImplementationIdD2Ev; +_ZN4cppu18OPropertySetHelper14queryInterfaceERKN3com3sun4star3uno4TypeE; +_ZN4cppu18OPropertySetHelper16getPropertyValueERKN3rtl8OUStringE; +_ZN4cppu18OPropertySetHelper16setPropertyValueERKN3rtl8OUStringERKN3com3sun4star3uno3AnyE; +_ZN4cppu18OPropertySetHelper17getPropertyValuesERKN3com3sun4star3uno8SequenceIN3rtl8OUStringEEE; +_ZN4cppu18OPropertySetHelper17setPropertyValuesERKN3com3sun4star3uno8SequenceIN3rtl8OUStringEEERKNS5_INS4_3AnyEEE; +_ZN4cppu18OPropertySetHelper20getFastPropertyValueEl; +_ZN4cppu18OPropertySetHelper20setFastPropertyValueElRKN3com3sun4star3uno3AnyE; +_ZN4cppu18OPropertySetHelper21createPropertySetInfoERNS_20IPropertyArrayHelperE; +_ZN4cppu18OPropertySetHelper21setFastPropertyValuesElPlPKN3com3sun4star3uno3AnyEl; +_ZN4cppu18OPropertySetHelper25addPropertyChangeListenerERKN3rtl8OUStringERKN3com3sun4star3uno9ReferenceINS7_5beans23XPropertyChangeListenerEEE; +_ZN4cppu18OPropertySetHelper25addVetoableChangeListenerERKN3rtl8OUStringERKN3com3sun4star3uno9ReferenceINS7_5beans23XVetoableChangeListenerEEE; +_ZN4cppu18OPropertySetHelper25firePropertiesChangeEventERKN3com3sun4star3uno8SequenceIN3rtl8OUStringEEERKNS4_9ReferenceINS3_5beans25XPropertiesChangeListenerEEE; +_ZN4cppu18OPropertySetHelper27addPropertiesChangeListenerERKN3com3sun4star3uno8SequenceIN3rtl8OUStringEEERKNS4_9ReferenceINS3_5beans25XPropertiesChangeListenerEEE; +_ZN4cppu18OPropertySetHelper28removePropertyChangeListenerERKN3rtl8OUStringERKN3com3sun4star3uno9ReferenceINS7_5beans23XPropertyChangeListenerEEE; +_ZN4cppu18OPropertySetHelper28removeVetoableChangeListenerERKN3rtl8OUStringERKN3com3sun4star3uno9ReferenceINS7_5beans23XVetoableChangeListenerEEE; +_ZN4cppu18OPropertySetHelper30removePropertiesChangeListenerERKN3com3sun4star3uno9ReferenceINS3_5beans25XPropertiesChangeListenerEEE; +_ZN4cppu18OPropertySetHelper4fireEPlPKN3com3sun4star3uno3AnyES8_lh; +_ZN4cppu18OPropertySetHelper9disposingEv; +_ZN4cppu18OPropertySetHelperC1ERNS_19OBroadcastHelperVarINS_34OMultiTypeInterfaceContainerHelperEN3com3sun4star3uno4TypeEEE; +_ZN4cppu18OPropertySetHelperC2ERNS_19OBroadcastHelperVarINS_34OMultiTypeInterfaceContainerHelperEN3com3sun4star3uno4TypeEEE; +_ZN4cppu18OPropertySetHelperD1Ev; +_ZN4cppu18OPropertySetHelperD2Ev; +_ZN4cppu18bootstrapInitialSFERKN3rtl8OUStringE; +_ZN4cppu18createFactoryProxyERKN3com3sun4star3uno9ReferenceINS2_4lang20XMultiServiceFactoryEEERKNS4_INS5_21XSingleServiceFactoryEEE; +_ZN4cppu19ImplHelper_getTypesEPNS_10class_dataE; +_ZN4cppu19createSingleFactoryERKN3com3sun4star3uno9ReferenceINS2_4lang20XMultiServiceFactoryEEERKN3rtl8OUStringEPFNS4_INS3_10XInterfaceEEES9_ERKNS3_8SequenceISB_EEP16_rtl_ModuleCount; +_ZN4cppu20IPropertyArrayHelperD0Ev; +_ZN4cppu20IPropertyArrayHelperD1Ev; +_ZN4cppu20IPropertyArrayHelperD2Ev; +_ZN4cppu20OPropertyArrayHelper11fillHandlesEPlRKN3com3sun4star3uno8SequenceIN3rtl8OUStringEEE; +_ZN4cppu20OPropertyArrayHelper13getPropertiesEv; +_ZN4cppu20OPropertyArrayHelper15getHandleByNameERKN3rtl8OUStringE; +_ZN4cppu20OPropertyArrayHelper17getPropertyByNameERKN3rtl8OUStringE; +_ZN4cppu20OPropertyArrayHelper17hasPropertyByNameERKN3rtl8OUStringE; +_ZN4cppu20OPropertyArrayHelper27fillPropertyMembersByHandleEPN3rtl8OUStringEPsl; +_ZN4cppu20OPropertyArrayHelper4initEh; +_ZN4cppu20OPropertyArrayHelperC1EPN3com3sun4star5beans8PropertyElh; +_ZN4cppu20OPropertyArrayHelperC1ERKN3com3sun4star3uno8SequenceINS3_5beans8PropertyEEEh; +_ZN4cppu20OPropertyArrayHelperC2EPN3com3sun4star5beans8PropertyElh; +_ZN4cppu20OPropertyArrayHelperC2ERKN3com3sun4star3uno8SequenceINS3_5beans8PropertyEEEh; +_ZN4cppu20WeakImplHelper_queryERKN3com3sun4star3uno4TypeEPNS_10class_dataEPvPNS_11OWeakObjectE; +_ZN4cppu20createNestedRegistryERKN3rtl8OUStringE; +_ZN4cppu20createSimpleRegistryERKN3rtl8OUStringE; +_ZN4cppu22ImplInhHelper_getTypesEPNS_10class_dataERKN3com3sun4star3uno8SequenceINS5_4TypeEEE; +_ZN4cppu22createComponentContextEPKNS_17ContextEntry_InitElRKN3com3sun4star3uno9ReferenceINS6_17XComponentContextEEE; +_ZN4cppu22getImplHelperInitMutexEv; +_ZN4cppu23WeakImplHelper_getTypesEPNS_10class_dataE; +_ZN4cppu24OInterfaceIteratorHelper4nextEv; +_ZN4cppu24OInterfaceIteratorHelper6removeEv; +_ZN4cppu24OInterfaceIteratorHelperC1ERNS_25OInterfaceContainerHelperE; +_ZN4cppu24OInterfaceIteratorHelperC2ERNS_25OInterfaceContainerHelperE; +_ZN4cppu24OInterfaceIteratorHelperD1Ev; +_ZN4cppu24OInterfaceIteratorHelperD2Ev; +_ZN4cppu24createOneInstanceFactoryERKN3com3sun4star3uno9ReferenceINS2_4lang20XMultiServiceFactoryEEERKN3rtl8OUStringEPFNS4_INS3_10XInterfaceEEES9_ERKNS3_8SequenceISB_EEP16_rtl_ModuleCount; +_ZN4cppu25OInterfaceContainerHelper12addInterfaceERKN3com3sun4star3uno9ReferenceINS4_10XInterfaceEEE; +_ZN4cppu25OInterfaceContainerHelper15disposeAndClearERKN3com3sun4star4lang11EventObjectE; +_ZN4cppu25OInterfaceContainerHelper15removeInterfaceERKN3com3sun4star3uno9ReferenceINS4_10XInterfaceEEE; +_ZN4cppu25OInterfaceContainerHelper17copyAndResetInUseEv; +_ZN4cppu25OInterfaceContainerHelper5clearEv; +_ZN4cppu25OInterfaceContainerHelperC1ERN3osl5MutexE; +_ZN4cppu25OInterfaceContainerHelperC2ERN3osl5MutexE; +_ZN4cppu25OInterfaceContainerHelperD1Ev; +_ZN4cppu25OInterfaceContainerHelperD2Ev; +_ZN4cppu25component_writeInfoHelperEPvS0_PKNS_19ImplementationEntryE; +_ZN4cppu26WeakAggImplHelper_getTypesEPNS_10class_dataE; +_ZN4cppu26WeakAggImplHelper_queryAggERKN3com3sun4star3uno4TypeEPNS_10class_dataEPvPNS_14OWeakAggObjectE; +_ZN4cppu26component_getFactoryHelperEPKcPvS2_PKNS_19ImplementationEntryE; +_ZN4cppu27WeakComponentImplHelperBase14queryInterfaceERKN3com3sun4star3uno4TypeE; +_ZN4cppu27WeakComponentImplHelperBase16addEventListenerERKN3com3sun4star3uno9ReferenceINS3_4lang14XEventListenerEEE; +_ZN4cppu27WeakComponentImplHelperBase19removeEventListenerERKN3com3sun4star3uno9ReferenceINS3_4lang14XEventListenerEEE; +_ZN4cppu27WeakComponentImplHelperBase7acquireEv; +_ZN4cppu27WeakComponentImplHelperBase7disposeEv; +_ZN4cppu27WeakComponentImplHelperBase7releaseEv; +_ZN4cppu27WeakComponentImplHelperBase9disposingEv; +_ZN4cppu27WeakComponentImplHelperBaseC1ERN3osl5MutexE; +_ZN4cppu27WeakComponentImplHelperBaseC2ERN3osl5MutexE; +_ZN4cppu27WeakComponentImplHelperBaseD0Ev; +_ZN4cppu27WeakComponentImplHelperBaseD1Ev; +_ZN4cppu27WeakComponentImplHelperBaseD2Ev; +_ZN4cppu27createSingleRegistryFactoryERKN3com3sun4star3uno9ReferenceINS2_4lang20XMultiServiceFactoryEEERKN3rtl8OUStringERKNS4_INS2_8registry12XRegistryKeyEEE; +_ZN4cppu27writeSharedLibComponentInfoERKN3rtl8OUStringES3_RKN3com3sun4star3uno9ReferenceINS6_4lang20XMultiServiceFactoryEEERKNS8_INS6_8registry12XRegistryKeyEEE; +_ZN4cppu28ImplHelper_queryNoXInterfaceERKN3com3sun4star3uno4TypeEPNS_10class_dataEPv; +_ZN4cppu28createRegistryServiceFactoryERKN3rtl8OUStringES3_hS3_; +_ZN4cppu28createSingleComponentFactoryEPFN3com3sun4star3uno9ReferenceINS3_10XInterfaceEEERKNS4_INS3_17XComponentContextEEEERKN3rtl8OUStringERKNS3_8SequenceISE_EEP16_rtl_ModuleCount; +_ZN4cppu29WeakComponentImplHelper_queryERKN3com3sun4star3uno4TypeEPNS_10class_dataEPvPNS_27WeakComponentImplHelperBaseE; +_ZN4cppu29installTypeDescriptionManagerERKN3com3sun4star3uno9ReferenceINS2_9container23XHierarchicalNameAccessEEE; +_ZN4cppu29loadSharedLibComponentFactoryERKN3rtl8OUStringES3_S3_RKN3com3sun4star3uno9ReferenceINS6_4lang20XMultiServiceFactoryEEERKNS8_INS6_8registry12XRegistryKeyEEE; +_ZN4cppu30ImplHelper_getImplementationIdEPNS_10class_dataE; +_ZN4cppu30WeakAggComponentImplHelperBase14queryInterfaceERKN3com3sun4star3uno4TypeE; +_ZN4cppu30WeakAggComponentImplHelperBase16addEventListenerERKN3com3sun4star3uno9ReferenceINS3_4lang14XEventListenerEEE; +_ZN4cppu30WeakAggComponentImplHelperBase16queryAggregationERKN3com3sun4star3uno4TypeE; +_ZN4cppu30WeakAggComponentImplHelperBase19removeEventListenerERKN3com3sun4star3uno9ReferenceINS3_4lang14XEventListenerEEE; +_ZN4cppu30WeakAggComponentImplHelperBase7acquireEv; +_ZN4cppu30WeakAggComponentImplHelperBase7disposeEv; +_ZN4cppu30WeakAggComponentImplHelperBase7releaseEv; +_ZN4cppu30WeakAggComponentImplHelperBase9disposingEv; +_ZN4cppu30WeakAggComponentImplHelperBaseC1ERN3osl5MutexE; +_ZN4cppu30WeakAggComponentImplHelperBaseC2ERN3osl5MutexE; +_ZN4cppu30WeakAggComponentImplHelperBaseD0Ev; +_ZN4cppu30WeakAggComponentImplHelperBaseD1Ev; +_ZN4cppu30WeakAggComponentImplHelperBaseD2Ev; +_ZN4cppu31createStandardClassWithSequenceERKN3com3sun4star3uno9ReferenceINS2_4lang20XMultiServiceFactoryEEERKN3rtl8OUStringERKNS4_INS2_10reflection9XIdlClassEEERKNS3_8SequenceISB_EE; +_ZN4cppu32WeakComponentImplHelper_getTypesEPNS_10class_dataE; +_ZN4cppu32createOneInstanceRegistryFactoryERKN3com3sun4star3uno9ReferenceINS2_4lang20XMultiServiceFactoryEEERKN3rtl8OUStringERKNS4_INS2_8registry12XRegistryKeyEEE; +_ZN4cppu33bootstrap_InitialComponentContextERKN3com3sun4star3uno9ReferenceINS2_8registry15XSimpleRegistryEEERKN3rtl8OUStringE; +_ZN4cppu34OMultiTypeInterfaceContainerHelper12addInterfaceERKN3com3sun4star3uno4TypeERKNS4_9ReferenceINS4_10XInterfaceEEE; +_ZN4cppu34OMultiTypeInterfaceContainerHelper15disposeAndClearERKN3com3sun4star4lang11EventObjectE; +_ZN4cppu34OMultiTypeInterfaceContainerHelper15removeInterfaceERKN3com3sun4star3uno4TypeERKNS4_9ReferenceINS4_10XInterfaceEEE; +_ZN4cppu34OMultiTypeInterfaceContainerHelper5clearEv; +_ZN4cppu34OMultiTypeInterfaceContainerHelperC1ERN3osl5MutexE; +_ZN4cppu34OMultiTypeInterfaceContainerHelperC2ERN3osl5MutexE; +_ZN4cppu34OMultiTypeInterfaceContainerHelperD1Ev; +_ZN4cppu34OMultiTypeInterfaceContainerHelperD2Ev; +_ZN4cppu35WeakAggComponentImplHelper_getTypesEPNS_10class_dataE; +_ZN4cppu35WeakAggComponentImplHelper_queryAggERKN3com3sun4star3uno4TypeEPNS_10class_dataEPvPNS_30WeakAggComponentImplHelperBaseE; +_ZN4cppu39OMultiTypeInterfaceContainerHelperInt3212addInterfaceERKlRKN3com3sun4star3uno9ReferenceINS6_10XInterfaceEEE; +_ZN4cppu39OMultiTypeInterfaceContainerHelperInt3215disposeAndClearERKN3com3sun4star4lang11EventObjectE; +_ZN4cppu39OMultiTypeInterfaceContainerHelperInt3215removeInterfaceERKlRKN3com3sun4star3uno9ReferenceINS6_10XInterfaceEEE; +_ZN4cppu39OMultiTypeInterfaceContainerHelperInt325clearEv; +_ZN4cppu39OMultiTypeInterfaceContainerHelperInt32C1ERN3osl5MutexE; +_ZN4cppu39OMultiTypeInterfaceContainerHelperInt32C2ERN3osl5MutexE; +_ZN4cppu39OMultiTypeInterfaceContainerHelperInt32D1Ev; +_ZN4cppu39OMultiTypeInterfaceContainerHelperInt32D2Ev; +_ZN4cppu40defaultBootstrap_InitialComponentContextERKN3rtl8OUStringE; +_ZN4cppu40defaultBootstrap_InitialComponentContextEv; +_ZN4cppu9ClassData15writeTypeOffsetERKN3com3sun4star3uno4TypeEl; +_ZN4cppu9ClassData16initTypeProviderEv; +_ZN4cppu9ClassData19getImplementationIdEv; +_ZN4cppu9ClassData5queryERKN3com3sun4star3uno4TypeEPNS3_4lang13XTypeProviderE; +_ZN4cppu9ClassData8getTypesEv; +_ZNK3com3sun4star3uno19WeakReferenceHelper3getEv; +_ZNK4cppu17OImplementationId19getImplementationIdEv; +_ZNK4cppu20OPropertyArrayHelper8getCountEv; +_ZNK4cppu25OInterfaceContainerHelper11getElementsEv; +_ZNK4cppu25OInterfaceContainerHelper9getLengthEv; +_ZNK4cppu34OMultiTypeInterfaceContainerHelper12getContainerERKN3com3sun4star3uno4TypeE; +_ZNK4cppu34OMultiTypeInterfaceContainerHelper17getContainedTypesEv; +_ZNK4cppu39OMultiTypeInterfaceContainerHelperInt3212getContainerERKl; +_ZNK4cppu39OMultiTypeInterfaceContainerHelperInt3217getContainedTypesEv; +_ZTVN4cppu11OWeakObjectE; +_ZTVN4cppu14OWeakAggObjectE; +_ZTVN4cppu16OComponentHelperE; +_ZTVN4cppu18OPropertySetHelperE; +_ZTVN4cppu20IPropertyArrayHelperE; +_ZTVN4cppu20OPropertyArrayHelperE; +_ZTVN4cppu27WeakComponentImplHelperBaseE; +_ZTVN4cppu30WeakAggComponentImplHelperBaseE; +component_getDescriptionFunc; +_ZN4cppu20OPropertyArrayHelperD0Ev; +_ZN4cppu20OPropertyArrayHelperD1Ev; +_ZThn16_N4cppu14OWeakAggObject12setDelegatorERKN3com3sun4star3uno9ReferenceINS4_10XInterfaceEEE; +_ZThn16_N4cppu14OWeakAggObject14queryInterfaceERKN3com3sun4star3uno4TypeE; +_ZThn16_N4cppu14OWeakAggObject16queryAggregationERKN3com3sun4star3uno4TypeE; +_ZThn16_N4cppu14OWeakAggObject7acquireEv; +_ZThn16_N4cppu14OWeakAggObject7releaseEv; +_ZThn16_N4cppu16OComponentHelper14queryInterfaceERKN3com3sun4star3uno4TypeE; +_ZThn16_N4cppu16OComponentHelper16queryAggregationERKN3com3sun4star3uno4TypeE; +_ZThn16_N4cppu16OComponentHelper7acquireEv; +_ZThn16_N4cppu16OComponentHelper7releaseEv; +_ZThn16_N4cppu27WeakComponentImplHelperBase14queryInterfaceERKN3com3sun4star3uno4TypeE; +_ZThn16_N4cppu27WeakComponentImplHelperBase16addEventListenerERKN3com3sun4star3uno9ReferenceINS3_4lang14XEventListenerEEE; +_ZThn16_N4cppu27WeakComponentImplHelperBase19removeEventListenerERKN3com3sun4star3uno9ReferenceINS3_4lang14XEventListenerEEE; +_ZThn16_N4cppu27WeakComponentImplHelperBase7acquireEv; +_ZThn16_N4cppu27WeakComponentImplHelperBase7disposeEv; +_ZThn16_N4cppu27WeakComponentImplHelperBase7releaseEv; +_ZThn16_N4cppu30WeakAggComponentImplHelperBase14queryInterfaceERKN3com3sun4star3uno4TypeE; +_ZThn16_N4cppu30WeakAggComponentImplHelperBase16queryAggregationERKN3com3sun4star3uno4TypeE; +_ZThn16_N4cppu30WeakAggComponentImplHelperBase7acquireEv; +_ZThn16_N4cppu30WeakAggComponentImplHelperBase7releaseEv; +_ZThn24_N4cppu16OComponentHelper14queryInterfaceERKN3com3sun4star3uno4TypeE; +_ZThn24_N4cppu16OComponentHelper7acquireEv; +_ZThn24_N4cppu16OComponentHelper7releaseEv; +_ZThn24_N4cppu16OComponentHelper8getTypesEv; +_ZThn24_N4cppu30WeakAggComponentImplHelperBase14queryInterfaceERKN3com3sun4star3uno4TypeE; +_ZThn24_N4cppu30WeakAggComponentImplHelperBase16addEventListenerERKN3com3sun4star3uno9ReferenceINS3_4lang14XEventListenerEEE; +_ZThn24_N4cppu30WeakAggComponentImplHelperBase19removeEventListenerERKN3com3sun4star3uno9ReferenceINS3_4lang14XEventListenerEEE; +_ZThn24_N4cppu30WeakAggComponentImplHelperBase7acquireEv; +_ZThn24_N4cppu30WeakAggComponentImplHelperBase7disposeEv; +_ZThn24_N4cppu30WeakAggComponentImplHelperBase7releaseEv; +_ZThn28_N4cppu16OComponentHelper14queryInterfaceERKN3com3sun4star3uno4TypeE; +_ZThn28_N4cppu16OComponentHelper16addEventListenerERKN3com3sun4star3uno9ReferenceINS3_4lang14XEventListenerEEE; +_ZThn28_N4cppu16OComponentHelper19removeEventListenerERKN3com3sun4star3uno9ReferenceINS3_4lang14XEventListenerEEE; +_ZThn28_N4cppu16OComponentHelper7acquireEv; +_ZThn28_N4cppu16OComponentHelper7disposeEv; +_ZThn28_N4cppu16OComponentHelper7releaseEv; +_ZThn4_N4cppu18OPropertySetHelper14queryInterfaceERKN3com3sun4star3uno4TypeE; +_ZThn4_N4cppu18OPropertySetHelper20getFastPropertyValueEl; +_ZThn4_N4cppu18OPropertySetHelper20setFastPropertyValueElRKN3com3sun4star3uno3AnyE; +_ZThn8_N4cppu18OPropertySetHelper14queryInterfaceERKN3com3sun4star3uno4TypeE; +_ZThn8_N4cppu18OPropertySetHelper16getPropertyValueERKN3rtl8OUStringE; +_ZThn8_N4cppu18OPropertySetHelper16setPropertyValueERKN3rtl8OUStringERKN3com3sun4star3uno3AnyE; +_ZThn8_N4cppu18OPropertySetHelper25addPropertyChangeListenerERKN3rtl8OUStringERKN3com3sun4star3uno9ReferenceINS7_5beans23XPropertyChangeListenerEEE; +_ZThn8_N4cppu18OPropertySetHelper25addVetoableChangeListenerERKN3rtl8OUStringERKN3com3sun4star3uno9ReferenceINS7_5beans23XVetoableChangeListenerEEE; +_ZThn8_N4cppu18OPropertySetHelper28removePropertyChangeListenerERKN3rtl8OUStringERKN3com3sun4star3uno9ReferenceINS7_5beans23XPropertyChangeListenerEEE; +_ZThn8_N4cppu18OPropertySetHelper28removeVetoableChangeListenerERKN3rtl8OUStringERKN3com3sun4star3uno9ReferenceINS7_5beans23XVetoableChangeListenerEEE; + +_ZN4cppu13AccessControl19checkFilePermissionERKN3rtl8OUStringES4_; +_ZN4cppu13AccessControl21checkSocketPermissionERKN3rtl8OUStringES4_; +_ZN4cppu13AccessControl22checkRuntimePermissionERKN3rtl8OUStringE; +_ZN4cppu13AccessControlC1ERKN3com3sun4star3uno9ReferenceINS3_8security17XAccessControllerEEE; +_ZN4cppu13AccessControlC2ERKN3com3sun4star3uno9ReferenceINS3_8security17XAccessControllerEEE; +_ZN4cppu13AccessControlC1ERKN3com3sun4star3uno9ReferenceINS4_17XComponentContextEEE; +_ZN4cppu13AccessControlC2ERKN3com3sun4star3uno9ReferenceINS4_17XComponentContextEEE; +_ZN4cppu13AccessControlC1ERKS0_; +_ZN4cppu13AccessControlC2ERKS0_; + +_ZN4cppu16UnoUrlDescriptorC1ERKN3rtl8OUStringE; +_ZN4cppu16UnoUrlDescriptorC1ERKS0_; +_ZN4cppu16UnoUrlDescriptorC2ERKN3rtl8OUStringE; +_ZN4cppu16UnoUrlDescriptorC2ERKS0_; +_ZN4cppu16UnoUrlDescriptorD1Ev; +_ZN4cppu16UnoUrlDescriptorD2Ev; +_ZN4cppu16UnoUrlDescriptoraSERKS0_; +_ZN4cppu6UnoUrlC1ERKN3rtl8OUStringE; +_ZN4cppu6UnoUrlC1ERKS0_; +_ZN4cppu6UnoUrlC2ERKN3rtl8OUStringE; +_ZN4cppu6UnoUrlC2ERKS0_; +_ZN4cppu6UnoUrlD1Ev; +_ZN4cppu6UnoUrlD2Ev; +_ZN4cppu6UnoUrlaSERKS0_; +_ZNK4cppu16UnoUrlDescriptor12getParameterERKN3rtl8OUStringE; +_ZNK4cppu16UnoUrlDescriptor12hasParameterERKN3rtl8OUStringE; +_ZNK4cppu16UnoUrlDescriptor13getDescriptorEv; +_ZNK4cppu16UnoUrlDescriptor7getNameEv; +_ZNK4cppu6UnoUrl11getProtocolEv; +_ZNK4cppu6UnoUrl13getConnectionEv; +_ZNK4cppu6UnoUrl13getObjectNameEv; + + local: + *; +}; + +UDK_3.1 { + global: + _ZN4cppu18getCaughtExceptionEv; + + _ZN4cppu18OPropertySetHelperC1ERNS_19OBroadcastHelperVarINS_34OMultiTypeInterfaceContainerHelperEN3com3sun4star3uno4TypeEEEb; + _ZN4cppu18OPropertySetHelperC2ERNS_19OBroadcastHelperVarINS_34OMultiTypeInterfaceContainerHelperEN3com3sun4star3uno4TypeEEEb; + + _ZN4cppu9bootstrapEv; + _ZN4cppu18BootstrapExceptionC1Ev; + _ZN4cppu18BootstrapExceptionC2Ev; + _ZN4cppu18BootstrapExceptionC1ERKN3rtl8OUStringE; + _ZN4cppu18BootstrapExceptionC2ERKN3rtl8OUStringE; + _ZN4cppu18BootstrapExceptionC1ERKS0_; + _ZN4cppu18BootstrapExceptionC2ERKS0_; + _ZN4cppu18BootstrapExceptionD0Ev; + _ZN4cppu18BootstrapExceptionD1Ev; + _ZN4cppu18BootstrapExceptionD2Ev; + _ZN4cppu18BootstrapExceptionaSERKS0_; + _ZNK4cppu18BootstrapException10getMessageEv; + # _ZTIN4cppu18BootstrapExceptionE; + # _ZTSN4cppu18BootstrapExceptionE; +} UDK_3_0_0; + +UDK_3.2 { + global: + _ZN4cppu20PropertySetMixinImpl10prepareSetERKN3rtl8OUStringERKN3com3sun4star3uno3AnyESB_PNS0_14BoundListenersE; + _ZN4cppu20PropertySetMixinImpl14BoundListenersC1Ev; + _ZN4cppu20PropertySetMixinImpl14BoundListenersC2Ev; + _ZN4cppu20PropertySetMixinImpl14BoundListenersD1Ev; + _ZN4cppu20PropertySetMixinImpl14BoundListenersD2Ev; + _ZN4cppu20PropertySetMixinImpl14queryInterfaceERKN3com3sun4star3uno4TypeE; + _ZN4cppu20PropertySetMixinImpl16getPropertyValueERKN3rtl8OUStringE; + _ZN4cppu20PropertySetMixinImpl16setPropertyValueERKN3rtl8OUStringERKN3com3sun4star3uno3AnyE; + _ZN4cppu20PropertySetMixinImpl17getPropertyValuesEv; + _ZN4cppu20PropertySetMixinImpl17setPropertyValuesERKN3com3sun4star3uno8SequenceINS3_5beans13PropertyValueEEE; + _ZN4cppu20PropertySetMixinImpl18getPropertySetInfoEv; + _ZN4cppu20PropertySetMixinImpl20getFastPropertyValueEl; + _ZN4cppu20PropertySetMixinImpl20setFastPropertyValueElRKN3com3sun4star3uno3AnyE; + _ZN4cppu20PropertySetMixinImpl25addPropertyChangeListenerERKN3rtl8OUStringERKN3com3sun4star3uno9ReferenceINS7_5beans23XPropertyChangeListenerEEE; + _ZN4cppu20PropertySetMixinImpl25addVetoableChangeListenerERKN3rtl8OUStringERKN3com3sun4star3uno9ReferenceINS7_5beans23XVetoableChangeListenerEEE; + _ZN4cppu20PropertySetMixinImpl28removePropertyChangeListenerERKN3rtl8OUStringERKN3com3sun4star3uno9ReferenceINS7_5beans23XPropertyChangeListenerEEE; + _ZN4cppu20PropertySetMixinImpl28removeVetoableChangeListenerERKN3rtl8OUStringERKN3com3sun4star3uno9ReferenceINS7_5beans23XVetoableChangeListenerEEE; + _ZN4cppu20PropertySetMixinImpl7disposeEv; + _ZN4cppu20PropertySetMixinImplC1ERKN3com3sun4star3uno9ReferenceINS4_17XComponentContextEEENS0_10ImplementsERKNS4_8SequenceIN3rtl8OUStringEEERKNS4_4TypeE; + _ZN4cppu20PropertySetMixinImplC2ERKN3com3sun4star3uno9ReferenceINS4_17XComponentContextEEENS0_10ImplementsERKNS4_8SequenceIN3rtl8OUStringEEERKNS4_4TypeE; + _ZN4cppu20PropertySetMixinImplD1Ev; + _ZN4cppu20PropertySetMixinImplD2Ev; + _ZNK4cppu20PropertySetMixinImpl14BoundListeners6notifyEv; + _ZThn4_N4cppu20PropertySetMixinImpl14queryInterfaceERKN3com3sun4star3uno4TypeE; + _ZThn4_N4cppu20PropertySetMixinImpl20getFastPropertyValueEl; + _ZThn4_N4cppu20PropertySetMixinImpl20setFastPropertyValueElRKN3com3sun4star3uno3AnyE; + _ZThn8_N4cppu20PropertySetMixinImpl14queryInterfaceERKN3com3sun4star3uno4TypeE; + _ZThn8_N4cppu20PropertySetMixinImpl17getPropertyValuesEv; + _ZThn8_N4cppu20PropertySetMixinImpl17setPropertyValuesERKN3com3sun4star3uno8SequenceINS3_5beans13PropertyValueEEE; +} UDK_3.1; + +UDK_3.3 { # OOo 2.3 + global: + _ZN4cppu18OPropertySetHelper8getTypesEv; +} UDK_3.2; + +UDK_3.4 { # OOo 2.4 + global: + _ZN4cppu19bootstrap_expandUriERKN3rtl8OUStringE; # rtl::OUString cppu::bootstrap_expandUri(rtl::OUString const &) +} UDK_3.3; + +UDK_3.5 { # OOo 3.0 + global: + _ZN4cppu18OPropertySetHelperC1ERNS_19OBroadcastHelperVarINS_34OMultiTypeInterfaceContainerHelperEN3com3sun4star3uno4TypeEEEPNS_22IEventNotificationHookEb; + _ZN4cppu18OPropertySetHelperC2ERNS_19OBroadcastHelperVarINS_34OMultiTypeInterfaceContainerHelperEN3com3sun4star3uno4TypeEEEPNS_22IEventNotificationHookEb; + _ZN4cppu28createOneInstanceComponentFactoryEPFN3com3sun4star3uno9ReferenceINS3_10XInterfaceEEERKNS4_INS3_17XComponentContextEEEERKN3rtl8OUStringERKNS3_8SequenceISE_EEP16_rtl_ModuleCount; +} UDK_3.4; diff --git a/cppuhelper/source/implbase.cxx b/cppuhelper/source/implbase.cxx new file mode 100644 index 000000000000..3765dbaa12c7 --- /dev/null +++ b/cppuhelper/source/implbase.cxx @@ -0,0 +1,474 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_cppuhelper.hxx" +#include <cppuhelper/implbase.hxx> +#include <cppuhelper/compbase.hxx> +#include <osl/diagnose.h> +#include <rtl/uuid.h> + +#include <com/sun/star/lang/XComponent.hpp> +#include "com/sun/star/uno/RuntimeException.hpp" + +using namespace ::osl; +using namespace ::rtl; +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; + +namespace cppu +{ +//================================================================================================== +Mutex & SAL_CALL getImplHelperInitMutex(void) SAL_THROW( () ) +{ + static Mutex * s_pMutex = 0; + if (! s_pMutex) + { + MutexGuard aGuard( Mutex::getGlobalMutex() ); + if (! s_pMutex) + { + static Mutex s_aMutex; + s_pMutex = & s_aMutex; + } + } + return * s_pMutex; +} + +// ClassDataBase +//__________________________________________________________________________________________________ +ClassDataBase::ClassDataBase() SAL_THROW( () ) + : bOffsetsInit( sal_False ) + , nType2Offset( 0 ) + , nClassCode( 0 ) + , pTypes( 0 ) + , pId( 0 ) +{ +} +//__________________________________________________________________________________________________ +ClassDataBase::ClassDataBase( sal_Int32 nClassCode_ ) SAL_THROW( () ) + : bOffsetsInit( sal_False ) + , nType2Offset( 0 ) + , nClassCode( nClassCode_ ) + , pTypes( 0 ) + , pId( 0 ) +{ +} +//__________________________________________________________________________________________________ +ClassDataBase::~ClassDataBase() SAL_THROW( () ) +{ + delete pTypes; + delete pId; + + for ( sal_Int32 nPos = nType2Offset; nPos--; ) + { + typelib_typedescription_release( + (typelib_TypeDescription *)((ClassData *)this)->arType2Offset[nPos].pTD ); + } +} + +// ClassData +//__________________________________________________________________________________________________ +void ClassData::writeTypeOffset( const Type & rType, sal_Int32 nOffset ) SAL_THROW( () ) +{ + arType2Offset[nType2Offset].nOffset = nOffset; + + arType2Offset[nType2Offset].pTD = 0; + typelib_typedescriptionreference_getDescription( + (typelib_TypeDescription **)&arType2Offset[nType2Offset].pTD, rType.getTypeLibType() ); + + if (arType2Offset[nType2Offset].pTD) + ++nType2Offset; +#if OSL_DEBUG_LEVEL > 1 + else + { + OString msg( "### cannot get type description for " ); + msg += OUStringToOString( rType.getTypeName(), RTL_TEXTENCODING_ASCII_US ); + OSL_ENSURE( sal_False, msg.getStr() ); + } +#endif +} +//__________________________________________________________________________________________________ +void ClassData::initTypeProvider() SAL_THROW( () ) +{ + ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + if (! pTypes) + { + // create id + pId = new Sequence< sal_Int8 >( 16 ); + rtl_createUuid( (sal_uInt8 *)pId->getArray(), 0, sal_True ); + + // collect types + Sequence< Type > * types = new Sequence< Type >( + nType2Offset + 1 + (nClassCode == 4 ? 2 : nClassCode) ); + Type * pTypeAr = types->getArray(); + + // given types + sal_Int32 nPos = nType2Offset; + while (nPos--) + pTypeAr[nPos] = ((typelib_TypeDescription *)arType2Offset[nPos].pTD)->pWeakRef; + + // XTypeProvider + pTypeAr[nType2Offset] = ::getCppuType( (const Reference< lang::XTypeProvider > *)0 ); + + // class code extra types: [[XComponent,] XWeak[, XAggregation]] + switch (nClassCode) + { + case 4: + pTypeAr[nType2Offset +2] = ::getCppuType( (const Reference< lang::XComponent > *)0 ); + pTypeAr[nType2Offset +1] = ::getCppuType( (const Reference< XWeak > *)0 ); + break; + case 3: + pTypeAr[nType2Offset +3] = ::getCppuType( (const Reference< lang::XComponent > *)0 ); + case 2: + pTypeAr[nType2Offset +2] = ::getCppuType( (const Reference< XAggregation > *)0 ); + case 1: + pTypeAr[nType2Offset +1] = ::getCppuType( (const Reference< XWeak > *)0 ); + } + + pTypes = types; + } +} +//__________________________________________________________________________________________________ +Sequence< Type > ClassData::getTypes() SAL_THROW( () ) +{ + if (! pTypes) + initTypeProvider(); + return *pTypes; +} +//__________________________________________________________________________________________________ +Sequence< sal_Int8 > ClassData::getImplementationId() SAL_THROW( () ) +{ + if (! pTypes) + initTypeProvider(); + return *pId; +} + +//-------------------------------------------------------------------------------------------------- +static inline sal_Bool td_equals( + typelib_TypeDescription * pTD, typelib_TypeDescriptionReference * pType ) + SAL_THROW( () ) +{ + return (pTD->pWeakRef == pType || + (pTD->pTypeName->length == pType->pTypeName->length && + rtl_ustr_compare( pTD->pTypeName->buffer, pType->pTypeName->buffer ) == 0)); +} +//__________________________________________________________________________________________________ +Any ClassData::query( const Type & rType, lang::XTypeProvider * pBase ) SAL_THROW( () ) +{ + if (rType == ::getCppuType( (const Reference< XInterface > *)0 )) + return Any( &pBase, ::getCppuType( (const Reference< XInterface > *)0 ) ); + for ( sal_Int32 nPos = 0; nPos < nType2Offset; ++nPos ) + { + const Type_Offset & rTO = arType2Offset[nPos]; + typelib_InterfaceTypeDescription * pTD = rTO.pTD; + while (pTD) + { + if (td_equals( (typelib_TypeDescription *)pTD, + *(typelib_TypeDescriptionReference **)&rType )) + { + void * pInterface = (char *)pBase + rTO.nOffset; + return Any( &pInterface, (typelib_TypeDescription *)pTD ); + } + pTD = pTD->pBaseTypeDescription; + } + } + if (rType == ::getCppuType( (const Reference< lang::XTypeProvider > *)0 )) + return Any( &pBase, ::getCppuType( (const Reference< lang::XTypeProvider > *)0 ) ); + + return Any(); +} + +//################################################################################################## +//################################################################################################## +//################################################################################################## + +// WeakComponentImplHelperBase +//__________________________________________________________________________________________________ +WeakComponentImplHelperBase::WeakComponentImplHelperBase( Mutex & rMutex ) + SAL_THROW( () ) + : rBHelper( rMutex ) +{ +} +//__________________________________________________________________________________________________ +WeakComponentImplHelperBase::~WeakComponentImplHelperBase() + SAL_THROW( () ) +{ +} +//__________________________________________________________________________________________________ +void WeakComponentImplHelperBase::disposing() +{ +} +//__________________________________________________________________________________________________ +Any WeakComponentImplHelperBase::queryInterface( Type const & rType ) + throw (RuntimeException) +{ + if (rType == ::getCppuType( (Reference< lang::XComponent > const *)0 )) + { + void * p = static_cast< lang::XComponent * >( this ); + return Any( &p, rType ); + } + return OWeakObject::queryInterface( rType ); +} +//__________________________________________________________________________________________________ +void WeakComponentImplHelperBase::acquire() + throw () +{ + OWeakObject::acquire(); +} +//__________________________________________________________________________________________________ +void WeakComponentImplHelperBase::release() + throw () +{ + if (osl_decrementInterlockedCount( &m_refCount ) == 0) { + // ensure no other references are created, via the weak connection point, from now on + disposeWeakConnectionPoint(); + // restore reference count: + osl_incrementInterlockedCount( &m_refCount ); + if (! rBHelper.bDisposed) { + try { + dispose(); + } + catch (RuntimeException const& exc) { // don't break throw () + OSL_ENSURE( + false, OUStringToOString( + exc.Message, RTL_TEXTENCODING_ASCII_US ).getStr() ); + static_cast<void>(exc); + } + OSL_ASSERT( rBHelper.bDisposed ); + } + OWeakObject::release(); + } +} +//__________________________________________________________________________________________________ +void WeakComponentImplHelperBase::dispose() + throw (RuntimeException) +{ + ClearableMutexGuard aGuard( rBHelper.rMutex ); + if (!rBHelper.bDisposed && !rBHelper.bInDispose) + { + rBHelper.bInDispose = sal_True; + aGuard.clear(); + try + { + // side effect: keeping a reference to this + lang::EventObject aEvt( static_cast< OWeakObject * >( this ) ); + try + { + rBHelper.aLC.disposeAndClear( aEvt ); + disposing(); + } + catch (...) + { + MutexGuard aGuard2( rBHelper.rMutex ); + // bDisposed and bInDispose must be set in this order: + rBHelper.bDisposed = sal_True; + rBHelper.bInDispose = sal_False; + throw; + } + MutexGuard aGuard2( rBHelper.rMutex ); + // bDisposed and bInDispose must be set in this order: + rBHelper.bDisposed = sal_True; + rBHelper.bInDispose = sal_False; + } + catch (RuntimeException &) + { + throw; + } + catch (Exception & exc) + { + throw RuntimeException( + OUString( RTL_CONSTASCII_USTRINGPARAM( + "unexpected UNO exception caught: ") ) + + exc.Message, Reference< XInterface >() ); + } + } +} +//__________________________________________________________________________________________________ +void WeakComponentImplHelperBase::addEventListener( + Reference< lang::XEventListener > const & xListener ) + throw (RuntimeException) +{ + ClearableMutexGuard aGuard( rBHelper.rMutex ); + if (rBHelper.bDisposed || rBHelper.bInDispose) + { + aGuard.clear(); + lang::EventObject aEvt( static_cast< OWeakObject * >( this ) ); + xListener->disposing( aEvt ); + } + else + { + rBHelper.addListener( ::getCppuType( &xListener ), xListener ); + } +} +//__________________________________________________________________________________________________ +void WeakComponentImplHelperBase::removeEventListener( + Reference< lang::XEventListener > const & xListener ) + throw (RuntimeException) +{ + rBHelper.removeListener( ::getCppuType( &xListener ), xListener ); +} + +// WeakAggComponentImplHelperBase +//__________________________________________________________________________________________________ +WeakAggComponentImplHelperBase::WeakAggComponentImplHelperBase( Mutex & rMutex ) + SAL_THROW( () ) + : rBHelper( rMutex ) +{ +} +//__________________________________________________________________________________________________ +WeakAggComponentImplHelperBase::~WeakAggComponentImplHelperBase() + SAL_THROW( () ) +{ +} +//__________________________________________________________________________________________________ +void WeakAggComponentImplHelperBase::disposing() +{ +} +//__________________________________________________________________________________________________ +Any WeakAggComponentImplHelperBase::queryInterface( Type const & rType ) + throw (RuntimeException) +{ + return OWeakAggObject::queryInterface( rType ); +} +//__________________________________________________________________________________________________ +Any WeakAggComponentImplHelperBase::queryAggregation( Type const & rType ) + throw (RuntimeException) +{ + if (rType == ::getCppuType( (Reference< lang::XComponent > const *)0 )) + { + void * p = static_cast< lang::XComponent * >( this ); + return Any( &p, rType ); + } + return OWeakAggObject::queryAggregation( rType ); +} +//__________________________________________________________________________________________________ +void WeakAggComponentImplHelperBase::acquire() + throw () +{ + OWeakAggObject::acquire(); +} +//__________________________________________________________________________________________________ +void WeakAggComponentImplHelperBase::release() + throw () +{ + Reference<XInterface> const xDelegator_(xDelegator); + if (xDelegator_.is()) { + OWeakAggObject::release(); + } + else if (osl_decrementInterlockedCount( &m_refCount ) == 0) { + // ensure no other references are created, via the weak connection point, from now on + disposeWeakConnectionPoint(); + // restore reference count: + osl_incrementInterlockedCount( &m_refCount ); + if (! rBHelper.bDisposed) { + try { + dispose(); + } + catch (RuntimeException const& exc) { // don't break throw () + OSL_ENSURE( + false, OUStringToOString( + exc.Message, RTL_TEXTENCODING_ASCII_US ).getStr() ); + static_cast<void>(exc); + } + OSL_ASSERT( rBHelper.bDisposed ); + } + OWeakAggObject::release(); + } +} +//__________________________________________________________________________________________________ +void WeakAggComponentImplHelperBase::dispose() + throw (RuntimeException) +{ + ClearableMutexGuard aGuard( rBHelper.rMutex ); + if (!rBHelper.bDisposed && !rBHelper.bInDispose) + { + rBHelper.bInDispose = sal_True; + aGuard.clear(); + try + { + // side effect: keeping a reference to this + lang::EventObject aEvt( static_cast< OWeakObject * >( this ) ); + try + { + rBHelper.aLC.disposeAndClear( aEvt ); + disposing(); + } + catch (...) + { + MutexGuard aGuard2( rBHelper.rMutex ); + // bDisposed and bInDispose must be set in this order: + rBHelper.bDisposed = sal_True; + rBHelper.bInDispose = sal_False; + throw; + } + MutexGuard aGuard2( rBHelper.rMutex ); + // bDisposed and bInDispose must be set in this order: + rBHelper.bDisposed = sal_True; + rBHelper.bInDispose = sal_False; + } + catch (RuntimeException &) + { + throw; + } + catch (Exception & exc) + { + throw RuntimeException( + OUString( RTL_CONSTASCII_USTRINGPARAM( + "unexpected UNO exception caught: ") ) + + exc.Message, Reference< XInterface >() ); + } + } +} +//__________________________________________________________________________________________________ +void WeakAggComponentImplHelperBase::addEventListener( + Reference< lang::XEventListener > const & xListener ) + throw (RuntimeException) +{ + ClearableMutexGuard aGuard( rBHelper.rMutex ); + if (rBHelper.bDisposed || rBHelper.bInDispose) + { + aGuard.clear(); + lang::EventObject aEvt( static_cast< OWeakObject * >( this ) ); + xListener->disposing( aEvt ); + } + else + { + rBHelper.addListener( ::getCppuType( &xListener ), xListener ); + } +} +//__________________________________________________________________________________________________ +void WeakAggComponentImplHelperBase::removeEventListener( + Reference< lang::XEventListener > const & xListener ) + throw (RuntimeException) +{ + rBHelper.removeListener( ::getCppuType( &xListener ), xListener ); +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/source/implbase_ex.cxx b/cppuhelper/source/implbase_ex.cxx new file mode 100644 index 000000000000..01452d81bf90 --- /dev/null +++ b/cppuhelper/source/implbase_ex.cxx @@ -0,0 +1,472 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_cppuhelper.hxx" +#include <sal/alloca.h> + +#include <string.h> +#include <osl/diagnose.h> +#include <rtl/byteseq.hxx> +#include <rtl/ustrbuf.hxx> +#include <rtl/uuid.h> +#include <cppuhelper/compbase_ex.hxx> + +#include "com/sun/star/uno/RuntimeException.hpp" + +using namespace ::cppu; +using namespace ::osl; +using namespace ::rtl; +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; + +namespace cppu +{ + +/** Shared mutex for implementation helper initialization. + Not for public use. +*/ +::osl::Mutex & SAL_CALL getImplHelperInitMutex(void) SAL_THROW( () ); + +//-------------------------------------------------------------------------------------------------- +static inline void checkInterface( Type const & rType ) + SAL_THROW( (RuntimeException) ) +{ + if (TypeClass_INTERFACE != rType.getTypeClass()) + { + OUStringBuffer buf( 64 ); + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("querying for interface \"") ); + buf.append( rType.getTypeName() ); + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("\": no interface type!") ); + OUString msg( buf.makeStringAndClear() ); +#if OSL_DEBUG_LEVEL > 0 + OString str( OUStringToOString( msg, RTL_TEXTENCODING_ASCII_US ) ); + OSL_ENSURE( 0, str.getStr() ); +#endif + throw RuntimeException( msg, Reference< XInterface >() ); + } +} +//-------------------------------------------------------------------------------------------------- +static inline bool isXInterface( rtl_uString * pStr ) SAL_THROW( () ) +{ + return (((OUString const *)&pStr)->equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("com.sun.star.uno.XInterface") ) != sal_False); +} +//-------------------------------------------------------------------------------------------------- +static inline void * makeInterface( sal_IntPtr nOffset, void * that ) SAL_THROW( () ) +{ + return (((char *)that) + nOffset); +} +//-------------------------------------------------------------------------------------------------- +static inline bool __td_equals( + typelib_TypeDescriptionReference const * pTDR1, + typelib_TypeDescriptionReference const * pTDR2 ) + SAL_THROW( () ) +{ + return ((pTDR1 == pTDR2) || + ((OUString const *)&pTDR1->pTypeName)->equals( *(OUString const *)&pTDR2->pTypeName ) != sal_False); +} +//-------------------------------------------------------------------------------------------------- +static inline type_entry * __getTypeEntries( class_data * cd ) + SAL_THROW( (RuntimeException) ) +{ + type_entry * pEntries = cd->m_typeEntries; + if (! cd->m_storedTypeRefs) // not inited? + { + MutexGuard guard( getImplHelperInitMutex() ); + if (! cd->m_storedTypeRefs) // not inited? + { + // get all types + for ( sal_Int32 n = cd->m_nTypes; n--; ) + { + type_entry * pEntry = &pEntries[ n ]; + Type const & rType = (*pEntry->m_type.getCppuType)( 0 ); + OSL_ENSURE( rType.getTypeClass() == TypeClass_INTERFACE, "### wrong helper init: expected interface!" ); + OSL_ENSURE( ! isXInterface( rType.getTypeLibType()->pTypeName ), "### want to implement XInterface: template argument is XInterface?!?!?!" ); + if (rType.getTypeClass() != TypeClass_INTERFACE) + { + OUStringBuffer buf( 48 ); + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("type \"") ); + buf.append( rType.getTypeName() ); + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("\" is no interface type!") ); + OUString msg( buf.makeStringAndClear() ); +#if OSL_DEBUG_LEVEL > 0 + OString str( OUStringToOString( msg, RTL_TEXTENCODING_ASCII_US ) ); + OSL_ENSURE( 0, str.getStr() ); +#endif + throw RuntimeException( msg, Reference< XInterface >() ); + } + // ref is statically held by getCppuType() + pEntry->m_type.typeRef = rType.getTypeLibType(); + } + cd->m_storedTypeRefs = sal_True; + } + } + return pEntries; +} +//-------------------------------------------------------------------------------------------------- +static inline void __fillTypes( Type * types, class_data * cd ) + SAL_THROW( (RuntimeException) ) +{ + type_entry * pEntries = __getTypeEntries( cd ); + for ( sal_Int32 n = cd->m_nTypes; n--; ) + { + types[ n ] = pEntries[ n ].m_type.typeRef; + } +} +//-------------------------------------------------------------------------------------------------- +namespace { + +bool recursivelyFindType( + typelib_TypeDescriptionReference const * demandedType, + typelib_InterfaceTypeDescription const * type, sal_IntPtr * offset) +{ + // This code assumes that the vtables of a multiple-inheritance class (the + // offset amount by which to adjust the this pointer) follow one another in + // the object layout, and that they contain slots for the inherited classes + // in a specifc order. In theory, that need not hold for any given + // platform; in practice, it seems to work well on all supported platforms: + next: + for (sal_Int32 i = 0; i < type->nBaseTypes; ++i) { + if (i > 0) { + *offset += sizeof (void *); + } + typelib_InterfaceTypeDescription const * base = type->ppBaseTypes[i]; + // ignore XInterface: + if (base->nBaseTypes > 0) { + if (__td_equals( + reinterpret_cast< + typelib_TypeDescriptionReference const * >(base), + demandedType)) + { + return true; + } + // Profiling showed that it is important to speed up the common case + // of only one base: + if (type->nBaseTypes == 1) { + type = base; + goto next; + } + if (recursivelyFindType(demandedType, base, offset)) { + return true; + } + } + } + return false; +} + +} + +static inline void * __queryDeepNoXInterface( + typelib_TypeDescriptionReference * pDemandedTDR, class_data * cd, void * that ) + SAL_THROW( (RuntimeException) ) +{ + type_entry * pEntries = __getTypeEntries( cd ); + sal_Int32 nTypes = cd->m_nTypes; + sal_Int32 n; + + // try top interfaces without getting td + for ( n = 0; n < nTypes; ++n ) + { + if (__td_equals( pEntries[ n ].m_type.typeRef, pDemandedTDR )) + { + return makeInterface( pEntries[ n ].m_offset, that ); + } + } + // query deep getting td + for ( n = 0; n < nTypes; ++n ) + { + typelib_TypeDescription * pTD = 0; + TYPELIB_DANGER_GET( &pTD, pEntries[ n ].m_type.typeRef ); + if (pTD) + { + // exclude top (already tested) and bottom (XInterface) interface + OSL_ENSURE( + reinterpret_cast< typelib_InterfaceTypeDescription * >(pTD)-> + nBaseTypes > 0, + "### want to implement XInterface:" + " template argument is XInterface?!?!?!" ); + sal_IntPtr offset = pEntries[n].m_offset; + bool found = recursivelyFindType( + pDemandedTDR, + reinterpret_cast< typelib_InterfaceTypeDescription * >(pTD), + &offset); + TYPELIB_DANGER_RELEASE( pTD ); + if (found) { + return makeInterface( offset, that ); + } + } + else + { + OUStringBuffer buf( 64 ); + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("cannot get type description for type \"") ); + buf.append( pEntries[ n ].m_type.typeRef->pTypeName ); + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("\"!") ); + OUString msg( buf.makeStringAndClear() ); +#if OSL_DEBUG_LEVEL > 0 + OString str( OUStringToOString( msg, RTL_TEXTENCODING_ASCII_US ) ); + OSL_ENSURE( 0, str.getStr() ); +#endif + throw RuntimeException( msg, Reference< XInterface >() ); + } + } + return 0; +} + +// ImplHelper +//================================================================================================== +Any SAL_CALL ImplHelper_query( + Type const & rType, class_data * cd, void * that ) + SAL_THROW( (RuntimeException) ) +{ + checkInterface( rType ); + typelib_TypeDescriptionReference * pTDR = rType.getTypeLibType(); + + void * p; + // shortcut for XInterface + if (isXInterface( pTDR->pTypeName )) + { + // take first one + p = makeInterface( cd->m_typeEntries[ 0 ].m_offset, that ); + } + else + { + p = __queryDeepNoXInterface( pTDR, cd, that ); + if (! p) + { + return Any(); + } + } + return Any( &p, pTDR ); +} +//================================================================================================== +Any SAL_CALL ImplHelper_queryNoXInterface( + Type const & rType, class_data * cd, void * that ) + SAL_THROW( (RuntimeException) ) +{ + checkInterface( rType ); + typelib_TypeDescriptionReference * pTDR = rType.getTypeLibType(); + + void * p = __queryDeepNoXInterface( pTDR, cd, that ); + if (p) + { + return Any( &p, pTDR ); + } + else + { + return Any(); + } +} +//================================================================================================== +Sequence< sal_Int8 > SAL_CALL ImplHelper_getImplementationId( class_data * cd ) + SAL_THROW( (RuntimeException) ) +{ + if (! cd->m_createdId) + { + sal_uInt8 * id = (sal_uInt8 *)alloca( 16 ); + ::rtl_createUuid( (sal_uInt8 *)id, 0, sal_True ); + + MutexGuard guard( getImplHelperInitMutex() ); + if (! cd->m_createdId) + { + memcpy( cd->m_id, id, 16 ); + cd->m_createdId = sal_True; + } + } + + sal_Sequence * seq = 0; + ::rtl_byte_sequence_constructFromArray( &seq, cd->m_id, 16 ); + return Sequence< sal_Int8 >( seq, SAL_NO_ACQUIRE ); +} +//================================================================================================== +Sequence< Type > SAL_CALL ImplHelper_getTypes( + class_data * cd ) + SAL_THROW( (RuntimeException) ) +{ + Sequence< Type > types( cd->m_nTypes ); + Type * pTypes = types.getArray(); + __fillTypes( pTypes, cd ); + return types; +} +//================================================================================================== +Sequence< Type > SAL_CALL ImplInhHelper_getTypes( + class_data * cd, Sequence< Type > const & rAddTypes ) + SAL_THROW( (RuntimeException) ) +{ + sal_Int32 nImplTypes = cd->m_nTypes; + sal_Int32 nAddTypes = rAddTypes.getLength(); + Sequence< Type > types( nImplTypes + nAddTypes ); + Type * pTypes = types.getArray(); + __fillTypes( pTypes, cd ); + // append base types + Type const * pAddTypes = rAddTypes.getConstArray(); + while (nAddTypes--) + { + pTypes[ nImplTypes + nAddTypes ] = pAddTypes[ nAddTypes ]; + } + return types; +} + +// WeakImplHelper +//================================================================================================== +Any SAL_CALL WeakImplHelper_query( + Type const & rType, class_data * cd, void * that, OWeakObject * pBase ) + SAL_THROW( (RuntimeException) ) +{ + checkInterface( rType ); + typelib_TypeDescriptionReference * pTDR = rType.getTypeLibType(); + + // shortcut XInterface to OWeakObject + if (! isXInterface( pTDR->pTypeName )) + { + void * p = __queryDeepNoXInterface( pTDR, cd, that ); + if (p) + { + return Any( &p, pTDR ); + } + } + return pBase->OWeakObject::queryInterface( rType ); +} +//================================================================================================== +Sequence< Type > SAL_CALL WeakImplHelper_getTypes( + class_data * cd ) + SAL_THROW( (RuntimeException) ) +{ + sal_Int32 nTypes = cd->m_nTypes; + Sequence< Type > types( nTypes +1 ); + Type * pTypes = types.getArray(); + __fillTypes( pTypes, cd ); + pTypes[ nTypes ] = ::getCppuType( (Reference< XWeak > const *)0 ); + return types; +} + +// WeakAggImplHelper +//================================================================================================== +Any SAL_CALL WeakAggImplHelper_queryAgg( + Type const & rType, class_data * cd, void * that, OWeakAggObject * pBase ) + SAL_THROW( (RuntimeException) ) +{ + checkInterface( rType ); + typelib_TypeDescriptionReference * pTDR = rType.getTypeLibType(); + + // shortcut XInterface to OWeakAggObject + if (! isXInterface( pTDR->pTypeName )) + { + void * p = __queryDeepNoXInterface( pTDR, cd, that ); + if (p) + { + return Any( &p, pTDR ); + } + } + return pBase->OWeakAggObject::queryAggregation( rType ); +} +//================================================================================================== +Sequence< Type > SAL_CALL WeakAggImplHelper_getTypes( + class_data * cd ) + SAL_THROW( (RuntimeException) ) +{ + sal_Int32 nTypes = cd->m_nTypes; + Sequence< Type > types( nTypes +2 ); + Type * pTypes = types.getArray(); + __fillTypes( pTypes, cd ); + pTypes[ nTypes++ ] = ::getCppuType( (Reference< XWeak > const *)0 ); + pTypes[ nTypes ] = ::getCppuType( (const Reference< XAggregation > *)0 ); + return types; +} + +// WeakComponentImplHelper +//================================================================================================== +Any SAL_CALL WeakComponentImplHelper_query( + Type const & rType, class_data * cd, void * that, WeakComponentImplHelperBase * pBase ) + SAL_THROW( (RuntimeException) ) +{ + checkInterface( rType ); + typelib_TypeDescriptionReference * pTDR = rType.getTypeLibType(); + + // shortcut XInterface to WeakComponentImplHelperBase + if (! isXInterface( pTDR->pTypeName )) + { + void * p = __queryDeepNoXInterface( pTDR, cd, that ); + if (p) + { + return Any( &p, pTDR ); + } + } + return pBase->WeakComponentImplHelperBase::queryInterface( rType ); +} +//================================================================================================== +Sequence< Type > SAL_CALL WeakComponentImplHelper_getTypes( + class_data * cd ) + SAL_THROW( (RuntimeException) ) +{ + sal_Int32 nTypes = cd->m_nTypes; + Sequence< Type > types( nTypes +2 ); + Type * pTypes = types.getArray(); + __fillTypes( pTypes, cd ); + pTypes[ nTypes++ ] = ::getCppuType( (Reference< XWeak > const *)0 ); + pTypes[ nTypes ] = ::getCppuType( (Reference< lang::XComponent > const *)0 ); + return types; +} + +// WeakAggComponentImplHelper +//================================================================================================== +Any SAL_CALL WeakAggComponentImplHelper_queryAgg( + Type const & rType, class_data * cd, void * that, WeakAggComponentImplHelperBase * pBase ) + SAL_THROW( (RuntimeException) ) +{ + checkInterface( rType ); + typelib_TypeDescriptionReference * pTDR = rType.getTypeLibType(); + + // shortcut XInterface to WeakAggComponentImplHelperBase + if (! isXInterface( pTDR->pTypeName )) + { + void * p = __queryDeepNoXInterface( pTDR, cd, that ); + if (p) + { + return Any( &p, pTDR ); + } + } + return pBase->WeakAggComponentImplHelperBase::queryAggregation( rType ); +} +//================================================================================================== +Sequence< Type > SAL_CALL WeakAggComponentImplHelper_getTypes( + class_data * cd ) + SAL_THROW( (RuntimeException) ) +{ + sal_Int32 nTypes = cd->m_nTypes; + Sequence< Type > types( nTypes +3 ); + Type * pTypes = types.getArray(); + __fillTypes( pTypes, cd ); + pTypes[ nTypes++ ] = ::getCppuType( (Reference< XWeak > const *)0 ); + pTypes[ nTypes++ ] = ::getCppuType( (const Reference< XAggregation > *)0 ); + pTypes[ nTypes ] = ::getCppuType( (const Reference< lang::XComponent > *)0 ); + return types; +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/source/implementationentry.cxx b/cppuhelper/source/implementationentry.cxx new file mode 100644 index 000000000000..0c870d8ac54c --- /dev/null +++ b/cppuhelper/source/implementationentry.cxx @@ -0,0 +1,105 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_cppuhelper.hxx" +#include <cppuhelper/implementationentry.hxx> +#include <rtl/ustrbuf.hxx> + +using namespace ::rtl; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::registry; + +namespace cppu { + +sal_Bool component_writeInfoHelper( + void *, void *pRegistryKey , const struct ImplementationEntry entries[] ) +{ + sal_Bool bRet = sal_False; + try + { + if( pRegistryKey ) + { + for( sal_Int32 i = 0; entries[i].create ; i ++ ) + { + OUStringBuffer buf( 124 ); + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("/") ); + buf.append( entries[i].getImplementationName() ); + buf.appendAscii(RTL_CONSTASCII_STRINGPARAM( "/UNO/SERVICES" ) ); + Reference< XRegistryKey > xNewKey( + reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey( buf.makeStringAndClear() ) ); + + Sequence< OUString > seq = entries[i].getSupportedServiceNames(); + const OUString *pArray = seq.getConstArray(); + for ( sal_Int32 nPos = 0 ; nPos < seq.getLength(); nPos ++ ) + xNewKey->createKey( pArray[nPos] ); + } + bRet = sal_True; + } + } + catch ( InvalidRegistryException & ) + { + OSL_ENSURE( sal_False, "### InvalidRegistryException!" ); + } + return bRet; +} + + +void * component_getFactoryHelper( + const sal_Char * pImplName, void *, void *, + const struct ImplementationEntry entries[] ) +{ + + void * pRet = 0; + Reference< XSingleComponentFactory > xFactory; + + for( sal_Int32 i = 0 ; entries[i].create ; i ++ ) + { + OUString implName = entries[i].getImplementationName(); + if( 0 == implName.compareToAscii( pImplName ) ) + { + xFactory = entries[i].createFactory( + entries[i].create, + implName, + entries[i].getSupportedServiceNames(), + entries[i].moduleCounter ); + } + } + + if( xFactory.is() ) + { + xFactory->acquire(); + pRet = xFactory.get(); + } + return pRet; +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/source/interfacecontainer.cxx b/cppuhelper/source/interfacecontainer.cxx new file mode 100644 index 000000000000..672a7f1230cc --- /dev/null +++ b/cppuhelper/source/interfacecontainer.cxx @@ -0,0 +1,730 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_cppuhelper.hxx" + +#include <cppuhelper/interfacecontainer.hxx> +#include <cppuhelper/queryinterface.hxx> +#include <cppuhelper/propshlp.hxx> + +#include <osl/diagnose.h> +#include <osl/mutex.hxx> + +#include <hash_map> + +#include <com/sun/star/lang/XEventListener.hpp> + + +using namespace osl; +using namespace com::sun::star::uno; +using namespace com::sun::star::lang; + +namespace cppu +{ + +//=================================================================== +//=================================================================== +//=================================================================== +/** + * Reallocate the sequence. + */ +static void realloc( Sequence< Reference< XInterface > > & rSeq, sal_Int32 nNewLen ) + SAL_THROW( () ) +{ + rSeq.realloc( nNewLen ); +} + +/** + * Remove an element from an interface sequence. + */ +static void sequenceRemoveElementAt( Sequence< Reference< XInterface > > & rSeq, sal_Int32 index ) + SAL_THROW( () ) +{ + sal_Int32 nNewLen = rSeq.getLength() - 1; + + Sequence< Reference< XInterface > > aDestSeq( rSeq.getLength() - 1 ); + // getArray on a const sequence is faster + const Reference< XInterface > * pSource = ((const Sequence< Reference< XInterface > > &)rSeq).getConstArray(); + Reference< XInterface > * pDest = aDestSeq.getArray(); + sal_Int32 i = 0; + for( ; i < index; i++ ) + pDest[i] = pSource[i]; + for( sal_Int32 j = i ; j < nNewLen; j++ ) + pDest[j] = pSource[j+1]; + rSeq = aDestSeq; +} + + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +#ifdef _MSC_VER +#pragma warning( disable: 4786 ) +#endif + +//=================================================================== +//=================================================================== +//=================================================================== +OInterfaceIteratorHelper::OInterfaceIteratorHelper( OInterfaceContainerHelper & rCont_ ) + SAL_THROW( () ) + : rCont( rCont_ ) +{ + MutexGuard aGuard( rCont.rMutex ); + if( rCont.bInUse ) + // worst case, two iterators at the same time + rCont.copyAndResetInUse(); + bIsList = rCont_.bIsList; + aData = rCont_.aData; + if( bIsList ) + { + rCont.bInUse = sal_True; + nRemain = aData.pAsSequence->getLength(); + } + else if( aData.pAsInterface ) + { + aData.pAsInterface->acquire(); + nRemain = 1; + } + else + nRemain = 0; +} + +OInterfaceIteratorHelper::~OInterfaceIteratorHelper() SAL_THROW( () ) +{ + sal_Bool bShared; + { + MutexGuard aGuard( rCont.rMutex ); + // bResetInUse protect the iterator against recursion + bShared = aData.pAsSequence == rCont.aData.pAsSequence && rCont.bIsList; + if( bShared ) + { + OSL_ENSURE( rCont.bInUse, "OInterfaceContainerHelper must be in use" ); + rCont.bInUse = sal_False; + } + } + + if( !bShared ) + { + if( bIsList ) + // Sequence owned by the iterator + delete aData.pAsSequence; + else if( aData.pAsInterface ) + // Interface is acquired by the iterator + aData.pAsInterface->release(); + } +} + +XInterface * OInterfaceIteratorHelper::next() SAL_THROW( () ) +{ + if( nRemain ) + { + nRemain--; + if( bIsList ) + // typecase to const,so the getArray method is faster + return aData.pAsSequence->getConstArray()[nRemain].get(); + else if( aData.pAsInterface ) + return aData.pAsInterface; + } + // exception + return 0; +} + +void OInterfaceIteratorHelper::remove() SAL_THROW( () ) +{ + if( bIsList ) + { + OSL_ASSERT( nRemain >= 0 && + nRemain < aData.pAsSequence->getLength() ); + XInterface * p = aData.pAsSequence->getConstArray()[nRemain].get(); + rCont.removeInterface( * reinterpret_cast< const Reference< XInterface > * >( &p ) ); + } + else + { + OSL_ASSERT( 0 == nRemain ); + rCont.removeInterface( * reinterpret_cast< const Reference< XInterface > * >(&aData.pAsInterface)); + } +} + +//=================================================================== +//=================================================================== +//=================================================================== + + +OInterfaceContainerHelper::OInterfaceContainerHelper( Mutex & rMutex_ ) SAL_THROW( () ) + : rMutex( rMutex_ ) + , bInUse( sal_False ) + , bIsList( sal_False ) +{ +} + +OInterfaceContainerHelper::~OInterfaceContainerHelper() SAL_THROW( () ) +{ + OSL_ENSURE( !bInUse, "~OInterfaceContainerHelper but is in use" ); + if( bIsList ) + delete aData.pAsSequence; + else if( aData.pAsInterface ) + aData.pAsInterface->release(); +} + +sal_Int32 OInterfaceContainerHelper::getLength() const SAL_THROW( () ) +{ + MutexGuard aGuard( rMutex ); + if( bIsList ) + return aData.pAsSequence->getLength(); + else if( aData.pAsInterface ) + return 1; + return 0; +} + +Sequence< Reference<XInterface> > OInterfaceContainerHelper::getElements() const SAL_THROW( () ) +{ + MutexGuard aGuard( rMutex ); + if( bIsList ) + return *aData.pAsSequence; + else if( aData.pAsInterface ) + { + Reference<XInterface> x( aData.pAsInterface ); + return Sequence< Reference< XInterface > >( &x, 1 ); + } + return Sequence< Reference< XInterface > >(); +} + +void OInterfaceContainerHelper::copyAndResetInUse() SAL_THROW( () ) +{ + OSL_ENSURE( bInUse, "OInterfaceContainerHelper not in use" ); + if( bInUse ) + { + // this should be the worst case. If a iterator is active + // and a new Listener is added. + if( bIsList ) + aData.pAsSequence = new Sequence< Reference< XInterface > >( *aData.pAsSequence ); + else if( aData.pAsInterface ) + aData.pAsInterface->acquire(); + + bInUse = sal_False; + } +} + +sal_Int32 OInterfaceContainerHelper::addInterface( const Reference<XInterface> & rListener ) SAL_THROW( () ) +{ + OSL_ASSERT( rListener.is() ); + MutexGuard aGuard( rMutex ); + if( bInUse ) + copyAndResetInUse(); + + if( bIsList ) + { + sal_Int32 nLen = aData.pAsSequence->getLength(); + realloc( *aData.pAsSequence, nLen +1 ); + aData.pAsSequence->getArray()[ nLen ] = rListener; + return nLen +1; + } + else if( aData.pAsInterface ) + { + Sequence< Reference< XInterface > > * pSeq = new Sequence< Reference< XInterface > >( 2 ); + Reference<XInterface> * pArray = pSeq->getArray(); + pArray[0] = aData.pAsInterface; + pArray[1] = rListener; + aData.pAsInterface->release(); + aData.pAsSequence = pSeq; + bIsList = sal_True; + return 2; + } + else + { + aData.pAsInterface = rListener.get(); + if( rListener.is() ) + rListener->acquire(); + return 1; + } +} + +sal_Int32 OInterfaceContainerHelper::removeInterface( const Reference<XInterface> & rListener ) SAL_THROW( () ) +{ + OSL_ASSERT( rListener.is() ); + MutexGuard aGuard( rMutex ); + if( bInUse ) + copyAndResetInUse(); + + if( bIsList ) + { + const Reference<XInterface> * pL = aData.pAsSequence->getConstArray(); + sal_Int32 nLen = aData.pAsSequence->getLength(); + sal_Int32 i; + for( i = 0; i < nLen; i++ ) + { + // It is not valid to compare the Pointer direkt, but is is is much + // more faster. + if( pL[i].get() == rListener.get() ) + { + sequenceRemoveElementAt( *aData.pAsSequence, i ); + break; + } + } + + if( i == nLen ) + { + // interface not found, use the correct compare method + for( i = 0; i < nLen; i++ ) + { + if( pL[i] == rListener ) + { + sequenceRemoveElementAt(*aData.pAsSequence, i ); + break; + } + } + } + + if( aData.pAsSequence->getLength() == 1 ) + { + XInterface * p = aData.pAsSequence->getConstArray()[0].get(); + p->acquire(); + delete aData.pAsSequence; + aData.pAsInterface = p; + bIsList = sal_False; + return 1; + } + else + return aData.pAsSequence->getLength(); + } + else if( aData.pAsInterface && Reference<XInterface>( aData.pAsInterface ) == rListener ) + { + aData.pAsInterface->release(); + aData.pAsInterface = 0; + } + return aData.pAsInterface ? 1 : 0; +} + +void OInterfaceContainerHelper::disposeAndClear( const EventObject & rEvt ) SAL_THROW( () ) +{ + ClearableMutexGuard aGuard( rMutex ); + OInterfaceIteratorHelper aIt( *this ); + // Release container, in case new entries come while disposing + OSL_ENSURE( !bIsList || bInUse, "OInterfaceContainerHelper not in use" ); + if( !bIsList && aData.pAsInterface ) + aData.pAsInterface->release(); + // set the member to null, use the iterator to delete the values + aData.pAsInterface = NULL; + bIsList = sal_False; + bInUse = sal_False; + aGuard.clear(); + while( aIt.hasMoreElements() ) + { + try + { + Reference<XEventListener > xLst( aIt.next(), UNO_QUERY ); + if( xLst.is() ) + xLst->disposing( rEvt ); + } + catch ( RuntimeException & ) + { + // be robust, if e.g. a remote bridge has disposed already. + // there is no way to delegate the error to the caller :o(. + } + } +} + + +void OInterfaceContainerHelper::clear() SAL_THROW( () ) +{ + ClearableMutexGuard aGuard( rMutex ); + OInterfaceIteratorHelper aIt( *this ); + // Release container, in case new entries come while disposing + OSL_ENSURE( !bIsList || bInUse, "OInterfaceContainerHelper not in use" ); + if( !bIsList && aData.pAsInterface ) + aData.pAsInterface->release(); + // set the member to null, use the iterator to delete the values + aData.pAsInterface = 0; + bIsList = sal_False; + bInUse = sal_False; + // release mutex before aIt destructor call + aGuard.clear(); +} + +//################################################################################################## +//################################################################################################## +//################################################################################################## + +// specialized class for type + +typedef ::std::vector< std::pair < Type , void* > > t_type2ptr; + +OMultiTypeInterfaceContainerHelper::OMultiTypeInterfaceContainerHelper( Mutex & rMutex_ ) + SAL_THROW( () ) + : rMutex( rMutex_ ) +{ + m_pMap = new t_type2ptr(); +} +OMultiTypeInterfaceContainerHelper::~OMultiTypeInterfaceContainerHelper() + SAL_THROW( () ) +{ + t_type2ptr * pMap = (t_type2ptr *)m_pMap; + t_type2ptr::iterator iter = pMap->begin(); + t_type2ptr::iterator end = pMap->end(); + + while( iter != end ) + { + delete (OInterfaceContainerHelper*)(*iter).second; + (*iter).second = 0; + ++iter; + } + delete pMap; +} +Sequence< Type > OMultiTypeInterfaceContainerHelper::getContainedTypes() const + SAL_THROW( () ) +{ + t_type2ptr * pMap = (t_type2ptr *)m_pMap; + t_type2ptr::size_type nSize; + + ::osl::MutexGuard aGuard( rMutex ); + nSize = pMap->size(); + if( nSize ) + { + ::com::sun::star::uno::Sequence< Type > aInterfaceTypes( nSize ); + Type * pArray = aInterfaceTypes.getArray(); + + t_type2ptr::iterator iter = pMap->begin(); + t_type2ptr::iterator end = pMap->end(); + + sal_Int32 i = 0; + while( iter != end ) + { + // are interfaces added to this container? + if( ((OInterfaceContainerHelper*)(*iter).second)->getLength() ) + // yes, put the type in the array + pArray[i++] = (*iter).first; + ++iter; + } + if( (t_type2ptr::size_type)i != nSize ) { + // may be empty container, reduce the sequence to the right size + aInterfaceTypes = ::com::sun::star::uno::Sequence< Type >( pArray, i ); + } + return aInterfaceTypes; + } + return ::com::sun::star::uno::Sequence< Type >(); +} + +static t_type2ptr::iterator findType(t_type2ptr *pMap, const Type & rKey ) +{ + t_type2ptr::iterator iter = pMap->begin(); + t_type2ptr::iterator end = pMap->end(); + + while( iter != end ) + { + if (iter->first == rKey) + break; + iter++; + } + return iter; +} + +OInterfaceContainerHelper * OMultiTypeInterfaceContainerHelper::getContainer( const Type & rKey ) const + SAL_THROW( () ) +{ + ::osl::MutexGuard aGuard( rMutex ); + + t_type2ptr * pMap = (t_type2ptr *)m_pMap; + t_type2ptr::iterator iter = findType( pMap, rKey ); + if( iter != pMap->end() ) + return (OInterfaceContainerHelper*) (*iter).second; + return 0; +} +sal_Int32 OMultiTypeInterfaceContainerHelper::addInterface( + const Type & rKey, const Reference< XInterface > & rListener ) + SAL_THROW( () ) +{ + ::osl::MutexGuard aGuard( rMutex ); + t_type2ptr * pMap = (t_type2ptr *)m_pMap; + t_type2ptr::iterator iter = findType( pMap, rKey ); + if( iter == pMap->end() ) + { + OInterfaceContainerHelper * pLC = new OInterfaceContainerHelper( rMutex ); + pMap->push_back(std::pair<Type, void*>(rKey, pLC)); + return pLC->addInterface( rListener ); + } + else + return ((OInterfaceContainerHelper*)(*iter).second)->addInterface( rListener ); +} +sal_Int32 OMultiTypeInterfaceContainerHelper::removeInterface( + const Type & rKey, const Reference< XInterface > & rListener ) + SAL_THROW( () ) +{ + ::osl::MutexGuard aGuard( rMutex ); + + // search container with id nUik + t_type2ptr * pMap = (t_type2ptr *)m_pMap; + t_type2ptr::iterator iter = findType( pMap, rKey ); + // container found? + if( iter != pMap->end() ) + return ((OInterfaceContainerHelper*)(*iter).second)->removeInterface( rListener ); + + // no container with this id. Always return 0 + return 0; +} +void OMultiTypeInterfaceContainerHelper::disposeAndClear( const EventObject & rEvt ) + SAL_THROW( () ) +{ + t_type2ptr::size_type nSize = 0; + OInterfaceContainerHelper ** ppListenerContainers = NULL; + { + ::osl::MutexGuard aGuard( rMutex ); + t_type2ptr * pMap = (t_type2ptr *)m_pMap; + nSize = pMap->size(); + if( nSize ) + { + typedef OInterfaceContainerHelper* ppp; + ppListenerContainers = new ppp[nSize]; + //ppListenerContainers = new (ListenerContainer*)[nSize]; + + t_type2ptr::iterator iter = pMap->begin(); + t_type2ptr::iterator end = pMap->end(); + + t_type2ptr::size_type i = 0; + while( iter != end ) + { + ppListenerContainers[i++] = (OInterfaceContainerHelper*)(*iter).second; + ++iter; + } + } + } + + // create a copy, because do not fire event in a guarded section + for( t_type2ptr::size_type i = 0; + i < nSize; i++ ) + { + if( ppListenerContainers[i] ) + ppListenerContainers[i]->disposeAndClear( rEvt ); + } + + delete [] ppListenerContainers; +} +void OMultiTypeInterfaceContainerHelper::clear() + SAL_THROW( () ) +{ + ::osl::MutexGuard aGuard( rMutex ); + t_type2ptr * pMap = (t_type2ptr *)m_pMap; + t_type2ptr::iterator iter = pMap->begin(); + t_type2ptr::iterator end = pMap->end(); + + while( iter != end ) + { + ((OInterfaceContainerHelper*)(*iter).second)->clear(); + ++iter; + } +} + + +//################################################################################################## +//################################################################################################## +//################################################################################################## + +// specialized class for long + +typedef ::std::vector< std::pair < sal_Int32 , void* > > t_long2ptr; + +static t_long2ptr::iterator findLong(t_long2ptr *pMap, sal_Int32 nKey ) +{ + t_long2ptr::iterator iter = pMap->begin(); + t_long2ptr::iterator end = pMap->end(); + + while( iter != end ) + { + if (iter->first == nKey) + break; + iter++; + } + return iter; +} + +OMultiTypeInterfaceContainerHelperInt32::OMultiTypeInterfaceContainerHelperInt32( Mutex & rMutex_ ) + SAL_THROW( () ) + : m_pMap( NULL ) + , rMutex( rMutex_ ) +{ + // delay pMap allocation until necessary. +} +OMultiTypeInterfaceContainerHelperInt32::~OMultiTypeInterfaceContainerHelperInt32() + SAL_THROW( () ) +{ + if (!m_pMap) + return; + + t_long2ptr * pMap = (t_long2ptr *)m_pMap; + t_long2ptr::iterator iter = pMap->begin(); + t_long2ptr::iterator end = pMap->end(); + + while( iter != end ) + { + delete (OInterfaceContainerHelper*)(*iter).second; + (*iter).second = 0; + ++iter; + } + delete pMap; +} +Sequence< sal_Int32 > OMultiTypeInterfaceContainerHelperInt32::getContainedTypes() const + SAL_THROW( () ) +{ + t_long2ptr * pMap = (t_long2ptr *)m_pMap; + t_long2ptr::size_type nSize; + + ::osl::MutexGuard aGuard( rMutex ); + nSize = pMap ? pMap->size() : 0; + if( nSize ) + { + ::com::sun::star::uno::Sequence< sal_Int32 > aInterfaceTypes( nSize ); + sal_Int32 * pArray = aInterfaceTypes.getArray(); + + t_long2ptr::iterator iter = pMap->begin(); + t_long2ptr::iterator end = pMap->end(); + + sal_Int32 i = 0; + while( iter != end ) + { + // are interfaces added to this container? + if( ((OInterfaceContainerHelper*)(*iter).second)->getLength() ) + // yes, put the type in the array + pArray[i++] = (*iter).first; + ++iter; + } + if( (t_long2ptr::size_type)i != nSize ) { + // may be empty container, reduce the sequence to the right size + aInterfaceTypes = ::com::sun::star::uno::Sequence< sal_Int32 >( pArray, i ); + } + return aInterfaceTypes; + } + return ::com::sun::star::uno::Sequence< sal_Int32 >(); +} +OInterfaceContainerHelper * OMultiTypeInterfaceContainerHelperInt32::getContainer( const sal_Int32 & rKey ) const + SAL_THROW( () ) +{ + ::osl::MutexGuard aGuard( rMutex ); + + if (!m_pMap) + return 0; + t_long2ptr * pMap = (t_long2ptr *)m_pMap; + t_long2ptr::iterator iter = findLong( pMap, rKey ); + if( iter != pMap->end() ) + return (OInterfaceContainerHelper*) (*iter).second; + return 0; +} +sal_Int32 OMultiTypeInterfaceContainerHelperInt32::addInterface( + const sal_Int32 & rKey, const Reference< XInterface > & rListener ) + SAL_THROW( () ) +{ + ::osl::MutexGuard aGuard( rMutex ); + if (!m_pMap) + m_pMap = new t_long2ptr(); + t_long2ptr * pMap = (t_long2ptr *)m_pMap; + t_long2ptr::iterator iter = findLong( pMap, rKey ); + if( iter == pMap->end() ) + { + OInterfaceContainerHelper * pLC = new OInterfaceContainerHelper( rMutex ); + pMap->push_back(std::pair< sal_Int32, void* >(rKey, pLC)); + return pLC->addInterface( rListener ); + } + else + return ((OInterfaceContainerHelper*)(*iter).second)->addInterface( rListener ); +} +sal_Int32 OMultiTypeInterfaceContainerHelperInt32::removeInterface( + const sal_Int32 & rKey, const Reference< XInterface > & rListener ) + SAL_THROW( () ) +{ + ::osl::MutexGuard aGuard( rMutex ); + + if (!m_pMap) + return 0; + // search container with id nUik + t_long2ptr * pMap = (t_long2ptr *)m_pMap; + t_long2ptr::iterator iter = findLong( pMap, rKey ); + // container found? + if( iter != pMap->end() ) + return ((OInterfaceContainerHelper*)(*iter).second)->removeInterface( rListener ); + + // no container with this id. Always return 0 + return 0; +} +void OMultiTypeInterfaceContainerHelperInt32::disposeAndClear( const EventObject & rEvt ) + SAL_THROW( () ) +{ + t_long2ptr::size_type nSize = 0; + OInterfaceContainerHelper ** ppListenerContainers = NULL; + { + ::osl::MutexGuard aGuard( rMutex ); + if (!m_pMap) + return; + + t_long2ptr * pMap = (t_long2ptr *)m_pMap; + nSize = pMap->size(); + if( nSize ) + { + typedef OInterfaceContainerHelper* ppp; + ppListenerContainers = new ppp[nSize]; + + t_long2ptr::iterator iter = pMap->begin(); + t_long2ptr::iterator end = pMap->end(); + + t_long2ptr::size_type i = 0; + while( iter != end ) + { + ppListenerContainers[i++] = (OInterfaceContainerHelper*)(*iter).second; + ++iter; + } + } + } + + // create a copy, because do not fire event in a guarded section + for( t_long2ptr::size_type i = 0; + i < nSize; i++ ) + { + if( ppListenerContainers[i] ) + ppListenerContainers[i]->disposeAndClear( rEvt ); + } + + delete [] ppListenerContainers; +} +void OMultiTypeInterfaceContainerHelperInt32::clear() + SAL_THROW( () ) +{ + ::osl::MutexGuard aGuard( rMutex ); + if (!m_pMap) + return; + t_long2ptr * pMap = (t_long2ptr *)m_pMap; + t_long2ptr::iterator iter = pMap->begin(); + t_long2ptr::iterator end = pMap->end(); + + while( iter != end ) + { + ((OInterfaceContainerHelper*)(*iter).second)->clear(); + ++iter; + } +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/source/macro_expander.cxx b/cppuhelper/source/macro_expander.cxx new file mode 100644 index 000000000000..38dc08b8af43 --- /dev/null +++ b/cppuhelper/source/macro_expander.cxx @@ -0,0 +1,201 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_cppuhelper.hxx" + +#include <rtl/bootstrap.hxx> + +#include <uno/mapping.hxx> + +#include <cppuhelper/factory.hxx> +#include <cppuhelper/compbase2.hxx> +#include <cppuhelper/component_context.hxx> + +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/util/XMacroExpander.hpp> +#include "com/sun/star/uno/RuntimeException.hpp" + +#include "macro_expander.hxx" + +#define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) ) +#define SERVICE_NAME_A "com.sun.star.lang.MacroExpander" +#define SERVICE_NAME_B "com.sun.star.lang.BootstrapMacroExpander" +#define IMPL_NAME "com.sun.star.lang.comp.cppuhelper.BootstrapMacroExpander" + + +using namespace ::rtl; +using namespace ::osl; +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; + +namespace cppu +{ +//---- private forward ----------------------------------------------------------------------------- +Bootstrap const & get_unorc() SAL_THROW( () ); +} + +namespace cppuhelper { namespace detail { + +rtl::OUString expandMacros(rtl::OUString const & text) { + rtl::OUString t(text); + rtl_bootstrap_expandMacros_from_handle( + cppu::get_unorc().getHandle(), &t.pData); + return t; +} + +} } + +namespace +{ +inline OUString s_impl_name() { return OUSTR(IMPL_NAME); } +static Sequence< OUString > const & s_get_service_names() +{ + static Sequence< OUString > const * s_pnames = 0; + if (! s_pnames) + { + MutexGuard guard( Mutex::getGlobalMutex() ); + if (! s_pnames) + { + static Sequence< OUString > s_names( 2 ); + s_names[ 0 ] = OUSTR(SERVICE_NAME_A); + s_names[ 1 ] = OUSTR(SERVICE_NAME_B); + s_pnames = &s_names; + } + } + return *s_pnames; +} + +typedef ::cppu::WeakComponentImplHelper2< + util::XMacroExpander, lang::XServiceInfo > t_uno_impl; + +struct mutex_holder +{ + Mutex m_mutex; +}; +class Bootstrap_MacroExpander : public mutex_holder, public t_uno_impl +{ +protected: + virtual void SAL_CALL disposing(); + +public: + inline Bootstrap_MacroExpander( Reference< XComponentContext > const & ) SAL_THROW( () ) + : t_uno_impl( m_mutex ) + {} + virtual ~Bootstrap_MacroExpander() + SAL_THROW( () ); + + // XMacroExpander impl + virtual OUString SAL_CALL expandMacros( OUString const & exp ) + throw (lang::IllegalArgumentException); + // XServiceInfo impl + virtual OUString SAL_CALL getImplementationName() + throw (RuntimeException); + virtual sal_Bool SAL_CALL supportsService( OUString const & serviceName ) + throw (RuntimeException); + virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() + throw (RuntimeException); +}; + +//__________________________________________________________________________________________________ +void Bootstrap_MacroExpander::disposing() +{} +//__________________________________________________________________________________________________ +Bootstrap_MacroExpander::~Bootstrap_MacroExpander() SAL_THROW( () ) +{} + +// XServiceInfo impl +//__________________________________________________________________________________________________ +OUString Bootstrap_MacroExpander::getImplementationName() + throw (RuntimeException) +{ + return s_impl_name(); +} +//__________________________________________________________________________________________________ +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; +} +//__________________________________________________________________________________________________ +Sequence< OUString > Bootstrap_MacroExpander::getSupportedServiceNames() + throw (RuntimeException) +{ + return s_get_service_names(); +} + +// XMacroExpander impl +//__________________________________________________________________________________________________ +OUString Bootstrap_MacroExpander::expandMacros( OUString const & exp ) + throw (lang::IllegalArgumentException) +{ + return cppuhelper::detail::expandMacros( exp ); +} + +//================================================================================================== +Reference< XInterface > SAL_CALL service_create( + Reference< XComponentContext > const & xComponentContext ) + SAL_THROW( (RuntimeException) ) +{ + return static_cast< ::cppu::OWeakObject * >( new Bootstrap_MacroExpander( xComponentContext ) ); +} + +} + +namespace cppu +{ + +//################################################################################################## +Reference< lang::XSingleComponentFactory > create_boostrap_macro_expander_factory() SAL_THROW( () ) +{ + Reference< lang::XSingleComponentFactory > free(::cppu::createSingleComponentFactory( + service_create, + s_impl_name(), + s_get_service_names() )); + + uno::Environment curr_env(Environment::getCurrent()); + uno::Environment target_env(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(CPPU_STRINGIFY(CPPU_ENV)))); + + uno::Mapping target2curr(target_env, curr_env); + + return Reference<lang::XSingleComponentFactory>( + reinterpret_cast<lang::XSingleComponentFactory *>( + target2curr.mapInterface(free.get(), ::getCppuType(&free))), + SAL_NO_ACQUIRE); +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/source/macro_expander.hxx b/cppuhelper/source/macro_expander.hxx new file mode 100644 index 000000000000..d9914aeecf09 --- /dev/null +++ b/cppuhelper/source/macro_expander.hxx @@ -0,0 +1,63 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef CPPUHELPER_SOURCE_MACRO_EXPANDER_HXX +#define CPPUHELPER_SOURCE_MACRO_EXPANDER_HXX + +#include "sal/config.h" + +namespace rtl { class OUString; } + +namespace cppuhelper { + +namespace detail { + +/** + * Helper function to expand macros based on the unorc/uno.ini. + * + * @internal + * + * @param text + * Some text. + * + * @return + * The expanded text. + * + * @exception com::sun::star::lang::IllegalArgumentException + * If uriReference is a vnd.sun.star.expand URL reference that contains unknown + * macros. + */ +::rtl::OUString expandMacros(rtl::OUString const & text); + +} + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/source/makefile.mk b/cppuhelper/source/makefile.mk new file mode 100644 index 000000000000..5755ed77631c --- /dev/null +++ b/cppuhelper/source/makefile.mk @@ -0,0 +1,192 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* +PRJ=.. + +PRJNAME=cppuhelper +TARGET=cppuhelper + +ENABLE_EXCEPTIONS=TRUE +USE_DEFFILE=TRUE + +# not strictly a bootstrap service but containing +# bootstrap code that may require generated files +# without "-L" (light) switch +BOOTSTRAP_SERVICE=TRUE + +.IF "$(OS)" != "WNT" && "$(GUI)"!="OS2" +UNIXVERSIONNAMES=UDK +.ENDIF # WNT + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk + +# --- Files -------------------------------------------------------- + +UNOUCRRDB=$(SOLARBINDIR)$/udkapi.rdb +UNOUCRDEP=$(UNOUCRRDB) +UNOUCROUT=$(OUT)$/inc$/$(TARGET) +INCPRE+=$(OUT)$/inc$/$(TARGET) $(OUT)$/inc$/private + +CPPUMAKERFLAGS= -C + +UNOTYPES= \ + com.sun.star.beans.PropertyAttribute \ + com.sun.star.beans.PropertyValue \ + com.sun.star.beans.XFastPropertySet \ + com.sun.star.beans.XMultiPropertySet \ + com.sun.star.beans.XPropertyAccess \ + com.sun.star.beans.XPropertySet \ + com.sun.star.bridge.UnoUrlResolver \ + com.sun.star.bridge.XUnoUrlResolver \ + com.sun.star.connection.SocketPermission \ + com.sun.star.container.XElementAccess \ + com.sun.star.container.XEnumerationAccess \ + com.sun.star.container.XHierarchicalNameAccess \ + com.sun.star.container.XNameAccess \ + com.sun.star.container.XNameContainer \ + com.sun.star.container.XSet \ + com.sun.star.io.FilePermission \ + com.sun.star.io.IOException \ + com.sun.star.lang.DisposedException \ + com.sun.star.lang.WrappedTargetRuntimeException \ + com.sun.star.lang.XComponent \ + com.sun.star.lang.XEventListener \ + com.sun.star.lang.XInitialization \ + com.sun.star.lang.XMultiComponentFactory \ + com.sun.star.lang.XMultiServiceFactory \ + com.sun.star.lang.XServiceInfo \ + com.sun.star.lang.XSingleComponentFactory \ + com.sun.star.lang.XSingleServiceFactory \ + com.sun.star.lang.XTypeProvider \ + com.sun.star.loader.XImplementationLoader \ + com.sun.star.reflection.XArrayTypeDescription \ + com.sun.star.reflection.XCompoundTypeDescription \ + com.sun.star.reflection.XEnumTypeDescription \ + com.sun.star.reflection.XIdlClass \ + com.sun.star.reflection.XIdlClassProvider \ + com.sun.star.reflection.XIdlField2 \ + com.sun.star.reflection.XIdlReflection \ + com.sun.star.reflection.XIndirectTypeDescription \ + com.sun.star.reflection.XInterfaceAttributeTypeDescription \ + com.sun.star.reflection.XInterfaceAttributeTypeDescription2 \ + com.sun.star.reflection.XInterfaceMemberTypeDescription \ + com.sun.star.reflection.XInterfaceMethodTypeDescription \ + com.sun.star.reflection.XInterfaceTypeDescription2 \ + com.sun.star.reflection.XMethodParameter \ + com.sun.star.reflection.XStructTypeDescription \ + com.sun.star.reflection.XTypeDescription \ + com.sun.star.reflection.XUnionTypeDescription \ + com.sun.star.registry.XImplementationRegistration \ + com.sun.star.registry.XRegistryKey \ + com.sun.star.registry.XSimpleRegistry \ + com.sun.star.security.RuntimePermission \ + com.sun.star.security.XAccessController \ + com.sun.star.uno.DeploymentException \ + com.sun.star.uno.RuntimeException \ + com.sun.star.uno.XAggregation \ + com.sun.star.uno.XComponentContext \ + com.sun.star.uno.XCurrentContext \ + com.sun.star.uno.XUnloadingPreference \ + com.sun.star.uno.XWeak \ + com.sun.star.util.XMacroExpander + +.IF "$(debug)" != "" +# msvc++: no inlining for debugging +.IF "$(COM)" == "MSC" +CFLAGS += -Ob0 +.ENDIF +.ENDIF + +SLOFILES= \ + $(SLO)$/typeprovider.obj \ + $(SLO)$/exc_thrower.obj \ + $(SLO)$/servicefactory.obj \ + $(SLO)$/bootstrap.obj \ + $(SLO)$/implbase.obj \ + $(SLO)$/implbase_ex.obj \ + $(SLO)$/propshlp.obj \ + $(SLO)$/weak.obj \ + $(SLO)$/interfacecontainer.obj \ + $(SLO)$/stdidlclass.obj \ + $(SLO)$/factory.obj \ + $(SLO)$/component_context.obj \ + $(SLO)$/component.obj \ + $(SLO)$/shlib.obj \ + $(SLO)$/tdmgr.obj \ + $(SLO)$/implementationentry.obj \ + $(SLO)$/access_control.obj \ + $(SLO)$/macro_expander.obj \ + $(SLO)$/unourl.obj \ + $(SLO)$/propertysetmixin.obj \ + $(SLO)$/findsofficepath.obj + +OBJFILES = $(OBJ)$/findsofficepath.obj + +.IF "$(GUI)" == "WNT" +SHL1TARGET=$(TARGET)$(UDK_MAJOR)$(COMID) +.ELIF "$(GUI)" == "OS2" +SHL1TARGET=cppuh +SHL1TARGET=cppuh$(UDK_MAJOR) +.ELSE +SHL1TARGET=uno_$(TARGET)$(COMID) +.ENDIF + +SHL1STDLIBS= \ + $(SALLIB) \ + $(SALHELPERLIB) \ + $(CPPULIB) +.IF "$(OS)" == "WNT" +SHL1STDLIBS += $(ADVAPI32LIB) +.ENDIF + +SHL1DEPN= +SHL1IMPLIB=i$(TARGET) +SHL1OBJS = $(SLOFILES) +SHL1RPATH=URELIB + +SHL1DEF=$(MISC)$/$(SHL1TARGET).def + +DEF1NAME=$(SHL1TARGET) + +.IF "$(COMNAME)"=="msci" +SHL1VERSIONMAP=msvc_win32_intel.map +.ELIF "$(COMNAME)"=="sunpro5" +SHL1VERSIONMAP=cc5_solaris_sparc.map +.ELIF "$(GUI)$(COMNAME)"=="OS2gcc3" +SHL1VERSIONMAP=gcc3os2.map +.ELIF "$(COMNAME)"=="gcc3" +SHL1VERSIONMAP=gcc3.map +.ENDIF + +# --- Targets ------------------------------------------------------ + +.IF "$(diag)"!="" +CFLAGS += -DDIAG=$(diag) +.ENDIF + +.INCLUDE : target.mk diff --git a/cppuhelper/source/msvc_win32_intel.map b/cppuhelper/source/msvc_win32_intel.map new file mode 100644 index 000000000000..6d5a491ab925 --- /dev/null +++ b/cppuhelper/source/msvc_win32_intel.map @@ -0,0 +1,280 @@ +UDK_3_0_0 { + global: +GetVersionInfo; +??0OComponentHelper@cppu@@QAE@AAVMutex@osl@@@Z; +??1OComponentHelper@cppu@@UAE@XZ; +??BOWeakObject@cppu@@QAA?AV?$Reference@VXInterface@uno@star@sun@com@@@uno@star@sun@com@@XZ; +??BWeakReferenceHelper@uno@star@sun@com@@QBA?AV?$Reference@VXInterface@uno@star@sun@com@@@1234@XZ; +??_7OComponentHelper@cppu@@6BOWeakObject@1@@; +??_7OComponentHelper@cppu@@6BXAggregation@uno@star@sun@com@@@; +??_7OComponentHelper@cppu@@6BXComponent@lang@star@sun@com@@@; +??_7OComponentHelper@cppu@@6BXTypeProvider@lang@star@sun@com@@@; +??_7OWeakAggObject@cppu@@6BOWeakObject@1@@; +??_7OWeakAggObject@cppu@@6BXAggregation@uno@star@sun@com@@@; +??_7OWeakObject@cppu@@6B@; +??_GOComponentHelper@cppu@@UAEPAXI@Z; +??_GOWeakAggObject@cppu@@MAEPAXI@Z; +??_GOWeakObject@cppu@@MAEPAXI@Z; +?addEventListener@OComponentHelper@cppu@@UAAXABV?$Reference@VXEventListener@lang@star@sun@com@@@uno@star@sun@com@@@Z; +?dispose@OComponentHelper@cppu@@UAAXXZ; +?disposing@OComponentHelper@cppu@@MAAXXZ; +?release@OComponentHelper@cppu@@UAAXXZ; +?removeEventListener@OComponentHelper@cppu@@UAAXABV?$Reference@VXEventListener@lang@star@sun@com@@@uno@star@sun@com@@@Z; +??1OTypeCollection@cppu@@QAE@XZ; +?createFactoryProxy@cppu@@YA?AV?$Reference@VXSingleServiceFactory@lang@star@sun@com@@@uno@star@sun@com@@ABV?$Reference@VXMultiServiceFactory@lang@star@sun@com@@@3456@ABV23456@@Z; +?createOneInstanceRegistryFactory@cppu@@YA?AV?$Reference@VXSingleServiceFactory@lang@star@sun@com@@@uno@star@sun@com@@ABV?$Reference@VXMultiServiceFactory@lang@star@sun@com@@@3456@ABVOUString@rtl@@ABV?$Reference@VXRegistryKey@registry@star@sun@com@@@3456@@Z; +?createSingleRegistryFactory@cppu@@YA?AV?$Reference@VXSingleServiceFactory@lang@star@sun@com@@@uno@star@sun@com@@ABV?$Reference@VXMultiServiceFactory@lang@star@sun@com@@@3456@ABVOUString@rtl@@ABV?$Reference@VXRegistryKey@registry@star@sun@com@@@3456@@Z; +?getTypes@OTypeCollection@cppu@@QAA?AV?$Sequence@VType@uno@star@sun@com@@@uno@star@sun@com@@XZ; +?createStandardClassWithSequence@cppu@@YAPAVXIdlClass@reflection@star@sun@com@@ABV?$Reference@VXMultiServiceFactory@lang@star@sun@com@@@uno@456@ABVOUString@rtl@@ABV?$Reference@VXIdlClass@reflection@star@sun@com@@@8456@ABV?$Sequence@VOUString@rtl@@@8456@@Z; +??0OInterfaceContainerHelper@cppu@@QAE@AAVMutex@osl@@@Z; +??0OInterfaceIteratorHelper@cppu@@QAE@AAVOInterfaceContainerHelper@1@@Z; +??1OInterfaceContainerHelper@cppu@@QAE@XZ; +??1OInterfaceIteratorHelper@cppu@@QAE@XZ; +?addInterface@OInterfaceContainerHelper@cppu@@QAAJABV?$Reference@VXInterface@uno@star@sun@com@@@uno@star@sun@com@@@Z; +?clear@OInterfaceContainerHelper@cppu@@QAAXXZ; +?copyAndResetInUse@OInterfaceContainerHelper@cppu@@AAEXXZ; +?disposeAndClear@OInterfaceContainerHelper@cppu@@QAAXABUEventObject@lang@star@sun@com@@@Z; +?getElements@OInterfaceContainerHelper@cppu@@QBA?AV?$Sequence@V?$Reference@VXInterface@uno@star@sun@com@@@uno@star@sun@com@@@uno@star@sun@com@@XZ; +?getLength@OInterfaceContainerHelper@cppu@@QBAJXZ; +?next@OInterfaceIteratorHelper@cppu@@QAAPAVXInterface@uno@star@sun@com@@XZ; +?removeInterface@OInterfaceContainerHelper@cppu@@QAAJABV?$Reference@VXInterface@uno@star@sun@com@@@uno@star@sun@com@@@Z; +??0WeakReferenceHelper@uno@star@sun@com@@QAE@ABV01234@@Z; +??0WeakReferenceHelper@uno@star@sun@com@@QAE@ABV?$Reference@VXInterface@uno@star@sun@com@@@1234@@Z; +??1OWeakAggObject@cppu@@MAE@XZ; +??1OWeakObject@cppu@@MAE@XZ; +??1WeakReferenceHelper@uno@star@sun@com@@QAE@XZ; +??4WeakReferenceHelper@uno@star@sun@com@@QAAAAV01234@ABV01234@@Z; +??4WeakReferenceHelper@uno@star@sun@com@@QAAAAV01234@ABV?$Reference@VXInterface@uno@star@sun@com@@@1234@@Z; +?acquire@OWeakAggObject@cppu@@UAAXXZ; +?acquire@OWeakObject@cppu@@UAAXXZ; +?get@WeakReferenceHelper@uno@star@sun@com@@QBA?AV?$Reference@VXInterface@uno@star@sun@com@@@2345@XZ; +?queryAdapter@OWeakObject@cppu@@UAA?AV?$Reference@VXAdapter@uno@star@sun@com@@@uno@star@sun@com@@XZ; +?queryAggregation@OWeakAggObject@cppu@@UAA?AVAny@uno@star@sun@com@@ABVType@4567@@Z; +?queryInterface@OWeakAggObject@cppu@@UAA?AVAny@uno@star@sun@com@@ABVType@4567@@Z; +?queryInterface@OWeakObject@cppu@@UAA?AVAny@uno@star@sun@com@@ABVType@4567@@Z; +?release@OWeakAggObject@cppu@@UAAXXZ; +?release@OWeakObject@cppu@@UAAXXZ; +?setDelegator@OWeakAggObject@cppu@@UAAXABV?$Reference@VXInterface@uno@star@sun@com@@@uno@star@sun@com@@@Z; +??0OPropertyArrayHelper@cppu@@QAE@ABV?$Sequence@UProperty@beans@star@sun@com@@@uno@star@sun@com@@E@Z; +??0OPropertyArrayHelper@cppu@@QAE@PAUProperty@beans@star@sun@com@@JE@Z; +??1IPropertyArrayHelper@cppu@@UAE@XZ; +??1OPropertyArrayHelper@cppu@@UAE@XZ; +??1OPropertySetHelper@cppu@@QAE@XZ; +??_7IPropertyArrayHelper@cppu@@6B@; +??_7OPropertyArrayHelper@cppu@@6B@; +??_7OPropertySetHelper@cppu@@6BXFastPropertySet@beans@star@sun@com@@@; +??_7OPropertySetHelper@cppu@@6BXMultiPropertySet@beans@star@sun@com@@@; +??_7OPropertySetHelper@cppu@@6BXPropertySet@beans@star@sun@com@@@; +??_GIPropertyArrayHelper@cppu@@UAEPAXI@Z; +??_GOPropertyArrayHelper@cppu@@UAEPAXI@Z; +?addPropertiesChangeListener@OPropertySetHelper@cppu@@UAAXABV?$Sequence@VOUString@rtl@@@uno@star@sun@com@@ABV?$Reference@VXPropertiesChangeListener@beans@star@sun@com@@@4567@@Z; +?addPropertyChangeListener@OPropertySetHelper@cppu@@UAAXABVOUString@rtl@@ABV?$Reference@VXPropertyChangeListener@beans@star@sun@com@@@uno@star@sun@com@@@Z; +?addVetoableChangeListener@OPropertySetHelper@cppu@@UAAXABVOUString@rtl@@ABV?$Reference@VXVetoableChangeListener@beans@star@sun@com@@@uno@star@sun@com@@@Z; +?createPropertySetInfo@OPropertySetHelper@cppu@@SA?AV?$Reference@VXPropertySetInfo@beans@star@sun@com@@@uno@star@sun@com@@AAVIPropertyArrayHelper@2@@Z; +?disposing@OPropertySetHelper@cppu@@QAAXXZ; +?fillHandles@OPropertyArrayHelper@cppu@@UAAJPAJABV?$Sequence@VOUString@rtl@@@uno@star@sun@com@@@Z; +?fillPropertyMembersByHandle@OPropertyArrayHelper@cppu@@UAAEPAVOUString@rtl@@PAFJ@Z; +?fire@OPropertySetHelper@cppu@@IAAXPAJPBVAny@uno@star@sun@com@@1JE@Z; +?firePropertiesChangeEvent@OPropertySetHelper@cppu@@UAAXABV?$Sequence@VOUString@rtl@@@uno@star@sun@com@@ABV?$Reference@VXPropertiesChangeListener@beans@star@sun@com@@@4567@@Z; +?getCount@OPropertyArrayHelper@cppu@@QBAJXZ; +?getFastPropertyValue@OPropertySetHelper@cppu@@UAA?AVAny@uno@star@sun@com@@J@Z; +?getHandleByName@OPropertyArrayHelper@cppu@@UAAJABVOUString@rtl@@@Z; +?getProperties@OPropertyArrayHelper@cppu@@UAA?AV?$Sequence@UProperty@beans@star@sun@com@@@uno@star@sun@com@@XZ; +?getPropertyByName@OPropertyArrayHelper@cppu@@UAA?AUProperty@beans@star@sun@com@@ABVOUString@rtl@@@Z; +?getPropertyValue@OPropertySetHelper@cppu@@UAA?AVAny@uno@star@sun@com@@ABVOUString@rtl@@@Z; +?getPropertyValues@OPropertySetHelper@cppu@@UAA?AV?$Sequence@VAny@uno@star@sun@com@@@uno@star@sun@com@@ABV?$Sequence@VOUString@rtl@@@4567@@Z; +?hasPropertyByName@OPropertyArrayHelper@cppu@@UAAEABVOUString@rtl@@@Z; +?init@OPropertyArrayHelper@cppu@@AAEXE@Z; +?queryInterface@OPropertySetHelper@cppu@@UAA?AVAny@uno@star@sun@com@@ABVType@4567@@Z; +?queryInterface@OPropertySetHelper@cppu@@W3AA?AVAny@uno@star@sun@com@@ABVType@4567@@Z; +?queryInterface@OPropertySetHelper@cppu@@W7AA?AVAny@uno@star@sun@com@@ABVType@4567@@Z; +?removePropertiesChangeListener@OPropertySetHelper@cppu@@UAAXABV?$Reference@VXPropertiesChangeListener@beans@star@sun@com@@@uno@star@sun@com@@@Z; +?removePropertyChangeListener@OPropertySetHelper@cppu@@UAAXABVOUString@rtl@@ABV?$Reference@VXPropertyChangeListener@beans@star@sun@com@@@uno@star@sun@com@@@Z; +?removeVetoableChangeListener@OPropertySetHelper@cppu@@UAAXABVOUString@rtl@@ABV?$Reference@VXVetoableChangeListener@beans@star@sun@com@@@uno@star@sun@com@@@Z; +?setFastPropertyValue@OPropertySetHelper@cppu@@UAAXJABVAny@uno@star@sun@com@@@Z; +?setFastPropertyValues@OPropertySetHelper@cppu@@IAAXJPAJPBVAny@uno@star@sun@com@@J@Z; +?setPropertyValue@OPropertySetHelper@cppu@@UAAXABVOUString@rtl@@ABVAny@uno@star@sun@com@@@Z; +?setPropertyValues@OPropertySetHelper@cppu@@UAAXABV?$Sequence@VOUString@rtl@@@uno@star@sun@com@@ABV?$Sequence@VAny@uno@star@sun@com@@@4567@@Z; +??0ClassDataBase@cppu@@QAE@J@Z; +??0ClassDataBase@cppu@@QAE@XZ; +??1ClassDataBase@cppu@@QAE@XZ; +?getImplHelperInitMutex@cppu@@YAAAVMutex@osl@@XZ; +?getImplementationId@ClassData@cppu@@QAA?AV?$Sequence@C@uno@star@sun@com@@XZ; +?getTypes@ClassData@cppu@@QAA?AV?$Sequence@VType@uno@star@sun@com@@@uno@star@sun@com@@XZ; +?initTypeProvider@ClassData@cppu@@QAAXXZ; +?query@ClassData@cppu@@QAA?AVAny@uno@star@sun@com@@ABVType@4567@PAVXTypeProvider@lang@567@@Z; +?writeTypeOffset@ClassData@cppu@@QAAXABVType@uno@star@sun@com@@J@Z; +?createRegistryServiceFactory@cppu@@YA?AV?$Reference@VXMultiServiceFactory@lang@star@sun@com@@@uno@star@sun@com@@ABVOUString@rtl@@0E0@Z; +?throwException@cppu@@YAXABVAny@uno@star@sun@com@@@Z; +??0OTypeCollection@cppu@@QAE@ABVType@uno@star@sun@com@@00000000000ABV?$Sequence@VType@uno@star@sun@com@@@3456@@Z; +??0OTypeCollection@cppu@@QAE@ABVType@uno@star@sun@com@@0000000000ABV?$Sequence@VType@uno@star@sun@com@@@3456@@Z; +??0OTypeCollection@cppu@@QAE@ABVType@uno@star@sun@com@@000000000ABV?$Sequence@VType@uno@star@sun@com@@@3456@@Z; +??0OTypeCollection@cppu@@QAE@ABVType@uno@star@sun@com@@00000000ABV?$Sequence@VType@uno@star@sun@com@@@3456@@Z; +??0OTypeCollection@cppu@@QAE@ABVType@uno@star@sun@com@@0000000ABV?$Sequence@VType@uno@star@sun@com@@@3456@@Z; +??0OTypeCollection@cppu@@QAE@ABVType@uno@star@sun@com@@000000ABV?$Sequence@VType@uno@star@sun@com@@@3456@@Z; +??0OTypeCollection@cppu@@QAE@ABVType@uno@star@sun@com@@00000ABV?$Sequence@VType@uno@star@sun@com@@@3456@@Z; +??0OTypeCollection@cppu@@QAE@ABVType@uno@star@sun@com@@0000ABV?$Sequence@VType@uno@star@sun@com@@@3456@@Z; +??0OTypeCollection@cppu@@QAE@ABVType@uno@star@sun@com@@000ABV?$Sequence@VType@uno@star@sun@com@@@3456@@Z; +??0OTypeCollection@cppu@@QAE@ABVType@uno@star@sun@com@@00ABV?$Sequence@VType@uno@star@sun@com@@@3456@@Z; +??0OTypeCollection@cppu@@QAE@ABVType@uno@star@sun@com@@0ABV?$Sequence@VType@uno@star@sun@com@@@3456@@Z; +??0OTypeCollection@cppu@@QAE@ABVType@uno@star@sun@com@@ABV?$Sequence@VType@uno@star@sun@com@@@3456@@Z; +??1OImplementationId@cppu@@QAE@XZ; +?getImplementationId@OImplementationId@cppu@@QBA?AV?$Sequence@C@uno@star@sun@com@@XZ; +?writeSharedLibComponentInfo@cppu@@YAXABVOUString@rtl@@0ABV?$Reference@VXMultiServiceFactory@lang@star@sun@com@@@uno@star@sun@com@@ABV?$Reference@VXRegistryKey@registry@star@sun@com@@@5678@@Z; +?remove@OInterfaceIteratorHelper@cppu@@QAAXXZ; +??0OWeakObject@cppu@@QAE@XZ; +?installTypeDescriptionManager@cppu@@YAEABV?$Reference@VXHierarchicalNameAccess@container@star@sun@com@@@uno@star@sun@com@@@Z; +?loadSharedLibComponentFactory@cppu@@YA?AV?$Reference@VXInterface@uno@star@sun@com@@@uno@star@sun@com@@ABVOUString@rtl@@00ABV?$Reference@VXMultiServiceFactory@lang@star@sun@com@@@3456@ABV?$Reference@VXRegistryKey@registry@star@sun@com@@@3456@@Z; +?createComponentContext@cppu@@YA?AV?$Reference@VXComponentContext@uno@star@sun@com@@@uno@star@sun@com@@PBUContextEntry_Init@1@JABV23456@@Z; +?bootstrap_InitialComponentContext@cppu@@YA?AV?$Reference@VXComponentContext@uno@star@sun@com@@@uno@star@sun@com@@ABV?$Reference@VXSimpleRegistry@registry@star@sun@com@@@3456@ABVOUString@rtl@@@Z; +?createNestedRegistry@cppu@@YA?AV?$Reference@VXSimpleRegistry@registry@star@sun@com@@@uno@star@sun@com@@ABVOUString@rtl@@@Z; +?createSimpleRegistry@cppu@@YA?AV?$Reference@VXSimpleRegistry@registry@star@sun@com@@@uno@star@sun@com@@ABVOUString@rtl@@@Z; +??0WeakAggComponentImplHelperBase@cppu@@IAE@AAVMutex@osl@@@Z; +??0WeakComponentImplHelperBase@cppu@@IAE@AAVMutex@osl@@@Z; +?acquire@WeakAggComponentImplHelperBase@cppu@@UAAXXZ; +?acquire@WeakComponentImplHelperBase@cppu@@UAAXXZ; +?addEventListener@WeakAggComponentImplHelperBase@cppu@@UAAXABV?$Reference@VXEventListener@lang@star@sun@com@@@uno@star@sun@com@@@Z; +?addEventListener@WeakComponentImplHelperBase@cppu@@UAAXABV?$Reference@VXEventListener@lang@star@sun@com@@@uno@star@sun@com@@@Z; +?dispose@WeakAggComponentImplHelperBase@cppu@@UAAXXZ; +?dispose@WeakComponentImplHelperBase@cppu@@UAAXXZ; +?queryAggregation@WeakAggComponentImplHelperBase@cppu@@UAA?AVAny@uno@star@sun@com@@ABVType@4567@@Z; +?queryInterface@WeakAggComponentImplHelperBase@cppu@@UAA?AVAny@uno@star@sun@com@@ABVType@4567@@Z; +?queryInterface@WeakComponentImplHelperBase@cppu@@UAA?AVAny@uno@star@sun@com@@ABVType@4567@@Z; +?release@WeakAggComponentImplHelperBase@cppu@@UAAXXZ; +?release@WeakComponentImplHelperBase@cppu@@UAAXXZ; +?removeEventListener@WeakAggComponentImplHelperBase@cppu@@UAAXABV?$Reference@VXEventListener@lang@star@sun@com@@@uno@star@sun@com@@@Z; +?removeEventListener@WeakComponentImplHelperBase@cppu@@UAAXABV?$Reference@VXEventListener@lang@star@sun@com@@@uno@star@sun@com@@@Z; +??1WeakAggComponentImplHelperBase@cppu@@UAE@XZ; +??1WeakComponentImplHelperBase@cppu@@UAE@XZ; +?disposing@WeakAggComponentImplHelperBase@cppu@@MAAXXZ; +?disposing@WeakComponentImplHelperBase@cppu@@MAAXXZ; +?createOneInstanceFactory@cppu@@YA?AV?$Reference@VXSingleServiceFactory@lang@star@sun@com@@@uno@star@sun@com@@ABV?$Reference@VXMultiServiceFactory@lang@star@sun@com@@@3456@ABVOUString@rtl@@P6A?AV?$Reference@VXInterface@uno@star@sun@com@@@3456@0@ZABV?$Sequence@VOUString@rtl@@@3456@PAU_rtl_ModuleCount@@@Z; +?createSingleComponentFactory@cppu@@YA?AV?$Reference@VXSingleComponentFactory@lang@star@sun@com@@@uno@star@sun@com@@P6A?AV?$Reference@VXInterface@uno@star@sun@com@@@3456@ABV?$Reference@VXComponentContext@uno@star@sun@com@@@3456@@ZABVOUString@rtl@@ABV?$Sequence@VOUString@rtl@@@3456@PAU_rtl_ModuleCount@@@Z; +?createSingleFactory@cppu@@YA?AV?$Reference@VXSingleServiceFactory@lang@star@sun@com@@@uno@star@sun@com@@ABV?$Reference@VXMultiServiceFactory@lang@star@sun@com@@@3456@ABVOUString@rtl@@P6A?AV?$Reference@VXInterface@uno@star@sun@com@@@3456@0@ZABV?$Sequence@VOUString@rtl@@@3456@PAU_rtl_ModuleCount@@@Z; +?defaultBootstrap_InitialComponentContext@cppu@@YA?AV?$Reference@VXComponentContext@uno@star@sun@com@@@uno@star@sun@com@@XZ; +?acquire@OComponentHelper@cppu@@UAAXXZ; +?getTypes@OComponentHelper@cppu@@UAA?AV?$Sequence@VType@uno@star@sun@com@@@uno@star@sun@com@@XZ; +?queryAggregation@OComponentHelper@cppu@@UAA?AVAny@uno@star@sun@com@@ABVType@4567@@Z; +?queryInterface@OComponentHelper@cppu@@UAA?AVAny@uno@star@sun@com@@ABVType@4567@@Z; +?removeListener@?$OBroadcastHelperVar@VOMultiTypeInterfaceContainerHelper@cppu@@VType@uno@star@sun@com@@@cppu@@QAEXABVType@uno@star@sun@com@@ABV?$Reference@VXInterface@uno@star@sun@com@@@4567@@Z; +??0OMultiTypeInterfaceContainerHelper@cppu@@QAE@AAVMutex@osl@@@Z; +??0OMultiTypeInterfaceContainerHelperInt32@cppu@@QAE@AAVMutex@osl@@@Z; +??1OMultiTypeInterfaceContainerHelper@cppu@@QAE@XZ; +??1OMultiTypeInterfaceContainerHelperInt32@cppu@@QAE@XZ; +?addInterface@OMultiTypeInterfaceContainerHelper@cppu@@QAAJABVType@uno@star@sun@com@@ABV?$Reference@VXInterface@uno@star@sun@com@@@4567@@Z; +?addInterface@OMultiTypeInterfaceContainerHelperInt32@cppu@@QAAJABJABV?$Reference@VXInterface@uno@star@sun@com@@@uno@star@sun@com@@@Z; +?clear@OMultiTypeInterfaceContainerHelper@cppu@@QAAXXZ; +?clear@OMultiTypeInterfaceContainerHelperInt32@cppu@@QAAXXZ; +?disposeAndClear@OMultiTypeInterfaceContainerHelper@cppu@@QAAXABUEventObject@lang@star@sun@com@@@Z; +?disposeAndClear@OMultiTypeInterfaceContainerHelperInt32@cppu@@QAAXABUEventObject@lang@star@sun@com@@@Z; +?getContainedTypes@OMultiTypeInterfaceContainerHelper@cppu@@QBA?AV?$Sequence@VType@uno@star@sun@com@@@uno@star@sun@com@@XZ; +?getContainedTypes@OMultiTypeInterfaceContainerHelperInt32@cppu@@QBA?AV?$Sequence@J@uno@star@sun@com@@XZ; +?getContainer@OMultiTypeInterfaceContainerHelper@cppu@@QBAPAVOInterfaceContainerHelper@2@ABVType@uno@star@sun@com@@@Z; +?getContainer@OMultiTypeInterfaceContainerHelperInt32@cppu@@QBAPAVOInterfaceContainerHelper@2@ABJ@Z; +?removeInterface@OMultiTypeInterfaceContainerHelper@cppu@@QAAJABVType@uno@star@sun@com@@ABV?$Reference@VXInterface@uno@star@sun@com@@@4567@@Z; +?removeInterface@OMultiTypeInterfaceContainerHelperInt32@cppu@@QAAJABJABV?$Reference@VXInterface@uno@star@sun@com@@@uno@star@sun@com@@@Z; +??0OPropertySetHelper@cppu@@QAE@AAU?$OBroadcastHelperVar@VOMultiTypeInterfaceContainerHelper@cppu@@VType@uno@star@sun@com@@@1@@Z; +?addListener@?$OBroadcastHelperVar@VOMultiTypeInterfaceContainerHelper@cppu@@VType@uno@star@sun@com@@@cppu@@QAEXABVType@uno@star@sun@com@@ABV?$Reference@VXInterface@uno@star@sun@com@@@4567@@Z; +?component_writeInfoHelper@cppu@@YAEPAX0QBUImplementationEntry@1@@Z; +?component_getFactoryHelper@cppu@@YAPAXPBDPAX1QBUImplementationEntry@1@@Z; +?ImplHelper_query@cppu@@YA?AVAny@uno@star@sun@com@@ABVType@3456@PAUclass_data@1@PAX@Z; +?ImplHelper_queryNoXInterface@cppu@@YA?AVAny@uno@star@sun@com@@ABVType@3456@PAUclass_data@1@PAX@Z; +?ImplHelper_getTypes@cppu@@YA?AV?$Sequence@VType@uno@star@sun@com@@@uno@star@sun@com@@PAUclass_data@1@@Z; +?ImplInhHelper_getTypes@cppu@@YA?AV?$Sequence@VType@uno@star@sun@com@@@uno@star@sun@com@@PAUclass_data@1@ABV23456@@Z; +?ImplHelper_getImplementationId@cppu@@YA?AV?$Sequence@C@uno@star@sun@com@@PAUclass_data@1@@Z; +?WeakImplHelper_query@cppu@@YA?AVAny@uno@star@sun@com@@ABVType@3456@PAUclass_data@1@PAXPAVOWeakObject@1@@Z; +?WeakImplHelper_getTypes@cppu@@YA?AV?$Sequence@VType@uno@star@sun@com@@@uno@star@sun@com@@PAUclass_data@1@@Z; +?WeakAggImplHelper_queryAgg@cppu@@YA?AVAny@uno@star@sun@com@@ABVType@3456@PAUclass_data@1@PAXPAVOWeakAggObject@1@@Z; +?WeakAggComponentImplHelper_getTypes@cppu@@YA?AV?$Sequence@VType@uno@star@sun@com@@@uno@star@sun@com@@PAUclass_data@1@@Z; +?WeakComponentImplHelper_query@cppu@@YA?AVAny@uno@star@sun@com@@ABVType@3456@PAUclass_data@1@PAXPAVWeakComponentImplHelperBase@1@@Z; +?WeakAggImplHelper_getTypes@cppu@@YA?AV?$Sequence@VType@uno@star@sun@com@@@uno@star@sun@com@@PAUclass_data@1@@Z; +?WeakAggComponentImplHelper_queryAgg@cppu@@YA?AVAny@uno@star@sun@com@@ABVType@3456@PAUclass_data@1@PAXPAVWeakAggComponentImplHelperBase@1@@Z; +?WeakComponentImplHelper_getTypes@cppu@@YA?AV?$Sequence@VType@uno@star@sun@com@@@uno@star@sun@com@@PAUclass_data@1@@Z; +?defaultBootstrap_InitialComponentContext@cppu@@YA?AV?$Reference@VXComponentContext@uno@star@sun@com@@@uno@star@sun@com@@ABVOUString@rtl@@@Z; + +??0AccessControl@cppu@@QAE@ABV?$Reference@VXComponentContext@uno@star@sun@com@@@uno@star@sun@com@@@Z; +??0AccessControl@cppu@@QAE@ABV?$Reference@VXAccessController@security@star@sun@com@@@uno@star@sun@com@@@Z; +??0AccessControl@cppu@@QAE@ABV01@@Z; +?checkRuntimePermission@AccessControl@cppu@@QAAXABVOUString@rtl@@@Z; +?checkFilePermission@AccessControl@cppu@@QAAXABVOUString@rtl@@0@Z; +?checkSocketPermission@AccessControl@cppu@@QAAXABVOUString@rtl@@0@Z; + +??0UnoUrl@cppu@@QAE@ABV01@@Z; +??0UnoUrl@cppu@@QAE@ABVOUString@rtl@@@Z; +??0UnoUrlDescriptor@cppu@@QAE@ABV01@@Z; +??0UnoUrlDescriptor@cppu@@QAE@ABVOUString@rtl@@@Z; +??1UnoUrl@cppu@@QAE@XZ; +??1UnoUrlDescriptor@cppu@@QAE@XZ; +??4UnoUrl@cppu@@QAEAAV01@ABV01@@Z; +??4UnoUrlDescriptor@cppu@@QAEAAV01@ABV01@@Z; +?getConnection@UnoUrl@cppu@@QBEABVUnoUrlDescriptor@2@XZ; +?getDescriptor@UnoUrlDescriptor@cppu@@QBEABVOUString@rtl@@XZ; +?getName@UnoUrlDescriptor@cppu@@QBEABVOUString@rtl@@XZ; +?getObjectName@UnoUrl@cppu@@QBEABVOUString@rtl@@XZ; +?getParameter@UnoUrlDescriptor@cppu@@QBE?AVOUString@rtl@@ABV34@@Z; +?getProtocol@UnoUrl@cppu@@QBEABVUnoUrlDescriptor@2@XZ; +?hasParameter@UnoUrlDescriptor@cppu@@QBE_NABVOUString@rtl@@@Z; + + local: + *; +}; + +UDK_3.1 { + global: + ?getCaughtException@cppu@@YA?AVAny@uno@star@sun@com@@XZ; + + ??0OPropertySetHelper@cppu@@QAE@AAU?$OBroadcastHelperVar@VOMultiTypeInterfaceContainerHelper@cppu@@VType@uno@star@sun@com@@@1@_N@Z; + + ?bootstrap@cppu@@YA?AV?$Reference@VXComponentContext@uno@star@sun@com@@@uno@star@sun@com@@XZ; + ??0BootstrapException@cppu@@QAE@XZ; + ??0BootstrapException@cppu@@QAE@ABVOUString@rtl@@@Z; + ??0BootstrapException@cppu@@QAE@ABV01@@Z; + ??1BootstrapException@cppu@@UAE@XZ; + ??4BootstrapException@cppu@@QAEAAV01@ABV01@@Z; + ?getMessage@BootstrapException@cppu@@QBEABVOUString@rtl@@XZ; +} UDK_3_0_0; + +UDK_3.2 { + global: + ??1PropertySetMixinImpl@cppu@@AAE@XZ; + ?queryInterface@PropertySetMixinImpl@cppu@@MAA?AVAny@uno@star@sun@com@@ABVType@4567@@Z; + ?getPropertySetInfo@PropertySetMixinImpl@cppu@@MAA?AV?$Reference@VXPropertySetInfo@beans@star@sun@com@@@uno@star@sun@com@@XZ; + ?notify@BoundListeners@PropertySetMixinImpl@cppu@@QBEXXZ; + ?setPropertyValue@PropertySetMixinImpl@cppu@@MAAXABVOUString@rtl@@ABVAny@uno@star@sun@com@@@Z; + ?getPropertyValue@PropertySetMixinImpl@cppu@@MAA?AVAny@uno@star@sun@com@@ABVOUString@rtl@@@Z; + ?removePropertyChangeListener@PropertySetMixinImpl@cppu@@MAAXABVOUString@rtl@@ABV?$Reference@VXPropertyChangeListener@beans@star@sun@com@@@uno@star@sun@com@@@Z; + ?removeVetoableChangeListener@PropertySetMixinImpl@cppu@@MAAXABVOUString@rtl@@ABV?$Reference@VXVetoableChangeListener@beans@star@sun@com@@@uno@star@sun@com@@@Z; + ?setFastPropertyValue@PropertySetMixinImpl@cppu@@MAAXJABVAny@uno@star@sun@com@@@Z; + ?getFastPropertyValue@PropertySetMixinImpl@cppu@@MAA?AVAny@uno@star@sun@com@@J@Z; + ?getPropertyValues@PropertySetMixinImpl@cppu@@MAA?AV?$Sequence@UPropertyValue@beans@star@sun@com@@@uno@star@sun@com@@XZ; + ?setPropertyValues@PropertySetMixinImpl@cppu@@MAAXABV?$Sequence@UPropertyValue@beans@star@sun@com@@@uno@star@sun@com@@@Z; + ?prepareSet@PropertySetMixinImpl@cppu@@IAEXABVOUString@rtl@@ABVAny@uno@star@sun@com@@1PAVBoundListeners@12@@Z; + ??0BoundListeners@PropertySetMixinImpl@cppu@@QAE@XZ; + ??1BoundListeners@PropertySetMixinImpl@cppu@@QAE@XZ; + ??0PropertySetMixinImpl@cppu@@AAE@ABV?$Reference@VXComponentContext@uno@star@sun@com@@@uno@star@sun@com@@W4Implements@01@ABV?$Sequence@VOUString@rtl@@@3456@ABVType@3456@@Z; + ?dispose@PropertySetMixinImpl@cppu@@IAEXXZ; + ?addPropertyChangeListener@PropertySetMixinImpl@cppu@@MAAXABVOUString@rtl@@ABV?$Reference@VXPropertyChangeListener@beans@star@sun@com@@@uno@star@sun@com@@@Z; + ?addVetoableChangeListener@PropertySetMixinImpl@cppu@@MAAXABVOUString@rtl@@ABV?$Reference@VXVetoableChangeListener@beans@star@sun@com@@@uno@star@sun@com@@@Z; +} UDK_3.1; + +UDK_3.3 { + global: + ?getTypes@OPropertySetHelper@cppu@@QAE?AV?$Sequence@VType@uno@star@sun@com@@@uno@star@sun@com@@XZ; +} UDK_3.2; + +UDK_3.4 { # OOo 2.4 + global: + ?bootstrap_expandUri@cppu@@YA?AVOUString@rtl@@ABV23@@Z; # rtl::OUString cppu::bootstrap_expandUri(rtl::OUString const &) +} UDK_3.3; + +UDK_3.5 { # OOo 3.0 + global: + ??0OPropertySetHelper@cppu@@QAE@AAU?$OBroadcastHelperVar@VOMultiTypeInterfaceContainerHelper@cppu@@VType@uno@star@sun@com@@@1@PAVIEventNotificationHook@1@_N@Z; +} UDK_3.4; + +UDK_3.6 { # OOo 3.3 + global: + ?disposeWeakConnectionPoint@OWeakObject@cppu@@IAEXXZ; + ?clear@WeakReferenceHelper@uno@star@sun@com@@QAAXXZ; + ?createOneInstanceComponentFactory@cppu@@YA?AV?$Reference@VXSingleComponentFactory@lang@star@sun@com@@@uno@star@sun@com@@P6A?AV?$Reference@VXInterface@uno@star@sun@com@@@3456@ABV?$Reference@VXComponentContext@uno@star@sun@com@@@3456@@ZABVOUString@rtl@@ABV?$Sequence@VOUString@rtl@@@3456@PAU_rtl_ModuleCount@@@Z; +} UDK_3.5; diff --git a/cppuhelper/source/propertysetmixin.cxx b/cppuhelper/source/propertysetmixin.cxx new file mode 100644 index 000000000000..bee27129e7b5 --- /dev/null +++ b/cppuhelper/source/propertysetmixin.cxx @@ -0,0 +1,1431 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_cppuhelper.hxx" + +#include "sal/config.h" + +#include "cppuhelper/propertysetmixin.hxx" + +#include "com/sun/star/beans/Property.hpp" +#include "com/sun/star/beans/PropertyChangeEvent.hpp" +#include "com/sun/star/beans/PropertyAttribute.hpp" +#include "com/sun/star/beans/PropertyValue.hpp" +#include "com/sun/star/beans/PropertyVetoException.hpp" +#include "com/sun/star/beans/UnknownPropertyException.hpp" +#include "com/sun/star/beans/XFastPropertySet.hpp" +#include "com/sun/star/beans/XPropertyAccess.hpp" +#include "com/sun/star/beans/XPropertyChangeListener.hpp" +#include "com/sun/star/beans/XPropertySet.hpp" +#include "com/sun/star/beans/XPropertySetInfo.hpp" +#include "com/sun/star/beans/XVetoableChangeListener.hpp" +#include "com/sun/star/container/NoSuchElementException.hpp" +#include "com/sun/star/container/XHierarchicalNameAccess.hpp" +#include "com/sun/star/lang/DisposedException.hpp" +#include "com/sun/star/lang/EventObject.hpp" +#include "com/sun/star/lang/IllegalAccessException.hpp" +#include "com/sun/star/lang/IllegalArgumentException.hpp" +#include "com/sun/star/lang/WrappedTargetException.hpp" +#include "com/sun/star/lang/WrappedTargetRuntimeException.hpp" +#include "com/sun/star/lang/XComponent.hpp" +#include "com/sun/star/lang/XMultiComponentFactory.hpp" +#include "com/sun/star/reflection/XCompoundTypeDescription.hpp" +#include "com/sun/star/reflection/XIdlClass.hpp" +#include "com/sun/star/reflection/XIdlField2.hpp" +#include "com/sun/star/reflection/XIdlReflection.hpp" +#include "com/sun/star/reflection/XIndirectTypeDescription.hpp" +#include "com/sun/star/reflection/XInterfaceAttributeTypeDescription2.hpp" +#include "com/sun/star/reflection/XInterfaceMemberTypeDescription.hpp" +#include "com/sun/star/reflection/XInterfaceTypeDescription2.hpp" +#include "com/sun/star/reflection/XStructTypeDescription.hpp" +#include "com/sun/star/reflection/XTypeDescription.hpp" +#include "com/sun/star/uno/Any.hxx" +#include "com/sun/star/uno/DeploymentException.hpp" +#include "com/sun/star/uno/Exception.hpp" +#include "com/sun/star/uno/Reference.hxx" +#include "com/sun/star/uno/RuntimeException.hpp" +#include "com/sun/star/uno/Sequence.hxx" +#include "com/sun/star/uno/Type.hxx" +#include "com/sun/star/uno/TypeClass.hpp" +#include "com/sun/star/uno/XComponentContext.hpp" +#include "com/sun/star/uno/XInterface.hpp" +#include "cppuhelper/implbase1.hxx" +#include "cppuhelper/weak.hxx" +#include "osl/diagnose.h" +#include "osl/mutex.hxx" +#include "rtl/ref.hxx" +#include "rtl/string.h" +#include "rtl/ustring.h" +#include "rtl/ustring.hxx" +#include "sal/types.h" +#include "salhelper/simplereferenceobject.hxx" + +#include <algorithm> +#include <map> +#include <new> +#include <set> +#include <vector> + +using cppu::PropertySetMixinImpl; + +namespace css = com::sun::star; + +namespace { + +template< typename T > struct AutoDispose { + AutoDispose() {} + + ~AutoDispose() { + try { + dispose(); + } catch (...) {} + } + + void dispose() { + css::uno::Reference< css::lang::XComponent > comp( + ifc, css::uno::UNO_QUERY); + if (comp.is()) { + comp->dispose(); + } + ifc.clear(); + } + + css::uno::Reference< T > ifc; + +private: + AutoDispose(AutoDispose &); // not defined + void operator =(AutoDispose); // not defined +}; + +struct PropertyData { + explicit PropertyData( + css::beans::Property const & theProperty, bool thePresent): + property(theProperty), present(thePresent) {} + + css::beans::Property property; + bool present; +}; + +struct Data: public salhelper::SimpleReferenceObject { + typedef std::map< rtl::OUString, PropertyData > PropertyMap; + + PropertyMap properties; + + PropertyMap::const_iterator get( + css::uno::Reference< css::uno::XInterface > const & object, + rtl::OUString const & name) const; + +protected: + void initProperties( + css::uno::Reference< css::reflection::XTypeDescription > const & type, + css::uno::Sequence< rtl::OUString > const & absentOptional, + std::vector< rtl::OUString > * handleNames) + { + TypeSet seen; + initProperties(type, absentOptional, handleNames, &seen); + } + +private: + typedef std::set< rtl::OUString > TypeSet; + + void initProperties( + css::uno::Reference< css::reflection::XTypeDescription > const & type, + css::uno::Sequence< rtl::OUString > const & absentOptional, + std::vector< rtl::OUString > * handleNames, TypeSet * seen); + + static css::uno::Reference< css::reflection::XTypeDescription > + resolveTypedefs( + css::uno::Reference< css::reflection::XTypeDescription > const & type); +}; + +Data::PropertyMap::const_iterator Data::get( + css::uno::Reference< css::uno::XInterface > const & object, + rtl::OUString const & name) const +{ + PropertyMap::const_iterator i(properties.find(name)); + if (i == properties.end() || !i->second.present) { + throw css::beans::UnknownPropertyException(name, object); + } + return i; +} + +void Data::initProperties( + css::uno::Reference< css::reflection::XTypeDescription > const & type, + css::uno::Sequence< rtl::OUString > const & absentOptional, + std::vector< rtl::OUString > * handleNames, TypeSet * seen) +{ + css::uno::Reference< css::reflection::XInterfaceTypeDescription2 > ifc( + resolveTypedefs(type), css::uno::UNO_QUERY_THROW); + if (seen->insert(ifc->getName()).second) { + css::uno::Sequence< + css::uno::Reference< css::reflection::XTypeDescription > > bases( + ifc->getBaseTypes()); + for (sal_Int32 i = 0; i < bases.getLength(); ++i) { + initProperties(bases[i], absentOptional, handleNames, seen); + } + css::uno::Sequence< + css::uno::Reference< + css::reflection::XInterfaceMemberTypeDescription > > members( + ifc->getMembers()); + rtl::OUString const * absentBegin = absentOptional.getConstArray(); + rtl::OUString const * absentEnd = + absentBegin + absentOptional.getLength(); + for (sal_Int32 i = 0; i < members.getLength(); ++i) { + if (members[i]->getTypeClass() + == css::uno::TypeClass_INTERFACE_ATTRIBUTE) + { + css::uno::Reference< + css::reflection::XInterfaceAttributeTypeDescription2 > attr( + members[i], css::uno::UNO_QUERY_THROW); + sal_Int16 attrAttribs = 0; + if (attr->isBound()) { + attrAttribs |= css::beans::PropertyAttribute::BOUND; + } + bool setUnknown = false; + if (attr->isReadOnly()) { + attrAttribs |= css::beans::PropertyAttribute::READONLY; + setUnknown = true; + } + css::uno::Sequence< + css::uno::Reference< + css::reflection::XCompoundTypeDescription > > excs( + attr->getGetExceptions()); + bool getUnknown = false; + //XXX Special interpretation of getter/setter exceptions only + // works if the specified exceptions are of the exact type, not + // of a supertype: + for (sal_Int32 j = 0; j < excs.getLength(); ++j) { + if (excs[j]->getName().equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM( + "com.sun.star.beans.UnknownPropertyException"))) + { + getUnknown = true; + break; + } + } + excs = attr->getSetExceptions(); + for (sal_Int32 j = 0; j < excs.getLength(); ++j) { + if (excs[j]->getName().equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM( + "com.sun.star.beans.UnknownPropertyException"))) + { + setUnknown = true; + } else if (excs[j]->getName().equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM( + "com.sun.star.beans." + "PropertyVetoException"))) + { + attrAttribs + |= css::beans::PropertyAttribute::CONSTRAINED; + } + } + if (getUnknown && setUnknown) { + attrAttribs |= css::beans::PropertyAttribute::OPTIONAL; + } + css::uno::Reference< css::reflection::XTypeDescription > t( + attr->getType()); + for (;;) + { + t = resolveTypedefs(t); + sal_Int16 n; + if (t->getName().matchAsciiL( + RTL_CONSTASCII_STRINGPARAM( + "com.sun.star.beans.Ambiguous<"))) + { + n = css::beans::PropertyAttribute::MAYBEAMBIGUOUS; + } else if (t->getName().matchAsciiL( + RTL_CONSTASCII_STRINGPARAM( + "com.sun.star.beans.Defaulted<"))) + { + n = css::beans::PropertyAttribute::MAYBEDEFAULT; + } else if (t->getName().matchAsciiL( + RTL_CONSTASCII_STRINGPARAM( + "com.sun.star.beans.Optional<"))) + { + n = css::beans::PropertyAttribute::MAYBEVOID; + } else { + break; + } + if ((attrAttribs & n) != 0) { + break; + } + attrAttribs |= n; + css::uno::Sequence< + css::uno::Reference< css::reflection::XTypeDescription > > + args( + css::uno::Reference< + css::reflection::XStructTypeDescription >( + t, + css::uno::UNO_QUERY_THROW)->getTypeArguments()); + if (args.getLength() != 1) { + throw css::uno::RuntimeException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "inconsistent UNO type registry")), + css::uno::Reference< css::uno::XInterface >()); + } + t = args[0]; + } + std::vector< rtl::OUString >::size_type handles + = handleNames->size(); + if (handles > SAL_MAX_INT32) { + throw css::uno::RuntimeException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "interface type has too many attributes")), + css::uno::Reference< css::uno::XInterface >()); + } + rtl::OUString name(members[i]->getMemberName()); + if (!properties.insert( + PropertyMap::value_type( + name, + PropertyData( + css::beans::Property( + name, static_cast< sal_Int32 >(handles), + css::uno::Type( + t->getTypeClass(), t->getName()), + attrAttribs), + (std::find(absentBegin, absentEnd, name) + == absentEnd)))). + second) + { + throw css::uno::RuntimeException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "inconsistent UNO type registry")), + css::uno::Reference< css::uno::XInterface >()); + } + handleNames->push_back(name); + } + } + } +} + +css::uno::Reference< css::reflection::XTypeDescription > Data::resolveTypedefs( + css::uno::Reference< css::reflection::XTypeDescription > const & type) +{ + css::uno::Reference< css::reflection::XTypeDescription > t(type); + while (t->getTypeClass() == css::uno::TypeClass_TYPEDEF) { + t = css::uno::Reference< css::reflection::XIndirectTypeDescription >( + t, css::uno::UNO_QUERY_THROW)->getReferencedType(); + } + return t; +} + +class Info: public cppu::WeakImplHelper1< css::beans::XPropertySetInfo > { +public: + explicit Info(Data * data): m_data(data) {} + + virtual css::uno::Sequence< css::beans::Property > SAL_CALL getProperties() + throw (css::uno::RuntimeException); + + virtual css::beans::Property SAL_CALL getPropertyByName( + rtl::OUString const & name) + throw ( + css::beans::UnknownPropertyException, css::uno::RuntimeException); + + virtual sal_Bool SAL_CALL hasPropertyByName(rtl::OUString const & name) + throw (css::uno::RuntimeException); + +private: + rtl::Reference< Data > m_data; +}; + +css::uno::Sequence< css::beans::Property > Info::getProperties() + throw (css::uno::RuntimeException) +{ + try { + OSL_ASSERT(m_data->properties.size() <= SAL_MAX_INT32); + css::uno::Sequence< css::beans::Property > s( + static_cast< sal_Int32 >(m_data->properties.size())); + sal_Int32 n = 0; + for (Data::PropertyMap::iterator i(m_data->properties.begin()); + i != m_data->properties.end(); ++i) + { + if (i->second.present) { + s[n++] = i->second.property; + } + } + s.realloc(n); + return s; + } catch (std::bad_alloc &) { + //TODO OutOfMemoryException: + throw css::uno::RuntimeException( + rtl::OUString(), static_cast< cppu::OWeakObject * >(this)); + } +} + +css::beans::Property Info::getPropertyByName(rtl::OUString const & name) + throw (css::beans::UnknownPropertyException, css::uno::RuntimeException) +{ + return m_data->get(static_cast< cppu::OWeakObject * >(this), name)-> + second.property; +} + +sal_Bool Info::hasPropertyByName(rtl::OUString const & name) + throw (css::uno::RuntimeException) +{ + Data::PropertyMap::iterator i(m_data->properties.find(name)); + return i != m_data->properties.end() && i->second.present; +} + +typedef +std::multiset< css::uno::Reference< css::beans::XPropertyChangeListener > > +BoundListenerBag; + +} + +class PropertySetMixinImpl::BoundListeners::Impl { +public: + BoundListenerBag specificListeners; + BoundListenerBag unspecificListeners; + css::beans::PropertyChangeEvent event; +}; + +PropertySetMixinImpl::BoundListeners::BoundListeners(): m_impl(new Impl) {} + +PropertySetMixinImpl::BoundListeners::~BoundListeners() { + delete m_impl; +} + +void PropertySetMixinImpl::BoundListeners::notify() const { + for (BoundListenerBag::const_iterator i(m_impl->specificListeners.begin()); + i != m_impl->specificListeners.end(); ++i) + { + try { + (*i)->propertyChange(m_impl->event); + } catch (css::lang::DisposedException &) {} + } + for (BoundListenerBag::const_iterator i( + m_impl->unspecificListeners.begin()); + i != m_impl->unspecificListeners.end(); ++i) + { + try { + (*i)->propertyChange(m_impl->event); + } catch (css::lang::DisposedException &) {} + } +} + +class PropertySetMixinImpl::Impl: public Data { +public: + Impl( + css::uno::Reference< css::uno::XComponentContext > const & context, + Implements theImplements, + css::uno::Sequence< rtl::OUString > const & absentOptional, + css::uno::Type const & type); + + rtl::OUString translateHandle( + css::uno::Reference< css::uno::XInterface > const & object, + sal_Int32 handle) const; + + void setProperty( + css::uno::Reference< css::uno::XInterface > const & object, + rtl::OUString const & name, css::uno::Any const & value, + bool isAmbiguous, bool isDefaulted, sal_Int16 illegalArgumentPosition) + const; + + css::uno::Any getProperty( + css::uno::Reference< css::uno::XInterface > const & object, + rtl::OUString const & name, css::beans::PropertyState * state) const; + + PropertySetMixinImpl::Implements implements; + css::uno::Sequence< rtl::OUString > handleMap; + + typedef std::map< rtl::OUString, BoundListenerBag > BoundListenerMap; + + typedef + std::multiset< css::uno::Reference< css::beans::XVetoableChangeListener > > + VetoListenerBag; + + typedef std::map< rtl::OUString, VetoListenerBag > VetoListenerMap; + + mutable osl::Mutex mutex; + BoundListenerMap boundListeners; + VetoListenerMap vetoListeners; + bool disposed; + +private: + css::uno::Reference< css::reflection::XIdlClass > getReflection( + rtl::OUString const & typeName) const; + + static css::uno::Any wrapValue( + css::uno::Reference< css::uno::XInterface > const & object, + css::uno::Any const & value, + css::uno::Reference< css::reflection::XIdlClass > const & type, + bool wrapAmbiguous, bool isAmbiguous, bool wrapDefaulted, + bool isDefaulted, bool wrapOptional); + + css::uno::Reference< css::uno::XComponentContext > const & m_context; + css::uno::Sequence< rtl::OUString > m_absentOptional; + css::uno::Type m_type; + css::uno::Reference< css::reflection::XIdlClass > m_idlClass; +}; + +PropertySetMixinImpl::Impl::Impl( + css::uno::Reference< css::uno::XComponentContext > const & context, + Implements theImplements, + css::uno::Sequence< rtl::OUString > const & absentOptional, + css::uno::Type const & type): + implements(theImplements), disposed(false), m_context(context), + m_absentOptional(absentOptional), m_type(type) +{ + OSL_ASSERT( + context.is() + && ((implements + & ~(IMPLEMENTS_PROPERTY_SET | IMPLEMENTS_FAST_PROPERTY_SET + | IMPLEMENTS_PROPERTY_ACCESS)) + == 0)); + m_idlClass = getReflection(m_type.getTypeName()); + css::uno::Reference< css::reflection::XTypeDescription > ifc; + try { + ifc = css::uno::Reference< css::reflection::XTypeDescription >( + css::uno::Reference< css::container::XHierarchicalNameAccess >( + m_context->getValueByName( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "/singletons/com.sun.star.reflection." + "theTypeDescriptionManager"))), + css::uno::UNO_QUERY_THROW)->getByHierarchicalName( + m_type.getTypeName()), + css::uno::UNO_QUERY_THROW); + } catch (css::container::NoSuchElementException & e) { + throw css::uno::RuntimeException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "unexpected" + " com.sun.star.container.NoSuchElementException: ")) + + e.Message), + css::uno::Reference< css::uno::XInterface >()); + } + std::vector< rtl::OUString > handleNames; + initProperties(ifc, m_absentOptional, &handleNames); + std::vector< rtl::OUString >::size_type size = handleNames.size(); + OSL_ASSERT(size <= SAL_MAX_INT32); + handleMap.realloc(static_cast< sal_Int32 >(size)); + std::copy(handleNames.begin(), handleNames.end(), handleMap.getArray()); +} + +rtl::OUString PropertySetMixinImpl::Impl::translateHandle( + css::uno::Reference< css::uno::XInterface > const & object, + sal_Int32 handle) const +{ + if (handle < 0 || handle >= handleMap.getLength()) { + throw css::beans::UnknownPropertyException( + (rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("bad handle ")) + + rtl::OUString::valueOf(handle)), + object); + } + return handleMap[handle]; +} + +void PropertySetMixinImpl::Impl::setProperty( + css::uno::Reference< css::uno::XInterface > const & object, + rtl::OUString const & name, css::uno::Any const & value, bool isAmbiguous, + bool isDefaulted, sal_Int16 illegalArgumentPosition) const +{ + PropertyMap::const_iterator i(properties.find(name)); + if (i == properties.end()) { + throw css::beans::UnknownPropertyException(name, object); + } + if ((isAmbiguous + && ((i->second.property.Attributes + & css::beans::PropertyAttribute::MAYBEAMBIGUOUS) + == 0)) + || (isDefaulted + && ((i->second.property.Attributes + & css::beans::PropertyAttribute::MAYBEDEFAULT) + == 0))) + { + throw css::lang::IllegalArgumentException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "flagging as ambiguous/defaulted non-ambiguous/defaulted" + " property ")) + + name), + object, illegalArgumentPosition); + } + css::uno::Reference< css::reflection::XIdlField2 > f( + m_idlClass->getField(name), css::uno::UNO_QUERY_THROW); + css::uno::Any o(object->queryInterface(m_type)); + css::uno::Any v( + wrapValue( + object, value, + (css::uno::Reference< css::reflection::XIdlField2 >( + m_idlClass->getField(name), css::uno::UNO_QUERY_THROW)-> + getType()), + ((i->second.property.Attributes + & css::beans::PropertyAttribute::MAYBEAMBIGUOUS) + != 0), + isAmbiguous, + ((i->second.property.Attributes + & css::beans::PropertyAttribute::MAYBEDEFAULT) + != 0), + isDefaulted, + ((i->second.property.Attributes + & css::beans::PropertyAttribute::MAYBEVOID) + != 0))); + try { + f->set(o, v); + } catch (css::lang::IllegalArgumentException & e) { + if (e.ArgumentPosition == 1) { + throw css::lang::IllegalArgumentException( + e.Message, object, illegalArgumentPosition); + } else { + throw css::uno::RuntimeException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "unexpected" + " com.sun.star.lang.IllegalArgumentException: ")) + + e.Message), + object); + } + } catch (css::lang::IllegalAccessException &) { + //TODO Clarify whether PropertyVetoException is the correct exception + // to throw when trying to set a read-only property: + throw css::beans::PropertyVetoException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("cannot set read-only property ")) + + name), + object); + } catch (css::lang::WrappedTargetRuntimeException & e) { + //FIXME A WrappedTargetRuntimeException from XIdlField2.get is not + // guaranteed to originate directly within XIdlField2.get (and thus have + // the expected semantics); it might also be passed through from lower + // layers. + if (e.TargetException.isExtractableTo( + getCppuType( + static_cast< css::beans::UnknownPropertyException * >(0))) + && ((i->second.property.Attributes + & css::beans::PropertyAttribute::OPTIONAL) + != 0)) + { + throw css::beans::UnknownPropertyException(name, object); + } else if (e.TargetException.isExtractableTo( + getCppuType( + static_cast< css::beans::PropertyVetoException * >( + 0))) + && ((i->second.property.Attributes + & css::beans::PropertyAttribute::CONSTRAINED) + != 0)) + { + throw css::beans::PropertyVetoException(name, object); + } else { + throw css::lang::WrappedTargetException( + e.Message, object, e.TargetException); + } + } +} + +css::uno::Any PropertySetMixinImpl::Impl::getProperty( + css::uno::Reference< css::uno::XInterface > const & object, + rtl::OUString const & name, css::beans::PropertyState * state) const +{ + PropertyMap::const_iterator i(properties.find(name)); + if (i == properties.end()) { + throw css::beans::UnknownPropertyException(name, object); + } + css::uno::Reference< css::reflection::XIdlField2 > field( + m_idlClass->getField(name), css::uno::UNO_QUERY_THROW); + css::uno::Any value; + try { + value = field->get(object->queryInterface(m_type)); + } catch (css::lang::IllegalArgumentException & e) { + throw css::uno::RuntimeException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "unexpected com.sun.star.lang.IllegalArgumentException: ")) + + e.Message), + object); + } catch (css::lang::WrappedTargetRuntimeException & e) { + //FIXME A WrappedTargetRuntimeException from XIdlField2.get is not + // guaranteed to originate directly within XIdlField2.get (and thus have + // the expected semantics); it might also be passed through from lower + // layers. + if (e.TargetException.isExtractableTo( + getCppuType( + static_cast< css::beans::UnknownPropertyException * >(0))) + && ((i->second.property.Attributes + & css::beans::PropertyAttribute::OPTIONAL) + != 0)) + { + throw css::beans::UnknownPropertyException(name, object); + } else { + throw css::lang::WrappedTargetException( + e.Message, object, e.TargetException); + } + } + bool undoAmbiguous + = ((i->second.property.Attributes + & css::beans::PropertyAttribute::MAYBEAMBIGUOUS) + != 0); + bool undoDefaulted + = ((i->second.property.Attributes + & css::beans::PropertyAttribute::MAYBEDEFAULT) + != 0); + bool undoOptional + = ((i->second.property.Attributes + & css::beans::PropertyAttribute::MAYBEVOID) + != 0); + bool isAmbiguous = false; + bool isDefaulted = false; + while (undoAmbiguous || undoDefaulted || undoOptional) { + if (undoAmbiguous + && value.getValueTypeName().matchAsciiL( + RTL_CONSTASCII_STRINGPARAM("com.sun.star.beans.Ambiguous<"))) + { + css::uno::Reference< css::reflection::XIdlClass > ambiguous( + getReflection(value.getValueTypeName())); + try { + if (!(css::uno::Reference< css::reflection::XIdlField2 >( + ambiguous->getField( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("IsAmbiguous"))), + css::uno::UNO_QUERY_THROW)->get(value) + >>= isAmbiguous)) + { + throw css::uno::RuntimeException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "unexpected type of" + " com.sun.star.beans.Ambiguous IsAmbiguous" + " member")), + object); + } + value = css::uno::Reference< css::reflection::XIdlField2 >( + ambiguous->getField( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Value"))), + css::uno::UNO_QUERY_THROW)->get(value); + } catch (css::lang::IllegalArgumentException & e) { + throw css::uno::RuntimeException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "unexpected com.sun.star.lang." + "IllegalArgumentException: ")) + + e.Message), + object); + } + undoAmbiguous = false; + } else if (undoDefaulted + && value.getValueTypeName().matchAsciiL( + RTL_CONSTASCII_STRINGPARAM( + "com.sun.star.beans.Defaulted<"))) + { + css::uno::Reference< css::reflection::XIdlClass > defaulted( + getReflection(value.getValueTypeName())); + try { + + if (!(css::uno::Reference< css::reflection::XIdlField2 >( + defaulted->getField( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("IsDefaulted"))), + css::uno::UNO_QUERY_THROW)->get(value) + >>= isDefaulted)) + { + throw css::uno::RuntimeException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "unexpected type of" + " com.sun.star.beans.Defaulted IsDefaulted" + " member")), + object); + } + value = css::uno::Reference< css::reflection::XIdlField2 >( + defaulted->getField( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Value"))), + css::uno::UNO_QUERY_THROW)->get(value); + } catch (css::lang::IllegalArgumentException & e) { + throw css::uno::RuntimeException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "unexpected com.sun.star.lang." + "IllegalArgumentException: ")) + + e.Message), + object); + } + undoDefaulted = false; + } else if (undoOptional + && value.getValueTypeName().matchAsciiL( + RTL_CONSTASCII_STRINGPARAM( + "com.sun.star.beans.Optional<"))) + { + css::uno::Reference< css::reflection::XIdlClass > optional( + getReflection(value.getValueTypeName())); + try { + bool present = false; + if (!(css::uno::Reference< css::reflection::XIdlField2 >( + optional->getField( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("IsPresent"))), + css::uno::UNO_QUERY_THROW)->get(value) + >>= present)) + { + throw css::uno::RuntimeException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "unexpected type of com.sun.star.beans.Optional" + " IsPresent member")), + object); + } + if (!present) { + value.clear(); + break; + } + value = css::uno::Reference< css::reflection::XIdlField2 >( + optional->getField( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Value"))), + css::uno::UNO_QUERY_THROW)->get(value); + } catch (css::lang::IllegalArgumentException & e) { + throw css::uno::RuntimeException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "unexpected com.sun.star.lang." + "IllegalArgumentException: ")) + + e.Message), + object); + } + undoOptional = false; + } else { + throw css::uno::RuntimeException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "unexpected type of attribute ")) + + name), + object); + } + } + if (state != 0) { + //XXX If isAmbiguous && isDefaulted, arbitrarily choose AMBIGUOUS_VALUE + // over DEFAULT_VALUE: + *state = isAmbiguous + ? css::beans::PropertyState_AMBIGUOUS_VALUE + : isDefaulted + ? css::beans::PropertyState_DEFAULT_VALUE + : css::beans::PropertyState_DIRECT_VALUE; + } + return value; +} + +css::uno::Reference< css::reflection::XIdlClass > +PropertySetMixinImpl::Impl::getReflection(rtl::OUString const & typeName) const +{ + css::uno::Reference< css::lang::XMultiComponentFactory > factory( + m_context->getServiceManager(), css::uno::UNO_QUERY_THROW); + AutoDispose< css::reflection::XIdlReflection > refl; + try { + refl.ifc = css::uno::Reference< css::reflection::XIdlReflection >( + factory->createInstanceWithContext( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.reflection.CoreReflection")), + m_context), + css::uno::UNO_QUERY_THROW); + } catch (css::uno::RuntimeException &) { + throw; + } catch (css::uno::Exception & e) { + throw css::uno::DeploymentException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "component context fails to supply service" + " com.sun.star.reflection.CoreReflection: ")) + + e.Message), + m_context); + } + css::uno::Reference< css::reflection::XIdlClass > idlClass( + refl.ifc->forName(typeName), css::uno::UNO_QUERY_THROW); + refl.dispose(); + return idlClass; +} + +css::uno::Any PropertySetMixinImpl::Impl::wrapValue( + css::uno::Reference< css::uno::XInterface > const & object, + css::uno::Any const & value, + css::uno::Reference< css::reflection::XIdlClass > const & type, + bool wrapAmbiguous, bool isAmbiguous, bool wrapDefaulted, bool isDefaulted, + bool wrapOptional) +{ + OSL_ASSERT( + (wrapAmbiguous || !isAmbiguous) && (wrapDefaulted || !isDefaulted)); + if (wrapAmbiguous + && type->getName().matchAsciiL( + RTL_CONSTASCII_STRINGPARAM("com.sun.star.beans.Ambiguous<"))) + { + css::uno::Any strct; + type->createObject(strct); + try { + css::uno::Reference< css::reflection::XIdlField2 > field( + type->getField( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("Value"))), + css::uno::UNO_QUERY_THROW); + field->set( + strct, + wrapValue( + object, value, field->getType(), false, false, + wrapDefaulted, isDefaulted, wrapOptional)); + css::uno::Reference< css::reflection::XIdlField2 >( + type->getField( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("IsAmbiguous"))), + css::uno::UNO_QUERY_THROW)->set( + strct, css::uno::makeAny(isAmbiguous)); + } catch (css::lang::IllegalArgumentException & e) { + throw css::uno::RuntimeException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "unexpected" + " com.sun.star.lang.IllegalArgumentException: ")) + + e.Message), + object); + } catch (css::lang::IllegalAccessException & e) { + throw css::uno::RuntimeException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "unexpected" + " com.sun.star.lang.IllegalAccessException: ")) + + e.Message), + object); + } + return strct; + } else if (wrapDefaulted + && type->getName().matchAsciiL( + RTL_CONSTASCII_STRINGPARAM("com.sun.star.beans.Defaulted<"))) + { + css::uno::Any strct; + type->createObject(strct); + try { + css::uno::Reference< css::reflection::XIdlField2 > field( + type->getField( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("Value"))), + css::uno::UNO_QUERY_THROW); + field->set( + strct, + wrapValue( + object, value, field->getType(), wrapAmbiguous, isAmbiguous, + false, false, wrapOptional)); + css::uno::Reference< css::reflection::XIdlField2 >( + type->getField( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("IsDefaulted"))), + css::uno::UNO_QUERY_THROW)->set( + strct, css::uno::makeAny(isDefaulted)); + } catch (css::lang::IllegalArgumentException & e) { + throw css::uno::RuntimeException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "unexpected" + " com.sun.star.lang.IllegalArgumentException: ")) + + e.Message), + object); + } catch (css::lang::IllegalAccessException & e) { + throw css::uno::RuntimeException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "unexpected" + " com.sun.star.lang.IllegalAccessException: ")) + + e.Message), + object); + } + return strct; + } else if (wrapOptional + && type->getName().matchAsciiL( + RTL_CONSTASCII_STRINGPARAM("com.sun.star.beans.Optional<"))) + { + css::uno::Any strct; + type->createObject(strct); + bool present = value.hasValue(); + try { + css::uno::Reference< css::reflection::XIdlField2 >( + type->getField( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("IsPresent"))), + css::uno::UNO_QUERY_THROW)->set( + strct, css::uno::makeAny(present)); + if (present) { + css::uno::Reference< css::reflection::XIdlField2 > field( + type->getField( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("Value"))), + css::uno::UNO_QUERY_THROW); + field->set( + strct, + wrapValue( + object, value, field->getType(), wrapAmbiguous, + isAmbiguous, wrapDefaulted, isDefaulted, false)); + } + } catch (css::lang::IllegalArgumentException & e) { + throw css::uno::RuntimeException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "unexpected" + " com.sun.star.lang.IllegalArgumentException: ")) + + e.Message), + object); + } catch (css::lang::IllegalAccessException & e) { + throw css::uno::RuntimeException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "unexpected" + " com.sun.star.lang.IllegalAccessException: ")) + + e.Message), + object); + } + return strct; + } else { + if (wrapAmbiguous || wrapDefaulted || wrapOptional) { + throw css::uno::RuntimeException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "unexpected type of attribute")), + object); + } + return value; + } +} + +PropertySetMixinImpl::PropertySetMixinImpl( + css::uno::Reference< css::uno::XComponentContext > const & context, + Implements implements, + css::uno::Sequence< rtl::OUString > const & absentOptional, + css::uno::Type const & type) +{ + m_impl = new Impl(context, implements, absentOptional, type); + m_impl->acquire(); +} + +PropertySetMixinImpl::~PropertySetMixinImpl() { + m_impl->release(); +} + +void PropertySetMixinImpl::checkUnknown(rtl::OUString const & propertyName) { + if (propertyName.getLength() != 0) { + m_impl->get( + static_cast< css::beans::XPropertySet * >(this), propertyName); + } +} + +void PropertySetMixinImpl::prepareSet( + rtl::OUString const & propertyName, css::uno::Any const & oldValue, + css::uno::Any const & newValue, BoundListeners * boundListeners) +{ + Impl::PropertyMap::const_iterator it(m_impl->properties.find(propertyName)); + OSL_ASSERT(it != m_impl->properties.end()); + Impl::VetoListenerBag specificVeto; + Impl::VetoListenerBag unspecificVeto; + { + osl::MutexGuard g(m_impl->mutex); + if (m_impl->disposed) { + throw css::lang::DisposedException( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("disposed")), + static_cast< css::beans::XPropertySet * >(this)); + } + if ((it->second.property.Attributes + & css::beans::PropertyAttribute::CONSTRAINED) + != 0) + { + Impl::VetoListenerMap::const_iterator i( + m_impl->vetoListeners.find(propertyName)); + if (i != m_impl->vetoListeners.end()) { + specificVeto = i->second; + } + i = m_impl->vetoListeners.find(rtl::OUString()); + if (i != m_impl->vetoListeners.end()) { + unspecificVeto = i->second; + } + } + if ((it->second.property.Attributes + & css::beans::PropertyAttribute::BOUND) + != 0) + { + OSL_ASSERT(boundListeners != 0); + Impl::BoundListenerMap::const_iterator i( + m_impl->boundListeners.find(propertyName)); + if (i != m_impl->boundListeners.end()) { + boundListeners->m_impl->specificListeners = i->second; + } + i = m_impl->boundListeners.find(rtl::OUString()); + if (i != m_impl->boundListeners.end()) { + boundListeners->m_impl->unspecificListeners = i->second; + } + } + } + if ((it->second.property.Attributes + & css::beans::PropertyAttribute::CONSTRAINED) + != 0) + { + css::beans::PropertyChangeEvent event( + static_cast< css::beans::XPropertySet * >(this), propertyName, + false, it->second.property.Handle, oldValue, newValue); + for (Impl::VetoListenerBag::iterator i(specificVeto.begin()); + i != specificVeto.end(); ++i) + { + try { + (*i)->vetoableChange(event); + } catch (css::lang::DisposedException &) {} + } + for (Impl::VetoListenerBag::iterator i(unspecificVeto.begin()); + i != unspecificVeto.end(); ++i) + { + try { + (*i)->vetoableChange(event); + } catch (css::lang::DisposedException &) {} + } + } + if ((it->second.property.Attributes & css::beans::PropertyAttribute::BOUND) + != 0) + { + OSL_ASSERT(boundListeners != 0); + boundListeners->m_impl->event = css::beans::PropertyChangeEvent( + static_cast< css::beans::XPropertySet * >(this), propertyName, + false, it->second.property.Handle, oldValue, newValue); + } +} + +void PropertySetMixinImpl::dispose() { + Impl::BoundListenerMap boundListeners; + Impl::VetoListenerMap vetoListeners; + { + osl::MutexGuard g(m_impl->mutex); + boundListeners.swap(m_impl->boundListeners); + vetoListeners.swap(m_impl->vetoListeners); + m_impl->disposed = true; + } + css::lang::EventObject event( + static_cast< css::beans::XPropertySet * >(this)); + for (Impl::BoundListenerMap::iterator i(boundListeners.begin()); + i != boundListeners.end(); ++i) + { + for (BoundListenerBag::iterator j(i->second.begin()); + j != i->second.end(); ++j) + { + (*j)->disposing(event); + } + } + for (Impl::VetoListenerMap::iterator i(vetoListeners.begin()); + i != vetoListeners.end(); ++i) + { + for (Impl::VetoListenerBag::iterator j(i->second.begin()); + j != i->second.end(); ++j) + { + (*j)->disposing(event); + } + } +} + +css::uno::Any PropertySetMixinImpl::queryInterface(css::uno::Type const & type) + throw (css::uno::RuntimeException) +{ + if (((m_impl->implements & IMPLEMENTS_PROPERTY_SET) != 0 + && type == css::beans::XPropertySet::static_type())) + { + css::uno::Reference< css::uno::XInterface > ifc( + static_cast< css::beans::XPropertySet * >(this)); + return css::uno::Any(&ifc, type); + } else if ((m_impl->implements & IMPLEMENTS_FAST_PROPERTY_SET) != 0 + && type == css::beans::XFastPropertySet::static_type()) + { + css::uno::Reference< css::uno::XInterface > ifc( + static_cast< css::beans::XFastPropertySet * >(this)); + return css::uno::Any(&ifc, type); + } else if ((m_impl->implements & IMPLEMENTS_PROPERTY_ACCESS) != 0 + && type == css::beans::XPropertyAccess::static_type()) + { + css::uno::Reference< css::uno::XInterface > ifc( + static_cast< css::beans::XPropertyAccess * >(this)); + return css::uno::Any(&ifc, type); + } else { + return css::uno::Any(); + } +} + +css::uno::Reference< css::beans::XPropertySetInfo > +PropertySetMixinImpl::getPropertySetInfo() throw (css::uno::RuntimeException) { + try { + return new Info(m_impl); + } catch (std::bad_alloc &) { + //TODO OutOfMemoryException: + throw css::uno::RuntimeException( + rtl::OUString(), static_cast< css::beans::XPropertySet * >(this)); + } +} + +void PropertySetMixinImpl::setPropertyValue( + rtl::OUString const & propertyName, css::uno::Any const & value) + throw ( + css::beans::UnknownPropertyException, css::beans::PropertyVetoException, + css::lang::IllegalArgumentException, css::lang::WrappedTargetException, + css::uno::RuntimeException) +{ + try { + m_impl->setProperty( + static_cast< css::beans::XPropertySet * >(this), propertyName, + value, false, false, 1); + } catch (std::bad_alloc &) { + //TODO OutOfMemoryException: + throw css::uno::RuntimeException( + rtl::OUString(), static_cast< css::beans::XPropertySet * >(this)); + } +} + +css::uno::Any PropertySetMixinImpl::getPropertyValue( + rtl::OUString const & propertyName) + throw ( + css::beans::UnknownPropertyException, css::lang::WrappedTargetException, + css::uno::RuntimeException) +{ + try { + return m_impl->getProperty( + static_cast< css::beans::XPropertySet * >(this), propertyName, 0); + } catch (std::bad_alloc &) { + //TODO OutOfMemoryException: + throw css::uno::RuntimeException( + rtl::OUString(), static_cast< css::beans::XPropertySet * >(this)); + } +} + +void PropertySetMixinImpl::addPropertyChangeListener( + rtl::OUString const & propertyName, + css::uno::Reference< css::beans::XPropertyChangeListener > const & listener) + throw ( + css::beans::UnknownPropertyException, css::lang::WrappedTargetException, + css::uno::RuntimeException) +{ + css::uno::Reference< css::beans::XPropertyChangeListener >( + listener, css::uno::UNO_QUERY_THROW); // reject NULL listener + checkUnknown(propertyName); + try { + bool disposed; + { + osl::MutexGuard g(m_impl->mutex); + disposed = m_impl->disposed; + if (!disposed) { + m_impl->boundListeners[propertyName].insert(listener); + } + } + if (disposed) { + listener->disposing( + css::lang::EventObject( + static_cast< css::beans::XPropertySet * >(this))); + } + } catch (std::bad_alloc &) { + //TODO OutOfMemoryException: + throw css::uno::RuntimeException( + rtl::OUString(), static_cast< css::beans::XPropertySet * >(this)); + } +} + +void PropertySetMixinImpl::removePropertyChangeListener( + rtl::OUString const & propertyName, + css::uno::Reference< css::beans::XPropertyChangeListener > const & listener) + throw ( + css::beans::UnknownPropertyException, css::lang::WrappedTargetException, + css::uno::RuntimeException) +{ + OSL_ASSERT(listener.is()); + checkUnknown(propertyName); + try { + osl::MutexGuard g(m_impl->mutex); + Impl::BoundListenerMap::iterator i( + m_impl->boundListeners.find(propertyName)); + if (i != m_impl->boundListeners.end()) { + BoundListenerBag::iterator j(i->second.find(listener)); + if (j != i->second.end()) { + i->second.erase(j); + } + } + } catch (std::bad_alloc &) { + //TODO OutOfMemoryException: + throw css::uno::RuntimeException( + rtl::OUString(), static_cast< css::beans::XPropertySet * >(this)); + } +} + +void PropertySetMixinImpl::addVetoableChangeListener( + rtl::OUString const & propertyName, + css::uno::Reference< css::beans::XVetoableChangeListener > const & listener) + throw ( + css::beans::UnknownPropertyException, css::lang::WrappedTargetException, + css::uno::RuntimeException) +{ + css::uno::Reference< css::beans::XVetoableChangeListener >( + listener, css::uno::UNO_QUERY_THROW); // reject NULL listener + checkUnknown(propertyName); + try { + bool disposed; + { + osl::MutexGuard g(m_impl->mutex); + disposed = m_impl->disposed; + if (!disposed) { + m_impl->vetoListeners[propertyName].insert(listener); + } + } + if (disposed) { + listener->disposing( + css::lang::EventObject( + static_cast< css::beans::XPropertySet * >(this))); + } + } catch (std::bad_alloc &) { + //TODO OutOfMemoryException: + throw css::uno::RuntimeException( + rtl::OUString(), static_cast< css::beans::XPropertySet * >(this)); + } +} + +void PropertySetMixinImpl::removeVetoableChangeListener( + rtl::OUString const & propertyName, + css::uno::Reference< css::beans::XVetoableChangeListener > const & listener) + throw ( + css::beans::UnknownPropertyException, css::lang::WrappedTargetException, + css::uno::RuntimeException) +{ + OSL_ASSERT(listener.is()); + checkUnknown(propertyName); + try { + osl::MutexGuard g(m_impl->mutex); + Impl::VetoListenerMap::iterator i( + m_impl->vetoListeners.find(propertyName)); + if (i != m_impl->vetoListeners.end()) { + Impl::VetoListenerBag::iterator j(i->second.find(listener)); + if (j != i->second.end()) { + i->second.erase(j); + } + } + } catch (std::bad_alloc &) { + //TODO OutOfMemoryException: + throw css::uno::RuntimeException( + rtl::OUString(), static_cast< css::beans::XPropertySet * >(this)); + } +} + +void PropertySetMixinImpl::setFastPropertyValue( + sal_Int32 handle, css::uno::Any const & value) + throw ( + css::beans::UnknownPropertyException, css::beans::PropertyVetoException, + css::lang::IllegalArgumentException, css::lang::WrappedTargetException, + css::uno::RuntimeException) +{ + try { + m_impl->setProperty( + static_cast< css::beans::XPropertySet * >(this), + m_impl->translateHandle( + static_cast< css::beans::XPropertySet * >(this), handle), + value, false, false, 1); + } catch (std::bad_alloc &) { + //TODO OutOfMemoryException: + throw css::uno::RuntimeException( + rtl::OUString(), static_cast< css::beans::XPropertySet * >(this)); + } +} + +css::uno::Any PropertySetMixinImpl::getFastPropertyValue(sal_Int32 handle) + throw ( + css::beans::UnknownPropertyException, css::lang::WrappedTargetException, + css::uno::RuntimeException) +{ + try { + return m_impl->getProperty( + static_cast< css::beans::XPropertySet * >(this), + m_impl->translateHandle( + static_cast< css::beans::XPropertySet * >(this), handle), + 0); + } catch (std::bad_alloc &) { + //TODO OutOfMemoryException: + throw css::uno::RuntimeException( + rtl::OUString(), static_cast< css::beans::XPropertySet * >(this)); + } +} + +css::uno::Sequence< css::beans::PropertyValue > +PropertySetMixinImpl::getPropertyValues() throw (css::uno::RuntimeException) { + try { + css::uno::Sequence< css::beans::PropertyValue > s( + m_impl->handleMap.getLength()); + sal_Int32 n = 0; + for (sal_Int32 i = 0; i < m_impl->handleMap.getLength(); ++i) { + try { + s[n].Value = m_impl->getProperty( + static_cast< css::beans::XPropertySet * >(this), + m_impl->handleMap[i], &s[n].State); + } catch (css::beans::UnknownPropertyException &) { + continue; + } catch (css::lang::WrappedTargetException & e) { + throw css::lang::WrappedTargetRuntimeException( + e.Message, static_cast< css::beans::XPropertySet * >(this), + e.TargetException); + } + s[n].Name = m_impl->handleMap[i]; + s[n].Handle = i; + ++n; + } + s.realloc(n); + return s; + } catch (std::bad_alloc &) { + //TODO OutOfMemoryException: + throw css::uno::RuntimeException( + rtl::OUString(), static_cast< css::beans::XPropertySet * >(this)); + } +} + +void PropertySetMixinImpl::setPropertyValues( + css::uno::Sequence< css::beans::PropertyValue > const & props) + throw ( + css::beans::UnknownPropertyException, css::beans::PropertyVetoException, + css::lang::IllegalArgumentException, css::lang::WrappedTargetException, + css::uno::RuntimeException) +{ + try { + for (sal_Int32 i = 0; i < props.getLength(); ++i) { + if (props[i].Handle != -1 + && (props[i].Name + != m_impl->translateHandle( + static_cast< css::beans::XPropertySet * >(this), + props[i].Handle))) + { + throw css::beans::UnknownPropertyException( + (rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("name ")) + + props[i].Name + + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM(" does not match handle ")) + + rtl::OUString::valueOf(props[i].Handle)), + static_cast< css::beans::XPropertySet * >(this)); + } + m_impl->setProperty( + static_cast< css::beans::XPropertySet * >(this), props[i].Name, + props[i].Value, + props[i].State == css::beans::PropertyState_AMBIGUOUS_VALUE, + props[i].State == css::beans::PropertyState_DEFAULT_VALUE, 0); + } + } catch (std::bad_alloc &) { + //TODO OutOfMemoryException: + throw css::uno::RuntimeException( + rtl::OUString(), static_cast< css::beans::XPropertySet * >(this)); + } +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/source/propshlp.cxx b/cppuhelper/source/propshlp.cxx new file mode 100644 index 000000000000..42bb1c1c539b --- /dev/null +++ b/cppuhelper/source/propshlp.cxx @@ -0,0 +1,1243 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_cppuhelper.hxx" + +#include "osl/diagnose.h" +#include "cppuhelper/implbase1.hxx" +#include "cppuhelper/weak.hxx" +#include "cppuhelper/propshlp.hxx" +#include "com/sun/star/beans/PropertyAttribute.hpp" +#include "com/sun/star/lang/DisposedException.hpp" + + +using namespace osl; +using namespace com::sun::star::uno; +using namespace com::sun::star::beans; +using namespace com::sun::star::lang; +using namespace rtl; +using namespace cppu; + +namespace cppu { + +IPropertyArrayHelper::~IPropertyArrayHelper() +{ +} + +inline const ::com::sun::star::uno::Type & getPropertyTypeIdentifier( ) SAL_THROW( () ) +{ + return ::getCppuType( (Reference< XPropertyChangeListener > *)0 ); +} +inline const ::com::sun::star::uno::Type & getPropertiesTypeIdentifier() SAL_THROW( () ) +{ + return ::getCppuType( (Reference< XPropertiesChangeListener > *)0 ); +} +inline const ::com::sun::star::uno::Type & getVetoableTypeIdentifier() SAL_THROW( () ) +{ + return ::getCppuType( (Reference< XVetoableChangeListener > *)0 ); +} + +extern "C" { + +static int compare_OUString_Property_Impl( const void *arg1, const void *arg2 ) + SAL_THROW_EXTERN_C() +{ + return ((OUString *)arg1)->compareTo( ((Property *)arg2)->Name ); +} + +} + +/** + * The class which implements the PropertySetInfo interface. + */ + +class OPropertySetHelperInfo_Impl + : public WeakImplHelper1< ::com::sun::star::beans::XPropertySetInfo > +{ + Sequence < Property > aInfos; + +public: + OPropertySetHelperInfo_Impl( IPropertyArrayHelper & rHelper_ ) SAL_THROW( () ); + + // XPropertySetInfo-Methoden + virtual Sequence< Property > SAL_CALL getProperties(void) throw(::com::sun::star::uno::RuntimeException); + virtual Property SAL_CALL getPropertyByName(const OUString& PropertyName) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL hasPropertyByName(const OUString& PropertyName) throw(::com::sun::star::uno::RuntimeException); +}; + + +/** + * Create an object that implements XPropertySetInfo IPropertyArrayHelper. + */ +OPropertySetHelperInfo_Impl::OPropertySetHelperInfo_Impl( + IPropertyArrayHelper & rHelper_ ) + SAL_THROW( () ) + :aInfos( rHelper_.getProperties() ) +{ +} + +/** + * Return the sequence of properties, which are provided throug the constructor. + */ +Sequence< Property > OPropertySetHelperInfo_Impl::getProperties(void) throw(::com::sun::star::uno::RuntimeException) + +{ + return aInfos; +} + +/** + * Return the sequence of properties, which are provided throug the constructor. + */ +Property OPropertySetHelperInfo_Impl::getPropertyByName( const OUString & PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException) +{ + Property * pR; + pR = (Property *)bsearch( &PropertyName, aInfos.getConstArray(), aInfos.getLength(), + sizeof( Property ), + compare_OUString_Property_Impl ); + if( !pR ) { + throw UnknownPropertyException(); + } + + return *pR; +} + +/** + * Return the sequence of properties, which are provided throug the constructor. + */ +sal_Bool OPropertySetHelperInfo_Impl::hasPropertyByName( const OUString & PropertyName ) throw(::com::sun::star::uno::RuntimeException) +{ + Property * pR; + pR = (Property *)bsearch( &PropertyName, aInfos.getConstArray(), aInfos.getLength(), + sizeof( Property ), + compare_OUString_Property_Impl ); + return pR != NULL; +} + +// ---------------------------------------------------- +// class PropertySetHelper_Impl +// ---------------------------------------------------- +class OPropertySetHelper::Impl { + +public: + Impl ( bool i_bIgnoreRuntimeExceptionsWhileFiring, + IEventNotificationHook *i_pFireEvents) + : m_bIgnoreRuntimeExceptionsWhileFiring( + i_bIgnoreRuntimeExceptionsWhileFiring ), + m_pFireEvents( i_pFireEvents ) + { } + + bool m_bIgnoreRuntimeExceptionsWhileFiring; + class IEventNotificationHook * const m_pFireEvents; +}; + + +// ---------------------------------------------------- +// class PropertySetHelper +// ---------------------------------------------------- +OPropertySetHelper::OPropertySetHelper( + OBroadcastHelper & rBHelper_ ) SAL_THROW( () ) + : rBHelper( rBHelper_ ), + aBoundLC( rBHelper_.rMutex ), + aVetoableLC( rBHelper_.rMutex ), + m_pReserved( new Impl(false, 0) ) +{ +} + +OPropertySetHelper::OPropertySetHelper( + OBroadcastHelper & rBHelper_, bool bIgnoreRuntimeExceptionsWhileFiring ) + : rBHelper( rBHelper_ ), + aBoundLC( rBHelper_.rMutex ), + aVetoableLC( rBHelper_.rMutex ), + m_pReserved( new Impl( bIgnoreRuntimeExceptionsWhileFiring, 0 ) ) +{ +} + +OPropertySetHelper::OPropertySetHelper( + OBroadcastHelper & rBHelper_, IEventNotificationHook * i_pFireEvents, + bool bIgnoreRuntimeExceptionsWhileFiring) + : rBHelper( rBHelper_ ), + aBoundLC( rBHelper_.rMutex ), + aVetoableLC( rBHelper_.rMutex ), + m_pReserved( + new Impl( bIgnoreRuntimeExceptionsWhileFiring, i_pFireEvents) ) +{ +} + +/** + * You must call disposing before. + */ +OPropertySetHelper::~OPropertySetHelper() SAL_THROW( () ) +{ +} + +/** + * These method is called from queryInterface, if no delegator is set. + * Otherwise this method is called from the delegator. + */ +// XAggregation +Any OPropertySetHelper::queryInterface( const ::com::sun::star::uno::Type & rType ) + throw (RuntimeException) +{ + return ::cppu::queryInterface( + rType, + static_cast< XPropertySet * >( this ), + static_cast< XMultiPropertySet * >( this ), + static_cast< XFastPropertySet * >( this ) ); +} + +/** + * called from the derivee's XTypeProvider::getTypes implementation + */ +::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > OPropertySetHelper::getTypes() + throw (RuntimeException) +{ + Sequence< ::com::sun::star::uno::Type > aTypes( 3 ); + aTypes[ 0 ] = XPropertySet::static_type(); + aTypes[ 1 ] = XMultiPropertySet::static_type(); + aTypes[ 2 ] = XFastPropertySet::static_type(); + return aTypes; +} + +// ComponentHelper +void OPropertySetHelper::disposing() SAL_THROW( () ) +{ + // Create an event with this as sender + Reference < XPropertySet > rSource( SAL_STATIC_CAST( XPropertySet * , this ) , UNO_QUERY ); + EventObject aEvt; + aEvt.Source = rSource; + + // inform all listeners to release this object + // The listener containers are automatically cleared + aBoundLC.disposeAndClear( aEvt ); + aVetoableLC.disposeAndClear( aEvt ); +} + +Reference < XPropertySetInfo > OPropertySetHelper::createPropertySetInfo( + IPropertyArrayHelper & rProperties ) SAL_THROW( () ) +{ + return static_cast< XPropertySetInfo * >( new OPropertySetHelperInfo_Impl( rProperties ) ); +} + +// XPropertySet +void OPropertySetHelper::setPropertyValue( + const OUString& rPropertyName, const Any& rValue ) + throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) +{ + // get the map table + IPropertyArrayHelper & rPH = getInfoHelper(); + // map the name to the handle + sal_Int32 nHandle = rPH.getHandleByName( rPropertyName ); + // call the method of the XFastPropertySet interface + setFastPropertyValue( nHandle, rValue ); +} + +// XPropertySet +Any OPropertySetHelper::getPropertyValue( + const OUString& rPropertyName ) + throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) +{ + // get the map table + IPropertyArrayHelper & rPH = getInfoHelper(); + // map the name to the handle + sal_Int32 nHandle = rPH.getHandleByName( rPropertyName ); + // call the method of the XFastPropertySet interface + return getFastPropertyValue( nHandle ); +} + +// XPropertySet +void OPropertySetHelper::addPropertyChangeListener( + const OUString& rPropertyName, + const Reference < XPropertyChangeListener > & rxListener ) + throw(::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException) +{ + MutexGuard aGuard( rBHelper.rMutex ); + OSL_ENSURE( !rBHelper.bInDispose, "do not addPropertyChangeListener in the dispose call" ); + OSL_ENSURE( !rBHelper.bDisposed, "object is disposed" ); + if( !rBHelper.bInDispose && !rBHelper.bDisposed ) + { + // only add listeners if you are not disposed + // a listener with no name means all properties + if( rPropertyName.getLength() ) + { + // get the map table + IPropertyArrayHelper & rPH = getInfoHelper(); + // map the name to the handle + sal_Int32 nHandle = rPH.getHandleByName( rPropertyName ); + if( nHandle == -1 ) { + // property not known throw exception + throw UnknownPropertyException() ; + } + + sal_Int16 nAttributes; + rPH.fillPropertyMembersByHandle( NULL, &nAttributes, nHandle ); + if( !(nAttributes & ::com::sun::star::beans::PropertyAttribute::BOUND) ) + { + OSL_ENSURE( sal_False, "add listener to an unbound property" ); + // silent ignore this + return; + } + // add the change listener to the helper container + + aBoundLC.addInterface( (sal_Int32)nHandle, rxListener ); + } + else + // add the change listener to the helper container + rBHelper.aLC.addInterface( + getPropertyTypeIdentifier( ), + rxListener + ); + } +} + + +// XPropertySet +void OPropertySetHelper::removePropertyChangeListener( + const OUString& rPropertyName, + const Reference < XPropertyChangeListener >& rxListener ) + throw(::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException) +{ + MutexGuard aGuard( rBHelper.rMutex ); + OSL_ENSURE( !rBHelper.bDisposed, "object is disposed" ); + // all listeners are automaticly released in a dispose call + if( !rBHelper.bInDispose && !rBHelper.bDisposed ) + { + if( rPropertyName.getLength() ) + { + // get the map table + IPropertyArrayHelper & rPH = getInfoHelper(); + // map the name to the handle + sal_Int32 nHandle = rPH.getHandleByName( rPropertyName ); + if( nHandle == -1 ) + // property not known throw exception + throw UnknownPropertyException(); + aBoundLC.removeInterface( (sal_Int32)nHandle, rxListener ); + } + else { + // remove the change listener to the helper container + rBHelper.aLC.removeInterface( + getPropertyTypeIdentifier( ), + rxListener + ); + } + } +} + +// XPropertySet +void OPropertySetHelper::addVetoableChangeListener( + const OUString& rPropertyName, + const Reference< XVetoableChangeListener > & rxListener ) + throw(::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException) +{ + MutexGuard aGuard( rBHelper.rMutex ); + OSL_ENSURE( !rBHelper.bInDispose, "do not addVetoableChangeListener in the dispose call" ); + OSL_ENSURE( !rBHelper.bDisposed, "object is disposed" ); + if( !rBHelper.bInDispose && !rBHelper.bDisposed ) + { + // only add listeners if you are not disposed + // a listener with no name means all properties + if( rPropertyName.getLength() ) + { + // get the map table + IPropertyArrayHelper & rPH = getInfoHelper(); + // map the name to the handle + sal_Int32 nHandle = rPH.getHandleByName( rPropertyName ); + if( nHandle == -1 ) { + // property not known throw exception + throw UnknownPropertyException(); + } + + sal_Int16 nAttributes; + rPH.fillPropertyMembersByHandle( NULL, &nAttributes, nHandle ); + if( !(nAttributes & PropertyAttribute::CONSTRAINED) ) + { + OSL_ENSURE( sal_False, "addVetoableChangeListener, and property is not constrained" ); + // silent ignore this + return; + } + // add the vetoable listener to the helper container + aVetoableLC.addInterface( (sal_Int32)nHandle, rxListener ); + } + else + // add the vetoable listener to the helper container + rBHelper.aLC.addInterface( + getVetoableTypeIdentifier( ), + rxListener + ); + } +} + +// XPropertySet +void OPropertySetHelper::removeVetoableChangeListener( + const OUString& rPropertyName, + const Reference < XVetoableChangeListener > & rxListener ) + throw(::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException) +{ + MutexGuard aGuard( rBHelper.rMutex ); + OSL_ENSURE( !rBHelper.bDisposed, "object is disposed" ); + // all listeners are automaticly released in a dispose call + if( !rBHelper.bInDispose && !rBHelper.bDisposed ) + { + if( rPropertyName.getLength() ) + { + // get the map table + IPropertyArrayHelper & rPH = getInfoHelper(); + // map the name to the handle + sal_Int32 nHandle = rPH.getHandleByName( rPropertyName ); + if( nHandle == -1 ) { + // property not known throw exception + throw UnknownPropertyException(); + } + // remove the vetoable listener to the helper container + aVetoableLC.removeInterface( (sal_Int32)nHandle, rxListener ); + } + else + // add the vetoable listener to the helper container + rBHelper.aLC.removeInterface( + getVetoableTypeIdentifier( ), + rxListener + ); + } +} + +// XFastPropertySet +void OPropertySetHelper::setFastPropertyValue( sal_Int32 nHandle, const Any& rValue ) + throw(::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::beans::PropertyVetoException, + ::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException) +{ + OSL_ENSURE( !rBHelper.bInDispose, "do not setFastPropertyValue in the dispose call" ); + OSL_ENSURE( !rBHelper.bDisposed, "object is disposed" ); + + IPropertyArrayHelper & rInfo = getInfoHelper(); + sal_Int16 nAttributes; + if( !rInfo.fillPropertyMembersByHandle( NULL, &nAttributes, nHandle ) ) { + // unknown property + throw UnknownPropertyException(); + } + if( nAttributes & PropertyAttribute::READONLY ) + throw PropertyVetoException(); + + Any aConvertedVal; + Any aOldVal; + + // Will the property change? + sal_Bool bChanged; + { + MutexGuard aGuard( rBHelper.rMutex ); + bChanged = convertFastPropertyValue( aConvertedVal, aOldVal, nHandle, rValue ); + // release guard to fire events + } + if( bChanged ) + { + // Is it a constrained property? + if( nAttributes & PropertyAttribute::CONSTRAINED ) + { + // In aValue is the converted rValue + // fire a constarined event + // second parameter NULL means constrained + fire( &nHandle, &rValue, &aOldVal, 1, sal_True ); + } + + { + MutexGuard aGuard( rBHelper.rMutex ); + try + { + // set the property to the new value + setFastPropertyValue_NoBroadcast( nHandle, aConvertedVal ); + } + catch (const ::com::sun::star::beans::UnknownPropertyException& ) { throw; /* allowed to leave */ } + catch (const ::com::sun::star::beans::PropertyVetoException& ) { throw; /* allowed to leave */ } + catch (const ::com::sun::star::lang::IllegalArgumentException& ) { throw; /* allowed to leave */ } + catch (const ::com::sun::star::lang::WrappedTargetException& ) { throw; /* allowed to leave */ } + catch (const ::com::sun::star::uno::RuntimeException& ) { throw; /* allowed to leave */ } + catch (const ::com::sun::star::uno::Exception& e ) + { + // not allowed to leave this meathod + ::com::sun::star::lang::WrappedTargetException aWrap; + aWrap.Context = static_cast< ::com::sun::star::beans::XPropertySet* >( this ); + aWrap.TargetException <<= e; + + throw ::com::sun::star::lang::WrappedTargetException( aWrap ); + } + + // release guard to fire events + } + // file a change event, if the value changed + fire( &nHandle, &rValue, &aOldVal, 1, sal_False ); + } +} + +// XFastPropertySet +Any OPropertySetHelper::getFastPropertyValue( sal_Int32 nHandle ) + throw(::com::sun::star::beans::UnknownPropertyException, + ::com::sun::star::lang::WrappedTargetException, + ::com::sun::star::uno::RuntimeException) + +{ + IPropertyArrayHelper & rInfo = getInfoHelper(); + if( !rInfo.fillPropertyMembersByHandle( NULL, NULL, nHandle ) ) + // unknown property + throw UnknownPropertyException(); + + Any aRet; + MutexGuard aGuard( rBHelper.rMutex ); + getFastPropertyValue( aRet, nHandle ); + return aRet; +} + +//-------------------------------------------------------------------------- +void OPropertySetHelper::fire +( + sal_Int32 * pnHandles, + const Any * pNewValues, + const Any * pOldValues, + sal_Int32 nHandles, // These is the Count of the array + sal_Bool bVetoable +) +{ + OSL_ENSURE( m_pReserved.get(), "No OPropertySetHelper::Impl" ); + if (m_pReserved->m_pFireEvents) { + m_pReserved->m_pFireEvents->fireEvents( + pnHandles, nHandles, bVetoable, + m_pReserved->m_bIgnoreRuntimeExceptionsWhileFiring); + } + + // Only fire, if one or more properties changed + if( nHandles ) + { + // create the event sequence of all changed properties + Sequence< PropertyChangeEvent > aEvts( nHandles ); + PropertyChangeEvent * pEvts = aEvts.getArray(); + Reference < XInterface > xSource( (XPropertySet *)this, UNO_QUERY ); + sal_Int32 i; + sal_Int32 nChangesLen = 0; + // Loop over all changed properties to fill the event struct + for( i = 0; i < nHandles; i++ ) + { + // Vetoable fire and constrained attribute set or + // Change fire and Changed and bound attribute set + IPropertyArrayHelper & rInfo = getInfoHelper(); + sal_Int16 nAttributes; + OUString aPropName; + rInfo.fillPropertyMembersByHandle( &aPropName, &nAttributes, pnHandles[i] ); + + if( + (bVetoable && (nAttributes & PropertyAttribute::CONSTRAINED)) || + (!bVetoable && (nAttributes & PropertyAttribute::BOUND)) + ) + { + pEvts[nChangesLen].Source = xSource; + pEvts[nChangesLen].PropertyName = aPropName; + pEvts[nChangesLen].PropertyHandle = pnHandles[i]; + pEvts[nChangesLen].OldValue = pOldValues[i]; + pEvts[nChangesLen].NewValue = pNewValues[i]; + nChangesLen++; + } + } + + bool bIgnoreRuntimeExceptionsWhileFiring = + m_pReserved->m_bIgnoreRuntimeExceptionsWhileFiring; + + // fire the events for all changed properties + for( i = 0; i < nChangesLen; i++ ) + { + // get the listener container for the property name + OInterfaceContainerHelper * pLC; + if( bVetoable ) // fire change Events? + pLC = aVetoableLC.getContainer( pEvts[i].PropertyHandle ); + else + pLC = aBoundLC.getContainer( pEvts[i].PropertyHandle ); + if( pLC ) + { + // Ueber alle Listener iterieren und Events senden + OInterfaceIteratorHelper aIt( *pLC); + while( aIt.hasMoreElements() ) + { + XInterface * pL = aIt.next(); + try + { + try + { + if( bVetoable ) // fire change Events? + { + ((XVetoableChangeListener *)pL)->vetoableChange( + pEvts[i] ); + } + else + { + ((XPropertyChangeListener *)pL)->propertyChange( + pEvts[i] ); + } + } + catch (DisposedException & exc) + { + OSL_ENSURE( exc.Context.is(), + "DisposedException without Context!" ); + if (exc.Context == pL) + aIt.remove(); + else + throw; + } + } + catch (RuntimeException & exc) + { + OSL_TRACE( + OUStringToOString( + OUString( RTL_CONSTASCII_USTRINGPARAM( + "caught RuntimeException while " + "firing listeners: ") ) + + exc.Message, RTL_TEXTENCODING_UTF8 ).getStr() ); + if (! bIgnoreRuntimeExceptionsWhileFiring) + throw; + } + } + } + // broadcast to all listeners with "" property name + if( bVetoable ){ + // fire change Events? + pLC = rBHelper.aLC.getContainer( + getVetoableTypeIdentifier() + ); + } + else { + pLC = rBHelper.aLC.getContainer( + getPropertyTypeIdentifier( ) + ); + } + if( pLC ) + { + // Ueber alle Listener iterieren und Events senden + OInterfaceIteratorHelper aIt( *pLC); + while( aIt.hasMoreElements() ) + { + XInterface * pL = aIt.next(); + try + { + try + { + if( bVetoable ) // fire change Events? + { + ((XVetoableChangeListener *)pL)->vetoableChange( + pEvts[i] ); + } + else + { + ((XPropertyChangeListener *)pL)->propertyChange( + pEvts[i] ); + } + } + catch (DisposedException & exc) + { + OSL_ENSURE( exc.Context.is(), + "DisposedException without Context!" ); + if (exc.Context == pL) + aIt.remove(); + else + throw; + } + } + catch (RuntimeException & exc) + { + OSL_TRACE( + OUStringToOString( + OUString( RTL_CONSTASCII_USTRINGPARAM( + "caught RuntimeException while " + "firing listeners: ") ) + + exc.Message, RTL_TEXTENCODING_UTF8 ).getStr() ); + if (! bIgnoreRuntimeExceptionsWhileFiring) + throw; + } + } + } + } + + // reduce array to changed properties + aEvts.realloc( nChangesLen ); + + if( !bVetoable ) + { + OInterfaceContainerHelper * pCont = 0; + pCont = rBHelper.aLC.getContainer( + getPropertiesTypeIdentifier( ) + ); + if( pCont ) + { + // Here is a Bug, unbound properties are also fired + OInterfaceIteratorHelper aIt( *pCont ); + while( aIt.hasMoreElements() ) + { + XPropertiesChangeListener * pL = + (XPropertiesChangeListener *)aIt.next(); + try + { + try + { + // fire the hole event sequence to the + // XPropertiesChangeListener's + pL->propertiesChange( aEvts ); + } + catch (DisposedException & exc) + { + OSL_ENSURE( exc.Context.is(), + "DisposedException without Context!" ); + if (exc.Context == pL) + aIt.remove(); + else + throw; + } + } + catch (RuntimeException & exc) + { + OSL_TRACE( + OUStringToOString( + OUString( RTL_CONSTASCII_USTRINGPARAM( + "caught RuntimeException while " + "firing listeners: ") ) + + exc.Message, RTL_TEXTENCODING_UTF8 ).getStr() ); + if (! bIgnoreRuntimeExceptionsWhileFiring) + throw; + } + } + } + } + } +} + +// OPropertySetHelper +void OPropertySetHelper::setFastPropertyValues( + sal_Int32 nSeqLen, + sal_Int32 * pHandles, + const Any * pValues, + sal_Int32 nHitCount ) + SAL_THROW( (::com::sun::star::uno::Exception) ) +{ + OSL_ENSURE( !rBHelper.bInDispose, "do not getFastPropertyValue in the dispose call" ); + OSL_ENSURE( !rBHelper.bDisposed, "object is disposed" ); + + Any * pConvertedValues = NULL; + Any * pOldValues = NULL; + + try + { + // get the map table + IPropertyArrayHelper & rPH = getInfoHelper(); + + pConvertedValues = new Any[ nHitCount ]; + pOldValues = new Any[ nHitCount ]; + sal_Int32 n = 0; + sal_Int32 i; + + { + // must lock the mutex outside the loop. So all values are consistent. + MutexGuard aGuard( rBHelper.rMutex ); + for( i = 0; i < nSeqLen; i++ ) + { + if( pHandles[i] != -1 ) + { + sal_Int16 nAttributes; + rPH.fillPropertyMembersByHandle( NULL, &nAttributes, pHandles[i] ); + if( nAttributes & PropertyAttribute::READONLY ) { + throw PropertyVetoException(); + } + // Will the property change? + if( convertFastPropertyValue( pConvertedValues[ n ], pOldValues[n], + pHandles[i], pValues[i] ) ) + { + // only increment if the property really change + pHandles[n] = pHandles[i]; + n++; + } + } + } + // release guard to fire events + } + + // fire vetoable events + fire( pHandles, pConvertedValues, pOldValues, n, sal_True ); + + { + // must lock the mutex outside the loop. + MutexGuard aGuard( rBHelper.rMutex ); + // Loop over all changed properties + for( i = 0; i < n; i++ ) + { + // Will the property change? + setFastPropertyValue_NoBroadcast( pHandles[i], pConvertedValues[i] ); + } + // release guard to fire events + } + + // fire change events + fire( pHandles, pConvertedValues, pOldValues, n, sal_False ); + } + catch( ... ) + { + delete [] pOldValues; + delete [] pConvertedValues; + throw; + } + delete [] pOldValues; + delete [] pConvertedValues; +} + +// XMultiPropertySet +/** + * The sequence may be conatain not known properties. The implementation + * must ignore these properties. + */ +void OPropertySetHelper::setPropertyValues( + const Sequence<OUString>& rPropertyNames, + const Sequence<Any>& rValues ) + throw(::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) +{ + sal_Int32 * pHandles = NULL; + try + { + sal_Int32 nSeqLen = rPropertyNames.getLength(); + pHandles = new sal_Int32[ nSeqLen ]; + // get the map table + IPropertyArrayHelper & rPH = getInfoHelper(); + // fill the handle array + sal_Int32 nHitCount = rPH.fillHandles( pHandles, rPropertyNames ); + if( nHitCount != 0 ) + setFastPropertyValues( nSeqLen, pHandles, rValues.getConstArray(), nHitCount ); + } + catch( ... ) + { + delete [] pHandles; + throw; + } + delete [] pHandles; +} + +// XMultiPropertySet +Sequence<Any> OPropertySetHelper::getPropertyValues( const Sequence<OUString>& rPropertyNames ) + throw(::com::sun::star::uno::RuntimeException) +{ + sal_Int32 nSeqLen = rPropertyNames.getLength(); + sal_Int32 * pHandles = new sal_Int32[ nSeqLen ]; + Sequence< Any > aValues( nSeqLen ); + + // get the map table + IPropertyArrayHelper & rPH = getInfoHelper(); + // fill the handle array + rPH.fillHandles( pHandles, rPropertyNames ); + + Any * pValues = aValues.getArray(); + + MutexGuard aGuard( rBHelper.rMutex ); + // fill the sequence with the values + for( sal_Int32 i = 0; i < nSeqLen; i++ ) + getFastPropertyValue( pValues[i], pHandles[i] ); + + delete [] pHandles; + return aValues; +} + +// XMultiPropertySet +void OPropertySetHelper::addPropertiesChangeListener( + const Sequence<OUString> & , + const Reference < XPropertiesChangeListener > & rListener ) + throw(::com::sun::star::uno::RuntimeException) +{ + rBHelper.addListener( getCppuType(&rListener) , rListener ); +} + +// XMultiPropertySet +void OPropertySetHelper::removePropertiesChangeListener( + const Reference < XPropertiesChangeListener > & rListener ) + throw(::com::sun::star::uno::RuntimeException) +{ + rBHelper.removeListener( getCppuType(&rListener) , rListener ); +} + +// XMultiPropertySet +void OPropertySetHelper::firePropertiesChangeEvent( + const Sequence<OUString>& rPropertyNames, + const Reference < XPropertiesChangeListener >& rListener ) + throw(::com::sun::star::uno::RuntimeException) +{ + sal_Int32 nLen = rPropertyNames.getLength(); + sal_Int32 * pHandles = new sal_Int32[nLen]; + IPropertyArrayHelper & rPH = getInfoHelper(); + rPH.fillHandles( pHandles, rPropertyNames ); + const OUString* pNames = rPropertyNames.getConstArray(); + + // get the count of matching properties + sal_Int32 nFireLen = 0; + sal_Int32 i; + for( i = 0; i < nLen; i++ ) + if( pHandles[i] != -1 ) + nFireLen++; + + Sequence<PropertyChangeEvent> aChanges( nFireLen ); + PropertyChangeEvent* pChanges = aChanges.getArray(); + + sal_Int32 nFirePos = 0; + { + // must lock the mutex outside the loop. So all values are consistent. + MutexGuard aGuard( rBHelper.rMutex ); + Reference < XInterface > xSource( (XPropertySet *)this, UNO_QUERY ); + for( i = 0; i < nLen; i++ ) + { + if( pHandles[i] != -1 ) + { + pChanges[nFirePos].Source = xSource; + pChanges[nFirePos].PropertyName = pNames[i]; + pChanges[nFirePos].PropertyHandle = pHandles[i]; + getFastPropertyValue( pChanges[nFirePos].OldValue, pHandles[i] ); + pChanges[nFirePos].NewValue = pChanges[nFirePos].OldValue; + nFirePos++; + } + } + // release guard to fire events + } + if( nFireLen ) + rListener->propertiesChange( aChanges ); + + delete [] pHandles; +} + +#ifdef xdvnsdfln +// XPropertyState +PropertyState OPropertySetHelper::getPropertyState( const OUString& PropertyName ) +{ + PropertyState aState; + return aState; +} + +// XPropertyState +Sequence< PropertyState > OPropertySetHelper::getPropertyStates( const Sequence< OUString >& PropertyNames ) +{ + ULONG nNames = PropertyNames.getLength(); + const OUString* pNames = PropertyNames.getConstArray(); + + Sequence< PropertyState > aStates( nNames ); + return aStates; + +} + +void OPropertySetHelper::setPropertyToDefault( const OUString& aPropertyName ) +{ + setPropertyValue( aPropertyName, Any() ); +} + +Any OPropertySetHelper::getPropertyDefault( const OUString& aPropertyName ) const +{ + return Any(); +} + +void OPropertySetHelper::addPropertyStateChangeListener( const OUString& aPropertyName, const XPropertyStateChangeListenerRef& Listener ) +{ +} + +void OPropertySetHelper::removePropertyStateChangeListener( const OUString& aPropertyName, const XPropertyStateChangeListenerRef& Listener ) +{ +} +#endif + +//======================================================================== +//== OPropertyArrayHelper ================================================ +//======================================================================== + +//======================================================================== + +// static OUString makeOUString( sal_Char *p ) +// { +// sal_Int32 nLen = strlen(p); +// sal_Unicode *pw = new sal_Unicode[nLen]; + +// for( int i = 0 ; i < nLen ; i ++ ) { + +// // Only ascii strings allowed with this helper ! +// OSL_ASSERT( p[i] < 127 ); +// pw[i] = p[i]; +// } +// OUString ow( pw , nLen ); +// delete pw; +// return ow; +// } + +extern "C" { + +static int compare_Property_Impl( const void *arg1, const void *arg2 ) + SAL_THROW_EXTERN_C() +{ + return ((Property *)arg1)->Name.compareTo( ((Property *)arg2)->Name ); +} + +} + +void OPropertyArrayHelper::init( sal_Bool bSorted ) SAL_THROW( () ) +{ + sal_Int32 i, nElements = aInfos.getLength(); + const Property* pProperties = aInfos.getConstArray(); + + for( i = 1; i < nElements; i++ ) + { + if( pProperties[i-1].Name >= pProperties[i].Name ) + { +#ifndef OS2 // YD disabled, too many troubles with debug builds! + if (bSorted) { + OSL_ENSURE( false, "Property array is not sorted" ); + } +#endif + // not sorted + qsort( aInfos.getArray(), nElements, sizeof( Property ), + compare_Property_Impl ); + break; + } + } + // may be that the array is resorted + pProperties = aInfos.getConstArray(); + for( i = 0; i < nElements; i++ ) + if( pProperties[i].Handle != i ) + return; + // The handle is the index + bRightOrdered = sal_True; +} + +OPropertyArrayHelper::OPropertyArrayHelper( + Property * pProps, + sal_Int32 nEle, + sal_Bool bSorted ) + SAL_THROW( () ) + : aInfos(pProps, nEle) + , bRightOrdered( sal_False ) +{ + init( bSorted ); +} + +OPropertyArrayHelper::OPropertyArrayHelper( + const Sequence< Property > & aProps, + sal_Bool bSorted ) + SAL_THROW( () ) + : aInfos(aProps) + , bRightOrdered( sal_False ) +{ + init( bSorted ); +} + +//======================================================================== +sal_Int32 OPropertyArrayHelper::getCount() const +{ + return aInfos.getLength(); +} + +//======================================================================== +sal_Bool OPropertyArrayHelper::fillPropertyMembersByHandle +( + OUString * pPropName, + sal_Int16 * pAttributes, + sal_Int32 nHandle +) +{ + const Property* pProperties = aInfos.getConstArray(); + sal_Int32 nElements = aInfos.getLength(); + + if( bRightOrdered ) + { + if( nHandle < 0 || nHandle >= nElements ) + return sal_False; + if( pPropName ) + *pPropName = pProperties[ nHandle ].Name; + if( pAttributes ) + *pAttributes = pProperties[ nHandle ].Attributes; + return sal_True; + } + else + { + // normally the array is sorted + for( sal_Int32 i = 0; i < nElements; i++ ) + { + if( pProperties[i].Handle == nHandle ) + { + if( pPropName ) + *pPropName = pProperties[ i ].Name; + if( pAttributes ) + *pAttributes = pProperties[ i ].Attributes; + return sal_True; + } + } + } + return sal_False; +} + +//======================================================================== +Sequence< Property > OPropertyArrayHelper::getProperties(void) +{ + /*if( aInfos.getLength() != nElements ) + { + ((OPropertyArrayHelper *)this)->aInfos.realloc( nElements ); + Property * pProps = ((OPropertyArrayHelper *)this)->aInfos.getArray(); + for( sal_Int32 i = 0; i < nElements; i++ ) + { + pProps[i].Name = pProperties[i].Name; + pProps[i].Handle = pProperties[i].Handle; + pProps[i].Type = pProperties[i].Type; + pProps[i].Attributes = pProperties[i].Attributes; + } + }*/ + return aInfos; +} + +//======================================================================== +Property OPropertyArrayHelper::getPropertyByName(const OUString& aPropertyName) + throw (UnknownPropertyException) +{ + Property * pR; + pR = (Property *)bsearch( &aPropertyName, aInfos.getConstArray(), aInfos.getLength(), + sizeof( Property ), + compare_OUString_Property_Impl ); + if( !pR ) { + throw UnknownPropertyException(); + } + + /*Property aProp; + aProp.Name = pR->Name; + aProp.Handle = pR->Handle; + aProp.Type = pR->Type; + aProp.Attributes = pR->Attributes; + return aProp;*/ + return *pR; +} + +//======================================================================== +sal_Bool OPropertyArrayHelper::hasPropertyByName(const OUString& aPropertyName) +{ + Property * pR; + pR = (Property *)bsearch( &aPropertyName, aInfos.getConstArray(), aInfos.getLength(), + sizeof( Property ), + compare_OUString_Property_Impl ); + return pR != NULL; +} + +//======================================================================== +sal_Int32 OPropertyArrayHelper::getHandleByName( const OUString & rPropName ) +{ + Property * pR; + pR = (Property *)bsearch( &rPropName, aInfos.getConstArray(), aInfos.getLength(), + sizeof( Property ), + compare_OUString_Property_Impl ); + return pR ? pR->Handle : -1; +} + +//======================================================================== +sal_Int32 OPropertyArrayHelper::fillHandles( sal_Int32 * pHandles, const Sequence< OUString > & rPropNames ) +{ + sal_Int32 nHitCount = 0; + const OUString * pReqProps = rPropNames.getConstArray(); + sal_Int32 nReqLen = rPropNames.getLength(); + const Property * pCur = aInfos.getConstArray(); + const Property * pEnd = pCur + aInfos.getLength(); + + for( sal_Int32 i = 0; i < nReqLen; i++ ) + { + // Calculate logarithm + sal_Int32 n = (sal_Int32)(pEnd - pCur); + sal_Int32 nLog = 0; + while( n ) + { + nLog += 1; + n = n >> 1; + } + + // Number of properties to search for * Log2 of the number of remaining + // properties to search in. + if( (nReqLen - i) * nLog >= pEnd - pCur ) + { + // linear search is better + while( pCur < pEnd && pReqProps[i] > pCur->Name ) + { + pCur++; + } + if( pCur < pEnd && pReqProps[i] == pCur->Name ) + { + pHandles[i] = pCur->Handle; + nHitCount++; + } + else + pHandles[i] = -1; + } + else + { + // binary search is better + sal_Int32 nCompVal = 1; + const Property * pOldEnd = pEnd--; + const Property * pMid = pCur; + + while( nCompVal != 0 && pCur <= pEnd ) + { + pMid = (pEnd - pCur) / 2 + pCur; + + nCompVal = pReqProps[i].compareTo( pMid->Name ); + + if( nCompVal > 0 ) + pCur = pMid + 1; + else + pEnd = pMid - 1; + } + + if( nCompVal == 0 ) + { + pHandles[i] = pMid->Handle; + nHitCount++; + pCur = pMid +1; + } + else if( nCompVal > 0 ) + { + pHandles[i] = -1; + pCur = pMid +1; + } + else + { + pHandles[i] = -1; + pCur = pMid; + } + pEnd = pOldEnd; + } + } + return nHitCount; +} + +} // end namespace cppu + + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/source/servicefactory.cxx b/cppuhelper/source/servicefactory.cxx new file mode 100644 index 000000000000..17b6eadb02af --- /dev/null +++ b/cppuhelper/source/servicefactory.cxx @@ -0,0 +1,663 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_cppuhelper.hxx" + +#if OSL_DEBUG_LEVEL > 0 +#include <stdio.h> +#endif +#include <vector> + +#include "rtl/string.hxx" +#include "rtl/ustrbuf.hxx" +#include "rtl/bootstrap.hxx" +#include "osl/diagnose.h" +#include "osl/file.h" +#include "osl/module.h" +#include "osl/process.h" +#include "cppuhelper/shlib.hxx" +#include "cppuhelper/factory.hxx" +#include "cppuhelper/component_context.hxx" +#include "cppuhelper/servicefactory.hxx" +#include "cppuhelper/bootstrap.hxx" + +#include "com/sun/star/uno/XComponentContext.hpp" +#include "com/sun/star/lang/XInitialization.hpp" +#include "com/sun/star/lang/XSingleServiceFactory.hpp" +#include "com/sun/star/lang/XSingleComponentFactory.hpp" +#include "com/sun/star/beans/XPropertySet.hpp" +#include "com/sun/star/container/XSet.hpp" +#include "com/sun/star/container/XHierarchicalNameAccess.hpp" +#include "com/sun/star/registry/XSimpleRegistry.hpp" +#include "com/sun/star/registry/XImplementationRegistration.hpp" +#include "com/sun/star/security/XAccessController.hpp" + +#define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) ) + + +using namespace ::rtl; +using namespace ::osl; +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; + +namespace cppu +{ + +// private forward decl +void addFactories( + char const * const * ppNames /* lib, implname, ..., 0 */, + OUString const & bootstrapPath, + Reference< lang::XMultiComponentFactory > const & xMgr, + Reference< registry::XRegistryKey > const & xKey ) + SAL_THROW( (Exception) ); + +Reference< security::XAccessController > +createDefaultAccessController() SAL_THROW( () ); + +Reference< lang::XSingleComponentFactory > +create_boostrap_macro_expander_factory() SAL_THROW( () ); + +OUString const & get_this_libpath(); + + +static Reference< XInterface > SAL_CALL createInstance( + Reference< XInterface > const & xFactory, + Reference< XComponentContext > const & xContext = + Reference< XComponentContext >() ) +{ + Reference< lang::XSingleComponentFactory > xFac( xFactory, UNO_QUERY ); + if (xFac.is()) + { + return xFac->createInstanceWithContext( xContext ); + } + else + { + Reference< lang::XSingleServiceFactory > xFac2( xFactory, UNO_QUERY ); + if (xFac2.is()) + { + OSL_ENSURE( !xContext.is(), "### ignoring context!" ); + return xFac2->createInstance(); + } + } + throw RuntimeException( + OUSTR("no factory object given!"), + Reference< XInterface >() ); +} + +Reference< registry::XSimpleRegistry > SAL_CALL createSimpleRegistry( + OUString const & rBootstrapPath ) + SAL_THROW( () ) +{ + try + { + return Reference< registry::XSimpleRegistry >( + createInstance( + loadSharedLibComponentFactory( + OUSTR("bootstrap.uno" SAL_DLLEXTENSION), + 0 == rBootstrapPath.getLength() + ? get_this_libpath() : rBootstrapPath, + OUSTR("com.sun.star.comp.stoc.SimpleRegistry"), + Reference< lang::XMultiServiceFactory >(), + Reference< registry::XRegistryKey >() ) ), + UNO_QUERY ); + } + catch (Exception & exc) + { +#if OSL_DEBUG_LEVEL > 0 + OString cstr_msg( + OUStringToOString( exc.Message, RTL_TEXTENCODING_ASCII_US ) ); + OSL_ENSURE( !"### exception occured:", cstr_msg.getStr() ); +#else + (void) exc; // avoid warning about unused variable +#endif + } + + return Reference< registry::XSimpleRegistry >(); +} + +Reference< registry::XSimpleRegistry > SAL_CALL createNestedRegistry( + OUString const & rBootstrapPath ) + SAL_THROW( () ) +{ + try + { + return Reference< registry::XSimpleRegistry >( + createInstance( + loadSharedLibComponentFactory( + OUSTR("bootstrap.uno" SAL_DLLEXTENSION), + 0 == rBootstrapPath.getLength() + ? get_this_libpath() : rBootstrapPath, + OUSTR("com.sun.star.comp.stoc.NestedRegistry"), + Reference< lang::XMultiServiceFactory >(), + Reference< registry::XRegistryKey >() ) ), + UNO_QUERY ); + } + catch (Exception & exc) + { +#if OSL_DEBUG_LEVEL > 0 + OString cstr_msg( + OUStringToOString( exc.Message, RTL_TEXTENCODING_ASCII_US ) ); + OSL_ENSURE( !"### exception occured:", cstr_msg.getStr() ); +#else + (void) exc; // avoid warning about unused variable +#endif + } + + return Reference< registry::XSimpleRegistry >(); +} + + +/** bootstrap variables: + + UNO_AC=<mode> [mandatory] + -- mode := { on, off, dynamic-only, single-user, single-default-user } + UNO_AC_SERVICE=<service_name> [optional] + -- override ac singleton service name + UNO_AC_SINGLEUSER=<user-id|nothing> [optional] + -- run with this user id or with default user policy (<nothing>) + set UNO_AC=single-[default-]user + UNO_AC_USERCACHE_SIZE=<cache_size> + -- number of user permission sets to be cached + + UNO_AC_POLICYSERVICE=<service_name> [optional] + -- override policy singleton service name + UNO_AC_POLICYFILE=<file_url> [optional] + -- read policy out of simple text file +*/ +static void add_access_control_entries( + ::std::vector< ContextEntry_Init > * values, + Bootstrap const & bootstrap ) + SAL_THROW( (Exception) ) +{ + ContextEntry_Init entry; + ::std::vector< ContextEntry_Init > & context_values = *values; + + OUString ac_policy; + if (bootstrap.getFrom( OUSTR("UNO_AC_POLICYSERVICE"), ac_policy )) + { + // overridden service name + // - policy singleton + entry.bLateInitService = true; + entry.name = OUSTR("/singletons/com.sun.star.security.thePolicy"); + entry.value <<= ac_policy; + context_values.push_back( entry ); + } + else if (bootstrap.getFrom( OUSTR("UNO_AC_POLICYFILE"), ac_policy )) + { + // check for file policy + // - file policy prop: file-name + if (0 != ac_policy.compareToAscii( + RTL_CONSTASCII_STRINGPARAM("file:///") )) + { + // no file url + OUString baseDir; + if ( ::osl_getProcessWorkingDir( &baseDir.pData ) + != osl_Process_E_None ) + { + OSL_ASSERT( false ); + } + OUString fileURL; + if ( ::osl_getAbsoluteFileURL( + baseDir.pData, ac_policy.pData, &fileURL.pData ) + != osl_File_E_None ) + { + OSL_ASSERT( false ); + } + ac_policy = fileURL; + } + + entry.bLateInitService = false; + entry.name = + OUSTR("/implementations/com.sun.star.security.comp.stoc.FilePolicy/" + "file-name"); + entry.value <<= ac_policy; + context_values.push_back( entry ); + // - policy singleton + entry.bLateInitService = true; + entry.name = OUSTR("/singletons/com.sun.star.security.thePolicy"); + entry.value <<= OUSTR("com.sun.star.security.comp.stoc.FilePolicy"); + context_values.push_back( entry ); + } // else policy singleton comes from storage + + OUString ac_mode; + if (! bootstrap.getFrom( OUSTR("UNO_AC"), ac_mode )) + { + ac_mode = OUSTR("off"); // default + } + OUString ac_user; + if (bootstrap.getFrom( OUSTR("UNO_AC_SINGLEUSER"), ac_user )) + { + // ac in single-user mode + if (ac_user.getLength()) + { + // - ac prop: single-user-id + entry.bLateInitService = false; + entry.name = + OUSTR("/services/com.sun.star.security.AccessController/" + "single-user-id"); + entry.value <<= ac_user; + context_values.push_back( entry ); + if (! ac_mode.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("single-user") )) + { + throw SecurityException( + OUSTR("set UNO_AC=single-user " + "if you set UNO_AC_SINGLEUSER=<user-id>!"), + Reference< XInterface >() ); + } + } + else + { + if (! ac_mode.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("single-default-user") )) + { + throw SecurityException( + OUSTR("set UNO_AC=single-default-user " + "if you set UNO_AC_SINGLEUSER=<nothing>!"), + Reference< XInterface >() ); + } + } + } + + OUString ac_service; + if (! bootstrap.getFrom( OUSTR("UNO_AC_SERVICE"), ac_service )) + { + // override service name + ac_service = OUSTR("com.sun.star.security.AccessController"); // default +// ac = OUSTR("com.sun.star.security.comp.stoc.AccessController"); + } + + // - ac prop: user-cache-size + OUString ac_cache; + if (bootstrap.getFrom( OUSTR("UNO_AC_USERCACHE_SIZE"), ac_cache )) + { + // ac cache size + sal_Int32 n = ac_cache.toInt32(); + if (0 < n) + { + entry.bLateInitService = false; + entry.name = + OUSTR("/services/com.sun.star.security.AccessController/" + "user-cache-size"); + entry.value <<= n; + context_values.push_back( entry ); + } + } + + // - ac prop: mode + // { "off", "on", "dynamic-only", "single-user", "single-default-user" } + entry.bLateInitService = false; + entry.name = OUSTR("/services/com.sun.star.security.AccessController/mode"); + entry.value <<= ac_mode; + context_values.push_back( entry ); + // - ac singleton + entry.bLateInitService = true; + entry.name = OUSTR("/singletons/com.sun.star.security.theAccessController"); + entry.value <<= ac_service; + context_values.push_back( entry ); +} + +Reference< lang::XMultiComponentFactory > bootstrapInitialSF( + OUString const & rBootstrapPath ) + SAL_THROW( (Exception) ) +{ + OUString const & bootstrap_path = + 0 == rBootstrapPath.getLength() ? get_this_libpath() : rBootstrapPath; + + Reference< lang::XMultiComponentFactory > xMgr( + createInstance( + loadSharedLibComponentFactory( + OUSTR("bootstrap.uno" SAL_DLLEXTENSION), bootstrap_path, + OUSTR("com.sun.star.comp.stoc.ORegistryServiceManager"), + Reference< lang::XMultiServiceFactory >(), + Reference< registry::XRegistryKey >() ) ), + UNO_QUERY ); + + // add initial bootstrap services + static char const * ar[] = { + "bootstrap.uno" SAL_DLLEXTENSION, + "com.sun.star.comp.stoc.OServiceManagerWrapper", + "bootstrap.uno" SAL_DLLEXTENSION, + "com.sun.star.comp.stoc.DLLComponentLoader", + "bootstrap.uno" SAL_DLLEXTENSION, + "com.sun.star.comp.stoc.SimpleRegistry", + "bootstrap.uno" SAL_DLLEXTENSION, + "com.sun.star.comp.stoc.NestedRegistry", + "bootstrap.uno" SAL_DLLEXTENSION, + "com.sun.star.comp.stoc.TypeDescriptionManager", + "bootstrap.uno" SAL_DLLEXTENSION, + "com.sun.star.comp.stoc.ImplementationRegistration", + "bootstrap.uno" SAL_DLLEXTENSION, + "com.sun.star.security.comp.stoc.AccessController", + "bootstrap.uno" SAL_DLLEXTENSION, + "com.sun.star.security.comp.stoc.FilePolicy", + 0 + }; + addFactories( + ar, bootstrap_path, + xMgr, Reference< registry::XRegistryKey >() ); + + return xMgr; +} + +// returns context with UNinitialized smgr +Reference< XComponentContext > bootstrapInitialContext( + Reference< lang::XMultiComponentFactory > const & xSF, + Reference< registry::XSimpleRegistry > const & types_xRegistry, + Reference< registry::XSimpleRegistry > const & services_xRegistry, + OUString const & rBootstrapPath, Bootstrap const & bootstrap ) + SAL_THROW( (Exception) ) +{ + Reference< lang::XInitialization > xSFInit( xSF, UNO_QUERY ); + if (! xSFInit.is()) + { + throw RuntimeException( + OUSTR("servicemanager does not support XInitialization!"), + Reference< XInterface >() ); + } + + // basic context values + ContextEntry_Init entry; + ::std::vector< ContextEntry_Init > context_values; + context_values.reserve( 14 ); + + // macro expander singleton for loader + entry.bLateInitService = true; + entry.name = OUSTR("/singletons/com.sun.star.util.theMacroExpander"); + entry.value <<= create_boostrap_macro_expander_factory(); + context_values.push_back( entry ); + + // tdmgr singleton + entry.bLateInitService = true; + entry.name = + OUSTR("/singletons/com.sun.star.reflection.theTypeDescriptionManager"); + entry.value <<= OUSTR("com.sun.star.comp.stoc.TypeDescriptionManager"); + context_values.push_back( entry ); + + // read out singleton infos from registry + if (services_xRegistry.is()) + { + Reference< registry::XRegistryKey > xKey( + services_xRegistry->getRootKey() ); + if (xKey.is()) + { + xKey = xKey->openKey( OUSTR("/SINGLETONS") ); + if (xKey.is()) + { + entry.bLateInitService = true; + + Sequence< Reference< registry::XRegistryKey > > keys( + xKey->openKeys() ); + Reference< registry::XRegistryKey > const * pKeys = + keys.getConstArray(); + for ( sal_Int32 nPos = keys.getLength(); nPos--; ) + { + Reference< registry::XRegistryKey > const & xKey2 = + pKeys[ nPos ]; + try + { + OUStringBuffer buf( 32 ); + buf.appendAscii( + RTL_CONSTASCII_STRINGPARAM("/singletons/") ); + buf.append( + xKey2->getKeyName().copy( + sizeof("/SINGLETONS") /* -\0 +'/' */ ) ); + entry.name = buf.makeStringAndClear(); + entry.value <<= xKey2->getStringValue(); + context_values.push_back( entry ); + } + catch (Exception & rExc) + { +#if OSL_DEBUG_LEVEL > 0 + OString aStr( + OUStringToOString( + xKey2->getKeyName().copy( 11 ), + RTL_TEXTENCODING_ASCII_US ) ); + OString aStr2( + OUStringToOString( + rExc.Message, RTL_TEXTENCODING_ASCII_US ) ); + fprintf( + stderr, + "### failed reading singleton [%s]" + " service name from registry: %s\n", + aStr.getStr(), aStr2.getStr() ); +#else + (void) rExc; // avoid warning about unused variable +#endif + } + } + } + } + } + + // ac, policy: + add_access_control_entries( &context_values, bootstrap ); + + // smgr singleton + entry.bLateInitService = false; + entry.name = OUSTR("/singletons/com.sun.star.lang.theServiceManager"); + entry.value <<= xSF; + context_values.push_back( entry ); + + Reference< XComponentContext > xContext( + createComponentContext( + &context_values[ 0 ], context_values.size(), + Reference< XComponentContext >() ) ); + // set default context + Reference< beans::XPropertySet > xProps( xSF, UNO_QUERY ); + OSL_ASSERT( xProps.is() ); + if (xProps.is()) + { + xProps->setPropertyValue( + OUSTR("DefaultContext"), makeAny( xContext ) ); + } + + Reference< container::XHierarchicalNameAccess > xTDMgr; + + // get tdmgr singleton + if (xContext->getValueByName( + OUSTR("/singletons/" + "com.sun.star.reflection.theTypeDescriptionManager") ) + >>= xTDMgr) + { + if (types_xRegistry.is()) // insert rdb provider? + { + // add registry td provider factory to smgr and instance to tdmgr + Reference< lang::XSingleComponentFactory > xFac( + loadSharedLibComponentFactory( + OUSTR("bootstrap.uno" SAL_DLLEXTENSION), + 0 == rBootstrapPath.getLength() + ? get_this_libpath() : rBootstrapPath, + OUSTR("com.sun.star.comp.stoc.RegistryTypeDescriptionProvider"), + Reference< lang::XMultiServiceFactory >( xSF, UNO_QUERY ), + Reference< registry::XRegistryKey >() ), UNO_QUERY ); + OSL_ASSERT( xFac.is() ); + + // smgr + Reference< container::XSet > xSet( xSF, UNO_QUERY ); + xSet->insert( makeAny( xFac ) ); + OSL_ENSURE( + xSet->has( makeAny( xFac ) ), + "### failed registering registry td provider at smgr!" ); + // tdmgr + xSet.set( xTDMgr, UNO_QUERY ); + OSL_ASSERT( xSet.is() ); + Any types_RDB( makeAny( types_xRegistry ) ); + Any rdbtdp( makeAny( xFac->createInstanceWithArgumentsAndContext( + Sequence< Any >( &types_RDB, 1 ), xContext ) ) ); + xSet->insert( rdbtdp ); + OSL_ENSURE( + xSet->has( rdbtdp ), + "### failed inserting registry td provider to tdmgr!" ); + } + // install callback + installTypeDescriptionManager( xTDMgr ); + } + + return xContext; +} + +static Reference< lang::XMultiComponentFactory > createImplServiceFactory( + const OUString & rWriteRegistry, + const OUString & rReadRegistry, + sal_Bool bReadOnly, + const OUString & rBootstrapPath ) + SAL_THROW( (Exception) ) +{ + Reference< lang::XMultiComponentFactory > xSF( + bootstrapInitialSF( rBootstrapPath ) ); + + Reference< registry::XSimpleRegistry > xRegistry; + + // open a registry + sal_Bool bRegistryShouldBeValid = sal_False; + if (rWriteRegistry.getLength() && !rReadRegistry.getLength()) + { + bRegistryShouldBeValid = sal_True; + xRegistry.set( createSimpleRegistry( rBootstrapPath ) ); + if (xRegistry.is()) + { + if (bReadOnly) + { + xRegistry->open( rWriteRegistry, sal_True, sal_False ); + } + else + { + xRegistry->open( rWriteRegistry, sal_False, sal_True ); + } + } + } + else if (rWriteRegistry.getLength() && rReadRegistry.getLength()) + { + // default registry + bRegistryShouldBeValid = sal_True; + xRegistry.set( createNestedRegistry( rBootstrapPath ) ); + + Reference< registry::XSimpleRegistry > xWriteReg( + createSimpleRegistry( rBootstrapPath ) ); + if (xWriteReg.is()) + { + if (bReadOnly) + { + try + { + xWriteReg->open( rWriteRegistry, sal_True, sal_False ); + } + catch (registry::InvalidRegistryException &) + { + } + + if (! xWriteReg->isValid()) + { + throw RuntimeException( + OUSTR("specified first registry " + "could not be open readonly!"), + Reference< XInterface >() ); + } + } + else + { + xWriteReg->open( rWriteRegistry, sal_False, sal_True ); + } + } + + Reference< registry::XSimpleRegistry > xReadReg( + createSimpleRegistry( rBootstrapPath ) ); + if (xReadReg.is()) + { + xReadReg->open( rReadRegistry, sal_True, sal_False ); + } + + Reference< lang::XInitialization > xInit( xRegistry, UNO_QUERY ); + Sequence< Any > aInitSeq( 2 ); + aInitSeq[ 0 ] <<= xWriteReg; + aInitSeq[ 1 ] <<= xReadReg; + xInit->initialize( aInitSeq ); + } + + if (bRegistryShouldBeValid && (!xRegistry.is() || !xRegistry->isValid())) + { + throw RuntimeException( + OUSTR("specified registry could not be initialized"), + Reference< XInterface >() ); + } + + Bootstrap bootstrap; + Reference< XComponentContext > xContext( + bootstrapInitialContext( + xSF, xRegistry, xRegistry, rBootstrapPath, bootstrap ) ); + + // initialize sf + Reference< lang::XInitialization > xInit( xSF, UNO_QUERY ); + OSL_ASSERT( xInit.is() ); + Sequence< Any > aSFInit( 1 ); + aSFInit[ 0 ] <<= xRegistry; + xInit->initialize( aSFInit ); + + return xSF; +} + +Reference< lang::XMultiServiceFactory > SAL_CALL createRegistryServiceFactory( + const OUString & rWriteRegistry, + const OUString & rReadRegistry, + sal_Bool bReadOnly, + const OUString & rBootstrapPath ) + SAL_THROW( (Exception) ) +{ + return Reference< lang::XMultiServiceFactory >( createImplServiceFactory( + rWriteRegistry, rReadRegistry, bReadOnly, rBootstrapPath ), UNO_QUERY ); +} + +Reference< XComponentContext > SAL_CALL bootstrap_InitialComponentContext( + Reference< registry::XSimpleRegistry > const & xRegistry, + OUString const & rBootstrapPath ) + SAL_THROW( (Exception) ) +{ + Bootstrap bootstrap; + + Reference< lang::XMultiComponentFactory > xSF( + bootstrapInitialSF( rBootstrapPath ) ); + Reference< XComponentContext > xContext( + bootstrapInitialContext( + xSF, xRegistry, xRegistry, rBootstrapPath, bootstrap ) ); + + // initialize sf + Reference< lang::XInitialization > xInit( xSF, UNO_QUERY ); + OSL_ASSERT( xInit.is() ); + Sequence< Any > aSFInit( 2 ); + aSFInit[ 0 ] <<= xRegistry; + aSFInit[ 1 ] <<= xContext; // default context + xInit->initialize( aSFInit ); + + return xContext; +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/source/shlib.cxx b/cppuhelper/source/shlib.cxx new file mode 100644 index 000000000000..c9e1a35a5361 --- /dev/null +++ b/cppuhelper/source/shlib.cxx @@ -0,0 +1,612 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_cppuhelper.hxx" + +#include "osl/diagnose.h" +#include "osl/file.hxx" +#include "osl/mutex.hxx" +#include "osl/module.hxx" +#include "rtl/unload.h" +#include "rtl/ustrbuf.hxx" +#include "uno/environment.h" +#include "uno/mapping.hxx" +#include "cppuhelper/factory.hxx" +#include "cppuhelper/shlib.hxx" + +#include "com/sun/star/beans/XPropertySet.hpp" + +#if OSL_DEBUG_LEVEL > 1 +#include <stdio.h> +#endif +#include <vector> + +#define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) ) + + +using namespace ::rtl; +using namespace ::osl; +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; + +namespace cppu +{ + +#if OSL_DEBUG_LEVEL > 1 +//------------------------------------------------------------------------------ +static inline void out( const char * p ) SAL_THROW( () ) +{ + printf( p ); +} +static inline void out( const OUString & r ) throw () +{ + OString s( OUStringToOString( r, RTL_TEXTENCODING_ASCII_US ) ); + out( s.getStr() ); +} +#endif + +//------------------------------------------------------------------------------ +static const ::std::vector< OUString > * getAccessDPath() SAL_THROW( () ) +{ + static ::std::vector< OUString > * s_p = 0; + static bool s_bInit = false; + + if (! s_bInit) + { + ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + if (! s_bInit) + { + const char * pEnv = ::getenv( "CPLD_ACCESSPATH" ); + if (pEnv) + { + static ::std::vector< OUString > s_v; + + OString aEnv( pEnv ); + sal_Int32 nIndex = 0; + do + { + OUString aStr( OStringToOUString( + aEnv.getToken( 0, ';', nIndex ), + RTL_TEXTENCODING_ASCII_US ) ); + OUString aFileUrl; + if (FileBase::getFileURLFromSystemPath(aStr, aFileUrl) + != FileBase::E_None) + { + OSL_ASSERT(false); + } + s_v.push_back( aFileUrl ); + } while( nIndex != -1 ); +#if OSL_DEBUG_LEVEL > 1 + out( "> cpld: acknowledged following access path(s): \"" ); + ::std::vector< OUString >::const_iterator iPos( s_v.begin() ); + while (iPos != s_v.end()) + { + out( *iPos ); + ++iPos; + if (iPos != s_v.end()) + out( ";" ); + } + out( "\"\n" ); +#endif + s_p = & s_v; + } + else + { + // no access path env set +#if OSL_DEBUG_LEVEL > 1 + out( "=> no CPLD_ACCESSPATH set.\n" ); +#endif + } + s_bInit = true; + } + } + + return s_p; +} + +//------------------------------------------------------------------------------ +static bool checkAccessPath( OUString * pComp ) throw () +{ + const ::std::vector< OUString > * pPath = getAccessDPath(); + + if (pPath) + { + sal_Bool bAbsolute = (pComp->compareToAscii( "file://" , 7 ) == 0); + for ( ::std::vector< OUString >::const_iterator iPos( pPath->begin() ); + iPos != pPath->end(); ++iPos ) + { + OUString aBaseDir( *iPos ); + OUString aAbs; + + if ( bAbsolute ) + { + aAbs = *pComp; +#if OSL_DEBUG_LEVEL > 1 + out( "> taking path: \"" ); + out( aAbs ); +#endif + } + else + { + if (osl_File_E_None != + ::osl_getAbsoluteFileURL( + aBaseDir.pData, pComp->pData, &aAbs.pData )) + { + continue; + } +#if OSL_DEBUG_LEVEL > 1 + out( "> found path: \"" ); + out( aBaseDir ); + out( "\" + \"" ); + out( *pComp ); + out( "\" => \"" ); + out( aAbs ); +#endif + } + + if (0 == aAbs.indexOf( aBaseDir ) && // still part of it? + aBaseDir.getLength() < aAbs.getLength() && + (aBaseDir[ aBaseDir.getLength() -1 ] == (sal_Unicode)'/' || + // dir boundary + aAbs[ aBaseDir.getLength() ] == (sal_Unicode)'/')) + { +#if OSL_DEBUG_LEVEL > 1 + out( ": ok.\n" ); +#endif + // load from absolute path + *pComp = aAbs; + return true; + } +#if OSL_DEBUG_LEVEL > 1 + else + { + out( "\" ...does not match given path \"" ); + out( aBaseDir ); + out( "\".\n" ); + } +#endif + } + return false; + } + else + { + // no access path env set + return true; + } +} + +//------------------------------------------------------------------------------ +static inline sal_Int32 endsWith( + const OUString & rText, const OUString & rEnd ) SAL_THROW( () ) +{ + if (rText.getLength() >= rEnd.getLength() && + rEnd.equalsIgnoreAsciiCase( + rText.copy( rText.getLength() - rEnd.getLength() ) )) + { + return rText.getLength() - rEnd.getLength(); + } + return -1; +} + +//------------------------------------------------------------------------------ +static OUString makeComponentPath( + const OUString & rLibName, const OUString & rPath ) +{ +#if OSL_DEBUG_LEVEL > 0 + // No system path allowed here ! + { + OUString aComp; + OSL_ASSERT( FileBase::E_None == + FileBase::getSystemPathFromFileURL( rLibName, aComp ) ); + OSL_ASSERT( + ! rPath.getLength() || + FileBase::E_None == + FileBase::getSystemPathFromFileURL( rPath, aComp ) ); + } +#endif + + OUStringBuffer buf( rPath.getLength() + rLibName.getLength() + 12 ); + + if (0 != rPath.getLength()) + { + buf.append( rPath ); + if (rPath[ rPath.getLength() -1 ] != '/') + buf.append( (sal_Unicode) '/' ); + } + sal_Int32 nEnd = endsWith( rLibName, OUSTR(SAL_DLLEXTENSION) ); + if (nEnd < 0) // !endsWith + { +#ifndef OS2 +//this is always triggered with .uno components +#if (OSL_DEBUG_LEVEL >= 2) + OSL_ENSURE( + !"### library name has no proper extension!", + OUStringToOString( rLibName, RTL_TEXTENCODING_ASCII_US ).getStr() ); +#endif +#endif // OS2 + +#if defined SAL_DLLPREFIX + nEnd = endsWith( rLibName, OUSTR(".uno") ); + if (nEnd < 0) // !endsWith + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(SAL_DLLPREFIX) ); +#endif + buf.append( rLibName ); + buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(SAL_DLLEXTENSION) ); + } + else // name is completely pre/postfixed + { + buf.append( rLibName ); + } + + OUString out( buf.makeStringAndClear() ); +#if OSL_DEBUG_LEVEL > 1 + OString str( OUStringToOString( out, RTL_TEXTENCODING_ASCII_US ) ); + OSL_TRACE( "component path=%s\n", str.getStr() ); +#endif + + return out; +} + +//============================================================================== +static OUString getLibEnv(OUString const & aModulePath, + oslModule lib, + uno::Environment * pEnv, + OUString * pSourceEnv_name, + uno::Environment const & cTargetEnv, + OUString const & cImplName = OUString()) +{ + OUString aExcMsg; + + sal_Char const * pEnvTypeName = NULL; + + OUString aGetEnvNameExt = OUSTR(COMPONENT_GETENVEXT); + component_getImplementationEnvironmentExtFunc pGetImplEnvExt = + (component_getImplementationEnvironmentExtFunc)osl_getFunctionSymbol(lib, aGetEnvNameExt.pData); + + if (pGetImplEnvExt) + { + OString implName(OUStringToOString(cImplName, RTL_TEXTENCODING_ASCII_US)); + pGetImplEnvExt(&pEnvTypeName, (uno_Environment **)pEnv, implName.getStr(), cTargetEnv.get()); + } + else + { + OUString aGetEnvName = OUSTR(COMPONENT_GETENV); + component_getImplementationEnvironmentFunc pGetImplEnv = + (component_getImplementationEnvironmentFunc)osl_getFunctionSymbol( + lib, aGetEnvName.pData ); + if (pGetImplEnv) + pGetImplEnv(&pEnvTypeName, (uno_Environment **)pEnv); + + else + { + aExcMsg = aModulePath; + aExcMsg += OUSTR(": cannot get symbol: "); + aExcMsg += aGetEnvName; + aExcMsg += OUSTR("- nor: "); + } + } + + if (!pEnv->is() && pEnvTypeName) + { + *pSourceEnv_name = OUString::createFromAscii(pEnvTypeName); + const char * pUNO_ENV_LOG = ::getenv( "UNO_ENV_LOG" ); + if (pUNO_ENV_LOG && rtl_str_getLength(pUNO_ENV_LOG) ) + { + OString implName(OUStringToOString(cImplName, RTL_TEXTENCODING_ASCII_US)); + OString aEnv( pUNO_ENV_LOG ); + sal_Int32 nIndex = 0; + do + { + const OString aStr( aEnv.getToken( 0, ';', nIndex ) ); + if ( aStr.equals(implName) ) + { + *pSourceEnv_name += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(":log")); + break; + } + } while( nIndex != -1 ); + } + + } + + return aExcMsg; +} + +extern "C" {static void s_getFactory(va_list * pParam) +{ + component_getFactoryFunc pSym = va_arg(*pParam, component_getFactoryFunc); + OString const * pImplName = va_arg(*pParam, OString const *); + void * pSMgr = va_arg(*pParam, void *); + void * pKey = va_arg(*pParam, void *); + void ** ppSSF = va_arg(*pParam, void **); + + *ppSSF = pSym(pImplName->getStr(), pSMgr, pKey); +}} + +Reference< XInterface > SAL_CALL loadSharedLibComponentFactory( + OUString const & rLibName, OUString const & rPath, + OUString const & rImplName, + Reference< lang::XMultiServiceFactory > const & xMgr, + Reference< registry::XRegistryKey > const & xKey ) + SAL_THROW( (loader::CannotActivateFactoryException) ) +{ + OUString aModulePath( makeComponentPath( rLibName, rPath ) ); + if (! checkAccessPath( &aModulePath )) + { + throw loader::CannotActivateFactoryException( + OUSTR("permission denied to load component library: ") + + aModulePath, + Reference< XInterface >() ); + } + + oslModule lib = osl_loadModule( + aModulePath.pData, SAL_LOADMODULE_LAZY | SAL_LOADMODULE_GLOBAL ); + if (! lib) + { + throw loader::CannotActivateFactoryException( + OUSTR("loading component library failed: ") + aModulePath, + Reference< XInterface >() ); + } + + Reference< XInterface > xRet; + + uno::Environment currentEnv(Environment::getCurrent()); + uno::Environment env; + + OUString aEnvTypeName; + + OUString aExcMsg = getLibEnv(aModulePath, lib, &env, &aEnvTypeName, currentEnv, rImplName); + if (!aExcMsg.getLength()) + { + OUString aGetFactoryName = OUSTR(COMPONENT_GETFACTORY); + oslGenericFunction pSym = osl_getFunctionSymbol( lib, aGetFactoryName.pData ); + if (pSym != 0) + { + OString aImplName( + OUStringToOString( rImplName, RTL_TEXTENCODING_ASCII_US ) ); + + if (!env.is()) + env = uno::Environment(aEnvTypeName); + + if (env.is() && currentEnv.is()) + { +#if OSL_DEBUG_LEVEL > 1 + { + rtl::OString libName(rtl::OUStringToOString(rLibName, RTL_TEXTENCODING_ASCII_US)); + rtl::OString implName(rtl::OUStringToOString(rImplName, RTL_TEXTENCODING_ASCII_US)); + rtl::OString envDcp(rtl::OUStringToOString(env.getTypeName(), RTL_TEXTENCODING_ASCII_US)); + + fprintf(stderr, "loadSharedLibComponentFactory envDcp: %-12.12s implName: %30.30s libName: %-15.15s\n", envDcp.getStr(), implName.getStr() + (implName.getLength() > 30 ? implName.getLength() - 30 : 0), libName.getStr()); + } +#endif + + Mapping aCurrent2Env( currentEnv, env ); + Mapping aEnv2Current( env, currentEnv ); + + if (aCurrent2Env.is() && aEnv2Current.is()) + { + void * pSMgr = aCurrent2Env.mapInterface( + xMgr.get(), ::getCppuType( &xMgr ) ); + void * pKey = aCurrent2Env.mapInterface( + xKey.get(), ::getCppuType( &xKey ) ); + + void * pSSF = NULL; + + env.invoke(s_getFactory, pSym, &aImplName, pSMgr, pKey, &pSSF); + + if (pKey) + { + (env.get()->pExtEnv->releaseInterface)( + env.get()->pExtEnv, pKey ); + } + if (pSMgr) + { + (*env.get()->pExtEnv->releaseInterface)( + env.get()->pExtEnv, pSMgr ); + } + + if (pSSF) + { + aEnv2Current.mapInterface( + reinterpret_cast< void ** >( &xRet ), + pSSF, ::getCppuType( &xRet ) ); + (env.get()->pExtEnv->releaseInterface)( + env.get()->pExtEnv, pSSF ); + } + else + { + aExcMsg = aModulePath; + aExcMsg += OUSTR(": cannot get factory of " + "demanded implementation: "); + aExcMsg += OStringToOUString( + aImplName, RTL_TEXTENCODING_ASCII_US ); + } + } + else + { + aExcMsg = + OUSTR("cannot get uno mappings: C++ <=> UNO!"); + } + } + else + { + aExcMsg = OUSTR("cannot get uno environments!"); + } + } + else + { + aExcMsg = aModulePath; + aExcMsg += OUSTR(": cannot get symbol: "); + aExcMsg += aGetFactoryName; + } + } + + if (! xRet.is()) + { + osl_unloadModule( lib ); +#if OSL_DEBUG_LEVEL > 1 + out( "### cannot activate factory: " ); + out( aExcMsg ); + out( "\n" ); +#endif + throw loader::CannotActivateFactoryException( + aExcMsg, + Reference< XInterface >() ); + } + + rtl_registerModuleForUnloading( lib); + return xRet; +} + +//============================================================================== +extern "C" { static void s_writeInfo(va_list * pParam) +{ + component_writeInfoFunc pSym = va_arg(*pParam, component_writeInfoFunc); + void * pSMgr = va_arg(*pParam, void *); + void * pKey = va_arg(*pParam, void *); + sal_Bool * pbRet = va_arg(*pParam, sal_Bool *); + + *pbRet = pSym(pSMgr, pKey); + +}} + +void SAL_CALL writeSharedLibComponentInfo( + OUString const & rLibName, OUString const & rPath, + Reference< lang::XMultiServiceFactory > const & xMgr, + Reference< registry::XRegistryKey > const & xKey ) + SAL_THROW( (registry::CannotRegisterImplementationException) ) +{ + OUString aModulePath( makeComponentPath( rLibName, rPath ) ); + + if (! checkAccessPath( &aModulePath )) + { + throw registry::CannotRegisterImplementationException( + OUSTR("permission denied to load component library: ") + + aModulePath, + Reference< XInterface >() ); + } + + oslModule lib = osl_loadModule( + aModulePath.pData, SAL_LOADMODULE_LAZY | SAL_LOADMODULE_GLOBAL ); + if (! lib) + { + throw registry::CannotRegisterImplementationException( + OUSTR("loading component library failed: ") + aModulePath, + Reference< XInterface >() ); + } + + sal_Bool bRet = sal_False; + + uno::Environment currentEnv(Environment::getCurrent()); + uno::Environment env; + + OUString aEnvTypeName; + OUString aExcMsg = getLibEnv(aModulePath, lib, &env, &aEnvTypeName, currentEnv); + if (!aExcMsg.getLength()) + { + OUString aWriteInfoName = OUSTR(COMPONENT_WRITEINFO); + oslGenericFunction pSym = osl_getFunctionSymbol( lib, aWriteInfoName.pData ); + if (pSym != 0) + { + if (!env.is()) + env = uno::Environment(aEnvTypeName); + + if (env.is() && currentEnv.is()) + { + Mapping aCurrent2Env( currentEnv, env ); + if (aCurrent2Env.is()) + { + void * pSMgr = aCurrent2Env.mapInterface( + xMgr.get(), ::getCppuType( &xMgr ) ); + void * pKey = aCurrent2Env.mapInterface( + xKey.get(), ::getCppuType( &xKey ) ); + if (pKey) + { + env.invoke(s_writeInfo, pSym, pSMgr, pKey, &bRet); + + + (*env.get()->pExtEnv->releaseInterface)( + env.get()->pExtEnv, pKey ); + if (! bRet) + { + aExcMsg = aModulePath; + aExcMsg += OUSTR(": component_writeInfo() " + "returned false!"); + } + } + else + { + // key is mandatory + aExcMsg = aModulePath; + aExcMsg += OUSTR(": registry is mandatory to invoke" + " component_writeInfo()!"); + } + + if (pSMgr) + { + (*env.get()->pExtEnv->releaseInterface)( + env.get()->pExtEnv, pSMgr ); + } + } + else + { + aExcMsg = OUSTR("cannot get uno mapping: C++ <=> UNO!"); + } + } + else + { + aExcMsg = OUSTR("cannot get uno environments!"); + } + } + else + { + aExcMsg = aModulePath; + aExcMsg += OUSTR(": cannot get symbol: "); + aExcMsg += aWriteInfoName; + } + } + +//! +//! OK: please look at #88219# +//! +//! ::osl_unloadModule( lib); + if (! bRet) + { +#if OSL_DEBUG_LEVEL > 1 + out( "### cannot write component info: " ); + out( aExcMsg ); + out( "\n" ); +#endif + throw registry::CannotRegisterImplementationException( + aExcMsg, Reference< XInterface >() ); + } +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/source/stdidlclass.cxx b/cppuhelper/source/stdidlclass.cxx new file mode 100644 index 000000000000..512913c65811 --- /dev/null +++ b/cppuhelper/source/stdidlclass.cxx @@ -0,0 +1,262 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_cppuhelper.hxx" + +#include <osl/mutex.hxx> + +#include <cppuhelper/weakref.hxx> +#include <cppuhelper/weak.hxx> +#include <cppuhelper/stdidlclass.hxx> + +#include <com/sun/star/reflection/XIdlClassProvider.hpp> +#include <com/sun/star/reflection/XIdlReflection.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/uno/DeploymentException.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> + +using namespace com::sun::star; +using namespace com::sun::star::uno; +using namespace com::sun::star::lang; +using namespace com::sun::star::reflection; +using namespace rtl; + +namespace cppu { + +/*--------------------------------------------------------- +* This helper class implements XIdlClass. Is used by +* createStdIdlClass() +*---------------------------------------------------------*/ +class OStdIdlClass : + public OWeakObject, + public XIdlClass, + public XIdlClassProvider +{ +public: + OStdIdlClass( + const Reference < XMultiServiceFactory > &rSMgr , + const OUString & sImplementationName , + const Reference < XIdlClass > & rSuperClass, + const Sequence < OUString > &seq + ) SAL_THROW( () ); + + // XInterface + Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) + throw(::com::sun::star::uno::RuntimeException); + + void SAL_CALL acquire() throw() { OWeakObject::acquire(); } + void SAL_CALL release() throw() { OWeakObject::release(); } + + // XIdlClassProvider + Sequence< Reference < XIdlClass > > SAL_CALL getIdlClasses(void) + throw (RuntimeException); + + // XIdlClass + virtual Sequence< Reference< XIdlClass > > SAL_CALL getClasses( ) throw(RuntimeException) + { return Sequence < Reference < XIdlClass > > (); } + virtual Reference< XIdlClass > SAL_CALL getClass( const ::rtl::OUString& ) throw(RuntimeException) + { return Reference < XIdlClass > (); } + virtual sal_Bool SAL_CALL equals( const Reference< XIdlClass >& Type ) throw(RuntimeException) + { return getName() == Type->getName(); } + virtual sal_Bool SAL_CALL isAssignableFrom( const Reference< XIdlClass >& xType ) throw(RuntimeException) + { return equals( xType ); } + virtual TypeClass SAL_CALL getTypeClass( ) throw(RuntimeException) + { return TypeClass_UNKNOWN; } + virtual OUString SAL_CALL getName( ) throw(RuntimeException) + { return m_sImplementationName; } + virtual Uik SAL_CALL getUik( ) throw(RuntimeException) + { return Uik(); } + virtual Sequence< Reference< XIdlClass > > SAL_CALL getSuperclasses( ) throw(RuntimeException) + { return m_seqSuperClasses; } + virtual Sequence< Reference< XIdlClass > > SAL_CALL getInterfaces( ) throw(RuntimeException); + + virtual Reference< XIdlClass > SAL_CALL getComponentType( ) throw(RuntimeException) + { return Reference < XIdlClass > (); } + virtual Reference< XIdlField > SAL_CALL getField( const ::rtl::OUString& ) throw(RuntimeException) + { return Reference < XIdlField > (); } + virtual Sequence< Reference< XIdlField > > SAL_CALL getFields( ) throw(RuntimeException) + { return Sequence< Reference < XIdlField > > (); } + virtual Reference< XIdlMethod > SAL_CALL getMethod( const ::rtl::OUString& ) throw(RuntimeException) + { return Reference < XIdlMethod > (); } + virtual Sequence< Reference< XIdlMethod > > SAL_CALL getMethods( ) throw(RuntimeException) + { return Sequence < Reference < XIdlMethod > > (); } + virtual Reference< XIdlArray > SAL_CALL getArray( ) throw(RuntimeException) + { return Reference < XIdlArray > (); } + virtual void SAL_CALL createObject( Any& ) throw(RuntimeException) {} + +private: + OUString m_sImplementationName; + Sequence < OUString > m_seqSupportedInterface; + Sequence < Reference < XIdlClass > > m_seqSuperClasses; + Reference < XMultiServiceFactory > m_rSMgr; + + Reference< XIdlReflection > m_xCorefl; + Reference< XIdlReflection > const & get_corefl() SAL_THROW( (RuntimeException) ); +}; + +Reference< XIdlReflection > const & OStdIdlClass::get_corefl() + SAL_THROW( (RuntimeException) ) +{ + if (! m_xCorefl.is()) + { + if( m_rSMgr.is() ) + { + Reference< beans::XPropertySet > xProps( m_rSMgr, UNO_QUERY ); + OSL_ASSERT( xProps.is() ); + if (xProps.is()) + { + Reference< XComponentContext > xContext; + xProps->getPropertyValue( + OUString( RTL_CONSTASCII_USTRINGPARAM("DefaultContext") ) ) >>= xContext; + OSL_ASSERT( xContext.is() ); + if (xContext.is()) + { + Reference < XIdlReflection > x; + xContext->getValueByName( + OUString( RTL_CONSTASCII_USTRINGPARAM("/singletons/com.sun.star.reflection.theCoreReflection") ) ) >>= x; + OSL_ENSURE( x.is(), "### CoreReflection singleton not accessible!?" ); + + if (x.is()) + { + ::osl::MutexGuard guard( ::osl::Mutex::getGlobalMutex() ); + if (! m_xCorefl.is()) + { + m_xCorefl = x; + } + } + } + } + } + if (! m_xCorefl.is()) + { + throw DeploymentException( + OUString( RTL_CONSTASCII_USTRINGPARAM("/singletons/com.sun.star.reflection.theCoreReflection singleton not accessible") ), + Reference< XInterface >() ); + } + } + return m_xCorefl; +} + +OStdIdlClass::OStdIdlClass( + const Reference < XMultiServiceFactory > &rSMgr , + const OUString & sImplementationName , + const Reference < XIdlClass > & rSuperClass, + const Sequence < OUString > &seq + ) SAL_THROW( () ) : + m_sImplementationName( sImplementationName ) , + m_seqSupportedInterface( seq ), + m_rSMgr( rSMgr ) +{ + if( rSuperClass.is() ) + m_seqSuperClasses = Sequence< Reference < XIdlClass > >( &rSuperClass, 1 ); + +} + +Any SAL_CALL OStdIdlClass::queryInterface( const Type & rType ) + throw(::com::sun::star::uno::RuntimeException) +{ + Any aRet( ::cppu::queryInterface( + rType, static_cast< XIdlClass * >( this ), static_cast< XIdlClassProvider * >( this ) ) ); + + return (aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType )); +} + + +Sequence< Reference< XIdlClass > > SAL_CALL OStdIdlClass::getInterfaces( ) throw(RuntimeException) +{ + int nMax = m_seqSupportedInterface.getLength(); + + Reference< XIdlReflection > const & rCoreRefl = get_corefl(); + if( rCoreRefl.is() ) + { + Sequence< Reference< XIdlClass > > seqClasses( nMax ); + + for( int n = 0 ; n < nMax ; n++ ) + { + seqClasses.getArray()[n] = rCoreRefl->forName( m_seqSupportedInterface.getArray()[n] ); + } + + return seqClasses; + } + return Sequence< Reference< XIdlClass > > () ; +} + + +// XIdlClassProvider +Sequence< Reference < XIdlClass > > SAL_CALL OStdIdlClass::getIdlClasses(void) + throw (RuntimeException) +{ + // weak reference to cache the standard class + static WeakReference< XIdlClass > weakRef; + + // try to make weakref hard + Reference < XIdlClass > r = weakRef; + + if( ! r.is() ) { + // xidlclass has not been initialized before or has been destroyed already. + r = ::cppu::createStandardClass( + m_rSMgr , + OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.cppuhelper.OStdIdlClass") ) , + Reference < XIdlClass > () , + SAL_STATIC_CAST( XIdlClassProvider * , this ) , + SAL_STATIC_CAST( XIdlClass * , this ) + ); + + // store reference for later use + weakRef = r; + } + + return Sequence < Reference < XIdlClass > > ( &r , 1 ); +} + + + + +// external constructor +XIdlClass * SAL_CALL createStandardClassWithSequence( + const Reference < XMultiServiceFactory > &rSMgr , + const OUString & sImplementationName , + const Reference < XIdlClass > & rSuperClass, + const Sequence < OUString > &seqInterfaceNames ) + SAL_THROW( () ) +{ + return SAL_STATIC_CAST( + XIdlClass * , + new OStdIdlClass( + rSMgr , + sImplementationName, + rSuperClass, + seqInterfaceNames + ) + ); +} + +} //end namespace cppu + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/source/tdmgr.cxx b/cppuhelper/source/tdmgr.cxx new file mode 100644 index 000000000000..c5b76e4fe4af --- /dev/null +++ b/cppuhelper/source/tdmgr.cxx @@ -0,0 +1,764 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_cppuhelper.hxx" +#include <sal/alloca.h> + +#include <osl/diagnose.h> +#include <rtl/alloc.h> +#include <rtl/ustring.hxx> + +#include <uno/mapping.hxx> + +#include <cppuhelper/bootstrap.hxx> +#include <cppuhelper/implbase1.hxx> +#include <typelib/typedescription.h> + +#include <com/sun/star/lang/XComponent.hpp> +#include <com/sun/star/container/XHierarchicalNameAccess.hpp> +#include <com/sun/star/reflection/XTypeDescription.hpp> +#include <com/sun/star/reflection/XEnumTypeDescription.hpp> +#include <com/sun/star/reflection/XIndirectTypeDescription.hpp> +#include <com/sun/star/reflection/XInterfaceMemberTypeDescription.hpp> +#include <com/sun/star/reflection/XInterfaceAttributeTypeDescription.hpp> +#include <com/sun/star/reflection/XMethodParameter.hpp> +#include <com/sun/star/reflection/XInterfaceMethodTypeDescription.hpp> +#include <com/sun/star/reflection/XInterfaceTypeDescription2.hpp> +#include <com/sun/star/reflection/XCompoundTypeDescription.hpp> +#include <com/sun/star/reflection/XStructTypeDescription.hpp> +#include <com/sun/star/reflection/XUnionTypeDescription.hpp> +#include "com/sun/star/uno/RuntimeException.hpp" + +#include "boost/scoped_array.hpp" + +using namespace ::rtl; +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::reflection; + + +namespace cppu +{ + +static typelib_TypeDescription * createCTD( + Reference< container::XHierarchicalNameAccess > const & access, + const Reference< XTypeDescription > & xType ); + +//================================================================================================== +inline static sal_Int64 coerceToInt64( const Any & rVal ) +{ + switch (rVal.getValueTypeClass()) + { + case TypeClass_CHAR: + return *(sal_Unicode *)rVal.getValue(); + case TypeClass_BOOLEAN: + return (*(sal_Bool *)rVal.getValue() ? 1 : 0); + case TypeClass_BYTE: + return *(sal_Int8 *)rVal.getValue(); + case TypeClass_SHORT: + return *(sal_Int16 *)rVal.getValue(); + case TypeClass_UNSIGNED_SHORT: + return *(sal_uInt16 *)rVal.getValue(); + case TypeClass_LONG: + return *(sal_Int32 *)rVal.getValue(); + case TypeClass_UNSIGNED_LONG: + return *(sal_uInt32 *)rVal.getValue(); + case TypeClass_HYPER: + return *(sal_Int64 *)rVal.getValue(); + case TypeClass_UNSIGNED_HYPER: + return *(sal_uInt64 *)rVal.getValue(); + case TypeClass_ENUM: + return *(int *)rVal.getValue(); + default: + OSL_ASSERT(false); + return 0; + } +} +//================================================================================================== +inline static typelib_TypeDescription * createCTD( + const Reference< XUnionTypeDescription > & xType ) +{ + typelib_TypeDescription * pRet = 0; + if (xType.is()) + { + OUString aTypeName( xType->getName() ); + + // discriminant type + Reference< XTypeDescription > xDiscrTD( xType->getDiscriminantType() ); + OUString aDiscrTypeName( xDiscrTD->getName() ); + typelib_TypeDescriptionReference * pDiscrTypeRef = 0; + typelib_typedescriptionreference_new( &pDiscrTypeRef, + (typelib_TypeClass)xDiscrTD->getTypeClass(), + aDiscrTypeName.pData ); + // default member type + Reference< XTypeDescription > xDefaultMemberTD( xType->getDefaultMemberType() ); + OUString aDefMemberTypeName( xDefaultMemberTD->getName() ); + typelib_TypeDescriptionReference * pDefMemberTypeRef = 0; + typelib_typedescriptionreference_new( &pDefMemberTypeRef, + (typelib_TypeClass)xDefaultMemberTD->getTypeClass(), + aDefMemberTypeName.pData ); + // init array + Sequence< Any > aDiscriminants( xType->getDiscriminants() ); + Sequence< Reference< XTypeDescription > > aMemberTypes( xType->getMemberTypes() ); + Sequence< OUString > aMemberNames( xType->getMemberNames() ); + sal_Int32 nMembers = aDiscriminants.getLength(); + OSL_ASSERT( nMembers == aMemberNames.getLength() && nMembers == aMemberTypes.getLength() ); + + const Any * pDiscriminants = aDiscriminants.getConstArray(); + const Reference< XTypeDescription > * pMemberTypes = aMemberTypes.getConstArray(); + const OUString * pMemberNames = aMemberNames.getConstArray(); + + typelib_Union_Init * pMembers = (typelib_Union_Init *)alloca( nMembers * sizeof(typelib_Union_Init) ); + + sal_Int32 nPos; + for ( nPos = nMembers; nPos--; ) + { + typelib_Union_Init & rEntry = pMembers[nPos]; + // member discriminant + rEntry.nDiscriminant = coerceToInt64( pDiscriminants[nPos] ); + // member type + OUString aMemberTypeName( pMemberTypes[nPos]->getName() ); + rEntry.pTypeRef = 0; + typelib_typedescriptionreference_new( &rEntry.pTypeRef, + (typelib_TypeClass)pMemberTypes[nPos]->getTypeClass(), + aMemberTypeName.pData ); + // member name + rEntry.pMemberName = pMemberNames[nPos].pData; + } + + typelib_typedescription_newUnion( &pRet, aTypeName.pData, + pDiscrTypeRef, + coerceToInt64( xType->getDefaultDiscriminant() ), + pDefMemberTypeRef, + nMembers, pMembers ); + + for ( nPos = nMembers; nPos--; ) + { + typelib_typedescriptionreference_release( pMembers[nPos].pTypeRef ); + } + + typelib_typedescriptionreference_release( pDiscrTypeRef ); + typelib_typedescriptionreference_release( pDefMemberTypeRef ); + } + return pRet; +} +//================================================================================================== +inline static typelib_TypeDescription * createCTD( + const Reference< XCompoundTypeDescription > & xType ) +{ + typelib_TypeDescription * pRet = 0; + if (xType.is()) + { + typelib_TypeDescription * pBaseType = createCTD( + Reference< XCompoundTypeDescription >::query( xType->getBaseType() ) ); + if (pBaseType) + typelib_typedescription_register( &pBaseType ); + + // construct member init array + const Sequence<Reference< XTypeDescription > > & rMemberTypes = xType->getMemberTypes(); + const Sequence< OUString > & rMemberNames = xType->getMemberNames(); + + const Reference< XTypeDescription > * pMemberTypes = rMemberTypes.getConstArray(); + const OUString * pMemberNames = rMemberNames.getConstArray(); + + sal_Int32 nMembers = rMemberTypes.getLength(); + OSL_ENSURE( nMembers == rMemberNames.getLength(), "### lens differ!" ); + + OUString aTypeName( xType->getName() ); + + typelib_CompoundMember_Init * pMemberInits = (typelib_CompoundMember_Init *)alloca( + sizeof(typelib_CompoundMember_Init) * nMembers ); + + sal_Int32 nPos; + for ( nPos = nMembers; nPos--; ) + { + typelib_CompoundMember_Init & rInit = pMemberInits[nPos]; + rInit.eTypeClass = (typelib_TypeClass)pMemberTypes[nPos]->getTypeClass(); + + OUString aMemberTypeName( pMemberTypes[nPos]->getName() ); + rtl_uString_acquire( rInit.pTypeName = aMemberTypeName.pData ); + + // string is held by rMemberNames + rInit.pMemberName = pMemberNames[nPos].pData; + } + + typelib_typedescription_new( + &pRet, + (typelib_TypeClass)xType->getTypeClass(), + aTypeName.pData, + (pBaseType ? pBaseType->pWeakRef : 0), + nMembers, pMemberInits ); + + // cleanup + for ( nPos = nMembers; nPos--; ) + { + rtl_uString_release( pMemberInits[nPos].pTypeName ); + } + if (pBaseType) + typelib_typedescription_release( pBaseType ); + } + return pRet; +} +//================================================================================================== +inline static typelib_TypeDescription * createCTD( + Reference< container::XHierarchicalNameAccess > const & access, + const Reference< XStructTypeDescription > & xType ) +{ + typelib_TypeDescription * pRet = 0; + if (xType.is() && xType->getTypeParameters().getLength() == 0) + { + typelib_TypeDescription * pBaseType = createCTD( + access, xType->getBaseType() ); + if (pBaseType) + typelib_typedescription_register( &pBaseType ); + + // construct member init array + const Sequence<Reference< XTypeDescription > > & rMemberTypes = xType->getMemberTypes(); + const Sequence< OUString > & rMemberNames = xType->getMemberNames(); + + const Reference< XTypeDescription > * pMemberTypes = rMemberTypes.getConstArray(); + const OUString * pMemberNames = rMemberNames.getConstArray(); + + sal_Int32 nMembers = rMemberTypes.getLength(); + OSL_ENSURE( nMembers == rMemberNames.getLength(), "### lens differ!" ); + + OUString aTypeName( xType->getName() ); + + typelib_StructMember_Init * pMemberInits = (typelib_StructMember_Init *)alloca( + sizeof(typelib_StructMember_Init) * nMembers ); + + Sequence< Reference< XTypeDescription > > templateMemberTypes; + sal_Int32 i = aTypeName.indexOf('<'); + if (i >= 0) { + Reference< XStructTypeDescription > templateDesc( + access->getByHierarchicalName(aTypeName.copy(0, i)), + UNO_QUERY_THROW); + OSL_ASSERT( + templateDesc->getTypeParameters().getLength() + == xType->getTypeArguments().getLength()); + templateMemberTypes = templateDesc->getMemberTypes(); + OSL_ASSERT(templateMemberTypes.getLength() == nMembers); + } + + sal_Int32 nPos; + for ( nPos = nMembers; nPos--; ) + { + typelib_StructMember_Init & rInit = pMemberInits[nPos]; + rInit.aBase.eTypeClass + = (typelib_TypeClass)pMemberTypes[nPos]->getTypeClass(); + + OUString aMemberTypeName( pMemberTypes[nPos]->getName() ); + rtl_uString_acquire( + rInit.aBase.pTypeName = aMemberTypeName.pData ); + + // string is held by rMemberNames + rInit.aBase.pMemberName = pMemberNames[nPos].pData; + + rInit.bParameterizedType = templateMemberTypes.getLength() != 0 + && (templateMemberTypes[nPos]->getTypeClass() + == TypeClass_UNKNOWN); + } + + typelib_typedescription_newStruct( + &pRet, + aTypeName.pData, + (pBaseType ? pBaseType->pWeakRef : 0), + nMembers, pMemberInits ); + + // cleanup + for ( nPos = nMembers; nPos--; ) + { + rtl_uString_release( pMemberInits[nPos].aBase.pTypeName ); + } + if (pBaseType) + typelib_typedescription_release( pBaseType ); + } + return pRet; +} +//================================================================================================== +inline static typelib_TypeDescription * createCTD( + const Reference< XInterfaceAttributeTypeDescription > & xAttribute ) +{ + typelib_TypeDescription * pRet = 0; + if (xAttribute.is()) + { + OUString aMemberName( xAttribute->getName() ); + Reference< XTypeDescription > xType( xAttribute->getType() ); + OUString aMemberTypeName( xType->getName() ); + + typelib_typedescription_newInterfaceAttribute( + (typelib_InterfaceAttributeTypeDescription **)&pRet, + xAttribute->getPosition(), + aMemberName.pData, // name + (typelib_TypeClass)xType->getTypeClass(), + aMemberTypeName.pData, // type name + xAttribute->isReadOnly() ); + } + return pRet; +} +//================================================================================================== +static typelib_TypeDescription * createCTD( + const Reference< XInterfaceMethodTypeDescription > & xMethod ) +{ + typelib_TypeDescription * pRet = 0; + if (xMethod.is()) + { + Reference< XTypeDescription > xReturnType( xMethod->getReturnType() ); + + // init all params + const Sequence<Reference< XMethodParameter > > & rParams = xMethod->getParameters(); + const Reference< XMethodParameter > * pParams = rParams.getConstArray(); + sal_Int32 nParams = rParams.getLength(); + + typelib_Parameter_Init * pParamInit = (typelib_Parameter_Init *)alloca( + sizeof(typelib_Parameter_Init) * nParams ); + + sal_Int32 nPos; + for ( nPos = nParams; nPos--; ) + { + const Reference< XMethodParameter > & xParam = pParams[nPos]; + const Reference< XTypeDescription > & xType = xParam->getType(); + typelib_Parameter_Init & rInit = pParamInit[xParam->getPosition()]; + + rInit.eTypeClass = (typelib_TypeClass)xType->getTypeClass(); + OUString aParamTypeName( xType->getName() ); + rtl_uString_acquire( rInit.pTypeName = aParamTypeName.pData ); + OUString aParamName( xParam->getName() ); + rtl_uString_acquire( rInit.pParamName = aParamName.pData ); + rInit.bIn = xParam->isIn(); + rInit.bOut = xParam->isOut(); + } + + // init all exception strings + const Sequence<Reference< XTypeDescription > > & rExceptions = xMethod->getExceptions(); + const Reference< XTypeDescription > * pExceptions = rExceptions.getConstArray(); + sal_Int32 nExceptions = rExceptions.getLength(); + rtl_uString ** ppExceptionNames = (rtl_uString **)alloca( + sizeof(rtl_uString *) * nExceptions ); + + for ( nPos = nExceptions; nPos--; ) + { + OUString aExceptionTypeName( pExceptions[nPos]->getName() ); + rtl_uString_acquire( ppExceptionNames[nPos] = aExceptionTypeName.pData ); + } + + OUString aTypeName( xMethod->getName() ); + OUString aReturnTypeName( xReturnType->getName() ); + + typelib_typedescription_newInterfaceMethod( + (typelib_InterfaceMethodTypeDescription **)&pRet, + xMethod->getPosition(), + xMethod->isOneway(), + aTypeName.pData, + (typelib_TypeClass)xReturnType->getTypeClass(), + aReturnTypeName.pData, + nParams, pParamInit, + nExceptions, ppExceptionNames ); + + for ( nPos = nParams; nPos--; ) + { + rtl_uString_release( pParamInit[nPos].pTypeName ); + rtl_uString_release( pParamInit[nPos].pParamName ); + } + for ( nPos = nExceptions; nPos--; ) + { + rtl_uString_release( ppExceptionNames[nPos] ); + } + } + return pRet; +} +//================================================================================================== +inline static typelib_TypeDescription * createCTD( + Reference< container::XHierarchicalNameAccess > const & access, + const Reference< XInterfaceTypeDescription2 > & xType ) +{ + typelib_TypeDescription * pRet = 0; + if (xType.is()) + { + Sequence< Reference< XTypeDescription > > aBases(xType->getBaseTypes()); + sal_Int32 nBases = aBases.getLength(); + // Exploit the fact that a typelib_TypeDescription for an interface type + // is also the typelib_TypeDescriptionReference for that type: + boost::scoped_array< typelib_TypeDescription * > aBaseTypes( + new typelib_TypeDescription *[nBases]); + {for (sal_Int32 i = 0; i < nBases; ++i) { + typelib_TypeDescription * p = createCTD(access, aBases[i]); + OSL_ASSERT( + !TYPELIB_TYPEDESCRIPTIONREFERENCE_ISREALLYWEAK(p->eTypeClass)); + typelib_typedescription_register(&p); + aBaseTypes[i] = p; + }} + typelib_TypeDescriptionReference ** pBaseTypeRefs + = reinterpret_cast< typelib_TypeDescriptionReference ** >( + aBaseTypes.get()); + + // construct all member refs + const Sequence<Reference< XInterfaceMemberTypeDescription > > & rMembers = xType->getMembers(); + sal_Int32 nMembers = rMembers.getLength(); + + typelib_TypeDescriptionReference ** ppMemberRefs = (typelib_TypeDescriptionReference **)alloca( + sizeof(typelib_TypeDescriptionReference *) * nMembers ); + + const Reference< XInterfaceMemberTypeDescription > * pMembers = rMembers.getConstArray(); + + OUString aTypeName( xType->getName() ); + + sal_Int32 nPos; + for ( nPos = nMembers; nPos--; ) + { + OUString aMemberTypeName( pMembers[nPos]->getName() ); + ppMemberRefs[nPos] = 0; + typelib_typedescriptionreference_new( + ppMemberRefs + nPos, + (typelib_TypeClass)pMembers[nPos]->getTypeClass(), + aMemberTypeName.pData ); + } + + Uik uik = xType->getUik(); + + typelib_typedescription_newMIInterface( + (typelib_InterfaceTypeDescription **)&pRet, + aTypeName.pData, + uik.m_Data1, uik.m_Data2, uik.m_Data3, uik.m_Data4, uik.m_Data5, + nBases, pBaseTypeRefs, + nMembers, ppMemberRefs ); + + // cleanup refs and base type + {for (int i = 0; i < nBases; ++i) { + typelib_typedescription_release(aBaseTypes[i]); + }} + + for ( nPos = nMembers; nPos--; ) + { + typelib_typedescriptionreference_release( ppMemberRefs[nPos] ); + } + } + return pRet; +} +//================================================================================================== +inline static typelib_TypeDescription * createCTD( const Reference< XEnumTypeDescription > & xType ) +{ + typelib_TypeDescription * pRet = 0; + if (xType.is()) + { + OUString aTypeName( xType->getName() ); + Sequence< OUString > aNames( xType->getEnumNames() ); + OSL_ASSERT( sizeof(OUString) == sizeof(rtl_uString *) ); // !!! + Sequence< sal_Int32 > aValues( xType->getEnumValues() ); + + typelib_typedescription_newEnum( + &pRet, aTypeName.pData, xType->getDefaultEnumValue(), + aNames.getLength(), + (rtl_uString **)aNames.getConstArray(), + const_cast< sal_Int32 * >( aValues.getConstArray() ) ); + } + return pRet; +} +//================================================================================================== +inline static typelib_TypeDescription * createCTD( + Reference< container::XHierarchicalNameAccess > const & access, + const Reference< XIndirectTypeDescription > & xType ) +{ + typelib_TypeDescription * pRet = 0; + if (xType.is()) + { + typelib_TypeDescription * pRefType = createCTD( + access, xType->getReferencedType() ); + typelib_typedescription_register( &pRefType ); + + OUString aTypeName( xType->getName() ); + + typelib_typedescription_new( + &pRet, + (typelib_TypeClass)xType->getTypeClass(), + aTypeName.pData, + pRefType->pWeakRef, + 0, 0 ); + + // cleanup + if (pRefType) + typelib_typedescription_release( pRefType ); + } + return pRet; +} + +//================================================================================================== +static typelib_TypeDescription * createCTD( + Reference< container::XHierarchicalNameAccess > const & access, + const Reference< XTypeDescription > & xType ) +{ + typelib_TypeDescription * pRet = 0; + + if (xType.is()) + { + switch (xType->getTypeClass()) + { + // built in types + case TypeClass_VOID: + { + OUString aTypeName( RTL_CONSTASCII_USTRINGPARAM("void") ); + typelib_typedescription_new( &pRet, typelib_TypeClass_VOID, aTypeName.pData, 0, 0, 0 ); + break; + } + case TypeClass_CHAR: + { + OUString aTypeName( RTL_CONSTASCII_USTRINGPARAM("char") ); + typelib_typedescription_new( &pRet, typelib_TypeClass_CHAR, aTypeName.pData, 0, 0, 0 ); + break; + } + case TypeClass_BOOLEAN: + { + OUString aTypeName( RTL_CONSTASCII_USTRINGPARAM("boolean") ); + typelib_typedescription_new( &pRet, typelib_TypeClass_BOOLEAN, aTypeName.pData, 0, 0, 0 ); + break; + } + case TypeClass_BYTE: + { + OUString aTypeName( RTL_CONSTASCII_USTRINGPARAM("byte") ); + typelib_typedescription_new( &pRet, typelib_TypeClass_BYTE, aTypeName.pData, 0, 0, 0 ); + break; + } + case TypeClass_SHORT: + { + OUString aTypeName( RTL_CONSTASCII_USTRINGPARAM("short") ); + typelib_typedescription_new( &pRet, typelib_TypeClass_SHORT, aTypeName.pData, 0, 0, 0 ); + break; + } + case TypeClass_UNSIGNED_SHORT: + { + OUString aTypeName( RTL_CONSTASCII_USTRINGPARAM("unsigned short") ); + typelib_typedescription_new( &pRet, typelib_TypeClass_UNSIGNED_SHORT, aTypeName.pData, 0, 0, 0 ); + break; + } + case TypeClass_LONG: + { + OUString aTypeName( RTL_CONSTASCII_USTRINGPARAM("long") ); + typelib_typedescription_new( &pRet, typelib_TypeClass_LONG, aTypeName.pData, 0, 0, 0 ); + break; + } + case TypeClass_UNSIGNED_LONG: + { + OUString aTypeName( RTL_CONSTASCII_USTRINGPARAM("unsigned long") ); + typelib_typedescription_new( &pRet, typelib_TypeClass_UNSIGNED_LONG, aTypeName.pData, 0, 0, 0 ); + break; + } + case TypeClass_HYPER: + { + OUString aTypeName( RTL_CONSTASCII_USTRINGPARAM("hyper") ); + typelib_typedescription_new( &pRet, typelib_TypeClass_HYPER, aTypeName.pData, 0, 0, 0 ); + break; + } + case TypeClass_UNSIGNED_HYPER: + { + OUString aTypeName( RTL_CONSTASCII_USTRINGPARAM("unsigned hyper") ); + typelib_typedescription_new( &pRet, typelib_TypeClass_UNSIGNED_HYPER, aTypeName.pData, 0, 0, 0 ); + break; + } + case TypeClass_FLOAT: + { + OUString aTypeName( RTL_CONSTASCII_USTRINGPARAM("float") ); + typelib_typedescription_new( &pRet, typelib_TypeClass_FLOAT, aTypeName.pData, 0, 0, 0 ); + break; + } + case TypeClass_DOUBLE: + { + OUString aTypeName( RTL_CONSTASCII_USTRINGPARAM("double") ); + typelib_typedescription_new( &pRet, typelib_TypeClass_DOUBLE, aTypeName.pData, 0, 0, 0 ); + break; + } + case TypeClass_STRING: + { + OUString aTypeName( RTL_CONSTASCII_USTRINGPARAM("string") ); + typelib_typedescription_new( &pRet, typelib_TypeClass_STRING, aTypeName.pData, 0, 0, 0 ); + break; + } + case TypeClass_TYPE: + { + OUString aTypeName( RTL_CONSTASCII_USTRINGPARAM("type") ); + typelib_typedescription_new( &pRet, typelib_TypeClass_TYPE, aTypeName.pData, 0, 0, 0 ); + break; + } + case TypeClass_ANY: + { + OUString aTypeName( RTL_CONSTASCII_USTRINGPARAM("any") ); + typelib_typedescription_new( &pRet, typelib_TypeClass_ANY, aTypeName.pData, 0, 0, 0 ); + break; + } + + case TypeClass_UNION: + pRet = createCTD( Reference< XUnionTypeDescription >::query( xType ) ); + break; + case TypeClass_EXCEPTION: + pRet = createCTD( Reference< XCompoundTypeDescription >::query( xType ) ); + break; + case TypeClass_STRUCT: + pRet = createCTD( + access, Reference< XStructTypeDescription >::query( xType ) ); + break; + case TypeClass_ENUM: + pRet = createCTD( Reference< XEnumTypeDescription >::query( xType ) ); + break; + case TypeClass_TYPEDEF: + { + Reference< XIndirectTypeDescription > xTypedef( xType, UNO_QUERY ); + if (xTypedef.is()) + pRet = createCTD( access, xTypedef->getReferencedType() ); + break; + } + case TypeClass_SEQUENCE: + pRet = createCTD( + access, Reference< XIndirectTypeDescription >::query( xType ) ); + break; + case TypeClass_INTERFACE: + pRet = createCTD( + access, + Reference< XInterfaceTypeDescription2 >::query( xType ) ); + break; + case TypeClass_INTERFACE_METHOD: + pRet = createCTD( Reference< XInterfaceMethodTypeDescription >::query( xType ) ); + break; + case TypeClass_INTERFACE_ATTRIBUTE: + pRet = createCTD( Reference< XInterfaceAttributeTypeDescription >::query( xType ) ); + break; + default: + break; + } + } + + return pRet; +} + + +//================================================================================================== +extern "C" +{ +static void SAL_CALL typelib_callback( + void * pContext, typelib_TypeDescription ** ppRet, rtl_uString * pTypeName ) +{ + OSL_ENSURE( pContext && ppRet && pTypeName, "### null ptr!" ); + if (ppRet) + { + if (*ppRet) + { + ::typelib_typedescription_release( *ppRet ); + *ppRet = 0; + } + if (pContext && pTypeName) + { + Reference< container::XHierarchicalNameAccess > access( + reinterpret_cast< container::XHierarchicalNameAccess * >( + pContext)); + try + { + OUString const & rTypeName = OUString::unacquired( &pTypeName ); + Reference< XTypeDescription > xTD; + if (access->getByHierarchicalName(rTypeName ) >>= xTD) + { + *ppRet = createCTD( access, xTD ); + } + } + catch (container::NoSuchElementException & exc) + { + (void) exc; // avoid warning about unused variable + OSL_TRACE( + "typelibrary type not available: %s", + OUStringToOString( + exc.Message, RTL_TEXTENCODING_UTF8 ).getStr() ); + } + catch (Exception & exc) + { + (void) exc; // avoid warning about unused variable + OSL_TRACE( + "%s", + OUStringToOString( + exc.Message, RTL_TEXTENCODING_UTF8 ).getStr() ); + } + } + } +} +} + +//================================================================================================== +class EventListenerImpl + : public WeakImplHelper1< lang::XEventListener > +{ + Reference< container::XHierarchicalNameAccess > m_xTDMgr; + +public: + inline EventListenerImpl( + Reference< container::XHierarchicalNameAccess > const & xTDMgr ) + SAL_THROW( () ) + : m_xTDMgr( xTDMgr ) + {} + + // XEventListener + virtual void SAL_CALL disposing( lang::EventObject const & rEvt ) + throw (RuntimeException); +}; +//__________________________________________________________________________________________________ +void EventListenerImpl::disposing( lang::EventObject const & rEvt ) + throw (RuntimeException) +{ + if (rEvt.Source != m_xTDMgr) { + OSL_ASSERT(false); + } + // deregister of c typelib callback + ::typelib_typedescription_revokeCallback( m_xTDMgr.get(), typelib_callback ); +} + +//================================================================================================== +sal_Bool SAL_CALL installTypeDescriptionManager( + Reference< container::XHierarchicalNameAccess > const & xTDMgr_c ) + SAL_THROW( () ) +{ + uno::Environment curr_env(Environment::getCurrent()); + uno::Environment target_env(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(CPPU_STRINGIFY(CPPU_ENV)))); + + uno::Mapping curr2target(curr_env, target_env); + + + Reference<container::XHierarchicalNameAccess> xTDMgr( + reinterpret_cast<container::XHierarchicalNameAccess *>( + curr2target.mapInterface(xTDMgr_c.get(), ::getCppuType(&xTDMgr_c))), + SAL_NO_ACQUIRE); + + Reference< lang::XComponent > xComp( xTDMgr, UNO_QUERY ); + if (xComp.is()) + { + xComp->addEventListener( new EventListenerImpl( xTDMgr ) ); + // register c typelib callback + ::typelib_typedescription_registerCallback( xTDMgr.get(), typelib_callback ); + return sal_True; + } + return sal_False; +} + +} // end namespace cppu + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/source/typeprovider.cxx b/cppuhelper/source/typeprovider.cxx new file mode 100644 index 000000000000..9707d7310dbe --- /dev/null +++ b/cppuhelper/source/typeprovider.cxx @@ -0,0 +1,328 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_cppuhelper.hxx" + +#include <cppuhelper/typeprovider.hxx> +#include <osl/mutex.hxx> + +using namespace osl; +using namespace com::sun::star::uno; + +namespace cppu +{ + +//__________________________________________________________________________________________________ +OImplementationId::~OImplementationId() SAL_THROW( () ) +{ + delete _pSeq; +} +//__________________________________________________________________________________________________ +Sequence< sal_Int8 > OImplementationId::getImplementationId() const SAL_THROW( () ) +{ + if (! _pSeq) + { + MutexGuard aGuard( Mutex::getGlobalMutex() ); + if (! _pSeq) + { + Sequence< sal_Int8 > * pSeq = new Sequence< sal_Int8 >( 16 ); + ::rtl_createUuid( (sal_uInt8 *)pSeq->getArray(), 0, _bUseEthernetAddress ); + _pSeq = pSeq; + } + } + return *_pSeq; +} + +//-------------------------------------------------------------------------------------------------- +static inline void copy( Sequence< Type > & rDest, const Sequence< Type > & rSource, sal_Int32 nOffset ) + SAL_THROW( () ) +{ + Type * pDest = rDest.getArray(); + const Type * pSource = rSource.getConstArray(); + + for ( sal_Int32 nPos = rSource.getLength(); nPos--; ) + pDest[nOffset+ nPos] = pSource[nPos]; +} + +//__________________________________________________________________________________________________ +OTypeCollection::OTypeCollection( + const Type & rType1, + const Sequence< Type > & rAddTypes ) + SAL_THROW( () ) + : _aTypes( 1 + rAddTypes.getLength() ) +{ + _aTypes[0] = rType1; + copy( _aTypes, rAddTypes, 1 ); +} +//__________________________________________________________________________________________________ +OTypeCollection::OTypeCollection( + const Type & rType1, + const Type & rType2, + const Sequence< Type > & rAddTypes ) + SAL_THROW( () ) + : _aTypes( 2 + rAddTypes.getLength() ) +{ + _aTypes[0] = rType1; + _aTypes[1] = rType2; + copy( _aTypes, rAddTypes, 2 ); +} +//__________________________________________________________________________________________________ +OTypeCollection::OTypeCollection( + const Type & rType1, + const Type & rType2, + const Type & rType3, + const Sequence< Type > & rAddTypes ) + SAL_THROW( () ) + : _aTypes( 3 + rAddTypes.getLength() ) +{ + _aTypes[0] = rType1; + _aTypes[1] = rType2; + _aTypes[2] = rType3; + copy( _aTypes, rAddTypes, 3 ); +} +//__________________________________________________________________________________________________ +OTypeCollection::OTypeCollection( + const Type & rType1, + const Type & rType2, + const Type & rType3, + const Type & rType4, + const Sequence< Type > & rAddTypes ) + SAL_THROW( () ) + : _aTypes( 4 + rAddTypes.getLength() ) +{ + _aTypes[0] = rType1; + _aTypes[1] = rType2; + _aTypes[2] = rType3; + _aTypes[3] = rType4; + copy( _aTypes, rAddTypes, 4 ); +} +//__________________________________________________________________________________________________ +OTypeCollection::OTypeCollection( + const Type & rType1, + const Type & rType2, + const Type & rType3, + const Type & rType4, + const Type & rType5, + const Sequence< Type > & rAddTypes ) + SAL_THROW( () ) + : _aTypes( 5 + rAddTypes.getLength() ) +{ + _aTypes[0] = rType1; + _aTypes[1] = rType2; + _aTypes[2] = rType3; + _aTypes[3] = rType4; + _aTypes[4] = rType5; + copy( _aTypes, rAddTypes, 5 ); +} +//__________________________________________________________________________________________________ +OTypeCollection::OTypeCollection( + const Type & rType1, + const Type & rType2, + const Type & rType3, + const Type & rType4, + const Type & rType5, + const Type & rType6, + const Sequence< Type > & rAddTypes ) + SAL_THROW( () ) + : _aTypes( 6 + rAddTypes.getLength() ) +{ + _aTypes[0] = rType1; + _aTypes[1] = rType2; + _aTypes[2] = rType3; + _aTypes[3] = rType4; + _aTypes[4] = rType5; + _aTypes[5] = rType6; + copy( _aTypes, rAddTypes, 6 ); +} +//__________________________________________________________________________________________________ +OTypeCollection::OTypeCollection( + const Type & rType1, + const Type & rType2, + const Type & rType3, + const Type & rType4, + const Type & rType5, + const Type & rType6, + const Type & rType7, + const Sequence< Type > & rAddTypes ) + SAL_THROW( () ) + : _aTypes( 7 + rAddTypes.getLength() ) +{ + _aTypes[0] = rType1; + _aTypes[1] = rType2; + _aTypes[2] = rType3; + _aTypes[3] = rType4; + _aTypes[4] = rType5; + _aTypes[5] = rType6; + _aTypes[6] = rType7; + copy( _aTypes, rAddTypes, 7 ); +} +//__________________________________________________________________________________________________ +OTypeCollection::OTypeCollection( + const Type & rType1, + const Type & rType2, + const Type & rType3, + const Type & rType4, + const Type & rType5, + const Type & rType6, + const Type & rType7, + const Type & rType8, + const Sequence< Type > & rAddTypes ) + SAL_THROW( () ) + : _aTypes( 8 + rAddTypes.getLength() ) +{ + _aTypes[0] = rType1; + _aTypes[1] = rType2; + _aTypes[2] = rType3; + _aTypes[3] = rType4; + _aTypes[4] = rType5; + _aTypes[5] = rType6; + _aTypes[6] = rType7; + _aTypes[7] = rType8; + copy( _aTypes, rAddTypes, 8 ); +} +//__________________________________________________________________________________________________ +OTypeCollection::OTypeCollection( + const Type & rType1, + const Type & rType2, + const Type & rType3, + const Type & rType4, + const Type & rType5, + const Type & rType6, + const Type & rType7, + const Type & rType8, + const Type & rType9, + const Sequence< Type > & rAddTypes ) + SAL_THROW( () ) + : _aTypes( 9 + rAddTypes.getLength() ) +{ + _aTypes[0] = rType1; + _aTypes[1] = rType2; + _aTypes[2] = rType3; + _aTypes[3] = rType4; + _aTypes[4] = rType5; + _aTypes[5] = rType6; + _aTypes[6] = rType7; + _aTypes[7] = rType8; + _aTypes[8] = rType9; + copy( _aTypes, rAddTypes, 9 ); +} +//__________________________________________________________________________________________________ +OTypeCollection::OTypeCollection( + const Type & rType1, + const Type & rType2, + const Type & rType3, + const Type & rType4, + const Type & rType5, + const Type & rType6, + const Type & rType7, + const Type & rType8, + const Type & rType9, + const Type & rType10, + const Sequence< Type > & rAddTypes ) + SAL_THROW( () ) + : _aTypes( 10 + rAddTypes.getLength() ) +{ + _aTypes[0] = rType1; + _aTypes[1] = rType2; + _aTypes[2] = rType3; + _aTypes[3] = rType4; + _aTypes[4] = rType5; + _aTypes[5] = rType6; + _aTypes[6] = rType7; + _aTypes[7] = rType8; + _aTypes[8] = rType9; + _aTypes[9] = rType10; + copy( _aTypes, rAddTypes, 10 ); +} +//__________________________________________________________________________________________________ +OTypeCollection::OTypeCollection( + const Type & rType1, + const Type & rType2, + const Type & rType3, + const Type & rType4, + const Type & rType5, + const Type & rType6, + const Type & rType7, + const Type & rType8, + const Type & rType9, + const Type & rType10, + const Type & rType11, + const Sequence< Type > & rAddTypes ) + SAL_THROW( () ) + : _aTypes( 11 + rAddTypes.getLength() ) +{ + _aTypes[0] = rType1; + _aTypes[1] = rType2; + _aTypes[2] = rType3; + _aTypes[3] = rType4; + _aTypes[4] = rType5; + _aTypes[5] = rType6; + _aTypes[6] = rType7; + _aTypes[7] = rType8; + _aTypes[8] = rType9; + _aTypes[9] = rType10; + _aTypes[10] = rType11; + copy( _aTypes, rAddTypes, 11 ); +} +//__________________________________________________________________________________________________ +OTypeCollection::OTypeCollection( + const Type & rType1, + const Type & rType2, + const Type & rType3, + const Type & rType4, + const Type & rType5, + const Type & rType6, + const Type & rType7, + const Type & rType8, + const Type & rType9, + const Type & rType10, + const Type & rType11, + const Type & rType12, + const Sequence< Type > & rAddTypes ) + SAL_THROW( () ) + : _aTypes( 12 + rAddTypes.getLength() ) +{ + _aTypes[0] = rType1; + _aTypes[1] = rType2; + _aTypes[2] = rType3; + _aTypes[3] = rType4; + _aTypes[4] = rType5; + _aTypes[5] = rType6; + _aTypes[6] = rType7; + _aTypes[7] = rType8; + _aTypes[8] = rType9; + _aTypes[9] = rType10; + _aTypes[10] = rType11; + _aTypes[11] = rType12; + copy( _aTypes, rAddTypes, 12 ); +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/source/unorc b/cppuhelper/source/unorc new file mode 100644 index 000000000000..c5af031bd4cd --- /dev/null +++ b/cppuhelper/source/unorc @@ -0,0 +1,30 @@ +=************************************************************************* += += DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. += += Copyright 2000, 2010 Oracle and/or its affiliates. += += OpenOffice.org - a multi-platform office productivity suite += += This file is part of OpenOffice.org. += += OpenOffice.org is free software: you can redistribute it and/or modify += it under the terms of the GNU Lesser General Public License version 3 += only, as published by the Free Software Foundation. += += OpenOffice.org is distributed in the hope that it will be useful, += but WITHOUT ANY WARRANTY; without even the implied warranty of += MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the += GNU Lesser General Public License version 3 for more details += (a copy is included in the LICENSE file that accompanied this code). += += You should have received a copy of the GNU Lesser General Public License += version 3 along with OpenOffice.org. If not, see += <http://www.openoffice.org/license.html> += for a copy of the LGPLv3 License. += += +=************************************************************************* + +[Bootstrap] +URE_INTERNAL_LIB_DIR=${ORIGIN} diff --git a/cppuhelper/source/unourl.cxx b/cppuhelper/source/unourl.cxx new file mode 100644 index 000000000000..724ea00ad4dc --- /dev/null +++ b/cppuhelper/source/unourl.cxx @@ -0,0 +1,301 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_cppuhelper.hxx" + +#include "cppuhelper/unourl.hxx" + +#include "osl/diagnose.h" +#include "rtl/malformeduriexception.hxx" +#include "rtl/string.h" +#include "rtl/textenc.h" +#include "rtl/uri.h" +#include "rtl/uri.hxx" +#include "rtl/ustring.h" +#include "rtl/ustring.hxx" +#include "sal/types.h" + +#include <map> + +using cppu::UnoUrl; +using cppu::UnoUrlDescriptor; + +namespace { + +inline bool isAlphanum(sal_Unicode c) +{ + return (c >= 0x30 && c <= 0x39) // '0'--'9' + || (c >= 0x41 && c <= 0x5A) // 'A'--'Z' + || (c >= 0x61 && c <= 0x7A); // 'a'--'z' +} + +} + +class UnoUrlDescriptor::Impl +{ +public: + typedef std::map< rtl::OUString, rtl::OUString > Parameters; + + rtl::OUString m_aDescriptor; + rtl::OUString m_aName; + Parameters m_aParameters; + + /** @exception rtl::MalformedUriException + */ + explicit inline Impl(rtl::OUString const & m_aDescriptor); + + inline Impl * clone() const { return new Impl(*this); } +}; + +inline UnoUrlDescriptor::Impl::Impl(rtl::OUString const & rDescriptor) +{ + m_aDescriptor = rDescriptor; + enum State { STATE_NAME0, STATE_NAME, STATE_KEY0, STATE_KEY, STATE_VALUE }; + State eState = STATE_NAME0; + sal_Int32 nStart = 0; + rtl::OUString aKey; + for (sal_Int32 i = 0;; ++i) + { + bool bEnd = i == rDescriptor.getLength(); + sal_Unicode c = bEnd ? 0 : rDescriptor.getStr()[i]; + switch (eState) + { + case STATE_NAME0: + if (bEnd || !isAlphanum(c)) + throw rtl::MalformedUriException( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( + "UNO URL contains bad descriptor name"))); + nStart = i; + eState = STATE_NAME; + break; + + case STATE_NAME: + if (bEnd || c == 0x2C) // ',' + { + m_aName + = rDescriptor.copy(nStart, i - nStart).toAsciiLowerCase(); + eState = STATE_KEY0; + } + else if (!isAlphanum(c)) + throw rtl::MalformedUriException( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( + "UNO URL contains bad descriptor name"))); + break; + + case STATE_KEY0: + if (bEnd || !isAlphanum(c)) + throw rtl::MalformedUriException( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( + "UNO URL contains bad parameter key"))); + nStart = i; + eState = STATE_KEY; + break; + + case STATE_KEY: + if (c == 0x3D) // '=' + { + aKey = rDescriptor.copy(nStart, i - nStart).toAsciiLowerCase(); + nStart = i + 1; + eState = STATE_VALUE; + } + else if (bEnd || !isAlphanum(c)) + throw rtl::MalformedUriException( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( + "UNO URL contains bad parameter key"))); + break; + + case STATE_VALUE: + if (bEnd || c == 0x2C) // ',' + { + if (!m_aParameters.insert( + Parameters::value_type( + aKey, + rtl::Uri::decode(rDescriptor.copy(nStart, + i - nStart), + rtl_UriDecodeWithCharset, + RTL_TEXTENCODING_UTF8))).second) + throw rtl::MalformedUriException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "UNO URL contains duplicated parameter"))); + eState = STATE_KEY0; + } + break; + } + if (bEnd) + break; + } +} + +UnoUrlDescriptor::UnoUrlDescriptor(rtl::OUString const & rDescriptor): + m_xImpl(new Impl(rDescriptor)) +{} + +UnoUrlDescriptor::UnoUrlDescriptor(std::auto_ptr< Impl > & rImpl): + m_xImpl(rImpl) +{} + +UnoUrlDescriptor::UnoUrlDescriptor(UnoUrlDescriptor const & rOther): + m_xImpl(rOther.m_xImpl->clone()) +{} + +UnoUrlDescriptor::~UnoUrlDescriptor() +{} + +UnoUrlDescriptor & UnoUrlDescriptor::operator =(UnoUrlDescriptor const & rOther) +{ + m_xImpl.reset(rOther.m_xImpl->clone()); + return *this; +} + +rtl::OUString const & UnoUrlDescriptor::getDescriptor() const +{ + return m_xImpl->m_aDescriptor; +} + +rtl::OUString const & UnoUrlDescriptor::getName() const +{ + return m_xImpl->m_aName; +} + +bool UnoUrlDescriptor::hasParameter(rtl::OUString const & rKey) const +{ + return m_xImpl->m_aParameters.find(rKey.toAsciiLowerCase()) + != m_xImpl->m_aParameters.end(); +} + +rtl::OUString UnoUrlDescriptor::getParameter(rtl::OUString const & rKey) const +{ + Impl::Parameters::const_iterator + aIt(m_xImpl->m_aParameters.find(rKey.toAsciiLowerCase())); + return aIt == m_xImpl->m_aParameters.end() ? rtl::OUString() : aIt->second; +} + +class UnoUrl::Impl +{ +public: + UnoUrlDescriptor m_aConnection; + UnoUrlDescriptor m_aProtocol; + rtl::OUString m_aObjectName; + + inline Impl * clone() const { return new Impl(*this); } + + /** @exception rtl::MalformedUriException + */ + static inline Impl * create(rtl::OUString const & rUrl); + +private: + inline Impl(std::auto_ptr< UnoUrlDescriptor::Impl > & rConnection, + std::auto_ptr< UnoUrlDescriptor::Impl > & rProtocol, + rtl::OUString const & rObjectName); +}; + +inline UnoUrl::Impl::Impl(std::auto_ptr< UnoUrlDescriptor::Impl > & rConnection, + std::auto_ptr< UnoUrlDescriptor::Impl > & rProtocol, + rtl::OUString const & rObjectName): + m_aConnection(rConnection), + m_aProtocol(rProtocol), + m_aObjectName(rObjectName) +{} + +inline UnoUrl::Impl * UnoUrl::Impl::create(rtl::OUString const & rUrl) +{ + if (!rUrl.matchIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("uno:"), 0)) + throw rtl::MalformedUriException( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( + "UNO URL does not start with \"uno:\""))); + sal_Int32 i = RTL_CONSTASCII_LENGTH("uno:"); + sal_Int32 j = rUrl.indexOf(';', i); + if (j < 0) + throw rtl::MalformedUriException( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( + "UNO URL has too few semicolons"))); + std::auto_ptr< UnoUrlDescriptor::Impl > + xConnection(new UnoUrlDescriptor::Impl(rUrl.copy(i, j - i))); + i = j + 1; + j = rUrl.indexOf(0x3B, i); // ';' + if (j < 0) + throw rtl::MalformedUriException( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( + "UNO URL has too few semicolons"))); + std::auto_ptr< UnoUrlDescriptor::Impl > + xProtocol(new UnoUrlDescriptor::Impl(rUrl.copy(i, j - i))); + i = j + 1; + if (i == rUrl.getLength()) + throw rtl::MalformedUriException( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( + "UNO URL contains empty ObjectName"))); + for (j = i; j < rUrl.getLength(); ++j) + { + sal_Unicode c = rUrl.getStr()[j]; + if (!isAlphanum(c) && c != 0x21 && c != 0x24 // '!', '$' + && c != 0x26 && c != 0x27 && c != 0x28 // '&', ''', '(' + && c != 0x28 && c != 0x2A && c != 0x2B // ')', '*', '+' + && c != 0x2C && c != 0x2D && c != 0x2E // ',', '-', '.' + && c != 0x2F && c != 0x3A && c != 0x3D // '/', ':', '=' + && c != 0x3F && c != 0x40 && c != 0x5F // '?', '@', '_' + && c != 0x7E) // '~' + throw rtl::MalformedUriException( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( + "UNO URL contains invalid ObjectName"))); + } + return new Impl(xConnection, xProtocol, rUrl.copy(i)); +} + +UnoUrl::UnoUrl(rtl::OUString const & rUrl): m_xImpl(Impl::create(rUrl)) +{} + +UnoUrl::UnoUrl(UnoUrl const & rOther): m_xImpl(rOther.m_xImpl->clone()) +{} + +UnoUrl::~UnoUrl() +{} + +UnoUrl & UnoUrl::operator =(UnoUrl const & rOther) +{ + m_xImpl.reset(rOther.m_xImpl->clone()); + return *this; +} + +UnoUrlDescriptor const & UnoUrl::getConnection() const +{ + return m_xImpl->m_aConnection; +} + +UnoUrlDescriptor const & UnoUrl::getProtocol() const +{ + return m_xImpl->m_aProtocol; +} + +rtl::OUString const & UnoUrl::getObjectName() const +{ + return m_xImpl->m_aObjectName; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/source/weak.cxx b/cppuhelper/source/weak.cxx new file mode 100644 index 000000000000..0224390b9436 --- /dev/null +++ b/cppuhelper/source/weak.cxx @@ -0,0 +1,541 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_cppuhelper.hxx" +#include <osl/mutex.hxx> +#include <cppuhelper/weakagg.hxx> +#include <cppuhelper/interfacecontainer.hxx> +#include "cppuhelper/exc_hlp.hxx" + +using namespace osl; +using namespace com::sun::star::uno; + +/** */ //for docpp +namespace cppu +{ + +// due to static Reflection destruction from usr, ther must be a mutex leak (#73272#) +inline static Mutex & getWeakMutex() SAL_THROW( () ) +{ + static Mutex * s_pMutex = 0; + if (! s_pMutex) + s_pMutex = new Mutex(); + return *s_pMutex; +} + +//------------------------------------------------------------------------ +//-- OWeakConnectionPoint ---------------------------------------------------- +//------------------------------------------------------------------------ +class OWeakConnectionPoint : public XAdapter +{ +public: + /** + Hold the weak object without an acquire (only the pointer). + */ + OWeakConnectionPoint( OWeakObject* pObj ) SAL_THROW( () ) + : m_aRefCount( 0 ) + , m_pObject(pObj) + , m_aReferences( getWeakMutex() ) + {} + + // XInterface + Any SAL_CALL queryInterface( const Type & rType ) throw(::com::sun::star::uno::RuntimeException); + void SAL_CALL acquire() throw(); + void SAL_CALL release() throw(); + + // XAdapter + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL queryAdapted() throw(::com::sun::star::uno::RuntimeException); + void SAL_CALL addReference( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XReference >& xRef ) throw(::com::sun::star::uno::RuntimeException); + void SAL_CALL removeReference( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XReference >& xRef ) throw(::com::sun::star::uno::RuntimeException); + + /// Called from the weak object if the reference count goes to zero. + void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException); + +private: + OWeakConnectionPoint(OWeakConnectionPoint &); // not defined + void operator =(OWeakConnectionPoint &); // not defined + + virtual ~OWeakConnectionPoint() {} + + /// The reference counter. + oslInterlockedCount m_aRefCount; + /// The weak object + OWeakObject* m_pObject; + /// The container to hold the weak references + OInterfaceContainerHelper m_aReferences; +}; + +// XInterface +Any SAL_CALL OWeakConnectionPoint::queryInterface( const Type & rType ) + throw(com::sun::star::uno::RuntimeException) +{ + return ::cppu::queryInterface( + rType, static_cast< XAdapter * >( this ), static_cast< XInterface * >( this ) ); +} + +// XInterface +void SAL_CALL OWeakConnectionPoint::acquire() throw() +{ + osl_incrementInterlockedCount( &m_aRefCount ); +} + +// XInterface +void SAL_CALL OWeakConnectionPoint::release() throw() +{ + if (! osl_decrementInterlockedCount( &m_aRefCount )) + delete this; +} + +void SAL_CALL OWeakConnectionPoint::dispose() throw(::com::sun::star::uno::RuntimeException) +{ + Any ex; + OInterfaceIteratorHelper aIt( m_aReferences ); + while( aIt.hasMoreElements() ) + { + try + { + ((XReference *)aIt.next())->dispose(); + } + catch (com::sun::star::lang::DisposedException &) {} + catch (RuntimeException &) + { + ex = cppu::getCaughtException(); + } + } + if (ex.hasValue()) + { + cppu::throwException(ex); + } +} + +// XInterface +Reference< XInterface > SAL_CALL OWeakConnectionPoint::queryAdapted() throw(::com::sun::star::uno::RuntimeException) +{ + Reference< XInterface > ret; + + ClearableMutexGuard guard(getWeakMutex()); + + if (m_pObject) + { + oslInterlockedCount n = osl_incrementInterlockedCount( &m_pObject->m_refCount ); + + if (n > 1) + { + // The refence is incremented. The object cannot be destroyed. + // Release the guard at the earliest point. + guard.clear(); + // WeakObject has a (XInterface *) cast operator + ret = *m_pObject; + n = osl_decrementInterlockedCount( &m_pObject->m_refCount ); + } + else + // Another thread wait in the dispose method at the guard + n = osl_decrementInterlockedCount( &m_pObject->m_refCount ); + } + + return ret; +} + +// XInterface +void SAL_CALL OWeakConnectionPoint::addReference(const Reference< XReference >& rRef) + throw(::com::sun::star::uno::RuntimeException) +{ + m_aReferences.addInterface( (const Reference< XInterface > &)rRef ); +} + +// XInterface +void SAL_CALL OWeakConnectionPoint::removeReference(const Reference< XReference >& rRef) + throw(::com::sun::star::uno::RuntimeException) +{ + m_aReferences.removeInterface( (const Reference< XInterface > &)rRef ); +} + + +//------------------------------------------------------------------------ +//-- OWeakObject ------------------------------------------------------- +//------------------------------------------------------------------------ + +#ifdef _MSC_VER +// Accidentally occurs in msvc mapfile = > had to be outlined. +OWeakObject::OWeakObject() SAL_THROW( () ) + : m_refCount( 0 ), + m_pWeakConnectionPoint( 0 ) +{ +} +#endif + +// XInterface +Any SAL_CALL OWeakObject::queryInterface( const Type & rType ) throw(::com::sun::star::uno::RuntimeException) +{ + return ::cppu::queryInterface( + rType, + static_cast< XWeak * >( this ), static_cast< XInterface * >( this ) ); +} + +// XInterface +void SAL_CALL OWeakObject::acquire() throw() +{ + osl_incrementInterlockedCount( &m_refCount ); +} + +// XInterface +void SAL_CALL OWeakObject::release() throw() +{ + if (osl_decrementInterlockedCount( &m_refCount ) == 0) { + // notify/clear all weak-refs before object's dtor is executed + // (which may check weak-refs to this object): + disposeWeakConnectionPoint(); + // destroy object: + delete this; + } +} + +void OWeakObject::disposeWeakConnectionPoint() +{ + OSL_PRECOND( m_refCount == 0, "OWeakObject::disposeWeakConnectionPoint: only to be called with a ref count of 0!" ); + if (m_pWeakConnectionPoint != 0) { + OWeakConnectionPoint * const p = m_pWeakConnectionPoint; + m_pWeakConnectionPoint = 0; + try { + p->dispose(); + } + catch (RuntimeException const& exc) { + OSL_ENSURE( + false, OUStringToOString( + exc.Message, RTL_TEXTENCODING_ASCII_US ).getStr() ); + static_cast<void>(exc); + } + p->release(); + } +} + +OWeakObject::~OWeakObject() SAL_THROW( (RuntimeException) ) +{ +} + +// XWeak +Reference< XAdapter > SAL_CALL OWeakObject::queryAdapter() + throw (::com::sun::star::uno::RuntimeException) +{ + if (!m_pWeakConnectionPoint) + { + // only acquire mutex if member is not created + MutexGuard aGuard( getWeakMutex() ); + if( !m_pWeakConnectionPoint ) + { + OWeakConnectionPoint * p = new OWeakConnectionPoint(this); + p->acquire(); + m_pWeakConnectionPoint = p; + } + } + + return m_pWeakConnectionPoint; +} + +//------------------------------------------------------------------------ +//-- OWeakAggObject ---------------------------------------------------- +//------------------------------------------------------------------------ +OWeakAggObject::~OWeakAggObject() SAL_THROW( (RuntimeException) ) +{ +} + +// XInterface +void OWeakAggObject::acquire() throw() +{ + Reference<XInterface > x( xDelegator ); + if (x.is()) + x->acquire(); + else + OWeakObject::acquire(); +} + +// XInterface +void OWeakAggObject::release() throw() +{ + Reference<XInterface > x( xDelegator ); + if (x.is()) + x->release(); + else + OWeakObject::release(); +} + +// XInterface +Any OWeakAggObject::queryInterface( const Type & rType ) throw(::com::sun::star::uno::RuntimeException) +{ + Reference< XInterface > x( xDelegator ); // harden ref + return (x.is() ? x->queryInterface( rType ) : queryAggregation( rType )); +} + +// XAggregation +Any OWeakAggObject::queryAggregation( const Type & rType ) throw(::com::sun::star::uno::RuntimeException) +{ + return ::cppu::queryInterface( + rType, + static_cast< XInterface * >( static_cast< OWeakObject * >( this ) ), + static_cast< XAggregation * >( this ), + static_cast< XWeak * >( this ) ); +} + +// XAggregation +void OWeakAggObject::setDelegator( const Reference<XInterface > & rDelegator ) throw(::com::sun::star::uno::RuntimeException) +{ + xDelegator = rDelegator; +} + +} + +/** */ //for docpp +namespace com +{ +/** */ //for docpp +namespace sun +{ +/** */ //for docpp +namespace star +{ +/** */ //for docpp +namespace uno +{ + + +//------------------------------------------------------------------------ +//-- OWeakRefListener ----------------------------------------------------- +//------------------------------------------------------------------------ +class OWeakRefListener : public XReference +{ +public: + OWeakRefListener(const OWeakRefListener& rRef) SAL_THROW( () ); + OWeakRefListener(const Reference< XInterface >& xInt) SAL_THROW( () ); + virtual ~OWeakRefListener() SAL_THROW( () ); + + // XInterface + Any SAL_CALL queryInterface( const Type & rType ) throw(RuntimeException); + void SAL_CALL acquire() throw(); + void SAL_CALL release() throw(); + + // XReference + void SAL_CALL dispose() throw(::com::sun::star::uno::RuntimeException); + + /// The reference counter. + oslInterlockedCount m_aRefCount; + /// The connection point of the weak object + Reference< XAdapter > m_XWeakConnectionPoint; + +private: + OWeakRefListener& SAL_CALL operator=(const OWeakRefListener& rRef) SAL_THROW( () ); +}; + +OWeakRefListener::OWeakRefListener(const OWeakRefListener& rRef) SAL_THROW( () ) + : com::sun::star::uno::XReference() + , m_aRefCount( 1 ) +{ + try + { + m_XWeakConnectionPoint = rRef.m_XWeakConnectionPoint; + + if (m_XWeakConnectionPoint.is()) + { + m_XWeakConnectionPoint->addReference((XReference*)this); + } + } + catch (RuntimeException &) { OSL_ASSERT( 0 ); } // assert here, but no unexpected() + osl_decrementInterlockedCount( &m_aRefCount ); +} + +OWeakRefListener::OWeakRefListener(const Reference< XInterface >& xInt) SAL_THROW( () ) + : m_aRefCount( 1 ) +{ + try + { + Reference< XWeak > xWeak( Reference< XWeak >::query( xInt ) ); + + if (xWeak.is()) + { + m_XWeakConnectionPoint = xWeak->queryAdapter(); + + if (m_XWeakConnectionPoint.is()) + { + m_XWeakConnectionPoint->addReference((XReference*)this); + } + } + } + catch (RuntimeException &) { OSL_ASSERT( 0 ); } // assert here, but no unexpected() + osl_decrementInterlockedCount( &m_aRefCount ); +} + +OWeakRefListener::~OWeakRefListener() SAL_THROW( () ) +{ + try + { + if (m_XWeakConnectionPoint.is()) + { + acquire(); // dont die again + m_XWeakConnectionPoint->removeReference((XReference*)this); + } + } + catch (RuntimeException &) { OSL_ASSERT( 0 ); } // assert here, but no unexpected() +} + +// XInterface +Any SAL_CALL OWeakRefListener::queryInterface( const Type & rType ) throw(RuntimeException) +{ + return ::cppu::queryInterface( + rType, static_cast< XReference * >( this ), static_cast< XInterface * >( this ) ); +} + +// XInterface +void SAL_CALL OWeakRefListener::acquire() throw() +{ + osl_incrementInterlockedCount( &m_aRefCount ); +} + +// XInterface +void SAL_CALL OWeakRefListener::release() throw() +{ + if( ! osl_decrementInterlockedCount( &m_aRefCount ) ) + delete this; +} + +void SAL_CALL OWeakRefListener::dispose() + throw(::com::sun::star::uno::RuntimeException) +{ + Reference< XAdapter > xAdp; + { + MutexGuard guard(cppu::getWeakMutex()); + if( m_XWeakConnectionPoint.is() ) + { + xAdp = m_XWeakConnectionPoint; + m_XWeakConnectionPoint.clear(); + } + } + + if( xAdp.is() ) + xAdp->removeReference((XReference*)this); +} + +//------------------------------------------------------------------------ +//-- WeakReferenceHelper ---------------------------------------------------------- +//------------------------------------------------------------------------ +WeakReferenceHelper::WeakReferenceHelper(const Reference< XInterface >& xInt) SAL_THROW( () ) + : m_pImpl( 0 ) +{ + if (xInt.is()) + { + m_pImpl = new OWeakRefListener(xInt); + m_pImpl->acquire(); + } +} + +WeakReferenceHelper::WeakReferenceHelper(const WeakReferenceHelper& rWeakRef) SAL_THROW( () ) + : m_pImpl( 0 ) +{ + Reference< XInterface > xInt( rWeakRef.get() ); + if (xInt.is()) + { + m_pImpl = new OWeakRefListener(xInt); + m_pImpl->acquire(); + } +} + +void WeakReferenceHelper::clear() SAL_THROW( () ) +{ + try + { + if (m_pImpl) + { + if (m_pImpl->m_XWeakConnectionPoint.is()) + { + m_pImpl->m_XWeakConnectionPoint->removeReference( + (XReference*)m_pImpl); + m_pImpl->m_XWeakConnectionPoint.clear(); + } + m_pImpl->release(); + m_pImpl = 0; + } + } + catch (RuntimeException &) { OSL_ASSERT( 0 ); } // assert here, but no unexpected() +} + +WeakReferenceHelper& WeakReferenceHelper::operator=(const WeakReferenceHelper& rWeakRef) SAL_THROW( () ) +{ + if (this == &rWeakRef) + { + return *this; + } + Reference< XInterface > xInt( rWeakRef.get() ); + return operator = ( xInt ); +} + +WeakReferenceHelper & SAL_CALL +WeakReferenceHelper::operator= (const Reference< XInterface > & xInt) +SAL_THROW( () ) +{ + try + { + clear(); + if (xInt.is()) + { + m_pImpl = new OWeakRefListener(xInt); + m_pImpl->acquire(); + } + } + catch (RuntimeException &) { OSL_ASSERT( 0 ); } // assert here, but no unexpected() + return *this; +} + +WeakReferenceHelper::~WeakReferenceHelper() SAL_THROW( () ) +{ + clear(); +} + +Reference< XInterface > WeakReferenceHelper::get() const SAL_THROW( () ) +{ + try + { + Reference< XAdapter > xAdp; + { + MutexGuard guard(cppu::getWeakMutex()); + if( m_pImpl && m_pImpl->m_XWeakConnectionPoint.is() ) + xAdp = m_pImpl->m_XWeakConnectionPoint; + } + + if (xAdp.is()) + return xAdp->queryAdapted(); + } + catch (RuntimeException &) { OSL_ASSERT( 0 ); } // assert here, but no unexpected() + + return Reference< XInterface >(); +} + +} +} +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/test/bootstrap/TestEnv.cxx b/cppuhelper/test/bootstrap/TestEnv.cxx new file mode 100644 index 000000000000..90e4bb65b9e6 --- /dev/null +++ b/cppuhelper/test/bootstrap/TestEnv.cxx @@ -0,0 +1,130 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_cppuhelper.hxx" + +#include "cppu/EnvDcp.hxx" + +#include "cppu/helper/purpenv/Environment.hxx" +#include "cppu/helper/purpenv/Mapping.hxx" + + + +#define LOG_LIFECYCLE_TestEnv +#ifdef LOG_LIFECYCLE_TestEnv +# include <iostream> +# define LOG_LIFECYCLE_TestEnv_emit(x) x + +#else +# define LOG_LIFECYCLE_TestEnv_emit(x) + +#endif + + +class SAL_DLLPRIVATE TestEnv : public cppu::Enterable +{ + int m_inCount; + + virtual ~TestEnv(); + +public: + explicit TestEnv(); + +protected: + virtual void v_enter(void); + virtual void v_leave(void); + + virtual void v_callInto_v(uno_EnvCallee * pCallee, va_list * pParam); + virtual void v_callOut_v (uno_EnvCallee * pCallee, va_list * pParam); + + virtual int v_isValid (rtl::OUString * pReason); +}; + +TestEnv::TestEnv() + : m_inCount(0) +{ + LOG_LIFECYCLE_TestEnv_emit(fprintf(stderr, "LIFE: %s -> %p\n", "TestEnv::TestEnv(...)", this)); +} + +TestEnv::~TestEnv(void) +{ + LOG_LIFECYCLE_TestEnv_emit(fprintf(stderr, "LIFE: %s -> %p\n", "TestEnv::~TestEnv(void)", this)); +} + + +void TestEnv::v_callInto_v(uno_EnvCallee * pCallee, va_list * pParam) +{ + ++ m_inCount; + pCallee(pParam); + -- m_inCount; +} + +void TestEnv::v_callOut_v(uno_EnvCallee * pCallee, va_list * pParam) +{ + -- m_inCount; + pCallee(pParam); + ++ m_inCount; +} + +void TestEnv::v_enter(void) +{ + ++ m_inCount; +} + +void TestEnv::v_leave(void) +{ + -- m_inCount; +} + +int TestEnv::v_isValid(rtl::OUString * pReason) +{ + int result = m_inCount & 1; + + if (result) + *pReason = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("OK")); + + else + *pReason = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("not entered/invoked")); + + return result; +} + +extern "C" void SAL_CALL uno_initEnvironment(uno_Environment * pEnv) SAL_THROW_EXTERN_C() +{ + cppu::helper::purpenv::Environment_initWithEnterable(pEnv, new TestEnv()); +} + +extern "C" void uno_ext_getMapping(uno_Mapping ** ppMapping, + uno_Environment * pFrom, + uno_Environment * pTo ) +{ + cppu::helper::purpenv::createMapping(ppMapping, pFrom, pTo); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/test/bootstrap/TestEnv.def b/cppuhelper/test/bootstrap/TestEnv.def new file mode 100644 index 000000000000..1444d92c13fa --- /dev/null +++ b/cppuhelper/test/bootstrap/TestEnv.def @@ -0,0 +1,8 @@ +HEAPSIZE 0 +EXPORTS + uno_initEnvironment + uno_ext_getMapping + + + + diff --git a/cppuhelper/test/bootstrap/bootstrap.test.cxx b/cppuhelper/test/bootstrap/bootstrap.test.cxx new file mode 100644 index 000000000000..5aa09b704680 --- /dev/null +++ b/cppuhelper/test/bootstrap/bootstrap.test.cxx @@ -0,0 +1,323 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +#include "sal/main.h" +#include "osl/file.hxx" + +#include "typelib/typedescription.hxx" + +#include "cppuhelper/bootstrap.hxx" +#include "cppuhelper/shlib.hxx" + +#include <com/sun/star/lang/XComponent.hpp> + +#include "uno/environment.hxx" +#include "cppu/EnvDcp.hxx" +#include "cppu/EnvGuards.hxx" + +#include <iostream> + + +#ifndef SAL_DLLPREFIX +# define SAL_DLLPREFIX "" +#endif + + +using namespace com::sun::star; + + +static rtl::OUString s_comment; + +static bool s_check_object_is_in(void * pObject) +{ + uno::Environment currentEnv(uno::Environment::getCurrent()); + + rtl_uString * pOId = NULL; + currentEnv.get()->pExtEnv->getObjectIdentifier(currentEnv.get()->pExtEnv, &pOId, pObject); + + + uno::TypeDescription typeDescription(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.uno.XInterface"))); + + void * pRegisteredObject = NULL; + currentEnv.get()->pExtEnv->getRegisteredInterface(currentEnv.get()->pExtEnv, + &pRegisteredObject, + pOId, + (typelib_InterfaceTypeDescription *)typeDescription.get()); + + + if (pOId) rtl_uString_release(pOId); + + bool result = pRegisteredObject != NULL; + + if (result) + currentEnv.get()->pExtEnv->releaseInterface(currentEnv.get()->pExtEnv, pRegisteredObject); + + return result; +} + +static void s_test__loadSharedLibComponentFactory(rtl::OUString const & clientPurpose, + rtl::OUString const & servicePurpose) +{ + cppu::EnvGuard envGuard(uno::Environment(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_LB_UNO)) + + clientPurpose, NULL)); + if (clientPurpose.getLength() && !envGuard.is()) + { + s_comment += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\t\tcouldn't get purpose env: \"")); + s_comment += clientPurpose; + s_comment += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\" - FAILURE\n")); + + return; + } + + rtl::OString os_clientPurpose(rtl::OUStringToOString(clientPurpose, RTL_TEXTENCODING_ASCII_US)); + + uno::Reference<uno::XInterface> xItf( + cppu::loadSharedLibComponentFactory( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SAL_DLLPREFIX "TestComponent.uno" SAL_DLLEXTENSION)), +#ifdef WIN32 + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("")), +#else + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("file://../lib/")), +#endif + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("impl.test.TestComponent")) + servicePurpose, + uno::Reference<lang::XMultiServiceFactory>(), + uno::Reference<registry::XRegistryKey>() + ) + ); + + if (!xItf.is()) + { + s_comment += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\t\tgot no object - FAILURE\n")); + return; + } + + if (!clientPurpose.equals(servicePurpose) && !s_check_object_is_in(xItf.get())) + { + s_comment += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\t\tcouldn't find object in current purpose \"")); + s_comment += clientPurpose; + s_comment += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\" - FAILURE\n")); + } + + if (!cppu::EnvDcp::getPurpose(uno::Environment::getCurrent().getTypeName()).equals(clientPurpose)) + { + s_comment += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\t\tdid not enter client purpose \"")); + s_comment += clientPurpose; + s_comment += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\" - FAILURE\n")); + } +} + +static void s_test__loadSharedLibComponentFactory__free_free() +{ + s_comment += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\ts_test__loadSharedLibComponentFactory__free_free\n")); + + s_test__loadSharedLibComponentFactory(rtl::OUString(), rtl::OUString()); +} + +static void s_test__loadSharedLibComponentFactory__free_purpose() +{ + s_comment += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\ts_test__loadSharedLibComponentFactory__free_purpose\n")); + + s_test__loadSharedLibComponentFactory(rtl::OUString(), + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(":testenv"))); +} + +static void s_test__loadSharedLibComponentFactory__purpose_free() +{ + s_comment += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\ts_test__loadSharedLibComponentFactory__purpose_free\n")); + + s_test__loadSharedLibComponentFactory(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(":testenv")), + rtl::OUString()); +} + +static void s_test__loadSharedLibComponentFactory__purpose_purpose() +{ + s_comment += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\ts_test__loadSharedLibComponentFactory__purpose_purpose\n")); + + s_test__loadSharedLibComponentFactory(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(":testenv")), + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(":testenv"))); +} + +static rtl::OUString s_getSDrive(void) +{ + rtl::OUString path;//(RTL_CONSTASCII_USTRINGPARAM("file://")); + + char const * tmp = getenv("SOLARVER"); + path += rtl::OUString(tmp, rtl_str_getLength(tmp), RTL_TEXTENCODING_ASCII_US); + path += rtl::OUString(SAL_PATHDELIMITER); + + tmp = getenv("INPATH"); + path += rtl::OUString(tmp, rtl_str_getLength(tmp), RTL_TEXTENCODING_ASCII_US); + path += rtl::OUString(SAL_PATHDELIMITER); +#ifdef WIN32 + path += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("bin")); + +#else + path += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("lib")); +#endif + + tmp = getenv("UPDMINOREXT"); + if (tmp) + path += rtl::OUString(tmp, rtl_str_getLength(tmp), RTL_TEXTENCODING_ASCII_US); + + osl::FileBase::getFileURLFromSystemPath(path, path); + + return path; +} + +static void s_test__createSimpleRegistry(rtl::OUString const & clientPurpose) +{ + cppu::EnvGuard envGuard(uno::Environment(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_LB_UNO)) + + clientPurpose, NULL)); + if (clientPurpose.getLength() && !envGuard.is()) + { + s_comment += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\t\tcouldn't get purpose env: \"")); + s_comment += clientPurpose; + s_comment += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\" - FAILURE\n")); + + return; + } + + uno::Reference<registry::XSimpleRegistry> registry(cppu::createSimpleRegistry( + s_getSDrive())); + + if (!registry.is()) + { + s_comment += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\t\tgot no object - FAILURE\n")); + return; + } + + if (clientPurpose.getLength() != 0 && !s_check_object_is_in(registry.get())) + { + s_comment += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\t\tcouldn't find object in current purpose \"")); + s_comment += clientPurpose; + s_comment += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\" - FAILURE\n")); + } +} + +static void s_test__createSimpleRegistry__free(void) +{ + s_comment += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\ts_test__createSimpleRegistry__free\n")); + + s_test__createSimpleRegistry(rtl::OUString()); +} + +static void s_test__createSimpleRegistry__purpose(void) +{ + s_comment += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\ts_test__createSimpleRegistry__purpose\n")); + + s_test__createSimpleRegistry(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(":testenv"))); +} + + +static void s_test__bootstrap_InitialComponentContext(rtl::OUString const & clientPurpose) +{ + cppu::EnvGuard envGuard(uno::Environment(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_LB_UNO)) + + clientPurpose, NULL)); + if (clientPurpose.getLength() && !envGuard.is()) + { + s_comment += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\t\tcouldn't get purpose env: \"")); + s_comment += clientPurpose; + s_comment += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\" - FAILURE\n")); + + return; + } + + uno::Reference<uno::XComponentContext> xContext( + cppu::bootstrap_InitialComponentContext( + uno::Reference<registry::XSimpleRegistry>(), + s_getSDrive()) + ); + + if (!xContext.is()) + { + s_comment += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\t\tgot no object - FAILURE\n")); + return; + } + + if (clientPurpose.getLength() != 0 && !s_check_object_is_in(xContext.get())) + { + s_comment += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\t\tcouldn't find object in current purpose \"")); + s_comment += clientPurpose; + s_comment += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\" - FAILURE\n")); + } + + uno::Reference<lang::XComponent> xComponent(xContext, uno::UNO_QUERY_THROW); + xComponent->dispose(); +} + +static void s_test__bootstrap_InitialComponentContext__free(void) +{ + s_comment += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\ts_test__bootstrap_InitialComponentContext__free\n")); + + s_test__bootstrap_InitialComponentContext(rtl::OUString()); +} + +static void s_test__bootstrap_InitialComponentContext__purpose(void) +{ + s_comment += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\ts_test__bootstrap_InitialComponentContext__purpose\n")); + + s_test__bootstrap_InitialComponentContext(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(":testenv"))); +} + + +SAL_IMPLEMENT_MAIN_WITH_ARGS(/*argc*/, argv) +{ + s_test__createSimpleRegistry__free(); + s_test__createSimpleRegistry__purpose(); + + s_test__loadSharedLibComponentFactory__free_free(); + s_test__loadSharedLibComponentFactory__free_purpose(); + s_test__loadSharedLibComponentFactory__purpose_free(); + s_test__loadSharedLibComponentFactory__purpose_purpose(); + + s_test__bootstrap_InitialComponentContext__free(); + s_test__bootstrap_InitialComponentContext__purpose(); + + int ret; + if (s_comment.indexOf(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FAILURE"))) == -1) + { + s_comment += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TESTS PASSED\n")); + ret = 0; + } + else + { + s_comment += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TESTS _NOT_ PASSED\n")); + ret = -1; + } + + std::cerr + << argv[0] + << std::endl + << rtl::OUStringToOString(s_comment, RTL_TEXTENCODING_ASCII_US).getStr() + << std::endl; + + return ret; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/test/bootstrap/makefile.mk b/cppuhelper/test/bootstrap/makefile.mk new file mode 100644 index 000000000000..59db7c00e611 --- /dev/null +++ b/cppuhelper/test/bootstrap/makefile.mk @@ -0,0 +1,61 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +PRJ := ..$/.. +PRJNAME := cppuhelper +TARGET := bootstrap.test + + +ENABLE_EXCEPTIONS := TRUE +NO_BSYMBOLIC := TRUE +USE_DEFFILE := TRUE + + +.INCLUDE : settings.mk + + +.IF "$(GUI)"=="UNX" || "$(GUI)"=="MAC" +PURPENVHELPERLIB := -luno_purpenvhelper$(COMID) + +.ELSE +PURPENVHELPERLIB := $(LIBPRE) ipurpenvhelper$(UDK_MAJOR)$(COMID).lib + +.ENDIF + + +APP1TARGET := $(TARGET) +APP1OBJS := $(OBJ)$/bootstrap.test.obj +APP1STDLIBS := $(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) + +SHL1TARGET := testenv_uno_uno +SHL1IMPLIB := i$(SHL1TARGET) +SHL1OBJS := $(SLO)$/TestEnv.obj +SHL1STDLIBS := $(PURPENVHELPERLIB) $(SALHELPERLIB) $(SALLIB) +SHL1DEF := TestEnv.def + + +.INCLUDE : target.mk diff --git a/cppuhelper/test/cfg_data/instance/uno/components.xml b/cppuhelper/test/cfg_data/instance/uno/components.xml new file mode 100644 index 000000000000..83305fca1273 --- /dev/null +++ b/cppuhelper/test/cfg_data/instance/uno/components.xml @@ -0,0 +1,76 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<components cfg:package="uno" + xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" + xmlns:cfg="http://openoffice.org/2000/registry/instance" + xmlns="http://openoffice.org/2000/uno/Components"> + + +<services cfg:type="set" cfg:element-type="service"> + + <service cfg:name="com.sun.star.script.Converter"> + <available-implementations cfg:type="string" cfg:derivedBy="list"> + com.sun.star.comp.stoc.TypeConverter + </available-implementations> + </service> + + <service cfg:name="com.sun.star.bootstrap.TestComponent0"> + <available-implementations cfg:type="string" cfg:derivedBy="list"> + com.sun.star.comp.bootstrap.TestComponent0 + </available-implementations> + <context-properties cfg:type="set" cfg:element-type="cfg:any"> + <cfg:any cfg:name="serviceprop0" cfg:type="int">13</cfg:any> + <cfg:any cfg:name="serviceprop1" cfg:type="string">value of serviceprop1</cfg:any> + </context-properties> + </service> + +</services> + + +<implementations cfg:type="set" cfg:element-type="implementation"> + + <implementation cfg:name="com.sun.star.comp.stoc.TypeConverter"> + <activator cfg:type="string">com.sun.star.loader.SharedLibrary</activator> + <url cfg:type="string">tcv.dll</url> + <supported-services cfg:type="string" cfg:derivedBy="list">com.sun.star.script.Converter</supported-services> + </implementation> + + <implementation cfg:name="com.sun.star.comp.bootstrap.TestComponent0"> + <activator cfg:type="string">com.sun.star.loader.SharedLibrary</activator> + <url cfg:type="string">cfg_test.dll</url> + <supported-services cfg:type="string" cfg:derivedBy="list">com.sun.star.bootstrap.TestComponent0</supported-services> + <context-properties cfg:type="set" cfg:element-type="cfg:any"> + <cfg:any cfg:name="implprop0" cfg:type="int">15</cfg:any> + <cfg:any cfg:name="implprop1" cfg:type="string">value of implprop1</cfg:any> + </context-properties> + </implementation> + +</implementations> + + +<singletons cfg:type="set" cfg:element-type="singleton"> + + <singleton cfg:name="com.sun.star.script.theConverter"> + <used-service cfg:type="string">com.sun.star.script.Converter</used-service> + </singleton> + + <singleton cfg:name="com.sun.star.bootstrap.theTestComponent0"> + <used-service cfg:type="string">com.sun.star.bootstrap.TestComponent0</used-service> + <initial-arguments cfg:type="set" cfg:element-type="cfg:any"> + <cfg:any cfg:name="0" cfg:type="string">first argument</cfg:any> + <cfg:any cfg:name="1" cfg:type="string">second argument</cfg:any> + <cfg:any cfg:name="2" cfg:type="string">third argument</cfg:any> + </initial-arguments> + </singleton> + +</singletons> + + +<global-context-properties cfg:type="set" cfg:element-type="cfg:any"> + + <cfg:any cfg:name="TestValue" cfg:type="int">5</cfg:any> + +</global-context-properties> + + +</components> diff --git a/cppuhelper/test/cfg_data/template/uno/components.xml b/cppuhelper/test/cfg_data/template/uno/components.xml new file mode 100644 index 000000000000..6ff26a5b9cec --- /dev/null +++ b/cppuhelper/test/cfg_data/template/uno/components.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="utf-8"?> + +<components cfg:package="uno" + xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" + xmlns:cfg="http://openoffice.org/2000/registry/instance"> + +<service> + <available-implementations cfg:type="string" cfg:derivedBy=="list"/> + <context-properties cfg:type="set" cfg:element-type="cfg:any"/> +</service> + +<implementation> + <activator cfg:type="string"/> + <url cfg:type="string"/> + <supported-services cfg:type="string" cfg:derivedBy="list"/> + <context-properties cfg:type="set" cfg:element-type="cfg:any"/> +</implementation> + +<singleton> + <used-service cfg:type="string"/> + <initial-arguments cfg:type="set" cfg:element-type="cfg:any"/> +</singleton> + +</components> diff --git a/cppuhelper/test/cfg_test.cxx b/cppuhelper/test/cfg_test.cxx new file mode 100644 index 000000000000..53345815f186 --- /dev/null +++ b/cppuhelper/test/cfg_test.cxx @@ -0,0 +1,306 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_cppuhelper.hxx" + +// starting the executable: +// -env:UNO_CFG_URL=local;<absolute_path>..\\..\\test\\cfg_data;<absolute_path>\\cfg_update +// -env:UNO_TYPES=cpputest.rdb + +#include <sal/main.h> + +#include <stdio.h> + +#include <rtl/strbuf.hxx> + +#include <cppuhelper/implementationentry.hxx> +#include <cppuhelper/bootstrap.hxx> +#include <cppuhelper/implbase2.hxx> + +#include <com/sun/star/lang/XMultiComponentFactory.hpp> +#include <com/sun/star/lang/XInitialization.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/lang/XComponent.hpp> + +#include <com/sun/star/registry/XImplementationRegistration.hpp> + +#define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) ) + + +using namespace ::cppu; +using namespace ::rtl; +using namespace ::osl; +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; + +namespace cfg_test +{ + +//-------------------------------------------------------------------------------------------------- +static Sequence< OUString > impl0_getSupportedServiceNames() +{ + OUString str( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.bootstrap.TestComponent0") ); + return Sequence< OUString >( &str, 1 ); +} +//-------------------------------------------------------------------------------------------------- +static OUString impl0_getImplementationName() +{ + return OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.bootstrap.TestComponent0") ); +} +//-------------------------------------------------------------------------------------------------- +static Sequence< OUString > impl1_getSupportedServiceNames() +{ + OUString str( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.bootstrap.TestComponent1") ); + return Sequence< OUString >( &str, 1 ); +} +//-------------------------------------------------------------------------------------------------- +static OUString impl1_getImplementationName() +{ + return OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.bootstrap.TestComponent1") ); +} + +//================================================================================================== +class ServiceImpl0 + : public WeakImplHelper2< lang::XServiceInfo, lang::XInitialization > +{ + Reference< XComponentContext > m_xContext; + +public: + ServiceImpl0( Reference< XComponentContext > const & xContext ) SAL_THROW( () ); + + // XInitialization + virtual void SAL_CALL initialize( const Sequence< Any >& rArgs ) throw (Exception, RuntimeException); + + // XServiceInfo + virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() throw (RuntimeException); + virtual OUString SAL_CALL getImplementationName() throw (RuntimeException); + virtual sal_Bool SAL_CALL supportsService( const OUString & rServiceName ) throw (RuntimeException); +}; +//__________________________________________________________________________________________________ +ServiceImpl0::ServiceImpl0( Reference< XComponentContext > const & xContext ) SAL_THROW( () ) + : m_xContext( xContext ) +{ + sal_Int32 n; + OUString val; + + // service properties + OSL_VERIFY( m_xContext->getValueByName( + OUSTR("/services/com.sun.star.bootstrap.TestComponent0/context-properties/serviceprop0") ) >>= n ); + OSL_VERIFY( n == 13 ); + OSL_VERIFY( m_xContext->getValueByName( + OUSTR("/services/com.sun.star.bootstrap.TestComponent0/context-properties/serviceprop1") ) >>= val ); + OSL_VERIFY( val.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("value of serviceprop1") ) ); + // impl properties + OSL_VERIFY( m_xContext->getValueByName( + OUSTR("/implementations/com.sun.star.comp.bootstrap.TestComponent0/context-properties/implprop0") ) >>= n ); + OSL_VERIFY( n == 15 ); + OSL_VERIFY( m_xContext->getValueByName( + OUSTR("/implementations/com.sun.star.comp.bootstrap.TestComponent0/context-properties/implprop1") ) >>= val ); + OSL_VERIFY( val.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("value of implprop1") ) ); +} +// XInitialization +//__________________________________________________________________________________________________ +void ServiceImpl0::initialize( const Sequence< Any >& rArgs ) + throw (Exception, RuntimeException) +{ + // check args + OUString val; + OSL_VERIFY( rArgs.getLength() == 3 ); + OSL_VERIFY( rArgs[ 0 ] >>= val ); + OSL_VERIFY( val.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("first argument") ) ); + OSL_VERIFY( rArgs[ 1 ] >>= val ); + OSL_VERIFY( val.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("second argument") ) ); + OSL_VERIFY( rArgs[ 2 ] >>= val ); + OSL_VERIFY( val.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("third argument") ) ); +} +// XServiceInfo +//__________________________________________________________________________________________________ +OUString ServiceImpl0::getImplementationName() + throw(::com::sun::star::uno::RuntimeException) +{ + return impl0_getImplementationName(); +} +//__________________________________________________________________________________________________ +Sequence< OUString > ServiceImpl0::getSupportedServiceNames() + throw(::com::sun::star::uno::RuntimeException) +{ + return impl0_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; +} + +//================================================================================================== +class ServiceImpl1 : public ServiceImpl0 +{ +public: + inline ServiceImpl1( Reference< XComponentContext > const & xContext ) SAL_THROW( () ) + : ServiceImpl0( xContext ) + {} + + // XServiceInfo + virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() throw (RuntimeException); + virtual OUString SAL_CALL getImplementationName() throw (RuntimeException); +}; +//__________________________________________________________________________________________________ +OUString ServiceImpl1::getImplementationName() + throw(::com::sun::star::uno::RuntimeException) +{ + return impl1_getImplementationName(); +} +//__________________________________________________________________________________________________ +Sequence< OUString > ServiceImpl1::getSupportedServiceNames() + throw(::com::sun::star::uno::RuntimeException) +{ + return impl1_getSupportedServiceNames(); +} + +//================================================================================================== +static Reference< XInterface > SAL_CALL ServiceImpl0_create( + Reference< XComponentContext > const & xContext ) + SAL_THROW( (Exception) ) +{ + return (OWeakObject *)new ServiceImpl0( xContext ); +} +//================================================================================================== +static Reference< XInterface > SAL_CALL ServiceImpl1_create( + Reference< XComponentContext > const & xContext ) + SAL_THROW( (Exception) ) +{ + return (OWeakObject *)new ServiceImpl1( xContext ); +} + +} // namespace cfg_test + +static struct ImplementationEntry g_entries[] = +{ + { + ::cfg_test::ServiceImpl0_create, ::cfg_test::impl0_getImplementationName, + ::cfg_test::impl0_getSupportedServiceNames, createSingleComponentFactory, + 0, 0 + }, + { + ::cfg_test::ServiceImpl1_create, ::cfg_test::impl1_getImplementationName, + ::cfg_test::impl1_getSupportedServiceNames, createSingleComponentFactory, + 0, 0 + }, + { 0, 0, 0, 0, 0, 0 } +}; + +// component exports +extern "C" +{ +//================================================================================================== +void SAL_CALL component_getImplementationEnvironment( + const sal_Char ** ppEnvTypeName, uno_Environment ** /*ppEnv*/ ) +{ + *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; +} +//================================================================================================== +sal_Bool SAL_CALL component_writeInfo( + void * pServiceManager, void * pRegistryKey ) +{ + return component_writeInfoHelper( + pServiceManager, pRegistryKey, g_entries ); +} +//================================================================================================== +void * SAL_CALL component_getFactory( + const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey ) +{ + return component_getFactoryHelper( + pImplName, pServiceManager, pRegistryKey , g_entries ); +} +} + + +//################################################################################################## +//################################################################################################## +//################################################################################################## + +SAL_IMPLEMENT_MAIN() +{ + try + { + Reference< XComponentContext > xContext( defaultBootstrap_InitialComponentContext() ); + Reference< lang::XMultiComponentFactory > xMgr( xContext->getServiceManager() ); + + // show what is in context + xContext->getValueByName( OUSTR("dump_maps") ); + + sal_Int32 n; + OSL_VERIFY( xContext->getValueByName( OUSTR("/global-context-properties/TestValue") ) >>= n ); + ::fprintf( stderr, "> n=%d\n", n ); + + Reference< XInterface > x; + OSL_VERIFY( !(xContext->getValueByName( OUSTR("/singletons/my_converter") ) >>= x) ); + OSL_VERIFY( xContext->getValueByName( OUSTR("/singletons/com.sun.star.script.theConverter") ) >>= x ); + OSL_VERIFY( xContext->getValueByName( OUSTR("/singletons/com.sun.star.bootstrap.theTestComponent0") ) >>= x ); + + ::fprintf( stderr, "> registering service...\n", n ); +#if defined(SAL_W32) || defined(SAL_OS2) + OUString libName( OUSTR("cfg_test.dll") ); +#elif defined(SAL_UNX) + OUString libName( OUSTR("libcfg_test.so") ); +#endif + Reference< registry::XImplementationRegistration > xImplReg( xMgr->createInstanceWithContext( + OUSTR("com.sun.star.registry.ImplementationRegistration"), xContext ), UNO_QUERY ); + OSL_ENSURE( xImplReg.is(), "### no impl reg!" ); + xImplReg->registerImplementation( + OUSTR("com.sun.star.loader.SharedLibrary"), libName, + Reference< registry::XSimpleRegistry >() ); + + OSL_VERIFY( (x = xMgr->createInstanceWithContext( OUSTR("com.sun.star.bootstrap.TestComponent0"), xContext )).is() ); + OSL_VERIFY( (x = xMgr->createInstanceWithContext( OUSTR("com.sun.star.bootstrap.TestComponent1"), xContext )).is() ); + + Reference< lang::XComponent > xComp( xContext, UNO_QUERY ); + if (xComp.is()) + { + xComp->dispose(); + } + return 0; + } + catch (Exception & exc) + { + OString str( OUStringToOString( exc.Message, RTL_TEXTENCODING_ASCII_US ) ); + ::fprintf( stderr, "# caught exception: %s\n", str.getStr() ); + return 1; + } +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/test/helpertest.idl b/cppuhelper/test/helpertest.idl new file mode 100644 index 000000000000..daa69656f4ef --- /dev/null +++ b/cppuhelper/test/helpertest.idl @@ -0,0 +1,84 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _TEST_CPPUTEST_IDL_ +#define _TEST_CPPUTEST_IDL_ + +#include <com/sun/star/uno/XInterface.idl> +#include <com/sun/star/uno/TypeClass.idl> + +module test +{ + +interface A : com::sun::star::uno::XInterface +{ + string a(); +}; + +interface BA : A +{ + string ba(); +}; + +interface CA : A +{ + string ca(); +}; + +interface DBA : BA +{ + string dba(); +}; + +interface E : com::sun::star::uno::XInterface +{ + string e(); +}; + +interface FE : E +{ + string fe(); +}; + +interface G : com::sun::star::uno::XInterface +{ + string g(); + string a(); +}; + +interface H : com::sun::star::uno::XInterface +{ + string h(); +}; +interface I : com::sun::star::uno::XInterface +{ + string i(); +}; + +}; //module test + +#endif diff --git a/cppuhelper/test/loader/loader.test.cxx b/cppuhelper/test/loader/loader.test.cxx new file mode 100644 index 000000000000..34846197d030 --- /dev/null +++ b/cppuhelper/test/loader/loader.test.cxx @@ -0,0 +1,208 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "sal/main.h" +#include <cppuhelper/shlib.hxx> +#include <cppuhelper/implbase1.hxx> +#include <cppu/EnvDcp.hxx> + +#include "../testcmp/TestComponent.hxx" + +#include <iostream> +#include <cstring> + +#ifndef SAL_DLLPREFIX +# define SAL_DLLPREFIX "" +#endif + + +using namespace ::com::sun::star; + + +class MyKey : public cppu::WeakImplHelper1<registry::XRegistryKey> + +{ +public: + virtual rtl::OUString SAL_CALL getKeyName() throw (uno::RuntimeException) { return rtl::OUString(); }; + + // Methods + virtual sal_Bool SAL_CALL isReadOnly( ) throw (registry::InvalidRegistryException, uno::RuntimeException) {return sal_False;}; + virtual sal_Bool SAL_CALL isValid( ) throw (uno::RuntimeException) {return sal_False;}; + virtual registry::RegistryKeyType SAL_CALL getKeyType( const rtl::OUString& /*rKeyName*/ ) throw (registry::InvalidRegistryException, uno::RuntimeException) {return registry::RegistryKeyType_KEY;}; + virtual registry::RegistryValueType SAL_CALL getValueType( ) throw (registry::InvalidRegistryException, uno::RuntimeException) {return registry::RegistryValueType_NOT_DEFINED;}; + virtual sal_Int32 SAL_CALL getLongValue( ) throw (registry::InvalidRegistryException, registry::InvalidValueException, uno::RuntimeException) {return 0;}; + virtual void SAL_CALL setLongValue( sal_Int32 /*value*/ ) throw (registry::InvalidRegistryException, uno::RuntimeException) {}; + virtual uno::Sequence< sal_Int32 > SAL_CALL getLongListValue( ) throw (registry::InvalidRegistryException, registry::InvalidValueException, uno::RuntimeException) { return uno::Sequence<sal_Int32>(); }; + virtual void SAL_CALL setLongListValue( const uno::Sequence< sal_Int32 >& /*seqValue*/ ) throw (registry::InvalidRegistryException, uno::RuntimeException) {}; + virtual rtl::OUString SAL_CALL getAsciiValue( ) throw (registry::InvalidRegistryException, registry::InvalidValueException, uno::RuntimeException) {return rtl::OUString();}; + virtual void SAL_CALL setAsciiValue( const rtl::OUString& /*value*/ ) throw (registry::InvalidRegistryException, uno::RuntimeException) {}; + virtual uno::Sequence< rtl::OUString > SAL_CALL getAsciiListValue( ) throw (registry::InvalidRegistryException, registry::InvalidValueException, uno::RuntimeException) {return uno::Sequence<rtl::OUString>();}; + virtual void SAL_CALL setAsciiListValue( const uno::Sequence< rtl::OUString >& /*seqValue*/ ) throw (registry::InvalidRegistryException, uno::RuntimeException) {}; + virtual rtl::OUString SAL_CALL getStringValue( ) throw (registry::InvalidRegistryException, registry::InvalidValueException, uno::RuntimeException) {return rtl::OUString();}; + virtual void SAL_CALL setStringValue( const rtl::OUString& /*value*/ ) throw (registry::InvalidRegistryException, uno::RuntimeException) {}; + virtual uno::Sequence< rtl::OUString > SAL_CALL getStringListValue( ) throw (registry::InvalidRegistryException, registry::InvalidValueException, uno::RuntimeException) {return uno::Sequence<rtl::OUString>();}; + virtual void SAL_CALL setStringListValue( const uno::Sequence< rtl::OUString >& /*seqValue*/ ) throw (registry::InvalidRegistryException, uno::RuntimeException) {}; + virtual uno::Sequence< sal_Int8 > SAL_CALL getBinaryValue( ) throw (registry::InvalidRegistryException, registry::InvalidValueException, uno::RuntimeException) {return uno::Sequence<sal_Int8>();}; + virtual void SAL_CALL setBinaryValue( const uno::Sequence< sal_Int8 >& /*value*/ ) throw (registry::InvalidRegistryException, uno::RuntimeException) {}; + virtual uno::Reference< registry::XRegistryKey > SAL_CALL openKey( const rtl::OUString& /*aKeyName*/ ) throw (registry::InvalidRegistryException, uno::RuntimeException) {return uno::Reference<registry::XRegistryKey>();}; + virtual uno::Reference< registry::XRegistryKey > SAL_CALL createKey( const rtl::OUString& /*aKeyName*/ ) throw (registry::InvalidRegistryException, uno::RuntimeException) {return uno::Reference<registry::XRegistryKey>();}; + virtual void SAL_CALL closeKey( ) throw (registry::InvalidRegistryException, uno::RuntimeException) {}; + virtual void SAL_CALL deleteKey( const rtl::OUString& /*rKeyName*/ ) throw (registry::InvalidRegistryException, uno::RuntimeException) {}; + virtual uno::Sequence< uno::Reference< registry::XRegistryKey > > SAL_CALL openKeys( ) throw (registry::InvalidRegistryException, uno::RuntimeException) {return uno::Sequence<uno::Reference<registry::XRegistryKey> >();}; + virtual uno::Sequence< rtl::OUString > SAL_CALL getKeyNames( ) throw (registry::InvalidRegistryException, uno::RuntimeException) {return uno::Sequence<rtl::OUString>();}; + virtual sal_Bool SAL_CALL createLink( const rtl::OUString& /*aLinkName*/, const rtl::OUString& /*aLinkTarget*/ ) throw (registry::InvalidRegistryException, uno::RuntimeException) {return sal_False;}; + virtual void SAL_CALL deleteLink( const rtl::OUString& /*rLinkName*/ ) throw (registry::InvalidRegistryException, uno::RuntimeException) {}; + virtual rtl::OUString SAL_CALL getLinkTarget( const rtl::OUString& /*rLinkName*/ ) throw (registry::InvalidRegistryException, uno::RuntimeException) {return rtl::OUString();}; + virtual rtl::OUString SAL_CALL getResolvedName( const rtl::OUString& /*aKeyName*/ ) throw (registry::InvalidRegistryException, uno::RuntimeException) {return rtl::OUString();}; +}; + + + +static rtl::OUString s_test__cppu_loadSharedLibComponentFactory(char const * pServicePurpose) +{ + rtl::OUString result; + + rtl::OUString servicePurpose = rtl::OUString(pServicePurpose, + rtl_str_getLength(pServicePurpose), + RTL_TEXTENCODING_ASCII_US); + + result += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\ts_test__cppu_loadSharedLibComponentFactory ")); + result += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("(\"")); + result += servicePurpose; + result += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\") - ")); + + try { + uno::Reference<uno::XInterface> xObject( + cppu::loadSharedLibComponentFactory( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SAL_DLLPREFIX "TestComponent.uno" SAL_DLLEXTENSION)), + rtl::OUString(), + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("impl.test.TestComponent")) + servicePurpose, + uno::Reference<lang::XMultiServiceFactory>(), + uno::Reference<registry::XRegistryKey>()) + ); + + rtl::OUString envDcp_purpose(cppu::EnvDcp::getPurpose(g_envDcp)); + if (envDcp_purpose == servicePurpose) + result += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("passed\n")); + + else + { + result += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FAILED - got: \"")); + result += envDcp_purpose; + result += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\"\n")); + } + } + catch(uno::Exception & exception) { + result += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FAILED - got: \"")); + result += exception.Message; + result += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\"\n")); + } + + return result; +} + +static rtl::OUString s_test__cppu_writeSharedLibComponentInfo(char const * pServicePurpose) +{ + rtl::OUString result; + + rtl::OUString servicePurpose = rtl::OUString(pServicePurpose, + rtl_str_getLength(pServicePurpose), + RTL_TEXTENCODING_ASCII_US); + + result += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\ts_test__cppu_writeSharedLibComponentInfo ")); + result += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("(\"")); + result += servicePurpose; + result += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\") - ")); + + char buff[256]; + strcpy(buff, "TestComponent.uno="); + strcat(buff, pServicePurpose); + + putenv(buff); + + try { + cppu::writeSharedLibComponentInfo( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SAL_DLLPREFIX "TestComponent.uno" SAL_DLLEXTENSION)), + rtl::OUString(), + uno::Reference<lang::XMultiServiceFactory>(), + uno::Reference<registry::XRegistryKey>(new MyKey) + ); + + rtl::OUString envDcp_purpose(cppu::EnvDcp::getPurpose(g_envDcp)); + if (envDcp_purpose == servicePurpose) + result += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("passed\n")); + + else + { + result += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FAILED - got: \"")); + result += envDcp_purpose; + result += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\"\n")); + } + } + catch(uno::Exception & exception) { + result += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FAILED - got: \"")); + result += exception.Message; + result += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\"\n")); + } + + return result; +} + + +SAL_IMPLEMENT_MAIN_WITH_ARGS(/*argc*/, argv) +{ + int result = 0; + + rtl::OUString message; + + message += rtl::OUString(argv[0], rtl_str_getLength(argv[0]), RTL_TEXTENCODING_ASCII_US); + message += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\n")); + + message += s_test__cppu_loadSharedLibComponentFactory(":unsafe"); + message += s_test__cppu_loadSharedLibComponentFactory(":affine"); + message += s_test__cppu_loadSharedLibComponentFactory(""); + + message += s_test__cppu_writeSharedLibComponentInfo(":unsafe"); + message += s_test__cppu_writeSharedLibComponentInfo(":affine"); + message += s_test__cppu_writeSharedLibComponentInfo(""); + + if (message.indexOf(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FAILED"))) == -1) + message += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TESTS PASSED\n")); + + else + { + message += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TESTS _NOT_ PASSED\n")); + result = -1; + } + + std::cout << rtl::OUStringToOString(message, RTL_TEXTENCODING_ASCII_US).getStr(); + + return result; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/test/loader/makefile.mk b/cppuhelper/test/loader/makefile.mk new file mode 100644 index 000000000000..dc1b5662bd43 --- /dev/null +++ b/cppuhelper/test/loader/makefile.mk @@ -0,0 +1,59 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +PRJ := ..$/.. +PRJNAME := cppuhelper +TARGET := loader.test + + +ENABLE_EXCEPTIONS := TRUE +NO_BSYMBOLIC := TRUE +USE_DEFFILE := TRUE + + +.INCLUDE : settings.mk + + +.IF "$(COM)" == "GCC" +#LINKFLAGS += -rdynamic +.ENDIF + + +ENVINCPRE := -I$(OUT)$/inc$/$(TARGET) + +APP1TARGET := $(TARGET) +APP1OBJS := $(OBJ)$/loader.test.obj +.IF "$(GUI)"=="WNT" +APP1STDLIBS := iTestComponent.uno.lib +.ELSE +APP1STDLIBS := -lTestComponent.uno + +.ENDIF + +APP1STDLIBS += $(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) + +.INCLUDE : target.mk diff --git a/cppuhelper/test/makefile.mk b/cppuhelper/test/makefile.mk new file mode 100644 index 000000000000..26e1cb394d3e --- /dev/null +++ b/cppuhelper/test/makefile.mk @@ -0,0 +1,168 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* +PRJ=.. + +PRJNAME=cppuhelper +TARGET=testhelper +ENABLE_EXCEPTIONS=TRUE +USE_DEFFILE=TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk + +# --- Files -------------------------------------------------------- + +UNOUCRDEP= $(SOLARBINDIR)$/udkapi.rdb +UNOUCRRDB= $(SOLARBINDIR)$/udkapi.rdb +UNOUCROUT= $(OUT)$/inc$/test +INCPRE+= $(OUT)$/inc$/test + +OBJFILES= \ + $(OBJ)$/testhelper.obj \ + $(OBJ)$/testpropshlp.obj \ + $(OBJ)$/testidlclass.obj \ + $(OBJ)$/testproptyphlp.obj \ + $(OBJ)$/testimplhelper.obj \ + $(OBJ)$/testcontainer.obj + +APP1TARGET=$(TARGET) +APP1OBJS=$(OBJFILES) + +APP1STDLIBS+= \ + $(CPPULIB) \ + $(CPPUHELPERLIB) \ + $(SALLIB) + +APP1DEF= $(MISC)$/$(APP1TARGET).def + +############################################# + +APP2OBJS = $(OBJ)$/testdefaultbootstrapping.obj +APP2STDLIBS += $(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) +APP2TARGET = testdefaultbootstrapping + +############################################# + +SLOFILES= \ + $(SLO)$/cfg_test.obj +LIB1TARGET=$(SLB)$/cfg_test.lib +LIB1OBJFILES=$(SLOFILES) + + +APP3OBJS = $(OBJ)$/cfg_test.obj +APP3STDLIBS += $(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) +APP3TARGET = test_cfg + +############################################# + +ALLIDLFILES:= helpertest.idl + +# --- Targets ------------------------------------------------------ + +.IF "$(depend)" == "" +ALL: $(BIN)$/cpputest.rdb \ + unoheader \ + $(BIN)$/testrc \ + $(BIN)$/testdefaultbootstrapping.pl \ + ALLTAR \ + $(BIN)$/$(APP2TARGET).bin \ + $(BIN)$/$(APP2TARGET).Bin \ + $(BIN)$/$(APP2TARGET).Exe + +.IF "$(GUI)"=="UNX" +ALL: $(BIN)$/$(APP2TARGET).exe + +$(BIN)$/$(APP2TARGET).exe : $(APP2TARGETN) + cp $(APP2TARGETN) $@ + +.ENDIF + + +$(BIN)$/$(APP2TARGET).bin : $(APP2TARGETN) + cp $(APP2TARGETN) $@ + +$(BIN)$/$(APP2TARGET).Bin : $(APP2TARGETN) + cp $(APP2TARGETN) $@ + +$(BIN)$/$(APP2TARGET).Exe : $(APP2TARGETN) + cp $(APP2TARGETN) $@ + +.ELSE +ALL: ALLDEP +.ENDIF + +.INCLUDE : target.mk + +CPPUMAKERFLAGS = +.IF "$(COM)" == "MSC" +CPPUMAKERFLAGS = -L +.ENDIF + +TYPES:=test.A;test.BA;test.CA;test.DBA;test.E;test.FE;test.G;test.H;test.I +HELPERTYPES:=com.sun.star.uno.XReference;com.sun.star.uno.XAdapter;com.sun.star.uno.XAggregation;com.sun.star.uno.XWeak;com.sun.star.lang.XComponent;com.sun.star.lang.XTypeProvider;com.sun.star.lang.XEventListener;com.sun.star.lang.XSingleServiceFactory;com.sun.star.lang.XMultiServiceFactory;com.sun.star.registry.XRegistryKey;com.sun.star.lang.XInitialization;com.sun.star.lang.XServiceInfo;com.sun.star.loader.XImplementationLoader;com.sun.star.lang.IllegalAccessException;com.sun.star.beans.XVetoableChangeListener;com.sun.star.beans.XPropertySet;com.sun.star.uno.XComponentContext +FACTORYTYPES:=com.sun.star.lang.XComponent;com.sun.star.registry.XSimpleRegistry;com.sun.star.lang.XInitialization;com.sun.star.lang.XMultiServiceFactory;com.sun.star.loader.XImplementationLoader;com.sun.star.registry.XImplementationRegistration;com.sun.star.container.XSet;com.sun.star.lang.XSingleServiceFactory;com.sun.star.lang.XSingleComponentFactory;com.sun.star.lang.XMultiComponentFactory + +.IF "$(OS)" == "WNT" || "$(OS)" == "OS2" +UNO_PATH := $(SOLARBINDIR) +UNO_OUT := $(OUT)$/bin +EXT_SO := .dll +.ELSE +UNO_PATH := $(SOLARLIBDIR) +UNO_OUT := $(OUT)$/lib +EXT_SO := .so +.ENDIF + +$(UNO_OUT)$/%$(EXT_SO): $(UNO_PATH)$/%$(EXT_SO) + $(COPY) $^ $@ + +$(BIN)$/cpputest.rdb: $(ALLIDLFILES) $(UNO_OUT)$/invocadapt.uno$(EXT_SO) $(UNO_OUT)$/bootstrap.uno$(EXT_SO) + idlc -I$(PRJ) -I$(SOLARIDLDIR) -O$(BIN) $(ALLIDLFILES) + regmerge $@ /UCR $(BIN)$/{$(?:f:s/.idl/.urd/)} + regmerge $@ / $(UNOUCRRDB) + regcomp -register -r $@ -c reflection.uno$(DLLPOST) + touch $@ + +unoheader: $(BIN)$/cpputest.rdb + cppumaker $(CPPUMAKERFLAGS) -BUCR -O$(UNOUCROUT) -T"$(TYPES);$(HELPERTYPES)" $(BIN)$/cpputest.rdb + cppumaker $(CPPUMAKERFLAGS) -BUCR -O$(UNOUCROUT) -T"$(FACTORYTYPES)" $(BIN)$/cpputest.rdb + + +$(BIN)$/testdefaultbootstrapping.pl: testdefaultbootstrapping.pl + cp testdefaultbootstrapping.pl $@ + +$(BIN)$/testrc: makefile.mk +.IF "$(GUI)"=="WNT" + echo [Tests] > $@ + echo TestKey1=com.sun.star.uno.NamingService.rdb >> $@ +.ELSE + echo '[Tests]' > $@ + echo 'TestKey1=file:///'$(PWD)/$(BIN)'/com.sun.star.uno.NamingService.rdb' >> $@ +.ENDIF + + + diff --git a/cppuhelper/test/testcmp/TestComponent.cxx b/cppuhelper/test/testcmp/TestComponent.cxx new file mode 100644 index 000000000000..b8858f3329bd --- /dev/null +++ b/cppuhelper/test/testcmp/TestComponent.cxx @@ -0,0 +1,250 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_cppuhelper.hxx" + + +#define CPPUHELPER_TEST_COMPONENT_IMPL +#include "TestComponent.hxx" + + +#include <string.h> + +#include "osl/thread.h" + +#include "cppuhelper/implbase1.hxx" +#include "cppuhelper/implementationentry.hxx" + +#include "com/sun/star/lang/XMultiComponentFactory.hpp" +#include "com/sun/star/lang/XServiceInfo.hpp" + +#include "com/sun/star/uno/XComponentContext.hpp" + + +#include "cppu/EnvDcp.hxx" + +#include <uno/environment.hxx> + +using namespace ::com::sun::star; + + +#define LOG_LIFECYCLE_TestComponent +#ifdef LOG_LIFECYCLE_TestComponent +# include <iostream> +# define LOG_LIFECYCLE_TestComponent_emit(x) x + +#else +# define LOG_LIFECYCLE_TestComponent_emit(x) + +#endif + + +class TestComponent: public cppu::WeakImplHelper1<lang::XServiceInfo> +{ + rtl::OUString m_implName; + +public: + static uno::Reference<uno::XInterface> create( + uno::Reference<uno::XComponentContext> const & xCtx + ) + SAL_THROW((uno::Exception)); + + + static uno::Sequence<rtl::OUString> SAL_CALL getSupportedServiceNames_Static(); + + explicit TestComponent(uno::Reference<uno::XComponentContext> const & xCtx); + virtual ~TestComponent(); + + uno::Any SAL_CALL queryInterface(uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException); + void SAL_CALL release() throw (); + void SAL_CALL acquire() throw (); + + // lang::XServiceInfo + virtual rtl::OUString SAL_CALL getImplementationName() throw (uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService(rtl::OUString const & ServiceName) + throw (uno::RuntimeException); + virtual uno::Sequence<rtl::OUString> SAL_CALL getSupportedServiceNames() + throw (uno::RuntimeException); + +protected: + uno::Reference<uno::XComponentContext> m_xComponentContext; +}; + + +uno::Reference<uno::XInterface> SAL_CALL TestComponent::create( + uno::Reference<uno::XComponentContext> const & xCtx +) + SAL_THROW((uno::Exception)) +{ + try + { + return static_cast<cppu::OWeakObject *>(new TestComponent(xCtx)); + } + catch (std::bad_alloc &) + { + throw uno::RuntimeException(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("std::bad_alloc")), + uno::Reference<uno::XInterface>()); + } +} + +uno::Sequence<rtl::OUString> SAL_CALL TestComponent::getSupportedServiceNames_Static() +{ + uno::Sequence<rtl::OUString> serviceNames(1); + serviceNames[0] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.lang.ServiceInfo")); + + return serviceNames; +} + + +TestComponent::TestComponent(uno::Reference<uno::XComponentContext> const & xCtx) + : m_xComponentContext(xCtx) +{ + LOG_LIFECYCLE_TestComponent_emit(fprintf(stderr, "LIFE: %s -> %p\n", "TestComponent::TestComponent()", this)); +} + +TestComponent::~TestComponent() +{ + LOG_LIFECYCLE_TestComponent_emit(fprintf(stderr, "LIFE: %s -> %p\n", "TestComponent::~TestComponent", this)); +} + +rtl::OUString SAL_CALL TestComponent::getImplementationName() + throw (uno::RuntimeException) +{ + return m_implName; +} + +void SAL_CALL TestComponent::acquire() throw () +{ + cppu::WeakImplHelper1<lang::XServiceInfo>::acquire(); +} + +void SAL_CALL TestComponent::release() throw () +{ + cppu::WeakImplHelper1<lang::XServiceInfo>::release(); +} + +uno::Any SAL_CALL TestComponent::queryInterface(uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException) +{ + return cppu::WeakImplHelper1<lang::XServiceInfo>::queryInterface(rType); +} + +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; +} + +uno::Sequence<rtl::OUString> SAL_CALL TestComponent::getSupportedServiceNames() + throw (uno::RuntimeException) +{ + return getSupportedServiceNames_Static(); +} + +extern "C" sal_Bool SAL_CALL component_writeInfo( + void * /*serviceManager*/, + void * /*registryKey*/ +) +{ + g_envDcp = uno::Environment::getCurrent().getTypeName(); + + return true; +} + +extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory( + char const * pImplName, + void * /*serviceManager*/, + void * /*registryKey*/ +) +{ + g_envDcp = uno::Environment::getCurrent().getTypeName(); + + uno::Reference< lang::XSingleComponentFactory > xFactory; + + rtl::OUString uTmp(pImplName, rtl_str_getLength(pImplName), RTL_TEXTENCODING_ASCII_US); + + rtl::OUString uImplName(cppu::EnvDcp::getTypeName(uTmp)); + rtl::OUString cmpName(RTL_CONSTASCII_USTRINGPARAM("impl.test.TestComponent")); + + if (uImplName.equals(cmpName)) + { + xFactory = cppu::createSingleComponentFactory( + TestComponent::create, + uImplName, + TestComponent::getSupportedServiceNames_Static()); + + xFactory->acquire(); + } + + return xFactory.get(); +} + +extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironmentExt( + sal_Char const ** envTypeName, + uno_Environment ** /*ppEnv*/, + sal_Char const * pImplName, + uno_Environment * /*pSrcEnv*/ +) +{ + rtl::OString purpose; + + if (pImplName) // this is the purpose for a specified impl + { + rtl::OUString uImplName(pImplName, rtl_str_getLength(pImplName), RTL_TEXTENCODING_ASCII_US); + purpose = rtl::OUStringToOString(cppu::EnvDcp::getPurpose(uImplName), RTL_TEXTENCODING_ASCII_US); + } + + if (!purpose.getLength()) + { + char * pPurpose = getenv("TestComponent.uno"); + if (pPurpose) + purpose = rtl::OString(pPurpose); + } + + if (purpose.getLength() == 0) + *envTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; + + else + { + char buff[256]; + strcpy(buff, CPPU_STRINGIFY(CPPU_ENV)); + strcat(buff, purpose.getStr()); + + *envTypeName = strdup(buff); + } +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/test/testcmp/TestComponent.hxx b/cppuhelper/test/testcmp/TestComponent.hxx new file mode 100644 index 000000000000..92824bd8acb6 --- /dev/null +++ b/cppuhelper/test/testcmp/TestComponent.hxx @@ -0,0 +1,59 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef INCLUDED_cppuhelper_test_testcmp_TestComponent_hxx +#define INCLUDED_cppuhelper_test_testcmp_TestComponent_hxx + +#include <sal/types.h> +#include <rtl/ustring.hxx> + +#ifdef CPPUHELPER_TEST_COMPONENT_IMPL +# define CPPUHELPER_TEST_COMPONENT_EXPORT SAL_DLLPUBLIC_EXPORT + +#elif defined(CPPUHELPER_TEST_COMPONENT_LIB) +# define CPPUHELPER_TEST_COMPONENT_EXPORT extern + +#elif defined(__GNUC__) && defined(HAVE_GCC_VISIBILITY_FEATURE) +# define CPPUHELPER_TEST_COMPONENT_EXPORT extern __attribute__ ((weak)) + +#elif defined(__SUNPRO_CC) +# define CPPUHELPER_TEST_COMPONENT_EXPORT extern + extern rtl::OUString g_envDcp; +# pragma weak g_envDcp + +#else +# define CPPUHELPER_TEST_COMPONENT_EXPORT SAL_DLLPUBLIC_IMPORT + +#endif + +CPPUHELPER_TEST_COMPONENT_EXPORT rtl::OUString g_envDcp; + + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/test/testcmp/TestComponent.uno.def b/cppuhelper/test/testcmp/TestComponent.uno.def new file mode 100755 index 000000000000..8c1906e67459 --- /dev/null +++ b/cppuhelper/test/testcmp/TestComponent.uno.def @@ -0,0 +1,11 @@ +HEAPSIZE 0 +EXPORTS + component_getImplementationEnvironmentExt; + component_getFactory; + component_writeInfo; + ?g_envDcp@@3VOUString@rtl@@A; + + + + + diff --git a/cppuhelper/test/testcmp/makefile.mk b/cppuhelper/test/testcmp/makefile.mk new file mode 100644 index 000000000000..24474b8abfa9 --- /dev/null +++ b/cppuhelper/test/testcmp/makefile.mk @@ -0,0 +1,49 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +PRJ := ..$/.. +PRJNAME := cppuhelper +TARGET := TestComponent.uno +ENABLE_EXCEPTIONS := TRUE + + +.INCLUDE: settings.mk + + +SHL1TARGET := $(TARGET) +SHL1OBJS := $(SLO)$/TestComponent.obj +SHL1STDLIBS := $(CPPUHELPERLIB) $(CPPULIB) $(SALHELPERLIB) $(SALLIB) +SHL1IMPLIB := i$(SHL1TARGET) +.IF "$(GUI)"=="WNT" +SHL1DEF := TestComponent.uno.def +.ELSE +DEF1NAME := $(SHL1TARGET) +.ENDIF + + +.INCLUDE: target.mk + diff --git a/cppuhelper/test/testcontainer.cxx b/cppuhelper/test/testcontainer.cxx new file mode 100644 index 000000000000..ccf9aeda31a7 --- /dev/null +++ b/cppuhelper/test/testcontainer.cxx @@ -0,0 +1,156 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_cppuhelper.hxx" +#include <osl/mutex.hxx> + +#include <cppuhelper/interfacecontainer.hxx> +#include <cppuhelper/implbase1.hxx> + +#include <com/sun/star/beans/XVetoableChangeListener.hpp> + +using namespace ::cppu; +using namespace ::osl; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::uno; + + +class TestListener : public WeakImplHelper1< XVetoableChangeListener > +{ + // Methods + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& /*Source*/ ) throw(::com::sun::star::uno::RuntimeException) + { + + } + + virtual void SAL_CALL vetoableChange( const ::com::sun::star::beans::PropertyChangeEvent& /*aEvent*/ ) + throw(::com::sun::star::beans::PropertyVetoException, ::com::sun::star::uno::RuntimeException) + { + + } + +}; + +void test_interfacecontainer() +{ + Mutex mutex; + + { + OInterfaceContainerHelper helper( mutex ); + + Reference< XVetoableChangeListener > r1 = new TestListener(); + Reference< XVetoableChangeListener > r2 = new TestListener(); + Reference< XVetoableChangeListener > r3 = new TestListener(); + + helper.addInterface( r1 ); + helper.addInterface( r2 ); + helper.addInterface( r3 ); + + helper.disposeAndClear( EventObject() ); + } + + { + OInterfaceContainerHelper helper( mutex ); + + Reference< XVetoableChangeListener > r1 = new TestListener(); + Reference< XVetoableChangeListener > r2 = new TestListener(); + Reference< XVetoableChangeListener > r3 = new TestListener(); + + helper.addInterface( r1 ); + helper.addInterface( r2 ); + helper.addInterface( r3 ); + + OInterfaceIteratorHelper iterator( helper ); + + while( iterator.hasMoreElements() ) + ((XVetoableChangeListener*)iterator.next())->vetoableChange( PropertyChangeEvent() ); + + helper.disposeAndClear( EventObject() ); + } + + { + OInterfaceContainerHelper helper( mutex ); + + Reference< XVetoableChangeListener > r1 = new TestListener(); + Reference< XVetoableChangeListener > r2 = new TestListener(); + Reference< XVetoableChangeListener > r3 = new TestListener(); + + helper.addInterface( r1 ); + helper.addInterface( r2 ); + helper.addInterface( r3 ); + + OInterfaceIteratorHelper iterator( helper ); + + ((XVetoableChangeListener*)iterator.next())->vetoableChange( PropertyChangeEvent() ); + iterator.remove(); + ((XVetoableChangeListener*)iterator.next())->vetoableChange( PropertyChangeEvent() ); + iterator.remove(); + ((XVetoableChangeListener*)iterator.next())->vetoableChange( PropertyChangeEvent() ); + iterator.remove(); + + OSL_ASSERT( helper.getLength() == 0 ); + helper.disposeAndClear( EventObject() ); + } + + { + OInterfaceContainerHelper helper( mutex ); + + Reference< XVetoableChangeListener > r1 = new TestListener(); + Reference< XVetoableChangeListener > r2 = new TestListener(); + Reference< XVetoableChangeListener > r3 = new TestListener(); + + helper.addInterface( r1 ); + helper.addInterface( r2 ); + helper.addInterface( r3 ); + + { + OInterfaceIteratorHelper iterator( helper ); + while( iterator.hasMoreElements() ) + { + Reference< XVetoableChangeListener > r = ((XVetoableChangeListener*)iterator.next()); + if( r == r1 ) + iterator.remove(); + } + } + OSL_ASSERT( helper.getLength() == 2 ); + { + OInterfaceIteratorHelper iterator( helper ); + while( iterator.hasMoreElements() ) + { + Reference< XVetoableChangeListener > r = ((XVetoableChangeListener*)iterator.next()); + OSL_ASSERT( r != r1 && ( r == r2 || r == r3 ) ); + } + } + + helper.disposeAndClear( EventObject() ); + } +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/test/testdefaultbootstrapping.cxx b/cppuhelper/test/testdefaultbootstrapping.cxx new file mode 100644 index 000000000000..52f1c96af619 --- /dev/null +++ b/cppuhelper/test/testdefaultbootstrapping.cxx @@ -0,0 +1,87 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_cppuhelper.hxx" + +#include <sal/main.h> + + + +#include <cstdio> + +#include <rtl/process.h> +#include <cppuhelper/bootstrap.hxx> + +#include <com/sun/star/lang/XMultiServiceFactory.hpp> + +using namespace ::cppu; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::uno; +using namespace ::rtl; + + +SAL_IMPLEMENT_MAIN() +{ + sal_Bool result = sal_True; + + try { + Reference<XComponentContext> xComponentContext = defaultBootstrap_InitialComponentContext(); + + Reference<XMultiServiceFactory> smgr(xComponentContext->getServiceManager(), UNO_QUERY); + + for(sal_uInt32 i = 0; i < rtl_getAppCommandArgCount(); ++ i) { + OUString arg; + + rtl_getAppCommandArg(i, &arg.pData); + if (arg.getLength()) + { + Reference<XInterface> xInterface = smgr->createInstance(arg); + OString tmp = OUStringToOString(arg, RTL_TEXTENCODING_ASCII_US); +#if OSL_DEBUG_LEVEL > 1 + fprintf(stderr, "got the %s service %p\n", tmp.getStr(), xInterface.get()); +#endif + + result = result && (xInterface.get() != 0); + } + } + } + catch(Exception & exception) { + OString message = OUStringToOString(exception.Message, RTL_TEXTENCODING_ASCII_US); + + fprintf(stderr, "an exception occurred: %s\n", message.getStr()); + } + +#if OSL_DEBUG_LEVEL > 1 + OSL_TRACE("---------------------------------- %i", result); +#endif + + return result; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/test/testdefaultbootstrapping.pl b/cppuhelper/test/testdefaultbootstrapping.pl new file mode 100644 index 000000000000..b96ed5c49bcb --- /dev/null +++ b/cppuhelper/test/testdefaultbootstrapping.pl @@ -0,0 +1,277 @@ +: +eval 'exec perl -wS $0 ${1+"$@"}' + if 0; +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +# +# deliver.pl - copy from module output tree to solver +# + +my $progname = "testdefaultbootstrapping"; +my $defExeExt; + +if ($ENV{GUI} eq "WNT") { + %services = ( + 'com.sun.star.uno.NamingService' => 'namingservice.uno.dll', + 'com.sun.star.reflection.CoreReflection' => 'reflection.uno.dll', + 'com.sun.star.script.InvocationAdapterFactory' => 'invocadapt.uno.dll', + ); + + $defExeExt = ".exe"; + +} +else { + %services = ( + 'com.sun.star.uno.NamingService' => 'namingservice.uno.so', + 'com.sun.star.reflection.CoreReflection' => 'reflection.uno.so', + 'com.sun.star.script.InvocationAdapterFactory' => 'invocadapt.uno.so' + ); + + $defExeExt = ""; +} + +sub extendProgName($) { + my $_extension = shift; + my $_result; + + if ($ENV{GUI} eq "WNT") { + $_result = $progname . $_extension; + } + else { + $_result = $ENV{PWD} . "/" . $progname . $_extension; + } + + return $_result; +} + + +sub rmDefRDB() { + unlink $progname . "_services.rdb"; +} + + +sub unregisterService($){ + my $service_name = shift; + + my $rdb_name = $service_name . '.rdb'; + + unlink $rdb_name; + + return 1; +} + +sub testForServices($$$) { + my $_services = shift; + my $_pars = shift; + my $_testexe = shift; + + +# my $_rc = system 'echo', $_testexe, @{$_services}, $_pars; + my $_rc = system $_testexe, @{$_services}, $_pars; + + return $_rc >> 8; +} + + +sub registerService($$){ + my $service_lib = shift; + my $rdb_name = shift; + +# system 'echo', "regcomp -register -r " . $rdb_name . " -c $service_lib"; + my $rc = system "regcomp -register -r " . $rdb_name . " -c $service_lib"; + + + return ! ( $rc >> 8 ); +} + + + +my $state = 1; +my @allservices; +my $allservices_rdbs=""; +my $rc; +my $comment; +my $testexe; + + +sub registerServices() { + use Cwd; + + # ensure that services can not be instantiated + foreach $service ( keys %services ) { + # ensure that the current service is not reachable + unregisterService($service); + $rc = !testForServices([$service], "", $testexe); + if(!$rc) { + $comment = $comment . "\tcouldn't unregister service " . $service . "\n"; + $state = 0; + } + + + # register the service and ensure that it is reachable + $rc = registerService($services{$service}, $service . '.rdb'); + if(!$rc) { + $comment = $comment . "\tcouldn't register service " . $service . "\n"; + $state = 0; + } + + $rc = testForServices([$service], "-env:UNO_SERVICES=" . $service . ".rdb", $testexe); + if(!$rc) { + $comment = $comment . "\tcouldn't reach service " . $service . "\n"; + $state = 0; + } + + # memorize all services + if (length($allservices_rdbs)) { + $allservices_rdbs = $allservices_rdbs . " "; + } + $allservices_rdbs = $allservices_rdbs . "file://" . getcwd() . "/" . $service . ".rdb"; + push @allservices, $service; + } +} + +sub testIndirection() { + #test indirection + $rc = testForServices(['com.sun.star.uno.NamingService'], '-env:UNO_SERVICES=${testrc:Tests:TestKey1}', $testexe); + if (!$rc) { + $comment = $comment . "\tindirection test not passed\n"; + $state = 0; + } +} + + +sub testBeneathExe() { + my $service = 'com.sun.star.reflection.CoreReflection'; + my $_testexe; + + my @_exes = (extendProgName(".exe"), + extendProgName(".Exe"), + extendProgName(".bin"), + extendProgName(".Bin")); + + foreach $_testexe ( @_exes ) { + #test rdb found beneath executable + registerService($services{$service}, $progname . "_services.rdb"); + my $_rc = testForServices([$service], "", $_testexe); + if (!$_rc) { + $comment = $comment . "\tbeneath executable test not passed: " . $_testexe . "\n"; + $state = 0; + } + } +} + +sub testBeneathLib_rdb() { + my $_service = 'com.sun.star.uno.NamingService'; + + use UNO; + + my $_rdb_name; + + if ($ENV{GUI} eq "WNT") { + $_rdb_name = "UNO" . "_services.rdb"; + } + else { + $_rdb_name = "../lib/UNO" . "_services.rdb"; + } + + registerService($services{$_service}, $_rdb_name); + my $_rc = UNO::tryService($_service); + if (!$_rc) { + $comment = $comment . "\tbeneath lib test not passed\n"; + $state = 0; + } + unlink $_rdb_name; +} + +sub testBeneathLib_rc() { + my $_service = 'com.sun.star.uno.NamingService'; + + use UNO; + + my $_rc_name; + + if ($ENV{GUI} eq "WNT") { + $_rc_name = "UNO.ini"; + } + else { + $_rc_name = "../lib/UNOrc"; + } + + my $_rdb_name = "../lib/test.rdb"; + + my $_handle; + open $_handle, ">" . $_rc_name; + print $_handle "UNO_SERVICES=" . $_rdb_name . "\n"; + close $_handle; + + registerService($services{$_service}, $_rdb_name); + my $_rc = UNO::tryService($_service); + if (!$_rc) { + $comment = $comment . "\tbeneath lib rc test not passed\n"; + $state = 0; + } + unlink $_rdb_name; + unlink $_rc_name; +} + +sub testAllAvailable() { + # test that all services are reachable through different rdbs + # change the directory to ensure, that all paths become expanded + chdir ".."; + + $rc = testForServices(\@allservices, "-env:UNO_SERVICES=" . $allservices_rdbs, $testexe); + if (!$rc) { + $comment = $comment . "\tmulti rdb test not passed\n"; + $state = 0; + } +} + +$testexe = extendProgName($defExeExt); + +rmDefRDB(); +registerServices(); +#print "alls:", @allservices, $allservices_rdbs, "\n"; + +testIndirection(); +testBeneathExe(); +testBeneathLib_rc(); +testBeneathLib_rdb(); +testAllAvailable(); + +print "**************************\n"; +if($state) { + print "****** tests passed ******\n"; +} +else { + print "**** tests NOT passed ****\n"; + print "Commnent:\n", $comment, "\n"; +} +print "**************************\n"; + + + diff --git a/cppuhelper/test/testhelper.cxx b/cppuhelper/test/testhelper.cxx new file mode 100644 index 000000000000..faa83b92fb24 --- /dev/null +++ b/cppuhelper/test/testhelper.cxx @@ -0,0 +1,107 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#if !defined(OSL_DEBUG_LEVEL) || OSL_DEBUG_LEVEL == 0 +# undef OSL_DEBUG_LEVEL +# define OSL_DEBUG_LEVEL 2 +#endif + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_cppuhelper.hxx" + +#include <sal/main.h> + +#include <stdio.h> +#include <rtl/ustrbuf.hxx> +#include <osl/diagnose.h> + +#include <cppuhelper/component_context.hxx> +#include <cppuhelper/servicefactory.hxx> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/registry/XSimpleRegistry.hpp> +#include <com/sun/star/registry/XImplementationRegistration.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/lang/XComponent.hpp> + +#include "testhelper.hxx" + +using namespace rtl; +using namespace cppu; +using namespace com::sun::star::uno; +using namespace com::sun::star; +using namespace com::sun::star::lang; +using namespace com::sun::star::registry; + +SAL_IMPLEMENT_MAIN() +{ + try + { + Reference< XMultiComponentFactory > xMgr( createRegistryServiceFactory( + OUString( RTL_CONSTASCII_USTRINGPARAM("cpputest.rdb") ) ), UNO_QUERY ); + Reference< XComponentContext > xInitialContext; + OSL_VERIFY( Reference< beans::XPropertySet >( xMgr, UNO_QUERY )->getPropertyValue( + OUString( RTL_CONSTASCII_USTRINGPARAM("DefaultContext") ) ) >>= xInitialContext ); + + ContextEntry_Init aEntry; + aEntry.bLateInitService = false; + aEntry.name = OUString( RTL_CONSTASCII_USTRINGPARAM("bla, bla") ); + aEntry.value = makeAny( (sal_Int32)5 ); + Reference< XComponentContext > xContext( createComponentContext( &aEntry, 1, xInitialContext ) ); + OSL_ASSERT( xContext->getServiceManager() != xMgr ); // must be wrapped one + OSL_ASSERT( + Reference< beans::XPropertySet >( + xContext->getServiceManager(), UNO_QUERY )->getPropertyValue( + OUString( RTL_CONSTASCII_USTRINGPARAM("DefaultContext") ) ) != xInitialContext ); + + Reference< XMultiServiceFactory > x( xMgr, UNO_QUERY ); + test_ImplHelper( x ); + testPropertyTypeHelper(); + testidlclass( x ); + test_PropertySetHelper(); + test_interfacecontainer(); + + OSL_VERIFY( xContext->getValueByName( + OUString( RTL_CONSTASCII_USTRINGPARAM("bla, bla") ) ) == (sal_Int32)5 ); + OSL_VERIFY( ! xInitialContext->getValueByName( + OUString( RTL_CONSTASCII_USTRINGPARAM("bla, bla") ) ).hasValue() ); + Reference< XComponent >( xInitialContext, UNO_QUERY )->dispose(); + xMgr.clear(); + xContext.clear(); + xInitialContext.clear(); + } + catch (Exception & exc) + { + OString cstr_msg( OUStringToOString( exc.Message, RTL_TEXTENCODING_ASCII_US ) ); + OSL_ENSURE( ! "exception occured: ", cstr_msg.getStr() ); + } + + printf( "Test finished\n" ); + return 0; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/test/testhelper.hxx b/cppuhelper/test/testhelper.hxx new file mode 100644 index 000000000000..c40d738d83ba --- /dev/null +++ b/cppuhelper/test/testhelper.hxx @@ -0,0 +1,34 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +void testidlclass( const ::com::sun::star::uno::Reference < ::com::sun::star::lang::XMultiServiceFactory > &r); +void testPropertyTypeHelper(); +void test_PropertySetHelper(); +void test_ImplHelper( const ::com::sun::star::uno::Reference < ::com::sun::star::lang::XMultiServiceFactory > & xSF ); +void test_interfacecontainer(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/test/testidlclass.cxx b/cppuhelper/test/testidlclass.cxx new file mode 100644 index 000000000000..fca2a64089f8 --- /dev/null +++ b/cppuhelper/test/testidlclass.cxx @@ -0,0 +1,230 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_cppuhelper.hxx" + +#include <cppuhelper/stdidlclass.hxx> + +#include <com/sun/star/reflection/XIdlClassProvider.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> + +#include "testhelper.hxx" + +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::reflection; +using namespace ::rtl; + + + + +void testidlclass( const Reference < XMultiServiceFactory > &rSMgr) +{ + const OUString sImplName( OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.cpputest") ) ); + + // this reference is static to test behaviour during exiting application + Reference < XIdlClass > r = + ::cppu::createStandardClass( + rSMgr , + sImplName, + Reference < XIdlClass > () , + (XMultiServiceFactory * ) 0 , + (XServiceInfo * ) 0 + ); + + OSL_ASSERT( r.is() ); + + + { // test the xidlclassprovider interface ! + Reference< XIdlClassProvider > rProv( r , UNO_QUERY ); + OSL_ASSERT( rProv.is() ); + + { + Sequence < Reference < XIdlClass > > seq = rProv->getIdlClasses(); + + // is always one + OSL_ASSERT( seq.getLength() == 1 ); + + // test the weak reference + rProv->getIdlClasses(); + + } + + rProv->getIdlClasses(); + + + } + + + OSL_ASSERT( r->getName() == sImplName ); + + // test equals + Reference < XIdlClass > r2 = + ::cppu::createStandardClass( + rSMgr , + sImplName, + Reference < XIdlClass > () , + (XMultiServiceFactory * ) 0 , + (XServiceInfo * ) 0 + ); + // test for implementation name + OSL_ASSERT( r2->equals( r ) ); + + Sequence < Reference < XIdlClass > > seqIdlClass = r->getInterfaces(); + + //TODO ! + // one idl class for one interface + // this test fails, if core reflection fails ! +// OSL_ASSERT( 1 == seqIdlClass.getLength() ); +// Reference < XIdlClass > rIdlInterface = seqIdlClass.getArray()[0]; + + // check for IdlClass interface returned by Core Reflection +// OSL_ASSERT( rIdlInterface.is() ); + + + + // Test all ten templates + Reference< XIdlClass > x = ::cppu::createStandardClass( + rSMgr , + sImplName, + Reference < XIdlClass > () , + (XMultiServiceFactory * ) 0 , + (XServiceInfo * ) 0 , + (XServiceInfo * ) 0 + ); + + // Test all ten templates + x = ::cppu::createStandardClass( + rSMgr , + sImplName, + Reference < XIdlClass > () , + (XMultiServiceFactory * ) 0 , + (XServiceInfo * ) 0 , + (XServiceInfo * ) 0 , + (XServiceInfo * ) 0 + ); + + + // Test all ten templates + x = ::cppu::createStandardClass( + rSMgr , + sImplName, + Reference < XIdlClass > () , + (XMultiServiceFactory * ) 0 , + (XServiceInfo * ) 0 , + (XServiceInfo * ) 0 , + (XServiceInfo * ) 0 , + (XServiceInfo * ) 0 + ); + + + + // Test all ten templates + x = ::cppu::createStandardClass( + rSMgr , + sImplName, + Reference < XIdlClass > () , + (XMultiServiceFactory * ) 0 , + (XServiceInfo * ) 0 , + (XServiceInfo * ) 0 , + (XServiceInfo * ) 0 , + (XServiceInfo * ) 0 , + (XServiceInfo * ) 0 + ); + + + + // Test all ten templates + x = ::cppu::createStandardClass( + rSMgr , + sImplName, + Reference < XIdlClass > () , + (XMultiServiceFactory * ) 0 , + (XServiceInfo * ) 0 , + (XServiceInfo * ) 0 , + (XServiceInfo * ) 0 , + (XServiceInfo * ) 0 , + (XServiceInfo * ) 0 , + (XServiceInfo * ) 0 + ); + + + // Test all ten templates + x = ::cppu::createStandardClass( + rSMgr , + sImplName, + Reference < XIdlClass > () , + (XMultiServiceFactory * ) 0 , + (XServiceInfo * ) 0 , + (XServiceInfo * ) 0 , + (XServiceInfo * ) 0 , + (XServiceInfo * ) 0 , + (XServiceInfo * ) 0 , + (XServiceInfo * ) 0 , + (XServiceInfo * ) 0 + ); + + + + + // Test all ten templates + x = ::cppu::createStandardClass( + rSMgr , + sImplName, + Reference < XIdlClass > () , + (XMultiServiceFactory * ) 0 , + (XServiceInfo * ) 0 , + (XServiceInfo * ) 0 , + (XServiceInfo * ) 0 , + (XServiceInfo * ) 0 , + (XServiceInfo * ) 0 , + (XServiceInfo * ) 0 , + (XServiceInfo * ) 0 , + (XServiceInfo * ) 0 + ); + + // Test all ten templates + x = ::cppu::createStandardClass( + rSMgr , + sImplName, + Reference < XIdlClass > () , + (XMultiServiceFactory * ) 0 , + (XServiceInfo * ) 0 , + (XServiceInfo * ) 0 , + (XServiceInfo * ) 0 , + (XServiceInfo * ) 0 , + (XServiceInfo * ) 0 , + (XServiceInfo * ) 0 , + (XServiceInfo * ) 0 , + (XServiceInfo * ) 0 , + (XServiceInfo * ) 0 + ); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/test/testimplhelper.cxx b/cppuhelper/test/testimplhelper.cxx new file mode 100644 index 000000000000..703c44ebebbb --- /dev/null +++ b/cppuhelper/test/testimplhelper.cxx @@ -0,0 +1,583 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#if !defined(OSL_DEBUG_LEVEL) || OSL_DEBUG_LEVEL == 0 +# undef OSL_DEBUG_LEVEL +# define OSL_DEBUG_LEVEL 2 +#endif + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_cppuhelper.hxx" + +#include <stdio.h> + +#include <cppuhelper/implbase1.hxx> +#include <cppuhelper/implbase2.hxx> +#include <cppuhelper/implbase3.hxx> +#include <cppuhelper/implbase4.hxx> +#include <cppuhelper/implbase5.hxx> +#include <cppuhelper/implbase6.hxx> +#include <cppuhelper/implbase7.hxx> +#include <cppuhelper/implbase8.hxx> +#include <cppuhelper/implbase9.hxx> +#include <cppuhelper/implbase10.hxx> +#include <cppuhelper/implbase11.hxx> +#include <cppuhelper/implbase12.hxx> + +#include <cppuhelper/compbase1.hxx> +#include <cppuhelper/compbase2.hxx> +#include <cppuhelper/compbase3.hxx> +#include <cppuhelper/compbase4.hxx> +#include <cppuhelper/compbase5.hxx> +#include <cppuhelper/compbase6.hxx> +#include <cppuhelper/compbase7.hxx> +#include <cppuhelper/compbase8.hxx> +#include <cppuhelper/compbase9.hxx> +#include <cppuhelper/compbase10.hxx> +#include <cppuhelper/compbase11.hxx> +#include <cppuhelper/compbase12.hxx> + +#include <osl/diagnose.h> +#include <cppuhelper/servicefactory.hxx> +#include <cppuhelper/implbase4.hxx> +#include <cppuhelper/compbase4.hxx> +#include <cppuhelper/exc_hlp.hxx> + +#include <test/A.hpp> +#include <test/BA.hpp> +#include <test/CA.hpp> +#include <test/DBA.hpp> +#include <test/E.hpp> +#include <test/FE.hpp> +#include <test/G.hpp> +#include <test/H.hpp> +#include <test/I.hpp> + +#include <com/sun/star/lang/IllegalAccessException.hpp> + +using namespace test; +using namespace rtl; +using namespace osl; +using namespace cppu; +using namespace com::sun::star; +using namespace com::sun::star::uno; + +//================================================================================================== +struct TestImpl : public ImplHelper4< CA, DBA, FE, G > +{ + sal_Int32 nRef; + + virtual ~TestImpl() + { OSL_TRACE( "> TestImpl dtor called... <\n" ); } + + virtual Any SAL_CALL queryInterface( const Type & rType ) throw(RuntimeException) + { return ImplHelper4< CA, DBA, FE, G >::queryInterface( rType ); } + virtual void SAL_CALL acquire( ) throw() + { ++nRef; } + virtual void SAL_CALL release( ) throw() + { if (! --nRef) delete this; } + + // A + virtual OUString SAL_CALL a() throw(RuntimeException) + { return OUString( RTL_CONSTASCII_USTRINGPARAM("a") ); } + // BA + virtual OUString SAL_CALL ba() throw(RuntimeException) + { return OUString( RTL_CONSTASCII_USTRINGPARAM("ba") ); } + // CA + virtual OUString SAL_CALL ca() throw(RuntimeException) + { return OUString( RTL_CONSTASCII_USTRINGPARAM("ca") ); } + // DBA + virtual OUString SAL_CALL dba() throw(RuntimeException) + { return OUString( RTL_CONSTASCII_USTRINGPARAM("dba") ); } + // E + virtual OUString SAL_CALL e() throw(RuntimeException) + { return OUString( RTL_CONSTASCII_USTRINGPARAM("e") ); } + // FE + virtual OUString SAL_CALL fe() throw(RuntimeException) + { return OUString( RTL_CONSTASCII_USTRINGPARAM("fe") ); } + // G + virtual OUString SAL_CALL g() throw(RuntimeException) + { return OUString( RTL_CONSTASCII_USTRINGPARAM("g") ); } +}; + +//================================================================================================== +struct TestWeakAggImpl : public WeakAggImplHelper4< CA, DBA, FE, G > +{ + virtual ~TestWeakAggImpl() + { OSL_TRACE( "> TestWeakAggImpl dtor called... <\n" ); } + + // A + virtual OUString SAL_CALL a() throw(RuntimeException) + { return OUString( RTL_CONSTASCII_USTRINGPARAM("a") ); } + // BA + virtual OUString SAL_CALL ba() throw(RuntimeException) + { return OUString( RTL_CONSTASCII_USTRINGPARAM("ba") ); } + // CA + virtual OUString SAL_CALL ca() throw(RuntimeException) + { return OUString( RTL_CONSTASCII_USTRINGPARAM("ca") ); } + // DBA + virtual OUString SAL_CALL dba() throw(RuntimeException) + { return OUString( RTL_CONSTASCII_USTRINGPARAM("dba") ); } + // E + virtual OUString SAL_CALL e() throw(RuntimeException) + { return OUString( RTL_CONSTASCII_USTRINGPARAM("e") ); } + // FE + virtual OUString SAL_CALL fe() throw(RuntimeException) + { return OUString( RTL_CONSTASCII_USTRINGPARAM("fe") ); } + // G + virtual OUString SAL_CALL g() throw(RuntimeException) + { return OUString( RTL_CONSTASCII_USTRINGPARAM("g") ); } +}; + +//================================================================================================== +struct TestWeakImpl : public WeakImplHelper4< CA, DBA, FE, G > +{ + TestWeakImpl() {} + + virtual ~TestWeakImpl() + { OSL_TRACE( "> TestWeakImpl dtor called... <\n" ); } + + // A + virtual OUString SAL_CALL a() throw(RuntimeException) + { return OUString( RTL_CONSTASCII_USTRINGPARAM("a") ); } + // BA + virtual OUString SAL_CALL ba() throw(RuntimeException) + { return OUString( RTL_CONSTASCII_USTRINGPARAM("ba") ); } + // CA + virtual OUString SAL_CALL ca() throw(RuntimeException) + { return OUString( RTL_CONSTASCII_USTRINGPARAM("ca") ); } + // DBA + virtual OUString SAL_CALL dba() throw(RuntimeException) + { return OUString( RTL_CONSTASCII_USTRINGPARAM("dba") ); } + // E + virtual OUString SAL_CALL e() throw(RuntimeException) + { return OUString( RTL_CONSTASCII_USTRINGPARAM("e") ); } + // FE + virtual OUString SAL_CALL fe() throw(RuntimeException) + { return OUString( RTL_CONSTASCII_USTRINGPARAM("fe") ); } + // G + virtual OUString SAL_CALL g() throw(RuntimeException) + { return OUString( RTL_CONSTASCII_USTRINGPARAM("g") ); } + +protected: + TestWeakImpl(int) {} + + TestWeakImpl(int, int) {} + + TestWeakImpl(int, int, int) {} + + TestWeakImpl(int, int, int, int) {} + + TestWeakImpl(int, int, int, int, int) {} + + TestWeakImpl(int, int, int, int, int, int, int = 0) {} +}; + +//================================================================================================== +struct TestWeakComponentImpl : public WeakComponentImplHelper4< CA, DBA, FE, G > +{ + Mutex m; + TestWeakComponentImpl() + : WeakComponentImplHelper4< CA, DBA, FE, G >( m ) + {} + virtual ~TestWeakComponentImpl() + { OSL_TRACE( "> TestWeakComponentImpl dtor called... <\n" ); } + + void SAL_CALL disposing() + { OSL_TRACE( "> TestWeakComponentImpl disposing called... <\n" ); } + + // A + virtual OUString SAL_CALL a() throw(RuntimeException) + { return OUString( RTL_CONSTASCII_USTRINGPARAM("a") ); } + // BA + virtual OUString SAL_CALL ba() throw(RuntimeException) + { return OUString( RTL_CONSTASCII_USTRINGPARAM("ba") ); } + // CA + virtual OUString SAL_CALL ca() throw(RuntimeException) + { return OUString( RTL_CONSTASCII_USTRINGPARAM("ca") ); } + // DBA + virtual OUString SAL_CALL dba() throw(RuntimeException) + { return OUString( RTL_CONSTASCII_USTRINGPARAM("dba") ); } + // E + virtual OUString SAL_CALL e() throw(RuntimeException) + { return OUString( RTL_CONSTASCII_USTRINGPARAM("e") ); } + // FE + virtual OUString SAL_CALL fe() throw(RuntimeException) + { return OUString( RTL_CONSTASCII_USTRINGPARAM("fe") ); } + // G + virtual OUString SAL_CALL g() throw(RuntimeException) + { return OUString( RTL_CONSTASCII_USTRINGPARAM("g") ); } +}; + +//================================================================================================== +struct TestWeakAggComponentImpl : public WeakAggComponentImplHelper4< CA, DBA, FE, G > +{ + Mutex m; + TestWeakAggComponentImpl() + : WeakAggComponentImplHelper4< CA, DBA, FE, G >( m ) + {} + virtual ~TestWeakAggComponentImpl() + { OSL_TRACE( "> TestWeakAggComponentImpl dtor called... <\n" ); } + + void SAL_CALL disposing() + { OSL_TRACE( "> TestWeakAggComponentImpl disposing called... <\n" ); } + + // A + virtual OUString SAL_CALL a() throw(RuntimeException) + { return OUString( RTL_CONSTASCII_USTRINGPARAM("a") ); } + // BA + virtual OUString SAL_CALL ba() throw(RuntimeException) + { return OUString( RTL_CONSTASCII_USTRINGPARAM("ba") ); } + // CA + virtual OUString SAL_CALL ca() throw(RuntimeException) + { return OUString( RTL_CONSTASCII_USTRINGPARAM("ca") ); } + // DBA + virtual OUString SAL_CALL dba() throw(RuntimeException) + { return OUString( RTL_CONSTASCII_USTRINGPARAM("dba") ); } + // E + virtual OUString SAL_CALL e() throw(RuntimeException) + { return OUString( RTL_CONSTASCII_USTRINGPARAM("e") ); } + // FE + virtual OUString SAL_CALL fe() throw(RuntimeException) + { return OUString( RTL_CONSTASCII_USTRINGPARAM("fe") ); } + // G + virtual OUString SAL_CALL g() throw(RuntimeException) + { return OUString( RTL_CONSTASCII_USTRINGPARAM("g") ); } +}; + +//================================================================================================== +struct TestImplInh : public ImplInheritanceHelper2< TestWeakImpl, H, I > +{ + TestImplInh() {} + + explicit TestImplInh(int): + ImplInheritanceHelper2< TestWeakImpl, H, I >(1) {} + + TestImplInh(int, int): + ImplInheritanceHelper2< TestWeakImpl, H, I >(1, 2) {} + + TestImplInh(int, int, int): + ImplInheritanceHelper2< TestWeakImpl, H, I >(1, 2, 3) {} + + TestImplInh(int, int, int, int): + ImplInheritanceHelper2< TestWeakImpl, H, I >(1, 2, 3, 4) {} + + TestImplInh(int, int, int, int, int): + ImplInheritanceHelper2< TestWeakImpl, H, I >(1, 2, 3, 4, 5) {} + + TestImplInh(int, int, int, int, int, int): + ImplInheritanceHelper2< TestWeakImpl, H, I >(1, 2, 3, 4, 5, 6) {} + + virtual ~TestImplInh() + { OSL_TRACE( "> TestWeakImplInh dtor called... <\n" ); } + + // H + virtual OUString SAL_CALL h() throw(RuntimeException) + { return OUString( RTL_CONSTASCII_USTRINGPARAM("h") ); } + // I + virtual OUString SAL_CALL i() throw(RuntimeException) + { return OUString( RTL_CONSTASCII_USTRINGPARAM("i") ); } +}; + +//================================================================================================== +struct TestAggImplInh : public AggImplInheritanceHelper2< TestWeakAggImpl, H, I > +{ + virtual ~TestAggImplInh() + { OSL_TRACE( "> TestAggImplInh dtor called... <\n" ); } + + // H + virtual OUString SAL_CALL h() throw(RuntimeException) + { return OUString( RTL_CONSTASCII_USTRINGPARAM("h2") ); } + // I + virtual OUString SAL_CALL i() throw(RuntimeException) + { return OUString( RTL_CONSTASCII_USTRINGPARAM("i2") ); } +}; + + +static bool isIn( Sequence< Type > const & rTypes, char const * name ) +{ + OUString str( OUString::createFromAscii( name ) ); + Type const * pTypes = rTypes.getConstArray(); + for ( sal_Int32 nPos = rTypes.getLength(); nPos--; ) + { + if (pTypes[ nPos ].getTypeName().equals( str )) + return true; + } + return false; +} + +//================================================================================================== +static void dotest( const Reference< XInterface > & xOriginal ) +{ + Reference< lang::XTypeProvider > xTP( xOriginal, UNO_QUERY ); + Sequence< sal_Int8 > id( xTP->getImplementationId() ); + Sequence< Type > types( xTP->getTypes() ); + ::fprintf( stderr, "> supported types: " ); + long n = 0; + for ( ; n < types.getLength(); ++n ) + { + OString str( OUStringToOString( types[ n ].getTypeName(), RTL_TEXTENCODING_ASCII_US ) ); + ::fprintf( stderr, (n < (types.getLength()-1)) ? "%s, " : "%s; type-id=\n", str.getStr() ); + } + for ( n = 0; n < 16; ++n ) + { + ::fprintf( stderr, n < 15 ? "%x " : "%x \n", id[ n ] ); + } + + Reference< A > xa( xOriginal, UNO_QUERY ); + OSL_ENSURE( xa->a().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("a") ), "### A failed!" ); + Reference< BA > xba( xa, UNO_QUERY ); + OSL_ENSURE( xba->ba().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("ba") ), "### BA failed!" ); + OSL_ENSURE( xba->a().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("a") ), "### BA failed!" ); + Reference< CA > xca( xba, UNO_QUERY ); + OSL_ENSURE( xca->ca().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("ca") ), "### CA failed!" ); + OSL_ENSURE( xca->a().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("a") ), "### CA failed!" ); + Reference< DBA > xdba( xca, UNO_QUERY ); + OSL_ENSURE( xdba->dba().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("dba") ), "### DBA failed!" ); + OSL_ENSURE( xdba->ba().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("ba") ), "### DBA failed!" ); + OSL_ENSURE( xdba->a().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("a") ), "### DBA failed!" ); + Reference< E > xe( xdba, UNO_QUERY ); + OSL_ENSURE( xe->e().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("e") ), "### E failed!" ); + Reference< FE > xfe( xe, UNO_QUERY ); + OSL_ENSURE( xfe->fe().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("fe") ), "### FE failed!" ); + Reference< G > xg( xfe, UNO_QUERY ); + OSL_ENSURE( xg->g().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("g") ), "### G failed!" ); + OSL_ENSURE( xg->a().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("a") ), "### G failed!" ); + + // type provider + Reference< lang::XTypeProvider > xProv( xg, UNO_QUERY ); + Sequence< Type > aTypes( xProv->getTypes() ); + + // CA, DBA, FE, G, XTypeProvider + OSL_ASSERT( isIn( aTypes, "test.CA" ) ); + OSL_ASSERT( isIn( aTypes, "test.DBA" ) ); + OSL_ASSERT( isIn( aTypes, "test.FE") ); + OSL_ASSERT( isIn( aTypes, "test.G") ); + OSL_ASSERT( isIn( aTypes, "com.sun.star.lang.XTypeProvider") ); + + Reference< XWeak > xWeak( xg, UNO_QUERY ); + if (xWeak.is()) + { + OSL_ASSERT( isIn( aTypes, "com.sun.star.uno.XWeak") ); + } + Reference< lang::XComponent > xComp( xg, UNO_QUERY ); + if (xComp.is()) + { + OSL_ASSERT( isIn( aTypes, "com.sun.star.lang.XComponent") ); + } + + Reference< XAggregation > xAgg( xg, UNO_QUERY ); + if (xAgg.is()) + { + OSL_ASSERT( isIn( aTypes, "com.sun.star.uno.XAggregation") ); + } + Reference< H > xH( xg, UNO_QUERY ); + if (xH.is()) + { + OSL_ASSERT( isIn( aTypes, "test.H") ); + } + Reference< I > xI( xg, UNO_QUERY ); + if (xI.is()) + { + OSL_ASSERT( isIn( aTypes, "test.I") ); + } + + OSL_ENSURE( xg == xOriginal, "### root!" ); +} + +void rethrow() +{ + throw; +} + +void throw_one( + lang::IllegalAccessException exc ) +{ + try + { + throw exc; + } + catch (...) + { + rethrow(); + } +} + + +//================================================================================================== +void test_ImplHelper( const Reference< lang::XMultiServiceFactory > & /*xSF*/ ) +{ + Reference< XInterface > xImpl( (lang::XTypeProvider *)new TestImpl() ); + Reference< lang::XTypeProvider > xTP1( xImpl, UNO_QUERY ); + Reference< XInterface > xWeakImpl( (OWeakObject *)new TestWeakImpl() ); + Reference< lang::XTypeProvider > xTP2( xWeakImpl, UNO_QUERY ); + Reference< XInterface > xWeakAggImpl( (OWeakObject *)new TestWeakAggImpl() ); + Reference< lang::XTypeProvider > xTP3( xWeakAggImpl, UNO_QUERY ); + Reference< XInterface > xWeakComponentImpl( (OWeakObject *)new TestWeakComponentImpl() ); + Reference< lang::XTypeProvider > xTP4( xWeakComponentImpl, UNO_QUERY ); + Reference< XInterface > xWeakAggComponentImpl( (OWeakObject *)new TestWeakAggComponentImpl() ); + Reference< lang::XTypeProvider > xTP5( xWeakAggComponentImpl, UNO_QUERY ); + // + OSL_ASSERT( + xTP1->getImplementationId() != xTP2->getImplementationId() && + xTP1->getImplementationId() != xTP3->getImplementationId() && + xTP1->getImplementationId() != xTP4->getImplementationId() && + xTP1->getImplementationId() != xTP5->getImplementationId() && + xTP2->getImplementationId() != xTP3->getImplementationId() && + xTP2->getImplementationId() != xTP4->getImplementationId() && + xTP2->getImplementationId() != xTP5->getImplementationId() && + xTP3->getImplementationId() != xTP4->getImplementationId() && + xTP3->getImplementationId() != xTP5->getImplementationId() && + xTP4->getImplementationId() != xTP5->getImplementationId() ); + // + + dotest( xImpl ); + dotest( xWeakImpl ); + dotest( xWeakAggImpl ); + dotest( xWeakComponentImpl ); + dotest( xWeakAggComponentImpl ); + + xWeakImpl = (OWeakObject *)new TestImplInh(); + Reference< lang::XTypeProvider > xTP6( xWeakImpl, UNO_QUERY ); + dotest( xWeakImpl ); + Reference< H > xH( xWeakImpl, UNO_QUERY ); + Reference< I > xI( xH, UNO_QUERY ); + OSL_ASSERT( xH->h().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("h") ) ); + OSL_ASSERT( xI->i().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("i") ) ); + + xWeakAggImpl = (OWeakObject *)new TestAggImplInh(); + Reference< lang::XTypeProvider > xTP7( xWeakAggImpl, UNO_QUERY ); + dotest( xWeakAggImpl ); + xH.set( xWeakAggImpl, UNO_QUERY ); + xI.set( xH, UNO_QUERY ); + OSL_ASSERT( xH->h().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("h2") ) ); + OSL_ASSERT( xI->i().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("i2") ) ); + + // + OSL_ASSERT( + xTP6->getImplementationId() != xTP1->getImplementationId() && + xTP6->getImplementationId() != xTP2->getImplementationId() && + xTP6->getImplementationId() != xTP3->getImplementationId() && + xTP6->getImplementationId() != xTP4->getImplementationId() && + xTP6->getImplementationId() != xTP5->getImplementationId() && + xTP6->getImplementationId() != xTP7->getImplementationId() && + xTP7->getImplementationId() != xTP1->getImplementationId() && + xTP7->getImplementationId() != xTP2->getImplementationId() && + xTP7->getImplementationId() != xTP3->getImplementationId() && + xTP7->getImplementationId() != xTP4->getImplementationId() && + xTP7->getImplementationId() != xTP5->getImplementationId() ); + // + + bool exc_succ = false; + lang::IllegalAccessException exc( + OUString( RTL_CONSTASCII_USTRINGPARAM("testtest") ), + xWeakAggImpl ); + // exception helper tests + try + { + throw exc; + } + catch (Exception &) + { + Any a( getCaughtException() ); + OSL_ASSERT( a == exc ); + + try + { + throwException( a ); + } + catch (lang::IllegalAccessException & e) + { + OSL_ASSERT( exc.Message == e.Message && exc.Context == e.Context ); + + try + { + throw_one( exc ); + } + catch (Exception &) + { + Any a2( getCaughtException() ); + OSL_ASSERT( (a2 == a) && (a2 == exc) ); + + try + { + throw_one( exc ); + } + catch (lang::IllegalAccessException &) + { + Any a3( getCaughtException() ); + OSL_ASSERT( (a3 == a) && (a3 == a2) && (a3 == exc) ); + exc_succ = true; + } + } + } + } + OSL_ASSERT( exc_succ ); + + try + { + throwException( makeAny( RuntimeException( + OUString( RTL_CONSTASCII_USTRINGPARAM("runtime exc") ), xImpl ) ) ); + } + catch (RuntimeException & rExc) + { + OSL_ENSURE( rExc.Message.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("runtime exc") ) && rExc.Context == xImpl, + "### unexpected exception content!" ); + try + { + throwException( makeAny( Exception( + OUString( RTL_CONSTASCII_USTRINGPARAM("exc") ), rExc.Context ) ) ); + } + catch (lang::IllegalAccessException &) + { + OSL_ENSURE( sal_False, "### unexpected IllegalAccessException exception caught!" ); + } + catch (Exception & rExc2) + { + OSL_ENSURE( rExc2.Message.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("exc") ) && rExc2.Context == xImpl, + "### unexpected exception content!" ); + try + { + throwException( makeAny( lang::IllegalAccessException( + OUString( RTL_CONSTASCII_USTRINGPARAM("axxess exc") ), rExc2.Context ) ) ); + } + catch (lang::IllegalAccessException & rExc3) + { + OSL_ENSURE( rExc3.Message.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("axxess exc") ) && rExc3.Context == xImpl, + "### unexpected exception content!" ); + return; + } + } + } + catch (...) + { + } + OSL_ENSURE( sal_False, "### exception test failed!" ); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/test/testlib/UNO.pm b/cppuhelper/test/testlib/UNO.pm new file mode 100644 index 000000000000..0bc7b27fc86a --- /dev/null +++ b/cppuhelper/test/testlib/UNO.pm @@ -0,0 +1,68 @@ +package UNO; + +require 5.005_62; +use strict; +use warnings; + +require Exporter; +require DynaLoader; + +our @ISA = qw(Exporter DynaLoader); + +# Items to export into callers namespace by default. Note: do not export +# names by default without a very good reason. Use EXPORT_OK instead. +# Do not simply export all your public functions/methods/constants. + +# This allows declaration use UNO ':all'; +# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK +# will save memory. +our %EXPORT_TAGS = ( 'all' => [ qw( + +) ] ); + +our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); + +our @EXPORT = qw( + +); +our $VERSION = '0.01'; + +bootstrap UNO $VERSION; + +# Preloaded methods go here. + +1; +__END__ +# Below is stub documentation for your module. You better edit it! + +=head1 NAME + +UNO - Perl extension for blah blah blah + +=head1 SYNOPSIS + + use UNO; + blah blah blah + +=head1 DESCRIPTION + +Stub documentation for UNO, created by h2xs. It looks like the +author of the extension was negligent enough to leave the stub +unedited. + +Blah blah blah. + +=head2 EXPORT + +None by default. + + +=head1 AUTHOR + +A. U. Thor, a.u.thor@a.galaxy.far.far.away + +=head1 SEE ALSO + +perl(1). + +=cut diff --git a/cppuhelper/test/testlib/defbootstrap.map b/cppuhelper/test/testlib/defbootstrap.map new file mode 100755 index 000000000000..2293d819d900 --- /dev/null +++ b/cppuhelper/test/testlib/defbootstrap.map @@ -0,0 +1,8 @@ +UDK_3_0_0 { + global: + + boot_UNO; + + local: + *; +}; diff --git a/cppuhelper/test/testlib/defbootstrap_lib.cxx b/cppuhelper/test/testlib/defbootstrap_lib.cxx new file mode 100644 index 000000000000..22a4c5d865a4 --- /dev/null +++ b/cppuhelper/test/testlib/defbootstrap_lib.cxx @@ -0,0 +1,120 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_cppuhelper.hxx" + +#include "EXTERN.h" +#include "perl.h" +#include "XSUB.h" + +#include <cstdio> + +#include <osl/module.hxx> +#include <rtl/process.h> +#include <cppuhelper/bootstrap.hxx> + +#include <com/sun/star/lang/XMultiServiceFactory.hpp> + +using namespace ::cppu; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::uno; +using namespace ::rtl; + +static sal_Bool tryService(const char * serviceName) +{ + // use micro deployment to create initial context + OUString libraryFileUrl; + ::osl::Module::getUrlFromAddress((void *)tryService, libraryFileUrl); + + OUString iniName = libraryFileUrl.copy(0, libraryFileUrl.lastIndexOf((sal_Unicode)'.')); // cut the library extension + iniName += OUString(RTL_CONSTASCII_USTRINGPARAM(SAL_CONFIGFILE(""))); // add the rc file extension + +#if OSL_DEBUG_LEVEL > 1 + OString sIniName = OUStringToOString(iniName, RTL_TEXTENCODING_ASCII_US); + fprintf(stderr, "defbootstrap.cxx:tryService: using ini: %s\n", sIniName.getStr()); +#endif + + sal_Bool result = sal_True; + + try { + Reference<XComponentContext> xComponentContext = defaultBootstrap_InitialComponentContext(iniName); + Reference<XMultiServiceFactory> smgr(xComponentContext->getServiceManager(), UNO_QUERY); + + OUString arg = OUString::createFromAscii(serviceName); + Reference<XInterface> xInterface = smgr->createInstance(arg); + +#if OSL_DEBUG_LEVEL > 1 + fprintf(stderr, "got the %s service %p\n", serviceName, xInterface.get()); +#endif + result = result && (xInterface.get() != 0); + } + catch(Exception & exception) { + OString message = OUStringToOString(exception.Message, RTL_TEXTENCODING_ASCII_US); + + fprintf(stderr, "an exception occurred: %s\n", message.getStr()); + } + +#if OSL_DEBUG_LEVEL > 1 + OSL_TRACE("---------------------------------- %i", result); +#endif + + return result; +} + +XS(XS_UNO_tryService) +{ + dXSARGS; + if (items != 1) + Perl_croak(aTHX_ "Usage: UNO::tryService(input)"); + { + const char * input = (const char *)SvPV(ST(0),PL_na); + int RETVAL; + dXSTARG; + + RETVAL = tryService(input); + XSprePUSH; PUSHi((IV)RETVAL); + } + XSRETURN(1); +} + +extern "C" { +XS(boot_UNO) +{ + dXSARGS; + char* file = __FILE__; + +/* XS_VERSION_BOOTCHECK ;*/ + + newXS("UNO::tryService", XS_UNO_tryService, file); + XSRETURN_YES; +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/test/testlib/makefile.mk b/cppuhelper/test/testlib/makefile.mk new file mode 100755 index 000000000000..edaba0c6532c --- /dev/null +++ b/cppuhelper/test/testlib/makefile.mk @@ -0,0 +1,103 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* +LINKFLAGSDEFS="" + +PRJ=..$/.. + +PRJNAME=cppuhelper +TARGET=defbootstrap +ENABLE_EXCEPTIONS=TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk + +PERLINST1:=$(shell @+$(PERL) -V:installarchlib) +PERLINST2:=$(subst,installarchlib=, $(PERLINST1)) +PERLINST3:=$(PERLINST2:s/'//) +PERLINST :=$(PERLINST3:s/;//) + +PERLLIBS:=$(PERLINST)$/CORE +PERLINCS:=$(PERLINST)$/CORE + +CFLAGS += -I$(PERLINCS) + +.IF "$(GUI)"=="WNT" +PERLLIB=perl58.lib + +LIB!:=$(LIB);$(PERLLIBS) +.EXPORT : LIB + +.ENDIF + +# --- Files -------------------------------------------------------- + +#CFLAGS += -DVERSION=\"0.01\" -DXS_VERSION=\"0.01\" -fPIC -I/develop6/update/dev/solenv/unxlngi3/lib/perl5/5.6.0/i686-linux/CORE/ +#CFLAGS += -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DVERSION=\"0.01\" -DXS_VERSION=\"0.01\" -KPIC -I/develop6/update/dev/solenv/unxsols2/lib/perl5/5.6.0/sun4-solaris/CORE + +SLOFILES= $(SLO)$/defbootstrap_lib.obj + +SHL1TARGET=$(TARGET) + +SHL1STDLIBS= \ + $(PERLLIB) \ + $(CPPUHELPERLIB) \ + $(CPPULIB) \ + $(SALLIB) + +SHL1DEPN= +SHL1IMPLIB=i$(TARGET) +SHL1LIBS=$(SLB)$/$(TARGET).lib +SHL1DEF=$(MISC)$/$(SHL1TARGET).def + +DEF1NAME=$(SHL1TARGET) +SHL1VERSIONMAP=defbootstrap.map + + +.IF "$(GUI)"=="WNT" +UNODLL=$(DLLDEST)$/UNO.dll +.ELSE +UNODLL=$(DLLDEST)$/UNO.so +.ENDIF + +# --- Targets ------------------------------------------------------ + +.IF "$(depend)" == "" +ALL: \ + ALLTAR \ + $(UNODLL) \ + $(BIN)$/UNO.pm +.ENDIF + +$(BIN)$/UNO.pm: UNO.pm + cp UNO.pm $@ + +$(UNODLL): $(SHL1TARGETN) + cp $(SHL1TARGETN) $@ + +.INCLUDE : target.mk + diff --git a/cppuhelper/test/testpropshlp.cxx b/cppuhelper/test/testpropshlp.cxx new file mode 100644 index 000000000000..ebea7d09289d --- /dev/null +++ b/cppuhelper/test/testpropshlp.cxx @@ -0,0 +1,1184 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#if !defined(OSL_DEBUG_LEVEL) || OSL_DEBUG_LEVEL == 0 +# undef OSL_DEBUG_LEVEL +# define OSL_DEBUG_LEVEL 2 +#endif + + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_cppuhelper.hxx" +#include <osl/mutex.hxx> +#include <osl/diagnose.h> + +#include <cppuhelper/propshlp.hxx> +#include <cppuhelper/weak.hxx> + +#include <cppuhelper/proptypehlp.hxx> + +#include <com/sun/star/uno/Any.hxx> +#include <com/sun/star/beans/PropertyAttribute.hpp> + +#include <cppuhelper/implbase3.hxx> + +using namespace ::cppu; +using namespace ::rtl; +using namespace ::osl; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::lang; + + + +/********************** +* +**********************/ +static Property * getPropertyTable1() +{ + static Property *pTable = 0; + + if( ! pTable ) { + MutexGuard guard( Mutex::getGlobalMutex() ); + if( ! pTable ) { + static Property aTable[] = + { + Property( OUString( RTL_CONSTASCII_USTRINGPARAM("a") ), 0, getCppuType( (OUString *)0) , + PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), //OUString + Property( OUString( RTL_CONSTASCII_USTRINGPARAM("b") ), 1, getCppuCharType( ) , + PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), //Char + Property( OUString( RTL_CONSTASCII_USTRINGPARAM("c") ), 2, getCppuType( (sal_Int32*)0) , + PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), //sal_Int32 + Property( OUString( RTL_CONSTASCII_USTRINGPARAM("d") ), 5, getCppuType( (double*)0) , + PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), //double + Property( OUString( RTL_CONSTASCII_USTRINGPARAM("e") ), 7, getCppuBooleanType() , + PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), //BOOL + Property( OUString( RTL_CONSTASCII_USTRINGPARAM("f") ), 8, getCppuType( (Any*)0) , + PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ) //Any + }; + pTable = aTable; + } + } + return pTable; +} + + +static Property * getPropertyTable2() +{ + static Property *pTable = 0; + + if( ! pTable ) { + MutexGuard guard( ::osl::Mutex::getGlobalMutex() ); + if( ! pTable ) { + static Property aTable[] = + { + Property( OUString( RTL_CONSTASCII_USTRINGPARAM("f") ), 8, getCppuType( (Any *)0) , + PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), // Any + Property( OUString( RTL_CONSTASCII_USTRINGPARAM("b") ), 1, getCppuCharType( ), + PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), // Char + Property( OUString( RTL_CONSTASCII_USTRINGPARAM("a") ), 0, getCppuType( (OUString*)0), + PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), // OUString + Property( OUString( RTL_CONSTASCII_USTRINGPARAM("d") ), 5, getCppuType( (double*)0) , + PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), // Double + Property( OUString( RTL_CONSTASCII_USTRINGPARAM("c") ), 2, getCppuType( (sal_Int32*)0), + PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), // sal_Int32 + Property( OUString( RTL_CONSTASCII_USTRINGPARAM("e") ), 7, getCppuBooleanType() , + PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ) // Bool + }; + pTable = aTable; + } + } + return pTable; +} + +static Property * getPropertyTable3() +{ + static Property *pTable = 0; + + if( ! pTable ) { + MutexGuard guard( ::osl::Mutex::getGlobalMutex() ); + if( ! pTable ) { + static Property aTable[] = + { + Property( OUString( RTL_CONSTASCII_USTRINGPARAM("b") ), 1, getCppuCharType( ), + PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), // Char + Property( OUString( RTL_CONSTASCII_USTRINGPARAM("f") ), 8, getCppuType( (Any *)0) , + PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), // any + Property( OUString( RTL_CONSTASCII_USTRINGPARAM("a") ), 0, getCppuType( (OUString*)0), + PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ) // OUString + }; + pTable = aTable; + } + } + return pTable; +} + + +static Property * getPropertyTable4() +{ + static Property *pTable = 0; + + if( ! pTable ) { + MutexGuard guard( ::osl::Mutex::getGlobalMutex() ); + if( ! pTable ) { + static Property aTable[] = + { + Property( OUString( RTL_CONSTASCII_USTRINGPARAM("a") ), 0, getCppuType( (OUString*)0), + PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), // OUString + Property( OUString( RTL_CONSTASCII_USTRINGPARAM("b") ), 1, getCppuCharType( ), + PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ), // Char + Property( OUString( RTL_CONSTASCII_USTRINGPARAM("f") ), 2, getCppuType( (Any *)0) , + PropertyAttribute::READONLY | PropertyAttribute::MAYBEVOID ) // Any + }; + pTable = aTable; + } + } + return pTable; +} + + + +/********************** +* +* Note : all Property names must be in the 127 ASCII subset ! +* +**********************/ + + +void test_PropertyArrayHelper() +{ + // Test getProperties() and getCount() + { + OPropertyArrayHelper a1( getPropertyTable1(), 6 ); + OSL_ENSURE( 6 == a1.getCount(), "not all properties inserted" ); + Sequence< Property > aProps = a1.getProperties(); + Property * pP = aProps.getArray(); + OSL_ENSURE( 6 == aProps.getLength(), "getProperties() gives not all properties" ); + for( int i = 0; i < 6; i++ ) + { + OSL_ENSURE( pP[i].Name == getPropertyTable1()[i].Name , "Name not correct" ); + OSL_ENSURE( pP[i].Handle == getPropertyTable1()[i].Handle, "Handle not correct" ); + OSL_ENSURE( pP[i].Attributes == getPropertyTable1()[i].Attributes, "Attributes not correct" ); + OSL_ENSURE( pP[i].Type == getPropertyTable1()[i].Type, "Type not correct" ); + } + } + + // Test sorting + { + OPropertyArrayHelper a1( getPropertyTable2(), 6, sal_False ); + Sequence< Property > aProps = a1.getProperties(); + Property * pP = aProps.getArray(); + OSL_ENSURE( 6 == aProps.getLength(), "getProperties() gives not all properties" ); + + // table to switch to sorted + int a[] = { 2 , 1 , 4, 3, 5, 0 }; + for( int i = 0; i < 6; i++ ) + { + OSL_ENSURE( pP[i].Name == getPropertyTable2()[a[i]].Name , "Name not correct" ); + OSL_ENSURE( pP[i].Handle == getPropertyTable2()[a[i]].Handle, "Handle not correct" ); + OSL_ENSURE( pP[i].Attributes == getPropertyTable2()[a[i]].Attributes, "Attributes not correct" ); + OSL_ENSURE( pP[i].Type == getPropertyTable2()[a[i]].Type, "Type not correct" ); + } + } + + // Test sorting + { + OPropertyArrayHelper a1( getPropertyTable3(), 3, sal_False ); + Sequence< Property > aProps = a1.getProperties(); + Property * pP = aProps.getArray(); + OSL_ENSURE( 3 == aProps.getLength(), "getProperties() gives not all properties" ); + // table to switch to sorted + int a[] = { 2 , 0 , 1 }; + for( int i = 0; i < 3; i++ ) + { + OSL_ENSURE( pP[i].Name == getPropertyTable3()[a[i]].Name , "Name not correct" ); + OSL_ENSURE( pP[i].Handle == getPropertyTable3()[a[i]].Handle, "Handle not correct" ); + OSL_ENSURE( pP[i].Attributes == getPropertyTable3()[a[i]].Attributes, "Attributes not correct" ); + OSL_ENSURE( pP[i].Type == getPropertyTable3()[a[i]].Type, "Type not correct" ); + } + } + + // Test getPropertyByName and hasPropertyByName + { + OPropertyArrayHelper a1( getPropertyTable1(), 6 ); + for( int i = 0; i < 6; i++ ) + { + OSL_ENSURE( a1.hasPropertyByName( getPropertyTable1()[i].Name ), "hasPropertyByName not correct" ); + Property aP = a1.getPropertyByName( getPropertyTable1()[i].Name ); + OSL_ENSURE( aP.Name == getPropertyTable1()[i].Name , "Name not correct" ); + OSL_ENSURE( aP.Handle == getPropertyTable1()[i].Handle, "Handle not correct" ); + OSL_ENSURE( aP.Attributes == getPropertyTable1()[i].Attributes, "Attributes not correct" ); + OSL_ENSURE( aP.Type == getPropertyTable1()[i].Type, "Type not correct" ); + } + + OSL_ENSURE( !a1.hasPropertyByName( OUString( RTL_CONSTASCII_USTRINGPARAM("never exist") ) ), "hasPropertyByName not correct" ); + try + { + a1.getPropertyByName( OUString( RTL_CONSTASCII_USTRINGPARAM("never exist") ) ); + OSL_ENSURE( sal_False, "exeption not thrown" ); + } + catch( UnknownPropertyException & ) + { + } + } + + // Test getHandleByName + { + OPropertyArrayHelper a1( getPropertyTable1(), 6 ); + for( int i = 0; i < 6; i++ ) + { + sal_Int32 Handle = a1.getHandleByName( getPropertyTable1()[i].Name ); + OSL_ENSURE( Handle == getPropertyTable1()[i].Handle, "Handle not correct" ); + } + sal_Int32 Handle = a1.getHandleByName( OUString( RTL_CONSTASCII_USTRINGPARAM("asdaf") ) ); + OSL_ENSURE( Handle == -1, "Handle not correct" ); + } + + // Test fillPropertyMembersByHandle + { + OPropertyArrayHelper a1( getPropertyTable1(), 6 ); + int i; + for( i = 0; i < 6; i++ ) + { + sal_Int16 nAttributes; + OUString aPropName; + sal_Bool b = a1.fillPropertyMembersByHandle( &aPropName, &nAttributes, getPropertyTable1()[i].Handle ); + OSL_ENSURE( b, "fillPropertyMembersByHandle: handle not found" ); + OSL_ENSURE( nAttributes == getPropertyTable1()[i].Attributes, "fillPropertyMembersByHandle: Attributes not correct" ); + OSL_ENSURE( aPropName == getPropertyTable1()[i].Name , "fillPropertyMembersByHandle: Name not correct" ); + } + OSL_ENSURE( !a1.fillPropertyMembersByHandle( NULL, NULL, 66666 ), "fillPropertyMembersByHandle: handle found" ); + // optimized table + OPropertyArrayHelper a4( getPropertyTable4(), 3 ); + for( i = 0; i < 3; i++ ) + { + sal_Int16 nAttributes; + OUString aPropName; + sal_Bool b = a1.fillPropertyMembersByHandle( &aPropName, &nAttributes, getPropertyTable4()[i].Handle ); + OSL_ENSURE( b, "fillPropertyMembersByHandle: handle not found" ); + OSL_ENSURE( nAttributes == getPropertyTable1()[i].Attributes, "fillPropertyMembersByHandle: Attributes not correct" ); + OSL_ENSURE( aPropName == getPropertyTable1()[i].Name , "fillPropertyMembersByHandle: Name not correct" ); + } + OSL_ENSURE( !a4.fillPropertyMembersByHandle( NULL, NULL, 66666 ), "fillPropertyMembersByHandle: handle found" ); + } + + // Test fillHandles + { + OPropertyArrayHelper a1( getPropertyTable1(), 6 ); + Sequence< OUString > aS( 4 ); + sal_Int32 Handles[4]; + // muss sortiert sein + aS.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("a") ); + aS.getArray()[1] = OUString( RTL_CONSTASCII_USTRINGPARAM("d") ); + aS.getArray()[2] = OUString( RTL_CONSTASCII_USTRINGPARAM("f") ); + aS.getArray()[3] = OUString( RTL_CONSTASCII_USTRINGPARAM("t") ); + sal_Int32 nHitCount = a1.fillHandles( Handles, aS ); + OSL_ENSURE( nHitCount == 3, "wrong number of hits " ); + OSL_ENSURE( Handles[0] == getPropertyTable1()[0].Handle, "Handle not correct" ); + OSL_ENSURE( Handles[1] == getPropertyTable1()[3].Handle, "Handle not correct" ); + OSL_ENSURE( Handles[2] == getPropertyTable1()[5].Handle, "Handle not correct" ); + OSL_ENSURE( Handles[3] == -1, "Handle not correct" ); + } +} + + + + +//---------------------------------------------------- +// test_OPropertySetHelper +//---------------------------------------------------- +struct MutexContainer +{ + Mutex aMutex; +}; +class test_OPropertySetHelper : + public MutexContainer, + public OBroadcastHelper , + public OPropertySetHelper, + public OWeakObject +{ +public: + + test_OPropertySetHelper( Property * p, sal_Int32 n ) + : MutexContainer() + , OBroadcastHelper( ((MutexContainer *)this)->aMutex ) +// , OPropertySetHelper( *SAL_STATIC_CAST(OBroadcastHelper *,this)) + // MSCI 4 bug ! : + // OBroadcastHelper == OBroadcastHelperVar<OMultiTypeInterfaceContainerHelper> + , OPropertySetHelper( + *SAL_STATIC_CAST(OBroadcastHelper *,this)) + , bBOOL( sal_False ) + , nINT16( 0 ) + , nINT32( 0 ) + , pBasicProps( p ) + , nPropCount( n ) + { + } + + + ~test_OPropertySetHelper() + { + } + + void dispose() + { + // see comphlp.cxx + sal_Bool bDoDispose = sal_False; + { + MutexGuard aGuard( rBHelper.rMutex ); + if( !rBHelper.bDisposed && !rBHelper.bInDispose ) + { + rBHelper.bInDispose = sal_True; + bDoDispose = sal_True; + } + } + if( bDoDispose ) + { + disposing(); + EventObject aEvt; + aEvt.Source = Reference < XInterface > ( SAL_STATIC_CAST( OWeakObject * ,this) ); + + rBHelper.aLC.disposeAndClear( aEvt ); + rBHelper.bDisposed = sal_True; + rBHelper.bInDispose = sal_False; + } + } + + // XInterface + Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(RuntimeException) + { + Any aRet( OPropertySetHelper::queryInterface( rType ) ); + return (aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType )); + } + void SAL_CALL acquire() throw() + { OWeakObject::acquire(); } + void SAL_CALL release() throw() + { OWeakObject::release(); } + + // XPropertySet + Reference < XPropertySetInfo > SAL_CALL getPropertySetInfo()throw(RuntimeException); + + using OPropertySetHelper::getFastPropertyValue; + + sal_Bool bBOOL; + sal_Int16 nINT16; + sal_Int32 nINT32; + Property * pBasicProps; + sal_Int32 nPropCount; +protected: + IPropertyArrayHelper & SAL_CALL getInfoHelper() throw(RuntimeException); + sal_Bool SAL_CALL convertFastPropertyValue( + Any & rConvertedValue, Any & rOldValue, + sal_Int32 nHandle, const Any& rValue ) + throw(IllegalArgumentException); + void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const Any& rValue ) throw(RuntimeException); + void SAL_CALL getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const throw(RuntimeException); +}; + +//---------------------------------------------------------------------- +//------ The Properties of this implementation ------------------------- +//---------------------------------------------------------------------- +// Id must be the index into the array +#define PROPERTY_BOOL 0 +#define PROPERTY_INT16 1 +#define PROPERTY_INT32 2 + +// Max number of properties +#define PROPERTY_COUNT 4 +// Names of Properties +/** + * All Properties of this implementation. Must be sorted by name. + */ +Property * getBasicProps() +{ + static Property *pTable = 0; + + if( ! pTable ) { + MutexGuard guard( ::osl::Mutex::getGlobalMutex() ); + if( ! pTable ) { + + static Property aBasicProps[PROPERTY_COUNT] = + { + Property( OUString( RTL_CONSTASCII_USTRINGPARAM("BOOL") ) , PROPERTY_BOOL , getCppuBooleanType(), PropertyAttribute::READONLY ), + Property( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ) , PROPERTY_INT16, + getCppuType( (sal_Int16*)0 ), PropertyAttribute::BOUND | PropertyAttribute::CONSTRAINED ), + Property( OUString( RTL_CONSTASCII_USTRINGPARAM("INT32") ) , PROPERTY_INT32, getCppuType( (sal_Int32*)0 ), PropertyAttribute::BOUND ), + Property( OUString( RTL_CONSTASCII_USTRINGPARAM("TEST") ) , 55 , getCppuType( (sal_Int32*)0), PropertyAttribute::BOUND ) + }; + pTable = aBasicProps; + } + } + return pTable; +} + + +//---------------------------------------------------- +// test_OPropertySetHelper_Listener +//---------------------------------------------------- +class test_OPropertySetHelper_Listener + : public WeakImplHelper3< XPropertyChangeListener, XPropertiesChangeListener, XVetoableChangeListener > +{ +public: + sal_Int32 nDisposing; + Mutex aMutex; + Any * pExceptedListenerValues; + sal_Int32 nCount; + sal_Int32 nCurrent; + + test_OPropertySetHelper_Listener( Any * p = 0, sal_Int32 n = 0 ) + : nDisposing( 0 ) + , pExceptedListenerValues( p ) + , nCount( n ) + , nCurrent( 0 ) + { + } + ~test_OPropertySetHelper_Listener() + { + } + + sal_Int32 getRefCount() + { return m_refCount; } + + // XEventListener + void SAL_CALL disposing(const EventObject& /*evt*/) throw ( RuntimeException) + { + MutexGuard aGuard( aMutex ); + nDisposing++; + } + + // XPropertyChangeListener + void SAL_CALL propertyChange(const PropertyChangeEvent& evt) throw (RuntimeException) + { + if( !pExceptedListenerValues ) + return; + MutexGuard aGuard( aMutex ); + OSL_ENSURE( nCurrent +1 < nCount, "PropertySetHelper: too many listener calls" ); + + switch( evt.PropertyHandle ) + { + case PROPERTY_BOOL: + { + OSL_ENSURE( sal_False , "PropertySetHelper: BOOL cannot change" ); + OSL_ENSURE( evt.PropertyName == OUString( RTL_CONSTASCII_USTRINGPARAM("BOOL") ), "PropertySetHelper: wrong name" ); + } + break; + + case PROPERTY_INT16: + { + OSL_ENSURE( evt.PropertyName == OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), "PropertySetHelper: wrong name" ); + + OSL_ENSURE( pExceptedListenerValues[nCurrent].getValueType().getTypeClass() == TypeClass_SHORT , + "PropertySetHelper: wrong data type" ); + + sal_Int16 nInt16, nOldInt16; + pExceptedListenerValues[nCurrent] >>= nInt16; + evt.OldValue >>= nOldInt16; + OSL_ENSURE( nInt16 == nOldInt16, "PropertySetHelper: wrong old value" ); + + + pExceptedListenerValues[nCurrent+1] >>= nInt16; + evt.NewValue >>= nOldInt16; + OSL_ENSURE( nInt16 == nOldInt16 , "PropertySetHelper: wrong new value" ); + } + break; + + case PROPERTY_INT32: + { + OSL_ENSURE( evt.PropertyName == OUString( RTL_CONSTASCII_USTRINGPARAM("INT32") ), "PropertySetHelper: wrong name" ); + + sal_Int32 nInt32,nOldInt32; + + pExceptedListenerValues[nCurrent] >>= nInt32; + evt.OldValue >>= nOldInt32; + OSL_ENSURE( nInt32 == nOldInt32 , "PropertySetHelper: wrong old value" ); + + pExceptedListenerValues[nCurrent+1] >>= nInt32; + evt.NewValue >>= nOldInt32; + OSL_ENSURE( nInt32 == nOldInt32 , "PropertySetHelper: wrong new value" ); + } + break; + + default: + OSL_ENSURE( sal_False, "XPropeSetHelper: invalid property handle" ); + } + nCurrent += 2; + } + + // XVetoableChangeListener + void SAL_CALL vetoableChange(const PropertyChangeEvent& evt) throw (PropertyVetoException, RuntimeException) + { + if( !pExceptedListenerValues ) + return; + MutexGuard aGuard( aMutex ); + OSL_ENSURE( nCurrent +1 < nCount, "PropertySetHelper: too many listener calls" ); + + switch( evt.PropertyHandle ) + { + case PROPERTY_BOOL: + { + OSL_ENSURE( sal_False , "PropertySetHelper: BOOL cannot change" ); + OSL_ENSURE( evt.PropertyName == OUString( RTL_CONSTASCII_USTRINGPARAM("BOOL") ), "PropertySetHelper: wrong name" ); + } + break; + + case PROPERTY_INT16: + { + OSL_ENSURE( evt.PropertyName == OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), "PropertySetHelper: wrong name" ); + + sal_Int16 nInt16, nOldInt16; + pExceptedListenerValues[nCurrent] >>= nInt16; + evt.OldValue >>= nOldInt16; + + OSL_ENSURE( nInt16 == nOldInt16,"PropertySetHelper: wrong old value" ); + + pExceptedListenerValues[nCurrent+1] >>= nInt16; + evt.NewValue >>= nOldInt16; + OSL_ENSURE( nInt16 == nOldInt16 , "PropertySetHelper: wrong new value" ); + + if( nOldInt16 == 100 ) + { + nCurrent += 2; + throw PropertyVetoException(); + } + } + break; + + case PROPERTY_INT32: + { + OSL_ENSURE( evt.PropertyName == OUString( RTL_CONSTASCII_USTRINGPARAM("INT32") ), "PropertySetHelper: wrong name" ); + + sal_Int32 nInt32,nOldInt32; + pExceptedListenerValues[nCurrent] >>= nInt32; + evt.OldValue >>= nOldInt32; + OSL_ENSURE( nInt32 == nOldInt32 , "PropertySetHelper: wrong old value" ); + + pExceptedListenerValues[nCurrent+1] >>= nInt32; + evt.NewValue >>= nOldInt32; + OSL_ENSURE( nInt32 == nOldInt32 , "PropertySetHelper: wrong new value" ); + } + break; + + default: + OSL_ENSURE( sal_False, "XPropeSetHelper: invalid property handle" ); + } + nCurrent += 2; + } + + // XPropertiesChangeListener + void SAL_CALL propertiesChange(const Sequence< PropertyChangeEvent >& evtSeq) throw (RuntimeException) + { + if( !pExceptedListenerValues ) + return; + MutexGuard aGuard( aMutex ); + for( sal_Int32 i = 0; i < evtSeq.getLength(); i++ ) + { + const PropertyChangeEvent & evt = evtSeq.getConstArray()[i]; + OSL_ENSURE( nCurrent +1 < nCount, "PropertySetHelper: too many listener calls" ); + + switch( evt.PropertyHandle ) + { + case PROPERTY_BOOL: + { + OSL_ENSURE( sal_False, "PropertySetHelper: BOOL cannot change" ); + OSL_ENSURE( evt.PropertyName == OUString( RTL_CONSTASCII_USTRINGPARAM("BOOL") ), "PropertySetHelper: wrong name" ); + } + break; + + case PROPERTY_INT16: + { + OSL_ENSURE( evt.PropertyName == OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), "PropertySetHelper: wrong name" ); + + sal_Int16 nInt16, nOldInt16; + pExceptedListenerValues[nCurrent] >>= nInt16; + evt.OldValue >>= nOldInt16; + OSL_ENSURE( nInt16 == nOldInt16 , "PropertySetHelper: wrong old value" ); + + + pExceptedListenerValues[nCurrent+1] >>= nInt16; + evt.NewValue >>= nOldInt16; + OSL_ENSURE( nInt16 == nOldInt16 , "PropertySetHelper: wrong new value" ); + } + break; + + case PROPERTY_INT32: + { + OSL_ENSURE( evt.PropertyName == OUString( RTL_CONSTASCII_USTRINGPARAM("INT32") ), "PropertySetHelper: wrong name" ); + + + sal_Int32 nInt32,nOldInt32; + pExceptedListenerValues[nCurrent] >>= nInt32; + evt.OldValue >>= nOldInt32; + OSL_ENSURE( nInt32 == nOldInt32 , "PropertySetHelper: wrong old value" ); + + pExceptedListenerValues[nCurrent+1] >>= nInt32; + evt.NewValue >>= nOldInt32; + OSL_ENSURE( nInt32 == nOldInt32 , "PropertySetHelper: wrong new value" ); + } + break; + + default: + OSL_ENSURE( sal_False, "XPropeSetHelper: invalid property handle" ); + } + nCurrent += 2; + } + } +}; + +/** + * Create a table that map names to index values. + */ +IPropertyArrayHelper & test_OPropertySetHelper::getInfoHelper() throw(RuntimeException) +{ + // no multi thread protection + static OPropertyArrayHelper aInfo( pBasicProps, nPropCount ); + return aInfo; +} + +// XPropertySet +Reference < XPropertySetInfo > test_OPropertySetHelper::getPropertySetInfo() + throw(RuntimeException) +{ + // no multi thread protection + static Reference < XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) ); + return xInfo; +} + +// Return sal_True, value changed +sal_Bool test_OPropertySetHelper::convertFastPropertyValue +( + Any & rConvertedValue, + Any & rOldValue, + sal_Int32 nHandle, + const Any& rValue +)throw(IllegalArgumentException) +{ + switch( nHandle ) + { + case PROPERTY_BOOL: + { + sal_Bool b; + convertPropertyValue( b , rValue ); + if( b != bBOOL ) + { + + rConvertedValue.setValue( &b , ::getCppuBooleanType() ); + rOldValue.setValue( & bBOOL , ::getCppuBooleanType() ); + return sal_True; + } + else + return sal_False; + } + + case PROPERTY_INT16: + { + sal_Int16 n16; + convertPropertyValue( n16 , rValue ); + + if( n16 != nINT16 ) + { + rConvertedValue <<= n16; + rOldValue <<= nINT16; + return sal_True; + } + else + return sal_False; + } + + case PROPERTY_INT32: + { + sal_Int32 n32; + convertPropertyValue( n32 , rValue ); + if( n32 != nINT32 ) + { + rConvertedValue <<= n32; + rOldValue <<= nINT32; + return sal_True; + } + else + return sal_False; + } + + default: + OSL_ENSURE( nHandle == -1, "invalid property handle" ); + return sal_False; + } +} + +/** + * only set the value. + */ +void test_OPropertySetHelper::setFastPropertyValue_NoBroadcast +( + sal_Int32 nHandle, + const Any& rValue +)throw(RuntimeException) +{ + switch( nHandle ) + { + case PROPERTY_BOOL: + OSL_ENSURE( rValue.getValueType().getTypeClass() == TypeClass_BOOLEAN, "invalid type" ); + bBOOL = *((sal_Bool*)rValue.getValue()); + break; + + case PROPERTY_INT16: + OSL_ENSURE( rValue.getValueType().getTypeClass() == TypeClass_SHORT, "invalid type" ); + rValue >>= nINT16; + break; + + case PROPERTY_INT32: + OSL_ENSURE( rValue.getValueType().getTypeClass() == TypeClass_LONG, "invalid type" ); + rValue >>= nINT32; + break; + + default: + OSL_ENSURE( nHandle == -1, "invalid property handle" ); + } +} + +//-------------------------- +void test_OPropertySetHelper::getFastPropertyValue( Any & rRet, sal_Int32 nHandle ) const + throw(RuntimeException) +{ + switch( nHandle ) + { + case PROPERTY_BOOL: + rRet.setValue( &bBOOL , getCppuBooleanType() ); + break; + + case PROPERTY_INT16: + rRet <<= nINT16; + break; + + case PROPERTY_INT32: + rRet <<= nINT32; + break; + + default: + OSL_ENSURE( nHandle == -1, "invalid property handle" ); + } +} + + +void test_PropertySetHelper() +{ + test_PropertyArrayHelper(); + + test_OPropertySetHelper * pPS; + + Reference < XPropertySet > xPS; + Reference < XPropertyChangeListener > xPS_L; + test_OPropertySetHelper_Listener * pPS_L; + + Reference < XInterface > x; + + for( int z = 0; z < 2; z++ ) + { + // first test aBasicProps Handles are { 0, 1, 2, 55 } + // first test getBasicProps() Handles are { 0, 1, 2 } + xPS = pPS = new test_OPropertySetHelper( getBasicProps(), PROPERTY_COUNT - z ); + xPS_L = static_cast< XPropertyChangeListener * >( pPS_L = new test_OPropertySetHelper_Listener() ); + + // Test queryInterface + Reference < XPropertySet > rProp( xPS , UNO_QUERY ); + OSL_ENSURE( rProp.is() , "PropertySetHelper: XPropertySet nor supported" ); + + Reference < XMultiPropertySet > rMulti( xPS , UNO_QUERY ); + OSL_ENSURE( rMulti.is() , "PropertySetHelper: XMultiPropertySet nor supported" ); + + Reference < XFastPropertySet > rFast( xPS , UNO_QUERY ); + OSL_ENSURE( rFast.is() , "PropertySetHelper: XFastPropertySet nor supported" ); + + x = Reference < XInterface > (); + + // Test add-remove listener + { + Reference < XPropertiesChangeListener > x1( xPS_L, UNO_QUERY ); + Reference < XVetoableChangeListener > x2( xPS_L, UNO_QUERY ); + + xPS->addPropertyChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), xPS_L ); + Sequence<OUString> szPN( 3 ); + szPN.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("BOOL") ); + szPN.getArray()[1] = OUString( RTL_CONSTASCII_USTRINGPARAM("INT32") ); + szPN.getArray()[2] = OUString( RTL_CONSTASCII_USTRINGPARAM("Does not exist") ); // must ne ignored by the addPropertiesChangeListener method + pPS->addPropertiesChangeListener( szPN, x1 ); + + szPN = Sequence<OUString>(); + pPS->addPropertiesChangeListener( szPN, x1 ); + pPS->addVetoableChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), x2 ); + + xPS->removePropertyChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), xPS_L ); + pPS->removePropertiesChangeListener( x1 ); + pPS->removePropertiesChangeListener( x1 ); + pPS->removeVetoableChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), x2 ); + + // this exception must thrown + try + { + xPS->addPropertyChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("Does not exist") ), xPS_L ); + OSL_ENSURE( sal_False, "PropertySetHelper: exeption not thrown" ); + } + catch( UnknownPropertyException & /*e*/ ) + { + + } + + try + { + xPS->addVetoableChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("Does not exist") ), x2 ); + OSL_ENSURE( sal_False, "PropertySetHelper: exeption not thrown" ); + } + catch( UnknownPropertyException & /*e*/ ) + { + + } + + } + OSL_ENSURE( pPS_L->getRefCount() == 1, "PropertySetHelper: wrong reference count" ); + + // Test disposing + { + Reference < XPropertiesChangeListener > x1( xPS_L, UNO_QUERY ); + Reference < XVetoableChangeListener > x2( xPS_L, UNO_QUERY ); + + xPS->addPropertyChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), xPS_L ); + Sequence<OUString> szPN( 2 ); + szPN.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("BOOL") ); + szPN.getArray()[1] = OUString( RTL_CONSTASCII_USTRINGPARAM("INT32") ); + pPS->addPropertiesChangeListener( szPN, x1 ); + szPN = Sequence<OUString>(); + pPS->addPropertiesChangeListener( szPN, x1 ); + pPS->addVetoableChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), x2 ); + pPS->dispose(); + } + OSL_ENSURE( pPS_L->nDisposing == 4 , "PropertySetHelper: wrong disposing count" ); + OSL_ENSURE( pPS_L->getRefCount() == 1 , "PropertySetHelper: wrong reference count" ); + pPS_L->nDisposing = 0; + xPS = pPS = new test_OPropertySetHelper( getBasicProps(), PROPERTY_COUNT - z ); + + // Test set- and get- (Fast) propertyValue + { + // set read only property + try + { + // Readonly raises a vetoable exception + sal_Bool b = sal_True; + Any aBool; + aBool.setValue( &b , getCppuBooleanType() ); + xPS->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("BOOL") ), aBool ); + OSL_ENSURE( sal_False, "PropertySetHelper: exeption not thrown" ); + } + catch( PropertyVetoException & /*e*/ ) + { + } + + try + { + // Readonly raises a vetoable exception + sal_Bool b = sal_True; + Any aBool; + aBool.setValue( &b , getCppuBooleanType() ); + // BOOL i s0 + pPS->setFastPropertyValue( PROPERTY_BOOL, aBool ); + OSL_ENSURE( sal_False, "PropertySetHelper: exeption not thrown" ); + } + catch( PropertyVetoException & /*e*/ ) + { + } + + // set unknown property + try + { + sal_Bool b = sal_True; + Any aBool; + aBool.setValue( &b , getCppuBooleanType() ); + xPS->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("Does not exist") ), aBool ); + OSL_ENSURE( sal_False, "PropertySetHelper: exeption not thrown" ); + } + catch( UnknownPropertyException & /*e*/ ) + { + } + + try + { + sal_Bool b = sal_True; + Any aBool; + aBool.setValue( &b , getCppuBooleanType() ); + pPS->setFastPropertyValue( 3, aBool ); + OSL_ENSURE( sal_False, "PropertySetHelper: exeption not thrown" ); + } + catch( UnknownPropertyException & /*e*/ ) + { + } + + // get unknown property + try + { + Any aBool; + aBool = xPS->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("Does not exist") ) ); + OSL_ENSURE( sal_False, "PropertySetHelper: exeption not thrown" ); + } + catch( UnknownPropertyException & /*e*/ ) + { + } + + try + { + Any aBool; + aBool = ((XFastPropertySet *)pPS)->getFastPropertyValue( 3 ); + OSL_ENSURE( sal_False, "PropertySetHelper: exeption not thrown" ); + } + catch( UnknownPropertyException & /*e*/ ) + { + } + + // set property with invalid type + try + { + Any aBool; + xPS->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("INT32") ), aBool ); + OSL_ENSURE( sal_False, "PropertySetHelper: exeption not thrown" ); + } + catch( IllegalArgumentException & /*e*/ ) + { + } + + try + { + Any aBool; + pPS->setFastPropertyValue( PROPERTY_INT32, aBool ); + OSL_ENSURE( sal_False, "PropertySetHelper: exeption not thrown" ); + } + catch( IllegalArgumentException & /*e*/ ) + { + } + + // narrowing conversion is not allowed! + try + { + Any aINT32; + aINT32 <<= (sal_Int32 ) 16; + xPS->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), aINT32 ); + OSL_ENSURE( sal_False, "PropertySetHelper: exeption not thrown" ); + } + catch( IllegalArgumentException & /*e*/ ) + { + } + + + try + { + Any aINT32; + aINT32 <<= (sal_Int32) 16; + pPS->setFastPropertyValue( PROPERTY_INT16, aINT32 ); + OSL_ENSURE( sal_False, "PropertySetHelper: exeption not thrown" ); + } + catch( IllegalArgumentException & /*e*/ ) + { + } + + + Any aValue; + aValue = xPS->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("BOOL") ) ); + sal_Bool b = *( (sal_Bool*)aValue.getValue()); + OSL_ENSURE( ! b, "PropertySetHelper: wrong BOOL value" ); + aValue = ((XFastPropertySet *)pPS)->getFastPropertyValue( PROPERTY_BOOL ); + + b = *((sal_Bool*)aValue.getValue()); + OSL_ENSURE( !b, "PropertySetHelper: wrong BOOL value" ); + + sal_Int16 n16; + aValue <<=(sal_Int16)22; + xPS->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), aValue ); + aValue = xPS->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ) ); + aValue >>= n16; + OSL_ENSURE( 22 == n16 , "PropertySetHelper: wrong INT16 value" ); + aValue <<= (sal_Int16)44; + ((XFastPropertySet *)pPS)->setFastPropertyValue( PROPERTY_INT16, aValue ); + + aValue = ((XFastPropertySet *)pPS)->getFastPropertyValue( PROPERTY_INT16 ); + aValue >>= n16; + OSL_ENSURE( 44 == n16, "PropertySetHelper: wrong INT16 value" ); + + // widening conversion + aValue <<= (sal_Int16)55; + xPS->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("INT32") ), aValue ); + aValue = xPS->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("INT32") ) ); + sal_Int32 n32; + aValue >>= n32; + OSL_ENSURE( 55 == n32 , "PropertySetHelper: wrong INT32 value" ); + aValue <<= (sal_Int16)66; + ((XFastPropertySet *)pPS)->setFastPropertyValue( PROPERTY_INT32, aValue ); + aValue = ((XFastPropertySet *)pPS)->getFastPropertyValue( PROPERTY_INT32 ); + aValue >>= n32; + OSL_ENSURE( 66 == n32, "PropertySetHelper: wrong INT32 value" ); + + Sequence< OUString >valueNames = Sequence<OUString>( 3 ); + valueNames.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("BOOL") ); + valueNames.getArray()[1] = OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ); + valueNames.getArray()[2] = OUString( RTL_CONSTASCII_USTRINGPARAM("INT32") ); + Sequence< Any > aValues = pPS->getPropertyValues( valueNames ); + + b = *((sal_Bool*)aValues.getConstArray()[0].getValue()); + aValues.getConstArray()[1] >>= n16; + aValues.getConstArray()[2] >>= n32; + + OSL_ENSURE( !b, "PropertySetHelper: wrong BOOL value" ); + OSL_ENSURE( 44 == n16, "PropertySetHelper: wrong INT16 value" ); + OSL_ENSURE( 66 == n32, "PropertySetHelper: wrong INT32 value" ); + } + pPS->nINT32 = 0; + pPS->nINT16 = 0; + + // Test add-remove listener + { + Reference < XVetoableChangeListener > x2( xPS_L, UNO_QUERY ); + + xPS->addPropertyChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), xPS_L ); + pPS->addVetoableChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), x2 ); + + pPS_L->nCount = 10; + Sequence< Any > aSeq( pPS_L->nCount ); + pPS_L->nCurrent = 0; + + pPS_L->pExceptedListenerValues = aSeq.getArray(); + + pPS_L->pExceptedListenerValues[0] <<= (sal_Int16) 0; // old value vetoable + pPS_L->pExceptedListenerValues[1] <<= (sal_Int16) 22; // new value vetoable + pPS_L->pExceptedListenerValues[2] <<= (sal_Int16) 0; // old value bound + pPS_L->pExceptedListenerValues[3] <<= (sal_Int16) 22; // new value bound + pPS_L->pExceptedListenerValues[4] <<= (sal_Int16) 22; // old value vetoable + pPS_L->pExceptedListenerValues[5] <<= (sal_Int16) 44; // new value vetoable + pPS_L->pExceptedListenerValues[6] <<= (sal_Int16) 22; // old value bound + pPS_L->pExceptedListenerValues[7] <<= (sal_Int16) 44; // new value bound + pPS_L->pExceptedListenerValues[8] <<= (sal_Int16) 44; // old value vetoable + pPS_L->pExceptedListenerValues[9] <<= (sal_Int16) 100; // new value vetoable exception + + Any aValue; + aValue <<= (sal_Int16)22; + xPS->setPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), aValue ); + aValue <<= (sal_Int16) 44; + ((XFastPropertySet *)pPS)->setFastPropertyValue( PROPERTY_INT16, aValue ); + aValue <<= (sal_Int16)100;// exception + + try + { + ((XFastPropertySet *)pPS)->setFastPropertyValue( PROPERTY_INT16, aValue ); + OSL_ENSURE( sal_False, "PropertySetHelper: exeption not thrown" ); + } + catch( PropertyVetoException & /*e*/ ) + { + } + + OSL_ENSURE( pPS_L->nCount == pPS_L->nCurrent, "not all listeners called" ); + pPS->nINT32 = 0; + pPS->nINT16 = 0; + pPS_L->nCount = 0; + pPS_L->nCurrent = 0; + pPS_L->pExceptedListenerValues = NULL; + xPS->removePropertyChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), xPS_L ); + pPS->removeVetoableChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), x2 ); + } + + // Test multi property set listener + { + Reference < XPropertiesChangeListener > x1( xPS_L, UNO_QUERY ); + Reference < XVetoableChangeListener > x2( xPS_L, UNO_QUERY ); + + pPS->addVetoableChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ) , x2 ); + Sequence<OUString> szPN( 4 ); + szPN.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("BOOL") ); + szPN.getArray()[1] = OUString( RTL_CONSTASCII_USTRINGPARAM("INT32") ); + szPN.getArray()[2] = OUString( RTL_CONSTASCII_USTRINGPARAM("Does not exist") ); // must ne ignored by the addPropertiesChangeListener method + szPN.getArray()[3] = OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ); + pPS->addPropertiesChangeListener( szPN, x1 ); + + pPS_L->nCount = 6; + Sequence< Any > aSeq( pPS_L->nCount ); + pPS_L->nCurrent = 0; + pPS_L->pExceptedListenerValues = aSeq.getArray(); + pPS_L->pExceptedListenerValues[0] <<= (sal_Int16) 0; // old value vetoable + pPS_L->pExceptedListenerValues[1] <<= (sal_Int16 ) 22; // new value vetoable + // INT32 is not constrained + pPS_L->pExceptedListenerValues[2] <<= (sal_Int16) 0; // old value bound + pPS_L->pExceptedListenerValues[3] <<= (sal_Int16) 22; // new value bound + pPS_L->pExceptedListenerValues[4] <<= (sal_Int32) 0; // old value bound + pPS_L->pExceptedListenerValues[5] <<= (sal_Int32) 44; // new value bound + + szPN = Sequence<OUString>( 2 ); + szPN.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ); + szPN.getArray()[1] = OUString( RTL_CONSTASCII_USTRINGPARAM("INT32") ); + Sequence< Any > aValues( 2 ); + aValues.getArray()[0] <<= (sal_Int16) 22; + aValues.getArray()[1] <<= (sal_Int16) 44; + pPS->setPropertyValues( szPN, aValues ); + OSL_ENSURE( pPS_L->nCount == pPS_L->nCurrent, "not all listeners called" ); + + //firePropertiesChangeEvent + pPS->nINT16 = 8; + pPS->nINT32 = 5; + pPS_L->nCount = 4; + pPS_L->nCurrent = 0; + pPS_L->pExceptedListenerValues[0] <<= (sal_Int16) 8; // old value + pPS_L->pExceptedListenerValues[1] <<= (sal_Int16) 8; // new value + pPS_L->pExceptedListenerValues[2] <<= (sal_Int32) 5; // old value + pPS_L->pExceptedListenerValues[3] <<= (sal_Int32) 5; // new value + pPS->firePropertiesChangeEvent( szPN, pPS_L ); + OSL_ENSURE( pPS_L->nCount == pPS_L->nCurrent, "not all listeners called" ); + + + //vetoable exception with multible + szPN.getArray()[0] = OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ); + szPN.getArray()[1] = OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ); + pPS->nINT32 = 0; + pPS->nINT16 = 0; + pPS_L->nCount = 4; + pPS_L->nCurrent = 0; + pPS_L->pExceptedListenerValues[0] <<= (sal_Int16) 0; // old value vetoable + pPS_L->pExceptedListenerValues[1] <<= (sal_Int16) 44; // new value vetoable + pPS_L->pExceptedListenerValues[2] <<= (sal_Int16) 0; // old value vetoable + pPS_L->pExceptedListenerValues[3] <<= (sal_Int16) 100; // new value vetoable + + try + { + aValues.getArray()[0] <<= (sal_Int16)44; + aValues.getArray()[1] <<= (sal_Int16)100; + pPS->setPropertyValues( szPN, aValues ); + OSL_ENSURE( sal_False, "PropertySetHelper: exeption not thrown" ); + } + catch ( PropertyVetoException & /*e*/ ) + { + } + + OSL_ENSURE( pPS_L->nCount == pPS_L->nCurrent, "not all listeners called" ); + pPS->removePropertiesChangeListener( x1 ); + pPS->removeVetoableChangeListener( OUString( RTL_CONSTASCII_USTRINGPARAM("INT16") ), x2 ); + } + } +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/test/testproptyphlp.cxx b/cppuhelper/test/testproptyphlp.cxx new file mode 100644 index 000000000000..852fa33ba09f --- /dev/null +++ b/cppuhelper/test/testproptyphlp.cxx @@ -0,0 +1,87 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_cppuhelper.hxx" +#include <cppuhelper/proptypehlp.hxx> + +#include <com/sun/star/beans/Property.hpp> + +using namespace ::com::sun::star::uno; +using namespace ::cppu; + +void testPropertyTypeHelper() +{ + Any a; + + a <<= ( sal_Int8 ) 25; + + sal_Int32 i; + convertPropertyValue( i , a ); + OSL_ASSERT( 25 == i ); + + sal_Int16 i16; + convertPropertyValue( i16 , a ); + OSL_ASSERT( 25 == i16 ); + + sal_Int8 i8; + convertPropertyValue( i8 , a ); + OSL_ASSERT( 25 == i8 ); + + sal_uInt32 i32; + convertPropertyValue( i32 , a ); + OSL_ASSERT( 25 == i32 ); + + double d; + convertPropertyValue( d , a ); + OSL_ASSERT( 25. == d ); + + float f; + convertPropertyValue( f , a ); + OSL_ASSERT( 25. == f ); + + ::com::sun::star::beans::Property prop; + + prop.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Huhu") ); + prop.Handle = 5; + prop.Attributes = 3; + + a <<= prop; + + ::com::sun::star::beans::Property prop2; + convertPropertyValue( prop2 , a ); + OSL_ASSERT( prop.Handle == prop2.Handle && prop.Name == prop2.Name && prop.Attributes == prop2.Attributes ); + + + ::rtl::OUString ow; + a <<= prop.Name; + convertPropertyValue( ow , a ); + OSL_ASSERT( ow == prop.Name ); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cppuhelper/unotypes/cppuhelper/detail/XExceptionThrower.idl b/cppuhelper/unotypes/cppuhelper/detail/XExceptionThrower.idl new file mode 100644 index 000000000000..eb328c1d8983 --- /dev/null +++ b/cppuhelper/unotypes/cppuhelper/detail/XExceptionThrower.idl @@ -0,0 +1,47 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#if ! defined INCLUDED_cppuhelper_detail_XExceptionThrower_idl +#define INCLUDED_cppuhelper_detail_XExceptionThrower_idl + +#include <com/sun/star/uno/Exception.idl> +#include <com/sun/star/uno/XInterface.idl> + + +module cppuhelper { module detail { + +interface XExceptionThrower : com::sun::star::uno::XInterface +{ + void throwException( [in] any exc ) + raises (com::sun::star::uno::Exception); + void rethrowException() + raises (com::sun::star::uno::Exception); +}; + +}; }; + +#endif diff --git a/cppuhelper/unotypes/makefile.mk b/cppuhelper/unotypes/makefile.mk new file mode 100644 index 000000000000..f58a7ebf18ad --- /dev/null +++ b/cppuhelper/unotypes/makefile.mk @@ -0,0 +1,52 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +PRJ = .. + +PRJNAME = cppuhelper +TARGET = private_types + +.INCLUDE : settings.mk + +UNOUCRRDB = $(BIN)$/$(TARGET).rdb +UNOUCRDEP = $(UNOUCRRDB) +UNOUCROUT = $(OUT)$/inc$/private + +CPPUMAKERFLAGS += -C -X$(SOLARBINDIR)$/types.rdb + +UNOTYPES = \ + cppuhelper.detail.XExceptionThrower + +ALLIDLFILES = \ + .$/cppuhelper$/detail$/XExceptionThrower.idl + +.INCLUDE : target.mk + +$(UNOUCRRDB) : $(ALLIDLFILES) $(SOLARBINDIR)$/types.rdb + $(IDLC) -I. -I$(SOLARIDLDIR) -O$(UCR) $(ALLIDLFILES) + $(REGMERGE) $@ /UCR $(UCR)$/{$(?:f:s/.idl/.urd/)} + touch $@ |