summaryrefslogtreecommitdiff
path: root/unotools
diff options
context:
space:
mode:
authorArkadiy Illarionov <qarkai@gmail.com>2019-06-27 23:29:01 +0300
committerArkadiy Illarionov <qarkai@gmail.com>2019-06-28 17:33:40 +0200
commit1e084caf573255a93ce86053d584976f317074df (patch)
tree9340232dd2ae3b3f38f4c8e996f93587adbb7fb8 /unotools
parent41cf4e6604bfb9b51ce54c5ea64d77249c7545d7 (diff)
Simplify Sequence iterations in unotools
Use range-based loops or replace with STL functions Change-Id: I220c5cd5dcc19fc35e1ad729ae69246f4a79ce2d Reviewed-on: https://gerrit.libreoffice.org/74825 Tested-by: Jenkins Reviewed-by: Arkadiy Illarionov <qarkai@gmail.com>
Diffstat (limited to 'unotools')
-rw-r--r--unotools/source/config/cmdoptions.cxx8
-rw-r--r--unotools/source/config/compatibility.cxx10
-rw-r--r--unotools/source/config/configitem.cxx125
-rw-r--r--unotools/source/config/confignode.cxx5
-rw-r--r--unotools/source/config/dynamicmenuoptions.cxx3
-rw-r--r--unotools/source/config/eventcfg.cxx17
-rw-r--r--unotools/source/config/fontcfg.cxx25
-rw-r--r--unotools/source/config/historyoptions.cxx9
-rw-r--r--unotools/source/config/lingucfg.cxx21
-rw-r--r--unotools/source/config/moduleoptions.cxx54
-rw-r--r--unotools/source/config/optionsdlg.cxx14
-rw-r--r--unotools/source/config/pathoptions.cxx3
-rw-r--r--unotools/source/config/securityoptions.cxx24
-rw-r--r--unotools/source/config/viewoptions.cxx21
-rw-r--r--unotools/source/i18n/localedatawrapper.cxx90
-rw-r--r--unotools/source/ucbhelper/progresshandlerwrap.cxx8
-rw-r--r--unotools/source/ucbhelper/ucbhelper.cxx8
-rw-r--r--unotools/source/ucbhelper/ucblockbytes.cxx9
18 files changed, 172 insertions, 282 deletions
diff --git a/unotools/source/config/cmdoptions.cxx b/unotools/source/config/cmdoptions.cxx
index 2c8f18e76aea..56b61ad2704a 100644
--- a/unotools/source/config/cmdoptions.cxx
+++ b/unotools/source/config/cmdoptions.cxx
@@ -277,11 +277,9 @@ Sequence< OUString > SvtCommandOptions_Impl::impl_GetPropertyNames()
Sequence< OUString > lDisabledItems = GetNodeNames( SETNODE_DISABLED, utl::ConfigNameFormat::LocalPath );
// Expand all keys
- for (sal_Int32 i=0; i<lDisabledItems.getLength(); ++i )
- {
- lDisabledItems[i] = SETNODE_DISABLED PATHDELIMITER + lDisabledItems[i]
- + PATHDELIMITER PROPERTYNAME_CMD;
- }
+ std::transform(lDisabledItems.begin(), lDisabledItems.end(), lDisabledItems.begin(),
+ [](const OUString& rItem) -> OUString {
+ return SETNODE_DISABLED PATHDELIMITER + rItem + PATHDELIMITER PROPERTYNAME_CMD; });
// Return result.
return lDisabledItems;
diff --git a/unotools/source/config/compatibility.cxx b/unotools/source/config/compatibility.cxx
index a1523d3aae41..f0d211de6957 100644
--- a/unotools/source/config/compatibility.cxx
+++ b/unotools/source/config/compatibility.cxx
@@ -159,7 +159,6 @@ SvtCompatibilityOptions_Impl::SvtCompatibilityOptions_Impl() : ConfigItem( ROOTN
// See impl_GetPropertyNames() for further information.
Sequence< OUString > lNodes;
Sequence< OUString > lNames = impl_GetPropertyNames( lNodes );
- sal_uInt32 nCount = lNodes.getLength();
Sequence< Any > lValues = GetProperties( lNames );
// Safe impossible cases.
@@ -171,11 +170,11 @@ SvtCompatibilityOptions_Impl::SvtCompatibilityOptions_Impl() : ConfigItem( ROOTN
// 4 subkeys for every item!
bool bDefaultFound = false;
sal_Int32 nDestStep = 0;
- for ( sal_uInt32 nItem = 0; nItem < nCount; ++nItem )
+ for ( const auto& rNode : lNodes )
{
SvtCompatibilityEntry aItem;
- aItem.setValue<OUString>( SvtCompatibilityEntry::Index::Name, lNodes[ nItem ] );
+ aItem.setValue<OUString>( SvtCompatibilityEntry::Index::Name, rNode );
for ( int i = static_cast<int>(SvtCompatibilityEntry::Index::Module); i < static_cast<int>(SvtCompatibilityEntry::Index::INVALID); ++i )
{
@@ -292,14 +291,13 @@ Sequence< OUString > SvtCompatibilityOptions_Impl::impl_GetPropertyNames( Sequen
// expand list to result list ...
Sequence< OUString > lProperties( rItems.getLength() * ( SvtCompatibilityEntry::getElementCount() - 1 ) );
- sal_Int32 nSourceCount = rItems.getLength();
sal_Int32 nDestStep = 0;
// Copy entries to destination and expand every item with 2 supported sub properties.
- for ( sal_Int32 nSourceStep = 0; nSourceStep < nSourceCount; ++nSourceStep )
+ for ( const auto& rItem : rItems )
{
OUString sFixPath = SETNODE_ALLFILEFORMATS;
sFixPath += PATHDELIMITER;
- sFixPath += rItems[ nSourceStep ];
+ sFixPath += rItem;
sFixPath += PATHDELIMITER;
for ( int i = static_cast<int>(SvtCompatibilityEntry::Index::Module); i < static_cast<int>(SvtCompatibilityEntry::Index::INVALID); ++i )
{
diff --git a/unotools/source/config/configitem.cxx b/unotools/source/config/configitem.cxx
index 6f5e99940703..4af2eb3bc977 100644
--- a/unotools/source/config/configitem.cxx
+++ b/unotools/source/config/configitem.cxx
@@ -35,6 +35,7 @@
#include <com/sun/star/beans/PropertyAttribute.hpp>
#include <com/sun/star/util/XChangesBatch.hpp>
#include <osl/diagnose.h>
+#include <comphelper/sequence.hxx>
#include <comphelper/solarmutex.hxx>
#include <rtl/ref.hxx>
#include <tools/diagnose_ex.h>
@@ -98,34 +99,21 @@ ConfigChangeListener_Impl::ConfigChangeListener_Impl(
{
}
-static bool lcl_Find(
- const OUString& rTemp,
- const OUString* pCheckPropertyNames,
- sal_Int32 nLength)
-{
- //return true if the path is completely correct or if it is longer
- //i.e ...Print/Content/Graphic and .../Print
- for(sal_Int32 nIndex = 0; nIndex < nLength; nIndex++)
- if( isPrefixOfConfigurationPath(rTemp, pCheckPropertyNames[nIndex]) )
- return true;
- return false;
-}
-
void ConfigChangeListener_Impl::changesOccurred( const ChangesEvent& rEvent )
{
- const ElementChange* pElementChanges = rEvent.Changes.getConstArray();
-
Sequence<OUString> aChangedNames(rEvent.Changes.getLength());
OUString* pNames = aChangedNames.getArray();
- const OUString* pCheckPropertyNames = aPropertyNames.getConstArray();
-
sal_Int32 nNotify = 0;
- for(int i = 0; i < aChangedNames.getLength(); i++)
+ for(const auto& rElementChange : rEvent.Changes)
{
OUString sTemp;
- pElementChanges[i].Accessor >>= sTemp;
- if(lcl_Find(sTemp, pCheckPropertyNames, aPropertyNames.getLength()))
+ rElementChange.Accessor >>= sTemp;
+ //true if the path is completely correct or if it is longer
+ //i.e ...Print/Content/Graphic and .../Print
+ bool bFound = std::any_of(aPropertyNames.begin(), aPropertyNames.end(),
+ [&sTemp](const OUString& rCheckPropertyName) { return isPrefixOfConfigurationPath(sTemp, rCheckPropertyName); });
+ if(bFound)
pNames[nNotify++] = sTemp;
}
if( nNotify )
@@ -252,10 +240,8 @@ void ConfigItem::impl_unpackLocalizedProperties( const Sequence< OUString >
// This method should be called for special ConfigItem-mode only!
OSL_ENSURE( ((m_nMode & ConfigItemMode::AllLocales ) == ConfigItemMode::AllLocales), "ConfigItem::impl_unpackLocalizedProperties() Wrong call of this method detected!" );
- sal_Int32 nSourceCounter; // used to step during input lists
sal_Int32 nSourceSize; // marks end of loop over input lists
sal_Int32 nDestinationCounter; // actual position in output lists
- sal_Int32 nPropertyCounter; // counter of inner loop for Sequence< PropertyValue >
sal_Int32 nPropertiesSize; // marks end of inner loop
OUString sNodeName; // base name of node ( e.g. "UIName/" ) ... expand to locale ( e.g. "UIName/de" )
Sequence< PropertyValue > lProperties; // localized values of an configuration entry gotten from lInValues-Any
@@ -279,7 +265,7 @@ void ConfigItem::impl_unpackLocalizedProperties( const Sequence< OUString >
// Split it ... insert PropertyValue.Name to lOutNames and PropertyValue.Value to lOutValues.
nDestinationCounter = 0;
- for( nSourceCounter=0; nSourceCounter<nSourceSize; ++nSourceCounter )
+ for( sal_Int32 nSourceCounter=0; nSourceCounter<nSourceSize; ++nSourceCounter )
{
// If item a special localized one ... split it and insert his parts to output lists ...
if( lInValues[nSourceCounter].getValueType() == cppu::UnoType<Sequence<PropertyValue>>::get() )
@@ -295,10 +281,10 @@ void ConfigItem::impl_unpackLocalizedProperties( const Sequence< OUString >
lOutValues.realloc ( nDestinationCounter+nPropertiesSize );
}
- for( nPropertyCounter=0; nPropertyCounter<nPropertiesSize; ++nPropertyCounter )
+ for( const auto& rProperty : lProperties )
{
- lOutNames [nDestinationCounter] = sNodeName + lProperties[nPropertyCounter].Name;
- lOutValues[nDestinationCounter] = lProperties[nPropertyCounter].Value;
+ lOutNames [nDestinationCounter] = sNodeName + rProperty.Name;
+ lOutValues[nDestinationCounter] = rProperty.Value;
++nDestinationCounter;
}
}
@@ -329,8 +315,7 @@ Sequence< sal_Bool > ConfigItem::GetReadOnlyStates(const css::uno::Sequence< OUS
// We must be sure to return a valid information every time!
// Set default to non readonly... similar to the configuration handling of this property.
- for ( i=0; i<nCount; ++i)
- lStates[i] = false;
+ std::fill(lStates.begin(), lStates.end(), false);
// no access - no information...
Reference< XHierarchicalNameAccess > xHierarchyAccess = GetTree();
@@ -577,22 +562,16 @@ static void lcl_normalizeLocalNames(Sequence< OUString >& _rNames, ConfigNameFor
OUString sTypeName = xTypeContainer->getElementTemplateName();
sTypeName = sTypeName.copy(sTypeName.lastIndexOf('/')+1);
- OUString * pNames = _rNames.getArray();
- for(int i = 0; i<_rNames.getLength(); ++i)
- {
- pNames[i] = wrapConfigurationElementName(pNames[i],sTypeName);
- }
+ std::transform(_rNames.begin(), _rNames.end(), _rNames.begin(),
+ [&sTypeName](const OUString& rName) -> OUString { return wrapConfigurationElementName(rName,sTypeName); });
}
else
{
Reference<XServiceInfo> xSVI(_xParentNode, UNO_QUERY);
if (xSVI.is() && xSVI->supportsService("com.sun.star.configuration.SetAccess"))
{
- OUString * pNames = _rNames.getArray();
- for(int i = 0; i<_rNames.getLength(); ++i)
- {
- pNames[i] = wrapConfigurationElementName(pNames[i]);
- }
+ std::transform(_rNames.begin(), _rNames.end(), _rNames.begin(),
+ [](const OUString& rName) -> OUString { return wrapConfigurationElementName(rName); });
}
}
}
@@ -659,13 +638,12 @@ bool ConfigItem::ClearNodeSet(const OUString& rNode)
if(!xCont.is())
return false;
Sequence< OUString > aNames = xCont->getElementNames();
- const OUString* pNames = aNames.getConstArray();
Reference<XChangesBatch> xBatch(xHierarchyAccess, UNO_QUERY);
- for(sal_Int32 i = 0; i < aNames.getLength(); i++)
+ for(const OUString& rName : aNames)
{
try
{
- xCont->removeByName(pNames[i]);
+ xCont->removeByName(rName);
}
catch (css::uno::Exception &)
{
@@ -690,7 +668,6 @@ bool ConfigItem::ClearNodeElements(const OUString& rNode, Sequence< OUString > c
Reference<XHierarchicalNameAccess> xHierarchyAccess = GetTree();
if(xHierarchyAccess.is())
{
- const OUString* pElements = rElements.getConstArray();
try
{
Reference<XNameContainer> xCont;
@@ -705,9 +682,9 @@ bool ConfigItem::ClearNodeElements(const OUString& rNode, Sequence< OUString > c
return false;
try
{
- for(sal_Int32 nElement = 0; nElement < rElements.getLength(); nElement++)
+ for(const OUString& rElement : rElements)
{
- xCont->removeByName(pElements[nElement]);
+ xCont->removeByName(rElement);
}
Reference<XChangesBatch> xBatch(xHierarchyAccess, UNO_QUERY);
xBatch->commitChanges();
@@ -735,17 +712,15 @@ static OUString lcl_extractSetPropertyName( const OUString& rInPath, const OUStr
static
Sequence< OUString > lcl_extractSetPropertyNames( const Sequence< PropertyValue >& rValues, const OUString& rPrefix )
{
- const PropertyValue* pProperties = rValues.getConstArray();
-
Sequence< OUString > aSubNodeNames(rValues.getLength());
OUString* pSubNodeNames = aSubNodeNames.getArray();
OUString sLastSubNode;
sal_Int32 nSubIndex = 0;
- for(sal_Int32 i = 0; i < rValues.getLength(); i++)
+ for(const PropertyValue& rProperty : rValues)
{
- OUString const sSubPath = dropPrefixFromConfigurationPath( pProperties[i].Name, rPrefix);
+ OUString const sSubPath = dropPrefixFromConfigurationPath( rProperty.Name, rPrefix);
OUString const sSubNode = extractFirstFromConfigurationPath( sSubPath );
if(sLastSubNode != sSubNode)
@@ -789,15 +764,13 @@ bool ConfigItem::SetSetProperties(
{
const Sequence< OUString > aSubNodeNames = lcl_extractSetPropertyNames(rValues, rNode);
- const sal_Int32 nSubNodeCount = aSubNodeNames.getLength();
-
- for(sal_Int32 j = 0; j <nSubNodeCount; j++)
+ for(const auto& rSubNodeName : aSubNodeNames)
{
- if(!xCont->hasByName(aSubNodeNames[j]))
+ if(!xCont->hasByName(rSubNodeName))
{
Reference<XInterface> xInst = xFac->createInstance();
Any aVal; aVal <<= xInst;
- xCont->insertByName(aSubNodeNames[j], aVal);
+ xCont->insertByName(rSubNodeName, aVal);
}
//set values
}
@@ -829,19 +802,18 @@ bool ConfigItem::SetSetProperties(
else
{
//if no factory is available then the node contains basic data elements
- const PropertyValue* pValues = rValues.getConstArray();
- for(int nValue = 0; nValue < rValues.getLength();nValue++)
+ for(const PropertyValue& rValue : rValues)
{
try
{
- OUString sSubNode = lcl_extractSetPropertyName( pValues[nValue].Name, rNode );
+ OUString sSubNode = lcl_extractSetPropertyName( rValue.Name, rNode );
if(xCont->hasByName(sSubNode))
- xCont->replaceByName(sSubNode, pValues[nValue].Value);
+ xCont->replaceByName(sSubNode, rValue.Value);
else
- xCont->insertByName(sSubNode, pValues[nValue].Value);
+ xCont->insertByName(sSubNode, rValue.Value);
- OSL_ENSURE( xHierarchyAccess->hasByHierarchicalName(pValues[nValue].Name),
+ OSL_ENSURE( xHierarchyAccess->hasByHierarchicalName(rValue.Name),
"Invalid config path" );
}
catch (css::uno::Exception &)
@@ -885,8 +857,6 @@ bool ConfigItem::ReplaceSetProperties(
// JB: Change: now the same name handling for sets of simple values
const Sequence< OUString > aSubNodeNames = lcl_extractSetPropertyNames(rValues, rNode);
- const OUString* pSubNodeNames = aSubNodeNames.getConstArray();
- const sal_Int32 nSubNodeCount = aSubNodeNames.getLength();
Reference<XSingleServiceFactory> xFac(xCont, UNO_QUERY);
const bool isSimpleValueSet = !xFac.is();
@@ -894,23 +864,14 @@ bool ConfigItem::ReplaceSetProperties(
//remove unknown members first
{
const Sequence<OUString> aContainerSubNodes = xCont->getElementNames();
- const OUString* pContainerSubNodes = aContainerSubNodes.getConstArray();
- for(sal_Int32 nContSub = 0; nContSub < aContainerSubNodes.getLength(); nContSub++)
+ for(const OUString& rContainerSubNode : aContainerSubNodes)
{
- bool bFound = false;
- for(sal_Int32 j = 0; j < nSubNodeCount; j++)
- {
- if(pSubNodeNames[j] == pContainerSubNodes[nContSub])
- {
- bFound = true;
- break;
- }
- }
+ bool bFound = comphelper::findValue(aSubNodeNames, rContainerSubNode) != -1;
if(!bFound)
try
{
- xCont->removeByName(pContainerSubNodes[nContSub]);
+ xCont->removeByName(rContainerSubNode);
}
catch (const Exception&)
{
@@ -919,7 +880,7 @@ bool ConfigItem::ReplaceSetProperties(
try
{
// #i37322#: fallback action: replace with <void/>
- xCont->replaceByName(pContainerSubNodes[nContSub], Any());
+ xCont->replaceByName(rContainerSubNode, Any());
// fallback successful: continue looping
continue;
}
@@ -938,14 +899,14 @@ bool ConfigItem::ReplaceSetProperties(
if(xFac.is()) // !isSimpleValueSet
{
- for(sal_Int32 j = 0; j < nSubNodeCount; j++)
+ for(const OUString& rSubNodeName : aSubNodeNames)
{
- if(!xCont->hasByName(pSubNodeNames[j]))
+ if(!xCont->hasByName(rSubNodeName))
{
//create if not available
Reference<XInterface> xInst = xFac->createInstance();
Any aVal; aVal <<= xInst;
- xCont->insertByName(pSubNodeNames[j], aVal);
+ xCont->insertByName(rSubNodeName, aVal);
}
}
try { xBatch->commitChanges(); }
@@ -972,19 +933,17 @@ bool ConfigItem::ReplaceSetProperties(
}
else
{
- const PropertyValue* pValues = rValues.getConstArray();
-
//if no factory is available then the node contains basic data elements
- for(int nValue = 0; nValue < rValues.getLength();nValue++)
+ for(const PropertyValue& rValue : rValues)
{
try
{
- OUString sSubNode = lcl_extractSetPropertyName( pValues[nValue].Name, rNode );
+ OUString sSubNode = lcl_extractSetPropertyName( rValue.Name, rNode );
if(xCont->hasByName(sSubNode))
- xCont->replaceByName(sSubNode, pValues[nValue].Value);
+ xCont->replaceByName(sSubNode, rValue.Value);
else
- xCont->insertByName(sSubNode, pValues[nValue].Value);
+ xCont->insertByName(sSubNode, rValue.Value);
}
catch (css::uno::Exception &)
{
diff --git a/unotools/source/config/confignode.cxx b/unotools/source/config/confignode.cxx
index 64ea55ced8c5..bb5760ccfbbd 100644
--- a/unotools/source/config/confignode.cxx
+++ b/unotools/source/config/confignode.cxx
@@ -192,9 +192,8 @@ namespace utl
{
aReturn = m_xDirectAccess->getElementNames();
// normalize the names
- OUString* pNames = aReturn.getArray();
- for (sal_Int32 i=0; i<aReturn.getLength(); ++i, ++pNames)
- *pNames = normalizeName(*pNames, NO_CONFIGURATION);
+ std::transform(aReturn.begin(), aReturn.end(), aReturn.begin(),
+ [this](const OUString& rName) -> OUString { return normalizeName(rName, NO_CONFIGURATION); });
}
catch(Exception&)
{
diff --git a/unotools/source/config/dynamicmenuoptions.cxx b/unotools/source/config/dynamicmenuoptions.cxx
index 6109fb4666d5..fe7f31d6b96a 100644
--- a/unotools/source/config/dynamicmenuoptions.cxx
+++ b/unotools/source/config/dynamicmenuoptions.cxx
@@ -481,8 +481,7 @@ void SvtDynamicMenuOptions_Impl::impl_SortAndExpandPropertyNames( const Sequence
// Copy all items to temp. vector to use fast sort operations :-)
lTemp.reserve(nSourceCount);
- for (sal_Int32 nSourceStep = 0; nSourceStep < nSourceCount; ++nSourceStep)
- lTemp.push_back( lSource[nSourceStep] );
+ std::copy(lSource.begin(), lSource.end(), std::back_inserter(lTemp));
// Sort all entries by number ...
stable_sort( lTemp.begin(), lTemp.end(), CountWithPrefixSort() );
diff --git a/unotools/source/config/eventcfg.cxx b/unotools/source/config/eventcfg.cxx
index e8cd76bd9d32..4c09402e2bcd 100644
--- a/unotools/source/config/eventcfg.cxx
+++ b/unotools/source/config/eventcfg.cxx
@@ -195,11 +195,11 @@ void GlobalEventConfig_Impl::initBindingInfo()
// Expand all keys
Sequence< OUString > lMacros(1);
- for (sal_Int32 i=0; i<lEventNames.getLength(); ++i )
+ for (const auto& rEventName : lEventNames )
{
OUStringBuffer aBuffer( 32 );
aBuffer.append( aSetNode );
- aBuffer.append( lEventNames[i] );
+ aBuffer.append( rEventName );
aBuffer.append( aCommandKey );
lMacros[0] = aBuffer.makeStringAndClear();
SAL_INFO("unotools", "reading binding for: " << lMacros[0]);
@@ -208,12 +208,12 @@ void GlobalEventConfig_Impl::initBindingInfo()
if( lValues.hasElements() )
{
lValues[0] >>= sMacroURL;
- sal_Int32 startIndex = lEventNames[i].indexOf('\'');
- sal_Int32 endIndex = lEventNames[i].lastIndexOf('\'');
+ sal_Int32 startIndex = rEventName.indexOf('\'');
+ sal_Int32 endIndex = rEventName.lastIndexOf('\'');
if( startIndex >=0 && endIndex > 0 )
{
startIndex++;
- OUString eventName = lEventNames[i].copy(startIndex,endIndex-startIndex);
+ OUString eventName = rEventName.copy(startIndex,endIndex-startIndex);
m_eventBindingHash[ eventName ] = sMacroURL;
}
}
@@ -230,11 +230,10 @@ void GlobalEventConfig_Impl::replaceByName( const OUString& aName, const Any& aE
Reference< XInterface > (), 2);
}
OUString macroURL;
- sal_Int32 nPropCount = props.getLength();
- for( sal_Int32 index = 0; index < nPropCount; ++index )
+ for( const auto& rProp : props )
{
- if ( props[ index ].Name == "Script" )
- props[ index ].Value >>= macroURL;
+ if ( rProp.Name == "Script" )
+ rProp.Value >>= macroURL;
}
m_eventBindingHash[ aName ] = macroURL;
SetModified();
diff --git a/unotools/source/config/fontcfg.cxx b/unotools/source/config/fontcfg.cxx
index 92b72799bcbb..50c45600d24b 100644
--- a/unotools/source/config/fontcfg.cxx
+++ b/unotools/source/config/fontcfg.cxx
@@ -119,14 +119,12 @@ DefaultFontConfiguration::DefaultFontConfiguration()
{
Sequence< OUString > aLocales = m_xConfigAccess->getElementNames();
// fill config hash with empty interfaces
- int nLocales = aLocales.getLength();
- const OUString* pLocaleStrings = aLocales.getConstArray();
- for( int i = 0; i < nLocales; i++ )
+ for( const OUString& rLocaleString : aLocales )
{
// Feed through LanguageTag for casing.
- OUString aLoc( LanguageTag( pLocaleStrings[i], true).getBcp47( false));
+ OUString aLoc( LanguageTag( rLocaleString, true).getBcp47( false));
m_aConfig[ aLoc ] = LocaleAccess();
- m_aConfig[ aLoc ].aConfigLocaleString = pLocaleStrings[i];
+ m_aConfig[ aLoc ].aConfigLocaleString = rLocaleString;
}
}
}
@@ -335,14 +333,12 @@ FontSubstConfiguration::FontSubstConfiguration() :
{
Sequence< OUString > aLocales = m_xConfigAccess->getElementNames();
// fill config hash with empty interfaces
- int nLocales = aLocales.getLength();
- const OUString* pLocaleStrings = aLocales.getConstArray();
- for( int i = 0; i < nLocales; i++ )
+ for( const OUString& rLocaleString : aLocales )
{
// Feed through LanguageTag for casing.
- OUString aLoc( LanguageTag( pLocaleStrings[i], true).getBcp47( false));
+ OUString aLoc( LanguageTag( rLocaleString, true).getBcp47( false));
m_aSubst[ aLoc ] = LocaleSubst();
- m_aSubst[ aLoc ].aConfigLocaleString = pLocaleStrings[i];
+ m_aSubst[ aLoc ].aConfigLocaleString = rLocaleString;
}
}
}
@@ -979,7 +975,6 @@ void FontSubstConfiguration::readLocaleSubst( const OUString& rBcp47 ) const
{
Sequence< OUString > aFonts = xNode->getElementNames();
int nFonts = aFonts.getLength();
- const OUString* pFontNames = aFonts.getConstArray();
// improve performance, heap fragmentation
it->second.aSubstAttributes.reserve( nFonts );
@@ -989,12 +984,12 @@ void FontSubstConfiguration::readLocaleSubst( const OUString& rBcp47 ) const
OUString const aSubstWeightStr ( "FontWeight" );
OUString const aSubstWidthStr ( "FontWidth" );
OUString const aSubstTypeStr ( "FontType" );
- for( int i = 0; i < nFonts; i++ )
+ for( const OUString& rFontName : aFonts )
{
Reference< XNameAccess > xFont;
try
{
- Any aAny = xNode->getByName( pFontNames[i] );
+ Any aAny = xNode->getByName( rFontName );
aAny >>= xFont;
}
catch (const NoSuchElementException&)
@@ -1005,13 +1000,13 @@ void FontSubstConfiguration::readLocaleSubst( const OUString& rBcp47 ) const
}
if( ! xFont.is() )
{
- SAL_WARN("unotools.config", "did not get font attributes for " << pFontNames[i]);
+ SAL_WARN("unotools.config", "did not get font attributes for " << rFontName);
continue;
}
FontNameAttr aAttr;
// read subst attributes from config
- aAttr.Name = pFontNames[i];
+ aAttr.Name = rFontName;
fillSubstVector( xFont, aSubstFontsStr, aAttr.Substitutions );
fillSubstVector( xFont, aSubstFontsMSStr, aAttr.MSSubstitutions );
aAttr.Weight = getSubstWeight( xFont, aSubstWeightStr );
diff --git a/unotools/source/config/historyoptions.cxx b/unotools/source/config/historyoptions.cxx
index 5fad79cfbb96..ec2233ff32ec 100644
--- a/unotools/source/config/historyoptions.cxx
+++ b/unotools/source/config/historyoptions.cxx
@@ -231,16 +231,15 @@ void SvtHistoryOptions_Impl::Clear( EHistoryType eHistory )
xListAccess->getByName(s_sItemList) >>= xNode;
Sequence<OUString> aStrings(xNode->getElementNames());
- const sal_Int32 nLength = aStrings.getLength();
- for (sal_Int32 i = 0; i < nLength; ++i)
- xNode->removeByName(aStrings[i]);
+ for (const auto& rString : aStrings)
+ xNode->removeByName(rString);
// clear OrderList
xListAccess->getByName(s_sOrderList) >>= xNode;
aStrings = xNode->getElementNames();
- for (sal_Int32 j = 0; j < nLength; ++j)
- xNode->removeByName(aStrings[j]);
+ for (const auto& rString : aStrings)
+ xNode->removeByName(rString);
::comphelper::ConfigurationHelper::flush(m_xCfg);
}
diff --git a/unotools/source/config/lingucfg.cxx b/unotools/source/config/lingucfg.cxx
index a1c07d61489c..1d62a2f3013e 100644
--- a/unotools/source/config/lingucfg.cxx
+++ b/unotools/source/config/lingucfg.cxx
@@ -970,9 +970,8 @@ bool SvtLinguConfig::GetDictionaryEntry(
if (bSuccess)
{
// get file URL's for the locations
- for (sal_Int32 i = 0; i < aLocations.getLength(); ++i)
+ for (OUString& rLocation : aLocations)
{
- OUString &rLocation = aLocations[i];
if (!lcl_GetFileUrlFromOrigin( rLocation, rLocation ))
bSuccess = false;
}
@@ -1018,33 +1017,27 @@ std::vector< SvtLinguConfigDictionaryEntry > SvtLinguConfig::GetActiveDictionari
{
uno::Sequence< OUString > aElementNames;
GetElementNamesFor( aG_Dictionaries, aElementNames );
- sal_Int32 nLen = aElementNames.getLength();
- const OUString *pElementNames = aElementNames.getConstArray();
const uno::Sequence< OUString > aDisabledDics( GetDisabledDictionaries() );
SvtLinguConfigDictionaryEntry aDicEntry;
- for (sal_Int32 i = 0; i < nLen; ++i)
+ for (const OUString& rElementName : aElementNames)
{
// does dictionary match the format we are looking for?
- if (GetDictionaryEntry( pElementNames[i], aDicEntry ) &&
+ if (GetDictionaryEntry( rElementName, aDicEntry ) &&
aDicEntry.aFormatName == rFormatName)
{
// check if it is active or not
- bool bDicIsActive = true;
- for (sal_Int32 k = 0; bDicIsActive && k < aDisabledDics.getLength(); ++k)
- {
- if (aDisabledDics[k] == pElementNames[i])
- bDicIsActive = false;
- }
+ bool bDicIsActive = std::none_of(aDisabledDics.begin(), aDisabledDics.end(),
+ [&rElementName](const OUString& rDic) { return rDic == rElementName; });
if (bDicIsActive)
{
DBG_ASSERT( !aDicEntry.aFormatName.isEmpty(),
"FormatName not set" );
- DBG_ASSERT( aDicEntry.aLocations.getLength(),
+ DBG_ASSERT( aDicEntry.aLocations.hasElements(),
"Locations not set" );
- DBG_ASSERT( aDicEntry.aLocaleNames.getLength(),
+ DBG_ASSERT( aDicEntry.aLocaleNames.hasElements(),
"Locales not set" );
aRes.push_back( aDicEntry );
}
diff --git a/unotools/source/config/moduleoptions.cxx b/unotools/source/config/moduleoptions.cxx
index 7d6fa71fe4ec..b877c0b90d27 100644
--- a/unotools/source/config/moduleoptions.cxx
+++ b/unotools/source/config/moduleoptions.cxx
@@ -354,13 +354,8 @@ void SvtModuleOptions_Impl::ImplCommit()
sBasePath = PATHSEPARATOR + rInfo.getFactory() + PATHSEPARATOR;
const css::uno::Sequence< css::beans::PropertyValue > lChangedProperties = rInfo.getChangedProperties ( sBasePath );
- const css::beans::PropertyValue* pChangedProperties = lChangedProperties.getConstArray();
- sal_Int32 nPropertyCount = lChangedProperties.getLength();
- for( sal_Int32 nProperty=0; nProperty<nPropertyCount; ++nProperty )
- {
- lCommitProperties[nRealCount] = pChangedProperties[nProperty];
- ++nRealCount;
- }
+ std::copy(lChangedProperties.begin(), lChangedProperties.end(), std::next(lCommitProperties.begin(), nRealCount));
+ nRealCount += lChangedProperties.getLength();
}
// Resize commit list to real size.
// If nothing to do - suppress calling of configuration ...
@@ -561,14 +556,14 @@ css::uno::Sequence< OUString > SvtModuleOptions_Impl::impl_ExpandSetNames( const
OUString* pPropNames = lPropNames.getArray();
sal_Int32 nPropStart = 0;
- for( sal_Int32 nName=0; nName<nCount; ++nName )
+ for( const auto& rSetName : lSetNames )
{
- pPropNames[nPropStart+PROPERTYHANDLE_SHORTNAME ] = lSetNames[nName] + PATHSEPARATOR PROPERTYNAME_SHORTNAME;
- pPropNames[nPropStart+PROPERTYHANDLE_TEMPLATEFILE ] = lSetNames[nName] + PATHSEPARATOR PROPERTYNAME_TEMPLATEFILE;
- pPropNames[nPropStart+PROPERTYHANDLE_WINDOWATTRIBUTES] = lSetNames[nName] + PATHSEPARATOR PROPERTYNAME_WINDOWATTRIBUTES;
- pPropNames[nPropStart+PROPERTYHANDLE_EMPTYDOCUMENTURL] = lSetNames[nName] + PATHSEPARATOR PROPERTYNAME_EMPTYDOCUMENTURL;
- pPropNames[nPropStart+PROPERTYHANDLE_DEFAULTFILTER ] = lSetNames[nName] + PATHSEPARATOR PROPERTYNAME_DEFAULTFILTER;
- pPropNames[nPropStart+PROPERTYHANDLE_ICON ] = lSetNames[nName] + PATHSEPARATOR PROPERTYNAME_ICON;
+ pPropNames[nPropStart+PROPERTYHANDLE_SHORTNAME ] = rSetName + PATHSEPARATOR PROPERTYNAME_SHORTNAME;
+ pPropNames[nPropStart+PROPERTYHANDLE_TEMPLATEFILE ] = rSetName + PATHSEPARATOR PROPERTYNAME_TEMPLATEFILE;
+ pPropNames[nPropStart+PROPERTYHANDLE_WINDOWATTRIBUTES] = rSetName + PATHSEPARATOR PROPERTYNAME_WINDOWATTRIBUTES;
+ pPropNames[nPropStart+PROPERTYHANDLE_EMPTYDOCUMENTURL] = rSetName + PATHSEPARATOR PROPERTYNAME_EMPTYDOCUMENTURL;
+ pPropNames[nPropStart+PROPERTYHANDLE_DEFAULTFILTER ] = rSetName + PATHSEPARATOR PROPERTYNAME_DEFAULTFILTER;
+ pPropNames[nPropStart+PROPERTYHANDLE_ICON ] = rSetName + PATHSEPARATOR PROPERTYNAME_ICON;
nPropStart += PROPERTYCOUNT;
}
@@ -698,13 +693,11 @@ void SvtModuleOptions_Impl::impl_Read( const css::uno::Sequence< OUString >& lFa
// see "nPropertyStart += PROPERTYCOUNT" ...
sal_Int32 nPropertyStart = 0;
- sal_Int32 nNodeCount = lFactories.getLength();
FactoryInfo* pInfo = nullptr;
SvtModuleOptions::EFactory eFactory;
- for( sal_Int32 nSetNode=0; nSetNode<nNodeCount; ++nSetNode )
+ for( const OUString& sFactoryName : lFactories )
{
- const OUString& sFactoryName = lFactories[nSetNode];
if( ClassifyFactoryByName( sFactoryName, eFactory ) )
{
OUString sTemp;
@@ -733,20 +726,18 @@ void SvtModuleOptions_Impl::MakeReadonlyStatesAvailable()
return;
css::uno::Sequence< OUString > lFactories = GetNodeNames(OUString());
- sal_Int32 c = lFactories.getLength();
- sal_Int32 i = 0;
- for (i=0; i<c; ++i)
- {
- OUStringBuffer sPath(256);
- sPath.append(lFactories[i] );
- sPath.append(PATHSEPARATOR );
- sPath.append(PROPERTYNAME_DEFAULTFILTER);
-
- lFactories[i] = sPath.makeStringAndClear();
- }
+ std::transform(lFactories.begin(), lFactories.end(), lFactories.begin(),
+ [](const OUString& rFactory) -> OUString {
+ OUStringBuffer sPath(256);
+ sPath.append(rFactory );
+ sPath.append(PATHSEPARATOR );
+ sPath.append(PROPERTYNAME_DEFAULTFILTER);
+ return sPath.makeStringAndClear();
+ });
css::uno::Sequence< sal_Bool > lReadonlyStates = GetReadOnlyStates(lFactories);
- for (i=0; i<c; ++i)
+ sal_Int32 c = lFactories.getLength();
+ for (sal_Int32 i=0; i<c; ++i)
{
OUString& rFactoryName = lFactories[i];
SvtModuleOptions::EFactory eFactory;
@@ -1085,11 +1076,10 @@ SvtModuleOptions::EFactory SvtModuleOptions::ClassifyFactoryByModel(const css::u
return EFactory::UNKNOWN_FACTORY;
const css::uno::Sequence< OUString > lServices = xInfo->getSupportedServiceNames();
- const OUString* pServices = lServices.getConstArray();
- for (sal_Int32 i=0; i<lServices.getLength(); ++i)
+ for (const OUString& rService : lServices)
{
- SvtModuleOptions::EFactory eApp = SvtModuleOptions::ClassifyFactoryByServiceName(pServices[i]);
+ SvtModuleOptions::EFactory eApp = SvtModuleOptions::ClassifyFactoryByServiceName(rService);
if (eApp != EFactory::UNKNOWN_FACTORY)
return eApp;
}
diff --git a/unotools/source/config/optionsdlg.cxx b/unotools/source/config/optionsdlg.cxx
index 8efc6e2dc56e..988ef98f3857 100644
--- a/unotools/source/config/optionsdlg.cxx
+++ b/unotools/source/config/optionsdlg.cxx
@@ -85,10 +85,9 @@ SvtOptionsDlgOptions_Impl::SvtOptionsDlgOptions_Impl()
OUString sRootNode( ROOT_NODE );
Sequence< OUString > aNodeSeq = GetNodeNames( sRootNode );
OUString sNode( sRootNode + g_sPathDelimiter );
- sal_uInt32 nCount = aNodeSeq.getLength();
- for ( sal_uInt32 n = 0; n < nCount; n++ )
+ for ( const auto& rNode : aNodeSeq )
{
- OUString sSubNode( sNode + aNodeSeq[n] );
+ OUString sSubNode( sNode + rNode );
ReadNode( sSubNode, NT_Group );
}
}
@@ -145,13 +144,10 @@ void SvtOptionsDlgOptions_Impl::ReadNode( const OUString& _rNode, NodeType _eTyp
{
OUString sNodes( sNode + sSet );
Sequence< OUString > aNodes = GetNodeNames( sNodes );
- if ( aNodes.hasElements() )
+ for ( const auto& rNode : aNodes )
{
- for ( sal_uInt32 n = 0; n < static_cast<sal_uInt32>(aNodes.getLength()); ++n )
- {
- OUString sSubNodeName( sNodes + g_sPathDelimiter + aNodes[n] );
- ReadNode( sSubNodeName, _eType == NT_Group ? NT_Page : NT_Option );
- }
+ OUString sSubNodeName( sNodes + g_sPathDelimiter + rNode );
+ ReadNode( sSubNodeName, _eType == NT_Group ? NT_Page : NT_Option );
}
}
}
diff --git a/unotools/source/config/pathoptions.cxx b/unotools/source/config/pathoptions.cxx
index df102637118e..bbd01f1a40e6 100644
--- a/unotools/source/config/pathoptions.cxx
+++ b/unotools/source/config/pathoptions.cxx
@@ -407,9 +407,8 @@ SvtPathOptions_Impl::SvtPathOptions_Impl() :
Sequence< Property > aPathPropSeq = xPropSetInfo->getProperties();
NameToHandleMap aTempHashMap;
- for ( sal_Int32 n = 0; n < aPathPropSeq.getLength(); n++ )
+ for ( const css::beans::Property& aProperty : aPathPropSeq )
{
- const css::beans::Property& aProperty = aPathPropSeq[n];
aTempHashMap.emplace(aProperty.Name, aProperty.Handle);
}
diff --git a/unotools/source/config/securityoptions.cxx b/unotools/source/config/securityoptions.cxx
index 25e70207da1d..33a87d8ffb6c 100644
--- a/unotools/source/config/securityoptions.cxx
+++ b/unotools/source/config/securityoptions.cxx
@@ -287,9 +287,8 @@ void SvtSecurityOptions_Impl::SetProperty( sal_Int32 nProperty, const Any& rValu
if (!utl::ConfigManager::IsFuzzing())
{
SvtPathOptions aOpt;
- sal_uInt32 nCount = m_seqSecureURLs.getLength();
- for( sal_uInt32 nItem = 0; nItem < nCount; ++nItem )
- m_seqSecureURLs[ nItem ] = aOpt.SubstituteVariable( m_seqSecureURLs[ nItem ] );
+ std::transform(m_seqSecureURLs.begin(), m_seqSecureURLs.end(), m_seqSecureURLs.begin(),
+ [&aOpt](const OUString& rUrl) -> OUString { return aOpt.SubstituteVariable( rUrl ); });
}
m_bROSecureURLs = bRO;
}
@@ -418,16 +417,15 @@ void SvtSecurityOptions_Impl::LoadAuthors()
sal_Int32 c2 = c1 * 3; // 3 Properties inside Struct TrustedAuthor
Sequence< OUString > lAllAuthors( c2 );
- sal_Int32 i1;
- sal_Int32 i2;
+ sal_Int32 i2 = 0;
OUString aSep( "/" );
- for( i1 = 0, i2 = 0; i1 < c1; ++i1 )
+ for( const auto& rAuthor : lAuthors )
{
- lAllAuthors[ i2 ] = PROPERTYNAME_MACRO_TRUSTEDAUTHORS + aSep + lAuthors[ i1 ] + aSep + PROPERTYNAME_TRUSTEDAUTHOR_SUBJECTNAME;
+ lAllAuthors[ i2 ] = PROPERTYNAME_MACRO_TRUSTEDAUTHORS + aSep + rAuthor + aSep + PROPERTYNAME_TRUSTEDAUTHOR_SUBJECTNAME;
++i2;
- lAllAuthors[ i2 ] = PROPERTYNAME_MACRO_TRUSTEDAUTHORS + aSep + lAuthors[ i1 ] + aSep + PROPERTYNAME_TRUSTEDAUTHOR_SERIALNUMBER;
+ lAllAuthors[ i2 ] = PROPERTYNAME_MACRO_TRUSTEDAUTHORS + aSep + rAuthor + aSep + PROPERTYNAME_TRUSTEDAUTHOR_SERIALNUMBER;
++i2;
- lAllAuthors[ i2 ] = PROPERTYNAME_MACRO_TRUSTEDAUTHORS + aSep + lAuthors[ i1 ] + aSep + PROPERTYNAME_TRUSTEDAUTHOR_RAWDATA;
+ lAllAuthors[ i2 ] = PROPERTYNAME_MACRO_TRUSTEDAUTHORS + aSep + rAuthor + aSep + PROPERTYNAME_TRUSTEDAUTHOR_RAWDATA;
++i2;
}
@@ -436,7 +434,8 @@ void SvtSecurityOptions_Impl::LoadAuthors()
{
std::vector< SvtSecurityOptions::Certificate > v;
SvtSecurityOptions::Certificate aCert( 3 );
- for( i1 = 0, i2 = 0; i1 < c1; ++i1 )
+ i2 = 0;
+ for( sal_Int32 i1 = 0; i1 < c1; ++i1 )
{
lValues[ i2 ] >>= aCert[ 0 ];
++i2;
@@ -590,9 +589,8 @@ void SvtSecurityOptions_Impl::ImplCommit()
{
Sequence< OUString > lURLs( m_seqSecureURLs );
SvtPathOptions aOpt;
- sal_Int32 nURLsCnt = lURLs.getLength();
- for( sal_Int32 nItem = 0; nItem < nURLsCnt; ++nItem )
- lURLs[ nItem ] = aOpt.UseVariable( lURLs[ nItem ] );
+ std::transform(lURLs.begin(), lURLs.end(), lURLs.begin(),
+ [&aOpt](const OUString& rUrl) -> OUString { return aOpt.UseVariable( rUrl ); });
lValues[ nRealCount ] <<= lURLs;
}
}
diff --git a/unotools/source/config/viewoptions.cxx b/unotools/source/config/viewoptions.cxx
index 85708df745a9..b88fddf630d3 100644
--- a/unotools/source/config/viewoptions.cxx
+++ b/unotools/source/config/viewoptions.cxx
@@ -319,16 +319,12 @@ css::uno::Sequence< css::beans::NamedValue > SvtViewOptionsBase_Impl::GetUserDat
if (xUserData.is())
{
const css::uno::Sequence<OUString> lNames = xUserData->getElementNames();
- const OUString* pNames = lNames.getConstArray();
sal_Int32 c = lNames.getLength();
- sal_Int32 i = 0;
css::uno::Sequence< css::beans::NamedValue > lUserData(c);
- for (i=0; i<c; ++i)
- {
- lUserData[i].Name = pNames[i];
- lUserData[i].Value = xUserData->getByName(pNames[i]);
- }
+ std::transform(lNames.begin(), lNames.end(), lUserData.begin(),
+ [&xUserData](const OUString& rName) -> css::beans::NamedValue {
+ return { rName, xUserData->getByName(rName) }; });
return lUserData;
}
@@ -358,15 +354,12 @@ void SvtViewOptionsBase_Impl::SetUserData( const OUString&
xNode->getByName(PROPERTY_USERDATA) >>= xUserData;
if (xUserData.is())
{
- const css::beans::NamedValue* pData = lData.getConstArray();
- sal_Int32 c = lData.getLength();
- sal_Int32 i = 0;
- for (i=0; i<c; ++i)
+ for (const css::beans::NamedValue& rData : lData)
{
- if (xUserData->hasByName(pData[i].Name))
- xUserData->replaceByName(pData[i].Name, pData[i].Value);
+ if (xUserData->hasByName(rData.Name))
+ xUserData->replaceByName(rData.Name, rData.Value);
else
- xUserData->insertByName(pData[i].Name, pData[i].Value);
+ xUserData->insertByName(rData.Name, rData.Value);
}
}
::comphelper::ConfigurationHelper::flush(m_xRoot);
diff --git a/unotools/source/i18n/localedatawrapper.cxx b/unotools/source/i18n/localedatawrapper.cxx
index 0374f1548faf..ead8a1ac53bb 100644
--- a/unotools/source/i18n/localedatawrapper.cxx
+++ b/unotools/source/i18n/localedatawrapper.cxx
@@ -299,9 +299,9 @@ std::vector< LanguageType > LocaleDataWrapper::getInstalledLanguageTypes()
sal_Int32 nCount = xLoc.getLength();
std::vector< LanguageType > xLang;
xLang.reserve(nCount);
- for ( sal_Int32 i=0; i<nCount; i++ )
+ for ( const auto& rLoc : xLoc )
{
- LanguageTag aLanguageTag( xLoc[i] );
+ LanguageTag aLanguageTag( rLoc );
OUString aDebugLocale;
if (areChecksEnabled())
{
@@ -477,21 +477,12 @@ void LocaleDataWrapper::getSecondaryCalendarImpl()
if (!xSecondaryCalendar && !bSecondaryCalendarValid)
{
Sequence< Calendar2 > xCals = getAllCalendars();
- sal_Int32 nCount = xCals.getLength();
- if (nCount > 1)
+ if (xCals.getLength() > 1)
{
- sal_Int32 nNonDef = -1;
- const Calendar2* pArr = xCals.getArray();
- for (sal_Int32 i=0; i<nCount; ++i)
- {
- if (!pArr[i].Default)
- {
- nNonDef = i;
- break;
- }
- }
- if (nNonDef >= 0)
- xSecondaryCalendar.reset( new Calendar2( xCals[nNonDef]));
+ auto pCal = std::find_if(xCals.begin(), xCals.end(),
+ [](const Calendar2& rCal) { return !rCal.Default; });
+ if (pCal != xCals.end())
+ xSecondaryCalendar.reset( new Calendar2( *pCal));
}
bSecondaryCalendarValid = true;
}
@@ -532,21 +523,15 @@ void LocaleDataWrapper::getDefaultCalendarImpl()
if (!xDefaultCalendar)
{
Sequence< Calendar2 > xCals = getAllCalendars();
- sal_Int32 nCount = xCals.getLength();
- sal_Int32 nDef = 0;
- if (nCount > 1)
+ auto pCal = xCals.begin();
+ if (xCals.getLength() > 1)
{
- const Calendar2* pArr = xCals.getArray();
- for (sal_Int32 i=0; i<nCount; ++i)
- {
- if (pArr[i].Default)
- {
- nDef = i;
- break;
- }
- }
+ pCal = std::find_if(xCals.begin(), xCals.end(),
+ [](const Calendar2& rCal) { return rCal.Default; });
+ if (pCal == xCals.end())
+ pCal = xCals.begin();
}
- xDefaultCalendar.reset( new Calendar2( xCals[nDef]));
+ xDefaultCalendar.reset( new Calendar2( *pCal));
}
}
@@ -631,35 +616,29 @@ sal_uInt16 LocaleDataWrapper::getCurrDigits() const
void LocaleDataWrapper::getCurrSymbolsImpl()
{
Sequence< Currency2 > aCurrSeq = getAllCurrencies();
- sal_Int32 nCnt = aCurrSeq.getLength();
- Currency2 const * const pCurrArr = aCurrSeq.getArray();
- sal_Int32 nElem;
- for ( nElem = 0; nElem < nCnt; nElem++ )
+ if ( !aCurrSeq.hasElements() )
{
- if ( pCurrArr[nElem].Default )
- break;
+ if (areChecksEnabled())
+ outputCheckMessage(OUString("LocaleDataWrapper::getCurrSymbolsImpl: no currency at all, using ShellsAndPebbles"));
+ aCurrSymbol = "ShellsAndPebbles";
+ aCurrBankSymbol = aCurrSymbol;
+ nCurrPositiveFormat = nCurrNegativeFormat = nCurrFormatDefault;
+ nCurrDigits = 2;
+ return;
}
- if ( nElem >= nCnt )
+ auto pCurr = std::find_if(aCurrSeq.begin(), aCurrSeq.end(),
+ [](const Currency2& rCurr) { return rCurr.Default; });
+ if ( pCurr == aCurrSeq.end() )
{
if (areChecksEnabled())
{
outputCheckMessage( appendLocaleInfo( "LocaleDataWrapper::getCurrSymbolsImpl: no default currency" ) );
}
- nElem = 0;
- if ( nElem >= nCnt )
- {
- if (areChecksEnabled())
- outputCheckMessage(OUString("LocaleDataWrapper::getCurrSymbolsImpl: no currency at all, using ShellsAndPebbles"));
- aCurrSymbol = "ShellsAndPebbles";
- aCurrBankSymbol = aCurrSymbol;
- nCurrPositiveFormat = nCurrNegativeFormat = nCurrFormatDefault;
- nCurrDigits = 2;
- return;
- }
+ pCurr = aCurrSeq.begin();
}
- aCurrSymbol = pCurrArr[nElem].Symbol;
- aCurrBankSymbol = pCurrArr[nElem].BankSymbol;
- nCurrDigits = pCurrArr[nElem].DecimalPlaces;
+ aCurrSymbol = pCurr->Symbol;
+ aCurrBankSymbol = pCurr->BankSymbol;
+ nCurrDigits = pCurr->DecimalPlaces;
}
void LocaleDataWrapper::scanCurrFormatImpl( const OUString& rCode,
@@ -999,9 +978,9 @@ void LocaleDataWrapper::getDateOrdersImpl()
// find the edit (21), a default (medium preferred),
// a medium (default preferred), and a long (default preferred)
NumberFormatCode const * const pFormatArr = aFormatSeq.getArray();
- sal_Int32 nElem, nEdit, nDef, nMedium, nLong;
+ sal_Int32 nEdit, nDef, nMedium, nLong;
nEdit = nDef = nMedium = nLong = -1;
- for ( nElem = 0; nElem < nCnt; nElem++ )
+ for ( sal_Int32 nElem = 0; nElem < nCnt; nElem++ )
{
if ( nEdit == -1 && pFormatArr[nElem].Index == NumberFormatIndex::DATE_SYS_DDMMYYYY )
nEdit = nElem;
@@ -1838,11 +1817,8 @@ void LocaleDataWrapper::setDateAcceptancePatterns(
// Copy existing full date pattern and append the sequence passed.
/* TODO: could check for duplicates and shrink target sequence */
Sequence< OUString > aTmp( rPatterns.getLength() + 1 );
- OUString* pArray1 = aTmp.getArray();
- const OUString* pArray2 = rPatterns.getConstArray();
- pArray1[0] = aDateAcceptancePatterns[0];
- for (sal_Int32 i=0; i < rPatterns.getLength(); ++i)
- pArray1[i+1] = pArray2[i];
+ aTmp[0] = aDateAcceptancePatterns[0];
+ std::copy(rPatterns.begin(), rPatterns.end(), std::next(aTmp.begin()));
aDateAcceptancePatterns = aTmp;
}
}
diff --git a/unotools/source/ucbhelper/progresshandlerwrap.cxx b/unotools/source/ucbhelper/progresshandlerwrap.cxx
index 9c50cf834ffc..2d085970bd53 100644
--- a/unotools/source/ucbhelper/progresshandlerwrap.cxx
+++ b/unotools/source/ucbhelper/progresshandlerwrap.cxx
@@ -37,13 +37,13 @@ static bool getStatusFromAny_Impl( const Any& aAny, OUString& aText, sal_Int32&
bool bNumIsSet = false;
Sequence< Any > aSetList;
- if( ( aAny >>= aSetList ) && aSetList.hasElements() )
- for( int ind = 0; ind < aSetList.getLength(); ind++ )
+ if( aAny >>= aSetList )
+ for( const auto& rSet : aSetList )
{
- if( !bNumIsSet && ( aSetList[ind] >>= nNum ) )
+ if( !bNumIsSet && ( rSet >>= nNum ) )
bNumIsSet = true;
else
- aText.isEmpty() && ( aSetList[ind] >>= aText );
+ aText.isEmpty() && ( rSet >>= aText );
}
return bNumIsSet;
diff --git a/unotools/source/ucbhelper/ucbhelper.cxx b/unotools/source/ucbhelper/ucbhelper.cxx
index ca7708b1c863..c2b25cd4f594 100644
--- a/unotools/source/ucbhelper/ucbhelper.cxx
+++ b/unotools/source/ucbhelper/ucbhelper.cxx
@@ -241,21 +241,21 @@ bool utl::UCBContentHelper::MakeFolder(
try {
css::uno::Sequence<css::ucb::ContentInfo> info(
parent.queryCreatableContentsInfo());
- for (sal_Int32 i = 0; i < info.getLength(); ++i) {
+ for (const auto& rInfo : info) {
// Simply look for the first KIND_FOLDER:
- if ((info[i].Attributes
+ if ((rInfo.Attributes
& css::ucb::ContentInfoAttribute::KIND_FOLDER)
!= 0)
{
// Make sure the only required bootstrap property is "Title":
- if ( info[i].Properties.getLength() != 1 || info[i].Properties[0].Name != "Title" )
+ if ( rInfo.Properties.getLength() != 1 || rInfo.Properties[0].Name != "Title" )
{
continue;
}
css::uno::Sequence<OUString> keys { "Title" };
css::uno::Sequence<css::uno::Any> values(1);
values[0] <<= title;
- if (parent.insertNewContent(info[i].Type, keys, values, result))
+ if (parent.insertNewContent(rInfo.Type, keys, values, result))
{
return true;
}
diff --git a/unotools/source/ucbhelper/ucblockbytes.cxx b/unotools/source/ucbhelper/ucblockbytes.cxx
index bff6ad67a390..a1e96fb3a338 100644
--- a/unotools/source/ucbhelper/ucblockbytes.cxx
+++ b/unotools/source/ucbhelper/ucblockbytes.cxx
@@ -161,10 +161,9 @@ public:
void SAL_CALL UcbPropertiesChangeListener_Impl::propertiesChange ( const Sequence<PropertyChangeEvent> &rEvent)
{
- sal_Int32 i, n = rEvent.getLength();
- for (i = 0; i < n; i++)
+ for (const auto& rPropChangeEvent : rEvent)
{
- if (rEvent[i].PropertyName == "DocumentHeader")
+ if (rPropChangeEvent.PropertyName == "DocumentHeader")
{
m_xLockBytes->SetStreamValid_Impl();
}
@@ -508,8 +507,8 @@ void Moderator::handle( const Reference<XInteractionRequest >& Request )
if(aReplyType == EXIT) {
Sequence<Reference<XInteractionContinuation> > aSeq(
Request->getContinuations());
- for(sal_Int32 i = 0; i < aSeq.getLength(); ++i) {
- Reference<XInteractionAbort> aRef(aSeq[i],UNO_QUERY);
+ for(const auto& rContinuation : aSeq) {
+ Reference<XInteractionAbort> aRef(rContinuation,UNO_QUERY);
if(aRef.is()) {
aRef->select();
}