diff options
Diffstat (limited to 'include/cppuhelper')
55 files changed, 11936 insertions, 0 deletions
diff --git a/include/cppuhelper/access_control.hxx b/include/cppuhelper/access_control.hxx new file mode 100644 index 000000000000..f1fbe3f13cd6 --- /dev/null +++ b/include/cppuhelper/access_control.hxx @@ -0,0 +1,119 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef _CPPUHELPER_ACCESS_CONTROL_HXX_ +#define _CPPUHELPER_ACCESS_CONTROL_HXX_ + +#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/security/XAccessController.hpp> +#include "cppuhelperdllapi.h" + + +namespace cppu +{ + +/** Helper class retriving access controller singleton from component context. +*/ +class CPPUHELPER_DLLPUBLIC 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 ac 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/include/cppuhelper/basemutex.hxx b/include/cppuhelper/basemutex.hxx new file mode 100644 index 000000000000..5394b834e434 --- /dev/null +++ b/include/cppuhelper/basemutex.hxx @@ -0,0 +1,43 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#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/include/cppuhelper/bootstrap.hxx b/include/cppuhelper/bootstrap.hxx new file mode 100644 index 000000000000..d76379a2f3e3 --- /dev/null +++ b/include/cppuhelper/bootstrap.hxx @@ -0,0 +1,167 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#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" +#include "cppuhelperdllapi.h" + +namespace com { namespace sun { namespace star { + namespace container { class XHierarchicalNameAccess; } + namespace uno { class XComponentContext; } +} } } + +namespace cppu +{ + +/** Installs type description manager instance, i.e. registers a callback at cppu core. + + @param xTDMgr manager instance + @return true, if successfully registered +*/ +CPPUHELPER_DLLPUBLIC 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 + information from bootstrap variables. + + 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 + + Please look at http://udk.openoffice.org/common/man/concept/uno_default_bootstrapping.html + for further info. + + @return component context +*/ +CPPUHELPER_DLLPUBLIC ::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 + information from an ini file. + + 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 + + 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 +*/ +CPPUHELPER_DLLPUBLIC ::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 CPPUHELPER_DLLPUBLIC 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 + */ +CPPUHELPER_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > +SAL_CALL bootstrap(); + +/// @cond INTERNAL +/** + * Helper function to expand vnd.sun.star.expand URLs in contexts where no + * properly bootstrapped UNO is (yet) available. + * + * @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 + */ +CPPUHELPER_DLLPUBLIC ::rtl::OUString +SAL_CALL bootstrap_expandUri(::rtl::OUString const & uri); +/// @endcond + +} // end namespace cppu + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/cppuhelper/compbase.hxx b/include/cppuhelper/compbase.hxx new file mode 100644 index 000000000000..dc0b8dd4f905 --- /dev/null +++ b/include/cppuhelper/compbase.hxx @@ -0,0 +1,107 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#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 +*/ + +/// @cond INTERNAL + +#define __DEF_COMPIMPLHELPER_A( N ) \ +namespace cppu \ +{ \ +template< __CLASS_IFC##N > \ +class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE 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 SAL_DLLPUBLIC_TEMPLATE 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(); } \ +}; + +#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 ); + +#define __DEF_COMPIMPLHELPER_C( N ) \ +} + +#define __DEF_COMPIMPLHELPER( N ) \ +__DEF_COMPIMPLHELPER_A( N ) \ +__DEF_COMPIMPLHELPER_B( N ) \ +__DEF_COMPIMPLHELPER_C( N ) + +/// @endcond + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/cppuhelper/compbase1.hxx b/include/cppuhelper/compbase1.hxx new file mode 100644 index 000000000000..8948f0120f36 --- /dev/null +++ b/include/cppuhelper/compbase1.hxx @@ -0,0 +1,158 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef _CPPUHELPER_COMPBASE1_HXX_ +#define _CPPUHELPER_COMPBASE1_HXX_ + +#include <cppuhelper/implbase1.hxx> +#include <cppuhelper/compbase_ex.hxx> + +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 SAL_DLLPUBLIC_TEMPLATE WeakComponentImplHelper1 + : public WeakComponentImplHelperBase + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1 + { + 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 + + /** Same as WeakComponentImplHelper1, except doesn't implement + addEventListener, removeEventListener and dispose. + + This requires derived classes to implement those three methods. + This makes it possible to implement classes which are required to + implement methods from multiple bases which have different + addEventListener/removeEventListener signatures without triggering + the g++ overloaded-virtual warning + */ + template< class Ifc1 > + class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE PartialWeakComponentImplHelper1 + : public WeakComponentImplHelperBase + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1 + { + struct cd : public rtl::StaticAggregate< class_data, ImplClassData1< Ifc1, PartialWeakComponentImplHelper1< Ifc1 > > > {}; + public: + inline PartialWeakComponentImplHelper1( ::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 ::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() ); } + }; + + /** 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 SAL_DLLPUBLIC_TEMPLATE WeakAggComponentImplHelper1 + : public WeakAggComponentImplHelperBase + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1 + { + 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/include/cppuhelper/compbase10.hxx b/include/cppuhelper/compbase10.hxx new file mode 100644 index 000000000000..588a47a6fa8a --- /dev/null +++ b/include/cppuhelper/compbase10.hxx @@ -0,0 +1,158 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef _CPPUHELPER_COMPBASE10_HXX_ +#define _CPPUHELPER_COMPBASE10_HXX_ + +#include <cppuhelper/implbase10.hxx> +#include <cppuhelper/compbase_ex.hxx> + +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 SAL_DLLPUBLIC_TEMPLATE 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 + { + 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 + + /** Same as WeakComponentImplHelper10, except doesn't implement + addEventListener, removeEventListener and dispose. + + This requires derived classes to implement those three methods. + This makes it possible to implement classes which are required to + implement methods from multiple bases which have different + addEventListener/removeEventListener signatures without triggering + the g++ overloaded-virtual warning + */ + 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 SAL_DLLPUBLIC_TEMPLATE PartialWeakComponentImplHelper10 + : 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 + { + struct cd : public rtl::StaticAggregate< class_data, ImplClassData10< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, PartialWeakComponentImplHelper10<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10> > > {}; + public: + inline PartialWeakComponentImplHelper10( ::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 ::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() ); } + }; + + /** 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 SAL_DLLPUBLIC_TEMPLATE 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 + { + 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/include/cppuhelper/compbase11.hxx b/include/cppuhelper/compbase11.hxx new file mode 100644 index 000000000000..259a12258f8d --- /dev/null +++ b/include/cppuhelper/compbase11.hxx @@ -0,0 +1,158 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef _CPPUHELPER_COMPBASE11_HXX_ +#define _CPPUHELPER_COMPBASE11_HXX_ + +#include <cppuhelper/implbase11.hxx> +#include <cppuhelper/compbase_ex.hxx> + +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 SAL_DLLPUBLIC_TEMPLATE 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 + { + 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 + + /** Same as WeakComponentImplHelper11, except doesn't implement + addEventListener, removeEventListener and dispose. + + This requires derived classes to implement those three methods. + This makes it possible to implement classes which are required to + implement methods from multiple bases which have different + addEventListener/removeEventListener signatures without triggering + the g++ overloaded-virtual warning + */ + 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 SAL_DLLPUBLIC_TEMPLATE PartialWeakComponentImplHelper11 + : 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 + { + struct cd : public rtl::StaticAggregate< class_data, ImplClassData11< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, PartialWeakComponentImplHelper11<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11> > > {}; + public: + inline PartialWeakComponentImplHelper11( ::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 ::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() ); } + }; + + /** 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 SAL_DLLPUBLIC_TEMPLATE 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 + { + 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/include/cppuhelper/compbase12.hxx b/include/cppuhelper/compbase12.hxx new file mode 100644 index 000000000000..3009dac8f46e --- /dev/null +++ b/include/cppuhelper/compbase12.hxx @@ -0,0 +1,158 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef _CPPUHELPER_COMPBASE12_HXX_ +#define _CPPUHELPER_COMPBASE12_HXX_ + +#include <cppuhelper/implbase12.hxx> +#include <cppuhelper/compbase_ex.hxx> + +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 SAL_DLLPUBLIC_TEMPLATE 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 + { + 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 + + /** Same as WeakComponentImplHelper12, except doesn't implement + addEventListener, removeEventListener and dispose. + + This requires derived classes to implement those three methods. + This makes it possible to implement classes which are required to + implement methods from multiple bases which have different + addEventListener/removeEventListener signatures without triggering + the g++ overloaded-virtual warning + */ + 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 SAL_DLLPUBLIC_TEMPLATE PartialWeakComponentImplHelper12 + : 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 + { + struct cd : public rtl::StaticAggregate< class_data, ImplClassData12< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, Ifc12, PartialWeakComponentImplHelper12<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, Ifc12> > > {}; + public: + inline PartialWeakComponentImplHelper12( ::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 ::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() ); } + }; + + /** 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 SAL_DLLPUBLIC_TEMPLATE 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 + { + 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/include/cppuhelper/compbase2.hxx b/include/cppuhelper/compbase2.hxx new file mode 100644 index 000000000000..e54a38b00e3b --- /dev/null +++ b/include/cppuhelper/compbase2.hxx @@ -0,0 +1,159 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef _CPPUHELPER_COMPBASE2_HXX_ +#define _CPPUHELPER_COMPBASE2_HXX_ + +#include <cppuhelper/implbase2.hxx> +#include <cppuhelper/compbase_ex.hxx> + +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 SAL_DLLPUBLIC_TEMPLATE WeakComponentImplHelper2 + : public WeakComponentImplHelperBase + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2 + { + 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 + + /** Same as WeakComponentImplHelper2, except doesn't implement + addEventListener, removeEventListener and dispose. + + This requires derived classes to implement those three methods. + This makes it possible to implement classes which are required to + implement methods from multiple bases which have different + addEventListener/removeEventListener signatures without triggering + the g++ overloaded-virtual warning + */ + template< class Ifc1, class Ifc2 > + class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE PartialWeakComponentImplHelper2 + : public WeakComponentImplHelperBase + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2 + { + struct cd : public rtl::StaticAggregate< class_data, ImplClassData2 < Ifc1, Ifc2, PartialWeakComponentImplHelper2<Ifc1, Ifc2> > > {}; + public: + inline PartialWeakComponentImplHelper2( ::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 ::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() ); } + }; + + + /** 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 SAL_DLLPUBLIC_TEMPLATE WeakAggComponentImplHelper2 + : public WeakAggComponentImplHelperBase + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2 + { + 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/include/cppuhelper/compbase3.hxx b/include/cppuhelper/compbase3.hxx new file mode 100644 index 000000000000..e43991a7c117 --- /dev/null +++ b/include/cppuhelper/compbase3.hxx @@ -0,0 +1,158 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef _CPPUHELPER_COMPBASE3_HXX_ +#define _CPPUHELPER_COMPBASE3_HXX_ + +#include <cppuhelper/implbase3.hxx> +#include <cppuhelper/compbase_ex.hxx> + +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 SAL_DLLPUBLIC_TEMPLATE WeakComponentImplHelper3 + : public WeakComponentImplHelperBase + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3 + { + 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 + + /** Same as WeakComponentImplHelper3, except doesn't implement + addEventListener, removeEventListener and dispose. + + This requires derived classes to implement those three methods. + This makes it possible to implement classes which are required to + implement methods from multiple bases which have different + addEventListener/removeEventListener signatures without triggering + the g++ overloaded-virtual warning + */ + template< class Ifc1, class Ifc2, class Ifc3 > + class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE PartialWeakComponentImplHelper3 + : public WeakComponentImplHelperBase + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3 + { + struct cd : public rtl::StaticAggregate< class_data, ImplClassData3 < Ifc1, Ifc2, Ifc3, PartialWeakComponentImplHelper3<Ifc1, Ifc2, Ifc3> > > {}; + public: + inline PartialWeakComponentImplHelper3( ::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 ::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() ); } + }; + + /** 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 SAL_DLLPUBLIC_TEMPLATE WeakAggComponentImplHelper3 + : public WeakAggComponentImplHelperBase + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3 + { + 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/include/cppuhelper/compbase4.hxx b/include/cppuhelper/compbase4.hxx new file mode 100644 index 000000000000..a20542e57abe --- /dev/null +++ b/include/cppuhelper/compbase4.hxx @@ -0,0 +1,158 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef _CPPUHELPER_COMPBASE4_HXX_ +#define _CPPUHELPER_COMPBASE4_HXX_ + +#include <cppuhelper/implbase4.hxx> +#include <cppuhelper/compbase_ex.hxx> + +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 SAL_DLLPUBLIC_TEMPLATE WeakComponentImplHelper4 + : public WeakComponentImplHelperBase + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4 + { + 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 + + /** Same as WeakComponentImplHelper4, except doesn't implement + addEventListener, removeEventListener and dispose. + + This requires derived classes to implement those three methods. + This makes it possible to implement classes which are required to + implement methods from multiple bases which have different + addEventListener/removeEventListener signatures without triggering + the g++ overloaded-virtual warning + */ + template< class Ifc1, class Ifc2, class Ifc3, class Ifc4 > + class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE PartialWeakComponentImplHelper4 + : public WeakComponentImplHelperBase + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4 + { + struct cd : public rtl::StaticAggregate< class_data, ImplClassData4 < Ifc1, Ifc2, Ifc3, Ifc4, PartialWeakComponentImplHelper4<Ifc1, Ifc2, Ifc3, Ifc4> > > {}; + public: + inline PartialWeakComponentImplHelper4( ::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 ::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() ); } + }; + + /** 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 SAL_DLLPUBLIC_TEMPLATE WeakAggComponentImplHelper4 + : public WeakAggComponentImplHelperBase + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4 + { + 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/include/cppuhelper/compbase5.hxx b/include/cppuhelper/compbase5.hxx new file mode 100644 index 000000000000..b22b1038b573 --- /dev/null +++ b/include/cppuhelper/compbase5.hxx @@ -0,0 +1,158 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef _CPPUHELPER_COMPBASE5_HXX_ +#define _CPPUHELPER_COMPBASE5_HXX_ + +#include <cppuhelper/implbase5.hxx> +#include <cppuhelper/compbase_ex.hxx> + +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 SAL_DLLPUBLIC_TEMPLATE WeakComponentImplHelper5 + : public WeakComponentImplHelperBase + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5 + { + 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 + + /** Same as WeakComponentImplHelper5, except doesn't implement + addEventListener, removeEventListener and dispose. + + This requires derived classes to implement those three methods. + This makes it possible to implement classes which are required to + implement methods from multiple bases which have different + addEventListener/removeEventListener signatures without triggering + the g++ overloaded-virtual warning + */ + template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5 > + class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE PartialWeakComponentImplHelper5 + : public WeakComponentImplHelperBase + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5 + { + struct cd : public rtl::StaticAggregate< class_data, ImplClassData5 < Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, PartialWeakComponentImplHelper5<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5> > > {}; + public: + inline PartialWeakComponentImplHelper5( ::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 ::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() ); } + }; + + /** 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 SAL_DLLPUBLIC_TEMPLATE WeakAggComponentImplHelper5 + : public WeakAggComponentImplHelperBase + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5 + { + 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/include/cppuhelper/compbase6.hxx b/include/cppuhelper/compbase6.hxx new file mode 100644 index 000000000000..778bbb722295 --- /dev/null +++ b/include/cppuhelper/compbase6.hxx @@ -0,0 +1,158 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef _CPPUHELPER_COMPBASE6_HXX_ +#define _CPPUHELPER_COMPBASE6_HXX_ + +#include <cppuhelper/implbase6.hxx> +#include <cppuhelper/compbase_ex.hxx> + +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 SAL_DLLPUBLIC_TEMPLATE WeakComponentImplHelper6 + : public WeakComponentImplHelperBase + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6 + { + 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 + + /** Same as WeakComponentImplHelper6, except doesn't implement + addEventListener, removeEventListener and dispose. + + This requires derived classes to implement those three methods. + This makes it possible to implement classes which are required to + implement methods from multiple bases which have different + addEventListener/removeEventListener signatures without triggering + the g++ overloaded-virtual warning + */ + template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6 > + class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE PartialWeakComponentImplHelper6 + : public WeakComponentImplHelperBase + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6 + { + struct cd : public rtl::StaticAggregate< class_data, ImplClassData6 < Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, PartialWeakComponentImplHelper6<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6> > > {}; + public: + inline PartialWeakComponentImplHelper6( ::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 ::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() ); } + }; + + /** 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 SAL_DLLPUBLIC_TEMPLATE WeakAggComponentImplHelper6 + : public WeakAggComponentImplHelperBase + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6 + { + 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/include/cppuhelper/compbase7.hxx b/include/cppuhelper/compbase7.hxx new file mode 100644 index 000000000000..edf3af3fd258 --- /dev/null +++ b/include/cppuhelper/compbase7.hxx @@ -0,0 +1,158 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef _CPPUHELPER_COMPBASE7_HXX_ +#define _CPPUHELPER_COMPBASE7_HXX_ + +#include <cppuhelper/implbase7.hxx> +#include <cppuhelper/compbase_ex.hxx> + +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 SAL_DLLPUBLIC_TEMPLATE WeakComponentImplHelper7 + : public WeakComponentImplHelperBase + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7 + { + 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 + + /** Same as WeakComponentImplHelper7, except doesn't implement + addEventListener, removeEventListener and dispose. + + This requires derived classes to implement those three methods. + This makes it possible to implement classes which are required to + implement methods from multiple bases which have different + addEventListener/removeEventListener signatures without triggering + the g++ overloaded-virtual warning + */ + template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7 > + class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE PartialWeakComponentImplHelper7 + : public WeakComponentImplHelperBase + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7 + { + struct cd : public rtl::StaticAggregate< class_data, ImplClassData7< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, PartialWeakComponentImplHelper7<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7> > > {}; + public: + inline PartialWeakComponentImplHelper7( ::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 ::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() ); } + }; + + /** 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 SAL_DLLPUBLIC_TEMPLATE WeakAggComponentImplHelper7 + : public WeakAggComponentImplHelperBase + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7 + { + 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/include/cppuhelper/compbase8.hxx b/include/cppuhelper/compbase8.hxx new file mode 100644 index 000000000000..efff5c4a2d09 --- /dev/null +++ b/include/cppuhelper/compbase8.hxx @@ -0,0 +1,158 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef _CPPUHELPER_COMPBASE8_HXX_ +#define _CPPUHELPER_COMPBASE8_HXX_ + +#include <cppuhelper/implbase8.hxx> +#include <cppuhelper/compbase_ex.hxx> + +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 SAL_DLLPUBLIC_TEMPLATE 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 + { + 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 + + /** Same as WeakComponentImplHelper8, except doesn't implement + addEventListener, removeEventListener and dispose. + + This requires derived classes to implement those three methods. + This makes it possible to implement classes which are required to + implement methods from multiple bases which have different + addEventListener/removeEventListener signatures without triggering + the g++ overloaded-virtual warning + */ + template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8 > + class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE PartialWeakComponentImplHelper8 + : public WeakComponentImplHelperBase + , public ::com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8 + { + struct cd : public rtl::StaticAggregate< class_data, ImplClassData8< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, PartialWeakComponentImplHelper8<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8> > > {}; + public: + inline PartialWeakComponentImplHelper8( ::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 ::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() ); } + }; + + /** 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 SAL_DLLPUBLIC_TEMPLATE 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 + { + 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/include/cppuhelper/compbase9.hxx b/include/cppuhelper/compbase9.hxx new file mode 100644 index 000000000000..5496e63864bd --- /dev/null +++ b/include/cppuhelper/compbase9.hxx @@ -0,0 +1,157 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef _CPPUHELPER_COMPBASE9_HXX_ +#define _CPPUHELPER_COMPBASE9_HXX_ + +#include <cppuhelper/implbase9.hxx> +#include <cppuhelper/compbase_ex.hxx> + +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 SAL_DLLPUBLIC_TEMPLATE 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 + { + 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 + + /** Same as WeakComponentImplHelper9, except doesn't implement + addEventListener, removeEventListener and dispose. + + This requires derived classes to implement those three methods. + This makes it possible to implement classes which are required to + implement methods from multiple bases which have different + addEventListener/removeEventListener signatures without triggering + the g++ overloaded-virtual warning + */ + template< class Ifc1, class Ifc2, class Ifc3, class Ifc4, class Ifc5, class Ifc6, class Ifc7, class Ifc8, class Ifc9 > + class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE PartialWeakComponentImplHelper9 + : 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 + { + struct cd : public rtl::StaticAggregate< class_data, ImplClassData9< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, PartialWeakComponentImplHelper9<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9> > > {}; + public: + inline PartialWeakComponentImplHelper9( ::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 ::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() ); } + }; + + /** 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 SAL_DLLPUBLIC_TEMPLATE 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 + { + 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/include/cppuhelper/compbase_ex.hxx b/include/cppuhelper/compbase_ex.hxx new file mode 100644 index 000000000000..5937f60e29cc --- /dev/null +++ b/include/cppuhelper/compbase_ex.hxx @@ -0,0 +1,168 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#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> +#include "cppuhelperdllapi.h" + +/// @cond INTERNAL + +namespace cppu +{ + +/** Implementation helper base class for components. Inherits from ::cppu::OWeakObject and + ::com::sun::star::lang::XComponent. +*/ +class CPPUHELPER_DLLPUBLIC 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. +*/ +class CPPUHELPER_DLLPUBLIC 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 +*/ +CPPUHELPER_DLLPUBLIC ::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 +*/ +CPPUHELPER_DLLPUBLIC ::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 +*/ +CPPUHELPER_DLLPUBLIC ::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 +*/ +CPPUHELPER_DLLPUBLIC ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL WeakAggComponentImplHelper_getTypes( + class_data * cd ) + SAL_THROW( (::com::sun::star::uno::RuntimeException) ); + +} + +/// @endcond + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/cppuhelper/component.hxx b/include/cppuhelper/component.hxx new file mode 100644 index 000000000000..64460959fbbf --- /dev/null +++ b/include/cppuhelper/component.hxx @@ -0,0 +1,113 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#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> + +#include "cppuhelperdllapi.h" + +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 CPPUHELPER_DLLPUBLIC 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(()); + /** Destructor. 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(); + + /// @cond INTERNAL + OBroadcastHelper rBHelper; + /// @endcond + +private: + inline OComponentHelper( const OComponentHelper & ) SAL_THROW(()); + inline OComponentHelper & operator = ( const OComponentHelper & ) SAL_THROW(()); +}; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/cppuhelper/component_context.hxx b/include/cppuhelper/component_context.hxx new file mode 100644 index 000000000000..575fa490a452 --- /dev/null +++ b/include/cppuhelper/component_context.hxx @@ -0,0 +1,91 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef _CPPUHELPER_COMPONENT_CONTEXT_HXX_ +#define _CPPUHELPER_COMPONENT_CONTEXT_HXX_ + +#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/lang/XSingleComponentFactory.hpp> +#include "cppuhelperdllapi.h" + + +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 +*/ +CPPUHELPER_DLLPUBLIC ::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/include/cppuhelper/cppuhelperdllapi.h b/include/cppuhelper/cppuhelperdllapi.h new file mode 100644 index 000000000000..8489402c4e86 --- /dev/null +++ b/include/cppuhelper/cppuhelperdllapi.h @@ -0,0 +1,34 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_CPPUHELPERDLLAPI_H +#define INCLUDED_CPPUHELPERDLLAPI_H + +#include "sal/types.h" + +#if defined(CPPUHELPER_DLLIMPLEMENTATION) +#define CPPUHELPER_DLLPUBLIC SAL_DLLPUBLIC_EXPORT +#else +#define CPPUHELPER_DLLPUBLIC SAL_DLLPUBLIC_IMPORT +#endif +#define CPPUHELPER_DLLPRIVATE SAL_DLLPRIVATE + +#endif /* INCLUDED_CPPUHELPERDLLAPI_H */ + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/cppuhelper/exc_hlp.hxx b/include/cppuhelper/exc_hlp.hxx new file mode 100644 index 000000000000..9c110ee6c018 --- /dev/null +++ b/include/cppuhelper/exc_hlp.hxx @@ -0,0 +1,94 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef _CPPUHELPER_EXC_HLP_HXX_ +#define _CPPUHELPER_EXC_HLP_HXX_ + +#include <com/sun/star/uno/Any.hxx> +#include "cppuhelperdllapi.h" + +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. +*/ +CPPUHELPER_DLLPUBLIC 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. + + @code + 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() ); + ... + } + @endcode + + 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). +*/ +CPPUHELPER_DLLPUBLIC ::com::sun::star::uno::Any SAL_CALL getCaughtException(); + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/cppuhelper/factory.hxx b/include/cppuhelper/factory.hxx new file mode 100644 index 000000000000..8dfda840d51c --- /dev/null +++ b/include/cppuhelper/factory.hxx @@ -0,0 +1,279 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#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> +#include "cppuhelperdllapi.h" + +//################################################################################################## + +#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). + + @param ppEnvTypeName 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. + + @deprecated component_writeInfo should no longer be used in new components + + 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 a backwards-compatibility remainder of a removed library + unloading feature; always set to null +*/ +CPPUHELPER_DLLPUBLIC ::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 a backwards-compatibility remainder of a removed library + unloading feature; always set to null + + @see createSingleComponentFactory +*/ +CPPUHELPER_DLLPUBLIC ::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 pCreateFunction the function pointer to create an object. + @param rServiceNames the service supported by the implementation. + @param pModCount a backwards-compatibility remainder of a removed library + unloading feature; always set to null. + @return a factory that support the interfaces XServiceProvider, XServiceInfo + XSingleServiceFactory and XComponent. + + @see createOneInstanceFactory + @deprecated +*/ +CPPUHELPER_DLLPUBLIC ::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 rFactory the wrapped service factory. + @return a factory that support the interfaces XServiceProvider, XServiceInfo + XSingleServiceFactory. + + @see createSingleFactory + @deprecated +*/ +CPPUHELPER_DLLPUBLIC ::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 rComponentName the implementation name. An empty string is possible. + @param pCreateFunction the function pointer to create an object. + @param rServiceNames the service supported by the implementation. + @param pModCount a backwards-compatibility remainder of a removed library + unloading feature; always set to null. + @return a factory that support the interfaces XServiceProvider, XServiceInfo + XSingleServiceFactory and XComponent. + + @see createSingleFactory + @deprecated +*/ +CPPUHELPER_DLLPUBLIC ::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 +*/ +CPPUHELPER_DLLPUBLIC ::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 rComponentName 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 +*/ +CPPUHELPER_DLLPUBLIC ::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/include/cppuhelper/findsofficepath.h b/include/cppuhelper/findsofficepath.h new file mode 100644 index 000000000000..1d24009f6bb8 --- /dev/null +++ b/include/cppuhelper/findsofficepath.h @@ -0,0 +1,39 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#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/include/cppuhelper/implbase.hxx b/include/cppuhelper/implbase.hxx new file mode 100644 index 000000000000..06ac7a8c8d1a --- /dev/null +++ b/include/cppuhelper/implbase.hxx @@ -0,0 +1,296 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#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> +#include "cppuhelperdllapi.h" + +/* This header should not be used anymore. + @deprecated +*/ + +/// @cond INTERNAL + +namespace cppu +{ + +/** Struct used for inline template implementation helpers: type entries. + Not for public use. +*/ +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. +*/ +struct CPPUHELPER_DLLPUBLIC 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. +*/ +struct CPPUHELPER_DLLPUBLIC 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. +*/ +CPPUHELPER_DLLPUBLIC ::osl::Mutex & SAL_CALL getImplHelperInitMutex(void) SAL_THROW(()); +} + +// +// settle down beavis, here comes the macro template hell :] +// + +//================================================================================================== + +#if defined _MSC_VER // public -> protected changes mangled names there +#define CPPUHELPER_DETAIL_IMPLHELPER_PROTECTED public +#else +#define CPPUHELPER_DETAIL_IMPLHELPER_PROTECTED protected +#endif + +/** 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 ) +*/ +#define __DEF_IMPLHELPER_PRE( N ) \ +namespace cppu \ +{ \ +struct ClassData##N : public ClassDataBase \ +{ \ + Type_Offset arType2Offset[ N ]; \ + ClassData##N( sal_Int32 nInClassCode ) SAL_THROW(()) \ + : ClassDataBase( nInClassCode ) \ + {} \ +}; \ +template< __CLASS_IFC##N > \ +class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE ImplHelperBase##N \ + : public ::com::sun::star::lang::XTypeProvider \ + , __PUBLIC_IFC##N \ +{ \ +CPPUHELPER_DETAIL_IMPLHELPER_PROTECTED: \ + ~ImplHelperBase##N() throw () {} \ +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 +*/ +#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 +*/ +#define __DEF_IMPLHELPER_POST_A( N ) \ + rCD.bOffsetsInit = sal_True; \ + } \ + } \ + return rCD; \ + } \ +}; \ +template< __CLASS_IFC##N > \ +class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE 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(); } \ +CPPUHELPER_DETAIL_IMPLHELPER_PROTECTED: \ + ~ImplHelper##N() throw () {} \ +}; \ +template< __CLASS_IFC##N > \ +class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE 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 SAL_DLLPUBLIC_TEMPLATE 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 +*/ +#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 +*/ +#define __DEF_IMPLHELPER_POST_C( N ) \ +} +//================================================================================================== +/** Implementation helper macro: have a look at __DEF_IMPLHELPER_PRE +*/ +#define __DEF_IMPLHELPER_POST( N ) \ +__DEF_IMPLHELPER_POST_A( N ) \ +__DEF_IMPLHELPER_POST_B( N ) \ +__DEF_IMPLHELPER_POST_C( N ) + +/// @endcond + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/cppuhelper/implbase1.hxx b/include/cppuhelper/implbase1.hxx new file mode 100644 index 000000000000..ead86fe6c56a --- /dev/null +++ b/include/cppuhelper/implbase1.hxx @@ -0,0 +1,296 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#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 +{ + /// @cond 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 ]; + }; + + 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); + } + }; + + /// @endcond + + /** 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 SAL_DLLPUBLIC_TEMPLATE 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() ); } + +#if !defined _MSC_VER // public -> protected changes mangled names there + protected: +#endif + ~ImplHelper1() throw () {} + }; + /** 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 SAL_DLLPUBLIC_TEMPLATE SAL_DLLPUBLIC_EXPORT WeakImplHelper1 + : public OWeakObject + , public com::sun::star::lang::XTypeProvider + , public Ifc1 + { + 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 SAL_DLLPUBLIC_TEMPLATE WeakAggImplHelper1 + : public OWeakAggObject + , public com::sun::star::lang::XTypeProvider + , public Ifc1 + { + 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 SAL_DLLPUBLIC_TEMPLATE ImplInheritanceHelper1 + : public BaseClass + , public Ifc1 + { + 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 SAL_DLLPUBLIC_TEMPLATE AggImplInheritanceHelper1 + : public BaseClass + , public Ifc1 + { + 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/include/cppuhelper/implbase10.hxx b/include/cppuhelper/implbase10.hxx new file mode 100644 index 000000000000..57fdda5b3ce0 --- /dev/null +++ b/include/cppuhelper/implbase10.hxx @@ -0,0 +1,296 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef _CPPUHELPER_IMPLBASE10_HXX_ +#define _CPPUHELPER_IMPLBASE10_HXX_ + +#include <cppuhelper/implbase_ex.hxx> +#include <rtl/instance.hxx> + +namespace cppu +{ + /// @cond 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 ]; + }; + + 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); + } + }; + + /// @endcond + + /** 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 SAL_DLLPUBLIC_TEMPLATE 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 + { + 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() ); } + +#if !defined _MSC_VER // public -> protected changes mangled names there + protected: +#endif + ~ImplHelper10() throw () {} + }; + /** 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 SAL_DLLPUBLIC_TEMPLATE 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 + { + 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 SAL_DLLPUBLIC_TEMPLATE 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 + { + 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 SAL_DLLPUBLIC_TEMPLATE ImplInheritanceHelper10 + : public BaseClass + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9, public Ifc10 + { + 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 SAL_DLLPUBLIC_TEMPLATE AggImplInheritanceHelper10 + : public BaseClass + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9, public Ifc10 + { + 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/include/cppuhelper/implbase11.hxx b/include/cppuhelper/implbase11.hxx new file mode 100644 index 000000000000..bd282e70fdc2 --- /dev/null +++ b/include/cppuhelper/implbase11.hxx @@ -0,0 +1,297 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef _CPPUHELPER_IMPLBASE11_HXX_ +#define _CPPUHELPER_IMPLBASE11_HXX_ + +#include <cppuhelper/implbase_ex.hxx> +#include <rtl/instance.hxx> + +namespace cppu +{ + /// @cond 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 ]; + }; + + 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); + } + }; + + /// @endcond + + /** 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 SAL_DLLPUBLIC_TEMPLATE 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 + { + 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() ); } + +#if !defined _MSC_VER // public -> protected changes mangled names there + protected: +#endif + ~ImplHelper11() throw () {} + }; + /** 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 SAL_DLLPUBLIC_TEMPLATE 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 + { + 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 SAL_DLLPUBLIC_TEMPLATE 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 + { + 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 SAL_DLLPUBLIC_TEMPLATE 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 + { + 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 SAL_DLLPUBLIC_TEMPLATE 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 + { + 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/include/cppuhelper/implbase12.hxx b/include/cppuhelper/implbase12.hxx new file mode 100644 index 000000000000..a1d4bf17fa07 --- /dev/null +++ b/include/cppuhelper/implbase12.hxx @@ -0,0 +1,298 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef _CPPUHELPER_IMPLBASE12_HXX_ +#define _CPPUHELPER_IMPLBASE12_HXX_ + +#include <cppuhelper/implbase_ex.hxx> +#include <rtl/instance.hxx> + +namespace cppu +{ + /// @cond 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 ]; + }; + + 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); + } + }; + + /// @endcond + + /** 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 SAL_DLLPUBLIC_TEMPLATE 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 + { + 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() ); } + +#if !defined _MSC_VER // public -> protected changes mangled names there + protected: +#endif + ~ImplHelper12() throw () {} + }; + /** 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 SAL_DLLPUBLIC_TEMPLATE 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 + { + 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 SAL_DLLPUBLIC_TEMPLATE 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 + { + 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 SAL_DLLPUBLIC_TEMPLATE 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 + { + 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 SAL_DLLPUBLIC_TEMPLATE 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 + { + 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/include/cppuhelper/implbase13.hxx b/include/cppuhelper/implbase13.hxx new file mode 100644 index 000000000000..b50fb038564c --- /dev/null +++ b/include/cppuhelper/implbase13.hxx @@ -0,0 +1,299 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef _CPPUHELPER_IMPLBASE13_HXX_ +#define _CPPUHELPER_IMPLBASE13_HXX_ + +#include <cppuhelper/implbase_ex.hxx> +#include <rtl/instance.hxx> + +namespace cppu +{ + /// @cond INTERNAL + + struct class_data13 + { + sal_Int16 m_nTypes; + sal_Bool m_storedTypeRefs; + sal_Bool m_storedId; + sal_Int8 m_id[ 16 ]; + type_entry m_typeEntries[ 13 + 1 ]; + }; + + 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 Ifc13, typename Impl > + struct ImplClassData13 + { + class_data* operator ()() + { + static class_data13 s_cd = + { + 13 +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 }, + { { Ifc13::static_type }, ((sal_IntPtr)(Ifc13 *) (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); + } + }; + + /// @endcond + + /** 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 Ifc13 > + class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE ImplHelper13 + : 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, public Ifc13 + { + struct cd : public rtl::StaticAggregate< class_data, ImplClassData13< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, Ifc12, Ifc13, ImplHelper13<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, Ifc12, Ifc13> > > {}; + 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() ); } + +#if !defined _MSC_VER // public -> protected changes mangled names there + protected: +#endif + ~ImplHelper13() throw () {} + }; + /** 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 Ifc13 > + class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakImplHelper13 + : 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, public Ifc13 + { + struct cd : public rtl::StaticAggregate< class_data, ImplClassData13< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, Ifc12, Ifc13, WeakImplHelper13<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, Ifc12, Ifc13> > > {}; + 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 Ifc13 > + class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE WeakAggImplHelper13 + : 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, public Ifc13 + { + struct cd : public rtl::StaticAggregate< class_data, ImplClassData13< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, Ifc12, Ifc13, WeakAggImplHelper13<Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, Ifc12, Ifc13> > > {}; + 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 Ifc13 > + class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE ImplInheritanceHelper13 + : 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, public Ifc13 + { + struct cd : public rtl::StaticAggregate< class_data, ImplClassData13< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, Ifc12, Ifc13, ImplInheritanceHelper13<BaseClass, Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, Ifc12, Ifc13> > > {}; + protected: + template< typename T1 > + explicit ImplInheritanceHelper13(T1 const & arg1): BaseClass(arg1) {} + template< typename T1, typename T2 > + ImplInheritanceHelper13(T1 const & arg1, T2 const & arg2): + BaseClass(arg1, arg2) {} + template< typename T1, typename T2, typename T3 > + ImplInheritanceHelper13( + T1 const & arg1, T2 const & arg2, T3 const & arg3): + BaseClass(arg1, arg2, arg3) {} + template< typename T1, typename T2, typename T3, typename T4 > + ImplInheritanceHelper13( + 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 > + ImplInheritanceHelper13( + 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 > + ImplInheritanceHelper13( + 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: + ImplInheritanceHelper13() {} + 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 Ifc13 > + class SAL_NO_VTABLE SAL_DLLPUBLIC_TEMPLATE AggImplInheritanceHelper13 + : 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, public Ifc13 + { + struct cd : public rtl::StaticAggregate< class_data, ImplClassData13< Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, Ifc12, Ifc13, AggImplInheritanceHelper13<BaseClass, Ifc1, Ifc2, Ifc3, Ifc4, Ifc5, Ifc6, Ifc7, Ifc8, Ifc9, Ifc10, Ifc11, Ifc12, Ifc13> > > {}; + protected: + template< typename T1 > + explicit AggImplInheritanceHelper13(T1 const & arg1): BaseClass(arg1) {} + template< typename T1, typename T2 > + AggImplInheritanceHelper13(T1 const & arg1, T2 const & arg2): + BaseClass(arg1, arg2) {} + template< typename T1, typename T2, typename T3 > + AggImplInheritanceHelper13( + T1 const & arg1, T2 const & arg2, T3 const & arg3): + BaseClass(arg1, arg2, arg3) {} + template< typename T1, typename T2, typename T3, typename T4 > + AggImplInheritanceHelper13( + 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 > + AggImplInheritanceHelper13( + 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 > + AggImplInheritanceHelper13( + 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: + AggImplInheritanceHelper13() {} + 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/include/cppuhelper/implbase2.hxx b/include/cppuhelper/implbase2.hxx new file mode 100644 index 000000000000..acd9bbe5e211 --- /dev/null +++ b/include/cppuhelper/implbase2.hxx @@ -0,0 +1,287 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef _CPPUHELPER_IMPLBASE2_HXX_ +#define _CPPUHELPER_IMPLBASE2_HXX_ + +#include <cppuhelper/implbase_ex.hxx> +#include <rtl/instance.hxx> + +namespace cppu +{ + /// @cond 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 ]; + }; + + 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); + } + }; + + /// @endcond + + /** 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 SAL_DLLPUBLIC_TEMPLATE ImplHelper2 + : public com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2 + { + 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() ); } + +#if !defined _MSC_VER // public -> protected changes mangled names there + protected: +#endif + ~ImplHelper2() throw () {} + }; + /** 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 SAL_DLLPUBLIC_TEMPLATE SAL_DLLPUBLIC_EXPORT WeakImplHelper2 + : public OWeakObject + , public com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2 + { + 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 SAL_DLLPUBLIC_TEMPLATE WeakAggImplHelper2 + : public OWeakAggObject + , public com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2 + { + 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 SAL_DLLPUBLIC_TEMPLATE ImplInheritanceHelper2 + : public BaseClass + , public Ifc1, public Ifc2 + { + 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 SAL_DLLPUBLIC_TEMPLATE AggImplInheritanceHelper2 + : public BaseClass + , public Ifc1, public Ifc2 + { + 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/include/cppuhelper/implbase3.hxx b/include/cppuhelper/implbase3.hxx new file mode 100644 index 000000000000..f887ee470538 --- /dev/null +++ b/include/cppuhelper/implbase3.hxx @@ -0,0 +1,289 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef _CPPUHELPER_IMPLBASE3_HXX_ +#define _CPPUHELPER_IMPLBASE3_HXX_ + +#include <cppuhelper/implbase_ex.hxx> +#include <rtl/instance.hxx> + +namespace cppu +{ + /// @cond 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 ]; + }; + + 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); + } + }; + + /// @endcond + + /** 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 SAL_DLLPUBLIC_TEMPLATE ImplHelper3 + : public com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3 + { + 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() ); } + +#if !defined _MSC_VER // public -> protected changes mangled names there + protected: +#endif + ~ImplHelper3() throw () {} + }; + /** 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 SAL_DLLPUBLIC_TEMPLATE WeakImplHelper3 + : public OWeakObject + , public com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3 + { + 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 SAL_DLLPUBLIC_TEMPLATE WeakAggImplHelper3 + : public OWeakAggObject + , public com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3 + { + 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 SAL_DLLPUBLIC_TEMPLATE ImplInheritanceHelper3 + : public BaseClass + , public Ifc1, public Ifc2, public Ifc3 + { + 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 SAL_DLLPUBLIC_TEMPLATE AggImplInheritanceHelper3 + : public BaseClass + , public Ifc1, public Ifc2, public Ifc3 + { + 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/include/cppuhelper/implbase4.hxx b/include/cppuhelper/implbase4.hxx new file mode 100644 index 000000000000..54fd60e0f54f --- /dev/null +++ b/include/cppuhelper/implbase4.hxx @@ -0,0 +1,290 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef _CPPUHELPER_IMPLBASE4_HXX_ +#define _CPPUHELPER_IMPLBASE4_HXX_ + +#include <cppuhelper/implbase_ex.hxx> +#include <rtl/instance.hxx> + +namespace cppu +{ + /// @cond 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 ]; + }; + + 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); + } + }; + + /// @endcond + + /** 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 SAL_DLLPUBLIC_TEMPLATE ImplHelper4 + : public com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4 + { + 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() ); } + +#if !defined _MSC_VER // public -> protected changes mangled names there + protected: +#endif + ~ImplHelper4() throw () {} + }; + /** 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 SAL_DLLPUBLIC_TEMPLATE WeakImplHelper4 + : public OWeakObject + , public com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4 + { + 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 SAL_DLLPUBLIC_TEMPLATE WeakAggImplHelper4 + : public OWeakAggObject + , public com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4 + { + 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 SAL_DLLPUBLIC_TEMPLATE ImplInheritanceHelper4 + : public BaseClass + , public Ifc1, public Ifc2, public Ifc3, public Ifc4 + { + 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 SAL_DLLPUBLIC_TEMPLATE AggImplInheritanceHelper4 + : public BaseClass + , public Ifc1, public Ifc2, public Ifc3, public Ifc4 + { + 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/include/cppuhelper/implbase5.hxx b/include/cppuhelper/implbase5.hxx new file mode 100644 index 000000000000..4a4b3e640426 --- /dev/null +++ b/include/cppuhelper/implbase5.hxx @@ -0,0 +1,291 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef _CPPUHELPER_IMPLBASE5_HXX_ +#define _CPPUHELPER_IMPLBASE5_HXX_ + +#include <cppuhelper/implbase_ex.hxx> +#include <rtl/instance.hxx> + +namespace cppu +{ + /// @cond 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 ]; + }; + + 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); + } + }; + + /// @endcond + + /** 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 SAL_DLLPUBLIC_TEMPLATE ImplHelper5 + : public com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5 + { + 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() ); } + +#if !defined _MSC_VER // public -> protected changes mangled names there + protected: +#endif + ~ImplHelper5() throw () {} + }; + /** 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 SAL_DLLPUBLIC_TEMPLATE WeakImplHelper5 + : public OWeakObject + , public com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5 + { + 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 SAL_DLLPUBLIC_TEMPLATE WeakAggImplHelper5 + : public OWeakAggObject + , public com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5 + { + 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 SAL_DLLPUBLIC_TEMPLATE ImplInheritanceHelper5 + : public BaseClass + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5 + { + 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 SAL_DLLPUBLIC_TEMPLATE AggImplInheritanceHelper5 + : public BaseClass + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5 + { + 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/include/cppuhelper/implbase6.hxx b/include/cppuhelper/implbase6.hxx new file mode 100644 index 000000000000..090da8d8a862 --- /dev/null +++ b/include/cppuhelper/implbase6.hxx @@ -0,0 +1,292 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef _CPPUHELPER_IMPLBASE6_HXX_ +#define _CPPUHELPER_IMPLBASE6_HXX_ + +#include <cppuhelper/implbase_ex.hxx> +#include <rtl/instance.hxx> + +namespace cppu +{ + /// @cond 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 ]; + }; + + 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); + } + }; + + /// @endcond + + /** 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 SAL_DLLPUBLIC_TEMPLATE ImplHelper6 + : public com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6 + { + 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() ); } + +#if !defined _MSC_VER // public -> protected changes mangled names there + protected: +#endif + ~ImplHelper6() throw () {} + }; + /** 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 SAL_DLLPUBLIC_TEMPLATE WeakImplHelper6 + : public OWeakObject + , public com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6 + { + 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 SAL_DLLPUBLIC_TEMPLATE WeakAggImplHelper6 + : public OWeakAggObject + , public com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6 + { + 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 SAL_DLLPUBLIC_TEMPLATE ImplInheritanceHelper6 + : public BaseClass + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6 + { + 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 SAL_DLLPUBLIC_TEMPLATE AggImplInheritanceHelper6 + : public BaseClass + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6 + { + 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/include/cppuhelper/implbase7.hxx b/include/cppuhelper/implbase7.hxx new file mode 100644 index 000000000000..62998349b822 --- /dev/null +++ b/include/cppuhelper/implbase7.hxx @@ -0,0 +1,293 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef _CPPUHELPER_IMPLBASE7_HXX_ +#define _CPPUHELPER_IMPLBASE7_HXX_ + +#include <cppuhelper/implbase_ex.hxx> +#include <rtl/instance.hxx> + +namespace cppu +{ + /// @cond 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 ]; + }; + + 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); + } + }; + + /// @endcond + + /** 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 SAL_DLLPUBLIC_TEMPLATE ImplHelper7 + : public com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7 + { + 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() ); } + +#if !defined _MSC_VER // public -> protected changes mangled names there + protected: +#endif + ~ImplHelper7() throw () {} + }; + /** 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 SAL_DLLPUBLIC_TEMPLATE WeakImplHelper7 + : public OWeakObject + , public com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7 + { + 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 SAL_DLLPUBLIC_TEMPLATE WeakAggImplHelper7 + : public OWeakAggObject + , public com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7 + { + 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 SAL_DLLPUBLIC_TEMPLATE ImplInheritanceHelper7 + : public BaseClass + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7 + { + 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 SAL_DLLPUBLIC_TEMPLATE AggImplInheritanceHelper7 + : public BaseClass + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7 + { + 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/include/cppuhelper/implbase8.hxx b/include/cppuhelper/implbase8.hxx new file mode 100644 index 000000000000..117dba731b9c --- /dev/null +++ b/include/cppuhelper/implbase8.hxx @@ -0,0 +1,294 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef _CPPUHELPER_IMPLBASE8_HXX_ +#define _CPPUHELPER_IMPLBASE8_HXX_ + +#include <cppuhelper/implbase_ex.hxx> +#include <rtl/instance.hxx> + +namespace cppu +{ + /// @cond 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 ]; + }; + + 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); + } + }; + + /// @endcond + + /** 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 SAL_DLLPUBLIC_TEMPLATE ImplHelper8 + : public com::sun::star::lang::XTypeProvider + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8 + { + 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() ); } + +#if !defined _MSC_VER // public -> protected changes mangled names there + protected: +#endif + ~ImplHelper8() throw () {} + }; + /** 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 SAL_DLLPUBLIC_TEMPLATE 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 + { + 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 SAL_DLLPUBLIC_TEMPLATE 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 + { + 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 SAL_DLLPUBLIC_TEMPLATE ImplInheritanceHelper8 + : public BaseClass + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8 + { + 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 SAL_DLLPUBLIC_TEMPLATE AggImplInheritanceHelper8 + : public BaseClass + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8 + { + 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/include/cppuhelper/implbase9.hxx b/include/cppuhelper/implbase9.hxx new file mode 100644 index 000000000000..ca4cdba53f3d --- /dev/null +++ b/include/cppuhelper/implbase9.hxx @@ -0,0 +1,295 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef _CPPUHELPER_IMPLBASE9_HXX_ +#define _CPPUHELPER_IMPLBASE9_HXX_ + +#include <cppuhelper/implbase_ex.hxx> +#include <rtl/instance.hxx> + +namespace cppu +{ + /// @cond 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 ]; + }; + + 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); + } + }; + + /// @endcond + + /** 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 SAL_DLLPUBLIC_TEMPLATE 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 + { + 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() ); } + +#if !defined _MSC_VER // public -> protected changes mangled names there + protected: +#endif + ~ImplHelper9() throw () {} + }; + /** 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 SAL_DLLPUBLIC_TEMPLATE 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 + { + 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 SAL_DLLPUBLIC_TEMPLATE 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 + { + 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 SAL_DLLPUBLIC_TEMPLATE ImplInheritanceHelper9 + : public BaseClass + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9 + { + 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 SAL_DLLPUBLIC_TEMPLATE AggImplInheritanceHelper9 + : public BaseClass + , public Ifc1, public Ifc2, public Ifc3, public Ifc4, public Ifc5, public Ifc6, public Ifc7, public Ifc8, public Ifc9 + { + 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/include/cppuhelper/implbase_ex.hxx b/include/cppuhelper/implbase_ex.hxx new file mode 100644 index 000000000000..4eb111de898a --- /dev/null +++ b/include/cppuhelper/implbase_ex.hxx @@ -0,0 +1,165 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#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 ) +*/ + +/// @cond INTERNAL + +namespace cppu +{ + +/** function pointer signature for getCppuType +*/ +typedef ::com::sun::star::uno::Type const & (SAL_CALL * fptr_getCppuType)( void * ) SAL_THROW(()); + +/** single type + object offset +*/ +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 +*/ +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 +*/ +CPPUHELPER_DLLPUBLIC ::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 +*/ +CPPUHELPER_DLLPUBLIC ::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 +*/ +CPPUHELPER_DLLPUBLIC ::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 +*/ +CPPUHELPER_DLLPUBLIC ::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 +*/ +CPPUHELPER_DLLPUBLIC ::com::sun::star::uno::Sequence< sal_Int8 > +SAL_CALL ImplHelper_getImplementationId( + class_data * cd ) + SAL_THROW( (::com::sun::star::uno::RuntimeException) ); + +/** WeakImplHelper +*/ +CPPUHELPER_DLLPUBLIC ::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 +*/ +CPPUHELPER_DLLPUBLIC ::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 +*/ +CPPUHELPER_DLLPUBLIC ::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 +*/ +CPPUHELPER_DLLPUBLIC ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > +SAL_CALL WeakAggImplHelper_getTypes( + class_data * cd ) + SAL_THROW( (::com::sun::star::uno::RuntimeException) ); + +} + +/// @endcond + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/cppuhelper/implbase_ex_post.hxx b/include/cppuhelper/implbase_ex_post.hxx new file mode 100644 index 000000000000..6d97b760613b --- /dev/null +++ b/include/cppuhelper/implbase_ex_post.hxx @@ -0,0 +1,168 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef _CPPUHELPER_IMPLBASE_EX_POST_HXX_ +#define _CPPUHELPER_IMPLBASE_EX_POST_HXX_ + +/// @cond 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 ) \ +} \ +} + +#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 SAL_DLLPUBLIC_TEMPLATE 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 SAL_DLLPUBLIC_TEMPLATE 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 SAL_DLLPUBLIC_TEMPLATE 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 SAL_DLLPUBLIC_TEMPLATE 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 SAL_DLLPUBLIC_TEMPLATE 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 > *) ); \ +} + +/// @endcond + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/cppuhelper/implbase_ex_pre.hxx b/include/cppuhelper/implbase_ex_pre.hxx new file mode 100644 index 000000000000..a9eb82df0251 --- /dev/null +++ b/include/cppuhelper/implbase_ex_pre.hxx @@ -0,0 +1,33 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef _CPPUHELPER_IMPLBASE_EX_PRE_HXX_ +#define _CPPUHELPER_IMPLBASE_EX_PRE_HXX_ + +/// @cond INTERNAL + +#define __IFC_EX_TYPE_INIT_NAME( class_cast, ifc_name ) \ +{ { ifc_name::static_type }, ((sal_IntPtr)(ifc_name *) class_cast 16) - 16 } + +#define __IFC_EX_TYPE_INIT( class_cast, N ) __IFC_EX_TYPE_INIT_NAME( class_cast, Ifc##N ) + +/// @endcond + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/cppuhelper/implementationentry.hxx b/include/cppuhelper/implementationentry.hxx new file mode 100644 index 000000000000..298c0dc9e9ba --- /dev/null +++ b/include/cppuhelper/implementationentry.hxx @@ -0,0 +1,121 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef _CPPUHELPER_IMPLEMENTATIONENTRY_HXX_ +#define _CPPUHELPER_IMPLEMENTATIONENTRY_HXX_ + +#include <cppuhelper/factory.hxx> +#include "cppuhelperdllapi.h" + +// MinGW wants it the one way around while MSVC wants it the other (cf. +// <sourceforge.net/support/tracker.php?aid=3514133> "Syntactic __cdecl +// incompatibility with MSVC"; and everywhere else, SAL_CALL is empty, so +// doesn't matter): +#if defined __GNUC__ +#define MY_FN_PTR(name) SAL_CALL (* name) +#else +#define MY_FN_PTR(name) (SAL_CALL * name) +#endif + +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 MY_FN_PTR( getImplementationName )(); + + /** Function that returns all supported servicenames of the implementation + ( same as XServiceInfo.getSupportedServiceNames() ). + */ + com::sun::star::uno::Sequence< rtl::OUString > MY_FN_PTR( getSupportedServiceNames ) (); + + /** Function that creates a SingleComponentFactory. + + The pModCount parameter is a backwards-compatibility remainder of a + removed library unloading feature; always set to null. + */ + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XSingleComponentFactory > + MY_FN_PTR( createFactory )( + ComponentFactoryFunc fptr, + ::rtl::OUString const & rImplementationName, + ::com::sun::star::uno::Sequence< ::rtl::OUString > const & rServiceNames, + rtl_ModuleCount * pModCount ); + + /** Backwards-compatibility remainder of a removed library unloading + feature; always set to null. + */ + rtl_ModuleCount * moduleCounter; + + /** Must be set to 0 ! + For future extensions. + */ + sal_Int32 nFlags; +}; + +/** Helper function for implementation of the component_writeInfo()-function. + + @deprecated component_writeInfo should no longer be used in new components + + @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. + */ +CPPUHELPER_DLLPUBLIC 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 second parameter passed to component_getFactory()-function + (This is a of the service manager, that creates the factory). + @param pRegistryKey The third parameter passed to the component_getFactory()-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. + */ +CPPUHELPER_DLLPUBLIC 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/include/cppuhelper/interfacecontainer.h b/include/cppuhelper/interfacecontainer.h new file mode 100644 index 000000000000..774f900a8b26 --- /dev/null +++ b/include/cppuhelper/interfacecontainer.h @@ -0,0 +1,607 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#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> +#include <com/sun/star/lang/EventObject.hpp> + +#include "com/sun/star/lang/DisposedException.hpp" +#include "cppuhelperdllapi.h" + +/** */ //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 CPPUHELPER_DLLPUBLIC 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 CPPUHELPER_DLLPUBLIC 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. + + @tparam ListenerT listener type + @tparam 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. + + @tparam ListenerT UNO event listener type, let your compiler deduce this for you + @tparam 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: +@code + awt::PaintEvent aEvent( static_cast< cppu::OWeakObject* >( this ), ... ); + listeners.notifyEach( &XPaintListener::windowPaint, aEvent ); +@endcode + */ + 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 & rMutex ) 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 safe. */ + 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 (size_t) s.getTypeName().hashCode(); } +}; + + +/** Specialized class for key type com::sun::star::uno::Type, + without explicit usage of STL symbols. +*/ +class CPPUHELPER_DLLPUBLIC 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 & rMutex ) 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/include/cppuhelper/interfacecontainer.hxx b/include/cppuhelper/interfacecontainer.hxx new file mode 100644 index 000000000000..292278f7a078 --- /dev/null +++ b/include/cppuhelper/interfacecontainer.hxx @@ -0,0 +1,195 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#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/include/cppuhelper/propertysetmixin.hxx b/include/cppuhelper/propertysetmixin.hxx new file mode 100644 index 000000000000..bbca3ac479ee --- /dev/null +++ b/include/cppuhelper/propertysetmixin.hxx @@ -0,0 +1,489 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_CPPUHELPER_PROPERTYSETMIXIN_HXX +#define 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" +#include "cppuhelperdllapi.h" + +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>. + + See the documentation of <code>cppu::PropertySetMixin</code> for + further details. + + 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 +*/ +#if HAVE_GCC_PRAGMA_DIAGNOSTIC_MODIFY && HAVE_GCC_PRAGMA_DIAGNOSTIC_SCOPE \ + && !defined __clang__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wnon-virtual-dtor" +#endif +class CPPUHELPER_DLLPUBLIC 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. + + This class is not thread safe; that is, the constructor, + <code>notify</code>, and the destructor must be called from the same + thread. + + See <code>cppu::PropertySetMixinImpl::prepareSet</code> for + further details. + */ + class CPPUHELPER_DLLPUBLIC BoundListeners { + public: + /** + @short The constructor. + + May throw <code>std::bad_alloc</code>. + */ + BoundListeners(); + + /** + @short The destructor. + + Does not throw. + */ + ~BoundListeners(); + + /** + @short Notifies any + <code>com::sun::star::beans::XPropertyChangeListener</code>s. + + May throw <code>com::sun::star::uno::RuntimeException</code> + and <code>std::bad_alloc</code>. + + 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. + + 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. + + 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"> + OpenOffice.org Coding Guidelines</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"> + OpenOffice.org Coding Guidelines</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. + + 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. + + 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>. + + 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>. + + 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>. + + 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); +}; +#if HAVE_GCC_PRAGMA_DIAGNOSTIC_MODIFY && HAVE_GCC_PRAGMA_DIAGNOSTIC_SCOPE \ + && !defined __clang__ +#pragma GCC diagnostic pop +#endif + +/** + @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. + + The UNO interface type is specified by the type parameter + <code>T</code> (which must correspond to a UNO interface type). + + 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. + + 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. + + 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/include/cppuhelper/propshlp.hxx b/include/cppuhelper/propshlp.hxx new file mode 100644 index 000000000000..aa99ebaa6536 --- /dev/null +++ b/include/cppuhelper/propshlp.hxx @@ -0,0 +1,736 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#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/XPropertySetOption.hpp> +#include <com/sun/star/beans/XMultiPropertySet.hpp> +#include <com/sun/star/beans/XFastPropertySet.hpp> + +#include <memory> +#include "cppuhelperdllapi.h" + + +namespace cppu +{ + + +/************************************************************************* +*************************************************************************/ + + +/** + This interface is used by the OPropertyHelper, to access the property description. + */ +class CPPUHELPER_DLLPUBLIC 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(()) + {} + + /** + Following the rule, the first virtual method implies a 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 pAttributes 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 CPPUHELPER_DLLPUBLIC 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 pAttributes 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 CPPUHELPER_DLLPUBLIC 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 & rMutex ) 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 r 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 + @param pnHandles the id's of the properties that changed. + @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. + @param bIgnoreRuntimeExceptionsWhileFiring + indicates whether occurring RuntimeExceptions will be + ignored when firing notifications + (vetoableChange(), propertyChange()) + to listeners. + PropertyVetoExceptions may still be thrown. + This flag is useful in an inter-process scenario when + remote bridges may break down + (firing DisposedExceptions). + + @see OPropertySetHelper::fire + */ + virtual void fireEvents( + sal_Int32 * pnHandles, + sal_Int32 nCount, + sal_Bool bVetoable, + bool bIgnoreRuntimeExceptionsWhileFiring) = 0; + +#if !defined _MSC_VER // public -> protected changes mangled names there +protected: +#endif + ~IEventNotificationHook() {} + // avoid warnings about virtual members and non-virtual dtor +}; + + + +/** + 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 CPPUHELPER_DLLPUBLIC 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 occurring RuntimeExceptions will be + ignored when firing notifications + (vetoableChange(), propertyChange()) + to listeners. + PropertyVetoExceptions may still be thrown. + This flag is useful in an inter-process scenario 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 occurring RuntimeExceptions will be + ignored when firing notifications + (vetoableChange(), propertyChange()) + to listeners. + PropertyVetoExceptions may still be thrown. + This flag is useful in an inter-process scenario 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. + */ + virtual ::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. + @param rValue the value to be converted + @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; + + /** sets an dependent property's value + + <p>Sometimes setting a given property needs to implicitly modify another property's value. Calling |setPropertyValue| + from within |setFastPropertyValue_NoBroadcast| is not an option here, as it would notify the property listeners + while our mutex is still locked. Setting the dependent property's value directly (e.g. by calling |setFastPropertyValue_NoBroadcast| + recursively) is not an option, too, since it would miss firing the property change event.</p> + + <p>So, in such cases, you use |setDependentFastPropertyValue| from within |setFastPropertyValue_NoBroadcast|. + It will convert and actually set the property value (invoking |convertFastPropertyValue| and |setFastPropertyValue_NoBroadcast| + for the given handle and value), and add the property change event to the list of events to be notified + when the bottom-most |setFastPropertyValue_NoBroadcast| on the stack returns.</p> + + <p><strong>Note</strong>: The method will <em>not</em> invoke veto listeners for the property.</p> + + <p><strong>Note</strong>: It's the caller's responsibility to ensure that our mutex is locked. This is + canonically given when the method is invoked from within |setFastPropertyValue_NoBroadcast|, in other + contexts, you might need to take own measures.</p> + */ + void setDependentFastPropertyValue( + sal_Int32 i_handle, + const ::com::sun::star::uno::Any& i_value + ); + + /** 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<Impl> m_pReserved; + +private: + OPropertySetHelper( const OPropertySetHelper & ) SAL_THROW(()); + OPropertySetHelper & operator = ( const OPropertySetHelper & ) SAL_THROW(()); + + /** notifies the given changes in property's values, <em>plus</em> all property changes collected during recent + |setDependentFastPropertyValue| calls. + */ + void impl_fireAll( + sal_Int32* i_handles, + const ::com::sun::star::uno::Any * i_newValues, + const ::com::sun::star::uno::Any * i_oldValues, + sal_Int32 i_count + ); + +#if defined _MSC_VER // public -> protected changes mangled names there +public: +#else +protected: +#endif +// Suppress warning about virtual functions but non-virtual destructor: +#if 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 + +/** + OPropertySetHelper plus XPropertySetOption + */ +class CPPUHELPER_DLLPUBLIC OPropertySetHelper2 : public OPropertySetHelper, + public ::com::sun::star::beans::XPropertySetOption +{ +public: + /** Constructor. + + See OPropertySetHelper constructors documentation + */ + explicit OPropertySetHelper2( + OBroadcastHelper & rBHelper, + IEventNotificationHook *i_pFireEvents = NULL, + bool bIgnoreRuntimeExceptionsWhileFiring = false); + + // XInterface + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) + throw (::com::sun::star::uno::RuntimeException); + + // XPropertySetOption + virtual void SAL_CALL enableChangeListenerNotification( sal_Bool bEnable ) + throw(::com::sun::star::uno::RuntimeException); + + + +private: + OPropertySetHelper2( const OPropertySetHelper2 & ) SAL_THROW(()); + OPropertySetHelper2 & operator = ( const OPropertySetHelper2 & ) SAL_THROW(()); + +#if defined _MSC_VER // public -> protected changes mangled names there +public: +#else +protected: +#endif +// Suppress warning about virtual functions but non-virtual destructor: + /** + You must call disposing before destruction. + */ + virtual ~OPropertySetHelper2() SAL_THROW(()); +}; + +} // end namespace cppuhelper +#endif // + + + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/cppuhelper/proptypehlp.h b/include/cppuhelper/proptypehlp.h new file mode 100644 index 000000000000..3236ca0363c3 --- /dev/null +++ b/include/cppuhelper/proptypehlp.h @@ -0,0 +1,70 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#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/include/cppuhelper/proptypehlp.hxx b/include/cppuhelper/proptypehlp.hxx new file mode 100644 index 000000000000..08107f3b91f7 --- /dev/null +++ b/include/cppuhelper/proptypehlp.hxx @@ -0,0 +1,523 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#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/include/cppuhelper/queryinterface.hxx b/include/cppuhelper/queryinterface.hxx new file mode 100644 index 000000000000..e8f2dfa9dcbf --- /dev/null +++ b/include/cppuhelper/queryinterface.hxx @@ -0,0 +1,534 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#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. + + @tparam 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. + + @tparam Interface1 interface type + @tparam 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. + + @tparam Interface1 interface type + @tparam Interface2 interface type + @tparam 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. + + @tparam Interface1 interface type + @tparam Interface2 interface type + @tparam Interface3 interface type + @tparam 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. + + @tparam Interface1 interface type + @tparam Interface2 interface type + @tparam Interface3 interface type + @tparam Interface4 interface type + @tparam 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. + + @tparam Interface1 interface type + @tparam Interface2 interface type + @tparam Interface3 interface type + @tparam Interface4 interface type + @tparam Interface5 interface type + @tparam 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. + + @tparam Interface1 interface type + @tparam Interface2 interface type + @tparam Interface3 interface type + @tparam Interface4 interface type + @tparam Interface5 interface type + @tparam Interface6 interface type + @tparam 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. + + @tparam Interface1 interface type + @tparam Interface2 interface type + @tparam Interface3 interface type + @tparam Interface4 interface type + @tparam Interface5 interface type + @tparam Interface6 interface type + @tparam Interface7 interface type + @tparam 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. + + @tparam Interface1 interface type + @tparam Interface2 interface type + @tparam Interface3 interface type + @tparam Interface4 interface type + @tparam Interface5 interface type + @tparam Interface6 interface type + @tparam Interface7 interface type + @tparam Interface8 interface type + @tparam 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. + + @tparam Interface1 interface type + @tparam Interface2 interface type + @tparam Interface3 interface type + @tparam Interface4 interface type + @tparam Interface5 interface type + @tparam Interface6 interface type + @tparam Interface7 interface type + @tparam Interface8 interface type + @tparam Interface9 interface type + @tparam 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. + + @tparam Interface1 interface type + @tparam Interface2 interface type + @tparam Interface3 interface type + @tparam Interface4 interface type + @tparam Interface5 interface type + @tparam Interface6 interface type + @tparam Interface7 interface type + @tparam Interface8 interface type + @tparam Interface9 interface type + @tparam Interface10 interface type + @tparam 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. + + @tparam Interface1 interface type + @tparam Interface2 interface type + @tparam Interface3 interface type + @tparam Interface4 interface type + @tparam Interface5 interface type + @tparam Interface6 interface type + @tparam Interface7 interface type + @tparam Interface8 interface type + @tparam Interface9 interface type + @tparam Interface10 interface type + @tparam Interface11 interface type + @tparam 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/include/cppuhelper/shlib.hxx b/include/cppuhelper/shlib.hxx new file mode 100644 index 000000000000..666359fac851 --- /dev/null +++ b/include/cppuhelper/shlib.hxx @@ -0,0 +1,133 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef _CPPUHELPER_SHLIB_HXX_ +#define _CPPUHELPER_SHLIB_HXX_ + +#include <osl/module.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> +#include "cppuhelperdllapi.h" + + +namespace cppu +{ + +// Note the pointless redundancy +// "::com::sun::star::lang::XSingleComponentFactory or +// ::com::sun::star::lang::XSingleComponentFactory" in the doc +// comments below. Whether the documentation is supposed to mean only +// XSingleComponentFactory, or whether the other one should be +// something else, I don't know. + +/** 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) +*/ +CPPUHELPER_DLLPUBLIC ::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) ); + +/** 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. An optional 'prefix' parameter is used to determine the symbol + name of the entry point in the library. + + @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 + @param rPrefix optional component prefix + @return + factory instance (com::sun::star::lang::XSingleComponentFactory or + com::sun::star::lang::XSingleComponentFactory) +*/ +CPPUHELPER_DLLPUBLIC ::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, + ::rtl::OUString const & rPrefix ) + SAL_THROW( (::com::sun::star::loader::CannotActivateFactoryException) ); + +/** Gets the factory out of an already loaded (for instance statically linked) component. + + @param pGetter the component's component_getFactory function + @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 + @param rPrefix optional component prefix + @return + factory instance (com::sun::star::lang::XSingleComponentFactory or + com::sun::star::lang::XSingleComponentFactory) +*/ +CPPUHELPER_DLLPUBLIC ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > +SAL_CALL invokeStaticComponentFactory( + oslGenericFunction pGetter, + ::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, + ::rtl::OUString const & rPrefix ) + 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. + + @deprecated component_writeInfo should no longer be used in new components + + @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 +*/ +CPPUHELPER_DLLPUBLIC 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/include/cppuhelper/supportsservice.hxx b/include/cppuhelper/supportsservice.hxx new file mode 100644 index 000000000000..a5cc2003a1ed --- /dev/null +++ b/include/cppuhelper/supportsservice.hxx @@ -0,0 +1,49 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_CPPUHELPER_SUPPORTSSERVICE_HXX +#define INCLUDED_CPPUHELPER_SUPPORTSSERVICE_HXX + +#include "sal/config.h" + +#include "cppuhelper/cppuhelperdllapi.h" + +namespace com { namespace sun { namespace star { namespace lang { + class XServiceInfo; +} } } } +namespace rtl { class OUString; } + +namespace cppu { + +/** A helper for implementations of com.sun.star.lang.XServiceInfo. + + This function is supposed to be called from implementations of + com::sun::star::lang::XServiceInfo::supportsService (and therefore, for + easier coding takes the caller's this pointer by pointer rather than by + com::sun::star::uno::Reference). + + @param implementation points to the service implementation whose + getSupportedServices method is consulted; must be non-null + + @param name the service name to test + + @return true iff the sequence returned by the given implementation's + getSupportedServices method contains the given name + + @since LibreOffice 4.0 +*/ +bool CPPUHELPER_DLLPUBLIC supportsService( + com::sun::star::lang::XServiceInfo * implementation, + rtl::OUString const & name); + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/cppuhelper/typeprovider.hxx b/include/cppuhelper/typeprovider.hxx new file mode 100644 index 000000000000..24201c9a8982 --- /dev/null +++ b/include/cppuhelper/typeprovider.hxx @@ -0,0 +1,233 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef _CPPUHELPER_TYPEPROVIDER_HXX_ +#define _CPPUHELPER_TYPEPROVIDER_HXX_ + +#include <rtl/alloc.h> +#include <rtl/uuid.h> +#include <com/sun/star/uno/Sequence.hxx> +#include "cppuhelperdllapi.h" + + +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 CPPUHELPER_DLLPUBLIC OTypeCollection +{ + ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > _aTypes; + +public: + /// @cond INTERNAL + // 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(()) + {} + /// @endcond + + 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 CPPUHELPER_DLLPUBLIC OImplementationId +{ + mutable ::com::sun::star::uno::Sequence< sal_Int8 > * _pSeq; + sal_Bool _bUseEthernetAddress; + +public: + /// @cond INTERNAL + + // 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(()) + {} + + ~OImplementationId() SAL_THROW(()); + + /// @endcond + + /** 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/include/cppuhelper/unourl.hxx b/include/cppuhelper/unourl.hxx new file mode 100644 index 000000000000..e9a7f2baa55e --- /dev/null +++ b/include/cppuhelper/unourl.hxx @@ -0,0 +1,185 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef INCLUDED_CPPUHELPER_UNOURL_HXX +#define INCLUDED_CPPUHELPER_UNOURL_HXX + +#include <memory> +#include "cppuhelperdllapi.h" + +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 CPPUHELPER_DLLPUBLIC UnoUrlDescriptor +{ +public: + 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); + + /// @cond INTERNAL + explicit UnoUrlDescriptor(std::auto_ptr< Impl > & rImpl); + /// @endcond + + 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 + rKey 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 + rKey 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 CPPUHELPER_DLLPUBLIC 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/include/cppuhelper/weak.hxx b/include/cppuhelper/weak.hxx new file mode 100644 index 000000000000..80d5ec07c500 --- /dev/null +++ b/include/cppuhelper/weak.hxx @@ -0,0 +1,164 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#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> +#include "cppuhelperdllapi.h" + + +namespace cppu +{ + +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 CPPUHELPER_DLLPUBLIC OWeakObject : public ::com::sun::star::uno::XWeak +{ + 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 + @pre + m_refCount equals 0 + */ + void disposeWeakConnectionPoint(); + + /** reference count. + + @attention + Don't modify manually! Use acquire() and release(). + */ + oslInterlockedCount m_refCount; + + /// @cond INTERNAL + + /** Container of all weak reference listeners and the connection point from the weak reference. + */ + OWeakConnectionPoint * m_pWeakConnectionPoint; + + /** reserved for future use. do not use. + */ + void * m_pReserved; + + /// @endcond + +public: + /// @cond INTERNAL + // 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(()) + {} + /// @endcond + +#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 & rObj ) SAL_THROW(()) + : com::sun::star::uno::XWeak() + , m_refCount( 0 ) + , m_pWeakConnectionPoint( 0 ) + { + (void) rObj; + } + /** 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/include/cppuhelper/weakagg.hxx b/include/cppuhelper/weakagg.hxx new file mode 100644 index 000000000000..bfe4ba5151d3 --- /dev/null +++ b/include/cppuhelper/weakagg.hxx @@ -0,0 +1,104 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef _CPPUHELPER_WEAKAGG_HXX_ +#define _CPPUHELPER_WEAKAGG_HXX_ + +#include <cppuhelper/weak.hxx> +#include <com/sun/star/uno/XAggregation.hpp> +#include "cppuhelperdllapi.h" + + +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 CPPUHELPER_DLLPUBLIC 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: + OWeakAggObject( const OWeakAggObject & rObj ) SAL_THROW(()); + OWeakAggObject & operator = ( const OWeakAggObject & rObj ) SAL_THROW(()); +}; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/cppuhelper/weakref.hxx b/include/cppuhelper/weakref.hxx new file mode 100644 index 000000000000..0a9530608159 --- /dev/null +++ b/include/cppuhelper/weakref.hxx @@ -0,0 +1,164 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +#ifndef _CPPUHELPER_WEAKREF_HXX_ +#define _CPPUHELPER_WEAKREF_HXX_ + +#include <com/sun/star/uno/XInterface.hpp> +#include "cppuhelperdllapi.h" + + +namespace com +{ +namespace sun +{ +namespace star +{ +namespace uno +{ + +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 CPPUHELPER_DLLPUBLIC 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: + /// @cond INTERNAL + OWeakRefListener * m_pImpl; + /// @endcond +}; + +/** 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. + + @tparam 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: */ |