diff options
author | Julien Nabet <serval2412@yahoo.fr> | 2018-03-09 23:27:25 +0100 |
---|---|---|
committer | Julien Nabet <serval2412@yahoo.fr> | 2018-03-10 09:44:56 +0100 |
commit | 5b2fc10f0cc9f15525c7723764a1feebeceb0d5e (patch) | |
tree | 1d4159a006696d3072dc98fc989c3fbd58e32b7a /dbaccess/source/ui | |
parent | 7c693fc3f7218e1ca0c85a0de76ae84226391256 (diff) |
Modernize a bit more dbaccess
mainly by using for-range loops
but also by simplifying some simple algo
Change-Id: If04cd78e62f80f9575e24f3d50ff1e427454da79
Reviewed-on: https://gerrit.libreoffice.org/51019
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Diffstat (limited to 'dbaccess/source/ui')
25 files changed, 266 insertions, 398 deletions
diff --git a/dbaccess/source/ui/app/AppController.cxx b/dbaccess/source/ui/app/AppController.cxx index d5339f785a0d..c0cc5dded3b9 100644 --- a/dbaccess/source/ui/app/AppController.cxx +++ b/dbaccess/source/ui/app/AppController.cxx @@ -769,12 +769,11 @@ FeatureState OApplicationController::GetState(sal_uInt16 _nId) const std::vector< OUString > aSelected; getSelectionElementNames( aSelected ); bool bAlterableViews = true; - for ( std::vector< OUString >::const_iterator selectedName = aSelected.begin(); - bAlterableViews && ( selectedName != aSelected.end() ) ; - ++selectedName - ) + for (auto const& selectedName : aSelected) { - bAlterableViews &= impl_isAlterableView_nothrow( *selectedName ); + bAlterableViews &= impl_isAlterableView_nothrow(selectedName); + if (!bAlterableViews) + break; } aReturn.bEnabled = bAlterableViews; } @@ -1047,9 +1046,8 @@ void OApplicationController::Execute(sal_uInt16 _nId, const Sequence< PropertyVa ScopedVclPtr<SfxAbstractPasteDialog> pDlg(pFact->CreatePasteDialog( getView() )); std::vector<SotClipboardFormatId> aFormatIds; getSupportedFormats(getContainer()->getElementType(),aFormatIds); - const std::vector<SotClipboardFormatId>::const_iterator aEnd = aFormatIds.end(); - for (std::vector<SotClipboardFormatId>::const_iterator aIter = aFormatIds.begin();aIter != aEnd; ++aIter) - pDlg->Insert(*aIter,""); + for (auto const& formatId : aFormatIds) + pDlg->Insert(formatId,""); const TransferableDataHelper& rClipboard = getViewClipboard(); pasteFormat(pDlg->GetFormat(rClipboard.GetTransferable())); @@ -2788,18 +2786,15 @@ sal_Bool SAL_CALL OApplicationController::select( const Any& _aSelection ) } } } - for ( SelectionByElementType::const_iterator sel = aSelectedElements.begin(); - sel != aSelectedElements.end(); - ++sel - ) + for (auto const& selectedElement : aSelectedElements) { - if ( sel->first == m_eCurrentType ) + if ( selectedElement.first == m_eCurrentType ) { - getContainer()->selectElements( comphelper::containerToSequence(sel->second) ); + getContainer()->selectElements( comphelper::containerToSequence(selectedElement.second) ); } else { - m_aPendingSelection[ sel->first ] = sel->second; + m_aPendingSelection[ selectedElement.first ] = selectedElement.second; } } diff --git a/dbaccess/source/ui/app/AppControllerGen.cxx b/dbaccess/source/ui/app/AppControllerGen.cxx index 99a04d7b76e7..98daf558b3cf 100644 --- a/dbaccess/source/ui/app/AppControllerGen.cxx +++ b/dbaccess/source/ui/app/AppControllerGen.cxx @@ -690,15 +690,14 @@ void OApplicationController::doAction(sal_uInt16 _nId, const ElementOpenMode _eO } std::vector< std::pair< OUString ,Reference< XModel > > > aComponents; - std::vector< OUString>::const_iterator aEnd = aList.end(); - for (std::vector< OUString>::const_iterator aIter = aList.begin(); aIter != aEnd; ++aIter) + for (auto const& elem : aList) { if ( SID_DB_APP_CONVERTTOVIEW == _nId ) - convertToView(*aIter); + convertToView(elem); else { - Reference< XModel > xModel( openElementWithArguments( *aIter, eType, eOpenMode, _nId,aArguments ), UNO_QUERY ); - aComponents.emplace_back( *aIter, xModel ); + Reference< XModel > xModel( openElementWithArguments( elem, eType, eOpenMode, _nId,aArguments ), UNO_QUERY ); + aComponents.emplace_back( elem, xModel ); } } @@ -706,19 +705,19 @@ void OApplicationController::doAction(sal_uInt16 _nId, const ElementOpenMode _eO if ( _eOpenMode == E_OPEN_FOR_MAIL ) { - std::vector< std::pair< OUString ,Reference< XModel > > >::const_iterator componentIter = aComponents.begin(); - std::vector< std::pair< OUString ,Reference< XModel > > >::const_iterator componentEnd = aComponents.end(); SfxMailModel aSendMail; SfxMailModel::SendMailResult eResult = SfxMailModel::SEND_MAIL_OK; - for (; componentIter != componentEnd && SfxMailModel::SEND_MAIL_OK == eResult; ++componentIter) + for (auto const& component : aComponents) { try { - Reference< XModel > xModel(componentIter->second,UNO_QUERY); + Reference< XModel > xModel(component.second,UNO_QUERY); // Send document as e-Mail using stored/default type - eResult = aSendMail.AttachDocument(xModel,componentIter->first); + eResult = aSendMail.AttachDocument(xModel,component.first); ::comphelper::disposeComponent(xModel); + if (eResult != SfxMailModel::SEND_MAIL_OK) + break; } catch(const Exception&) { diff --git a/dbaccess/source/ui/app/AppDetailView.cxx b/dbaccess/source/ui/app/AppDetailView.cxx index e66afd50f6af..e42ca5a4df06 100644 --- a/dbaccess/source/ui/app/AppDetailView.cxx +++ b/dbaccess/source/ui/app/AppDetailView.cxx @@ -472,9 +472,11 @@ void OTasksWindow::fillTaskEntryList( const TaskEntryList& _rList ) // copy the commands so we can use them with the config managers Sequence< OUString > aCommands( _rList.size() ); OUString* pCommands = aCommands.getArray(); - TaskEntryList::const_iterator aEnd = _rList.end(); - for ( TaskEntryList::const_iterator pCopyTask = _rList.begin(); pCopyTask != aEnd; ++pCopyTask, ++pCommands ) - *pCommands = pCopyTask->sUNOCommand; + for (auto const& copyTask : _rList) + { + *pCommands = copyTask.sUNOCommand; + ++pCommands; + } Sequence< Reference< XGraphic> > aImages = xImageMgr->getImages( ImageType::SIZE_DEFAULT | ImageType::COLOR_NORMAL , @@ -483,14 +485,15 @@ void OTasksWindow::fillTaskEntryList( const TaskEntryList& _rList ) const Reference< XGraphic >* pImages( aImages.getConstArray() ); - for ( TaskEntryList::const_iterator pTask = _rList.begin(); pTask != aEnd; ++pTask, ++pImages ) + for (auto const& task : _rList) { - SvTreeListEntry* pEntry = m_aCreation->InsertEntry( pTask->sTitle ); - pEntry->SetUserData( new TaskEntry( *pTask ) ); + SvTreeListEntry* pEntry = m_aCreation->InsertEntry(task.sTitle); + pEntry->SetUserData( new TaskEntry(task) ); Image aImage( *pImages ); m_aCreation->SetExpandedEntryBmp( pEntry, aImage ); m_aCreation->SetCollapsedEntryBmp( pEntry, aImage ); + ++pImages; } } catch(Exception&) @@ -717,12 +720,9 @@ void OApplicationDetailView::impl_fillTaskPaneData( ElementType _eType, TaskPane } // for the remaining entries, assign mnemonics - for ( TaskEntryList::const_iterator pTask = rList.begin(); - pTask != rList.end(); - ++pTask - ) + for (auto const& task : rList) { - aAllMnemonics.CreateMnemonic( pTask->sTitle ); + aAllMnemonics.CreateMnemonic(task.sTitle); // don't do this for now, until our task window really supports mnemonics } } diff --git a/dbaccess/source/ui/app/subcomponentmanager.cxx b/dbaccess/source/ui/app/subcomponentmanager.cxx index 0ede91bdbabc..493339887d9c 100644 --- a/dbaccess/source/ui/app/subcomponentmanager.cxx +++ b/dbaccess/source/ui/app/subcomponentmanager.cxx @@ -337,25 +337,22 @@ namespace dbaui return; // find the sub component whose name changed - for ( SubComponents::iterator comp = m_pData->m_aComponents.begin(); - comp != m_pData->m_aComponents.end(); - ++comp - ) + for (auto & component : m_pData->m_aComponents) { - if ( comp->xDocumentDefinitionProperties != i_rEvent.Source ) + if ( component.xDocumentDefinitionProperties != i_rEvent.Source ) continue; OUString sNewName; OSL_VERIFY( i_rEvent.NewValue >>= sNewName ); #if OSL_DEBUG_LEVEL > 0 - OUString sOldKnownName( comp->sName ); + OUString sOldKnownName( component.sName ); OUString sOldName; OSL_VERIFY( i_rEvent.OldValue >>= sOldName ); OSL_ENSURE( sOldName == sOldKnownName, "SubComponentManager::propertyChange: inconsistency in the old names!" ); #endif - comp->sName = sNewName; + component.sName = sNewName; break; } } @@ -430,12 +427,9 @@ namespace dbaui try { SubComponents aWorkingCopy( m_pData->m_aComponents ); - for ( SubComponents::const_iterator comp = aWorkingCopy.begin(); - comp != aWorkingCopy.end(); - ++comp - ) + for (auto const& elem : aWorkingCopy) { - lcl_closeComponent( *comp ); + lcl_closeComponent(elem); } } catch ( const Exception& ) @@ -521,15 +515,12 @@ namespace dbaui ENSURE_OR_RETURN_FALSE( !i_rName.isEmpty(), "SubComponentManager::closeSubFrames: illegal name!" ); SubComponents aWorkingCopy( m_pData->m_aComponents ); - for ( SubComponents::const_iterator comp = aWorkingCopy.begin(); - comp != aWorkingCopy.end(); - ++comp - ) + for (auto const& elem : aWorkingCopy) { - if ( ( comp->sName != i_rName ) || ( comp->nComponentType != _nComponentType ) ) + if ( ( elem.sName != i_rName ) || ( elem.nComponentType != _nComponentType ) ) continue; - if ( !lcl_closeComponent( *comp ) ) + if ( !lcl_closeComponent(elem) ) return false; } @@ -539,24 +530,21 @@ namespace dbaui bool SubComponentManager::lookupSubComponent( const Reference< XComponent >& i_rComponent, OUString& o_rName, sal_Int32& o_rComponentType ) { - for ( SubComponents::const_iterator comp = m_pData->m_aComponents.begin(); - comp != m_pData->m_aComponents.end(); - ++comp - ) + for (auto const& component : m_pData->m_aComponents) { - if ( ( comp->xModel.is() - && ( comp->xModel == i_rComponent ) + if ( ( component.xModel.is() + && ( component.xModel == i_rComponent ) ) - || ( comp->xController.is() - && ( comp->xController == i_rComponent ) + || ( component.xController.is() + && ( component.xController == i_rComponent ) ) - || ( comp->xFrame.is() - && ( comp->xFrame == i_rComponent ) + || ( component.xFrame.is() + && ( component.xFrame == i_rComponent ) ) ) { - o_rName = comp->sName; - o_rComponentType = comp->nComponentType; + o_rName = component.sName; + o_rComponentType = component.nComponentType; return true; } } diff --git a/dbaccess/source/ui/browser/genericcontroller.cxx b/dbaccess/source/ui/browser/genericcontroller.cxx index 474104a89191..0081edd43106 100644 --- a/dbaccess/source/ui/browser/genericcontroller.cxx +++ b/dbaccess/source/ui/browser/genericcontroller.cxx @@ -366,12 +366,9 @@ namespace void lcl_notifyMultipleStates( XStatusListener& _rListener, FeatureStateEvent& _rEvent, const States& _rStates ) { - for ( States::const_iterator state = _rStates.begin(); - state != _rStates.end(); - ++state - ) + for (auto const& elem : _rStates) { - _rEvent.State = *state; + _rEvent.State = elem; _rListener.statusChanged( _rEvent ); } } @@ -445,18 +442,14 @@ void OGenericUnoController::ImplBroadcastFeatureState(const OUString& _rFeature, // we are notifying them, so we must use a copy of m_arrStatusListener, not // m_arrStatusListener itself Dispatch aNotifyLoop( m_arrStatusListener ); - Dispatch::iterator iterSearch = aNotifyLoop.begin(); - Dispatch::const_iterator iterEnd = aNotifyLoop.end(); - while (iterSearch != iterEnd) + for (auto const& elem : aNotifyLoop) { - DispatchTarget& rCurrent = *iterSearch; - if ( aFeatureCommands.find( rCurrent.aURL.Complete ) != aFeatureCommands.end() ) + if ( aFeatureCommands.find( elem.aURL.Complete ) != aFeatureCommands.end() ) { - aEvent.FeatureURL = rCurrent.aURL; - lcl_notifyMultipleStates( *rCurrent.xListener.get(), aEvent, aStates ); + aEvent.FeatureURL = elem.aURL; + lcl_notifyMultipleStates( *elem.xListener.get(), aEvent, aStates ); } - ++iterSearch; } } @@ -571,12 +564,8 @@ void OGenericUnoController::InvalidateAll() void OGenericUnoController::InvalidateAll_Impl() { // invalidate all supported features - - for ( SupportedFeatures::const_iterator aIter = m_aSupportedFeatures.begin(); - aIter != m_aSupportedFeatures.end(); - ++aIter - ) - ImplBroadcastFeatureState( aIter->first, nullptr, true ); + for (auto const& supportedFeature : m_aSupportedFeatures) + ImplBroadcastFeatureState( supportedFeature.first, nullptr, true ); { ::osl::MutexGuard aGuard( m_aFeatureMutex); @@ -745,10 +734,9 @@ void OGenericUnoController::disposing() EventObject aDisposeEvent; aDisposeEvent.Source = static_cast<XWeak*>(this); Dispatch aStatusListener = m_arrStatusListener; - Dispatch::const_iterator aEnd = aStatusListener.end(); - for (Dispatch::const_iterator aIter = aStatusListener.begin(); aIter != aEnd; ++aIter) + for (auto const& statusListener : aStatusListener) { - aIter->xListener->disposing(aDisposeEvent); + statusListener.xListener->disposing(aDisposeEvent); } m_arrStatusListener.clear(); } @@ -1211,12 +1199,9 @@ bool OGenericUnoController::isCommandEnabled( const OUString& _rCompleteCommandU Sequence< ::sal_Int16 > SAL_CALL OGenericUnoController::getSupportedCommandGroups() { CommandHashMap aCmdHashMap; - for ( SupportedFeatures::const_iterator aIter = m_aSupportedFeatures.begin(); - aIter != m_aSupportedFeatures.end(); - ++aIter - ) - if ( aIter->second.GroupId != CommandGroup::INTERNAL ) - aCmdHashMap.emplace( aIter->second.GroupId, 0 ); + for (auto const& supportedFeature : m_aSupportedFeatures) + if ( supportedFeature.second.GroupId != CommandGroup::INTERNAL ) + aCmdHashMap.emplace( supportedFeature.second.GroupId, 0 ); return comphelper::mapKeysToSequence( aCmdHashMap ); } @@ -1235,14 +1220,11 @@ Sequence< DispatchInformation > SAL_CALL OGenericUnoController::getConfigurableD { std::vector< DispatchInformation > aInformationVector; DispatchInformation aDispatchInfo; - for ( SupportedFeatures::const_iterator aIter = m_aSupportedFeatures.begin(); - aIter != m_aSupportedFeatures.end(); - ++aIter - ) + for (auto const& supportedFeature : m_aSupportedFeatures) { - if ( sal_Int16( aIter->second.GroupId ) == CommandGroup ) + if ( sal_Int16( supportedFeature.second.GroupId ) == CommandGroup ) { - aDispatchInfo = aIter->second; + aDispatchInfo = supportedFeature.second; aInformationVector.push_back( aDispatchInfo ); } } diff --git a/dbaccess/source/ui/browser/sbagrid.cxx b/dbaccess/source/ui/browser/sbagrid.cxx index 5d4583ae4eb5..000d2da02a90 100644 --- a/dbaccess/source/ui/browser/sbagrid.cxx +++ b/dbaccess/source/ui/browser/sbagrid.cxx @@ -205,12 +205,10 @@ void SAL_CALL SbaXGridControl::createPeer(const Reference< css::awt::XToolkit > // TODO: why the hell this whole class does not use any mutex? Reference< css::frame::XDispatch > xDisp(getPeer(), UNO_QUERY); - for ( StatusMultiplexerArray::const_iterator aIter = m_aStatusMultiplexer.begin(); - aIter != m_aStatusMultiplexer.end(); - ++aIter) + for (auto const& elem : m_aStatusMultiplexer) { - if ((*aIter).second.is() && (*aIter).second->getLength()) - xDisp->addStatusListener((*aIter).second.get(), (*aIter).first); + if (elem.second.is() && elem.second->getLength()) + xDisp->addStatusListener(elem.second.get(), elem.first); } } @@ -273,14 +271,12 @@ void SAL_CALL SbaXGridControl::dispose() EventObject aEvt; aEvt.Source = *this; - for ( StatusMultiplexerArray::iterator aIter = m_aStatusMultiplexer.begin(); - aIter != m_aStatusMultiplexer.end(); - ++aIter) + for (auto & elem : m_aStatusMultiplexer) { - if ((*aIter).second.is()) + if (elem.second.is()) { - (*aIter).second->disposeAndClear(aEvt); - (*aIter).second.clear(); + elem.second->disposeAndClear(aEvt); + elem.second.clear(); } } StatusMultiplexerArray().swap(m_aStatusMultiplexer); diff --git a/dbaccess/source/ui/browser/unodatbr.cxx b/dbaccess/source/ui/browser/unodatbr.cxx index ca2dc64699fe..92fec3b8b9f8 100644 --- a/dbaccess/source/ui/browser/unodatbr.cxx +++ b/dbaccess/source/ui/browser/unodatbr.cxx @@ -783,18 +783,12 @@ void SbaTableQueryBrowser::InitializeGridModel(const Reference< css::form::XForm aInitialValues.emplace_back( PROPERTY_MOUSE_WHEEL_BEHAVIOR, makeAny( MouseWheelBehavior::SCROLL_DISABLED ) ); // now set all those values - for ( std::vector< NamedValue >::const_iterator property = aInitialValues.begin(); - property != aInitialValues.end(); - ++property - ) + for (auto const& property : aInitialValues) { - xGridCol->setPropertyValue( property->Name, property->Value ); + xGridCol->setPropertyValue( property.Name, property.Value ); } - for ( std::vector< OUString >::const_iterator copyPropertyName = aCopyProperties.begin(); - copyPropertyName != aCopyProperties.end(); - ++copyPropertyName - ) - xGridCol->setPropertyValue( *copyPropertyName, xColumn->getPropertyValue( *copyPropertyName ) ); + for (auto const& copyPropertyName : aCopyProperties) + xGridCol->setPropertyValue( copyPropertyName, xColumn->getPropertyValue(copyPropertyName) ); xColContainer->insertByName(rName, makeAny(xGridCol)); } @@ -968,19 +962,17 @@ void SAL_CALL SbaTableQueryBrowser::statusChanged( const FeatureStateEvent& _rEv { // search the external dispatcher causing this call Reference< XDispatch > xSource(_rEvent.Source, UNO_QUERY); - ExternalFeaturesMap::iterator aLoop; - for ( aLoop = m_aExternalFeatures.begin(); - aLoop != m_aExternalFeatures.end(); - ++aLoop - ) + bool bFound = false; + for (auto & externalFeature : m_aExternalFeatures) { - if ( _rEvent.FeatureURL.Complete == aLoop->second.aURL.Complete) + if ( _rEvent.FeatureURL.Complete == externalFeature.second.aURL.Complete) { - OSL_ENSURE( xSource.get() == aLoop->second.xDispatcher.get(), "SbaTableQueryBrowser::statusChanged: inconsistent!" ); + bFound = true; + OSL_ENSURE( xSource.get() == externalFeature.second.xDispatcher.get(), "SbaTableQueryBrowser::statusChanged: inconsistent!" ); // update the enabled state - aLoop->second.bEnabled = _rEvent.IsEnabled; + externalFeature.second.bEnabled = _rEvent.IsEnabled; - switch ( aLoop->first ) + switch ( externalFeature.first ) { case ID_BROWSER_DOCUMENT_DATASOURCE: { @@ -1004,14 +996,14 @@ void SAL_CALL SbaTableQueryBrowser::statusChanged( const FeatureStateEvent& _rEv default: // update the toolbox - implCheckExternalSlot( aLoop->first ); + implCheckExternalSlot( externalFeature.first ); break; } break; } } - OSL_ENSURE(aLoop != m_aExternalFeatures.end(), "SbaTableQueryBrowser::statusChanged: don't know who sent this!"); + OSL_ENSURE(bFound, "SbaTableQueryBrowser::statusChanged: don't know who sent this!"); } void SbaTableQueryBrowser::checkDocumentDataSource() @@ -1276,28 +1268,25 @@ void SbaTableQueryBrowser::connectExternalDispatches() } } - for ( ExternalFeaturesMap::iterator feature = m_aExternalFeatures.begin(); - feature != m_aExternalFeatures.end(); - ++feature - ) + for (auto & externalFeature : m_aExternalFeatures) { - feature->second.xDispatcher = xProvider->queryDispatch( - feature->second.aURL, "_parent", FrameSearchFlag::PARENT + externalFeature.second.xDispatcher = xProvider->queryDispatch( + externalFeature.second.aURL, "_parent", FrameSearchFlag::PARENT ); - if ( feature->second.xDispatcher.get() == static_cast< XDispatch* >( this ) ) + if ( externalFeature.second.xDispatcher.get() == static_cast< XDispatch* >( this ) ) { SAL_WARN("dbaccess.ui", "SbaTableQueryBrowser::connectExternalDispatches: this should not happen anymore!" ); // (nowadays, the URLs aren't in our SupportedFeatures list anymore, so we should // not supply a dispatcher for this) - feature->second.xDispatcher.clear(); + externalFeature.second.xDispatcher.clear(); } - if ( feature->second.xDispatcher.is() ) + if ( externalFeature.second.xDispatcher.is() ) { try { - feature->second.xDispatcher->addStatusListener( this, feature->second.aURL ); + externalFeature.second.xDispatcher->addStatusListener( this, externalFeature.second.aURL ); } catch( const Exception& ) { @@ -1305,7 +1294,7 @@ void SbaTableQueryBrowser::connectExternalDispatches() } } - implCheckExternalSlot( feature->first ); + implCheckExternalSlot( externalFeature.first ); } } } @@ -1347,19 +1336,19 @@ void SAL_CALL SbaTableQueryBrowser::disposing( const css::lang::EventObject& _rS ExternalFeaturesMap::const_iterator aEnd = m_aExternalFeatures.end(); while (aLoop != aEnd) { - ExternalFeaturesMap::const_iterator aI = aLoop++; - if ( aI->second.xDispatcher.get() == xSource.get() ) + if ( aLoop->second.xDispatcher.get() == xSource.get() ) { - sal_uInt16 nSlot = aI->first; + sal_uInt16 nSlot = aLoop->first; // remove it - m_aExternalFeatures.erase(aI); + aLoop = m_aExternalFeatures.erase(aLoop); // maybe update the UI implCheckExternalSlot(nSlot); // continue, the same XDispatch may be responsible for more than one URL } + ++aLoop; } } else @@ -1393,16 +1382,13 @@ void SAL_CALL SbaTableQueryBrowser::disposing( const css::lang::EventObject& _rS void SbaTableQueryBrowser::implRemoveStatusListeners() { // clear all old dispatches - for ( ExternalFeaturesMap::const_iterator aLoop = m_aExternalFeatures.begin(); - aLoop != m_aExternalFeatures.end(); - ++aLoop - ) + for (auto const& externalFeature : m_aExternalFeatures) { - if ( aLoop->second.xDispatcher.is() ) + if ( externalFeature.second.xDispatcher.is() ) { try { - aLoop->second.xDispatcher->removeStatusListener( this, aLoop->second.aURL ); + externalFeature.second.xDispatcher->removeStatusListener( this, externalFeature.second.aURL ); } catch (Exception&) { diff --git a/dbaccess/source/ui/control/FieldDescControl.cxx b/dbaccess/source/ui/control/FieldDescControl.cxx index 937a7792b756..05525ceeb9f3 100644 --- a/dbaccess/source/ui/control/FieldDescControl.cxx +++ b/dbaccess/source/ui/control/FieldDescControl.cxx @@ -783,10 +783,8 @@ void OFieldDescControl::ActivateAggregate( EControlType eType ) m_pType->SetDropDownLineCount(20); { const OTypeInfoMap* pTypeInfo = getTypeInfo(); - OTypeInfoMap::const_iterator aIter = pTypeInfo->begin(); - OTypeInfoMap::const_iterator aEnd = pTypeInfo->end(); - for(;aIter != aEnd;++aIter) - m_pType->InsertEntry( aIter->second->aUIName ); + for (auto const& elem : *pTypeInfo) + m_pType->InsertEntry( elem.second->aUIName ); } m_pType->SelectEntryPos(0); InitializeControl(m_pType,HID_TAB_ENT_TYPE,true); diff --git a/dbaccess/source/ui/control/RelationControl.cxx b/dbaccess/source/ui/control/RelationControl.cxx index 6f0465d45410..ad2ea0ba783d 100644 --- a/dbaccess/source/ui/control/RelationControl.cxx +++ b/dbaccess/source/ui/control/RelationControl.cxx @@ -469,22 +469,20 @@ namespace dbaui OTableWindow* pInitialRight = nullptr; // Collect the names of all TabWins - OJoinTableView::OTableWindowMap::const_iterator aIter = m_pTableMap->begin(); - OJoinTableView::OTableWindowMap::const_iterator aEnd = m_pTableMap->end(); - for(;aIter != aEnd;++aIter) + for (auto const& elem : *m_pTableMap) { - m_pLeftTable->InsertEntry(aIter->first); - m_pRightTable->InsertEntry(aIter->first); + m_pLeftTable->InsertEntry(elem.first); + m_pRightTable->InsertEntry(elem.first); if (!pInitialLeft) { - pInitialLeft = aIter->second; - m_strCurrentLeft = aIter->first; + pInitialLeft = elem.second; + m_strCurrentLeft = elem.first; } else if (!pInitialRight) { - pInitialRight = aIter->second; - m_strCurrentRight = aIter->first; + pInitialRight = elem.second; + m_strCurrentRight = elem.first; } } @@ -602,30 +600,28 @@ namespace dbaui bool bValid = !rLines.empty(); if (bValid) { - OConnectionLineDataVec::const_iterator l(rLines.begin()); - const OConnectionLineDataVec::const_iterator le(rLines.end()); - for (; bValid && l!=le; ++l) + for (auto const& line : rLines) { - bValid = ! ((*l)->GetSourceFieldName().isEmpty() || (*l)->GetDestFieldName().isEmpty()); + bValid = ! (line->GetSourceFieldName().isEmpty() || line->GetDestFieldName().isEmpty()); + if (!bValid) + break; } } m_pParentDialog->setValid(bValid); - ORelationControl::ops_type::const_iterator i (m_pRC_Tables->m_ops.begin()); - const ORelationControl::ops_type::const_iterator e (m_pRC_Tables->m_ops.end()); m_pRC_Tables->DeactivateCell(); - for(; i != e; ++i) + for (auto const& elem : m_pRC_Tables->m_ops) { - switch(i->first) + switch(elem.first) { case ORelationControl::DELETE: - m_pRC_Tables->RowRemoved(i->second.first, i->second.second - i->second.first); + m_pRC_Tables->RowRemoved(elem.second.first, elem.second.second - elem.second.first); break; case ORelationControl::INSERT: - m_pRC_Tables->RowInserted(i->second.first, i->second.second - i->second.first); + m_pRC_Tables->RowInserted(elem.second.first, elem.second.second - elem.second.first); break; case ORelationControl::MODIFY: - for(OConnectionLineDataVec::size_type j = i->second.first; j < i->second.second; ++j) + for(OConnectionLineDataVec::size_type j = elem.second.first; j < elem.second.second; ++j) m_pRC_Tables->RowModified(j); break; } diff --git a/dbaccess/source/ui/control/charsetlistbox.cxx b/dbaccess/source/ui/control/charsetlistbox.cxx index 13ff25598c5d..7cc4b15a9212 100644 --- a/dbaccess/source/ui/control/charsetlistbox.cxx +++ b/dbaccess/source/ui/control/charsetlistbox.cxx @@ -31,11 +31,9 @@ namespace dbaui { SetDropDownLineCount( 20 ); - OCharsetDisplay::const_iterator charSet = m_aCharSets.begin(); - while ( charSet != m_aCharSets.end() ) + for (auto const& charset : m_aCharSets) { - InsertEntry( (*charSet).getDisplayName() ); - ++charSet; + InsertEntry( charset.getDisplayName() ); } } diff --git a/dbaccess/source/ui/control/tabletree.cxx b/dbaccess/source/ui/control/tabletree.cxx index 73c1620f5f2a..8ee5c648d37f 100644 --- a/dbaccess/source/ui/control/tabletree.cxx +++ b/dbaccess/source/ui/control/tabletree.cxx @@ -265,16 +265,13 @@ void OTableTreeListBox::UpdateTableList( const Reference< XConnection >& _rxConn return; // get the table/view names - TNames::const_iterator aIter = _rTables.begin(); - TNames::const_iterator aEnd = _rTables.end(); - Reference< XDatabaseMetaData > xMeta( _rxConnection->getMetaData(), UNO_QUERY_THROW ); - for ( ; aIter != aEnd; ++aIter ) + for (auto const& table : _rTables) { // add the entry implAddEntry( xMeta, - aIter->first, + table.first, false ); } @@ -296,14 +293,11 @@ void OTableTreeListBox::UpdateTableList( const Reference< XConnection >& _rxConn sal_Int32 nFolderType = bCatalogs ? DatabaseObjectContainer::CATALOG : DatabaseObjectContainer::SCHEMA; SvTreeListEntry* pRootEntry = getAllObjectsEntry(); - for ( std::vector< OUString >::const_iterator folder = aFolderNames.begin(); - folder != aFolderNames.end(); - ++folder - ) + for (auto const& folderName : aFolderNames) { - SvTreeListEntry* pFolder = GetEntryPosByName( *folder, pRootEntry ); + SvTreeListEntry* pFolder = GetEntryPosByName( folderName, pRootEntry ); if ( !pFolder ) - InsertEntry( *folder, pRootEntry, false, TREELIST_APPEND, reinterpret_cast< void* >( nFolderType ) ); + InsertEntry( folderName, pRootEntry, false, TREELIST_APPEND, reinterpret_cast< void* >( nFolderType ) ); } } } diff --git a/dbaccess/source/ui/dlg/DbAdminImpl.cxx b/dbaccess/source/ui/dlg/DbAdminImpl.cxx index 3dd943d14990..67638a3601ab 100644 --- a/dbaccess/source/ui/dlg/DbAdminImpl.cxx +++ b/dbaccess/source/ui/dlg/DbAdminImpl.cxx @@ -562,24 +562,21 @@ void ODbDataSourceAdministrationHelper::translateProperties(const Reference< XPr { if (_rxSource.is()) { - for ( MapInt2String::const_iterator aDirect = m_aDirectPropTranslator.begin(); - aDirect != m_aDirectPropTranslator.end(); - ++aDirect - ) + for (auto const& elem : m_aDirectPropTranslator) { // get the property value Any aValue; try { - aValue = _rxSource->getPropertyValue(aDirect->second); + aValue = _rxSource->getPropertyValue(elem.second); } catch(Exception&) { SAL_WARN("dbaccess", "ODbDataSourceAdministrationHelper::translateProperties: could not extract the property " - << aDirect->second); + << elem.second); } // transfer it into an item - implTranslateProperty(_rDest, aDirect->first, aValue); + implTranslateProperty(_rDest, elem.first, aValue); } // get the additional information @@ -608,17 +605,14 @@ void ODbDataSourceAdministrationHelper::translateProperties(const Reference< XPr if ( !aInfos.empty() ) { PropertyValue aSearchFor; - MapInt2String::const_iterator aEnd = m_aIndirectPropTranslator.end(); - for ( MapInt2String::const_iterator aIndirect = m_aIndirectPropTranslator.begin(); - aIndirect != aEnd; - ++aIndirect) + for (auto const& elem : m_aIndirectPropTranslator) { - aSearchFor.Name = aIndirect->second; + aSearchFor.Name = elem.second; PropertyValueSet::const_iterator aInfoPos = aInfos.find(aSearchFor); if (aInfos.end() != aInfoPos) // the property is contained in the info sequence // -> transfer it into an item - implTranslateProperty(_rDest, aIndirect->first, aInfoPos->Value); + implTranslateProperty(_rDest, elem.first, aInfoPos->Value); } } @@ -650,30 +644,27 @@ void ODbDataSourceAdministrationHelper::translateProperties(const SfxItemSet& _r const OUString sUrlProp("URL"); // transfer the direct properties - for ( MapInt2String::const_iterator aDirect = m_aDirectPropTranslator.begin(); - aDirect != m_aDirectPropTranslator.end(); - ++aDirect - ) + for (auto const& elem : m_aDirectPropTranslator) { - const SfxPoolItem* pCurrentItem = _rSource.GetItem(static_cast<sal_uInt16>(aDirect->first)); + const SfxPoolItem* pCurrentItem = _rSource.GetItem(static_cast<sal_uInt16>(elem.first)); if (pCurrentItem) { sal_Int16 nAttributes = PropertyAttribute::READONLY; if (xInfo.is()) { - try { nAttributes = xInfo->getPropertyByName(aDirect->second).Attributes; } + try { nAttributes = xInfo->getPropertyByName(elem.second).Attributes; } catch(Exception&) { } } if ((nAttributes & PropertyAttribute::READONLY) == 0) { - if ( sUrlProp == aDirect->second ) + if ( sUrlProp == elem.second ) { Any aValue(makeAny(getConnectionURL())); // aValue <<= OUString(); - lcl_putProperty(_rxDest, aDirect->second,aValue); + lcl_putProperty(_rxDest, elem.second,aValue); } else - implTranslateProperty(_rxDest, aDirect->second, pCurrentItem); + implTranslateProperty(_rxDest, elem.second, pCurrentItem); } } } @@ -708,11 +699,10 @@ void ODbDataSourceAdministrationHelper::fillDatasourceInfo(const SfxItemSet& _rS // collect the translated property values for the relevant items PropertyValueSet aRelevantSettings; MapInt2String::const_iterator aTranslation; - std::vector< sal_Int32>::const_iterator aDetailsEnd = aDetailIds.end(); - for (std::vector< sal_Int32>::const_iterator aIter = aDetailIds.begin();aIter != aDetailsEnd ; ++aIter) + for (auto const& detailId : aDetailIds) { - const SfxPoolItem* pCurrent = _rSource.GetItem(static_cast<sal_uInt16>(*aIter)); - aTranslation = m_aIndirectPropTranslator.find(*aIter); + const SfxPoolItem* pCurrent = _rSource.GetItem(static_cast<sal_uInt16>(detailId)); + aTranslation = m_aIndirectPropTranslator.find(detailId); if ( pCurrent && (m_aIndirectPropTranslator.end() != aTranslation) ) { if ( aTranslation->second == INFO_CHARSET ) @@ -772,25 +762,17 @@ void ODbDataSourceAdministrationHelper::fillDatasourceInfo(const SfxItemSet& _rS // now check the to-be-preserved props std::vector< sal_Int32 > aRemoveIndexes; sal_Int32 nPositionCorrector = 0; - MapInt2String::const_iterator aPreservedEnd = aPreservedSettings.end(); - for ( MapInt2String::const_iterator aPreserved = aPreservedSettings.begin(); - aPreserved != aPreservedEnd; - ++aPreserved - ) + for (auto const& preservedSetting : aPreservedSettings) { - if (aIndirectProps.end() != aIndirectProps.find(aPreserved->second)) + if (aIndirectProps.end() != aIndirectProps.find(preservedSetting.second)) { - aRemoveIndexes.push_back(aPreserved->first - nPositionCorrector); + aRemoveIndexes.push_back(preservedSetting.first - nPositionCorrector); ++nPositionCorrector; } } // now finally remove all such props - std::vector< sal_Int32 >::const_iterator aRemoveEnd = aRemoveIndexes.end(); - for ( std::vector< sal_Int32 >::const_iterator aRemoveIndex = aRemoveIndexes.begin(); - aRemoveIndex != aRemoveEnd; - ++aRemoveIndex - ) - ::comphelper::removeElementAt(_rInfo, *aRemoveIndex); + for (auto const& removeIndex : aRemoveIndexes) + ::comphelper::removeElementAt(_rInfo, removeIndex); } ::connectivity::DriversConfig aDriverConfig(getORB()); @@ -809,21 +791,18 @@ void ODbDataSourceAdministrationHelper::fillDatasourceInfo(const SfxItemSet& _rS sal_Int32 nOldLength = _rInfo.getLength(); _rInfo.realloc(nOldLength + aRelevantSettings.size()); PropertyValue* pAppendValues = _rInfo.getArray() + nOldLength; - PropertyValueSet::const_iterator aRelevantEnd = aRelevantSettings.end(); - for ( PropertyValueSet::const_iterator aLoop = aRelevantSettings.begin(); - aLoop != aRelevantEnd; - ++aLoop, ++pAppendValues - ) + for (auto const& relevantSetting : aRelevantSettings) { - if ( aLoop->Name == INFO_CHARSET ) + if ( relevantSetting.Name == INFO_CHARSET ) { OUString sCharSet; - aLoop->Value >>= sCharSet; + relevantSetting.Value >>= sCharSet; if ( !sCharSet.isEmpty() ) - *pAppendValues = *aLoop; + *pAppendValues = relevantSetting; } else - *pAppendValues = *aLoop; + *pAppendValues = relevantSetting; + ++pAppendValues; } } } diff --git a/dbaccess/source/ui/dlg/DriverSettings.cxx b/dbaccess/source/ui/dlg/DriverSettings.cxx index c5352001ff71..ba388a60c734 100644 --- a/dbaccess/source/ui/dlg/DriverSettings.cxx +++ b/dbaccess/source/ui/dlg/DriverSettings.cxx @@ -36,12 +36,9 @@ void ODriversSettings::getSupportedIndirectSettings( const OUString& _sURLPrefix // central DataSourceUI instance. DataSourceMetaData aMeta( _sURLPrefix ); const FeatureSet& rFeatures( aMeta.getFeatureSet() ); - for ( FeatureSet::const_iterator feature = rFeatures.begin(); - feature != rFeatures.end(); - ++feature - ) + for (auto const& feature : rFeatures) { - _out_rDetailsIds.push_back( *feature ); + _out_rDetailsIds.push_back(feature); } // the rest is configuration-based diff --git a/dbaccess/source/ui/dlg/advancedsettings.cxx b/dbaccess/source/ui/dlg/advancedsettings.cxx index 6fc2d8263ee4..745837bba65c 100644 --- a/dbaccess/source/ui/dlg/advancedsettings.cxx +++ b/dbaccess/source/ui/dlg/advancedsettings.cxx @@ -89,22 +89,19 @@ namespace dbaui const FeatureSet& rFeatures( _rDSMeta.getFeatureSet() ); // create all the check boxes for the boolean settings - for ( BooleanSettingDescs::const_iterator setting = m_aBooleanSettings.begin(); - setting != m_aBooleanSettings.end(); - ++setting - ) + for (auto const& booleanSetting : m_aBooleanSettings) { - sal_uInt16 nItemId = setting->nItemId; + sal_uInt16 nItemId = booleanSetting.nItemId; if ( rFeatures.has( nItemId ) ) { - get(*setting->ppControl, setting->sControlId); - (*setting->ppControl)->SetClickHdl( LINK(this, OGenericAdministrationPage, OnControlModifiedClick) ); - (*setting->ppControl)->Show(); + get(*booleanSetting.ppControl, booleanSetting.sControlId); + (*booleanSetting.ppControl)->SetClickHdl( LINK(this, OGenericAdministrationPage, OnControlModifiedClick) ); + (*booleanSetting.ppControl)->Show(); // check whether this must be a tristate check box const SfxPoolItem& rItem = _rCoreAttrs.Get( nItemId ); if ( nullptr != dynamic_cast< const OptionalBoolItem* >(&rItem) ) - (*setting->ppControl)->EnableTriState(); + (*booleanSetting.ppControl)->EnableTriState(); } } @@ -214,14 +211,11 @@ namespace dbaui void SpecialSettingsPage::fillControls(std::vector< ISaveValueWrapper* >& _rControlList) { - for ( BooleanSettingDescs::const_iterator setting = m_aBooleanSettings.begin(); - setting != m_aBooleanSettings.end(); - ++setting - ) + for (auto const& booleanSetting : m_aBooleanSettings) { - if ( *setting->ppControl ) + if ( *booleanSetting.ppControl ) { - _rControlList.push_back( new OSaveValueWrapper< CheckBox >( *setting->ppControl ) ); + _rControlList.push_back( new OSaveValueWrapper< CheckBox >( *booleanSetting.ppControl ) ); } } @@ -244,18 +238,15 @@ namespace dbaui } // the boolean items - for ( BooleanSettingDescs::const_iterator setting = m_aBooleanSettings.begin(); - setting != m_aBooleanSettings.end(); - ++setting - ) + for (auto const& booleanSetting : m_aBooleanSettings) { - if ( !(*setting->ppControl) ) + if ( !(*booleanSetting.ppControl) ) continue; ::boost::optional< bool > aValue(false); aValue.reset(); - const SfxPoolItem* pItem = _rSet.GetItem<SfxPoolItem>(setting->nItemId); + const SfxPoolItem* pItem = _rSet.GetItem<SfxPoolItem>(booleanSetting.nItemId); if (const SfxBoolItem *pBoolItem = dynamic_cast<const SfxBoolItem*>( pItem) ) { aValue.reset( pBoolItem->GetValue() ); @@ -269,14 +260,14 @@ namespace dbaui if ( !aValue ) { - (*setting->ppControl)->SetState( TRISTATE_INDET ); + (*booleanSetting.ppControl)->SetState( TRISTATE_INDET ); } else { bool bValue = *aValue; - if ( setting->bInvertedDisplay ) + if ( booleanSetting.bInvertedDisplay ) bValue = !bValue; - (*setting->ppControl)->Check( bValue ); + (*booleanSetting.ppControl)->Check( bValue ); } } @@ -301,14 +292,11 @@ namespace dbaui bool bChangedSomething = false; // the boolean items - for ( BooleanSettingDescs::const_iterator setting = m_aBooleanSettings.begin(); - setting != m_aBooleanSettings.end(); - ++setting - ) + for (auto const& booleanSetting : m_aBooleanSettings) { - if ( !*setting->ppControl ) + if ( !*booleanSetting.ppControl ) continue; - fillBool( *_rSet, *setting->ppControl, setting->nItemId, bChangedSomething, setting->bInvertedDisplay ); + fillBool( *_rSet, *booleanSetting.ppControl, booleanSetting.nItemId, bChangedSomething, booleanSetting.bInvertedDisplay ); } // the non-boolean items diff --git a/dbaccess/source/ui/dlg/dbadmin.cxx b/dbaccess/source/ui/dlg/dbadmin.cxx index 5d55c2b1cf6a..d94427f8e54a 100644 --- a/dbaccess/source/ui/dlg/dbadmin.cxx +++ b/dbaccess/source/ui/dlg/dbadmin.cxx @@ -185,11 +185,8 @@ void ODbAdminDialog::impl_resetPages(const Reference< XPropertySet >& _rxDatasou // are set. Select another data source of the same type, where the indirect props are not set (yet). Then, // the indirect property values of the first ds are shown in the second ds ...) const ODbDataSourceAdministrationHelper::MapInt2String& rMap = m_pImpl->getIndirectProperties(); - for ( ODbDataSourceAdministrationHelper::MapInt2String::const_iterator aIndirect = rMap.begin(); - aIndirect != rMap.end(); - ++aIndirect - ) - GetInputSetImpl()->ClearItem( static_cast<sal_uInt16>(aIndirect->first) ); + for (auto const& elem : rMap) + GetInputSetImpl()->ClearItem( static_cast<sal_uInt16>(elem.first) ); // extract all relevant data from the property set of the data source m_pImpl->translateProperties(_rxDatasource, *GetInputSetImpl()); diff --git a/dbaccess/source/ui/dlg/dbwizsetup.cxx b/dbaccess/source/ui/dlg/dbwizsetup.cxx index b0df0e5fbbda..46f8160a29ef 100644 --- a/dbaccess/source/ui/dlg/dbwizsetup.cxx +++ b/dbaccess/source/ui/dlg/dbwizsetup.cxx @@ -186,12 +186,10 @@ void ODbTypeWizDialogSetup::declareAuthDepPath( const OUString& _sURL, PathId _n // collect the elements of the path WizardPath aPath; - svt::RoadmapWizardTypes::WizardPath::const_iterator aIter = _rPaths.begin(); - svt::RoadmapWizardTypes::WizardPath::const_iterator aEnd = _rPaths.end(); - for(;aIter != aEnd;++aIter) + for (auto const& path : _rPaths) { - if ( bHasAuthentication || ( *aIter != PAGE_DBSETUPWIZARD_AUTHENTIFICATION ) ) - aPath.push_back( *aIter ); + if ( bHasAuthentication || ( path != PAGE_DBSETUPWIZARD_AUTHENTIFICATION ) ) + aPath.push_back(path); } // call base method @@ -383,11 +381,8 @@ void ODbTypeWizDialogSetup::resetPages(const Reference< XPropertySet >& _rxDatas // are set. Select another data source of the same type, where the indirect props are not set (yet). Then, // the indirect property values of the first ds are shown in the second ds ...) const ODbDataSourceAdministrationHelper::MapInt2String& rMap = m_pImpl->getIndirectProperties(); - for ( ODbDataSourceAdministrationHelper::MapInt2String::const_iterator aIndirect = rMap.begin(); - aIndirect != rMap.end(); - ++aIndirect - ) - getWriteOutputSet()->ClearItem( static_cast<sal_uInt16>(aIndirect->first) ); + for (auto const& elem : rMap) + getWriteOutputSet()->ClearItem( static_cast<sal_uInt16>(elem.first) ); // extract all relevant data from the property set of the data source m_pImpl->translateProperties(_rxDatasource, *getWriteOutputSet()); diff --git a/dbaccess/source/ui/dlg/dsselect.cxx b/dbaccess/source/ui/dlg/dsselect.cxx index 4a9483eddd4b..6d62c3ee0a23 100644 --- a/dbaccess/source/ui/dlg/dsselect.cxx +++ b/dbaccess/source/ui/dlg/dsselect.cxx @@ -143,12 +143,9 @@ void ODatasourceSelectDialog::fillListBox(const StringBag& _rDatasources) sSelected = m_pDatasource->GetSelectedEntry(); m_pDatasource->Clear(); // fill the list - for ( StringBag::const_iterator aDS = _rDatasources.begin(); - aDS != _rDatasources.end(); - ++aDS - ) + for (auto const& datasource : _rDatasources) { - m_pDatasource->InsertEntry( *aDS ); + m_pDatasource->InsertEntry(datasource); } if (m_pDatasource->GetEntryCount()) diff --git a/dbaccess/source/ui/dlg/generalpage.cxx b/dbaccess/source/ui/dlg/generalpage.cxx index 12b1e62f4fe9..738b33af880b 100644 --- a/dbaccess/source/ui/dlg/generalpage.cxx +++ b/dbaccess/source/ui/dlg/generalpage.cxx @@ -172,12 +172,8 @@ namespace dbaui } } std::sort( aDisplayedTypes.begin(), aDisplayedTypes.end(), DisplayedTypeLess() ); - DisplayedTypes::const_iterator aDisplayEnd = aDisplayedTypes.end(); - for ( DisplayedTypes::const_iterator loop = aDisplayedTypes.begin(); - loop != aDisplayEnd; - ++loop - ) - insertEmbeddedDBTypeEntryData( loop->eType, loop->sDisplayName ); + for (auto const& displayedType : aDisplayedTypes) + insertEmbeddedDBTypeEntryData( displayedType.eType, displayedType.sDisplayName ); } } } diff --git a/dbaccess/source/ui/dlg/indexdialog.cxx b/dbaccess/source/ui/dlg/indexdialog.cxx index 41eb4cf381c8..e2e7adc0986f 100644 --- a/dbaccess/source/ui/dlg/indexdialog.cxx +++ b/dbaccess/source/ui/dlg/indexdialog.cxx @@ -66,13 +66,12 @@ namespace dbaui if (_rLHS.size() != _rRHS.size()) return false; - IndexFields::const_iterator aLeft = _rLHS.begin(); - IndexFields::const_iterator aLeftEnd = _rLHS.end(); IndexFields::const_iterator aRight = _rRHS.begin(); - for (; aLeft != aLeftEnd; ++aLeft, ++aRight) + for (auto const& left : _rLHS) { - if (*aLeft != *aRight) + if (left != *aRight) return false; + ++aRight; } return true; @@ -238,18 +237,16 @@ namespace dbaui m_pClose->SetClickHdl(LINK(this, DbaIndexDialog, OnCloseDialog)); // if all of the indexes have an empty description, we're not interested in displaying it - Indexes::const_iterator aCheck; - - for ( aCheck = m_pIndexes->begin(); - aCheck != m_pIndexes->end(); - ++aCheck - ) + bool bFound = false; + for (auto const& check : *m_pIndexes) { - if (!aCheck->sDescription.isEmpty()) + if (!check.sDescription.isEmpty()) + { + bFound = true; break; + } } - - if (aCheck == m_pIndexes->end()) + if (!bFound) { // hide the controls which are necessary for the description m_pDescription->Hide(); @@ -286,17 +283,17 @@ namespace dbaui Image aPKeyIcon(BitmapEx(BMP_PKEYICON)); // fill the list with the index names m_pIndexList->Clear(); - Indexes::const_iterator aIndexLoop = m_pIndexes->begin(); - Indexes::const_iterator aEnd = m_pIndexes->end(); - for (; aIndexLoop != aEnd; ++aIndexLoop) + sal_Int32 nPos = 0; + for (auto const& indexLoop : *m_pIndexes) { SvTreeListEntry* pNewEntry = nullptr; - if (aIndexLoop->bPrimaryKey) - pNewEntry = m_pIndexList->InsertEntry(aIndexLoop->sName, aPKeyIcon, aPKeyIcon); + if (indexLoop.bPrimaryKey) + pNewEntry = m_pIndexList->InsertEntry(indexLoop.sName, aPKeyIcon, aPKeyIcon); else - pNewEntry = m_pIndexList->InsertEntry(aIndexLoop->sName); + pNewEntry = m_pIndexList->InsertEntry(indexLoop.sName); - pNewEntry->SetUserData(reinterpret_cast< void* >(sal_Int32(aIndexLoop - m_pIndexes->begin()))); + pNewEntry->SetUserData(reinterpret_cast< void* >(nPos)); + ++nPos; } OnIndexSelected(*m_pIndexList); @@ -693,16 +690,13 @@ namespace dbaui // no double fields std::set< OUString > aExistentFields; - for ( IndexFields::const_iterator aFieldCheck = _rPos->aFields.begin(); - aFieldCheck != _rPos->aFields.end(); - ++aFieldCheck - ) + for (auto const& fieldCheck : _rPos->aFields) { - if (aExistentFields.end() != aExistentFields.find(aFieldCheck->sFieldName)) + if (aExistentFields.end() != aExistentFields.find(fieldCheck.sFieldName)) { // a column is specified twice ... won't work anyway, so prevent this here and now OUString sMessage(DBA_RES(STR_INDEXDESIGN_DOUBLE_COLUMN_NAME)); - sMessage = sMessage.replaceFirst("$name$", aFieldCheck->sFieldName); + sMessage = sMessage.replaceFirst("$name$", fieldCheck.sFieldName); std::unique_ptr<weld::MessageDialog> xError(Application::CreateMessageDialog(GetFrameWeld(), VclMessageType::Warning, VclButtonsType::Ok, sMessage)); @@ -710,7 +704,7 @@ namespace dbaui m_pFields->GrabFocus(); return false; } - aExistentFields.insert(aFieldCheck->sFieldName); + aExistentFields.insert(fieldCheck.sFieldName); } return true; diff --git a/dbaccess/source/ui/dlg/indexfieldscontrol.cxx b/dbaccess/source/ui/dlg/indexfieldscontrol.cxx index 1dfa36a4cea4..377913d832e7 100644 --- a/dbaccess/source/ui/dlg/indexfieldscontrol.cxx +++ b/dbaccess/source/ui/dlg/indexfieldscontrol.cxx @@ -165,13 +165,11 @@ namespace dbaui { // do not just copy the array, we may have empty field names (which should not be copied) _rFields.resize(m_aFields.size()); - IndexFields::const_iterator aSource = m_aFields.begin(); - IndexFields::const_iterator aSourceEnd = m_aFields.end(); IndexFields::iterator aDest = _rFields.begin(); - for (; aSource != aSourceEnd; ++aSource) - if (!aSource->sFieldName.isEmpty()) + for (auto const& source : m_aFields) + if (!source.sFieldName.isEmpty()) { - *aDest = *aSource; + *aDest = source; ++aDest; } @@ -400,7 +398,7 @@ namespace dbaui else if (sSelectedEntry.isEmpty() && (nCurrentRow == rowCount - 2)) { // in the (last-1)th row, an empty entry has been selected // -> remove the last row - m_aFields.erase(m_aFields.end() - 1); + m_aFields.pop_back(); RowRemoved(GetRowCount() - 1); Invalidate(GetRowRectPixel(nCurrentRow)); } diff --git a/dbaccess/source/ui/dlg/paramdialog.cxx b/dbaccess/source/ui/dlg/paramdialog.cxx index 7fa6db46298b..ea2e7640459b 100644 --- a/dbaccess/source/ui/dlg/paramdialog.cxx +++ b/dbaccess/source/ui/dlg/paramdialog.cxx @@ -339,16 +339,16 @@ namespace dbaui m_aVisitedParams[m_nCurrentlySelected] |= VisitFlags::Visited; // was it the last "not visited yet" entry ? - std::vector<VisitFlags>::const_iterator aIter; - for ( aIter = m_aVisitedParams.begin(); - aIter < m_aVisitedParams.end(); - ++aIter - ) + bool bVisited = false; + for (auto const& visitedParam : m_aVisitedParams) { - if (!((*aIter) & VisitFlags::Visited)) + if (!(visitedParam & VisitFlags::Visited)) + { + bVisited = true; break; + } } - if (aIter == m_aVisitedParams.end()) + if (!bVisited) { // yes, there isn't another one -> change the "default button" m_pTravelNext->SetStyle(m_pTravelNext->GetStyle() & ~WB_DEFBUTTON); m_pOKBtn->SetStyle(m_pOKBtn->GetStyle() | WB_DEFBUTTON); diff --git a/dbaccess/source/ui/dlg/sqlmessage.cxx b/dbaccess/source/ui/dlg/sqlmessage.cxx index e7f8811da03e..490b2d014a70 100644 --- a/dbaccess/source/ui/dlg/sqlmessage.cxx +++ b/dbaccess/source/ui/dlg/sqlmessage.cxx @@ -326,13 +326,11 @@ OExceptionChainDialog::OExceptionChainDialog(vcl::Window* pParent, const Excepti bool bHave22018 = false; size_t elementPos = 0; - for ( ExceptionDisplayChain::const_iterator loop = m_aExceptions.begin(); - loop != m_aExceptions.end(); - ++loop, ++elementPos - ) + for (auto const& elem : m_aExceptions) { - lcl_insertExceptionEntry( *m_pExceptionList, elementPos, *loop ); - bHave22018 = loop->sSQLState == "22018"; + lcl_insertExceptionEntry(*m_pExceptionList, elementPos, elem); + bHave22018 = elem.sSQLState == "22018"; + ++elementPos; } // if the error has the code 22018, then add an additional explanation @@ -575,12 +573,9 @@ void OSQLMessageBox::impl_addDetailsButton() { // even if the text fits into what we can display, we might need to details button // if there is more non-trivial information in the errors than the mere messages - for ( ExceptionDisplayChain::const_iterator error = m_pImpl->aDisplayInfo.begin(); - error != m_pImpl->aDisplayInfo.end(); - ++error - ) + for (auto const& error : m_pImpl->aDisplayInfo) { - if ( lcl_hasDetails( *error ) ) + if ( lcl_hasDetails(error) ) { bMoreDetailsAvailable = true; break; diff --git a/dbaccess/source/ui/inc/TableFieldDescription.hxx b/dbaccess/source/ui/inc/TableFieldDescription.hxx index 6c40ab18fd2e..bcef693d7ab0 100644 --- a/dbaccess/source/ui/inc/TableFieldDescription.hxx +++ b/dbaccess/source/ui/inc/TableFieldDescription.hxx @@ -118,12 +118,12 @@ namespace dbaui bool HasCriteria() const { - std::vector< OUString>::const_iterator aIter = m_aCriteria.begin(); - std::vector< OUString>::const_iterator aEnd = m_aCriteria.end(); - for(;aIter != aEnd;++aIter) - if(!aIter->isEmpty()) - break; - return aIter != aEnd; + for (auto const& criteria : m_aCriteria) + { + if(!criteria.isEmpty()) + return true; + } + return false; } const std::vector< OUString>& GetCriteria() const { return m_aCriteria; } diff --git a/dbaccess/source/ui/misc/DExport.cxx b/dbaccess/source/ui/misc/DExport.cxx index fae5ddf492a1..10a08db16bba 100644 --- a/dbaccess/source/ui/misc/DExport.cxx +++ b/dbaccess/source/ui/misc/DExport.cxx @@ -281,11 +281,8 @@ ODatabaseExport::ODatabaseExport(const SharedConnection& _rxConnection, ODatabaseExport::~ODatabaseExport() { m_pFormatter = nullptr; - ODatabaseExport::TColumns::const_iterator aIter = m_aDestColumns.begin(); - ODatabaseExport::TColumns::const_iterator aEnd = m_aDestColumns.end(); - - for(;aIter != aEnd;++aIter) - delete aIter->second; + for (auto const& destColumn : m_aDestColumns) + delete destColumn.second; m_vDestVector.clear(); m_aDestColumns.clear(); } @@ -555,10 +552,13 @@ void ODatabaseExport::SetColumnTypes(const TColumnVector* _pList,const OTypeInfo OSL_ENSURE(m_vNumberFormat.size() == m_vColumnSize.size() && m_vColumnSize.size() == _pList->size(),"Illegal columns in list"); Reference< XNumberFormatsSupplier > xSupplier = m_xFormatter->getNumberFormatsSupplier(); Reference< XNumberFormats > xFormats = xSupplier->getNumberFormats(); - TColumnVector::const_iterator aIter = _pList->begin(); - TColumnVector::const_iterator aEnd = _pList->end(); - for(sal_Int32 i= 0;aIter != aEnd && i < static_cast<sal_Int32>(m_vNumberFormat.size()) && i < static_cast<sal_Int32>(m_vColumnSize.size()) ;++aIter,++i) + sal_Int32 minBothSize = std::min<sal_Int32>(m_vNumberFormat.size(), m_vColumnSize.size()); + sal_Int32 i = 0; + for (auto const& elem : *_pList) { + if (i >= minBothSize) + break; + sal_Int32 nDataType; sal_Int32 nLength(0),nScale(0); sal_Int16 nType = m_vNumberFormat[i] & ~NumberFormat::DEFINED; @@ -603,18 +603,19 @@ void ODatabaseExport::SetColumnTypes(const TColumnVector* _pList,const OTypeInfo OTypeInfoMap::const_iterator aFind = _pInfoMap->find(nDataType); if(aFind != _pInfoMap->end()) { - (*aIter)->second->SetType(aFind->second); - (*aIter)->second->SetPrecision(std::min<sal_Int32>(aFind->second->nPrecision,nLength)); - (*aIter)->second->SetScale(std::min<sal_Int32>(aFind->second->nMaximumScale,nScale)); + elem->second->SetType(aFind->second); + elem->second->SetPrecision(std::min<sal_Int32>(aFind->second->nPrecision,nLength)); + elem->second->SetScale(std::min<sal_Int32>(aFind->second->nMaximumScale,nScale)); sal_Int32 nFormatKey = ::dbtools::getDefaultNumberFormat( nDataType, - (*aIter)->second->GetScale(), - (*aIter)->second->IsCurrency(), + elem->second->GetScale(), + elem->second->IsCurrency(), Reference< XNumberFormatTypes>(xFormats,UNO_QUERY), m_aLocale); - (*aIter)->second->SetFormatKey(nFormatKey); + elem->second->SetFormatKey(nFormatKey); } + ++i; } } } @@ -840,12 +841,11 @@ Reference< XPreparedStatement > ODatabaseExport::createPreparedStatment( const R } // create the sql string - std::vector< OUString>::const_iterator aInsertEnd = aInsertList.end(); - for (std::vector< OUString>::const_iterator aInsertIter = aInsertList.begin(); aInsertIter != aInsertEnd; ++aInsertIter) + for (auto const& elem : aInsertList) { - if ( !aInsertIter->isEmpty() ) + if ( !elem.isEmpty() ) { - aSql += *aInsertIter; + aSql += elem; aSql += ","; aValues += "?,"; } diff --git a/dbaccess/source/ui/misc/RowSetDrop.cxx b/dbaccess/source/ui/misc/RowSetDrop.cxx index c1cba83d2490..9bd1dc8a88ca 100644 --- a/dbaccess/source/ui/misc/RowSetDrop.cxx +++ b/dbaccess/source/ui/misc/RowSetDrop.cxx @@ -154,71 +154,70 @@ bool ORowSetImportExport::insertNewRow() { m_xTargetResultSetUpdate->moveToInsertRow(); sal_Int32 i = 1; - std::vector<sal_Int32>::const_iterator aEnd = m_aColumnMapping.end(); - for (std::vector<sal_Int32>::const_iterator aIter = m_aColumnMapping.begin(); aIter != aEnd ;++aIter,++i ) + for (auto const& column : m_aColumnMapping) { - if(*aIter > 0) + if(column > 0) { Any aValue; switch(m_aColumnTypes[i-1]) { case DataType::CHAR: case DataType::VARCHAR: - aValue <<= m_xRow->getString(*aIter); + aValue <<= m_xRow->getString(column); break; case DataType::DECIMAL: case DataType::NUMERIC: - aValue <<= m_xRow->getDouble(*aIter); + aValue <<= m_xRow->getDouble(column); break; case DataType::BIGINT: - aValue <<= m_xRow->getLong(*aIter); + aValue <<= m_xRow->getLong(column); break; case DataType::FLOAT: - aValue <<= m_xRow->getFloat(*aIter); + aValue <<= m_xRow->getFloat(column); break; case DataType::DOUBLE: - aValue <<= m_xRow->getDouble(*aIter); + aValue <<= m_xRow->getDouble(column); break; case DataType::LONGVARCHAR: - aValue <<= m_xRow->getString(*aIter); + aValue <<= m_xRow->getString(column); break; case DataType::LONGVARBINARY: - aValue <<= m_xRow->getBytes(*aIter); + aValue <<= m_xRow->getBytes(column); break; case DataType::DATE: - aValue <<= m_xRow->getDate(*aIter); + aValue <<= m_xRow->getDate(column); break; case DataType::TIME: - aValue <<= m_xRow->getTime(*aIter); + aValue <<= m_xRow->getTime(column); break; case DataType::TIMESTAMP: - aValue <<= m_xRow->getTimestamp(*aIter); + aValue <<= m_xRow->getTimestamp(column); break; case DataType::BIT: case DataType::BOOLEAN: - aValue <<= m_xRow->getBoolean(*aIter); + aValue <<= m_xRow->getBoolean(column); break; case DataType::TINYINT: - aValue <<= m_xRow->getByte(*aIter); + aValue <<= m_xRow->getByte(column); break; case DataType::SMALLINT: - aValue <<= m_xRow->getShort(*aIter); + aValue <<= m_xRow->getShort(column); break; case DataType::INTEGER: - aValue <<= m_xRow->getInt(*aIter); + aValue <<= m_xRow->getInt(column); break; case DataType::REAL: - aValue <<= m_xRow->getDouble(*aIter); + aValue <<= m_xRow->getDouble(column); break; case DataType::BINARY: case DataType::VARBINARY: - aValue <<= m_xRow->getBytes(*aIter); + aValue <<= m_xRow->getBytes(column); break; case DataType::BLOB: - aValue <<= m_xRow->getBlob(*aIter); + aValue <<= m_xRow->getBlob(column); break; case DataType::CLOB: - aValue <<= m_xRow->getClob(*aIter); + aValue <<= m_xRow->getClob(column); break; default: SAL_WARN("dbaccess.ui", "Unknown type"); @@ -228,8 +227,9 @@ bool ORowSetImportExport::insertNewRow() else m_xTargetRowUpdate->updateObject(i,aValue); } - else if(*aIter == 0)//now we have know that we to set this column to null + else if(column == 0)//now we have know that we to set this column to null m_xTargetRowUpdate->updateNull(i); + ++i; } m_xTargetResultSetUpdate->insertRow(); } |