diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-08-15 11:26:29 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-08-15 14:18:49 +0200 |
commit | 5a526f9196a8aeb527a2fc6d7c081812770c28be (patch) | |
tree | 076a324476d79bf397fb97d5884db571106425e8 /dbaccess | |
parent | cf3fb54debffeab546085e648c73c576343be9f4 (diff) |
loplugin:sequenceloop dbaccess..extensions
Change-Id: I0eb33a8e293eb8afd0cf5a933384c44e023a2e6b
Reviewed-on: https://gerrit.libreoffice.org/77498
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'dbaccess')
18 files changed, 40 insertions, 29 deletions
diff --git a/dbaccess/source/core/api/query.cxx b/dbaccess/source/core/api/query.cxx index 76cc0130cc94..ddb1f59c2ef6 100644 --- a/dbaccess/source/core/api/query.cxx +++ b/dbaccess/source/core/api/query.cxx @@ -168,7 +168,8 @@ void OQuery::rebuildColumns() throw RuntimeException(); } - for ( const OUString& rName : xColumns->getElementNames() ) + const Sequence<OUString> aColNames = xColumns->getElementNames(); + for ( const OUString& rName : aColNames ) { Reference<XPropertySet> xSource(xColumns->getByName( rName ),UNO_QUERY); OUString sLabel = rName; diff --git a/dbaccess/source/core/dataaccess/connection.cxx b/dbaccess/source/core/dataaccess/connection.cxx index 313fac79f6f7..988d20182a68 100644 --- a/dbaccess/source/core/dataaccess/connection.cxx +++ b/dbaccess/source/core/dataaccess/connection.cxx @@ -762,7 +762,7 @@ void OConnection::impl_checkTableQueryNames_nothrow() std::set< OUString > aSortedTableNames( aTableNames.begin(), aTableNames.end() ); Reference< XNameAccess > xQueries( getQueries() ); - Sequence< OUString > aQueryNames( xQueries->getElementNames() ); + const Sequence< OUString > aQueryNames( xQueries->getElementNames() ); for ( auto const & queryName : aQueryNames ) { diff --git a/dbaccess/source/core/dataaccess/databasecontext.cxx b/dbaccess/source/core/dataaccess/databasecontext.cxx index 447c85767979..0bcdb475c353 100644 --- a/dbaccess/source/core/dataaccess/databasecontext.cxx +++ b/dbaccess/source/core/dataaccess/databasecontext.cxx @@ -481,7 +481,7 @@ void ODatabaseContext::storeTransientProperties( ODatabaseModelImpl& _rModelImpl if (xSetInfo.is()) aProperties = xSetInfo->getProperties(); - for ( const Property& rProperty : aProperties ) + for ( const Property& rProperty : std::as_const(aProperties) ) { if ( ( ( rProperty.Attributes & PropertyAttribute::TRANSIENT) != 0 ) && ( ( rProperty.Attributes & PropertyAttribute::READONLY) == 0 ) diff --git a/dbaccess/source/core/dataaccess/databasedocument.cxx b/dbaccess/source/core/dataaccess/databasedocument.cxx index 21250ea0723d..b5ee7df84635 100644 --- a/dbaccess/source/core/dataaccess/databasedocument.cxx +++ b/dbaccess/source/core/dataaccess/databasedocument.cxx @@ -571,7 +571,7 @@ namespace { Reference< css::sdb::application::XDatabaseDocumentUI > xDatabaseUI( i_rController, UNO_QUERY_THROW ); - Sequence< Reference< XComponent > > aComponents( xDatabaseUI->getSubComponents() ); + const Sequence< Reference< XComponent > > aComponents( xDatabaseUI->getSubComponents() ); bool isAnyModified = false; for ( auto const & xComponent : aComponents ) diff --git a/dbaccess/source/core/dataaccess/databaseregistrations.cxx b/dbaccess/source/core/dataaccess/databaseregistrations.cxx index 052226a3d921..9178e60efd85 100644 --- a/dbaccess/source/core/dataaccess/databaseregistrations.cxx +++ b/dbaccess/source/core/dataaccess/databaseregistrations.cxx @@ -153,7 +153,7 @@ namespace dbaccess ::utl::OConfigurationNode DatabaseRegistrations::impl_getNodeForName_nothrow( const OUString& _rName ) { - Sequence< OUString > aNames( m_aConfigurationRoot.getNodeNames() ); + const Sequence< OUString > aNames( m_aConfigurationRoot.getNodeNames() ); for ( auto const & nodeName : aNames ) { ::utl::OConfigurationNode aNodeForName = m_aConfigurationRoot.openNode( nodeName ); @@ -241,7 +241,7 @@ namespace dbaccess if ( !m_aConfigurationRoot.isValid() ) throw RuntimeException( OUString(), *this ); - Sequence< OUString > aProgrammaticNames( m_aConfigurationRoot.getNodeNames() ); + const Sequence< OUString > aProgrammaticNames( m_aConfigurationRoot.getNodeNames() ); Sequence< OUString > aDisplayNames( aProgrammaticNames.getLength() ); OUString* pDisplayName = aDisplayNames.getArray(); diff --git a/dbaccess/source/core/dataaccess/datasource.cxx b/dbaccess/source/core/dataaccess/datasource.cxx index 25b3558d275b..4085d705f67b 100644 --- a/dbaccess/source/core/dataaccess/datasource.cxx +++ b/dbaccess/source/core/dataaccess/datasource.cxx @@ -854,7 +854,7 @@ sal_Bool ODatabaseSource::convertFastPropertyValue(Any & rConvertedValue, Any & if (!(rValue >>= aValues)) throw IllegalArgumentException(); - for ( auto const & checkName : aValues ) + for ( auto const & checkName : std::as_const(aValues) ) { if ( checkName.Name.isEmpty() ) throw IllegalArgumentException(); @@ -926,7 +926,7 @@ namespace { // obtain all properties currently known at the bag Reference< XPropertySetInfo > xPSI( _rxPropertyBag->getPropertySetInfo(), UNO_SET_THROW ); - Sequence< Property > aAllExistentProperties( xPSI->getProperties() ); + const Sequence< Property > aAllExistentProperties( xPSI->getProperties() ); Reference< XPropertyState > xPropertyState( _rxPropertyBag, UNO_QUERY_THROW ); @@ -1032,7 +1032,7 @@ void ODatabaseSource::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) con // collect the property attributes of all current settings Reference< XPropertySet > xSettingsAsProps( m_pImpl->m_xSettings, UNO_QUERY_THROW ); Reference< XPropertySetInfo > xPST( xSettingsAsProps->getPropertySetInfo(), UNO_SET_THROW ); - Sequence< Property > aSettings( xPST->getProperties() ); + const Sequence< Property > aSettings( xPST->getProperties() ); std::map< OUString, sal_Int32 > aPropertyAttributes; for ( auto const & setting : aSettings ) { diff --git a/dbaccess/source/core/misc/ContainerMediator.cxx b/dbaccess/source/core/misc/ContainerMediator.cxx index e899f1a16935..0b06d9404ffd 100644 --- a/dbaccess/source/core/misc/ContainerMediator.cxx +++ b/dbaccess/source/core/misc/ContainerMediator.cxx @@ -210,7 +210,7 @@ void OContainerMediator::notifyElementCreated( const OUString& _sName, const Ref // collect the to-be-monitored properties Reference< XPropertySetInfo > xPSI( _xDest->getPropertySetInfo(), UNO_SET_THROW ); - Sequence< Property > aProperties( xPSI->getProperties() ); + const Sequence< Property > aProperties( xPSI->getProperties() ); for ( auto const & property : aProperties ) { if ( ( property.Attributes & PropertyAttribute::READONLY ) != 0 ) diff --git a/dbaccess/source/core/recovery/dbdocrecovery.cxx b/dbaccess/source/core/recovery/dbdocrecovery.cxx index be0e50586da9..e330ce0cbc04 100644 --- a/dbaccess/source/core/recovery/dbdocrecovery.cxx +++ b/dbaccess/source/core/recovery/dbdocrecovery.cxx @@ -242,7 +242,7 @@ namespace dbaccess for (auto const& controller : i_rControllers) { Reference< XDatabaseDocumentUI > xDatabaseUI(controller, UNO_QUERY_THROW); - Sequence< Reference< XComponent > > aComponents( xDatabaseUI->getSubComponents() ); + const Sequence< Reference< XComponent > > aComponents( xDatabaseUI->getSubComponents() ); for ( auto const & component : aComponents ) { diff --git a/dbaccess/source/ext/macromigration/migrationengine.cxx b/dbaccess/source/ext/macromigration/migrationengine.cxx index 254eaaa9091a..59369641b413 100644 --- a/dbaccess/source/ext/macromigration/migrationengine.cxx +++ b/dbaccess/source/ext/macromigration/migrationengine.cxx @@ -966,7 +966,7 @@ namespace dbmm _rContainerLoc.isEmpty() ? OUString() : OUString( _rContainerLoc + "/" ) ); - Sequence< OUString > aElementNames( _rxContainer->getElementNames() ); + const Sequence< OUString > aElementNames( _rxContainer->getElementNames() ); for ( auto const & elementName : aElementNames ) { Any aElement( _rxContainer->getByName( elementName ) ); @@ -1431,7 +1431,7 @@ namespace dbmm Reference< XNameAccess > xSourceLib( xSourceLibraries->getByName( *pSourceLibName ), UNO_QUERY_THROW ); Reference< XNameContainer > xTargetLib( xTargetLibraries->createLibrary( sNewLibName ), UNO_SET_THROW ); - Sequence< OUString > aLibElementNames( xSourceLib->getElementNames() ); + const Sequence< OUString > aLibElementNames( xSourceLib->getElementNames() ); for ( auto const & sourceElementName : aLibElementNames ) { Any aElement = xSourceLib->getByName( sourceElementName ); @@ -1627,7 +1627,7 @@ namespace dbmm return; Reference< XNameReplace > xEvents( xSuppEvents->getEvents(), UNO_SET_THROW ); - Sequence< OUString > aEventNames = xEvents->getElementNames(); + const Sequence< OUString > aEventNames = xEvents->getElementNames(); Any aEvent; for ( auto const & eventName : aEventNames ) @@ -1658,7 +1658,7 @@ namespace dbmm { Reference< XScriptEventsSupplier > xEventsSupplier( _rxElement, UNO_QUERY_THROW ); Reference< XNameReplace > xEvents( xEventsSupplier->getEvents(), UNO_QUERY_THROW ); - Sequence< OUString > aEventNames( xEvents->getElementNames() ); + const Sequence< OUString > aEventNames( xEvents->getElementNames() ); ScriptEventDescriptor aScriptEvent; for ( OUString const & eventName : aEventNames ) diff --git a/dbaccess/source/ui/browser/exsrcbrw.cxx b/dbaccess/source/ui/browser/exsrcbrw.cxx index d835731c3df1..597ab6a73dff 100644 --- a/dbaccess/source/ui/browser/exsrcbrw.cxx +++ b/dbaccess/source/ui/browser/exsrcbrw.cxx @@ -182,7 +182,7 @@ void SAL_CALL SbaExternalSourceBrowser::dispatch(const css::util::URL& aURL, con // set its properties if (xNewColProperties.is()) { - for (const css::beans::PropertyValue& rControlProp : aControlProps) + for (const css::beans::PropertyValue& rControlProp : std::as_const(aControlProps)) { try { diff --git a/dbaccess/source/ui/browser/formadapter.cxx b/dbaccess/source/ui/browser/formadapter.cxx index cd1400a5c15f..aea58079ff23 100644 --- a/dbaccess/source/ui/browser/formadapter.cxx +++ b/dbaccess/source/ui/browser/formadapter.cxx @@ -1202,7 +1202,8 @@ Reference< css::beans::XPropertySetInfo > SAL_CALL SbaXFormAdapter::getPropertyS if (-1 == m_nNamePropHandle) { // we need to determine the handle for the NAME property - for (const css::beans::Property& rProp : xReturn->getProperties()) + const Sequence<css::beans::Property> aProps = xReturn->getProperties(); + for (const css::beans::Property& rProp : aProps) { if (rProp.Name == PROPERTY_NAME) { diff --git a/dbaccess/source/ui/browser/unodatbr.cxx b/dbaccess/source/ui/browser/unodatbr.cxx index f28149f84284..6903e7c5565e 100644 --- a/dbaccess/source/ui/browser/unodatbr.cxx +++ b/dbaccess/source/ui/browser/unodatbr.cxx @@ -657,7 +657,8 @@ void SbaTableQueryBrowser::InitializeGridModel(const Reference< css::form::XForm OUString sDefaultProperty; Reference< XPropertySet > xColumn; Reference< XPropertySetInfo > xColPSI; - for (const OUString& rName : xColumns->getElementNames()) + const Sequence<OUString> aColNames = xColumns->getElementNames(); + for (const OUString& rName : aColNames) { xColumn.set( xColumns->getByName( rName ), UNO_QUERY_THROW ); xColPSI.set( xColumn->getPropertySetInfo(), UNO_SET_THROW ); @@ -2059,7 +2060,8 @@ void SbaTableQueryBrowser::initializeTreeModel() OUString sQueriesName, sTablesName; // fill the model with the names of the registered datasources - for (const OUString& rDatasource : m_xDatabaseContext->getElementNames()) + const Sequence<OUString> aDatasourceNames = m_xDatabaseContext->getElementNames(); + for (const OUString& rDatasource : aDatasourceNames) implAddDatasource( rDatasource, aDBImage, sQueriesName, aQueriesImage, sTablesName, aTablesImage, SharedConnection() ); } } @@ -2074,7 +2076,8 @@ void SbaTableQueryBrowser::populateTree(const Reference<XNameAccess>& _xNameAcce try { - for (const OUString& rName : _xNameAccess->getElementNames()) + const Sequence<OUString> aNames = _xNameAccess->getElementNames(); + for (const OUString& rName : aNames) { if( !m_pTreeView->getListBox().GetEntryPosByName(rName,_pParent)) { @@ -3557,7 +3560,8 @@ void SbaTableQueryBrowser::clearGridColumns(const Reference< XNameContainer >& _ { // first we have to clear the grid Reference< XInterface > xColumn; - for (const OUString& rName : _xColContainer->getElementNames()) + const Sequence<OUString> aColNames = _xColContainer->getElementNames(); + for (const OUString& rName : aColNames) { _xColContainer->getByName(rName) >>= xColumn; _xColContainer->removeByName(rName); diff --git a/dbaccess/source/ui/dlg/DbAdminImpl.cxx b/dbaccess/source/ui/dlg/DbAdminImpl.cxx index 26ffae2aff03..2d12a18ad546 100644 --- a/dbaccess/source/ui/dlg/DbAdminImpl.cxx +++ b/dbaccess/source/ui/dlg/DbAdminImpl.cxx @@ -583,7 +583,7 @@ void ODbDataSourceAdministrationHelper::translateProperties(const Reference< XPr // collect the names of the additional settings PropertyValueSet aInfos; - for (const PropertyValue& rAdditionalInfo : aAdditionalInfo) + for (const PropertyValue& rAdditionalInfo : std::as_const(aAdditionalInfo)) { if( rAdditionalInfo.Name == "JDBCDRV" ) { // compatibility diff --git a/dbaccess/source/ui/dlg/adtabdlg.cxx b/dbaccess/source/ui/dlg/adtabdlg.cxx index 1add8474188e..9cb22f5fbb10 100644 --- a/dbaccess/source/ui/dlg/adtabdlg.cxx +++ b/dbaccess/source/ui/dlg/adtabdlg.cxx @@ -300,7 +300,7 @@ void QueryListFacade::updateTableObjectList( bool /*_bAllowViews*/ ) Reference< XContainer> xContainer(xQueries,UNO_QUERY_THROW); m_pContainerListener = new ::comphelper::OContainerListenerAdapter(this,xContainer); } - Sequence< OUString > aQueryNames = xQueries->getElementNames(); + const Sequence< OUString > aQueryNames = xQueries->getElementNames(); for ( auto const & name : aQueryNames ) m_rQueryList.append("", name, aQueryImage); diff --git a/dbaccess/source/ui/dlg/dbfindex.cxx b/dbaccess/source/ui/dlg/dbfindex.cxx index fe934b7914c0..42bcff9585e7 100644 --- a/dbaccess/source/ui/dlg/dbfindex.cxx +++ b/dbaccess/source/ui/dlg/dbfindex.cxx @@ -261,7 +261,8 @@ void ODbaseIndexDialog::Init() std::vector< OUString > aUsedIndexes; aURL.SetSmartProtocol(INetProtocol::File); - for(const OUString& rURL : ::utl::LocalFileHelper::GetFolderContents(m_aDSN, bFolder)) + const Sequence<OUString> aFolderUrls = ::utl::LocalFileHelper::GetFolderContents(m_aDSN, bFolder); + for(const OUString& rURL : aFolderUrls) { OUString aName; osl::FileBase::getSystemPathFromFileURL(rURL,aName); diff --git a/dbaccess/source/ui/misc/UITools.cxx b/dbaccess/source/ui/misc/UITools.cxx index 4cd6b43d889f..47414efe08ab 100644 --- a/dbaccess/source/ui/misc/UITools.cxx +++ b/dbaccess/source/ui/misc/UITools.cxx @@ -908,7 +908,7 @@ bool appendToFilter(const Reference<XConnection>& _xConnection, xProp->getPropertyValue(PROPERTY_TABLEFILTER) >>= aFilter; // first check if we have something like SCHEMA.% bool bHasToInsert = true; - for (const OUString& rItem : aFilter) + for (const OUString& rItem : std::as_const(aFilter)) { if(rItem.indexOf('%') != -1) { diff --git a/dbaccess/source/ui/querydesign/QueryTableView.cxx b/dbaccess/source/ui/querydesign/QueryTableView.cxx index 2cab54cad51d..f6123e2b9676 100644 --- a/dbaccess/source/ui/querydesign/QueryTableView.cxx +++ b/dbaccess/source/ui/querydesign/QueryTableView.cxx @@ -137,7 +137,8 @@ namespace OUString sRelatedColumn; // iterate through all foreignkey columns to create the connections - for(const OUString& rElement : _rxSourceForeignKeyColumns->getElementNames()) + const Sequence<OUString> aKeyCols = _rxSourceForeignKeyColumns->getElementNames(); + for(const OUString& rElement : aKeyCols) { Reference<XPropertySet> xColumn; if ( !( _rxSourceForeignKeyColumns->getByName(rElement) >>= xColumn ) ) diff --git a/dbaccess/source/ui/tabledesign/TableController.cxx b/dbaccess/source/ui/tabledesign/TableController.cxx index 3aff255781d2..b7b8a11b4579 100644 --- a/dbaccess/source/ui/tabledesign/TableController.cxx +++ b/dbaccess/source/ui/tabledesign/TableController.cxx @@ -777,7 +777,8 @@ void OTableController::loadData() // sal_Bool bReadOldRow = xMetaData->supportsAlterTableWithAddColumn() && xMetaData->supportsAlterTableWithDropColumn(); bool bIsAlterAllowed = isAlterAllowed(); - for(const OUString& rColumn : xColumns->getElementNames()) + const Sequence<OUString> aColNames = xColumns->getElementNames(); + for(const OUString& rColumn : aColNames) { Reference<XPropertySet> xColumn; xColumns->getByName(rColumn) >>= xColumn; @@ -847,7 +848,8 @@ void OTableController::loadData() Reference<XNameAccess> xKeyColumns = getKeyColumns(); if(xKeyColumns.is()) { - for(const OUString& rKeyColumn : xKeyColumns->getElementNames()) + const Sequence<OUString> aKeyColumnNames = xKeyColumns->getElementNames(); + for(const OUString& rKeyColumn : aKeyColumnNames) { for(std::shared_ptr<OTableRow> const& pRow : m_vRowList) { @@ -1158,7 +1160,8 @@ void OTableController::alterColumns() // now we have to look for the columns who could be deleted if ( xDrop.is() ) { - for(const OUString& rColumnName : xColumns->getElementNames()) + const Sequence<OUString> aColNames = xColumns->getElementNames(); + for(const OUString& rColumnName : aColNames) { if(aColumns.find(rColumnName) == aColumns.end()) // found a column to delete { |