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 ++++---- dbaccess/source/core/dataaccess/databasedocument.cxx | 7 +++---- dbaccess/source/core/dataaccess/documentdefinition.cxx | 8 ++++---- dbaccess/source/inc/apitools.hxx | 7 +++---- dbaccess/source/ui/inc/sbamultiplex.hxx | 7 +++---- 5 files changed, 17 insertions(+), 20 deletions(-) (limited to 'dbaccess') 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(); \ -- cgit