summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sw/inc/fmtinfmt.hxx5
-rw-r--r--sw/inc/shellres.hxx2
-rw-r--r--sw/inc/undobj.hxx8
-rw-r--r--sw/inc/unostyle.hxx2
-rw-r--r--sw/source/core/inc/UndoCore.hxx6
-rw-r--r--sw/source/core/inc/UndoOverwrite.hxx2
-rw-r--r--sw/source/core/inc/UndoRedline.hxx2
-rw-r--r--sw/source/core/inc/UndoTable.hxx8
-rw-r--r--sw/source/core/txtnode/fmtatr2.cxx13
-rw-r--r--sw/source/core/undo/undel.cxx16
-rw-r--r--sw/source/core/undo/undobj.cxx18
-rw-r--r--sw/source/core/undo/undobj1.cxx1
-rw-r--r--sw/source/core/undo/unfmco.cxx1
-rw-r--r--sw/source/core/undo/unins.cxx21
-rw-r--r--sw/source/core/undo/unmove.cxx9
-rw-r--r--sw/source/core/undo/unovwr.cxx10
-rw-r--r--sw/source/core/undo/unredln.cxx1
-rw-r--r--sw/source/core/undo/untbl.cxx40
-rw-r--r--sw/source/core/undo/untblk.cxx2
-rw-r--r--sw/source/core/unocore/unofield.cxx7
-rw-r--r--sw/source/core/unocore/unostyle.cxx4
-rw-r--r--sw/source/filter/basflt/fltshell.cxx36
-rw-r--r--sw/source/filter/html/htmlatr.cxx25
-rw-r--r--sw/source/filter/html/htmlfld.cxx2
-rw-r--r--sw/source/filter/html/htmltab.cxx17
-rw-r--r--sw/source/filter/html/swhtml.cxx11
-rw-r--r--sw/source/filter/html/swhtml.hxx2
-rw-r--r--sw/source/filter/html/wrthtml.cxx1
-rw-r--r--sw/source/filter/html/wrthtml.hxx4
-rw-r--r--sw/source/filter/inc/fltshell.hxx4
-rw-r--r--sw/source/filter/inc/msfilter.hxx2
-rw-r--r--sw/source/filter/ww8/writerhelper.cxx8
-rw-r--r--sw/source/filter/ww8/writerwordglue.cxx1
-rw-r--r--sw/source/filter/ww8/wrtw8sty.cxx11
-rw-r--r--sw/source/filter/ww8/wrtww8.hxx4
-rw-r--r--sw/source/filter/ww8/ww8glsy.cxx3
-rw-r--r--sw/source/filter/ww8/ww8glsy.hxx5
-rw-r--r--sw/source/filter/ww8/ww8graf.cxx4
-rw-r--r--sw/source/filter/ww8/ww8par.cxx10
-rw-r--r--sw/source/filter/ww8/ww8par5.cxx3
-rw-r--r--sw/source/filter/ww8/ww8scan.cxx21
-rw-r--r--sw/source/filter/ww8/ww8scan.hxx12
-rw-r--r--sw/source/filter/ww8/ww8toolbar.cxx6
-rw-r--r--sw/source/filter/ww8/ww8toolbar.hxx4
-rw-r--r--sw/source/filter/xml/XMLRedlineImportHelper.cxx14
-rw-r--r--sw/source/filter/xml/xmlbrsh.cxx1
-rw-r--r--sw/source/filter/xml/xmlbrshi.hxx2
-rw-r--r--sw/source/filter/xml/xmlfmt.cxx29
-rw-r--r--sw/source/uibase/config/usrpref.cxx1
-rw-r--r--sw/source/uibase/dialog/SwSpellDialogChildWindow.cxx13
-rw-r--r--sw/source/uibase/dochdl/gloshdl.cxx32
-rw-r--r--sw/source/uibase/inc/content.hxx3
-rw-r--r--sw/source/uibase/inc/gloshdl.hxx3
-rw-r--r--sw/source/uibase/inc/swtablerep.hxx4
-rw-r--r--sw/source/uibase/inc/uiitems.hxx6
-rw-r--r--sw/source/uibase/inc/usrpref.hxx2
-rw-r--r--sw/source/uibase/table/swtablerep.cxx3
-rw-r--r--sw/source/uibase/utlui/content.cxx25
-rw-r--r--sw/source/uibase/utlui/initui.cxx3
-rw-r--r--sw/source/uibase/utlui/uiitems.cxx3
60 files changed, 219 insertions, 299 deletions
diff --git a/sw/inc/fmtinfmt.hxx b/sw/inc/fmtinfmt.hxx
index 347a366a4326..db8606322bc2 100644
--- a/sw/inc/fmtinfmt.hxx
+++ b/sw/inc/fmtinfmt.hxx
@@ -21,6 +21,7 @@
#include <svl/poolitem.hxx>
#include "swdllapi.h"
+#include <memory>
class SvxMacro;
class SvxMacroTableDtor;
@@ -38,7 +39,7 @@ class SW_DLLPUBLIC SwFormatINetFormat: public SfxPoolItem
OUString msINetFormatName;
OUString msVisitedFormatName;
OUString msHyperlinkName; ///< Name of the link.
- SvxMacroTableDtor* mpMacroTable;
+ std::unique_ptr<SvxMacroTableDtor> mpMacroTable;
SwTextINetFormat* mpTextAttr; ///< My TextAttribute.
sal_uInt16 mnINetFormatId;
sal_uInt16 mnVisitedFormatId;
@@ -126,7 +127,7 @@ public:
void SetMacroTable( const SvxMacroTableDtor* pTable );
const SvxMacroTableDtor* GetMacroTable() const
{
- return mpMacroTable;
+ return mpMacroTable.get();
}
/// Macro getter and setter.
diff --git a/sw/inc/shellres.hxx b/sw/inc/shellres.hxx
index 80b9c61cdf14..f324299a69b7 100644
--- a/sw/inc/shellres.hxx
+++ b/sw/inc/shellres.hxx
@@ -84,7 +84,7 @@ struct SW_DLLPUBLIC ShellResource : public Resource
private:
void GetAutoFormatNameLst_() const;
- mutable std::vector<OUString> *pAutoFormatNameLst;
+ mutable std::unique_ptr<std::vector<OUString>> pAutoFormatNameLst;
OUString sPageDescFirstName;
OUString sPageDescFollowName;
OUString sPageDescName;
diff --git a/sw/inc/undobj.hxx b/sw/inc/undobj.hxx
index fedc5673f4b9..284e3160d26b 100644
--- a/sw/inc/undobj.hxx
+++ b/sw/inc/undobj.hxx
@@ -55,7 +55,7 @@ class SwUndo
protected:
bool bCacheComment;
- mutable OUString * pComment;
+ mutable std::unique_ptr<OUString> pComment;
static void RemoveIdxFromSection( SwDoc&, sal_uLong nSttIdx, sal_uLong* pEndIdx = nullptr );
static void RemoveIdxFromRange( SwPaM& rPam, bool bMoveNext );
@@ -150,7 +150,7 @@ class SwUndoSaveContent
{
protected:
- SwHistory* pHistory;
+ std::unique_ptr<SwHistory> pHistory;
// Needed for deletion of content. For Redo content is moved into the
// UndoNodesArray. These methods always create a new node to insert
@@ -202,8 +202,8 @@ public:
void RestoreSection( SwDoc* pDoc, SwNodeIndex* pIdx, sal_uInt16 nSectType );
void RestoreSection( SwDoc* pDoc, const SwNodeIndex& rInsPos );
- const SwHistory* GetHistory() const { return pHistory; }
- SwHistory* GetHistory() { return pHistory; }
+ const SwHistory* GetHistory() const { return pHistory.get(); }
+ SwHistory* GetHistory() { return pHistory.get(); }
};
// This class saves the PaM as sal_uInt16's and is able to restore it
diff --git a/sw/inc/unostyle.hxx b/sw/inc/unostyle.hxx
index 9806d2f79d5f..58bf8c74cb97 100644
--- a/sw/inc/unostyle.hxx
+++ b/sw/inc/unostyle.hxx
@@ -172,7 +172,7 @@ public:
class SwXAutoStylesEnumerator : public cppu::WeakImplHelper< css::container::XEnumeration >,
public SwClient
{
- SwAutoStylesEnumImpl *m_pImpl;
+ std::unique_ptr<SwAutoStylesEnumImpl> m_pImpl;
public:
SwXAutoStylesEnumerator( SwDoc* pDoc, IStyleAccess::SwAutoStyleFamily eFam );
virtual ~SwXAutoStylesEnumerator() override;
diff --git a/sw/source/core/inc/UndoCore.hxx b/sw/source/core/inc/UndoCore.hxx
index fc1792f152ce..4c73adc8ae7d 100644
--- a/sw/source/core/inc/UndoCore.hxx
+++ b/sw/source/core/inc/UndoCore.hxx
@@ -144,7 +144,7 @@ private:
class SwUndoFormatColl : public SwUndo, private SwUndRng
{
OUString aFormatName;
- SwHistory* pHistory;
+ std::unique_ptr<SwHistory> pHistory;
SwFormatColl* pFormatColl;
// for correct <ReDo(..)> and <Repeat(..)>
// boolean, which indicates that the attributes are reseted at the nodes
@@ -181,7 +181,7 @@ public:
*/
virtual SwRewriter GetRewriter() const override;
- SwHistory* GetHistory() { return pHistory; }
+ SwHistory* GetHistory() { return pHistory.get(); }
};
@@ -190,7 +190,7 @@ class SwUndoSetFlyFormat : public SwUndo, public SwClient
SwFrameFormat* pFrameFormat; // saved FlyFormat
SwFrameFormat* pOldFormat;
SwFrameFormat* pNewFormat;
- SfxItemSet* pItemSet; // the re-/ set attributes
+ std::unique_ptr<SfxItemSet> pItemSet; // the re-/ set attributes
sal_uLong nOldNode, nNewNode;
sal_Int32 nOldContent, nNewContent;
sal_uInt16 nOldAnchorTyp, nNewAnchorTyp;
diff --git a/sw/source/core/inc/UndoOverwrite.hxx b/sw/source/core/inc/UndoOverwrite.hxx
index 9bd86d983e31..a573f90b8982 100644
--- a/sw/source/core/inc/UndoOverwrite.hxx
+++ b/sw/source/core/inc/UndoOverwrite.hxx
@@ -34,7 +34,7 @@ namespace utl {
class SwUndoOverwrite: public SwUndo, private SwUndoSaveContent
{
OUString aDelStr, aInsStr;
- SwRedlineSaveDatas* pRedlSaveData;
+ std::unique_ptr<SwRedlineSaveDatas> pRedlSaveData;
sal_uLong nSttNode;
sal_Int32 nSttContent;
bool bInsChar : 1; // no Overwrite, but Insert
diff --git a/sw/source/core/inc/UndoRedline.hxx b/sw/source/core/inc/UndoRedline.hxx
index e4178532bb2c..c839a6d2d1df 100644
--- a/sw/source/core/inc/UndoRedline.hxx
+++ b/sw/source/core/inc/UndoRedline.hxx
@@ -70,7 +70,7 @@ public:
class SwUndoRedlineSort : public SwUndoRedline
{
- SwSortOptions* pOpt;
+ std::unique_ptr<SwSortOptions> pOpt;
sal_uLong nSaveEndNode, nOffset;
sal_Int32 nSaveEndContent;
diff --git a/sw/source/core/inc/UndoTable.hxx b/sw/source/core/inc/UndoTable.hxx
index ed31bde5b16f..90aa8ffc7153 100644
--- a/sw/source/core/inc/UndoTable.hxx
+++ b/sw/source/core/inc/UndoTable.hxx
@@ -124,7 +124,7 @@ public:
class SwUndoAttrTable : public SwUndo
{
sal_uLong nSttNode;
- SaveTable* pSaveTable;
+ std::unique_ptr<SaveTable> pSaveTable;
bool bClearTabCol : 1;
public:
@@ -142,7 +142,7 @@ class SwUndoTableAutoFormat : public SwUndo
{
OUString m_TableStyleName;
sal_uLong nSttNode;
- SaveTable* pSaveTable;
+ std::unique_ptr<SaveTable> pSaveTable;
std::vector< std::shared_ptr<SwUndoTableNumFormat> > m_Undos;
bool bSaveContentAttr;
sal_uInt16 m_nRepeatHeading;
@@ -164,7 +164,7 @@ using SwUndoSaveSections = std::vector<std::unique_ptr<SwUndoSaveSection>>;
class SwUndoTableNdsChg : public SwUndo
{
- SaveTable* pSaveTable;
+ std::unique_ptr<SaveTable> pSaveTable;
std::set<sal_uLong> m_Boxes;
struct BoxMove
{
@@ -306,7 +306,7 @@ public:
class SwUndoCpyTable : public SwUndo
{
- SwUndoDelete* pDel;
+ std::unique_ptr<SwUndoDelete> pDel;
sal_uLong nTableNode;
public:
diff --git a/sw/source/core/txtnode/fmtatr2.cxx b/sw/source/core/txtnode/fmtatr2.cxx
index 51bb40a07fee..df31e6a4d5d5 100644
--- a/sw/source/core/txtnode/fmtatr2.cxx
+++ b/sw/source/core/txtnode/fmtatr2.cxx
@@ -194,18 +194,16 @@ SwFormatINetFormat::SwFormatINetFormat( const SwFormatINetFormat& rAttr )
, msINetFormatName( rAttr.msINetFormatName )
, msVisitedFormatName( rAttr.msVisitedFormatName )
, msHyperlinkName( rAttr.msHyperlinkName )
- , mpMacroTable( nullptr )
, mpTextAttr( nullptr )
, mnINetFormatId( rAttr.mnINetFormatId )
, mnVisitedFormatId( rAttr.mnVisitedFormatId )
{
if ( rAttr.GetMacroTable() )
- mpMacroTable = new SvxMacroTableDtor( *rAttr.GetMacroTable() );
+ mpMacroTable.reset( new SvxMacroTableDtor( *rAttr.GetMacroTable() ) );
}
SwFormatINetFormat::~SwFormatINetFormat()
{
- delete mpMacroTable;
}
bool SwFormatINetFormat::operator==( const SfxPoolItem& rAttr ) const
@@ -223,7 +221,7 @@ bool SwFormatINetFormat::operator==( const SfxPoolItem& rAttr ) const
if( !bRet )
return false;
- const SvxMacroTableDtor* pOther = static_cast<const SwFormatINetFormat&>(rAttr).mpMacroTable;
+ const SvxMacroTableDtor* pOther = static_cast<const SwFormatINetFormat&>(rAttr).mpMacroTable.get();
if( !mpMacroTable )
return ( !pOther || pOther->empty() );
if( !pOther )
@@ -247,19 +245,18 @@ void SwFormatINetFormat::SetMacroTable( const SvxMacroTableDtor* pNewTable )
if( mpMacroTable )
*mpMacroTable = *pNewTable;
else
- mpMacroTable = new SvxMacroTableDtor( *pNewTable );
+ mpMacroTable.reset( new SvxMacroTableDtor( *pNewTable ) );
}
else
{
- delete mpMacroTable;
- mpMacroTable = nullptr;
+ mpMacroTable.reset();
}
}
void SwFormatINetFormat::SetMacro( sal_uInt16 nEvent, const SvxMacro& rMacro )
{
if( !mpMacroTable )
- mpMacroTable = new SvxMacroTableDtor;
+ mpMacroTable.reset( new SvxMacroTableDtor );
mpMacroTable->Insert( nEvent, rMacro );
}
diff --git a/sw/source/core/undo/undel.cxx b/sw/source/core/undo/undel.cxx
index 2b91ad4167f1..9825faf3ecca 100644
--- a/sw/source/core/undo/undel.cxx
+++ b/sw/source/core/undo/undel.cxx
@@ -134,7 +134,7 @@ SwUndoDelete::SwUndoDelete(
}
if( !pHistory )
- pHistory = new SwHistory;
+ pHistory.reset( new SwHistory );
// delete all footnotes for now
const SwPosition *pStt = rPam.Start(),
@@ -196,7 +196,7 @@ SwUndoDelete::SwUndoDelete(
// EndNode needs to be reset. Same for PageDesc and ColBreak.
if( pEndTextNd->HasSwAttrSet() )
{
- SwRegHistory aRegHist( *pEndTextNd, pHistory );
+ SwRegHistory aRegHist( *pEndTextNd, pHistory.get() );
if( SfxItemState::SET == pEndTextNd->GetpSwAttrSet()->GetItemState(
RES_BREAK, false ) )
pEndTextNd->ResetAttr( RES_BREAK );
@@ -357,7 +357,7 @@ SwUndoDelete::SwUndoDelete(
// is a history necessary here at all?
if( pHistory && !pHistory->Count() )
- DELETEZ( pHistory );
+ pHistory.reset();
}
bool SwUndoDelete::SaveContent( const SwPosition* pStt, const SwPosition* pEnd,
@@ -368,7 +368,7 @@ bool SwUndoDelete::SaveContent( const SwPosition* pStt, const SwPosition* pEnd,
if( pSttTextNd )
{
bool bOneNode = nSttNode == nEndNode;
- SwRegHistory aRHst( *pSttTextNd, pHistory );
+ SwRegHistory aRHst( *pSttTextNd, pHistory.get() );
// always save all text atttibutes because of possibly overlapping
// areas of on/off
pHistory->CopyAttr( pSttTextNd->GetpSwpHints(), nNdIdx,
@@ -407,7 +407,7 @@ bool SwUndoDelete::SaveContent( const SwPosition* pStt, const SwPosition* pEnd,
{
SwIndex aEndIdx( pEndTextNd );
nNdIdx = pEnd->nNode.GetIndex();
- SwRegHistory aRHst( *pEndTextNd, pHistory );
+ SwRegHistory aRHst( *pEndTextNd, pHistory.get() );
// always save all text atttibutes because of possibly overlapping
// areas of on/off
@@ -920,14 +920,14 @@ void SwUndoDelete::UndoImpl(::sw::UndoRedoContext & rContext)
{
// if so save the attributes of the others
SwHistory aHstr;
- aHstr.Move( 0, pHistory, m_nSetPos );
+ aHstr.Move( 0, pHistory.get(), m_nSetPos );
pHistory->Rollback(&rDoc);
pHistory->Move( 0, &aHstr );
}
else
{
pHistory->Rollback(&rDoc);
- DELETEZ( pHistory );
+ pHistory.reset();
}
}
}
@@ -984,7 +984,7 @@ void SwUndoDelete::RedoImpl(::sw::UndoRedoContext & rContext)
{
pHistory->SetTmpEnd( pHistory->Count() );
SwHistory aHstr;
- aHstr.Move( 0, pHistory );
+ aHstr.Move( 0, pHistory.get() );
if( m_bDelFullPara )
{
diff --git a/sw/source/core/undo/undobj.cxx b/sw/source/core/undo/undobj.cxx
index 5d0dfb27b4c3..81cad0213685 100644
--- a/sw/source/core/undo/undobj.cxx
+++ b/sw/source/core/undo/undobj.cxx
@@ -185,7 +185,6 @@ bool SwUndo::IsDelBox() const
SwUndo::~SwUndo()
{
- delete pComment;
}
class UndoRedoRedlineGuard
@@ -266,7 +265,7 @@ OUString SwUndo::GetComment() const
{
if (! pComment)
{
- pComment = new OUString(SW_RES(UNDO_BASE + GetId()));
+ pComment.reset( new OUString(SW_RES(UNDO_BASE + GetId())) );
SwRewriter aRewriter = GetRewriter();
@@ -305,7 +304,6 @@ SwUndoSaveContent::SwUndoSaveContent()
SwUndoSaveContent::~SwUndoSaveContent()
{
- delete pHistory;
}
// This is needed when deleting content. For REDO all contents will be moved
@@ -504,7 +502,7 @@ void SwUndoSaveContent::DelContentIndex( const SwPosition& rMark,
// deleted in the DTOR of SwFootnote!
SwTextNode* pTextNd = const_cast<SwTextNode*>(static_cast<const SwTextNode*>(pFootnoteNd));
if( !pHistory )
- pHistory = new SwHistory;
+ pHistory.reset( new SwHistory );
SwTextAttr* const pFootnoteHint =
pTextNd->GetTextAttrForCharAt( nFootnoteSttIdx );
assert(pFootnoteHint);
@@ -529,7 +527,7 @@ void SwUndoSaveContent::DelContentIndex( const SwPosition& rMark,
// deleted in the DTOR of SwFootnote!
SwTextNode* pTextNd = const_cast<SwTextNode*>(static_cast<const SwTextNode*>(pFootnoteNd));
if( !pHistory )
- pHistory = new SwHistory;
+ pHistory.reset( new SwHistory );
SwTextAttr* const pFootnoteHint =
pTextNd->GetTextAttrForCharAt( nFootnoteSttIdx );
assert(pFootnoteHint);
@@ -567,7 +565,7 @@ void SwUndoSaveContent::DelContentIndex( const SwPosition& rMark,
: ( *pStt <= *pAPos && *pAPos < *pEnd )) )
{
if( !pHistory )
- pHistory = new SwHistory;
+ pHistory.reset( new SwHistory );
SwTextNode *const pTextNd =
pAPos->nNode.GetNode().GetTextNode();
SwTextAttr* const pFlyHint = pTextNd->GetTextAttrForCharAt(
@@ -599,7 +597,7 @@ void SwUndoSaveContent::DelContentIndex( const SwPosition& rMark,
if (bTmp)
{
if( !pHistory )
- pHistory = new SwHistory;
+ pHistory.reset( new SwHistory );
// Moving the anchor?
if( !( DelContentType::CheckNoCntnt & nDelContentType ) &&
@@ -631,7 +629,7 @@ void SwUndoSaveContent::DelContentIndex( const SwPosition& rMark,
( pStt->nNode <= pAPos->nNode && pAPos->nNode <= pEnd->nNode ) )
{
if( !pHistory )
- pHistory = new SwHistory;
+ pHistory.reset( new SwHistory );
if (IsDestroyFrameAnchoredAtChar(
*pAPos, *pStt, *pEnd, pDoc, nDelContentType))
{
@@ -662,7 +660,7 @@ void SwUndoSaveContent::DelContentIndex( const SwPosition& rMark,
pStt->nNode == pAPos->nNode )
{
if( !pHistory )
- pHistory = new SwHistory;
+ pHistory.reset( new SwHistory );
pHistory->Add( *static_cast<SwFlyFrameFormat *>(pFormat), nChainInsPos );
@@ -781,7 +779,7 @@ void SwUndoSaveContent::DelContentIndex( const SwPosition& rMark,
if( IDocumentMarkAccess::GetType(*pBkmk) != IDocumentMarkAccess::MarkType::UNO_BOOKMARK )
{
if( !pHistory )
- pHistory = new SwHistory;
+ pHistory.reset( new SwHistory );
pHistory->Add( *pBkmk, bSavePos, bSaveOtherPos );
}
if ( bSavePos
diff --git a/sw/source/core/undo/undobj1.cxx b/sw/source/core/undo/undobj1.cxx
index 73556ba96eb6..331470225d06 100644
--- a/sw/source/core/undo/undobj1.cxx
+++ b/sw/source/core/undo/undobj1.cxx
@@ -459,7 +459,6 @@ SwRewriter SwUndoSetFlyFormat::GetRewriter() const
SwUndoSetFlyFormat::~SwUndoSetFlyFormat()
{
- delete pItemSet;
}
void SwUndoSetFlyFormat::DeRegisterFromFormat( SwFormat& rFormat )
diff --git a/sw/source/core/undo/unfmco.cxx b/sw/source/core/undo/unfmco.cxx
index 5aeaf87e70d5..7af6718bdf60 100644
--- a/sw/source/core/undo/unfmco.cxx
+++ b/sw/source/core/undo/unfmco.cxx
@@ -43,7 +43,6 @@ SwUndoFormatColl::SwUndoFormatColl( const SwPaM& rRange,
SwUndoFormatColl::~SwUndoFormatColl()
{
- delete pHistory;
}
void SwUndoFormatColl::UndoImpl(::sw::UndoRedoContext & rContext)
diff --git a/sw/source/core/undo/unins.cxx b/sw/source/core/undo/unins.cxx
index 57fc3c0c66c9..ae7abdb72c8e 100644
--- a/sw/source/core/undo/unins.cxx
+++ b/sw/source/core/undo/unins.cxx
@@ -607,7 +607,7 @@ SwUndoReplace::Impl::Impl(
SwTextNode* pNd = pStt->nNode.GetNode().GetTextNode();
OSL_ENSURE( pNd, "Dude, where's my TextNode?" );
- pHistory = new SwHistory;
+ pHistory.reset( new SwHistory );
DelContentIndex( *rPam.GetMark(), *rPam.GetPoint() );
m_nSetPos = pHistory->Count();
@@ -641,8 +641,7 @@ SwUndoReplace::Impl::Impl(
if( !pHistory->Count() )
{
- delete pHistory;
- pHistory = nullptr;
+ pHistory.reset();
}
const sal_Int32 nECnt = m_bSplitNext ? pNd->GetText().getLength()
@@ -719,14 +718,14 @@ void SwUndoReplace::Impl::UndoImpl(::sw::UndoRedoContext & rContext)
{
// than save those attributes as well
SwHistory aHstr;
- aHstr.Move( 0, pHistory, m_nSetPos );
+ aHstr.Move( 0, pHistory.get(), m_nSetPos );
pHistory->Rollback( pDoc );
pHistory->Move( 0, &aHstr );
}
else
{
pHistory->Rollback( pDoc );
- DELETEZ( pHistory );
+ pHistory.reset();
}
}
}
@@ -755,24 +754,24 @@ void SwUndoReplace::Impl::RedoImpl(::sw::UndoRedoContext & rContext)
if( pHistory )
{
- SwHistory* pSave = pHistory;
+ auto pSave = std::move(pHistory);
SwHistory aHst;
- pHistory = &aHst;
+ pHistory.reset( &aHst );
DelContentIndex( *rPam.GetMark(), *rPam.GetPoint() );
m_nSetPos = pHistory->Count();
- pHistory = pSave;
+ pHistory.release();
+ pHistory = std::move(pSave);
pHistory->Move( 0, &aHst );
}
else
{
- pHistory = new SwHistory;
+ pHistory.reset( new SwHistory );
DelContentIndex( *rPam.GetMark(), *rPam.GetPoint() );
m_nSetPos = pHistory->Count();
if( !m_nSetPos )
{
- delete pHistory;
- pHistory = nullptr;
+ pHistory.reset();
}
}
diff --git a/sw/source/core/undo/unmove.cxx b/sw/source/core/undo/unmove.cxx
index a2c0ffb5a283..24f6452b242f 100644
--- a/sw/source/core/undo/unmove.cxx
+++ b/sw/source/core/undo/unmove.cxx
@@ -48,7 +48,7 @@ SwUndoMove::SwUndoMove( const SwPaM& rRange, const SwPosition& rMvPos )
SwTextNode* pTextNd = pDoc->GetNodes()[ nSttNode ]->GetTextNode();
SwTextNode* pEndTextNd = pDoc->GetNodes()[ nEndNode ]->GetTextNode();
- pHistory = new SwHistory;
+ pHistory.reset( new SwHistory );
if( pTextNd )
{
@@ -90,7 +90,7 @@ SwUndoMove::SwUndoMove( const SwPaM& rRange, const SwPosition& rMvPos )
DelFootnote( rRange );
if( pHistory && !pHistory->Count() )
- DELETEZ( pHistory );
+ pHistory.reset();
}
SwUndoMove::SwUndoMove( SwDoc* pDoc, const SwNodeRange& rRg,
@@ -132,7 +132,7 @@ SwUndoMove::SwUndoMove( SwDoc* pDoc, const SwNodeRange& rRg,
DelContentIndex( aMkPos, aPtPos, DelContentType::Ftn );
if( pHistory && !pHistory->Count() )
- DELETEZ( pHistory );
+ pHistory.reset();
}
nFootnoteStt = 0;
@@ -342,8 +342,7 @@ void SwUndoMove::DelFootnote( const SwPaM& rRange )
if( pHistory && !pHistory->Count() )
{
- delete pHistory;
- pHistory = nullptr;
+ pHistory.reset();
}
}
}
diff --git a/sw/source/core/undo/unovwr.cxx b/sw/source/core/undo/unovwr.cxx
index 0f537eaeaa3d..3f2924fb0c13 100644
--- a/sw/source/core/undo/unovwr.cxx
+++ b/sw/source/core/undo/unovwr.cxx
@@ -49,11 +49,10 @@ SwUndoOverwrite::SwUndoOverwrite( SwDoc* pDoc, SwPosition& rPos,
{
SwPaM aPam( rPos.nNode, rPos.nContent.GetIndex(),
rPos.nNode, rPos.nContent.GetIndex()+1 );
- pRedlSaveData = new SwRedlineSaveDatas;
+ pRedlSaveData.reset( new SwRedlineSaveDatas );
if( !FillSaveData( aPam, *pRedlSaveData, false ))
{
- delete pRedlSaveData;
- pRedlSaveData = nullptr;
+ pRedlSaveData.reset();
}
}
@@ -69,8 +68,8 @@ SwUndoOverwrite::SwUndoOverwrite( SwDoc* pDoc, SwPosition& rPos,
{
aDelStr += OUStringLiteral1( pTextNd->GetText()[nSttContent] );
if( !pHistory )
- pHistory = new SwHistory;
- SwRegHistory aRHst( *pTextNd, pHistory );
+ pHistory.reset( new SwHistory );
+ SwRegHistory aRHst( *pTextNd, pHistory.get() );
pHistory->CopyAttr( pTextNd->GetpSwpHints(), nSttNode, 0,
nTextNdLen, false );
++rPos.nContent;
@@ -96,7 +95,6 @@ SwUndoOverwrite::SwUndoOverwrite( SwDoc* pDoc, SwPosition& rPos,
SwUndoOverwrite::~SwUndoOverwrite()
{
- delete pRedlSaveData;
}
bool SwUndoOverwrite::CanGrouping( SwDoc* pDoc, SwPosition& rPos,
diff --git a/sw/source/core/undo/unredln.cxx b/sw/source/core/undo/unredln.cxx
index c5a751a587b7..8684ee77e846 100644
--- a/sw/source/core/undo/unredln.cxx
+++ b/sw/source/core/undo/unredln.cxx
@@ -220,7 +220,6 @@ SwUndoRedlineSort::SwUndoRedlineSort( const SwPaM& rRange,
SwUndoRedlineSort::~SwUndoRedlineSort()
{
- delete pOpt;
}
void SwUndoRedlineSort::UndoRedlineImpl(SwDoc & rDoc, SwPaM & rPam)
diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx
index bd8aa85061c9..3804958cd55b 100644
--- a/sw/source/core/undo/untbl.cxx
+++ b/sw/source/core/undo/untbl.cxx
@@ -102,7 +102,7 @@ class SaveTable
friend class SaveBox;
friend class SaveLine;
SfxItemSet m_aTableSet;
- SaveLine* m_pLine;
+ std::unique_ptr<SaveLine> m_pLine;
const SwTable* m_pSwTable;
SfxItemSets m_aSets;
SwFrameFormatsV m_aFrameFormats;
@@ -195,13 +195,12 @@ struct SwTableToTextSave
sal_uLong m_nSttNd;
sal_uLong m_nEndNd;
sal_Int32 m_nContent;
- SwHistory* m_pHstry;
+ std::unique_ptr<SwHistory> m_pHstry;
// metadata references for first and last paragraph in cell
std::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndoStart;
std::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndoEnd;
SwTableToTextSave( SwDoc& rDoc, sal_uLong nNd, sal_uLong nEndIdx, sal_Int32 nContent );
- ~SwTableToTextSave() { delete m_pHstry; }
private:
SwTableToTextSave(const SwTableToTextSave&) = delete;
@@ -363,7 +362,7 @@ SwTableToTextSave::SwTableToTextSave( SwDoc& rDoc, sal_uLong nNd, sal_uLong nEnd
SwTextNode* pNd = rDoc.GetNodes()[ nNd ]->GetTextNode();
if( pNd )
{
- m_pHstry = new SwHistory;
+ m_pHstry.reset( new SwHistory );
m_pHstry->Add( pNd->GetTextColl(), nNd, SwNodeType::Text );
if ( pNd->GetpSwpHints() )
@@ -376,8 +375,7 @@ SwTableToTextSave::SwTableToTextSave( SwDoc& rDoc, sal_uLong nNd, sal_uLong nEnd
if( !m_pHstry->Count() )
{
- delete m_pHstry;
- m_pHstry = nullptr;
+ m_pHstry.reset();
}
// METADATA: store
@@ -877,9 +875,9 @@ SaveTable::SaveTable( const SwTable& rTable, sal_uInt16 nLnCnt, bool bSaveFormul
m_bModifyBox = false;
m_bNewModel = rTable.IsNewModel();
m_aTableSet.Put(rTable.GetFrameFormat()->GetAttrSet());
- m_pLine = new SaveLine( nullptr, *rTable.GetTabLines()[ 0 ], *this );
+ m_pLine.reset( new SaveLine( nullptr, *rTable.GetTabLines()[ 0 ], *this ) );
- SaveLine* pLn = m_pLine;
+ SaveLine* pLn = m_pLine.get();
if( USHRT_MAX == nLnCnt )
nLnCnt = rTable.GetTabLines().size();
for( sal_uInt16 n = 1; n < nLnCnt; ++n )
@@ -891,7 +889,6 @@ SaveTable::SaveTable( const SwTable& rTable, sal_uInt16 nLnCnt, bool bSaveFormul
SaveTable::~SaveTable()
{
- delete m_pLine;
}
sal_uInt16 SaveTable::AddFormat( SwFrameFormat* pFormat, bool bIsLine )
@@ -961,7 +958,7 @@ void SaveTable::RestoreAttr( SwTable& rTable, bool bMdfyBox )
? rTable.GetTabLines().size()
: m_nLineCount;
- SaveLine* pLn = m_pLine;
+ SaveLine* pLn = m_pLine.get();
for( size_t n = 0; n < nLnCnt; ++n, pLn = pLn->pNext )
{
if( !pLn )
@@ -1378,12 +1375,11 @@ SwUndoAttrTable::SwUndoAttrTable( const SwTableNode& rTableNd, bool bClearTabCol
nSttNode( rTableNd.GetIndex() )
{
bClearTabCol = bClearTabCols;
- pSaveTable = new SaveTable( rTableNd.GetTable() );
+ pSaveTable.reset( new SaveTable( rTableNd.GetTable() ) );
}
SwUndoAttrTable::~SwUndoAttrTable()
{
- delete pSaveTable;
}
void SwUndoAttrTable::UndoImpl(::sw::UndoRedoContext & rContext)
@@ -1396,8 +1392,7 @@ void SwUndoAttrTable::UndoImpl(::sw::UndoRedoContext & rContext)
{
SaveTable* pOrig = new SaveTable( pTableNd->GetTable() );
pSaveTable->RestoreAttr( pTableNd->GetTable() );
- delete pSaveTable;
- pSaveTable = pOrig;
+ pSaveTable.reset( pOrig );
}
if( bClearTabCol )
@@ -1418,7 +1413,7 @@ SwUndoTableAutoFormat::SwUndoTableAutoFormat( const SwTableNode& rTableNd,
, bSaveContentAttr( false )
, m_nRepeatHeading(rTableNd.GetTable().GetRowsToRepeat())
{
- pSaveTable = new SaveTable( rTableNd.GetTable() );
+ pSaveTable.reset( new SaveTable( rTableNd.GetTable() ) );
if( rAFormat.IsFont() || rAFormat.IsJustify() )
{
@@ -1431,7 +1426,6 @@ SwUndoTableAutoFormat::SwUndoTableAutoFormat( const SwTableNode& rTableNd,
SwUndoTableAutoFormat::~SwUndoTableAutoFormat()
{
- delete pSaveTable;
}
void SwUndoTableAutoFormat::SaveBoxContent( const SwTableBox& rBox )
@@ -1471,8 +1465,7 @@ SwUndoTableAutoFormat::UndoRedo(bool const bUndo, ::sw::UndoRedoContext & rConte
}
pSaveTable->RestoreAttr( pTableNd->GetTable(), !bUndo );
- delete pSaveTable;
- pSaveTable = pOrig;
+ pSaveTable.reset( pOrig );
}
void SwUndoTableAutoFormat::UndoImpl(::sw::UndoRedoContext & rContext)
@@ -1499,7 +1492,7 @@ SwUndoTableNdsChg::SwUndoTableNdsChg( SwUndoId nAction,
bSameHeight( bSmHght )
{
const SwTable& rTable = rTableNd.GetTable();
- pSaveTable = new SaveTable( rTable );
+ pSaveTable.reset( new SaveTable( rTable ) );
// and remember selection
ReNewBoxes( rBoxes );
@@ -1517,7 +1510,7 @@ SwUndoTableNdsChg::SwUndoTableNdsChg( SwUndoId nAction,
bSameHeight( false )
{
const SwTable& rTable = rTableNd.GetTable();
- pSaveTable = new SaveTable( rTable );
+ pSaveTable.reset( new SaveTable( rTable ) );
// and remember selection
ReNewBoxes( rBoxes );
@@ -1537,7 +1530,6 @@ void SwUndoTableNdsChg::ReNewBoxes( const SwSelBoxes& rBoxes )
SwUndoTableNdsChg::~SwUndoTableNdsChg()
{
- delete pSaveTable;
}
void SwUndoTableNdsChg::SaveNewBoxes( const SwTableNode& rTableNd,
@@ -2844,7 +2836,6 @@ SwUndoCpyTable::SwUndoCpyTable(const SwDoc* pDoc)
SwUndoCpyTable::~SwUndoCpyTable()
{
- delete pDel;
}
void SwUndoCpyTable::UndoImpl(::sw::UndoRedoContext & rContext)
@@ -2869,14 +2860,13 @@ void SwUndoCpyTable::UndoImpl(::sw::UndoRedoContext & rContext)
}
SwPaM aPam( *pTNd, *pTNd->EndOfSectionNode(), 0 , 1 );
- pDel = new SwUndoDelete( aPam, true );
+ pDel.reset( new SwUndoDelete( aPam, true ) );
}
void SwUndoCpyTable::RedoImpl(::sw::UndoRedoContext & rContext)
{
pDel->UndoImpl(rContext);
- delete pDel;
- pDel = nullptr;
+ pDel.reset();
}
SwUndoSplitTable::SwUndoSplitTable( const SwTableNode& rTableNd,
diff --git a/sw/source/core/undo/untblk.cxx b/sw/source/core/undo/untblk.cxx
index 0dd4d1127f9e..8850ecc322a7 100644
--- a/sw/source/core/undo/untblk.cxx
+++ b/sw/source/core/undo/untblk.cxx
@@ -37,7 +37,7 @@ SwUndoInserts::SwUndoInserts( SwUndoId nUndoId, const SwPaM& rPam )
pTextFormatColl( nullptr ), pLastNdColl(nullptr), pFrameFormats( nullptr ), pRedlData( nullptr ),
bSttWasTextNd( true ), nNdDiff( 0 ), nSetPos( 0 )
{
- pHistory = new SwHistory;
+ pHistory.reset( new SwHistory );
SwDoc* pDoc = rPam.GetDoc();
SwTextNode* pTextNd = rPam.GetPoint()->nNode.GetNode().GetTextNode();
diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx
index fb7078450e43..2ac98b6e9acd 100644
--- a/sw/source/core/unocore/unofield.cxx
+++ b/sw/source/core/unocore/unofield.cxx
@@ -1088,7 +1088,7 @@ struct SwFieldProperties_Impl
double fDouble;
uno::Sequence<beans::PropertyValue> aPropSeq;
uno::Sequence<OUString> aStrings;
- util::DateTime* pDateTime;
+ std::unique_ptr<util::DateTime> pDateTime;
sal_Int32 nSubType;
sal_Int32 nFormat;
@@ -1118,9 +1118,6 @@ struct SwFieldProperties_Impl
bBool3(false),
bBool4(true) //Automatic language
{}
- ~SwFieldProperties_Impl()
- {delete pDateTime;}
-
};
class SwXTextField::Impl
@@ -2277,7 +2274,7 @@ throw (beans::UnknownPropertyException, beans::PropertyVetoException,
case FIELD_PROP_DATE_TIME :
if (!m_pImpl->m_pProps->pDateTime)
- m_pImpl->m_pProps->pDateTime = new util::DateTime;
+ m_pImpl->m_pProps->pDateTime.reset( new util::DateTime );
rValue >>= (*m_pImpl->m_pProps->pDateTime);
break;
case FIELD_PROP_PROP_SEQ:
diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx
index f84ddc7362ef..ee0a421af411 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -3778,7 +3778,6 @@ SwXAutoStylesEnumerator::SwXAutoStylesEnumerator( SwDoc* pDoc, IStyleAccess::SwA
SwXAutoStylesEnumerator::~SwXAutoStylesEnumerator()
{
- delete m_pImpl;
}
void SwXAutoStylesEnumerator::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew)
@@ -3786,8 +3785,7 @@ void SwXAutoStylesEnumerator::Modify( const SfxPoolItem* pOld, const SfxPoolItem
ClientModify(this, pOld, pNew);
if(!GetRegisteredIn())
{
- delete m_pImpl;
- m_pImpl = nullptr;
+ m_pImpl.reset();
}
}
diff --git a/sw/source/filter/basflt/fltshell.cxx b/sw/source/filter/basflt/fltshell.cxx
index e95c8fa7a5a6..803df6aa2aa8 100644
--- a/sw/source/filter/basflt/fltshell.cxx
+++ b/sw/source/filter/basflt/fltshell.cxx
@@ -96,11 +96,11 @@ static OUString lcl_getTypePath(OUString& rType)
SwFltStackEntry::SwFltStackEntry(const SwPosition& rStartPos, SfxPoolItem* pHt)
: m_aMkPos(rStartPos)
, m_aPtPos(rStartPos)
+ , pAttr( pHt ) // store a copy of the attribute
, mnStartCP(-1)
, mnEndCP(-1)
, bIsParaEnd(false)
{
- pAttr = pHt; // store a copy of the attribute
bOld = false; // used for marking Attributes *before* skipping field results
bOpen = true; // lock the attribute --> may first
bConsumedByField = false;
@@ -109,7 +109,6 @@ SwFltStackEntry::SwFltStackEntry(const SwPosition& rStartPos, SfxPoolItem* pHt)
SwFltStackEntry::~SwFltStackEntry()
{
// Although attribute got passed as pointer, it gets deleted here
- delete pAttr;
}
void SwFltStackEntry::SetEndPos(const SwPosition& rEndPos)
@@ -372,15 +371,15 @@ SwFltStackEntry* SwFltControlStack::SetAttr(const SwPosition& rPos,
// query handle
bF = true;
}
- else if (nAttrId == RES_FLTR_BOOKMARK && nHand == static_cast<SwFltBookmark*>(rEntry.pAttr)->GetHandle())
+ else if (nAttrId == RES_FLTR_BOOKMARK && nHand == static_cast<SwFltBookmark*>(rEntry.pAttr.get())->GetHandle())
{
bF = true;
}
- else if (nAttrId == RES_FLTR_ANNOTATIONMARK && nHand == static_cast<CntUInt16Item*>(rEntry.pAttr)->GetValue())
+ else if (nAttrId == RES_FLTR_ANNOTATIONMARK && nHand == static_cast<CntUInt16Item*>(rEntry.pAttr.get())->GetValue())
{
bF = true;
}
- else if (nAttrId == RES_FLTR_RDFMARK && nHand == static_cast<SwFltRDFMark*>(rEntry.pAttr)->GetHandle())
+ else if (nAttrId == RES_FLTR_RDFMARK && nHand == static_cast<SwFltRDFMark*>(rEntry.pAttr.get())->GetHandle())
{
bF = true;
}
@@ -532,7 +531,7 @@ void SwFltControlStack::SetAttrInDoc(const SwPosition& rTmpPos,
{
case RES_FLTR_ANCHOR:
{
- SwFrameFormat* pFormat = static_cast<SwFltAnchor*>(rEntry.pAttr)->GetFrameFormat();
+ SwFrameFormat* pFormat = static_cast<SwFltAnchor*>(rEntry.pAttr.get())->GetFrameFormat();
if (pFormat != nullptr)
{
MakePoint(rEntry, pDoc, aRegion);
@@ -560,7 +559,7 @@ void SwFltControlStack::SetAttrInDoc(const SwPosition& rTmpPos,
case RES_FLTR_NUMRULE: // insert Numrule
{
- const OUString& rNumNm = static_cast<SfxStringItem*>(rEntry.pAttr)->GetValue();
+ const OUString& rNumNm = static_cast<SfxStringItem*>(rEntry.pAttr.get())->GetValue();
SwNumRule* pNumRule = pDoc->FindNumRulePtr( rNumNm );
if( pNumRule )
{
@@ -588,8 +587,8 @@ void SwFltControlStack::SetAttrInDoc(const SwPosition& rTmpPos,
case RES_FLTR_BOOKMARK:
{
- SwFltBookmark* pB = static_cast<SwFltBookmark*>(rEntry.pAttr);
- const OUString& rName = static_cast<SwFltBookmark*>(rEntry.pAttr)->GetName();
+ SwFltBookmark* pB = static_cast<SwFltBookmark*>(rEntry.pAttr.get());
+ const OUString& rName = static_cast<SwFltBookmark*>(rEntry.pAttr.get())->GetName();
if (IsFlagSet(BOOK_TO_VAR_REF))
{
@@ -631,7 +630,7 @@ void SwFltControlStack::SetAttrInDoc(const SwPosition& rTmpPos,
{
if (MakeBookRegionOrPoint(rEntry, pDoc, aRegion, true))
{
- SwFltRDFMark* pMark = static_cast<SwFltRDFMark*>(rEntry.pAttr);
+ SwFltRDFMark* pMark = static_cast<SwFltRDFMark*>(rEntry.pAttr.get());
if (aRegion.GetNode().IsTextNode())
{
SwTextNode& rTextNode = *aRegion.GetNode().GetTextNode();
@@ -657,7 +656,7 @@ void SwFltControlStack::SetAttrInDoc(const SwPosition& rTmpPos,
SwPosition* pPoint = aRegion.GetPoint();
- SwFltTOX* pTOXAttr = static_cast<SwFltTOX*>(rEntry.pAttr);
+ SwFltTOX* pTOXAttr = static_cast<SwFltTOX*>(rEntry.pAttr.get());
// test if on this node there had been a pagebreak BEFORE the
// tox attribute was put on the stack
@@ -702,7 +701,7 @@ void SwFltControlStack::SetAttrInDoc(const SwPosition& rTmpPos,
pDoc->getIDocumentRedlineAccess().SetRedlineFlags( RedlineFlags::On
| RedlineFlags::ShowInsert
| RedlineFlags::ShowDelete );
- SwFltRedline& rFltRedline = *static_cast<SwFltRedline*>(rEntry.pAttr);
+ SwFltRedline& rFltRedline = *static_cast<SwFltRedline*>(rEntry.pAttr.get());
if( USHRT_MAX != rFltRedline.nAutorNoPrev )
{
@@ -780,7 +779,7 @@ SfxPoolItem* SwFltControlStack::GetFormatStackAttr(sal_uInt16 nWhich, sal_uInt16
{
if (pPos)
*pPos = nSize;
- return rEntry.pAttr; // Ok, so stop
+ return rEntry.pAttr.get(); // Ok, so stop
}
}
return nullptr;
@@ -797,7 +796,7 @@ const SfxPoolItem* SwFltControlStack::GetOpenStackAttr(const SwPosition& rPos, s
SwFltStackEntry &rEntry = *m_Entries[--nSize];
if (rEntry.bOpen && rEntry.pAttr->Which() == nWhich && rEntry.m_aMkPos == aFltPos)
{
- return rEntry.pAttr;
+ return rEntry.pAttr.get();
}
}
return nullptr;
@@ -893,20 +892,19 @@ void SwFltControlStack::Delete(const SwPaM &rPam)
SwFltAnchor::SwFltAnchor(SwFrameFormat* pFormat) :
SfxPoolItem(RES_FLTR_ANCHOR), pFrameFormat(pFormat)
{
- pClient = new SwFltAnchorClient(this);
- pFrameFormat->Add(pClient);
+ pClient.reset( new SwFltAnchorClient(this) );
+ pFrameFormat->Add(pClient.get());
}
SwFltAnchor::SwFltAnchor(const SwFltAnchor& rCpy) :
SfxPoolItem(RES_FLTR_ANCHOR), pFrameFormat(rCpy.pFrameFormat)
{
- pClient = new SwFltAnchorClient(this);
- pFrameFormat->Add(pClient);
+ pClient.reset( new SwFltAnchorClient(this) );
+ pFrameFormat->Add(pClient.get());
}
SwFltAnchor::~SwFltAnchor()
{
- delete pClient;
}
void SwFltAnchor::SetFrameFormat(SwFrameFormat * _pFrameFormat)
diff --git a/sw/source/filter/html/htmlatr.cxx b/sw/source/filter/html/htmlatr.cxx
index 286c0b19b415..406a5661e0b3 100644
--- a/sw/source/filter/html/htmlatr.cxx
+++ b/sw/source/filter/html/htmlatr.cxx
@@ -296,8 +296,8 @@ SwHTMLFormatInfo::SwHTMLFormatInfo( const SwFormat *pF, SwDoc *pDoc, SwDoc *pTem
if( pReferenceFormat || nDeep==0 )
{
- pItemSet = new SfxItemSet( *pFormat->GetAttrSet().GetPool(),
- pFormat->GetAttrSet().GetRanges() );
+ pItemSet.reset( new SfxItemSet( *pFormat->GetAttrSet().GetPool(),
+ pFormat->GetAttrSet().GetRanges() ) );
// if the differences to a different style are supposed to be
// written, hard attribute is necessary. This is always true
// for styles that are not derived from HTML-tag styles.
@@ -311,8 +311,7 @@ SwHTMLFormatInfo::SwHTMLFormatInfo( const SwFormat *pF, SwDoc *pDoc, SwDoc *pTem
// later on
if( !pItemSet->Count() )
{
- delete pItemSet;
- pItemSet = nullptr;
+ pItemSet.reset();
}
}
@@ -361,8 +360,8 @@ SwHTMLFormatInfo::SwHTMLFormatInfo( const SwFormat *pF, SwDoc *pDoc, SwDoc *pTem
if( rSet != rRef )
{
if( !pItemSet )
- pItemSet = new SfxItemSet( *pFormat->GetAttrSet().GetPool(),
- pFormat->GetAttrSet().GetRanges() );
+ pItemSet.reset( new SfxItemSet( *pFormat->GetAttrSet().GetPool(),
+ pFormat->GetAttrSet().GetRanges() ) );
pItemSet->Put( rSet );
}
}
@@ -391,8 +390,8 @@ SwHTMLFormatInfo::SwHTMLFormatInfo( const SwFormat *pF, SwDoc *pDoc, SwDoc *pTem
if( eLang != eDfltLang )
{
if( !pItemSet )
- pItemSet = new SfxItemSet( *pFormat->GetAttrSet().GetPool(),
- pFormat->GetAttrSet().GetRanges() );
+ pItemSet.reset( new SfxItemSet( *pFormat->GetAttrSet().GetPool(),
+ pFormat->GetAttrSet().GetRanges() ) );
pItemSet->Put( rLang );
}
@@ -408,8 +407,8 @@ SwHTMLFormatInfo::SwHTMLFormatInfo( const SwFormat *pF, SwDoc *pDoc, SwDoc *pTem
if( rTmpLang.GetLanguage() != eLang )
{
if( !pItemSet )
- pItemSet = new SfxItemSet( *pFormat->GetAttrSet().GetPool(),
- pFormat->GetAttrSet().GetRanges() );
+ pItemSet.reset( new SfxItemSet( *pFormat->GetAttrSet().GetPool(),
+ pFormat->GetAttrSet().GetRanges() ) );
pItemSet->Put( rTmpLang );
}
}
@@ -419,7 +418,6 @@ SwHTMLFormatInfo::SwHTMLFormatInfo( const SwFormat *pF, SwDoc *pDoc, SwDoc *pTem
SwHTMLFormatInfo::~SwHTMLFormatInfo()
{
- delete pItemSet;
}
void OutHTML_SwFormat( Writer& rWrt, const SwFormat& rFormat,
@@ -1027,14 +1025,14 @@ class HTMLStartEndPos
{
sal_Int32 nStart;
sal_Int32 nEnd;
- SfxPoolItem* pItem;
+ std::unique_ptr<SfxPoolItem> pItem;
public:
HTMLStartEndPos( const SfxPoolItem& rItem, sal_Int32 nStt, sal_Int32 nE );
~HTMLStartEndPos();
- const SfxPoolItem *GetItem() const { return pItem; }
+ const SfxPoolItem *GetItem() const { return pItem.get(); }
void SetStart( sal_Int32 nStt ) { nStart = nStt; }
sal_Int32 GetStart() const { return nStart; }
@@ -1052,7 +1050,6 @@ HTMLStartEndPos::HTMLStartEndPos( const SfxPoolItem& rItem, sal_Int32 nStt,
HTMLStartEndPos::~HTMLStartEndPos()
{
- delete pItem;
}
typedef std::vector<HTMLStartEndPos *> HTMLStartEndPositions;
diff --git a/sw/source/filter/html/htmlfld.cxx b/sw/source/filter/html/htmlfld.cxx
index 282a1d6c7535..15e3d4b3f273 100644
--- a/sw/source/filter/html/htmlfld.cxx
+++ b/sw/source/filter/html/htmlfld.cxx
@@ -624,7 +624,7 @@ void SwHTMLParser::InsertComment( const OUString& rComment, const sal_Char *pTag
break;
if( RES_TXTATR_FIELD == pAttr->pItem->Which() &&
- RES_SCRIPTFLD == static_cast<const SwFormatField *>(pAttr->pItem)->GetField()->GetTyp()->Which() )
+ RES_SCRIPTFLD == static_cast<const SwFormatField *>(pAttr->pItem.get())->GetField()->GetTyp()->Which() )
{
bMoveFwd = false;
break;
diff --git a/sw/source/filter/html/htmltab.cxx b/sw/source/filter/html/htmltab.cxx
index 94e4dc9e7435..3b3faa062f6f 100644
--- a/sw/source/filter/html/htmltab.cxx
+++ b/sw/source/filter/html/htmltab.cxx
@@ -107,7 +107,7 @@ class HTMLTableContext
SwTableNode *pTableNd; // table node
SwFrameFormat *pFrameFormat; // der Fly frame::Frame, containing the table
- SwPosition *pPos; // position behind the table
+ std::unique_ptr<SwPosition> pPos; // position behind the table
size_t nContextStAttrMin;
size_t nContextStMin;
@@ -145,7 +145,7 @@ public:
void SavePREListingXMP( SwHTMLParser& rParser );
void RestorePREListingXMP( SwHTMLParser& rParser );
- SwPosition *GetPos() const { return pPos; }
+ SwPosition *GetPos() const { return pPos.get(); }
void SetTableNode( SwTableNode *pNd ) { pTableNd = pNd; }
SwTableNode *GetTableNode() const { return pTableNd; }
@@ -2715,7 +2715,6 @@ void HTMLTable::MakeParentContents()
HTMLTableContext::~HTMLTableContext()
{
- delete pPos;
}
void HTMLTableContext::SavePREListingXMP( SwHTMLParser& rParser )
@@ -3026,7 +3025,7 @@ class CellSaveStruct : public SectionSaveStruct
HTMLTableCnts* m_pCnts; // Liste aller Inhalte
HTMLTableCnts* m_pCurrCnts; // der aktuelle Inhalt oder 0
- SwNodeIndex *m_pNoBreakEndNodeIndex;// Absatz-Index eines </NOBR>
+ std::unique_ptr<SwNodeIndex> m_pNoBreakEndNodeIndex;// Absatz-Index eines </NOBR>
double m_nValue;
@@ -3051,8 +3050,6 @@ public:
CellSaveStruct( SwHTMLParser& rParser, HTMLTable *pCurTable, bool bHd,
bool bReadOpt );
- virtual ~CellSaveStruct() override;
-
void AddContents( HTMLTableCnts *pNewCnts );
HTMLTableCnts *GetFirstContents() { return m_pCnts; }
@@ -3222,11 +3219,6 @@ CellSaveStruct::CellSaveStruct( SwHTMLParser& rParser, HTMLTable *pCurTable,
rParser.PushContext( pCntxt );
}
-CellSaveStruct::~CellSaveStruct()
-{
- delete m_pNoBreakEndNodeIndex;
-}
-
void CellSaveStruct::AddContents( HTMLTableCnts *pNewCnts )
{
if( m_pCnts )
@@ -3295,8 +3287,7 @@ void CellSaveStruct::EndNoBreak( const SwPosition& rPos )
{
if( m_bNoBreak )
{
- delete m_pNoBreakEndNodeIndex;
- m_pNoBreakEndNodeIndex = new SwNodeIndex( rPos.nNode );
+ m_pNoBreakEndNodeIndex.reset( new SwNodeIndex( rPos.nNode ) );
m_nNoBreakEndContentPos = rPos.nContent.GetIndex();
m_bNoBreak = false;
}
diff --git a/sw/source/filter/html/swhtml.cxx b/sw/source/filter/html/swhtml.cxx
index 9b4fac0e3d48..6c927f430fd3 100644
--- a/sw/source/filter/html/swhtml.cxx
+++ b/sw/source/filter/html/swhtml.cxx
@@ -2808,7 +2808,7 @@ void SwHTMLParser::SetAttr_( bool bChkEnd, bool bBeforeTable,
{
case RES_FLTR_BOOKMARK: // insert bookmark
{
- const OUString sName( static_cast<SfxStringItem*>(pAttr->pItem)->GetValue() );
+ const OUString sName( static_cast<SfxStringItem*>(pAttr->pItem.get())->GetValue() );
IDocumentMarkAccess* const pMarkAccess = m_pDoc->getIDocumentMarkAccess();
IDocumentMarkAccess::const_iterator_t ppBkmk = pMarkAccess->findMark( sName );
if( ppBkmk != pMarkAccess->getAllMarksEnd() &&
@@ -2834,7 +2834,7 @@ void SwHTMLParser::SetAttr_( bool bChkEnd, bool bBeforeTable,
{
sal_uInt16 nFieldWhich =
pPostIts
- ? static_cast<const SwFormatField *>(pAttr->pItem)->GetField()->GetTyp()->Which()
+ ? static_cast<const SwFormatField *>(pAttr->pItem.get())->GetField()->GetTyp()->Which()
: 0;
if( pPostIts && (RES_POSTITFLD == nFieldWhich ||
RES_SCRIPTFLD == nFieldWhich) )
@@ -2882,7 +2882,7 @@ void SwHTMLParser::SetAttr_( bool bChkEnd, bool bBeforeTable,
// ggfs. ein Bookmark anspringen
if( RES_TXTATR_INETFMT == nWhich &&
JUMPTO_MARK == m_eJumpTo &&
- m_sJmpMark == static_cast<SwFormatINetFormat*>(pAttr->pItem)->GetName() )
+ m_sJmpMark == static_cast<SwFormatINetFormat*>(pAttr->pItem.get())->GetName() )
{
m_bChkJumpMark = true;
m_eJumpTo = JUMPTO_NONE;
@@ -5427,11 +5427,11 @@ HTMLAttr::HTMLAttr( const SwPosition& rPos, const SfxPoolItem& rItem,
bInsAtStart( true ),
bLikePara( false ),
bValid( true ),
+ pItem( rItem.Clone() ),
pNext( nullptr ),
pPrev( nullptr ),
ppHead( ppHd )
{
- pItem = rItem.Clone();
}
HTMLAttr::HTMLAttr( const HTMLAttr &rAttr, const SwNodeIndex &rEndPara,
@@ -5443,16 +5443,15 @@ HTMLAttr::HTMLAttr( const HTMLAttr &rAttr, const SwNodeIndex &rEndPara,
bInsAtStart( rAttr.bInsAtStart ),
bLikePara( rAttr.bLikePara ),
bValid( rAttr.bValid ),
+ pItem( rAttr.pItem->Clone() ),
pNext( nullptr ),
pPrev( nullptr ),
ppHead( ppHd )
{
- pItem = rAttr.pItem->Clone();
}
HTMLAttr::~HTMLAttr()
{
- delete pItem;
}
HTMLAttr *HTMLAttr::Clone(const SwNodeIndex& rEndPara, sal_Int32 nEndCnt) const
diff --git a/sw/source/filter/html/swhtml.hxx b/sw/source/filter/html/swhtml.hxx
index 6ef39ce7dd88..7b57351e6f47 100644
--- a/sw/source/filter/html/swhtml.hxx
+++ b/sw/source/filter/html/swhtml.hxx
@@ -80,7 +80,7 @@ class HTMLAttr
bool bLikePara : 1; // Attribut ueber dem gesamten Absatz setzen
bool bValid : 1; // ist das Attribut gueltig?
- SfxPoolItem* pItem;
+ std::unique_ptr<SfxPoolItem> pItem;
HTMLAttr *pNext; // noch zu schliessene Attrs mit unterschiedl. Werten
HTMLAttr *pPrev; // bereits geschlossene aber noch nicht gesetze Attrs
HTMLAttr **ppHead; // der Listenkopf
diff --git a/sw/source/filter/html/wrthtml.cxx b/sw/source/filter/html/wrthtml.cxx
index 64631a56a396..bdc9f0ad50a7 100644
--- a/sw/source/filter/html/wrthtml.cxx
+++ b/sw/source/filter/html/wrthtml.cxx
@@ -157,7 +157,6 @@ SwHTMLWriter::SwHTMLWriter( const OUString& rBaseURL )
SwHTMLWriter::~SwHTMLWriter()
{
- delete m_pNumRuleInfo;
}
void SwHTMLWriter::SetupFilterOptions(SfxMedium& rMedium)
diff --git a/sw/source/filter/html/wrthtml.hxx b/sw/source/filter/html/wrthtml.hxx
index 7694b179f295..794027f0f05e 100644
--- a/sw/source/filter/html/wrthtml.hxx
+++ b/sw/source/filter/html/wrthtml.hxx
@@ -211,7 +211,7 @@ struct SwHTMLFormatInfo
OString aToken; // das auszugebende Token
OUString aClass; // die auszugebende Klasse
- SfxItemSet *pItemSet; // der auszugebende Attribut-Set
+ std::unique_ptr<SfxItemSet> pItemSet; // der auszugebende Attribut-Set
sal_Int32 nLeftMargin; // ein par default-Werte fuer
sal_Int32 nRightMargin; // Absatz-Vorlagen
@@ -256,7 +256,7 @@ class IDocumentStylePoolAccess;
class SwHTMLWriter : public Writer
{
SwHTMLPosFlyFrames *m_pHTMLPosFlyFrames;
- SwHTMLNumRuleInfo *m_pNumRuleInfo;// aktuelle Numerierung
+ std::unique_ptr<SwHTMLNumRuleInfo> m_pNumRuleInfo;// aktuelle Numerierung
SwHTMLNumRuleInfo *m_pNextNumRuleInfo;
sal_uInt32 m_nHTMLMode; // Beschreibung der Export-Konfiguration
diff --git a/sw/source/filter/inc/fltshell.hxx b/sw/source/filter/inc/fltshell.hxx
index 702e12f5792e..4ba7b72c7eac 100644
--- a/sw/source/filter/inc/fltshell.hxx
+++ b/sw/source/filter/inc/fltshell.hxx
@@ -97,7 +97,7 @@ public:
SwFltPosition m_aMkPos;
SwFltPosition m_aPtPos;
- SfxPoolItem * pAttr;// Format Attribute
+ std::unique_ptr<SfxPoolItem> pAttr;// Format Attribute
bool bOld; // to mark Attributes *before* skipping field results
bool bOpen; //Entry open, awaiting being closed
@@ -193,7 +193,7 @@ class SwFltAnchorClient;
class SW_DLLPUBLIC SwFltAnchor : public SfxPoolItem
{
SwFrameFormat* pFrameFormat;
- SwFltAnchorClient * pClient;
+ std::unique_ptr<SwFltAnchorClient> pClient;
public:
SwFltAnchor(SwFrameFormat* pFlyFormat);
diff --git a/sw/source/filter/inc/msfilter.hxx b/sw/source/filter/inc/msfilter.hxx
index 3710424fba00..bc9f26fbd71e 100644
--- a/sw/source/filter/inc/msfilter.hxx
+++ b/sw/source/filter/inc/msfilter.hxx
@@ -239,7 +239,7 @@ namespace sw
{
private:
//I hate these things stupid pImpl things, but its warranted here
- ::myImplHelpers::StyleMapperImpl<SwCharFormat> *mpImpl;
+ std::unique_ptr<::myImplHelpers::StyleMapperImpl<SwCharFormat>> mpImpl;
public:
explicit CharStyleMapper(SwDoc &rDoc);
~CharStyleMapper();
diff --git a/sw/source/filter/ww8/writerhelper.cxx b/sw/source/filter/ww8/writerhelper.cxx
index 9c0139e78661..996711a1f11a 100644
--- a/sw/source/filter/ww8/writerhelper.cxx
+++ b/sw/source/filter/ww8/writerhelper.cxx
@@ -729,7 +729,7 @@ namespace sw
bool operator()(const SwFltStackEntry *pEntry) const
{
const SwFltRedline *pTest = static_cast<const SwFltRedline *>
- (pEntry->pAttr);
+ (pEntry->pAttr.get());
return (pEntry->bOpen && (pTest->eType == meType));
}
};
@@ -817,7 +817,7 @@ namespace sw
mrDoc.getIDocumentRedlineAccess().SetRedlineFlags(RedlineFlags::On | RedlineFlags::ShowInsert |
RedlineFlags::ShowDelete);
const SwFltRedline *pFltRedline = static_cast<const SwFltRedline*>
- (pEntry->pAttr);
+ (pEntry->pAttr.get());
if (USHRT_MAX != pFltRedline->nAutorNoPrev)
{
@@ -847,9 +847,9 @@ namespace sw
const SwFltStackEntry *pTwoE) const
{
const SwFltRedline *pOne= static_cast<const SwFltRedline*>
- (pOneE->pAttr);
+ (pOneE->pAttr.get());
const SwFltRedline *pTwo= static_cast<const SwFltRedline*>
- (pTwoE->pAttr);
+ (pTwoE->pAttr.get());
//Return the earlier time, if two have the same time, prioritize
//inserts over deletes
diff --git a/sw/source/filter/ww8/writerwordglue.cxx b/sw/source/filter/ww8/writerwordglue.cxx
index 7e64c7f3fc64..b9fbd570fac0 100644
--- a/sw/source/filter/ww8/writerwordglue.cxx
+++ b/sw/source/filter/ww8/writerwordglue.cxx
@@ -475,7 +475,6 @@ namespace sw
CharStyleMapper::~CharStyleMapper()
{
- delete mpImpl;
}
CharStyleMapper::StyleResult CharStyleMapper::GetStyle(
diff --git a/sw/source/filter/ww8/wrtw8sty.cxx b/sw/source/filter/ww8/wrtw8sty.cxx
index 0b139cf3ac2d..23a7122890e4 100644
--- a/sw/source/filter/ww8/wrtw8sty.cxx
+++ b/sw/source/filter/ww8/wrtw8sty.cxx
@@ -155,8 +155,8 @@ MSWordStyles::MSWordStyles( MSWordExportBase& rExport, bool bListStyles )
(bListStyles ? m_rExport.m_pDoc->GetNumRuleTable().size() - 1 : 0);
// somewhat generous ( free for up to 15 )
- m_pFormatA = new SwFormat*[ nAlloc ];
- memset( m_pFormatA, 0, nAlloc * sizeof( SwFormat* ) );
+ m_pFormatA.reset( new SwFormat*[ nAlloc ] );
+ memset( m_pFormatA.get(), 0, nAlloc * sizeof( SwFormat* ) );
memset( m_aHeadingParagraphStyles, -1 , MAXLEVEL * sizeof( sal_uInt16));
BuildStylesTable();
@@ -165,7 +165,6 @@ MSWordStyles::MSWordStyles( MSWordExportBase& rExport, bool bListStyles )
MSWordStyles::~MSWordStyles()
{
- delete[] m_pFormatA;
}
// Sty_SetWWSlot() dependencies for the styles -> zero is allowed
@@ -1029,7 +1028,6 @@ MSWordSections::~MSWordSections()
WW8_WrPlcSepx::~WW8_WrPlcSepx()
{
- delete pTextPos;
}
bool MSWordSections::HeaderFooterWritten()
@@ -1763,7 +1761,7 @@ bool WW8_WrPlcSepx::WriteKFText( WW8Export& rWrt )
sal_uLong nCpStart = rWrt.Fc2Cp( rWrt.Strm().Tell() );
OSL_ENSURE( !pTextPos, "who set the pointer?" );
- pTextPos = new WW8_WrPlc0( nCpStart );
+ pTextPos.reset( new WW8_WrPlc0( nCpStart ) );
WriteFootnoteEndText( rWrt, nCpStart );
CheckForFacinPg( rWrt );
@@ -1803,8 +1801,7 @@ bool WW8_WrPlcSepx::WriteKFText( WW8Export& rWrt )
}
else
{
- delete pTextPos;
- pTextPos = nullptr;
+ pTextPos.reset();
}
return rWrt.pFib->m_ccpHdr != 0;
diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx
index b5e649b0cee6..6cbb890ab07f 100644
--- a/sw/source/filter/ww8/wrtww8.hxx
+++ b/sw/source/filter/ww8/wrtww8.hxx
@@ -239,7 +239,7 @@ class WW8_WrPlcSepx : public MSWordSections
std::vector< std::shared_ptr<WW8_PdAttrDesc> > m_SectionAttributes;
// hack to prevent adding sections in endnotes
bool m_bHeaderFooterWritten;
- WW8_WrPlc0* pTextPos; // Position of the headers/footers
+ std::unique_ptr<WW8_WrPlc0> pTextPos; // Position of the headers/footers
WW8_WrPlcSepx( const WW8_WrPlcSepx& ) = delete;
WW8_WrPlcSepx& operator=( const WW8_WrPlcSepx& ) = delete;
@@ -1514,7 +1514,7 @@ class MSWordStyles
{
MSWordExportBase& m_rExport;
sal_uInt16 m_aHeadingParagraphStyles[MAXLEVEL];
- SwFormat** m_pFormatA; ///< Slot <-> Character and paragraph style array (0 for list styles).
+ std::unique_ptr<SwFormat*[]> m_pFormatA; ///< Slot <-> Character and paragraph style array (0 for list styles).
sal_uInt16 m_nUsedSlots;
bool m_bListStyles; ///< If list styles are requested to be exported as well.
std::map<sal_uInt16, const SwNumRule*> m_aNumRules; ///< Slot <-> List style map.
diff --git a/sw/source/filter/ww8/ww8glsy.cxx b/sw/source/filter/ww8/ww8glsy.cxx
index c80a26082796..24a13480f100 100644
--- a/sw/source/filter/ww8/ww8glsy.cxx
+++ b/sw/source/filter/ww8/ww8glsy.cxx
@@ -48,8 +48,7 @@ WW8Glossary::WW8Glossary(tools::SvRef<SotStorageStream> &refStrm, sal_uInt8 nVer
if (xTableStream.Is() && SVSTREAM_OK == xTableStream->GetError())
{
xTableStream->SetEndian(SvStreamEndian::LITTLE);
- pGlossary =
- new WW8GlossaryFib(*refStrm, nVersion, *xTableStream, aWwFib);
+ pGlossary.reset( new WW8GlossaryFib(*refStrm, nVersion, *xTableStream, aWwFib) );
}
}
}
diff --git a/sw/source/filter/ww8/ww8glsy.hxx b/sw/source/filter/ww8/ww8glsy.hxx
index abd9518015ef..117e66d3cb8a 100644
--- a/sw/source/filter/ww8/ww8glsy.hxx
+++ b/sw/source/filter/ww8/ww8glsy.hxx
@@ -59,12 +59,11 @@ class WW8Glossary
public:
WW8Glossary( tools::SvRef<SotStorageStream> &refStrm, sal_uInt8 nVersion, SotStorage *pStg);
bool Load( SwTextBlocks &rBlocks, bool bSaveRelFile );
- ~WW8Glossary() { delete pGlossary; }
- WW8GlossaryFib *GetFib() { return pGlossary; }
+ WW8GlossaryFib *GetFib() { return pGlossary.get(); }
sal_uInt16 GetNoStrings() const { return nStrings; }
private:
- WW8GlossaryFib *pGlossary;
+ std::unique_ptr<WW8GlossaryFib> pGlossary;
tools::SvRef<SotStorageStream> xTableStream;
tools::SvRef<SotStorageStream> &rStrm;
tools::SvRef<SotStorage> xStg;
diff --git a/sw/source/filter/ww8/ww8graf.cxx b/sw/source/filter/ww8/ww8graf.cxx
index 53d782b2e5e7..3bd74491fcbf 100644
--- a/sw/source/filter/ww8/ww8graf.cxx
+++ b/sw/source/filter/ww8/ww8graf.cxx
@@ -650,7 +650,7 @@ void SwWW8ImplReader::InsertAttrsAsDrawingAttrs(long nStartCp, long nEndCp,
OUString sURL;
for (size_t nI = m_pCtrlStck->size(); nI > nCount; --nI)
{
- const SfxPoolItem *pItem = ((*m_pCtrlStck)[nI-1]).pAttr;
+ const SfxPoolItem *pItem = ((*m_pCtrlStck)[nI-1]).pAttr.get();
sal_uInt16 nWhich = pItem->Which();
if (nWhich == RES_TXTATR_INETFMT)
{
@@ -686,7 +686,7 @@ void SwWW8ImplReader::InsertAttrsAsDrawingAttrs(long nStartCp, long nEndCp,
{
for (size_t i = nCurrentCount; i < m_pCtrlStck->size(); ++i)
{
- const SfxPoolItem *pItem = ((*m_pCtrlStck)[i]).pAttr;
+ const SfxPoolItem *pItem = ((*m_pCtrlStck)[i]).pAttr.get();
sal_uInt16 nWhich = pItem->Which();
if( nWhich < RES_FLTRATTR_BEGIN ||
nWhich >= RES_FLTRATTR_END )
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index 0a42707dbf6e..a586b9af226e 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -1388,7 +1388,7 @@ void SwWW8ReferencedFltEndStack::SetAttrInDoc( const SwPosition& rTmpPos,
// and which is not referenced.
bool bInsertBookmarkIntoDoc = true;
- SwFltBookmark* pFltBookmark = dynamic_cast<SwFltBookmark*>(rEntry.pAttr);
+ SwFltBookmark* pFltBookmark = dynamic_cast<SwFltBookmark*>(rEntry.pAttr.get());
if ( pFltBookmark != nullptr && pFltBookmark->IsTOCBookmark() )
{
const OUString& rName = pFltBookmark->GetName();
@@ -1429,7 +1429,7 @@ void SwWW8FltControlStack::SetAttrInDoc(const SwPosition& rTmpPos,
SwPaM aRegion(rTmpPos);
if (rEntry.MakeRegion(pDoc, aRegion, false))
{
- SvxLRSpaceItem aNewLR( *static_cast<SvxLRSpaceItem*>(rEntry.pAttr) );
+ SvxLRSpaceItem aNewLR( *static_cast<SvxLRSpaceItem*>(rEntry.pAttr.get()) );
sal_uLong nStart = aRegion.Start()->nNode.GetIndex();
sal_uLong nEnd = aRegion.End()->nNode.GetIndex();
for(; nStart <= nEnd; ++nStart)
@@ -1502,7 +1502,7 @@ void SwWW8FltControlStack::SetAttrInDoc(const SwPosition& rTmpPos,
if (nullptr != (pFrame = SwWW8ImplReader::ContainsSingleInlineGraphic(aRegion)))
{
const SwFormatINetFormat *pAttr = static_cast<const SwFormatINetFormat *>(
- rEntry.pAttr);
+ rEntry.pAttr.get());
SwFormatURL aURL;
aURL.SetURL(pAttr->GetValue(), false);
aURL.SetTargetFrameName(pAttr->GetTargetFrame());
@@ -1590,7 +1590,7 @@ const SfxPoolItem* SwWW8FltControlStack::GetStackAttr(const SwPosition& rPos,
* means props that end at 3 are not included
*/
{
- return rEntry.pAttr;
+ return rEntry.pAttr.get();
}
}
}
@@ -1637,7 +1637,7 @@ void SwWW8FltRefStack::SetAttrInDoc(const SwPosition& rTmpPos,
SwNodeIndex aIdx(rEntry.m_aMkPos.m_nNode, 1);
SwPaM aPaM(aIdx, rEntry.m_aMkPos.m_nContent);
- SwFormatField& rFormatField = *static_cast<SwFormatField*>(rEntry.pAttr);
+ SwFormatField& rFormatField = *static_cast<SwFormatField*>(rEntry.pAttr.get());
SwField* pField = rFormatField.GetField();
if (!RefToVar(pField, rEntry))
diff --git a/sw/source/filter/ww8/ww8par5.cxx b/sw/source/filter/ww8/ww8par5.cxx
index 24eae0d5f134..cb14e24c7b2e 100644
--- a/sw/source/filter/ww8/ww8par5.cxx
+++ b/sw/source/filter/ww8/ww8par5.cxx
@@ -1285,9 +1285,8 @@ SwFltStackEntry *SwWW8FltRefStack::RefToVar(const SwField* pField,
{
SwGetExpField aField( static_cast<SwGetExpFieldType*>(
pDoc->getIDocumentFieldsAccess().GetSysFieldType(RES_GETEXPFLD)), sName, nsSwGetSetExpType::GSE_STRING, 0);
- delete rEntry.pAttr;
SwFormatField aTmp(aField);
- rEntry.pAttr = aTmp.Clone();
+ rEntry.pAttr.reset( aTmp.Clone() );
pRet = &rEntry;
}
}
diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx
index 6c16920b68e6..039b24ce5183 100644
--- a/sw/source/filter/ww8/ww8scan.cxx
+++ b/sw/source/filter/ww8/ww8scan.cxx
@@ -1933,10 +1933,10 @@ WW8PLCFspecial::WW8PLCFspecial(SvStream* pSt, sal_uInt32 nFilePos,
nPLCF = bValid ? std::min(nRemainingSize, static_cast<std::size_t>(nPLCF)) : nValidMin;
// Pointer to Pos- and Struct-array
- pPLCF_PosArray = new sal_Int32[ ( nPLCF + 3 ) / 4 ];
+ pPLCF_PosArray.reset( new sal_Int32[ ( nPLCF + 3 ) / 4 ] );
pPLCF_PosArray[0] = 0;
- nPLCF = bValid ? pSt->ReadBytes(pPLCF_PosArray, nPLCF) : nValidMin;
+ nPLCF = bValid ? pSt->ReadBytes(pPLCF_PosArray.get(), nPLCF) : nValidMin;
nPLCF = std::max(nPLCF, nValidMin);
@@ -2086,8 +2086,8 @@ void WW8PLCF::ReadPLCF(SvStream& rSt, WW8_FC nFilePos, sal_uInt32 nPLCF)
if (bValid)
{
// Pointer to Pos-array
- pPLCF_PosArray = new WW8_CP[ ( nPLCF + 3 ) / 4 ];
- bValid = checkRead(rSt, pPLCF_PosArray, nPLCF);
+ pPLCF_PosArray.reset( new WW8_CP[ ( nPLCF + 3 ) / 4 ] );
+ bValid = checkRead(rSt, pPLCF_PosArray.get(), nPLCF);
}
if (bValid)
@@ -2114,8 +2114,7 @@ void WW8PLCF::ReadPLCF(SvStream& rSt, WW8_FC nFilePos, sal_uInt32 nPLCF)
void WW8PLCF::MakeFailedPLCF()
{
nIMax = 0;
- delete[] pPLCF_PosArray;
- pPLCF_PosArray = new sal_Int32[2];
+ pPLCF_PosArray.reset( new sal_Int32[2] );
pPLCF_PosArray[0] = pPLCF_PosArray[1] = WW8_CP_MAX;
pPLCF_Contents = reinterpret_cast<sal_uInt8*>(&pPLCF_PosArray[nIMax + 1]);
}
@@ -2149,7 +2148,7 @@ void WW8PLCF::GeneratePLCF(SvStream& rSt, sal_Int32 nPN, sal_Int32 ncpN)
{
size_t nSiz = 6 * nIMax + 4;
size_t nElems = ( nSiz + 3 ) / 4;
- pPLCF_PosArray = new sal_Int32[ nElems ]; // Pointer to Pos-array
+ pPLCF_PosArray.reset( new sal_Int32[ nElems ] ); // Pointer to Pos-array
for (sal_Int32 i = 0; i < ncpN && !failure; ++i)
{
@@ -2283,10 +2282,10 @@ WW8PLCFpcd::WW8PLCFpcd(SvStream* pSt, sal_uInt32 nFilePos,
bValid = false;
nPLCF = bValid ? std::min(nRemainingSize, static_cast<std::size_t>(nPLCF)) : nValidMin;
- pPLCF_PosArray = new sal_Int32[ ( nPLCF + 3 ) / 4 ]; // Pointer to Pos-array
+ pPLCF_PosArray.reset( new sal_Int32[ ( nPLCF + 3 ) / 4 ] ); // Pointer to Pos-array
pPLCF_PosArray[0] = 0;
- nPLCF = bValid ? pSt->ReadBytes(pPLCF_PosArray, nPLCF) : nValidMin;
+ nPLCF = bValid ? pSt->ReadBytes(pPLCF_PosArray.get(), nPLCF) : nValidMin;
nPLCF = std::max(nPLCF, nValidMin);
nIMax = ( nPLCF - 4 ) / ( 4 + nStruct );
@@ -6853,8 +6852,8 @@ WW8Fonts::WW8Fonts( SvStream& rSt, WW8Fib& rFib )
if( nMax )
{
// allocate Index Array
- pFontA = new WW8_FFN[ nMax ];
- WW8_FFN* p = pFontA;
+ pFontA.reset( new WW8_FFN[ nMax ] );
+ WW8_FFN* p = pFontA.get();
if( eVersion <= ww::eWW2 )
{
diff --git a/sw/source/filter/ww8/ww8scan.hxx b/sw/source/filter/ww8/ww8scan.hxx
index eff6796d72b3..fab19068750b 100644
--- a/sw/source/filter/ww8/ww8scan.hxx
+++ b/sw/source/filter/ww8/ww8scan.hxx
@@ -209,7 +209,7 @@ struct WW8PLCFxSave1
class WW8PLCFspecial // iterator for PLCFs
{
private:
- sal_Int32* pPLCF_PosArray; ///< pointer to Pos-array and to the whole structure
+ std::unique_ptr<sal_Int32[]> pPLCF_PosArray; ///< pointer to Pos-array and to the whole structure
sal_uInt8* pPLCF_Contents; ///< pointer to content-array-part of Pos-array
long nIMax; ///< number of elements
long nIdx; ///< marker where we currently are
@@ -221,7 +221,6 @@ private:
public:
WW8PLCFspecial(SvStream* pSt, sal_uInt32 nFilePos, sal_uInt32 nPLCF,
sal_uInt32 nStruct);
- ~WW8PLCFspecial() { delete[] pPLCF_PosArray; }
long GetIdx() const { return nIdx; }
void SetIdx( long nI ) { nIdx = nI; }
long GetIMax() const { return nIMax; }
@@ -283,7 +282,7 @@ private:
class WW8PLCF // Iterator for PLCFs
{
private:
- WW8_CP* pPLCF_PosArray; // pointer to Pos-array and the whole structure
+ std::unique_ptr<WW8_CP[]> pPLCF_PosArray; // pointer to Pos-array and the whole structure
sal_uInt8* pPLCF_Contents; // pointer to content-array-part of Pos-array
sal_Int32 nIMax; // number of elements
sal_Int32 nIdx;
@@ -310,7 +309,6 @@ public:
WW8PLCF(SvStream& rSt, WW8_FC nFilePos, sal_Int32 nPLCF, int nStruct,
WW8_CP nStartPos, sal_Int32 nPN, sal_Int32 ncpN);
- ~WW8PLCF(){ delete[] pPLCF_PosArray; }
sal_Int32 GetIdx() const { return nIdx; }
void SetIdx( sal_Int32 nI ) { nIdx = nI; }
sal_Int32 GetIMax() const { return nIMax; }
@@ -331,7 +329,7 @@ class WW8PLCFpcd
{
friend class WW8PLCFpcd_Iter;
- sal_Int32* pPLCF_PosArray; // pointer to Pos-array and the whole structure
+ std::unique_ptr<sal_Int32[]> pPLCF_PosArray; // pointer to Pos-array and the whole structure
sal_uInt8* pPLCF_Contents; // pointer to content-array-part of Pos-array
long nIMax;
sal_uInt32 nStru;
@@ -342,7 +340,6 @@ class WW8PLCFpcd
public:
WW8PLCFpcd(SvStream* pSt, sal_uInt32 nFilePos, sal_uInt32 nPLCF,
sal_uInt32 nStruct);
- ~WW8PLCFpcd(){ delete[] pPLCF_PosArray; }
};
/* multiple WW8PLCFpcd_Iter may point to the same WW8PLCFpcd !!! */
@@ -1560,12 +1557,11 @@ private:
WW8Fonts(const WW8Fonts&) = delete;
WW8Fonts& operator=(const WW8Fonts&) = delete;
protected:
- WW8_FFN* pFontA; // Array of Pointers to Font Description
+ std::unique_ptr<WW8_FFN[]> pFontA; // Array of Pointers to Font Description
sal_uInt16 nMax; // Array-Size
public:
WW8Fonts( SvStream& rSt, WW8Fib& rFib );
- ~WW8Fonts() { delete[] pFontA; }
const WW8_FFN* GetFont( sal_uInt16 nNum ) const;
sal_uInt16 GetMax() const { return nMax; }
};
diff --git a/sw/source/filter/ww8/ww8toolbar.cxx b/sw/source/filter/ww8/ww8toolbar.cxx
index a0dce1d2c8ab..ae317235d0aa 100644
--- a/sw/source/filter/ww8/ww8toolbar.cxx
+++ b/sw/source/filter/ww8/ww8toolbar.cxx
@@ -981,7 +981,6 @@ PlfAcd::PlfAcd() :
PlfAcd::~PlfAcd()
{
- delete[] rgacd;
}
bool PlfAcd::Read( SvStream &rS)
@@ -1000,7 +999,7 @@ bool PlfAcd::Read( SvStream &rS)
}
if (iMac)
{
- rgacd = new Acd[ iMac ];
+ rgacd.reset( new Acd[ iMac ] );
for ( sal_Int32 index = 0; index < iMac; ++index )
{
if ( !rgacd[ index ].Read( rS ) )
@@ -1033,7 +1032,6 @@ PlfKme::PlfKme() :
PlfKme::~PlfKme()
{
- delete[] rgkme;
}
bool PlfKme::Read(SvStream &rS)
@@ -1044,7 +1042,7 @@ bool PlfKme::Read(SvStream &rS)
rS.ReadInt32( iMac );
if ( iMac )
{
- rgkme = new Kme[ iMac ];
+ rgkme.reset( new Kme[ iMac ] );
for( sal_Int32 index=0; index<iMac; ++index )
{
if ( !rgkme[ index ].Read( rS ) )
diff --git a/sw/source/filter/ww8/ww8toolbar.hxx b/sw/source/filter/ww8/ww8toolbar.hxx
index c5079f4eb617..c37176f647ae 100644
--- a/sw/source/filter/ww8/ww8toolbar.hxx
+++ b/sw/source/filter/ww8/ww8toolbar.hxx
@@ -231,7 +231,7 @@ public:
class PlfAcd: public Tcg255SubStruct
{
sal_Int32 iMac;
- Acd* rgacd;
+ std::unique_ptr<Acd[]> rgacd;
PlfAcd(const PlfAcd&) = delete;
PlfAcd& operator = ( const PlfAcd&) = delete;
@@ -268,7 +268,7 @@ public:
class PlfKme : public Tcg255SubStruct
{
sal_Int32 iMac;
- Kme* rgkme;
+ std::unique_ptr<Kme[]> rgkme;
PlfKme(const PlfKme&) = delete;
PlfKme& operator = ( const PlfKme&) = delete;
diff --git a/sw/source/filter/xml/XMLRedlineImportHelper.cxx b/sw/source/filter/xml/XMLRedlineImportHelper.cxx
index a4e2f55f1df3..9a47127c0ce5 100644
--- a/sw/source/filter/xml/XMLRedlineImportHelper.cxx
+++ b/sw/source/filter/xml/XMLRedlineImportHelper.cxx
@@ -79,7 +79,7 @@ static SwDoc* lcl_GetDocViaTunnel( Reference<XTextRange> const & rRange )
class XTextRangeOrNodeIndexPosition
{
Reference<XTextRange> xRange;
- SwNodeIndex* pIndex; // pIndex will point to the *previous* node
+ std::unique_ptr<SwNodeIndex> pIndex; // pIndex will point to the *previous* node
public:
XTextRangeOrNodeIndexPosition();
@@ -103,25 +103,17 @@ XTextRangeOrNodeIndexPosition::XTextRangeOrNodeIndexPosition() :
XTextRangeOrNodeIndexPosition::~XTextRangeOrNodeIndexPosition()
{
- delete pIndex;
}
void XTextRangeOrNodeIndexPosition::Set( Reference<XTextRange> & rRange )
{
xRange = rRange->getStart(); // set bookmark
- if (nullptr != pIndex)
- {
- delete pIndex;
- pIndex = nullptr;
- }
+ pIndex.reset();
}
void XTextRangeOrNodeIndexPosition::Set( SwNodeIndex& rIndex )
{
- if (nullptr != pIndex)
- delete pIndex;
-
- pIndex = new SwNodeIndex(rIndex);
+ pIndex.reset( new SwNodeIndex(rIndex) );
(*pIndex)-- ; // previous node!!!
xRange = nullptr;
}
diff --git a/sw/source/filter/xml/xmlbrsh.cxx b/sw/source/filter/xml/xmlbrsh.cxx
index d31249bbf796..1a64f534c355 100644
--- a/sw/source/filter/xml/xmlbrsh.cxx
+++ b/sw/source/filter/xml/xmlbrsh.cxx
@@ -183,7 +183,6 @@ SwXMLBrushItemImportContext::SwXMLBrushItemImportContext(
SwXMLBrushItemImportContext::~SwXMLBrushItemImportContext()
{
- delete pItem;
}
SwXMLBrushItemExport::SwXMLBrushItemExport( SwXMLExport& rExp ) :
diff --git a/sw/source/filter/xml/xmlbrshi.hxx b/sw/source/filter/xml/xmlbrshi.hxx
index 7a507ddc5902..dc6076499773 100644
--- a/sw/source/filter/xml/xmlbrshi.hxx
+++ b/sw/source/filter/xml/xmlbrshi.hxx
@@ -36,7 +36,7 @@ class SwXMLBrushItemImportContext : public SvXMLImportContext
{
private:
css::uno::Reference < css::io::XOutputStream > xBase64Stream;
- SvxBrushItem *pItem;
+ std::unique_ptr<SvxBrushItem> pItem;
void ProcessAttrs(
const css::uno::Reference<css::xml::sax::XAttributeList > & xAttrList,
diff --git a/sw/source/filter/xml/xmlfmt.cxx b/sw/source/filter/xml/xmlfmt.cxx
index dd792d307a30..fbe0ff77878b 100644
--- a/sw/source/filter/xml/xmlfmt.cxx
+++ b/sw/source/filter/xml/xmlfmt.cxx
@@ -335,10 +335,10 @@ SvXMLImportContext *SwXMLTextStyleContext_Impl::CreateChildContext(
class SwXMLItemSetStyleContext_Impl : public SvXMLStyleContext
{
- OUString sMasterPageName;
- SfxItemSet *pItemSet;
+ OUString sMasterPageName;
+ std::unique_ptr<SfxItemSet> pItemSet;
SwXMLTextStyleContext_Impl *pTextStyle;
- SvXMLStylesContext &rStyles;
+ SvXMLStylesContext &rStyles;
OUString sDataStyleName;
@@ -368,7 +368,6 @@ public:
const uno::Reference< xml::sax::XAttributeList > & xAttrList,
SvXMLStylesContext& rStylesC,
sal_uInt16 nFamily);
- virtual ~SwXMLItemSetStyleContext_Impl() override;
virtual void CreateAndInsert( bool bOverwrite ) override;
@@ -378,7 +377,7 @@ public:
const uno::Reference< xml::sax::XAttributeList > & xAttrList ) override;
// The item set may be empty!
- SfxItemSet *GetItemSet() { return pItemSet; }
+ SfxItemSet *GetItemSet() { return pItemSet.get(); }
bool HasMasterPageName() const { return bHasMasterPageName; }
@@ -434,16 +433,16 @@ SvXMLImportContext *SwXMLItemSetStyleContext_Impl::CreateItemSetContext(
switch( GetFamily() )
{
case XML_STYLE_FAMILY_TABLE_TABLE:
- pItemSet = new SfxItemSet( rItemPool, aTableSetRange );
+ pItemSet.reset( new SfxItemSet( rItemPool, aTableSetRange ) );
break;
case XML_STYLE_FAMILY_TABLE_COLUMN:
- pItemSet = new SfxItemSet( rItemPool, RES_FRM_SIZE, RES_FRM_SIZE, 0 );
+ pItemSet.reset( new SfxItemSet( rItemPool, RES_FRM_SIZE, RES_FRM_SIZE, 0 ) );
break;
case XML_STYLE_FAMILY_TABLE_ROW:
- pItemSet = new SfxItemSet( rItemPool, aTableLineSetRange );
+ pItemSet.reset( new SfxItemSet( rItemPool, aTableLineSetRange ) );
break;
case XML_STYLE_FAMILY_TABLE_CELL:
- pItemSet = new SfxItemSet( rItemPool, aTableBoxSetRange );
+ pItemSet.reset( new SfxItemSet( rItemPool, aTableBoxSetRange ) );
break;
default:
OSL_ENSURE( false,
@@ -456,8 +455,7 @@ SvXMLImportContext *SwXMLItemSetStyleContext_Impl::CreateItemSetContext(
*pItemSet );
if( !pContext )
{
- delete pItemSet;
- pItemSet = nullptr;
+ pItemSet.reset();
}
return pContext;
@@ -479,11 +477,6 @@ SwXMLItemSetStyleContext_Impl::SwXMLItemSetStyleContext_Impl( SwXMLImport& rImpo
{
}
-SwXMLItemSetStyleContext_Impl::~SwXMLItemSetStyleContext_Impl()
-{
- delete pItemSet;
-}
-
void SwXMLItemSetStyleContext_Impl::CreateAndInsert( bool bOverwrite )
{
if( pTextStyle )
@@ -564,7 +557,7 @@ void SwXMLItemSetStyleContext_Impl::ConnectPageDesc()
if( !pItemSet )
{
SfxItemPool& rItemPool = pDoc->GetAttrPool();
- pItemSet = new SfxItemSet( rItemPool, aTableSetRange );
+ pItemSet.reset( new SfxItemSet( rItemPool, aTableSetRange ) );
}
const SfxPoolItem *pItem;
@@ -603,7 +596,7 @@ bool SwXMLItemSetStyleContext_Impl::ResolveDataStyleName()
SwDoc *pDoc = SwImport::GetDocFromXMLImport( GetSwImport() );
SfxItemPool& rItemPool = pDoc->GetAttrPool();
- pItemSet = new SfxItemSet( rItemPool, aTableBoxSetRange );
+ pItemSet.reset( new SfxItemSet( rItemPool, aTableBoxSetRange ) );
}
SwTableBoxNumFormat aNumFormatItem(nFormat);
pItemSet->Put(aNumFormatItem);
diff --git a/sw/source/uibase/config/usrpref.cxx b/sw/source/uibase/config/usrpref.cxx
index 6372386370cc..7fb9e59d7e33 100644
--- a/sw/source/uibase/config/usrpref.cxx
+++ b/sw/source/uibase/config/usrpref.cxx
@@ -79,7 +79,6 @@ SwMasterUsrPref::SwMasterUsrPref(bool bWeb) :
SwMasterUsrPref::~SwMasterUsrPref()
{
- delete m_pWebColorConfig;
}
Sequence<OUString> SwContentViewConfig::GetPropertyNames()
diff --git a/sw/source/uibase/dialog/SwSpellDialogChildWindow.cxx b/sw/source/uibase/dialog/SwSpellDialogChildWindow.cxx
index 55b74f7ba198..99f26ebd23c2 100644
--- a/sw/source/uibase/dialog/SwSpellDialogChildWindow.cxx
+++ b/sw/source/uibase/dialog/SwSpellDialogChildWindow.cxx
@@ -75,7 +75,8 @@ struct SpellState
bool m_bOtherSpelled; // frames, footnotes, headers and footers spelled
bool m_bStartedInOther; // started the spelling inside of the _other_ area
bool m_bStartedInSelection; // there was an initial text selection
- SwPaM* pOtherCursor; // position where the spelling inside the _other_ area started
+ std::unique_ptr<SwPaM>
+ pOtherCursor; // position where the spelling inside the _other_ area started
bool m_bDrawingsSpelled; // all drawings spelled
Reference<XTextRange> m_xStartRange; // text range that marks the start of spelling
const SdrObject* m_pStartDrawing; // draw text object spelling started in
@@ -118,8 +119,6 @@ struct SpellState
m_bTextObjectsCollected(false)
{}
- ~SpellState() {delete pOtherCursor;}
-
// reset state in ::InvalidateSpellDialog
void Reset()
{ m_bInitialCall = true;
@@ -130,8 +129,7 @@ struct SpellState
m_bTextObjectsCollected = false;
m_aTextObjects.clear();
m_bStartedInOther = false;
- delete pOtherCursor;
- pOtherCursor = nullptr;
+ pOtherCursor.reset();
}
};
@@ -230,7 +228,7 @@ svx::SpellPortions SwSpellDialogChildWindow::GetNextWrongSentence(bool bRecheck)
m_pSpellState->m_SpellStartPosition = bOtherText ? SPELL_START_OTHER : SPELL_START_BODY;
if(bOtherText)
{
- m_pSpellState->pOtherCursor = new SwPaM(*pWrtShell->GetCursor()->GetPoint());
+ m_pSpellState->pOtherCursor.reset( new SwPaM(*pWrtShell->GetCursor()->GetPoint()) );
m_pSpellState->m_bStartedInOther = true;
pWrtShell->SpellStart( SwDocPositions::OtherStart, SwDocPositions::OtherEnd, SwDocPositions::Curr );
}
@@ -329,8 +327,7 @@ The code below would only be part of the solution.
m_pSpellState->m_bStartedInOther = false;
pWrtShell->SetSelection(*m_pSpellState->pOtherCursor);
pWrtShell->SpellEnd();
- delete m_pSpellState->pOtherCursor;
- m_pSpellState->pOtherCursor = nullptr;
+ m_pSpellState->pOtherCursor.reset();
pWrtShell->SpellStart(SwDocPositions::OtherStart, SwDocPositions::Curr, SwDocPositions::OtherStart );
(void)pWrtShell->SpellSentence(aRet, m_bIsGrammarCheckingOn);
}
diff --git a/sw/source/uibase/dochdl/gloshdl.cxx b/sw/source/uibase/dochdl/gloshdl.cxx
index fe066e0ab13b..eea2fc3dd121 100644
--- a/sw/source/uibase/dochdl/gloshdl.cxx
+++ b/sw/source/uibase/dochdl/gloshdl.cxx
@@ -88,7 +88,7 @@ void SwGlossaryHdl::GlossaryDlg()
}
pDlg.disposeAndClear();
- DELETEZ(pCurGrp);
+ pCurGrp.reset();
if(HasGlossaryList())
{
GetGlossaryList()->ClearGroups();
@@ -140,8 +140,7 @@ void SwGlossaryHdl::SetCurGroup(const OUString &rGrp, bool bApi, bool bAlwaysCre
aCurGrp = sGroup;
if(!bApi)
{
- delete pCurGrp;
- pCurGrp = rStatGlossaries.GetGroupDoc(aCurGrp, true);
+ pCurGrp.reset( rStatGlossaries.GetGroupDoc(aCurGrp, true) );
}
}
@@ -245,7 +244,7 @@ bool SwGlossaryHdl::DelGroup(const OUString &rGrpName)
if(pCurGrp)
{
if (pCurGrp->GetName() == sGroup)
- DELETEZ(pCurGrp);
+ pCurGrp.reset();
}
return true;
}
@@ -275,7 +274,7 @@ OUString SwGlossaryHdl::GetGlossaryShortName(const OUString &rName)
{
OUString sReturn;
SwTextBlocks *pTmp =
- pCurGrp ? pCurGrp: rStatGlossaries.GetGroupDoc( aCurGrp );
+ pCurGrp ? pCurGrp.get() : rStatGlossaries.GetGroupDoc( aCurGrp );
if(pTmp)
{
sal_uInt16 nIdx = pTmp->GetLongIndex( rName );
@@ -290,7 +289,7 @@ OUString SwGlossaryHdl::GetGlossaryShortName(const OUString &rName)
// short name for autotext already used?
bool SwGlossaryHdl::HasShortName(const OUString& rShortName) const
{
- SwTextBlocks *pBlock = pCurGrp ? pCurGrp
+ SwTextBlocks *pBlock = pCurGrp ? pCurGrp.get()
: rStatGlossaries.GetGroupDoc( aCurGrp );
bool bRet = pBlock->GetIndex( rShortName ) != (sal_uInt16) -1;
if( !pCurGrp )
@@ -303,7 +302,7 @@ bool SwGlossaryHdl::NewGlossary(const OUString& rName, const OUString& rShortNam
bool bCreateGroup, bool bNoAttr)
{
SwTextBlocks *pTmp =
- pCurGrp ? pCurGrp: rStatGlossaries.GetGroupDoc( aCurGrp, bCreateGroup );
+ pCurGrp ? pCurGrp.get() : rStatGlossaries.GetGroupDoc( aCurGrp, bCreateGroup );
//pTmp == 0 if the AutoText path setting is wrong
if(!pTmp)
return false;
@@ -333,7 +332,7 @@ bool SwGlossaryHdl::NewGlossary(const OUString& rName, const OUString& rShortNam
// Delete a autotext
bool SwGlossaryHdl::DelGlossary(const OUString &rShortName)
{
- SwTextBlocks *pGlossary = pCurGrp ? pCurGrp
+ SwTextBlocks *pGlossary = pCurGrp ? pCurGrp.get()
: rStatGlossaries.GetGroupDoc(aCurGrp);
//pTmp == 0 if the AutoText path setting is wrong
if(!pGlossary)
@@ -524,7 +523,7 @@ bool SwGlossaryHdl::InsertGlossary(const OUString &rName)
OSL_ENSURE(pWrtShell->CanInsert(), "illegal");
SwTextBlocks *pGlos =
- pCurGrp? pCurGrp: rStatGlossaries.GetGroupDoc(aCurGrp);
+ pCurGrp ? pCurGrp.get() : rStatGlossaries.GetGroupDoc(aCurGrp);
if (!pGlos)
return false;
@@ -569,7 +568,7 @@ void SwGlossaryHdl::SetMacros(const OUString& rShortName,
SwTextBlocks *pGlossary )
{
SwTextBlocks *pGlos = pGlossary ? pGlossary :
- pCurGrp ? pCurGrp
+ pCurGrp ? pCurGrp.get()
: rStatGlossaries.GetGroupDoc( aCurGrp );
SvxMacroTableDtor aMacroTable;
if( pStart )
@@ -590,7 +589,7 @@ void SwGlossaryHdl::GetMacros( const OUString &rShortName,
SwTextBlocks *pGlossary )
{
SwTextBlocks *pGlos = pGlossary ? pGlossary
- : pCurGrp ? pCurGrp
+ : pCurGrp ? pCurGrp.get()
: rStatGlossaries.GetGroupDoc(aCurGrp);
sal_uInt16 nIndex = pGlos->GetIndex( rShortName );
if( nIndex != USHRT_MAX )
@@ -624,7 +623,6 @@ SwGlossaryHdl::SwGlossaryHdl(SfxViewFrame* pVwFrame, SwWrtShell *pSh)
SwGlossaryHdl::~SwGlossaryHdl()
{
- delete pCurGrp;
}
// rename an autotext
@@ -632,7 +630,7 @@ bool SwGlossaryHdl::Rename(const OUString& rOldShort, const OUString& rNewShortN
const OUString& rNewName )
{
bool bRet = false;
- SwTextBlocks *pGlossary = pCurGrp ? pCurGrp
+ SwTextBlocks *pGlossary = pCurGrp ? pCurGrp.get()
: rStatGlossaries.GetGroupDoc(aCurGrp);
if(pGlossary)
{
@@ -660,7 +658,7 @@ bool SwGlossaryHdl::IsReadOnly( const OUString* pGrpNm ) const
if (pGrpNm)
pGlossary = rStatGlossaries.GetGroupDoc( *pGrpNm );
else if (pCurGrp)
- pGlossary = pCurGrp;
+ pGlossary = pCurGrp.get();
else
pGlossary = rStatGlossaries.GetGroupDoc(aCurGrp);
@@ -672,7 +670,7 @@ bool SwGlossaryHdl::IsReadOnly( const OUString* pGrpNm ) const
bool SwGlossaryHdl::IsOld() const
{
- SwTextBlocks *pGlossary = pCurGrp ? pCurGrp
+ SwTextBlocks *pGlossary = pCurGrp ? pCurGrp.get()
: rStatGlossaries.GetGroupDoc(aCurGrp);
bool bRet = pGlossary && pGlossary->IsOld();
if( !pCurGrp )
@@ -688,7 +686,7 @@ bool SwGlossaryHdl::FindGroupName(OUString& rGroup)
bool SwGlossaryHdl::CopyToClipboard(SwWrtShell& rSh, const OUString& rShortName)
{
- SwTextBlocks *pGlossary = pCurGrp ? pCurGrp
+ SwTextBlocks *pGlossary = pCurGrp ? pCurGrp.get()
: rStatGlossaries.GetGroupDoc(aCurGrp);
SwTransferable* pTransfer = new SwTransferable( rSh );
@@ -715,7 +713,7 @@ bool SwGlossaryHdl::ImportGlossaries( const OUString& rName )
SwTextBlocks *pGlossary = nullptr;
pMed->SetFilter( pFilter );
Reader* pR = SwReaderWriter::GetReader( pFilter->GetUserData() );
- if( pR && nullptr != ( pGlossary = pCurGrp ? pCurGrp
+ if( pR && nullptr != ( pGlossary = pCurGrp ? pCurGrp.get()
: rStatGlossaries.GetGroupDoc(aCurGrp)) )
{
SwReader aReader( *pMed, rName );
diff --git a/sw/source/uibase/inc/content.hxx b/sw/source/uibase/inc/content.hxx
index 815dcd8dab8d..74123da60820 100644
--- a/sw/source/uibase/inc/content.hxx
+++ b/sw/source/uibase/inc/content.hxx
@@ -138,7 +138,8 @@ public:
class SwContentType : public SwTypeNumber
{
SwWrtShell* pWrtShell;
- SwContentArr* pMember; // array for content
+ std::unique_ptr<SwContentArr>
+ pMember; // array for content
OUString sContentTypeName; // name of content type
OUString sSingleContentTypeName; // name of content type, singular
OUString sTypeToken; // attachment for URL
diff --git a/sw/source/uibase/inc/gloshdl.hxx b/sw/source/uibase/inc/gloshdl.hxx
index 3ad60ed733f7..8b43af0b126e 100644
--- a/sw/source/uibase/inc/gloshdl.hxx
+++ b/sw/source/uibase/inc/gloshdl.hxx
@@ -35,7 +35,8 @@ class SW_DLLPUBLIC SwGlossaryHdl
OUString aCurGrp;
SfxViewFrame* pViewFrame;
SwWrtShell* pWrtShell;
- SwTextBlocks* pCurGrp;
+ std::unique_ptr<SwTextBlocks>
+ pCurGrp;
SAL_DLLPRIVATE bool Expand( const OUString& rShortName,
SwGlossaries* pGlossaries,
diff --git a/sw/source/uibase/inc/swtablerep.hxx b/sw/source/uibase/inc/swtablerep.hxx
index b98e84037816..2bf8c1d1a019 100644
--- a/sw/source/uibase/inc/swtablerep.hxx
+++ b/sw/source/uibase/inc/swtablerep.hxx
@@ -27,7 +27,7 @@ class SwTabCols;
struct TColumn;
class SW_DLLPUBLIC SwTableRep
{
- TColumn* pTColumns;
+ std::unique_ptr<TColumn[]> pTColumns;
SwTwips nTableWidth;
SwTwips nSpace;
@@ -77,7 +77,7 @@ public:
SwTwips GetSpace() const { return nSpace;}
void SetSpace(SwTwips nSet) {nSpace = nSet;}
- TColumn* GetColumns() const {return pTColumns;}
+ TColumn* GetColumns() const {return pTColumns.get();}
};
#endif
diff --git a/sw/source/uibase/inc/uiitems.hxx b/sw/source/uibase/inc/uiitems.hxx
index ae078078aad6..124bf7e33a08 100644
--- a/sw/source/uibase/inc/uiitems.hxx
+++ b/sw/source/uibase/inc/uiitems.hxx
@@ -70,7 +70,7 @@ public:
class SW_DLLPUBLIC SwUINumRuleItem : public SfxPoolItem
{
- SwNumRule* pRule;
+ std::unique_ptr<SwNumRule> pRule;
public:
SwUINumRuleItem( const SwNumRule& rRule );
@@ -83,8 +83,8 @@ public:
virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override;
virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override;
- const SwNumRule* GetNumRule() const { return pRule; }
- SwNumRule* GetNumRule() { return pRule; }
+ const SwNumRule* GetNumRule() const { return pRule.get(); }
+ SwNumRule* GetNumRule() { return pRule.get(); }
};
class SwBackgroundDestinationItem : public SfxUInt16Item
diff --git a/sw/source/uibase/inc/usrpref.hxx b/sw/source/uibase/inc/usrpref.hxx
index 8e40de357cce..3a8e3a1a7a46 100644
--- a/sw/source/uibase/inc/usrpref.hxx
+++ b/sw/source/uibase/inc/usrpref.hxx
@@ -144,7 +144,7 @@ class SwMasterUsrPref : public SwViewOption
SwLayoutViewConfig m_aLayoutConfig;
SwGridConfig m_aGridConfig;
SwCursorConfig m_aCursorConfig;
- SwWebColorConfig* m_pWebColorConfig;
+ std::unique_ptr<SwWebColorConfig> m_pWebColorConfig;
bool m_bApplyCharUnit; // apply_char_unit
public:
diff --git a/sw/source/uibase/table/swtablerep.cxx b/sw/source/uibase/table/swtablerep.cxx
index 5324aa866464..177be7c54dbc 100644
--- a/sw/source/uibase/table/swtablerep.cxx
+++ b/sw/source/uibase/table/swtablerep.cxx
@@ -66,7 +66,7 @@ SwTableRep::SwTableRep( const SwTabCols& rTabCol )
bColsChanged(false)
{
nAllCols = nColCount = rTabCol.Count();
- pTColumns = new TColumn[ nColCount + 1 ];
+ pTColumns.reset( new TColumn[ nColCount + 1 ] );
SwTwips nStart = 0,
nEnd;
for( sal_uInt16 i = 0; i < nAllCols; ++i )
@@ -86,7 +86,6 @@ SwTableRep::SwTableRep( const SwTabCols& rTabCol )
SwTableRep::~SwTableRep()
{
- delete[] pTColumns;
}
bool SwTableRep::FillTabCols( SwTabCols& rTabCols ) const
diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx
index dd3d33919217..b5ec8107b975 100644
--- a/sw/source/uibase/utlui/content.cxx
+++ b/sw/source/uibase/utlui/content.cxx
@@ -298,12 +298,12 @@ void SwContentType::Init(bool* pbInvalidateWindow)
size_t nOldRegionCount = 0;
bool bInvalidate = false;
if(!pMember)
- pMember = new SwContentArr;
+ pMember.reset( new SwContentArr );
else if(!pMember->empty())
{
- pOldMember = pMember;
+ pOldMember = pMember.release();
nOldRegionCount = pOldMember->size();
- pMember = new SwContentArr;
+ pMember.reset( new SwContentArr );
}
const Point aNullPt;
nMemberCount = pWrtShell->GetSectionFormatCount();
@@ -372,11 +372,11 @@ void SwContentType::Init(bool* pbInvalidateWindow)
{
nMemberCount = 0;
if(!pMember)
- pMember = new SwContentArr;
+ pMember.reset( new SwContentArr );
else if(!pMember->empty())
pMember->DeleteAndDestroyAll();
- nMemberCount = lcl_InsertURLFieldContent(pMember, pWrtShell, this);
+ nMemberCount = lcl_InsertURLFieldContent(pMember.get(), pWrtShell, this);
bEdit = true;
nOldMemberCount = nMemberCount;
@@ -387,7 +387,7 @@ void SwContentType::Init(bool* pbInvalidateWindow)
{
nMemberCount = 0;
if(!pMember)
- pMember = new SwContentArr;
+ pMember.reset( new SwContentArr );
else if(!pMember->empty())
pMember->DeleteAndDestroyAll();
@@ -449,7 +449,6 @@ void SwContentType::Init(bool* pbInvalidateWindow)
SwContentType::~SwContentType()
{
- delete pMember;
}
const SwContent* SwContentType::GetMember(size_t nIndex)
@@ -476,13 +475,13 @@ void SwContentType::FillMemberList(bool* pbLevelOrVisibilityChanged)
SwPtrMsgPoolItem aAskItem( RES_CONTENT_VISIBLE, nullptr );
if(pMember && pbLevelOrVisibilityChanged)
{
- pOldMember = pMember;
+ pOldMember = pMember.release();
nOldMemberCount = pOldMember->size();
- pMember = new SwContentArr;
+ pMember.reset( new SwContentArr );
*pbLevelOrVisibilityChanged = false;
}
else if(!pMember)
- pMember = new SwContentArr;
+ pMember.reset( new SwContentArr );
else if(!pMember->empty())
pMember->DeleteAndDestroyAll();
switch(nContentType)
@@ -659,7 +658,7 @@ void SwContentType::FillMemberList(bool* pbLevelOrVisibilityChanged)
}
break;
case ContentTypeId::URLFIELD:
- nMemberCount = lcl_InsertURLFieldContent(pMember, pWrtShell, this);
+ nMemberCount = lcl_InsertURLFieldContent(pMember.get(), pWrtShell, this);
break;
case ContentTypeId::INDEX:
{
@@ -691,7 +690,7 @@ void SwContentType::FillMemberList(bool* pbLevelOrVisibilityChanged)
{
nMemberCount = 0;
if(!pMember)
- pMember = new SwContentArr;
+ pMember.reset( new SwContentArr );
else if(!pMember->empty())
pMember->DeleteAndDestroyAll();
SwPostItMgr* aMgr = pWrtShell->GetView().GetPostItMgr();
@@ -723,7 +722,7 @@ void SwContentType::FillMemberList(bool* pbLevelOrVisibilityChanged)
{
nMemberCount = 0;
if(!pMember)
- pMember = new SwContentArr;
+ pMember.reset( new SwContentArr );
else if(!pMember->empty())
pMember->DeleteAndDestroyAll();
diff --git a/sw/source/uibase/utlui/initui.cxx b/sw/source/uibase/utlui/initui.cxx
index eaea5300ec27..8713459eff50 100644
--- a/sw/source/uibase/utlui/initui.cxx
+++ b/sw/source/uibase/utlui/initui.cxx
@@ -227,7 +227,6 @@ ShellResource::ShellResource()
ShellResource::~ShellResource()
{
- delete pAutoFormatNameLst;
}
OUString ShellResource::GetPageDescName(sal_uInt16 nNo, PageNameMode eMode)
@@ -278,7 +277,7 @@ struct ImpAutoFormatNameListLoader : public Resource
void ShellResource::GetAutoFormatNameLst_() const
{
assert(!pAutoFormatNameLst);
- pAutoFormatNameLst = new std::vector<OUString>;
+ pAutoFormatNameLst.reset( new std::vector<OUString> );
pAutoFormatNameLst->reserve(STR_AUTOFMTREDL_END);
ImpAutoFormatNameListLoader aTmp(*pAutoFormatNameLst);
}
diff --git a/sw/source/uibase/utlui/uiitems.cxx b/sw/source/uibase/utlui/uiitems.cxx
index b0180b6131b1..579085aa1988 100644
--- a/sw/source/uibase/utlui/uiitems.cxx
+++ b/sw/source/uibase/utlui/uiitems.cxx
@@ -232,9 +232,8 @@ SwUINumRuleItem::SwUINumRuleItem( const SwUINumRuleItem& rItem )
{
}
- SwUINumRuleItem::~SwUINumRuleItem()
+SwUINumRuleItem::~SwUINumRuleItem()
{
- delete pRule;
}
SfxPoolItem* SwUINumRuleItem::Clone( SfxItemPool * /*pPool*/ ) const