[Libreoffice-commits] core.git: sw/inc sw/source
Noel Grandin (via logerrit)
logerrit at kemper.freedesktop.org
Thu Mar 28 06:40:53 UTC 2019
sw/inc/authfld.hxx | 2
sw/inc/chpfld.hxx | 2
sw/inc/dbfld.hxx | 10 ++--
sw/inc/ddefld.hxx | 2
sw/inc/docufld.hxx | 32 ++++++-------
sw/inc/expfld.hxx | 8 +--
sw/inc/fldbas.hxx | 2
sw/inc/flddat.hxx | 2
sw/inc/flddropdown.hxx | 2
sw/inc/reffld.hxx | 2
sw/inc/usrfld.hxx | 2
sw/source/core/doc/DocumentFieldsManager.cxx | 12 ++---
sw/source/core/fields/authfld.cxx | 4 -
sw/source/core/fields/chpfld.cxx | 4 -
sw/source/core/fields/dbfld.cxx | 25 ++++------
sw/source/core/fields/ddefld.cxx | 4 -
sw/source/core/fields/docufld.cxx | 62 ++++++++++++---------------
sw/source/core/fields/expfld.cxx | 13 ++---
sw/source/core/fields/flddat.cxx | 5 --
sw/source/core/fields/flddropdown.cxx | 4 -
sw/source/core/fields/macrofld.cxx | 5 --
sw/source/core/fields/reffld.cxx | 4 -
sw/source/core/fields/scrptfld.cxx | 4 -
sw/source/core/fields/tblcalc.cxx | 4 -
sw/source/core/fields/usrfld.cxx | 4 -
sw/source/core/undo/rolbck.cxx | 2
sw/source/core/undo/untbl.cxx | 6 +-
27 files changed, 107 insertions(+), 121 deletions(-)
New commits:
commit d337731d4f7017d51fab08f0edbac1effc9baf90
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Wed Mar 27 10:45:33 2019 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Mar 28 07:40:21 2019 +0100
return by unique_ptr from SwFieldType::Copy
Change-Id: I145b55c9cd62a5853c0dd26cc9b805b9f3a0e436
Reviewed-on: https://gerrit.libreoffice.org/69854
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/sw/inc/authfld.hxx b/sw/inc/authfld.hxx
index df836c5889e2..ea92f4289d9b 100644
--- a/sw/inc/authfld.hxx
+++ b/sw/inc/authfld.hxx
@@ -75,7 +75,7 @@ public:
SwAuthorityFieldType(SwDoc* pDoc);
virtual ~SwAuthorityFieldType() override;
- virtual SwFieldType* Copy() const override;
+ virtual std::unique_ptr<SwFieldType> Copy() const override;
virtual void QueryValue( css::uno::Any& rVal, sal_uInt16 nWhichId ) const override;
virtual void PutValue( const css::uno::Any& rVal, sal_uInt16 nWhichId ) override;
diff --git a/sw/inc/chpfld.hxx b/sw/inc/chpfld.hxx
index db7f7d528c82..2eab37afe536 100644
--- a/sw/inc/chpfld.hxx
+++ b/sw/inc/chpfld.hxx
@@ -41,7 +41,7 @@ class SW_DLLPUBLIC SwChapterFieldType : public SwFieldType
public:
SwChapterFieldType();
- virtual SwFieldType* Copy() const override;
+ virtual std::unique_ptr<SwFieldType> Copy() const override;
};
diff --git a/sw/inc/dbfld.hxx b/sw/inc/dbfld.hxx
index ae974501d283..0145c9171d93 100644
--- a/sw/inc/dbfld.hxx
+++ b/sw/inc/dbfld.hxx
@@ -39,7 +39,7 @@ public:
virtual ~SwDBFieldType() override;
virtual OUString GetName() const override;
- virtual SwFieldType* Copy() const override;
+ virtual std::unique_ptr<SwFieldType> Copy() const override;
void AddRef() { m_nRefCnt++; }
void ReleaseRef();
@@ -151,7 +151,7 @@ class SW_DLLPUBLIC SwDBNextSetFieldType : public SwFieldType
public:
SwDBNextSetFieldType();
- virtual SwFieldType* Copy() const override;
+ virtual std::unique_ptr<SwFieldType> Copy() const override;
};
// Next data record with condition.
@@ -190,7 +190,7 @@ class SwDBNumSetFieldType : public SwFieldType
public:
SwDBNumSetFieldType();
- virtual SwFieldType* Copy() const override;
+ virtual std::unique_ptr<SwFieldType> Copy() const override;
};
// Data record with number xxx.
@@ -238,7 +238,7 @@ public:
SwDBNameFieldType(SwDoc*);
OUString Expand() const;
- virtual SwFieldType* Copy() const override;
+ virtual std::unique_ptr<SwFieldType> Copy() const override;
};
// Database field.
@@ -259,7 +259,7 @@ class SW_DLLPUBLIC SwDBSetNumberFieldType : public SwFieldType
public:
SwDBSetNumberFieldType();
- virtual SwFieldType* Copy() const override;
+ virtual std::unique_ptr<SwFieldType> Copy() const override;
};
// Database field.
diff --git a/sw/inc/ddefld.hxx b/sw/inc/ddefld.hxx
index b4c306c1d2a8..8334adbda7ad 100644
--- a/sw/inc/ddefld.hxx
+++ b/sw/inc/ddefld.hxx
@@ -70,7 +70,7 @@ public:
void SetExpansion( const OUString& rStr ) { aExpansion = rStr;
bCRLFFlag = false; }
- virtual SwFieldType* Copy() const override;
+ virtual std::unique_ptr<SwFieldType> Copy() const override;
virtual OUString GetName() const override;
virtual void QueryValue( css::uno::Any& rVal, sal_uInt16 nWhich ) const override;
diff --git a/sw/inc/docufld.hxx b/sw/inc/docufld.hxx
index d7316a224224..d6ff1692e5bf 100644
--- a/sw/inc/docufld.hxx
+++ b/sw/inc/docufld.hxx
@@ -135,7 +135,7 @@ public:
sal_uInt16 const nMaxPage, const OUString&, LanguageType = LANGUAGE_NONE ) const;
void ChangeExpansion( SwDoc* pDoc,
bool bVirtPageNum, const SvxNumType* pNumFormat );
- virtual SwFieldType* Copy() const override;
+ virtual std::unique_ptr<SwFieldType> Copy() const override;
};
// Page numbering.
@@ -177,7 +177,7 @@ public:
SwAuthorFieldType();
static OUString Expand(sal_uLong);
- virtual SwFieldType* Copy() const override;
+ virtual std::unique_ptr<SwFieldType> Copy() const override;
};
class SwAuthorField : public SwField
@@ -203,7 +203,7 @@ public:
SwFileNameFieldType(SwDoc*);
OUString Expand(sal_uLong) const;
- virtual SwFieldType* Copy() const override;
+ virtual std::unique_ptr<SwFieldType> Copy() const override;
};
class SW_DLLPUBLIC SwFileNameField : public SwField
@@ -229,7 +229,7 @@ public:
SwTemplNameFieldType(SwDoc*);
OUString Expand(sal_uLong) const;
- virtual SwFieldType* Copy() const override;
+ virtual std::unique_ptr<SwFieldType> Copy() const override;
};
class SW_DLLPUBLIC SwTemplNameField : public SwField
@@ -252,7 +252,7 @@ class SwDocStatFieldType : public SwFieldType
public:
SwDocStatFieldType(SwDoc*);
OUString Expand(sal_uInt16 nSubType, SvxNumType nFormat) const;
- virtual SwFieldType* Copy() const override;
+ virtual std::unique_ptr<SwFieldType> Copy() const override;
void SetNumFormat( SvxNumType eFormat ) { m_nNumberingType = eFormat; }
};
@@ -282,7 +282,7 @@ class SwHiddenTextFieldType : public SwFieldType
public:
SwHiddenTextFieldType(bool bSetHidden = true);
- virtual SwFieldType* Copy() const override;
+ virtual std::unique_ptr<SwFieldType> Copy() const override;
void SetHiddenFlag( bool bSetHidden );
bool GetHiddenFlag() const { return m_bHidden; }
@@ -351,7 +351,7 @@ class SwHiddenParaFieldType : public SwFieldType
public:
SwHiddenParaFieldType();
- virtual SwFieldType* Copy() const override;
+ virtual std::unique_ptr<SwFieldType> Copy() const override;
};
class SwHiddenParaField : public SwField
@@ -382,7 +382,7 @@ class SwMacroFieldType : public SwFieldType
public:
SwMacroFieldType(SwDoc*);
- virtual SwFieldType* Copy() const override;
+ virtual std::unique_ptr<SwFieldType> Copy() const override;
};
class SW_DLLPUBLIC SwMacroField : public SwField
@@ -430,7 +430,7 @@ private:
public:
SwPostItFieldType(SwDoc* pDoc);
- virtual SwFieldType* Copy() const override;
+ virtual std::unique_ptr<SwFieldType> Copy() const override;
SwDoc* GetDoc() const
{
@@ -502,7 +502,7 @@ public:
SwDocInfoFieldType(SwDoc* pDc);
OUString Expand(sal_uInt16 nSubType, sal_uInt32 nFormat, LanguageType nLang, const OUString& rName) const;
- virtual SwFieldType* Copy() const override;
+ virtual std::unique_ptr<SwFieldType> Copy() const override;
};
class SW_DLLPUBLIC SwDocInfoField : public SwValueField
@@ -536,7 +536,7 @@ public:
SwExtUserFieldType();
static OUString Expand(sal_uInt16 nSubType);
- virtual SwFieldType* Copy() const override;
+ virtual std::unique_ptr<SwFieldType> Copy() const override;
};
class SwExtUserField : public SwField
@@ -565,7 +565,7 @@ class SwRefPageSetFieldType : public SwFieldType
public:
SwRefPageSetFieldType();
- virtual SwFieldType* Copy() const override;
+ virtual std::unique_ptr<SwFieldType> Copy() const override;
protected:
/// Overlay, because there is nothing to update!
@@ -609,7 +609,7 @@ protected:
virtual void Modify( const SfxPoolItem*, const SfxPoolItem * ) override;
public:
SwRefPageGetFieldType( SwDoc* pDoc );
- virtual SwFieldType* Copy() const override;
+ virtual std::unique_ptr<SwFieldType> Copy() const override;
bool MakeSetList(SetGetExpFields& rTmpLst, SwRootFrame const* pLayout);
SwDoc* GetDoc() const { return m_pDoc; }
};
@@ -641,7 +641,7 @@ class SwJumpEditFieldType : public SwFieldType
public:
SwJumpEditFieldType( SwDoc* pDoc );
- virtual SwFieldType* Copy() const override;
+ virtual std::unique_ptr<SwFieldType> Copy() const override;
SwCharFormat* GetCharFormat();
};
@@ -677,7 +677,7 @@ class SwScriptFieldType : public SwFieldType
public:
SwScriptFieldType( SwDoc* pDoc );
- virtual SwFieldType* Copy() const override;
+ virtual std::unique_ptr<SwFieldType> Copy() const override;
};
class SwScriptField : public SwField
@@ -716,7 +716,7 @@ class SwCombinedCharFieldType : public SwFieldType
public:
SwCombinedCharFieldType();
- virtual SwFieldType* Copy() const override;
+ virtual std::unique_ptr<SwFieldType> Copy() const override;
};
// ScriptField
diff --git a/sw/inc/expfld.hxx b/sw/inc/expfld.hxx
index 1f1c53c72d94..23d00b3d9fbb 100644
--- a/sw/inc/expfld.hxx
+++ b/sw/inc/expfld.hxx
@@ -71,7 +71,7 @@ class SwGetExpFieldType : public SwValueFieldType
{
public:
SwGetExpFieldType(SwDoc* pDoc);
- virtual SwFieldType* Copy() const override;
+ virtual std::unique_ptr<SwFieldType> Copy() const override;
/** Overlay, because get-field cannot be changed and therefore
does not need to be updated. Update at changing of set-values! */
@@ -155,7 +155,7 @@ protected:
public:
SwSetExpFieldType( SwDoc* pDoc, const OUString& rName,
sal_uInt16 nType = nsSwGetSetExpType::GSE_EXPR );
- virtual SwFieldType* Copy() const override;
+ virtual std::unique_ptr<SwFieldType> Copy() const override;
virtual OUString GetName() const override;
inline void SetType(sal_uInt16 nTyp);
@@ -274,7 +274,7 @@ class SwInputFieldType : public SwFieldType
public:
SwInputFieldType( SwDoc* pDoc );
- virtual SwFieldType* Copy() const override;
+ virtual std::unique_ptr<SwFieldType> Copy() const override;
SwDoc* GetDoc() const { return mpDoc; }
};
@@ -368,7 +368,7 @@ class SwTableFieldType : public SwValueFieldType
{
public:
SwTableFieldType(SwDoc* pDocPtr);
- virtual SwFieldType* Copy() const override;
+ virtual std::unique_ptr<SwFieldType> Copy() const override;
};
class SwTableField : public SwValueField, public SwTableFormula
diff --git a/sw/inc/fldbas.hxx b/sw/inc/fldbas.hxx
index 745c640e73ab..aafce0c4c718 100644
--- a/sw/inc/fldbas.hxx
+++ b/sw/inc/fldbas.hxx
@@ -258,7 +258,7 @@ public:
/// Only in derived classes.
virtual OUString GetName() const;
- virtual SwFieldType* Copy() const = 0;
+ virtual std::unique_ptr<SwFieldType> Copy() const = 0;
virtual void QueryValue( css::uno::Any& rVal, sal_uInt16 nWhich ) const;
virtual void PutValue( const css::uno::Any& rVal, sal_uInt16 nWhich );
diff --git a/sw/inc/flddat.hxx b/sw/inc/flddat.hxx
index b2896729b8bd..38ea963196b9 100644
--- a/sw/inc/flddat.hxx
+++ b/sw/inc/flddat.hxx
@@ -37,7 +37,7 @@ class SwDateTimeFieldType : public SwValueFieldType
public:
SwDateTimeFieldType(SwDoc* pDoc);
- virtual SwFieldType* Copy() const override;
+ virtual std::unique_ptr<SwFieldType> Copy() const override;
};
class SW_DLLPUBLIC SwDateTimeField : public SwValueField
diff --git a/sw/inc/flddropdown.hxx b/sw/inc/flddropdown.hxx
index b42445afa2ed..cc29a2e84c7f 100644
--- a/sw/inc/flddropdown.hxx
+++ b/sw/inc/flddropdown.hxx
@@ -46,7 +46,7 @@ public:
@return a copy of this type
*/
- virtual SwFieldType * Copy () const override;
+ virtual std::unique_ptr<SwFieldType> Copy () const override;
};
/**
diff --git a/sw/inc/reffld.hxx b/sw/inc/reffld.hxx
index 634642c4a47c..4adf0becfc31 100644
--- a/sw/inc/reffld.hxx
+++ b/sw/inc/reffld.hxx
@@ -68,7 +68,7 @@ protected:
virtual void Modify( const SfxPoolItem*, const SfxPoolItem* ) override;
public:
SwGetRefFieldType(SwDoc* pDoc );
- virtual SwFieldType* Copy() const override;
+ virtual std::unique_ptr<SwFieldType> Copy() const override;
SwDoc* GetDoc() const { return m_pDoc; }
diff --git a/sw/inc/usrfld.hxx b/sw/inc/usrfld.hxx
index 80ab6c257c90..7723cf3a903c 100644
--- a/sw/inc/usrfld.hxx
+++ b/sw/inc/usrfld.hxx
@@ -47,7 +47,7 @@ public:
SwUserFieldType( SwDoc* pDocPtr, const OUString& );
virtual OUString GetName() const override;
- virtual SwFieldType* Copy() const override;
+ virtual std::unique_ptr<SwFieldType> Copy() const override;
OUString Expand(sal_uInt32 nFormat, sal_uInt16 nSubType, LanguageType nLng);
diff --git a/sw/source/core/doc/DocumentFieldsManager.cxx b/sw/source/core/doc/DocumentFieldsManager.cxx
index 18db8ba4937e..e27475de02b7 100644
--- a/sw/source/core/doc/DocumentFieldsManager.cxx
+++ b/sw/source/core/doc/DocumentFieldsManager.cxx
@@ -244,33 +244,33 @@ SwFieldType* DocumentFieldsManager::InsertFieldType(const SwFieldType &rFieldTyp
return (*mpFieldTypes)[i];
}
- SwFieldType* pNew = rFieldTyp.Copy();
+ std::unique_ptr<SwFieldType> pNew = rFieldTyp.Copy();
switch( nFieldWhich )
{
case SwFieldIds::Dde:
- static_cast<SwDDEFieldType*>(pNew)->SetDoc( &m_rDoc );
+ static_cast<SwDDEFieldType*>(pNew.get())->SetDoc( &m_rDoc );
break;
case SwFieldIds::Database:
case SwFieldIds::Table:
case SwFieldIds::DateTime:
case SwFieldIds::GetExp:
- static_cast<SwValueFieldType*>(pNew)->SetDoc( &m_rDoc );
+ static_cast<SwValueFieldType*>(pNew.get())->SetDoc( &m_rDoc );
break;
case SwFieldIds::User:
case SwFieldIds::SetExp:
- static_cast<SwValueFieldType*>(pNew)->SetDoc( &m_rDoc );
+ static_cast<SwValueFieldType*>(pNew.get())->SetDoc( &m_rDoc );
// JP 29.07.96: Optionally prepare FieldList for Calculator:
mpUpdateFields->InsertFieldType( *pNew );
break;
case SwFieldIds::TableOfAuthorities :
- static_cast<SwAuthorityFieldType*>(pNew)->SetDoc( &m_rDoc );
+ static_cast<SwAuthorityFieldType*>(pNew.get())->SetDoc( &m_rDoc );
break;
default: break;
}
- mpFieldTypes->insert( mpFieldTypes->begin() + nSize, pNew );
+ mpFieldTypes->insert( mpFieldTypes->begin() + nSize, pNew.release() );
m_rDoc.getIDocumentState().SetModified();
return (*mpFieldTypes)[ nSize ];
diff --git a/sw/source/core/fields/authfld.cxx b/sw/source/core/fields/authfld.cxx
index cb93ce2a9f43..fa21aa81643d 100644
--- a/sw/source/core/fields/authfld.cxx
+++ b/sw/source/core/fields/authfld.cxx
@@ -79,9 +79,9 @@ SwAuthorityFieldType::~SwAuthorityFieldType()
{
}
-SwFieldType* SwAuthorityFieldType::Copy() const
+std::unique_ptr<SwFieldType> SwAuthorityFieldType::Copy() const
{
- return new SwAuthorityFieldType(m_pDoc);
+ return std::make_unique<SwAuthorityFieldType>(m_pDoc);
}
void SwAuthorityFieldType::RemoveField(const SwAuthEntry* nHandle)
diff --git a/sw/source/core/fields/chpfld.cxx b/sw/source/core/fields/chpfld.cxx
index 31dd91c4d50b..9473b086d759 100644
--- a/sw/source/core/fields/chpfld.cxx
+++ b/sw/source/core/fields/chpfld.cxx
@@ -58,9 +58,9 @@ SwChapterFieldType::SwChapterFieldType()
{
}
-SwFieldType* SwChapterFieldType::Copy() const
+std::unique_ptr<SwFieldType> SwChapterFieldType::Copy() const
{
- return new SwChapterFieldType();
+ return std::make_unique<SwChapterFieldType>();
}
// chapter field
diff --git a/sw/source/core/fields/dbfld.cxx b/sw/source/core/fields/dbfld.cxx
index f17faa166e8c..cba8ed87cae7 100644
--- a/sw/source/core/fields/dbfld.cxx
+++ b/sw/source/core/fields/dbfld.cxx
@@ -73,10 +73,9 @@ SwDBFieldType::~SwDBFieldType()
{
}
-SwFieldType* SwDBFieldType::Copy() const
+std::unique_ptr<SwFieldType> SwDBFieldType::Copy() const
{
- SwDBFieldType* pTmp = new SwDBFieldType(GetDoc(), m_sColumn, m_aDBData);
- return pTmp;
+ return std::make_unique<SwDBFieldType>(GetDoc(), m_sColumn, m_aDBData);
}
OUString SwDBFieldType::GetName() const
@@ -555,10 +554,9 @@ SwDBNextSetFieldType::SwDBNextSetFieldType()
{
}
-SwFieldType* SwDBNextSetFieldType::Copy() const
+std::unique_ptr<SwFieldType> SwDBNextSetFieldType::Copy() const
{
- SwDBNextSetFieldType* pTmp = new SwDBNextSetFieldType();
- return pTmp;
+ return std::make_unique<SwDBNextSetFieldType>();
}
// SwDBSetField
@@ -640,10 +638,9 @@ SwDBNumSetFieldType::SwDBNumSetFieldType() :
{
}
-SwFieldType* SwDBNumSetFieldType::Copy() const
+std::unique_ptr<SwFieldType> SwDBNumSetFieldType::Copy() const
{
- SwDBNumSetFieldType* pTmp = new SwDBNumSetFieldType();
- return pTmp;
+ return std::make_unique<SwDBNumSetFieldType>();
}
SwDBNumSetField::SwDBNumSetField(SwDBNumSetFieldType* pTyp,
@@ -756,10 +753,9 @@ OUString SwDBNameFieldType::Expand() const
return aData.sDataSource + "." + aData.sCommand;
}
-SwFieldType* SwDBNameFieldType::Copy() const
+std::unique_ptr<SwFieldType> SwDBNameFieldType::Copy() const
{
- SwDBNameFieldType *pTmp = new SwDBNameFieldType(m_pDoc);
- return pTmp;
+ return std::make_unique<SwDBNameFieldType>(m_pDoc);
}
// name of the connected database
@@ -799,10 +795,9 @@ SwDBSetNumberFieldType::SwDBSetNumberFieldType()
{
}
-SwFieldType* SwDBSetNumberFieldType::Copy() const
+std::unique_ptr<SwFieldType> SwDBSetNumberFieldType::Copy() const
{
- SwDBSetNumberFieldType *pTmp = new SwDBSetNumberFieldType;
- return pTmp;
+ return std::make_unique<SwDBSetNumberFieldType>();
}
// set-number of the connected database
diff --git a/sw/source/core/fields/ddefld.cxx b/sw/source/core/fields/ddefld.cxx
index 6527887ef7b7..4211f3fcb770 100644
--- a/sw/source/core/fields/ddefld.cxx
+++ b/sw/source/core/fields/ddefld.cxx
@@ -203,9 +203,9 @@ SwDDEFieldType::~SwDDEFieldType()
refLink->Disconnect();
}
-SwFieldType* SwDDEFieldType::Copy() const
+std::unique_ptr<SwFieldType> SwDDEFieldType::Copy() const
{
- SwDDEFieldType* pType = new SwDDEFieldType( aName, GetCmd(), GetType() );
+ std::unique_ptr<SwDDEFieldType> pType(new SwDDEFieldType( aName, GetCmd(), GetType() ));
pType->aExpansion = aExpansion;
pType->bCRLFFlag = bCRLFFlag;
pType->bDeleted = bDeleted;
diff --git a/sw/source/core/fields/docufld.cxx b/sw/source/core/fields/docufld.cxx
index a11d3b59a696..ec14fd1be535 100644
--- a/sw/source/core/fields/docufld.cxx
+++ b/sw/source/core/fields/docufld.cxx
@@ -121,9 +121,9 @@ OUString SwPageNumberFieldType::Expand( SvxNumType nFormat, short nOff,
return FormatNumber( nTmp, nTmpFormat, nLang );
}
-SwFieldType* SwPageNumberFieldType::Copy() const
+std::unique_ptr<SwFieldType> SwPageNumberFieldType::Copy() const
{
- SwPageNumberFieldType *pTmp = new SwPageNumberFieldType();
+ std::unique_ptr<SwPageNumberFieldType> pTmp(new SwPageNumberFieldType());
pTmp->m_nNumberingType = m_nNumberingType;
pTmp->m_bVirtual = m_bVirtual;
@@ -325,9 +325,9 @@ OUString SwAuthorFieldType::Expand(sal_uLong nFormat)
return rOpt.GetID();
}
-SwFieldType* SwAuthorFieldType::Copy() const
+std::unique_ptr<SwFieldType> SwAuthorFieldType::Copy() const
{
- return new SwAuthorFieldType;
+ return std::make_unique<SwAuthorFieldType>();
}
SwAuthorField::SwAuthorField(SwAuthorFieldType* pTyp, sal_uInt32 nFormat)
@@ -458,10 +458,9 @@ OUString SwFileNameFieldType::Expand(sal_uLong nFormat) const
return aRet;
}
-SwFieldType* SwFileNameFieldType::Copy() const
+std::unique_ptr<SwFieldType> SwFileNameFieldType::Copy() const
{
- SwFieldType *pTmp = new SwFileNameFieldType(m_pDoc);
- return pTmp;
+ return std::make_unique<SwFileNameFieldType>(m_pDoc);
}
SwFileNameField::SwFileNameField(SwFileNameFieldType* pTyp, sal_uInt32 nFormat)
@@ -629,10 +628,9 @@ OUString SwTemplNameFieldType::Expand(sal_uLong nFormat) const
return aRet;
}
-SwFieldType* SwTemplNameFieldType::Copy() const
+std::unique_ptr<SwFieldType> SwTemplNameFieldType::Copy() const
{
- SwFieldType *pTmp = new SwTemplNameFieldType(m_pDoc);
- return pTmp;
+ return std::make_unique<SwTemplNameFieldType>(m_pDoc);
}
SwTemplNameField::SwTemplNameField(SwTemplNameFieldType* pTyp, sal_uInt32 nFormat)
@@ -750,10 +748,9 @@ OUString SwDocStatFieldType::Expand(sal_uInt16 nSubType, SvxNumType nFormat) con
return OUString::number( nVal );
}
-SwFieldType* SwDocStatFieldType::Copy() const
+std::unique_ptr<SwFieldType> SwDocStatFieldType::Copy() const
{
- SwDocStatFieldType *pTmp = new SwDocStatFieldType(m_pDoc);
- return pTmp;
+ return std::make_unique<SwDocStatFieldType>(m_pDoc);
}
/**
@@ -840,10 +837,9 @@ SwDocInfoFieldType::SwDocInfoFieldType(SwDoc* pDc)
{
}
-SwFieldType* SwDocInfoFieldType::Copy() const
+std::unique_ptr<SwFieldType> SwDocInfoFieldType::Copy() const
{
- SwDocInfoFieldType* pTyp = new SwDocInfoFieldType(GetDoc());
- return pTyp;
+ return std::make_unique<SwDocInfoFieldType>(GetDoc());
}
static void lcl_GetLocalDataWrapper( LanguageType nLang,
@@ -1258,9 +1254,9 @@ SwHiddenTextFieldType::SwHiddenTextFieldType( bool bSetHidden )
{
}
-SwFieldType* SwHiddenTextFieldType::Copy() const
+std::unique_ptr<SwFieldType> SwHiddenTextFieldType::Copy() const
{
- return new SwHiddenTextFieldType( m_bHidden );
+ return std::make_unique<SwHiddenTextFieldType>( m_bHidden );
}
void SwHiddenTextFieldType::SetHiddenFlag( bool bSetHidden )
@@ -1649,10 +1645,9 @@ SwHiddenParaFieldType::SwHiddenParaFieldType()
{
}
-SwFieldType* SwHiddenParaFieldType::Copy() const
+std::unique_ptr<SwFieldType> SwHiddenParaFieldType::Copy() const
{
- SwHiddenParaFieldType* pTyp = new SwHiddenParaFieldType();
- return pTyp;
+ return std::make_unique<SwHiddenParaFieldType>();
}
// field for line height 0
@@ -1727,9 +1722,9 @@ SwPostItFieldType::SwPostItFieldType(SwDoc *pDoc)
, mpDoc(pDoc)
{}
-SwFieldType* SwPostItFieldType::Copy() const
+std::unique_ptr<SwFieldType> SwPostItFieldType::Copy() const
{
- return new SwPostItFieldType(mpDoc);
+ return std::make_unique<SwPostItFieldType>(mpDoc);
}
// PostIt field
@@ -1943,10 +1938,9 @@ SwExtUserFieldType::SwExtUserFieldType()
{
}
-SwFieldType* SwExtUserFieldType::Copy() const
+std::unique_ptr<SwFieldType> SwExtUserFieldType::Copy() const
{
- SwExtUserFieldType* pTyp = new SwExtUserFieldType;
- return pTyp;
+ return std::make_unique<SwExtUserFieldType>();
}
OUString SwExtUserFieldType::Expand(sal_uInt16 nSub )
@@ -2073,9 +2067,9 @@ SwRefPageSetFieldType::SwRefPageSetFieldType()
{
}
-SwFieldType* SwRefPageSetFieldType::Copy() const
+std::unique_ptr<SwFieldType> SwRefPageSetFieldType::Copy() const
{
- return new SwRefPageSetFieldType;
+ return std::make_unique<SwRefPageSetFieldType>();
}
// overridden since there is nothing to update
@@ -2150,9 +2144,9 @@ SwRefPageGetFieldType::SwRefPageGetFieldType( SwDoc* pDc )
{
}
-SwFieldType* SwRefPageGetFieldType::Copy() const
+std::unique_ptr<SwFieldType> SwRefPageGetFieldType::Copy() const
{
- SwRefPageGetFieldType* pNew = new SwRefPageGetFieldType( m_pDoc );
+ std::unique_ptr<SwRefPageGetFieldType> pNew(new SwRefPageGetFieldType( m_pDoc ));
pNew->m_nNumberingType = m_nNumberingType;
return pNew;
}
@@ -2450,9 +2444,9 @@ SwJumpEditFieldType::SwJumpEditFieldType( SwDoc* pD )
{
}
-SwFieldType* SwJumpEditFieldType::Copy() const
+std::unique_ptr<SwFieldType> SwJumpEditFieldType::Copy() const
{
- return new SwJumpEditFieldType( m_pDoc );
+ return std::make_unique<SwJumpEditFieldType>( m_pDoc );
}
SwCharFormat* SwJumpEditFieldType::GetCharFormat()
@@ -2574,9 +2568,9 @@ SwCombinedCharFieldType::SwCombinedCharFieldType()
{
}
-SwFieldType* SwCombinedCharFieldType::Copy() const
+std::unique_ptr<SwFieldType> SwCombinedCharFieldType::Copy() const
{
- return new SwCombinedCharFieldType;
+ return std::make_unique<SwCombinedCharFieldType>();
}
// combined character field
diff --git a/sw/source/core/fields/expfld.cxx b/sw/source/core/fields/expfld.cxx
index 6db9140996b2..b12ae69cdfc7 100644
--- a/sw/source/core/fields/expfld.cxx
+++ b/sw/source/core/fields/expfld.cxx
@@ -269,9 +269,9 @@ SwGetExpFieldType::SwGetExpFieldType(SwDoc* pDc)
{
}
-SwFieldType* SwGetExpFieldType::Copy() const
+std::unique_ptr<SwFieldType> SwGetExpFieldType::Copy() const
{
- return new SwGetExpFieldType(GetDoc());
+ return std::make_unique<SwGetExpFieldType>(GetDoc());
}
void SwGetExpFieldType::Modify( const SfxPoolItem*, const SfxPoolItem* pNew )
@@ -517,9 +517,9 @@ SwSetExpFieldType::SwSetExpFieldType( SwDoc* pDc, const OUString& rName, sal_uIn
EnableFormat(false); // do not use Numberformatter
}
-SwFieldType* SwSetExpFieldType::Copy() const
+std::unique_ptr<SwFieldType> SwSetExpFieldType::Copy() const
{
- SwSetExpFieldType* pNew = new SwSetExpFieldType(GetDoc(), m_sName, m_nType);
+ std::unique_ptr<SwSetExpFieldType> pNew(new SwSetExpFieldType(GetDoc(), m_sName, m_nType));
pNew->m_bDeleted = m_bDeleted;
pNew->m_sDelim = m_sDelim;
pNew->m_nLevel = m_nLevel;
@@ -1205,10 +1205,9 @@ SwInputFieldType::SwInputFieldType( SwDoc* pD )
{
}
-SwFieldType* SwInputFieldType::Copy() const
+std::unique_ptr<SwFieldType> SwInputFieldType::Copy() const
{
- SwInputFieldType* pType = new SwInputFieldType( mpDoc );
- return pType;
+ return std::make_unique<SwInputFieldType>( mpDoc );
}
SwInputField::SwInputField( SwInputFieldType* pFieldType,
diff --git a/sw/source/core/fields/flddat.cxx b/sw/source/core/fields/flddat.cxx
index 18ca8ddaed11..f2a6a779a0ed 100644
--- a/sw/source/core/fields/flddat.cxx
+++ b/sw/source/core/fields/flddat.cxx
@@ -35,10 +35,9 @@ SwDateTimeFieldType::SwDateTimeFieldType(SwDoc* pInitDoc)
: SwValueFieldType( pInitDoc, SwFieldIds::DateTime )
{}
-SwFieldType* SwDateTimeFieldType::Copy() const
+std::unique_ptr<SwFieldType> SwDateTimeFieldType::Copy() const
{
- SwDateTimeFieldType *pTmp = new SwDateTimeFieldType(GetDoc());
- return pTmp;
+ return std::make_unique<SwDateTimeFieldType>(GetDoc());
}
SwDateTimeField::SwDateTimeField(SwDateTimeFieldType* pInitType, sal_uInt16 nSub, sal_uLong nFormat, LanguageType nLng)
diff --git a/sw/source/core/fields/flddropdown.cxx b/sw/source/core/fields/flddropdown.cxx
index b0a7bd449756..cb7d706c3941 100644
--- a/sw/source/core/fields/flddropdown.cxx
+++ b/sw/source/core/fields/flddropdown.cxx
@@ -40,9 +40,9 @@ SwDropDownFieldType::~SwDropDownFieldType()
{
}
-SwFieldType * SwDropDownFieldType::Copy() const
+std::unique_ptr<SwFieldType> SwDropDownFieldType::Copy() const
{
- return new SwDropDownFieldType;
+ return std::make_unique<SwDropDownFieldType>();
}
SwDropDownField::SwDropDownField(SwFieldType * pTyp)
diff --git a/sw/source/core/fields/macrofld.cxx b/sw/source/core/fields/macrofld.cxx
index a15051ca4120..aa0576e61395 100644
--- a/sw/source/core/fields/macrofld.cxx
+++ b/sw/source/core/fields/macrofld.cxx
@@ -34,10 +34,9 @@ SwMacroFieldType::SwMacroFieldType(SwDoc* pDocument)
{
}
-SwFieldType* SwMacroFieldType::Copy() const
+std::unique_ptr<SwFieldType> SwMacroFieldType::Copy() const
{
- SwMacroFieldType* pType = new SwMacroFieldType(m_pDoc);
- return pType;
+ return std::make_unique<SwMacroFieldType>(m_pDoc);
}
SwMacroField::SwMacroField(SwMacroFieldType* pInitType,
diff --git a/sw/source/core/fields/reffld.cxx b/sw/source/core/fields/reffld.cxx
index d2137e355557..1546e71d6d61 100644
--- a/sw/source/core/fields/reffld.cxx
+++ b/sw/source/core/fields/reffld.cxx
@@ -1068,9 +1068,9 @@ SwGetRefFieldType::SwGetRefFieldType( SwDoc* pDc )
: SwFieldType( SwFieldIds::GetRef ), m_pDoc( pDc )
{}
-SwFieldType* SwGetRefFieldType::Copy() const
+std::unique_ptr<SwFieldType> SwGetRefFieldType::Copy() const
{
- return new SwGetRefFieldType( m_pDoc );
+ return std::make_unique<SwGetRefFieldType>( m_pDoc );
}
void SwGetRefFieldType::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew )
diff --git a/sw/source/core/fields/scrptfld.cxx b/sw/source/core/fields/scrptfld.cxx
index 5773694d7efb..37f2e3dc2084 100644
--- a/sw/source/core/fields/scrptfld.cxx
+++ b/sw/source/core/fields/scrptfld.cxx
@@ -29,9 +29,9 @@ SwScriptFieldType::SwScriptFieldType( SwDoc* pD )
: SwFieldType( SwFieldIds::Script ), m_pDoc( pD )
{}
-SwFieldType* SwScriptFieldType::Copy() const
+std::unique_ptr<SwFieldType> SwScriptFieldType::Copy() const
{
- return new SwScriptFieldType( m_pDoc );
+ return std::make_unique<SwScriptFieldType>( m_pDoc );
}
SwScriptField::SwScriptField( SwScriptFieldType* pInitType,
diff --git a/sw/source/core/fields/tblcalc.cxx b/sw/source/core/fields/tblcalc.cxx
index d4f1bee9ade2..4ea4087efef1 100644
--- a/sw/source/core/fields/tblcalc.cxx
+++ b/sw/source/core/fields/tblcalc.cxx
@@ -38,9 +38,9 @@ SwTableFieldType::SwTableFieldType(SwDoc* pDocPtr)
: SwValueFieldType( pDocPtr, SwFieldIds::Table )
{}
-SwFieldType* SwTableFieldType::Copy() const
+std::unique_ptr<SwFieldType> SwTableFieldType::Copy() const
{
- return new SwTableFieldType(GetDoc());
+ return std::make_unique<SwTableFieldType>(GetDoc());
}
void SwTableField::CalcField( SwTableCalcPara& rCalcPara )
diff --git a/sw/source/core/fields/usrfld.cxx b/sw/source/core/fields/usrfld.cxx
index 1a18258193ad..89ef18611115 100644
--- a/sw/source/core/fields/usrfld.cxx
+++ b/sw/source/core/fields/usrfld.cxx
@@ -201,9 +201,9 @@ OUString SwUserFieldType::Expand(sal_uInt32 nFormat, sal_uInt16 nSubType, Langua
return m_aContent;
}
-SwFieldType* SwUserFieldType::Copy() const
+std::unique_ptr<SwFieldType> SwUserFieldType::Copy() const
{
- SwUserFieldType *pTmp = new SwUserFieldType( GetDoc(), m_aName );
+ std::unique_ptr<SwUserFieldType> pTmp(new SwUserFieldType( GetDoc(), m_aName ));
pTmp->m_aContent = m_aContent;
pTmp->m_nType = m_nType;
pTmp->m_bValidValue = m_bValidValue;
diff --git a/sw/source/core/undo/rolbck.cxx b/sw/source/core/undo/rolbck.cxx
index 8a24eb941527..b2782a55532f 100644
--- a/sw/source/core/undo/rolbck.cxx
+++ b/sw/source/core/undo/rolbck.cxx
@@ -266,7 +266,7 @@ SwHistorySetTextField::SwHistorySetTextField( SwTextField* pTextField, sal_uLong
m_nFieldWhich == SwFieldIds::Dde ||
!pDoc->getIDocumentFieldsAccess().GetSysFieldType( m_nFieldWhich ))
{
- m_pFieldType.reset( m_pField->GetField()->GetTyp()->Copy() );
+ m_pFieldType = m_pField->GetField()->GetTyp()->Copy();
m_pField->GetField()->ChgTyp( m_pFieldType.get() ); // change field type
}
m_nNodeIndex = nNodePos;
diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx
index 5876797dc740..9c3d75fc81ff 100644
--- a/sw/source/core/undo/untbl.cxx
+++ b/sw/source/core/undo/untbl.cxx
@@ -281,7 +281,7 @@ void SwUndoInsTable::UndoImpl(::sw::UndoRedoContext & rContext)
sTableNm = pTableNd->GetTable().GetFrameFormat()->GetName();
if( auto pDDETable = dynamic_cast<const SwDDETable *>(&pTableNd->GetTable()) )
- pDDEFieldType.reset( static_cast<SwDDEFieldType*>(pDDETable->GetDDEFieldType()->Copy()) );
+ pDDEFieldType.reset(static_cast<SwDDEFieldType*>(pDDETable->GetDDEFieldType()->Copy().release()));
rDoc.GetNodes().Delete( aIdx, pTableNd->EndOfSectionIndex() -
aIdx.GetIndex() + 1 );
@@ -404,7 +404,7 @@ SwUndoTableToText::SwUndoTableToText( const SwTable& rTable, sal_Unicode cCh )
m_vBoxSaves.reserve(rTable.GetTabSortBoxes().size());
if( auto pDDETable = dynamic_cast<const SwDDETable *>(&rTable) )
- pDDEFieldType.reset( static_cast<SwDDEFieldType*>(pDDETable->GetDDEFieldType()->Copy()) );
+ pDDEFieldType.reset(static_cast<SwDDEFieldType*>(pDDETable->GetDDEFieldType()->Copy().release()));
bCheckNumFormat = rTable.GetFrameFormat()->GetDoc()->IsInsTableFormatNum();
@@ -641,7 +641,7 @@ void SwUndoTableToText::RedoImpl(::sw::UndoRedoContext & rContext)
OSL_ENSURE( pTableNd, "Could not find any TableNode" );
if( auto pDDETable = dynamic_cast<const SwDDETable *>(&pTableNd->GetTable()) )
- pDDEFieldType.reset( static_cast<SwDDEFieldType*>(pDDETable->GetDDEFieldType()->Copy()) );
+ pDDEFieldType.reset(static_cast<SwDDEFieldType*>(pDDETable->GetDDEFieldType()->Copy().release()));
rDoc.TableToText( pTableNd, cSeparator );
More information about the Libreoffice-commits
mailing list