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

Noel Grandin noelgrandin at gmail.com
Tue May 2 06:18:28 UTC 2017


 sw/inc/IDocumentFieldsAccess.hxx |    3 ++-
 sw/inc/doc.hxx                   |    1 -
 sw/inc/docary.hxx                |    6 ++----
 sw/source/core/doc/docfmt.cxx    |    2 +-
 sw/source/core/fields/dbfld.cxx  |    7 ++++---
 sw/source/core/fields/fldbas.cxx |    6 ++----
 6 files changed, 11 insertions(+), 14 deletions(-)

New commits:
commit 5eaad8eb1d46b6f85605c5ac210e8b1397b18b22
Author: Noel Grandin <noelgrandin at gmail.com>
Date:   Mon May 1 14:34:38 2017 +0200

    SwFieldTypes can just be a std::vector typedef
    
    Change-Id: I10b43a71c8cedc6efbb30056d3da7fd431f04791
    Reviewed-on: https://gerrit.libreoffice.org/37121
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sw/inc/IDocumentFieldsAccess.hxx b/sw/inc/IDocumentFieldsAccess.hxx
index c78e5a249b3b..7d999d955a29 100644
--- a/sw/inc/IDocumentFieldsAccess.hxx
+++ b/sw/inc/IDocumentFieldsAccess.hxx
@@ -22,9 +22,10 @@
 
 #include <sal/types.h>
 #include <tools/solar.h>
+#include <vector>
 
-class SwFieldTypes;
 class SwFieldType;
+typedef std::vector<SwFieldType*> SwFieldTypes;
 class SfxPoolItem;
 struct SwPosition;
 class SwDocUpdateField;
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index 61d57940d2f9..d1e1073cd522 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -88,7 +88,6 @@ class SwEditShell;
 class SwFieldType;
 class SwField;
 class SwTextField;
-class SwFieldTypes;
 class SwFlyFrameFormat;
 class SwFormatsBase;
 class SwFormat;
diff --git a/sw/inc/docary.hxx b/sw/inc/docary.hxx
index 255bc8127ff7..8e0131516a11 100644
--- a/sw/inc/docary.hxx
+++ b/sw/inc/docary.hxx
@@ -295,10 +295,8 @@ public:
     void dumpAsXml(struct _xmlTextWriter* pWriter) const;
 };
 
-class SwFieldTypes : public SwVectorModifyBase<SwFieldType*> {
-public:
-    void dumpAsXml(struct _xmlTextWriter* pWriter) const;
-};
+typedef std::vector<SwFieldType*> SwFieldTypes;
+void dumpAsXml(struct _xmlTextWriter* pWriter, SwFieldTypes const &);
 
 typedef std::vector<SwTOXType*> SwTOXTypes;
 
diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx
index 5dff133d929f..0e27f6140fb8 100644
--- a/sw/source/core/doc/docfmt.cxx
+++ b/sw/source/core/doc/docfmt.cxx
@@ -1940,7 +1940,7 @@ void SwDoc::dumpAsXml(xmlTextWriterPtr pWriter) const
     maDBData.dumpAsXml(pWriter);
     mpMarkManager->dumpAsXml(pWriter);
     m_pUndoManager->dumpAsXml(pWriter);
-    getIDocumentFieldsAccess().GetFieldTypes()->dumpAsXml(pWriter);
+    ::dumpAsXml(pWriter, *getIDocumentFieldsAccess().GetFieldTypes());
     mpTextFormatCollTable->dumpAsXml(pWriter);
     mpCharFormatTable->dumpAsXml(pWriter);
     mpFrameFormatTable->dumpAsXml(pWriter, "frmFormatTable");
diff --git a/sw/source/core/fields/dbfld.cxx b/sw/source/core/fields/dbfld.cxx
index e6724c228c7b..151dfe79c507 100644
--- a/sw/source/core/fields/dbfld.cxx
+++ b/sw/source/core/fields/dbfld.cxx
@@ -90,11 +90,12 @@ void SwDBFieldType::ReleaseRef()
 
     if (--nRefCnt <= 0)
     {
-        size_t nPos = GetDoc()->getIDocumentFieldsAccess().GetFieldTypes()->GetPos(this);
+        auto pFieldTypes = GetDoc()->getIDocumentFieldsAccess().GetFieldTypes();
+        auto it = std::find(pFieldTypes->begin(), pFieldTypes->end(), this);
 
-        if (nPos != SIZE_MAX)
+        if (it != pFieldTypes->end())
         {
-            GetDoc()->getIDocumentFieldsAccess().RemoveFieldType(nPos);
+            GetDoc()->getIDocumentFieldsAccess().RemoveFieldType(it - pFieldTypes->begin());
             delete this;
         }
     }
diff --git a/sw/source/core/fields/fldbas.cxx b/sw/source/core/fields/fldbas.cxx
index 4dcb10a43843..27627dddee55 100644
--- a/sw/source/core/fields/fldbas.cxx
+++ b/sw/source/core/fields/fldbas.cxx
@@ -155,13 +155,11 @@ bool SwFieldType::PutValue( const uno::Any& , sal_uInt16 )
     return false;
 }
 
-void SwFieldTypes::dumpAsXml(xmlTextWriterPtr pWriter) const
+void dumpAsXml(xmlTextWriterPtr pWriter, SwFieldTypes const & rTypes)
 {
     xmlTextWriterStartElement(pWriter, BAD_CAST("SwFieldTypes"));
-    sal_uInt16 nCount = size();
-    for (sal_uInt16 nType = 0; nType < nCount; ++nType)
+    for (auto pCurType : rTypes)
     {
-        const SwFieldType *pCurType = (*this)[nType];
         SwIterator<SwFormatField, SwFieldType> aIter(*pCurType);
         for (const SwFormatField* pFormatField = aIter.First(); pFormatField; pFormatField = aIter.Next())
             pFormatField->dumpAsXml(pWriter);


More information about the Libreoffice-commits mailing list