[Libreoffice-commits] core.git: ucbhelper/source ucb/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Mon Oct 22 07:48:22 UTC 2018
ucb/source/core/ucb.cxx | 24 +--
ucb/source/ucp/cmis/cmis_content.cxx | 93 ++++-------
ucb/source/ucp/cmis/cmis_datasupplier.cxx | 7
ucb/source/ucp/cmis/cmis_repo_content.cxx | 15 -
ucb/source/ucp/file/filprp.cxx | 12 -
ucb/source/ucp/file/filtask.cxx | 13 -
ucb/source/ucp/gio/gio_content.cxx | 29 +--
ucb/source/ucp/hierarchy/hierarchycontent.cxx | 16 --
ucb/source/ucp/package/pkgcontent.cxx | 25 ---
ucb/source/ucp/tdoc/tdoc_content.cxx | 25 ---
ucb/source/ucp/tdoc/tdoc_docmgr.cxx | 94 +++--------
ucb/source/ucp/tdoc/tdoc_provider.cxx | 24 ---
ucb/source/ucp/webdav-neon/ContentProperties.cxx | 57 ++-----
ucb/source/ucp/webdav-neon/DAVResourceAccess.cxx | 26 ---
ucb/source/ucp/webdav-neon/DAVSessionFactory.cxx | 14 -
ucb/source/ucp/webdav-neon/NeonHeadRequest.cxx | 34 +---
ucb/source/ucp/webdav-neon/NeonLockStore.cxx | 19 --
ucb/source/ucp/webdav-neon/NeonSession.cxx | 58 ++-----
ucb/source/ucp/webdav-neon/webdavcontent.cxx | 165 +++++++--------------
ucb/source/ucp/webdav-neon/webdavcontentcaps.cxx | 55 ++-----
ucb/source/ucp/webdav-neon/webdavdatasupplier.cxx | 32 +---
ucb/source/ucp/webdav/ContentProperties.cxx | 75 ++-------
ucb/source/ucp/webdav/DAVResourceAccess.cxx | 14 -
ucb/source/ucp/webdav/DAVSessionFactory.cxx | 14 -
ucb/source/ucp/webdav/SerfGetReqProcImpl.cxx | 21 --
ucb/source/ucp/webdav/SerfHeadReqProcImpl.cxx | 21 --
ucb/source/ucp/webdav/SerfLockStore.cxx | 16 --
ucb/source/ucp/webdav/SerfRequestProcessorImpl.cxx | 14 -
ucb/source/ucp/webdav/webdavcontent.cxx | 103 +++----------
ucb/source/ucp/webdav/webdavcontentcaps.cxx | 54 ++----
ucb/source/ucp/webdav/webdavdatasupplier.cxx | 24 ---
ucbhelper/source/client/interceptedinteraction.cxx | 35 +---
ucbhelper/source/provider/providerhelper.cxx | 10 -
33 files changed, 390 insertions(+), 848 deletions(-)
New commits:
commit e06afb0c9546ddcde1cedd75f59001396ac6fdf2
Author: Arkadiy Illarionov <qarkai at gmail.com>
AuthorDate: Sat Oct 20 22:15:25 2018 +0300
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Mon Oct 22 09:47:59 2018 +0200
Simplify containers iterations in ucb, ucbhelper
Use range-based loop or replace with STL functions.
Change-Id: I3cdb0f89523008199af1550de164a52b75c52ba5
Reviewed-on: https://gerrit.libreoffice.org/62088
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/ucb/source/core/ucb.cxx b/ucb/source/core/ucb.cxx
index 8672fa26a7a0..6b3cf12a8f3b 100644
--- a/ucb/source/core/ucb.cxx
+++ b/ucb/source/core/ucb.cxx
@@ -464,16 +464,10 @@ void SAL_CALL UniversalContentBroker::deregisterContentProvider(
{
ProviderList_Impl & rList = aMapIt->getValue();
- ProviderList_Impl::iterator aListEnd(rList.end());
- for (ProviderList_Impl::iterator aListIt(rList.begin());
- aListIt != aListEnd; ++aListIt)
- {
- if ((*aListIt).getProvider() == Provider)
- {
- rList.erase(aListIt);
- break;
- }
- }
+ auto aListIt = std::find_if(rList.begin(), rList.end(),
+ [&Provider](const ProviderListEntry_Impl& rEntry) { return rEntry.getProvider() == Provider; });
+ if (aListIt != rList.end())
+ rList.erase(aListIt);
if (rList.empty())
m_aProviders.erase(aMapIt);
@@ -810,20 +804,18 @@ void UniversalContentBroker::configureUcb()
void UniversalContentBroker::prepareAndRegister(
const ContentProviderDataList& rData)
{
- ContentProviderDataList::const_iterator aEnd(rData.end());
- for (ContentProviderDataList::const_iterator aIt(rData.begin());
- aIt != aEnd; ++aIt)
+ for (const auto& rContentProviderData : rData)
{
OUString aProviderArguments;
- if (fillPlaceholders(aIt->Arguments,
+ if (fillPlaceholders(rContentProviderData.Arguments,
m_aArguments,
&aProviderArguments))
{
registerAtUcb(this,
m_xContext,
- aIt->ServiceName,
+ rContentProviderData.ServiceName,
aProviderArguments,
- aIt->URLTemplate);
+ rContentProviderData.URLTemplate);
}
else
diff --git a/ucb/source/ucp/cmis/cmis_content.cxx b/ucb/source/ucp/cmis/cmis_content.cxx
index 65cb142f67bd..8a680d6193bb 100644
--- a/ucb/source/ucp/cmis/cmis_content.cxx
+++ b/ucb/source/ucp/cmis/cmis_content.cxx
@@ -44,6 +44,7 @@
#endif
#include <comphelper/processfactory.hxx>
+#include <comphelper/sequence.hxx>
#include <cppuhelper/exc_hlp.hxx>
#include <config_oauth2.h>
#include <o3tl/runtimetooustring.hxx>
@@ -106,11 +107,9 @@ namespace
uno::Sequence< OUString > aStrings( aCmisStrings.size( ) );
OUString* aStringsArr = aStrings.getArray( );
sal_Int32 i = 0;
- for ( vector< string >::iterator it = aCmisStrings.begin( );
- it != aCmisStrings.end( ); ++it, ++i )
+ for ( const auto& rCmisStr : aCmisStrings )
{
- string str = *it;
- aStringsArr[i] = STD_TO_OUSTR( str );
+ aStringsArr[i++] = STD_TO_OUSTR( rCmisStr );
}
aValue <<= aStrings;
}
@@ -121,10 +120,9 @@ namespace
uno::Sequence< sal_Int64 > aLongs( aCmisLongs.size( ) );
sal_Int64* aLongsArr = aLongs.getArray( );
sal_Int32 i = 0;
- for ( vector< long >::iterator it = aCmisLongs.begin( );
- it != aCmisLongs.end( ); ++it, ++i )
+ for ( const auto& rCmisLong : aCmisLongs )
{
- aLongsArr[i] = *it;
+ aLongsArr[i++] = rCmisLong;
}
aValue <<= aLongs;
}
@@ -132,14 +130,7 @@ namespace
case libcmis::PropertyType::Decimal:
{
vector< double > aCmisDoubles = pProperty->getDoubles( );
- uno::Sequence< double > aDoubles( aCmisDoubles.size( ) );
- double* aDoublesArr = aDoubles.getArray( );
- sal_Int32 i = 0;
- for ( vector< double >::iterator it = aCmisDoubles.begin( );
- it != aCmisDoubles.end( ); ++it, ++i )
- {
- aDoublesArr[i] = *it;
- }
+ uno::Sequence< double > aDoubles = comphelper::containerToSequence(aCmisDoubles);
aValue <<= aDoubles;
}
break;
@@ -149,10 +140,9 @@ namespace
uno::Sequence< sal_Bool > aBools( aCmisBools.size( ) );
sal_Bool* aBoolsArr = aBools.getArray( );
sal_Int32 i = 0;
- for ( vector< bool >::iterator it = aCmisBools.begin( );
- it != aCmisBools.end( ); ++it, ++i )
+ for ( const auto& rCmisBool : aCmisBools )
{
- aBoolsArr[i] = *it;
+ aBoolsArr[i++] = rCmisBool;
}
aValue <<= aBools;
}
@@ -163,10 +153,9 @@ namespace
uno::Sequence< util::DateTime > aTimes( aCmisTimes.size( ) );
util::DateTime* aTimesArr = aTimes.getArray( );
sal_Int32 i = 0;
- for ( vector< boost::posix_time::ptime >::iterator it = aCmisTimes.begin( );
- it != aCmisTimes.end( ); ++it, ++i )
+ for ( const auto& rCmisTime : aCmisTimes )
{
- aTimesArr[i] = lcl_boostToUnoTime( *it );
+ aTimesArr[i++] = lcl_boostToUnoTime( rCmisTime );
}
aValue <<= aTimes;
}
@@ -479,15 +468,17 @@ namespace cmis
if ( pProperty )
{
vector< string > typesIds = pProperty->getStrings( );
- for ( vector< string >::iterator typeIt = typesIds.begin();
- typeIt != typesIds.end() && !m_pObjectType; ++typeIt )
+ for ( const auto& rType : typesIds )
{
bTypeRestricted = true;
- libcmis::ObjectTypePtr type = getSession( xEnv )->getType( *typeIt );
+ libcmis::ObjectTypePtr type = getSession( xEnv )->getType( rType );
// FIXME Improve performances by adding getBaseTypeId( ) method to libcmis
if ( type->getBaseType( )->getId( ) == typeId )
+ {
m_pObjectType = type;
+ break;
+ }
}
}
}
@@ -550,12 +541,10 @@ namespace cmis
if (pParentFolder)
{
vector< libcmis::ObjectPtr > children = pParentFolder->getChildren();
- for (vector< libcmis::ObjectPtr >::iterator it = children.begin();
- it != children.end() && !m_pObject; ++it)
- {
- if ((*it)->getName() == sName)
- m_pObject = *it;
- }
+ auto it = std::find_if(children.begin(), children.end(),
+ [&sName](const libcmis::ObjectPtr& rChild) { return rChild->getName() == sName; });
+ if (it != children.end())
+ m_pObject = *it;
}
}
@@ -851,15 +840,14 @@ namespace cmis
uno::Sequence< document::CmisProperty > aCmisProperties( aProperties.size( ) );
document::CmisProperty* pCmisProps = aCmisProperties.getArray( );
sal_Int32 i = 0;
- for ( map< string, libcmis::PropertyPtr >::iterator it = aProperties.begin();
- it != aProperties.end( ); ++it, ++i )
+ for ( const auto& rProperty : aProperties )
{
- string sId = it->first;
- string sDisplayName = it->second->getPropertyType()->getDisplayName( );
- bool bUpdatable = it->second->getPropertyType()->isUpdatable( );
- bool bRequired = it->second->getPropertyType()->isRequired( );
- bool bMultiValued = it->second->getPropertyType()->isMultiValued();
- bool bOpenChoice = it->second->getPropertyType()->isOpenChoice();
+ string sId = rProperty.first;
+ string sDisplayName = rProperty.second->getPropertyType()->getDisplayName( );
+ bool bUpdatable = rProperty.second->getPropertyType()->isUpdatable( );
+ bool bRequired = rProperty.second->getPropertyType()->isRequired( );
+ bool bMultiValued = rProperty.second->getPropertyType()->isMultiValued();
+ bool bOpenChoice = rProperty.second->getPropertyType()->isOpenChoice();
pCmisProps[i].Id = STD_TO_OUSTR( sId );
pCmisProps[i].Name = STD_TO_OUSTR( sDisplayName );
@@ -867,8 +855,8 @@ namespace cmis
pCmisProps[i].Required = bRequired;
pCmisProps[i].MultiValued = bMultiValued;
pCmisProps[i].OpenChoice = bOpenChoice;
- pCmisProps[i].Value = lcl_cmisPropertyToUno( it->second );
- switch ( it->second->getPropertyType( )->getType( ) )
+ pCmisProps[i].Value = lcl_cmisPropertyToUno( rProperty.second );
+ switch ( rProperty.second->getPropertyType( )->getType( ) )
{
default:
case libcmis::PropertyType::String:
@@ -887,7 +875,7 @@ namespace cmis
pCmisProps[i].Type = CMIS_TYPE_DATETIME;
break;
}
-
+ ++i;
}
xRow->appendObject( rProp.Name, uno::makeAny( aCmisProperties ) );
}
@@ -1177,11 +1165,9 @@ namespace cmis
// Get the Original document (latest version)
vector< libcmis::DocumentPtr > aVersions = pPwc->getAllVersions( );
- bool bFound = false;
- for ( vector< libcmis::DocumentPtr >::iterator it = aVersions.begin();
- it != aVersions.end( ) && !bFound; ++it )
+ for ( const auto& rVersion : aVersions )
{
- libcmis::DocumentPtr pVersion = *it;
+ libcmis::DocumentPtr pVersion = rVersion;
map< string, libcmis::PropertyPtr > aProps = pVersion->getProperties( );
bool bIsLatestVersion = false;
map< string, libcmis::PropertyPtr >::iterator propIt = aProps.find( string( "cmis:isLatestVersion" ) );
@@ -1192,7 +1178,6 @@ namespace cmis
if ( bIsLatestVersion )
{
- bFound = true;
// Compute the URL of the Document
URL aCmisUrl( m_sURL );
vector< string > aPaths = pVersion->getPaths( );
@@ -1209,6 +1194,7 @@ namespace cmis
aCmisUrl.setObjectId( STD_TO_OUSTR( sId ) );
}
aRet = aCmisUrl.asString( );
+ break;
}
}
}
@@ -1241,14 +1227,14 @@ namespace cmis
vector< libcmis::DocumentPtr > aCmisVersions = pDoc->getAllVersions( );
uno::Sequence< document::CmisVersion > aVersions( aCmisVersions.size( ) );
int i = 0;
- for ( vector< libcmis::DocumentPtr >::iterator it = aCmisVersions.begin();
- it != aCmisVersions.end( ); ++it, ++i )
+ for ( const auto& rVersion : aCmisVersions )
{
- libcmis::DocumentPtr pVersion = *it;
+ libcmis::DocumentPtr pVersion = rVersion;
aVersions[i].Id = STD_TO_OUSTR( pVersion->getId( ) );
aVersions[i].Author = STD_TO_OUSTR( pVersion->getCreatedBy( ) );
aVersions[i].TimeStamp = lcl_boostToUnoTime( pVersion->getLastModificationDate( ) );
aVersions[i].Comment = STD_TO_OUSTR( pVersion->getStringProperty("cmis:checkinComment") );
+ ++i;
}
return aVersions;
}
@@ -2049,8 +2035,7 @@ namespace cmis
vector< libcmis::ObjectPtr > children = pFolder->getChildren( );
// Loop over the results
- for ( vector< libcmis::ObjectPtr >::iterator it = children.begin();
- it != children.end(); ++it )
+ for ( const auto& rChild : children )
{
// TODO Cache the objects
@@ -2061,15 +2046,15 @@ namespace cmis
OUString sPath( m_sObjectPath );
if ( !sPath.endsWith("/") )
sPath += "/";
- sPath += STD_TO_OUSTR( ( *it )->getName( ) );
- OUString sId = STD_TO_OUSTR( ( *it )->getId( ) );
+ sPath += STD_TO_OUSTR( rChild->getName( ) );
+ OUString sId = STD_TO_OUSTR( rChild->getId( ) );
aUrl.setObjectId( sId );
aUrl.setObjectPath( sPath );
aUrl.setUsername( sUser );
uno::Reference< ucb::XContentIdentifier > xId = new ucbhelper::ContentIdentifier( aUrl.asString( ) );
- uno::Reference< ucb::XContent > xContent = new Content( m_xContext, m_pProvider, xId, *it );
+ uno::Reference< ucb::XContent > xContent = new Content( m_xContext, m_pProvider, xId, rChild );
results.push_back( xContent );
}
diff --git a/ucb/source/ucp/cmis/cmis_datasupplier.cxx b/ucb/source/ucp/cmis/cmis_datasupplier.cxx
index 83baa3ba37aa..dead6a2d6203 100644
--- a/ucb/source/ucp/cmis/cmis_datasupplier.cxx
+++ b/ucb/source/ucp/cmis/cmis_datasupplier.cxx
@@ -38,16 +38,15 @@ namespace cmis
std::vector< uno::Reference< ucb::XContent > > aChildren = m_pChildrenProvider->getChildren( );
// Loop over the results and filter them
- for ( std::vector< uno::Reference< ucb::XContent > >::iterator it = aChildren.begin();
- it != aChildren.end(); ++it )
+ for ( const auto& rChild : aChildren )
{
- OUString sContentType = ( *it )->getContentType( );
+ OUString sContentType = rChild->getContentType( );
bool bIsFolder = sContentType != CMIS_FILE_TYPE;
if ( ( mnOpenMode == ucb::OpenMode::FOLDERS && bIsFolder ) ||
( mnOpenMode == ucb::OpenMode::DOCUMENTS && !bIsFolder ) ||
( mnOpenMode == ucb::OpenMode::ALL ) )
{
- maResults.emplace_back( *it );
+ maResults.emplace_back( rChild );
}
}
mbCountFinal = true;
diff --git a/ucb/source/ucp/cmis/cmis_repo_content.cxx b/ucb/source/ucp/cmis/cmis_repo_content.cxx
index ca5333493c54..0e6174831e6f 100644
--- a/ucb/source/ucp/cmis/cmis_repo_content.cxx
+++ b/ucb/source/ucp/cmis/cmis_repo_content.cxx
@@ -243,12 +243,10 @@ namespace cmis
if ( !m_sRepositoryId.isEmpty() )
{
- for ( std::vector< libcmis::RepositoryPtr >::iterator it = m_aRepositories.begin( );
- it != m_aRepositories.end( ) && nullptr == repo.get( ); ++it )
- {
- if ( STD_TO_OUSTR( ( *it )->getId( ) ) == m_sRepositoryId )
- repo = *it;
- }
+ auto it = std::find_if(m_aRepositories.begin(), m_aRepositories.end(),
+ [&](const libcmis::RepositoryPtr& rRepo) { return STD_TO_OUSTR(rRepo->getId()) == m_sRepositoryId; });
+ if (it != m_aRepositories.end())
+ repo = *it;
}
else
repo = m_aRepositories.front( );
@@ -405,11 +403,10 @@ namespace cmis
if ( m_sRepositoryId.isEmpty( ) )
{
- for ( std::vector< libcmis::RepositoryPtr >::iterator it = m_aRepositories.begin( );
- it != m_aRepositories.end(); ++it )
+ for ( const auto& rRepo : m_aRepositories )
{
URL aUrl( m_aURL );
- aUrl.setObjectPath( STD_TO_OUSTR( ( *it )->getId( ) ) );
+ aUrl.setObjectPath( STD_TO_OUSTR( rRepo->getId( ) ) );
uno::Reference< ucb::XContentIdentifier > xId = new ucbhelper::ContentIdentifier( aUrl.asString( ) );
uno::Reference< ucb::XContent > xContent = new RepoContent( m_xContext, m_pProvider, xId, m_aRepositories );
diff --git a/ucb/source/ucp/file/filprp.cxx b/ucb/source/ucp/file/filprp.cxx
index 6d0eb8d0d9d3..e0c6f5587971 100644
--- a/ucb/source/ucp/file/filprp.cxx
+++ b/ucb/source/ucp/file/filprp.cxx
@@ -45,18 +45,16 @@ XPropertySetInfo_impl::XPropertySetInfo_impl( TaskManager* pMyShell,const OUStri
TaskManager::ContentMap::iterator it = m_pMyShell->m_aContent.find( aUnqPath );
TaskManager::PropertySet& properties = *(it->second.properties);
- TaskManager::PropertySet::iterator it1 = properties.begin();
m_seq.realloc( properties.size() );
sal_Int32 count = 0;
- while( it1 != properties.end() )
+ for( const auto& rProp : properties )
{
- m_seq[ count++ ] = beans::Property( it1->getPropertyName(),
- it1->getHandle(),
- it1->getType(),
- it1->getAttributes() );
- ++it1;
+ m_seq[ count++ ] = beans::Property( rProp.getPropertyName(),
+ rProp.getHandle(),
+ rProp.getType(),
+ rProp.getAttributes() );
}
}
diff --git a/ucb/source/ucp/file/filtask.cxx b/ucb/source/ucp/file/filtask.cxx
index 71ca460b160e..7bdd707b9b10 100644
--- a/ucb/source/ucp/file/filtask.cxx
+++ b/ucb/source/ucp/file/filtask.cxx
@@ -512,11 +512,10 @@ TaskManager::registerNotifier( const OUString& aUnqPath, Notifier* pNotifier )
std::vector< Notifier* >& nlist = *( it->second.notifier );
- std::vector<Notifier*>::iterator it1 = nlist.begin();
- while( it1 != nlist.end() ) // Every "Notifier" only once
+ std::vector<Notifier*>::iterator it1 = std::find(nlist.begin(), nlist.end(), pNotifier);
+ if( it1 != nlist.end() ) // Every "Notifier" only once
{
- if( *it1 == pNotifier ) return;
- ++it1;
+ return;
}
nlist.push_back( pNotifier );
}
@@ -2761,11 +2760,9 @@ TaskManager::getContentExchangedEventListeners( const OUString& aOldPrefix,
// However, these may be in status BaseContent::Deleted
if( copyList != nullptr )
{
- std::vector< Notifier* >::iterator copyIt = copyList->begin();
- while( copyIt != copyList->end() )
+ for( const auto& rCopyPtr : *copyList )
{
- itnew->second.notifier->push_back( *copyIt );
- ++copyIt;
+ itnew->second.notifier->push_back( rCopyPtr );
}
}
}
diff --git a/ucb/source/ucp/gio/gio_content.cxx b/ucb/source/ucp/gio/gio_content.cxx
index 9a701013f06f..bc840e699fe5 100644
--- a/ucb/source/ucp/gio/gio_content.cxx
+++ b/ucb/source/ucp/gio/gio_content.cxx
@@ -571,12 +571,9 @@ void Content::queryChildren( ContentRefList& rChildren )
sal_Int32 nLen = aURL.getLength();
- ucbhelper::ContentRefList::const_iterator it = aAllContents.begin();
- ucbhelper::ContentRefList::const_iterator end = aAllContents.end();
-
- while ( it != end )
+ for ( const auto& rContent : aAllContents )
{
- ucbhelper::ContentImplHelperRef xChild = (*it);
+ ucbhelper::ContentImplHelperRef xChild = rContent;
OUString aChildURL = xChild->getIdentifier()->getContentIdentifier();
// Is aURL a prefix of aChildURL?
@@ -591,7 +588,6 @@ void Content::queryChildren( ContentRefList& rChildren )
rChildren.emplace_back(static_cast< ::gio::Content * >(xChild.get() ) );
}
}
- ++it;
}
}
@@ -617,12 +613,9 @@ bool Content::exchangeIdentity( const uno::Reference< ucb::XContentIdentifier >&
ContentRefList aChildren;
queryChildren( aChildren );
- ContentRefList::const_iterator it = aChildren.begin();
- ContentRefList::const_iterator end = aChildren.end();
-
- while ( it != end )
+ for ( const auto& rChild : aChildren )
{
- ContentRef xChild = (*it);
+ ContentRef xChild = rChild;
// Create new content identifier for the child...
uno::Reference< ucb::XContentIdentifier > xOldChildId = xChild->getIdentifier();
@@ -635,10 +628,8 @@ bool Content::exchangeIdentity( const uno::Reference< ucb::XContentIdentifier >&
if ( !xChild->exchangeIdentity( xNewChildId ) )
return false;
-
- ++it;
- }
- return true;
+ }
+ return true;
}
return false;
@@ -1011,13 +1002,9 @@ void Content::destroy( bool bDeletePhysical )
::gio::Content::ContentRefList aChildren;
queryChildren( aChildren );
- ContentRefList::const_iterator it = aChildren.begin();
- ContentRefList::const_iterator end = aChildren.end();
-
- while ( it != end )
+ for ( auto& rChild : aChildren )
{
- (*it)->destroy( bDeletePhysical );
- ++it;
+ rChild->destroy( bDeletePhysical );
}
}
diff --git a/ucb/source/ucp/hierarchy/hierarchycontent.cxx b/ucb/source/ucp/hierarchy/hierarchycontent.cxx
index 954a89d7abe9..ec47a14f1f1c 100644
--- a/ucb/source/ucp/hierarchy/hierarchycontent.cxx
+++ b/ucb/source/ucp/hierarchy/hierarchycontent.cxx
@@ -741,12 +741,9 @@ void HierarchyContent::queryChildren( HierarchyContentRefVector& rChildren )
sal_Int32 nLen = aURL.getLength();
- ::ucbhelper::ContentRefList::const_iterator it = aAllContents.begin();
- ::ucbhelper::ContentRefList::const_iterator end = aAllContents.end();
-
- while ( it != end )
+ for ( const auto& rContent : aAllContents )
{
- ::ucbhelper::ContentImplHelperRef xChild = (*it);
+ ::ucbhelper::ContentImplHelperRef xChild = rContent;
OUString aChildURL
= xChild->getIdentifier()->getContentIdentifier();
@@ -765,7 +762,6 @@ void HierarchyContent::queryChildren( HierarchyContentRefVector& rChildren )
static_cast< HierarchyContent * >( xChild.get() ) );
}
}
- ++it;
}
}
@@ -812,11 +808,9 @@ bool HierarchyContent::exchangeIdentity(
HierarchyContentRefVector aChildren;
queryChildren( aChildren );
- HierarchyContentRefVector::const_iterator it = aChildren.begin();
-
- while ( it != aChildren.end() )
+ for ( const auto& rChild : aChildren )
{
- HierarchyContentRef xChild = (*it);
+ HierarchyContentRef xChild = rChild;
// Create new content identifier for the child...
uno::Reference< ucb::XContentIdentifier > xOldChildId
@@ -833,8 +827,6 @@ bool HierarchyContent::exchangeIdentity(
if ( !xChild->exchangeIdentity( xNewChildId ) )
return false;
-
- ++it;
}
}
return true;
diff --git a/ucb/source/ucp/package/pkgcontent.cxx b/ucb/source/ucp/package/pkgcontent.cxx
index 8158c13783ff..e428044625e8 100644
--- a/ucb/source/ucp/package/pkgcontent.cxx
+++ b/ucb/source/ucp/package/pkgcontent.cxx
@@ -1677,13 +1677,9 @@ void Content::destroy(
ContentRefList aChildren;
queryChildren( aChildren );
- ContentRefList::const_iterator it = aChildren.begin();
- ContentRefList::const_iterator end = aChildren.end();
-
- while ( it != end )
+ for ( auto& rChild : aChildren )
{
- (*it)->destroy( bDeletePhysical, xEnv );
- ++it;
+ rChild->destroy( bDeletePhysical, xEnv );
}
}
}
@@ -2003,12 +1999,9 @@ bool Content::exchangeIdentity(
ContentRefList aChildren;
queryChildren( aChildren );
- ContentRefList::const_iterator it = aChildren.begin();
- ContentRefList::const_iterator end = aChildren.end();
-
- while ( it != end )
+ for ( const auto& rChild : aChildren )
{
- ContentRef xChild = (*it);
+ ContentRef xChild = rChild;
// Create new content identifier for the child...
uno::Reference< ucb::XContentIdentifier > xOldChildId
@@ -2025,8 +2018,6 @@ bool Content::exchangeIdentity(
if ( !xChild->exchangeIdentity( xNewChildId ) )
return false;
-
- ++it;
}
}
return true;
@@ -2056,12 +2047,9 @@ void Content::queryChildren( ContentRefList& rChildren )
sal_Int32 nLen = aURL.getLength();
- ::ucbhelper::ContentRefList::const_iterator it = aAllContents.begin();
- ::ucbhelper::ContentRefList::const_iterator end = aAllContents.end();
-
- while ( it != end )
+ for ( const auto& rContent : aAllContents )
{
- ::ucbhelper::ContentImplHelperRef xChild = (*it);
+ ::ucbhelper::ContentImplHelperRef xChild = rContent;
OUString aChildURL
= xChild->getIdentifier()->getContentIdentifier();
@@ -2076,7 +2064,6 @@ void Content::queryChildren( ContentRefList& rChildren )
static_cast< Content * >( xChild.get() ) );
}
}
- ++it;
}
}
diff --git a/ucb/source/ucp/tdoc/tdoc_content.cxx b/ucb/source/ucp/tdoc/tdoc_content.cxx
index 50ff16e044f5..1cf7fbdaa222 100644
--- a/ucb/source/ucp/tdoc/tdoc_content.cxx
+++ b/ucb/source/ucp/tdoc/tdoc_content.cxx
@@ -724,12 +724,9 @@ void Content::queryChildren( ContentRefList& rChildren )
sal_Int32 nLen = aURL.getLength();
- ::ucbhelper::ContentRefList::const_iterator it = aAllContents.begin();
- ::ucbhelper::ContentRefList::const_iterator end = aAllContents.end();
-
- while ( it != end )
+ for ( const auto& rContent : aAllContents )
{
- ::ucbhelper::ContentImplHelperRef xChild = (*it);
+ ::ucbhelper::ContentImplHelperRef xChild = rContent;
OUString aChildURL
= xChild->getIdentifier()->getContentIdentifier();
@@ -748,7 +745,6 @@ void Content::queryChildren( ContentRefList& rChildren )
static_cast< Content * >( xChild.get() ) );
}
}
- ++it;
}
}
@@ -796,12 +792,9 @@ bool Content::exchangeIdentity(
ContentRefList aChildren;
queryChildren( aChildren );
- ContentRefList::const_iterator it = aChildren.begin();
- ContentRefList::const_iterator end = aChildren.end();
-
- while ( it != end )
+ for ( const auto& rChild : aChildren )
{
- ContentRef xChild = (*it);
+ ContentRef xChild = rChild;
// Create new content identifier for the child...
uno::Reference< ucb::XContentIdentifier > xOldChildId
@@ -818,8 +811,6 @@ bool Content::exchangeIdentity(
if ( !xChild->exchangeIdentity( xNewChildId ) )
return false;
-
- ++it;
}
}
return true;
@@ -1701,13 +1692,9 @@ void Content::destroy( bool bDeletePhysical,
ContentRefList aChildren;
queryChildren( aChildren );
- ContentRefList::const_iterator it = aChildren.begin();
- ContentRefList::const_iterator end = aChildren.end();
-
- while ( it != end )
+ for ( auto& rChild : aChildren )
{
- (*it)->destroy( bDeletePhysical, xEnv );
- ++it;
+ rChild->destroy( bDeletePhysical, xEnv );
}
}
}
diff --git a/ucb/source/ucp/tdoc/tdoc_docmgr.cxx b/ucb/source/ucp/tdoc/tdoc_docmgr.cxx
index 152e72d2b356..3de939721de9 100644
--- a/ucb/source/ucp/tdoc/tdoc_docmgr.cxx
+++ b/ucb/source/ucp/tdoc/tdoc_docmgr.cxx
@@ -181,17 +181,8 @@ void SAL_CALL OfficeDocumentsManager::documentEventOccured(
{
osl::MutexGuard aGuard( m_aMtx );
- DocumentList::const_iterator it = m_aDocs.begin();
- while ( it != m_aDocs.end() )
- {
- if ( (*it).second.xModel == xModel )
- {
- // already known.
- found = true;
- break;
- }
- ++it;
- }
+ found = std::any_of(m_aDocs.begin(), m_aDocs.end(),
+ [&xModel](const DocumentList::value_type& rEntry) { return rEntry.second.xModel == xModel; });
}
if (!found)
@@ -257,15 +248,13 @@ void SAL_CALL OfficeDocumentsManager::documentEventOccured(
{
osl::MutexGuard aGuard( m_aMtx );
- for (auto it = m_aDocs.begin(); it != m_aDocs.end(); ++it)
+ auto it = std::find_if(m_aDocs.begin(), m_aDocs.end(),
+ [&xModel](const DocumentList::value_type& rEntry) { return rEntry.second.xModel == xModel; });
+ if ( it != m_aDocs.end() )
{
- if ( (*it).second.xModel == xModel )
- {
- aDocId = (*it).first;
- found = true;
- m_aDocs.erase( it );
- break;
- }
+ aDocId = (*it).first;
+ found = true;
+ m_aDocs.erase( it );
}
}
@@ -309,19 +298,15 @@ void SAL_CALL OfficeDocumentsManager::documentEventOccured(
osl::MutexGuard aGuard( m_aMtx );
- DocumentList::iterator it = m_aDocs.begin();
- while ( it != m_aDocs.end() )
- {
- if ( (*it).second.xModel == xModel )
- {
- (*it).second.xStorage = xStorage;
- break;
- }
- ++it;
- }
+ DocumentList::iterator it = std::find_if(m_aDocs.begin(), m_aDocs.end(),
+ [&xModel](const DocumentList::value_type& rEntry) { return rEntry.second.xModel == xModel; });
OSL_ENSURE( it != m_aDocs.end(),
"OnSaveDone event notified for unknown document!" );
+ if ( it != m_aDocs.end() )
+ {
+ (*it).second.xStorage = xStorage;
+ }
}
}
else if ( Event.EventName == "OnSaveAsDone" )
@@ -345,22 +330,18 @@ void SAL_CALL OfficeDocumentsManager::documentEventOccured(
osl::MutexGuard aGuard( m_aMtx );
- DocumentList::iterator it = m_aDocs.begin();
- while ( it != m_aDocs.end() )
- {
- if ( (*it).second.xModel == xModel )
- {
- (*it).second.xStorage = xStorage;
-
- // Adjust title.
- (*it).second.aTitle = title;
- break;
- }
- ++it;
- }
+ DocumentList::iterator it = std::find_if(m_aDocs.begin(), m_aDocs.end(),
+ [&xModel](const DocumentList::value_type& rEntry) { return rEntry.second.xModel == xModel; });
OSL_ENSURE( it != m_aDocs.end(),
"OnSaveAsDone event notified for unknown document!" );
+ if ( it != m_aDocs.end() )
+ {
+ (*it).second.xStorage = xStorage;
+
+ // Adjust title.
+ (*it).second.aTitle = title;
+ }
}
}
else if ( Event.EventName == "OnTitleChanged"
@@ -387,18 +368,14 @@ void SAL_CALL OfficeDocumentsManager::documentEventOccured(
osl::MutexGuard aGuard( m_aMtx );
- DocumentList::iterator it = m_aDocs.begin();
- while ( it != m_aDocs.end() )
+ DocumentList::iterator it = std::find_if(m_aDocs.begin(), m_aDocs.end(),
+ [&xModel](const DocumentList::value_type& rEntry) { return rEntry.second.xModel == xModel; });
+ if ( it != m_aDocs.end() )
{
- if ( (*it).second.xModel == xModel )
- {
- // Adjust title.
- (*it).second.aTitle = aTitle;
+ // Adjust title.
+ (*it).second.aTitle = aTitle;
- m_aDocs[ aDocId ] = StorageInfo( aTitle, xStorage, xModel );
- break;
- }
- ++it;
+ m_aDocs[ aDocId ] = StorageInfo( aTitle, xStorage, xModel );
}
// OSL_ENSURE( it != m_aDocs.end(),
@@ -450,17 +427,8 @@ void OfficeDocumentsManager::buildDocumentsList()
{
osl::MutexGuard aGuard( m_aMtx );
- DocumentList::const_iterator it = m_aDocs.begin();
- while ( it != m_aDocs.end() )
- {
- if ( (*it).second.xModel == xModel )
- {
- // already known.
- found = true;
- break;
- }
- ++it;
- }
+ found = std::any_of(m_aDocs.begin(), m_aDocs.end(),
+ [&xModel](const DocumentList::value_type& rEntry) { return rEntry.second.xModel == xModel; });
}
if (!found)
diff --git a/ucb/source/ucp/tdoc/tdoc_provider.cxx b/ucb/source/ucp/tdoc/tdoc_provider.cxx
index c73b99e804dd..fef2f3145f5e 100644
--- a/ucb/source/ucp/tdoc/tdoc_provider.cxx
+++ b/ucb/source/ucp/tdoc/tdoc_provider.cxx
@@ -231,17 +231,14 @@ void ContentProvider::notifyDocumentClosed( const OUString & rDocId )
::ucbhelper::ContentRefList aAllContents;
queryExistingContents( aAllContents );
- ::ucbhelper::ContentRefList::const_iterator it = aAllContents.begin();
- ::ucbhelper::ContentRefList::const_iterator end = aAllContents.end();
-
// Notify all content objects related to the closed doc.
bool bFoundDocumentContent = false;
rtl::Reference< Content > xRoot;
- while ( it != end )
+ for ( const auto& rContent : aAllContents )
{
- Uri aUri( (*it)->getIdentifier()->getContentIdentifier() );
+ Uri aUri( rContent->getIdentifier()->getContentIdentifier() );
OSL_ENSURE( aUri.isValid(),
"ContentProvider::notifyDocumentClosed - Invalid URI!" );
@@ -249,7 +246,7 @@ void ContentProvider::notifyDocumentClosed( const OUString & rDocId )
{
if ( aUri.isRoot() )
{
- xRoot = static_cast< Content * >( (*it).get() );
+ xRoot = static_cast< Content * >( rContent.get() );
}
else if ( aUri.isDocument() )
{
@@ -268,12 +265,10 @@ void ContentProvider::notifyDocumentClosed( const OUString & rDocId )
{
// Inform content.
rtl::Reference< Content > xContent
- = static_cast< Content * >( (*it).get() );
+ = static_cast< Content * >( rContent.get() );
xContent->notifyDocumentClosed();
}
-
- ++it;
}
if ( xRoot.is() )
@@ -294,28 +289,23 @@ void ContentProvider::notifyDocumentOpened( const OUString & rDocId )
::ucbhelper::ContentRefList aAllContents;
queryExistingContents( aAllContents );
- ::ucbhelper::ContentRefList::const_iterator it = aAllContents.begin();
- ::ucbhelper::ContentRefList::const_iterator end = aAllContents.end();
-
// Find root content. If instantiated let it propagate document insertion.
- while ( it != end )
+ for ( const auto& rContent : aAllContents )
{
- Uri aUri( (*it)->getIdentifier()->getContentIdentifier() );
+ Uri aUri( rContent->getIdentifier()->getContentIdentifier() );
OSL_ENSURE( aUri.isValid(),
"ContentProvider::notifyDocumentOpened - Invalid URI!" );
if ( aUri.isRoot() )
{
rtl::Reference< Content > xRoot
- = static_cast< Content * >( (*it).get() );
+ = static_cast< Content * >( rContent.get() );
xRoot->notifyChildInserted( rDocId );
// Done.
break;
}
-
- ++it;
}
}
diff --git a/ucb/source/ucp/webdav-neon/ContentProperties.cxx b/ucb/source/ucp/webdav-neon/ContentProperties.cxx
index 8f651edff0ab..2a9186b059cb 100644
--- a/ucb/source/ucp/webdav-neon/ContentProperties.cxx
+++ b/ucb/source/ucp/webdav-neon/ContentProperties.cxx
@@ -112,15 +112,9 @@ ContentProperties::ContentProperties( const DAVResource& rResource )
true );
}
- std::vector< DAVPropertyValue >::const_iterator it
- = rResource.properties.begin();
- std::vector< DAVPropertyValue >::const_iterator end
- = rResource.properties.end();
-
- while ( it != end )
+ for ( const auto& rProp : rResource.properties )
{
- addProperty( *it );
- ++it;
+ addProperty( rProp );
}
if ( rResource.uri.endsWith("/") )
@@ -190,14 +184,13 @@ const PropertyValue * ContentProperties::get(
if ( it == end )
{
- it = m_xProps->begin();
- while ( it != end )
- {
- if ( (*it).first.equalsIgnoreAsciiCase( rName ) )
- return &(*it).second;
+ it = std::find_if(m_xProps->cbegin(), end,
+ [&rName](const PropertyValueMap::value_type& rEntry) {
+ return rEntry.first.equalsIgnoreAsciiCase( rName );
+ });
+ if ( it != end )
+ return &(*it).second;
- ++it;
- }
return nullptr;
}
else
@@ -355,13 +348,8 @@ void ContentProperties::addProperties(
const std::vector< OUString > & rProps,
const ContentProperties & rContentProps )
{
- std::vector< OUString >::const_iterator it = rProps.begin();
- std::vector< OUString >::const_iterator end = rProps.end();
-
- while ( it != end )
+ for ( const OUString & rName : rProps )
{
- const OUString & rName = (*it);
-
if ( !contains( rName ) ) // ignore duplicates
{
const PropertyValue * pProp = rContentProps.get( rName );
@@ -375,7 +363,6 @@ void ContentProperties::addProperties(
addProperty( rName, uno::Any(), false );
}
}
- ++it;
}
}
@@ -558,17 +545,12 @@ void CachableContentProperties::addProperties(
{
const std::unique_ptr< PropertyValueMap > & props = rProps.getProperties();
- PropertyValueMap::const_iterator it = props->begin();
- const PropertyValueMap::const_iterator end = props->end();
-
- while ( it != end )
+ for ( const auto& rProp : *props )
{
- if ( isCachable( (*it).first, (*it).second.isCaseSensitive() ) )
- m_aProps.addProperty( (*it).first,
- (*it).second.value(),
- (*it).second.isCaseSensitive() );
-
- ++it;
+ if ( isCachable( rProp.first, rProp.second.isCaseSensitive() ) )
+ m_aProps.addProperty( rProp.first,
+ rProp.second.value(),
+ rProp.second.isCaseSensitive() );
}
}
@@ -576,15 +558,10 @@ void CachableContentProperties::addProperties(
void CachableContentProperties::addProperties(
const std::vector< DAVPropertyValue > & rProps )
{
- std::vector< DAVPropertyValue >::const_iterator it = rProps.begin();
- const std::vector< DAVPropertyValue >::const_iterator end = rProps.end();
-
- while ( it != end )
+ for ( const auto& rProp : rProps )
{
- if ( isCachable( (*it).Name, (*it).IsCaseSensitive ) )
- m_aProps.addProperty( *it );
-
- ++it;
+ if ( isCachable( rProp.Name, rProp.IsCaseSensitive ) )
+ m_aProps.addProperty( rProp );
}
}
diff --git a/ucb/source/ucp/webdav-neon/DAVResourceAccess.cxx b/ucb/source/ucp/webdav-neon/DAVResourceAccess.cxx
index 47aad2a694a6..bf28bb1b0c41 100644
--- a/ucb/source/ucp/webdav-neon/DAVResourceAccess.cxx
+++ b/ucb/source/ucp/webdav-neon/DAVResourceAccess.cxx
@@ -1097,13 +1097,10 @@ void DAVResourceAccess::getUserRequestHeaders(
// en.wikipedia.org:80 forces back 403 "Scripts should use an informative
// User-Agent string with contact information, or they may be IP-blocked
// without notice" otherwise:
- for ( DAVRequestHeaders::iterator i(rRequestHeaders.begin());
- i != rRequestHeaders.end(); ++i )
+ if ( std::any_of(rRequestHeaders.begin(), rRequestHeaders.end(),
+ [](const DAVRequestHeader& rHeader) { return rHeader.first.equalsIgnoreAsciiCase( "User-Agent" ); }) )
{
- if ( i->first.equalsIgnoreAsciiCase( "User-Agent" ) )
- {
- return;
- }
+ return;
}
rRequestHeaders.emplace_back( "User-Agent", "LibreOffice" );
}
@@ -1116,9 +1113,6 @@ bool DAVResourceAccess::detectRedirectCycle(
NeonUri aUri( rRedirectURL );
- std::vector< NeonUri >::const_iterator it = m_aRedirectURIs.begin();
- std::vector< NeonUri >::const_iterator end = m_aRedirectURIs.end();
-
// Check for maximum number of redirections
// according to <https://tools.ietf.org/html/rfc7231#section-6.4>.
// A pratical limit may be 5, due to earlier specifications:
@@ -1128,16 +1122,10 @@ bool DAVResourceAccess::detectRedirectCycle(
return true;
// try to detect a cyclical redirection
- while ( it != end )
- {
- // if equal, cyclical redirection detected
- if ( aUri == (*it) )
- return true;
-
- ++it;
- }
-
- return false;
+ return std::any_of(m_aRedirectURIs.begin(), m_aRedirectURIs.end(),
+ [&aUri](const NeonUri& rUri) {
+ // if equal, cyclical redirection detected
+ return aUri == rUri; });
}
diff --git a/ucb/source/ucp/webdav-neon/DAVSessionFactory.cxx b/ucb/source/ucp/webdav-neon/DAVSessionFactory.cxx
index 060fcb8984d5..173a8445ccdb 100644
--- a/ucb/source/ucp/webdav-neon/DAVSessionFactory.cxx
+++ b/ucb/source/ucp/webdav-neon/DAVSessionFactory.cxx
@@ -52,18 +52,10 @@ rtl::Reference< DAVSession > DAVSessionFactory::createDAVSession(
if (!m_xProxyDecider)
m_xProxyDecider.reset( new ucbhelper::InternetProxyDecider( rxContext ) );
- Map::iterator aIt( m_aMap.begin() );
- Map::iterator aEnd( m_aMap.end() );
+ Map::iterator aIt = std::find_if(m_aMap.begin(), m_aMap.end(),
+ [&inUri, &rFlags](const Map::value_type& rEntry) { return rEntry.second->CanUse( inUri, rFlags ); });
- while ( aIt != aEnd )
- {
- if ( (*aIt).second->CanUse( inUri, rFlags ) )
- break;
-
- ++aIt;
- }
-
- if ( aIt == aEnd )
+ if ( aIt == m_aMap.end() )
{
NeonUri aURI( inUri );
diff --git a/ucb/source/ucp/webdav-neon/NeonHeadRequest.cxx b/ucb/source/ucp/webdav-neon/NeonHeadRequest.cxx
index 824622ec9746..f3759a5f0657 100644
--- a/ucb/source/ucp/webdav-neon/NeonHeadRequest.cxx
+++ b/ucb/source/ucp/webdav-neon/NeonHeadRequest.cxx
@@ -49,15 +49,9 @@ void process_headers( ne_request * req,
{
if( !rHeaderNames.empty() )
{
- std::vector< OUString >::const_iterator it(
- rHeaderNames.begin() );
- const std::vector< OUString >::const_iterator end(
- rHeaderNames.end() );
-
- while ( it != end )
+ for ( const auto& rHeader : rHeaderNames )
{
- SAL_INFO( "ucb.ucp.webdav", "HEAD - requested header: " << (*it) );
- ++it;
+ SAL_INFO( "ucb.ucp.webdav", "HEAD - requested header: " << rHeader );
}
}
}
@@ -75,25 +69,17 @@ void process_headers( ne_request * req,
if ( !bIncludeIt )
{
// Check whether this header was requested.
- std::vector< OUString >::const_iterator it(
- rHeaderNames.begin() );
- const std::vector< OUString >::const_iterator end(
- rHeaderNames.end() );
+ auto it = std::find_if(rHeaderNames.begin(), rHeaderNames.end(),
+ [&aHeaderName](const OUString& rName) {
+ // header names are case insensitive
+ return rName.equalsIgnoreAsciiCase( aHeaderName );
+ });
- while ( it != end )
+ if ( it != rHeaderNames.end() )
{
- // header names are case insensitive
- if ( (*it).equalsIgnoreAsciiCase( aHeaderName ) )
- {
- aHeaderName = (*it);
- break;
- }
-
- ++it;
- }
-
- if ( it != end )
+ aHeaderName = (*it);
bIncludeIt = true;
+ }
}
if ( bIncludeIt )
diff --git a/ucb/source/ucp/webdav-neon/NeonLockStore.cxx b/ucb/source/ucp/webdav-neon/NeonLockStore.cxx
index 062fb402b885..4543778fa81a 100644
--- a/ucb/source/ucp/webdav-neon/NeonLockStore.cxx
+++ b/ucb/source/ucp/webdav-neon/NeonLockStore.cxx
@@ -113,17 +113,13 @@ NeonLockStore::~NeonLockStore()
// release active locks, if any.
SAL_WARN_IF( !m_aLockInfoMap.empty(), "ucb.ucp.webdav", "NeonLockStore::~NeonLockStore - Releasing active locks!" );
- LockInfoMap::const_iterator it( m_aLockInfoMap.begin() );
- const LockInfoMap::const_iterator end( m_aLockInfoMap.end() );
- while ( it != end )
+ for ( auto& rLockInfo : m_aLockInfoMap )
{
- NeonLock * pLock = (*it).first;
- (*it).second.xSession->UNLOCK( pLock );
+ NeonLock * pLock = rLockInfo.first;
+ rLockInfo.second.xSession->UNLOCK( pLock );
ne_lockstore_remove( m_pNeonLockStore, pLock );
ne_lock_destroy( pLock );
-
- ++it;
}
ne_lockstore_destroy( m_pNeonLockStore );
@@ -203,11 +199,9 @@ void NeonLockStore::refreshLocks()
{
osl::MutexGuard aGuard( m_aMutex );
- LockInfoMap::iterator it( m_aLockInfoMap.begin() );
- const LockInfoMap::const_iterator end( m_aLockInfoMap.end() );
- while ( it != end )
+ for ( auto& rLockInfo : m_aLockInfoMap )
{
- LockInfo & rInfo = (*it).second;
+ LockInfo & rInfo = rLockInfo.second;
if ( rInfo.nLastChanceToSendRefreshRequest != -1 )
{
// 30 seconds or less remaining until lock expires?
@@ -219,7 +213,7 @@ void NeonLockStore::refreshLocks()
// refresh the lock.
sal_Int32 nlastChanceToSendRefreshRequest = -1;
if ( rInfo.xSession->LOCK(
- (*it).first,
+ rLockInfo.first,
/* out param */ nlastChanceToSendRefreshRequest ) )
{
rInfo.nLastChanceToSendRefreshRequest
@@ -232,7 +226,6 @@ void NeonLockStore::refreshLocks()
}
}
}
- ++it;
}
}
diff --git a/ucb/source/ucp/webdav-neon/NeonSession.cxx b/ucb/source/ucp/webdav-neon/NeonSession.cxx
index 81fa6adca3ad..28ed1b17c43b 100644
--- a/ucb/source/ucp/webdav-neon/NeonSession.cxx
+++ b/ucb/source/ucp/webdav-neon/NeonSession.cxx
@@ -598,21 +598,16 @@ void NeonSession::PreSendRequest(ne_request* req, ne_buffer* headers)
const DAVRequestHeaders & rHeaders
= getRequestEnvironment().m_aRequestHeaders;
- DAVRequestHeaders::const_iterator it1( rHeaders.begin() );
- const DAVRequestHeaders::const_iterator end1( rHeaders.end() );
-
- while ( it1 != end1 )
+ for ( const auto& rHeader : rHeaders )
{
OString aHeader
- = OUStringToOString( (*it1).first,
+ = OUStringToOString( rHeader.first,
RTL_TEXTENCODING_UTF8 );
OString aValue
- = OUStringToOString( (*it1).second,
+ = OUStringToOString( rHeader.second,
RTL_TEXTENCODING_UTF8 );
ne_buffer_concat( headers, aHeader.getStr(), ": ",
aValue.getStr(), EOL, nullptr );
-
- ++it1;
}
}
@@ -1025,10 +1020,9 @@ void NeonSession::PROPFIND( const OUString & inPath,
#if defined SAL_LOG_INFO
{ //debug
SAL_INFO( "ucb.ucp.webdav", "PROPFIND - relative URL: <" << inPath << "> Depth: " << inDepth );
- for(std::vector< OUString >::const_iterator it = inPropNames.begin();
- it < inPropNames.end(); ++it)
+ for(const auto& rPropName : inPropNames)
{
- SAL_INFO( "ucb.ucp.webdav", "PROPFIND - property requested: " << *it );
+ SAL_INFO( "ucb.ucp.webdav", "PROPFIND - property requested: " << rPropName );
}
} //debug
#endif
@@ -1067,13 +1061,11 @@ void NeonSession::PROPFIND( const OUString & inPath,
#if defined SAL_LOG_INFO
{ //debug
- for ( std::vector< DAVResourceInfo >::const_iterator itres = ioResInfo.begin();
- itres < ioResInfo.end(); ++itres)
+ for ( const auto& rResInfo : ioResInfo )
{
- for ( std::vector< OUString >::const_iterator it = (*itres).properties.begin();
- it < (*itres).properties.end(); ++it)
+ for ( const auto& rProp : rResInfo.properties )
{
- SAL_INFO( "ucb.ucp.webdav", "PROPFIND - returned property (name only): " << *it );
+ SAL_INFO( "ucb.ucp.webdav", "PROPFIND - returned property (name only): " << rProp );
}
}
} //debug
@@ -1812,17 +1804,12 @@ bool NeonSession::removeExpiredLocktoken( const OUString & inURL,
if ( aResources.empty() )
return false;
- std::vector< DAVPropertyValue >::const_iterator it
- = aResources[ 0 ].properties.begin();
- std::vector< DAVPropertyValue >::const_iterator end
- = aResources[ 0 ].properties.end();
-
- while ( it != end )
+ for ( const auto& rProp : aResources[ 0 ].properties )
{
- if ( (*it).Name == DAVProperties::LOCKDISCOVERY )
+ if ( rProp.Name == DAVProperties::LOCKDISCOVERY )
{
uno::Sequence< ucb::Lock > aLocks;
- if ( !( (*it).Value >>= aLocks ) )
+ if ( !( rProp.Value >>= aLocks ) )
return false;
if ( !containsLocktoken( aLocks, theLock->token ) )
@@ -1834,7 +1821,6 @@ bool NeonSession::removeExpiredLocktoken( const OUString & inURL,
// still valid.
return false;
}
- ++it;
}
// No lockdiscovery prop in propfind result / locktoken not found
@@ -2051,24 +2037,16 @@ void runResponseHeaderHandler( void * userdata,
if ( !bIncludeIt )
{
// Check whether this header was requested.
- std::vector< OUString >::const_iterator it(
- pCtx->pHeaderNames->begin() );
- const std::vector< OUString >::const_iterator end(
- pCtx->pHeaderNames->end() );
+ auto it = std::find_if(pCtx->pHeaderNames->cbegin(), pCtx->pHeaderNames->cend(),
+ [&aHeaderName](const OUString& rName) {
+ // header names are case insensitive
+ return rName.equalsIgnoreAsciiCase( aHeaderName ); });
- while ( it != end )
+ if ( it != pCtx->pHeaderNames->end() )
{
- // header names are case insensitive
- if ( (*it).equalsIgnoreAsciiCase( aHeaderName ) )
- {
- aHeaderName = (*it);
- break;
- }
- ++it;
- }
-
- if ( it != end )
+ aHeaderName = (*it);
bIncludeIt = true;
+ }
}
if ( bIncludeIt )
diff --git a/ucb/source/ucp/webdav-neon/webdavcontent.cxx b/ucb/source/ucp/webdav-neon/webdavcontent.cxx
index 39af4be04001..0c4267e9a728 100644
--- a/ucb/source/ucp/webdav-neon/webdavcontent.cxx
+++ b/ucb/source/ucp/webdav-neon/webdavcontent.cxx
@@ -110,21 +110,13 @@ namespace
std::unique_ptr< ContentProperties > &xProps,
const uno::Reference< ucb::XCommandEnvironment >& xEnv )
{
- bool bIsRequestSize = false;
DAVResource aResource;
DAVRequestHeaders aPartialGet;
aPartialGet.emplace_back( OUString( "Range" ), // see <https://tools.ietf.org/html/rfc7233#section-3.1>
OUString( "bytes=0-0" ) );
- for ( std::vector< rtl::OUString >::const_iterator it = aHeaderNames.begin();
- it != aHeaderNames.end(); ++it )
- {
- if ( *it == "Content-Length" )
- {
- bIsRequestSize = true;
- break;
- }
- }
+ bool bIsRequestSize = std::any_of(aHeaderNames.begin(), aHeaderNames.end(),
+ [](const rtl::OUString& rHeaderName) { return rHeaderName == "Content-Length"; });
if ( bIsRequestSize )
{
@@ -145,15 +137,14 @@ namespace
// Solution: if "Content-Range" is present, map it with UCB "Size" property
rtl::OUString aAcceptRanges, aContentRange, aContentLength;
std::vector< DAVPropertyValue > &aResponseProps = aResource.properties;
- for ( std::vector< DAVPropertyValue >::const_iterator it = aResponseProps.begin();
- it != aResponseProps.end(); ++it )
+ for ( const auto& rResponseProp : aResponseProps )
{
- if ( it->Name == "Accept-Ranges" )
- it->Value >>= aAcceptRanges;
- else if ( it->Name == "Content-Range" )
- it->Value >>= aContentRange;
- else if ( it->Name == "Content-Length" )
- it->Value >>= aContentLength;
+ if ( rResponseProp.Name == "Accept-Ranges" )
+ rResponseProp.Value >>= aAcceptRanges;
+ else if ( rResponseProp.Name == "Content-Range" )
+ rResponseProp.Value >>= aContentRange;
+ else if ( rResponseProp.Name == "Content-Length" )
+ rResponseProp.Value >>= aContentLength;
}
sal_Int64 nSize = 1;
@@ -182,14 +173,11 @@ namespace
// "*" means that the instance-length is unknown at the time when the response was generated
if ( aSize != "*" )
{
- for ( std::vector< DAVPropertyValue >::iterator it = aResponseProps.begin();
- it != aResponseProps.end(); ++it )
+ auto it = std::find_if(aResponseProps.begin(), aResponseProps.end(),
+ [](const DAVPropertyValue& rProp) { return rProp.Name == "Content-Length"; });
+ if (it != aResponseProps.end())
{
- if (it->Name == "Content-Length")
- {
- it->Value <<= aSize;
- break;
- }
+ it->Value <<= aSize;
}
}
}
@@ -1251,19 +1239,14 @@ uno::Reference< sdbc::XRow > Content::getPropertyValues(
// Append all standard UCB, DAV and HTTP properties.
const std::unique_ptr< PropertyValueMap > & xProps = rData.getProperties();
- PropertyValueMap::const_iterator it = xProps->begin();
- PropertyValueMap::const_iterator end = xProps->end();
-
ContentProvider * pProvider
= static_cast< ContentProvider * >( rProvider.get() );
beans::Property aProp;
- while ( it != end )
+ for ( const auto& rProp : *xProps )
{
- pProvider->getProperty( (*it).first, aProp );
- xRow->appendObject( aProp, (*it).second.value() );
-
- ++it;
+ pProvider->getProperty( rProp.first, aProp );
+ xRow->appendObject( aProp, rProp.second.value() );
}
// Append all local Additional Properties.
@@ -1401,25 +1384,19 @@ uno::Reference< sdbc::XRow > Content::getPropertyValues(
{
const OUString & rName = rProperties[ n ].Name;
- std::vector< OUString >::const_iterator it
- = m_aFailedPropNames.begin();
std::vector< OUString >::const_iterator end
= m_aFailedPropNames.end();
- while ( it != end )
+ auto it = std::find(m_aFailedPropNames.cbegin(), end, rName);
+ if ( it != end )
{
- if ( *it == rName )
- {
- // the failed property in cache is the same as the requested one,
- // so add it to the requested properties list
- aProperties[ nProps ] = rProperties[ n ];
- nProps++;
- break;
- }
-
- ++it;
+ // the failed property in cache is the same as the requested one,
+ // so add it to the requested properties list
+ aProperties[ nProps ] = rProperties[ n ];
+ nProps++;
}
+ // XXX something strange happens here: identical code for different conditions
if ( it == end )
{
aProperties[ nProps ] = rProperties[ n ];
@@ -1451,21 +1428,19 @@ uno::Reference< sdbc::XRow > Content::getPropertyValues(
#if defined SAL_LOG_INFO
{//debug
// print received resources
- std::vector< DAVPropertyValue >::const_iterator it = resources[0].properties.begin();
- std::vector< DAVPropertyValue >::const_iterator end = resources[0].properties.end();
- while ( it != end )
+ for ( const auto& rProp : resources[0].properties )
{
OUString aPropValue;
bool bValue;
uno::Sequence< ucb::LockEntry > aSupportedLocks;
- if( (*it).Value >>= aPropValue )
- SAL_INFO( "ucb.ucp.webdav", "PROPFIND (getPropertyValues) - returned property: " << (*it).Name << ":" << aPropValue );
- else if( (*it).Value >>= bValue )
- SAL_INFO( "ucb.ucp.webdav", "PROPFIND (getPropertyValues) - returned property: " << (*it).Name << ":" <<
+ if( rProp.Value >>= aPropValue )
+ SAL_INFO( "ucb.ucp.webdav", "PROPFIND (getPropertyValues) - returned property: " << rProp.Name << ":" << aPropValue );
+ else if( rProp.Value >>= bValue )
+ SAL_INFO( "ucb.ucp.webdav", "PROPFIND (getPropertyValues) - returned property: " << rProp.Name << ":" <<
( bValue ? "true" : "false" ) );
- else if( (*it).Value >>= aSupportedLocks )
+ else if( rProp.Value >>= aSupportedLocks )
{
- SAL_INFO( "ucb.ucp.webdav", "PROPFIND (getPropertyValues) - returned property: " << (*it).Name << ":" );
+ SAL_INFO( "ucb.ucp.webdav", "PROPFIND (getPropertyValues) - returned property: " << rProp.Name << ":" );
for ( sal_Int32 n = 0; n < aSupportedLocks.getLength(); ++n )
{
SAL_INFO( "ucb.ucp.webdav"," scope: "
@@ -1474,7 +1449,6 @@ uno::Reference< sdbc::XRow > Content::getPropertyValues(
<< ( aSupportedLocks[ n ].Type != css::ucb::LockType_WRITE ? "" : "write" ) );
}
}
- ++it;
}
}
#endif
@@ -1676,31 +1650,30 @@ uno::Reference< sdbc::XRow > Content::getPropertyValues(
rProperties, aMissingProps ) )
{
//
- for ( std::vector< rtl::OUString >::const_iterator it = aMissingProps.begin();
- it != aMissingProps.end(); ++it )
+ for ( const auto& rProp : aMissingProps )
{
// For the time being only a couple of properties need to be added
- if ( (*it) == "DateModified" || (*it) == "DateCreated" )
+ if ( rProp == "DateModified" || rProp == "DateCreated" )
{
util::DateTime aDate;
xProps->addProperty(
- (*it),
+ rProp,
uno::makeAny( aDate ),
true );
}
// If WebDAV didn't return the resource type, assume default
// This happens e.g. for lists exported by SharePoint
- else if ( (*it) == "IsFolder" )
+ else if ( rProp == "IsFolder" )
{
xProps->addProperty(
- (*it),
+ rProp,
uno::makeAny( false ),
true );
}
- else if ( (*it) == "IsDocument" )
+ else if ( rProp == "IsDocument" )
{
xProps->addProperty(
- (*it),
+ rProp,
uno::makeAny( true ),
true );
}
@@ -2033,21 +2006,14 @@ uno::Sequence< uno::Any > Content::setPropertyValues(
aStaticDAVOptionsCache.removeDAVOptions( xResAccess->getURL() );
xResAccess->PROPPATCH( aProppatchValues, xEnv );
- std::vector< ProppatchValue >::const_iterator it
- = aProppatchValues.begin();
- std::vector< ProppatchValue >::const_iterator end
- = aProppatchValues.end();
-
- while ( it != end )
+ for ( const auto& rProppatchValue : aProppatchValues )
{
- aEvent.PropertyName = (*it).name;
+ aEvent.PropertyName = rProppatchValue.name;
aEvent.OldValue = uno::Any(); // @@@ to expensive to obtain!
- aEvent.NewValue = (*it).value;
+ aEvent.NewValue = rProppatchValue.value;
aChanges.getArray()[ nChanged ] = aEvent;
nChanged++;
-
- ++it;
}
}
catch ( DAVException const & e )
@@ -2448,12 +2414,9 @@ void Content::queryChildren( ContentRefList& rChildren )
sal_Int32 nLen = aURL.getLength();
- ::ucbhelper::ContentRefList::const_iterator it = aAllContents.begin();
- ::ucbhelper::ContentRefList::const_iterator end = aAllContents.end();
-
- while ( it != end )
+ for ( const auto& rChild : aAllContents )
{
- ::ucbhelper::ContentImplHelperRef xChild = (*it);
+ ::ucbhelper::ContentImplHelperRef xChild = rChild;
OUString aChildURL
= xChild->getIdentifier()->getContentIdentifier();
@@ -2473,7 +2436,6 @@ void Content::queryChildren( ContentRefList& rChildren )
xChild.get() ) );
}
}
- ++it;
}
}
@@ -3007,13 +2969,9 @@ void Content::destroy( bool bDeletePhysical )
::webdav_ucp::Content::ContentRefList aChildren;
queryChildren( aChildren );
- ContentRefList::const_iterator it = aChildren.begin();
- ContentRefList::const_iterator end = aChildren.end();
-
- while ( it != end )
+ for ( auto& rChild : aChildren )
{
- (*it)->destroy( bDeletePhysical );
- ++it;
+ rChild->destroy( bDeletePhysical );
}
}
@@ -3096,16 +3054,13 @@ Content::ResourceType Content::resourceTypeForLocks(
// all returned properties are in
// resources.properties[n].Name/.Value
- std::vector< DAVPropertyValue >::iterator it;
-
- for ( it = resources[0].properties.begin();
- it != resources[0].properties.end(); ++it)
+ for ( const auto& rProp : resources[0].properties )
{
- if ( (*it).Name == DAVProperties::SUPPORTEDLOCK )
+ if ( rProp.Name == DAVProperties::SUPPORTEDLOCK )
{
wasSupportedlockFound = true;
uno::Sequence< ucb::LockEntry > aSupportedLocks;
- if ( (*it).Value >>= aSupportedLocks )
+ if ( rProp.Value >>= aSupportedLocks )
{
for ( sal_Int32 n = 0; n < aSupportedLocks.getLength(); ++n )
{
@@ -3503,12 +3458,9 @@ bool Content::exchangeIdentity(
ContentRefList aChildren;
queryChildren( aChildren );
- ContentRefList::const_iterator it = aChildren.begin();
- ContentRefList::const_iterator end = aChildren.end();
-
- while ( it != end )
+ for ( const auto& rChild : aChildren )
{
- ContentRef xChild = (*it);
+ ContentRef xChild = rChild;
// Create new content identifier for the child...
uno::Reference< ucb::XContentIdentifier >
@@ -3525,8 +3477,6 @@ bool Content::exchangeIdentity(
if ( !xChild->exchangeIdentity( xNewChildId ) )
return false;
-
- ++it;
}
return true;
}
@@ -3830,21 +3780,19 @@ Content::ResourceType Content::getResourceType(
#if defined SAL_LOG_INFO
{//debug
// print received resources
- std::vector< DAVPropertyValue >::const_iterator it = resources[0].properties.begin();
- std::vector< DAVPropertyValue >::const_iterator end = resources[0].properties.end();
- while ( it != end )
+ for ( const auto& rProp : resources[0].properties )
{
OUString aPropValue;
bool bValue;
uno::Sequence< ucb::LockEntry > aSupportedLocks;
- if((*it).Value >>= aPropValue )
- SAL_INFO( "ucb.ucp.webdav", "PROPFIND (getResourceType) - ret'd prop: " << (*it).Name << ":" << aPropValue );
- else if( (*it).Value >>= bValue )
- SAL_INFO( "ucb.ucp.webdav", "PROPFIND (getResourceType) - ret'd prop: " << (*it).Name << ":" <<
+ if(rProp.Value >>= aPropValue )
+ SAL_INFO( "ucb.ucp.webdav", "PROPFIND (getResourceType) - ret'd prop: " << rProp.Name << ":" << aPropValue );
+ else if( rProp.Value >>= bValue )
+ SAL_INFO( "ucb.ucp.webdav", "PROPFIND (getResourceType) - ret'd prop: " << rProp.Name << ":" <<
( bValue ? "true" : "false" ) );
- else if( (*it).Value >>= aSupportedLocks )
+ else if( rProp.Value >>= aSupportedLocks )
{
- SAL_INFO( "ucb.ucp.webdav", "PROPFIND (getResourceType) - ret'd prop: " << (*it).Name << ":" );
+ SAL_INFO( "ucb.ucp.webdav", "PROPFIND (getResourceType) - ret'd prop: " << rProp.Name << ":" );
for ( sal_Int32 n = 0; n < aSupportedLocks.getLength(); ++n )
{
SAL_INFO( "ucb.ucp.webdav","PROPFIND (getResourceType) - supportedlock[" << n <<"]: scope: "
@@ -3853,7 +3801,6 @@ Content::ResourceType Content::getResourceType(
<< ( aSupportedLocks[ n ].Type != css::ucb::LockType_WRITE ? "" : "write" ) );
}
}
- ++it;
}
}
#endif
diff --git a/ucb/source/ucp/webdav-neon/webdavcontentcaps.cxx b/ucb/source/ucp/webdav-neon/webdavcontentcaps.cxx
index faf6c742ac3e..4d52efcf5e6b 100644
--- a/ucb/source/ucp/webdav-neon/webdavcontentcaps.cxx
+++ b/ucb/source/ucp/webdav-neon/webdavcontentcaps.cxx
@@ -310,8 +310,7 @@ uno::Sequence< beans::Property > Content::getProperties(
xProvider.set( m_pProvider );
}
- typedef std::set< OUString > StringSet;
- StringSet aPropSet;
+ std::set< OUString > aPropSet;
// No server access for just created (not yet committed) objects.
// Only a minimal set of properties supported at this stage.
@@ -374,71 +373,68 @@ uno::Sequence< beans::Property > Content::getProperties(
bool bHasCreatableInfos = false;
{
- std::set< OUString >::const_iterator it = aPropSet.begin();
- std::set< OUString >::const_iterator end = aPropSet.end();
- while ( it != end )
+ for ( const auto& rProp : aPropSet )
{
if ( !bHasCreationDate &&
- ( (*it) == DAVProperties::CREATIONDATE ) )
+ ( rProp == DAVProperties::CREATIONDATE ) )
{
bHasCreationDate = true;
}
else if ( !bHasGetLastModified &&
- ( (*it) == DAVProperties::GETLASTMODIFIED ) )
+ ( rProp == DAVProperties::GETLASTMODIFIED ) )
{
bHasGetLastModified = true;
}
else if ( !bHasGetContentType &&
- ( (*it) == DAVProperties::GETCONTENTTYPE ) )
+ ( rProp == DAVProperties::GETCONTENTTYPE ) )
{
bHasGetContentType = true;
}
else if ( !bHasGetContentLength &&
- ( (*it) == DAVProperties::GETCONTENTLENGTH ) )
+ ( rProp == DAVProperties::GETCONTENTLENGTH ) )
{
bHasGetContentLength = true;
}
- else if ( !bHasContentType && (*it) == "ContentType" )
+ else if ( !bHasContentType && rProp == "ContentType" )
{
bHasContentType = true;
}
- else if ( !bHasIsDocument && (*it) == "IsDocument" )
+ else if ( !bHasIsDocument && rProp == "IsDocument" )
{
bHasIsDocument = true;
}
- else if ( !bHasIsFolder && (*it) == "IsFolder" )
+ else if ( !bHasIsFolder && rProp == "IsFolder" )
{
bHasIsFolder = true;
}
- else if ( !bHasTitle && (*it) == "Title" )
+ else if ( !bHasTitle && rProp == "Title" )
{
bHasTitle = true;
}
- else if ( !bHasBaseURI && (*it) == "BaseURI" )
+ else if ( !bHasBaseURI && rProp == "BaseURI" )
{
bHasBaseURI = true;
}
- else if ( !bHasDateCreated && (*it) == "DateCreated" )
+ else if ( !bHasDateCreated && rProp == "DateCreated" )
{
bHasDateCreated = true;
}
- else if ( !bHasDateModified && (*it) == "DateModified" )
+ else if ( !bHasDateModified && rProp == "DateModified" )
{
bHasDateModified = true;
}
- else if ( !bHasMediaType && (*it) == "MediaType" )
+ else if ( !bHasMediaType && rProp == "MediaType" )
{
bHasMediaType = true;
}
- else if ( !bHasSize && (*it) == "Size" )
+ else if ( !bHasSize && rProp == "Size" )
{
bHasSize = true;
}
- else if ( !bHasCreatableInfos && (*it) == "CreatableContentsInfo" )
+ else if ( !bHasCreatableInfos && rProp == "CreatableContentsInfo" )
{
bHasCreatableInfos = true;
}
- ++it;
}
}
@@ -501,15 +497,10 @@ uno::Sequence< beans::Property > Content::getProperties(
const std::unique_ptr< PropertyValueMap > & xProps
= xCachedProps->getProperties();
- PropertyValueMap::const_iterator map_it = xProps->begin();
- const PropertyValueMap::const_iterator map_end = xProps->end();
-
- while ( map_it != map_end )
+ for ( const auto& rEntry : *xProps )
{
- if ( aPropSet.find( (*map_it).first ) == set_end )
- aPropSet.insert( (*map_it).first );
-
- ++map_it;
+ if ( aPropSet.find( rEntry.first ) == set_end )
+ aPropSet.insert( rEntry.first );
}
}
@@ -517,13 +508,13 @@ uno::Sequence< beans::Property > Content::getProperties(
sal_Int32 nCount = aPropSet.size();
uno::Sequence< beans::Property > aProperties( nCount );
- std::set< OUString >::const_iterator it = aPropSet.begin();
+ sal_Int32 n = 0;
beans::Property aProp;
- for ( sal_Int32 n = 0; n < nCount; ++n, ++it )
+ for ( const auto& rProp : aPropSet )
{
- xProvider->getProperty( (*it), aProp );
- aProperties[ n ] = aProp;
+ xProvider->getProperty( rProp, aProp );
+ aProperties[ n++ ] = aProp;
}
return aProperties;
diff --git a/ucb/source/ucp/webdav-neon/webdavdatasupplier.cxx b/ucb/source/ucp/webdav-neon/webdavdatasupplier.cxx
index c933929bc8c7..e5fe6403650d 100644
--- a/ucb/source/ucp/webdav-neon/webdavdatasupplier.cxx
+++ b/ucb/source/ucp/webdav-neon/webdavdatasupplier.cxx
@@ -343,20 +343,10 @@ bool DataSupplier::getData()
// needed to get a valid ContentProperties::pIsFolder value, which
// is needed for OpenMode handling.
- std::vector< OUString >::const_iterator it
- = propertyNames.begin();
- std::vector< OUString >::const_iterator end
- = propertyNames.end();
+ bool isNoResourceType = std::none_of(propertyNames.begin(), propertyNames.end(),
+ [](const OUString& rName) { return rName == DAVProperties::RESOURCETYPE; });
- while ( it != end )
- {
- if ( (*it) == DAVProperties::RESOURCETYPE )
- break;
-
- ++it;
- }
-
- if ( it == end )
+ if ( isNoResourceType )
propertyNames.push_back( DAVProperties::RESOURCETYPE );
std::vector< DAVResource > resources;
@@ -372,22 +362,16 @@ bool DataSupplier::getData()
#if defined SAL_LOG_INFO
{
//print the resource for every URI returned
- std::vector< DAVResource >::const_iterator it3 = resources.begin();
- std::vector< DAVResource >::const_iterator end3 = resources.end();
- while ( it3 != end3 )
+ for ( const auto& rResource : resources )
{
- NeonUri aCurrURI( (*it3).uri );
+ NeonUri aCurrURI( rResource.uri );
OUString aCurrPath = aCurrURI.GetPath();
aCurrPath = NeonUri::unescape( aCurrPath );
- SAL_INFO( "ucb.ucp.webdav", "getData() - resource URL: <" << (*it3).uri << ">, unescaped to: <" << aCurrPath << "> )" );
- std::vector< DAVPropertyValue >::const_iterator it4 = (*it3).properties.begin();
- std::vector< DAVPropertyValue >::const_iterator end4 = (*it3).properties.end();
- while ( it4 != end4 )
+ SAL_INFO( "ucb.ucp.webdav", "getData() - resource URL: <" << rResource.uri << ">, unescaped to: <" << aCurrPath << "> )" );
+ for ( const auto& rProp : rResource.properties )
{
- SAL_INFO( "ucb.ucp.webdav", "PROPFIND - property name: " << (*it4).Name );
- ++it4;
+ SAL_INFO( "ucb.ucp.webdav", "PROPFIND - property name: " << rProp.Name );
}
- ++it3;
}
}
#endif
diff --git a/ucb/source/ucp/webdav/ContentProperties.cxx b/ucb/source/ucp/webdav/ContentProperties.cxx
index 7fed92ffa48f..058b2a55c1c0 100644
--- a/ucb/source/ucp/webdav/ContentProperties.cxx
+++ b/ucb/source/ucp/webdav/ContentProperties.cxx
@@ -99,15 +99,9 @@ ContentProperties::ContentProperties( const DAVResource& rResource )
true );
}
- std::vector< DAVPropertyValue >::const_iterator it
- = rResource.properties.begin();
- std::vector< DAVPropertyValue >::const_iterator end
- = rResource.properties.end();
-
- while ( it != end )
+ for ( const auto& rProp : rResource.properties )
{
- addProperty( *it );
- ++it;
+ addProperty( rProp );
}
if ( rResource.uri.endsWith("/") )
@@ -183,14 +177,13 @@ const PropertyValue * ContentProperties::get(
if ( it == end )
{
- it = m_xProps->begin();
- while ( it != end )
- {
- if ( (*it).first.equalsIgnoreAsciiCase( rName ) )
- return &(*it).second;
+ it = std::find_if(m_xProps->cbegin(), end,
+ [&rName](const PropertyValueMap::value_type& rEntry) {
+ return rEntry.first.equalsIgnoreAsciiCase( rName );
+ });
+ if ( it != end )
+ return &(*it).second;
- ++it;
- }
return nullptr;
}
else
@@ -359,13 +352,8 @@ void ContentProperties::addProperties(
const std::vector< OUString > & rProps,
const ContentProperties & rContentProps )
{
- std::vector< OUString >::const_iterator it = rProps.begin();
- std::vector< OUString >::const_iterator end = rProps.end();
-
- while ( it != end )
+ for ( const OUString & rName : rProps )
{
- const OUString & rName = (*it);
-
if ( !contains( rName ) ) // ignore duplicates
{
const PropertyValue * pProp = rContentProps.get( rName );
@@ -379,21 +367,16 @@ void ContentProperties::addProperties(
addProperty( rName, uno::Any(), false );
}
}
- ++it;
}
}
void ContentProperties::addProperties( const ContentProperties & rProps )
{
- PropertyValueMap::const_iterator it = rProps.m_xProps->begin();
- const PropertyValueMap::const_iterator end = rProps.m_xProps->end();
-
- while ( it != end )
+ for ( const auto& rProp : *rProps.m_xProps )
{
addProperty(
- (*it).first, (*it).second.value(), (*it).second.isCaseSensitive() );
- ++it;
+ rProp.first, rProp.second.value(), rProp.second.isCaseSensitive() );
}
}
@@ -401,13 +384,9 @@ void ContentProperties::addProperties( const ContentProperties & rProps )
void ContentProperties::addProperties(
const std::vector< DAVPropertyValue > & rProps )
{
- std::vector< DAVPropertyValue >::const_iterator it = rProps.begin();
- const std::vector< DAVPropertyValue >::const_iterator end = rProps.end();
-
- while ( it != end )
+ for ( const auto& rProp : rProps )
{
- addProperty( *it );
- ++it;
+ addProperty( rProp );
}
}
@@ -591,17 +570,12 @@ void CachableContentProperties::addProperties(
{
const std::unique_ptr< PropertyValueMap > & props = rProps.getProperties();
- PropertyValueMap::const_iterator it = props->begin();
- const PropertyValueMap::const_iterator end = props->end();
-
- while ( it != end )
+ for ( const auto& rProp : *props )
{
- if ( isCachable( (*it).first, (*it).second.isCaseSensitive() ) )
- m_aProps.addProperty( (*it).first,
- (*it).second.value(),
- (*it).second.isCaseSensitive() );
-
- ++it;
+ if ( isCachable( rProp.first, rProp.second.isCaseSensitive() ) )
+ m_aProps.addProperty( rProp.first,
+ rProp.second.value(),
+ rProp.second.isCaseSensitive() );
}
}
@@ -609,16 +583,11 @@ void CachableContentProperties::addProperties(
void CachableContentProperties::addProperties(
const std::vector< DAVPropertyValue > & rProps )
{
- std::vector< DAVPropertyValue >::const_iterator it = rProps.begin();
- const std::vector< DAVPropertyValue >::const_iterator end = rProps.end();
-
- while ( it != end )
+ for ( const auto& rProp : rProps )
{
- if ( isCachable( (*it).Name, (*it).IsCaseSensitive ) )
- m_aProps.addProperty( *it );
-
- ++it;
- }
+ if ( isCachable( rProp.Name, rProp.IsCaseSensitive ) )
+ m_aProps.addProperty( rProp );
+ }
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/ucb/source/ucp/webdav/DAVResourceAccess.cxx b/ucb/source/ucp/webdav/DAVResourceAccess.cxx
index eda8e0fcc8c3..2132cb095390 100644
--- a/ucb/source/ucp/webdav/DAVResourceAccess.cxx
+++ b/ucb/source/ucp/webdav/DAVResourceAccess.cxx
@@ -1059,18 +1059,8 @@ bool DAVResourceAccess::detectRedirectCycle(
SerfUri aUri( rRedirectURL );
- std::vector< SerfUri >::const_iterator it = m_aRedirectURIs.begin();
- std::vector< SerfUri >::const_iterator end = m_aRedirectURIs.end();
-
- while ( it != end )
- {
- if ( aUri == (*it) )
- return true;
-
- ++it;
- }
-
- return false;
+ return std::any_of(m_aRedirectURIs.begin(), m_aRedirectURIs.end(),
+ [&aUri](const SerfUri& rUri) { return aUri == rUri; });
}
diff --git a/ucb/source/ucp/webdav/DAVSessionFactory.cxx b/ucb/source/ucp/webdav/DAVSessionFactory.cxx
index 587c649545ec..a0f5df5a9ad2 100644
--- a/ucb/source/ucp/webdav/DAVSessionFactory.cxx
+++ b/ucb/source/ucp/webdav/DAVSessionFactory.cxx
@@ -39,18 +39,10 @@ rtl::Reference< DAVSession > DAVSessionFactory::createDAVSession(
if ( !m_xProxyDecider.get() )
m_xProxyDecider.reset( new ucbhelper::InternetProxyDecider( rxContext ) );
- Map::iterator aIt( m_aMap.begin() );
- Map::iterator aEnd( m_aMap.end() );
+ Map::iterator aIt = std::find_if(m_aMap.begin(), m_aMap.end(),
+ [&inUri](const Map::value_type& rEntry) { return rEntry.second->CanUse( inUri ); });
- while ( aIt != aEnd )
- {
- if ( (*aIt).second->CanUse( inUri ) )
- break;
-
- ++aIt;
- }
-
- if ( aIt == aEnd )
+ if ( aIt == m_aMap.end() )
{
SerfUri aURI( inUri );
diff --git a/ucb/source/ucp/webdav/SerfGetReqProcImpl.cxx b/ucb/source/ucp/webdav/SerfGetReqProcImpl.cxx
index 17dcb24531b8..c06b94f16b50 100644
--- a/ucb/source/ucp/webdav/SerfGetReqProcImpl.cxx
+++ b/ucb/source/ucp/webdav/SerfGetReqProcImpl.cxx
@@ -151,22 +151,11 @@ void SerfGetReqProcImpl::processSingleResponseHeader( const char* inHeaderName,
else
{
// store only header fields which are requested
- std::vector< OUString >::const_iterator it( mpHeaderNames->begin() );
- const std::vector< OUString >::const_iterator end( mpHeaderNames->end() );
-
- while ( it != end )
- {
- // header names are case insensitive
- if ( (*it).equalsIgnoreAsciiCase( aHeaderName ) )
- {
- bStoreHeaderField = true;
- break;
- }
- else
- {
- ++it;
- }
- }
+ bStoreHeaderField = std::any_of(mpHeaderNames->begin(), mpHeaderNames->end(),
+ [&aHeaderName](const OUString& rHeaderName) {
+ // header names are case insensitive
+ return rHeaderName.equalsIgnoreAsciiCase( aHeaderName );
+ });
}
if ( bStoreHeaderField )
diff --git a/ucb/source/ucp/webdav/SerfHeadReqProcImpl.cxx b/ucb/source/ucp/webdav/SerfHeadReqProcImpl.cxx
index 984c78cc2b22..a771570dadc3 100644
--- a/ucb/source/ucp/webdav/SerfHeadReqProcImpl.cxx
+++ b/ucb/source/ucp/webdav/SerfHeadReqProcImpl.cxx
@@ -106,22 +106,11 @@ void SerfHeadReqProcImpl::processSingleResponseHeader( const char* inHeaderName,
else
{
// store only header fields which are requested
- std::vector< OUString >::const_iterator it( mpHeaderNames->begin() );
- const std::vector< OUString >::const_iterator end( mpHeaderNames->end() );
-
- while ( it != end )
- {
- // header names are case insensitive
- if ( (*it).equalsIgnoreAsciiCase( aHeaderName ) )
- {
- bStoreHeaderField = true;
- break;
- }
- else
- {
- ++it;
- }
- }
+ bStoreHeaderField = std::any_of(mpHeaderNames->begin(), mpHeaderNames->end(),
+ [&aHeaderName](const OUString& rHeaderName) {
+ // header names are case insensitive
+ return rHeaderName.equalsIgnoreAsciiCase( aHeaderName );
+ });
}
if ( bStoreHeaderField )
diff --git a/ucb/source/ucp/webdav/SerfLockStore.cxx b/ucb/source/ucp/webdav/SerfLockStore.cxx
index ec8da85476e5..ec2f6ae1bea7 100644
--- a/ucb/source/ucp/webdav/SerfLockStore.cxx
+++ b/ucb/source/ucp/webdav/SerfLockStore.cxx
@@ -92,12 +92,9 @@ SerfLockStore::~SerfLockStore()
SAL_WARN_IF( !m_aLockInfoMap.empty(), "ucb.ucp.webdav",
"SerfLockStore::~SerfLockStore - Releasing active locks!" );
- LockInfoMap::const_iterator it( m_aLockInfoMap.begin() );
- const LockInfoMap::const_iterator end( m_aLockInfoMap.end() );
- while ( it != end )
+ for ( auto& rLockInfo : m_aLockInfoMap )
{
- (*it).second.m_xSession->UNLOCK( (*it).first );
- ++it;
+ rLockInfo.second.m_xSession->UNLOCK( rLockInfo.first );
}
}
@@ -189,11 +186,9 @@ void SerfLockStore::refreshLocks()
{
osl::MutexGuard aGuard( m_aMutex );
- LockInfoMap::iterator it( m_aLockInfoMap.begin() );
- const LockInfoMap::const_iterator end( m_aLockInfoMap.end() );
- while ( it != end )
+ for ( auto& rLockInfo : m_aLockInfoMap )
{
- LockInfo & rInfo = (*it).second;
+ LockInfo & rInfo = rLockInfo.second;
if ( rInfo.m_nLastChanceToSendRefreshRequest != -1 )
{
// 30 seconds or less remaining until lock expires?
@@ -205,7 +200,7 @@ void SerfLockStore::refreshLocks()
// refresh the lock.
sal_Int32 nlastChanceToSendRefreshRequest = -1;
if ( rInfo.m_xSession->LOCK(
- (*it).first, &nlastChanceToSendRefreshRequest ) )
+ rLockInfo.first, &nlastChanceToSendRefreshRequest ) )
{
rInfo.m_nLastChanceToSendRefreshRequest
= nlastChanceToSendRefreshRequest;
@@ -217,7 +212,6 @@ void SerfLockStore::refreshLocks()
}
}
}
- ++it;
}
}
diff --git a/ucb/source/ucp/webdav/SerfRequestProcessorImpl.cxx b/ucb/source/ucp/webdav/SerfRequestProcessorImpl.cxx
index 66e45efc6a52..dffd5e907e63 100644
--- a/ucb/source/ucp/webdav/SerfRequestProcessorImpl.cxx
+++ b/ucb/source/ucp/webdav/SerfRequestProcessorImpl.cxx
@@ -82,25 +82,19 @@ void SerfRequestProcessorImpl::handleChunkedEncoding (
void SerfRequestProcessorImpl::setRequestHeaders( serf_bucket_t* inoutSerfHeaderBucket )
{
bool bHasUserAgent( false );
- DAVRequestHeaders::const_iterator aHeaderIter( mrRequestHeaders.begin() );
- const DAVRequestHeaders::const_iterator aEnd( mrRequestHeaders.end() );
- while ( aHeaderIter != aEnd )
+ for ( const auto& rHeader : mrRequestHeaders )
{
- const OString aHeader = OUStringToOString( (*aHeaderIter).first,
- RTL_TEXTENCODING_UTF8 );
- const OString aValue = OUStringToOString( (*aHeaderIter).second,
- RTL_TEXTENCODING_UTF8 );
+ const OString aHeader = OUStringToOString( rHeader.first, RTL_TEXTENCODING_UTF8 );
+ const OString aValue = OUStringToOString( rHeader.second, RTL_TEXTENCODING_UTF8 );
SAL_INFO("ucb.ucp.webdav", "Request Header - \"" << aHeader << ": " << aValue << "\"");
if ( !bHasUserAgent )
- bHasUserAgent = aHeaderIter->first == "User-Agent";
+ bHasUserAgent = rHeader.first == "User-Agent";
serf_bucket_headers_setc( inoutSerfHeaderBucket,
aHeader.getStr(),
aValue.getStr() );
-
- ++aHeaderIter;
}
if ( !bHasUserAgent )
diff --git a/ucb/source/ucp/webdav/webdavcontent.cxx b/ucb/source/ucp/webdav/webdavcontent.cxx
index 8fb3b7a52d79..a6e7087c26a2 100644
--- a/ucb/source/ucp/webdav/webdavcontent.cxx
+++ b/ucb/source/ucp/webdav/webdavcontent.cxx
@@ -96,7 +96,6 @@ void lcl_sendPartialGETRequest( bool &bError,
std::unique_ptr< ContentProperties > &xProps,
const uno::Reference< ucb::XCommandEnvironment >& xEnv )
{
- bool bIsRequestSize = false;
DAVResource aResource;
DAVRequestHeaders aPartialGet;
aPartialGet.push_back(
@@ -104,15 +103,8 @@ void lcl_sendPartialGETRequest( bool &bError,
OUString( "Range" ),
OUString( "bytes=0-0" )));
- for ( std::vector< rtl::OUString >::const_iterator it = aHeaderNames.begin();
- it != aHeaderNames.end(); ++it )
- {
- if ( *it == "Content-Length" )
- {
- bIsRequestSize = true;
- break;
- }
- }
+ bool bIsRequestSize = std::any_of(aHeaderNames.begin(), aHeaderNames.end(),
+ [](const rtl::OUString& rHeaderName) { return rHeaderName == "Content-Length"; });
if ( bIsRequestSize )
{
@@ -136,15 +128,14 @@ void lcl_sendPartialGETRequest( bool &bError,
// Solution: if "Content-Range" is present, map it with UCB "Size" property
rtl::OUString aAcceptRanges, aContentRange, aContentLength;
std::vector< DAVPropertyValue > &aResponseProps = aResource.properties;
- for ( std::vector< DAVPropertyValue >::const_iterator it = aResponseProps.begin();
- it != aResponseProps.end(); ++it )
+ for ( const auto& rResponseProp : aResponseProps )
{
- if ( it->Name == "Accept-Ranges" )
- it->Value >>= aAcceptRanges;
- else if ( it->Name == "Content-Range" )
- it->Value >>= aContentRange;
- else if ( it->Name == "Content-Length" )
- it->Value >>= aContentLength;
+ if ( rResponseProp.Name == "Accept-Ranges" )
+ rResponseProp.Value >>= aAcceptRanges;
+ else if ( rResponseProp.Name == "Content-Range" )
+ rResponseProp.Value >>= aContentRange;
+ else if ( rResponseProp.Name == "Content-Length" )
+ rResponseProp.Value >>= aContentLength;
}
sal_Int64 nSize = 1;
@@ -170,14 +161,11 @@ void lcl_sendPartialGETRequest( bool &bError,
// "*" means that the instance-length is unknown at the time when the response was generated
if ( aSize != "*" )
{
- for ( std::vector< DAVPropertyValue >::iterator it = aResponseProps.begin();
- it != aResponseProps.end(); ++it )
+ auto it = std::find_if(aResponseProps.begin(), aResponseProps.end(),
+ [](const DAVPropertyValue& rProp) { return rProp.Name == "Content-Length"; });
+ if (it != aResponseProps.end())
{
- if (it->Name == "Content-Length")
- {
- it->Value <<= aSize;
- break;
- }
+ it->Value <<= aSize;
}
}
}
@@ -1230,19 +1218,14 @@ uno::Reference< sdbc::XRow > Content::getPropertyValues(
const std::unique_ptr< PropertyValueMap > & xProps = rData.getProperties();
- PropertyValueMap::const_iterator it = xProps->begin();
- PropertyValueMap::const_iterator end = xProps->end();
-
ContentProvider * pProvider
= static_cast< ContentProvider * >( rProvider.get() );
beans::Property aProp;
- while ( it != end )
+ for ( const auto& rProp : *xProps )
{
- if ( pProvider->getProperty( (*it).first, aProp ) )
- xRow->appendObject( aProp, (*it).second.value() );
-
- ++it;
+ if ( pProvider->getProperty( rProp.first, aProp ) )
+ xRow->appendObject( aProp, rProp.second.value() );
}
// Append all local Additional Properties.
@@ -1342,20 +1325,8 @@ uno::Reference< sdbc::XRow > Content::getPropertyValues(
{
const OUString & rName = rProperties[ n ].Name;
- std::vector< OUString >::const_iterator it
- = m_aFailedPropNames.begin();
- std::vector< OUString >::const_iterator end
- = m_aFailedPropNames.end();
-
- while ( it != end )
- {
- if ( *it == rName )
- break;
-
- ++it;
- }
-
- if ( it == end )
+ if ( std::none_of(m_aFailedPropNames.begin(), m_aFailedPropNames.end(),
+ [&rName](const OUString& rPropName) { return rPropName == rName; }) )
{
aProperties[ nProps ] = rProperties[ n ];
nProps++;
@@ -1869,21 +1840,14 @@ uno::Sequence< uno::Any > Content::setPropertyValues(
// Set property values at server.
xResAccess->PROPPATCH( aProppatchValues, xEnv );
- std::vector< ProppatchValue >::const_iterator it
- = aProppatchValues.begin();
- std::vector< ProppatchValue >::const_iterator end
- = aProppatchValues.end();
-
- while ( it != end )
+ for ( const auto& rProppatchValue : aProppatchValues )
{
- aEvent.PropertyName = (*it).name;
+ aEvent.PropertyName = rProppatchValue.name;
aEvent.OldValue = uno::Any(); // @@@ to expensive to obtain!
- aEvent.NewValue = (*it).value;
+ aEvent.NewValue = rProppatchValue.value;
aChanges.getArray()[ nChanged ] = aEvent;
nChanged++;
-
- ++it;
}
}
catch ( DAVException const & e )
@@ -2271,12 +2235,9 @@ void Content::queryChildren( ContentRefList& rChildren )
sal_Int32 nLen = aURL.getLength();
- ::ucbhelper::ContentRefList::const_iterator it = aAllContents.begin();
- ::ucbhelper::ContentRefList::const_iterator end = aAllContents.end();
-
- while ( it != end )
+ for ( const auto& rChild : aAllContents )
{
- ::ucbhelper::ContentImplHelperRef xChild = (*it);
+ ::ucbhelper::ContentImplHelperRef xChild = rChild;
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list