editeng/source/rtf/rtfitem.cxx          |    6 +---
 editeng/source/rtf/svxrtf.cxx           |   28 ++++++++-----------
 include/svl/itemiter.hxx                |    6 +++-
 svl/source/items/itemiter.cxx           |   17 ++++-------
 svl/source/items/itemset.cxx            |   12 ++------
 svx/source/dialog/srchdlg.cxx           |    6 +---
 sw/source/core/crsr/crstrvl.cxx         |    8 ++---
 sw/source/core/crsr/findattr.cxx        |   18 ++++--------
 sw/source/core/doc/docfly.cxx           |   19 ++++++-------
 sw/source/core/doc/docfmt.cxx           |   12 ++------
 sw/source/core/doc/docredln.cxx         |    6 ----
 sw/source/core/doc/textboxhelper.cxx    |   17 +++++------
 sw/source/core/docnode/ndsect.cxx       |   12 +++-----
 sw/source/core/layout/fly.cxx           |   16 ++++-------
 sw/source/core/layout/pagechg.cxx       |   16 ++++-------
 sw/source/core/layout/sectfrm.cxx       |   16 ++++-------
 sw/source/core/layout/tabfrm.cxx        |   16 ++++-------
 sw/source/core/layout/wsfrm.cxx         |   31 +++++++++------------
 sw/source/core/text/atrstck.cxx         |    7 +---
 sw/source/core/text/txtfld.cxx          |    7 +---
 sw/source/core/tox/ToxTextGenerator.cxx |    8 ++---
 sw/source/core/txtnode/ndtxt.cxx        |    6 +---
 sw/source/core/txtnode/thints.cxx       |   46 +++++++-------------------------
 sw/source/core/txtnode/txtedt.cxx       |    7 +---
 sw/source/core/undo/rolbck.cxx          |   20 +++----------
 sw/source/core/undo/unattr.cxx          |    7 +---
 sw/source/core/undo/undobj1.cxx         |   13 +--------
 sw/source/filter/writer/wrt_fn.cxx      |    2 -
 sw/source/filter/ww8/writerhelper.cxx   |    4 +-
 sw/source/filter/ww8/wrtw8esh.cxx       |    2 -
 sw/source/filter/ww8/wrtww8gr.cxx       |    8 ++---
 sw/source/filter/ww8/ww8atr.cxx         |    4 +-
 sw/source/filter/ww8/ww8par.cxx         |   15 +++-------
 sw/source/filter/ww8/ww8par3.cxx        |   14 ++++-----
 sw/source/filter/ww8/ww8par6.cxx        |    2 -
 sw/source/uibase/app/docstyle.cxx       |    6 +---
 sw/source/uibase/config/uinums.cxx      |    6 +---
 sw/source/uibase/utlui/attrdesc.cxx     |   13 +++------
 38 files changed, 170 insertions(+), 289 deletions(-)

New commits:
commit 1fc63383ccd8af144d681ba405f5ead863ac24e1
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Mon Sep 30 20:22:30 2019 +0300
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Tue Oct 1 06:33:11 2019 +0200

    Avoid redundant IsAtEnd: NextItem returns nullptr iif iterator is at end
    
    To keep the check efficient, split NextItem to inline and Impl parts
    
    Change-Id: Id5877a3c5bed73aac9c39c655b106a715cf888ea
    Reviewed-on: https://gerrit.libreoffice.org/79894
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/editeng/source/rtf/rtfitem.cxx b/editeng/source/rtf/rtfitem.cxx
index 78b185fb8ca7..775104700941 100644
--- a/editeng/source/rtf/rtfitem.cxx
+++ b/editeng/source/rtf/rtfitem.cxx
@@ -1885,13 +1885,11 @@ void SvxRTFParser::SetDefault( int nToken, int nValue )
     {
         SfxItemIter aIter( aTmp );
         const SfxPoolItem* pItem = aIter.GetCurItem();
-        while( true )
+        do
         {
             pAttrPool->SetPoolDefaultItem( *pItem );
-            if( aIter.IsAtEnd() )
-                break;
             pItem = aIter.NextItem();
-        }
+        } while (pItem);
     }
 }
 
diff --git a/editeng/source/rtf/svxrtf.cxx b/editeng/source/rtf/svxrtf.cxx
index cb50be3cb795..f78fcb891454 100644
--- a/editeng/source/rtf/svxrtf.cxx
+++ b/editeng/source/rtf/svxrtf.cxx
@@ -700,17 +700,15 @@ void SvxRTFParser::AttrGroupEnd()   // process the 
current, delete from Stack
             {
                 SfxItemIter aIter( pOld->aAttrSet );
                 const SfxPoolItem* pItem = aIter.GetCurItem(), *pGet;
-                while( true )
+                do
                 {
                     if( SfxItemState::SET == pCurrent->aAttrSet.GetItemState(
                         pItem->Which(), false, &pGet ) &&
                         *pItem == *pGet )
                         pOld->aAttrSet.ClearItem( pItem->Which() );
 
-                    if( aIter.IsAtEnd() )
-                        break;
                     pItem = aIter.NextItem();
-                }
+                } while (pItem);
 
                 if (!pOld->aAttrSet.Count() && !pOld->m_pChildList &&
                     !pOld->nStyleNo )
@@ -1064,16 +1062,15 @@ void SvxRTFItemStackType::Compress( const SvxRTFParser& 
rParser )
             // Search for all which are set over the whole area
             SfxItemIter aIter( aMrgSet );
             const SfxPoolItem* pItem;
+            const SfxPoolItem* pIterItem = aIter.GetCurItem();
             do {
-                sal_uInt16 nWhich = aIter.GetCurItem()->Which();
+                sal_uInt16 nWhich = pIterItem->Which();
                 if( SfxItemState::SET != pTmp->aAttrSet.GetItemState( nWhich,
-                      false, &pItem ) || *pItem != *aIter.GetCurItem() )
+                      false, &pItem ) || *pItem != *pIterItem)
                     aMrgSet.ClearItem( nWhich );
 
-                if( aIter.IsAtEnd() )
-                    break;
-                aIter.NextItem();
-            } while( true );
+                pIterItem = aIter.NextItem();
+            } while(pIterItem);
 
             if( !aMrgSet.Count() )
                 return;
@@ -1110,15 +1107,14 @@ void SvxRTFItemStackType::SetRTFDefaults( const 
SfxItemSet& rDefaults )
     if( rDefaults.Count() )
     {
         SfxItemIter aIter( rDefaults );
+        const SfxPoolItem* pItem = aIter.GetCurItem();
         do {
-            sal_uInt16 nWhich = aIter.GetCurItem()->Which();
+            sal_uInt16 nWhich = pItem->Which();
             if( SfxItemState::SET != aAttrSet.GetItemState( nWhich, false ))
-                aAttrSet.Put( *aIter.GetCurItem() );
+                aAttrSet.Put(*pItem);
 
-            if( aIter.IsAtEnd() )
-                break;
-            aIter.NextItem();
-        } while( true );
+            pItem = aIter.NextItem();
+        } while(pItem);
     }
 }
 
diff --git a/include/svl/itemiter.hxx b/include/svl/itemiter.hxx
index 913ca9cba0eb..bfcc43715ef5 100644
--- a/include/svl/itemiter.hxx
+++ b/include/svl/itemiter.hxx
@@ -45,13 +45,17 @@ public:
     {
         return m_rSet.m_nCount ? *(m_rSet.m_pItems.get() + m_nCurrent) : 
nullptr;
     }
-    const SfxPoolItem* NextItem();
+    const SfxPoolItem* NextItem() { return (m_nCurrent < m_nEnd) ? 
ImplNextItem() : nullptr; }
 
     bool       IsAtEnd()     const { return m_nCurrent == m_nEnd; }
 
     sal_uInt16 GetCurPos()   const { return m_nCurrent; }
     sal_uInt16 GetFirstPos() const { return m_nStart; }
     sal_uInt16 GetLastPos()  const { return m_nEnd; }
+
+private:
+    const SfxPoolItem* ImplNextItem();
+
 };
 
 #endif
diff --git a/svl/source/items/itemiter.cxx b/svl/source/items/itemiter.cxx
index aaedcf26ae33..fe0ee377f439 100644
--- a/svl/source/items/itemiter.cxx
+++ b/svl/source/items/itemiter.cxx
@@ -50,17 +50,14 @@ SfxItemIter::~SfxItemIter()
 {
 }
 
-const SfxPoolItem* SfxItemIter::NextItem()
+// Precondition : m_nCurrent < m_nEnd
+const SfxPoolItem* SfxItemIter::ImplNextItem()
 {
-    if (m_nCurrent < m_nEnd)
-    {
-        SfxPoolItem const** ppFnd = m_rSet.m_pItems.get();
-        do {
-            m_nCurrent++;
-        } while (m_nCurrent < m_nEnd && !*(ppFnd + m_nCurrent ));
-        return *(ppFnd+m_nCurrent);
-    }
-    return nullptr;
+    SfxPoolItem const** ppFnd = m_rSet.m_pItems.get();
+    do {
+        m_nCurrent++;
+    } while (m_nCurrent < m_nEnd && !*(ppFnd + m_nCurrent ));
+    return *(ppFnd+m_nCurrent);
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svl/source/items/itemset.cxx b/svl/source/items/itemset.cxx
index 35da205612ac..f325cec50f34 100644
--- a/svl/source/items/itemset.cxx
+++ b/svl/source/items/itemset.cxx
@@ -1014,17 +1014,15 @@ void SfxItemSet::Intersect( const SfxItemSet& rSet )
     {
         SfxItemIter aIter( *this );
         const SfxPoolItem* pItem = aIter.GetCurItem();
-        while( true )
+        do
         {
             sal_uInt16 nWhich = IsInvalidItem( pItem )
                                 ? GetWhichByPos( aIter.GetCurPos() )
                                 : pItem->Which();
             if( SfxItemState::UNKNOWN == rSet.GetItemState( nWhich, false ) )
                 ClearItem( nWhich );        // Delete
-            if( aIter.IsAtEnd() )
-                break;
             pItem = aIter.NextItem();
-        }
+        } while (pItem);
     }
 }
 
@@ -1080,17 +1078,15 @@ void SfxItemSet::Differentiate( const SfxItemSet& rSet )
     {
         SfxItemIter aIter( *this );
         const SfxPoolItem* pItem = aIter.GetCurItem();
-        while( true )
+        do
         {
             sal_uInt16 nWhich = IsInvalidItem( pItem )
                                 ? GetWhichByPos( aIter.GetCurPos() )
                                 : pItem->Which();
             if( SfxItemState::SET == rSet.GetItemState( nWhich, false ) )
                 ClearItem( nWhich ); // Delete
-            if( aIter.IsAtEnd() )
-                break;
             pItem = aIter.NextItem();
-        }
+        } while (pItem);
 
     }
 }
diff --git a/svx/source/dialog/srchdlg.cxx b/svx/source/dialog/srchdlg.cxx
index bc751ab885d3..fc36f99258f5 100644
--- a/svx/source/dialog/srchdlg.cxx
+++ b/svx/source/dialog/srchdlg.cxx
@@ -196,7 +196,7 @@ void SearchAttrItemList::Put( const SfxItemSet& rSet )
     const SfxPoolItem* pItem = aIter.GetCurItem();
     sal_uInt16 nWhich;
 
-    while ( true )
+    do
     {
         // only test that it is available?
         if( IsInvalidItem( pItem ) )
@@ -213,10 +213,8 @@ void SearchAttrItemList::Put( const SfxItemSet& rSet )
         aItem.nSlot = pPool->GetSlotId( nWhich );
         Insert( aItem );
 
-        if ( aIter.IsAtEnd() )
-            break;
         pItem = aIter.NextItem();
-    }
+    } while (pItem);
 }
 
 
diff --git a/sw/source/core/crsr/crstrvl.cxx b/sw/source/core/crsr/crstrvl.cxx
index 9c0d9c130150..eed25eb2617e 100644
--- a/sw/source/core/crsr/crstrvl.cxx
+++ b/sw/source/core/crsr/crstrvl.cxx
@@ -1804,9 +1804,9 @@ bool SwCursorShell::GetContentAtPos( const Point& rPt,
                 {
                     OUStringBuffer sAttrs;
                     SfxItemIter aIter( aSet );
-                    const SfxPoolItem* pItem = aIter.FirstItem();
+                    const SfxPoolItem* pItem = aIter.GetCurItem();
                     const IntlWrapper aInt(SvtSysLocale().GetUILanguageTag());
-                    while( true )
+                    do
                     {
                         if( !IsInvalidItem( pItem ))
                         {
@@ -1817,10 +1817,8 @@ bool SwCursorShell::GetContentAtPos( const Point& rPt,
                                 sAttrs.append(", ");
                             sAttrs.append(aStr);
                         }
-                        if( aIter.IsAtEnd() )
-                            break;
                         pItem = aIter.NextItem();
-                    }
+                    } while (pItem);
                     if (!sAttrs.isEmpty())
                     {
                         if( !rContentAtPos.sStr.isEmpty() )
diff --git a/sw/source/core/crsr/findattr.cxx b/sw/source/core/crsr/findattr.cxx
index 9c3064f272eb..08d5b6d51e8d 100644
--- a/sw/source/core/crsr/findattr.cxx
+++ b/sw/source/core/crsr/findattr.cxx
@@ -283,7 +283,7 @@ void SwAttrCheckArr::SetNewSet( const SwTextNode& rTextNd, 
const SwPaM& rPam )
     const SfxPoolItem* pFndItem;
     sal_uInt16 nWhich;
 
-    while( true )
+    do
     {
         if( IsInvalidItem( pItem ) )
         {
@@ -312,10 +312,8 @@ void SwAttrCheckArr::SetNewSet( const SwTextNode& rTextNd, 
const SwPaM& rPam )
             }
         }
 
-        if( aIter.IsAtEnd() )
-            break;
         pItem = aIter.NextItem();
-    }
+    } while (pItem);
 }
 
 static bool
@@ -860,7 +858,7 @@ static bool lcl_Search( const SwContentNode& rCNd, const 
SfxItemSet& rCmpSet, bo
     const SfxPoolItem* pNdItem;
     sal_uInt16 nWhich;
 
-    while( true )
+    do
     {
         if( IsInvalidItem( pItem ))
         {
@@ -877,10 +875,8 @@ static bool lcl_Search( const SwContentNode& rCNd, const 
SfxItemSet& rCmpSet, bo
                 return false;
         }
 
-        if( aIter.IsAtEnd() )
-            break;
         pItem = aIter.NextItem();
-    }
+    } while (pItem);
     return true; // found
 }
 
@@ -1348,17 +1344,15 @@ int SwFindParaAttr::DoFind(SwPaM & rCursor, 
SwMoveFnCollection const & fnMove,
 
             SfxItemIter aIter( *pSet );
             const SfxPoolItem* pItem = aIter.GetCurItem();
-            while( true )
+            do
             {
                 // reset all that are not set with pool defaults
                 if( !IsInvalidItem( pItem ) && SfxItemState::SET !=
                     pReplSet->GetItemState( pItem->Which(), false ))
                     aSet.Put( pPool->GetDefaultItem( pItem->Which() ));
 
-                if( aIter.IsAtEnd() )
-                    break;
                 pItem = aIter.NextItem();
-            }
+            } while (pItem);
             aSet.Put( *pReplSet );
             rCursor.GetDoc()->getIDocumentContentOperations().InsertItemSet(
                     rCursor, aSet, SetAttrMode::DEFAULT, m_pLayout);
diff --git a/sw/source/core/doc/docfly.cxx b/sw/source/core/doc/docfly.cxx
index 908d25de5176..58f4521f94d0 100644
--- a/sw/source/core/doc/docfly.cxx
+++ b/sw/source/core/doc/docfly.cxx
@@ -448,9 +448,9 @@ lcl_SetFlyFrameAttr(SwDoc & rDoc,
     const SfxPoolItem* pItem;
     SfxItemIter aIter( rSet );
     SfxItemSet aTmpSet( rDoc.GetAttrPool(), aFrameFormatSetRange );
-    sal_uInt16 nWhich = aIter.GetCurItem()->Which();
+    const SfxPoolItem* pItemIter = aIter.GetCurItem();
     do {
-        switch( nWhich )
+        switch(pItemIter->Which())
         {
         case RES_FILL_ORDER:
         case RES_BREAK:
@@ -460,24 +460,23 @@ lcl_SetFlyFrameAttr(SwDoc & rDoc,
             OSL_FAIL( "Unknown Fly attribute." );
             [[fallthrough]];
         case RES_CHAIN:
-            rSet.ClearItem( nWhich );
+            rSet.ClearItem(pItemIter->Which());
             break;
         case RES_ANCHOR:
             if( DONTMAKEFRMS != nMakeFrames )
                 break;
             [[fallthrough]];
         default:
-            if( !IsInvalidItem( aIter.GetCurItem() ) && ( SfxItemState::SET !=
-                rFlyFormat.GetAttrSet().GetItemState( nWhich, true, &pItem ) ||
-                *pItem != *aIter.GetCurItem() ))
-                aTmpSet.Put( *aIter.GetCurItem() );
+            if( !IsInvalidItem(pItemIter) && ( SfxItemState::SET !=
+                rFlyFormat.GetAttrSet().GetItemState(pItemIter->Which(), true, 
&pItem ) ||
+                *pItem != *pItemIter))
+                aTmpSet.Put(*pItemIter);
             break;
         }
 
-        if( aIter.IsAtEnd() )
-            break;
+        pItemIter = aIter.NextItem();
 
-    } while( 0 != ( nWhich = aIter.NextItem()->Which() ) );
+    } while (pItemIter && (0 != pItemIter->Which()));
 
     if( aTmpSet.Count() )
         rFlyFormat.SetFormatAttr( aTmpSet );
diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx
index 12d1cad9563e..c9ca44a6a8d2 100644
--- a/sw/source/core/doc/docfmt.cxx
+++ b/sw/source/core/doc/docfmt.cxx
@@ -195,8 +195,7 @@ static bool lcl_RstAttr( const SwNodePtr& rpNd, void* pArgs 
)
                 OSL_ENSURE( !bKeepAttributes,
                         "<lcl_RstAttr(..)> - certain attributes are kept, but 
not needed." );
                 SfxItemIter aIter( *pPara->pDelSet );
-                pItem = aIter.FirstItem();
-                while(pItem)
+                for (pItem = aIter.GetCurItem(); pItem; pItem = 
aIter.NextItem())
                 {
                     if ( ( pItem->Which() != RES_PAGEDESC &&
                            pItem->Which() != RES_BREAK &&
@@ -205,9 +204,6 @@ static bool lcl_RstAttr( const SwNodePtr& rpNd, void* pArgs 
)
                     {
                         pNode->ResetAttr( pItem->Which() );
                     }
-                    if (aIter.IsAtEnd())
-                        break;
-                    pItem = aIter.NextItem();
                 }
             }
             else if( pPara->bResetAll )
@@ -559,7 +555,7 @@ void SwDoc::SetDefault( const SfxItemSet& rSet )
     SfxItemIter aIter( rSet );
     const SfxPoolItem* pItem = aIter.GetCurItem();
     SfxItemPool* pSdrPool = GetAttrPool().GetSecondaryPool();
-    while( true )
+    do
     {
         bool bCheckSdrDflt = false;
         const sal_uInt16 nWhich = pItem->Which();
@@ -609,10 +605,8 @@ void SwDoc::SetDefault( const SfxItemSet& rSet )
             }
         }
 
-        if( aIter.IsAtEnd() )
-            break;
         pItem = aIter.NextItem();
-    }
+    } while (pItem);
 
     if( aNew.Count() && aCallMod.HasWriterListeners() )
     {
diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx
index 8eb527eb519f..c6a3e694e210 100644
--- a/sw/source/core/doc/docredln.cxx
+++ b/sw/source/core/doc/docredln.cxx
@@ -834,13 +834,9 @@ void SwRedlineExtraData_FormatColl::SetItemSet( const 
SfxItemSet& rSet )
 SwRedlineExtraData_Format::SwRedlineExtraData_Format( const SfxItemSet& rSet )
 {
     SfxItemIter aIter( rSet );
-    const SfxPoolItem* pItem = aIter.FirstItem();
-    while(pItem)
+    for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = 
aIter.NextItem())
     {
         m_aWhichIds.push_back( pItem->Which() );
-        if( aIter.IsAtEnd() )
-            break;
-        pItem = aIter.NextItem();
     }
 }
 
diff --git a/sw/source/core/doc/textboxhelper.cxx 
b/sw/source/core/doc/textboxhelper.cxx
index 89072dffae14..3c4e63a12b2f 100644
--- a/sw/source/core/doc/textboxhelper.cxx
+++ b/sw/source/core/doc/textboxhelper.cxx
@@ -661,14 +661,14 @@ void SwTextBoxHelper::syncFlyFrameAttr(SwFrameFormat& 
rShape, SfxItemSet const&
         SfxItemSet aTextBoxSet(pFormat->GetDoc()->GetAttrPool(), 
aFrameFormatSetRange);
 
         SfxItemIter aIter(rSet);
-        sal_uInt16 nWhich = aIter.GetCurItem()->Which();
+        const SfxPoolItem* pItem = aIter.GetCurItem();
         do
         {
-            switch (nWhich)
+            switch (pItem->Which())
             {
                 case RES_VERT_ORIENT:
                 {
-                    auto& rOrient = static_cast<const 
SwFormatVertOrient&>(*aIter.GetCurItem());
+                    auto& rOrient = static_cast<const 
SwFormatVertOrient&>(*pItem);
                     SwFormatVertOrient aOrient(rOrient);
 
                     tools::Rectangle aRect = getTextRectangle(&rShape, 
/*bAbsolute=*/false);
@@ -688,7 +688,7 @@ void SwTextBoxHelper::syncFlyFrameAttr(SwFrameFormat& 
rShape, SfxItemSet const&
                 break;
                 case RES_HORI_ORIENT:
                 {
-                    auto& rOrient = static_cast<const 
SwFormatHoriOrient&>(*aIter.GetCurItem());
+                    auto& rOrient = static_cast<const 
SwFormatHoriOrient&>(*pItem);
                     SwFormatHoriOrient aOrient(rOrient);
 
                     tools::Rectangle aRect = getTextRectangle(&rShape, 
/*bAbsolute=*/false);
@@ -724,14 +724,13 @@ void SwTextBoxHelper::syncFlyFrameAttr(SwFrameFormat& 
rShape, SfxItemSet const&
                 }
                 break;
                 default:
-                    SAL_WARN("sw.core",
-                             "SwTextBoxHelper::syncFlyFrameAttr: unhandled 
which-id: " << nWhich);
+                    SAL_WARN("sw.core", "SwTextBoxHelper::syncFlyFrameAttr: 
unhandled which-id: "
+                                            << pItem->Which());
                     break;
             }
 
-            if (aIter.IsAtEnd())
-                break;
-        } while (0 != (nWhich = aIter.NextItem()->Which()));
+            pItem = aIter.NextItem();
+        } while (pItem && (0 != pItem->Which()));
 
         if (aTextBoxSet.Count())
             pFormat->GetDoc()->SetFlyFrameAttr(*pFormat, aTextBoxSet);
diff --git a/sw/source/core/docnode/ndsect.cxx 
b/sw/source/core/docnode/ndsect.cxx
index 58dd8e7d9c4d..5be1211da092 100644
--- a/sw/source/core/docnode/ndsect.cxx
+++ b/sw/source/core/docnode/ndsect.cxx
@@ -620,19 +620,17 @@ void SwDoc::UpdateSection( size_t const nPos, 
SwSectionData & rNewData,
         if( pAttr && pAttr->Count() )
         {
             SfxItemIter aIter( *pAttr );
-            sal_uInt16 nWhich = aIter.GetCurItem()->Which();
-            while( true )
+            const SfxPoolItem* pItem = aIter.GetCurItem();
+            do
             {
-                if( pFormat->GetFormatAttr( nWhich ) != *aIter.GetCurItem() )
+                if (pFormat->GetFormatAttr(pItem->Which()) != *pItem)
                 {
                     bOnlyAttrChg = true;
                     break;
                 }
 
-                if( aIter.IsAtEnd() )
-                    break;
-                nWhich = aIter.NextItem()->Which();
-            }
+                pItem = aIter.NextItem();
+            } while (pItem);
         }
 
         if( bOnlyAttrChg )
diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx
index 728c191d753f..33b5e194e160 100644
--- a/sw/source/core/layout/fly.cxx
+++ b/sw/source/core/layout/fly.cxx
@@ -643,18 +643,16 @@ void SwFlyFrame::Modify( const SfxPoolItem* pOld, const 
SfxPoolItem * pNew )
     {
         SfxItemIter aNIter( *static_cast<const 
SwAttrSetChg*>(pNew)->GetChgSet() );
         SfxItemIter aOIter( *static_cast<const 
SwAttrSetChg*>(pOld)->GetChgSet() );
+        const SfxPoolItem* pNItem = aNIter.GetCurItem();
+        const SfxPoolItem* pOItem = aOIter.GetCurItem();
         SwAttrSetChg aOldSet( *static_cast<const SwAttrSetChg*>(pOld) );
         SwAttrSetChg aNewSet( *static_cast<const SwAttrSetChg*>(pNew) );
-        while( true )
+        do
         {
-            UpdateAttr_( aOIter.GetCurItem(),
-                         aNIter.GetCurItem(), nInvFlags,
-                         &aOldSet, &aNewSet );
-            if( aNIter.IsAtEnd() )
-                break;
-            aNIter.NextItem();
-            aOIter.NextItem();
-        }
+            UpdateAttr_(pOItem, pNItem, nInvFlags, &aOldSet, &aNewSet);
+            pNItem = aNIter.NextItem();
+            pOItem = aOIter.NextItem();
+        } while (pNItem);
         if ( aOldSet.Count() || aNewSet.Count() )
             SwLayoutFrame::Modify( &aOldSet, &aNewSet );
     }
diff --git a/sw/source/core/layout/pagechg.cxx 
b/sw/source/core/layout/pagechg.cxx
index 284f92a97556..a2b70fb68e81 100644
--- a/sw/source/core/layout/pagechg.cxx
+++ b/sw/source/core/layout/pagechg.cxx
@@ -507,18 +507,16 @@ void SwPageFrame::Modify( const SfxPoolItem* pOld, const 
SfxPoolItem * pNew )
     {
         SfxItemIter aNIter( *static_cast<const 
SwAttrSetChg*>(pNew)->GetChgSet() );
         SfxItemIter aOIter( *static_cast<const 
SwAttrSetChg*>(pOld)->GetChgSet() );
+        const SfxPoolItem* pNItem = aNIter.GetCurItem();
+        const SfxPoolItem* pOItem = aOIter.GetCurItem();
         SwAttrSetChg aOldSet( *static_cast<const SwAttrSetChg*>(pOld) );
         SwAttrSetChg aNewSet( *static_cast<const SwAttrSetChg*>(pNew) );
-        while( true )
+        do
         {
-            UpdateAttr_( aOIter.GetCurItem(),
-                         aNIter.GetCurItem(), nInvFlags,
-                         &aOldSet, &aNewSet );
-            if( aNIter.IsAtEnd() )
-                break;
-            aNIter.NextItem();
-            aOIter.NextItem();
-        }
+            UpdateAttr_(pOItem, pNItem, nInvFlags, &aOldSet, &aNewSet);
+            pNItem = aNIter.NextItem();
+            pOItem = aOIter.NextItem();
+        } while (pNItem);
         if ( aOldSet.Count() || aNewSet.Count() )
             SwLayoutFrame::Modify( &aOldSet, &aNewSet );
     }
diff --git a/sw/source/core/layout/sectfrm.cxx 
b/sw/source/core/layout/sectfrm.cxx
index e64301f8fbe4..7c71e6c44e33 100644
--- a/sw/source/core/layout/sectfrm.cxx
+++ b/sw/source/core/layout/sectfrm.cxx
@@ -2569,18 +2569,16 @@ void SwSectionFrame::Modify( const SfxPoolItem* pOld, 
const SfxPoolItem * pNew )
     {
         SfxItemIter aNIter( *static_cast<const 
SwAttrSetChg*>(pNew)->GetChgSet() );
         SfxItemIter aOIter( *static_cast<const 
SwAttrSetChg*>(pOld)->GetChgSet() );
+        const SfxPoolItem* pNItem = aNIter.GetCurItem();
+        const SfxPoolItem* pOItem = aOIter.GetCurItem();
         SwAttrSetChg aOldSet( *static_cast<const SwAttrSetChg*>(pOld) );
         SwAttrSetChg aNewSet( *static_cast<const SwAttrSetChg*>(pNew) );
-        while( true )
+        do
         {
-            UpdateAttr_( aOIter.GetCurItem(),
-                         aNIter.GetCurItem(), nInvFlags,
-                         &aOldSet, &aNewSet );
-            if( aNIter.IsAtEnd() )
-                break;
-            aNIter.NextItem();
-            aOIter.NextItem();
-        }
+            UpdateAttr_(pOItem, pNItem, nInvFlags, &aOldSet, &aNewSet);
+            pNItem = aNIter.NextItem();
+            pOItem = aOIter.NextItem();
+        } while (pNItem);
         if ( aOldSet.Count() || aNewSet.Count() )
             SwLayoutFrame::Modify( &aOldSet, &aNewSet );
     }
diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx
index bfe8a7a9e4ea..4395bd231900 100644
--- a/sw/source/core/layout/tabfrm.cxx
+++ b/sw/source/core/layout/tabfrm.cxx
@@ -3164,18 +3164,16 @@ void SwTabFrame::Modify( const SfxPoolItem* pOld, const 
SfxPoolItem * pNew )
     {
         SfxItemIter aNIter( *static_cast<const 
SwAttrSetChg*>(pNew)->GetChgSet() );
         SfxItemIter aOIter( *static_cast<const 
SwAttrSetChg*>(pOld)->GetChgSet() );
+        const SfxPoolItem* pNItem = aNIter.GetCurItem();
+        const SfxPoolItem* pOItem = aOIter.GetCurItem();
         SwAttrSetChg aOldSet( *static_cast<const SwAttrSetChg*>(pOld) );
         SwAttrSetChg aNewSet( *static_cast<const SwAttrSetChg*>(pNew) );
-        while( true )
+        do
         {
-            UpdateAttr_( aOIter.GetCurItem(),
-                         aNIter.GetCurItem(), nInvFlags,
-                         &aOldSet, &aNewSet );
-            if( aNIter.IsAtEnd() )
-                break;
-            aNIter.NextItem();
-            aOIter.NextItem();
-        }
+            UpdateAttr_(pOItem, pNItem, nInvFlags, &aOldSet, &aNewSet);
+            pNItem = aNIter.NextItem();
+            pOItem = aOIter.NextItem();
+        } while (pNItem);
         if ( aOldSet.Count() || aNewSet.Count() )
             SwLayoutFrame::Modify( &aOldSet, &aNewSet );
     }
diff --git a/sw/source/core/layout/wsfrm.cxx b/sw/source/core/layout/wsfrm.cxx
index 62eca76b99a8..f17a7ba68870 100644
--- a/sw/source/core/layout/wsfrm.cxx
+++ b/sw/source/core/layout/wsfrm.cxx
@@ -479,15 +479,14 @@ void SwFrame::Modify( const SfxPoolItem* pOld, const 
SfxPoolItem * pNew )
     {
         SfxItemIter aNIter( *static_cast<const 
SwAttrSetChg*>(pNew)->GetChgSet() );
         SfxItemIter aOIter( *static_cast<const 
SwAttrSetChg*>(pOld)->GetChgSet() );
-        while( true )
+        const SfxPoolItem* pNItem = aNIter.GetCurItem();
+        const SfxPoolItem* pOItem = aOIter.GetCurItem();
+        do
         {
-            UpdateAttrFrame( aOIter.GetCurItem(),
-                         aNIter.GetCurItem(), nInvFlags );
-            if( aNIter.IsAtEnd() )
-                break;
-            aNIter.NextItem();
-            aOIter.NextItem();
-        }
+            UpdateAttrFrame(pOItem, pNItem, nInvFlags);
+            pNItem = aNIter.NextItem();
+            pOItem = aOIter.NextItem();
+        } while (pNItem);
     }
     else
         UpdateAttrFrame( pOld, pNew, nInvFlags );
@@ -2308,18 +2307,16 @@ void SwContentFrame::Modify( const SfxPoolItem* pOld, 
const SfxPoolItem * pNew )
     {
         SfxItemIter aNIter( *static_cast<const 
SwAttrSetChg*>(pNew)->GetChgSet() );
         SfxItemIter aOIter( *static_cast<const 
SwAttrSetChg*>(pOld)->GetChgSet() );
+        const SfxPoolItem* pNItem = aNIter.GetCurItem();
+        const SfxPoolItem* pOItem = aOIter.GetCurItem();
         SwAttrSetChg aOldSet( *static_cast<const SwAttrSetChg*>(pOld) );
         SwAttrSetChg aNewSet( *static_cast<const SwAttrSetChg*>(pNew) );
-        while( true )
+        do
         {
-            UpdateAttr_( aOIter.GetCurItem(),
-                         aNIter.GetCurItem(), nInvFlags,
-                         &aOldSet, &aNewSet );
-            if( aNIter.IsAtEnd() )
-                break;
-            aNIter.NextItem();
-            aOIter.NextItem();
-        }
+            UpdateAttr_(pOItem, pNItem, nInvFlags, &aOldSet, &aNewSet);
+            pNItem = aNIter.NextItem();
+            pOItem = aOIter.NextItem();
+        } while (pNItem);
         if ( aOldSet.Count() || aNewSet.Count() )
             SwFrame::Modify( &aOldSet, &aNewSet );
     }
diff --git a/sw/source/core/text/atrstck.cxx b/sw/source/core/text/atrstck.cxx
index b195e2ddaafb..79740aa73c42 100644
--- a/sw/source/core/text/atrstck.cxx
+++ b/sw/source/core/text/atrstck.cxx
@@ -304,7 +304,7 @@ void SwAttrHandler::Init( const SfxPoolItem** pPoolItem, 
const SwAttrSet* pAS,
         SfxItemIter aIter( *pAS );
         sal_uInt16 nWhich;
         const SfxPoolItem* pItem = aIter.GetCurItem();
-        while( true )
+        do
         {
             nWhich = pItem->Which();
             if (isCHRATR(nWhich))
@@ -313,11 +313,8 @@ void SwAttrHandler::Init( const SfxPoolItem** pPoolItem, 
const SwAttrSet* pAS,
                 FontChg( *pItem, rFnt, true );
             }
 
-            if( aIter.IsAtEnd() )
-                break;
-
             pItem = aIter.NextItem();
-        }
+        } while (pItem);
     }
 
     // It is possible, that Init is called more than once, e.g., in a
diff --git a/sw/source/core/text/txtfld.cxx b/sw/source/core/text/txtfld.cxx
index dbcce0cba63e..1cd40e555c93 100644
--- a/sw/source/core/text/txtfld.cxx
+++ b/sw/source/core/text/txtfld.cxx
@@ -461,18 +461,15 @@ static void 
checkApplyParagraphMarkFormatToNumbering(SwFont* pNumFnt, SwTextForm
 
         SfxItemIter aIter(*pSet);
         const SfxPoolItem* pItem = aIter.GetCurItem();
-        while (true)
+        do
         {
             if (SwTextNode::IsIgnoredCharFormatForNumbering(pItem->Which()))
                 pCleanedSet->ClearItem(pItem->Which());
             else if (pFormat && pFormat->HasItem(pItem->Which()))
                 pCleanedSet->ClearItem(pItem->Which());
 
-            if (aIter.IsAtEnd())
-                break;
-
             pItem = aIter.NextItem();
-        }
+        } while (pItem);
         // Highlightcolor also needed to be untouched, but we can't have that 
just by clearing the item
         Color nSaveHighlight = pNumFnt->GetHighlightColor();
         pNumFnt->SetDiffFnt(pCleanedSet.get(), pIDSA);
diff --git a/sw/source/core/tox/ToxTextGenerator.cxx 
b/sw/source/core/tox/ToxTextGenerator.cxx
index 9b046f9c4c22..4714c45ce1bb 100644
--- a/sw/source/core/tox/ToxTextGenerator.cxx
+++ b/sw/source/core/tox/ToxTextGenerator.cxx
@@ -287,7 +287,8 @@ ToxTextGenerator::CollectAttributesForTox(const SwTextAttr& 
hint, SwAttrPool& po
     const SwFormatAutoFormat& afmt = hint.GetAutoFormat();
     SfxItemIter aIter( *afmt.GetStyleHandle());
     const SfxPoolItem* pItem = aIter.GetCurItem();
-    while (true) {
+    do
+    {
         if (pItem->Which() == RES_CHRATR_ESCAPEMENT ||
             pItem->Which() == RES_CHRATR_POSTURE ||
             pItem->Which() == RES_CHRATR_CJK_POSTURE ||
@@ -295,11 +296,8 @@ ToxTextGenerator::CollectAttributesForTox(const 
SwTextAttr& hint, SwAttrPool& po
         {
             retval->Put(std::unique_ptr<SfxPoolItem>(pItem->Clone()));
         }
-        if (aIter.IsAtEnd()) {
-            break;
-        }
         pItem = aIter.NextItem();
-    }
+    } while (pItem);
     return retval;
 }
 
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index a4d897cb3c05..0626058868d0 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -2468,7 +2468,7 @@ void SwTextNode::CutImpl( SwTextNode * const pDest, const 
SwIndex & rDestStart,
                 // check all items in the property set
                 SfxItemIter aIter( *pDest->GetpSwAttrSet() );
                 const SfxPoolItem* pItem = aIter.GetCurItem();
-                while( true )
+                do
                 {
                     // check current item
                     sal_uInt16 nWhich = IsInvalidItem( pItem )
@@ -2489,10 +2489,8 @@ void SwTextNode::CutImpl( SwTextNode * const pDest, 
const SwIndex & rDestStart,
                     }
 
                     // let's check next item
-                    if( aIter.IsAtEnd() )
-                        break;
                     pItem = aIter.NextItem();
-                }
+                } while (pItem);
             }
         }
 
diff --git a/sw/source/core/txtnode/thints.cxx 
b/sw/source/core/txtnode/thints.cxx
index e2dea45e13fb..84ae91570a1f 100644
--- a/sw/source/core/txtnode/thints.cxx
+++ b/sw/source/core/txtnode/thints.cxx
@@ -774,18 +774,15 @@ void SwpHints::BuildPortions( SwTextNode& rNode, 
SwTextAttr& rNewHint,
                         aCharAutoFormatSetRange);
                     SfxItemIter aItemIter( *pOldStyle );
                     const SfxPoolItem* pItem = aItemIter.GetCurItem();
-                    while( true )
+                    do
                     {
                         if ( !CharFormat::IsItemIncluded( pItem->Which(), 
&rNewHint ) )
                         {
                             aNewSet.Put( *pItem );
                         }
 
-                        if( aItemIter.IsAtEnd() )
-                            break;
-
                         pItem = aItemIter.NextItem();
-                    }
+                    } while (pItem);
 
                     // Remove old hint
                     Delete( pOther );
@@ -859,7 +856,7 @@ void SwpHints::BuildPortions( SwTextNode& rNode, 
SwTextAttr& rNewHint,
                                 aNewSet.ClearItem( pItem->Which() );
                         }
                     }
-                    while (!aIter2.IsAtEnd() && nullptr != (pItem = 
aIter2.NextItem()));
+                    while ((pItem = aIter2.NextItem()));
                 }
 
                 // Remove old hint
@@ -901,7 +898,7 @@ void SwpHints::BuildPortions( SwTextNode& rNode, 
SwTextAttr& rNewHint,
                             }
                         }
                     }
-                    while (!aIter2.IsAtEnd() && nullptr != (pItem = 
aIter2.NextItem()));
+                    while ((pItem = aIter2.NextItem()));
 
                     if ( pNewSet )
                     {
@@ -1903,7 +1900,7 @@ bool SwTextNode::SetAttr(
 
     do
     {
-        if ( pItem && !IsInvalidItem(pItem) )
+        if (!IsInvalidItem(pItem))
         {
             const sal_uInt16 nWhich = pItem->Which();
             OSL_ENSURE( isCHRATR(nWhich) || isTXTATR(nWhich),
@@ -1949,10 +1946,8 @@ bool SwTextNode::SetAttr(
                 }
             }
         }
-        if ( aIter.IsAtEnd() )
-            break;
         pItem = aIter.NextItem();
-    } while( true );
+    } while(pItem);
 
     if ( aCharSet.Count() )
     {
@@ -2181,7 +2176,7 @@ bool SwTextNode::GetParaAttr(SfxItemSet& rSet, sal_Int32 
nStt, sal_Int32 nEnd,
 
                     const sal_Int32 nHintEnd = *pAttrEnd;
 
-                    while ( pItem )
+                    for (; pItem; pItem = pItemIter ? pItemIter->NextItem() : 
nullptr)
                     {
                         const sal_uInt16 nHintWhich = pItem->Which();
                         OSL_ENSURE(!isUNKNOWNATR(nHintWhich),
@@ -2237,9 +2232,6 @@ bool SwTextNode::GetParaAttr(SfxItemSet& rSet, sal_Int32 
nStt, sal_Int32 nEnd,
                                 }
                             }
                         }
-
-                        pItem = ( pItemIter.get() && !pItemIter->IsAtEnd() )
-                                    ? pItemIter->NextItem() : nullptr;
                     } // end while
                 }
             }
@@ -2319,20 +2311,13 @@ struct RemovePresentAttrs
 
         const SwTextAttr* const pAutoStyle(i_rAttrSpan.second);
         SfxItemIter aIter(m_rAttrSet);
-        const SfxPoolItem* pItem(aIter.GetCurItem());
-        while (pItem)
+        for (const SfxPoolItem* pItem(aIter.GetCurItem()); pItem; pItem = 
aIter.NextItem())
         {
             const sal_uInt16 nWhich(pItem->Which());
             if (CharFormat::IsItemIncluded(nWhich, pAutoStyle))
             {
                 m_rAttrSet.ClearItem(nWhich);
             }
-
-            if (aIter.IsAtEnd())
-            {
-                break;
-            }
-            pItem = aIter.NextItem();
         }
     }
 
@@ -2384,16 +2369,9 @@ lcl_FillWhichIds(const SfxItemSet& i_rAttrSet, 
std::vector<sal_uInt16>& o_rClear
 {
     o_rClearIds.reserve(i_rAttrSet.Count());
     SfxItemIter aIter(i_rAttrSet);
-    const SfxPoolItem* pItem(aIter.GetCurItem());
-    while (pItem)
+    for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = 
aIter.NextItem())
     {
         o_rClearIds.push_back(pItem->Which());
-
-        if (aIter.IsAtEnd())
-        {
-            break;
-        }
-        pItem = aIter.NextItem();
     }
 }
 
@@ -2516,7 +2494,7 @@ void SwTextNode::FormatToTextAttr( SwTextNode* pNd )
             SfxItemSet aConvertSet( GetDoc()->GetAttrPool(), 
aCharFormatSetRange );
             std::vector<sal_uInt16> aClearWhichIds;
 
-            while( true )
+            do
             {
                 if( SfxItemState::SET == aNdSet.GetItemState( pItem->Which(), 
false, &pNdItem ) )
                 {
@@ -2535,10 +2513,8 @@ void SwTextNode::FormatToTextAttr( SwTextNode* pNd )
                     aConvertSet.Put(*pItem);
                 }
 
-                if( aIter.IsAtEnd() )
-                    break;
                 pItem = aIter.NextItem();
-            }
+            } while (pItem);
 
             // 4/ clear items of this that are set with the same value on pNd
             ClearItemsFromAttrSet( aClearWhichIds );
diff --git a/sw/source/core/txtnode/txtedt.cxx 
b/sw/source/core/txtnode/txtedt.cxx
index d38c2978b751..05ee2e75b40b 100644
--- a/sw/source/core/txtnode/txtedt.cxx
+++ b/sw/source/core/txtnode/txtedt.cxx
@@ -314,7 +314,7 @@ static bool lcl_HaveCommonAttributes( IStyleAccess& 
rStyleAccess,
     {
         SfxItemIter aIter( *pSet1 );
         const SfxPoolItem* pItem = aIter.GetCurItem();
-        while( true )
+        do
         {
             if ( SfxItemState::SET == rSet2.GetItemState( pItem->Which(), 
false ) )
             {
@@ -323,11 +323,8 @@ static bool lcl_HaveCommonAttributes( IStyleAccess& 
rStyleAccess,
                 pNewSet->ClearItem( pItem->Which() );
             }
 
-            if( aIter.IsAtEnd() )
-                break;
-
             pItem = aIter.NextItem();
-        }
+        } while (pItem);
     }
 
     if ( pNewSet )
diff --git a/sw/source/core/undo/rolbck.cxx b/sw/source/core/undo/rolbck.cxx
index a80d270cb81f..8d30afb1b870 100644
--- a/sw/source/core/undo/rolbck.cxx
+++ b/sw/source/core/undo/rolbck.cxx
@@ -1191,27 +1191,17 @@ void SwHistory::CopyFormatAttr(
     if(rSet.Count())
     {
         SfxItemIter aIter(rSet);
-
+        const SfxPoolItem* pItem = aIter.GetCurItem();
         do
         {
-            if(!IsInvalidItem(aIter.GetCurItem()))
-            {
-                const SfxPoolItem* pNew = aIter.GetCurItem();
-
-                Add(
-                    pNew,
-                    pNew,
-                    nNodeIdx);
-            }
-
-            if(aIter.IsAtEnd())
+            if(!IsInvalidItem(pItem))
             {
-                break;
+                Add(pItem, pItem, nNodeIdx);
             }
 
-            aIter.NextItem();
+            pItem = aIter.NextItem();
 
-        } while(true);
+        } while(pItem);
     }
 }
 
diff --git a/sw/source/core/undo/unattr.cxx b/sw/source/core/undo/unattr.cxx
index b880309dfb24..038302aa187c 100644
--- a/sw/source/core/undo/unattr.cxx
+++ b/sw/source/core/undo/unattr.cxx
@@ -83,12 +83,9 @@ void SwUndoFormatAttrHelper::Modify( const SfxPoolItem* 
pOld, const SfxPoolItem*
                 if ( GetUndo() ) {
                     SfxItemIter aIter(
                         *static_cast<const SwAttrSetChg*>(pOld)->GetChgSet() );
-                    const SfxPoolItem* pItem = aIter.GetCurItem();
-                    while ( pItem ) {
+                    for (auto pItem = aIter.GetCurItem(); pItem; pItem = 
aIter.NextItem())
+                    {
                         m_pUndo->PutAttr( *pItem, rDoc );
-                        if( aIter.IsAtEnd() )
-                            break;
-                        pItem = aIter.NextItem();
                     }
                 } else {
                     m_pUndo.reset( new SwUndoFormatAttr(
diff --git a/sw/source/core/undo/undobj1.cxx b/sw/source/core/undo/undobj1.cxx
index 1fb7f4551881..49eab82628c0 100644
--- a/sw/source/core/undo/undobj1.cxx
+++ b/sw/source/core/undo/undobj1.cxx
@@ -542,18 +542,13 @@ void SwUndoSetFlyFormat::UndoImpl(::sw::UndoRedoContext & 
rContext)
             m_pFrameFormat->SetDerivedFrom(pDerivedFromFrameFormat);
 
         SfxItemIter aIter( *m_pItemSet );
-        const SfxPoolItem* pItem = aIter.GetCurItem();
-        while( pItem )
+        for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = 
aIter.NextItem())
         {
             if( IsInvalidItem( pItem ))
                 m_pFrameFormat->ResetFormatAttr( m_pItemSet->GetWhichByPos(
                                         aIter.GetCurPos() ));
             else
                 m_pFrameFormat->SetFormatAttr( *pItem );
-
-            if( aIter.IsAtEnd() )
-                break;
-            pItem = aIter.NextItem();
         }
 
         if( m_bAnchorChanged )
@@ -689,13 +684,9 @@ void SwUndoSetFlyFormat::Modify( const SfxPoolItem* pOld, 
const SfxPoolItem* )
         else if( RES_ATTRSET_CHG == nWhich )
         {
             SfxItemIter aIter( *static_cast<const 
SwAttrSetChg*>(pOld)->GetChgSet() );
-            const SfxPoolItem* pItem = aIter.GetCurItem();
-            while( pItem )
+            for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = 
aIter.NextItem())
             {
                 PutAttr( pItem->Which(), pItem );
-                if( aIter.IsAtEnd() )
-                    break;
-                pItem = aIter.NextItem();
             }
         }
     }
diff --git a/sw/source/filter/writer/wrt_fn.cxx 
b/sw/source/filter/writer/wrt_fn.cxx
index 1debd24bd0c1..a881d5e8fd7d 100644
--- a/sw/source/filter/writer/wrt_fn.cxx
+++ b/sw/source/filter/writer/wrt_fn.cxx
@@ -80,7 +80,7 @@ Writer& Out_SfxItemSet( const SwAttrFnTab pTab, Writer& rWrt,
             {
                 bFillItemUsed = true;
             }
-        } while( !aIter.IsAtEnd() && nullptr != ( pItem = aIter.NextItem() ) );
+        } while ((pItem = aIter.NextItem()));
     }
     else
     {
diff --git a/sw/source/filter/ww8/writerhelper.cxx 
b/sw/source/filter/ww8/writerhelper.cxx
index 4c45fc48abb9..520283dc5fe1 100644
--- a/sw/source/filter/ww8/writerhelper.cxx
+++ b/sw/source/filter/ww8/writerhelper.cxx
@@ -410,7 +410,7 @@ namespace sw
                 {
                     do
                         rItems[pItem->Which()] = pItem;
-                    while (!aIter.IsAtEnd() && nullptr != (pItem = 
aIter.NextItem()));
+                    while ((pItem = aIter.NextItem()));
                 }
             }
         }
@@ -434,7 +434,7 @@ namespace sw
                     const SfxPoolItem *pItem = aIter.GetCurItem();
                     do
                         rSet.ClearItem(pItem->Which());
-                    while (!aIter.IsAtEnd() && nullptr != (pItem = 
aIter.NextItem()));
+                    while ((pItem = aIter.NextItem()));
                 }
             }
         }
diff --git a/sw/source/filter/ww8/wrtw8esh.cxx 
b/sw/source/filter/ww8/wrtw8esh.cxx
index 3d38d9ced1e8..7932a848cc4a 100644
--- a/sw/source/filter/ww8/wrtw8esh.cxx
+++ b/sw/source/filter/ww8/wrtw8esh.cxx
@@ -1319,7 +1319,7 @@ void MSWord_SdrAttrIter::OutParaAttr(bool bCharAttr, 
const std::set<sal_uInt16>*
                 if (m_rExport.CollapseScriptsforWordOk(nScript,nWhich))
                     m_rExport.AttrOutput().OutputItem(*pI);
             }
-        } while( !aIter.IsAtEnd() && nullptr != ( pItem = aIter.NextItem() ) );
+        } while ((pItem = aIter.NextItem()));
         m_rExport.SetCurItemSet( pOldSet );
     }
 }
diff --git a/sw/source/filter/ww8/wrtww8gr.cxx 
b/sw/source/filter/ww8/wrtww8gr.cxx
index 61d9ad960a27..d66cb8cc280f 100644
--- a/sw/source/filter/ww8/wrtww8gr.cxx
+++ b/sw/source/filter/ww8/wrtww8gr.cxx
@@ -99,9 +99,8 @@ bool WW8Export::TestOleNeedsGraphic(const SwAttrSet& rSet, 
tools::SvRef<SotStora
 {
     bool bGraphicNeeded = false;
     SfxItemIter aIter( rSet );
-    const SfxPoolItem* pItem = aIter.GetCurItem();
-
-    do {
+    for (auto pItem = aIter.GetCurItem(); !bGraphicNeeded && pItem; pItem = 
aIter.NextItem())
+    {
         switch (pItem->Which())
         {
             /*
@@ -121,8 +120,7 @@ bool WW8Export::TestOleNeedsGraphic(const SwAttrSet& rSet, 
tools::SvRef<SotStora
             default:
                 bGraphicNeeded = true;
         }
-    } while( !bGraphicNeeded && !aIter.IsAtEnd() &&
-        nullptr != ( pItem = aIter.NextItem() ) );
+    }
 
     /*
     Now we must see if the object contains a preview itself which is equal to
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index 535a6568360c..73059165f100 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -5429,12 +5429,12 @@ void AttributeOutputBase::OutputStyleItemSet( const 
SfxItemSet& rSet, bool bTest
     const SfxPoolItem* pItem;
     if ( !pSet->GetParent() )
     {
-        OSL_ENSURE( rSet.Count(), "Was already handled or?" );
+        assert(rSet.Count() && "Was already handled or?");
         SfxItemIter aIter( *pSet );
         pItem = aIter.GetCurItem();
         do {
             OutputItem( *pItem );
-        } while ( !aIter.IsAtEnd() && nullptr != ( pItem = aIter.NextItem() ) 
);
+        } while ((pItem = aIter.NextItem()));
     }
     else
     {
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 0c2808864dab..a525b2a996d0 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -2876,17 +2876,12 @@ void SwWW8ImplReader::PostProcessAttrs()
     {
         SfxItemIter aIter(m_pPostProcessAttrsInfo->mItemSet);
 
-        const SfxPoolItem * pItem = aIter.GetCurItem();
-        if (pItem != nullptr)
+        for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = 
aIter.NextItem())
         {
-            do
-            {
-                m_xCtrlStck->NewAttr(*m_pPostProcessAttrsInfo->mPaM.GetPoint(),
-                                   *pItem);
-                m_xCtrlStck->SetAttr(*m_pPostProcessAttrsInfo->mPaM.GetMark(),
-                                   pItem->Which());
-            }
-            while (!aIter.IsAtEnd() && nullptr != (pItem = aIter.NextItem()));
+            m_xCtrlStck->NewAttr(*m_pPostProcessAttrsInfo->mPaM.GetPoint(),
+                               *pItem);
+            m_xCtrlStck->SetAttr(*m_pPostProcessAttrsInfo->mPaM.GetMark(),
+                               pItem->Which());
         }
 
         m_pPostProcessAttrsInfo.reset();
diff --git a/sw/source/filter/ww8/ww8par3.cxx b/sw/source/filter/ww8/ww8par3.cxx
index 1fd69d154894..3b5deed3e5ff 100644
--- a/sw/source/filter/ww8/ww8par3.cxx
+++ b/sw/source/filter/ww8/ww8par3.cxx
@@ -1017,24 +1017,22 @@ void WW8ListManager::AdjustLVL( sal_uInt8 nLevel, 
SwNumRule& rNumRule,
                 && (pLowerLevelItemSet->Count() == pThisLevelItemSet->Count()) 
)
             {
                 nIdenticalItemSetLevel = nLowerLevel;
-                sal_uInt16 nWhich = aIter.GetCurItem()->Which();
-                while (true)
+                const SfxPoolItem* pItemIter = aIter.GetCurItem();
+                do
                 {
                     if(  // search for appropriate pItem in pLowerLevelItemSet
                          (SfxItemState::SET != 
pLowerLevelItemSet->GetItemState(
-                                            nWhich, false, &pItem ) )
+                                            pItemIter->Which(), false, &pItem 
) )
                         || // use virtual "!=" Operator
-                         (*pItem != *aIter.GetCurItem() ) )
+                         (*pItem != *pItemIter) )
                     // if no Item with equal nWhich was found or Item value 
was not equal
                     // store inequality and break!
                     {
                         nIdenticalItemSetLevel = nMaxLevel;
                         break;
                     }
-                    if( aIter.IsAtEnd() )
-                        break;
-                    nWhich = aIter.NextItem()->Which();
-                }
+                    pItemIter = aIter.NextItem();
+                } while (pItemIter);
 
                 if( nIdenticalItemSetLevel != nMaxLevel )
                     break;
diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx
index aa68d9180295..2e21260408df 100644
--- a/sw/source/filter/ww8/ww8par6.cxx
+++ b/sw/source/filter/ww8/ww8par6.cxx
@@ -2265,7 +2265,7 @@ void WW8DupProperties::Insert(const SwPosition &rPos)
             do
             {
                 pCtrlStck->NewAttr(rPos, *pItem);
-            }while( !aIter.IsAtEnd() && nullptr != ( pItem = aIter.NextItem() 
) );
+            } while ((pItem = aIter.NextItem()));
         }
     }
 }
diff --git a/sw/source/uibase/app/docstyle.cxx 
b/sw/source/uibase/app/docstyle.cxx
index 6d4032e57a8f..e80257079860 100644
--- a/sw/source/uibase/app/docstyle.cxx
+++ b/sw/source/uibase/app/docstyle.cxx
@@ -1663,7 +1663,7 @@ void SwDocStyleSheet::SetItemSet( const SfxItemSet& rSet,
     {
         SfxItemIter aIter( rSet );
         const SfxPoolItem* pItem = aIter.GetCurItem();
-        while( true )
+        do
         {
             if( IsInvalidItem( pItem ) )            // Clear
             {
@@ -1673,10 +1673,8 @@ void SwDocStyleSheet::SetItemSet( const SfxItemSet& rSet,
                                         *pFormat );
             }
 
-            if( aIter.IsAtEnd() )
-                break;
             pItem = aIter.NextItem();
-        }
+        } while (pItem);
         SfxItemSet aSet(rSet);
         aSet.ClearInvalidItems();
 
diff --git a/sw/source/uibase/config/uinums.cxx 
b/sw/source/uibase/config/uinums.cxx
index 700e0f86c28e..e2663ceda664 100644
--- a/sw/source/uibase/config/uinums.cxx
+++ b/sw/source/uibase/config/uinums.cxx
@@ -198,13 +198,11 @@ SwNumRulesWithName::SwNumFormatGlobal::SwNumFormatGlobal( 
const SwNumFormat& rFo
         {
             SfxItemIter aIter( pFormat->GetAttrSet() );
             const SfxPoolItem *pCurr = aIter.GetCurItem();
-            while( true )
+            do
             {
                 
m_Items.push_back(std::unique_ptr<SfxPoolItem>(pCurr->Clone()));
-                if( aIter.IsAtEnd() )
-                    break;
                 pCurr = aIter.NextItem();
-            }
+            } while (pCurr);
         }
 
         aFormat.SetCharFormat( nullptr );
diff --git a/sw/source/uibase/utlui/attrdesc.cxx 
b/sw/source/uibase/utlui/attrdesc.cxx
index 421d1d749da0..f6f88080bab2 100644
--- a/sw/source/uibase/utlui/attrdesc.cxx
+++ b/sw/source/uibase/utlui/attrdesc.cxx
@@ -73,19 +73,16 @@ void SwAttrSet::GetPresentation(
     if( Count() )
     {
         SfxItemIter aIter( *this );
+        const SfxPoolItem* pItem = aIter.GetCurItem();
         const IntlWrapper aInt(SvtSysLocale().GetUILanguageTag());
-        while( true )
+        do
         {
-            aIter.GetCurItem()->GetPresentation( ePres, eCoreMetric,
-                                                 ePresMetric, aStr,
-                                                 aInt );
+            pItem->GetPresentation(ePres, eCoreMetric, ePresMetric, aStr, 
aInt);
             if( rText.getLength() && aStr.getLength() )
                 rText += ", ";
             rText += aStr;
-            if( aIter.IsAtEnd() )
-                break;
-            aIter.NextItem();
-        }
+            pItem = aIter.NextItem();
+        } while (pItem);
     }
 }
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to