[Libreoffice-commits] core.git: sw/source
Noel Grandin
noel.grandin at collabora.co.uk
Thu Oct 19 18:39:20 UTC 2017
sw/source/core/doc/docfld.cxx | 25 ++++++++-----------------
sw/source/core/inc/docfld.hxx | 7 ++++---
2 files changed, 12 insertions(+), 20 deletions(-)
New commits:
commit ed3d2e9863c11a36756466d907fa7fa8ecb726d0
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Thu Oct 19 14:49:08 2017 +0200
use std::unique_ptr in SwDocUpdateField
Change-Id: I9d6eba5e2714a29fd3a2ad301298ad8590a4af36
Reviewed-on: https://gerrit.libreoffice.org/43549
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/sw/source/core/doc/docfld.cxx b/sw/source/core/doc/docfld.cxx
index dcbc666ccfde..90c44f70ab60 100644
--- a/sw/source/core/doc/docfld.cxx
+++ b/sw/source/core/doc/docfld.cxx
@@ -776,7 +776,7 @@ void SwDocUpdateField::InsDelFieldInFieldLst( bool bIns, const SwTextField& rFie
{
if( !bIns ) // if list is present and deleted
return; // don't do a thing
- pFieldSortLst = new SetGetExpFields;
+ pFieldSortLst.reset(new SetGetExpFields);
}
if( bIns ) // insert anew:
@@ -805,8 +805,7 @@ void SwDocUpdateField::MakeFieldList( SwDoc& rDoc, bool bAll, int eGetMode )
void SwDocUpdateField::MakeFieldList_( SwDoc& rDoc, int eGetMode )
{
// new version: walk all fields of the attribute pool
- delete pFieldSortLst;
- pFieldSortLst = new SetGetExpFields;
+ pFieldSortLst.reset(new SetGetExpFields);
// consider and unhide sections
// with hide condition, only in mode GETFLD_ALL (<eGetMode == GETFLD_ALL>)
@@ -1104,8 +1103,8 @@ void SwDocUpdateField::InsertFieldType( const SwFieldType& rType )
if( !pFnd )
{
SwCalcFieldType* pNew = new SwCalcFieldType( sFieldName, &rType );
- pNew->pNext.reset( aFieldTypeTable[ n ] );
- aFieldTypeTable[ n ] = pNew;
+ pNew->pNext.reset( aFieldTypeTable[ n ].release() );
+ aFieldTypeTable[ n ].reset(pNew);
}
}
}
@@ -1134,14 +1133,13 @@ void SwDocUpdateField::RemoveFieldType( const SwFieldType& rType )
SwHash* pFnd = Find( sFieldName, GetFieldTypeTable(), TBLSZ, &n );
if( pFnd )
{
- if( aFieldTypeTable[ n ] == pFnd )
+ if( aFieldTypeTable[ n ].get() == pFnd )
{
- aFieldTypeTable[ n ] = static_cast<SwCalcFieldType*>(pFnd->pNext.release());
- delete pFnd;
+ aFieldTypeTable[ n ].reset(static_cast<SwCalcFieldType*>(pFnd->pNext.release()));
}
else
{
- SwHash* pPrev = aFieldTypeTable[ n ];
+ SwHash* pPrev = aFieldTypeTable[ n ].get();
while( pPrev->pNext.get() != pFnd )
pPrev = pPrev->pNext.get();
pPrev->pNext = std::move(pFnd->pNext);
@@ -1152,23 +1150,16 @@ void SwDocUpdateField::RemoveFieldType( const SwFieldType& rType )
}
SwDocUpdateField::SwDocUpdateField(SwDoc* pDoc)
- : pFieldSortLst(nullptr)
- , nNodes(0)
+ : nNodes(0)
, nFieldLstGetMode(0)
, pDocument(pDoc)
, bInUpdateFields(false)
, bFieldsDirty(false)
-
{
- memset( aFieldTypeTable, 0, sizeof( aFieldTypeTable ) );
}
SwDocUpdateField::~SwDocUpdateField()
{
- delete pFieldSortLst;
-
- for(SwCalcFieldType* p : aFieldTypeTable)
- delete p;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/inc/docfld.hxx b/sw/source/core/inc/docfld.hxx
index 5410ed76f52a..9979d557a8ee 100644
--- a/sw/source/core/inc/docfld.hxx
+++ b/sw/source/core/inc/docfld.hxx
@@ -24,6 +24,7 @@
#include <doc.hxx>
#include <IDocumentTimerAccess.hxx>
#include <o3tl/sorted_vector.hxx>
+#include <memory>
class SwTextField;
class SwIndex;
@@ -131,8 +132,8 @@ const int GETFLD_EXPAND = 2;
class SwDocUpdateField
{
- SetGetExpFields* pFieldSortLst; // current field list for calculation
- SwCalcFieldType* aFieldTypeTable[ TBLSZ ];
+ std::unique_ptr<SetGetExpFields> pFieldSortLst; // current field list for calculation
+ std::unique_ptr<SwCalcFieldType> aFieldTypeTable[ TBLSZ ];
sal_uLong nNodes; // if the node count is different
sal_uInt8 nFieldLstGetMode;
@@ -149,7 +150,7 @@ public:
SwDocUpdateField(SwDoc* pDocument);
~SwDocUpdateField();
- const SetGetExpFields* GetSortLst() const { return pFieldSortLst; }
+ const SetGetExpFields* GetSortLst() const { return pFieldSortLst.get(); }
void MakeFieldList( SwDoc& rDoc, bool bAll, int eGetMode );
More information about the Libreoffice-commits
mailing list