sw/source/core/fields/docufld.cxx |   77 +++++++++++++++++---------------------
 1 file changed, 35 insertions(+), 42 deletions(-)

New commits:
commit aeab7de4cd2975b90d07d8b32d51efd953bbff3c
Author:     Bjoern Michaelsen <bjoern.michael...@libreoffice.org>
AuthorDate: Sat Mar 14 22:16:41 2020 +0100
Commit:     Björn Michaelsen <bjoern.michael...@libreoffice.org>
CommitDate: Sun Mar 15 02:20:02 2020 +0100

    docufld.cxx: SwIterator no more ...
    
    Change-Id: Ieb0c9f8aea3fa70260cb74e6b7850fd84108aacb
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90498
    Tested-by: Jenkins
    Reviewed-by: Björn Michaelsen <bjoern.michael...@libreoffice.org>

diff --git a/sw/source/core/fields/docufld.cxx 
b/sw/source/core/fields/docufld.cxx
index 4faf7c3bd74a..6b4c4eb39b7c 100644
--- a/sw/source/core/fields/docufld.cxx
+++ b/sw/source/core/fields/docufld.cxx
@@ -2173,13 +2173,10 @@ void SwRefPageGetFieldType::Modify( const SfxPoolItem* 
pOld, const SfxPoolItem*
         SetGetExpFields aTmpLst;
         if (MakeSetList(aTmpLst, pLayout))
         {
-            SwIterator<SwFormatField,SwFieldType> aIter( *this );
-            for ( SwFormatField* pFormatField = aIter.First(); pFormatField; 
pFormatField = aIter.Next() )
-            {
-                    // update only the GetRef fields
-                    if( pFormatField->GetTextField() )
-                        UpdateField(pFormatField->GetTextField(), aTmpLst, 
pLayout);
-            }
+            std::vector<SwFormatField*> vFields;
+            GatherFields(vFields);
+            for(auto pFormatField: vFields)
+                UpdateField(pFormatField->GetTextField(), aTmpLst, pLayout);
         }
     };
 
@@ -2214,51 +2211,47 @@ bool 
SwRefPageGetFieldType::MakeSetList(SetGetExpFields& rTmpLst,
         SwRootFrame const*const pLayout)
 {
     IDocumentRedlineAccess const& rIDRA(m_pDoc->getIDocumentRedlineAccess());
-    SwIterator<SwFormatField,SwFieldType> 
aIter(*m_pDoc->getIDocumentFieldsAccess().GetSysFieldType( 
SwFieldIds::RefPageSet));
-    for ( SwFormatField* pFormatField = aIter.First(); pFormatField; 
pFormatField = aIter.Next() )
+    std::vector<SwFormatField*> vFields;
+    GatherFields(vFields);
+    for(auto pFormatField: vFields)
     {
         // update only the GetRef fields
         const SwTextField* pTField = pFormatField->GetTextField();
-        if( pTField )
+        if (!pLayout || !pLayout->IsHideRedlines() || 
!sw::IsFieldDeletedInModel(rIDRA, *pTField))
         {
-            if (!pLayout || !pLayout->IsHideRedlines()
-                || !sw::IsFieldDeletedInModel(rIDRA, *pTField))
-            {
-                const SwTextNode& rTextNd = pTField->GetTextNode();
+            const SwTextNode& rTextNd = pTField->GetTextNode();
 
-                // Always the first! (in Tab-Headline, header/footer )
-                Point aPt;
-                std::pair<Point, bool> const tmp(aPt, false);
-                const SwContentFrame *const pFrame = rTextNd.getLayoutFrame(
-                    pLayout, nullptr, &tmp);
-
-                std::unique_ptr<SetGetExpField> pNew;
+            // Always the first! (in Tab-Headline, header/footer )
+            Point aPt;
+            std::pair<Point, bool> const tmp(aPt, false);
+            const SwContentFrame *const pFrame = rTextNd.getLayoutFrame(
+                pLayout, nullptr, &tmp);
 
-                if( !pFrame ||
-                     pFrame->IsInDocBody() ||
-                    // #i31868#
-                    // Check if pFrame is not yet connected to the layout.
-                    !pFrame->FindPageFrame() )
-                {
-                    //  create index for determination of the TextNode
-                    SwNodeIndex aIdx( rTextNd );
-                    pNew.reset( new SetGetExpField( aIdx, pTField ) );
-                }
-                else
-                {
-                    //  create index for determination of the TextNode
-                    SwPosition aPos( m_pDoc->GetNodes().GetEndOfPostIts() );
-                    bool const bResult = GetBodyTextNode( *m_pDoc, aPos, 
*pFrame );
-                    OSL_ENSURE(bResult, "where is the Field?");
-                    pNew.reset( new SetGetExpField( aPos.nNode, pTField,
-                                                &aPos.nContent ) );
-                }
+            std::unique_ptr<SetGetExpField> pNew;
 
-                rTmpLst.insert( std::move(pNew) );
+            if( !pFrame ||
+                 pFrame->IsInDocBody() ||
+                // #i31868#
+                // Check if pFrame is not yet connected to the layout.
+                !pFrame->FindPageFrame() )
+            {
+                //  create index for determination of the TextNode
+                SwNodeIndex aIdx( rTextNd );
+                pNew.reset( new SetGetExpField( aIdx, pTField ) );
             }
+            else
+            {
+                //  create index for determination of the TextNode
+                SwPosition aPos( m_pDoc->GetNodes().GetEndOfPostIts() );
+                bool const bResult = GetBodyTextNode( *m_pDoc, aPos, *pFrame );
+                OSL_ENSURE(bResult, "where is the Field?");
+                pNew.reset( new SetGetExpField( aPos.nNode, pTField,
+                                            &aPos.nContent ) );
+            }
+
+            rTmpLst.insert( std::move(pNew) );
         }
     }
-
     return !rTmpLst.empty();
 }
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to