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 @@
#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;
......
......@@ -88,6 +88,7 @@ class SwEditShell;
class SwFieldType;
class SwField;
class SwTextField;
class SwFieldTypes;
class SwFlyFrameFormat;
class SwFormatsBase;
class SwFormat;
......
......@@ -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;
......
......@@ -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");
......
......@@ -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;
}
}
......
......@@ -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);
......
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