sw/inc/fldbas.hxx                 |    2 +-
 sw/inc/fmtfld.hxx                 |    3 ++-
 sw/source/core/doc/doc.cxx        |    9 ++++-----
 sw/source/core/fields/fldbas.cxx  |    4 ++--
 sw/source/core/txtnode/atrfld.cxx |   14 +++++++++-----
 5 files changed, 18 insertions(+), 14 deletions(-)

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

    SwDoc::RemoveInvisibleContent(): SwIterator no more ...
    
    Change-Id: I62400059950bbd0cd110a4d1144d8e9a7163b744
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90499
    Tested-by: Jenkins
    Reviewed-by: Björn Michaelsen <bjoern.michael...@libreoffice.org>

diff --git a/sw/inc/fldbas.hxx b/sw/inc/fldbas.hxx
index 10c4faa78adf..ca47780e1287 100644
--- a/sw/inc/fldbas.hxx
+++ b/sw/inc/fldbas.hxx
@@ -279,7 +279,7 @@ public:
     bool HasHiddenInformationNotes();
     void GatherNodeIndex(std::vector<sal_uLong>& rvNodeIndex);
     void GatherRefFields(std::vector<SwGetRefField*>& rvRFields, const 
sal_uInt16 nTyp);
-    void GatherFields(std::vector<SwFormatField*>& rvFormatFields) const;
+    void GatherFields(std::vector<SwFormatField*>& rvFormatFields, bool 
bCollectOnlyInDocNodes=true) const;
 };
 
 inline void SwFieldType::UpdateFields() const
diff --git a/sw/inc/fmtfld.hxx b/sw/inc/fmtfld.hxx
index 1f26be54263e..0745f4ff5fc1 100644
--- a/sw/inc/fmtfld.hxx
+++ b/sw/inc/fmtfld.hxx
@@ -68,8 +68,9 @@ namespace sw {
         GatherRefFieldsHint(std::vector<SwGetRefField*>& rvRFields, const 
sal_uInt16 nType) : m_rvRFields(rvRFields), m_nType(nType) {};
     };
     struct GatherFieldsHint final : SfxHint {
+        const bool m_bCollectOnlyInDocNodes;
         std::vector<SwFormatField*>& m_rvFields;
-        GatherFieldsHint(std::vector<SwFormatField*>& rvFields) : 
m_rvFields(rvFields) {};
+        GatherFieldsHint(std::vector<SwFormatField*>& rvFields, bool 
bCollectOnlyInDocNodes = true) : 
m_bCollectOnlyInDocNodes(bCollectOnlyInDocNodes), m_rvFields(rvFields) {};
     };
 }
 
diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx
index 26e47a48725f..f29135722565 100644
--- a/sw/source/core/doc/doc.cxx
+++ b/sw/source/core/doc/doc.cxx
@@ -1400,11 +1400,10 @@ bool SwDoc::RemoveInvisibleContent()
         {
             if (const SwFieldType* pType = pTypeGuard->get())
             {
-                SwIterator<SwFormatField, SwFieldType> aIter(*pType);
-                for (SwFormatField* pFormatField = aIter.First(); pFormatField;
-                     pFormatField = aIter.Next())
-                    bRet |= HandleHidingField(*pFormatField, GetNodes(),
-                                              getIDocumentContentOperations());
+                std::vector<SwFormatField*> vFields;
+                pType->GatherFields(vFields);
+                for(auto pFormatField: vFields)
+                    bRet |= HandleHidingField(*pFormatField, GetNodes(), 
getIDocumentContentOperations());
             }
         }
     }
diff --git a/sw/source/core/fields/fldbas.cxx b/sw/source/core/fields/fldbas.cxx
index cabb78ec6c89..382880ecd8f4 100644
--- a/sw/source/core/fields/fldbas.cxx
+++ b/sw/source/core/fields/fldbas.cxx
@@ -190,9 +190,9 @@ void 
SwFieldType::GatherRefFields(std::vector<SwGetRefField*>& rvRFields, const
     CallSwClientNotify(sw::GatherRefFieldsHint(rvRFields, nTyp));
 }
 
-void SwFieldType::GatherFields(std::vector<SwFormatField*>& rvFields) const
+void SwFieldType::GatherFields(std::vector<SwFormatField*>& rvFields, bool 
bCollectOnlyInDocNodes) const
 {
-    CallSwClientNotify(sw::GatherFieldsHint(rvFields));
+    CallSwClientNotify(sw::GatherFieldsHint(rvFields, bCollectOnlyInDocNodes));
 }
 
 void SwFieldTypes::dumpAsXml(xmlTextWriterPtr pWriter) const
diff --git a/sw/source/core/txtnode/atrfld.cxx 
b/sw/source/core/txtnode/atrfld.cxx
index 30b8f6aec960..b41eb943c429 100644
--- a/sw/source/core/txtnode/atrfld.cxx
+++ b/sw/source/core/txtnode/atrfld.cxx
@@ -275,11 +275,15 @@ void SwFormatField::SwClientNotify( const SwModify& 
rModify, const SfxHint& rHin
             
pGatherRefFieldsHint->m_rvRFields.push_back(static_cast<SwGetRefField*>(GetField()));
     } else if (const auto pGatherFieldsHint = dynamic_cast<const 
sw::GatherFieldsHint*>( &rHint ))
     {
-        if(!GetTextField())
-            return;
-        SwTextNode* pNd = GetTextField()->GetpTextNode();
-        if(pNd && pNd->GetNodes().IsDocNodes())
-            pGatherFieldsHint->m_rvFields.push_back(this);
+        if(pGatherFieldsHint->m_bCollectOnlyInDocNodes)
+        {
+            if(!GetTextField())
+                return;
+            SwTextNode* pNd = GetTextField()->GetpTextNode();
+            if(!pNd || !pNd->GetNodes().IsDocNodes())
+                return;
+        }
+        pGatherFieldsHint->m_rvFields.push_back(this);
     }
 }
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to