From 1553d3787cbe0cdababf31382bf3376a3640d8cf Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Wed, 20 May 2020 08:43:33 +0200 Subject: use for-range on Sequence in d* and fix bug in GenericClipboard::initialize, where it was looping through the arguments, but always reading the first one. I'm guessing it was never an issue because it is always called with only one argument Change-Id: I8f72b6bce8c77a69c7d75115e34630e2c308261e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94553 Tested-by: Jenkins Reviewed-by: Noel Grandin --- dbaccess/source/core/dataaccess/ModelImpl.cxx | 8 +-- .../source/core/dataaccess/databasedocument.cxx | 7 +- .../source/core/dataaccess/documentdefinition.cxx | 8 +-- dbaccess/source/inc/apitools.hxx | 7 +- dbaccess/source/ui/inc/sbamultiplex.hxx | 7 +- desktop/source/app/check_ext_deps.cxx | 4 +- desktop/source/app/dispatchwatcher.cxx | 14 ++-- desktop/source/deployment/gui/dp_gui_dialog2.cxx | 3 +- .../deployment/gui/dp_gui_extensioncmdqueue.cxx | 5 +- .../source/deployment/gui/dp_gui_extlistbox.cxx | 4 +- desktop/source/deployment/gui/dp_gui_theextmgr.cxx | 28 ++++---- .../source/deployment/gui/dp_gui_updatedialog.cxx | 5 +- .../deployment/manager/dp_extensionmanager.cxx | 19 +++-- .../source/deployment/manager/dp_properties.cxx | 3 +- desktop/source/deployment/misc/dp_misc.cxx | 4 +- desktop/source/deployment/misc/dp_platform.cxx | 4 +- desktop/source/deployment/misc/dp_ucb.cxx | 3 +- desktop/source/deployment/misc/dp_update.cxx | 14 ++-- .../deployment/registry/component/dp_component.cxx | 18 ++--- desktop/source/deployment/registry/dp_backend.cxx | 7 +- desktop/source/deployment/registry/dp_registry.cxx | 4 +- desktop/source/lib/init.cxx | 22 +++--- desktop/source/lib/lokinteractionhandler.cxx | 14 ++-- desktop/source/migration/migration.cxx | 83 ++++++++++------------ desktop/source/pkgchk/unopkg/unopkg_app.cxx | 14 ++-- desktop/test/deployment/active/active_native.cxx | 2 +- desktop/test/deployment/passive/passive_native.cxx | 2 +- dtrans/source/generic/generic_clipboard.cxx | 6 +- dtrans/source/win32/dtobj/DOTransferable.cxx | 4 +- dtrans/test/win32/dnd/dndTest.cxx | 2 +- embedserv/source/embed/docholder.cxx | 32 ++++----- 31 files changed, 164 insertions(+), 193 deletions(-) diff --git a/dbaccess/source/core/dataaccess/ModelImpl.cxx b/dbaccess/source/core/dataaccess/ModelImpl.cxx index 1b74735ec108..8f6dbaa31bb0 100644 --- a/dbaccess/source/core/dataaccess/ModelImpl.cxx +++ b/dbaccess/source/core/dataaccess/ModelImpl.cxx @@ -289,11 +289,11 @@ Sequence< OUString > SAL_CALL DocumentStorageAccess::getDocumentSubStoragesNames std::vector< OUString > aNames; - Sequence< OUString > aElementNames( xRootStor->getElementNames() ); - for ( sal_Int32 i=0; i aElementNames( xRootStor->getElementNames() ); + for ( OUString const & name : aElementNames ) { - if ( xRootStor->isStorageElement( aElementNames[i] ) ) - aNames.push_back( aElementNames[i] ); + if ( xRootStor->isStorageElement( name ) ) + aNames.push_back( name ); } return aNames.empty() ? Sequence< OUString >() diff --git a/dbaccess/source/core/dataaccess/databasedocument.cxx b/dbaccess/source/core/dataaccess/databasedocument.cxx index 29d63ae81353..6811ae332e84 100644 --- a/dbaccess/source/core/dataaccess/databasedocument.cxx +++ b/dbaccess/source/core/dataaccess/databasedocument.cxx @@ -344,13 +344,12 @@ static const char sPictures[] = "Pictures"; /// @throws RuntimeException static void lcl_uglyHackToStoreDialogeEmbedImages( const Reference< XStorageBasedLibraryContainer >& xDlgCont, const Reference< XStorage >& xStorage, const Reference< XModel >& rxModel, const Reference& rxContext ) { - Sequence< OUString > sLibraries = xDlgCont->getElementNames(); + const Sequence< OUString > sLibraries = xDlgCont->getElementNames(); Reference< XStorage > xTmpPic = xStorage->openStorageElement( "tempPictures", ElementModes::READWRITE ); std::vector> vxGraphicList; - for ( sal_Int32 i=0; i < sLibraries.getLength(); ++i ) + for ( OUString const & sLibrary : sLibraries ) { - OUString sLibrary( sLibraries[ i ] ); xDlgCont->loadLibrary( sLibrary ); Reference< XNameContainer > xLib; xDlgCont->getByName( sLibrary ) >>= xLib; @@ -362,7 +361,7 @@ static void lcl_uglyHackToStoreDialogeEmbedImages( const Reference< XStorageBase { Reference < awt::XDialogProvider > xDlgPrv = awt::DialogProvider::createWithModel(rxContext, rxModel); OUString sDialogUrl = - "vnd.sun.star.script:" + sLibraries[i] + "." + sDialogs[j] + "?location=document"; + "vnd.sun.star.script:" + sLibrary + "." + sDialogs[j] + "?location=document"; Reference< css::awt::XControl > xDialog( xDlgPrv->createDialog( sDialogUrl ), UNO_QUERY ); Reference< XInterface > xModel( xDialog->getModel() ); diff --git a/dbaccess/source/core/dataaccess/documentdefinition.cxx b/dbaccess/source/core/dataaccess/documentdefinition.cxx index b16f1fed5aca..40fddc4dec36 100644 --- a/dbaccess/source/core/dataaccess/documentdefinition.cxx +++ b/dbaccess/source/core/dataaccess/documentdefinition.cxx @@ -366,17 +366,17 @@ OUString ODocumentDefinition::GetDocumentServiceFromMediaType( const OUString& _ Reference< XNameAccess > xObjConfig = aConfigHelper.GetObjConfiguration(); if ( xObjConfig.is() ) { - Sequence< OUString > aClassIDs = xObjConfig->getElementNames(); - for ( sal_Int32 nInd = 0; nInd < aClassIDs.getLength(); nInd++ ) + const Sequence< OUString > aClassIDs = xObjConfig->getElementNames(); + for ( OUString const & classId : aClassIDs ) { Reference< XNameAccess > xObjectProps; OUString aEntryDocName; - if ( ( xObjConfig->getByName( aClassIDs[nInd] ) >>= xObjectProps ) && xObjectProps.is() + if ( ( xObjConfig->getByName( classId ) >>= xObjectProps ) && xObjectProps.is() && ( xObjectProps->getByName("ObjectDocumentServiceName") >>= aEntryDocName ) && aEntryDocName == sResult ) { - _rClassId = comphelper::MimeConfigurationHelper::GetSequenceClassIDRepresentation(aClassIDs[nInd]); + _rClassId = comphelper::MimeConfigurationHelper::GetSequenceClassIDRepresentation(classId); break; } } diff --git a/dbaccess/source/inc/apitools.hxx b/dbaccess/source/inc/apitools.hxx index 315791bd62be..725cebd0b3db 100644 --- a/dbaccess/source/inc/apitools.hxx +++ b/dbaccess/source/inc/apitools.hxx @@ -77,10 +77,9 @@ public: #define IMPLEMENT_SERVICE_INFO_SUPPORTS(classname) \ sal_Bool SAL_CALL classname::supportsService( const OUString& _rServiceName ) \ { \ - css::uno::Sequence< OUString > aSupported(getSupportedServiceNames()); \ - const OUString* pSupported = aSupported.getConstArray(); \ - for (sal_Int32 i=0; i aSupported(getSupportedServiceNames()); \ + for (const OUString& s : aSupported) \ + if (s == _rServiceName) \ return true; \ \ return false; \ diff --git a/dbaccess/source/ui/inc/sbamultiplex.hxx b/dbaccess/source/ui/inc/sbamultiplex.hxx index 920978437036..c71c9cbbeea5 100644 --- a/dbaccess/source/ui/inc/sbamultiplex.hxx +++ b/dbaccess/source/ui/inc/sbamultiplex.hxx @@ -264,11 +264,10 @@ namespace dbaui sal_Int32 classname::getOverallLen() const \ { \ sal_Int32 nLen = 0; \ - css::uno::Sequence< OUString > aContained = m_aListeners.getContainedTypes(); \ - const OUString* pContained = aContained.getConstArray(); \ - for ( sal_Int32 i=0; i aContained = m_aListeners.getContainedTypes(); \ + for ( OUString const & s : aContained) \ { \ - ::cppu::OInterfaceContainerHelper* pListeners = m_aListeners.getContainer(*pContained); \ + ::cppu::OInterfaceContainerHelper* pListeners = m_aListeners.getContainer(s); \ if (!pListeners) \ continue; \ nLen += pListeners->getLength(); \ diff --git a/desktop/source/app/check_ext_deps.cxx b/desktop/source/app/check_ext_deps.cxx index 2d7c2e1b277b..cb32e3b0387a 100644 --- a/desktop/source/app/check_ext_deps.cxx +++ b/desktop/source/app/check_ext_deps.cxx @@ -261,10 +261,8 @@ static bool impl_checkDependencies( const uno::Reference< uno::XComponentContext sal_Int32 const nMax = 2; #endif - for ( sal_Int32 i = 0; i < xAllPackages.getLength(); ++i ) + for ( uno::Sequence< uno::Reference< deployment::XPackage > > const & xPackageList : std::as_const(xAllPackages) ) { - uno::Sequence< uno::Reference< deployment::XPackage > > xPackageList = xAllPackages[i]; - for ( sal_Int32 j = 0; (j xPackage = xPackageList[j]; diff --git a/desktop/source/app/dispatchwatcher.cxx b/desktop/source/app/dispatchwatcher.cxx index 5bf047d591cf..450fd0e1e207 100644 --- a/desktop/source/app/dispatchwatcher.cxx +++ b/desktop/source/app/dispatchwatcher.cxx @@ -188,21 +188,21 @@ void scriptCat(const Reference< XModel >& xDoc ) return; } - Sequence< OUString > aLibNames = xLibraries->getElementNames(); + const Sequence< OUString > aLibNames = xLibraries->getElementNames(); std::cout << "Libraries: " << aLibNames.getLength() << "\n"; - for ( sal_Int32 i = 0 ; i < aLibNames.getLength() ; ++i ) + for (OUString const & libName : aLibNames) { - std::cout << "Library: '" << aLibNames[i] << "' children: "; + std::cout << "Library: '" << libName << "' children: "; Reference< XNameContainer > xContainer; try { - if (!xLibraries->isLibraryLoaded( aLibNames[i] )) - xLibraries->loadLibrary( aLibNames[i] ); + if (!xLibraries->isLibraryLoaded( libName )) + xLibraries->loadLibrary( libName ); xContainer = Reference< XNameContainer >( - xLibraries->getByName( aLibNames[i] ), UNO_QUERY ); + xLibraries->getByName( libName ), UNO_QUERY ); } catch (const css::uno::Exception &e) { - std::cout << "[" << aLibNames[i] << "] - failed to load library: " << e.Message << "\n"; + std::cout << "[" << libName << "] - failed to load library: " << e.Message << "\n"; continue; } if( !xContainer.is() ) diff --git a/desktop/source/deployment/gui/dp_gui_dialog2.cxx b/desktop/source/deployment/gui/dp_gui_dialog2.cxx index a345a87d22a9..d018edad0109 100644 --- a/desktop/source/deployment/gui/dp_gui_dialog2.cxx +++ b/desktop/source/deployment/gui/dp_gui_dialog2.cxx @@ -639,9 +639,8 @@ uno::Sequence< OUString > ExtMgrDialog::raiseAddPicker() const uno::Sequence< uno::Reference< deployment::XPackageTypeInfo > > packageTypes( m_pManager->getExtensionManager()->getSupportedPackageTypes() ); - for ( sal_Int32 pos = 0; pos < packageTypes.getLength(); ++pos ) + for ( uno::Reference< deployment::XPackageTypeInfo > const & xPackageType : packageTypes ) { - uno::Reference< deployment::XPackageTypeInfo > const & xPackageType = packageTypes[ pos ]; const OUString filter( xPackageType->getFileFilter() ); if (!filter.isEmpty()) { diff --git a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx index b6231ab9c73c..00ed69d515de 100644 --- a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx +++ b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx @@ -366,10 +366,9 @@ void ProgressCmdEnv::handle( uno::Reference< task::XInteractionRequest > const & { std::vector< OUString > deps; deps.reserve(depExc.UnsatisfiedDependencies.getLength()); - for (sal_Int32 i = 0; i < depExc.UnsatisfiedDependencies.getLength(); ++i) + for (auto const & i : std::as_const(depExc.UnsatisfiedDependencies)) { - deps.push_back( - dp_misc::Dependencies::getErrorText( depExc.UnsatisfiedDependencies[i]) ); + deps.push_back( dp_misc::Dependencies::getErrorText(i) ); } { SolarMutexGuard guard; diff --git a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx index e42b6e41c172..89aaed148346 100644 --- a/desktop/source/deployment/gui/dp_gui_extlistbox.cxx +++ b/desktop/source/deployment/gui/dp_gui_extlistbox.cxx @@ -145,10 +145,10 @@ void Entry_Impl::checkDependencies() if ( e.Cause >>= depExc ) { OUStringBuffer aMissingDep( DpResId( RID_STR_ERROR_MISSING_DEPENDENCIES ) ); - for ( sal_Int32 i = 0; i < depExc.UnsatisfiedDependencies.getLength(); ++i ) + for ( const auto& i : std::as_const(depExc.UnsatisfiedDependencies) ) { aMissingDep.append("\n"); - aMissingDep.append(dp_misc::Dependencies::getErrorText( depExc.UnsatisfiedDependencies[i])); + aMissingDep.append(dp_misc::Dependencies::getErrorText(i)); } aMissingDep.append("\n"); m_sErrorText = aMissingDep.makeStringAndClear(); diff --git a/desktop/source/deployment/gui/dp_gui_theextmgr.cxx b/desktop/source/deployment/gui/dp_gui_theextmgr.cxx index 66600848abd2..1f3d8d710b03 100644 --- a/desktop/source/deployment/gui/dp_gui_theextmgr.cxx +++ b/desktop/source/deployment/gui/dp_gui_theextmgr.cxx @@ -220,9 +220,9 @@ void TheExtensionManager::checkUpdates() e.Context, anyEx ); } - for ( sal_Int32 i = 0; i < xAllPackages.getLength(); ++i ) + for ( auto const & i : std::as_const(xAllPackages) ) { - uno::Reference< deployment::XPackage > xPackage = dp_misc::getExtensionWithHighestVersion(xAllPackages[i]); + uno::Reference< deployment::XPackage > xPackage = dp_misc::getExtensionWithHighestVersion(i); OSL_ASSERT(xPackage.is()); if ( xPackage.is() ) { @@ -303,13 +303,10 @@ void TheExtensionManager::createPackageList() e.Context, anyEx ); } - for ( sal_Int32 i = 0; i < xAllPackages.getLength(); ++i ) + for ( uno::Sequence< uno::Reference< deployment::XPackage > > const & xPackageList : std::as_const(xAllPackages) ) { - uno::Sequence< uno::Reference< deployment::XPackage > > xPackageList = xAllPackages[i]; - - for ( sal_Int32 j = 0; j < xPackageList.getLength(); ++j ) + for ( uno::Reference< deployment::XPackage > const & xPackage : xPackageList ) { - uno::Reference< deployment::XPackage > xPackage = xPackageList[j]; if ( xPackage.is() ) { PackageState eState = getPackageState( xPackage ); @@ -322,11 +319,10 @@ void TheExtensionManager::createPackageList() } } - uno::Sequence< uno::Reference< deployment::XPackage > > xNoLicPackages = m_xExtensionManager->getExtensionsWithUnacceptedLicenses( SHARED_PACKAGE_MANAGER, + const uno::Sequence< uno::Reference< deployment::XPackage > > xNoLicPackages = m_xExtensionManager->getExtensionsWithUnacceptedLicenses( SHARED_PACKAGE_MANAGER, uno::Reference< ucb::XCommandEnvironment >() ); - for ( sal_Int32 i = 0; i < xNoLicPackages.getLength(); ++i ) + for ( uno::Reference< deployment::XPackage > const & xPackage : xNoLicPackages ) { - uno::Reference< deployment::XPackage > xPackage = xNoLicPackages[i]; if ( xPackage.is() ) { getDialogHelper()->addPackageToList( xPackage, true ); @@ -387,11 +383,11 @@ bool TheExtensionManager::supportsOptions( const uno::Reference< deployment::XPa OSL_ASSERT( aId.IsPresent ); //iterate over all available nodes - uno::Sequence< OUString > seqNames = m_xNameAccessNodes->getElementNames(); + const uno::Sequence< OUString > seqNames = m_xNameAccessNodes->getElementNames(); - for ( int i = 0; i < seqNames.getLength(); i++ ) + for ( OUString const & nodeName : seqNames ) { - uno::Any anyNode = m_xNameAccessNodes->getByName( seqNames[i] ); + uno::Any anyNode = m_xNameAccessNodes->getByName( nodeName ); //If we have a node then it must contain the set of leaves. This is part of OptionsDialog.xcs uno::Reference< XInterface> xIntNode = anyNode.get< uno::Reference< XInterface > >(); uno::Reference< container::XNameAccess > xNode( xIntNode, uno::UNO_QUERY_THROW ); @@ -401,10 +397,10 @@ bool TheExtensionManager::supportsOptions( const uno::Reference< deployment::XPa uno::Reference< container::XNameAccess > xLeaves( xIntLeaves, uno::UNO_QUERY_THROW ); //iterate over all available leaves - uno::Sequence< OUString > seqLeafNames = xLeaves->getElementNames(); - for ( int j = 0; j < seqLeafNames.getLength(); j++ ) + const uno::Sequence< OUString > seqLeafNames = xLeaves->getElementNames(); + for ( OUString const & leafName : seqLeafNames ) { - uno::Any anyLeaf = xLeaves->getByName( seqLeafNames[j] ); + uno::Any anyLeaf = xLeaves->getByName( leafName ); uno::Reference< XInterface > xIntLeaf = anyLeaf.get< uno::Reference< XInterface > >(); uno::Reference< beans::XPropertySet > xLeaf( xIntLeaf, uno::UNO_QUERY_THROW ); //investigate the Id property if it matches the extension identifier which diff --git a/desktop/source/deployment/gui/dp_gui_updatedialog.cxx b/desktop/source/deployment/gui/dp_gui_updatedialog.cxx index 4c5269499f19..60a0337119d5 100644 --- a/desktop/source/deployment/gui/dp_gui_updatedialog.cxx +++ b/desktop/source/deployment/gui/dp_gui_updatedialog.cxx @@ -775,11 +775,10 @@ void UpdateDialog::getIgnoredUpdates() args[0] <<= aValue; uno::Reference< container::XNameAccess > xNameAccess( xConfig->createInstanceWithArguments( "com.sun.star.configuration.ConfigurationAccess", args), uno::UNO_QUERY_THROW ); - uno::Sequence< OUString > aElementNames = xNameAccess->getElementNames(); + const uno::Sequence< OUString > aElementNames = xNameAccess->getElementNames(); - for ( sal_Int32 i = 0; i < aElementNames.getLength(); i++ ) + for ( OUString const & aIdentifier : aElementNames ) { - OUString aIdentifier = aElementNames[i]; OUString aVersion; uno::Any aPropValue( uno::Reference< beans::XPropertySet >( xNameAccess->getByName( aIdentifier ), uno::UNO_QUERY_THROW )->getPropertyValue( PROPERTY_VERSION ) ); diff --git a/desktop/source/deployment/manager/dp_extensionmanager.cxx b/desktop/source/deployment/manager/dp_extensionmanager.cxx index b8c23c60dfdb..39bdbf65cced 100644 --- a/desktop/source/deployment/manager/dp_extensionmanager.cxx +++ b/desktop/source/deployment/manager/dp_extensionmanager.cxx @@ -239,9 +239,8 @@ void ExtensionManager::addExtensionsToMap( ++index; } - for (int i = 0; i < seqExt.getLength(); ++i) + for (const Reference& xExtension : seqExt) { - Reference const & xExtension = seqExt[i]; OUString id = dp_misc::getIdentifier(xExtension); id2extensions::iterator ivec = mapExt.find(id); if (ivec == mapExt.end()) @@ -1142,17 +1141,17 @@ void ExtensionManager::reinstallDeployedExtensions( { const uno::Sequence< Reference > extensions( xPackageManager->getDeployedPackages(xAbortChannel, xCmdEnv)); - for ( sal_Int32 pos = 0; pos < extensions.getLength(); ++pos ) + for ( const Reference& package : extensions ) { try { beans::Optional< beans::Ambiguous< sal_Bool > > registered( - extensions[pos]->isRegistered(xAbortChannel, xCmdEnv)); + package->isRegistered(xAbortChannel, xCmdEnv)); if (registered.IsPresent && !(registered.Value.IsAmbiguous || registered.Value.Value)) { - const OUString id = dp_misc::getIdentifier(extensions[ pos ]); + const OUString id = dp_misc::getIdentifier(package); OSL_ASSERT(!id.isEmpty()); disabledExts.insert(id); } @@ -1172,12 +1171,12 @@ void ExtensionManager::reinstallDeployedExtensions( const uno::Sequence< Reference > extensions( xPackageManager->getDeployedPackages(xAbortChannel, xCmdEnv)); - for ( sal_Int32 pos = 0; pos < extensions.getLength(); ++pos ) + for ( const Reference& package : extensions ) { try { - const OUString id = dp_misc::getIdentifier(extensions[ pos ]); - const OUString fileName = extensions[ pos ]->getName(); + const OUString id = dp_misc::getIdentifier(package); + const OUString fileName = package->getName(); OSL_ASSERT(!id.isEmpty()); activateExtension( id, fileName, disabledExts.find(id) != disabledExts.end(), @@ -1237,10 +1236,8 @@ sal_Bool ExtensionManager::synchronize( { const uno::Sequence > > seqSeqExt = getAllExtensions(xAbortChannel, xCmdEnv); - for (sal_Int32 i = 0; i < seqSeqExt.getLength(); i++) + for (uno::Sequence > const & seqExt : seqSeqExt) { - uno::Sequence > const & seqExt = - seqSeqExt[i]; activateExtension(seqExt, isUserDisabled(seqExt), true, xAbortChannel, xCmdEnv); } diff --git a/desktop/source/deployment/manager/dp_properties.cxx b/desktop/source/deployment/manager/dp_properties.cxx index 46535e0ee0e1..ab5ccc7eb5c7 100644 --- a/desktop/source/deployment/manager/dp_properties.cxx +++ b/desktop/source/deployment/manager/dp_properties.cxx @@ -72,9 +72,8 @@ ExtensionProperties::ExtensionProperties( { m_propFileUrl = urlExtension + "properties"; - for (sal_Int32 i = 0; i < properties.getLength(); i++) + for (css::beans::NamedValue const & v : properties) { - css::beans::NamedValue const & v = properties[i]; if (v.Name == PROP_SUPPRESS_LICENSE) { m_prop_suppress_license = getPropertyValue(v); diff --git a/desktop/source/deployment/misc/dp_misc.cxx b/desktop/source/deployment/misc/dp_misc.cxx index 0621cc51e099..513294535ce8 100644 --- a/desktop/source/deployment/misc/dp_misc.cxx +++ b/desktop/source/deployment/misc/dp_misc.cxx @@ -535,9 +535,9 @@ void disposeBridges(Reference const & ctx) Reference bridgeFac( css::bridge::BridgeFactory::create(ctx) ); const Sequence< Reference >seqBridges = bridgeFac->getExistingBridges(); - for (sal_Int32 i = 0; i < seqBridges.getLength(); i++) + for (const Reference& bridge : seqBridges) { - Reference comp(seqBridges[i], UNO_QUERY); + Reference comp(bridge, UNO_QUERY); if (comp.is()) { try { diff --git a/desktop/source/deployment/misc/dp_platform.cxx b/desktop/source/deployment/misc/dp_platform.cxx index 50ca73a362f4..9e4fd320b39f 100644 --- a/desktop/source/deployment/misc/dp_platform.cxx +++ b/desktop/source/deployment/misc/dp_platform.cxx @@ -189,9 +189,9 @@ bool platform_fits( OUString const & platform_string ) bool hasValidPlatform( css::uno::Sequence const & platformStrings) { bool ret = false; - for (sal_Int32 i = 0; i < platformStrings.getLength(); i++) + for (const OUString& s : platformStrings) { - if ( isPlatformSupported( platformStrings[i] )) + if ( isPlatformSupported( s ) ) { ret = true; break; diff --git a/desktop/source/deployment/misc/dp_ucb.cxx b/desktop/source/deployment/misc/dp_ucb.cxx index 09ce86610cb8..71e7d18a1c9c 100644 --- a/desktop/source/deployment/misc/dp_ucb.cxx +++ b/desktop/source/deployment/misc/dp_ucb.cxx @@ -119,10 +119,9 @@ bool create_folder( RTL_TEXTENCODING_UTF8 ) ); const Sequence infos( parentContent.queryCreatableContentsInfo() ); - for ( sal_Int32 pos = 0; pos < infos.getLength(); ++pos ) + for ( ContentInfo const & info : infos ) { // look KIND_FOLDER: - ContentInfo const & info = infos[ pos ]; if ((info.Attributes & ContentInfoAttribute::KIND_FOLDER) != 0) { // make sure the only required bootstrap property is "Title": diff --git a/desktop/source/deployment/misc/dp_update.cxx b/desktop/source/deployment/misc/dp_update.cxx index 0d6f4acdee45..7116be42bf44 100644 --- a/desktop/source/deployment/misc/dp_update.cxx +++ b/desktop/source/deployment/misc/dp_update.cxx @@ -100,16 +100,16 @@ void getOwnUpdateInfos( uno::Any anyError; //It is unclear from the idl if there can be a null reference returned. //However all valid information should be the same - Sequence > + const Sequence > infos(getUpdateInformation(updateInformation, urls, search_id, anyError)); if (anyError.hasValue()) out_errors.emplace_back(inout.second.extension, anyError); - for (sal_Int32 j = 0; j < infos.getLength(); ++j) + for (const Reference< xml::dom::XElement >& element : infos) { dp_misc::DescriptionInfoset infoset( xContext, - Reference< xml::dom::XNode >(infos[j], UNO_QUERY_THROW)); + Reference< xml::dom::XNode >(element, UNO_QUERY_THROW)); if (!infoset.hasDescription()) continue; std::optional< OUString > result_id(infoset.getIdentifier()); @@ -120,7 +120,7 @@ void getOwnUpdateInfos( if (*result_id != search_id) continue; inout.second.version = infoset.getVersion(); - inout.second.info.set(infos[j], UNO_QUERY_THROW); + inout.second.info.set(element, UNO_QUERY_THROW); break; } } @@ -142,16 +142,16 @@ void getDefaultUpdateInfos( OSL_ASSERT(!sDefaultURL.isEmpty()); Any anyError; - Sequence< Reference< xml::dom::XElement > > + const Sequence< Reference< xml::dom::XElement > > infos( getUpdateInformation( updateInformation, Sequence< OUString >(&sDefaultURL, 1), OUString(), anyError)); if (anyError.hasValue()) out_errors.emplace_back(Reference(), anyError); - for (sal_Int32 i = 0; i < infos.getLength(); ++i) + for (const Reference< xml::dom::XElement >& element : infos) { - Reference< xml::dom::XNode > node(infos[i], UNO_QUERY_THROW); + Reference< xml::dom::XNode > node(element, UNO_QUERY_THROW); dp_misc::DescriptionInfoset infoset(xContext, node); std::optional< OUString > id(infoset.getIdentifier()); if (!id) { diff --git a/desktop/source/deployment/registry/component/dp_component.cxx b/desktop/source/deployment/registry/component/dp_component.cxx index cdc840762068..8cb39ce476bd 100644 --- a/desktop/source/deployment/registry/component/dp_component.cxx +++ b/desktop/source/deployment/registry/component/dp_component.cxx @@ -1105,30 +1105,30 @@ void extractComponentData( if (!registryName.endsWith("/")) { prefix += RTL_CONSTASCII_LENGTH("/"); } - css::uno::Sequence< css::uno::Reference< css::registry::XRegistryKey > > + const css::uno::Sequence< css::uno::Reference< css::registry::XRegistryKey > > keys(registry->openKeys()); css::uno::Reference< css::lang::XMultiComponentFactory > smgr( context->getServiceManager(), css::uno::UNO_SET_THROW); - for (sal_Int32 i = 0; i < keys.getLength(); ++i) { - OUString name(keys[i]->getKeyName().copy(prefix)); + for (css::uno::Reference< css::registry::XRegistryKey > const & key : keys) { + OUString name(key->getKeyName().copy(prefix)); data->implementationNames.push_back(name); css::uno::Reference< css::registry::XRegistryKey > singletons( - keys[i]->openKey("UNO/SINGLETONS")); + key->openKey("UNO/SINGLETONS")); if (singletons.is()) { - sal_Int32 prefix2 = keys[i]->getKeyName().getLength() + + sal_Int32 prefix2 = key->getKeyName().getLength() + RTL_CONSTASCII_LENGTH("/UNO/SINGLETONS/"); - css::uno::Sequence< + const css::uno::Sequence< css::uno::Reference< css::registry::XRegistryKey > > singletonKeys(singletons->openKeys()); - for (sal_Int32 j = 0; j < singletonKeys.getLength(); ++j) { + for (css::uno::Reference< css::registry::XRegistryKey > const & singletonKey : singletonKeys) { data->singletons.emplace_back( - singletonKeys[j]->getKeyName().copy(prefix2), name); + singletonKey->getKeyName().copy(prefix2), name); } } if (factories != nullptr) { factories->push_back( componentLoader->activate( - name, OUString(), componentUrl, keys[i])); + name, OUString(), componentUrl, key)); } } } diff --git a/desktop/source/deployment/registry/dp_backend.cxx b/desktop/source/deployment/registry/dp_backend.cxx index e6339def509a..42bbc65cdb4c 100644 --- a/desktop/source/deployment/registry/dp_backend.cxx +++ b/desktop/source/deployment/registry/dp_backend.cxx @@ -556,13 +556,12 @@ void Package::fireModified() if (container == nullptr) return; - Sequence< Reference > elements( + const Sequence< Reference > elements( container->getElements() ); lang::EventObject evt( static_cast(this) ); - for ( sal_Int32 pos = 0; pos < elements.getLength(); ++pos ) + for ( const Reference& x : elements ) { - Reference xListener( - elements[ pos ], UNO_QUERY ); + Reference xListener( x, UNO_QUERY ); if (xListener.is()) xListener->modified( evt ); } diff --git a/desktop/source/deployment/registry/dp_registry.cxx b/desktop/source/deployment/registry/dp_registry.cxx index 7a63de3250f0..50d0c0c4d68e 100644 --- a/desktop/source/deployment/registry/dp_registry.cxx +++ b/desktop/source/deployment/registry/dp_registry.cxx @@ -184,10 +184,8 @@ void PackageRegistryImpl::insertBackend( const Sequence< Reference > packageTypes( xBackend->getSupportedPackageTypes() ); - for ( sal_Int32 pos = 0; pos < packageTypes.getLength(); ++pos ) + for ( Reference const & xPackageType : packageTypes ) { - Reference const & xPackageType = - packageTypes[ pos ]; m_typesInfos.push_back( xPackageType ); const OUString mediaType( normalizeMediaType( diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 373deb3c7c53..451f3149d67f 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -4347,9 +4347,9 @@ static char* getLanguages(const char* pCommand) boost::property_tree::ptree aValues; boost::property_tree::ptree aChild; OUString sLanguage; - for ( sal_Int32 itLocale = 0; itLocale < aLocales.getLength(); itLocale++ ) + for ( css::lang::Locale const & locale : std::as_const(aLocales) ) { - const LanguageTag aLanguageTag( aLocales[itLocale]); + const LanguageTag aLanguageTag( locale ); sLanguage = SvtLanguageTable::GetLanguageString(aLanguageTag.getLanguageType()); if (sLanguage.startsWith("{") && sLanguage.endsWith("}")) continue; @@ -4467,8 +4467,8 @@ static char* getStyles(LibreOfficeKitDocument* pThis, const char* pCommand) boost::property_tree::ptree aTree; aTree.put("commandName", pCommand); uno::Reference xStyleFamiliesSupplier(pDocument->mxComponent, uno::UNO_QUERY); - uno::Reference xStyleFamilies = xStyleFamiliesSupplier->getStyleFamilies(); - uno::Sequence aStyleFamilies = xStyleFamilies->getElementNames(); + const uno::Reference xStyleFamilies = xStyleFamiliesSupplier->getStyleFamilies(); + const uno::Sequence aStyleFamilies = xStyleFamilies->getElementNames(); static const std::vector aWriterStyles = { @@ -4487,10 +4487,9 @@ static char* getStyles(LibreOfficeKitDocument* pThis, const char* pCommand) std::set aDefaultStyleNames; boost::property_tree::ptree aValues; - for (sal_Int32 nStyleFam = 0; nStyleFam < aStyleFamilies.getLength(); ++nStyleFam) + for (OUString const & sStyleFam : aStyleFamilies) { boost::property_tree::ptree aChildren; - OUString sStyleFam = aStyleFamilies[nStyleFam]; uno::Reference xStyleFamily(xStyleFamilies->getByName(sStyleFam), uno::UNO_QUERY); // Writer provides a huge number of styles, we have a list of 7 "default" styles which @@ -4527,7 +4526,6 @@ static char* getStyles(LibreOfficeKitDocument* pThis, const char* pCommand) // Header & Footer Styles { - OUString sName; boost::property_tree::ptree aChild; boost::property_tree::ptree aChildren; const OUString sPageStyles("PageStyles"); @@ -4536,16 +4534,16 @@ static char* getStyles(LibreOfficeKitDocument* pThis, const char* pCommand) if (xStyleFamilies->hasByName(sPageStyles) && (xStyleFamilies->getByName(sPageStyles) >>= xContainer)) { - uno::Sequence aSeqNames = xContainer->getElementNames(); - for (sal_Int32 itName = 0; itName < aSeqNames.getLength(); itName++) + const uno::Sequence aSeqNames = xContainer->getElementNames(); + for (OUString const & sName : aSeqNames) { bool bIsPhysical; - sName = aSeqNames[itName]; xProperty.set(xContainer->getByName(sName), uno::UNO_QUERY); if (xProperty.is() && (xProperty->getPropertyValue("IsPhysical") >>= bIsPhysical) && bIsPhysical) { - xProperty->getPropertyValue("DisplayName") >>= sName; - aChild.put("", sName.toUtf8()); + OUString displayName; + xProperty->getPropertyValue("DisplayName") >>= displayName; + aChild.put("", displayName.toUtf8()); aChildren.push_back(std::make_pair("", aChild)); } } diff --git a/desktop/source/lib/lokinteractionhandler.cxx b/desktop/source/lib/lokinteractionhandler.cxx index 3dfd602b261a..0933e4c230a7 100644 --- a/desktop/source/lib/lokinteractionhandler.cxx +++ b/desktop/source/lib/lokinteractionhandler.cxx @@ -127,9 +127,9 @@ namespace { /// Just approve the interaction. void selectApproved(uno::Sequence> const &rContinuations) { - for (sal_Int32 i = 0; i < rContinuations.getLength(); ++i) + for (auto const & c : rContinuations) { - uno::Reference xApprove(rContinuations[i], uno::UNO_QUERY); + uno::Reference xApprove(c, uno::UNO_QUERY); if (xApprove.is()) xApprove->select(); } @@ -289,19 +289,19 @@ bool LOKInteractionHandler::handlePasswordRequest(const uno::Sequence const xIPW2(rContinuations[i], uno::UNO_QUERY); + uno::Reference const xIPW2(cont, uno::UNO_QUERY); xIPW2->setPasswordToModify(m_Password); xIPW2->select(); } else { - uno::Reference const xIPW(rContinuations[i], uno::UNO_QUERY); + uno::Reference const xIPW(cont, uno::UNO_QUERY); if (xIPW.is()) { xIPW->setPassword(m_Password); @@ -313,13 +313,13 @@ bool LOKInteractionHandler::handlePasswordRequest(const uno::Sequence const xIPW2(rContinuations[i], uno::UNO_QUERY); + uno::Reference const xIPW2(cont, uno::UNO_QUERY); xIPW2->setRecommendReadOnly(true); xIPW2->select(); } else { - uno::Reference const xAbort(rContinuations[i], uno::UNO_QUERY); + uno::Reference const xAbort(cont, uno::UNO_QUERY); if (xAbort.is()) { xAbort->select(); diff --git a/desktop/source/migration/migration.cxx b/desktop/source/migration/migration.cxx index 4987adf3feb0..25964de3cb79 100644 --- a/desktop/source/migration/migration.cxx +++ b/desktop/source/migration/migration.cxx @@ -306,23 +306,23 @@ void MigrationImpl::readAvailableMigrations(migrations_available& rAvailableMigr { // get supported version names uno::Reference< XNameAccess > aMigrationAccess(getConfigAccess("org.openoffice.Setup/Migration/SupportedVersions"), uno::UNO_SET_THROW); - uno::Sequence< OUString > seqSupportedVersions = aMigrationAccess->getElementNames(); + const uno::Sequence< OUString > seqSupportedVersions = aMigrationAccess->getElementNames(); const OUString aVersionIdentifiers( "VersionIdentifiers" ); const OUString aPriorityIdentifier( "Priority" ); - for (sal_Int32 i=0; i seqVersions; - uno::Reference< XNameAccess > xMigrationData( aMigrationAccess->getByName(seqSupportedVersions[i]), uno::UNO_QUERY_THROW ); + uno::Reference< XNameAccess > xMigrationData( aMigrationAccess->getByName(supportedVersion), uno::UNO_QUERY_THROW ); xMigrationData->getByName( aVersionIdentifiers ) >>= seqVersions; xMigrationData->getByName( aPriorityIdentifier ) >>= nPriority; supported_migration aSupportedMigration; - aSupportedMigration.name = seqSupportedVersions[i]; + aSupportedMigration.name = supportedVersion; aSupportedMigration.nPriority = nPriority; - for (sal_Int32 j=0; j MigrationImpl::dectectUIChangesForAllModules( uno::Reference< embed::XStorage > xToolbar = xModule->openStorageElement(TOOLBAR, embed::ElementModes::READ); if (xToolbar.is()) { - const OUString RESOURCEURL_CUSTOM_ELEMENT("custom_"); - sal_Int32 nCustomLen = 7; - - ::uno::Sequence< OUString > lToolbars = xToolbar->getElementNames(); - for (sal_Int32 j=0; j=nCustomLen && - sToolbarName.copy(0, nCustomLen) == RESOURCEURL_CUSTOM_ELEMENT) + const ::uno::Sequence< OUString > lToolbars = xToolbar->getElementNames(); + for (OUString const & sToolbarName : lToolbars) { + if (sToolbarName.startsWith("custom_")) continue; aModuleInfo.sModuleShortName = sModuleShortName; @@ -875,18 +870,18 @@ void MigrationImpl::compareOldAndNewConfig(const OUString& sParent, std::vector< MigrationItem > vOldItems; std::vector< MigrationItem > vNewItems; - uno::Sequence< beans::PropertyValue > aProp; + uno::Sequence< beans::PropertyValue > aProps; sal_Int32 nOldCount = xIndexOld->getCount(); sal_Int32 nNewCount = xIndexNew->getCount(); for (int n=0; ngetByIndex(n) >>= aProp) { - for(int i=0; i>= aMigrationItem.m_sCommandURL; - else if ( aProp[i].Name == ITEM_DESCRIPTOR_CONTAINER ) - aProp[i].Value >>= aMigrationItem.m_xPopupMenu; + if (xIndexOld->getByIndex(n) >>= aProps) { + for(beans::PropertyValue const & prop : std::as_const(aProps)) { + if ( prop.Name == ITEM_DESCRIPTOR_COMMANDURL ) + prop.Value >>= aMigrationItem.m_sCommandURL; + else if ( prop.Name == ITEM_DESCRIPTOR_CONTAINER ) + prop.Value >>= aMigrationItem.m_xPopupMenu; } if (!aMigrationItem.m_sCommandURL.isEmpty()) @@ -896,12 +891,12 @@ void MigrationImpl::compareOldAndNewConfig(const OUString& sParent, for (int n=0; ngetByIndex(n) >>= aProp) { - for(int i=0; i>= aMigrationItem.m_sCommandURL; - else if ( aProp[i].Name == ITEM_DESCRIPTOR_CONTAINER ) - aProp[i].Value >>= aMigrationItem.m_xPopupMenu; + if (xIndexNew->getByIndex(n) >>= aProps) { + for(beans::PropertyValue const & prop : std::as_const(aProps)) { + if ( prop.Name == ITEM_DESCRIPTOR_COMMANDURL ) + prop.Value >>= aMigrationItem.m_sCommandURL; + else if ( prop.Name == ITEM_DESCRIPTOR_CONTAINER ) + prop.Value >>= aMigrationItem.m_xPopupMenu; } if (!aMigrationItem.m_sCommandURL.isEmpty()) @@ -964,14 +959,14 @@ void MigrationImpl::mergeOldToNewVersion(const uno::Reference< ui::XUIConfigurat uno::Sequence< beans::PropertyValue > aPropSeq; xTemp->getByIndex(i) >>= aPropSeq; - for (sal_Int32 j=0; j>= sCommandURL; + prop.Value >>= sCommandURL; else if ( sPropName == ITEM_DESCRIPTOR_LABEL ) - aPropSeq[j].Value >>= sLabel; + prop.Value >>= sLabel; else if ( sPropName == ITEM_DESCRIPTOR_CONTAINER ) - aPropSeq[j].Value >>= xChild; + prop.Value >>= xChild; } if (sCommandURL == sToken) { @@ -999,9 +994,9 @@ void MigrationImpl::mergeOldToNewVersion(const uno::Reference< ui::XUIConfigurat OUString sCmd; uno::Sequence< beans::PropertyValue > aTempPropSeq; xTemp->getByIndex(i) >>= aTempPropSeq; - for (sal_Int32 j=0; j>= sCmd; + for (beans::PropertyValue const & prop : std::as_const(aTempPropSeq)) { + if ( prop.Name == ITEM_DESCRIPTOR_COMMANDURL ) { + prop.Value >>= sCmd; break; } } @@ -1041,9 +1036,9 @@ uno::Reference< container::XIndexContainer > NewVersionUIInfo::getNewMenubarSett { uno::Reference< container::XIndexContainer > xNewMenuSettings; - for (sal_Int32 i=0; i>= xNewMenuSettings; + for (auto const & prop : m_lNewVersionMenubarSettingsSeq) { + if (prop.Name == sModuleShortName) { + prop.Value >>= xNewMenuSettings; break; } } @@ -1055,13 +1050,13 @@ uno::Reference< container::XIndexContainer > NewVersionUIInfo::getNewToolbarSett { uno::Reference< container::XIndexContainer > xNewToolbarSettings; - for (sal_Int32 i=0; i lToolbarSettingsSeq; - m_lNewVersionToolbarSettingsSeq[i].Value >>= lToolbarSettingsSeq; - for (sal_Int32 j=0; j>= xNewToolbarSettings; + newProp.Value >>= lToolbarSettingsSeq; + for (auto const & prop : std::as_const(lToolbarSettingsSeq)) { + if (prop.Name == sToolbarName) { + prop.Value >>= xNewToolbarSettings; break; } } diff --git a/desktop/source/pkgchk/unopkg/unopkg_app.cxx b/desktop/source/pkgchk/unopkg/unopkg_app.cxx index 8532366885c0..6c9f8ce00bae 100644 --- a/desktop/source/pkgchk/unopkg/unopkg_app.cxx +++ b/desktop/source/pkgchk/unopkg/unopkg_app.cxx @@ -164,15 +164,15 @@ Reference findPackage( Reference const & environment, OUString const & idOrFileName ) { - Sequence< Reference > ps( + const Sequence< Reference > ps( manager->getDeployedExtensions(repository, Reference(), environment ) ); - for ( sal_Int32 i = 0; i < ps.getLength(); ++i ) - if ( dp_misc::getIdentifier( ps[i] ) == idOrFileName ) - return ps[i]; - for ( sal_Int32 i = 0; i < ps.getLength(); ++i ) - if ( ps[i]->getName() == idOrFileName ) - return ps[i]; + for ( auto const & package : ps ) + if ( dp_misc::getIdentifier( package ) == idOrFileName ) + return package; + for ( auto const & package : ps ) + if ( package->getName() == idOrFileName ) + return package; return Reference(); } diff --git a/desktop/test/deployment/active/active_native.cxx b/desktop/test/deployment/active/active_native.cxx index 0f12544b6a6b..b024b5e4ff40 100644 --- a/desktop/test/deployment/active/active_native.cxx +++ b/desktop/test/deployment/active/active_native.cxx @@ -136,7 +136,7 @@ Provider::queryDispatches( { css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > s( Requests.getLength()); - for (sal_Int32 i = 0; i < s.getLength(); ++i) { + for (sal_Int32 i = 0; i < s.(); ++i) { s[i] = queryDispatch( Requests[i].FeatureURL, Requests[i].FrameName, Requests[i].SearchFlags); diff --git a/desktop/test/deployment/passive/passive_native.cxx b/desktop/test/deployment/passive/passive_native.cxx index 83b955a00313..7b95fff8b537 100644 --- a/desktop/test/deployment/passive/passive_native.cxx +++ b/desktop/test/deployment/passive/passive_native.cxx @@ -133,7 +133,7 @@ Provider::queryDispatches( { css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > s( Requests.getLength()); - for (sal_Int32 i = 0; i < s.getLength(); ++i) { + for (sal_Int32 i = 0; i < s.(); ++i) { s[i] = queryDispatch( Requests[i].FeatureURL, Requests[i].FrameName, Requests[i].SearchFlags); diff --git a/dtrans/source/generic/generic_clipboard.cxx b/dtrans/source/generic/generic_clipboard.cxx index 4fa49b3d5ebe..4f358db37336 100644 --- a/dtrans/source/generic/generic_clipboard.cxx +++ b/dtrans/source/generic/generic_clipboard.cxx @@ -45,10 +45,10 @@ void SAL_CALL GenericClipboard::initialize( const Sequence< Any >& aArguments ) { if (!m_bInitialized) { - for (sal_Int32 n = 0, nmax = aArguments.getLength(); n < nmax; n++) - if (aArguments[n].getValueType() == cppu::UnoType::get()) + for (Any const & arg : aArguments) + if (arg.getValueType() == cppu::UnoType::get()) { - aArguments[0] >>= m_aName; + arg >>= m_aName; break; } } diff --git a/dtrans/source/win32/dtobj/DOTransferable.cxx b/dtrans/source/win32/dtobj/DOTransferable.cxx index f90406462c81..8f27e7124e0a 100644 --- a/dtrans/source/win32/dtobj/DOTransferable.cxx +++ b/dtrans/source/win32/dtobj/DOTransferable.cxx @@ -294,8 +294,8 @@ sal_Bool SAL_CALL CDOTransferable::isDataFlavorSupported( const DataFlavor& aFla { OSL_ASSERT( isValidFlavor( aFlavor ) ); - for ( sal_Int32 i = 0; i < m_FlavorList.getLength( ); i++ ) - if ( compareDataFlavors( aFlavor, m_FlavorList[i] ) ) + for ( DataFlavor const & df : std::as_const(m_FlavorList) ) + if ( compareDataFlavors( aFlavor, df ) ) return true; return false; diff --git a/dtrans/test/win32/dnd/dndTest.cxx b/dtrans/test/win32/dnd/dndTest.cxx index b9f1d841e1c5..3a022d98758d 100644 --- a/dtrans/test/win32/dnd/dndTest.cxx +++ b/dtrans/test/win32/dnd/dndTest.cxx @@ -149,7 +149,7 @@ DWORD WINAPI MTAFunc( void* threadData) StartDragData* pData= (StartDragData*)msg.wParam; Sequence seq= pData->transferable->getTransferDataFlavors(); // have a look what flavours are supported - for( int i=0; i aResArgs = m_xDocument->getArgs(); - for ( int nInd = 0; nInd < aResArgs.getLength(); nInd++ ) - if ( aResArgs[nInd].Name == "MacroExecutionMode" ) + const uno::Sequence< beans::PropertyValue > aResArgs = m_xDocument->getArgs(); + for ( beans::PropertyValue const & prop : aResArgs ) + if ( prop.Name == "MacroExecutionMode" ) { - aResArgs[nInd].Value >>= m_nMacroExecMode; + prop.Value >>= m_nMacroExecMode; break; } } @@ -918,13 +918,12 @@ void DocumentHolder::setTitle(const OUString& aDocumentName) uno::Sequence aSeq; if(m_xDocument.is()) { - aSeq = - m_xDocument->getArgs(); - for(sal_Int32 j = 0; j < aSeq.getLength(); ++j) + aSeq = m_xDocument->getArgs(); + for(beans::PropertyValue const & prop : std::as_const(aSeq)) { - if(aSeq[j].Name == "FilterName") + if(prop.Name == "FilterName") { - aSeq[j].Value >>= aFilterName; + prop.Value >>= aFilterName; break; } } @@ -939,11 +938,10 @@ void DocumentHolder::setTitle(const OUString& aDocumentName) if(xNameAccess.is() && (xNameAccess->getByName(aFilterName) >>= aSeq)) { - for(sal_Int32 j = 0; j < aSeq.getLength(); ++j) - if(aSeq[j].Name == - "UIName") + for(beans::PropertyValue const & prop : std::as_const(aSeq)) + if(prop.Name == "UIName") { - aSeq[j].Value >>= m_aFilterName; + prop.Value >>= m_aFilterName; break; } } @@ -1045,12 +1043,12 @@ HRESULT DocumentHolder::GetDocumentBorder( RECT *pRect ) { if ( pRect && m_xDocument.is() ) { - uno::Sequence< beans::PropertyValue > aArgs = m_xDocument->getArgs(); - for ( sal_Int32 nInd = 0; nInd < aArgs.getLength(); nInd++ ) - if ( aArgs[nInd].Name == "DocumentBorder" ) + const uno::Sequence< beans::PropertyValue > aArgs = m_xDocument->getArgs(); + for ( beans::PropertyValue const & prop : aArgs ) + if ( prop.Name == "DocumentBorder" ) { uno::Sequence< sal_Int32 > aRect; - if ( ( aArgs[nInd].Value >>= aRect ) && aRect.getLength() == 4 ) + if ( ( prop.Value >>= aRect ) && aRect.getLength() == 4 ) { pRect->left = aRect[0]; pRect->top = aRect[1]; -- cgit v1.2.3