summaryrefslogtreecommitdiff
path: root/ucb/source/ucp
diff options
context:
space:
mode:
authorArkadiy Illarionov <qarkai@gmail.com>2019-06-29 22:24:22 +0300
committerArkadiy Illarionov <qarkai@gmail.com>2019-06-30 12:40:20 +0200
commit02872ceafb8adca47cce856d0e44107494ba2e21 (patch)
tree33a62ca57f6de9507ff1e9ccb7880372fbe91f77 /ucb/source/ucp
parent639698862d16310b60514277d59227eec37eb02a (diff)
Simplify Sequence iterations in ucb
Use range-based loops or replace with STL functions Change-Id: I755dec47aeeed879a032eecd50dee585c392ec59 Reviewed-on: https://gerrit.libreoffice.org/74915 Tested-by: Jenkins Reviewed-by: Arkadiy Illarionov <qarkai@gmail.com>
Diffstat (limited to 'ucb/source/ucp')
-rw-r--r--ucb/source/ucp/cmis/cmis_content.cxx75
-rw-r--r--ucb/source/ucp/cmis/cmis_repo_content.cxx10
-rw-r--r--ucb/source/ucp/ext/ucpext_content.cxx15
-rw-r--r--ucb/source/ucp/file/bc.cxx26
-rw-r--r--ucb/source/ucp/file/filcmd.cxx28
-rw-r--r--ucb/source/ucp/file/filnot.cxx23
-rw-r--r--ucb/source/ucp/file/filprp.cxx13
-rw-r--r--ucb/source/ucp/file/filrset.cxx30
-rw-r--r--ucb/source/ucp/file/filtask.cxx78
-rw-r--r--ucb/source/ucp/file/prov.cxx13
-rw-r--r--ucb/source/ucp/ftp/ftpcontent.cxx45
-rw-r--r--ucb/source/ucp/ftp/ftpresultsetI.cxx22
-rw-r--r--ucb/source/ucp/ftp/ftpresultsetbase.cxx13
-rw-r--r--ucb/source/ucp/gio/gio_content.cxx10
-rw-r--r--ucb/source/ucp/hierarchy/hierarchycontent.cxx19
-rw-r--r--ucb/source/ucp/package/pkgcontent.cxx17
-rw-r--r--ucb/source/ucp/tdoc/tdoc_content.cxx17
-rw-r--r--ucb/source/ucp/webdav-neon/ContentProperties.cxx15
-rw-r--r--ucb/source/ucp/webdav-neon/DAVResourceAccess.cxx6
-rw-r--r--ucb/source/ucp/webdav-neon/LinkSequence.cxx19
-rw-r--r--ucb/source/ucp/webdav-neon/NeonSession.cxx22
-rw-r--r--ucb/source/ucp/webdav-neon/webdavcontent.cxx53
22 files changed, 227 insertions, 342 deletions
diff --git a/ucb/source/ucp/cmis/cmis_content.cxx b/ucb/source/ucp/cmis/cmis_content.cxx
index 2f5dd71fc857..cf8cdacf05c2 100644
--- a/ucb/source/ucp/cmis/cmis_content.cxx
+++ b/ucb/source/ucp/cmis/cmis_content.cxx
@@ -182,57 +182,44 @@ namespace
{
uno::Sequence< OUString > seqValue;
value >>= seqValue;
- sal_Int32 nNumValue = seqValue.getLength( );
- for ( sal_Int32 i = 0; i < nNumValue; ++i )
- {
- values.push_back( OUSTR_TO_STDSTR( seqValue[i] ) );
- }
+ std::transform(seqValue.begin(), seqValue.end(), std::back_inserter(values),
+ [](const OUString& rValue) -> std::string { return OUSTR_TO_STDSTR( rValue ); });
type = libcmis::PropertyType::String;
}
else if ( prop.Type == CMIS_TYPE_BOOL )
{
uno::Sequence< sal_Bool > seqValue;
value >>= seqValue;
- sal_Int32 nNumValue = seqValue.getLength( );
- for ( sal_Int32 i = 0; i < nNumValue; ++i )
- {
- values.push_back( OUSTR_TO_STDSTR( OUString::boolean( seqValue[i] ) ) );
- }
+ std::transform(seqValue.begin(), seqValue.end(), std::back_inserter(values),
+ [](const bool nValue) -> std::string { return OUSTR_TO_STDSTR( OUString::boolean( nValue ) ); });
type = libcmis::PropertyType::Bool;
}
else if ( prop.Type == CMIS_TYPE_INTEGER )
{
uno::Sequence< sal_Int64 > seqValue;
value >>= seqValue;
- sal_Int32 nNumValue = seqValue.getLength( );
- for ( sal_Int32 i = 0; i < nNumValue; ++i )
- {
- values.push_back( OUSTR_TO_STDSTR( OUString::number( seqValue[i] ) ) );
- }
+ std::transform(seqValue.begin(), seqValue.end(), std::back_inserter(values),
+ [](const sal_Int64 nValue) -> std::string { return OUSTR_TO_STDSTR( OUString::number( nValue ) ); });
type = libcmis::PropertyType::Integer;
}
else if ( prop.Type == CMIS_TYPE_DECIMAL )
{
uno::Sequence< double > seqValue;
value >>= seqValue;
- sal_Int32 nNumValue = seqValue.getLength( );
- for ( sal_Int32 i = 0; i < nNumValue; ++i )
- {
- values.push_back( OUSTR_TO_STDSTR( OUString::number( seqValue[i] ) ) );
- }
+ std::transform(seqValue.begin(), seqValue.end(), std::back_inserter(values),
+ [](const double fValue) -> std::string { return OUSTR_TO_STDSTR( OUString::number( fValue ) ); });
type = libcmis::PropertyType::Decimal;
}
else if ( prop.Type == CMIS_TYPE_DATETIME )
{
uno::Sequence< util::DateTime > seqValue;
value >>= seqValue;
- sal_Int32 nNumValue = seqValue.getLength( );
- for ( sal_Int32 i = 0; i < nNumValue; ++i )
- {
- OUStringBuffer aBuffer;
- ::sax::Converter::convertDateTime( aBuffer, seqValue[i], nullptr );
- values.push_back( OUSTR_TO_STDSTR( aBuffer.makeStringAndClear( ) ) );
- }
+ std::transform(seqValue.begin(), seqValue.end(), std::back_inserter(values),
+ [](const util::DateTime& rValue) -> std::string {
+ OUStringBuffer aBuffer;
+ ::sax::Converter::convertDateTime( aBuffer, rValue, nullptr );
+ return OUSTR_TO_STDSTR( aBuffer.makeStringAndClear( ) );
+ });
type = libcmis::PropertyType::DateTime;
}
@@ -602,11 +589,10 @@ namespace cmis
iCmisProps >>= aPropsSeq;
map< string, libcmis::PropertyPtr > aProperties;
- sal_Int32 propsLen = aPropsSeq.getLength( );
- for ( sal_Int32 i = 0; i< propsLen; i++ )
+ for ( const auto& rProp : aPropsSeq )
{
- std::string id = OUSTR_TO_STDSTR( aPropsSeq[i].Id );
- libcmis::PropertyPtr prop = lcl_unoToCmisProperty( aPropsSeq[i] );
+ std::string id = OUSTR_TO_STDSTR( rProp.Id );
+ libcmis::PropertyPtr prop = lcl_unoToCmisProperty( rProp );
aProperties.insert( std::pair<string, libcmis::PropertyPtr>( id, prop ) );
}
libcmis::ObjectPtr updateObj;
@@ -628,16 +614,8 @@ namespace cmis
{
rtl::Reference< ::ucbhelper::PropertyValueSet > xRow = new ::ucbhelper::PropertyValueSet( m_xContext );
- sal_Int32 nProps;
- const beans::Property* pProps;
-
- nProps = rProperties.getLength();
- pProps = rProperties.getConstArray();
-
- for( sal_Int32 n = 0; n < nProps; ++n )
+ for( const beans::Property& rProp : rProperties )
{
- const beans::Property& rProp = pProps[ n ];
-
try
{
if ( rProp.Name == "IsDocument" )
@@ -840,14 +818,13 @@ namespace cmis
uno::Sequence< document::CmisProperty > aCmisProperties( aProperties.size( ) );
document::CmisProperty* pCmisProps = aCmisProperties.getArray( );
sal_Int32 i = 0;
- for ( const auto& rProperty : aProperties )
+ for ( const auto& [sId, rProperty] : aProperties )
{
- 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();
+ string sDisplayName = rProperty->getPropertyType()->getDisplayName( );
+ bool bUpdatable = rProperty->getPropertyType()->isUpdatable( );
+ bool bRequired = rProperty->getPropertyType()->isRequired( );
+ bool bMultiValued = rProperty->getPropertyType()->isMultiValued();
+ bool bOpenChoice = rProperty->getPropertyType()->isOpenChoice();
pCmisProps[i].Id = STD_TO_OUSTR( sId );
pCmisProps[i].Name = STD_TO_OUSTR( sDisplayName );
@@ -855,8 +832,8 @@ namespace cmis
pCmisProps[i].Required = bRequired;
pCmisProps[i].MultiValued = bMultiValued;
pCmisProps[i].OpenChoice = bOpenChoice;
- pCmisProps[i].Value = lcl_cmisPropertyToUno( rProperty.second );
- switch ( rProperty.second->getPropertyType( )->getType( ) )
+ pCmisProps[i].Value = lcl_cmisPropertyToUno( rProperty );
+ switch ( rProperty->getPropertyType( )->getType( ) )
{
default:
case libcmis::PropertyType::String:
diff --git a/ucb/source/ucp/cmis/cmis_repo_content.cxx b/ucb/source/ucp/cmis/cmis_repo_content.cxx
index 0e6174831e6f..744c6ba84270 100644
--- a/ucb/source/ucp/cmis/cmis_repo_content.cxx
+++ b/ucb/source/ucp/cmis/cmis_repo_content.cxx
@@ -83,16 +83,8 @@ namespace cmis
{
rtl::Reference< ::ucbhelper::PropertyValueSet > xRow = new ::ucbhelper::PropertyValueSet( m_xContext );
- sal_Int32 nProps;
- const beans::Property* pProps;
-
- nProps = rProperties.getLength();
- pProps = rProperties.getConstArray();
-
- for( sal_Int32 n = 0; n < nProps; ++n )
+ for( const beans::Property& rProp : rProperties )
{
- const beans::Property& rProp = pProps[ n ];
-
try
{
if ( rProp.Name == "IsDocument" )
diff --git a/ucb/source/ucp/ext/ucpext_content.cxx b/ucb/source/ucp/ext/ucpext_content.cxx
index f55c3418cc48..efb67d4fdfe2 100644
--- a/ucb/source/ucp/ext/ucpext_content.cxx
+++ b/ucb/source/ucp/ext/ucpext_content.cxx
@@ -381,14 +381,10 @@ namespace ucb { namespace ucp { namespace ext
// note: empty sequence means "get values of all supported properties".
::rtl::Reference< ::ucbhelper::PropertyValueSet > xRow = new ::ucbhelper::PropertyValueSet( rxContext );
- const sal_Int32 nCount = i_rProperties.getLength();
- if ( nCount )
+ if ( i_rProperties.hasElements() )
{
- const Property* pProps = i_rProperties.getConstArray();
- for ( sal_Int32 n = 0; n < nCount; ++n )
+ for ( const Property& rProp : i_rProperties )
{
- const Property& rProp = pProps[ n ];
-
// Process Core properties.
if ( rProp.Name == "ContentType" )
{
@@ -513,13 +509,10 @@ namespace ucb { namespace ucp { namespace ext
aEvent.Further = false;
aEvent.PropertyHandle = -1;
- const PropertyValue* pValues = i_rValues.getConstArray();
- const sal_Int32 nCount = i_rValues.getLength();
-
- for ( sal_Int32 n = 0; n < nCount; ++n, ++pValues )
+ for ( auto& rRet : aRet )
{
// all our properties are read-only ...
- aRet[ n ] <<= IllegalAccessException("property is read-only.", *this );
+ rRet <<= IllegalAccessException("property is read-only.", *this );
}
return aRet;
diff --git a/ucb/source/ucp/file/bc.cxx b/ucb/source/ucp/file/bc.cxx
index 2e5538286f00..12ff24619303 100644
--- a/ucb/source/ucp/file/bc.cxx
+++ b/ucb/source/ucp/file/bc.cxx
@@ -404,9 +404,9 @@ BaseContent::addPropertiesChangeListener(
else
{
Reference< beans::XPropertySetInfo > xProp = m_pMyShell->info_p( m_aUncPath );
- for( sal_Int32 i = 0; i < PropertyNames.getLength(); ++i )
- if( xProp->hasPropertyByName( PropertyNames[i] ) )
- m_pPropertyListener->addInterface( PropertyNames[i],Listener );
+ for( const auto& rName : PropertyNames )
+ if( xProp->hasPropertyByName( rName ) )
+ m_pPropertyListener->addInterface( rName,Listener );
}
}
@@ -423,8 +423,8 @@ BaseContent::removePropertiesChangeListener( const Sequence< OUString >& Propert
if( ! m_pPropertyListener )
return;
- for( sal_Int32 i = 0; i < PropertyNames.getLength(); ++i )
- m_pPropertyListener->removeInterface( PropertyNames[i],Listener );
+ for( const auto& rName : PropertyNames )
+ m_pPropertyListener->removeInterface( rName,Listener );
m_pPropertyListener->removeInterface( OUString(), Listener );
}
@@ -762,12 +762,12 @@ BaseContent::setPropertyValues(
// Special handling for files which have to be inserted
if( m_nState & JustInserted )
{
- for( sal_Int32 i = 0; i < Values.getLength(); ++i )
+ for( const auto& rValue : Values )
{
- if( Values[i].Name == Title )
+ if( rValue.Name == Title )
{
OUString NewTitle;
- if( Values[i].Value >>= NewTitle )
+ if( rValue.Value >>= NewTitle )
{
if ( m_nState & NameForInsertionSet )
{
@@ -1247,17 +1247,15 @@ BaseContent::cPCL()
std::unique_ptr<PropertyChangeNotifier> p;
- sal_Int32 length = seqNames.getLength();
-
- if( length )
+ if( seqNames.hasElements() )
{
std::unique_ptr<ListenerMap> listener(new ListenerMap);
- for( sal_Int32 i = 0; i < length; ++i )
+ for( const auto& rName : seqNames )
{
- cppu::OInterfaceContainerHelper* pContainer = m_pPropertyListener->getContainer(seqNames[i]);
+ cppu::OInterfaceContainerHelper* pContainer = m_pPropertyListener->getContainer(rName);
if (!pContainer)
continue;
- (*listener)[seqNames[i]] = pContainer->getElements();
+ (*listener)[rName] = pContainer->getElements();
}
p.reset( new PropertyChangeNotifier( this, std::move(listener) ) );
diff --git a/ucb/source/ucp/file/filcmd.cxx b/ucb/source/ucp/file/filcmd.cxx
index 5ab934799df7..c046051bcecd 100644
--- a/ucb/source/ucp/file/filcmd.cxx
+++ b/ucb/source/ucp/file/filcmd.cxx
@@ -83,9 +83,10 @@ CommandInfo SAL_CALL
XCommandInfo_impl::getCommandInfoByName(
const OUString& aName )
{
- for( sal_Int32 i = 0; i < m_pMyShell->m_sCommandInfo.getLength(); i++ )
- if( m_pMyShell->m_sCommandInfo[i].Name == aName )
- return m_pMyShell->m_sCommandInfo[i];
+ auto pCommand = std::find_if(m_pMyShell->m_sCommandInfo.begin(), m_pMyShell->m_sCommandInfo.end(),
+ [&aName](const CommandInfo& rCommand) { return rCommand.Name == aName; });
+ if (pCommand != m_pMyShell->m_sCommandInfo.end())
+ return *pCommand;
throw UnsupportedCommandException( THROW_WHERE );
}
@@ -95,9 +96,10 @@ CommandInfo SAL_CALL
XCommandInfo_impl::getCommandInfoByHandle(
sal_Int32 Handle )
{
- for( sal_Int32 i = 0; i < m_pMyShell->m_sCommandInfo.getLength(); ++i )
- if( m_pMyShell->m_sCommandInfo[i].Handle == Handle )
- return m_pMyShell->m_sCommandInfo[i];
+ auto pCommand = std::find_if(m_pMyShell->m_sCommandInfo.begin(), m_pMyShell->m_sCommandInfo.end(),
+ [&Handle](const CommandInfo& rCommand) { return rCommand.Handle == Handle; });
+ if (pCommand != m_pMyShell->m_sCommandInfo.end())
+ return *pCommand;
throw UnsupportedCommandException( THROW_WHERE );
}
@@ -107,11 +109,8 @@ sal_Bool SAL_CALL
XCommandInfo_impl::hasCommandByName(
const OUString& aName )
{
- for( sal_Int32 i = 0; i < m_pMyShell->m_sCommandInfo.getLength(); ++i )
- if( m_pMyShell->m_sCommandInfo[i].Name == aName )
- return true;
-
- return false;
+ return std::any_of(m_pMyShell->m_sCommandInfo.begin(), m_pMyShell->m_sCommandInfo.end(),
+ [&aName](const CommandInfo& rCommand) { return rCommand.Name == aName; });
}
@@ -119,11 +118,8 @@ sal_Bool SAL_CALL
XCommandInfo_impl::hasCommandByHandle(
sal_Int32 Handle )
{
- for( sal_Int32 i = 0; i < m_pMyShell->m_sCommandInfo.getLength(); ++i )
- if( m_pMyShell->m_sCommandInfo[i].Handle == Handle )
- return true;
-
- return false;
+ return std::any_of(m_pMyShell->m_sCommandInfo.begin(), m_pMyShell->m_sCommandInfo.end(),
+ [&Handle](const CommandInfo& rCommand) { return rCommand.Handle == Handle; });
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/ucb/source/ucp/file/filnot.cxx b/ucb/source/ucp/file/filnot.cxx
index ae659c4bceb3..6c199770e59b 100644
--- a/ucb/source/ucp/file/filnot.cxx
+++ b/ucb/source/ucp/file/filnot.cxx
@@ -210,20 +210,19 @@ PropertyChangeNotifier::~PropertyChangeNotifier()
void PropertyChangeNotifier::notifyPropertyChanged(
- const uno::Sequence< beans::PropertyChangeEvent >& Changes_ )
+ const uno::Sequence< beans::PropertyChangeEvent >& seqChanged )
{
- sal_Int32 j;
- uno::Sequence< beans::PropertyChangeEvent > Changes = Changes_;
+ uno::Sequence< beans::PropertyChangeEvent > Changes = seqChanged;
- for( j = 0; j < Changes.getLength(); ++j )
- Changes[j].Source = m_xCreatorContent;
+ for( auto& rChange : Changes )
+ rChange.Source = m_xCreatorContent;
// notify listeners for all Events
uno::Sequence< uno::Reference< uno::XInterface > > seqList = (*m_pListeners)[ OUString() ];
- for( j = 0; j < seqList.getLength(); ++j )
+ for( const auto& rListener : seqList )
{
- uno::Reference< beans::XPropertiesChangeListener > aListener( seqList[j],uno::UNO_QUERY );
+ uno::Reference< beans::XPropertiesChangeListener > aListener( rListener,uno::UNO_QUERY );
if( aListener.is() )
{
aListener->propertiesChange( Changes );
@@ -231,14 +230,14 @@ void PropertyChangeNotifier::notifyPropertyChanged(
}
uno::Sequence< beans::PropertyChangeEvent > seq(1);
- for( j = 0; j < Changes.getLength(); ++j )
+ for( const auto& rChange : Changes )
{
- seq[0] = Changes[j];
- seqList = (*m_pListeners)[ seq[0].PropertyName ];
+ seq[0] = rChange;
+ seqList = (*m_pListeners)[ rChange.PropertyName ];
- for( sal_Int32 i = 0; i < seqList.getLength(); ++i )
+ for( const auto& rListener : seqList )
{
- uno::Reference< beans::XPropertiesChangeListener > aListener( seqList[i],uno::UNO_QUERY );
+ uno::Reference< beans::XPropertiesChangeListener > aListener( rListener,uno::UNO_QUERY );
if( aListener.is() )
{
aListener->propertiesChange( seq );
diff --git a/ucb/source/ucp/file/filprp.cxx b/ucb/source/ucp/file/filprp.cxx
index 4226832e068f..400513035964 100644
--- a/ucb/source/ucp/file/filprp.cxx
+++ b/ucb/source/ucp/file/filprp.cxx
@@ -76,10 +76,12 @@ XPropertySetInfo_impl::~XPropertySetInfo_impl()
beans::Property SAL_CALL
XPropertySetInfo_impl::getPropertyByName( const OUString& aName )
{
- for( sal_Int32 i = 0; i < m_seq.getLength(); ++i )
- if( m_seq[i].Name == aName ) return m_seq[i];
+ auto pProp = std::find_if(m_seq.begin(), m_seq.end(),
+ [&aName](const beans::Property& rProp) { return rProp.Name == aName; });
+ if (pProp != m_seq.end())
+ return *pProp;
- throw beans::UnknownPropertyException( THROW_WHERE );
+ throw beans::UnknownPropertyException( THROW_WHERE );
}
@@ -93,9 +95,8 @@ XPropertySetInfo_impl::getProperties()
sal_Bool SAL_CALL
XPropertySetInfo_impl::hasPropertyByName( const OUString& aName )
{
- for( sal_Int32 i = 0; i < m_seq.getLength(); ++i )
- if( m_seq[i].Name == aName ) return true;
- return false;
+ return std::any_of(m_seq.begin(), m_seq.end(),
+ [&aName](const beans::Property& rProp) { return rProp.Name == aName; });
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/ucb/source/ucp/file/filrset.cxx b/ucb/source/ucp/file/filrset.cxx
index db6b756fd67c..9c3916844c1a 100644
--- a/ucb/source/ucp/file/filrset.cxx
+++ b/ucb/source/ucp/file/filrset.cxx
@@ -594,22 +594,22 @@ XResultSet_impl::getCapabilities()
uno::Reference< sdbc::XResultSetMetaData > SAL_CALL
XResultSet_impl::getMetaData()
{
- for ( sal_Int32 n = 0; n < m_sProperty.getLength(); ++n )
+ auto pProp = std::find_if(m_sProperty.begin(), m_sProperty.end(),
+ [](const beans::Property& rProp) { return rProp.Name == "Title"; });
+ if (pProp != m_sProperty.end())
{
- if ( m_sProperty.getConstArray()[ n ].Name == "Title" )
- {
- std::vector< ::ucbhelper::ResultSetColumnData >
- aColumnData( m_sProperty.getLength() );
- // @@@ #82177# - Determine correct value!
- aColumnData[ n ].isCaseSensitive = false;
-
- ::ucbhelper::ResultSetMetaData* p =
- new ::ucbhelper::ResultSetMetaData(
- m_pMyShell->m_xContext,
- m_sProperty,
- aColumnData );
- return uno::Reference< sdbc::XResultSetMetaData >( p );
- }
+ std::vector< ::ucbhelper::ResultSetColumnData >
+ aColumnData( m_sProperty.getLength() );
+ auto n = std::distance(m_sProperty.begin(), pProp);
+ // @@@ #82177# - Determine correct value!
+ aColumnData[ n ].isCaseSensitive = false;
+
+ ::ucbhelper::ResultSetMetaData* p =
+ new ::ucbhelper::ResultSetMetaData(
+ m_pMyShell->m_xContext,
+ m_sProperty,
+ aColumnData );
+ return uno::Reference< sdbc::XResultSetMetaData >( p );
}
::ucbhelper::ResultSetMetaData* p =
diff --git a/ucb/source/ucp/file/filtask.cxx b/ucb/source/ucp/file/filtask.cxx
index 656d84ca4e67..bb47d6e653ba 100644
--- a/ucb/source/ucp/file/filtask.cxx
+++ b/ucb/source/ucp/file/filtask.cxx
@@ -1099,18 +1099,16 @@ TaskManager::getv( sal_Int32 CommandId,
TaskManager::ContentMap::iterator it = m_aContent.find( aUnqPath );
commit( it,aFileStatus );
- TaskManager::PropertySet::iterator it1;
PropertySet& propset = it->second.properties;
- for( sal_Int32 i = 0; i < seq.getLength(); ++i )
- {
- MyProperty readProp( properties[i].Name );
- it1 = propset.find( readProp );
- if( it1 == propset.end() )
- seq[i] = uno::Any();
- else
- seq[i] = it1->getValue();
- }
+ std::transform(properties.begin(), properties.end(), seq.begin(),
+ [&propset](const beans::Property& rProp) -> uno::Any {
+ MyProperty readProp( rProp.Name );
+ auto it1 = propset.find( readProp );
+ if( it1 == propset.end() )
+ return uno::Any();
+ return it1->getValue();
+ });
}
XRow_impl* p = new XRow_impl( this,seq );
@@ -2154,28 +2152,28 @@ TaskManager::getMaskFromProperties(
const uno::Sequence< beans::Property >& seq )
{
n_Mask = 0;
- for(sal_Int32 j = 0; j < seq.getLength(); ++j) {
- if(seq[j].Name == Title)
+ for(const auto& rProp : seq) {
+ if(rProp.Name == Title)
n_Mask |= osl_FileStatus_Mask_FileName;
- else if(seq[j].Name == CasePreservingURL)
+ else if(rProp.Name == CasePreservingURL)
n_Mask |= osl_FileStatus_Mask_FileURL;
- else if(seq[j].Name == IsDocument ||
- seq[j].Name == IsFolder ||
- seq[j].Name == IsVolume ||
- seq[j].Name == IsRemoveable ||
- seq[j].Name == IsRemote ||
- seq[j].Name == IsCompactDisc ||
- seq[j].Name == IsFloppy ||
- seq[j].Name == ContentType)
+ else if(rProp.Name == IsDocument ||
+ rProp.Name == IsFolder ||
+ rProp.Name == IsVolume ||
+ rProp.Name == IsRemoveable ||
+ rProp.Name == IsRemote ||
+ rProp.Name == IsCompactDisc ||
+ rProp.Name == IsFloppy ||
+ rProp.Name == ContentType)
n_Mask |= (osl_FileStatus_Mask_Type | osl_FileStatus_Mask_LinkTargetURL);
- else if(seq[j].Name == Size)
+ else if(rProp.Name == Size)
n_Mask |= (osl_FileStatus_Mask_FileSize |
osl_FileStatus_Mask_Type |
osl_FileStatus_Mask_LinkTargetURL);
- else if(seq[j].Name == IsHidden ||
- seq[j].Name == IsReadOnly)
+ else if(rProp.Name == IsHidden ||
+ rProp.Name == IsReadOnly)
n_Mask |= osl_FileStatus_Mask_Attributes;
- else if(seq[j].Name == DateModified)
+ else if(rProp.Name == DateModified)
n_Mask |= osl_FileStatus_Mask_ModifyTime;
}
}
@@ -2215,15 +2213,15 @@ TaskManager::load( const ContentMap::iterator& it, bool create )
PropertySet& properties = it->second.properties;
uno::Sequence< beans::Property > seq = xS->getPropertySetInfo()->getProperties();
- for( sal_Int32 i = 0; i < seq.getLength(); ++i )
+ for( const auto& rProp : seq )
{
MyProperty readProp( false,
- seq[i].Name,
- seq[i].Handle,
- seq[i].Type,
- xS->getPropertyValue( seq[i].Name ),
+ rProp.Name,
+ rProp.Handle,
+ rProp.Type,
+ xS->getPropertyValue( rProp.Name ),
beans::PropertyState_DIRECT_VALUE,
- seq[i].Attributes );
+ rProp.Attributes );
properties.insert( readProp );
}
}
@@ -2524,18 +2522,16 @@ TaskManager::getv(
TaskManager::ContentMap::iterator it = m_aContent.find( aUnqPath );
commit( it,aFileStatus );
- TaskManager::PropertySet::iterator it1;
PropertySet& propset = it->second.properties;
- for( sal_Int32 i = 0; i < seq.getLength(); ++i )
- {
- MyProperty readProp( properties[i].Name );
- it1 = propset.find( readProp );
- if( it1 == propset.end() )
- seq[i] = uno::Any();
- else
- seq[i] = it1->getValue();
- }
+ std::transform(properties.begin(), properties.end(), seq.begin(),
+ [&propset](const beans::Property& rProp) -> uno::Any {
+ MyProperty readProp( rProp.Name );
+ auto it1 = propset.find( readProp );
+ if( it1 == propset.end() )
+ return uno::Any();
+ return it1->getValue();
+ });
}
deregisterNotifier( aUnqPath,pNotifier );
diff --git a/ucb/source/ucp/file/prov.cxx b/ucb/source/ucp/file/prov.cxx
index 368876d90540..c222655f4b73 100644
--- a/ucb/source/ucp/file/prov.cxx
+++ b/ucb/source/ucp/file/prov.cxx
@@ -346,9 +346,10 @@ XPropertySetInfoImpl2::queryInterface( const Type& rType )
Property SAL_CALL
XPropertySetInfoImpl2::getPropertyByName( const OUString& aName )
{
- for( sal_Int32 i = 0; i < m_seq.getLength(); ++i )
- if( m_seq[i].Name == aName )
- return m_seq[i];
+ auto pProp = std::find_if(m_seq.begin(), m_seq.end(),
+ [&aName](const Property& rProp) { return rProp.Name == aName; });
+ if (pProp != m_seq.end())
+ return *pProp;
throw UnknownPropertyException( THROW_WHERE );
}
@@ -365,10 +366,8 @@ sal_Bool SAL_CALL
XPropertySetInfoImpl2::hasPropertyByName(
const OUString& aName )
{
- for( sal_Int32 i = 0; i < m_seq.getLength(); ++i )
- if( m_seq[i].Name == aName )
- return true;
- return false;
+ return std::any_of(m_seq.begin(), m_seq.end(),
+ [&aName](const Property& rProp) { return rProp.Name == aName; });
}
diff --git a/ucb/source/ucp/ftp/ftpcontent.cxx b/ucb/source/ucp/ftp/ftpcontent.cxx
index 93cf2bf2b82f..937ebb7a3ce6 100644
--- a/ucb/source/ucp/ftp/ftpcontent.cxx
+++ b/ucb/source/ucp/ftp/ftpcontent.cxx
@@ -731,41 +731,41 @@ Reference< XRow > FTPContent::getPropertyValues(
FTPDirentry aDirEntry = m_aFTPURL.direntry();
- for(sal_Int32 i = 0; i < seqProp.getLength(); ++i) {
- const OUString& Name = seqProp[i].Name;
+ for(const auto& rProp : seqProp) {
+ const OUString& Name = rProp.Name;
if(Name == "Title")
- xRow->appendString(seqProp[i],aDirEntry.m_aName);
+ xRow->appendString(rProp,aDirEntry.m_aName);
else if(Name == "CreatableContentsInfo")
- xRow->appendObject(seqProp[i],
+ xRow->appendObject(rProp,
makeAny(queryCreatableContentsInfo()));
else if(aDirEntry.m_nMode != INETCOREFTP_FILEMODE_UNKNOWN) {
if(Name == "ContentType")
- xRow->appendString(seqProp[i],
+ xRow->appendString(rProp,
(aDirEntry.m_nMode & INETCOREFTP_FILEMODE_ISDIR)
? OUString(FTP_FOLDER)
: OUString(FTP_FILE) );
else if(Name == "IsReadOnly")
- xRow->appendBoolean(seqProp[i],
+ xRow->appendBoolean(rProp,
(aDirEntry.m_nMode
& INETCOREFTP_FILEMODE_WRITE) == 0 );
else if(Name == "IsDocument")
- xRow->appendBoolean(seqProp[i],
+ xRow->appendBoolean(rProp,
(aDirEntry.m_nMode &
INETCOREFTP_FILEMODE_ISDIR) != INETCOREFTP_FILEMODE_ISDIR);
else if(Name == "IsFolder")
- xRow->appendBoolean(seqProp[i],
+ xRow->appendBoolean(rProp,
(aDirEntry.m_nMode &
INETCOREFTP_FILEMODE_ISDIR) == INETCOREFTP_FILEMODE_ISDIR);
else if(Name == "Size")
- xRow->appendLong(seqProp[i],
+ xRow->appendLong(rProp,
aDirEntry.m_nSize);
else if(Name == "DateCreated")
- xRow->appendTimestamp(seqProp[i],
+ xRow->appendTimestamp(rProp,
aDirEntry.m_aDate);
else
- xRow->appendVoid(seqProp[i]);
+ xRow->appendVoid(rProp);
} else
- xRow->appendVoid(seqProp[i]);
+ xRow->appendVoid(rProp);
}
return Reference<XRow>(xRow.get());
@@ -817,16 +817,17 @@ Sequence<Any> FTPContent::setPropertyValues(
// either unknown or read-only
ret[i] <<= UnknownPropertyException();
- for(sal_Int32 j = 0; j < props.getLength(); ++j)
- if(props[j].Name == seqPropVal[i].Name) {
- ret[i] <<= IllegalAccessException(
- "Property is read-only!",
- //props[j].Attributes & PropertyAttribute::READONLY
- // ? "Property is read-only!"
- // : "Access denied!"),
- static_cast< cppu::OWeakObject * >( this ));
- break;
- }
+ const auto& rName = seqPropVal[i].Name;
+ auto pProp = std::find_if(props.begin(), props.end(),
+ [&rName](const Property& rProp) { return rProp.Name == rName; });
+ if (pProp != props.end()) {
+ ret[i] <<= IllegalAccessException(
+ "Property is read-only!",
+ //props[j].Attributes & PropertyAttribute::READONLY
+ // ? "Property is read-only!"
+ // : "Access denied!"),
+ static_cast< cppu::OWeakObject * >( this ));
+ }
}
}
diff --git a/ucb/source/ucp/ftp/ftpresultsetI.cxx b/ucb/source/ucp/ftp/ftpresultsetI.cxx
index a6163aaa4f2b..6ef79b786e04 100644
--- a/ucb/source/ucp/ftp/ftpresultsetI.cxx
+++ b/ucb/source/ucp/ftp/ftpresultsetI.cxx
@@ -55,37 +55,37 @@ ResultSetI::ResultSetI(const Reference<XComponentContext>& rxContext,
rtl::Reference<ucbhelper::PropertyValueSet> xRow =
new ucbhelper::PropertyValueSet(rxContext);
- for( int i = 0; i < seqProp.getLength(); ++i) {
- const OUString& Name = seqProp[i].Name;
+ for( const auto& rProp : seqProp) {
+ const OUString& Name = rProp.Name;
if(Name == "ContentType")
- xRow->appendString(seqProp[i],
+ xRow->appendString(rProp,
OUString( "application/ftp" ));
else if(Name == "Title")
- xRow->appendString(seqProp[i],dirvec[n].m_aName);
+ xRow->appendString(rProp,dirvec[n].m_aName);
else if(Name == "IsReadOnly")
- xRow->appendBoolean(seqProp[i],
+ xRow->appendBoolean(rProp,
(dirvec[n].m_nMode &
INETCOREFTP_FILEMODE_WRITE) == INETCOREFTP_FILEMODE_WRITE);
else if(Name == "IsDocument")
- xRow->appendBoolean(seqProp[i],
+ xRow->appendBoolean(rProp,
(dirvec[n].m_nMode &
INETCOREFTP_FILEMODE_ISDIR) != INETCOREFTP_FILEMODE_ISDIR);
else if(Name == "IsFolder")
- xRow->appendBoolean(seqProp[i],
+ xRow->appendBoolean(rProp,
( dirvec[n].m_nMode &
INETCOREFTP_FILEMODE_ISDIR) == INETCOREFTP_FILEMODE_ISDIR);
else if(Name == "Size")
- xRow->appendLong(seqProp[i],
+ xRow->appendLong(rProp,
dirvec[n].m_nSize);
else if(Name == "DateCreated")
- xRow->appendTimestamp(seqProp[i],
+ xRow->appendTimestamp(rProp,
dirvec[n].m_aDate);
else if(Name == "CreatableContentsInfo")
xRow->appendObject(
- seqProp[i],
+ rProp,
makeAny(FTPContent::queryCreatableContentsInfo_Static()));
else
- xRow->appendVoid(seqProp[i]);
+ xRow->appendVoid(rProp);
}
m_aItems[n].set(xRow.get());
}
diff --git a/ucb/source/ucp/ftp/ftpresultsetbase.cxx b/ucb/source/ucp/ftp/ftpresultsetbase.cxx
index 83aa79ea82e3..e18e14212103 100644
--- a/ucb/source/ucp/ftp/ftpresultsetbase.cxx
+++ b/ucb/source/ucp/ftp/ftpresultsetbase.cxx
@@ -376,18 +376,17 @@ public:
beans::Property SAL_CALL getPropertyByName( const OUString& aName ) override
{
- for( int i = 0; i < m_aSeq.getLength(); ++i )
- if( aName == m_aSeq[i].Name )
- return m_aSeq[i];
+ auto pProp = std::find_if(m_aSeq.begin(), m_aSeq.end(),
+ [&aName](const beans::Property& rProp) { return aName == rProp.Name; });
+ if (pProp != m_aSeq.end())
+ return *pProp;
throw beans::UnknownPropertyException();
}
sal_Bool SAL_CALL hasPropertyByName( const OUString& Name ) override
{
- for( int i = 0; i < m_aSeq.getLength(); ++i )
- if( Name == m_aSeq[i].Name )
- return true;
- return false;
+ return std::any_of(m_aSeq.begin(), m_aSeq.end(),
+ [&Name](const beans::Property& rProp) { return Name == rProp.Name; });
}
private:
diff --git a/ucb/source/ucp/gio/gio_content.cxx b/ucb/source/ucp/gio/gio_content.cxx
index 841a19980824..f24fd29d132c 100644
--- a/ucb/source/ucp/gio/gio_content.cxx
+++ b/ucb/source/ucp/gio/gio_content.cxx
@@ -445,17 +445,9 @@ css::uno::Reference< css::sdbc::XRow > Content::getPropertyValues(
{
rtl::Reference< ::ucbhelper::PropertyValueSet > xRow = new ::ucbhelper::PropertyValueSet( m_xContext );
- sal_Int32 nProps;
- const css::beans::Property* pProps;
-
- nProps = rProperties.getLength();
- pProps = rProperties.getConstArray();
-
GFileInfo *pInfo = nullptr;
- for( sal_Int32 n = 0; n < nProps; ++n )
+ for( const css::beans::Property& rProp : rProperties )
{
- const css::beans::Property& rProp = pProps[ n ];
-
if ( rProp.Name == "IsDocument" )
{
getFileInfo(xEnv, &pInfo, true);
diff --git a/ucb/source/ucp/hierarchy/hierarchycontent.cxx b/ucb/source/ucp/hierarchy/hierarchycontent.cxx
index 923225a1df90..65051e16c193 100644
--- a/ucb/source/ucp/hierarchy/hierarchycontent.cxx
+++ b/ucb/source/ucp/hierarchy/hierarchycontent.cxx
@@ -63,6 +63,7 @@
#include <com/sun/star/uno/Any.hxx>
#include <com/sun/star/uno/Sequence.hxx>
#include <comphelper/propertysequence.hxx>
+#include <comphelper/sequence.hxx>
#include <cppuhelper/queryinterface.hxx>
#include <ucbhelper/contentidentifier.hxx>
#include <ucbhelper/propertyvalueset.hxx>
@@ -685,15 +686,7 @@ bool HierarchyContent::isReadOnly()
{
uno::Sequence< OUString > aNames
= xConfigProv->getAvailableServiceNames();
- sal_Int32 nCount = aNames.getLength();
- for ( sal_Int32 n = 0; n < nCount; ++n )
- {
- if ( aNames[ n ] == "com.sun.star.ucb.HierarchyDataReadWriteAccess" )
- {
- m_bIsReadOnly = false;
- break;
- }
- }
+ m_bIsReadOnly = comphelper::findValue(aNames, "com.sun.star.ucb.HierarchyDataReadWriteAccess") == -1;
}
}
}
@@ -851,17 +844,13 @@ uno::Reference< sdbc::XRow > HierarchyContent::getPropertyValues(
rtl::Reference< ::ucbhelper::PropertyValueSet > xRow
= new ::ucbhelper::PropertyValueSet( rxContext );
- sal_Int32 nCount = rProperties.getLength();
- if ( nCount )
+ if ( rProperties.hasElements() )
{
uno::Reference< beans::XPropertySet > xAdditionalPropSet;
bool bTriedToGetAdditionalPropSet = false;
- const beans::Property* pProps = rProperties.getConstArray();
- for ( sal_Int32 n = 0; n < nCount; ++n )
+ for ( const beans::Property& rProp : rProperties )
{
- const beans::Property& rProp = pProps[ n ];
-
// Process Core properties.
if ( rProp.Name == "ContentType" )
diff --git a/ucb/source/ucp/package/pkgcontent.cxx b/ucb/source/ucp/package/pkgcontent.cxx
index dba85a3a9d30..85cb0b16d3c8 100644
--- a/ucb/source/ucp/package/pkgcontent.cxx
+++ b/ucb/source/ucp/package/pkgcontent.cxx
@@ -714,13 +714,8 @@ uno::Reference< sdbc::XRow > Content::getPropertyValues(
rtl::Reference< ::ucbhelper::PropertyValueSet > xRow
= new ::ucbhelper::PropertyValueSet( rxContext );
- sal_Int32 nCount = rProperties.getLength();
- if ( nCount )
- {
- const beans::Property* pProps = rProperties.getConstArray();
- for ( sal_Int32 n = 0; n < nCount; ++n )
- xRow->appendVoid( pProps[ n ] );
- }
+ for ( const beans::Property& rProp : rProperties )
+ xRow->appendVoid( rProp );
return uno::Reference< sdbc::XRow >( xRow.get() );
}
@@ -741,17 +736,13 @@ uno::Reference< sdbc::XRow > Content::getPropertyValues(
rtl::Reference< ::ucbhelper::PropertyValueSet > xRow
= new ::ucbhelper::PropertyValueSet( rxContext );
- sal_Int32 nCount = rProperties.getLength();
- if ( nCount )
+ if ( rProperties.hasElements() )
{
uno::Reference< beans::XPropertySet > xAdditionalPropSet;
bool bTriedToGetAdditionalPropSet = false;
- const beans::Property* pProps = rProperties.getConstArray();
- for ( sal_Int32 n = 0; n < nCount; ++n )
+ for ( const beans::Property& rProp : rProperties )
{
- const beans::Property& rProp = pProps[ n ];
-
// Process Core properties.
if ( rProp.Name == "ContentType" )
diff --git a/ucb/source/ucp/tdoc/tdoc_content.cxx b/ucb/source/ucp/tdoc/tdoc_content.cxx
index 9dd5b6e6ae98..8a693fbe133b 100644
--- a/ucb/source/ucp/tdoc/tdoc_content.cxx
+++ b/ucb/source/ucp/tdoc/tdoc_content.cxx
@@ -844,13 +844,8 @@ uno::Reference< sdbc::XRow > Content::getPropertyValues(
rtl::Reference< ::ucbhelper::PropertyValueSet > xRow
= new ::ucbhelper::PropertyValueSet( rxContext );
- sal_Int32 nCount = rProperties.getLength();
- if ( nCount )
- {
- const beans::Property* pProps = rProperties.getConstArray();
- for ( sal_Int32 n = 0; n < nCount; ++n )
- xRow->appendVoid( pProps[ n ] );
- }
+ for ( const beans::Property& rProp : rProperties )
+ xRow->appendVoid( rProp );
return uno::Reference< sdbc::XRow >( xRow.get() );
}
@@ -870,17 +865,13 @@ uno::Reference< sdbc::XRow > Content::getPropertyValues(
rtl::Reference< ::ucbhelper::PropertyValueSet > xRow
= new ::ucbhelper::PropertyValueSet( rxContext );
- sal_Int32 nCount = rProperties.getLength();
- if ( nCount )
+ if ( rProperties.hasElements() )
{
uno::Reference< beans::XPropertySet > xAdditionalPropSet;
bool bTriedToGetAdditionalPropSet = false;
- const beans::Property* pProps = rProperties.getConstArray();
- for ( sal_Int32 n = 0; n < nCount; ++n )
+ for ( const beans::Property& rProp : rProperties )
{
- const beans::Property& rProp = pProps[ n ];
-
// Process Core properties.
if ( rProp.Name == "ContentType" )
diff --git a/ucb/source/ucp/webdav-neon/ContentProperties.cxx b/ucb/source/ucp/webdav-neon/ContentProperties.cxx
index c13f0ed0b550..12bbf4f740cd 100644
--- a/ucb/source/ucp/webdav-neon/ContentProperties.cxx
+++ b/ucb/source/ucp/webdav-neon/ContentProperties.cxx
@@ -222,11 +222,8 @@ void ContentProperties::UCBNamesToDAVNames(
bool bContentLength = false;
bool bResourceType = false;
- sal_Int32 nCount = rProps.getLength();
- for ( sal_Int32 n = 0; n < nCount; ++n )
+ for ( const beans::Property & rProp : rProps )
{
- const beans::Property & rProp = rProps[ n ];
-
if ( rProp.Name == "Title" )
{
// Title is always obtained from resource's URI.
@@ -295,11 +292,8 @@ void ContentProperties::UCBNamesToHTTPNames(
// Content-Type <- MediaType
// Content-Length <- Size
- sal_Int32 nCount = rProps.getLength();
- for ( sal_Int32 n = 0; n < nCount; ++n )
+ for ( const beans::Property & rProp : rProps )
{
- const beans::Property & rProp = rProps[ n ];
-
if ( rProp.Name == "DateModified" )
{
propertyNames.emplace_back("Last-Modified" );
@@ -326,10 +320,9 @@ bool ContentProperties::containsAllNames(
{
rNamesNotContained.clear();
- sal_Int32 nCount = rProps.getLength();
- for ( sal_Int32 n = 0; n < nCount; ++n )
+ for ( const auto& rProp : rProps )
{
- const OUString & rName = rProps[ n ].Name;
+ const OUString & rName = rProp.Name;
if ( !contains( rName ) )
{
// Not found.
diff --git a/ucb/source/ucp/webdav-neon/DAVResourceAccess.cxx b/ucb/source/ucp/webdav-neon/DAVResourceAccess.cxx
index bf1004a9e411..905c78518a5f 100644
--- a/ucb/source/ucp/webdav-neon/DAVResourceAccess.cxx
+++ b/ucb/source/ucp/webdav-neon/DAVResourceAccess.cxx
@@ -1084,11 +1084,11 @@ void DAVResourceAccess::getUserRequestHeaders(
uno::Sequence< beans::StringPair > aRequestHeaders
= xDAVEnv->getUserRequestHeaders( rURI, eMethod );
- for ( sal_Int32 n = 0; n < aRequestHeaders.getLength(); ++n )
+ for ( const auto& rRequestHeader : aRequestHeaders )
{
rRequestHeaders.emplace_back(
- aRequestHeaders[ n ].First,
- aRequestHeaders[ n ].Second );
+ rRequestHeader.First,
+ rRequestHeader.Second );
}
}
}
diff --git a/ucb/source/ucp/webdav-neon/LinkSequence.cxx b/ucb/source/ucp/webdav-neon/LinkSequence.cxx
index da0bd63aebd1..fc9e29851be0 100644
--- a/ucb/source/ucp/webdav-neon/LinkSequence.cxx
+++ b/ucb/source/ucp/webdav-neon/LinkSequence.cxx
@@ -197,20 +197,15 @@ bool LinkSequence::toXML( const uno::Sequence< ucb::Link > & rInData,
{
// <link><src>value</src><dst>value</dst></link><link><src>....
- sal_Int32 nCount = rInData.getLength();
- if ( nCount )
+ for ( const auto& rLink : rInData )
{
- for ( sal_Int32 n = 0; n < nCount; ++n )
- {
- rOutData += "<link><src>";
- rOutData += rInData[ n ].Source;
- rOutData += "</src><dst>";
- rOutData += rInData[ n ].Destination;
- rOutData += "</dst></link>";
- }
- return true;
+ rOutData += "<link><src>";
+ rOutData += rLink.Source;
+ rOutData += "</src><dst>";
+ rOutData += rLink.Destination;
+ rOutData += "</dst></link>";
}
- return false;
+ return rInData.hasElements();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/ucb/source/ucp/webdav-neon/NeonSession.cxx b/ucb/source/ucp/webdav-neon/NeonSession.cxx
index 667d24b05351..a075268806c8 100644
--- a/ucb/source/ucp/webdav-neon/NeonSession.cxx
+++ b/ucb/source/ucp/webdav-neon/NeonSession.cxx
@@ -146,12 +146,10 @@ static bool noKeepAlive( const uno::Sequence< beans::NamedValue >& rFlags )
return false;
// find "KeepAlive" property
- const beans::NamedValue* pAry(rFlags.getConstArray());
- const sal_Int32 nLen(rFlags.getLength());
const beans::NamedValue* pValue(
- std::find_if(pAry,pAry+nLen,
+ std::find_if(rFlags.begin(), rFlags.end(),
[] (beans::NamedValue const& rNV) { return rNV.Name == "KeepAlive"; } ));
- return pValue != pAry+nLen && !pValue->Value.get<bool>();
+ return pValue != rFlags.end() && !pValue->Value.get<bool>();
}
struct NeonRequestContext
@@ -1773,17 +1771,11 @@ namespace {
bool containsLocktoken( const uno::Sequence< ucb::Lock > & rLocks,
const char * token )
{
- for ( sal_Int32 n = 0; n < rLocks.getLength(); ++n )
- {
- const uno::Sequence< OUString > & rTokens
- = rLocks[ n ].LockTokens;
- for ( sal_Int32 m = 0; m < rTokens.getLength(); ++m )
- {
- if ( rTokens[ m ].equalsAscii( token ) )
- return true;
- }
- }
- return false;
+ return std::any_of(rLocks.begin(), rLocks.end(), [&token](const ucb::Lock& rLock) {
+ const uno::Sequence< OUString > & rTokens = rLock.LockTokens;
+ return std::any_of(rTokens.begin(), rTokens.end(),
+ [&token](const OUString& rToken) { return rToken.equalsAscii( token ); });
+ });
}
} // namespace
diff --git a/ucb/source/ucp/webdav-neon/webdavcontent.cxx b/ucb/source/ucp/webdav-neon/webdavcontent.cxx
index bd05e53fd880..25941bce6c13 100644
--- a/ucb/source/ucp/webdav-neon/webdavcontent.cxx
+++ b/ucb/source/ucp/webdav-neon/webdavcontent.cxx
@@ -1195,17 +1195,13 @@ uno::Reference< sdbc::XRow > Content::getPropertyValues(
rtl::Reference< ::ucbhelper::PropertyValueSet > xRow
= new ::ucbhelper::PropertyValueSet( rxContext );
- sal_Int32 nCount = rProperties.getLength();
- if ( nCount )
+ if ( rProperties.hasElements() )
{
uno::Reference< beans::XPropertySet > xAdditionalPropSet;
bool bTriedToGetAdditionalPropSet = false;
- const beans::Property* pProps = rProperties.getConstArray();
- for ( sal_Int32 n = 0; n < nCount; ++n )
+ for ( const beans::Property& rProp : rProperties )
{
- const beans::Property& rProp = pProps[ n ];
-
// Process standard UCB, DAV and HTTP properties.
const uno::Any & rValue = rData.getValue( rProp.Name );
if ( rValue.hasValue() )
@@ -1378,12 +1374,8 @@ uno::Reference< sdbc::XRow > Content::getPropertyValues(
if ( !m_aFailedPropNames.empty() )
{
- sal_Int32 nProps = 0;
- sal_Int32 nCount = rProperties.getLength();
- for ( sal_Int32 n = 0; n < nCount; ++n, ++nProps )
- {
- aProperties[ nProps ] = rProperties[ n ];
- }
+ sal_Int32 nProps = rProperties.getLength();
+ std::copy(rProperties.begin(), rProperties.end(), aProperties.begin());
aProperties.realloc( nProps );
}
@@ -1659,10 +1651,9 @@ uno::Reference< sdbc::XRow > Content::getPropertyValues(
}
}
- sal_Int32 nCount = rProperties.getLength();
- for ( sal_Int32 n = 0; n < nCount; ++n )
+ for ( const auto& rProperty : rProperties )
{
- const OUString rName = rProperties[ n ].Name;
+ const OUString rName = rProperty.Name;
if ( rName == "BaseURI" )
{
// Add BaseURI property, if requested.
@@ -2969,11 +2960,11 @@ Content::ResourceType Content::resourceTypeForLocks(
if ( m_xCachedProps->getValue( DAVProperties::SUPPORTEDLOCK )
>>= aSupportedLocks ) //get the cached value for supportedlock
{
- for ( sal_Int32 n = 0; n < aSupportedLocks.getLength(); ++n )
+ for ( const auto& rSupportedLock : aSupportedLocks )
{
- if ( aSupportedLocks[ n ].Scope
+ if ( rSupportedLock.Scope
== ucb::LockScope_EXCLUSIVE &&
- aSupportedLocks[ n ].Type
+ rSupportedLock.Type
== ucb::LockType_WRITE )
eResourceTypeForLocks = DAV;
}
@@ -3040,20 +3031,20 @@ Content::ResourceType Content::resourceTypeForLocks(
uno::Sequence< ucb::LockEntry > aSupportedLocks;
if ( rProp.Value >>= aSupportedLocks )
{
- for ( sal_Int32 n = 0; n < aSupportedLocks.getLength(); ++n )
+ bool isSupported = std::any_of(aSupportedLocks.begin(), aSupportedLocks.end(),
+ [](const ucb::LockEntry& rLock) {
+ // TODO: if the lock type is changed from 'exclusive write' to 'shared write'
+ // e.g. to implement 'Calc shared file feature', the ucb::LockScope_EXCLUSIVE
+ // value should be checked as well, adaptation the code may be needed
+ return rLock.Scope == ucb::LockScope_EXCLUSIVE
+ && rLock.Type == ucb::LockType_WRITE;
+ });
+ if (isSupported)
{
- // TODO: if the lock type is changed from 'exclusive write' to 'shared write'
- // e.g. to implement 'Calc shared file feature', the ucb::LockScope_EXCLUSIVE
- // value should be checked as well, adaptation the code may be needed
- if ( aSupportedLocks[ n ].Scope == ucb::LockScope_EXCLUSIVE &&
- aSupportedLocks[ n ].Type == ucb::LockType_WRITE )
- {
- // requested locking mode is supported
- eResourceTypeForLocks = DAV;
- SAL_INFO( "ucb.ucp.webdav", "resourceTypeForLocks - URL: <"
- << m_xIdentifier->getContentIdentifier() << ">, DAV lock/unlock supported");
- break;
- }
+ // requested locking mode is supported
+ eResourceTypeForLocks = DAV;
+ SAL_INFO( "ucb.ucp.webdav", "resourceTypeForLocks - URL: <"
+ << m_xIdentifier->getContentIdentifier() << ">, DAV lock/unlock supported");
}
break;
}