Kaydet (Commit) 6a143985 authored tarafından Arkadiy Illarionov's avatar Arkadiy Illarionov Kaydeden (comit) Noel Grandin

Simplify containers iterations in desktop, dtrans, editeng, extensions

Use range-based loop or replace with STL functions

Change-Id: Ic5389d123d0a6a32a8bb46b081165e94a7c55292
Reviewed-on: https://gerrit.libreoffice.org/68036
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst d707a5e6
......@@ -885,15 +885,12 @@ bool ExtensionBox_Impl::FindEntryPos( const TEntry_Impl& rEntry, const long nSta
void ExtensionBox_Impl::cleanVecListenerAdded()
{
auto i = m_vListenerAdded.begin();
while( i != m_vListenerAdded.end())
{
const uno::Reference<deployment::XPackage> hardRef(*i);
if (!hardRef.is())
i = m_vListenerAdded.erase(i);
else
++i;
}
m_vListenerAdded.erase(std::remove_if(m_vListenerAdded.begin(), m_vListenerAdded.end(),
[](const uno::WeakReference<deployment::XPackage>& rxListener) {
const uno::Reference<deployment::XPackage> hardRef(rxListener);
return !hardRef.is();
}),
m_vListenerAdded.end());
}
void ExtensionBox_Impl::addEventListenerOnce(
......@@ -1003,39 +1000,37 @@ void ExtensionBox_Impl::removeEntry( const uno::Reference< deployment::XPackage
{
::osl::ClearableMutexGuard aGuard( m_entriesMutex );
for ( auto iIndex = m_vEntries.begin(); iIndex != m_vEntries.end(); ++iIndex )
auto iIndex = std::find_if(m_vEntries.begin(), m_vEntries.end(),
[&xPackage](const TEntry_Impl& rxEntry) { return rxEntry->m_xPackage == xPackage; });
if (iIndex != m_vEntries.end())
{
if ( (*iIndex)->m_xPackage == xPackage )
long nPos = iIndex - m_vEntries.begin();
// Entries mustn't be removed here, because they contain a hyperlink control
// which can only be deleted when the thread has the solar mutex. Therefore
// the entry will be moved into the m_vRemovedEntries list which will be
// cleared on the next paint event
m_vRemovedEntries.push_back( *iIndex );
(*iIndex)->m_xPackage->removeEventListener(m_xRemoveListener.get());
m_vEntries.erase( iIndex );
m_bNeedsRecalc = true;
if ( IsReallyVisible() )
invalidate = true;
if ( m_bHasActive )
{
long nPos = iIndex - m_vEntries.begin();
// Entries mustn't be removed here, because they contain a hyperlink control
// which can only be deleted when the thread has the solar mutex. Therefore
// the entry will be moved into the m_vRemovedEntries list which will be
// cleared on the next paint event
m_vRemovedEntries.push_back( *iIndex );
(*iIndex)->m_xPackage->removeEventListener(m_xRemoveListener.get());
m_vEntries.erase( iIndex );
m_bNeedsRecalc = true;
if ( IsReallyVisible() )
invalidate = true;
if ( m_bHasActive )
{
if ( nPos < m_nActive )
m_nActive -= 1;
else if ( ( nPos == m_nActive ) &&
( nPos == static_cast<long>(m_vEntries.size()) ) )
m_nActive -= 1;
m_bHasActive = false;
//clear before calling out of this method
aGuard.clear();
selectEntry( m_nActive );
}
break;
if ( nPos < m_nActive )
m_nActive -= 1;
else if ( ( nPos == m_nActive ) &&
( nPos == static_cast<long>(m_vEntries.size()) ) )
m_nActive -= 1;
m_bHasActive = false;
//clear before calling out of this method
aGuard.clear();
selectEntry( m_nActive );
}
}
}
......
......@@ -337,18 +337,11 @@ bool MigrationImpl::checkMigrationCompleted()
static void insertSorted(migrations_available& rAvailableMigrations, supported_migration const & aSupportedMigration)
{
bool bInserted( false );
migrations_available::iterator pIter = rAvailableMigrations.begin();
while (pIter != rAvailableMigrations.end())
{
if ( pIter->nPriority < aSupportedMigration.nPriority ) {
rAvailableMigrations.insert(pIter, aSupportedMigration );
bInserted = true;
break; // i111193: insert invalidates iterator!
}
++pIter;
}
if ( !bInserted )
migrations_available::iterator pIter = std::find_if(rAvailableMigrations.begin(), rAvailableMigrations.end(),
[&aSupportedMigration](const supported_migration& rMigration) { return rMigration.nPriority < aSupportedMigration.nPriority; });
if (pIter != rAvailableMigrations.end())
rAvailableMigrations.insert(pIter, aSupportedMigration );
else
rAvailableMigrations.push_back( aSupportedMigration );
}
......
......@@ -20,6 +20,7 @@
#include <sal/config.h>
#include <com/sun/star/container/NoSuchElementException.hpp>
#include <comphelper/sequence.hxx>
#include <rtl/ustring.hxx>
#include <tools/inetmime.hxx>
......@@ -51,18 +52,7 @@ OUString SAL_CALL CMimeContentType::getFullMediaType( )
Sequence< OUString > SAL_CALL CMimeContentType::getParameters( )
{
Sequence< OUString > seqParams;
map< OUString, OUString >::iterator iter;
map< OUString, OUString >::iterator iter_end = m_ParameterMap.end( );
for ( iter = m_ParameterMap.begin( ); iter != iter_end; ++iter )
{
seqParams.realloc( seqParams.getLength( ) + 1 );
seqParams[seqParams.getLength( ) - 1] = iter->first;
}
return seqParams;
return comphelper::mapKeysToSequence(m_ParameterMap);
}
sal_Bool SAL_CALL CMimeContentType::hasParameter( const OUString& aName )
......
......@@ -93,14 +93,13 @@ sal_Bool processCntTypesAndWriteResultIntoFile( char* fname, vector< string >& v
// set pointer to file start
fseek( fstream, 0, SEEK_SET );
vector< string >::iterator iter_end = vecData.end( );
for ( vector< string >::iterator iter = vecData.begin( ); iter != iter_end; ++iter )
for ( const auto& rData : vecData )
{
try
{
fprintf( fstream, "Read: %s\n", iter->c_str( ) );
fprintf( fstream, "Read: %s\n", rData.c_str( ) );
Reference< XMimeContentType > xMCntTyp = cnttypeFactory->createMimeContentType( OUString::createFromAscii( iter->c_str( ) ) );
Reference< XMimeContentType > xMCntTyp = cnttypeFactory->createMimeContentType( OUString::createFromAscii( rData.c_str( ) ) );
fwprintf( fstream, OUString("Type: %s\n"), xMCntTyp->getMediaType( ).getStr( ) );
fwprintf( fstream, OUString("Subtype: %s\n"), xMCntTyp->getMediaSubtype( ).getStr( ) );
......
......@@ -355,38 +355,27 @@ namespace {
void findDataFlavorForStandardFormatId( sal_Int32 aStandardFormatId, DataFlavor& aDataFlavor )
{
/*
we break the for loop if we find the first CF_INVALID
we stop search if we find the first CF_INVALID
because in the translation table the entries with a
standard clipboard format id appear before the other
entries with CF_INVALID
*/
vector< FormatEntry >::const_iterator citer_end = g_TranslTable.end( );
for ( vector< FormatEntry >::const_iterator citer = g_TranslTable.begin( ); citer != citer_end; ++citer )
{
sal_Int32 stdId = citer->aStandardFormatId;
if ( aStandardFormatId == stdId )
{
aDataFlavor = citer->aDataFlavor;
break;
}
else if ( stdId == CF_INVALID )
break;
}
vector< FormatEntry >::const_iterator citer = std::find_if(g_TranslTable.begin(), g_TranslTable.end(),
[&aStandardFormatId](const FormatEntry& rEntry) {
return rEntry.aStandardFormatId == aStandardFormatId
|| rEntry.aStandardFormatId == CF_INVALID;
});
if (citer != g_TranslTable.end() && citer->aStandardFormatId == aStandardFormatId)
aDataFlavor = citer->aDataFlavor;
}
void findDataFlavorForNativeFormatName( const OUString& aNativeFormatName, DataFlavor& aDataFlavor )
{
vector< FormatEntry >::const_iterator citer_end = g_TranslTable.end( );
for ( vector< FormatEntry >::const_iterator citer = g_TranslTable.begin( );
citer != citer_end;
++citer )
{
if ( aNativeFormatName.equalsIgnoreAsciiCase( citer->aNativeFormatName ) )
{
aDataFlavor = citer->aDataFlavor;
break;
}
}
vector< FormatEntry >::const_iterator citer = std::find_if(g_TranslTable.begin(), g_TranslTable.end(),
[&aNativeFormatName](const FormatEntry& rEntry) {
return aNativeFormatName.equalsIgnoreAsciiCase(rEntry.aNativeFormatName); });
if (citer != g_TranslTable.end())
aDataFlavor = citer->aDataFlavor;
}
void findStandardFormatIdForCharset( const OUString& aCharset, Any& aAny )
......@@ -403,16 +392,13 @@ void findStandardFormatIdForCharset( const OUString& aCharset, Any& aAny )
void setStandardFormatIdForNativeFormatName( const OUString& aNativeFormatName, Any& aAny )
{
vector< FormatEntry >::const_iterator citer_end = g_TranslTable.end( );
for ( vector< FormatEntry >::const_iterator citer = g_TranslTable.begin( ); citer != citer_end; ++citer )
{
if ( aNativeFormatName.equalsIgnoreAsciiCase( citer->aNativeFormatName ) &&
(CF_INVALID != citer->aStandardFormatId) )
{
aAny <<= citer->aStandardFormatId;
break;
}
}
vector< FormatEntry >::const_iterator citer = std::find_if(g_TranslTable.begin(), g_TranslTable.end(),
[&aNativeFormatName](const FormatEntry& rEntry) {
return aNativeFormatName.equalsIgnoreAsciiCase(rEntry.aNativeFormatName)
&& (CF_INVALID != rEntry.aStandardFormatId);
});
if (citer != g_TranslTable.end())
aAny <<= citer->aStandardFormatId;
}
void findStdFormatIdOrNativeFormatNameForFullMediaType(
......@@ -420,23 +406,21 @@ void findStdFormatIdOrNativeFormatNameForFullMediaType(
const OUString& aFullMediaType,
Any& aAny )
{
vector< FormatEntry >::const_iterator citer_end = g_TranslTable.end( );
for ( vector< FormatEntry >::const_iterator citer = g_TranslTable.begin( ); citer != citer_end; ++citer )
vector< FormatEntry >::const_iterator citer = std::find_if(g_TranslTable.begin(), g_TranslTable.end(),
[&aRefXMimeFactory, &aFullMediaType](const FormatEntry& rEntry) {
Reference<XMimeContentType> refXMime( aRefXMimeFactory->createMimeContentType(rEntry.aDataFlavor.MimeType) );
return aFullMediaType.equalsIgnoreAsciiCase(refXMime->getFullMediaType());
});
if (citer != g_TranslTable.end())
{
Reference< XMimeContentType >
refXMime( aRefXMimeFactory->createMimeContentType( citer->aDataFlavor.MimeType ) );
if ( aFullMediaType.equalsIgnoreAsciiCase( refXMime->getFullMediaType( ) ) )
sal_Int32 cf = citer->aStandardFormatId;
if ( CF_INVALID != cf )
aAny <<= cf;
else
{
sal_Int32 cf = citer->aStandardFormatId;
if ( CF_INVALID != cf )
aAny <<= cf;
else
{
OSL_ENSURE( citer->aNativeFormatName.getLength( ),
"Invalid standard format id and empty native format name in translation table" );
aAny <<= citer->aNativeFormatName;
}
break;
OSL_ENSURE( citer->aNativeFormatName.getLength( ),
"Invalid standard format id and empty native format name in translation table" );
aAny <<= citer->aNativeFormatName;
}
}
}
......
......@@ -884,36 +884,20 @@ void Test::testHyperlinkSearch()
bool hasBold(const editeng::Section& rSecAttr)
{
std::vector<const SfxPoolItem*>::const_iterator it = rSecAttr.maAttributes.begin(), itEnd = rSecAttr.maAttributes.end();
for (; it != itEnd; ++it)
{
const SfxPoolItem* p = *it;
if (p->Which() != EE_CHAR_WEIGHT)
continue;
if (static_cast<const SvxWeightItem*>(p)->GetWeight() != WEIGHT_BOLD)
continue;
return true;
}
return false;
return std::any_of(rSecAttr.maAttributes.begin(), rSecAttr.maAttributes.end(),
[](const SfxPoolItem* p) {
return p->Which() == EE_CHAR_WEIGHT
&& static_cast<const SvxWeightItem*>(p)->GetWeight() == WEIGHT_BOLD;
});
}
bool hasItalic(const editeng::Section& rSecAttr)
{
std::vector<const SfxPoolItem*>::const_iterator it = rSecAttr.maAttributes.begin(), itEnd = rSecAttr.maAttributes.end();
for (; it != itEnd; ++it)
{
const SfxPoolItem* p = *it;
if (p->Which() != EE_CHAR_ITALIC)
continue;
if (static_cast<const SvxPostureItem*>(p)->GetPosture() != ITALIC_NORMAL)
continue;
return true;
}
return false;
return std::any_of(rSecAttr.maAttributes.begin(), rSecAttr.maAttributes.end(),
[](const SfxPoolItem* p) {
return p->Which() == EE_CHAR_ITALIC
&& static_cast<const SvxPostureItem*>(p)->GetPosture() == ITALIC_NORMAL;
});
}
void Test::testBoldItalicCopyPaste()
......@@ -1104,19 +1088,11 @@ void Test::testBoldItalicCopyPaste()
// Auxiliary function to test Underline text Copy/Paste using Legacy Format
bool hasUnderline(const editeng::Section& rSecAttr)
{
std::vector<const SfxPoolItem*>::const_iterator it = rSecAttr.maAttributes.begin(), itEnd = rSecAttr.maAttributes.end();
for (; it != itEnd; ++it)
{
const SfxPoolItem* p = *it;
if (p->Which() != EE_CHAR_UNDERLINE)
continue;
if (static_cast<const SvxUnderlineItem*>(p)->GetLineStyle() != LINESTYLE_SINGLE)
continue;
return true;
}
return false;
return std::any_of(rSecAttr.maAttributes.begin(), rSecAttr.maAttributes.end(),
[](const SfxPoolItem* p) {
return p->Which() == EE_CHAR_UNDERLINE
&& static_cast<const SvxUnderlineItem*>(p)->GetLineStyle() == LINESTYLE_SINGLE;
});
}
void Test::testUnderlineCopyPaste()
......
......@@ -235,8 +235,8 @@ namespace accessibility
rChild.SetState( AccessibleStateType::FOCUSED );
// add states passed from outside
for( VectorOfStates::const_iterator aIt = maChildStates.begin(), aEnd = maChildStates.end(); aIt != aEnd; ++aIt )
rChild.SetState( *aIt );
for( const auto& rState : maChildStates )
rChild.SetState( rState );
}
void AccessibleParaManager::SetState( sal_Int32 nChild, const sal_Int16 nStateId )
......
......@@ -913,12 +913,11 @@ namespace accessibility
uno::Sequence< beans::PropertyValue > aSeq = mpImpl->GetParagraph( nPara ).getDefaultAttributes( RequestedAttributes );
PropertyValueVector aIntersectionVec;
PropertyValueVector::const_iterator aEnd = aDefAttrVec.end();
for ( PropertyValueVector::const_iterator aItr = aDefAttrVec.begin(); aItr != aEnd; ++aItr )
for ( const auto& rDefAttr : aDefAttrVec )
{
const beans::PropertyValue* pItr = aSeq.getConstArray();
const beans::PropertyValue* pEnd = pItr + aSeq.getLength();
const beans::PropertyValue* pFind = std::find_if( pItr, pEnd, PropertyValueEqualFunctor(*aItr) );
const beans::PropertyValue* pFind = std::find_if( pItr, pEnd, PropertyValueEqualFunctor(rDefAttr) );
if ( pFind != pEnd )
{
aIntersectionVec.push_back( *pFind );
......
......@@ -2798,12 +2798,13 @@ const EditCharAttrib* CharAttribList::FindAttrib( sal_uInt16 nWhich, sal_Int32 n
{
// Backwards, if one ends where the next starts.
// => The starting one is the valid one ...
AttribsType::const_reverse_iterator it = aAttribs.rbegin(), itEnd = aAttribs.rend();
for (; it != itEnd; ++it)
AttribsType::const_reverse_iterator it = std::find_if(aAttribs.rbegin(), aAttribs.rend(),
[&nWhich, &nPos](const AttribsType::value_type& rxAttr) {
return rxAttr->Which() == nWhich && rxAttr->IsIn(nPos); });
if (it != aAttribs.rend())
{
const EditCharAttrib& rAttr = **it;
if (rAttr.Which() == nWhich && rAttr.IsIn(nPos))
return &rAttr;
return &rAttr;
}
return nullptr;
}
......@@ -2812,12 +2813,13 @@ EditCharAttrib* CharAttribList::FindAttrib( sal_uInt16 nWhich, sal_Int32 nPos )
{
// Backwards, if one ends where the next starts.
// => The starting one is the valid one ...
AttribsType::reverse_iterator it = aAttribs.rbegin(), itEnd = aAttribs.rend();
for (; it != itEnd; ++it)
AttribsType::reverse_iterator it = std::find_if(aAttribs.rbegin(), aAttribs.rend(),
[&nWhich, &nPos](AttribsType::value_type& rxAttr) {
return rxAttr->Which() == nWhich && rxAttr->IsIn(nPos); });
if (it != aAttribs.rend())
{
EditCharAttrib& rAttr = **it;
if (rAttr.Which() == nWhich && rAttr.IsIn(nPos))
return &rAttr;
return &rAttr;
}
return nullptr;
}
......@@ -2836,14 +2838,9 @@ const EditCharAttrib* CharAttribList::FindNextAttrib( sal_uInt16 nWhich, sal_Int
bool CharAttribList::HasAttrib( sal_Int32 nStartPos, sal_Int32 nEndPos ) const
{
AttribsType::const_reverse_iterator it = aAttribs.rbegin(), itEnd = aAttribs.rend();
for (; it != itEnd; ++it)
{
const EditCharAttrib& rAttr = **it;
if (rAttr.GetStart() < nEndPos && rAttr.GetEnd() > nStartPos)
return true;
}
return false;
return std::any_of(aAttribs.rbegin(), aAttribs.rend(),
[&nStartPos, &nEndPos](const AttribsType::value_type& rxAttr) {
return rxAttr->GetStart() < nEndPos && rxAttr->GetEnd() > nStartPos; });
}
......
......@@ -401,27 +401,22 @@ void WrongList::ClearWrongs( size_t nStart, size_t nEnd,
void WrongList::InsertWrong( size_t nStart, size_t nEnd )
{
WrongList::iterator nPos = maRanges.end();
for (WrongList::iterator i = maRanges.begin(); i != maRanges.end(); ++i)
WrongList::iterator nPos = std::find_if(maRanges.begin(), maRanges.end(),
[&nStart](const editeng::MisspellRange& rRange) { return rRange.mnStart >= nStart; });
if (nPos != maRanges.end())
{
if (i->mnStart >= nStart)
{
nPos = i;
{
// It can really only happen that the Wrong starts exactly here
// and runs along, but not that there are several ranges ...
// Exactly in the range is no one allowed to be, otherwise this
// Method can not be called!
SAL_WARN_IF((i->mnStart != nStart || i->mnEnd <= nEnd) && i->mnStart <= nEnd, "editeng", "InsertWrong: RangeMismatch!");
if (i->mnStart == nStart && i->mnEnd > nEnd)
i->mnStart = nEnd + 1;
}
break;
// It can really only happen that the Wrong starts exactly here
// and runs along, but not that there are several ranges ...
// Exactly in the range is no one allowed to be, otherwise this
// Method can not be called!
SAL_WARN_IF((nPos->mnStart != nStart || nPos->mnEnd <= nEnd) && nPos->mnStart <= nEnd, "editeng", "InsertWrong: RangeMismatch!");
if (nPos->mnStart == nStart && nPos->mnEnd > nEnd)
nPos->mnStart = nEnd + 1;
}
}
if (nPos != maRanges.end())
maRanges.insert(nPos, editeng::MisspellRange(nStart, nEnd));
}
else
maRanges.emplace_back(nStart, nEnd);
......@@ -444,20 +439,12 @@ bool WrongList::operator==(const WrongList& rCompare) const
{
// check direct members
if(GetInvalidStart() != rCompare.GetInvalidStart()
|| GetInvalidEnd() != rCompare.GetInvalidEnd()
|| maRanges.size() != rCompare.maRanges.size())
|| GetInvalidEnd() != rCompare.GetInvalidEnd())
return false;
WrongList::const_iterator rCB = rCompare.maRanges.begin();
for (auto const& rangeA : maRanges)
{
if(rangeA.mnStart != rCB->mnStart || rangeA.mnEnd != rCB->mnEnd)
return false;
++rCB;
}
return true;
return std::equal(maRanges.begin(), maRanges.end(), rCompare.maRanges.begin(), rCompare.maRanges.end(),
[](const editeng::MisspellRange& a, const editeng::MisspellRange& b) {
return a.mnStart == b.mnStart && a.mnEnd == b.mnEnd; });
}
bool WrongList::empty() const
......@@ -506,10 +493,8 @@ bool WrongList::DbgIsBuggy() const
bool bError = false;
for (WrongList::const_iterator i = maRanges.begin(); !bError && (i != maRanges.end()); ++i)
{
for (WrongList::const_iterator j = i + 1; !bError && (j != maRanges.end()); ++j)
{
bError = i->mnStart <= j->mnEnd && j->mnStart <= i->mnEnd;
}
bError = std::any_of(i + 1, maRanges.end(), [&i](const editeng::MisspellRange& rRange) {
return i->mnStart <= rRange.mnEnd && rRange.mnStart <= i->mnEnd; });
}
return bError;
}
......
......@@ -652,9 +652,8 @@ ErrCode ImpEditEngine::WriteRTF( SvStream& rOutput, EditSelection aSel )
rOutput.WriteCharPtr( "}}" ); // 1xparentheses paragraphs, 1xparentheses RTF document
rOutput.Flush();
std::vector<SvxFontItem*>::iterator it;
for (it = aFontTable.begin(); it != aFontTable.end(); ++it)
delete *it;
for (auto& pItem : aFontTable)
delete pItem;
return rOutput.GetError();
}
......@@ -2122,8 +2121,6 @@ void ImpEditEngine::ApplyChangedSentence(EditView const & rEditView,
aSet.Put(SvxLanguageItem(aCurrentNewPortion->eLanguage, nLangWhichId));
SetAttribs( *aCurrentOldPosition, aSet );
}
if(aCurrentNewPortion == rNewPortions.begin())
break;
}
while(aCurrentNewPortion != rNewPortions.begin());
}
......@@ -2139,15 +2136,14 @@ void ImpEditEngine::ApplyChangedSentence(EditView const & rEditView,
//delete the sentence completely
ImpDeleteSelection( aAllSentence );
svx::SpellPortions::const_iterator aCurrentNewPortion = rNewPortions.begin();
EditPaM aCurrentPaM = aAllSentence.Min();
while(aCurrentNewPortion != rNewPortions.end())
for(const auto& rCurrentNewPortion : rNewPortions)
{
//set the language attribute
LanguageType eCurLanguage = GetLanguage( aCurrentPaM );
if(eCurLanguage != aCurrentNewPortion->eLanguage)
if(eCurLanguage != rCurrentNewPortion.eLanguage)
{
SvtScriptType nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage( aCurrentNewPortion->eLanguage );
SvtScriptType nScriptType = SvtLanguageOptions::GetScriptTypeOfLanguage( rCurrentNewPortion.eLanguage );
sal_uInt16 nLangWhichId = EE_CHAR_LANGUAGE;
switch(nScriptType)
{
......@@ -2156,12 +2152,11 @@ void ImpEditEngine::ApplyChangedSentence(EditView const & rEditView,
default: break;
}
SfxItemSet aSet( aEditDoc.GetItemPool(), {{nLangWhichId, nLangWhichId}});
aSet.Put(SvxLanguageItem(aCurrentNewPortion->eLanguage, nLangWhichId));
aSet.Put(SvxLanguageItem(rCurrentNewPortion.eLanguage, nLangWhichId));
SetAttribs( aCurrentPaM, aSet );
}
//insert the new string and set the cursor to the end of the inserted string
aCurrentPaM = ImpInsertText( aCurrentPaM , aCurrentNewPortion->sText );
++aCurrentNewPortion;
aCurrentPaM = ImpInsertText( aCurrentPaM , rCurrentNewPortion.sText );
}
}
UndoActionEnd();
......
......@@ -1292,16 +1292,12 @@ size_t Outliner::InsertView( OutlinerView* pView, size_t nIndex )
void Outliner::RemoveView( OutlinerView const * pView )
{
for ( ViewList::iterator it = aViewList.begin(); it != aViewList.end(); ++it )
ViewList::iterator it = std::find(aViewList.begin(), aViewList.end(), pView);
if (it != aViewList.end())
{
if ( *it == pView )
{
pView->pEditView->HideCursor(); // HACK
pEditEngine->RemoveView( pView->pEditView.get() );
aViewList.erase( it );
break;
}
pView->pEditView->HideCursor(); // HACK
pEditEngine->RemoveView( pView->pEditView.get() );
aViewList.erase( it );
}
}
......
......@@ -178,20 +178,18 @@ namespace dbp
{
Reference< XNameAccess > xExistenceChecker(xColumnContainer.get());
std::vector< OUString >::const_iterator pColumnServiceName = aColumnServiceNames.begin();
std::vector< OUString >::const_iterator pColumnLabelPostfix = aColumnLabelPostfixes.begin();
std::vector< OUString >::const_iterator pFormFieldName = aFormFieldNames.begin();
std::vector< OUString >::const_iterator pColumnServiceNameEnd = aColumnServiceNames.end();
for (;pColumnServiceName < pColumnServiceNameEnd; ++pColumnServiceName, ++pColumnLabelPostfix, ++pFormFieldName)
for (const auto& rColumnServiceName : aColumnServiceNames)
{
// create a (grid)column for the (resultset)column
try
{
Reference< XPropertySet > xColumn( xColumnFactory->createColumn(*pColumnServiceName), UNO_SET_THROW );
Reference< XPropertySet > xColumn( xColumnFactory->createColumn(rColumnServiceName), UNO_SET_THROW );
Reference< XPropertySetInfo > xColumnPSI( xColumn->getPropertySetInfo(), UNO_SET_THROW );
OUString sColumnName(*pColumnServiceName);
OUString sColumnName(rColumnServiceName);
disambiguateName(xExistenceChecker, sColumnName);
// the data field the column should be bound to
......@@ -213,6 +211,9 @@ namespace dbp
"unexpected exception while creating the grid column for field " <<
*pFormFieldName );
}
++pColumnLabelPostfix;
++pFormFieldName;
}
}
}
......
......@@ -91,17 +91,14 @@ namespace compmodule
&& (s_pImplementationNames->size() == s_pFactoryFunctionPointers->size()),
"OModule::revokeComponent : inconsistent state !");
sal_Int32 nLen = s_pImplementationNames->size();
for (sal_Int32 i=0; i<nLen; ++i)
auto it = std::find(s_pImplementationNames->begin(), s_pImplementationNames->end(), _rImplementationName);
if (it != s_pImplementationNames->end())
{
if ((*s_pImplementationNames)[i] == _rImplementationName)
{
s_pImplementationNames->erase(s_pImplementationNames->begin() + i);
s_pSupportedServices->erase(s_pSupportedServices->begin() + i);
s_pCreationFunctionPointers->erase(s_pCreationFunctionPointers->begin() + i);
s_pFactoryFunctionPointers->erase(s_pFactoryFunctionPointers->begin() + i);
break;
}
sal_Int32 i = static_cast<sal_Int32>(std::distance(s_pImplementationNames->begin(), it));
s_pImplementationNames->erase(it);
s_pSupportedServices->erase(s_pSupportedServices->begin() + i);
s_pCreationFunctionPointers->erase(s_pCreationFunctionPointers->begin() + i);
s_pFactoryFunctionPointers->erase(s_pFactoryFunctionPointers->begin() + i);
}
if (s_pImplementationNames->empty())
......
......@@ -621,9 +621,8 @@ namespace pcr
void OBrowserListBox::SetPropertyValue(const OUString& _rEntryName, const Any& _rValue, bool _bUnknownValue )
{
ListBoxLines::iterator line = m_aLines.begin();
for ( ; line != m_aLines.end() && ( line->aName != _rEntryName ); ++line )
;
ListBoxLines::iterator line = std::find_if(m_aLines.begin(), m_aLines.end(),
[&_rEntryName](const ListBoxLine& rLine) { return rLine.aName == _rEntryName; });
if ( line != m_aLines.end() )
{
......@@ -658,9 +657,8 @@ namespace pcr
bool OBrowserListBox::impl_getBrowserLineForName( const OUString& _rEntryName, BrowserLinePointer& _out_rpLine ) const
{
ListBoxLines::const_iterator line = m_aLines.begin();
for ( ; line != m_aLines.end() && ( line->aName != _rEntryName ); ++line )
;
ListBoxLines::const_iterator line = std::find_if(m_aLines.begin(), m_aLines.end(),
[&_rEntryName](const ListBoxLine& rLine) { return rLine.aName == _rEntryName; });
if ( line != m_aLines.end() )
_out_rpLine = line->pLine;
......@@ -1023,14 +1021,13 @@ namespace pcr
bool OBrowserListBox::RemoveEntry( const OUString& _rName )
{
ListBoxLines::size_type nPos = 0;
ListBoxLines::iterator it = <