diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-05-02 15:28:11 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2017-05-02 15:40:28 +0100 |
commit | de9106a511ed9c202423e3c3a9754feb4f969364 (patch) | |
tree | 57f429b79c30f3cc5db106961edc4d69e7e37cf8 /sw | |
parent | 4778f39ece4b41625b876e5e7673893e1e011a62 (diff) |
Revert "SwFieldTypes can just be a std::vector typedef"
This reverts commit 5eaad8eb1d46b6f85605c5ac210e8b1397b18b22.
cause it now leaks as the ~SwVectorModifyBase base deletes the entries
Change-Id: I02374f4b439b9cf3e8f331aa9c6892b4418f37f0
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/IDocumentFieldsAccess.hxx | 3 | ||||
-rw-r--r-- | sw/inc/doc.hxx | 1 | ||||
-rw-r--r-- | sw/inc/docary.hxx | 6 | ||||
-rw-r--r-- | sw/source/core/doc/docfmt.cxx | 2 | ||||
-rw-r--r-- | sw/source/core/fields/dbfld.cxx | 7 | ||||
-rw-r--r-- | sw/source/core/fields/fldbas.cxx | 6 |
6 files changed, 14 insertions, 11 deletions
diff --git a/sw/inc/IDocumentFieldsAccess.hxx b/sw/inc/IDocumentFieldsAccess.hxx index 7d999d955a29..c78e5a249b3b 100644 --- a/sw/inc/IDocumentFieldsAccess.hxx +++ b/sw/inc/IDocumentFieldsAccess.hxx @@ -22,10 +22,9 @@ #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 d1e1073cd522..61d57940d2f9 100644 --- a/sw/inc/doc.hxx +++ b/sw/inc/doc.hxx @@ -88,6 +88,7 @@ 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 8e0131516a11..255bc8127ff7 100644 --- a/sw/inc/docary.hxx +++ b/sw/inc/docary.hxx @@ -295,8 +295,10 @@ public: void dumpAsXml(struct _xmlTextWriter* pWriter) const; }; -typedef std::vector<SwFieldType*> SwFieldTypes; -void dumpAsXml(struct _xmlTextWriter* pWriter, SwFieldTypes const &); +class SwFieldTypes : public SwVectorModifyBase<SwFieldType*> { +public: + void dumpAsXml(struct _xmlTextWriter* pWriter) const; +}; typedef std::vector<SwTOXType*> SwTOXTypes; diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx index 0e27f6140fb8..5dff133d929f 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); - ::dumpAsXml(pWriter, *getIDocumentFieldsAccess().GetFieldTypes()); + getIDocumentFieldsAccess().GetFieldTypes()->dumpAsXml(pWriter); 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 151dfe79c507..e6724c228c7b 100644 --- a/sw/source/core/fields/dbfld.cxx +++ b/sw/source/core/fields/dbfld.cxx @@ -90,12 +90,11 @@ void SwDBFieldType::ReleaseRef() if (--nRefCnt <= 0) { - auto pFieldTypes = GetDoc()->getIDocumentFieldsAccess().GetFieldTypes(); - auto it = std::find(pFieldTypes->begin(), pFieldTypes->end(), this); + size_t nPos = GetDoc()->getIDocumentFieldsAccess().GetFieldTypes()->GetPos(this); - if (it != pFieldTypes->end()) + if (nPos != SIZE_MAX) { - GetDoc()->getIDocumentFieldsAccess().RemoveFieldType(it - pFieldTypes->begin()); + GetDoc()->getIDocumentFieldsAccess().RemoveFieldType(nPos); delete this; } } diff --git a/sw/source/core/fields/fldbas.cxx b/sw/source/core/fields/fldbas.cxx index 27627dddee55..4dcb10a43843 100644 --- a/sw/source/core/fields/fldbas.cxx +++ b/sw/source/core/fields/fldbas.cxx @@ -155,11 +155,13 @@ bool SwFieldType::PutValue( const uno::Any& , sal_uInt16 ) return false; } -void dumpAsXml(xmlTextWriterPtr pWriter, SwFieldTypes const & rTypes) +void SwFieldTypes::dumpAsXml(xmlTextWriterPtr pWriter) const { xmlTextWriterStartElement(pWriter, BAD_CAST("SwFieldTypes")); - for (auto pCurType : rTypes) + sal_uInt16 nCount = size(); + for (sal_uInt16 nType = 0; nType < nCount; ++nType) { + const SwFieldType *pCurType = (*this)[nType]; SwIterator<SwFormatField, SwFieldType> aIter(*pCurType); for (const SwFormatField* pFormatField = aIter.First(); pFormatField; pFormatField = aIter.Next()) pFormatField->dumpAsXml(pWriter); |