shell/source/cmdmail/cmdmailsuppl.cxx | 15 - slideshow/source/engine/activities/activitiesfactory.cxx | 4 slideshow/source/engine/opengl/TransitionerImpl.cxx | 93 ++---- slideshow/source/engine/shapes/shapeimporter.cxx | 7 slideshow/source/engine/slide/slideimpl.cxx | 16 - slideshow/source/engine/tools.cxx | 6 sot/source/sdstor/ucbstorage.cxx | 12 sot/source/unoolestorage/xolesimplestorage.cxx | 8 starmath/source/cfgitem.cxx | 38 -- starmath/source/mathmlimport.cxx | 39 +- starmath/source/unomodel.cxx | 28 - stoc/Library_bootstrap.mk | 1 stoc/source/corereflection/criface.cxx | 8 stoc/source/defaultregistry/defaultregistry.cxx | 96 ------ stoc/source/implementationregistration/implreg.cxx | 215 ++++----------- stoc/source/inspect/introspection.cxx | 55 +-- stoc/source/invocation/invocation.cxx | 8 stoc/source/servicemanager/servicemanager.cxx | 50 +-- stoc/source/simpleregistry/simpleregistry.cxx | 18 - svgio/qa/cppunit/SvgImportTest.cxx | 14 20 files changed, 221 insertions(+), 510 deletions(-)
New commits: commit 6ffdc88e79904882e319bdd0b901e7491abae0b3 Author: Arkadiy Illarionov <qar...@gmail.com> AuthorDate: Sat Jul 20 20:03:15 2019 +0300 Commit: Arkadiy Illarionov <qar...@gmail.com> CommitDate: Mon Jul 22 18:42:35 2019 +0200 Simplify Sequence iterations in shell..svgio Use range-based loops, STL and comphelper functions Change-Id: I612d36abcc09a91c60f7212de6747a1a1bdcfc69 Reviewed-on: https://gerrit.libreoffice.org/76056 Tested-by: Jenkins Reviewed-by: Arkadiy Illarionov <qar...@gmail.com> diff --git a/shell/source/cmdmail/cmdmailsuppl.cxx b/shell/source/cmdmail/cmdmailsuppl.cxx index 6a076a632806..b4e4322a2ff2 100644 --- a/shell/source/cmdmail/cmdmailsuppl.cxx +++ b/shell/source/cmdmail/cmdmailsuppl.cxx @@ -237,20 +237,18 @@ void SAL_CALL CmdMailSuppl::sendSimpleMailMessage( const Reference< XSimpleMailM // Append carbon copy recipients set in the message Sequence< OUString > aStringList = xSimpleMailMessage->getCcRecipient(); - sal_Int32 n, nmax = aStringList.getLength(); - for ( n = 0; n < nmax; n++ ) + for ( const auto& rString : aStringList ) { aBuffer.append(" --cc "); - appendShellWord(aBuffer, aStringList[n], false); + appendShellWord(aBuffer, rString, false); } // Append blind carbon copy recipients set in the message aStringList = xSimpleMailMessage->getBccRecipient(); - nmax = aStringList.getLength(); - for ( n = 0; n < nmax; n++ ) + for ( const auto& rString : aStringList ) { aBuffer.append(" --bcc "); - appendShellWord(aBuffer, aStringList[n], false); + appendShellWord(aBuffer, rString, false); } // Append subject if set in the message @@ -262,11 +260,10 @@ void SAL_CALL CmdMailSuppl::sendSimpleMailMessage( const Reference< XSimpleMailM // Append attachments set in the message aStringList = xSimpleMailMessage->getAttachement(); - nmax = aStringList.getLength(); - for ( n = 0; n < nmax; n++ ) + for ( const auto& rString : aStringList ) { OUString aSystemPath; - if ( FileBase::E_None == FileBase::getSystemPathFromFileURL(aStringList[n], aSystemPath) ) + if ( FileBase::E_None == FileBase::getSystemPathFromFileURL(rString, aSystemPath) ) { aBuffer.append(" --attach "); appendShellWord(aBuffer, aSystemPath, true); diff --git a/slideshow/source/engine/activities/activitiesfactory.cxx b/slideshow/source/engine/activities/activitiesfactory.cxx index ba75b46eb5a1..e2cc9987e998 100644 --- a/slideshow/source/engine/activities/activitiesfactory.cxx +++ b/slideshow/source/engine/activities/activitiesfactory.cxx @@ -621,11 +621,11 @@ AnimationActivitySharedPtr createValueListActivity( ValueVectorType aValueVector; aValueVector.reserve( rValues.getLength() ); - for( ::std::size_t i=0, nLen=rValues.getLength(); i<nLen; ++i ) + for( const auto& rValue : rValues ) { ValueType aValue; ENSURE_OR_THROW( - extractValue( aValue, rValues[i], rShape, rSlideBounds ), + extractValue( aValue, rValue, rShape, rSlideBounds ), "createValueListActivity(): Could not extract values" ); aValueVector.push_back( aValue ); } diff --git a/slideshow/source/engine/opengl/TransitionerImpl.cxx b/slideshow/source/engine/opengl/TransitionerImpl.cxx index f66d1402ee24..2bec0badb196 100644 --- a/slideshow/source/engine/opengl/TransitionerImpl.cxx +++ b/slideshow/source/engine/opengl/TransitionerImpl.cxx @@ -550,52 +550,46 @@ private: } virtual uno::Sequence< double > SAL_CALL convertFromRGB( const uno::Sequence< rendering::RGBColor >& rgbColor ) override { - const rendering::RGBColor* pIn( rgbColor.getConstArray() ); - const std::size_t nLen( rgbColor.getLength() ); + const sal_Int32 nLen( rgbColor.getLength() ); uno::Sequence< double > aRes(nLen*4); double* pColors=aRes.getArray(); - for( std::size_t i=0; i<nLen; ++i ) + for( const rendering::RGBColor& rIn : rgbColor ) { - *pColors++ = pIn->Red; - *pColors++ = pIn->Green; - *pColors++ = pIn->Blue; + *pColors++ = rIn.Red; + *pColors++ = rIn.Green; + *pColors++ = rIn.Blue; *pColors++ = 1.0; - ++pIn; } return aRes; } virtual uno::Sequence< double > SAL_CALL convertFromARGB( const uno::Sequence< rendering::ARGBColor >& rgbColor ) override { - const rendering::ARGBColor* pIn( rgbColor.getConstArray() ); - const std::size_t nLen( rgbColor.getLength() ); + const sal_Int32 nLen( rgbColor.getLength() ); uno::Sequence< double > aRes(nLen*4); double* pColors=aRes.getArray(); - for( std::size_t i=0; i<nLen; ++i ) + for( const rendering::ARGBColor& rIn : rgbColor ) { - *pColors++ = pIn->Red; - *pColors++ = pIn->Green; - *pColors++ = pIn->Blue; - *pColors++ = pIn->Alpha; - ++pIn; + *pColors++ = rIn.Red; + *pColors++ = rIn.Green; + *pColors++ = rIn.Blue; + *pColors++ = rIn.Alpha; } return aRes; } virtual uno::Sequence< double > SAL_CALL convertFromPARGB( const uno::Sequence< rendering::ARGBColor >& rgbColor ) override { - const rendering::ARGBColor* pIn( rgbColor.getConstArray() ); - const std::size_t nLen( rgbColor.getLength() ); + const sal_Int32 nLen( rgbColor.getLength() ); uno::Sequence< double > aRes(nLen*4); double* pColors=aRes.getArray(); - for( std::size_t i=0; i<nLen; ++i ) + for( const rendering::ARGBColor& rIn : rgbColor ) { - *pColors++ = pIn->Red/pIn->Alpha; - *pColors++ = pIn->Green/pIn->Alpha; - *pColors++ = pIn->Blue/pIn->Alpha; - *pColors++ = pIn->Alpha; - ++pIn; + *pColors++ = rIn.Red/rIn.Alpha; + *pColors++ = rIn.Green/rIn.Alpha; + *pColors++ = rIn.Blue/rIn.Alpha; + *pColors++ = rIn.Alpha; } return aRes; } @@ -618,21 +612,14 @@ private: { if( dynamic_cast<OGLColorSpace*>(targetColorSpace.get()) ) { - const sal_Int8* pIn( deviceColor.getConstArray() ); - const std::size_t nLen( deviceColor.getLength() ); + const sal_Int32 nLen( deviceColor.getLength() ); ENSURE_ARG_OR_THROW2(nLen%4==0, "number of channels no multiple of 4", static_cast<rendering::XColorSpace*>(this), 0); uno::Sequence<double> aRes(nLen); - double* pOut( aRes.getArray() ); - for( std::size_t i=0; i<nLen; i+=4 ) - { - *pOut++ = vcl::unotools::toDoubleColor(*pIn++); - *pOut++ = vcl::unotools::toDoubleColor(*pIn++); - *pOut++ = vcl::unotools::toDoubleColor(*pIn++); - *pOut++ = vcl::unotools::toDoubleColor(*pIn++); - } + std::transform(deviceColor.begin(), deviceColor.end(), aRes.begin(), + vcl::unotools::toDoubleColor); return aRes; } else @@ -729,54 +716,48 @@ private: virtual uno::Sequence< sal_Int8 > SAL_CALL convertIntegerFromRGB( const uno::Sequence< rendering::RGBColor >& rgbColor ) override { - const rendering::RGBColor* pIn( rgbColor.getConstArray() ); - const std::size_t nLen( rgbColor.getLength() ); + const sal_Int32 nLen( rgbColor.getLength() ); uno::Sequence< sal_Int8 > aRes(nLen*4); sal_Int8* pColors=aRes.getArray(); - for( std::size_t i=0; i<nLen; ++i ) + for( const rendering::RGBColor& rIn : rgbColor ) { - *pColors++ = vcl::unotools::toByteColor(pIn->Red); - *pColors++ = vcl::unotools::toByteColor(pIn->Green); - *pColors++ = vcl::unotools::toByteColor(pIn->Blue); + *pColors++ = vcl::unotools::toByteColor(rIn.Red); + *pColors++ = vcl::unotools::toByteColor(rIn.Green); + *pColors++ = vcl::unotools::toByteColor(rIn.Blue); *pColors++ = -1; - ++pIn; } return aRes; } virtual uno::Sequence< sal_Int8 > SAL_CALL convertIntegerFromARGB( const uno::Sequence< rendering::ARGBColor >& rgbColor ) override { - const rendering::ARGBColor* pIn( rgbColor.getConstArray() ); - const std::size_t nLen( rgbColor.getLength() ); + const sal_Int32 nLen( rgbColor.getLength() ); uno::Sequence< sal_Int8 > aRes(nLen*4); sal_Int8* pColors=aRes.getArray(); - for( std::size_t i=0; i<nLen; ++i ) + for( const rendering::ARGBColor& rIn : rgbColor ) { - *pColors++ = vcl::unotools::toByteColor(pIn->Red); - *pColors++ = vcl::unotools::toByteColor(pIn->Green); - *pColors++ = vcl::unotools::toByteColor(pIn->Blue); - *pColors++ = vcl::unotools::toByteColor(pIn->Alpha); - ++pIn; + *pColors++ = vcl::unotools::toByteColor(rIn.Red); + *pColors++ = vcl::unotools::toByteColor(rIn.Green); + *pColors++ = vcl::unotools::toByteColor(rIn.Blue); + *pColors++ = vcl::unotools::toByteColor(rIn.Alpha); } return aRes; } virtual uno::Sequence< sal_Int8 > SAL_CALL convertIntegerFromPARGB( const uno::Sequence< rendering::ARGBColor >& rgbColor ) override { - const rendering::ARGBColor* pIn( rgbColor.getConstArray() ); - const std::size_t nLen( rgbColor.getLength() ); + const sal_Int32 nLen( rgbColor.getLength() ); uno::Sequence< sal_Int8 > aRes(nLen*4); sal_Int8* pColors=aRes.getArray(); - for( std::size_t i=0; i<nLen; ++i ) + for( const rendering::ARGBColor& rIn : rgbColor ) { - *pColors++ = vcl::unotools::toByteColor(pIn->Red/pIn->Alpha); - *pColors++ = vcl::unotools::toByteColor(pIn->Green/pIn->Alpha); - *pColors++ = vcl::unotools::toByteColor(pIn->Blue/pIn->Alpha); - *pColors++ = vcl::unotools::toByteColor(pIn->Alpha); - ++pIn; + *pColors++ = vcl::unotools::toByteColor(rIn.Red/rIn.Alpha); + *pColors++ = vcl::unotools::toByteColor(rIn.Green/rIn.Alpha); + *pColors++ = vcl::unotools::toByteColor(rIn.Blue/rIn.Alpha); + *pColors++ = vcl::unotools::toByteColor(rIn.Alpha); } return aRes; } diff --git a/slideshow/source/engine/shapes/shapeimporter.cxx b/slideshow/source/engine/shapes/shapeimporter.cxx index 619da5d4af1c..2b2139ab63b8 100644 --- a/slideshow/source/engine/shapes/shapeimporter.cxx +++ b/slideshow/source/engine/shapes/shapeimporter.cxx @@ -398,14 +398,13 @@ void ShapeImporter::importPolygons(uno::Reference<beans::XPropertySet> const& xP getPropertyValue( fLineWidth, xPropSet, "LineWidth" ); drawing::PointSequence* pOuterSequence = aRetval.getArray(); - awt::Point* pInnerSequence = pOuterSequence->getArray(); ::basegfx::B2DPolygon aPoly; basegfx::B2DPoint aPoint; - for( sal_Int32 nCurrPoly=0; nCurrPoly<pOuterSequence->getLength(); ++nCurrPoly, ++pInnerSequence ) + for( const awt::Point& rPoint : *pOuterSequence ) { - aPoint.setX((*pInnerSequence).X); - aPoint.setY((*pInnerSequence).Y); + aPoint.setX(rPoint.X); + aPoint.setY(rPoint.Y); aPoly.append( aPoint ); } for( const auto& pView : mrContext.mrViewContainer ) diff --git a/slideshow/source/engine/slide/slideimpl.cxx b/slideshow/source/engine/slide/slideimpl.cxx index 13b1181f48c9..3786a00786c2 100644 --- a/slideshow/source/engine/slide/slideimpl.cxx +++ b/slideshow/source/engine/slide/slideimpl.cxx @@ -845,11 +845,10 @@ void SlideImpl::applyShapeAttributes( TargetPropertiesCreator::createTargetProperties( xRootAnimationNode, bInitial ) ); // apply extracted values to our shapes - const ::std::size_t nSize( aProps.getLength() ); - for( ::std::size_t i=0; i<nSize; ++i ) + for( const auto& rProp : aProps ) { sal_Int16 nParaIndex( -1 ); - uno::Reference< drawing::XShape > xShape( aProps[i].Target, + uno::Reference< drawing::XShape > xShape( rProp.Target, uno::UNO_QUERY ); if( !xShape.is() ) @@ -857,7 +856,7 @@ void SlideImpl::applyShapeAttributes( // not a shape target. Maybe a ParagraphTarget? presentation::ParagraphTarget aParaTarget; - if( aProps[i].Target >>= aParaTarget ) + if( rProp.Target >>= aParaTarget ) { // yep, ParagraphTarget found - extract shape // and index @@ -913,14 +912,13 @@ void SlideImpl::applyShapeAttributes( } } - const uno::Sequence< beans::NamedValue >& rShapeProps( aProps[i].Properties ); - const ::std::size_t nShapePropSize( rShapeProps.getLength() ); - for( ::std::size_t j=0; j<nShapePropSize; ++j ) + const uno::Sequence< beans::NamedValue >& rShapeProps( rProp.Properties ); + for( const auto& rShapeProp : rShapeProps ) { bool bVisible=false; - if( rShapeProps[j].Name.equalsIgnoreAsciiCase("visibility") && + if( rShapeProp.Name.equalsIgnoreAsciiCase("visibility") && extractValue( bVisible, - rShapeProps[j].Value, + rShapeProp.Value, pShape, ::basegfx::B2DSize( getSlideSize() ) )) { diff --git a/slideshow/source/engine/tools.cxx b/slideshow/source/engine/tools.cxx index 089f473f69ac..096715a73c90 100644 --- a/slideshow/source/engine/tools.cxx +++ b/slideshow/source/engine/tools.cxx @@ -432,11 +432,7 @@ namespace slideshow bool findNamedValue( uno::Sequence< beans::NamedValue > const& rSequence, const beans::NamedValue& rSearchKey ) { - const beans::NamedValue* pArray = rSequence.getConstArray(); - const size_t nLen( rSequence.getLength() ); - - return ::std::any_of( pArray, - pArray + nLen, + return ::std::any_of( rSequence.begin(), rSequence.end(), NamedValueComparator( rSearchKey ) ); } diff --git a/sot/source/sdstor/ucbstorage.cxx b/sot/source/sdstor/ucbstorage.cxx index a4c754610229..591a22805946 100644 --- a/sot/source/sdstor/ucbstorage.cxx +++ b/sot/source/sdstor/ucbstorage.cxx @@ -1813,14 +1813,12 @@ sal_Int32 UCBStorage_Impl::GetObjectCount() static OUString Find_Impl( const Sequence < Sequence < PropertyValue > >& rSequence, const OUString& rPath ) { bool bFound = false; - for ( sal_Int32 nSeqs=0; nSeqs<rSequence.getLength(); nSeqs++ ) + for ( const Sequence < PropertyValue >& rMyProps : rSequence ) { - const Sequence < PropertyValue >& rMyProps = rSequence[nSeqs]; OUString aType; - for ( sal_Int32 nProps=0; nProps<rMyProps.getLength(); nProps++ ) + for ( const PropertyValue& rAny : rMyProps ) { - const PropertyValue& rAny = rMyProps[nProps]; if ( rAny.Name == "FullPath" ) { OUString aTmp; @@ -1944,14 +1942,12 @@ bool UCBStorage_Impl::Insert( ::ucbhelper::Content *pContent ) try { Sequence< ContentInfo > aInfo = pContent->queryCreatableContentsInfo(); - sal_Int32 nCount = aInfo.getLength(); - if ( nCount == 0 ) + if ( !aInfo.hasElements() ) return false; - for ( sal_Int32 i = 0; i < nCount; ++i ) + for ( const ContentInfo & rCurr : aInfo ) { // Simply look for the first KIND_FOLDER... - const ContentInfo & rCurr = aInfo[i]; if ( rCurr.Attributes & ContentInfoAttribute::KIND_FOLDER ) { // Make sure the only required bootstrap property is "Title", diff --git a/sot/source/unoolestorage/xolesimplestorage.cxx b/sot/source/unoolestorage/xolesimplestorage.cxx index 80f2d0605c10..09de314226ab 100644 --- a/sot/source/unoolestorage/xolesimplestorage.cxx +++ b/sot/source/unoolestorage/xolesimplestorage.cxx @@ -237,15 +237,15 @@ void OLESimpleStorage::InsertNameAccessToStorage_Impl( BaseStorage* pStorage, co try { uno::Sequence< OUString > aElements = xNameAccess->getElementNames(); - for ( sal_Int32 nInd = 0; nInd < aElements.getLength(); nInd++ ) + for ( const auto& rElement : aElements ) { uno::Reference< io::XInputStream > xInputStream; uno::Reference< container::XNameAccess > xSubNameAccess; - uno::Any aAny = xNameAccess->getByName( aElements[nInd] ); + uno::Any aAny = xNameAccess->getByName( rElement ); if ( aAny >>= xInputStream ) - InsertInputStreamToStorage_Impl( pNewStorage.get(), aElements[nInd], xInputStream ); + InsertInputStreamToStorage_Impl( pNewStorage.get(), rElement, xInputStream ); else if ( aAny >>= xSubNameAccess ) - InsertNameAccessToStorage_Impl( pNewStorage.get(), aElements[nInd], xSubNameAccess ); + InsertNameAccessToStorage_Impl( pNewStorage.get(), rElement, xSubNameAccess ); } } catch( uno::Exception& ) diff --git a/starmath/source/cfgitem.cxx b/starmath/source/cfgitem.cxx index fb43b5ce5bee..5b6b900e051c 100644 --- a/starmath/source/cfgitem.cxx +++ b/starmath/source/cfgitem.cxx @@ -373,17 +373,9 @@ void SmMathConfig::ReadSymbol( SmSym &rSymbol, sal_Int32 nProps = aNames.getLength(); OUString aDelim( "/" ); - OUString *pName = aNames.getArray(); - for (sal_Int32 i = 0; i < nProps; ++i) - { - OUString &rName = pName[i]; - OUString aTmp( rName ); - rName = rBaseNode; - rName += aDelim; - rName += rSymbolName; - rName += aDelim; - rName += aTmp; - } + std::transform(aNames.begin(), aNames.end(), aNames.begin(), + [&rBaseNode, &rSymbolName, &aDelim](const OUString& rName) -> OUString { + return rBaseNode + aDelim + rSymbolName + aDelim + rName; }); const Sequence< Any > aValues = const_cast<SmMathConfig*>(this)->GetProperties(aNames); @@ -569,15 +561,13 @@ void SmMathConfig::LoadFontFormatList() pFontFormatList->Clear(); Sequence< OUString > aNodes( GetNodeNames( FONT_FORMAT_LIST ) ); - const OUString *pNode = aNodes.getConstArray(); - sal_Int32 nNodes = aNodes.getLength(); - for (sal_Int32 i = 0; i < nNodes; ++i) + for (const OUString& rNode : aNodes) { SmFontFormat aFntFmt; - ReadFontFormat( aFntFmt, pNode[i], FONT_FORMAT_LIST ); - if (!pFontFormatList->GetFontFormat( pNode[i] )) - pFontFormatList->AddFontFormat( pNode[i], aFntFmt ); + ReadFontFormat( aFntFmt, rNode, FONT_FORMAT_LIST ); + if (!pFontFormatList->GetFontFormat( rNode )) + pFontFormatList->AddFontFormat( rNode, aFntFmt ); } pFontFormatList->SetModified( false ); } @@ -590,17 +580,9 @@ void SmMathConfig::ReadFontFormat( SmFontFormat &rFontFormat, sal_Int32 nProps = aNames.getLength(); OUString aDelim( "/" ); - OUString *pName = aNames.getArray(); - for (sal_Int32 i = 0; i < nProps; ++i) - { - OUString &rName = pName[i]; - OUString aTmp( rName ); - rName = rBaseNode; - rName += aDelim; - rName += rSymbolName; - rName += aDelim; - rName += aTmp; - } + std::transform(aNames.begin(), aNames.end(), aNames.begin(), + [&rBaseNode, &rSymbolName, &aDelim](const OUString& rName) -> OUString { + return rBaseNode + aDelim + rSymbolName + aDelim + rName; }); const Sequence< Any > aValues = const_cast<SmMathConfig*>(this)->GetProperties(aNames); diff --git a/starmath/source/mathmlimport.cxx b/starmath/source/mathmlimport.cxx index fcc4a6c45bd4..a0d7afd51267 100644 --- a/starmath/source/mathmlimport.cxx +++ b/starmath/source/mathmlimport.cxx @@ -3079,38 +3079,34 @@ void SmXMLImport::SetViewSettings(const Sequence<PropertyValue>& aViewProps) tools::Rectangle aRect( pDocShell->GetVisArea() ); - sal_Int32 nCount = aViewProps.getLength(); - const PropertyValue *pValue = aViewProps.getConstArray(); - long nTmp = 0; - for (sal_Int32 i = 0; i < nCount ; i++) + for (const PropertyValue& rValue : aViewProps) { - if (pValue->Name == "ViewAreaTop" ) + if (rValue.Name == "ViewAreaTop" ) { - pValue->Value >>= nTmp; + rValue.Value >>= nTmp; aRect.SaturatingSetY(nTmp); } - else if (pValue->Name == "ViewAreaLeft" ) + else if (rValue.Name == "ViewAreaLeft" ) { - pValue->Value >>= nTmp; + rValue.Value >>= nTmp; aRect.SaturatingSetX(nTmp); } - else if (pValue->Name == "ViewAreaWidth" ) + else if (rValue.Name == "ViewAreaWidth" ) { - pValue->Value >>= nTmp; + rValue.Value >>= nTmp; Size aSize( aRect.GetSize() ); aSize.setWidth( nTmp ); aRect.SaturatingSetSize(aSize); } - else if (pValue->Name == "ViewAreaHeight" ) + else if (rValue.Name == "ViewAreaHeight" ) { - pValue->Value >>= nTmp; + rValue.Value >>= nTmp; Size aSize( aRect.GetSize() ); aSize.setHeight( nTmp ); aRect.SaturatingSetSize(aSize); } - pValue++; } pDocShell->SetVisArea ( aRect ); @@ -3126,22 +3122,19 @@ void SmXMLImport::SetConfigurationSettings(const Sequence<PropertyValue>& aConfP if (!xInfo.is() ) return; - sal_Int32 nCount = aConfProps.getLength(); - const PropertyValue* pValues = aConfProps.getConstArray(); - const OUString sFormula ( "Formula" ); const OUString sBasicLibraries ( "BasicLibraries" ); const OUString sDialogLibraries ( "DialogLibraries" ); - while ( nCount-- ) + for ( const PropertyValue& rValue : aConfProps ) { - if (pValues->Name != sFormula && - pValues->Name != sBasicLibraries && - pValues->Name != sDialogLibraries) + if (rValue.Name != sFormula && + rValue.Name != sBasicLibraries && + rValue.Name != sDialogLibraries) { try { - if ( xInfo->hasPropertyByName( pValues->Name ) ) - xProps->setPropertyValue( pValues->Name, pValues->Value ); + if ( xInfo->hasPropertyByName( rValue.Name ) ) + xProps->setPropertyValue( rValue.Name, rValue.Value ); } catch (const beans::PropertyVetoException &) { @@ -3152,8 +3145,6 @@ void SmXMLImport::SetConfigurationSettings(const Sequence<PropertyValue>& aConfP DBG_UNHANDLED_EXCEPTION("starmath"); } } - - pValues++; } } diff --git a/starmath/source/unomodel.cxx b/starmath/source/unomodel.cxx index 8042f0e099d7..ce6e1d0c4f68 100644 --- a/starmath/source/unomodel.cxx +++ b/starmath/source/unomodel.cxx @@ -636,22 +636,20 @@ void SmModel::_setPropertyValues(const PropertyMapEntry** ppEntries, const Any* if ( !(*pValues >>= aSequence) ) throw IllegalArgumentException(); - sal_uInt32 nSize = aSequence.getLength(); SmModule *pp = SM_MOD(); SmSymbolManager &rManager = pp->GetSymbolManager(); - SymbolDescriptor *pDescriptor = aSequence.getArray(); - for (sal_uInt32 i = 0; i < nSize ; i++, pDescriptor++) + for (const SymbolDescriptor& rDescriptor : aSequence) { vcl::Font aFont; - aFont.SetFamilyName ( pDescriptor->sFontName ); - aFont.SetCharSet ( static_cast < rtl_TextEncoding > (pDescriptor->nCharSet) ); - aFont.SetFamily ( static_cast < FontFamily > (pDescriptor->nFamily ) ); - aFont.SetPitch ( static_cast < FontPitch > (pDescriptor->nPitch ) ); - aFont.SetWeight ( static_cast < FontWeight > (pDescriptor->nWeight ) ); - aFont.SetItalic ( static_cast < FontItalic > (pDescriptor->nItalic ) ); - SmSym aSymbol ( pDescriptor->sName, aFont, static_cast < sal_Unicode > (pDescriptor->nCharacter), - pDescriptor->sSymbolSet ); - aSymbol.SetExportName ( pDescriptor->sExportName ); + aFont.SetFamilyName ( rDescriptor.sFontName ); + aFont.SetCharSet ( static_cast < rtl_TextEncoding > (rDescriptor.nCharSet) ); + aFont.SetFamily ( static_cast < FontFamily > (rDescriptor.nFamily ) ); + aFont.SetPitch ( static_cast < FontPitch > (rDescriptor.nPitch ) ); + aFont.SetWeight ( static_cast < FontWeight > (rDescriptor.nWeight ) ); + aFont.SetItalic ( static_cast < FontItalic > (rDescriptor.nItalic ) ); + SmSym aSymbol ( rDescriptor.sName, aFont, static_cast < sal_Unicode > (rDescriptor.nCharacter), + rDescriptor.sSymbolSet ); + aSymbol.SetExportName ( rDescriptor.sExportName ); rManager.AddOrReplaceSymbol ( aSymbol ); } } @@ -982,10 +980,10 @@ void SAL_CALL SmModel::render( // get device to be rendered in uno::Reference< awt::XDevice > xRenderDevice; - for (sal_Int32 i = 0, nCount = rxOptions.getLength(); i < nCount; ++i) + for (const auto& rxOption : rxOptions) { - if( rxOptions[i].Name == "RenderDevice" ) - rxOptions[i].Value >>= xRenderDevice; + if( rxOption.Name == "RenderDevice" ) + rxOption.Value >>= xRenderDevice; } if (!xRenderDevice.is()) diff --git a/stoc/Library_bootstrap.mk b/stoc/Library_bootstrap.mk index b31359663de6..49fbafc12a09 100644 --- a/stoc/Library_bootstrap.mk +++ b/stoc/Library_bootstrap.mk @@ -26,6 +26,7 @@ $(eval $(call gb_Library_use_internal_bootstrap_api,bootstrap,\ )) $(eval $(call gb_Library_use_libraries,bootstrap,\ + comphelper \ cppu \ cppuhelper \ reg \ diff --git a/stoc/source/corereflection/criface.cxx b/stoc/source/corereflection/criface.cxx index 5c4bd80af019..d71fc12a8dbc 100644 --- a/stoc/source/corereflection/criface.cxx +++ b/stoc/source/corereflection/criface.cxx @@ -790,11 +790,9 @@ sal_Bool InterfaceIdlClassImpl::isAssignableFrom( const Reference< XIdlClass > & else { const Sequence< Reference< XIdlClass > > & rSeq = xType->getSuperclasses(); - for (sal_Int32 i = 0; i < rSeq.getLength(); ++i) { - if (isAssignableFrom(rSeq[i])) { - return true; - } - } + if (std::any_of(rSeq.begin(), rSeq.end(), + [this](const Reference<XIdlClass>& rType){ return isAssignableFrom(rType); })) + return true; } } return false; diff --git a/stoc/source/defaultregistry/defaultregistry.cxx b/stoc/source/defaultregistry/defaultregistry.cxx index 4e6aa42c6480..afa4d2ad6aa6 100644 --- a/stoc/source/defaultregistry/defaultregistry.cxx +++ b/stoc/source/defaultregistry/defaultregistry.cxx @@ -18,6 +18,7 @@ */ #include <osl/mutex.hxx> +#include <comphelper/sequence.hxx> #include <cppuhelper/weak.hxx> #include <cppuhelper/implbase.hxx> #include <cppuhelper/implbase4.hxx> @@ -756,54 +757,27 @@ Sequence< Reference< XRegistryKey > > SAL_CALL NestedKeyImpl::openKeys( ) sal_uInt32 local = localSeq.getLength(); sal_uInt32 def = defaultSeq.getLength(); - sal_uInt32 len = 0; - - sal_uInt32 i, j; - for (i=0; i < local; i++) - { - for (j=0 ; j < def; j++) - { - if ( localSeq.getConstArray()[i] == defaultSeq.getConstArray()[j] ) - { - len++; - break; - } - } - } + sal_uInt32 len = static_cast<sal_uInt32>(std::count_if(localSeq.begin(), localSeq.end(), + [&defaultSeq](const OUString& rLocal) { return comphelper::findValue(defaultSeq, rLocal) != -1; })); Sequence< Reference<XRegistryKey> > retSeq(local + def - len); - OUString name; - sal_Int32 lastIndex; - for (i=0; i < local; i++) - { - name = localSeq.getConstArray()[i]; - lastIndex = name.lastIndexOf('/'); - name = name.copy(lastIndex); - retSeq.getArray()[i] = new NestedKeyImpl(name, this); - } + auto lKeyNameToRegKey = [this](const OUString& rName) -> Reference<XRegistryKey> { + sal_Int32 lastIndex = rName.lastIndexOf('/'); + OUString name = rName.copy(lastIndex); + return new NestedKeyImpl(name, this); + }; + std::transform(localSeq.begin(), localSeq.end(), retSeq.begin(), lKeyNameToRegKey); sal_uInt32 k = local; - for (i=0; i < def; i++) + for (const auto& rDef : defaultSeq) { - bool insert = true; - - for (j=0 ; j < local; j++) - { - if ( retSeq.getConstArray()[j]->getKeyName() - == defaultSeq.getConstArray()[i] ) - { - insert = false; - break; - } - } + bool insert = std::none_of(retSeq.begin(), std::next(retSeq.begin(), local), + [&rDef](const Reference<XRegistryKey>& rKey) { return rKey->getKeyName() == rDef; }); if ( insert ) { - name = defaultSeq.getConstArray()[i]; - lastIndex = name.lastIndexOf('/'); - name = name.copy(lastIndex); - retSeq.getArray()[k++] = new NestedKeyImpl(name, this); + retSeq.getArray()[k++] = lKeyNameToRegKey(rDef); } } @@ -830,49 +804,7 @@ Sequence< OUString > SAL_CALL NestedKeyImpl::getKeyNames( ) defaultSeq = m_defaultKey->getKeyNames(); } - sal_uInt32 local = localSeq.getLength(); - sal_uInt32 def = defaultSeq.getLength(); - sal_uInt32 len = 0; - - sal_uInt32 i, j; - for (i=0; i < local; i++) - { - for (j=0 ; j < def; j++) - { - if ( localSeq.getConstArray()[i] == defaultSeq.getConstArray()[j] ) - { - len++; - break; - } - } - } - - Sequence<OUString> retSeq(local + def - len); - - for (i=0; i < local; i++) - { - retSeq.getArray()[i] = localSeq.getConstArray()[i]; - } - - sal_uInt32 k = local; - for (i=0; i < def; i++) - { - bool insert = true; - - for (j=0 ; j < local; j++) - { - if ( retSeq.getConstArray()[j] == defaultSeq.getConstArray()[i] ) - { - insert = false; - break; - } - } - - if ( insert ) - retSeq.getArray()[k++] = defaultSeq.getConstArray()[i]; - } - - return retSeq; + return comphelper::combineSequences(localSeq, defaultSeq); } diff --git a/stoc/source/implementationregistration/implreg.cxx b/stoc/source/implementationregistration/implreg.cxx index 45c8f033f0db..5923e44a91c6 100644 --- a/stoc/source/implementationregistration/implreg.cxx +++ b/stoc/source/implementationregistration/implreg.cxx @@ -96,8 +96,6 @@ void deleteAllLinkReferences(const Reference < XSimpleRegistry >& xReg, if (!linkNames.hasElements()) return; - const OUString* pLinkNames = linkNames.getConstArray(); - OUString aLinkName; OUString aLinkParent; Reference < XRegistryKey > xLinkParent; @@ -105,9 +103,9 @@ void deleteAllLinkReferences(const Reference < XSimpleRegistry >& xReg, const sal_Unicode* pShortName = nullptr; sal_Int32 sEnd = 0; - for (sal_Int32 i = 0; i < linkNames.getLength(); i++) + for (const OUString& rLinkName : linkNames) { - aLinkName = pLinkNames[i]; + aLinkName = rLinkName; pTmpName = aLinkName.getStr(); @@ -219,14 +217,12 @@ OUString searchImplForLink( if (xKey.is()) { Sequence< Reference < XRegistryKey > > subKeys( xKey->openKeys() ); - const Reference < XRegistryKey > * pSubKeys = subKeys.getConstArray(); OUString key_name( slash_UNO + linkName ); - for (sal_Int32 i = 0; i < subKeys.getLength(); i++) + for (const Reference < XRegistryKey >& xImplKey : subKeys) { try { - Reference < XRegistryKey > xImplKey( pSubKeys[i] ); if (xImplKey->getKeyType( key_name ) == RegistryKeyType_LINK) { OUString oldImplName = xImplKey->getKeyName().copy(strlen("/IMPLEMENTATIONS/")); @@ -252,31 +248,25 @@ OUString searchLinkTargetForImpl(const Reference < XRegistryKey >& xRootKey, const OUString& linkName, const OUString& implName) { - Reference < XRegistryKey > xKey = xRootKey->openKey( slash_IMPLEMENTATIONS ); - - if (xKey.is()) - { - Sequence< Reference < XRegistryKey > > subKeys = xKey->openKeys(); - - const Reference < XRegistryKey >* pSubKeys = subKeys.getConstArray(); - Reference < XRegistryKey > xImplKey; - - for (sal_Int32 i = 0; i < subKeys.getLength(); i++) - { - xImplKey = pSubKeys[i]; + Reference < XRegistryKey > xKey = xRootKey->openKey( slash_IMPLEMENTATIONS ); - OUString tmpImplName = xImplKey->getKeyName().copy(strlen("/IMPLEMENTATIONS/")); - OUString qualifiedLinkName( slash_UNO ); - qualifiedLinkName += linkName; - if (tmpImplName == implName && - xImplKey->getKeyType( qualifiedLinkName ) == RegistryKeyType_LINK) - { - return xImplKey->getLinkTarget( qualifiedLinkName ); - } - } - } + if (xKey.is()) + { + Sequence< Reference < XRegistryKey > > subKeys = xKey->openKeys(); + + OUString qualifiedLinkName( slash_UNO + linkName ); + + auto pSubKey = std::find_if(subKeys.begin(), subKeys.end(), + [&implName, &qualifiedLinkName](const Reference<XRegistryKey>& rSubKey) { + OUString tmpImplName = rSubKey->getKeyName().copy(strlen("/IMPLEMENTATIONS/")); + return tmpImplName == implName + && rSubKey->getKeyType( qualifiedLinkName ) == RegistryKeyType_LINK; + }); + if (pSubKey != subKeys.end()) + return (*pSubKey)->getLinkTarget( qualifiedLinkName ); + } - return OUString(); + return OUString(); } @@ -291,37 +281,25 @@ void createUniqueSubEntry(const Reference < XRegistryKey > & xSuperKey, if (xSuperKey->getValueType() == RegistryValueType_ASCIILIST) { - sal_Int32 length = 0; - bool bReady = false; - Sequence<OUString> implEntries = xSuperKey->getAsciiListValue(); - length = implEntries.getLength(); + sal_Int32 length = implEntries.getLength(); - for (sal_Int32 i = 0; !bReady && (i < length); i++) - { - bReady = (implEntries.getConstArray()[i] == value); - } + bool bReady = comphelper::findValue(implEntries, value) != -1; if (bReady) { Sequence<OUString> implEntriesNew(length); implEntriesNew.getArray()[0] = value; - for (sal_Int32 i=0, j=1; i < length; i++) - { - if (implEntries.getConstArray()[i] != value) - implEntriesNew.getArray()[j++] = implEntries.getConstArray()[i]; - } + std::copy_if(implEntries.begin(), implEntries.end(), std::next(implEntriesNew.begin()), + [&value](const OUString& rEntry) { return rEntry != value; }); xSuperKey->setAsciiListValue(implEntriesNew); } else { Sequence<OUString> implEntriesNew(length+1); implEntriesNew.getArray()[0] = value; - for (sal_Int32 i = 0; i < length; i++) - { - implEntriesNew.getArray()[i+1] = implEntries.getConstArray()[i]; - } + std::copy(implEntries.begin(), implEntries.end(), std::next(implEntriesNew.begin())); xSuperKey->setAsciiListValue(implEntriesNew); } } else @@ -342,15 +320,9 @@ bool deleteSubEntry(const Reference < XRegistryKey >& xSuperKey, const OUString& { Sequence<OUString> implEntries = xSuperKey->getAsciiListValue(); sal_Int32 length = implEntries.getLength(); - sal_Int32 equals = 0; + sal_Int32 equals = static_cast<sal_Int32>(std::count(implEntries.begin(), implEntries.end(), value)); bool hasNoImplementations = false; - for (sal_Int32 i = 0; i < length; i++) - { - if (implEntries.getConstArray()[i] == value) - equals++; - } - if (equals == length) { hasNoImplementations = true; @@ -358,14 +330,8 @@ bool deleteSubEntry(const Reference < XRegistryKey >& xSuperKey, const OUString& { Sequence<OUString> implEntriesNew(length - equals); - sal_Int32 j = 0; - for (sal_Int32 i = 0; i < length; i++) - { - if (implEntries.getConstArray()[i] != value) - { - implEntriesNew.getArray()[j++] = implEntries.getConstArray()[i]; - } - } + std::copy_if(implEntries.begin(), implEntries.end(), implEntriesNew.begin(), + [&value](const OUString& rEntry) { return rEntry != value; }); xSuperKey->setAsciiListValue(implEntriesNew); } @@ -457,15 +423,9 @@ void deleteUserLink(const Reference < XRegistryKey >& xRootKey, { Sequence<OUString> implEntries = xOldKey->getAsciiListValue(); sal_Int32 length = implEntries.getLength(); - sal_Int32 equals = 0; + sal_Int32 equals = static_cast<sal_Int32>(std::count(implEntries.begin(), implEntries.end(), implName)); bool hasNoImplementations = false; - for (sal_Int32 i = 0; i < length; i++) - { - if (implEntries.getConstArray()[i] == implName) - equals++; - } - if (equals == length) { hasNoImplementations = true; @@ -571,11 +531,10 @@ void prepareUserKeys(const Reference < XSimpleRegistry >& xDest, if (subKeys.hasElements()) { hasSubKeys = true; - const Reference < XRegistryKey > * pSubKeys = subKeys.getConstArray(); - for (sal_Int32 i = 0; i < subKeys.getLength(); i++) + for (const Reference < XRegistryKey > & rSubKey : subKeys) { - prepareUserKeys(xDest, xUnoKey, pSubKeys[i], implName, bRegister); + prepareUserKeys(xDest, xUnoKey, rSubKey, implName, bRegister); } } } @@ -620,13 +579,10 @@ void deleteAllImplementations( const Reference < XSimpleRegistry >& xReg, if (subKeys.hasElements()) { - const Reference < XRegistryKey> * pSubKeys = subKeys.getConstArray(); - Reference < XRegistryKey > xImplKey; bool hasLocationUrl = false; - for (sal_Int32 i = 0; i < subKeys.getLength(); i++) + for (const Reference < XRegistryKey> & xImplKey : subKeys) { - xImplKey = pSubKeys[i]; Reference < XRegistryKey > xKey = xImplKey->openKey( slash_UNO_slash_LOCATION ); @@ -651,20 +607,15 @@ void deleteAllImplementations( const Reference < XSimpleRegistry >& xReg, { Sequence< Reference < XRegistryKey > > subKeys2 = xKey->openKeys(); - if (subKeys2.hasElements()) + for (const Reference < XRegistryKey > & rSubKey2 : subKeys2) { - const Reference < XRegistryKey > * pSubKeys2 = subKeys2.getConstArray(); - - for (sal_Int32 j = 0; j < subKeys2.getLength(); j++) + if (rSubKey2->getKeyName() != (xImplKey->getKeyName() + slash_UNO_slash_SERVICES ) && + rSubKey2->getKeyName() != (xImplKey->getKeyName() + slash_UNO_slash_REGISTRY_LINKS ) && + rSubKey2->getKeyName() != (xImplKey->getKeyName() + slash_UNO_slash_ACTIVATOR ) && + rSubKey2->getKeyName() != (xImplKey->getKeyName() + slash_UNO_slash_SINGLETONS ) && + rSubKey2->getKeyName() != (xImplKey->getKeyName() + slash_UNO_slash_LOCATION) ) { - if (pSubKeys2[j]->getKeyName() != (xImplKey->getKeyName() + slash_UNO_slash_SERVICES ) && - pSubKeys2[j]->getKeyName() != (xImplKey->getKeyName() + slash_UNO_slash_REGISTRY_LINKS ) && - pSubKeys2[j]->getKeyName() != (xImplKey->getKeyName() + slash_UNO_slash_ACTIVATOR ) && - pSubKeys2[j]->getKeyName() != (xImplKey->getKeyName() + slash_UNO_slash_SINGLETONS ) && - pSubKeys2[j]->getKeyName() != (xImplKey->getKeyName() + slash_UNO_slash_LOCATION) ) - { - prepareUserKeys(xReg, xKey, pSubKeys2[j], implName, false); - } + prepareUserKeys(xReg, xKey, rSubKey2, implName, false); } } } @@ -768,25 +719,15 @@ void deleteAllServiceEntries( const Reference < XSimpleRegistry >& xReg, if (subKeys.hasElements()) { - const Reference < XRegistryKey > * pSubKeys = subKeys.getConstArray(); - Reference < XRegistryKey > xServiceKey; bool hasNoImplementations = false; - for (sal_Int32 i = 0; i < subKeys.getLength(); i++) + for (const Reference < XRegistryKey > & xServiceKey : subKeys) { - xServiceKey = pSubKeys[i]; - if (xServiceKey->getValueType() == RegistryValueType_ASCIILIST) { Sequence<OUString> implEntries = xServiceKey->getAsciiListValue(); sal_Int32 length = implEntries.getLength(); - sal_Int32 equals = 0; - - for (sal_Int32 j = 0; j < length; j++) - { - if (implEntries.getConstArray()[j] == implName) - equals++; - } + sal_Int32 equals = static_cast<sal_Int32>(std::count(implEntries.begin(), implEntries.end(), implName)); if (equals == length) { @@ -797,14 +738,8 @@ void deleteAllServiceEntries( const Reference < XSimpleRegistry >& xReg, { Sequence<OUString> implEntriesNew(length-equals); - sal_Int32 j = 0; - for (sal_Int32 k = 0; k < length; k++) - { - if (implEntries.getConstArray()[k] != implName) - { - implEntriesNew.getArray()[j++] = implEntries.getConstArray()[k]; - } - } + std::copy_if(implEntries.begin(), implEntries.end(), implEntriesNew.begin(), + [&implName](const OUString& rEntry) { return rEntry != implName; }); xServiceKey->setAsciiListValue(implEntriesNew); } @@ -844,13 +779,8 @@ bool is_supported_service( return true; Sequence< Reference< reflection::XServiceTypeDescription > > seq( xService_td->getMandatoryServices() ); - Reference< reflection::XServiceTypeDescription > const * p = seq.getConstArray(); - for ( sal_Int32 nPos = seq.getLength(); nPos--; ) - { - if (is_supported_service( service_name, p[ nPos ] )) - return true; - } - return false; + return std::any_of(seq.begin(), seq.end(), [&service_name](const auto& rService) { + return is_supported_service( service_name, rService ); }); } @@ -951,14 +881,7 @@ void insert_singletons( { } // check implname is already in - sal_Int32 nPos_implnames = implnames.getLength(); - OUString const * pImplnames = implnames.getConstArray(); - while (nPos_implnames--) - { - if (implname == pImplnames[ nPos_implnames ]) - break; - } - if (nPos_implnames < 0) + if (comphelper::findValue(implnames, implname) == -1) { // append and write back implnames.realloc( implnames.getLength() +1 ); @@ -987,13 +910,8 @@ void prepareRegistry( "prepareRegistry(): source registry is empty" ); } - const Reference < XRegistryKey >* pSubKeys = subKeys.getConstArray(); - Reference < XRegistryKey > xImplKey; - - for (sal_Int32 i = 0; i < subKeys.getLength(); i++) + for (const Reference < XRegistryKey >& xImplKey : subKeys) { - xImplKey = pSubKeys[i]; - Reference < XRegistryKey > xKey = xImplKey->openKey( slash_UNO_slash_SERVICES ); @@ -1001,7 +919,6 @@ void prepareRegistry( { // update entries in SERVICES section Sequence< Reference < XRegistryKey > > serviceKeys = xKey->openKeys(); - const Reference < XRegistryKey > * pServiceKeys = serviceKeys.getConstArray(); OUString implName = xImplKey->getKeyName().copy(1); sal_Int32 firstDot = implName.indexOf('/'); @@ -1011,9 +928,9 @@ void prepareRegistry( sal_Int32 offset = xKey->getKeyName().getLength() + 1; - for (sal_Int32 j = 0; j < serviceKeys.getLength(); j++) + for (const Reference < XRegistryKey >& rServiceKey : serviceKeys) { - OUString serviceName = pServiceKeys[j]->getKeyName().copy(offset); + OUString serviceName = rServiceKey->getKeyName().copy(offset); createUniqueSubEntry( xDest->getRootKey()->createKey( @@ -1026,18 +943,13 @@ void prepareRegistry( { Sequence< Reference < XRegistryKey > > subKeys2 = xKey->openKeys(); - if (subKeys2.hasElements()) + for (const Reference < XRegistryKey >& rSubKey2 : subKeys2) { - const Reference < XRegistryKey > * pSubKeys2 = subKeys2.getConstArray(); - - for (sal_Int32 j = 0; j < subKeys2.getLength(); j++) + if (rSubKey2->getKeyName() != (xImplKey->getKeyName() + slash_UNO_slash_SERVICES) && + rSubKey2->getKeyName() != (xImplKey->getKeyName() + slash_UNO_slash_REGISTRY_LINKS ) && + rSubKey2->getKeyName() != (xImplKey->getKeyName() + slash_UNO_slash_SINGLETONS )) { - if (pSubKeys2[j]->getKeyName() != (xImplKey->getKeyName() + slash_UNO_slash_SERVICES) && - pSubKeys2[j]->getKeyName() != (xImplKey->getKeyName() + slash_UNO_slash_REGISTRY_LINKS ) && - pSubKeys2[j]->getKeyName() != (xImplKey->getKeyName() + slash_UNO_slash_SINGLETONS )) - { - prepareUserKeys(xDest, xKey, pSubKeys2[j], implName, true); - } + prepareUserKeys(xDest, xKey, rSubKey2, implName, true); } } } @@ -1066,14 +978,9 @@ void prepareRegistry( // update link entries in REGISTRY_LINKS section Sequence<OUString> linkNames = xKey->getAsciiListValue(); - if (linkNames.hasElements()) + for (const OUString& rLinkName : linkNames) { - const OUString* pLinkNames = linkNames.getConstArray(); - - for (sal_Int32 j = 0; j < linkNames.getLength(); j++) - { - prepareLink(xDest, xImplKey, pLinkNames[j]); - } + prepareLink(xDest, xImplKey, rLinkName); } } @@ -1115,15 +1022,9 @@ void findImplementations( const Reference < XRegistryKey > & xSource, { Sequence< Reference < XRegistryKey > > subKeys = xSource->openKeys(); - if (subKeys.hasElements()) + for (const Reference < XRegistryKey >& rSubKey : subKeys) { - const Reference < XRegistryKey >* pSubKeys = subKeys.getConstArray(); - - for (sal_Int32 i = 0; i < subKeys.getLength(); i++) - { - findImplementations(pSubKeys[i], implNames); - } - + findImplementations(rSubKey, implNames); } } catch(InvalidRegistryException&) diff --git a/stoc/source/inspect/introspection.cxx b/stoc/source/inspect/introspection.cxx index 79df9d25a542..474952f7cdd5 100644 --- a/stoc/source/inspect/introspection.cxx +++ b/stoc/source/inspect/introspection.cxx @@ -93,20 +93,12 @@ typedef WeakImplHelper< XIntrospectionAccess, XMaterialHolder, XExactName, bool isDerivedFrom( const Reference<XIdlClass>& xToTestClass, const Reference<XIdlClass>& xDerivedFromClass ) { Sequence< Reference<XIdlClass> > aClassesSeq = xToTestClass->getSuperclasses(); - const Reference<XIdlClass>* pClassesArray = aClassesSeq.getConstArray(); - sal_Int32 nSuperClassCount = aClassesSeq.getLength(); - for ( sal_Int32 i = 0; i < nSuperClassCount; ++i ) - { - const Reference<XIdlClass>& rxClass = pClassesArray[i]; - - if ( xDerivedFromClass->equals( rxClass ) || - isDerivedFrom( rxClass, xDerivedFromClass ) - ) - return true; - } - - return false; + return std::any_of(aClassesSeq.begin(), aClassesSeq.end(), + [&xDerivedFromClass](const Reference<XIdlClass>& rxClass) { + return xDerivedFromClass->equals( rxClass ) + || isDerivedFrom( rxClass, xDerivedFromClass ); + }); } @@ -1761,13 +1753,9 @@ css::uno::Reference<css::beans::XIntrospectionAccess> Implementation::inspect( aClassSeq.realloc( nIfaceCount + 1 ); aClassSeq.getArray()[ nIfaceCount ] = xImplClass2; - nIfaceCount++; - const Reference<XIdlClass>* pParamArray = aClassSeq.getConstArray(); - - for( sal_Int32 j = 0 ; j < nIfaceCount ; j++ ) + for( const Reference<XIdlClass>& rxIfaceClass : aClassSeq ) { - const Reference<XIdlClass>& rxIfaceClass = pParamArray[j]; if (!seen.insert(rxIfaceClass->getName()).second) { continue; } @@ -1776,12 +1764,9 @@ css::uno::Reference<css::beans::XIntrospectionAccess> Implementation::inspect( // Get fields Sequence< Reference<XIdlField> > fields = rxIfaceClass->getFields(); - const Reference<XIdlField>* pFields = fields.getConstArray(); - sal_Int32 nLen = fields.getLength(); - for( i = 0 ; i < nLen ; i++ ) + for( const Reference<XIdlField>& xField : fields ) { - Reference<XIdlField> xField = pFields[i]; Reference<XIdlClass> xPropType = xField->getType(); // Is the property sequence big enough? @@ -2291,7 +2276,6 @@ css::uno::Reference<css::beans::XIntrospectionAccess> Implementation::inspect( // Option 1: Search for parameters for a listener class // Disadvantage: Superclasses should be searched recursively Sequence< Reference<XIdlClass> > aParams = rxMethod->getParameterTypes(); - const Reference<XIdlClass>* pParamArray2 = aParams.getConstArray(); css::uno::Reference<css::reflection::XIdlClass> xEventListenerClass( @@ -2300,19 +2284,15 @@ css::uno::Reference<css::beans::XIntrospectionAccess> Implementation::inspect( css::lang::XEventListener>::get() .getTypeName())); // Old: Reference<XIdlClass> xEventListenerClass = XEventListener_getReflection()->getIdlClass(); - sal_Int32 nParamCount = aParams.getLength(); - sal_Int32 k; - for( k = 0 ; k < nParamCount ; k++ ) + auto pParam = std::find_if(aParams.begin(), aParams.end(), + [&xEventListenerClass](const Reference<XIdlClass>& rxClass) { + // Are we derived from a listener? + return rxClass->equals( xEventListenerClass ) + || isDerivedFrom( rxClass, xEventListenerClass ); + }); + if (pParam != aParams.end()) { - const Reference<XIdlClass>& rxClass = pParamArray2[k]; - - // Are we derived from a listener? - if( rxClass->equals( xEventListenerClass ) || - isDerivedFrom( rxClass, xEventListenerClass ) ) - { - xListenerClass = rxClass; - break; - } + xListenerClass = *pParam; } // Option 2: Unload the name of the method @@ -2376,12 +2356,9 @@ css::uno::Reference<css::beans::XIntrospectionAccess> Implementation::inspect( // Get fields Sequence< Reference<XIdlField> > fields = xClassRef->getFields(); - const Reference<XIdlField>* pFields = fields.getConstArray(); - sal_Int32 nLen = fields.getLength(); - for( i = 0 ; i < nLen ; i++ ) + for( const Reference<XIdlField>& xField : fields ) { - Reference<XIdlField> xField = pFields[i]; Reference<XIdlClass> xPropType = xField->getType(); OUString aPropName = xField->getName(); diff --git a/stoc/source/invocation/invocation.cxx b/stoc/source/invocation/invocation.cxx index 8211828f90cf..694ffa2904b8 100644 --- a/stoc/source/invocation/invocation.cxx +++ b/stoc/source/invocation/invocation.cxx @@ -680,14 +680,10 @@ Any Invocation_Impl::invoke( const OUString& FunctionName, const Sequence<Any>& // OUT Params OutIndices.realloc( nOutIndex ); - pOutIndices = OutIndices.getArray(); OutParams.realloc( nOutIndex ); - Any* pOutParams = OutParams.getArray(); - while (nOutIndex--) - { - pOutParams[nOutIndex] = pInvokeParams[ pOutIndices[nOutIndex] ]; - } + std::transform(OutIndices.begin(), OutIndices.end(), OutParams.begin(), + [&pInvokeParams](const sal_Int16 nIndex) -> Any { return pInvokeParams[nIndex]; }); return aRet; } diff --git a/stoc/source/servicemanager/servicemanager.cxx b/stoc/source/servicemanager/servicemanager.cxx index 5f38ec917c71..000c7d0dc900 100644 --- a/stoc/source/servicemanager/servicemanager.cxx +++ b/stoc/source/servicemanager/servicemanager.cxx @@ -51,6 +51,7 @@ #include <com/sun/star/container/XContentEnumerationAccess.hpp> #include <com/sun/star/uno/XComponentContext.hpp> +#include <iterator> #include <unordered_map> #include <unordered_set> @@ -88,12 +89,7 @@ Sequence< OUString > retrieveAsciiValueList( sal_Int32 n2Len = seq2.getLength(); seq.realloc( n1Len + n2Len ); - const OUString *pSource = seq2.getConstArray(); - OUString *pTarget = seq.getArray(); - for( int i = 0 ; i < n2Len ; i ++ ) - { - pTarget[i+n1Len] = pSource[i]; - } + std::copy(seq2.begin(), seq2.end(), std::next(seq.begin(), n1Len)); } } } @@ -198,13 +194,8 @@ beans::Property PropertySetInfo_Impl::getPropertyByName( OUString const & name ) sal_Bool PropertySetInfo_Impl::hasPropertyByName( OUString const & name ) { - beans::Property const * p = m_properties.getConstArray(); - for ( sal_Int32 nPos = m_properties.getLength(); nPos--; ) - { - if (p[ nPos ].Name == name) - return true; - } - return false; + return std::any_of(m_properties.begin(), m_properties.end(), + [&name](const beans::Property& rProp) { return rProp.Name == name; }); } @@ -784,12 +775,10 @@ Reference< XInterface > OServiceManager::createInstanceWithContext( Sequence< Reference< XInterface > > factories( queryServiceFactories( rServiceSpecifier, xContext ) ); - Reference< XInterface > const * p = factories.getConstArray(); - for ( sal_Int32 nPos = 0; nPos < factories.getLength(); ++nPos ) + for ( Reference< XInterface > const & xFactory : factories ) { try { - Reference< XInterface > const & xFactory = p[ nPos ]; if (xFactory.is()) { Reference< XSingleComponentFactory > xFac( xFactory, UNO_QUERY ); @@ -838,12 +827,10 @@ Reference< XInterface > OServiceManager::createInstanceWithArgumentsAndContext( Sequence< Reference< XInterface > > factories( queryServiceFactories( rServiceSpecifier, xContext ) ); - Reference< XInterface > const * p = factories.getConstArray(); - for ( sal_Int32 nPos = 0; nPos < factories.getLength(); ++nPos ) + for ( Reference< XInterface > const & xFactory : factories ) { try { - Reference< XInterface > const & xFactory = p[ nPos ]; if (xFactory.is()) { Reference< XSingleComponentFactory > xFac( xFactory, UNO_QUERY ); @@ -1052,11 +1039,10 @@ void OServiceManager::insert( const Any & Element ) //put into the service map Sequence< OUString > aServiceNames = xInfo->getSupportedServiceNames(); - const OUString * pArray = aServiceNames.getConstArray(); - for( sal_Int32 i = 0; i < aServiceNames.getLength(); i++ ) + for( const OUString& rServiceName : aServiceNames ) { m_ServiceMap.emplace( - pArray[i], *o3tl::doAccess<Reference<XInterface>>(Element) ); + rServiceName, *o3tl::doAccess<Reference<XInterface>>(Element) ); } } } @@ -1137,11 +1123,10 @@ void OServiceManager::remove( const Any & Element ) return; Sequence< OUString > aServiceNames = xSF->getSupportedServiceNames(); - const OUString * pArray = aServiceNames.getConstArray(); - for( sal_Int32 i = 0; i < aServiceNames.getLength(); i++ ) + for( const OUString& rServiceName : aServiceNames ) { pair<HashMultimap_OWString_Interface::iterator, HashMultimap_OWString_Interface::iterator> p = - m_ServiceMap.equal_range( pArray[i] ); + m_ServiceMap.equal_range( rServiceName ); while( p.first != p.second ) { @@ -1321,10 +1306,9 @@ Reference<XInterface > ORegistryServiceManager::loadWithServiceName( const OUString& serviceName, Reference< XComponentContext > const & xContext ) { Sequence<OUString> implEntries = getFromServiceName( serviceName ); - for (sal_Int32 i = 0; i < implEntries.getLength(); i++) + for (const auto& rEntry : implEntries) { - Reference< XInterface > x( - loadWithImplementationName( implEntries.getConstArray()[i], xContext ) ); + Reference< XInterface > x( loadWithImplementationName( rEntry, xContext ) ); if (x.is()) return x; } @@ -1349,8 +1333,9 @@ void ORegistryServiceManager::fillAllNamesFromRegistry( HashSet_OWString & rSet { sal_Int32 nPrefix = xServicesKey->getKeyName().getLength() +1; Sequence<Reference<XRegistryKey > > aKeys = xServicesKey->openKeys(); - for( sal_Int32 i = 0; i < aKeys.getLength(); i++ ) - rSet.insert( aKeys.getConstArray()[i]->getKeyName().copy( nPrefix ) ); + std::transform(aKeys.begin(), aKeys.end(), std::inserter(rSet, rSet.end()), + [nPrefix](const Reference<XRegistryKey>& rKey) -> OUString { + return rKey->getKeyName().copy( nPrefix ); }); } } catch (InvalidRegistryException &) @@ -1428,11 +1413,8 @@ Reference<XEnumeration > ORegistryServiceManager::createContentEnumeration( // get all implementation names registered under this service name from the registry Sequence<OUString> aImpls = getFromServiceName( aServiceName ); // load and insert all factories specified by the registry - sal_Int32 i; - OUString aImplName; - for( i = 0; i < aImpls.getLength(); i++ ) + for( const OUString& aImplName : aImpls ) { - aImplName = aImpls.getConstArray()[i]; if ( !haveFactoryWithThisImplementation(aImplName) ) { loadWithImplementationName( aImplName, m_xContext ); diff --git a/stoc/source/simpleregistry/simpleregistry.cxx b/stoc/source/simpleregistry/simpleregistry.cxx index 9d2a6a1e9382..ab2251cedc86 100644 --- a/stoc/source/simpleregistry/simpleregistry.cxx +++ b/stoc/source/simpleregistry/simpleregistry.cxx @@ -33,6 +33,7 @@ #include <com/sun/star/uno/RuntimeException.hpp> #include <com/sun/star/uno/XInterface.hpp> #include <com/sun/star/uno/Sequence.hxx> +#include <comphelper/sequence.hxx> #include <cppuhelper/implbase.hxx> #include <cppuhelper/supportsservice.hxx> #include <cppuhelper/weak.hxx> @@ -313,12 +314,7 @@ css::uno::Sequence< sal_Int32 > Key::getLongListValue() void Key::setLongListValue(css::uno::Sequence< sal_Int32 > const & seqValue) { osl::MutexGuard guard(registry_->mutex_); - std::vector< sal_Int32 > list; - list.reserve(seqValue.getLength()); - for (sal_Int32 i = 0; i < seqValue.getLength(); ++i) - { - list.push_back(seqValue[i]); - } + auto list = comphelper::sequenceToContainer<std::vector<sal_Int32>>(seqValue); RegError err = key_.setLongListValue( OUString(), list.data(), static_cast< sal_uInt32 >(list.size())); if (err != RegError::NO_ERROR) { @@ -475,9 +471,9 @@ void Key::setAsciiListValue( { osl::MutexGuard guard(registry_->mutex_); std::vector< OString > list; - for (sal_Int32 i = 0; i < seqValue.getLength(); ++i) { + for (const auto& rValue : seqValue) { OString utf8; - if (!seqValue[i].convertToString( + if (!rValue.convertToString( &utf8, RTL_TEXTENCODING_UTF8, (RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR | RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR))) @@ -616,10 +612,8 @@ void Key::setStringListValue( osl::MutexGuard guard(registry_->mutex_); std::vector< sal_Unicode * > list; list.reserve(seqValue.getLength()); - for (sal_Int32 i = 0; i < seqValue.getLength(); ++i) - { - list.push_back(const_cast< sal_Unicode * >(seqValue[i].getStr())); - } + std::transform(seqValue.begin(), seqValue.end(), std::back_inserter(list), + [](const OUString& rValue) -> sal_Unicode* { return const_cast<sal_Unicode*>(rValue.getStr()); }); RegError err = key_.setUnicodeListValue( OUString(), list.data(), static_cast< sal_uInt32 >(list.size())); if (err != RegError::NO_ERROR) { diff --git a/svgio/qa/cppunit/SvgImportTest.cxx b/svgio/qa/cppunit/SvgImportTest.cxx index b3ef8abdd4d4..be3f719ab1d2 100644 --- a/svgio/qa/cppunit/SvgImportTest.cxx +++ b/svgio/qa/cppunit/SvgImportTest.cxx @@ -138,17 +138,9 @@ void Test::checkRectPrimitive(Primitive2DSequence const & rPrimitive) bool arePrimitive2DSequencesEqual(const Primitive2DSequence& rA, const Primitive2DSequence& rB) { - const sal_Int32 nCount(rA.getLength()); - - if(nCount != rB.getLength()) - return false; - - for(sal_Int32 a(0); a < nCount; a++) { - if(!drawinglayer::primitive2d::arePrimitive2DReferencesEqual(rA[a], rB[a])) - return false; - } - - return true; + return std::equal(rA.begin(), rA.end(), rB.begin(), rB.end(), + [](const Primitive2DReference& a, const Primitive2DReference& b) { + return drawinglayer::primitive2d::arePrimitive2DReferencesEqual(a, b); }); } // Attributes for an object (like rect as in this case) can be defined _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits