summaryrefslogtreecommitdiff
path: root/svtools
diff options
context:
space:
mode:
authorArkadiy Illarionov <qarkai@gmail.com>2019-07-12 00:45:46 +0300
committerArkadiy Illarionov <qarkai@gmail.com>2019-07-15 18:56:33 +0200
commit579b5bcd0477c411d2ae94be9aa33e653d8a38b6 (patch)
treea38c0a8231a149ebe7f2356ad38a612529ca3e70 /svtools
parent574db10513be6b25f24c8cab49cbc9e63aca87d3 (diff)
Simplify Sequence iterations in svtools
Use range-based loops, STL and comphelper functions Change-Id: I4197b5083327998169a39389b968e1ff99f13339 Reviewed-on: https://gerrit.libreoffice.org/75440 Tested-by: Jenkins Reviewed-by: Arkadiy Illarionov <qarkai@gmail.com>
Diffstat (limited to 'svtools')
-rw-r--r--svtools/source/config/extcolorcfg.cxx7
-rw-r--r--svtools/source/config/fontsubstconfig.cxx16
-rw-r--r--svtools/source/config/helpopt.cxx14
-rw-r--r--svtools/source/config/miscopt.cxx14
-rw-r--r--svtools/source/config/slidesorterbaropt.cxx14
-rw-r--r--svtools/source/contnr/DocumentInfoPreview.cxx4
-rw-r--r--svtools/source/contnr/contentenumeration.cxx9
-rw-r--r--svtools/source/control/inettbc.cxx174
-rw-r--r--svtools/source/dialogs/PlaceEditDialog.cxx3
-rw-r--r--svtools/source/dialogs/addresstemplate.cxx40
-rw-r--r--svtools/source/dialogs/colrdlg.cxx6
-rw-r--r--svtools/source/dialogs/insdlg.cxx5
-rw-r--r--svtools/source/filter/DocumentToGraphicRenderer.cxx18
-rw-r--r--svtools/source/filter/SvFilterOptionsDialog.cxx30
-rw-r--r--svtools/source/filter/exportdialog.cxx5
-rw-r--r--svtools/source/java/javainteractionhandler.cxx9
-rw-r--r--svtools/source/misc/embedhlp.cxx12
-rw-r--r--svtools/source/misc/imagemgr.cxx4
-rw-r--r--svtools/source/misc/langhelp.cxx19
-rw-r--r--svtools/source/misc/langtab.cxx4
-rw-r--r--svtools/source/uno/genericunodialog.cxx5
-rw-r--r--svtools/source/uno/popupmenucontrollerbase.cxx13
-rw-r--r--svtools/source/uno/statusbarcontroller.cxx4
-rw-r--r--svtools/source/uno/toolboxcontroller.cxx4
-rw-r--r--svtools/source/uno/unocontroltablemodel.cxx6
-rw-r--r--svtools/source/uno/unoevent.cxx4
-rw-r--r--svtools/source/uno/wizard/unowizard.cxx28
-rw-r--r--svtools/source/uno/wizard/wizardshell.cxx4
28 files changed, 186 insertions, 289 deletions
diff --git a/svtools/source/config/extcolorcfg.cxx b/svtools/source/config/extcolorcfg.cxx
index 6fdcf0ead67c..634344521d77 100644
--- a/svtools/source/config/extcolorcfg.cxx
+++ b/svtools/source/config/extcolorcfg.cxx
@@ -30,6 +30,7 @@
#include <unotools/configitem.hxx>
#include <unotools/configpaths.hxx>
#include <com/sun/star/uno/Sequence.h>
+#include <comphelper/sequence.hxx>
#include <svl/poolitem.hxx>
#include <svl/hint.hxx>
#include <osl/mutex.hxx>
@@ -436,11 +437,7 @@ bool ExtendedColorConfig_Impl::ExistsScheme(const OUString& _sSchemeName)
uno::Sequence < OUString > aComponentNames = GetPropertyNames(sBase);
sBase += "/" + _sSchemeName;
- const OUString* pCompIter = aComponentNames.getConstArray();
- const OUString* pCompEnd = pCompIter + aComponentNames.getLength();
- for(;pCompIter != pCompEnd && *pCompIter != sBase;++pCompIter)
- ;
- return pCompIter != pCompEnd;
+ return comphelper::findValue(aComponentNames, sBase) != -1;
}
void ExtendedColorConfig_Impl::SetColorConfigValue(const OUString& _sName, const ExtendedColorConfigValue& rValue )
diff --git a/svtools/source/config/fontsubstconfig.cxx b/svtools/source/config/fontsubstconfig.cxx
index 7db21e021ba2..ffcc6399002d 100644
--- a/svtools/source/config/fontsubstconfig.cxx
+++ b/svtools/source/config/fontsubstconfig.cxx
@@ -60,24 +60,22 @@ SvtFontSubstConfig::SvtFontSubstConfig() :
OUString sPropPrefix(cFontPairs);
Sequence<OUString> aNodeNames = GetNodeNames(sPropPrefix, ConfigNameFormat::LocalPath);
- const OUString* pNodeNames = aNodeNames.getConstArray();
Sequence<OUString> aPropNames(aNodeNames.getLength() * 4);
OUString* pNames = aPropNames.getArray();
sal_Int32 nName = 0;
sPropPrefix += "/";
- sal_Int32 nNode;
- for(nNode = 0; nNode < aNodeNames.getLength(); nNode++)
+ for(const OUString& rNodeName : aNodeNames)
{
- OUString sStart = sPropPrefix + pNodeNames[nNode] + "/";
- pNames[nName] = sStart; pNames[nName++] += cReplaceFont;
- pNames[nName] = sStart; pNames[nName++] += cSubstituteFont;
- pNames[nName] = sStart; pNames[nName++] += cAlways;
- pNames[nName] = sStart; pNames[nName++] += cOnScreenOnly;
+ OUString sStart = sPropPrefix + rNodeName + "/";
+ pNames[nName++] = sStart + cReplaceFont;
+ pNames[nName++] = sStart + cSubstituteFont;
+ pNames[nName++] = sStart + cAlways;
+ pNames[nName++] = sStart + cOnScreenOnly;
}
Sequence<Any> aNodeValues = GetProperties(aPropNames);
const Any* pNodeValues = aNodeValues.getConstArray();
nName = 0;
- for(nNode = 0; nNode < aNodeNames.getLength(); nNode++)
+ for(sal_Int32 nNode = 0; nNode < aNodeNames.getLength(); nNode++)
{
SubstitutionStruct aInsert;
pNodeValues[nName++] >>= aInsert.sFont;
diff --git a/svtools/source/config/helpopt.cxx b/svtools/source/config/helpopt.cxx
index 900b67c31505..8677b4a6a757 100644
--- a/svtools/source/config/helpopt.cxx
+++ b/svtools/source/config/helpopt.cxx
@@ -27,6 +27,7 @@
#include <tools/debug.hxx>
#include <com/sun/star/uno/Any.hxx>
#include <com/sun/star/uno/Sequence.hxx>
+#include <comphelper/sequence.hxx>
#include <vcl/help.hxx>
#include <osl/mutex.hxx>
#include <sal/log.hxx>
@@ -125,17 +126,6 @@ SvtHelpOptions_Impl::~SvtHelpOptions_Impl()
Commit();
}
-static int lcl_MapPropertyName( const OUString& rCompare,
- const uno::Sequence< OUString>& aInternalPropertyNames)
-{
- for(int nProp = 0; nProp < aInternalPropertyNames.getLength(); ++nProp)
- {
- if( aInternalPropertyNames[nProp] == rCompare )
- return nProp;
- }
- return -1;
-}
-
void SvtHelpOptions_Impl::Load(const uno::Sequence< OUString>& rPropertyNames)
{
const uno::Sequence< OUString> aInternalPropertyNames( GetPropertyNames());
@@ -156,7 +146,7 @@ void SvtHelpOptions_Impl::Load(const uno::Sequence< OUString>& rPropertyNames)
if ( pValues[nProp] >>= bTmp )
{
switch ( static_cast< HelpProperty >(
- lcl_MapPropertyName(rPropertyNames[nProp], aInternalPropertyNames) ) )
+ comphelper::findValue(aInternalPropertyNames, rPropertyNames[nProp]) ) )
{
case HelpProperty::ExtendedHelp:
bExtendedHelp = bTmp;
diff --git a/svtools/source/config/miscopt.cxx b/svtools/source/config/miscopt.cxx
index 2b76004d968f..4328e3b8bc65 100644
--- a/svtools/source/config/miscopt.cxx
+++ b/svtools/source/config/miscopt.cxx
@@ -23,6 +23,7 @@
#include <tools/debug.hxx>
#include <com/sun/star/uno/Any.hxx>
#include <com/sun/star/uno/Sequence.hxx>
+#include <comphelper/sequence.hxx>
#include <tools/link.hxx>
#include <osl/diagnose.h>
@@ -409,17 +410,6 @@ SvtMiscOptions_Impl::~SvtMiscOptions_Impl()
assert(!IsModified()); // should have been committed
}
-static int lcl_MapPropertyName( const OUString& rCompare,
- const uno::Sequence< OUString>& aInternalPropertyNames)
-{
- for(int nProp = 0; nProp < aInternalPropertyNames.getLength(); ++nProp)
- {
- if( aInternalPropertyNames[nProp] == rCompare )
- return nProp;
- }
- return -1;
-}
-
void SvtMiscOptions_Impl::Load( const Sequence< OUString >& rPropertyNames )
{
const uno::Sequence< OUString> aInternalPropertyNames( GetPropertyNames());
@@ -436,7 +426,7 @@ void SvtMiscOptions_Impl::Load( const Sequence< OUString >& rPropertyNames )
{
if (!seqValues[nProperty].hasValue())
continue;
- switch( lcl_MapPropertyName(rPropertyNames[nProperty], aInternalPropertyNames) )
+ switch( comphelper::findValue(aInternalPropertyNames, rPropertyNames[nProperty]) )
{
case PROPERTYHANDLE_PLUGINSENABLED : {
if( !(seqValues[nProperty] >>= m_bPluginsEnabled) )
diff --git a/svtools/source/config/slidesorterbaropt.cxx b/svtools/source/config/slidesorterbaropt.cxx
index 7c77d2bae968..9480dcc50a15 100644
--- a/svtools/source/config/slidesorterbaropt.cxx
+++ b/svtools/source/config/slidesorterbaropt.cxx
@@ -26,6 +26,7 @@
#include <com/sun/star/uno/Sequence.hxx>
#include <comphelper/lok.hxx>
+#include <comphelper/sequence.hxx>
#include <rtl/instance.hxx>
using namespace ::utl;
@@ -197,17 +198,6 @@ SvtSlideSorterBarOptions_Impl::~SvtSlideSorterBarOptions_Impl()
Commit();
}
-static int lcl_MapPropertyName( const OUString& rCompare,
- const uno::Sequence< OUString>& aInternalPropertyNames)
-{
- for(int nProp = 0; nProp < aInternalPropertyNames.getLength(); ++nProp)
- {
- if( aInternalPropertyNames[nProp] == rCompare )
- return nProp;
- }
- return -1;
-}
-
void SvtSlideSorterBarOptions_Impl::Load( const Sequence< OUString >& rPropertyNames )
{
const uno::Sequence< OUString> aInternalPropertyNames( GetPropertyNames());
@@ -224,7 +214,7 @@ void SvtSlideSorterBarOptions_Impl::Load( const Sequence< OUString >& rPropertyN
{
if (!seqValues[nProperty].hasValue())
continue;
- switch( lcl_MapPropertyName(rPropertyNames[nProperty], aInternalPropertyNames) )
+ switch( comphelper::findValue(aInternalPropertyNames, rPropertyNames[nProperty]) )
{
case PROPERTYHANDLE_VISIBLE_IMPRESSVIEW:
{
diff --git a/svtools/source/contnr/DocumentInfoPreview.cxx b/svtools/source/contnr/DocumentInfoPreview.cxx
index c853084e4e0e..22d29b2a65ce 100644
--- a/svtools/source/contnr/DocumentInfoPreview.cxx
+++ b/svtools/source/contnr/DocumentInfoPreview.cxx
@@ -104,8 +104,8 @@ void ODocumentInfoPreview::fill(
css::uno::Reference< css::beans::XPropertySetInfo > info(
user->getPropertySetInfo());
css::uno::Sequence< css::beans::Property > props(info->getProperties());
- for (sal_Int32 i = 0; i < props.getLength(); ++i) {
- OUString name(props[i].Name);
+ for (const auto& rProp : props) {
+ OUString name(rProp.Name);
css::uno::Any aAny(user->getPropertyValue(name));
css::uno::Reference< css::script::XTypeConverter > conv(
css::script::Converter::create(
diff --git a/svtools/source/contnr/contentenumeration.cxx b/svtools/source/contnr/contentenumeration.cxx
index c3fff23b4a2f..168b2a35afaa 100644
--- a/svtools/source/contnr/contentenumeration.cxx
+++ b/svtools/source/contnr/contentenumeration.cxx
@@ -30,6 +30,7 @@
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/document/DocumentProperties.hpp>
#include <comphelper/processfactory.hxx>
+#include <comphelper/sequence.hxx>
#include <vcl/svapp.hxx>
#include <osl/mutex.hxx>
#include <sal/log.hxx>
@@ -324,13 +325,7 @@ namespace svt
{
OUString entryName = sRealURL.copy( sRealURL.lastIndexOf( '/' ) + 1 );
- for (int i = 0; i < m_rBlackList.getLength() ; i++)
- {
- if ( entryName == m_rBlackList[i] )
- return true;
- }
-
- return false;
+ return comphelper::findValue(m_rBlackList, entryName) != -1;
}
diff --git a/svtools/source/control/inettbc.cxx b/svtools/source/control/inettbc.cxx
index e0358e05c86c..197c7871a247 100644
--- a/svtools/source/control/inettbc.cxx
+++ b/svtools/source/control/inettbc.cxx
@@ -193,20 +193,16 @@ void SvtMatchContext_Impl::FillPicklist(std::vector<OUString>& rPickList)
{
Sequence< PropertyValue > seqPropertySet = seqPicklist[ nItem ];
- OUString sTitle;
- INetURLObject aURL;
-
- sal_uInt32 nPropertyCount = seqPropertySet.getLength();
-
- for( sal_uInt32 nProperty=0; nProperty < nPropertyCount; nProperty++ )
+ auto pProperty = std::find_if(seqPropertySet.begin(), seqPropertySet.end(),
+ [](const PropertyValue& rProperty) { return rProperty.Name == HISTORY_PROPERTYNAME_TITLE; });
+ if (pProperty != seqPropertySet.end())
{
- if( seqPropertySet[nProperty].Name == HISTORY_PROPERTYNAME_TITLE )
- {
- seqPropertySet[nProperty].Value >>= sTitle;
- aURL.SetURL( sTitle );
- rPickList.insert(rPickList.begin() + nItem, aURL.GetMainURL(INetURLObject::DecodeMechanism::WithCharset));
- break;
- }
+ OUString sTitle;
+ INetURLObject aURL;
+
+ pProperty->Value >>= sTitle;
+ aURL.SetURL( sTitle );
+ rPickList.insert(rPickList.begin() + nItem, aURL.GetMainURL(INetURLObject::DecodeMechanism::WithCharset));
}
}
}
@@ -518,20 +514,16 @@ void MatchContext_Impl::FillPicklist(std::vector<OUString>& rPickList)
{
Sequence< PropertyValue > seqPropertySet = seqPicklist[ nItem ];
- OUString sTitle;
- INetURLObject aURL;
-
- sal_uInt32 nPropertyCount = seqPropertySet.getLength();
-
- for( sal_uInt32 nProperty=0; nProperty < nPropertyCount; nProperty++ )
+ auto pProperty = std::find_if(seqPropertySet.begin(), seqPropertySet.end(),
+ [](const PropertyValue& rProperty) { return rProperty.Name == HISTORY_PROPERTYNAME_TITLE; });
+ if (pProperty != seqPropertySet.end())
{
- if( seqPropertySet[nProperty].Name == HISTORY_PROPERTYNAME_TITLE )
- {
- seqPropertySet[nProperty].Value >>= sTitle;
- aURL.SetURL( sTitle );
- rPickList.insert(rPickList.begin() + nItem, aURL.GetMainURL(INetURLObject::DecodeMechanism::WithCharset));
- break;
- }
+ OUString sTitle;
+ INetURLObject aURL;
+
+ pProperty->Value >>= sTitle;
+ aURL.SetURL( sTitle );
+ rPickList.insert(rPickList.begin() + nItem, aURL.GetMainURL(INetURLObject::DecodeMechanism::WithCharset));
}
}
}
@@ -1497,53 +1489,46 @@ void SvtURLBox::UpdatePicklistForSmartProtocol_Impl()
// read history pick list
Sequence< Sequence< PropertyValue > > seqPicklist = SvtHistoryOptions().GetList( ePICKLIST );
- sal_uInt32 nCount = seqPicklist.getLength();
INetURLObject aCurObj;
- for( sal_uInt32 nItem=0; nItem < nCount; nItem++ )
+ for( const Sequence< PropertyValue >& rPropertySet : seqPicklist )
{
- Sequence< PropertyValue > seqPropertySet = seqPicklist[ nItem ];
-
- OUString sURL;
+ auto pProperty = std::find_if(rPropertySet.begin(), rPropertySet.end(),
+ [](const PropertyValue& rProperty) { return rProperty.Name == HISTORY_PROPERTYNAME_URL; });
+ if (pProperty != rPropertySet.end())
+ {
+ OUString sURL;
- sal_uInt32 nPropertyCount = seqPropertySet.getLength();
+ pProperty->Value >>= sURL;
+ aCurObj.SetURL( sURL );
- for( sal_uInt32 nProperty=0; nProperty < nPropertyCount; nProperty++ )
- {
- if( seqPropertySet[nProperty].Name == HISTORY_PROPERTYNAME_URL )
+ if ( !sURL.isEmpty() && ( eSmartProtocol != INetProtocol::NotValid ) )
{
- seqPropertySet[nProperty].Value >>= sURL;
- aCurObj.SetURL( sURL );
-
- if ( !sURL.isEmpty() && ( eSmartProtocol != INetProtocol::NotValid ) )
- {
- if( aCurObj.GetProtocol() != eSmartProtocol )
- break;
- }
+ if( aCurObj.GetProtocol() != eSmartProtocol )
+ continue;
+ }
- OUString aURL( aCurObj.GetMainURL( INetURLObject::DecodeMechanism::WithCharset ) );
+ OUString aURL( aCurObj.GetMainURL( INetURLObject::DecodeMechanism::WithCharset ) );
- if ( !aURL.isEmpty() )
+ if ( !aURL.isEmpty() )
+ {
+ bool bFound = aURL.endsWith("/");
+ if ( !bFound )
{
- bool bFound = aURL.endsWith("/");
- if ( !bFound )
- {
- OUString aUpperURL = aURL.toAsciiUpperCase();
+ OUString aUpperURL = aURL.toAsciiUpperCase();
- bFound = ::std::any_of(pImpl->m_aFilters.begin(),
- pImpl->m_aFilters.end(),
- FilterMatch( aUpperURL ) );
- }
- if ( bFound )
- {
- OUString aFile;
- if (osl::FileBase::getSystemPathFromFileURL(aURL, aFile) == osl::FileBase::E_None)
- InsertEntry(aFile);
- else
- InsertEntry(aURL);
- }
+ bFound = ::std::any_of(pImpl->m_aFilters.begin(),
+ pImpl->m_aFilters.end(),
+ FilterMatch( aUpperURL ) );
+ }
+ if ( bFound )
+ {
+ OUString aFile;
+ if (osl::FileBase::getSystemPathFromFileURL(aURL, aFile) == osl::FileBase::E_None)
+ InsertEntry(aFile);
+ else
+ InsertEntry(aURL);
}
- break;
}
}
}
@@ -2070,53 +2055,46 @@ void URLBox::UpdatePicklistForSmartProtocol_Impl()
// read history pick list
Sequence< Sequence< PropertyValue > > seqPicklist = SvtHistoryOptions().GetList( ePICKLIST );
- sal_uInt32 nCount = seqPicklist.getLength();
INetURLObject aCurObj;
- for( sal_uInt32 nItem=0; nItem < nCount; nItem++ )
+ for( const Sequence< PropertyValue >& rPropertySet : seqPicklist )
{
- Sequence< PropertyValue > seqPropertySet = seqPicklist[ nItem ];
-
- OUString sURL;
+ auto pProperty = std::find_if(rPropertySet.begin(), rPropertySet.end(),
+ [](const PropertyValue& rProperty) { return rProperty.Name == HISTORY_PROPERTYNAME_URL; });
+ if (pProperty != rPropertySet.end())
+ {
+ OUString sURL;
- sal_uInt32 nPropertyCount = seqPropertySet.getLength();
+ pProperty->Value >>= sURL;
+ aCurObj.SetURL( sURL );
- for( sal_uInt32 nProperty=0; nProperty < nPropertyCount; nProperty++ )
- {
- if( seqPropertySet[nProperty].Name == HISTORY_PROPERTYNAME_URL )
+ if ( !sURL.isEmpty() && ( eSmartProtocol != INetProtocol::NotValid ) )
{
- seqPropertySet[nProperty].Value >>= sURL;
- aCurObj.SetURL( sURL );
-
- if ( !sURL.isEmpty() && ( eSmartProtocol != INetProtocol::NotValid ) )
- {
- if( aCurObj.GetProtocol() != eSmartProtocol )
- break;
- }
+ if( aCurObj.GetProtocol() != eSmartProtocol )
+ continue;
+ }
- OUString aURL( aCurObj.GetMainURL( INetURLObject::DecodeMechanism::WithCharset ) );
+ OUString aURL( aCurObj.GetMainURL( INetURLObject::DecodeMechanism::WithCharset ) );
- if ( !aURL.isEmpty() )
+ if ( !aURL.isEmpty() )
+ {
+ bool bFound = aURL.endsWith("/");
+ if ( !bFound )
{
- bool bFound = aURL.endsWith("/");
- if ( !bFound )
- {
- OUString aUpperURL = aURL.toAsciiUpperCase();
+ OUString aUpperURL = aURL.toAsciiUpperCase();
- bFound = ::std::any_of(pImpl->m_aFilters.begin(),
- pImpl->m_aFilters.end(),
- FilterMatch( aUpperURL ) );
- }
- if ( bFound )
- {
- OUString aFile;
- if (osl::FileBase::getSystemPathFromFileURL(aURL, aFile) == osl::FileBase::E_None)
- m_xWidget->append_text(aFile);
- else
- m_xWidget->append_text(aURL);
- }
+ bFound = ::std::any_of(pImpl->m_aFilters.begin(),
+ pImpl->m_aFilters.end(),
+ FilterMatch( aUpperURL ) );
+ }
+ if ( bFound )
+ {
+ OUString aFile;
+ if (osl::FileBase::getSystemPathFromFileURL(aURL, aFile) == osl::FileBase::E_None)
+ m_xWidget->append_text(aFile);
+ else
+ m_xWidget->append_text(aURL);
}
- break;
}
}
}
diff --git a/svtools/source/dialogs/PlaceEditDialog.cxx b/svtools/source/dialogs/PlaceEditDialog.cxx
index cd6c7022ac20..d26bec4c58e6 100644
--- a/svtools/source/dialogs/PlaceEditDialog.cxx
+++ b/svtools/source/dialogs/PlaceEditDialog.cxx
@@ -192,7 +192,8 @@ void PlaceEditDialog::InitDetails( )
Sequence< OUString > aTypesNamesList( officecfg::Office::Common::Misc::CmisServersNames::get( xContext ) );
int nPos = 0;
- for ( sal_Int32 i = 0; i < aTypesUrlsList.getLength( ) && i < aTypesNamesList.getLength( ); ++i )
+ auto nSize = std::min(aTypesUrlsList.getLength(), aTypesNamesList.getLength());
+ for ( sal_Int32 i = 0; i < nSize; ++i )
{
OUString sUrl = aTypesUrlsList[i].replaceFirst("<host", "<" + SvtResId(STR_SVT_HOST)).replaceFirst("port>", SvtResId(STR_SVT_PORT) + ">");
diff --git a/svtools/source/dialogs/addresstemplate.cxx b/svtools/source/dialogs/addresstemplate.cxx
index c2abda3193d8..84606e549750 100644
--- a/svtools/source/dialogs/addresstemplate.cxx
+++ b/svtools/source/dialogs/addresstemplate.cxx
@@ -173,19 +173,16 @@ namespace svt
while ( nIndex >= 0);
// loop through the given names
- const AliasProgrammaticPair* pFields = _rFields.getConstArray();
- const AliasProgrammaticPair* pFieldsEnd = pFields + _rFields.getLength();
- for (;pFields != pFieldsEnd; ++pFields)
+ for (const AliasProgrammaticPair& rField : _rFields)
{
- StringBag::const_iterator aKnownPos = aKnownNames.find( pFields->ProgrammaticName );
- if ( aKnownNames.end() != aKnownPos )
+ if ( aKnownNames.end() != aKnownNames.find( rField.ProgrammaticName ) )
{
- m_aAliases[ pFields->ProgrammaticName ] = pFields->Alias;
+ m_aAliases[ rField.ProgrammaticName ] = rField.Alias;
}
else
{
SAL_WARN( "svtools", "AssigmentTransientData::AssigmentTransientData: unknown programmatic name: "
- << pFields->ProgrammaticName );
+ << rField.ProgrammaticName );
}
}
}
@@ -292,9 +289,8 @@ void AssignmentPersistentData::ImplCommit()
:ConfigItem("Office.DataAccess/AddressBook")
{
Sequence< OUString > aStoredNames = GetNodeNames("Fields");
- const OUString* pStoredNames = aStoredNames.getConstArray();
- for (sal_Int32 i=0; i<aStoredNames.getLength(); ++i, ++pStoredNames)
- m_aStoredFields.insert(*pStoredNames);
+ std::copy(aStoredNames.begin(), aStoredNames.end(),
+ std::inserter(m_aStoredFields, m_aStoredFields.end()));
}
bool AssignmentPersistentData::hasFieldAssignment(const OUString& _rLogicalName)
@@ -713,10 +709,8 @@ void AssignmentPersistentData::ImplCommit()
{
OSL_FAIL("AddressBookSourceDialog::initializeDatasources: caught an exception while asking for the data source names!");
}
- const OUString* pDatasourceNames = aDatasourceNames.getConstArray();
- const OUString* pEnd = pDatasourceNames + aDatasourceNames.getLength();
- for (; pDatasourceNames < pEnd; ++pDatasourceNames)
- m_xDatasource->append_text(*pDatasourceNames);
+ for (const OUString& rDatasourceName : aDatasourceNames)
+ m_xDatasource->append_text(rDatasourceName);
}
IMPL_LINK(AddressBookSourceDialog, OnFieldScroll, weld::ScrolledWindow&, rScrollBar, void)
@@ -812,12 +806,10 @@ void AssignmentPersistentData::ImplCommit()
bool bKnowOldTable = false;
// fill the table list
- const OUString* pTableNames = aTableNames.getConstArray();
- const OUString* pEnd = pTableNames + aTableNames.getLength();
- for (;pTableNames != pEnd; ++pTableNames)
+ for (const OUString& rTableName : aTableNames)
{
- m_xTable->append_text(*pTableNames);
- if (*pTableNames == sOldTable)
+ m_xTable->append_text(rTableName);
+ if (rTableName == sOldTable)
bKnowOldTable = true;
}
@@ -861,13 +853,9 @@ void AssignmentPersistentData::ImplCommit()
}
- const OUString* pColumnNames = aColumnNames.getConstArray();
- const OUString* pEnd = pColumnNames + aColumnNames.getLength();
-
// for quicker access
::std::set< OUString > aColumnNameSet;
- for (pColumnNames = aColumnNames.getConstArray(); pColumnNames != pEnd; ++pColumnNames)
- aColumnNameSet.insert(*pColumnNames);
+ std::copy(aColumnNames.begin(), aColumnNames.end(), std::inserter(aColumnNameSet, aColumnNameSet.end()));
std::vector<OUString>::iterator aInitialSelection = m_pImpl->aFieldAssignments.begin() + m_pImpl->nFieldScrollPos;
@@ -885,8 +873,8 @@ void AssignmentPersistentData::ImplCommit()
pListbox->set_id(0, OUString::number(i));
// the field names
- for (pColumnNames = aColumnNames.getConstArray(); pColumnNames != pEnd; ++pColumnNames)
- pListbox->append_text(*pColumnNames);
+ for (const OUString& rColumnName : aColumnNames)
+ pListbox->append_text(rColumnName);
if (!aInitialSelection->isEmpty() && (aColumnNameSet.end() != aColumnNameSet.find(*aInitialSelection)))
// we can select the entry as specified in our field assignment array
diff --git a/svtools/source/dialogs/colrdlg.cxx b/svtools/source/dialogs/colrdlg.cxx
index 9934966e1c0a..1000e0dc5c1d 100644
--- a/svtools/source/dialogs/colrdlg.cxx
+++ b/svtools/source/dialogs/colrdlg.cxx
@@ -84,11 +84,11 @@ short SvColorDialog::Execute(weld::Window* pParent)
if( ret )
{
props = xPropertyAccess->getPropertyValues();
- for( sal_Int32 n = 0; n < props.getLength(); n++ )
+ for( const auto& rProp : props )
{
- if( props[n].Name == sColor )
+ if( rProp.Name == sColor )
{
- props[n].Value >>= maColor;
+ rProp.Value >>= maColor;
}
}
}
diff --git a/svtools/source/dialogs/insdlg.cxx b/svtools/source/dialogs/insdlg.cxx
index 01f699d4b835..28fcc05b3685 100644
--- a/svtools/source/dialogs/insdlg.cxx
+++ b/svtools/source/dialogs/insdlg.cxx
@@ -107,7 +107,6 @@ void SvObjectServerList::FillInsertObjects()
if( xNameAccess.is())
{
uno::Sequence< OUString > seqNames= xNameAccess->getElementNames();
- sal_Int32 nInd;
OUString aStringProductName( "%PRODUCTNAME" );
sal_Int32 nStringProductNameLength = aStringProductName.getLength();
@@ -115,10 +114,10 @@ void SvObjectServerList::FillInsertObjects()
OUString aStringProductVersion( "%PRODUCTVERSION" );
sal_Int32 nStringProductVersionLength = aStringProductVersion.getLength();
- for( nInd = 0; nInd < seqNames.getLength(); nInd++ )
+ for( const auto& rName : seqNames )
{
uno::Reference< container::XNameAccess > xEntry ;
- xNameAccess->getByName( seqNames[nInd] ) >>= xEntry;
+ xNameAccess->getByName( rName ) >>= xEntry;
if ( xEntry.is() )
{
OUString aUIName;
diff --git a/svtools/source/filter/DocumentToGraphicRenderer.cxx b/svtools/source/filter/DocumentToGraphicRenderer.cxx
index 5dbcd9034633..39b8e40426d4 100644
--- a/svtools/source/filter/DocumentToGraphicRenderer.cxx
+++ b/svtools/source/filter/DocumentToGraphicRenderer.cxx
@@ -152,23 +152,23 @@ Size DocumentToGraphicRenderer::getDocumentSizeIn100mm(sal_Int32 nCurrentPage,
if (nPages >= nCurrentPage)
{
Sequence< beans::PropertyValue > aResult = mxRenderable->getRenderer(nCurrentPage - 1, selection, renderProperties );
- for( sal_Int32 nProperty = 0, nPropertyCount = aResult.getLength(); nProperty < nPropertyCount; ++nProperty )
+ for( const auto& rProperty : aResult )
{
- if ( aResult[ nProperty ].Name == "PageSize" )
+ if ( rProperty.Name == "PageSize" )
{
- aResult[ nProperty ].Value >>= aSize;
+ rProperty.Value >>= aSize;
}
- else if (aResult[nProperty].Name == "PagePos")
+ else if (rProperty.Name == "PagePos")
{
- aResult[nProperty].Value >>= aPos;
+ rProperty.Value >>= aPos;
}
- else if (aResult[nProperty].Name == "CalcPagePos")
+ else if (rProperty.Name == "CalcPagePos")
{
- aResult[nProperty].Value >>= aCalcPos;
+ rProperty.Value >>= aCalcPos;
}
- else if (aResult[nProperty].Name == "CalcPageContentSize")
+ else if (rProperty.Name == "CalcPageContentSize")
{
- aResult[nProperty].Value >>= aCalcPageSize;
+ rProperty.Value >>= aCalcPageSize;
}
}
}
diff --git a/svtools/source/filter/SvFilterOptionsDialog.cxx b/svtools/source/filter/SvFilterOptionsDialog.cxx
index fb630a824b12..2879600544f7 100644
--- a/svtools/source/filter/SvFilterOptionsDialog.cxx
+++ b/svtools/source/filter/SvFilterOptionsDialog.cxx
@@ -158,12 +158,10 @@ uno::Sequence< OUString > SAL_CALL SvFilterOptionsDialog::getSupportedServiceNam
// XPropertyAccess
uno::Sequence< beans::PropertyValue > SvFilterOptionsDialog::getPropertyValues()
{
- sal_Int32 i, nCount;
- for ( i = 0, nCount = maMediaDescriptor.getLength(); i < nCount; i++ )
- {
- if ( maMediaDescriptor[ i ].Name == "FilterData" )
- break;
- }
+ auto pProp = std::find_if(maMediaDescriptor.begin(), maMediaDescriptor.end(),
+ [](const beans::PropertyValue& rProp) { return rProp.Name == "FilterData"; });
+ auto i = static_cast<sal_Int32>(std::distance(maMediaDescriptor.begin(), pProp));
+ sal_Int32 nCount = maMediaDescriptor.getLength();
if ( i == nCount )
maMediaDescriptor.realloc( ++nCount );
@@ -177,16 +175,15 @@ void SvFilterOptionsDialog::setPropertyValues( const uno::Sequence< beans::Prope
{
maMediaDescriptor = aProps;
- sal_Int32 i, nCount;
- for ( i = 0, nCount = maMediaDescriptor.getLength(); i < nCount; i++ )
+ for ( const auto& rProp : maMediaDescriptor )
{
- if ( maMediaDescriptor[ i ].Name == "FilterData" )
+ if ( rProp.Name == "FilterData" )
{
- maMediaDescriptor[ i ].Value >>= maFilterDataSequence;
+ rProp.Value >>= maFilterDataSequence;
}
- else if ( maMediaDescriptor[ i ].Name == "SelectionOnly" )
+ else if ( rProp.Name == "SelectionOnly" )
{
- maMediaDescriptor[ i ].Value >>= mbExportSelection;
+ rProp.Value >>= mbExportSelection;
}
}
}
@@ -202,14 +199,13 @@ sal_Int16 SvFilterOptionsDialog::execute()
OUString aInternalFilterName;
uno::Reference<graphic::XGraphic> xGraphic;
- sal_Int32 j, nCount = maMediaDescriptor.getLength();
- for ( j = 0; j < nCount; j++ )
+ for ( const auto& rProp : maMediaDescriptor )
{
- const OUString& rName = maMediaDescriptor[ j ].Name;
+ const OUString& rName = rProp.Name;
if ( rName == "FilterName" )
{
OUString aStr;
- maMediaDescriptor[ j ].Value >>= aStr;
+ rProp.Value >>= aStr;
aInternalFilterName = aStr.replaceFirst( "draw_", "" );
aInternalFilterName = aInternalFilterName.replaceFirst( "impress_", "" );
aInternalFilterName = aInternalFilterName.replaceFirst( "calc_", "" );
@@ -218,7 +214,7 @@ sal_Int16 SvFilterOptionsDialog::execute()
}
else if ( rName == "Graphic" )
{
- maMediaDescriptor[ j ].Value >>= xGraphic;
+ rProp.Value >>= xGraphic;
}
}
if ( !aInternalFilterName.isEmpty() )
diff --git a/svtools/source/filter/exportdialog.cxx b/svtools/source/filter/exportdialog.cxx
index a190281e0f31..0cbedcbf2f18 100644
--- a/svtools/source/filter/exportdialog.cxx
+++ b/svtools/source/filter/exportdialog.cxx
@@ -137,10 +137,9 @@ static basegfx::B2DRange GetShapeRangeForXShape( const uno::Reference< drawing::
const uno::Sequence< beans::PropertyValue > aParams;
const uno::Sequence< uno::Reference< graphic::XPrimitive2D > > aPrimitiveSequence( rxPrimitiveFactory2D->createPrimitivesFromXShape( rxShape, aParams ) );
- const sal_Int32 nCount = aPrimitiveSequence.getLength();
- for( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++ )
+ for( const auto& rPrimitive : aPrimitiveSequence )
{
- const geometry::RealRectangle2D aRect( aPrimitiveSequence[ nIndex ]->getRange( rViewInformation ) );
+ const geometry::RealRectangle2D aRect( rPrimitive->getRange( rViewInformation ) );
aShapeRange.expand( basegfx::B2DTuple( aRect.X1, aRect.Y1 ) );
aShapeRange.expand( basegfx::B2DTuple( aRect.X2, aRect.Y2 ) );
}
diff --git a/svtools/source/java/javainteractionhandler.cxx b/svtools/source/java/javainteractionhandler.cxx
index 094961c51ce3..f20433c28878 100644
--- a/svtools/source/java/javainteractionhandler.cxx
+++ b/svtools/source/java/javainteractionhandler.cxx
@@ -97,18 +97,17 @@ void SAL_CALL JavaInteractionHandler::handle( const Reference< XInteractionReque
Reference< XInteractionAbort > abort;
Reference< XInteractionRetry > retry;
- sal_Int32 i;
- for ( i = 0; i < aSeqCont.getLength(); i++ )
+ for ( const auto& rCont : aSeqCont )
{
- abort.set( aSeqCont[i], UNO_QUERY );
+ abort.set( rCont, UNO_QUERY );
if ( abort.is() )
break;
}
- for ( i= 0; i < aSeqCont.getLength(); i++)
+ for ( const auto& rCont : aSeqCont )
{
- retry.set( aSeqCont[i], UNO_QUERY );
+ retry.set( rCont, UNO_QUERY );
if ( retry.is() )
break;
}
diff --git a/svtools/source/misc/embedhlp.cxx b/svtools/source/misc/embedhlp.cxx
index beb765409a35..0e7728156f7b 100644
--- a/svtools/source/misc/embedhlp.cxx
+++ b/svtools/source/misc/embedhlp.cxx
@@ -865,18 +865,18 @@ OUString EmbeddedObjectRef::GetChartType()
uno::Sequence< uno::Reference< chart2::XCoordinateSystem > > aCooSysSeq( xCooSysCnt->getCoordinateSystems());
// IA2 CWS. Unused: int nCoordinateCount = aCooSysSeq.getLength();
bool bGetChartType = false;
- for( sal_Int32 nCooSysIdx=0; nCooSysIdx<aCooSysSeq.getLength(); ++nCooSysIdx )
+ for( const auto& rCooSys : aCooSysSeq )
{
- uno::Reference< chart2::XChartTypeContainer > xCTCnt( aCooSysSeq[nCooSysIdx], uno::UNO_QUERY_THROW );
+ uno::Reference< chart2::XChartTypeContainer > xCTCnt( rCooSys, uno::UNO_QUERY_THROW );
uno::Sequence< uno::Reference< chart2::XChartType > > aChartTypes( xCTCnt->getChartTypes());
- int nDimesionCount = aCooSysSeq[nCooSysIdx]->getDimension();
+ int nDimesionCount = rCooSys->getDimension();
if( nDimesionCount == 3 )
Style += "3D ";
else
Style += "2D ";
- for( sal_Int32 nCTIdx=0; nCTIdx<aChartTypes.getLength(); ++nCTIdx )
+ for( const auto& rChartType : aChartTypes )
{
- OUString strChartType = aChartTypes[nCTIdx]->getChartType();
+ OUString strChartType = rChartType->getChartType();
if (strChartType == "com.sun.star.chart2.AreaChartType")
{
Style += "Areas";
@@ -889,7 +889,7 @@ OUString EmbeddedObjectRef::GetChartType()
}
else if (strChartType == "com.sun.star.chart2.ColumnChartType")
{
- uno::Reference< beans::XPropertySet > xProp( aCooSysSeq[nCooSysIdx], uno::UNO_QUERY );
+ uno::Reference< beans::XPropertySet > xProp( rCooSys, uno::UNO_QUERY );
if( xProp.is())
{
bool bCurrent = false;
diff --git a/svtools/source/misc/imagemgr.cxx b/svtools/source/misc/imagemgr.cxx
index e7eab73f2b54..c459198daa3f 100644
--- a/svtools/source/misc/imagemgr.cxx
+++ b/svtools/source/misc/imagemgr.cxx
@@ -232,10 +232,8 @@ static OUString GetImageExtensionByFactory_Impl( const OUString& rURL )
if ( !aInternalType.isEmpty() && xAccess->hasByName( aInternalType ) )
{
xAccess->getByName( aInternalType ) >>= aTypeProps;
- sal_Int32 nProps = aTypeProps.getLength();
- for ( sal_Int32 i = 0; i < nProps; ++i )
+ for ( const css::beans::PropertyValue& rProp : aTypeProps )
{
- const css::beans::PropertyValue& rProp = aTypeProps[i];
if (rProp.Name == "Extensions")
{
css::uno::Sequence < OUString > aExtensions;
diff --git a/svtools/source/misc/langhelp.cxx b/svtools/source/misc/langhelp.cxx
index 6cedddca3f89..aaba6c74fbe4 100644
--- a/svtools/source/misc/langhelp.cxx
+++ b/svtools/source/misc/langhelp.cxx
@@ -53,19 +53,14 @@ OUString getInstalledLocaleForLanguage(css::uno::Sequence<OUString> const & inst
if (locale.isEmpty())
return OUString(); // do not attempt to resolve anything
- for (sal_Int32 i = 0; i != installed.getLength(); ++i) {
- if (installed[i] == locale) {
- return installed[i];
- }
- }
+ if (comphelper::findValue(installed, locale) != -1)
+ return locale;
+
std::vector<OUString> fallbacks(LanguageTag(locale).getFallbackStrings(false));
- for (OUString & rf : fallbacks) {
- for (sal_Int32 i = 0; i != installed.getLength(); ++i) {
- if (installed[i] == rf) {
- return installed[i];
- }
- }
- }
+ auto pf = std::find_if(fallbacks.begin(), fallbacks.end(),
+ [&installed](const OUString& rf) { return comphelper::findValue(installed, rf) != -1; });
+ if (pf != fallbacks.end())
+ return *pf;
return OUString();
}
diff --git a/svtools/source/misc/langtab.cxx b/svtools/source/misc/langtab.cxx
index 9b2e200eebe5..62d31910da7d 100644
--- a/svtools/source/misc/langtab.cxx
+++ b/svtools/source/misc/langtab.cxx
@@ -173,10 +173,8 @@ SvtLanguageTableImpl::SvtLanguageTableImpl()
auto xNA = officecfg::VCL::ExtraLanguages::get();
uno::Sequence <OUString> rElementNames = xNA->getElementNames();
- sal_Int32 nLen = rElementNames.getLength();
- for (sal_Int32 i = 0; i < nLen; ++i)
+ for (const OUString& rBcp47 : rElementNames)
{
- const OUString& rBcp47 = rElementNames[i];
OUString aName;
sal_Int32 nType = 0;
uno::Reference <container::XNameAccess> xNB;
diff --git a/svtools/source/uno/genericunodialog.cxx b/svtools/source/uno/genericunodialog.cxx
index 4e21ff393dba..7c71c5da82d5 100644
--- a/svtools/source/uno/genericunodialog.cxx
+++ b/svtools/source/uno/genericunodialog.cxx
@@ -260,9 +260,8 @@ void SAL_CALL OGenericUnoDialog::initialize( const Sequence< Any >& aArguments )
if ( m_bInitialized )
throw AlreadyInitializedException( OUString(), *this );
- const Any* pArguments = aArguments.getConstArray();
- for (sal_Int32 i=0; i<aArguments.getLength(); ++i, ++pArguments)
- implInitialize(*pArguments);
+ for (const Any& rArgument : aArguments)
+ implInitialize(rArgument);
m_bInitialized = true;
}
diff --git a/svtools/source/uno/popupmenucontrollerbase.cxx b/svtools/source/uno/popupmenucontrollerbase.cxx
index 6ad828a281a6..02055485a99e 100644
--- a/svtools/source/uno/popupmenucontrollerbase.cxx
+++ b/svtools/source/uno/popupmenucontrollerbase.cxx
@@ -221,12 +221,9 @@ Sequence< Reference< XDispatch > > SAL_CALL PopupMenuControllerBase::queryDispat
uno::Sequence< uno::Reference< frame::XDispatch > > lDispatcher( nCount );
// Step over all descriptors and try to get any dispatcher for it.
- for( sal_Int32 i=0; i<nCount; ++i )
- {
- lDispatcher[i] = queryDispatch( lDescriptor[i].FeatureURL ,
- lDescriptor[i].FrameName ,
- lDescriptor[i].SearchFlags );
- }
+ std::transform(lDescriptor.begin(), lDescriptor.end(), lDispatcher.begin(),
+ [this](const DispatchDescriptor& rDesc) -> uno::Reference< frame::XDispatch > {
+ return queryDispatch(rDesc.FeatureURL, rDesc.FrameName, rDesc.SearchFlags); });
return lDispatcher;
}
@@ -312,9 +309,9 @@ void SAL_CALL PopupMenuControllerBase::initialize( const Sequence< Any >& aArgum
OUString aCommandURL;
Reference< XFrame > xFrame;
- for ( int i = 0; i < aArguments.getLength(); i++ )
+ for ( const auto& rArgument : aArguments )
{
- if ( aArguments[i] >>= aPropValue )
+ if ( rArgument >>= aPropValue )
{
if ( aPropValue.Name == "Frame" )
aPropValue.Value >>= xFrame;
diff --git a/svtools/source/uno/statusbarcontroller.cxx b/svtools/source/uno/statusbarcontroller.cxx
index 13cb1f99ae99..88c07535dd16 100644
--- a/svtools/source/uno/statusbarcontroller.cxx
+++ b/svtools/source/uno/statusbarcontroller.cxx
@@ -141,9 +141,9 @@ void SAL_CALL StatusbarController::initialize( const Sequence< Any >& aArguments
m_bInitialized = true;
PropertyValue aPropValue;
- for ( int i = 0; i < aArguments.getLength(); i++ )
+ for ( const auto& rArgument : aArguments )
{
- if ( aArguments[i] >>= aPropValue )
+ if ( rArgument >>= aPropValue )
{
if ( aPropValue.Name == "Frame" )
aPropValue.Value >>= m_xFrame;
diff --git a/svtools/source/uno/toolboxcontroller.cxx b/svtools/source/uno/toolboxcontroller.cxx
index 01f14ff5395f..ef5183a6b969 100644
--- a/svtools/source/uno/toolboxcontroller.cxx
+++ b/svtools/source/uno/toolboxcontroller.cxx
@@ -173,9 +173,9 @@ void SAL_CALL ToolboxController::initialize( const Sequence< Any >& aArguments )
m_bInitialized = true;
m_bSupportVisible = false;
PropertyValue aPropValue;
- for ( int i = 0; i < aArguments.getLength(); i++ )
+ for ( const auto& rArgument : aArguments )
{
- if ( aArguments[i] >>= aPropValue )
+ if ( rArgument >>= aPropValue )
{
if ( aPropValue.Name == "Frame" )
m_xFrame.set(aPropValue.Value,UNO_QUERY);
diff --git a/svtools/source/uno/unocontroltablemodel.cxx b/svtools/source/uno/unocontroltablemodel.cxx
index c0aad3af8a8c..c7fe0f2714be 100644
--- a/svtools/source/uno/unocontroltablemodel.cxx
+++ b/svtools/source/uno/unocontroltablemodel.cxx
@@ -696,10 +696,8 @@ namespace svt { namespace table
else
{
::std::vector< ::Color > aColors( aAPIColors.getLength() );
- for ( sal_Int32 i=0; i<aAPIColors.getLength(); ++i )
- {
- aColors[i] = Color(aAPIColors[i]);
- }
+ std::transform(aAPIColors.begin(), aAPIColors.end(), aColors.begin(),
+ [](const css::util::Color& rAPIColor) -> ::Color { return Color(rAPIColor); });
m_pImpl->m_aRowColors = aColors;
}
}
diff --git a/svtools/source/uno/unoevent.cxx b/svtools/source/uno/unoevent.cxx
index a0ca2b82080d..4604af791521 100644
--- a/svtools/source/uno/unoevent.cxx
+++ b/svtools/source/uno/unoevent.cxx
@@ -151,10 +151,8 @@ void getMacroFromAny(
OUString sScriptVal;
OUString sMacroVal;
OUString sLibVal;
- sal_Int32 nCount = aSequence.getLength();
- for (sal_Int32 i = 0; i < nCount; i++)
+ for (const PropertyValue& aValue : aSequence)
{
- PropertyValue& aValue = aSequence[i];
if (aValue.Name == sEventType)
{
OUString sTmp;
diff --git a/svtools/source/uno/wizard/unowizard.cxx b/svtools/source/uno/wizard/unowizard.cxx
index 300fa62ae594..650ba4965c45 100644
--- a/svtools/source/uno/wizard/unowizard.cxx
+++ b/svtools/source/uno/wizard/unowizard.cxx
@@ -183,17 +183,13 @@ namespace {
throw IllegalArgumentException( OUString(), i_rContext, 2 );
// page IDs must be in ascending order
- sal_Int16 nPreviousPageID = i_rPaths[i][0];
- for ( sal_Int32 j=1; j<i_rPaths[i].getLength(); ++j )
+ auto pPageId = std::adjacent_find(i_rPaths[i].begin(), i_rPaths[i].end(), std::greater_equal<sal_Int16>());
+ if (pPageId != i_rPaths[i].end())
{
- if ( i_rPaths[i][j] <= nPreviousPageID )
- {
- throw IllegalArgumentException(
- "Path " + OUString::number(i)
- + ": invalid page ID sequence - each page ID must be greater than the previous one.",
- i_rContext, 2 );
- }
- nPreviousPageID = i_rPaths[i][j];
+ throw IllegalArgumentException(
+ "Path " + OUString::number(i)
+ + ": invalid page ID sequence - each page ID must be greater than the previous one.",
+ i_rContext, 2 );
}
}
@@ -203,13 +199,11 @@ namespace {
// if we have multiple paths, they must start with the same page id
const sal_Int16 nFirstPageId = i_rPaths[0][0];
- for ( sal_Int32 i = 0; i < i_rPaths.getLength(); ++i )
- {
- if ( i_rPaths[i][0] != nFirstPageId )
- throw IllegalArgumentException(
- "All paths must start with the same page id.",
- i_rContext, 2 );
- }
+ if (std::any_of(i_rPaths.begin(), i_rPaths.end(),
+ [nFirstPageId](const Sequence< sal_Int16 >& rPath) { return rPath[0] != nFirstPageId; }))
+ throw IllegalArgumentException(
+ "All paths must start with the same page id.",
+ i_rContext, 2 );
}
void SAL_CALL Wizard::initialize( const Sequence< Any >& i_Arguments )
diff --git a/svtools/source/uno/wizard/wizardshell.cxx b/svtools/source/uno/wizard/wizardshell.cxx
index a7386fc16f3a..81843f74befa 100644
--- a/svtools/source/uno/wizard/wizardshell.cxx
+++ b/svtools/source/uno/wizard/wizardshell.cxx
@@ -63,8 +63,8 @@ namespace svt { namespace uno
{
const Sequence< sal_Int16 >& rPath( i_rPaths[i] );
WizardPath aPath( rPath.getLength() );
- for ( sal_Int32 j=0; j<rPath.getLength(); ++j )
- aPath[j] = impl_pageIdToState( rPath[j] );
+ std::transform(rPath.begin(), rPath.end(), aPath.begin(),
+ [this](const sal_Int16 nPageId) -> WizardPath::value_type { return impl_pageIdToState(nPageId); });
declarePath( i, aPath );
}