25#include <osl/diagnose.h>
26#include <osl/mutex.hxx>
30#include <com/sun/star/lang/XEventListener.hpp>
72 OSL_ENSURE(
rCont.
bInUse,
"OInterfaceContainerHelper2 must be in use" );
126 OSL_ENSURE( !
bInUse,
"~OInterfaceContainerHelper2 but is in use" );
135 MutexGuard aGuard(
rMutex );
145 std::vector< Reference<XInterface> > rVec;
146 MutexGuard aGuard(
rMutex );
158 OSL_ENSURE(
bInUse,
"OInterfaceContainerHelper2 not in use" );
174 OSL_ASSERT( rListener.is() );
175 MutexGuard aGuard(
rMutex );
186 std::vector< Reference< XInterface > > * pVec =
new std::vector< Reference< XInterface > >( 2 );
188 (*pVec)[1] = rListener;
198 rListener->acquire();
205 OSL_ASSERT( rListener.is() );
206 MutexGuard aGuard(
rMutex );
214 [&rListener](
const css::uno::Reference<css::uno::XInterface>& rItem) {
215 return rItem.get() == rListener.get(); });
246 MutexGuard aGuard(
rMutex );
255 throw std::out_of_range(
"index out of range");
260 ClearableMutexGuard aGuard(
rMutex );
263 OSL_ENSURE( !
bIsList ||
bInUse,
"OInterfaceContainerHelper2 not in use" );
277 xLst->disposing( rEvt );
290 MutexGuard aGuard(
rMutex );
292 OSL_ENSURE( !
bIsList ||
bInUse,
"OInterfaceContainerHelper2 not in use" );
318 ::osl::MutexGuard aGuard(
rMutex );
319 std::vector< Type > aInterfaceTypes;
320 aInterfaceTypes.reserve(
m_aMap.size() );
321 for (
const auto& rItem :
m_aMap)
324 if( rItem.second->getLength() )
326 aInterfaceTypes.push_back(rItem.first);
328 return aInterfaceTypes;
334 [&rKey](
const t_type2ptr::value_type& rItem) { return rItem.first == rKey; });
340 [&rKey](
const t_type2ptr::value_type& rItem) { return rItem.first == rKey; });
345 ::osl::MutexGuard aGuard(
rMutex );
348 if( iter !=
m_aMap.end() )
349 return (*iter).second.get();
356 ::osl::MutexGuard aGuard(
rMutex );
358 if( iter ==
m_aMap.end() )
361 m_aMap.emplace_back(rKey, pLC);
364 return (*iter).second->addInterface( rListener );
370 ::osl::MutexGuard aGuard(
rMutex );
375 if( iter !=
m_aMap.end() )
376 return (*iter).second->removeInterface( rListener );
384 t_type2ptr::size_type nSize = 0;
385 std::unique_ptr<OInterfaceContainerHelper2 *[]> ppListenerContainers;
387 ::osl::MutexGuard aGuard(
rMutex );
392 ppListenerContainers.reset(
new ppp[nSize]);
394 t_type2ptr::size_type
i = 0;
395 for (
const auto& rItem :
m_aMap)
397 ppListenerContainers[
i++] = rItem.second.get();
403 for( t_type2ptr::size_type
i = 0;
i < nSize;
i++ )
405 if( ppListenerContainers[
i] )
406 ppListenerContainers[
i]->disposeAndClear( rEvt );
412 ::osl::MutexGuard aGuard(
rMutex );
414 for (
auto& rItem :
m_aMap)
415 rItem.second->clear();
A container of interfaces.
bool bIsList
TRUE -> aData.pAsVector is of type Sequence< XInterfaceSequence >.
bool bInUse
TRUE -> used by an iterator.
~OInterfaceContainerHelper2()
Release all interfaces.
void disposeAndClear(const css::lang::EventObject &rEvt)
Call disposing on all object in the container that support XEventListener.
sal_Int32 getLength() const
Return the number of Elements in the container.
void clear()
Clears the container without calling disposing().
css::uno::Reference< css::uno::XInterface > getInterface(sal_Int32 nIndex) const
Return an interface by index.
OInterfaceContainerHelper2(::osl::Mutex &rMutex)
Create an interface container.
std::vector< css::uno::Reference< css::uno::XInterface > > getElements() const
Return all interfaces added to this container.
sal_Int32 removeInterface(const css::uno::Reference< css::uno::XInterface > &rxIFace)
Removes an element from the container.
sal_Int32 addInterface(const css::uno::Reference< css::uno::XInterface > &rxIFace)
Inserts an element into the container.
detail::element_alias2 aData
bIsList == TRUE -> aData.pAsVector of type vector< XInterfaceSequence >, otherwise aData....
This is the iterator of an OInterfaceContainerHelper2.
OInterfaceIteratorHelper2(OInterfaceContainerHelper2 &rCont)
Create an iterator over the elements of the container.
css::uno::XInterface * next()
Return the next element of the iterator.
bool hasMoreElements() const
Return true, if there are more elements in the iterator.
void remove()
Removes the current element (the last one returned by next()) from the underlying container.
OInterfaceContainerHelper2 & rCont
detail::element_alias2 aData
~OInterfaceIteratorHelper2()
Releases the connection to the container.
OInterfaceContainerHelper2 * getContainer(const css::uno::Type &rKey) const
Return the container created under this key.
~OMultiTypeInterfaceContainerHelper2()
Delete all containers.
void clear()
Remove all elements of all containers.
sal_Int32 removeInterface(const css::uno::Type &rKey, const css::uno::Reference< css::uno::XInterface > &rxIFace)
Removes an element from the container with the specified key.
OMultiTypeInterfaceContainerHelper2(::osl::Mutex &rMutex)
Create a container of interface containers.
sal_Int32 addInterface(const css::uno::Type &rKey, const css::uno::Reference< css::uno::XInterface > &r)
Inserts an element into the container with the specified key.
void disposeAndClear(const css::lang::EventObject &rEvt)
Call disposing on all object in the container that support XEventListener.
t_type2ptr::iterator findType(const css::uno::Type &rKey)
std::vector< css::uno::Type > getContainedTypes() const
Return all id's under which at least one interface is added.
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
static PropertyMapEntry const * find(const rtl::Reference< PropertySetInfo > &mxInfo, const OUString &aName) noexcept
css::uno::XInterface * pAsInterface
std::vector< css::uno::Reference< css::uno::XInterface > > * pAsVector