Kaydet (Commit) de9106a5 authored tarafından Caolán McNamara's avatar Caolán McNamara

Revert "SwFieldTypes can just be a std::vector typedef"

This reverts commit 5eaad8eb.

cause it now leaks as the ~SwVectorModifyBase base deletes the entries

Change-Id: I02374f4b439b9cf3e8f331aa9c6892b4418f37f0
üst 4778f39e
...@@ -22,10 +22,9 @@ ...@@ -22,10 +22,9 @@
#include <sal/types.h> #include <sal/types.h>
#include <tools/solar.h> #include <tools/solar.h>
#include <vector>
class SwFieldTypes;
class SwFieldType; class SwFieldType;
typedef std::vector<SwFieldType*> SwFieldTypes;
class SfxPoolItem; class SfxPoolItem;
struct SwPosition; struct SwPosition;
class SwDocUpdateField; class SwDocUpdateField;
......
...@@ -88,6 +88,7 @@ class SwEditShell; ...@@ -88,6 +88,7 @@ class SwEditShell;
class SwFieldType; class SwFieldType;
class SwField; class SwField;
class SwTextField; class SwTextField;
class SwFieldTypes;
class SwFlyFrameFormat; class SwFlyFrameFormat;
class SwFormatsBase; class SwFormatsBase;
class SwFormat; class SwFormat;
......
...@@ -295,8 +295,10 @@ public: ...@@ -295,8 +295,10 @@ public:
void dumpAsXml(struct _xmlTextWriter* pWriter) const; void dumpAsXml(struct _xmlTextWriter* pWriter) const;
}; };
typedef std::vector<SwFieldType*> SwFieldTypes; class SwFieldTypes : public SwVectorModifyBase<SwFieldType*> {
void dumpAsXml(struct _xmlTextWriter* pWriter, SwFieldTypes const &); public:
void dumpAsXml(struct _xmlTextWriter* pWriter) const;
};
typedef std::vector<SwTOXType*> SwTOXTypes; typedef std::vector<SwTOXType*> SwTOXTypes;
......
...@@ -1940,7 +1940,7 @@ void SwDoc::dumpAsXml(xmlTextWriterPtr pWriter) const ...@@ -1940,7 +1940,7 @@ void SwDoc::dumpAsXml(xmlTextWriterPtr pWriter) const
maDBData.dumpAsXml(pWriter); maDBData.dumpAsXml(pWriter);
mpMarkManager->dumpAsXml(pWriter); mpMarkManager->dumpAsXml(pWriter);
m_pUndoManager->dumpAsXml(pWriter); m_pUndoManager->dumpAsXml(pWriter);
::dumpAsXml(pWriter, *getIDocumentFieldsAccess().GetFieldTypes()); getIDocumentFieldsAccess().GetFieldTypes()->dumpAsXml(pWriter);
mpTextFormatCollTable->dumpAsXml(pWriter); mpTextFormatCollTable->dumpAsXml(pWriter);
mpCharFormatTable->dumpAsXml(pWriter); mpCharFormatTable->dumpAsXml(pWriter);
mpFrameFormatTable->dumpAsXml(pWriter, "frmFormatTable"); mpFrameFormatTable->dumpAsXml(pWriter, "frmFormatTable");
......
...@@ -90,12 +90,11 @@ void SwDBFieldType::ReleaseRef() ...@@ -90,12 +90,11 @@ void SwDBFieldType::ReleaseRef()
if (--nRefCnt <= 0) if (--nRefCnt <= 0)
{ {
auto pFieldTypes = GetDoc()->getIDocumentFieldsAccess().GetFieldTypes(); size_t nPos = GetDoc()->getIDocumentFieldsAccess().GetFieldTypes()->GetPos(this);
auto it = std::find(pFieldTypes->begin(), pFieldTypes->end(), this);
if (it != pFieldTypes->end()) if (nPos != SIZE_MAX)
{ {
GetDoc()->getIDocumentFieldsAccess().RemoveFieldType(it - pFieldTypes->begin()); GetDoc()->getIDocumentFieldsAccess().RemoveFieldType(nPos);
delete this; delete this;
} }
} }
......
...@@ -155,11 +155,13 @@ bool SwFieldType::PutValue( const uno::Any& , sal_uInt16 ) ...@@ -155,11 +155,13 @@ bool SwFieldType::PutValue( const uno::Any& , sal_uInt16 )
return false; return false;
} }
void dumpAsXml(xmlTextWriterPtr pWriter, SwFieldTypes const & rTypes) void SwFieldTypes::dumpAsXml(xmlTextWriterPtr pWriter) const
{ {
xmlTextWriterStartElement(pWriter, BAD_CAST("SwFieldTypes")); 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); SwIterator<SwFormatField, SwFieldType> aIter(*pCurType);
for (const SwFormatField* pFormatField = aIter.First(); pFormatField; pFormatField = aIter.Next()) for (const SwFormatField* pFormatField = aIter.First(); pFormatField; pFormatField = aIter.Next())
pFormatField->dumpAsXml(pWriter); pFormatField->dumpAsXml(pWriter);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment