diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2021-08-07 09:24:46 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-08-07 21:34:33 +0200 |
commit | 86abf3a682b424dc0fcbccf030f5a0b9bfb81d8c (patch) | |
tree | ba40de884231f604bbd8eedb610834d92afb86ae /UnoControls | |
parent | 2cd1442f83d41af1f2b663ccb8bfab6a954009f1 (diff) |
create comphelper::OMultiTypeInterfaceContainerHelper2 and use it
based on OInterfaceContainerHelper2 which is considerably
faster than the original OInterfaceContainerHelper
Change-Id: I9c8b6d0e5382018824bf7188a26343703abf2d51
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120161
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'UnoControls')
7 files changed, 22 insertions, 19 deletions
diff --git a/UnoControls/inc/basecontainercontrol.hxx b/UnoControls/inc/basecontainercontrol.hxx index fe0d87f2d8cb..507dd2be394a 100644 --- a/UnoControls/inc/basecontainercontrol.hxx +++ b/UnoControls/inc/basecontainercontrol.hxx @@ -24,6 +24,7 @@ #include "basecontrol.hxx" #include <com/sun/star/awt/XControlContainer.hpp> +#include <comphelper/multicontainer2.hxx> namespace unocontrols { @@ -144,7 +145,7 @@ private: // list of pointer of "struct IMPL_ControlInfo" to hold child-controls ::std::vector< IMPL_ControlInfo > maControlInfoList; - ::cppu::OMultiTypeInterfaceContainerHelper m_aListeners; + comphelper::OMultiTypeInterfaceContainerHelper2 m_aListeners; }; diff --git a/UnoControls/inc/multiplexer.hxx b/UnoControls/inc/multiplexer.hxx index 3fc19c126114..58bd1563fb0a 100644 --- a/UnoControls/inc/multiplexer.hxx +++ b/UnoControls/inc/multiplexer.hxx @@ -28,7 +28,7 @@ #include <com/sun/star/awt/XFocusListener.hpp> #include <cppuhelper/weak.hxx> #include <cppuhelper/weakref.hxx> -#include <cppuhelper/interfacecontainer.hxx> +#include <comphelper/multicontainer2.hxx> namespace com::sun::star::awt { class XWindow; } namespace com::sun::star::awt { struct KeyEvent; } @@ -223,7 +223,7 @@ private: ::osl::Mutex m_aMutex; css::uno::Reference< css::awt::XWindow > m_xPeer; /// The source of the events. Normally this is the peer object. css::uno::WeakReference< css::awt::XWindow > m_xControl; - ::cppu::OMultiTypeInterfaceContainerHelper m_aListenerHolder; + comphelper::OMultiTypeInterfaceContainerHelper2 m_aListenerHolder; }; diff --git a/UnoControls/source/base/basecontainercontrol.cxx b/UnoControls/source/base/basecontainercontrol.cxx index dbcfb77bbc2e..a440505149ed 100644 --- a/UnoControls/source/base/basecontainercontrol.cxx +++ b/UnoControls/source/base/basecontainercontrol.cxx @@ -219,7 +219,7 @@ void SAL_CALL BaseContainerControl::addControl ( const OUString& rName, const Re } // Send message to all listener - OInterfaceContainerHelper* pInterfaceContainer = m_aListeners.getContainer( cppu::UnoType<XContainerListener>::get()); + comphelper::OInterfaceContainerHelper2* pInterfaceContainer = m_aListeners.getContainer( cppu::UnoType<XContainerListener>::get()); if (!pInterfaceContainer) return; @@ -231,7 +231,7 @@ void SAL_CALL BaseContainerControl::addControl ( const OUString& rName, const Re aEvent.Element <<= rControl; // Get all listener - OInterfaceIteratorHelper aIterator (*pInterfaceContainer); + comphelper::OInterfaceIteratorHelper2 aIterator (*pInterfaceContainer); // Send event while ( aIterator.hasMoreElements() ) @@ -266,7 +266,7 @@ void SAL_CALL BaseContainerControl::removeControl ( const Reference< XControl > maControlInfoList.erase(maControlInfoList.begin() + n); // Send message to all other listener - OInterfaceContainerHelper * pInterfaceContainer = m_aListeners.getContainer( cppu::UnoType<XContainerListener>::get()); + comphelper::OInterfaceContainerHelper2 * pInterfaceContainer = m_aListeners.getContainer( cppu::UnoType<XContainerListener>::get()); if (pInterfaceContainer) { @@ -275,7 +275,7 @@ void SAL_CALL BaseContainerControl::removeControl ( const Reference< XControl > aEvent.Source = *this; aEvent.Element <<= rControl; - OInterfaceIteratorHelper aIterator (*pInterfaceContainer); + comphelper::OInterfaceIteratorHelper2 aIterator (*pInterfaceContainer); while ( aIterator.hasMoreElements() ) { diff --git a/UnoControls/source/base/multiplexer.cxx b/UnoControls/source/base/multiplexer.cxx index 6e737c7f9b26..c7bf65c170c1 100644 --- a/UnoControls/source/base/multiplexer.cxx +++ b/UnoControls/source/base/multiplexer.cxx @@ -38,11 +38,11 @@ namespace unocontrols { #define MULTIPLEX( INTERFACE, METHOD, EVENTTYP, EVENT ) \ \ /* First get all interfaces from container with right type.*/ \ - OInterfaceContainerHelper* pContainer = m_aListenerHolder.getContainer( cppu::UnoType<INTERFACE>::get() ); \ + comphelper::OInterfaceContainerHelper2* pContainer = m_aListenerHolder.getContainer( cppu::UnoType<INTERFACE>::get() ); \ /* Do the follow only, if elements in container exist.*/ \ if( !pContainer ) \ return; \ - OInterfaceIteratorHelper aIterator( *pContainer ); \ + comphelper::OInterfaceIteratorHelper2 aIterator( *pContainer ); \ EVENTTYP aLocalEvent = EVENT; \ /* Remark: The control is the event source not the peer.*/ \ /* We must change the source of the event. */ \ @@ -156,7 +156,7 @@ void OMRCListenerMultiplexerHelper::setPeer( const Reference< XWindow >& xPeer ) if( m_xPeer.is() ) { // get all types from the listener added to the peer - const Sequence< Type > aContainedTypes = m_aListenerHolder.getContainedTypes(); + const std::vector< Type > aContainedTypes = m_aListenerHolder.getContainedTypes(); // loop over all listener types and remove the listeners from the peer for( const auto& rContainedType : aContainedTypes ) impl_unadviseFromPeer( m_xPeer, rContainedType ); @@ -165,7 +165,7 @@ void OMRCListenerMultiplexerHelper::setPeer( const Reference< XWindow >& xPeer ) if( m_xPeer.is() ) { // get all types from the listener added to the peer - const Sequence< Type > aContainedTypes = m_aListenerHolder.getContainedTypes(); + const std::vector< Type > aContainedTypes = m_aListenerHolder.getContainedTypes(); // loop over all listener types and add the listeners to the peer for( const auto& rContainedType : aContainedTypes ) impl_adviseToPeer( m_xPeer, rContainedType ); diff --git a/UnoControls/source/controls/OConnectionPointContainerHelper.cxx b/UnoControls/source/controls/OConnectionPointContainerHelper.cxx index d0e9d30b611b..bf687a0df5d6 100644 --- a/UnoControls/source/controls/OConnectionPointContainerHelper.cxx +++ b/UnoControls/source/controls/OConnectionPointContainerHelper.cxx @@ -22,6 +22,7 @@ #include <OConnectionPointHelper.hxx> #include <cppuhelper/queryinterface.hxx> +#include <comphelper/sequence.hxx> // namespaces @@ -94,7 +95,7 @@ void SAL_CALL OConnectionPointContainerHelper::release() noexcept Sequence< Type > SAL_CALL OConnectionPointContainerHelper::getConnectionPointTypes() { // Container is threadsafe himself ! - return m_aMultiTypeContainer.getContainedTypes(); + return comphelper::containerToSequence(m_aMultiTypeContainer.getContainedTypes()); } // XConnectionPointContainer @@ -105,7 +106,7 @@ Reference< XConnectionPoint > SAL_CALL OConnectionPointContainerHelper::queryCon Reference< XConnectionPoint > xConnectionPoint; // Get all elements of the container, which have the searched type. - OInterfaceContainerHelper* pSpecialContainer = m_aMultiTypeContainer.getContainer( aType ); + comphelper::OInterfaceContainerHelper2* pSpecialContainer = m_aMultiTypeContainer.getContainer( aType ); if ( pSpecialContainer && pSpecialContainer->getLength() > 0 ) { // Ready for multithreading diff --git a/UnoControls/source/controls/OConnectionPointHelper.cxx b/UnoControls/source/controls/OConnectionPointHelper.cxx index f44aef51aab1..b6ddaaa513a0 100644 --- a/UnoControls/source/controls/OConnectionPointHelper.cxx +++ b/UnoControls/source/controls/OConnectionPointHelper.cxx @@ -23,6 +23,7 @@ #include <com/sun/star/lang/InvalidListenerException.hpp> #include <cppuhelper/queryinterface.hxx> +#include <comphelper/sequence.hxx> // namespaces @@ -188,13 +189,13 @@ Sequence< Reference< XInterface > > SAL_CALL OConnectionPointHelper::getConnecti // Set default return value, if method failed. Sequence< Reference< XInterface > > seqReturnConnections; // Get reference to private member of OConnectionPointHelperContainer! - OMultiTypeInterfaceContainerHelper& aSharedContainer = m_pContainerImplementation->impl_getMultiTypeContainer(); + comphelper::OMultiTypeInterfaceContainerHelper2& aSharedContainer = m_pContainerImplementation->impl_getMultiTypeContainer(); // Get pointer to specialized container which hold all interfaces of searched type. - OInterfaceContainerHelper* pSpecialContainer = aSharedContainer.getContainer( m_aInterfaceType ); + comphelper::OInterfaceContainerHelper2* pSpecialContainer = aSharedContainer.getContainer( m_aInterfaceType ); // Get elements of searched type, if some else exist. if ( pSpecialContainer != nullptr ) { - seqReturnConnections = pSpecialContainer->getElements(); + seqReturnConnections = comphelper::containerToSequence(pSpecialContainer->getElements()); } // Don't forget this! impl_UnlockContainer(); diff --git a/UnoControls/source/inc/OConnectionPointContainerHelper.hxx b/UnoControls/source/inc/OConnectionPointContainerHelper.hxx index 54eed76e6ce1..c1e46b457f79 100644 --- a/UnoControls/source/inc/OConnectionPointContainerHelper.hxx +++ b/UnoControls/source/inc/OConnectionPointContainerHelper.hxx @@ -21,7 +21,7 @@ #include <com/sun/star/lang/XConnectionPointContainer.hpp> #include <cppuhelper/weak.hxx> -#include <cppuhelper/interfacecontainer.hxx> +#include <comphelper/multicontainer2.hxx> namespace com::sun::star::lang { class XConnectionPoint; } @@ -92,11 +92,11 @@ public: // Is necessary to get container member at OConnectionPoint-instance. // Impl methods are not threadsafe! // "Parent" function must do this. - ::cppu::OMultiTypeInterfaceContainerHelper& impl_getMultiTypeContainer() { return m_aMultiTypeContainer; } + comphelper::OMultiTypeInterfaceContainerHelper2& impl_getMultiTypeContainer() { return m_aMultiTypeContainer; } private: ::osl::Mutex& m_aSharedMutex; - ::cppu::OMultiTypeInterfaceContainerHelper m_aMultiTypeContainer; // Container to hold listener + comphelper::OMultiTypeInterfaceContainerHelper2 m_aMultiTypeContainer; // Container to hold listener }; } |