summaryrefslogtreecommitdiff
path: root/UnoControls/source/base/basecontainercontrol.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'UnoControls/source/base/basecontainercontrol.cxx')
-rw-r--r--UnoControls/source/base/basecontainercontrol.cxx92
1 files changed, 32 insertions, 60 deletions
diff --git a/UnoControls/source/base/basecontainercontrol.cxx b/UnoControls/source/base/basecontainercontrol.cxx
index 2f21979cc644..bf638a9c56a4 100644
--- a/UnoControls/source/base/basecontainercontrol.cxx
+++ b/UnoControls/source/base/basecontainercontrol.cxx
@@ -53,23 +53,25 @@ BaseContainerControl::~BaseContainerControl()
Any SAL_CALL BaseContainerControl::queryInterface( const Type& rType )
{
- // Attention:
- // Don't use mutex or guard in this method!!! Is a method of XInterface.
- Any aReturn;
- Reference< XInterface > xDel = BaseControl::impl_getDelegator();
- if ( xDel.is() )
+ // Ask for my own supported interfaces ...
+ // Attention: XTypeProvider and XInterface are supported by WeakComponentImplHelper!
+ Any aReturn ( ::cppu::queryInterface( rType ,
+ static_cast< XControlModel* > ( this ) ,
+ static_cast< XControlContainer* > ( this )
+ )
+ );
+
+ // If searched interface supported by this class ...
+ if ( aReturn.hasValue() )
{
- // If a delegator exists, forward question to its queryInterface.
- // Delegator will ask its own queryAggregation!
- aReturn = xDel->queryInterface( rType );
+ // ... return this information.
+ return aReturn;
}
else
{
- // If a delegator is unknown, forward question to own queryAggregation.
- aReturn = queryAggregation( rType );
+ // Else; ... ask baseclass for interfaces!
+ return BaseControl::queryInterface( rType );
}
-
- return aReturn;
}
// XTypeProvider
@@ -84,31 +86,6 @@ Sequence< Type > SAL_CALL BaseContainerControl::getTypes()
return ourTypeCollection.getTypes();
}
-// XAggregation
-
-Any SAL_CALL BaseContainerControl::queryAggregation( const Type& aType )
-{
- // Ask for my own supported interfaces ...
- // Attention: XTypeProvider and XInterface are supported by OComponentHelper!
- Any aReturn ( ::cppu::queryInterface( aType ,
- static_cast< XControlModel* > ( this ) ,
- static_cast< XControlContainer* > ( this )
- )
- );
-
- // If searched interface supported by this class ...
- if ( aReturn.hasValue() )
- {
- // ... return this information.
- return aReturn;
- }
- else
- {
- // Else; ... ask baseclass for interfaces!
- return BaseControl::queryAggregation( aType );
- }
-}
-
// XControl
void SAL_CALL BaseContainerControl::createPeer( const Reference< XToolkit >& xToolkit ,
@@ -123,7 +100,7 @@ void SAL_CALL BaseContainerControl::createPeer( const Reference< XToolkit >&
// create peers at all children
Sequence< Reference< XControl > > seqControlList = getControls();
- for ( auto& rxControl : seqControlList )
+ for ( auto& rxControl : asNonConstRange(seqControlList) )
{
rxControl->createPeer( xToolkit, getPeer() );
}
@@ -195,31 +172,31 @@ void SAL_CALL BaseContainerControl::addControl ( const OUString& rName, const Re
return;
// take memory for new item
- IMPL_ControlInfo* pNewControl = new IMPL_ControlInfo;
+ IMPL_ControlInfo aNewControl;
// Ready for multithreading
MutexGuard aGuard (m_aMutex);
// set control
- pNewControl->sName = rName;
- pNewControl->xControl = rControl;
+ aNewControl.sName = rName;
+ aNewControl.xControl = rControl;
// and insert in list
- maControlInfoList.emplace_back( pNewControl );
+ maControlInfoList.emplace_back( aNewControl );
// initialize new control
- pNewControl->xControl->setContext ( static_cast<OWeakObject*>(this) );
- pNewControl->xControl->addEventListener ( static_cast< XEventListener* >( static_cast< XWindowListener* >( this ) ) );
+ aNewControl.xControl->setContext (getXWeak());
+ aNewControl.xControl->addEventListener ( static_cast< XEventListener* >( static_cast< XWindowListener* >( this ) ) );
// when container has a peer...
if (getPeer().is())
{
// ... then create a peer on child
- pNewControl->xControl->createPeer ( getPeer()->getToolkit(), getPeer() );
+ aNewControl.xControl->createPeer ( getPeer()->getToolkit(), getPeer() );
}
// 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 +208,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() )
@@ -255,7 +232,7 @@ void SAL_CALL BaseContainerControl::removeControl ( const Reference< XControl >
for ( size_t n = 0; n < nControls; n++ )
{
// Search for right control
- IMPL_ControlInfo* pControl = maControlInfoList[ n ].get();
+ IMPL_ControlInfo* pControl = &maControlInfoList[ n ];
if ( rControl == pControl->xControl )
{
//.is it found ... remove listener from control
@@ -266,7 +243,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 +252,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() )
{
@@ -308,18 +285,14 @@ Reference< XControl > SAL_CALL BaseContainerControl::getControl ( const OUString
// Ready for multithreading
MutexGuard aGuard ( Mutex::getGlobalMutex() );
- size_t nControls = maControlInfoList.size();
-
// Search for right control
- for( size_t nCount = 0; nCount < nControls; ++nCount )
+ for( const IMPL_ControlInfo& rSearchControl : maControlInfoList )
{
- IMPL_ControlInfo* pSearchControl = maControlInfoList[ nCount ].get();
-
- if ( pSearchControl->sName == rName )
+ if ( rSearchControl.sName == rName )
{
// We have found it ...
// Break operation and return.
- return pSearchControl->xControl;
+ return rSearchControl.xControl;
}
}
@@ -340,10 +313,9 @@ Sequence< Reference< XControl > > SAL_CALL BaseContainerControl::getControls ()
Reference< XControl > * pDestination = aDescriptor.getArray ();
// Copy controls to sequence
- for( nCount = 0; nCount < nControls; ++nCount )
+ for( const IMPL_ControlInfo& rCopyControl : maControlInfoList )
{
- IMPL_ControlInfo* pCopyControl = maControlInfoList[ nCount ].get();
- pDestination [ nCount ] = pCopyControl->xControl;
+ pDestination [ nCount++ ] = rCopyControl.xControl;
}
// Return sequence