[Libreoffice-commits] core.git: 3 commits - sw/inc sw/source
Caolán McNamara
caolanm at redhat.com
Tue May 2 14:40:57 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 +-
sw/source/filter/ww8/ww8toolbar.cxx | 80 ++++++++++++++++++------------------
7 files changed, 54 insertions(+), 51 deletions(-)
New commits:
commit de9106a511ed9c202423e3c3a9754feb4f969364
Author: Caolán McNamara <caolanm at redhat.com>
Date: Tue May 2 15:28:11 2017 +0100
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
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);
commit 4778f39ece4b41625b876e5e7673893e1e011a62
Author: Caolán McNamara <caolanm at redhat.com>
Date: Tue May 2 15:17:58 2017 +0100
ofz fix leak
Change-Id: I237f19f237e6b78f98798352c1f881b0d27a6a9e
diff --git a/sw/source/filter/ww8/ww8toolbar.cxx b/sw/source/filter/ww8/ww8toolbar.cxx
index 86663ea36ede..b269f013da52 100644
--- a/sw/source/filter/ww8/ww8toolbar.cxx
+++ b/sw/source/filter/ww8/ww8toolbar.cxx
@@ -825,48 +825,48 @@ Tcg255::~Tcg255()
bool Tcg255::processSubStruct( sal_uInt8 nId, SvStream &rS )
{
- Tcg255SubStruct* pSubStruct = nullptr;
+ std::unique_ptr<Tcg255SubStruct> xSubStruct;
switch ( nId )
{
case 0x1:
{
- pSubStruct = new PlfMcd;
+ xSubStruct.reset(new PlfMcd);
break;
}
case 0x2:
{
- pSubStruct = new PlfAcd;
+ xSubStruct.reset(new PlfAcd);
break;
}
case 0x3:
case 0x4:
{
- pSubStruct = new PlfKme;
+ xSubStruct.reset(new PlfKme);
break;
}
case 0x10:
{
- pSubStruct = new TcgSttbf;
+ xSubStruct.reset(new TcgSttbf);
break;
}
case 0x11:
{
- pSubStruct = new MacroNames;
+ xSubStruct.reset(new MacroNames);
break;
}
case 0x12:
{
- pSubStruct = new SwCTBWrapper;
+ xSubStruct.reset(new SwCTBWrapper);
break;
}
default:
SAL_INFO("sw.ww8","Unknown id 0x" << std::hex << nId);
return false;
}
- pSubStruct->ch = nId;
- if ( !pSubStruct->Read( rS ) )
+ xSubStruct->ch = nId;
+ if (!xSubStruct->Read(rS))
return false;
- rgtcgData.push_back( pSubStruct );
+ rgtcgData.push_back(xSubStruct.release());
return true;
}
commit 89c60b5d6671bd18cf57f55a2685ac43becd3756
Author: Caolán McNamara <caolanm at redhat.com>
Date: Tue May 2 15:16:23 2017 +0100
fix indent
Change-Id: Ic949efdb47861770e9e333e154ede54d7fa88e50
diff --git a/sw/source/filter/ww8/ww8toolbar.cxx b/sw/source/filter/ww8/ww8toolbar.cxx
index 2bfca76017b4..86663ea36ede 100644
--- a/sw/source/filter/ww8/ww8toolbar.cxx
+++ b/sw/source/filter/ww8/ww8toolbar.cxx
@@ -825,43 +825,43 @@ Tcg255::~Tcg255()
bool Tcg255::processSubStruct( sal_uInt8 nId, SvStream &rS )
{
- Tcg255SubStruct* pSubStruct = nullptr;
- switch ( nId )
- {
- case 0x1:
- {
- pSubStruct = new PlfMcd;
- break;
- }
- case 0x2:
- {
- pSubStruct = new PlfAcd;
- break;
- }
- case 0x3:
- case 0x4:
- {
- pSubStruct = new PlfKme;
- break;
- }
- case 0x10:
- {
- pSubStruct = new TcgSttbf;
- break;
- }
- case 0x11:
- {
- pSubStruct = new MacroNames;
- break;
- }
- case 0x12:
- {
- pSubStruct = new SwCTBWrapper;
- break;
- }
- default:
- SAL_INFO("sw.ww8","Unknown id 0x" << std::hex << nId);
- return false;
+ Tcg255SubStruct* pSubStruct = nullptr;
+ switch ( nId )
+ {
+ case 0x1:
+ {
+ pSubStruct = new PlfMcd;
+ break;
+ }
+ case 0x2:
+ {
+ pSubStruct = new PlfAcd;
+ break;
+ }
+ case 0x3:
+ case 0x4:
+ {
+ pSubStruct = new PlfKme;
+ break;
+ }
+ case 0x10:
+ {
+ pSubStruct = new TcgSttbf;
+ break;
+ }
+ case 0x11:
+ {
+ pSubStruct = new MacroNames;
+ break;
+ }
+ case 0x12:
+ {
+ pSubStruct = new SwCTBWrapper;
+ break;
+ }
+ default:
+ SAL_INFO("sw.ww8","Unknown id 0x" << std::hex << nId);
+ return false;
}
pSubStruct->ch = nId;
if ( !pSubStruct->Read( rS ) )
More information about the Libreoffice-commits
mailing list