[Libreoffice-commits] core.git: sw/inc sw/source

Bjoern Michaelsen (via logerrit) logerrit at kemper.freedesktop.org
Sun Feb 16 17:12:33 UTC 2020


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

New commits:
commit fbe8f2dc3b8a5734df0643c37a1f854f7eb84023
Author:     Bjoern Michaelsen <bjoern.michaelsen at libreoffice.org>
AuthorDate: Sun Feb 16 12:54:36 2020 +0100
Commit:     Björn Michaelsen <bjoern.michaelsen at libreoffice.org>
CommitDate: Sun Feb 16 18:12:01 2020 +0100

    no more SwIterator in GatherChapterFields
    
    Change-Id: Iab5e210199948b2fbe9cca2f2ff6a36341a6c1c5
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88780
    Tested-by: Jenkins
    Reviewed-by: Björn Michaelsen <bjoern.michaelsen at libreoffice.org>

diff --git a/sw/inc/fldbas.hxx b/sw/inc/fldbas.hxx
index 93012dc5458b..8601dea443b8 100644
--- a/sw/inc/fldbas.hxx
+++ b/sw/inc/fldbas.hxx
@@ -22,6 +22,8 @@
 #include <i18nlangtag/lang.h>
 #include "swdllapi.h"
 #include "calbck.hxx"
+#include "ndindex.hxx"
+
 #include <cppuhelper/weakref.hxx>
 #include <editeng/svxenum.hxx>
 #include <vector>
@@ -274,6 +276,7 @@ public:
     SwFormatField* FindFormatForPostItId(sal_uInt32 nPostItId) const;
     void CollectPostIts(std::vector<SwFormatField*>& rvFormatFields, IDocumentRedlineAccess const& rIDRA, bool HideRedlines);
     bool HasHiddenInformationNotes();
+    void GatherNodeIndex(std::vector<sal_uLong>& rvNodeIndex);
 };
 
 inline void SwFieldType::UpdateFields() const
diff --git a/sw/inc/fmtfld.hxx b/sw/inc/fmtfld.hxx
index b2e6a6bf1508..e68a9be41582 100644
--- a/sw/inc/fmtfld.hxx
+++ b/sw/inc/fmtfld.hxx
@@ -26,6 +26,7 @@
 
 #include "swdllapi.h"
 #include "calbck.hxx"
+#include "ndindex.hxx"
 
 class SwField;
 class SwTextField;
@@ -56,6 +57,10 @@ namespace sw {
         bool& m_rbHasHiddenInformationNotes;
         HasHiddenInformationNotesHint(bool& rbHasHiddenInformationNotes) : m_rbHasHiddenInformationNotes(rbHasHiddenInformationNotes) {};
     };
+    struct GatherNodeIndexHint final : SfxHint {
+        std::vector<sal_uLong>& m_rvNodeIndex;
+        GatherNodeIndexHint(std::vector<sal_uLong>& rvNodeIndex) : m_rvNodeIndex(rvNodeIndex) {};
+    };
 }
 
 
diff --git a/sw/source/core/fields/fldbas.cxx b/sw/source/core/fields/fldbas.cxx
index b17d07fd4171..a56b2c81302b 100644
--- a/sw/source/core/fields/fldbas.cxx
+++ b/sw/source/core/fields/fldbas.cxx
@@ -180,6 +180,11 @@ bool SwFieldType::HasHiddenInformationNotes()
     return bHasHiddenInformationNotes;
 }
 
+void SwFieldType::GatherNodeIndex(std::vector<sal_uLong>& rvNodeIndex)
+{
+    CallSwClientNotify(sw::GatherNodeIndexHint(rvNodeIndex));
+}
+
 void SwFieldTypes::dumpAsXml(xmlTextWriterPtr pWriter) const
 {
     xmlTextWriterStartElement(pWriter, BAD_CAST("SwFieldTypes"));
diff --git a/sw/source/core/txtnode/atrfld.cxx b/sw/source/core/txtnode/atrfld.cxx
index 67ec2b0992f2..88b67c451b94 100644
--- a/sw/source/core/txtnode/atrfld.cxx
+++ b/sw/source/core/txtnode/atrfld.cxx
@@ -262,6 +262,10 @@ void SwFormatField::SwClientNotify( const SwModify& rModify, const SfxHint& rHin
     {
         if(!pHasHiddenInfoHint->m_rbHasHiddenInformationNotes && GetTextField() && IsFieldInDoc())
             pHasHiddenInfoHint->m_rbHasHiddenInformationNotes = true;
+    } else if (const auto pGatherNodeIndexHint = dynamic_cast<const sw::GatherNodeIndexHint*>( &rHint ))
+    {
+        if(auto pTextField = GetTextField())
+            pGatherNodeIndexHint->m_rvNodeIndex.push_back(pTextField->GetTextNode().GetIndex());
     }
 }
 
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index 96c7ebe0f50c..38181c2d69b8 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -355,15 +355,7 @@ void MSWordExportBase::GatherChapterFields()
 {
     //If the header/footer contains a chapter field
     SwFieldType* pType = m_pDoc->getIDocumentFieldsAccess().GetSysFieldType( SwFieldIds::Chapter );
-    SwIterator<SwFormatField,SwFieldType> aFormatFields( *pType );
-    for ( SwFormatField* pField = aFormatFields.First(); pField; pField = aFormatFields.Next() )
-    {
-        if (const SwTextField *pTextField = pField->GetTextField())
-        {
-            const SwTextNode &rTextNode = pTextField->GetTextNode();
-            m_aChapterFieldLocs.push_back(rTextNode.GetIndex());
-        }
-    }
+    pType->GatherNodeIndex(m_aChapterFieldLocs);
 }
 
 bool MSWordExportBase::ContentContainsChapterField(const SwFormatContent &rContent) const


More information about the Libreoffice-commits mailing list