summaryrefslogtreecommitdiff
path: root/framework/source/uiconfiguration
diff options
context:
space:
mode:
authorJulien Nabet <serval2412@yahoo.fr>2018-03-17 21:42:27 +0100
committerJulien Nabet <serval2412@yahoo.fr>2018-03-17 23:08:48 +0100
commit823ef9ef3238efd92895254e0f8042ff1e543bb6 (patch)
tree08d58131644869f46319b246b919a33bbf64f46e /framework/source/uiconfiguration
parentb9cf7da2907f759c98b801939e7c04cf0b80388f (diff)
Use for-range loops in framework
Change-Id: I72ea832848fd7c76863bcee70a3303de488c0b0f Reviewed-on: https://gerrit.libreoffice.org/51471 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Diffstat (limited to 'framework/source/uiconfiguration')
-rw-r--r--framework/source/uiconfiguration/ImplImageList.cxx8
-rw-r--r--framework/source/uiconfiguration/imagemanagerimpl.cxx29
-rw-r--r--framework/source/uiconfiguration/moduleuicfgsupplier.cxx6
-rw-r--r--framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx64
-rw-r--r--framework/source/uiconfiguration/uiconfigurationmanager.cxx39
5 files changed, 56 insertions, 90 deletions
diff --git a/framework/source/uiconfiguration/ImplImageList.cxx b/framework/source/uiconfiguration/ImplImageList.cxx
index 19bb1e8a1266..c759acd6fdf4 100644
--- a/framework/source/uiconfiguration/ImplImageList.cxx
+++ b/framework/source/uiconfiguration/ImplImageList.cxx
@@ -38,9 +38,9 @@ ImplImageList::ImplImageList( const ImplImageList &aSrc )
, maImageSize(aSrc.maImageSize)
{
maImages.reserve( aSrc.maImages.size() );
- for ( std::vector<ImageAryData *>::const_iterator aIt = aSrc.maImages.begin(), aEnd = aSrc.maImages.end(); aIt != aEnd; ++aIt )
+ for (auto const& elem : aSrc.maImages)
{
- ImageAryData* pAryData = new ImageAryData( **aIt );
+ ImageAryData* pAryData = new ImageAryData(*elem);
maImages.push_back( pAryData );
if( !pAryData->maName.isEmpty() )
maNameHash [ pAryData->maName ] = pAryData;
@@ -49,8 +49,8 @@ ImplImageList::ImplImageList( const ImplImageList &aSrc )
ImplImageList::~ImplImageList()
{
- for ( std::vector<ImageAryData *>::iterator aIt = maImages.begin(), aEnd = maImages.end(); aIt != aEnd; ++aIt )
- delete *aIt;
+ for (auto const& elem : maImages)
+ delete elem;
}
void ImplImageList::AddImage( const OUString &aName,
diff --git a/framework/source/uiconfiguration/imagemanagerimpl.cxx b/framework/source/uiconfiguration/imagemanagerimpl.cxx
index ee88e2756541..080ac0db8aa7 100644
--- a/framework/source/uiconfiguration/imagemanagerimpl.cxx
+++ b/framework/source/uiconfiguration/imagemanagerimpl.cxx
@@ -995,24 +995,23 @@ void ImageManagerImpl::reload()
GraphicNameAccess* pReplacedImages( nullptr );
GraphicNameAccess* pRemovedImages( nullptr );
- const sal_uInt32 nNewCount = aNewUserCmdImageSet.size();
- for ( j = 0; j < nNewCount; j++ )
+ for (auto const& newUserCmdImage : aNewUserCmdImageSet)
{
- CommandMap::iterator pIter = aOldUserCmdImageSet.find( aNewUserCmdImageSet[j] );
+ CommandMap::iterator pIter = aOldUserCmdImageSet.find(newUserCmdImage);
if ( pIter != aOldUserCmdImageSet.end() )
{
pIter->second = true; // mark entry as replaced
if ( !pReplacedImages )
pReplacedImages = new GraphicNameAccess();
- pReplacedImages->addElement( aNewUserCmdImageSet[j],
- GetXGraphic(pImageList->GetImage(aNewUserCmdImageSet[j])) );
+ pReplacedImages->addElement( newUserCmdImage,
+ GetXGraphic(pImageList->GetImage(newUserCmdImage)) );
}
else
{
if ( !pInsertedImages )
pInsertedImages = new GraphicNameAccess();
- pInsertedImages->addElement( aNewUserCmdImageSet[j],
- GetXGraphic(pImageList->GetImage(aNewUserCmdImageSet[j])) );
+ pInsertedImages->addElement( newUserCmdImage,
+ GetXGraphic(pImageList->GetImage(newUserCmdImage)) );
}
}
@@ -1027,30 +1026,29 @@ void ImageManagerImpl::reload()
pDefaultImageList = implts_getDefaultImageList();
}
uno::Reference<XGraphic> xEmptyGraphic;
- CommandMap::const_iterator pIter = aOldUserCmdImageSet.begin();
- while ( pIter != aOldUserCmdImageSet.end() )
+ for (auto const& oldUserCmdImage : aOldUserCmdImageSet)
{
- if ( !pIter->second )
+ if ( !oldUserCmdImage.second )
{
if ( m_bUseGlobal )
{
- Image aImage = pDefaultImageList->getImageFromCommandURL( i, pIter->first );
+ Image aImage = pDefaultImageList->getImageFromCommandURL( i, oldUserCmdImage.first );
if ( !aImage )
- aImage = rGlobalImageList->getImageFromCommandURL( i, pIter->first );
+ aImage = rGlobalImageList->getImageFromCommandURL( i, oldUserCmdImage.first );
if ( !aImage )
{
// No image in the module/global image list => remove user image
if ( !pRemovedImages )
pRemovedImages = new GraphicNameAccess();
- pRemovedImages->addElement( pIter->first, xEmptyGraphic );
+ pRemovedImages->addElement( oldUserCmdImage.first, xEmptyGraphic );
}
else
{
// Image has been found in the module/global image list => replace user image
if ( !pReplacedImages )
pReplacedImages = new GraphicNameAccess();
- pReplacedImages->addElement(pIter->first, GetXGraphic(aImage));
+ pReplacedImages->addElement(oldUserCmdImage.first, GetXGraphic(aImage));
}
} // if ( m_bUseGlobal )
else
@@ -1058,10 +1056,9 @@ void ImageManagerImpl::reload()
// No image in the user image list => remove user image
if ( !pRemovedImages )
pRemovedImages = new GraphicNameAccess();
- pRemovedImages->addElement( pIter->first, xEmptyGraphic );
+ pRemovedImages->addElement( oldUserCmdImage.first, xEmptyGraphic );
}
}
- ++pIter;
}
aGuard.clear();
diff --git a/framework/source/uiconfiguration/moduleuicfgsupplier.cxx b/framework/source/uiconfiguration/moduleuicfgsupplier.cxx
index e451113d9aa1..095fcb5b0f66 100644
--- a/framework/source/uiconfiguration/moduleuicfgsupplier.cxx
+++ b/framework/source/uiconfiguration/moduleuicfgsupplier.cxx
@@ -124,13 +124,11 @@ void SAL_CALL ModuleUIConfigurationManagerSupplier::disposing()
osl::MutexGuard g(rBHelper.rMutex);
// dispose all our module user interface configuration managers
- ModuleToModuleCfgMgr::iterator pIter = m_aModuleToModuleUICfgMgrMap.begin();
- while ( pIter != m_aModuleToModuleUICfgMgrMap.end() )
+ for (auto const& elem : m_aModuleToModuleUICfgMgrMap)
{
- Reference< XComponent > xComponent( pIter->second, UNO_QUERY );
+ Reference< XComponent > xComponent( elem.second, UNO_QUERY );
if ( xComponent.is() )
xComponent->dispose();
- ++pIter;
}
m_aModuleToModuleUICfgMgrMap.clear();
m_xModuleMgr.clear();
diff --git a/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx b/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx
index 49f3db5ca722..92dfa66c1a00 100644
--- a/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx
+++ b/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx
@@ -278,17 +278,16 @@ void ModuleUIConfigurationManager::impl_fillSequenceWithElementTypeInfo( UIEleme
impl_preloadUIElementTypeList( LAYER_DEFAULT, nElementType );
UIElementDataHashMap& rUserElements = m_aUIElements[LAYER_USERDEFINED][nElementType].aElementsHashMap;
- UIElementDataHashMap::const_iterator pUserIter = rUserElements.begin();
OUString aCustomUrlPrefix( "custom_" );
- while ( pUserIter != rUserElements.end() )
+ for (auto const& userElement : rUserElements)
{
- sal_Int32 nIndex = pUserIter->second.aResourceURL.indexOf( aCustomUrlPrefix, RESOURCEURL_PREFIX_SIZE );
+ sal_Int32 nIndex = userElement.second.aResourceURL.indexOf( aCustomUrlPrefix, RESOURCEURL_PREFIX_SIZE );
if ( nIndex > RESOURCEURL_PREFIX_SIZE )
{
// Performance: Retrieve user interface name only for custom user interface elements.
// It's only used by them!
- UIElementData* pDataSettings = impl_findUIElementData( pUserIter->second.aResourceURL, nElementType );
+ UIElementData* pDataSettings = impl_findUIElementData( userElement.second.aResourceURL, nElementType );
if ( pDataSettings )
{
// Retrieve user interface name from XPropertySet interface
@@ -300,33 +299,31 @@ void ModuleUIConfigurationManager::impl_fillSequenceWithElementTypeInfo( UIEleme
a >>= aUIName;
}
- UIElementInfo aInfo( pUserIter->second.aResourceURL, aUIName );
- aUIElementInfoCollection.emplace( pUserIter->second.aResourceURL, aInfo );
+ UIElementInfo aInfo( userElement.second.aResourceURL, aUIName );
+ aUIElementInfoCollection.emplace( userElement.second.aResourceURL, aInfo );
}
}
else
{
// The user interface name for standard user interface elements is stored in the WindowState.xcu file
- UIElementInfo aInfo( pUserIter->second.aResourceURL, OUString() );
- aUIElementInfoCollection.emplace( pUserIter->second.aResourceURL, aInfo );
+ UIElementInfo aInfo( userElement.second.aResourceURL, OUString() );
+ aUIElementInfoCollection.emplace( userElement.second.aResourceURL, aInfo );
}
- ++pUserIter;
}
UIElementDataHashMap& rDefaultElements = m_aUIElements[LAYER_DEFAULT][nElementType].aElementsHashMap;
- UIElementDataHashMap::const_iterator pDefIter = rDefaultElements.begin();
- while ( pDefIter != rDefaultElements.end() )
+ for (auto const& defaultElement : rDefaultElements)
{
- UIElementInfoHashMap::const_iterator pIterInfo = aUIElementInfoCollection.find( pDefIter->second.aResourceURL );
+ UIElementInfoHashMap::const_iterator pIterInfo = aUIElementInfoCollection.find( defaultElement.second.aResourceURL );
if ( pIterInfo == aUIElementInfoCollection.end() )
{
- sal_Int32 nIndex = pDefIter->second.aResourceURL.indexOf( aCustomUrlPrefix, RESOURCEURL_PREFIX_SIZE );
+ sal_Int32 nIndex = defaultElement.second.aResourceURL.indexOf( aCustomUrlPrefix, RESOURCEURL_PREFIX_SIZE );
if ( nIndex > RESOURCEURL_PREFIX_SIZE )
{
// Performance: Retrieve user interface name only for custom user interface elements.
// It's only used by them!
- UIElementData* pDataSettings = impl_findUIElementData( pDefIter->second.aResourceURL, nElementType );
+ UIElementData* pDataSettings = impl_findUIElementData( defaultElement.second.aResourceURL, nElementType );
if ( pDataSettings )
{
// Retrieve user interface name from XPropertySet interface
@@ -337,20 +334,17 @@ void ModuleUIConfigurationManager::impl_fillSequenceWithElementTypeInfo( UIEleme
Any a = xPropSet->getPropertyValue( m_aPropUIName );
a >>= aUIName;
}
-
- UIElementInfo aInfo( pDefIter->second.aResourceURL, aUIName );
- aUIElementInfoCollection.emplace( pDefIter->second.aResourceURL, aInfo );
+ UIElementInfo aInfo( defaultElement.second.aResourceURL, aUIName );
+ aUIElementInfoCollection.emplace( defaultElement.second.aResourceURL, aInfo );
}
}
else
{
// The user interface name for standard user interface elements is stored in the WindowState.xcu file
- UIElementInfo aInfo( pDefIter->second.aResourceURL, OUString() );
- aUIElementInfoCollection.emplace( pDefIter->second.aResourceURL, aInfo );
+ UIElementInfo aInfo( defaultElement.second.aResourceURL, OUString() );
+ aUIElementInfoCollection.emplace( defaultElement.second.aResourceURL, aInfo );
}
}
-
- ++pDefIter;
}
}
@@ -542,11 +536,10 @@ ModuleUIConfigurationManager::UIElementData* ModuleUIConfigurationManager::impl
void ModuleUIConfigurationManager::impl_storeElementTypeData( const Reference< XStorage >& xStorage, UIElementType& rElementType, bool bResetModifyState )
{
UIElementDataHashMap& rHashMap = rElementType.aElementsHashMap;
- UIElementDataHashMap::iterator pIter = rHashMap.begin();
- while ( pIter != rHashMap.end() )
+ for (auto & elem : rHashMap)
{
- UIElementData& rElement = pIter->second;
+ UIElementData& rElement = elem.second;
if ( rElement.bModified )
{
if ( rElement.bDefault )
@@ -612,8 +605,6 @@ void ModuleUIConfigurationManager::impl_storeElementTypeData( const Reference< X
rElement.bModified = false;
}
}
-
- ++pIter;
}
// commit element type storage
@@ -634,7 +625,6 @@ void ModuleUIConfigurationManager::impl_resetElementTypeData(
ConfigEventNotifyContainer& rReplaceNotifyContainer )
{
UIElementDataHashMap& rHashMap = rUserElementType.aElementsHashMap;
- UIElementDataHashMap::iterator pIter = rHashMap.begin();
Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY );
Reference< XInterface > xIfac( xThis, UNO_QUERY );
@@ -643,9 +633,9 @@ void ModuleUIConfigurationManager::impl_resetElementTypeData(
// Make copies of the event structures to be thread-safe. We have to unlock our mutex before calling
// our listeners!
- while ( pIter != rHashMap.end() )
+ for (auto & elem : rHashMap)
{
- UIElementData& rElement = pIter->second;
+ UIElementData& rElement = elem.second;
if ( !rElement.bDefault )
{
if ( xDefaultNameAccess->hasByName( rElement.aName ))
@@ -685,8 +675,6 @@ void ModuleUIConfigurationManager::impl_resetElementTypeData(
rElement.bDefault = true;
}
}
-
- ++pIter;
}
// Remove all settings from our user interface elements
@@ -700,7 +688,6 @@ void ModuleUIConfigurationManager::impl_reloadElementTypeData(
ConfigEventNotifyContainer& rReplaceNotifyContainer )
{
UIElementDataHashMap& rHashMap = rUserElementType.aElementsHashMap;
- UIElementDataHashMap::iterator pIter = rHashMap.begin();
Reference< XNameAccess > xUserNameAccess( rUserElementType.xStorage, UNO_QUERY );
Reference< XNameAccess > xDefaultNameAccess( rDefaultElementType.xStorage, UNO_QUERY );
@@ -708,9 +695,9 @@ void ModuleUIConfigurationManager::impl_reloadElementTypeData(
Reference< XInterface > xIfac( xThis, UNO_QUERY );
sal_Int16 nType = rUserElementType.nElementType;
- while ( pIter != rHashMap.end() )
+ for (auto & elem : rHashMap)
{
- UIElementData& rElement = pIter->second;
+ UIElementData& rElement = elem.second;
if ( rElement.bModified )
{
if ( xUserNameAccess->hasByName( rElement.aName ))
@@ -770,7 +757,6 @@ void ModuleUIConfigurationManager::impl_reloadElementTypeData(
rElement.bDefault = true;
}
}
- ++pIter;
}
rUserElementType.bModified = false;
@@ -1096,15 +1082,13 @@ Sequence< Sequence< PropertyValue > > SAL_CALL ModuleUIConfigurationManager::get
aUIElementInfo[1].Name = m_aPropUIName;
aElementInfoSeq.resize( aUIElementInfoCollection.size() );
- UIElementInfoHashMap::const_iterator pIter = aUIElementInfoCollection.begin();
sal_Int32 n = 0;
- while ( pIter != aUIElementInfoCollection.end() )
+ for (auto const& elem : aUIElementInfoCollection)
{
- aUIElementInfo[0].Value <<= pIter->second.aResourceURL;
- aUIElementInfo[1].Value <<= pIter->second.aUIName;
+ aUIElementInfo[0].Value <<= elem.second.aResourceURL;
+ aUIElementInfo[1].Value <<= elem.second.aUIName;
aElementInfoSeq[n++] = aUIElementInfo;
- ++pIter;
}
return comphelper::containerToSequence(aElementInfoSeq);
diff --git a/framework/source/uiconfiguration/uiconfigurationmanager.cxx b/framework/source/uiconfiguration/uiconfigurationmanager.cxx
index 45dd1bf4e00a..9fb4b42ea11d 100644
--- a/framework/source/uiconfiguration/uiconfigurationmanager.cxx
+++ b/framework/source/uiconfiguration/uiconfigurationmanager.cxx
@@ -253,11 +253,10 @@ void UIConfigurationManager::impl_fillSequenceWithElementTypeInfo( UIElementInfo
impl_preloadUIElementTypeList( nElementType );
UIElementDataHashMap& rUserElements = m_aUIElements[nElementType].aElementsHashMap;
- UIElementDataHashMap::const_iterator pUserIter = rUserElements.begin();
- while ( pUserIter != rUserElements.end() )
+ for (auto const& elem : rUserElements)
{
- UIElementData* pDataSettings = impl_findUIElementData( pUserIter->second.aResourceURL, nElementType );
+ UIElementData* pDataSettings = impl_findUIElementData( elem.second.aResourceURL, nElementType );
if ( pDataSettings && !pDataSettings->bDefault )
{
// Retrieve user interface name from XPropertySet interface
@@ -269,10 +268,9 @@ void UIConfigurationManager::impl_fillSequenceWithElementTypeInfo( UIElementInfo
a >>= aUIName;
}
- UIElementInfo aInfo( pUserIter->second.aResourceURL, aUIName );
- aUIElementInfoCollection.emplace( pUserIter->second.aResourceURL, aInfo );
+ UIElementInfo aInfo( elem.second.aResourceURL, aUIName );
+ aUIElementInfoCollection.emplace( elem.second.aResourceURL, aInfo );
}
- ++pUserIter;
}
}
@@ -450,11 +448,10 @@ UIConfigurationManager::UIElementData* UIConfigurationManager::impl_findUIElemen
void UIConfigurationManager::impl_storeElementTypeData( Reference< XStorage > const & xStorage, UIElementType& rElementType, bool bResetModifyState )
{
UIElementDataHashMap& rHashMap = rElementType.aElementsHashMap;
- UIElementDataHashMap::iterator pIter = rHashMap.begin();
- while ( pIter != rHashMap.end() )
+ for (auto & elem : rHashMap)
{
- UIElementData& rElement = pIter->second;
+ UIElementData& rElement = elem.second;
if ( rElement.bModified )
{
if ( rElement.bDefault )
@@ -520,8 +517,6 @@ void UIConfigurationManager::impl_storeElementTypeData( Reference< XStorage > co
rElement.bModified = false;
}
}
-
- ++pIter;
}
// commit element type storage
@@ -539,16 +534,15 @@ void UIConfigurationManager::impl_resetElementTypeData(
ConfigEventNotifyContainer& rRemoveNotifyContainer )
{
UIElementDataHashMap& rHashMap = rDocElementType.aElementsHashMap;
- UIElementDataHashMap::iterator pIter = rHashMap.begin();
Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY );
Reference< XInterface > xIfac( xThis, UNO_QUERY );
// Make copies of the event structures to be thread-safe. We have to unlock our mutex before calling
// our listeners!
- while ( pIter != rHashMap.end() )
+ for (auto & elem : rHashMap)
{
- UIElementData& rElement = pIter->second;
+ UIElementData& rElement = elem.second;
if ( !rElement.bDefault )
{
// Remove user-defined settings from document
@@ -566,8 +560,6 @@ void UIConfigurationManager::impl_resetElementTypeData(
}
else
rElement.bModified = false;
-
- ++pIter;
}
// Remove all settings from our user interface elements
@@ -580,16 +572,15 @@ void UIConfigurationManager::impl_reloadElementTypeData(
ConfigEventNotifyContainer& rReplaceNotifyContainer )
{
UIElementDataHashMap& rHashMap = rDocElementType.aElementsHashMap;
- UIElementDataHashMap::iterator pIter = rHashMap.begin();
Reference< XStorage > xElementStorage( rDocElementType.xStorage );
Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY );
Reference< XInterface > xIfac( xThis, UNO_QUERY );
sal_Int16 nType = rDocElementType.nElementType;
- while ( pIter != rHashMap.end() )
+ for (auto & elem : rHashMap)
{
- UIElementData& rElement = pIter->second;
+ UIElementData& rElement = elem.second;
if ( rElement.bModified )
{
if ( xElementStorage->hasByName( rElement.aName ))
@@ -627,7 +618,6 @@ void UIConfigurationManager::impl_reloadElementTypeData(
rElement.bDefault = true;
}
}
- ++pIter;
}
rDocElementType.bModified = false;
@@ -870,15 +860,12 @@ Sequence< Sequence< PropertyValue > > SAL_CALL UIConfigurationManager::getUIElem
aUIElementInfo[1].Name = m_aPropUIName;
aElementInfoSeq.resize( aUIElementInfoCollection.size() );
- UIElementInfoHashMap::const_iterator pIter = aUIElementInfoCollection.begin();
-
sal_Int32 n = 0;
- while ( pIter != aUIElementInfoCollection.end() )
+ for (auto const& elem : aUIElementInfoCollection)
{
- aUIElementInfo[0].Value <<= pIter->second.aResourceURL;
- aUIElementInfo[1].Value <<= pIter->second.aUIName;
+ aUIElementInfo[0].Value <<= elem.second.aResourceURL;
+ aUIElementInfo[1].Value <<= elem.second.aUIName;
aElementInfoSeq[n++] = aUIElementInfo;
- ++pIter;
}
return comphelper::containerToSequence(aElementInfoSeq);