chart2/source/controller/itemsetwrapper/ItemConverter.cxx |    4 -
 editeng/source/rtf/rtfitem.cxx                            |    8 --
 editeng/source/rtf/svxrtf.cxx                             |   14 +--
 include/svl/itemiter.hxx                                  |   16 ++--
 sc/source/core/data/docpool.cxx                           |    5 -
 sfx2/source/control/bindings.cxx                          |   13 +--
 sfx2/source/control/dispatch.cxx                          |   20 +----
 sfx2/source/control/request.cxx                           |    8 +-
 svl/source/items/itemiter.cxx                             |    3 
 svl/source/items/itemset.cxx                              |    4 -
 svl/source/items/style.cxx                                |    4 -
 svl/source/items/stylepool.cxx                            |   12 +--
 svx/source/dialog/hdft.cxx                                |   10 +-
 svx/source/dialog/srchdlg.cxx                             |    2 
 svx/source/sdr/properties/textproperties.cxx              |   10 +-
 svx/source/svdraw/svdedtv1.cxx                            |    9 +-
 svx/source/svdraw/svdedxv.cxx                             |    5 -
 svx/source/svdraw/svdpntv.cxx                             |    5 -
 sw/source/core/access/AccessibilityCheck.cxx              |   12 +--
 sw/source/core/crsr/crstrvl.cxx                           |    8 --
 sw/source/core/crsr/findattr.cxx                          |   29 ++-----
 sw/source/core/doc/DocumentRedlineManager.cxx             |    2 
 sw/source/core/doc/dbgoutsw.cxx                           |    4 -
 sw/source/core/doc/docfly.cxx                             |    6 -
 sw/source/core/doc/docfmt.cxx                             |   28 ++-----
 sw/source/core/doc/docredln.cxx                           |    4 -
 sw/source/core/doc/textboxhelper.cxx                      |   13 +--
 sw/source/core/docnode/ndsect.cxx                         |    9 --
 sw/source/core/edit/edattr.cxx                            |    7 -
 sw/source/core/frmedt/fefly1.cxx                          |    4 -
 sw/source/core/layout/atrfrm.cxx                          |    4 -
 sw/source/core/layout/fly.cxx                             |    4 -
 sw/source/core/layout/pagechg.cxx                         |    4 -
 sw/source/core/layout/sectfrm.cxx                         |    4 -
 sw/source/core/layout/tabfrm.cxx                          |    4 -
 sw/source/core/layout/wsfrm.cxx                           |    8 +-
 sw/source/core/text/atrstck.cxx                           |   12 +--
 sw/source/core/text/itratr.cxx                            |    4 -
 sw/source/core/text/txtfld.cxx                            |    6 -
 sw/source/core/tox/ToxTextGenerator.cxx                   |    8 --
 sw/source/core/txtnode/ndtxt.cxx                          |   15 +--
 sw/source/core/txtnode/thints.cxx                         |   55 ++++++--------
 sw/source/core/txtnode/txtedt.cxx                         |    9 --
 sw/source/core/undo/rolbck.cxx                            |   23 ++---
 sw/source/core/undo/unattr.cxx                            |   12 ++-
 sw/source/core/undo/undobj1.cxx                           |   10 +-
 sw/source/core/unocore/unostyle.cxx                       |    4 -
 sw/source/filter/html/htmlcss1.cxx                        |    5 -
 sw/source/filter/html/htmlctxt.cxx                        |    9 +-
 sw/source/filter/html/htmldrawreader.cxx                  |    5 -
 sw/source/filter/html/swhtml.cxx                          |    2 
 sw/source/filter/md/wrtmd.cxx                             |    6 -
 sw/source/filter/writer/wrt_fn.cxx                        |    9 +-
 sw/source/filter/ww8/rtfattributeoutput.cxx               |    2 
 sw/source/filter/ww8/writerhelper.cxx                     |   12 +--
 sw/source/filter/ww8/wrtw8esh.cxx                         |    8 --
 sw/source/filter/ww8/wrtww8gr.cxx                         |    4 -
 sw/source/filter/ww8/ww8atr.cxx                           |    2 
 sw/source/filter/ww8/ww8par.cxx                           |    5 -
 sw/source/filter/ww8/ww8par3.cxx                          |    7 -
 sw/source/filter/ww8/ww8par6.cxx                          |    7 -
 sw/source/uibase/app/docstyle.cxx                         |   21 ++---
 sw/source/uibase/config/uinums.cxx                        |    8 --
 sw/source/uibase/utlui/attrdesc.cxx                       |    8 --
 sw/source/uibase/wrtsh/wrtsh1.cxx                         |    2 
 65 files changed, 250 insertions(+), 336 deletions(-)

New commits:
commit 2e063bf91b38a1226fc3ec909c83108b150563f6
Author:     Noel Grandin <[email protected]>
AuthorDate: Fri Feb 20 15:44:20 2026 +0200
Commit:     Noel Grandin <[email protected]>
CommitDate: Sat Feb 21 12:38:26 2026 +0100

    speed up SfxItemIter
    
    take some branches out of the hot path, which means
    converting some places to for loops.
    
    Change-Id: Idcac06f27761994e2554f723662f242a38d3778c
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199853
    Reviewed-by: Noel Grandin <[email protected]>
    Tested-by: Jenkins

diff --git a/chart2/source/controller/itemsetwrapper/ItemConverter.cxx 
b/chart2/source/controller/itemsetwrapper/ItemConverter.cxx
index 1a4eebf91127..0647c16fd17c 100644
--- a/chart2/source/controller/itemsetwrapper/ItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/ItemConverter.cxx
@@ -153,7 +153,6 @@ bool ItemConverter::ApplyItemSet( const SfxItemSet & 
rItemSet )
     OSL_ASSERT( m_xPropertySet.is());
 
     bool bItemsChanged = false;
-    SfxItemIter aIter( rItemSet );
     tPropertyNameWithMemberId aProperty;
     uno::Any aValue;
 
@@ -176,8 +175,9 @@ bool ItemConverter::ApplyItemSet( const SfxItemSet & 
rItemSet )
                 bItemsChanged = ApplySpecialItem(pItem->Which(), rItemSet);
     }
 
-    for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = 
aIter.NextItem())
+    for (SfxItemIter aIter( rItemSet ); !aIter.IsAtEnd(); aIter.Next())
     {
+        const SfxPoolItem* pItem = aIter.GetCurItem();
         if (SCHATTR_STAT_KIND_ERROR == pItem->Which())
             continue;
 
diff --git a/editeng/source/rtf/rtfitem.cxx b/editeng/source/rtf/rtfitem.cxx
index addf148d124e..223b830a6b34 100644
--- a/editeng/source/rtf/rtfitem.cxx
+++ b/editeng/source/rtf/rtfitem.cxx
@@ -1851,13 +1851,11 @@ void SvxRTFParser::SetDefault( int nToken, int nValue )
 
     if( aTmp.Count() )
     {
-        SfxItemIter aIter( aTmp );
-        const SfxPoolItem* pItem = aIter.GetCurItem();
-        do
+        for (SfxItemIter aIter( aTmp ); !aIter.IsAtEnd(); aIter.Next())
         {
+            const SfxPoolItem* pItem = aIter.GetCurItem();
             pAttrPool->SetUserDefaultItem( *pItem );
-            pItem = aIter.NextItem();
-        } while (pItem);
+        }
     }
 }
 
diff --git a/editeng/source/rtf/svxrtf.cxx b/editeng/source/rtf/svxrtf.cxx
index 425e63e2098b..28f9de64391f 100644
--- a/editeng/source/rtf/svxrtf.cxx
+++ b/editeng/source/rtf/svxrtf.cxx
@@ -704,7 +704,7 @@ void SvxRTFParser::AttrGroupEnd()   // process the current, 
delete from Stack
             // this by remembering the WhichIDs of Items to delete
             std::vector<sal_uInt16> aDeleteWhichIDs;
 
-            for (SfxItemIter aIter(pOld->aAttrSet); !aIter.IsAtEnd(); 
aIter.NextItem())
+            for (SfxItemIter aIter(pOld->aAttrSet); !aIter.IsAtEnd(); 
aIter.Next())
             {
                 const SfxPoolItem* pGet(nullptr);
                 if (SfxItemState::SET == 
pCurrent->aAttrSet.GetItemState(aIter.GetCurWhich(), false, &pGet)
@@ -1102,7 +1102,7 @@ void SvxRTFItemStackType::Compress( const SvxRTFParser& 
rParser )
             // ITEM: SfxItemIter and removing SfxPoolItems:
             std::vector<sal_uInt16> aDeleteWhichIDs;
 
-            for (SfxItemIter aIter(aMrgSet); !aIter.IsAtEnd(); 
aIter.NextItem())
+            for (SfxItemIter aIter(aMrgSet); !aIter.IsAtEnd(); aIter.Next())
             {
                 const SfxPoolItem* pGet(nullptr);
                 if (SfxItemState::SET != 
pTmp->aAttrSet.GetItemState(aIter.GetCurWhich(), false, &pGet)
@@ -1146,15 +1146,13 @@ void SvxRTFItemStackType::SetRTFDefaults( const 
SfxItemSet& rDefaults )
 {
     if( rDefaults.Count() )
     {
-        SfxItemIter aIter( rDefaults );
-        const SfxPoolItem* pItem = aIter.GetCurItem();
-        do {
+        for (SfxItemIter aIter( rDefaults ); !aIter.IsAtEnd(); aIter.Next())
+        {
+            const SfxPoolItem* pItem = aIter.GetCurItem();
             sal_uInt16 nWhich = pItem->Which();
             if( SfxItemState::SET != aAttrSet.GetItemState( nWhich, false ))
                 aAttrSet.Put(*pItem);
-
-            pItem = aIter.NextItem();
-        } while(pItem);
+        }
     }
 }
 
diff --git a/include/svl/itemiter.hxx b/include/svl/itemiter.hxx
index 93f1c2a89655..e58ba3762163 100644
--- a/include/svl/itemiter.hxx
+++ b/include/svl/itemiter.hxx
@@ -45,27 +45,29 @@ public:
 
     const SfxPoolItem* GetCurItem() const
     {
-        if (IsAtEnd())
-            return nullptr;
-
+        assert(!IsAtEnd());
         return maCurrent->second;
     }
 
     sal_uInt16 GetCurWhich() const
     {
-        if (IsAtEnd())
-            return 0;
-
+        assert(!IsAtEnd());
         return maCurrent->first;
     }
 
     const SfxPoolItem* NextItem()
     {
+        maCurrent++;
         if (IsAtEnd())
             return nullptr;
+        else
+            return GetCurItem();
+    }
 
+    void Next()
+    {
+        assert(!IsAtEnd());
         maCurrent++;
-        return GetCurItem();
     }
 
     bool IsAtEnd() const { return maCurrent == m_rSet.m_aPoolItemMap.end(); }
diff --git a/sc/source/core/data/docpool.cxx b/sc/source/core/data/docpool.cxx
index afbe7d0e2758..ab96fa3c8c8e 100644
--- a/sc/source/core/data/docpool.cxx
+++ b/sc/source/core/data/docpool.cxx
@@ -292,10 +292,9 @@ static bool lcl_HFPresentation
             return false;
     }
 
-    SfxItemIter aIter( rSet );
-
-    for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = 
aIter.NextItem())
+    for (SfxItemIter aIter( rSet ); !aIter.IsAtEnd(); aIter.Next())
     {
+        const SfxPoolItem* pItem = aIter.GetCurItem();
         sal_uInt16 nWhich = pItem->Which();
 
         OUString aText;
diff --git a/sfx2/source/control/bindings.cxx b/sfx2/source/control/bindings.cxx
index 0d78ff1eb741..bc72f90f2589 100644
--- a/sfx2/source/control/bindings.cxx
+++ b/sfx2/source/control/bindings.cxx
@@ -394,11 +394,8 @@ void SfxBindings::SetState
     // when locked then only invalidate
     if ( nRegLevel )
     {
-        SfxItemIter aIter(rSet);
-        for ( const SfxPoolItem *pItem = aIter.GetCurItem();
-              pItem;
-              pItem = aIter.NextItem() )
-            Invalidate( pItem->Which() );
+        for (SfxItemIter aIter( rSet ); !aIter.IsAtEnd(); aIter.Next())
+            Invalidate( aIter.GetCurItem()->Which() );
     }
     else
     {
@@ -408,11 +405,9 @@ void SfxBindings::SetState
 
         // Iterate over the itemset, update if the slot bound
         //! Bug: Use WhichIter and possibly send VoidItems up
-        SfxItemIter aIter(rSet);
-        for ( const SfxPoolItem *pItem = aIter.GetCurItem();
-              pItem;
-              pItem = aIter.NextItem() )
+        for (SfxItemIter aIter( rSet ); !aIter.IsAtEnd(); aIter.Next())
         {
+            const SfxPoolItem* pItem = aIter.GetCurItem();
             SfxStateCache* pCache =
                     GetStateCache( rSet.GetPool()->GetSlotId(pItem->Which()) );
             if ( pCache )
diff --git a/sfx2/source/control/dispatch.cxx b/sfx2/source/control/dispatch.cxx
index 9b253b9930c9..26c734134299 100644
--- a/sfx2/source/control/dispatch.cxx
+++ b/sfx2/source/control/dispatch.cxx
@@ -801,11 +801,8 @@ SfxPoolItemHolder SfxDispatcher::Execute(sal_uInt16 nSlot, 
SfxCallMode nCall,
         SfxAllItemSet aSet( pShell->GetPool() );
         if ( pArgs )
         {
-            SfxItemIter aIter(*pArgs);
-            for ( const SfxPoolItem *pArg = aIter.GetCurItem();
-                pArg;
-                pArg = aIter.NextItem() )
-                MappedPut_Impl( aSet, *pArg );
+            for (SfxItemIter aIter( *pArgs ); !aIter.IsAtEnd(); aIter.Next())
+                MappedPut_Impl( aSet, *aIter.GetCurItem() );
         }
         SfxRequest aReq(nSlot, nCall, aSet);
         if (pInternalArgs)
@@ -892,11 +889,8 @@ SfxPoolItemHolder SfxDispatcher::Execute(sal_uInt16 nSlot, 
SfxCallMode eCall,
     if ( GetShellAndSlot_Impl( nSlot,  &pShell, &pSlot, false, true ) )
     {
         SfxAllItemSet aSet( pShell->GetPool() );
-        SfxItemIter aIter(rArgs);
-        for ( const SfxPoolItem *pArg = aIter.GetCurItem();
-              pArg;
-              pArg = aIter.NextItem() )
-            MappedPut_Impl( aSet, *pArg );
+        for (SfxItemIter aIter( rArgs ); !aIter.IsAtEnd(); aIter.Next())
+            MappedPut_Impl( aSet, *aIter.GetCurItem() );
         SfxRequest aReq( nSlot, eCall, aSet );
         aReq.SetModifier( 0 );
         Execute_( *pShell, *pSlot, aReq, eCall );
@@ -1786,11 +1780,9 @@ bool SfxDispatcher::FillState_(const SfxSlotServer& 
rSvr, SfxItemSet& rState,
         if ( rState.Count() )
         {
             SfxInterface *pIF = pSh->GetInterface();
-            SfxItemIter aIter( rState );
-            for ( const SfxPoolItem *pItem = aIter.GetCurItem();
-                  pItem;
-                  pItem = aIter.NextItem() )
+            for (SfxItemIter aIter( rState ); !aIter.IsAtEnd(); aIter.Next())
             {
+                const SfxPoolItem* pItem = aIter.GetCurItem();
                 if ( !IsInvalidItem(pItem) && !IsDisabledItem(pItem) )
                 {
                     sal_uInt16 nSlotId = 
rState.GetPool()->GetSlotId(pItem->Which());
diff --git a/sfx2/source/control/request.cxx b/sfx2/source/control/request.cxx
index 7abcd34c1479..f1bee2212356 100644
--- a/sfx2/source/control/request.cxx
+++ b/sfx2/source/control/request.cxx
@@ -474,9 +474,9 @@ void SfxRequest::Done
     }
     else
     {
-        SfxItemIter aIter(rSet);
-        for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = 
aIter.NextItem())
+        for (SfxItemIter aIter(rSet); !aIter.IsAtEnd(); aIter.Next())
         {
+            const SfxPoolItem* pItem = aIter.GetCurItem();
             if(!IsInvalidItem(pItem))
                 pArgs->Put(*pItem);
         }
@@ -618,9 +618,9 @@ void SfxRequest::Done_Impl
         if ( pSet )
         {
             // iterate over Items
-            SfxItemIter aIter(*pSet);
-            for ( const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem 
= aIter.NextItem() )
+            for (SfxItemIter aIter( *pSet ); !aIter.IsAtEnd(); aIter.Next())
             {
+                const SfxPoolItem* pItem = aIter.GetCurItem();
                 // to determine the slot ID for the individual item
                 sal_uInt16 nSlotId = rPool.GetSlotId( pItem->Which() );
                 if ( nSlotId == nSlot )
diff --git a/svl/source/items/itemiter.cxx b/svl/source/items/itemiter.cxx
index 652c511e56da..67b2dbc99a05 100644
--- a/svl/source/items/itemiter.cxx
+++ b/svl/source/items/itemiter.cxx
@@ -22,8 +22,7 @@
 
 SfxItemState SfxItemIter::GetItemState(bool bSrchInParent, const SfxPoolItem** 
ppItem) const
 {
-    if (IsAtEnd())
-        return SfxItemState::UNKNOWN;
+    assert(!IsAtEnd());
 
     SfxItemState eState(SfxItemSet::GetItemState_ForIter(maCurrent, ppItem));
 
diff --git a/svl/source/items/itemset.cxx b/svl/source/items/itemset.cxx
index 9e08774c2a23..1911fcb3b82c 100644
--- a/svl/source/items/itemset.cxx
+++ b/svl/source/items/itemset.cxx
@@ -1372,9 +1372,9 @@ void SfxItemSet::dumpAsXml(xmlTextWriterPtr pWriter) const
 {
     tools::XmlWriter aWriter(pWriter);
     aWriter.startElement("SfxItemSet");
-    SfxItemIter aIter(*this);
-    for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = 
aIter.NextItem())
+    for (SfxItemIter aIter( *this ); !aIter.IsAtEnd(); aIter.Next())
     {
+        const SfxPoolItem* pItem = aIter.GetCurItem();
         if (IsInvalidItem(pItem))
         {
             aWriter.startElement("invalid");
diff --git a/svl/source/items/style.cxx b/svl/source/items/style.cxx
index bccbe71f7614..594736cc43b1 100644
--- a/svl/source/items/style.cxx
+++ b/svl/source/items/style.cxx
@@ -343,12 +343,12 @@ bool SfxStyleSheetBase::IsUsed() const
  */
 OUString SfxStyleSheetBase::GetDescription( MapUnit eMetric )
 {
-    SfxItemIter aIter( GetItemSet() );
     OUStringBuffer aDesc;
 
     IntlWrapper aIntlWrapper(SvtSysLocale().GetUILanguageTag());
-    for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = 
aIter.NextItem())
+    for (SfxItemIter aIter( GetItemSet() ); !aIter.IsAtEnd(); aIter.Next())
     {
+        const SfxPoolItem* pItem = aIter.GetCurItem();
         OUString aItemPresentation;
 
         if ( !IsInvalidItem( pItem ) &&
diff --git a/svl/source/items/stylepool.cxx b/svl/source/items/stylepool.cxx
index 4d89fc680086..40cd38961232 100644
--- a/svl/source/items/stylepool.cxx
+++ b/svl/source/items/stylepool.cxx
@@ -374,8 +374,6 @@ std::shared_ptr<SfxItemSet> StylePoolImpl::insertItemSet( 
const SfxItemSet& rSet
     Node* pCurNode = &maRoot[ rSet.GetParent() ];
     if (pParentName)
         maParentNames[ rSet.GetParent() ] = *pParentName;
-    SfxItemIter aIter( rSet );
-    const SfxPoolItem* pItem = aIter.GetCurItem();
     // Every SfxPoolItem in the SfxItemSet causes a step deeper into the tree,
     // a complete empty SfxItemSet would stay at the root node.
     // #i86923# insert ignorable items to the tree leaves.
@@ -384,26 +382,24 @@ std::shared_ptr<SfxItemSet> StylePoolImpl::insertItemSet( 
const SfxItemSet& rSet
     {
         xFoundIgnorableItems.emplace( *mpIgnorableItems );
     }
-    while( pItem )
+    for (SfxItemIter aIter( rSet ); !aIter.IsAtEnd(); aIter.Next())
     {
+        const SfxPoolItem* pItem = aIter.GetCurItem();
         if (!pItem->isShareable())
             bNonShareable = true;
         if (!xFoundIgnorableItems || (xFoundIgnorableItems->Put(*pItem) == 
nullptr))
         {
             pCurNode = pCurNode->findChildNode( *pItem, false );
         }
-        pItem = aIter.NextItem();
     }
     if ( xFoundIgnorableItems && xFoundIgnorableItems->Count() > 0 )
     {
-        SfxItemIter aIgnorableItemsIter( *xFoundIgnorableItems );
-        pItem = aIgnorableItemsIter.GetCurItem();
-        while( pItem )
+        for (SfxItemIter aIter( *xFoundIgnorableItems ); !aIter.IsAtEnd(); 
aIter.Next())
         {
+            const SfxPoolItem* pItem = aIter.GetCurItem();
             if (!pItem->isShareable())
                 bNonShareable = true;
             pCurNode = pCurNode->findChildNode( *pItem, true );
-            pItem = aIgnorableItemsIter.NextItem();
         }
     }
     // Every leaf node represents an inserted item set, but "non-leaf" nodes 
represents subsets
diff --git a/svx/source/dialog/hdft.cxx b/svx/source/dialog/hdft.cxx
index 03c085e0db2a..45e877c2221c 100644
--- a/svx/source/dialog/hdft.cxx
+++ b/svx/source/dialog/hdft.cxx
@@ -93,10 +93,9 @@ namespace svx {
         ScopedVclPtr<SfxAbstractTabDialog> 
pDlg(pFact->CreateSvxBorderBackgroundDlg(pParent, *pBBSet, true 
/*bEnableDrawingLayerFillStyles*/));
         if ( pDlg->Execute() == RET_OK && pDlg->GetOutputItemSet() )
         {
-            SfxItemIter aIter( *pDlg->GetOutputItemSet() );
-
-            for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = 
aIter.NextItem())
+            for (SfxItemIter aIter( *pDlg->GetOutputItemSet() ); 
!aIter.IsAtEnd(); aIter.Next())
             {
+                const SfxPoolItem* pItem = aIter.GetCurItem();
                 if ( !IsInvalidItem( pItem ) )
                     pBBSet->Put( *pItem );
             }
@@ -619,10 +618,9 @@ IMPL_LINK_NOARG(SvxHFPage, BackgroundHdl, weld::Button&, 
void)
     pDlg->StartExecuteAsync([pDlg, this](sal_Int32 nResult) {
         if (nResult == RET_OK && pDlg->GetOutputItemSet())
         {
-            SfxItemIter aIter(*pDlg->GetOutputItemSet());
-
-            for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = 
aIter.NextItem())
+            for (SfxItemIter aIter( *pDlg->GetOutputItemSet() ); 
!aIter.IsAtEnd(); aIter.Next())
             {
+                const SfxPoolItem* pItem = aIter.GetCurItem();
                 if(!IsInvalidItem(pItem))
                 {
                     m_pBBSet->Put(*pItem);
diff --git a/svx/source/dialog/srchdlg.cxx b/svx/source/dialog/srchdlg.cxx
index fa814ea57ddb..4ab3dce6fbc4 100644
--- a/svx/source/dialog/srchdlg.cxx
+++ b/svx/source/dialog/srchdlg.cxx
@@ -203,7 +203,7 @@ void SearchAttrItemList::Put( const SfxItemSet& rSet )
 
     SfxItemPool* pPool = rSet.GetPool();
 
-    for (SfxItemIter aIter(rSet); !aIter.IsAtEnd(); aIter.NextItem())
+    for (SfxItemIter aIter(rSet); !aIter.IsAtEnd(); aIter.Next())
     {
         const sal_uInt16 nWhich(aIter.GetCurWhich());
         const sal_uInt16 nSlot(pPool->GetSlotId(nWhich));
diff --git a/svx/source/sdr/properties/textproperties.cxx 
b/svx/source/sdr/properties/textproperties.cxx
index 04e4afb00fb9..d8fe6df3a351 100644
--- a/svx/source/sdr/properties/textproperties.cxx
+++ b/svx/source/sdr/properties/textproperties.cxx
@@ -330,11 +330,9 @@ namespace sdr::properties
                                     // remove all hard paragraph attributes
                                     // which occur in StyleSheet, take care of
                                     // parents (!)
-                                    SfxItemIter 
aIter(pNewStyleSheet->GetItemSet());
-
-                                    for (const SfxPoolItem* pItem = 
aIter.GetCurItem(); pItem;
-                                         pItem = aIter.NextItem())
+                                    for (SfxItemIter aIter( 
pNewStyleSheet->GetItemSet() ); !aIter.IsAtEnd(); aIter.Next())
                                     {
+                                        const SfxPoolItem* pItem = 
aIter.GetCurItem();
                                         if(!IsInvalidItem(pItem))
                                         {
                                             sal_uInt16 nW(pItem->Which());
@@ -401,9 +399,9 @@ namespace sdr::properties
             { // own scope to get SfxItemIter aIter destroyed ASAP - it maybe 
detected
               // as reading source to the ItemSet when Items get changed 
below, but it
               // is no longer active/needed
-                SfxItemIter aIter(*moItemSet);
-                for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; 
pItem = aIter.NextItem())
+                for (SfxItemIter aIter( *moItemSet ); !aIter.IsAtEnd(); 
aIter.Next())
                 {
+                    const SfxPoolItem* pItem = aIter.GetCurItem();
                     if(!IsInvalidItem(pItem))
                         aChangedItems.push_back(pItem);
                 }
diff --git a/svx/source/svdraw/svdedtv1.cxx b/svx/source/svdraw/svdedtv1.cxx
index 67f8bbb69592..c3dd247b61ee 100644
--- a/svx/source/svdraw/svdedtv1.cxx
+++ b/svx/source/svdraw/svdedtv1.cxx
@@ -1076,9 +1076,9 @@ std::vector<sal_uInt16> GetAllCharPropIds(const 
SfxItemSet& rSet)
 {
     std::vector<sal_uInt16> aCharWhichIds;
     {
-        SfxItemIter aIter(rSet);
-        for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = 
aIter.NextItem())
+        for (SfxItemIter aIter( rSet ); !aIter.IsAtEnd(); aIter.Next())
         {
+            const SfxPoolItem* pItem = aIter.GetCurItem();
             if (!IsInvalidItem(pItem))
             {
                 sal_uInt16 nWhich = pItem->Which();
@@ -1111,10 +1111,9 @@ void SdrEditView::SetAttrToMarked(const SfxItemSet& 
rAttr, bool bReplaceAll)
 #ifdef DBG_UTIL
     {
         bool bHasEEFeatureItems=false;
-        SfxItemIter aIter(rAttr);
-        for (const SfxPoolItem* pItem = aIter.GetCurItem(); 
!bHasEEFeatureItems && pItem;
-             pItem = aIter.NextItem())
+        for (SfxItemIter aIter( rAttr ); !bHasEEFeatureItems && 
!aIter.IsAtEnd(); aIter.Next())
         {
+            const SfxPoolItem* pItem = aIter.GetCurItem();
             if (!IsInvalidItem(pItem)) {
                 sal_uInt16 nW=pItem->Which();
                 if (nW>=EE_FEATURE_START && nW<=EE_FEATURE_END) 
bHasEEFeatureItems=true;
diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx
index 6b35e2516f8d..d81ecaea1a18 100644
--- a/svx/source/svdraw/svdedxv.cxx
+++ b/svx/source/svdraw/svdedxv.cxx
@@ -2403,10 +2403,9 @@ bool SdrObjEditView::SetAttributes(const SfxItemSet& 
rSet, bool bReplaceAll)
 #ifdef DBG_UTIL
         {
             bool bHasEEFeatureItems = false;
-            SfxItemIter aIter(rSet);
-            for (const SfxPoolItem* pItem = aIter.GetCurItem(); 
!bHasEEFeatureItems && pItem;
-                 pItem = aIter.NextItem())
+            for (SfxItemIter aIter(rSet); !bHasEEFeatureItems && 
!aIter.IsAtEnd(); aIter.Next())
             {
+                const SfxPoolItem* pItem = aIter.GetCurItem();
                 if (!IsInvalidItem(pItem))
                 {
                     sal_uInt16 nW = pItem->Which();
diff --git a/svx/source/svdraw/svdpntv.cxx b/svx/source/svdraw/svdpntv.cxx
index 78211ccec927..c755098e5fe7 100644
--- a/svx/source/svdraw/svdpntv.cxx
+++ b/svx/source/svdraw/svdpntv.cxx
@@ -961,10 +961,9 @@ void SdrPaintView::SetDefaultAttr(const SfxItemSet& rAttr, 
bool bReplaceAll)
 #ifdef DBG_UTIL
     {
         bool bHasEEFeatureItems=false;
-        SfxItemIter aIter(rAttr);
-        for (const SfxPoolItem* pItem = aIter.GetCurItem(); 
!bHasEEFeatureItems && pItem;
-             pItem = aIter.NextItem())
+        for (SfxItemIter aIter( rAttr ); !bHasEEFeatureItems && 
!aIter.IsAtEnd(); aIter.Next())
         {
+            const SfxPoolItem* pItem = aIter.GetCurItem();
             if (!IsInvalidItem(pItem)) {
                 sal_uInt16 nW=pItem->Which();
                 if (nW>=EE_FEATURE_START && nW<=EE_FEATURE_END) 
bHasEEFeatureItems=true;
diff --git a/sw/source/core/access/AccessibilityCheck.cxx 
b/sw/source/core/access/AccessibilityCheck.cxx
index 80b4a59b5d21..4c31a02102ba 100644
--- a/sw/source/core/access/AccessibilityCheck.cxx
+++ b/sw/source/core/access/AccessibilityCheck.cxx
@@ -988,8 +988,6 @@ public:
                          const std::map<sal_Int32, const SwTextAttr*>& 
rCharFormats)
     {
         const SwFormatAutoFormat& rAutoFormat = pTextAttr->GetAutoFormat();
-        SfxItemIter aItemIter(*rAutoFormat.GetStyleHandle());
-        const SfxPoolItem* pItem = aItemIter.GetCurItem();
 
         const SwTextAttr* pCharAttr = nullptr;
         auto itr = rCharFormats.find(pTextAttr->GetStart());
@@ -1001,8 +999,9 @@ public:
             pCharformat = pCharAttr->GetCharFormat().GetCharFormat();
 
         std::vector<OUString> aFormattings;
-        while (pItem)
+        for (SfxItemIter aIter(*rAutoFormat.GetStyleHandle()); 
!aIter.IsAtEnd(); aIter.Next())
         {
+            const SfxPoolItem* pItem = aIter.GetCurItem();
             OUString sFormattingType;
             switch (pItem->Which())
             {
@@ -1375,7 +1374,6 @@ public:
             }
             if (!sFormattingType.isEmpty())
                 aFormattings.push_back(sFormattingType);
-            pItem = aItemIter.NextItem();
         }
         if (aFormattings.empty())
             return;
@@ -1958,10 +1956,9 @@ private:
     void checkAutoFormat(SwTextNode* pTextNode, const SwTextAttr* pTextAttr)
     {
         const SwFormatAutoFormat& rAutoFormat = pTextAttr->GetAutoFormat();
-        SfxItemIter aItemIter(*rAutoFormat.GetStyleHandle());
-        const SfxPoolItem* pItem = aItemIter.GetCurItem();
-        while (pItem)
+        for (SfxItemIter aIter(*rAutoFormat.GetStyleHandle()); 
!aIter.IsAtEnd(); aIter.Next())
         {
+            const SfxPoolItem* pItem = aIter.GetCurItem();
             if (pItem->Which() == RES_CHRATR_ESCAPEMENT)
             {
                 auto pEscapementItem = static_cast<const 
SvxEscapementItem*>(pItem);
@@ -1980,7 +1977,6 @@ private:
                     break;
                 }
             }
-            pItem = aItemIter.NextItem();
         }
     }
 
diff --git a/sw/source/core/crsr/crstrvl.cxx b/sw/source/core/crsr/crstrvl.cxx
index 52ea96a509f3..8052070f0dbf 100644
--- a/sw/source/core/crsr/crstrvl.cxx
+++ b/sw/source/core/crsr/crstrvl.cxx
@@ -2176,11 +2176,10 @@ bool SwCursorShell::GetContentAtPos( const Point& rPt,
             if( aSet.Count() )
             {
                 OUStringBuffer sAttrs;
-                SfxItemIter aIter( aSet );
-                const SfxPoolItem* pItem = aIter.GetCurItem();
                 const IntlWrapper aInt(SvtSysLocale().GetUILanguageTag());
-                do
+                for (SfxItemIter aIter( aSet ); !aIter.IsAtEnd(); aIter.Next())
                 {
+                    const SfxPoolItem* pItem = aIter.GetCurItem();
                     if( !IsInvalidItem( pItem ))
                     {
                         OUString aStr;
@@ -2190,8 +2189,7 @@ bool SwCursorShell::GetContentAtPos( const Point& rPt,
                             sAttrs.append(", ");
                         sAttrs.append(aStr);
                     }
-                    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 f4ff66f81e1b..507e3a72c60b 100644
--- a/sw/source/core/crsr/findattr.cxx
+++ b/sw/source/core/crsr/findattr.cxx
@@ -226,7 +226,7 @@ SwAttrCheckArr::SwAttrCheckArr( const SfxItemSet& rSet, 
bool bFwd,
     if (0 != m_aComapeSet.Count())
     {
         nMinUsedWhichID = 5000; // SFX_WHICH_MAX+1;
-        for (SfxItemIter aIter(m_aComapeSet); !aIter.IsAtEnd(); 
aIter.NextItem())
+        for (SfxItemIter aIter(m_aComapeSet); !aIter.IsAtEnd(); aIter.Next())
         {
             const sal_uInt16 nCurrentWhich(aIter.GetCurWhich());
             if (SfxItemPool::IsSlot(nCurrentWhich))
@@ -282,13 +282,12 @@ void SwAttrCheckArr::SetNewSet( const SwTextNode& 
rTextNd, const SwPaM& rPam )
 
     const SfxItemSet& rSet = rTextNd.GetSwAttrSet();
 
-    SfxItemIter aIter( m_aComapeSet );
-    const SfxPoolItem* pItem = aIter.GetCurItem();
     const SfxPoolItem* pFndItem;
     sal_uInt16 nWhich;
 
-    do
+    for (SfxItemIter aIter( m_aComapeSet ); !aIter.IsAtEnd(); aIter.Next())
     {
+        const SfxPoolItem* pItem = aIter.GetCurItem();
         if( IsInvalidItem( pItem ) )
         {
             nWhich = aIter.GetCurWhich();
@@ -316,9 +315,7 @@ void SwAttrCheckArr::SetNewSet( const SwTextNode& rTextNd, 
const SwPaM& rPam )
                 m_nFound++;
             }
         }
-
-        pItem = aIter.NextItem();
-    } while (pItem);
+    }
 }
 
 static bool
@@ -896,13 +893,12 @@ static bool lcl_Search( const SwContentNode& rCNd, const 
SfxItemSet& rCmpSet, bo
         return false;
 
     const SfxItemSet& rNdSet = rCNd.GetSwAttrSet();
-    SfxItemIter aIter( rCmpSet );
-    const SfxPoolItem* pItem = aIter.GetCurItem();
     const SfxPoolItem* pNdItem;
     sal_uInt16 nWhich;
 
-    do
+    for (SfxItemIter aIter( rCmpSet ); !aIter.IsAtEnd(); aIter.Next())
     {
+        const SfxPoolItem* pItem = aIter.GetCurItem();
         if( IsInvalidItem( pItem ))
         {
             nWhich = aIter.GetCurWhich();
@@ -917,9 +913,7 @@ static bool lcl_Search( const SwContentNode& rCNd, const 
SfxItemSet& rCmpSet, bo
             if( !CmpAttr( rNdSet.Get( nWhich, !bNoColls ), *pItem ))
                 return false;
         }
-
-        pItem = aIter.NextItem();
-    } while (pItem);
+    }
     return true; // found
 }
 
@@ -1395,17 +1389,14 @@ int SwFindParaAttr::DoFind(SwPaM & rCursor, 
SwMoveFnCollection const & fnMove,
             SfxItemPool* pPool = pReplSet->GetPool();
             SfxItemSet aSet( *pPool, pReplSet->GetRanges() );
 
-            SfxItemIter aIter( *pSet );
-            const SfxPoolItem* pItem = aIter.GetCurItem();
-            do
+            for (SfxItemIter aIter( *pSet ); !aIter.IsAtEnd(); aIter.Next())
             {
+                const SfxPoolItem* pItem = aIter.GetCurItem();
                 // reset all that are not set with pool defaults
                 if( !IsInvalidItem( pItem ) && SfxItemState::SET !=
                     pReplSet->GetItemState( pItem->Which(), false ))
                     aSet.Put( pPool->GetUserOrPoolDefaultItem( pItem->Which() 
));
-
-                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/DocumentRedlineManager.cxx 
b/sw/source/core/doc/DocumentRedlineManager.cxx
index 1284650c0229..a4779aa6073e 100644
--- a/sw/source/core/doc/DocumentRedlineManager.cxx
+++ b/sw/source/core/doc/DocumentRedlineManager.cxx
@@ -444,7 +444,7 @@ namespace
 
             if (!bSameSet)
             {
-                for (SfxItemIter aIter(aTmp); !aIter.IsAtEnd(); 
aIter.NextItem())
+                for (SfxItemIter aIter(aTmp); !aIter.IsAtEnd(); aIter.Next())
                 {
                     const sal_uInt16 nWhich(aIter.GetCurWhich());
                     if( SfxItemState::SET == aTmp.GetItemState( nWhich, false 
) &&
diff --git a/sw/source/core/doc/dbgoutsw.cxx b/sw/source/core/doc/dbgoutsw.cxx
index 3e54aa44a8f3..9b739d2575aa 100644
--- a/sw/source/core/doc/dbgoutsw.cxx
+++ b/sw/source/core/doc/dbgoutsw.cxx
@@ -249,12 +249,12 @@ const char * dbg_out(const SfxPoolItem * pItem)
 
 static OUString lcl_dbg_out(const SfxItemSet & rSet)
 {
-    SfxItemIter aIter(rSet);
     bool bFirst = true;
     OUStringBuffer aStr = "[ ";
 
-    for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = 
aIter.NextItem())
+    for (SfxItemIter aIter( rSet ); !aIter.IsAtEnd(); aIter.Next())
     {
+        const SfxPoolItem* pItem = aIter.GetCurItem();
         if (!bFirst)
             aStr.append(", ");
 
diff --git a/sw/source/core/doc/docfly.cxx b/sw/source/core/doc/docfly.cxx
index a1efb32d4e03..dd042473e4af 100644
--- a/sw/source/core/doc/docfly.cxx
+++ b/sw/source/core/doc/docfly.cxx
@@ -458,7 +458,7 @@ lcl_SetFlyFrameAttr(SwDoc & rDoc,
     std::vector<sal_uInt16> aDeleteWhichIDs;
     SfxItemSet aTmpSet(rDoc.GetAttrPool(), aFrameFormatSetRange);
 
-    for (SfxItemIter aIter(rSet); !aIter.IsAtEnd() && 0 != 
aIter.GetCurWhich(); aIter.NextItem())
+    for (SfxItemIter aIter(rSet); !aIter.IsAtEnd() && 0 != 
aIter.GetCurWhich(); aIter.Next())
     {
         switch(aIter.GetCurWhich())
         {
@@ -503,10 +503,10 @@ lcl_SetFlyFrameAttr(SwDoc & rDoc,
 void SwDoc::CheckForUniqueItemForLineFillNameOrIndex(SfxItemSet& rSet)
 {
     SwDrawModel& rDrawModel = 
getIDocumentDrawModelAccess().GetOrCreateDrawModel();
-    SfxItemIter aIter(rSet);
 
-    for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = 
aIter.NextItem())
+    for (SfxItemIter aIter( rSet ); !aIter.IsAtEnd(); aIter.Next())
     {
+        const SfxPoolItem* pItem = aIter.GetCurItem();
         if (IsInvalidItem(pItem))
             continue;
         std::unique_ptr<SfxPoolItem> pResult;
diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx
index d289f7ec2cd9..009823b99146 100644
--- a/sw/source/core/doc/docfmt.cxx
+++ b/sw/source/core/doc/docfmt.cxx
@@ -135,12 +135,10 @@ static bool lcl_RstAttr( SwNode* pNd, void* pArgs )
             if ( aListAttrSet.Count() )
             {
                 aSavedAttrsSet.Put(aListAttrSet);
-                SfxItemIter aIter( aListAttrSet );
-                const SfxPoolItem* pItem = aIter.GetCurItem();
-                while( pItem )
+                for (SfxItemIter aIter( aListAttrSet ); !aIter.IsAtEnd(); 
aIter.Next())
                 {
+                    const SfxPoolItem* pItem = aIter.GetCurItem();
                     aClearWhichIds.push_back( pItem->Which() );
-                    pItem = aIter.NextItem();
                 }
             }
         }
@@ -208,9 +206,9 @@ static bool lcl_RstAttr( SwNode* pNd, void* pArgs )
             {
                 OSL_ENSURE( !bKeepAttributes,
                         "<lcl_RstAttr(..)> - certain attributes are kept, but 
not needed." );
-                SfxItemIter aIter( *pPara->pDelSet );
-                for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; 
pItem = aIter.NextItem())
+                for (SfxItemIter aIter( *pPara->pDelSet ); !aIter.IsAtEnd(); 
aIter.Next())
                 {
+                    const SfxPoolItem* pItem = aIter.GetCurItem();
                     if ( ( pItem->Which() != RES_PAGEDESC &&
                            pItem->Which() != RES_BREAK &&
                            pItem->Which() != RES_FRMATR_STYLE_NAME &&
@@ -581,11 +579,10 @@ void SwDoc::SetDefault( const SfxItemSet& rSet )
     sw::BroadcastingModify aCallMod;
     SwAttrSet aOld( GetAttrPool(), rSet.GetRanges() ),
             aNew( GetAttrPool(), rSet.GetRanges() );
-    SfxItemIter aIter( rSet );
-    const SfxPoolItem* pItem = aIter.GetCurItem();
     SfxItemPool* pSdrPool = GetAttrPool().GetSecondaryPool();
-    do
+    for (SfxItemIter aIter( rSet ); !aIter.IsAtEnd(); aIter.Next())
     {
+        const SfxPoolItem* pItem = aIter.GetCurItem();
         bool bCheckSdrDflt = false;
         const sal_uInt16 nWhich = pItem->Which();
         aOld.Put( GetAttrPool().GetUserOrPoolDefaultItem( nWhich ) );
@@ -634,9 +631,7 @@ void SwDoc::SetDefault( const SfxItemSet& rSet )
                 }
             }
         }
-
-        pItem = aIter.NextItem();
-    } while (pItem);
+    }
 
     if( aNew.Count() && aCallMod.HasWriterListeners() )
     {
@@ -1907,9 +1902,9 @@ void SwDoc::SetFormatItemByAutoFormat( const SwPaM& rPam, 
const SfxItemSet& rSet
 
     const sal_Int32 nEnd(rPam.End()->GetContentIndex());
     std::vector<WhichPair> whichIds;
-    SfxItemIter iter(rSet);
-    for (SfxPoolItem const* pItem = iter.GetCurItem(); pItem; pItem = 
iter.NextItem())
+    for (SfxItemIter aIter( rSet ); !aIter.IsAtEnd(); aIter.Next())
     {
+        const SfxPoolItem* pItem = aIter.GetCurItem();
         if (RES_CHRATR_BEGIN <= pItem->Which() && pItem->Which() < 
RES_CHRATR_END)
         {   // tdf#162911 don't add items with static default like INETFMT
             whichIds.push_back({pItem->Which(), pItem->Which()});
@@ -1962,10 +1957,9 @@ void SwDoc::ChgFormat(SwFormat & rFormat, const 
SfxItemSet & rSet)
         // invalidate all new items in <aOldSet> in order to clear these items,
         // if the undo action is triggered.
         {
-            SfxItemIter aIter(aSet);
-
-            for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = 
aIter.NextItem())
+            for (SfxItemIter aIter( aSet ); !aIter.IsAtEnd(); aIter.Next())
             {
+                const SfxPoolItem* pItem = aIter.GetCurItem();
                 aOldSet.InvalidateItem(pItem->Which());
             }
         }
diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx
index 03805112de18..d434ecc179d0 100644
--- a/sw/source/core/doc/docredln.cxx
+++ b/sw/source/core/doc/docredln.cxx
@@ -1229,9 +1229,9 @@ void 
SwRedlineExtraData_FormatColl::dumpAsXml(xmlTextWriterPtr pWriter) const
 
 SwRedlineExtraData_Format::SwRedlineExtraData_Format( const SfxItemSet& rSet )
 {
-    SfxItemIter aIter( rSet );
-    for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = 
aIter.NextItem())
+    for (SfxItemIter aIter( rSet ); !aIter.IsAtEnd(); aIter.Next())
     {
+        const SfxPoolItem* pItem = aIter.GetCurItem();
         m_aWhichIds.push_back( pItem->Which() );
     }
 }
diff --git a/sw/source/core/doc/textboxhelper.cxx 
b/sw/source/core/doc/textboxhelper.cxx
index 62ced4d44011..abcfe51df2ae 100644
--- a/sw/source/core/doc/textboxhelper.cxx
+++ b/sw/source/core/doc/textboxhelper.cxx
@@ -1062,11 +1062,12 @@ void SwTextBoxHelper::syncFlyFrameAttr(SwFrameFormat& 
rShape, SfxItemSet const&
                                && 
rShape.GetAnchor().GetAnchorNode()->FindTableNode();
     SfxItemSet aTextBoxSet(pFormat->GetDoc().GetAttrPool(), 
aFrameFormatSetRange);
 
-    SfxItemIter aIter(rSet);
-    const SfxPoolItem* pItem = aIter.GetCurItem();
-
-    do
+    for (SfxItemIter aIter(rSet); !aIter.IsAtEnd(); aIter.Next())
     {
+        const SfxPoolItem* pItem = aIter.GetCurItem();
+        if (pItem->Which() == 0)
+            break;
+
         switch (pItem->Which())
         {
             case RES_VERT_ORIENT:
@@ -1176,9 +1177,7 @@ void SwTextBoxHelper::syncFlyFrameAttr(SwFrameFormat& 
rShape, SfxItemSet const&
                                         << pItem->Which());
                 break;
         }
-
-        pItem = aIter.NextItem();
-    } while (pItem && (0 != pItem->Which()));
+    }
 
     if (aTextBoxSet.Count())
     {
diff --git a/sw/source/core/docnode/ndsect.cxx 
b/sw/source/core/docnode/ndsect.cxx
index 8c1cebb6f4aa..f6837e507ccb 100644
--- a/sw/source/core/docnode/ndsect.cxx
+++ b/sw/source/core/docnode/ndsect.cxx
@@ -603,18 +603,15 @@ void SwDoc::UpdateSection( size_t const nPos, 
SwSectionData & rNewData,
         bool bOnlyAttrChg = false;
         if( pAttr && pAttr->Count() )
         {
-            SfxItemIter aIter( *pAttr );
-            const SfxPoolItem* pItem = aIter.GetCurItem();
-            do
+            for (SfxItemIter aIter( *pAttr ); !aIter.IsAtEnd(); aIter.Next())
             {
+                const SfxPoolItem* pItem = aIter.GetCurItem();
                 if (pFormat->GetFormatAttr(pItem->Which()) != *pItem)
                 {
                     bOnlyAttrChg = true;
                     break;
                 }
-
-                pItem = aIter.NextItem();
-            } while (pItem);
+            }
         }
 
         if( bOnlyAttrChg )
diff --git a/sw/source/core/edit/edattr.cxx b/sw/source/core/edit/edattr.cxx
index 349cbbcd6560..64646b3382e2 100644
--- a/sw/source/core/edit/edattr.cxx
+++ b/sw/source/core/edit/edattr.cxx
@@ -351,10 +351,10 @@ std::vector<std::pair< const SfxPoolItem*, 
std::unique_ptr<SwPaM> >> SwEditShell
                         const SfxItemSet* pAutoSet = CharFormat::GetItemSet( 
pHt->GetAttr() );
                         if( pAutoSet )
                         {
-                            SfxItemIter aItemIter( *pAutoSet );
-                            pItem = aItemIter.GetCurItem();
-                            while( pItem )
+                            pItem = nullptr;
+                            for (SfxItemIter aIter( *pAutoSet ); 
!aIter.IsAtEnd(); aIter.Next())
                             {
+                                pItem = aIter.GetCurItem();
                                 if( pItem->Which() == nWhich )
                                 {
                                     sal_Int32 nStart = 0, nStop = 0;
@@ -369,7 +369,6 @@ std::vector<std::pair< const SfxPoolItem*, 
std::unique_ptr<SwPaM> >> SwEditShell
                                     vItem.emplace_back( pItem, 
std::make_unique<SwPaM>(*pNd, nStart, *pNd, nStop) );
                                     break;
                                 }
-                                pItem = aItemIter.NextItem();
                             }
                             // default item
                             if( !pItem && !pTextNd->HasSwAttrSet() )
diff --git a/sw/source/core/frmedt/fefly1.cxx b/sw/source/core/frmedt/fefly1.cxx
index 15130cba6849..2689adf24da4 100644
--- a/sw/source/core/frmedt/fefly1.cxx
+++ b/sw/source/core/frmedt/fefly1.cxx
@@ -1361,9 +1361,9 @@ void SwFEShell::ResetFlyFrameAttr( const SfxItemSet* pSet 
)
 
     StartAllAction();
 
-    SfxItemIter aIter( *pSet );
-    for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = 
aIter.NextItem())
+    for (SfxItemIter aIter( *pSet ); !aIter.IsAtEnd(); aIter.Next())
     {
+        const SfxPoolItem* pItem = aIter.GetCurItem();
         if( !IsInvalidItem( pItem ) )
         {
             sal_uInt16 nWhich = pItem->Which();
diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx
index edc33f3243e1..b8ccefa1aba2 100644
--- a/sw/source/core/layout/atrfrm.cxx
+++ b/sw/source/core/layout/atrfrm.cxx
@@ -2795,9 +2795,9 @@ void SwFrameFormat::SwClientNotify(const SwModify& rMod, 
const SfxHint& rHint)
         // reset fill information
         if(maFillAttributes && supportsFullDrawingLayerFillAttributeSet())
         {
-            SfxItemIter aIter(*pNewAttrSetChg->GetChgSet());
-            for(const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = 
aIter.NextItem())
+            for (SfxItemIter aIter( *pNewAttrSetChg->GetChgSet() ); 
!aIter.IsAtEnd(); aIter.Next())
             {
+                const SfxPoolItem* pItem = aIter.GetCurItem();
                 if(!IsInvalidItem(pItem) && pItem->Which() >= XATTR_FILL_FIRST 
&& pItem->Which() <= XATTR_FILL_LAST)
                 {
                     maFillAttributes.reset();
diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx
index 4d3de4f88efb..94994423fa07 100644
--- a/sw/source/core/layout/fly.cxx
+++ b/sw/source/core/layout/fly.cxx
@@ -826,8 +826,8 @@ void SwFlyFrame::SwClientNotify(const SwModify& rMod, const 
SfxHint& rHint)
             {
                 SfxItemIter aNIter(*pChangeHint->m_pNew->GetChgSet());
                 SfxItemIter aOIter(*pChangeHint->m_pOld->GetChgSet());
-                const SfxPoolItem* pNItem = aNIter.GetCurItem();
-                const SfxPoolItem* pOItem = aOIter.GetCurItem();
+                const SfxPoolItem* pNItem = aNIter.IsAtEnd() ? nullptr : 
aNIter.GetCurItem();
+                const SfxPoolItem* pOItem = aOIter.IsAtEnd() ? nullptr : 
aOIter.GetCurItem();
                 SwAttrSetChg aOldSet(*pChangeHint->m_pOld);
                 SwAttrSetChg aNewSet(*pChangeHint->m_pNew);
                 do
diff --git a/sw/source/core/layout/pagechg.cxx 
b/sw/source/core/layout/pagechg.cxx
index a3559a4785e3..78cabaf7fcf0 100644
--- a/sw/source/core/layout/pagechg.cxx
+++ b/sw/source/core/layout/pagechg.cxx
@@ -564,8 +564,8 @@ void SwPageFrame::SwClientNotify(const SwModify& rModify, 
const SfxHint& rHint)
                 const SwAttrSetChg& rNewSetChg = *pChangeHint->m_pNew;
                 SfxItemIter aOIter(*rOldSetChg.GetChgSet());
                 SfxItemIter aNIter(*rNewSetChg.GetChgSet());
-                const SfxPoolItem* pOItem = aOIter.GetCurItem();
-                const SfxPoolItem* pNItem = aNIter.GetCurItem();
+                const SfxPoolItem* pOItem = aOIter.IsAtEnd() ? nullptr : 
aOIter.GetCurItem();
+                const SfxPoolItem* pNItem = aNIter.IsAtEnd() ? nullptr : 
aNIter.GetCurItem();
                 SwAttrSetChg aOldSet(rOldSetChg);
                 SwAttrSetChg aNewSet(rNewSetChg);
                 do
diff --git a/sw/source/core/layout/sectfrm.cxx 
b/sw/source/core/layout/sectfrm.cxx
index 9a417e2d0598..7a331d3d9fce 100644
--- a/sw/source/core/layout/sectfrm.cxx
+++ b/sw/source/core/layout/sectfrm.cxx
@@ -2749,8 +2749,8 @@ void SwSectionFrame::SwClientNotify(const SwModify& rMod, 
const SfxHint& rHint)
                 const SwAttrSetChg& rNewSetChg = *pChangeHint->m_pNew;
                 SfxItemIter aOIter(*rOldSetChg.GetChgSet());
                 SfxItemIter aNIter(*rNewSetChg.GetChgSet());
-                const SfxPoolItem* pOItem = aOIter.GetCurItem();
-                const SfxPoolItem* pNItem = aNIter.GetCurItem();
+                const SfxPoolItem* pOItem = aOIter.IsAtEnd() ? nullptr : 
aOIter.GetCurItem();
+                const SfxPoolItem* pNItem = aNIter.IsAtEnd() ? nullptr : 
aNIter.GetCurItem();
                 SwAttrSetChg aOldSet(rOldSetChg);
                 SwAttrSetChg aNewSet(rNewSetChg);
                 do
diff --git a/sw/source/core/layout/tabfrm.cxx b/sw/source/core/layout/tabfrm.cxx
index 23c8337b4e55..98c8688a1da4 100644
--- a/sw/source/core/layout/tabfrm.cxx
+++ b/sw/source/core/layout/tabfrm.cxx
@@ -4095,8 +4095,8 @@ void SwTabFrame::SwClientNotify(const SwModify& rMod, 
const SfxHint& rHint)
             const SwAttrSetChg& rNewSetChg = *pChangeHint->m_pNew;
             SfxItemIter aOIter(*rOldSetChg.GetChgSet());
             SfxItemIter aNIter(*rNewSetChg.GetChgSet());
-            const SfxPoolItem* pOItem = aOIter.GetCurItem();
-            const SfxPoolItem* pNItem = aNIter.GetCurItem();
+            const SfxPoolItem* pOItem = aOIter.IsAtEnd() ? nullptr : 
aOIter.GetCurItem();
+            const SfxPoolItem* pNItem = aNIter.IsAtEnd() ? nullptr : 
aNIter.GetCurItem();
             SwAttrSetChg aOldSet(rOldSetChg);
             SwAttrSetChg aNewSet(rNewSetChg);
             do
diff --git a/sw/source/core/layout/wsfrm.cxx b/sw/source/core/layout/wsfrm.cxx
index 6f53cccf3899..f28276de6c93 100644
--- a/sw/source/core/layout/wsfrm.cxx
+++ b/sw/source/core/layout/wsfrm.cxx
@@ -528,8 +528,8 @@ void SwFrame::SwClientNotify(const SwModify&, const 
SfxHint& rHint)
         {
             SfxItemIter aNIter(*pChangeHint->m_pNew->GetChgSet());
             SfxItemIter aOIter(*pChangeHint->m_pOld->GetChgSet());
-            const SfxPoolItem* pNItem = aNIter.GetCurItem();
-            const SfxPoolItem* pOItem = aOIter.GetCurItem();
+            const SfxPoolItem* pNItem = aNIter.IsAtEnd() ? nullptr : 
aNIter.GetCurItem();
+            const SfxPoolItem* pOItem = aOIter.IsAtEnd() ? nullptr : 
aOIter.GetCurItem();
             do
             {
                 UpdateAttrFrame(pOItem, pNItem, eInvFlags);
@@ -2430,8 +2430,8 @@ void SwContentFrame::SwClientNotify(const SwModify& rMod, 
const SfxHint& rHint)
             const SwAttrSetChg& rNewSetChg = *pChangeHint->m_pNew;
             SfxItemIter aOIter(*rOldSetChg.GetChgSet());
             SfxItemIter aNIter(*rNewSetChg.GetChgSet());
-            const SfxPoolItem* pNItem = aNIter.GetCurItem();
-            const SfxPoolItem* pOItem = aOIter.GetCurItem();
+            const SfxPoolItem* pNItem = aNIter.IsAtEnd() ? nullptr : 
aNIter.GetCurItem();
+            const SfxPoolItem* pOItem = aOIter.IsAtEnd() ? nullptr : 
aOIter.GetCurItem();
             SwAttrSetChg aOldSet(rOldSetChg);
             SwAttrSetChg aNewSet(rNewSetChg);
             do
diff --git a/sw/source/core/text/atrstck.cxx b/sw/source/core/text/atrstck.cxx
index 82cec27250fc..1d8c0ba479f5 100644
--- a/sw/source/core/text/atrstck.cxx
+++ b/sw/source/core/text/atrstck.cxx
@@ -305,20 +305,16 @@ void SwAttrHandler::Init( const SfxPoolItem* const* 
pPoolItem, const SwAttrSet*
 
     if ( pAS && pAS->Count() )
     {
-        SfxItemIter aIter( *pAS );
-        sal_uInt16 nWhich;
-        const SfxPoolItem* pItem = aIter.GetCurItem();
-        do
+        for (SfxItemIter aIter( *pAS ); !aIter.IsAtEnd(); aIter.Next())
         {
-            nWhich = pItem->Which();
+            const SfxPoolItem* pItem = aIter.GetCurItem();
+            sal_uInt16 nWhich = pItem->Which();
             if (isCHRATR(nWhich))
             {
                 m_pDefaultArray[ StackPos[ nWhich ] ] = pItem;
                 FontChg( *pItem, rFnt, true );
             }
-
-            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/itratr.cxx b/sw/source/core/text/itratr.cxx
index 94ca008db390..e77cb9e7f3a5 100644
--- a/sw/source/core/text/itratr.cxx
+++ b/sw/source/core/text/itratr.cxx
@@ -522,9 +522,9 @@ bool SwAttrIter::Seek(TextFrameIndex const nNewPos)
 
 static void InsertCharAttrs(SfxPoolItem const** pAttrs, SfxItemSet const& 
rItems)
 {
-    SfxItemIter iter(rItems);
-    for (SfxPoolItem const* pItem = iter.GetCurItem(); pItem; pItem = 
iter.NextItem())
+    for (SfxItemIter aIter( rItems ); !aIter.IsAtEnd(); aIter.Next())
     {
+        const SfxPoolItem* pItem = aIter.GetCurItem();
         auto const nWhich(pItem->Which());
         if (isCHRATR(nWhich) && RES_CHRATR_RSID != nWhich)
         {
diff --git a/sw/source/core/text/txtfld.cxx b/sw/source/core/text/txtfld.cxx
index 4eb0934bd979..90504946911a 100644
--- a/sw/source/core/text/txtfld.cxx
+++ b/sw/source/core/text/txtfld.cxx
@@ -374,10 +374,9 @@ static void 
checkApplyParagraphMarkFormatToNumbering(SwFont* pNumFnt, SwTextForm
         pCleanedSet->ClearItem(RES_TXTATR_CHARFMT);
     };
 
-    SfxItemIter aIter(*pSet);
-    const SfxPoolItem* pItem = aIter.GetCurItem();
-    while (pItem)
+    for (SfxItemIter aIter( *pSet ); !aIter.IsAtEnd(); aIter.Next())
     {
+        const SfxPoolItem* pItem = aIter.GetCurItem();
         if (SwTextNode::IsIgnoredCharFormatForNumbering(pItem->Which()))
             pCleanedSet->ClearItem(pItem->Which());
         else if (pFormat && pFormat->HasItem(pItem->Which()))
@@ -411,7 +410,6 @@ static void 
checkApplyParagraphMarkFormatToNumbering(SwFont* pNumFnt, SwTextForm
             if (eCaseMap == SvxCaseMap::SmallCaps)
                 pCleanedSet->ClearItem(pItem->Which());
         }
-        pItem = aIter.NextItem();
     };
 
     // SetDiffFnt resets the background color (why?), so capture it and 
re-apply if it had a value,
diff --git a/sw/source/core/tox/ToxTextGenerator.cxx 
b/sw/source/core/tox/ToxTextGenerator.cxx
index 5ec2599a0fa9..2abbb2469231 100644
--- a/sw/source/core/tox/ToxTextGenerator.cxx
+++ b/sw/source/core/tox/ToxTextGenerator.cxx
@@ -322,10 +322,9 @@ ToxTextGenerator::CollectAttributesForTox(const 
SwTextAttr& hint, SwAttrPool& po
         return retval;
     }
     const SwFormatAutoFormat& afmt = hint.GetAutoFormat();
-    SfxItemIter aIter( *afmt.GetStyleHandle());
-    const SfxPoolItem* pItem = aIter.GetCurItem();
-    do
+    for (SfxItemIter aIter( *afmt.GetStyleHandle() ); !aIter.IsAtEnd(); 
aIter.Next())
     {
+        const SfxPoolItem* pItem = aIter.GetCurItem();
         if (pItem->Which() == RES_CHRATR_ESCAPEMENT ||
             pItem->Which() == RES_CHRATR_POSTURE ||
             pItem->Which() == RES_CHRATR_CJK_POSTURE ||
@@ -333,8 +332,7 @@ ToxTextGenerator::CollectAttributesForTox(const SwTextAttr& 
hint, SwAttrPool& po
         {
             retval->Put(std::unique_ptr<SfxPoolItem>(pItem->Clone()));
         }
-        pItem = aIter.NextItem();
-    } while (pItem);
+    }
     return retval;
 }
 
diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx
index b3f0681fb40c..b053db3179e9 100644
--- a/sw/source/core/txtnode/ndtxt.cxx
+++ b/sw/source/core/txtnode/ndtxt.cxx
@@ -2639,10 +2639,9 @@ void SwTextNode::CutImpl( SwTextNode * const pDest, 
const SwContentIndex & rDest
             if (pDest->GetpSwAttrSet())
             {
                 // check all items in the property set
-                SfxItemIter aIter( *pDest->GetpSwAttrSet() );
-                const SfxPoolItem* pItem = aIter.GetCurItem();
-                do
+                for (SfxItemIter aIter( *pDest->GetpSwAttrSet() ); 
!aIter.IsAtEnd(); aIter.Next())
                 {
+                    const SfxPoolItem* pItem = aIter.GetCurItem();
                     // check current item
                     const sal_uInt16 nWhich = IsInvalidItem( pItem )
                         ? aIter.GetCurWhich()
@@ -2662,10 +2661,7 @@ void SwTextNode::CutImpl( SwTextNode * const pDest, 
const SwContentIndex & rDest
                         if (hasSwAttrSet)
                             break;
                     }
-
-                    // let's check next item
-                    pItem = aIter.NextItem();
-                } while (pItem);
+                }
             }
         }
 
@@ -5693,10 +5689,9 @@ void SwTextNode::TriggerNodeUpdate(const 
sw::AttrSetChangeHint& rHint)
             bool bReset(false);
 
             // ..on ItemChange from DrawingLayer FillAttributes
-            SfxItemIter aIter(*pNewValue->GetChgSet());
-
-            for(const SfxPoolItem* pItem = aIter.GetCurItem(); pItem && 
!bReset; pItem = aIter.NextItem())
+            for (SfxItemIter aIter( *pNewValue->GetChgSet() ); 
!aIter.IsAtEnd(); aIter.Next())
             {
+                const SfxPoolItem* pItem = aIter.GetCurItem();
                 bReset = !IsInvalidItem(pItem) && pItem->Which() >= 
XATTR_FILL_FIRST && pItem->Which() <= XATTR_FILL_LAST;
             }
 
diff --git a/sw/source/core/txtnode/thints.cxx 
b/sw/source/core/txtnode/thints.cxx
index a4ff7ab57340..7742b518bacf 100644
--- a/sw/source/core/txtnode/thints.cxx
+++ b/sw/source/core/txtnode/thints.cxx
@@ -826,17 +826,14 @@ void SwpHints::BuildPortions( SwTextNode& rNode, 
SwTextAttr& rNewHint,
                     // is also set the new character style:
                     SfxItemSet aNewSet( *pOldStyle->GetPool(),
                         aCharAutoFormatSetRange);
-                    SfxItemIter aItemIter( *pOldStyle );
-                    const SfxPoolItem* pItem = aItemIter.GetCurItem();
-                    do
+                    for (SfxItemIter aIter( *pOldStyle ); !aIter.IsAtEnd(); 
aIter.Next())
                     {
+                        const SfxPoolItem* pItem = aIter.GetCurItem();
                         if ( !CharFormat::IsItemIncluded( pItem->Which(), 
&rNewHint ) )
                         {
                             aNewSet.Put( *pItem );
                         }
-
-                        pItem = aItemIter.NextItem();
-                    } while (pItem);
+                    }
 
                     // Remove old hint
                     Delete( pOther );
@@ -898,7 +895,7 @@ void SwpHints::BuildPortions( SwTextNode& rNode, 
SwTextAttr& rNewHint,
                     const SfxItemSet& rWholeParaAttrSet(rNode.GetSwAttrSet());
                     std::vector<sal_uInt16> aDeleteWhichIDs;
 
-                    for (SfxItemIter aIter(aNewSet); !aIter.IsAtEnd(); 
aIter.NextItem())
+                    for (SfxItemIter aIter(aNewSet); !aIter.IsAtEnd(); 
aIter.Next())
                     {
                         const SfxPoolItem* pGet(nullptr);
                         if (SfxItemState::SET == 
rWholeParaAttrSet.GetItemState(aIter.GetCurWhich(), false, &pGet) &&
@@ -934,12 +931,11 @@ void SwpHints::BuildPortions( SwTextNode& rNode, 
SwTextAttr& rNewHint,
                 {
                     std::unique_ptr<SfxItemSet> pNewSet;
 
-                    SfxItemIter aIter2( *pNewStyle );
-                    const SfxPoolItem* pItem = aIter2.GetCurItem();
                     const SfxItemSet& rWholeParaAttrSet = rNode.GetSwAttrSet();
 
-                    do
+                    for (SfxItemIter aIter2( *pNewStyle ); !aIter2.IsAtEnd(); 
aIter2.Next())
                     {
+                        const SfxPoolItem* pItem = aIter2.GetCurItem();
                         const SfxPoolItem* pTmpItem = nullptr;
                         // here direct SfxPoolItem ptr comp was wrong, found 
using SfxPoolItem::areSame
                         if ( SfxItemState::SET == 
rWholeParaAttrSet.GetItemState( pItem->Which(), false, &pTmpItem ) &&
@@ -954,7 +950,6 @@ void SwpHints::BuildPortions( SwTextNode& rNode, 
SwTextAttr& rNewHint,
                             }
                         }
                     }
-                    while ((pItem = aIter2.NextItem()));
 
                     if ( pNewSet )
                     {
@@ -1991,11 +1986,10 @@ bool SwTextNode::SetAttr(
     SfxItemSet aCharSet( *rSet.GetPool(), aCharAutoFormatSetRange );
 
     size_t nCount = 0;
-    SfxItemIter aIter( *pSet );
-    const SfxPoolItem* pItem = aIter.GetCurItem();
 
-    do
+    for (SfxItemIter aIter( *pSet ); !aIter.IsAtEnd(); aIter.Next())
     {
+        const SfxPoolItem* pItem = aIter.GetCurItem();
         if (!IsInvalidItem(pItem))
         {
             const sal_uInt16 nWhich = pItem->Which();
@@ -2041,8 +2035,7 @@ bool SwTextNode::SetAttr(
                 }
             }
         }
-        pItem = aIter.NextItem();
-    } while(pItem);
+    }
 
     if ( aCharSet.Count() )
     {
@@ -2280,7 +2273,8 @@ bool SwTextNode::GetParaAttr(SfxItemSet& rSet, sal_Int32 
nStt, sal_Int32 nEnd,
                         if ( pAutoSet )
                         {
                             oItemIter.emplace( *pAutoSet );
-                            pItem = oItemIter->GetCurItem();
+                            if (!oItemIter->IsAtEnd())
+                                pItem = oItemIter->GetCurItem();
                         }
                     }
                     else
@@ -2425,7 +2419,7 @@ struct RemovePresentAttrs
         // ITEM: SfxItemIter and removing SfxPoolItems:
         std::vector<sal_uInt16> aDeleteWhichIDs;
 
-        for (SfxItemIter aIter(m_rAttrSet); !aIter.IsAtEnd(); aIter.NextItem())
+        for (SfxItemIter aIter(m_rAttrSet); !aIter.IsAtEnd(); aIter.Next())
         {
             if (CharFormat::IsItemIncluded(aIter.GetCurWhich(), pAutoStyle))
             {
@@ -2484,9 +2478,9 @@ void
 lcl_FillWhichIds(const SfxItemSet& i_rAttrSet, std::vector<sal_uInt16>& 
o_rClearIds)
 {
     o_rClearIds.reserve(i_rAttrSet.Count());
-    SfxItemIter aIter(i_rAttrSet);
-    for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = 
aIter.NextItem())
+    for (SfxItemIter aIter( i_rAttrSet ); !aIter.IsAtEnd(); aIter.Next())
     {
+        const SfxPoolItem* pItem = aIter.GetCurItem();
         o_rClearIds.push_back(pItem->Which());
     }
 }
@@ -2605,13 +2599,13 @@ void SwTextNode::FormatToTextAttr( SwTextNode* pNd )
 
         if( aThisSet.Count() )
         {
-            SfxItemIter aIter( aThisSet );
-            const SfxPoolItem* pItem = aIter.GetCurItem(), *pNdItem = nullptr;
+            const SfxPoolItem* pNdItem = nullptr;
             SfxItemSet aConvertSet( GetDoc().GetAttrPool(), 
aCharFormatSetRange );
             std::vector<sal_uInt16> aClearWhichIds;
 
-            do
+            for (SfxItemIter aIter( aThisSet ); !aIter.IsAtEnd(); aIter.Next())
             {
+                const SfxPoolItem* pItem = aIter.GetCurItem();
                 if( SfxItemState::SET == aNdSet.GetItemState( pItem->Which(), 
false, &pNdItem ) )
                 {
                     if (*pItem == *pNdItem) // 4
@@ -2628,9 +2622,7 @@ void SwTextNode::FormatToTextAttr( SwTextNode* pNd )
                 {
                     aConvertSet.Put(*pItem);
                 }
-
-                pItem = aIter.NextItem();
-            } while (pItem);
+            }
 
             // 4/ clear items of this that are set with the same value on pNd
             ClearItemsFromAttrSet( aClearWhichIds );
@@ -2997,9 +2989,10 @@ static MergeResult lcl_Compare_Attributes(
             // sadly SfxItemSet::operator== does not seem to work?
             SfxItemIter iter1(rSet1);
             SfxItemIter iter2(rSet2);
-            for (SfxPoolItem const* pItem1 = iter1.GetCurItem(),
-                                  * pItem2 = iter2.GetCurItem();;)
+            for (;;)
             {
+                SfxPoolItem const* pItem1 = iter1.IsAtEnd() ? nullptr : 
iter1.GetCurItem();
+                SfxPoolItem const* pItem2 = iter2.IsAtEnd() ? nullptr : 
iter2.GetCurItem();
                 if (pItem1 && pItem1->Which() == RES_CHRATR_RSID)
                     pItem1 = iter1.NextItem();
                 if (pItem2 && pItem2->Which() == RES_CHRATR_RSID)
@@ -3022,8 +3015,10 @@ static MergeResult lcl_Compare_Attributes(
                 {
                     return DIFFER;
                 }
-                pItem1 = iter1.NextItem();
-                pItem2 = iter2.NextItem();
+                if (!iter1.IsAtEnd())
+                    iter1.Next();
+                if (!iter2.IsAtEnd())
+                    iter2.Next();
             }
         }
         ++aIter1;
diff --git a/sw/source/core/txtnode/txtedt.cxx 
b/sw/source/core/txtnode/txtedt.cxx
index b2441e0f5e5e..06f33e199efe 100644
--- a/sw/source/core/txtnode/txtedt.cxx
+++ b/sw/source/core/txtnode/txtedt.cxx
@@ -337,19 +337,16 @@ static bool lcl_HaveCommonAttributes( IStyleAccess& 
rStyleAccess,
     }
     else if ( pSet1->Count() )
     {
-        SfxItemIter aIter( *pSet1 );
-        const SfxPoolItem* pItem = aIter.GetCurItem();
-        do
+        for (SfxItemIter aIter( *pSet1 ); !aIter.IsAtEnd(); aIter.Next())
         {
+            const SfxPoolItem* pItem = aIter.GetCurItem();
             if ( SfxItemState::SET == rSet2.GetItemState( pItem->Which(), 
false ) )
             {
                 if ( !pNewSet )
                     pNewSet = rSet2.Clone();
                 pNewSet->ClearItem( pItem->Which() );
             }
-
-            pItem = aIter.NextItem();
-        } while (pItem);
+        }
     }
 
     if ( pNewSet )
diff --git a/sw/source/core/undo/rolbck.cxx b/sw/source/core/undo/rolbck.cxx
index f5ce46dfd8c7..714f29891fea 100644
--- a/sw/source/core/undo/rolbck.cxx
+++ b/sw/source/core/undo/rolbck.cxx
@@ -856,7 +856,7 @@ SwHistorySetAttrSet::SwHistorySetAttrSet(
     // I re-designed this to iterate over the source ItemSet (rSet) and add 
Items
     // as needed to the target ItemSet m_OldSet. This is tricky since some 
NonShareable
     // 'special' Items get special treatment.
-    for (SfxItemIter aIter(rSet); !aIter.IsAtEnd(); aIter.NextItem())
+    for (SfxItemIter aIter(rSet); !aIter.IsAtEnd(); aIter.Next())
     {
         // check if Item is intended to be contained
         if (rSetArr.contains(aIter.GetCurWhich()))
@@ -1310,18 +1310,14 @@ void SwHistory::CopyFormatAttr(
     if(!rSet.Count())
         return;
 
-    SfxItemIter aIter(rSet);
-    const SfxPoolItem* pItem = aIter.GetCurItem();
-    do
+    for (SfxItemIter aIter( rSet ); !aIter.IsAtEnd(); aIter.Next())
     {
+        const SfxPoolItem* pItem = aIter.GetCurItem();
         if(!IsInvalidItem(pItem))
         {
             AddPoolItem(pItem, pItem, nNodeIdx);
         }
-
-        pItem = aIter.NextItem();
-
-    } while(pItem);
+    }
 }
 
 void SwHistory::dumpAsXml(xmlTextWriterPtr pWriter) const
@@ -1494,9 +1490,10 @@ bool SwRegHistory::InsertItems( const SfxItemSet& rSet,
 #ifndef NDEBUG
     if ( m_pHistory && bInserted )
     {
-        SfxItemIter aIter(rSet);
-        for (SfxPoolItem const* pItem = aIter.GetCurItem(); pItem; pItem = 
aIter.NextItem())
-        {   // check that the history recorded a hint to reset every item
+        for (SfxItemIter aIter( rSet ); !aIter.IsAtEnd(); aIter.Next())
+        {
+            const SfxPoolItem* pItem = aIter.GetCurItem();
+            // check that the history recorded a hint to reset every item
             sal_uInt16 const nWhich(pItem->Which());
             sal_uInt16 const nExpected(
                 (isCHRATR(nWhich) || RES_TXTATR_UNKNOWN_CONTAINER == nWhich)
@@ -1554,9 +1551,9 @@ void SwRegHistory::MakeSetWhichIds()
     }
     if( pSet && pSet->Count() )
     {
-        SfxItemIter aIter( *pSet );
-        for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = 
aIter.NextItem())
+        for (SfxItemIter aIter( *pSet ); !aIter.IsAtEnd(); aIter.Next())
         {
+            const SfxPoolItem* pItem = aIter.GetCurItem();
             sal_uInt16 nW = pItem->Which();
             m_WhichIdSet.insert( nW );
         }
diff --git a/sw/source/core/undo/unattr.cxx b/sw/source/core/undo/unattr.cxx
index 1b7b8956c585..e0ae8801f9a9 100644
--- a/sw/source/core/undo/unattr.cxx
+++ b/sw/source/core/undo/unattr.cxx
@@ -87,9 +87,11 @@ void SwUndoFormatAttrHelper::SwClientNotify(const SwModify&, 
const SfxHint& rHin
         if(!GetUndo())
             m_pUndo.reset(new SwUndoFormatAttr(SfxItemSet(rChgSet), m_rFormat, 
m_bSaveDrawPt));
         else {
-            SfxItemIter aIter(rChgSet);
-            for(auto pItem = aIter.GetCurItem(); pItem; pItem = 
aIter.NextItem())
+            for (SfxItemIter aIter( rChgSet ); !aIter.IsAtEnd(); aIter.Next())
+            {
+                const SfxPoolItem* pItem = aIter.GetCurItem();
                 m_pUndo->PutAttr(*pItem, rDoc);
+            }
         }
         return;
     }
@@ -594,9 +596,11 @@ void SwUndoFormatResetAttr::UndoImpl(::sw::UndoRedoContext 
&)
 
 void SwUndoFormatResetAttr::RedoImpl(::sw::UndoRedoContext &)
 {
-    SfxItemIter aIter(m_aSet);
-    for (auto pItem = aIter.GetCurItem(); pItem; pItem = aIter.NextItem())
+    for (SfxItemIter aIter( m_aSet ); !aIter.IsAtEnd(); aIter.Next())
+    {
+        const SfxPoolItem* pItem = aIter.GetCurItem();
         m_pChangedFormat->ResetFormatAttr(pItem->Which());
+    }
     BroadcastStyleChange();
 }
 
diff --git a/sw/source/core/undo/undobj1.cxx b/sw/source/core/undo/undobj1.cxx
index 6c09ede713f4..9fe078e2f371 100644
--- a/sw/source/core/undo/undobj1.cxx
+++ b/sw/source/core/undo/undobj1.cxx
@@ -567,9 +567,9 @@ void SwUndoSetFlyFormat::UndoImpl(::sw::UndoRedoContext & 
rContext)
     if( m_pFrameFormat->DerivedFrom() != pDerivedFromFrameFormat)
         m_pFrameFormat->SetDerivedFrom(pDerivedFromFrameFormat);
 
-    SfxItemIter aIter( *m_oItemSet );
-    for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = 
aIter.NextItem())
+    for (SfxItemIter aIter( *m_oItemSet ); !aIter.IsAtEnd(); aIter.Next())
     {
+        const SfxPoolItem* pItem = aIter.GetCurItem();
         if( IsInvalidItem( pItem ))
             m_pFrameFormat->ResetFormatAttr( aIter.GetCurWhich() );
         else
@@ -704,9 +704,11 @@ void SwUndoSetFlyFormat::SwClientNotify(const SwModify&, 
const SfxHint& rHint)
         auto pChangeHint = static_cast<const sw::AttrSetChangeHint*>(&rHint);
         if(!pChangeHint->m_pOld)
             return;
-        SfxItemIter aIter(*pChangeHint->m_pOld->GetChgSet());
-        for(const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = 
aIter.NextItem())
+        for (SfxItemIter aIter( *pChangeHint->m_pOld->GetChgSet() ); 
!aIter.IsAtEnd(); aIter.Next())
+        {
+            const SfxPoolItem* pItem = aIter.GetCurItem();
             PutAttr(pItem->Which(), pItem);
+        }
     }
     else if (rHint.GetId() == SfxHintId::SwLegacyModify)
     {
diff --git a/sw/source/core/unocore/unostyle.cxx 
b/sw/source/core/unocore/unostyle.cxx
index 4aa6b2f8c0c9..bb441e5a0209 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -4387,10 +4387,10 @@ uno::Sequence< beans::PropertyValue > 
SwXAutoStyle::getProperties()
     const SfxItemPropertyMap &rMap = pPropSet->getPropertyMap();
 
     SfxItemSet& rSet = *mpSet;
-    SfxItemIter aIter(rSet);
 
-    for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = 
aIter.NextItem())
+    for (SfxItemIter aIter( rSet ); !aIter.IsAtEnd(); aIter.Next())
     {
+        const SfxPoolItem* pItem = aIter.GetCurItem();
         const sal_uInt16 nWID = pItem->Which();
 
         // TODO: Optimize - and fix! the old iteration filled each WhichId
diff --git a/sw/source/filter/html/htmlcss1.cxx 
b/sw/source/filter/html/htmlcss1.cxx
index 7fbeb7609f1d..69e7d0a50f05 100644
--- a/sw/source/filter/html/htmlcss1.cxx
+++ b/sw/source/filter/html/htmlcss1.cxx
@@ -2249,10 +2249,9 @@ void SwHTMLParser::EndContextAttrs( HTMLAttrContext 
*pContext )
 
 void SwHTMLParser::InsertParaAttrs( const SfxItemSet& rItemSet )
 {
-    SfxItemIter aIter( rItemSet );
-
-    for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = 
aIter.NextItem())
+    for (SfxItemIter aIter( rItemSet ); !aIter.IsAtEnd(); aIter.Next())
     {
+        const SfxPoolItem* pItem = aIter.GetCurItem();
         // search for the table entry of the item...
         sal_uInt16 nWhich = pItem->Which();
         HTMLAttr **ppAttr = GetAttrTabEntry( nWhich );
diff --git a/sw/source/filter/html/htmlctxt.cxx 
b/sw/source/filter/html/htmlctxt.cxx
index 6bee92a52780..b32ce055efb2 100644
--- a/sw/source/filter/html/htmlctxt.cxx
+++ b/sw/source/filter/html/htmlctxt.cxx
@@ -580,14 +580,13 @@ void SwHTMLParser::InsertAttrs( SfxItemSet &rItemSet,
             m_aContexts.back().get() != pContext,
             "SwHTMLParser::InsertAttrs: Context already on the Stack");
 
-    SfxItemIter aIter( rItemSet );
-
     const SvxFirstLineIndentItem * pFirstLineItem(nullptr);
     const SvxTextLeftMarginItem * pTextLeftMargin(nullptr);
     const SvxRightMarginItem * pRightMargin(nullptr);
 
-    for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = 
aIter.NextItem())
+    for (SfxItemIter aIter( rItemSet ); !aIter.IsAtEnd(); aIter.Next())
     {
+        const SfxPoolItem* pItem = aIter.GetCurItem();
         switch( pItem->Which() )
         {
         case RES_MARGIN_FIRSTLINE:
@@ -675,9 +674,9 @@ void SwHTMLParser::InsertAttrs( SfxItemSet &rItemSet,
             }
 #endif
 
-    SfxItemIter aIter2(rItemSet);
-    for (const SfxPoolItem* pItem = aIter2.GetCurItem(); pItem; pItem = 
aIter2.NextItem())
+    for (SfxItemIter aIter( rItemSet ); !aIter.IsAtEnd(); aIter.Next())
     {
+        const SfxPoolItem* pItem = aIter.GetCurItem();
         HTMLAttr **ppAttr = nullptr;
 
         switch( pItem->Which() )
diff --git a/sw/source/filter/html/htmldrawreader.cxx 
b/sw/source/filter/html/htmldrawreader.cxx
index b2a68f2533e4..e021339ead6f 100644
--- a/sw/source/filter/html/htmldrawreader.cxx
+++ b/sw/source/filter/html/htmldrawreader.cxx
@@ -440,10 +440,9 @@ void SwHTMLParser::NewMarquee( HTMLTable *pCurTable )
     if( HasStyleOptions( aStyle, aId, aClass )  &&
         ParseStyleOptions( aStyle, aId, aClass, aStyleItemSet, aPropInfo ) )
     {
-        SfxItemIter aIter( aStyleItemSet );
-
-        for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = 
aIter.NextItem())
+        for (SfxItemIter aIter( aStyleItemSet ); !aIter.IsAtEnd(); 
aIter.Next())
         {
+            const SfxPoolItem* pItem = aIter.GetCurItem();
             PutEEPoolItem( aItemSet, *pItem );
         }
     }
diff --git a/sw/source/filter/html/swhtml.cxx b/sw/source/filter/html/swhtml.cxx
index 28bf2ddad04b..cad3e5dffb0f 100644
--- a/sw/source/filter/html/swhtml.cxx
+++ b/sw/source/filter/html/swhtml.cxx
@@ -4837,7 +4837,7 @@ void SwHTMLParser::SetTextCollAttrs( HTMLAttrContext 
*pContext )
         std::unique_ptr<SfxItemSet> const pCharSet(new 
SfxItemSet(*m_pTargetCharAttrs));
         // do not use SfxItemSet::Differentiate(), it doesn't compare values!
         std::vector<sal_uInt16> clear;
-        for (SfxItemIter it{*pCharSet}; !it.IsAtEnd(); it.NextItem())
+        for (SfxItemIter it{*pCharSet}; !it.IsAtEnd(); it.Next())
         {
             SfxPoolItem const& rItem{*it.GetCurItem()};
             if (SfxPoolItem const*const 
pItem{pCollToSet->GetAttrSet().GetItem(rItem.Which(), true)})
diff --git a/sw/source/filter/md/wrtmd.cxx b/sw/source/filter/md/wrtmd.cxx
index 82daeaa17cc9..bc471e11a2a7 100644
--- a/sw/source/filter/md/wrtmd.cxx
+++ b/sw/source/filter/md/wrtmd.cxx
@@ -231,7 +231,7 @@ void ApplyItem(SwMDWriter& rWrt, FormattingStatus& rChange, 
const SfxPoolItem& r
         {
             if (const auto* pNestedItem = iter.GetCurItem())
                 ApplyItem(rWrt, rChange, *pNestedItem, increment);
-            iter.NextItem();
+            iter.Next();
         }
     };
 
@@ -759,7 +759,7 @@ void OutMarkdown_SwTextNode(SwMDWriter& rWrt, const 
SwTextNode& rNode, bool bFir
         NodePositions positions;
 
         // Start paragraph properties
-        for (SfxItemIter iter(rNode.GetSwAttrSet()); !iter.IsAtEnd(); 
iter.NextItem())
+        for (SfxItemIter iter(rNode.GetSwAttrSet()); !iter.IsAtEnd(); 
iter.Next())
             positions.hintStarts.add(nStrPos, iter.GetCurItem());
 
         // Store character formatting
@@ -786,7 +786,7 @@ void OutMarkdown_SwTextNode(SwMDWriter& rWrt, const 
SwTextNode& rNode, bool bFir
         positions.hintEnds.sort();
 
         // End paragraph properties
-        for (SfxItemIter iter(rNode.GetSwAttrSet()); !iter.IsAtEnd(); 
iter.NextItem())
+        for (SfxItemIter iter(rNode.GetSwAttrSet()); !iter.IsAtEnd(); 
iter.Next())
             positions.hintEnds.add(nEnd, iter.GetCurItem());
 
         if (const SwRedlineTable& rRedlines
diff --git a/sw/source/filter/writer/wrt_fn.cxx 
b/sw/source/filter/writer/wrt_fn.cxx
index cda66d3379cb..61e8e91c4f4e 100644
--- a/sw/source/filter/writer/wrt_fn.cxx
+++ b/sw/source/filter/writer/wrt_fn.cxx
@@ -64,9 +64,10 @@ SwHTMLWriter& Out_SfxItemSet( const SwAttrFnTab pTab, 
SwHTMLWriter& rWrt,
     if( !bDeep || !pSet->GetParent() )
     {
         OSL_ENSURE( rSet.Count(), "It has been handled already, right?" );
-        SfxItemIter aIter( *pSet );
-        pItem = aIter.GetCurItem();
-        do {
+        pItem = nullptr;
+        for (SfxItemIter aIter( *pSet ); !aIter.IsAtEnd(); aIter.Next())
+        {
+            pItem = aIter.GetCurItem();
             // pTab only covers POOLATTR_BEGIN..POOLATTR_END.
             if( pItem->Which() <= POOLATTR_END )
             {
@@ -80,7 +81,7 @@ SwHTMLWriter& Out_SfxItemSet( const SwAttrFnTab pTab, 
SwHTMLWriter& rWrt,
             {
                 bFillItemUsed = true;
             }
-        } while ((pItem = aIter.NextItem()));
+        }
     }
     else
     {
diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx 
b/sw/source/filter/ww8/rtfattributeoutput.cxx
index 02f3c201060d..e4051aa159f9 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.cxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.cxx
@@ -666,7 +666,7 @@ OString 
RtfAttributeOutput::MoveProperties(GetCharacterPropertiesMode mode)
     // 2. Add the character formatting, that is not part of assoc groups
     if (auto* pStyleItem = m_aCharFormatting.GetItemIfSet(RES_TXTATR_CHARFMT, 
false))
         OutputFormattingItem(*pStyleItem, rBuf);
-    for (SfxItemIter it(m_aCharFormatting); !it.IsAtEnd(); it.NextItem())
+    for (SfxItemIter it(m_aCharFormatting); !it.IsAtEnd(); it.Next())
     {
         if (it.GetCurWhich() != RES_TXTATR_CHARFMT)
             OutputFormattingItem(*it.GetCurItem(), rBuf);
diff --git a/sw/source/filter/ww8/writerhelper.cxx 
b/sw/source/filter/ww8/writerhelper.cxx
index 9f6e4b15f15c..e25ba9d18b7e 100644
--- a/sw/source/filter/ww8/writerhelper.cxx
+++ b/sw/source/filter/ww8/writerhelper.cxx
@@ -391,7 +391,7 @@ namespace sw
         {
             if( bExportParentItemSet )
             {
-                for (SfxItemIter aIter(rSet); !aIter.IsAtEnd(); 
aIter.NextItem())
+                for (SfxItemIter aIter(rSet); !aIter.IsAtEnd(); aIter.Next())
                 {
                     const SfxPoolItem* pItem(nullptr);
                     if(SfxItemState::SET == aIter.GetItemState(true, &pItem))
@@ -400,7 +400,7 @@ namespace sw
             }
             else if( rSet.Count())
             {
-                for (SfxItemIter aIter(rSet); !aIter.IsAtEnd(); 
aIter.NextItem())
+                for (SfxItemIter aIter(rSet); !aIter.IsAtEnd(); aIter.Next())
                     rItems[aIter.GetCurWhich()] = aIter.GetCurItem();
             }
 //            DeduplicateItems(rItems);
@@ -421,11 +421,11 @@ namespace sw
             {
                 if (pCharFormat->GetAttrSet().Count())
                 {
-                    SfxItemIter aIter(pCharFormat->GetAttrSet());
-                    const SfxPoolItem *pItem = aIter.GetCurItem();
-                    do
+                    for (SfxItemIter aIter( pCharFormat->GetAttrSet() ); 
!aIter.IsAtEnd(); aIter.Next())
+                    {
+                        const SfxPoolItem* pItem = aIter.GetCurItem();
                         rSet.ClearItem(pItem->Which());
-                    while ((pItem = aIter.NextItem()));
+                    }
                 }
             }
         }
diff --git a/sw/source/filter/ww8/wrtw8esh.cxx 
b/sw/source/filter/ww8/wrtw8esh.cxx
index 232751644903..895dd78cc55e 100644
--- a/sw/source/filter/ww8/wrtw8esh.cxx
+++ b/sw/source/filter/ww8/wrtw8esh.cxx
@@ -1286,14 +1286,12 @@ void MSWord_SdrAttrIter::OutParaAttr(bool bCharAttr, 
const std::set<sal_uInt16>*
     const SfxItemSet* pOldSet = m_rExport.GetCurItemSet();
     m_rExport.SetCurItemSet( &aSet );
 
-    SfxItemIter aIter( aSet );
-    const SfxPoolItem* pItem = aIter.GetCurItem();
-
     const SfxItemPool* pSrcPool = m_pEditPool,
                      * pDstPool = &m_rExport.m_rDoc.GetAttrPool();
 
-    do
+    for (SfxItemIter aIter( aSet ); !aIter.IsAtEnd(); aIter.Next())
     {
+        const SfxPoolItem* pItem = aIter.GetCurItem();
         sal_uInt16 nWhich = pItem->Which();
         if (pWhichsToIgnore && pWhichsToIgnore->find(nWhich) != 
pWhichsToIgnore->end())
             continue;
@@ -1312,7 +1310,7 @@ void MSWord_SdrAttrIter::OutParaAttr(bool bCharAttr, 
const std::set<sal_uInt16>*
             if (m_rExport.CollapseScriptsforWordOk(m_nScript,nWhich))
                 m_rExport.AttrOutput().OutputItem(*pI);
         }
-    } 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 505a9f966c57..7c11d8b8c554 100644
--- a/sw/source/filter/ww8/wrtww8gr.cxx
+++ b/sw/source/filter/ww8/wrtww8gr.cxx
@@ -89,9 +89,9 @@ bool WW8Export::TestOleNeedsGraphic(const SwAttrSet& rSet, 
rtl::Reference<SotSto
                                     OUString const& rStorageName, SwOLENode& 
rOLENd)
 {
     bool bGraphicNeeded = false;
-    SfxItemIter aIter( rSet );
-    for (auto pItem = aIter.GetCurItem(); !bGraphicNeeded && pItem; pItem = 
aIter.NextItem())
+    for (SfxItemIter aIter( rSet ); !bGraphicNeeded && !aIter.IsAtEnd(); 
aIter.Next())
     {
+        const SfxPoolItem* pItem = aIter.GetCurItem();
         switch (pItem->Which())
         {
             /*
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index 20bd53cb94fd..12d10022332a 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -6016,7 +6016,7 @@ void AttributeOutputBase::OutputStyleItemSet( const 
SfxItemSet& rSet, bool bTest
         const SfxPoolItem* pFillStyle(nullptr);
         const SfxPoolItem* pGradient(nullptr);
 
-        for (SfxItemIter aIter(*pSet); !aIter.IsAtEnd(); aIter.NextItem())
+        for (SfxItemIter aIter(*pSet); !aIter.IsAtEnd(); aIter.Next())
         {
             pItem = aIter.GetCurItem();
 
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index f16fcb74e26c..4cbb1eb5614d 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -2971,10 +2971,9 @@ void SwWW8ImplReader::PostProcessAttrs()
     if (m_pPostProcessAttrsInfo == nullptr)
         return;
 
-    SfxItemIter aIter(m_pPostProcessAttrsInfo->mItemSet);
-
-    for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = 
aIter.NextItem())
+    for (SfxItemIter aIter( m_pPostProcessAttrsInfo->mItemSet ); 
!aIter.IsAtEnd(); aIter.Next())
     {
+        const SfxPoolItem* pItem = aIter.GetCurItem();
         m_xCtrlStck->NewAttr(*m_pPostProcessAttrsInfo->mPaM.GetPoint(),
                            *pItem);
         m_xCtrlStck->SetAttr(*m_pPostProcessAttrsInfo->mPaM.GetMark(),
diff --git a/sw/source/filter/ww8/ww8par3.cxx b/sw/source/filter/ww8/ww8par3.cxx
index 5b1df65463ef..229eb80582db 100644
--- a/sw/source/filter/ww8/ww8par3.cxx
+++ b/sw/source/filter/ww8/ww8par3.cxx
@@ -1025,9 +1025,9 @@ void WW8ListManager::AdjustLVL( sal_uInt8 nLevel, 
SwNumRule& rNumRule,
                 && (pLowerLevelItemSet->Count() == pThisLevelItemSet->Count()) 
)
             {
                 nIdenticalItemSetLevel = nLowerLevel;
-                const SfxPoolItem* pItemIter = aIter.GetCurItem();
-                do
+                for ( ; !aIter.IsAtEnd(); aIter.Next())
                 {
+                    const SfxPoolItem* pItemIter = aIter.GetCurItem();
                     if(  // search for appropriate pItem in pLowerLevelItemSet
                          (SfxItemState::SET != 
pLowerLevelItemSet->GetItemState(
                                             pItemIter->Which(), false, &pItem 
) )
@@ -1039,8 +1039,7 @@ void WW8ListManager::AdjustLVL( sal_uInt8 nLevel, 
SwNumRule& rNumRule,
                         nIdenticalItemSetLevel = nMaxLevel;
                         break;
                     }
-                    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 39bb94fb3a65..51724613a877 100644
--- a/sw/source/filter/ww8/ww8par6.cxx
+++ b/sw/source/filter/ww8/ww8par6.cxx
@@ -2321,12 +2321,11 @@ void WW8DupProperties::Insert(const SwPosition &rPos)
     {
         if( pSet->Count() )
         {
-            SfxItemIter aIter( *pSet );
-            const SfxPoolItem* pItem = aIter.GetCurItem();
-            do
+            for (SfxItemIter aIter( *pSet ); !aIter.IsAtEnd(); aIter.Next())
             {
+                const SfxPoolItem* pItem = aIter.GetCurItem();
                 m_pCtrlStck->NewAttr(rPos, *pItem);
-            } while ((pItem = aIter.NextItem()));
+            }
         }
     }
 }
diff --git a/sw/source/uibase/app/docstyle.cxx 
b/sw/source/uibase/app/docstyle.cxx
index 7021bbb919ab..5f8ea37308fe 100644
--- a/sw/source/uibase/app/docstyle.cxx
+++ b/sw/source/uibase/app/docstyle.cxx
@@ -198,11 +198,11 @@ public:
         rItemSet.ClearItem();
 
         auto pCol = 
static_cast<SwDocStyleSheet*>(pSourceSheet)->GetCollection();
-        SfxItemIter aIter(pCol->GetAttrSet());
         std::optional<SvxLRSpaceItem> oLRSpaceItem;
 
-        for (auto pItem = aIter.GetCurItem(); pItem; pItem = aIter.NextItem())
+        for (SfxItemIter aIter(pCol->GetAttrSet()); !aIter.IsAtEnd(); 
aIter.Next())
         {
+            const SfxPoolItem* pItem = aIter.GetCurItem();
             if (aIter.GetItemState(false) != SfxItemState::SET)
                 continue;
 
@@ -1006,11 +1006,11 @@ OUString  SwDocStyleSheet::GetDescription(MapUnit eUnit)
         if( !pSet )
             GetItemSet();
 
-        SfxItemIter aIter( *pSet );
         OUStringBuffer aDesc;
 
-        for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = 
aIter.NextItem())
+        for (SfxItemIter aIter( *pSet ); !aIter.IsAtEnd(); aIter.Next())
         {
+            const SfxPoolItem* pItem = aIter.GetCurItem();
             if(!IsInvalidItem(pItem))
             {
                 switch ( pItem->Which() )
@@ -1044,7 +1044,6 @@ OUString  SwDocStyleSheet::GetDescription(MapUnit eUnit)
         if( !pSet )
             GetItemSet();
 
-        SfxItemIter aIter( *pSet );
         OUStringBuffer aDesc;
         OUString sPageNum;
         OUString sModel;
@@ -1059,8 +1058,9 @@ OUString  SwDocStyleSheet::GetDescription(MapUnit eUnit)
         const drawing::FillStyle 
eFillStyle(pSet->Get(XATTR_FILLSTYLE).GetValue());
         const bool 
bUseFloatTransparence(pSet->Get(XATTR_FILLFLOATTRANSPARENCE).IsEnabled());
 
-        for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = 
aIter.NextItem())
+        for (SfxItemIter aIter( *pSet ); !aIter.IsAtEnd(); aIter.Next())
         {
+            const SfxPoolItem* pItem = aIter.GetCurItem();
             if(!IsInvalidItem(pItem))
             {
                 switch ( pItem->Which() )
@@ -1870,19 +1870,16 @@ void SwDocStyleSheet::SetItemSet(const SfxItemSet& 
rSet, const bool bBroadcast,
             // of this method) but happens because lcl_setLineNumbering calls 
GetItemSet/SetItemSet
             // at the *same* xStyleSheet. You can see that 
SwDocStyleSheet::GetItemSet() above
             // does return m_aCoreSet. I guess that lcl_setLineNumbering 
should not do that...
-            SfxItemIter aIter( rSet );
-            const SfxPoolItem* pItem = aIter.GetCurItem();
-            do
+            for (SfxItemIter aIter( rSet ); !aIter.IsAtEnd(); aIter.Next())
             {
+                const SfxPoolItem* pItem = aIter.GetCurItem();
                 if( IsInvalidItem( pItem ) )            // Clear
                 {
                     // use method <SwDoc::ResetAttrAtFormat(..)> in order to
                     // create an Undo object for the attribute reset.
                     aWhichIdsToReset.emplace_back(aIter.GetCurWhich());
                 }
-
-                pItem = aIter.NextItem();
-            } while (pItem);
+            }
         }
 
         m_rDoc.ResetAttrAtFormat(aWhichIdsToReset, *pFormat);
diff --git a/sw/source/uibase/config/uinums.cxx 
b/sw/source/uibase/config/uinums.cxx
index 41dcb7372ce4..fce7e78a8fc3 100644
--- a/sw/source/uibase/config/uinums.cxx
+++ b/sw/source/uibase/config/uinums.cxx
@@ -188,13 +188,11 @@ SwNumRulesWithName::SwNumFormatGlobal::SwNumFormatGlobal( 
const SwNumFormat& rFo
     m_nCharPoolId = pFormat->GetPoolFormatId();
     if( pFormat->GetAttrSet().Count() )
     {
-        SfxItemIter aIter( pFormat->GetAttrSet() );
-        const SfxPoolItem *pCurr = aIter.GetCurItem();
-        do
+        for (SfxItemIter aIter( pFormat->GetAttrSet() ); !aIter.IsAtEnd(); 
aIter.Next())
         {
+            const SfxPoolItem* pCurr = aIter.GetCurItem();
             m_Items.push_back(std::unique_ptr<SfxPoolItem>(pCurr->Clone()));
-            pCurr = aIter.NextItem();
-        } while (pCurr);
+        }
     }
 
     m_aFormat.SetCharFormat( nullptr );
diff --git a/sw/source/uibase/utlui/attrdesc.cxx 
b/sw/source/uibase/utlui/attrdesc.cxx
index af8f712667b3..f7e80fe3d2d7 100644
--- a/sw/source/uibase/utlui/attrdesc.cxx
+++ b/sw/source/uibase/utlui/attrdesc.cxx
@@ -71,17 +71,15 @@ void SwAttrSet::GetPresentation(
     if( !Count() )
         return;
 
-    SfxItemIter aIter( *this );
-    const SfxPoolItem* pItem = aIter.GetCurItem();
     const IntlWrapper aInt(SvtSysLocale().GetUILanguageTag());
-    do
+    for (SfxItemIter aIter( *this ); !aIter.IsAtEnd(); aIter.Next())
     {
+        const SfxPoolItem* pItem = aIter.GetCurItem();
         pItem->GetPresentation(ePres, eCoreMetric, ePresMetric, aStr, aInt);
         if( rText.getLength() && aStr.getLength() )
             rText += ", ";
         rText += aStr;
-        pItem = aIter.NextItem();
-    } while (pItem);
+    }
 }
 
 bool SwFormatCharFormat::GetPresentation
diff --git a/sw/source/uibase/wrtsh/wrtsh1.cxx 
b/sw/source/uibase/wrtsh/wrtsh1.cxx
index 6fc0bde2e2de..7963f852f4d0 100644
--- a/sw/source/uibase/wrtsh/wrtsh1.cxx
+++ b/sw/source/uibase/wrtsh/wrtsh1.cxx
@@ -2045,7 +2045,7 @@ void SwWrtShell::AutoUpdatePara(SwTextFormatColl* pColl, 
const SfxItemSet& rStyl
     // ITEM: SfxItemIter and removing SfxPoolItems:
     std::vector<sal_uInt16> aDeleteWhichIDs;
 
-    for (SfxItemIter aIter(aCoreSet); !aIter.IsAtEnd(); aIter.NextItem())
+    for (SfxItemIter aIter(aCoreSet); !aIter.IsAtEnd(); aIter.Next())
     {
         if(!IsInvalidItem(aIter.GetCurItem()))
         {

Reply via email to