idl/inc/object.hxx | 2 +- idl/source/objects/object.cxx | 38 ++++++++++++++------------------------ 2 files changed, 15 insertions(+), 25 deletions(-)
New commits: commit 67594344631c362d43b9d6a0cfadefbcfa5046d8 Author: Yli875 <qq3202390...@gmail.com> AuthorDate: Tue Sep 12 11:58:54 2023 -0700 Commit: Ilmari Lauhakangas <ilmari.lauhakan...@libreoffice.org> CommitDate: Tue Oct 3 22:08:54 2023 +0200 tdf#145538 Use range based for loops in idl:object Change-Id: I7c9935254be5bea050a09859cebbc4112894999b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156858 Tested-by: Jenkins Tested-by: Ilmari Lauhakangas <ilmari.lauhakan...@libreoffice.org> Reviewed-by: Ilmari Lauhakangas <ilmari.lauhakan...@libreoffice.org> diff --git a/idl/inc/object.hxx b/idl/inc/object.hxx index b5c30c9e0247..4254a4e1f318 100644 --- a/idl/inc/object.hxx +++ b/idl/inc/object.hxx @@ -80,7 +80,7 @@ public: virtual void ReadContextSvIdl( SvIdlDataBase &, SvTokenStream & rInStm ) override; - void FillClasses( SvMetaClassList & rList ); + void FillClasses( SvMetaClassList & rClassList ); virtual void WriteSfx( SvIdlDataBase & rBase, SvStream & rOutStm ) override; }; diff --git a/idl/source/objects/object.cxx b/idl/source/objects/object.cxx index 8f207ca5ac04..4f3a0836791d 100644 --- a/idl/source/objects/object.cxx +++ b/idl/source/objects/object.cxx @@ -138,9 +138,8 @@ sal_uInt16 SvMetaClass::WriteSlotParamArray( SvIdlDataBase & rBase, SvStream & rOutStm ) { sal_uInt16 nCount = 0; - for ( size_t i = 0, n = rSlotList.size(); i < n; ++i ) + for ( const auto& pAttr : rSlotList ) { - SvMetaSlot *pAttr = rSlotList[ i ]; nCount = nCount + pAttr->WriteSlotParamArray( rBase, rOutStm ); } @@ -169,18 +168,14 @@ void SvMetaClass::InsertSlots( SvSlotElementList& rList, std::vector<sal_uInt32> const OString& rPrefix, SvIdlDataBase& rBase) { // was this class already written? - for ( size_t i = 0, n = rClassList.size(); i < n ; ++i ) - if ( rClassList[ i ] == this ) - return; + if ( std::find( rClassList.begin(), rClassList.end(), this ) != rClassList.end() ) + return; rClassList.push_back( this ); // write all direct attributes - size_t n; - for( n = 0; n < aAttrList.size(); n++ ) + for( const auto& pAttr : aAttrList ) { - SvMetaAttribute * pAttr = aAttrList[n]; - sal_uInt32 nId = pAttr->GetSlotId().GetValue(); std::vector<sal_uInt32>::iterator iter = std::find(rSuperList.begin(), @@ -204,9 +199,8 @@ void SvMetaClass::InsertSlots( SvSlotElementList& rList, std::vector<sal_uInt32> // Write all attributes of the imported classes, as long as they have // not already been imported by the superclass. - for( n = 0; n < aClassElementList.size(); n++ ) + for( auto& rElement : aClassElementList ) { - SvClassElement& rElement = aClassElementList[n]; SvMetaClass * pCl = rElement.GetClass(); OStringBuffer rPre(rPrefix.getLength() + 1 + rElement.GetPrefix().getLength()); rPre.append(rPrefix); @@ -226,26 +220,24 @@ void SvMetaClass::InsertSlots( SvSlotElementList& rList, std::vector<sal_uInt32> } } -void SvMetaClass::FillClasses( SvMetaClassList & rList ) +void SvMetaClass::FillClasses( SvMetaClassList & rClassList ) { // Am I not yet in? - for ( size_t i = 0, n = rList.size(); i < n; ++i ) - if ( rList[ i ] == this ) - return; + if ( std::find( rClassList.begin(), rClassList.end(), this ) != rClassList.end() ) + return; - rList.push_back( this ); + rClassList.push_back( this ); // my imports - for( size_t n = 0; n < aClassElementList.size(); n++ ) + for( auto& rElement : aClassElementList ) { - SvClassElement& rElement = aClassElementList[n]; SvMetaClass * pCl = rElement.GetClass(); - pCl->FillClasses( rList ); + pCl->FillClasses( rClassList ); } // my superclass if( aSuperClass.is() ) - aSuperClass->FillClasses( rList ); + aSuperClass->FillClasses( rClassList ); } @@ -255,9 +247,8 @@ void SvMetaClass::WriteSlotStubs( std::string_view rShellName, SvStream & rOutStm ) { // write all attributes - for ( size_t i = 0, n = rSlotList.size(); i < n; ++i ) + for ( const auto& pAttr : rSlotList ) { - SvMetaSlot *pAttr = rSlotList[ i ]; pAttr->WriteSlotStubs( rShellName, rList, rOutStm ); } } @@ -334,9 +325,8 @@ void SvMetaClass::WriteSfx( SvIdlDataBase & rBase, SvStream & rOutStm ) rOutStm.WriteOString( "};" ) << endl; rOutStm.WriteOString( "#endif" ) << endl << endl; - for( size_t i = 0, n = aSlotList.size(); i < n; ++i ) + for( auto& pAttr : aSlotList ) { - SvMetaSlot* pAttr = aSlotList[ i ]; pAttr->ResetSlotPointer(); }