summaryrefslogtreecommitdiff
path: root/lotuswordpro
diff options
context:
space:
mode:
authorArkadiy Illarionov <qarkai@gmail.com>2019-02-16 18:39:23 +0300
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-02-18 07:41:05 +0100
commit44841a6778821be3e68ab15819b39064b20e968f (patch)
tree8e9119cf35764f18f5b008e7758c6f950306fb8c /lotuswordpro
parentbcfbd24be02d2de5d4d27c147dc58c4515a9a0f5 (diff)
Simplify containers iterations in [f-l]*
Use range-based loop or replace with STL functions Change-Id: Ib3fab47318d1bfbb4df8f886a8cd9596525a420f Reviewed-on: https://gerrit.libreoffice.org/67914 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'lotuswordpro')
-rw-r--r--lotuswordpro/source/filter/lwpstory.cxx41
1 files changed, 9 insertions, 32 deletions
diff --git a/lotuswordpro/source/filter/lwpstory.cxx b/lotuswordpro/source/filter/lwpstory.cxx
index b0f9586270e2..32d6342e47dc 100644
--- a/lotuswordpro/source/filter/lwpstory.cxx
+++ b/lotuswordpro/source/filter/lwpstory.cxx
@@ -68,6 +68,7 @@
#include "lwppagelayout.hxx"
#include <rtl/ustrbuf.hxx>
+#include <algorithm>
#include <set>
@@ -183,17 +184,9 @@ void LwpStory::SetCurrentLayout(LwpPageLayout *pPageLayout)
**************************************************************************/
LwpPageLayout* LwpStory::GetNextPageLayout()
{
- std::vector<LwpPageLayout*>::iterator it;
- for( it = m_LayoutList.begin(); it != m_LayoutList.end(); ++it )
- {
- if(m_pCurrentLayout == *it)
- {
- if((it+1) !=m_LayoutList.end())
- {
- return *(it+1);
- }
- }
- }
+ std::vector<LwpPageLayout*>::iterator it = std::find(m_LayoutList.begin(), m_LayoutList.end(), m_pCurrentLayout);
+ if (it != m_LayoutList.end() && (it+1) != m_LayoutList.end())
+ return *(it+1);
return nullptr;
}
/**************************************************************************
@@ -222,22 +215,15 @@ void LwpStory::SortPageLayout()
xLayout = GetLayout(xLayout.get());
}
// sort the pagelayout according to their position
- std::vector<LwpPageLayout*>::iterator aIt;
if (!aLayoutList.empty())
{
- for( aIt = aLayoutList.begin(); aIt != aLayoutList.end() -1; ++aIt)
+ for( std::vector<LwpPageLayout*>::iterator aIt = aLayoutList.begin(); aIt != aLayoutList.end() -1; ++aIt)
{
for( std::vector<LwpPageLayout*>::iterator bIt = aIt +1; bIt != aLayoutList.end(); ++bIt )
{
- if(**aIt < **bIt)
+ if(!(**aIt < **bIt))
{
- continue;
- }
- else
- {
- LwpPageLayout* pTemp = *aIt;
- *aIt = *bIt;
- *bIt = pTemp;
+ std::swap(*aIt, *bIt);
}
}
}
@@ -477,17 +463,8 @@ OUString LwpStory::RegisterFirstFribStyle()
bool LwpStory::IsBullStyleUsedBefore(const OUString& rStyleName, sal_uInt8 nPos)
{
- std::vector <NamePosPair>::reverse_iterator rIter;
- for (rIter = m_vBulletStyleNameList.rbegin(); rIter != m_vBulletStyleNameList.rend(); ++rIter)
- {
- OUString aName = (*rIter).first;
- sal_uInt8 nPosition = (*rIter).second;
- if (aName == rStyleName && nPosition == nPos)
- {
- return true;
- }
- }
- return false;
+ return std::any_of(m_vBulletStyleNameList.rbegin(), m_vBulletStyleNameList.rend(),
+ [&rStyleName, &nPos](const NamePosPair& rPair) { return rPair.first == rStyleName && rPair.second == nPos; });
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */