summaryrefslogtreecommitdiff
path: root/svl/source
diff options
context:
space:
mode:
authorArkadiy Illarionov <qarkai@gmail.com>2019-07-13 21:29:10 +0300
committerArkadiy Illarionov <qarkai@gmail.com>2019-07-15 18:57:11 +0200
commitc9cce0d931b41ede0eca14b2ed2b84453f048362 (patch)
tree4931a620a9fe86fcf861456f475dc38184e7dc14 /svl/source
parent579b5bcd0477c411d2ae94be9aa33e653d8a38b6 (diff)
Simplify Sequence iterations in svl
Use range-based loops, STL and comphelper functions Change-Id: I1c3dbf194600bec60c0881d2d19ff07b89d8333b Reviewed-on: https://gerrit.libreoffice.org/75563 Tested-by: Jenkins Reviewed-by: Arkadiy Illarionov <qarkai@gmail.com>
Diffstat (limited to 'svl/source')
-rw-r--r--svl/source/config/asiancfg.cxx6
-rw-r--r--svl/source/items/ilstitem.cxx4
-rw-r--r--svl/source/items/itemprop.cxx14
-rw-r--r--svl/source/items/slstitm.cxx4
-rw-r--r--svl/source/items/srchitem.cxx54
-rw-r--r--svl/source/misc/ownlist.cxx7
-rw-r--r--svl/source/numbers/supservs.cxx7
-rw-r--r--svl/source/numbers/zforlist.cxx116
-rw-r--r--svl/source/numbers/zformat.cxx22
-rw-r--r--svl/source/passwordcontainer/passwordcontainer.cxx34
-rw-r--r--svl/source/passwordcontainer/syscreds.cxx5
11 files changed, 120 insertions, 153 deletions
diff --git a/svl/source/config/asiancfg.cxx b/svl/source/config/asiancfg.cxx
index af8b6e95b230..43a6d19351c2 100644
--- a/svl/source/config/asiancfg.cxx
+++ b/svl/source/config/asiancfg.cxx
@@ -103,9 +103,9 @@ css::uno::Sequence< css::lang::Locale > SvxAsianConfig::GetStartEndCharLocales()
impl_->context)->
getElementNames());
css::uno::Sequence< css::lang::Locale > ls(ns.getLength());
- for (sal_Int32 i = 0; i < ns.getLength(); ++i) {
- ls[i] = LanguageTag::convertToLocale( ns[i], false);
- }
+ std::transform(ns.begin(), ns.end(), ls.begin(),
+ [](const OUString& rName) -> css::lang::Locale {
+ return LanguageTag::convertToLocale( rName, false); });
return ls;
}
diff --git a/svl/source/items/ilstitem.cxx b/svl/source/items/ilstitem.cxx
index 75499d772252..a63055c7ffef 100644
--- a/svl/source/items/ilstitem.cxx
+++ b/svl/source/items/ilstitem.cxx
@@ -40,9 +40,7 @@ SfxIntegerListItem::SfxIntegerListItem( sal_uInt16 which, const ::std::vector <
SfxIntegerListItem::SfxIntegerListItem( sal_uInt16 which, const css::uno::Sequence < sal_Int32 >& rList )
: SfxPoolItem( which )
{
- m_aList.resize( rList.getLength() );
- for ( sal_Int32 n=0; n<rList.getLength(); ++n )
- m_aList[n] = rList[n];
+ comphelper::sequenceToContainer(m_aList, rList);
}
SfxIntegerListItem::~SfxIntegerListItem()
diff --git a/svl/source/items/itemprop.cxx b/svl/source/items/itemprop.cxx
index ca9de98910d2..6e0d046b93ed 100644
--- a/svl/source/items/itemprop.cxx
+++ b/svl/source/items/itemprop.cxx
@@ -82,7 +82,7 @@ const SfxItemPropertySimpleEntry* SfxItemPropertyMap::getByName( const OUString
uno::Sequence<beans::Property> const & SfxItemPropertyMap::getProperties() const
{
- if( !m_pImpl->m_aPropSeq.getLength() )
+ if( !m_pImpl->m_aPropSeq.hasElements() )
{
m_pImpl->m_aPropSeq.realloc( m_pImpl->size() );
beans::Property* pPropArray = m_pImpl->m_aPropSeq.getArray();
@@ -125,15 +125,13 @@ bool SfxItemPropertyMap::hasPropertyByName( const OUString& rName ) const
void SfxItemPropertyMap::mergeProperties( const uno::Sequence< beans::Property >& rPropSeq )
{
- const beans::Property* pPropArray = rPropSeq.getConstArray();
- sal_uInt32 nElements = rPropSeq.getLength();
- for( sal_uInt32 nElement = 0; nElement < nElements; ++nElement )
+ for( const beans::Property& rProp : rPropSeq )
{
SfxItemPropertySimpleEntry aTemp(
- sal::static_int_cast< sal_Int16 >( pPropArray[nElement].Handle ), //nWID
- pPropArray[nElement].Type, //aType
- pPropArray[nElement].Attributes); //nFlags
- (*m_pImpl)[pPropArray[nElement].Name] = aTemp;
+ sal::static_int_cast< sal_Int16 >( rProp.Handle ), //nWID
+ rProp.Type, //aType
+ rProp.Attributes); //nFlags
+ (*m_pImpl)[rProp.Name] = aTemp;
}
}
diff --git a/svl/source/items/slstitm.cxx b/svl/source/items/slstitm.cxx
index db0b781bbac1..225c43f08cfe 100644
--- a/svl/source/items/slstitm.cxx
+++ b/svl/source/items/slstitm.cxx
@@ -22,6 +22,7 @@
#include <svl/poolitem.hxx>
#include <com/sun/star/uno/Any.hxx>
#include <com/sun/star/uno/Sequence.hxx>
+#include <comphelper/sequence.hxx>
#include <osl/diagnose.h>
#include <rtl/ustrbuf.hxx>
#include <tools/lineend.hxx>
@@ -147,8 +148,7 @@ void SfxStringListItem::SetStringList( const css::uno::Sequence< OUString >& rLi
mpList.reset(new std::vector<OUString>);
// String belongs to the list
- for ( sal_Int32 n = 0; n < rList.getLength(); n++ )
- mpList->push_back(rList[n]);
+ comphelper::sequenceToContainer(*mpList, rList);
}
void SfxStringListItem::GetStringList( css::uno::Sequence< OUString >& rList ) const
diff --git a/svl/source/items/srchitem.cxx b/svl/source/items/srchitem.cxx
index e53df3a77518..5443cc06539b 100644
--- a/svl/source/items/srchitem.cxx
+++ b/svl/source/items/srchitem.cxx
@@ -508,91 +508,91 @@ bool SvxSearchItem::PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId )
if ( ( rVal >>= aSeq ) && ( aSeq.getLength() == SRCH_PARAMS ) )
{
sal_Int16 nConvertedCount( 0 );
- for ( sal_Int32 i = 0; i < aSeq.getLength(); ++i )
+ for ( const auto& rProp : aSeq )
{
- if ( aSeq[i].Name == SRCH_PARA_OPTIONS )
+ if ( rProp.Name == SRCH_PARA_OPTIONS )
{
css::util::SearchOptions2 nTmpSearchOpt2;
- if ( aSeq[i].Value >>= nTmpSearchOpt2 )
+ if ( rProp.Value >>= nTmpSearchOpt2 )
{
m_aSearchOpt = nTmpSearchOpt2;
++nConvertedCount;
}
}
- else if ( aSeq[i].Name == SRCH_PARA_FAMILY )
+ else if ( rProp.Name == SRCH_PARA_FAMILY )
{
sal_uInt16 nTemp( 0 );
- if ( aSeq[i].Value >>= nTemp )
+ if ( rProp.Value >>= nTemp )
{
m_eFamily = SfxStyleFamily( nTemp );
++nConvertedCount;
}
}
- else if ( aSeq[i].Name == SRCH_PARA_COMMAND )
+ else if ( rProp.Name == SRCH_PARA_COMMAND )
{
sal_uInt16 nTmp;
- if ( aSeq[i].Value >>= nTmp )
+ if ( rProp.Value >>= nTmp )
{
m_nCommand = static_cast<SvxSearchCmd>(nTmp);
++nConvertedCount;
}
}
- else if ( aSeq[i].Name == SRCH_PARA_CELLTYPE )
+ else if ( rProp.Name == SRCH_PARA_CELLTYPE )
{
sal_uInt16 nTmp;
- if ( aSeq[i].Value >>= nTmp )
+ if ( rProp.Value >>= nTmp )
{
m_nCellType = static_cast<SvxSearchCellType>(nTmp);
++nConvertedCount;
}
}
- else if ( aSeq[i].Name == SRCH_PARA_APPFLAG )
+ else if ( rProp.Name == SRCH_PARA_APPFLAG )
{
sal_uInt16 nTmp;
- if ( aSeq[i].Value >>= nTmp )
+ if ( rProp.Value >>= nTmp )
{
m_nAppFlag = static_cast<SvxSearchApp>(nTmp);
++nConvertedCount;
}
}
- else if ( aSeq[i].Name == SRCH_PARA_ROWDIR )
+ else if ( rProp.Name == SRCH_PARA_ROWDIR )
{
- if ( aSeq[i].Value >>= m_bRowDirection )
+ if ( rProp.Value >>= m_bRowDirection )
++nConvertedCount;
}
- else if ( aSeq[i].Name == SRCH_PARA_ALLTABLES )
+ else if ( rProp.Name == SRCH_PARA_ALLTABLES )
{
- if ( aSeq[i].Value >>= m_bAllTables )
+ if ( rProp.Value >>= m_bAllTables )
++nConvertedCount;
}
- else if ( aSeq[i].Name == SRCH_PARA_SEARCHFILTERED )
+ else if ( rProp.Name == SRCH_PARA_SEARCHFILTERED )
{
- if ( aSeq[i].Value >>= m_bSearchFiltered )
+ if ( rProp.Value >>= m_bSearchFiltered )
++nConvertedCount;
}
- else if ( aSeq[i].Name == SRCH_PARA_SEARCHFORMATTED )
+ else if ( rProp.Name == SRCH_PARA_SEARCHFORMATTED )
{
- if ( aSeq[i].Value >>= m_bSearchFormatted )
+ if ( rProp.Value >>= m_bSearchFormatted )
++nConvertedCount;
}
- else if ( aSeq[i].Name == SRCH_PARA_BACKWARD )
+ else if ( rProp.Name == SRCH_PARA_BACKWARD )
{
- if ( aSeq[i].Value >>= m_bBackward )
+ if ( rProp.Value >>= m_bBackward )
++nConvertedCount;
}
- else if ( aSeq[i].Name == SRCH_PARA_PATTERN )
+ else if ( rProp.Name == SRCH_PARA_PATTERN )
{
- if ( aSeq[i].Value >>= m_bPattern )
+ if ( rProp.Value >>= m_bPattern )
++nConvertedCount;
}
- else if ( aSeq[i].Name == SRCH_PARA_CONTENT )
+ else if ( rProp.Name == SRCH_PARA_CONTENT )
{
- if ( aSeq[i].Value >>= m_bContent )
+ if ( rProp.Value >>= m_bContent )
++nConvertedCount;
}
- else if ( aSeq[i].Name == SRCH_PARA_ASIANOPT )
+ else if ( rProp.Name == SRCH_PARA_ASIANOPT )
{
- if ( aSeq[i].Value >>= m_bAsianOptions )
+ if ( rProp.Value >>= m_bAsianOptions )
++nConvertedCount;
}
}
diff --git a/svl/source/misc/ownlist.cxx b/svl/source/misc/ownlist.cxx
index 5fbaef109a53..162d3e235b3a 100644
--- a/svl/source/misc/ownlist.cxx
+++ b/svl/source/misc/ownlist.cxx
@@ -41,13 +41,12 @@ void SvCommandList::Append
void SvCommandList::FillFromSequence( const css::uno::Sequence < css::beans::PropertyValue >& aCommandSequence )
{
- const sal_Int32 nCount = aCommandSequence.getLength();
OUString aCommand, aArg;
OUString aApiArg;
- for( sal_Int32 nIndex=0; nIndex<nCount; nIndex++ )
+ for( const auto& rCommand : aCommandSequence )
{
- aCommand = aCommandSequence[nIndex].Name;
- if( !( aCommandSequence[nIndex].Value >>= aApiArg ) )
+ aCommand = rCommand.Name;
+ if( !( rCommand.Value >>= aApiArg ) )
return;
aArg = aApiArg;
Append( aCommand, aArg );
diff --git a/svl/source/numbers/supservs.cxx b/svl/source/numbers/supservs.cxx
index 629f2991b4f9..77bbd449e88e 100644
--- a/svl/source/numbers/supservs.cxx
+++ b/svl/source/numbers/supservs.cxx
@@ -75,13 +75,12 @@ void SAL_CALL SvNumberFormatsSupplierServiceObject::initialize( const Sequence<
LanguageType eNewFormatterLanguage = LANGUAGE_SYSTEM;
// the default
- const Any* pArgs = _rArguments.getConstArray();
- for (sal_Int32 i=0; i<_rArguments.getLength(); ++i, ++pArgs)
+ for (const Any& rArg : _rArguments)
{
- if (pArgs->getValueType().equals(aExpectedArgType))
+ if (rArg.getValueType().equals(aExpectedArgType))
{
css::lang::Locale aLocale;
- *pArgs >>= aLocale;
+ rArg >>= aLocale;
eNewFormatterLanguage = LanguageTag::convertToLanguageType( aLocale, false);
}
#ifdef DBG_UTIL
diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx
index 85d9a90c9435..bd35c725d5db 100644
--- a/svl/source/numbers/zforlist.cxx
+++ b/svl/source/numbers/zforlist.cxx
@@ -2106,12 +2106,10 @@ sal_Int32 SvNumberFormatter::ImpGetFormatCodeIndex(
css::uno::Sequence< css::i18n::NumberFormatCode >& rSeq,
const NfIndexTableOffset nTabOff )
{
- const sal_Int32 nLen = rSeq.getLength();
- for ( sal_Int32 j=0; j<nLen; j++ )
- {
- if ( rSeq[j].Index == nTabOff )
- return j;
- }
+ auto pSeq = std::find_if(rSeq.begin(), rSeq.end(),
+ [nTabOff](const css::i18n::NumberFormatCode& rCode) { return rCode.Index == nTabOff; });
+ if (pSeq != rSeq.end())
+ return static_cast<sal_Int32>(std::distance(rSeq.begin(), pSeq));
if (LocaleDataWrapper::areChecksEnabled() && (nTabOff < NF_CURRENCY_START
|| NF_CURRENCY_END < nTabOff || nTabOff == NF_CURRENCY_1000INT
|| nTabOff == NF_CURRENCY_1000INT_RED
@@ -2121,31 +2119,27 @@ sal_Int32 SvNumberFormatter::ImpGetFormatCodeIndex(
+ OUString::number( nTabOff );
LocaleDataWrapper::outputCheckMessage( xLocaleData->appendLocaleInfo(aMsg));
}
- if ( nLen )
+ if ( rSeq.hasElements() )
{
- sal_Int32 j;
// look for a preset default
- for ( j=0; j<nLen; j++ )
- {
- if ( rSeq[j].Default )
- return j;
- }
+ pSeq = std::find_if(rSeq.begin(), rSeq.end(),
+ [](const css::i18n::NumberFormatCode& rCode) { return rCode.Default; });
+ if (pSeq != rSeq.end())
+ return static_cast<sal_Int32>(std::distance(rSeq.begin(), pSeq));
// currencies are special, not all format codes must exist, but all
// builtin number format key index positions must have a format assigned
if ( NF_CURRENCY_START <= nTabOff && nTabOff <= NF_CURRENCY_END )
{
// look for a format with decimals
- for ( j=0; j<nLen; j++ )
- {
- if ( rSeq[j].Index == NF_CURRENCY_1000DEC2 )
- return j;
- }
+ pSeq = std::find_if(rSeq.begin(), rSeq.end(),
+ [](const css::i18n::NumberFormatCode& rCode) { return rCode.Index == NF_CURRENCY_1000DEC2; });
+ if (pSeq != rSeq.end())
+ return static_cast<sal_Int32>(std::distance(rSeq.begin(), pSeq));
// last resort: look for a format without decimals
- for ( j=0; j<nLen; j++ )
- {
- if ( rSeq[j].Index == NF_CURRENCY_1000INT )
- return j;
- }
+ pSeq = std::find_if(rSeq.begin(), rSeq.end(),
+ [](const css::i18n::NumberFormatCode& rCode) { return rCode.Index == NF_CURRENCY_1000INT; });
+ if (pSeq != rSeq.end())
+ return static_cast<sal_Int32>(std::distance(rSeq.begin(), pSeq));
}
}
else
@@ -2763,39 +2757,37 @@ void SvNumberFormatter::ImpGenerateAdditionalFormats( sal_uInt32 CLOffset,
}
sal_uInt32 nPos = CLOffset + pStdFormat->GetLastInsertKey( SvNumberformat::FormatterPrivateAccess() );
css::lang::Locale aLocale = GetLanguageTag().getLocale();
- sal_Int32 j;
// All currencies, this time with [$...] which was stripped in
// ImpGenerateFormats for old "automatic" currency formats.
uno::Sequence< i18n::NumberFormatCode > aFormatSeq = rNumberFormatCode->getAllFormatCode( i18n::KNumberFormatUsage::CURRENCY, aLocale );
- i18n::NumberFormatCode * pFormatArr = aFormatSeq.getArray();
sal_Int32 nCodes = aFormatSeq.getLength();
ImpAdjustFormatCodeDefault( aFormatSeq.getArray(), nCodes );
- for ( j = 0; j < nCodes; j++ )
+ for ( i18n::NumberFormatCode& rFormat : aFormatSeq )
{
if ( nPos - CLOffset >= SV_COUNTRY_LANGUAGE_OFFSET )
{
SAL_WARN( "svl.numbers", "ImpGenerateAdditionalFormats: too many formats" );
break; // for
}
- if ( pFormatArr[j].Index < NF_INDEX_TABLE_LOCALE_DATA_DEFAULTS &&
- pFormatArr[j].Index != NF_CURRENCY_1000DEC2_CCC )
+ if ( rFormat.Index < NF_INDEX_TABLE_LOCALE_DATA_DEFAULTS &&
+ rFormat.Index != NF_CURRENCY_1000DEC2_CCC )
{ // Insert only if not already inserted, but internal index must be
// above so ImpInsertFormat can distinguish it.
- sal_Int16 nOrgIndex = pFormatArr[j].Index;
- pFormatArr[j].Index = sal::static_int_cast< sal_Int16 >(
- pFormatArr[j].Index + nCodes + NF_INDEX_TABLE_ENTRIES);
+ sal_Int16 nOrgIndex = rFormat.Index;
+ rFormat.Index = sal::static_int_cast< sal_Int16 >(
+ rFormat.Index + nCodes + NF_INDEX_TABLE_ENTRIES);
//! no default on currency
- bool bDefault = aFormatSeq[j].Default;
- aFormatSeq[j].Default = false;
- if ( SvNumberformat* pNewFormat = ImpInsertFormat( pFormatArr[j], nPos+1,
+ bool bDefault = rFormat.Default;
+ rFormat.Default = false;
+ if ( SvNumberformat* pNewFormat = ImpInsertFormat( rFormat, nPos+1,
bAfterChangingSystemCL, nOrgIndex ) )
{
pNewFormat->SetAdditionalBuiltin();
nPos++;
}
- pFormatArr[j].Index = nOrgIndex;
- aFormatSeq[j].Default = bDefault;
+ rFormat.Index = nOrgIndex;
+ rFormat.Default = bDefault;
}
}
@@ -2806,25 +2798,20 @@ void SvNumberFormatter::ImpGenerateAdditionalFormats( sal_uInt32 CLOffset,
// There is no harm though, on first invocation ImpGetDefaultFormat() will
// use the first default encountered.
aFormatSeq = rNumberFormatCode->getAllFormatCodes( aLocale );
- nCodes = aFormatSeq.getLength();
- if ( nCodes )
+ for ( const auto& rFormat : aFormatSeq )
{
- pFormatArr = aFormatSeq.getArray();
- for ( j = 0; j < nCodes; j++ )
+ if ( nPos - CLOffset >= SV_COUNTRY_LANGUAGE_OFFSET )
{
- if ( nPos - CLOffset >= SV_COUNTRY_LANGUAGE_OFFSET )
- {
- SAL_WARN( "svl.numbers", "ImpGenerateAdditionalFormats: too many formats" );
- break; // for
- }
- if ( pFormatArr[j].Index >= NF_INDEX_TABLE_LOCALE_DATA_DEFAULTS )
+ SAL_WARN( "svl.numbers", "ImpGenerateAdditionalFormats: too many formats" );
+ break; // for
+ }
+ if ( rFormat.Index >= NF_INDEX_TABLE_LOCALE_DATA_DEFAULTS )
+ {
+ if ( SvNumberformat* pNewFormat = ImpInsertFormat( rFormat, nPos+1,
+ bAfterChangingSystemCL ) )
{
- if ( SvNumberformat* pNewFormat = ImpInsertFormat( pFormatArr[j], nPos+1,
- bAfterChangingSystemCL ) )
- {
- pNewFormat->SetAdditionalBuiltin();
- nPos++;
- }
+ pNewFormat->SetAdditionalBuiltin();
+ nPos++;
}
}
}
@@ -3754,20 +3741,14 @@ void SvNumberFormatter::GetCompatibilityCurrency( OUString& rSymbol, OUString& r
css::uno::Sequence< css::i18n::Currency2 >
xCurrencies( xLocaleData->getAllCurrencies() );
- const css::i18n::Currency2 *pCurrencies = xCurrencies.getConstArray();
- sal_Int32 nCurrencies = xCurrencies.getLength();
-
- sal_Int32 j;
- for ( j=0; j < nCurrencies; ++j )
+ auto pCurrency = std::find_if(xCurrencies.begin(), xCurrencies.end(),
+ [](const css::i18n::Currency2& rCurrency) { return rCurrency.UsedInCompatibleFormatCodes; });
+ if (pCurrency != xCurrencies.end())
{
- if ( pCurrencies[j].UsedInCompatibleFormatCodes )
- {
- rSymbol = pCurrencies[j].Symbol;
- rAbbrev = pCurrencies[j].BankSymbol;
- break;
- }
+ rSymbol = pCurrency->Symbol;
+ rAbbrev = pCurrency->BankSymbol;
}
- if ( j >= nCurrencies )
+ else
{
if (LocaleDataWrapper::areChecksEnabled())
{
@@ -3864,16 +3845,15 @@ void SvNumberFormatter::ImpInitCurrencyTable()
css::uno::Sequence< css::lang::Locale > xLoc = LocaleDataWrapper::getInstalledLocaleNames();
sal_Int32 nLocaleCount = xLoc.getLength();
SAL_INFO( "svl.numbers", "number of locales: \"" << nLocaleCount << "\"" );
- css::lang::Locale const * const pLocales = xLoc.getConstArray();
NfCurrencyTable &rCurrencyTable = theCurrencyTable::get();
NfCurrencyTable &rLegacyOnlyCurrencyTable = theLegacyOnlyCurrencyTable::get();
NfInstalledLocales &rInstalledLocales = theInstalledLocales::get();
sal_uInt16 nLegacyOnlyCurrencyPos = 0;
- for ( sal_Int32 nLocale = 0; nLocale < nLocaleCount; nLocale++ )
+ for ( css::lang::Locale const & rLocale : xLoc )
{
- LanguageType eLang = LanguageTag::convertToLanguageType( pLocales[nLocale], false);
+ LanguageType eLang = LanguageTag::convertToLanguageType( rLocale, false);
rInstalledLocales.insert( eLang);
- pLocaleData->setLanguageTag( LanguageTag( pLocales[nLocale]) );
+ pLocaleData->setLanguageTag( LanguageTag( rLocale) );
Sequence< Currency2 > aCurrSeq = pLocaleData->getAllCurrencies();
sal_Int32 nCurrencyCount = aCurrSeq.getLength();
Currency2 const * const pCurrencies = aCurrSeq.getConstArray();
diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx
index 4248e03256f2..c182c932d099 100644
--- a/svl/source/numbers/zformat.cxx
+++ b/svl/source/numbers/zformat.cxx
@@ -3363,20 +3363,18 @@ void SvNumberformat::SwitchToOtherCalendar( OUString& rOrgCalendar,
if ( nCnt <= 1 )
return;
- for ( sal_Int32 j=0; j < nCnt; j++ )
+ auto pCal = std::find_if(xCals.begin(), xCals.end(),
+ [](const OUString& rCalName) { return rCalName != GREGORIAN; });
+ if (pCal == xCals.end())
+ return;
+
+ if ( !rOrgCalendar.getLength() )
{
- if ( xCals[j] != GREGORIAN )
- {
- if ( !rOrgCalendar.getLength() )
- {
- rOrgCalendar = rCal.getUniqueID();
- fOrgDateTime = rCal.getDateTime();
- }
- rCal.loadCalendar( xCals[j], rLoc().getLanguageTag().getLocale() );
- rCal.setDateTime( fOrgDateTime );
- break; // for
- }
+ rOrgCalendar = rCal.getUniqueID();
+ fOrgDateTime = rCal.getDateTime();
}
+ rCal.loadCalendar( *pCal, rLoc().getLanguageTag().getLocale() );
+ rCal.setDateTime( fOrgDateTime );
}
void SvNumberformat::SwitchToGregorianCalendar( const OUString& rOrgCalendar,
diff --git a/svl/source/passwordcontainer/passwordcontainer.cxx b/svl/source/passwordcontainer/passwordcontainer.cxx
index ba86b8887e3d..a8dfd1bc0f29 100644
--- a/svl/source/passwordcontainer/passwordcontainer.cxx
+++ b/svl/source/passwordcontainer/passwordcontainer.cxx
@@ -183,22 +183,20 @@ PassMap StorageItem::getInfo()
Sequence< OUString > aNodeNames = ConfigItem::GetNodeNames( "Store" );
sal_Int32 aNodeCount = aNodeNames.getLength();
Sequence< OUString > aPropNames( aNodeCount );
- sal_Int32 aNodeInd;
- for( aNodeInd = 0; aNodeInd < aNodeCount; ++aNodeInd )
- {
- aPropNames[aNodeInd] = "Store/Passwordstorage['" + aNodeNames[aNodeInd] + "']/Password";
- }
+ std::transform(aNodeNames.begin(), aNodeNames.end(), aPropNames.begin(),
+ [](const OUString& rName) -> OUString {
+ return "Store/Passwordstorage['" + rName + "']/Password"; });
Sequence< Any > aPropertyValues = ConfigItem::GetProperties( aPropNames );
- if( aPropertyValues.getLength() != aNodeNames.getLength() )
+ if( aPropertyValues.getLength() != aNodeCount )
{
- OSL_ENSURE( aPropertyValues.getLength() == aNodeNames.getLength(), "Problems during reading" );
+ OSL_FAIL( "Problems during reading" );
return aResult;
}
- for( aNodeInd = 0; aNodeInd < aNodeCount; ++aNodeInd )
+ for( sal_Int32 aNodeInd = 0; aNodeInd < aNodeCount; ++aNodeInd )
{
std::vector< OUString > aUrlUsr = getInfoFromInd( aNodeNames[aNodeInd] );
@@ -251,7 +249,7 @@ bool StorageItem::useStorage()
if( aPropertyValues.getLength() != aNodeNames.getLength() )
{
- OSL_ENSURE( aPropertyValues.getLength() == aNodeNames.getLength(), "Problems during reading" );
+ OSL_FAIL( "Problems during reading" );
return false;
}
@@ -278,7 +276,7 @@ bool StorageItem::getEncodedMP( OUString& aResult )
if( aPropertyValues.getLength() != aNodeNames.getLength() )
{
- OSL_ENSURE( aPropertyValues.getLength() == aNodeNames.getLength(), "Problems during reading" );
+ OSL_FAIL( "Problems during reading" );
return false;
}
@@ -1104,11 +1102,9 @@ sal_Bool SAL_CALL PasswordContainer::changeMasterPassword( const uno::Reference<
m_pStorageFile->setEncodedMP( EncodePasswords( aMaster, m_aMasterPasswd ) );
// store all the entries with the new password
- for ( int nURLInd = 0; nURLInd < aPersistent.getLength(); nURLInd++ )
- for ( int nNameInd = 0; nNameInd< aPersistent[nURLInd].UserList.getLength(); nNameInd++ )
- addPersistent( aPersistent[nURLInd].Url,
- aPersistent[nURLInd].UserList[nNameInd].UserName,
- aPersistent[nURLInd].UserList[nNameInd].Passwords,
+ for ( const auto& rURL : aPersistent )
+ for ( const auto& rUser : rURL.UserList )
+ addPersistent( rURL.Url, rUser.UserName, rUser.Passwords,
uno::Reference< task::XInteractionHandler >() );
bResult = true;
@@ -1208,11 +1204,9 @@ sal_Bool SAL_CALL PasswordContainer::useDefaultMasterPassword( const uno::Refere
m_pStorageFile->setEncodedMP( OUString(), true );
// store all the entries with the new password
- for ( int nURLInd = 0; nURLInd < aPersistent.getLength(); nURLInd++ )
- for ( int nNameInd = 0; nNameInd< aPersistent[nURLInd].UserList.getLength(); nNameInd++ )
- addPersistent( aPersistent[nURLInd].Url,
- aPersistent[nURLInd].UserList[nNameInd].UserName,
- aPersistent[nURLInd].UserList[nNameInd].Passwords,
+ for ( const auto& rURL : aPersistent )
+ for ( const auto& rUser : rURL.UserList )
+ addPersistent( rURL.Url, rUser.UserName, rUser.Passwords,
uno::Reference< task::XInteractionHandler >() );
bResult = true;
diff --git a/svl/source/passwordcontainer/syscreds.cxx b/svl/source/passwordcontainer/syscreds.cxx
index 44e125d62861..09604631051b 100644
--- a/svl/source/passwordcontainer/syscreds.cxx
+++ b/svl/source/passwordcontainer/syscreds.cxx
@@ -20,6 +20,7 @@
#include "syscreds.hxx"
#include <osl/diagnose.h>
#include <comphelper/sequence.hxx>
+#include <iterator>
using namespace com::sun::star;
@@ -171,8 +172,8 @@ void SysCredentialsConfig::initCfg()
{
uno::Sequence< OUString > aURLs(
m_aConfigItem.getSystemCredentialsURLs() );
- for ( sal_Int32 n = 0; n < aURLs.getLength(); ++n )
- m_aCfgContainer.insert( aURLs[ n ] );
+ std::copy(aURLs.begin(), aURLs.end(),
+ std::inserter(m_aCfgContainer, m_aCfgContainer.end()));
m_bCfgInited = true;
}