summaryrefslogtreecommitdiff
path: root/comphelper
diff options
context:
space:
mode:
authorDaniel Robertson <danlrobertson89@gmail.com>2015-09-23 08:53:42 -0400
committerNoel Grandin <noelgrandin@gmail.com>2015-09-24 16:23:34 +0000
commit96fa0df15b2be95fc3c4dc3df8ad9b77a4baeebd (patch)
tree8b5a80990e6508b0996a6ec66c8ed6f0b70aa184 /comphelper
parent74ce05b940be952be63687f31be45a58afa1d1ee (diff)
comphelper: replace for_each with range-based for
Replace complex uses of ::std::for_each with a range-based for-loop. Change-Id: I57d3d2e830e7700b793e1836777cbe72504c6825 Reviewed-on: https://gerrit.libreoffice.org/18817 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'comphelper')
-rw-r--r--comphelper/source/container/NamedPropertyValuesContainer.cxx9
-rw-r--r--comphelper/source/container/embeddedobjectcontainer.cxx86
-rw-r--r--comphelper/source/container/namecontainer.cxx7
-rw-r--r--comphelper/source/eventattachermgr/eventattachermgr.cxx150
-rw-r--r--comphelper/source/misc/accessiblewrapper.cxx64
-rw-r--r--comphelper/source/property/MasterPropertySet.cxx36
-rw-r--r--comphelper/source/property/MasterPropertySetInfo.cxx18
-rw-r--r--comphelper/source/property/propertysetinfo.cxx7
8 files changed, 137 insertions, 240 deletions
diff --git a/comphelper/source/container/NamedPropertyValuesContainer.cxx b/comphelper/source/container/NamedPropertyValuesContainer.cxx
index 391e0507d723..513813fce232 100644
--- a/comphelper/source/container/NamedPropertyValuesContainer.cxx
+++ b/comphelper/source/container/NamedPropertyValuesContainer.cxx
@@ -151,16 +151,11 @@ css::uno::Any SAL_CALL NamedPropertyValuesContainer::getByName( const OUString&
css::uno::Sequence< OUString > SAL_CALL NamedPropertyValuesContainer::getElementNames( )
throw(css::uno::RuntimeException, std::exception)
{
- NamedPropertyValues::iterator aIter = maProperties.begin();
- const NamedPropertyValues::iterator aEnd = maProperties.end();
-
uno::Sequence< OUString > aNames( maProperties.size() );
OUString* pNames = aNames.getArray();
- while( aIter != aEnd )
- {
- *pNames++ = (*aIter++).first;
- }
+ for( const auto& rProperty : maProperties )
+ *pNames++ = rProperty.first;
return aNames;
}
diff --git a/comphelper/source/container/embeddedobjectcontainer.cxx b/comphelper/source/container/embeddedobjectcontainer.cxx
index 778b3265a05f..2dbbe7ae9796 100644
--- a/comphelper/source/container/embeddedobjectcontainer.cxx
+++ b/comphelper/source/container/embeddedobjectcontainer.cxx
@@ -196,11 +196,10 @@ EmbeddedObjectContainer::~EmbeddedObjectContainer()
void EmbeddedObjectContainer::CloseEmbeddedObjects()
{
- EmbeddedObjectContainerNameMap::iterator aIt = pImpl->maObjectContainer.begin();
- while ( aIt != pImpl->maObjectContainer.end() )
+ for( const auto& rObj : pImpl->maObjectContainer )
{
- uno::Reference < util::XCloseable > xClose( (*aIt).second, uno::UNO_QUERY );
- if ( xClose.is() )
+ uno::Reference < util::XCloseable > xClose( rObj.second, uno::UNO_QUERY );
+ if( xClose.is() )
{
try
{
@@ -210,8 +209,6 @@ void EmbeddedObjectContainer::CloseEmbeddedObjects()
{
}
}
-
- ++aIt;
}
}
@@ -234,10 +231,11 @@ OUString EmbeddedObjectContainer::CreateUniqueObjectName()
uno::Sequence < OUString > EmbeddedObjectContainer::GetObjectNames()
{
uno::Sequence < OUString > aSeq( pImpl->maObjectContainer.size() );
- EmbeddedObjectContainerNameMap::iterator aIt = pImpl->maObjectContainer.begin();
- sal_Int32 nIdx=0;
- while ( aIt != pImpl->maObjectContainer.end() )
- aSeq[nIdx++] = (*aIt++).first;
+ OUString* pNames = aSeq.getArray();
+
+ for( const auto& rObj : pImpl->maObjectContainer )
+ *pNames++ = rObj.first;
+
return aSeq;
}
@@ -260,15 +258,11 @@ bool EmbeddedObjectContainer::HasEmbeddedObject( const OUString& rName )
bool EmbeddedObjectContainer::HasEmbeddedObject( const uno::Reference < embed::XEmbeddedObject >& xObj )
{
- EmbeddedObjectContainerNameMap::iterator aIt = pImpl->maObjectContainer.begin();
- while ( aIt != pImpl->maObjectContainer.end() )
+ for( const auto& rObj : pImpl->maObjectContainer )
{
- if ( (*aIt).second == xObj )
+ if( rObj.second == xObj )
return true;
- else
- ++aIt;
}
-
return false;
}
@@ -283,15 +277,11 @@ bool EmbeddedObjectContainer::HasInstantiatedEmbeddedObject( const OUString& rNa
OUString EmbeddedObjectContainer::GetEmbeddedObjectName( const css::uno::Reference < css::embed::XEmbeddedObject >& xObj )
{
- EmbeddedObjectContainerNameMap::iterator aIt = pImpl->maObjectContainer.begin();
- while ( aIt != pImpl->maObjectContainer.end() )
+ for( const auto& rObj : pImpl->maObjectContainer )
{
- if ( (*aIt).second == xObj )
- return (*aIt).first;
- else
- ++aIt;
+ if( rObj.second == xObj )
+ return rObj.first;
}
-
SAL_WARN( "comphelper.container", "Unknown object!" );
return OUString();
}
@@ -434,13 +424,15 @@ void EmbeddedObjectContainer::AddEmbeddedObject( const css::uno::Reference < css
// look for object in temporary container
if ( pImpl->mpTempObjectContainer )
{
- aIt = pImpl->mpTempObjectContainer->pImpl->maObjectContainer.begin();
- while ( aIt != pImpl->mpTempObjectContainer->pImpl->maObjectContainer.end() )
+ EmbeddedObjectContainerNameMap::iterator aEnd = pImpl->mpTempObjectContainer->pImpl->maObjectContainer.end();
+ for( EmbeddedObjectContainerNameMap::iterator aIter = pImpl->mpTempObjectContainer->pImpl->maObjectContainer.end();
+ aIter != aEnd;
+ ++aIter )
{
- if ( (*aIt).second == xObj )
+ if ( aIter->second == xObj )
{
// copy replacement image from temporary container (if there is any)
- OUString aTempName = (*aIt).first;
+ OUString aTempName = aIter->first;
OUString aMediaType;
uno::Reference < io::XInputStream > xStream = pImpl->mpTempObjectContainer->GetGraphicStream( xObj, &aMediaType );
if ( xStream.is() )
@@ -464,11 +456,9 @@ void EmbeddedObjectContainer::AddEmbeddedObject( const css::uno::Reference < css
}
// temp. container needs to forget the object
- pImpl->mpTempObjectContainer->pImpl->maObjectContainer.erase( aIt );
+ pImpl->mpTempObjectContainer->pImpl->maObjectContainer.erase( aIter );
break;
}
- else
- ++aIt;
}
}
}
@@ -857,17 +847,17 @@ bool EmbeddedObjectContainer::MoveEmbeddedObject( EmbeddedObjectContainer& rSrc,
{
// now remove the object from the former container
bRet = false;
- EmbeddedObjectContainerNameMap::iterator aIt = rSrc.pImpl->maObjectContainer.begin();
- while ( aIt != rSrc.pImpl->maObjectContainer.end() )
+ EmbeddedObjectContainerNameMap::iterator aEnd = rSrc.pImpl->maObjectContainer.end();
+ for( EmbeddedObjectContainerNameMap::iterator aIter = rSrc.pImpl->maObjectContainer.begin();
+ aIter != aEnd;
+ ++aIter )
{
- if ( (*aIt).second == xObj )
+ if ( aIter->second == xObj )
{
- rSrc.pImpl->maObjectContainer.erase( aIt );
+ rSrc.pImpl->maObjectContainer.erase( aIter );
bRet = true;
break;
}
-
- ++aIt;
}
SAL_WARN_IF( !bRet, "comphelper.container", "Object not found for removal!" );
@@ -1055,20 +1045,20 @@ bool EmbeddedObjectContainer::RemoveEmbeddedObject( const uno::Reference < embed
}
bool bFound = false;
- EmbeddedObjectContainerNameMap::iterator aIt = pImpl->maObjectContainer.begin();
- while ( aIt != pImpl->maObjectContainer.end() )
+ EmbeddedObjectContainerNameMap::iterator aEnd = pImpl->maObjectContainer.end();
+ for( EmbeddedObjectContainerNameMap::iterator aIter = pImpl->maObjectContainer.begin();
+ aIter != aEnd;
+ ++aIter )
{
- if ( (*aIt).second == xObj )
+ if ( aIter->second == xObj )
{
- pImpl->maObjectContainer.erase( aIt );
+ pImpl->maObjectContainer.erase( aIter );
bFound = true;
uno::Reference < container::XChild > xChild( xObj, uno::UNO_QUERY );
if ( xChild.is() )
xChild->setParent( uno::Reference < uno::XInterface >() );
break;
}
-
- ++aIt;
}
SAL_WARN_IF( !bFound,"comphelper.container", "Object not found for removal!" );
@@ -1103,17 +1093,17 @@ bool EmbeddedObjectContainer::CloseEmbeddedObject( const uno::Reference < embed:
// disconnect the object from the container and close it if possible
bool bFound = false;
- EmbeddedObjectContainerNameMap::iterator aIt = pImpl->maObjectContainer.begin();
- while ( aIt != pImpl->maObjectContainer.end() )
+ EmbeddedObjectContainerNameMap::iterator aEnd = pImpl->maObjectContainer.end();
+ for( EmbeddedObjectContainerNameMap::iterator aIter = pImpl->maObjectContainer.begin();
+ aIter != aEnd;
+ ++aIter )
{
- if ( (*aIt).second == xObj )
+ if ( aIter->second == xObj )
{
- pImpl->maObjectContainer.erase( aIt );
+ pImpl->maObjectContainer.erase( aIter );
bFound = true;
break;
}
-
- ++aIt;
}
if ( bFound )
diff --git a/comphelper/source/container/namecontainer.cxx b/comphelper/source/container/namecontainer.cxx
index e23cc1b793cd..294a5f7ee7ed 100644
--- a/comphelper/source/container/namecontainer.cxx
+++ b/comphelper/source/container/namecontainer.cxx
@@ -160,15 +160,12 @@ Sequence< OUString > SAL_CALL NameContainer::getElementNames( )
{
MutexGuard aGuard( maMutex );
- SvGenericNameContainerMapImpl::iterator aIter = maProperties.begin();
- const SvGenericNameContainerMapImpl::iterator aEnd = maProperties.end();
-
Sequence< OUString > aNames( maProperties.size() );
OUString* pNames = aNames.getArray();
- while( aIter != aEnd )
+ for( const auto& rProperty : maProperties )
{
- *pNames++ = (*aIter++).first;
+ *pNames++ = rProperty.first;
}
return aNames;
diff --git a/comphelper/source/eventattachermgr/eventattachermgr.cxx b/comphelper/source/eventattachermgr/eventattachermgr.cxx
index 72e32f64eb10..c04e65c3d99d 100644
--- a/comphelper/source/eventattachermgr/eventattachermgr.cxx
+++ b/comphelper/source/eventattachermgr/eventattachermgr.cxx
@@ -416,39 +416,6 @@ Reference< XIdlReflection > ImplEventAttacherManager::getReflection() throw( Exc
return aIt;
}
-namespace {
-
-class DetachObject : public std::unary_function<AttachedObject_Impl, void>
-{
- ImplEventAttacherManager& mrMgr;
- sal_Int32 mnIdx;
-public:
- DetachObject(ImplEventAttacherManager& rMgr, sal_Int32 nIdx) :
- mrMgr(rMgr), mnIdx(nIdx) {}
-
- void operator() (AttachedObject_Impl& rObj)
- {
- mrMgr.detach(mnIdx, rObj.xTarget);
- }
-};
-
-class AttachObject : public std::unary_function<AttachedObject_Impl, void>
-{
- ImplEventAttacherManager& mrMgr;
- sal_Int32 mnIdx;
-public:
- AttachObject(ImplEventAttacherManager& rMgr, sal_Int32 nIdx) :
- mrMgr(rMgr), mnIdx(nIdx) {}
-
- void operator() (AttachedObject_Impl& rObj)
- {
- mrMgr.attach(mnIdx, rObj.xTarget, rObj.aHelper);
- }
-};
-
-}
-
-
// Methods of XEventAttacherManager
void SAL_CALL ImplEventAttacherManager::registerScriptEvent
(
@@ -468,31 +435,26 @@ void SAL_CALL ImplEventAttacherManager::registerScriptEvent
sal_Int32 nLastDot = aEvt.ListenerType.lastIndexOf('.');
if (nLastDot != -1)
aEvt.ListenerType = aEvt.ListenerType.copy(nLastDot+1);
- (*aIt).aEventList.push_back( aEvt );
+ aIt->aEventList.push_back( aEvt );
// register new new Event
- ::std::deque< AttachedObject_Impl >::iterator aObjIt = (*aIt).aObjList.begin();
- ::std::deque< AttachedObject_Impl >::iterator aObjEnd = (*aIt).aObjList.end();
- while( aObjIt != aObjEnd )
+ for( auto& rObj : aIt->aObjList )
{
// resize
- sal_Int32 nPos = (*aObjIt).aAttachedListenerSeq.getLength();
- (*aObjIt).aAttachedListenerSeq.realloc( nPos + 1 );
- Reference< XEventListener > * pArray = (*aObjIt).aAttachedListenerSeq.getArray();
-
+ sal_Int32 nPos = rObj.aAttachedListenerSeq.getLength();
+ rObj.aAttachedListenerSeq.realloc( nPos + 1 );
+ Reference< XEventListener >* pArray = rObj.aAttachedListenerSeq.getArray();
Reference< XAllListener > xAll =
new AttacherAllListener_Impl( this, ScriptEvent.ScriptType, ScriptEvent.ScriptCode );
try
{
- pArray[nPos] = xAttacher->attachSingleEventListener( (*aObjIt).xTarget, xAll,
- (*aObjIt).aHelper, ScriptEvent.ListenerType,
+ pArray[nPos] = xAttacher->attachSingleEventListener( rObj.xTarget, xAll,
+ rObj.aHelper, ScriptEvent.ListenerType,
ScriptEvent.AddListenerParam, ScriptEvent.EventMethod );
}
catch( Exception& )
{
}
-
- ++aObjIt;
}
}
@@ -507,17 +469,17 @@ void SAL_CALL ImplEventAttacherManager::registerScriptEvents
Guard< Mutex > aGuard( aLock );
// Examine the index and apply the array
- ::std::deque<AttacherIndex_Impl>::iterator aIt = implCheckIndex( nIndex );
-
- ::std::deque< AttachedObject_Impl > aList = (*aIt).aObjList;
- ::std::for_each(aList.begin(), aList.end(), DetachObject(*this, nIndex));
+ ::std::deque< AttachedObject_Impl > aList = implCheckIndex( nIndex )->aObjList;
+ for( const auto& rObj : aList )
+ this->detach( nIndex, rObj.xTarget );
const ScriptEventDescriptor* pArray = ScriptEvents.getConstArray();
sal_Int32 nLen = ScriptEvents.getLength();
for( sal_Int32 i = 0 ; i < nLen ; i++ )
registerScriptEvent( nIndex, pArray[ i ] );
- ::std::for_each(aList.begin(), aList.end(), AttachObject(*this, nIndex));
+ for( const auto& rObj : aList )
+ this->attach( nIndex, rObj.xTarget, rObj.aHelper );
}
@@ -534,29 +496,31 @@ void SAL_CALL ImplEventAttacherManager::revokeScriptEvent
::std::deque<AttacherIndex_Impl>::iterator aIt = implCheckIndex( nIndex );
- ::std::deque< AttachedObject_Impl > aList = (*aIt).aObjList;
- ::std::for_each(aList.begin(), aList.end(), DetachObject(*this, nIndex));
+ ::std::deque< AttachedObject_Impl > aList = aIt->aObjList;
+ for( const auto& rObj : aList )
+ this->detach( nIndex, rObj.xTarget );
OUString aLstType = ListenerType;
sal_Int32 nLastDot = aLstType.lastIndexOf('.');
if (nLastDot != -1)
aLstType = aLstType.copy(nLastDot+1);
- ::std::deque< ScriptEventDescriptor >::iterator aEvtIt = (*aIt).aEventList.begin();
- ::std::deque< ScriptEventDescriptor >::iterator aEvtEnd = (*aIt).aEventList.end();
- while( aEvtIt != aEvtEnd )
+ ::std::deque< ScriptEventDescriptor >::const_iterator aEvtEnd = aIt->aEventList.end();
+ for( std::deque< ScriptEventDescriptor >::iterator aEvtIt = aIt->aEventList.begin();
+ aEvtIt != aEvtEnd;
+ ++aEvtIt )
{
- if( aLstType == (*aEvtIt).ListenerType
- && EventMethod == (*aEvtIt).EventMethod
- && ToRemoveListenerParam == (*aEvtIt).AddListenerParam )
+ if( aLstType == aEvtIt->ListenerType &&
+ EventMethod == aEvtIt->EventMethod &&
+ ToRemoveListenerParam == aEvtIt->AddListenerParam )
{
- (*aIt).aEventList.erase( aEvtIt );
+ aIt->aEventList.erase( aEvtIt );
break;
}
-
- ++aEvtIt;
}
- ::std::for_each(aList.begin(), aList.end(), AttachObject(*this, nIndex));
+
+ for( const auto& rObj : aList )
+ this->attach( nIndex, rObj.xTarget, rObj.aHelper );
}
@@ -566,10 +530,12 @@ void SAL_CALL ImplEventAttacherManager::revokeScriptEvents(sal_Int32 nIndex )
Guard< Mutex > aGuard( aLock );
::std::deque<AttacherIndex_Impl>::iterator aIt = implCheckIndex( nIndex );
- ::std::deque< AttachedObject_Impl > aList = (*aIt).aObjList;
- ::std::for_each(aList.begin(), aList.end(), DetachObject(*this, nIndex));
- (*aIt).aEventList.clear();
- ::std::for_each(aList.begin(), aList.end(), AttachObject(*this, nIndex));
+ ::std::deque< AttachedObject_Impl > aList = aIt->aObjList;
+ for( const auto& rObj : aList )
+ this->detach( nIndex, rObj.xTarget );
+ aIt->aEventList.clear();
+ for( const auto& rObj : aList )
+ this->attach( nIndex, rObj.xTarget, rObj.aHelper );
}
@@ -594,8 +560,10 @@ void SAL_CALL ImplEventAttacherManager::removeEntry(sal_Int32 nIndex)
Guard< Mutex > aGuard( aLock );
::std::deque<AttacherIndex_Impl>::iterator aIt = implCheckIndex( nIndex );
- ::std::deque< AttachedObject_Impl > aList = (*aIt).aObjList;
- ::std::for_each(aList.begin(), aList.end(), DetachObject(*this, nIndex));
+ ::std::deque< AttachedObject_Impl > aList = aIt->aObjList;
+ for( const auto& rObj : aList )
+ this->detach( nIndex, rObj.xTarget );
+
aIndex.erase( aIt );
}
@@ -606,16 +574,13 @@ Sequence< ScriptEventDescriptor > SAL_CALL ImplEventAttacherManager::getScriptEv
Guard< Mutex > aGuard( aLock );
::std::deque<AttacherIndex_Impl>::iterator aIt = implCheckIndex( nIndex );
- Sequence< ScriptEventDescriptor > aSeq( (*aIt).aEventList.size() );
+ Sequence< ScriptEventDescriptor > aSeq( aIt->aEventList.size() );
ScriptEventDescriptor * pArray = aSeq.getArray();
- ::std::deque< ScriptEventDescriptor >::iterator aEvtIt = (*aIt).aEventList.begin();
- ::std::deque< ScriptEventDescriptor >::iterator aEvtEnd = (*aIt).aEventList.end();
sal_Int32 i = 0;
- while( aEvtIt != aEvtEnd )
+ for( const auto& rEvt : aIt->aEventList )
{
- pArray[i++] = *aEvtIt;
- ++aEvtIt;
+ pArray[i++] = rEvt;
}
return aSeq;
}
@@ -648,7 +613,6 @@ void SAL_CALL ImplEventAttacherManager::attach(sal_Int32 nIndex, const Reference
aTmp.aHelper = Helper;
aCurrentPosition->aObjList.push_back( aTmp );
- //::std::deque< AttachedObject_Impl >::iterator aObjIt = (*aIt).aObjList.back();
AttachedObject_Impl & rCurObj = aCurrentPosition->aObjList.back();
rCurObj.aAttachedListenerSeq = Sequence< Reference< XEventListener > >( aCurrentPosition->aEventList.size() );
@@ -693,37 +657,34 @@ void SAL_CALL ImplEventAttacherManager::detach(sal_Int32 nIndex, const Reference
throw IllegalArgumentException();
::std::deque< AttacherIndex_Impl >::iterator aCurrentPosition = aIndex.begin() + nIndex;
- ::std::deque< AttachedObject_Impl >::iterator aObjIt = aCurrentPosition->aObjList.begin();
::std::deque< AttachedObject_Impl >::iterator aObjEnd = aCurrentPosition->aObjList.end();
- while( aObjIt != aObjEnd )
+ for( ::std::deque< AttachedObject_Impl >::iterator aObjIt = aCurrentPosition->aObjList.begin();
+ aObjIt != aObjEnd;
+ ++aObjIt )
{
- if( (*aObjIt).xTarget == xObject )
+ if( aObjIt->xTarget == xObject )
{
- Reference< XEventListener > * pArray = (*aObjIt).aAttachedListenerSeq.getArray();
+ Reference< XEventListener > * pArray = aObjIt->aAttachedListenerSeq.getArray();
- ::std::deque< ScriptEventDescriptor >::iterator aEvtIt = aCurrentPosition->aEventList.begin();
- ::std::deque< ScriptEventDescriptor >::iterator aEvtEnd = aCurrentPosition->aEventList.end();
sal_Int32 i = 0;
- while( aEvtIt != aEvtEnd )
+ for( const auto& rEvt : aCurrentPosition->aEventList )
{
if( pArray[i].is() )
{
try
{
- xAttacher->removeListener( (*aObjIt).xTarget, (*aEvtIt).ListenerType,
- (*aEvtIt).AddListenerParam, pArray[i] );
+ xAttacher->removeListener( aObjIt->xTarget, rEvt.ListenerType,
+ rEvt.AddListenerParam, pArray[i] );
}
catch( Exception& )
{
}
}
- i++;
- ++aEvtIt;
+ ++i;
}
aCurrentPosition->aObjList.erase( aObjIt );
break;
}
- ++aObjIt;
}
}
@@ -768,26 +729,17 @@ void SAL_CALL ImplEventAttacherManager::write(const Reference< XObjectOutputStre
OutStream->writeLong( aIndex.size() );
// Write out sequences
- ::std::deque<AttacherIndex_Impl>::iterator aIt = aIndex.begin();
- ::std::deque<AttacherIndex_Impl>::iterator aEnd = aIndex.end();
- while( aIt != aEnd )
+ for( const auto& rIx : aIndex )
{
- // Write out the length of the sequence and all descriptions
- OutStream->writeLong( (*aIt).aEventList.size() );
- ::std::deque< ScriptEventDescriptor >::iterator aEvtIt = (*aIt).aEventList.begin();
- ::std::deque< ScriptEventDescriptor >::iterator aEvtEnd = (*aIt).aEventList.end();
- while( aEvtIt != aEvtEnd )
+ OutStream->writeLong( rIx.aEventList.size() );
+ for( const auto& rDesc : rIx.aEventList )
{
- const ScriptEventDescriptor& rDesc = (*aEvtIt);
OutStream->writeUTF( rDesc.ListenerType );
OutStream->writeUTF( rDesc.EventMethod );
OutStream->writeUTF( rDesc.AddListenerParam );
OutStream->writeUTF( rDesc.ScriptType );
OutStream->writeUTF( rDesc.ScriptCode );
-
- ++aEvtIt;
}
- ++aIt;
}
// The length is now known
diff --git a/comphelper/source/misc/accessiblewrapper.cxx b/comphelper/source/misc/accessiblewrapper.cxx
index b582fc2114c6..516390dcc356 100644
--- a/comphelper/source/misc/accessiblewrapper.cxx
+++ b/comphelper/source/misc/accessiblewrapper.cxx
@@ -32,42 +32,6 @@ using namespace ::com::sun::star::lang;
namespace comphelper
{
-
- struct RemoveEventListener
- : public ::std::unary_function< AccessibleMap::value_type, void >
- {
- private:
- Reference< XEventListener > m_xListener;
-
- public:
- explicit RemoveEventListener( const Reference< XEventListener >& _rxListener )
- :m_xListener( _rxListener )
- {
- }
-
- void operator()( const AccessibleMap::value_type& _rMapEntry ) const
- {
- Reference< XComponent > xComp( _rMapEntry.first, UNO_QUERY );
- if ( xComp.is() )
- xComp->removeEventListener( m_xListener );
- }
- };
-
-
- struct DisposeMappedChild
- : public ::std::unary_function< AccessibleMap::value_type, void >
- {
- void operator()( const AccessibleMap::value_type& _rMapEntry ) const
- {
- Reference< XComponent > xContextComponent;
- if ( _rMapEntry.second.is() )
- xContextComponent.set(_rMapEntry.second->getAccessibleContext(), css::uno::UNO_QUERY);
- if ( xContextComponent.is() )
- xContextComponent->dispose();
- }
- };
-
-
OWrappedAccessibleChildrenManager::OWrappedAccessibleChildrenManager( const Reference< XComponentContext >& _rxContext )
:m_xContext( _rxContext )
,m_bTransientChildren( true )
@@ -99,8 +63,9 @@ namespace comphelper
if ( m_aChildrenMap.end() != aRemovedPos )
{ // it was cached
// remove ourself as event listener
- RemoveEventListener aOperator( this );
- aOperator( *aRemovedPos );
+ Reference< XComponent > xComp( aRemovedPos->first, UNO_QUERY );
+ if( xComp.is() )
+ xComp->removeEventListener( this );
// and remove the entry from the map
m_aChildrenMap.erase( aRemovedPos );
}
@@ -110,7 +75,12 @@ namespace comphelper
void OWrappedAccessibleChildrenManager::invalidateAll( )
{
// remove as event listener from the map elements
- ::std::for_each( m_aChildrenMap.begin(), m_aChildrenMap.end(), RemoveEventListener( this ) );
+ for( const auto& rChild : m_aChildrenMap )
+ {
+ Reference< XComponent > xComp( rChild.first, UNO_QUERY );
+ if( xComp.is() )
+ xComp->removeEventListener( this );
+ }
// clear the map
AccessibleMap aMap;
m_aChildrenMap.swap( aMap );
@@ -167,8 +137,20 @@ namespace comphelper
void OWrappedAccessibleChildrenManager::dispose()
{
// dispose our children
- ::std::for_each( m_aChildrenMap.begin(), m_aChildrenMap.end(), RemoveEventListener( this ) );
- ::std::for_each( m_aChildrenMap.begin(), m_aChildrenMap.end(), DisposeMappedChild( ) );
+ for( const auto rChild : m_aChildrenMap )
+ {
+ Reference< XComponent > xComp( rChild.first, UNO_QUERY );
+ if( xComp.is() )
+ xComp->removeEventListener( this );
+
+ Reference< XComponent > xContextComponent;
+ if( rChild.second.is() )
+ xContextComponent.set( rChild.second->getAccessibleContext(),
+ ::css::uno::UNO_QUERY );
+ if( xContextComponent.is() )
+ xContextComponent->dispose();
+ }
+
// clear our children
AccessibleMap aMap;
m_aChildrenMap.swap( aMap );
diff --git a/comphelper/source/property/MasterPropertySet.cxx b/comphelper/source/property/MasterPropertySet.cxx
index 358e6918fca6..e6c7ed2b9c90 100644
--- a/comphelper/source/property/MasterPropertySet.cxx
+++ b/comphelper/source/property/MasterPropertySet.cxx
@@ -78,12 +78,8 @@ MasterPropertySet::MasterPropertySet( comphelper::MasterPropertySetInfo* pInfo,
MasterPropertySet::~MasterPropertySet()
throw()
{
- SlaveMap::iterator aEnd = maSlaveMap.end(), aIter = maSlaveMap.begin();
- while (aIter != aEnd )
- {
- delete (*aIter).second;
- ++aIter;
- }
+ for( auto& rSlave : maSlaveMap )
+ delete rSlave.second;
}
// XPropertySet
@@ -248,15 +244,13 @@ void SAL_CALL MasterPropertySet::setPropertyValues( const Sequence< OUString >&
}
_postSetValues();
- SlaveMap::const_iterator aSlaveIter = maSlaveMap.begin(), aSlaveEnd = maSlaveMap.end();
- while (aSlaveIter != aSlaveEnd)
+ for( const auto& rSlave : maSlaveMap )
{
- if ( (*aSlaveIter).second->IsInit())
+ if( rSlave.second->IsInit() )
{
- (*aSlaveIter).second->mpSlave->_postSetValues();
- (*aSlaveIter).second->SetInit ( false );
+ rSlave.second->mpSlave->_postSetValues();
+ rSlave.second->SetInit( false );
}
- ++aSlaveIter;
}
}
}
@@ -313,15 +307,13 @@ Sequence< Any > SAL_CALL MasterPropertySet::getPropertyValues( const Sequence< O
}
_postSetValues();
- SlaveMap::const_iterator aSlaveIter = maSlaveMap.begin(), aSlaveEnd = maSlaveMap.end();
- while (aSlaveIter != aSlaveEnd)
+ for( const auto& rSlave : maSlaveMap )
{
- if ( (*aSlaveIter).second->IsInit())
+ if( rSlave.second->IsInit() )
{
- (*aSlaveIter).second->mpSlave->_postSetValues();
- (*aSlaveIter).second->SetInit ( false );
+ rSlave.second->mpSlave->_postSetValues();
+ rSlave.second->SetInit( false );
}
- ++aSlaveIter;
}
}
return aValues;
@@ -415,15 +407,13 @@ Sequence< PropertyState > SAL_CALL MasterPropertySet::getPropertyStates( const S
}
}
_postGetPropertyState();
- SlaveMap::const_iterator aSlaveIter = maSlaveMap.begin(), aSlaveEnd = maSlaveMap.end();
- while (aSlaveIter != aSlaveEnd)
+ for( const auto& rSlave : maSlaveMap )
{
- if ( (*aSlaveIter).second->IsInit())
+ if( rSlave.second->IsInit() )
{
comphelper::ChainablePropertySet::_postGetPropertyState();
- (*aSlaveIter).second->SetInit ( false );
+ rSlave.second->SetInit( false );
}
- ++aSlaveIter;
}
}
return aStates;
diff --git a/comphelper/source/property/MasterPropertySetInfo.cxx b/comphelper/source/property/MasterPropertySetInfo.cxx
index ef7fbd42f483..9fe965e3b9bc 100644
--- a/comphelper/source/property/MasterPropertySetInfo.cxx
+++ b/comphelper/source/property/MasterPropertySetInfo.cxx
@@ -46,27 +46,21 @@ MasterPropertySetInfo::MasterPropertySetInfo( PropertyInfo const * pMap )
MasterPropertySetInfo::~MasterPropertySetInfo()
throw()
{
- PropertyDataHash::iterator aEnd = maMap.end(), aIter = maMap.begin();
- while (aIter != aEnd )
- {
- delete (*aIter).second;
- ++aIter;
- }
+ for( auto& rObj : maMap )
+ delete rObj.second;
}
void MasterPropertySetInfo::add( PropertyInfoHash &rHash, sal_uInt8 nMapId )
{
if( maProperties.getLength() )
maProperties.realloc( 0 );
- PropertyInfoHash::iterator aIter = rHash.begin(), aEnd = rHash.end();
- while ( aIter != aEnd )
+ for( const auto& rObj : rHash )
{
SAL_WARN_IF(
- maMap.find(aIter->first) != maMap.end(),
- "comphelper", "Duplicate property name \"" << aIter->first << "\"");
- maMap[(*aIter).first] = new PropertyData ( nMapId, (*aIter).second );
- ++aIter;
+ maMap.find(rObj.first) != maMap.end(),
+ "comphelper", "Duplicate property name \"" << rObj.first << "\"");
+ maMap[rObj.first] = new PropertyData ( nMapId, rObj.second );
}
}
diff --git a/comphelper/source/property/propertysetinfo.cxx b/comphelper/source/property/propertysetinfo.cxx
index 90985f24854b..a97b8abd0ae4 100644
--- a/comphelper/source/property/propertysetinfo.cxx
+++ b/comphelper/source/property/propertysetinfo.cxx
@@ -93,11 +93,9 @@ Sequence< Property > PropertyMapImpl::getProperties() throw()
maProperties = Sequence< Property >( maPropertyMap.size() );
Property* pProperties = maProperties.getArray();
- PropertyMap::iterator aIter = maPropertyMap.begin();
- const PropertyMap::iterator aEnd = maPropertyMap.end();
- while( aIter != aEnd )
+ for( const auto& rProperty : maPropertyMap )
{
- PropertyMapEntry const * pEntry = (*aIter).second;
+ PropertyMapEntry const * pEntry = rProperty.second;
pProperties->Name = pEntry->maName;
pProperties->Handle = pEntry->mnHandle;
@@ -105,7 +103,6 @@ Sequence< Property > PropertyMapImpl::getProperties() throw()
pProperties->Attributes = pEntry->mnAttributes;
++pProperties;
- ++aIter;
}
}