summaryrefslogtreecommitdiff
path: root/starmath
diff options
context:
space:
mode:
authorArkadiy Illarionov <qarkai@gmail.com>2018-11-27 22:17:40 +0300
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-11-29 12:06:44 +0100
commit0ded54c33f01d18d2cd06547bd8307bd140cf28f (patch)
treee250a9a8bb89b2042d9a0bc09f80bf65757eec19 /starmath
parent7d311ea864e7cfeb1c8f4ca417911db20d13361e (diff)
Simplify containers iterations in slideshow, sot, starmath, stoc
Use range-based loop or replace with STL functions Change-Id: I94792c28b283a0998bf813317e5beb37d93e0c23 Reviewed-on: https://gerrit.libreoffice.org/64125 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'starmath')
-rw-r--r--starmath/source/accessibility.cxx20
-rw-r--r--starmath/source/cfgitem.cxx11
-rw-r--r--starmath/source/cursor.cxx47
-rw-r--r--starmath/source/dialog.cxx10
-rw-r--r--starmath/source/symbol.cxx17
-rw-r--r--starmath/source/unomodel.cxx14
6 files changed, 53 insertions, 66 deletions
diff --git a/starmath/source/accessibility.cxx b/starmath/source/accessibility.cxx
index 5e4993298a1e..345c70efcc16 100644
--- a/starmath/source/accessibility.cxx
+++ b/starmath/source/accessibility.cxx
@@ -1040,39 +1040,39 @@ static SfxItemState GetSvxEditEngineItemState( EditEngine const & rEditEngine, c
const SfxPoolItem* pParaItem = nullptr;
- for(std::vector<EECharAttrib>::const_iterator i = aAttribs.begin(); i < aAttribs.end(); ++i)
+ for(const auto& rAttrib : aAttribs)
{
- OSL_ENSURE( i->pAttr, "GetCharAttribs gives corrupt data" );
+ OSL_ENSURE( rAttrib.pAttr, "GetCharAttribs gives corrupt data" );
- const bool bEmptyPortion = (i->nStart == i->nEnd);
- if( (!bEmptyPortion && (i->nStart >= nEndPos)) || (bEmptyPortion && (i->nStart > nEndPos)) )
+ const bool bEmptyPortion = (rAttrib.nStart == rAttrib.nEnd);
+ if( (!bEmptyPortion && (rAttrib.nStart >= nEndPos)) || (bEmptyPortion && (rAttrib.nStart > nEndPos)) )
break; // break if we are already behind our selection
- if( (!bEmptyPortion && (i->nEnd <= nPos)) || (bEmptyPortion && (i->nEnd < nPos)) )
+ if( (!bEmptyPortion && (rAttrib.nEnd <= nPos)) || (bEmptyPortion && (rAttrib.nEnd < nPos)) )
continue; // or if the attribute ends before our selection
- if( i->pAttr->Which() != nWhich )
+ if( rAttrib.pAttr->Which() != nWhich )
continue; // skip if is not the searched item
// if we already found an item
if( pParaItem )
{
// ... and its different to this one than the state is don't care
- if( *pParaItem != *(i->pAttr) )
+ if( *pParaItem != *(rAttrib.pAttr) )
return SfxItemState::DONTCARE;
}
else
{
- pParaItem = i->pAttr;
+ pParaItem = rAttrib.pAttr;
}
if( bEmpty )
bEmpty = false;
- if( !bGaps && i->nStart > nLastEnd )
+ if( !bGaps && rAttrib.nStart > nLastEnd )
bGaps = true;
- nLastEnd = i->nEnd;
+ nLastEnd = rAttrib.nEnd;
}
if( !bEmpty && !bGaps && nLastEnd < ( nEndPos - 1 ) )
diff --git a/starmath/source/cfgitem.cxx b/starmath/source/cfgitem.cxx
index e5c86e05ca53..025deb9c0049 100644
--- a/starmath/source/cfgitem.cxx
+++ b/starmath/source/cfgitem.cxx
@@ -484,11 +484,9 @@ void SmMathConfig::GetSymbols( std::vector< SmSym > &rSymbols ) const
sal_Int32 nNodes = aNodes.getLength();
rSymbols.resize( nNodes );
- std::vector< SmSym >::iterator aIt( rSymbols.begin() );
- std::vector< SmSym >::iterator aEnd( rSymbols.end() );
- while (aIt != aEnd)
+ for (auto& rSymbol : rSymbols)
{
- ReadSymbol( *aIt++, *pNode++, SYMBOL_LIST );
+ ReadSymbol( rSymbol, *pNode++, SYMBOL_LIST );
}
}
@@ -506,11 +504,8 @@ void SmMathConfig::SetSymbols( const std::vector< SmSym > &rNewSymbols )
PropertyValue *pVal = pValues;
OUString aDelim( "/" );
- std::vector< SmSym >::const_iterator aIt( rNewSymbols.begin() );
- std::vector< SmSym >::const_iterator aEnd( rNewSymbols.end() );
- while (aIt != aEnd)
+ for (const SmSym& rSymbol : rNewSymbols)
{
- const SmSym &rSymbol = *aIt++;
OUString aNodeNameDelim( SYMBOL_LIST );
aNodeNameDelim += aDelim;
aNodeNameDelim += rSymbol.GetExportName();
diff --git a/starmath/source/cursor.cxx b/starmath/source/cursor.cxx
index a1ada63bede4..a883b679ce2a 100644
--- a/starmath/source/cursor.cxx
+++ b/starmath/source/cursor.cxx
@@ -340,34 +340,31 @@ SmNodeList::iterator SmCursor::FindPositionInLineList(SmNodeList* pLineList,
const SmCaretPos& rCaretPos)
{
//Find iterator for position
- SmNodeList::iterator it;
- for(it = pLineList->begin(); it != pLineList->end(); ++it){
- if(*it == rCaretPos.pSelectedNode)
+ SmNodeList::iterator it = std::find(pLineList->begin(), pLineList->end(), rCaretPos.pSelectedNode);
+ if (it != pLineList->end())
+ {
+ if((*it)->GetType() == SmNodeType::Text)
{
- if((*it)->GetType() == SmNodeType::Text)
+ //Split textnode if needed
+ if(rCaretPos.nIndex > 0)
{
- //Split textnode if needed
- if(rCaretPos.nIndex > 0)
- {
- SmTextNode* pText = static_cast<SmTextNode*>(rCaretPos.pSelectedNode);
- if (rCaretPos.nIndex == pText->GetText().getLength())
- return ++it;
- OUString str1 = pText->GetText().copy(0, rCaretPos.nIndex);
- OUString str2 = pText->GetText().copy(rCaretPos.nIndex);
- pText->ChangeText(str1);
- ++it;
- //Insert str2 as new text node
- assert(!str2.isEmpty());
- SmTextNode* pNewText = new SmTextNode(pText->GetToken(), pText->GetFontDesc());
- pNewText->ChangeText(str2);
- it = pLineList->insert(it, pNewText);
- }
- }else
+ SmTextNode* pText = static_cast<SmTextNode*>(rCaretPos.pSelectedNode);
+ if (rCaretPos.nIndex == pText->GetText().getLength())
+ return ++it;
+ OUString str1 = pText->GetText().copy(0, rCaretPos.nIndex);
+ OUString str2 = pText->GetText().copy(rCaretPos.nIndex);
+ pText->ChangeText(str1);
++it;
- //it now pointer to the node following pos, so pLineList->insert(it, ...) will insert correctly
- return it;
-
- }
+ //Insert str2 as new text node
+ assert(!str2.isEmpty());
+ SmTextNode* pNewText = new SmTextNode(pText->GetToken(), pText->GetFontDesc());
+ pNewText->ChangeText(str2);
+ it = pLineList->insert(it, pNewText);
+ }
+ }else
+ ++it;
+ //it now pointer to the node following pos, so pLineList->insert(it, ...) will insert correctly
+ return it;
}
//If we didn't find pSelectedNode, it must be because the caret is in front of the line
return pLineList->begin();
diff --git a/starmath/source/dialog.cxx b/starmath/source/dialog.cxx
index 61f3edeaf885..550401d8f157 100644
--- a/starmath/source/dialog.cxx
+++ b/starmath/source/dialog.cxx
@@ -1186,9 +1186,8 @@ void SmSymbolDialog::FillSymbolSets()
m_xSymbolSets->set_active(-1);
std::set< OUString > aSybolSetNames( rSymbolMgr.GetSymbolSetNames() );
- std::set< OUString >::const_iterator aIt( aSybolSetNames.begin() );
- for ( ; aIt != aSybolSetNames.end(); ++aIt)
- m_xSymbolSets->append_text(*aIt);
+ for (const auto& rSymbolSetName : aSybolSetNames)
+ m_xSymbolSets->append_text(rSymbolSetName);
}
IMPL_LINK_NOARG( SmSymbolDialog, SymbolSetChangeHdl, weld::ComboBox&, void )
@@ -1440,9 +1439,8 @@ void SmSymDefineDialog::FillSymbolSets(weld::ComboBox& rComboBox, bool bDeleteTe
rComboBox.set_entry_text(OUString());
const std::set< OUString > aSymbolSetNames( m_aSymbolMgrCopy.GetSymbolSetNames() );
- std::set< OUString >::const_iterator aIt( aSymbolSetNames.begin() );
- for ( ; aIt != aSymbolSetNames.end(); ++aIt)
- rComboBox.append_text(*aIt);
+ for (const auto& rSymbolSetName : aSymbolSetNames)
+ rComboBox.append_text(rSymbolSetName);
}
void SmSymDefineDialog::FillFonts()
diff --git a/starmath/source/symbol.cxx b/starmath/source/symbol.cxx
index cb0533c1b269..86af8f6c528e 100644
--- a/starmath/source/symbol.cxx
+++ b/starmath/source/symbol.cxx
@@ -124,9 +124,8 @@ SmSym *SmSymbolManager::GetSymbolByName(const OUString& rSymbolName)
const SymbolPtrVec_t SmSymbolManager::GetSymbols() const
{
SymbolPtrVec_t aRes;
- SymbolMap_t::const_iterator aIt( m_aSymbols.begin() );
- for ( ; aIt != m_aSymbols.end(); ++aIt)
- aRes.push_back( &aIt->second );
+ for (const auto& rEntry : m_aSymbols)
+ aRes.push_back( &rEntry.second );
// OSL_ENSURE( sSymbols.size() == m_aSymbols.size(), "number of symbols mismatch " );
return aRes;
}
@@ -182,9 +181,8 @@ void SmSymbolManager::RemoveSymbol( const OUString & rSymbolName )
std::set< OUString > SmSymbolManager::GetSymbolSetNames() const
{
std::set< OUString > aRes;
- SymbolMap_t::const_iterator aIt( m_aSymbols.begin() );
- for ( ; aIt != m_aSymbols.end(); ++aIt )
- aRes.insert( aIt->second.GetSymbolSetName() );
+ for (const auto& rEntry : m_aSymbols)
+ aRes.insert( rEntry.second.GetSymbolSetName() );
return aRes;
}
@@ -194,11 +192,10 @@ const SymbolPtrVec_t SmSymbolManager::GetSymbolSet( const OUString& rSymbolSetNa
SymbolPtrVec_t aRes;
if (!rSymbolSetName.isEmpty())
{
- SymbolMap_t::const_iterator aIt( m_aSymbols.begin() );
- for ( ; aIt != m_aSymbols.end(); ++aIt )
+ for (const auto& rEntry : m_aSymbols)
{
- if (aIt->second.GetSymbolSetName() == rSymbolSetName)
- aRes.push_back( &aIt->second );
+ if (rEntry.second.GetSymbolSetName() == rSymbolSetName)
+ aRes.push_back( &rEntry.second );
}
}
return aRes;
diff --git a/starmath/source/unomodel.cxx b/starmath/source/unomodel.cxx
index b7ff3bd2206f..b19c1aab166d 100644
--- a/starmath/source/unomodel.cxx
+++ b/starmath/source/unomodel.cxx
@@ -843,21 +843,21 @@ void SmModel::_getPropertyValues( const PropertyMapEntry **ppEntries, Any *pValu
Sequence < SymbolDescriptor > aSequence ( aVector.size() );
SymbolDescriptor * pDescriptor = aSequence.getArray();
- vector < const SmSym * >::const_iterator aIter = aVector.begin(), aEnd = aVector.end();
- for(; aIter != aEnd; pDescriptor++, ++aIter)
+ for (const SmSym* pSymbol : aVector)
{
- pDescriptor->sName = (*aIter)->GetName();
- pDescriptor->sExportName = (*aIter)->GetExportName();
- pDescriptor->sSymbolSet = (*aIter)->GetSymbolSetName();
- pDescriptor->nCharacter = static_cast < sal_Int32 > ((*aIter)->GetCharacter());
+ pDescriptor->sName = pSymbol->GetName();
+ pDescriptor->sExportName = pSymbol->GetExportName();
+ pDescriptor->sSymbolSet = pSymbol->GetSymbolSetName();
+ pDescriptor->nCharacter = static_cast < sal_Int32 > (pSymbol->GetCharacter());
- vcl::Font rFont = (*aIter)->GetFace();
+ vcl::Font rFont = pSymbol->GetFace();
pDescriptor->sFontName = rFont.GetFamilyName();
pDescriptor->nCharSet = sal::static_int_cast< sal_Int16 >(rFont.GetCharSet());
pDescriptor->nFamily = sal::static_int_cast< sal_Int16 >(rFont.GetFamilyType());
pDescriptor->nPitch = sal::static_int_cast< sal_Int16 >(rFont.GetPitch());
pDescriptor->nWeight = sal::static_int_cast< sal_Int16 >(rFont.GetWeight());
pDescriptor->nItalic = sal::static_int_cast< sal_Int16 >(rFont.GetItalic());
+ pDescriptor++;
}
*pValue <<= aSequence;
}