summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compilerplugins/clang/useuniqueptr.cxx5
-rw-r--r--sw/inc/doc.hxx116
-rw-r--r--sw/source/core/doc/docedt.cxx9
-rw-r--r--sw/source/core/doc/docfmt.cxx30
-rw-r--r--sw/source/core/doc/doclay.cxx4
-rw-r--r--sw/source/core/doc/docnew.cxx80
-rw-r--r--sw/source/core/doc/swstylemanager.cxx5
-rw-r--r--sw/source/core/doc/swstylemanager.hxx5
-rw-r--r--sw/source/core/doc/visiturl.cxx2
-rw-r--r--sw/source/core/docnode/ndsect.cxx2
-rw-r--r--sw/source/core/edit/acorrect.cxx3
11 files changed, 133 insertions, 128 deletions
diff --git a/compilerplugins/clang/useuniqueptr.cxx b/compilerplugins/clang/useuniqueptr.cxx
index 131727f0f44f..df6343f61578 100644
--- a/compilerplugins/clang/useuniqueptr.cxx
+++ b/compilerplugins/clang/useuniqueptr.cxx
@@ -278,6 +278,11 @@ void UseUniquePtr::CheckDeleteExpr(const CXXMethodDecl* methodDecl, const CXXDel
auto tc = loplugin::TypeCheck(fieldDecl->getType());
if (tc.Class("map").StdNamespace() || tc.Class("unordered_map").StdNamespace())
return;
+ // these sw::Ring based classes do not lend themselves to std::unique_ptr management
+ if (tc.Pointer().Class("SwNodeIndex").GlobalNamespace() || tc.Pointer().Class("SwShellTableCursor").GlobalNamespace()
+ || tc.Pointer().Class("SwBlockCursor").GlobalNamespace() || tc.Pointer().Class("SwVisibleCursor").GlobalNamespace()
+ || tc.Pointer().Class("SwShellCursor").GlobalNamespace())
+ return;
// there is a loop in ~ImplPrnQueueList deleting stuff on a global data structure
if (loplugin::isSamePathname(aFileName, SRCDIR "/vcl/inc/print.h"))
return;
diff --git a/sw/inc/doc.hxx b/sw/inc/doc.hxx
index 5aac6bcd5061..ff1ba91a3f79 100644
--- a/sw/inc/doc.hxx
+++ b/sw/inc/doc.hxx
@@ -225,42 +225,42 @@ class SW_DLLPUBLIC SwDoc final
const std::unique_ptr< ::sw::DocumentExternalDataManager > m_pDocumentExternalDataManager;
// Pointer
- SwFrameFormat *mpDfltFrameFormat; //< Default formats.
- SwFrameFormat *mpEmptyPageFormat; //< Format for the default empty page
- SwFrameFormat *mpColumnContFormat; //< Format for column container
- SwCharFormat *mpDfltCharFormat;
- SwTextFormatColl *mpDfltTextFormatColl; //< Defaultformatcollections
- SwGrfFormatColl *mpDfltGrfFormatColl;
-
- SwFrameFormats *mpFrameFormatTable; //< Format table
- SwCharFormats *mpCharFormatTable;
- SwFrameFormats *mpSpzFrameFormatTable;
- SwSectionFormats *mpSectionFormatTable;
- SwFrameFormats *mpTableFrameFormatTable; //< For tables
- SwTextFormatColls *mpTextFormatCollTable; //< FormatCollections
- SwGrfFormatColls *mpGrfFormatCollTable;
-
- SwTOXTypes *mpTOXTypes; //< Tables/indices
- SwDefTOXBase_Impl * mpDefTOXBases; //< defaults of SwTOXBase's
+ std::unique_ptr<SwFrameFormat> mpDfltFrameFormat; //< Default formats.
+ std::unique_ptr<SwFrameFormat> mpEmptyPageFormat; //< Format for the default empty page
+ std::unique_ptr<SwFrameFormat> mpColumnContFormat; //< Format for column container
+ std::unique_ptr<SwCharFormat> mpDfltCharFormat;
+ std::unique_ptr<SwTextFormatColl> mpDfltTextFormatColl; //< Defaultformatcollections
+ std::unique_ptr<SwGrfFormatColl> mpDfltGrfFormatColl;
+
+ std::unique_ptr<SwFrameFormats> mpFrameFormatTable; //< Format table
+ std::unique_ptr<SwCharFormats> mpCharFormatTable;
+ std::unique_ptr<SwFrameFormats> mpSpzFrameFormatTable;
+ std::unique_ptr<SwSectionFormats> mpSectionFormatTable;
+ std::unique_ptr<SwFrameFormats> mpTableFrameFormatTable; //< For tables
+ std::unique_ptr<SwTextFormatColls> mpTextFormatCollTable; //< FormatCollections
+ std::unique_ptr<SwGrfFormatColls> mpGrfFormatCollTable;
+
+ std::unique_ptr<SwTOXTypes> mpTOXTypes; //< Tables/indices
+ std::unique_ptr<SwDefTOXBase_Impl> mpDefTOXBases; //< defaults of SwTOXBase's
std::unique_ptr<SwDBManager, o3tl::default_delete<SwDBManager>> m_pOwnDBManager; //< own DBManager
SwDBManager * m_pDBManager; //< DBManager for evaluation of DB-fields.
SwNumRule *mpOutlineRule;
- SwFootnoteInfo *mpFootnoteInfo;
- SwEndNoteInfo *mpEndNoteInfo;
- SwLineNumberInfo*mpLineNumberInfo;
- SwFootnoteIdxs *mpFootnoteIdxs;
+ std::unique_ptr<SwFootnoteInfo> mpFootnoteInfo;
+ std::unique_ptr<SwEndNoteInfo> mpEndNoteInfo;
+ std::unique_ptr<SwLineNumberInfo> mpLineNumberInfo;
+ std::unique_ptr<SwFootnoteIdxs> mpFootnoteIdxs;
SwDocShell *mpDocShell; //< Ptr to SfxDocShell of Doc.
SfxObjectShellLock mxTmpDocShell; //< A temporary shell that is used to copy OLE-Nodes
- SwAutoCorrExceptWord *mpACEWord; /**< For the automated takeover of
+ std::unique_ptr<SwAutoCorrExceptWord> mpACEWord; /**< For the automated takeover of
auto-corrected words that are "re-corrected". */
- SwURLStateChanged *mpURLStateChgd; //< SfxClient for changes in INetHistory
- SvNumberFormatter *mpNumberFormatter; //< NumFormatter for tables / fields
+ std::unique_ptr<SwURLStateChanged> mpURLStateChgd; //< SfxClient for changes in INetHistory
+ std::unique_ptr<SvNumberFormatter> mpNumberFormatter; //< NumFormatter for tables / fields
- mutable SwNumRuleTable *mpNumRuleTable; //< List of all named NumRules.
+ mutable std::unique_ptr<SwNumRuleTable> mpNumRuleTable; //< List of all named NumRules.
// Hash map to find numrules by name
mutable std::unordered_map<OUString, SwNumRule *> maNumRuleMap;
@@ -268,11 +268,11 @@ class SW_DLLPUBLIC SwDoc final
std::unique_ptr<SwPagePreviewPrtData> m_pPgPViewPrtData; //< Indenting / spacing for printing of page view.
SwExtTextInput *mpExtInputRing;
- IStyleAccess *mpStyleAccess; //< handling of automatic styles
- SwLayoutCache *mpLayoutCache; /**< Layout cache to read and save with the
- document for a faster formatting */
+ std::unique_ptr<IStyleAccess> mpStyleAccess; //< handling of automatic styles
+ std::unique_ptr<SwLayoutCache> mpLayoutCache; /**< Layout cache to read and save with the
+ document for a faster formatting */
- IGrammarContact *mpGrammarContact; //< for grammar checking in paragraphs during editing
+ std::unique_ptr<IGrammarContact> mpGrammarContact; //< for grammar checking in paragraphs during editing
css::uno::Reference< css::script::vba::XVBAEventProcessor > mxVbaEvents;
css::uno::Reference<css::container::XNameContainer> m_xTemplateToProjectCache;
@@ -719,23 +719,23 @@ public:
bool DontExpandFormat( const SwPosition& rPos, bool bFlag = true );
// Formats
- const SwFrameFormats* GetFrameFormats() const { return mpFrameFormatTable; }
- SwFrameFormats* GetFrameFormats() { return mpFrameFormatTable; }
- const SwCharFormats* GetCharFormats() const { return mpCharFormatTable;}
- SwCharFormats* GetCharFormats() { return mpCharFormatTable;}
+ const SwFrameFormats* GetFrameFormats() const { return mpFrameFormatTable.get(); }
+ SwFrameFormats* GetFrameFormats() { return mpFrameFormatTable.get(); }
+ const SwCharFormats* GetCharFormats() const { return mpCharFormatTable.get();}
+ SwCharFormats* GetCharFormats() { return mpCharFormatTable.get();}
// LayoutFormats (frames, DrawObjects), sometimes const sometimes not
- const SwFrameFormats* GetSpzFrameFormats() const { return mpSpzFrameFormatTable; }
- SwFrameFormats* GetSpzFrameFormats() { return mpSpzFrameFormatTable; }
-
- const SwFrameFormat *GetDfltFrameFormat() const { return mpDfltFrameFormat; }
- SwFrameFormat *GetDfltFrameFormat() { return mpDfltFrameFormat; }
- const SwFrameFormat *GetEmptyPageFormat() const { return mpEmptyPageFormat; }
- SwFrameFormat *GetEmptyPageFormat() { return mpEmptyPageFormat; }
- const SwFrameFormat *GetColumnContFormat() const{ return mpColumnContFormat; }
- SwFrameFormat *GetColumnContFormat() { return mpColumnContFormat; }
- const SwCharFormat *GetDfltCharFormat() const { return mpDfltCharFormat;}
- SwCharFormat *GetDfltCharFormat() { return mpDfltCharFormat;}
+ const SwFrameFormats* GetSpzFrameFormats() const { return mpSpzFrameFormatTable.get(); }
+ SwFrameFormats* GetSpzFrameFormats() { return mpSpzFrameFormatTable.get(); }
+
+ const SwFrameFormat *GetDfltFrameFormat() const { return mpDfltFrameFormat.get(); }
+ SwFrameFormat *GetDfltFrameFormat() { return mpDfltFrameFormat.get(); }
+ const SwFrameFormat *GetEmptyPageFormat() const { return mpEmptyPageFormat.get(); }
+ SwFrameFormat *GetEmptyPageFormat() { return mpEmptyPageFormat.get(); }
+ const SwFrameFormat *GetColumnContFormat() const{ return mpColumnContFormat.get(); }
+ SwFrameFormat *GetColumnContFormat() { return mpColumnContFormat.get(); }
+ const SwCharFormat *GetDfltCharFormat() const { return mpDfltCharFormat.get();}
+ SwCharFormat *GetDfltCharFormat() { return mpDfltCharFormat.get();}
// @return the interface of the management of (auto)styles
IStyleAccess& GetIStyleAccess() { return *mpStyleAccess; }
@@ -758,10 +758,10 @@ public:
// Formatcollections (styles)
// TXT
- const SwTextFormatColl* GetDfltTextFormatColl() const { return mpDfltTextFormatColl; }
- SwTextFormatColl* GetDfltTextFormatColl() { return mpDfltTextFormatColl; }
- const SwTextFormatColls *GetTextFormatColls() const { return mpTextFormatCollTable; }
- SwTextFormatColls *GetTextFormatColls() { return mpTextFormatCollTable; }
+ const SwTextFormatColl* GetDfltTextFormatColl() const { return mpDfltTextFormatColl.get(); }
+ SwTextFormatColl* GetDfltTextFormatColl() { return mpDfltTextFormatColl.get(); }
+ const SwTextFormatColls *GetTextFormatColls() const { return mpTextFormatCollTable.get(); }
+ SwTextFormatColls *GetTextFormatColls() { return mpTextFormatCollTable.get(); }
SwTextFormatColl *MakeTextFormatColl( const OUString &rFormatName,
SwTextFormatColl *pDerivedFrom,
bool bBroadcast = false);
@@ -785,15 +785,15 @@ public:
void ChkCondColls();
- const SwGrfFormatColl* GetDfltGrfFormatColl() const { return mpDfltGrfFormatColl; }
- SwGrfFormatColl* GetDfltGrfFormatColl() { return mpDfltGrfFormatColl; }
- const SwGrfFormatColls *GetGrfFormatColls() const { return mpGrfFormatCollTable; }
+ const SwGrfFormatColl* GetDfltGrfFormatColl() const { return mpDfltGrfFormatColl.get(); }
+ SwGrfFormatColl* GetDfltGrfFormatColl() { return mpDfltGrfFormatColl.get(); }
+ const SwGrfFormatColls *GetGrfFormatColls() const { return mpGrfFormatCollTable.get(); }
SwGrfFormatColl *MakeGrfFormatColl(const OUString &rFormatName,
SwGrfFormatColl *pDerivedFrom);
// Table formatting
- const SwFrameFormats* GetTableFrameFormats() const { return mpTableFrameFormatTable; }
- SwFrameFormats* GetTableFrameFormats() { return mpTableFrameFormatTable; }
+ const SwFrameFormats* GetTableFrameFormats() const { return mpTableFrameFormatTable.get(); }
+ SwFrameFormats* GetTableFrameFormats() { return mpTableFrameFormatTable.get(); }
size_t GetTableFrameFormatCount( bool bUsed ) const;
SwFrameFormat& GetTableFrameFormat(size_t nFormat, bool bUsed ) const;
SwTableFormat* MakeTableFrameFormat(const OUString &rFormatName, SwFrameFormat *pDerivedFrom);
@@ -1350,8 +1350,8 @@ public:
bool IsVisitedURL( const OUString& rURL );
// Save current values for automatic registration of exceptions in Autocorrection.
- void SetAutoCorrExceptWord( SwAutoCorrExceptWord* pNew );
- SwAutoCorrExceptWord* GetAutoCorrExceptWord() { return mpACEWord; }
+ void SetAutoCorrExceptWord( std::unique_ptr<SwAutoCorrExceptWord> pNew );
+ SwAutoCorrExceptWord* GetAutoCorrExceptWord() { return mpACEWord.get(); }
void DeleteAutoCorrExceptWord();
const SwFormatINetFormat* FindINetAttr( const OUString& rName ) const;
@@ -1485,7 +1485,7 @@ public:
void ReadLayoutCache( SvStream& rStream );
void WriteLayoutCache( SvStream& rStream );
- SwLayoutCache* GetLayoutCache() const { return mpLayoutCache; }
+ SwLayoutCache* GetLayoutCache() const { return mpLayoutCache.get(); }
/** Checks if any of the text node contains hidden characters.
Used for optimization. Changing the view option 'view hidden text'
@@ -1493,7 +1493,7 @@ public:
*/
bool ContainsHiddenChars() const;
- IGrammarContact* getGrammarContact() const { return mpGrammarContact; }
+ IGrammarContact* getGrammarContact() const { return mpGrammarContact.get(); }
/** Marks/Unmarks a list level of a certain list
@@ -1617,7 +1617,7 @@ inline SvNumberFormatter* SwDoc::GetNumberFormatter( bool bCreate )
{
if( bCreate && !mpNumberFormatter )
CreateNumberFormatter();
- return mpNumberFormatter;
+ return mpNumberFormatter.get();
}
inline const SvNumberFormatter* SwDoc::GetNumberFormatter( bool bCreate ) const
diff --git a/sw/source/core/doc/docedt.cxx b/sw/source/core/doc/docedt.cxx
index 68087a0fb1b6..89454ea879ae 100644
--- a/sw/source/core/doc/docedt.cxx
+++ b/sw/source/core/doc/docedt.cxx
@@ -798,17 +798,14 @@ uno::Reference< XHyphenatedWord > SwDoc::Hyphenate(
}
// Save the current values to add them as automatic entries to AutoCorrect.
-void SwDoc::SetAutoCorrExceptWord( SwAutoCorrExceptWord* pNew )
+void SwDoc::SetAutoCorrExceptWord( std::unique_ptr<SwAutoCorrExceptWord> pNew )
{
- if( pNew != mpACEWord )
- delete mpACEWord;
- mpACEWord = pNew;
+ mpACEWord = std::move(pNew);
}
void SwDoc::DeleteAutoCorrExceptWord()
{
- delete mpACEWord;
- mpACEWord = nullptr;
+ mpACEWord.reset();
}
void SwDoc::CountWords( const SwPaM& rPaM, SwDocStat& rStat )
diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx
index e7e42b679554..2a41f7bbb7b8 100644
--- a/sw/source/core/doc/docfmt.cxx
+++ b/sw/source/core/doc/docfmt.cxx
@@ -568,29 +568,29 @@ void SwDoc::SetDefault( const SfxItemSet& rSet )
if (isCHRATR(nWhich) || isTXTATR(nWhich))
{
- aCallMod.Add( mpDfltTextFormatColl );
- aCallMod.Add( mpDfltCharFormat );
+ aCallMod.Add( mpDfltTextFormatColl.get() );
+ aCallMod.Add( mpDfltCharFormat.get() );
bCheckSdrDflt = nullptr != pSdrPool;
}
else if ( isPARATR(nWhich) ||
isPARATR_LIST(nWhich) )
{
- aCallMod.Add( mpDfltTextFormatColl );
+ aCallMod.Add( mpDfltTextFormatColl.get() );
bCheckSdrDflt = nullptr != pSdrPool;
}
else if (isGRFATR(nWhich))
{
- aCallMod.Add( mpDfltGrfFormatColl );
+ aCallMod.Add( mpDfltGrfFormatColl.get() );
}
else if (isFRMATR(nWhich) || isDrawingLayerAttribute(nWhich) )
{
- aCallMod.Add( mpDfltGrfFormatColl );
- aCallMod.Add( mpDfltTextFormatColl );
- aCallMod.Add( mpDfltFrameFormat );
+ aCallMod.Add( mpDfltGrfFormatColl.get() );
+ aCallMod.Add( mpDfltTextFormatColl.get() );
+ aCallMod.Add( mpDfltFrameFormat.get() );
}
else if (isBOXATR(nWhich))
{
- aCallMod.Add( mpDfltFrameFormat );
+ aCallMod.Add( mpDfltFrameFormat.get() );
}
// also copy the defaults
@@ -644,7 +644,7 @@ void SwDoc::SetDefault( const SfxItemSet& rSet )
aOld.ClearItem( RES_PARATR_TABSTOP );
if( bChg )
{
- SwFormatChg aChgFormat( mpDfltCharFormat );
+ SwFormatChg aChgFormat( mpDfltCharFormat.get() );
// notify the frames
aCallMod.ModifyNotification( &aChgFormat, &aChgFormat );
}
@@ -968,7 +968,7 @@ void SwDoc::DelTextFormatColl(size_t nFormatColl, bool bBroadcast)
// Who has the to-be-deleted as their Next?
SwTextFormatColl *pDel = (*mpTextFormatCollTable)[nFormatColl];
- if( mpDfltTextFormatColl == pDel )
+ if( mpDfltTextFormatColl.get() == pDel )
return; // never delete default!
if (bBroadcast)
@@ -1171,7 +1171,7 @@ SwTextFormatColl* SwDoc::CopyTextColl( const SwTextFormatColl& rColl )
return pNewColl;
// search for the "parent" first
- SwTextFormatColl* pParent = mpDfltTextFormatColl;
+ SwTextFormatColl* pParent = mpDfltTextFormatColl.get();
if( pParent != rColl.DerivedFrom() )
pParent = CopyTextColl( *static_cast<SwTextFormatColl*>(rColl.DerivedFrom()) );
@@ -1238,7 +1238,7 @@ SwGrfFormatColl* SwDoc::CopyGrfColl( const SwGrfFormatColl& rColl )
return pNewColl;
// Search for the "parent" first
- SwGrfFormatColl* pParent = mpDfltGrfFormatColl;
+ SwGrfFormatColl* pParent = mpDfltGrfFormatColl.get();
if( pParent != rColl.DerivedFrom() )
pParent = CopyGrfColl( *static_cast<SwGrfFormatColl*>(rColl.DerivedFrom()) );
@@ -1700,14 +1700,14 @@ bool SwDoc::DontExpandFormat( const SwPosition& rPos, bool bFlag )
SwTableBoxFormat* SwDoc::MakeTableBoxFormat()
{
- SwTableBoxFormat* pFormat = new SwTableBoxFormat( GetAttrPool(), mpDfltFrameFormat );
+ SwTableBoxFormat* pFormat = new SwTableBoxFormat( GetAttrPool(), mpDfltFrameFormat.get() );
getIDocumentState().SetModified();
return pFormat;
}
SwTableLineFormat* SwDoc::MakeTableLineFormat()
{
- SwTableLineFormat* pFormat = new SwTableLineFormat( GetAttrPool(), mpDfltFrameFormat );
+ SwTableLineFormat* pFormat = new SwTableLineFormat( GetAttrPool(), mpDfltFrameFormat.get() );
getIDocumentState().SetModified();
return pFormat;
}
@@ -1718,7 +1718,7 @@ void SwDoc::CreateNumberFormatter()
LanguageType eLang = LANGUAGE_SYSTEM;
- mpNumberFormatter = new SvNumberFormatter( comphelper::getProcessComponentContext(), eLang );
+ mpNumberFormatter.reset( new SvNumberFormatter( comphelper::getProcessComponentContext(), eLang ) );
mpNumberFormatter->SetEvalDateFormat( NF_EVALDATEFORMAT_FORMAT_INTL );
if (!utl::ConfigManager::IsFuzzing())
mpNumberFormatter->SetYear2000(static_cast<sal_uInt16>(::utl::MiscCfg().GetYear2000()));
diff --git a/sw/source/core/doc/doclay.cxx b/sw/source/core/doc/doclay.cxx
index 86ad696d877a..e6dba60efc3b 100644
--- a/sw/source/core/doc/doclay.cxx
+++ b/sw/source/core/doc/doclay.cxx
@@ -983,7 +983,7 @@ SwDoc::InsertLabel(
bBefore, nId, rCharacterStyle, bCpyBrd, this );
}
- SwFlyFrameFormat *const pNewFormat = lcl_InsertLabel(*this, mpTextFormatCollTable, pUndo,
+ SwFlyFrameFormat *const pNewFormat = lcl_InsertLabel(*this, mpTextFormatCollTable.get(), pUndo,
eType, rText, rSeparator, rNumberingSeparator, bBefore,
nId, nNdIdx, rCharacterStyle, bCpyBrd);
@@ -1270,7 +1270,7 @@ SwFlyFrameFormat* SwDoc::InsertDrawLabel(
}
SwFlyFrameFormat *const pNewFormat = lcl_InsertDrawLabel(
- *this, mpTextFormatCollTable, pUndo, pOldFormat,
+ *this, mpTextFormatCollTable.get(), pUndo, pOldFormat,
rText, rSeparator, rNumberSeparator, nId, rCharacterStyle, rSdrObj);
if (pUndo)
diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx
index 07fca37917bb..eca99322d09a 100644
--- a/sw/source/core/doc/docnew.cxx
+++ b/sw/source/core/doc/docnew.cxx
@@ -231,8 +231,8 @@ SwDoc::SwDoc()
m_pDocumentStylePoolManager( new ::sw::DocumentStylePoolManager( *this ) ),
m_pDocumentExternalDataManager( new ::sw::DocumentExternalDataManager ),
mpDfltFrameFormat( new SwFrameFormat( GetAttrPool(), "Frameformat", nullptr ) ),
- mpEmptyPageFormat( new SwFrameFormat( GetAttrPool(), "Empty Page", mpDfltFrameFormat ) ),
- mpColumnContFormat( new SwFrameFormat( GetAttrPool(), "Columncontainer", mpDfltFrameFormat ) ),
+ mpEmptyPageFormat( new SwFrameFormat( GetAttrPool(), "Empty Page", mpDfltFrameFormat.get() ) ),
+ mpColumnContFormat( new SwFrameFormat( GetAttrPool(), "Columncontainer", mpDfltFrameFormat.get() ) ),
mpDfltCharFormat( new SwCharFormat( GetAttrPool(), "Character style", nullptr ) ),
mpDfltTextFormatColl( new SwTextFormatColl( GetAttrPool(), "Paragraph style" ) ),
mpDfltGrfFormatColl( new SwGrfFormatColl( GetAttrPool(), "Graphikformatvorlage" ) ),
@@ -307,14 +307,14 @@ SwDoc::SwDoc()
* DefaultFormats and are also in the list.
*/
/* Formats */
- mpFrameFormatTable->push_back(mpDfltFrameFormat);
- mpCharFormatTable->push_back(mpDfltCharFormat);
+ mpFrameFormatTable->push_back(mpDfltFrameFormat.get());
+ mpCharFormatTable->push_back(mpDfltCharFormat.get());
/* FormatColls */
// TXT
- mpTextFormatCollTable->push_back(mpDfltTextFormatColl);
+ mpTextFormatCollTable->push_back(mpDfltTextFormatColl.get());
// GRF
- mpGrfFormatCollTable->push_back(mpDfltGrfFormatColl);
+ mpGrfFormatCollTable->push_back(mpDfltGrfFormatColl.get());
// Create PageDesc, EmptyPageFormat and ColumnFormat
if (m_PageDescs.empty())
@@ -338,7 +338,7 @@ SwDoc::SwDoc()
new SwTextNode(
SwNodeIndex(GetUndoManager().GetUndoNodes().GetEndOfContent()),
- mpDfltTextFormatColl );
+ mpDfltTextFormatColl.get() );
new SwTextNode( SwNodeIndex( GetNodes().GetEndOfContent() ),
getIDocumentStylePoolAccess().GetTextCollFromPool( RES_POOLCOLL_STANDARD ));
@@ -394,12 +394,11 @@ SwDoc::~SwDoc()
mpDocShell->SetUndoManager(nullptr);
}
- delete mpGrammarContact;
- mpGrammarContact = nullptr;
+ mpGrammarContact.reset();
getIDocumentTimerAccess().StopIdling(); // stop idle timer
- delete mpURLStateChgd;
+ mpURLStateChgd.reset();
// Deactivate Undo notification from Draw
if( GetDocumentDrawModelManager().GetDrawModel() )
@@ -424,7 +423,7 @@ SwDoc::~SwDoc()
if(pCursor)
pCursor->m_aNotifier.Broadcast(aHint);
}
- delete mpACEWord;
+ mpACEWord.reset();
// Release the BaseLinks
{
@@ -471,7 +470,7 @@ SwDoc::~SwDoc()
}
mpTOXTypes->clear();
}
- delete mpDefTOXBases;
+ mpDefTOXBases.reset();
// Any of the FrameFormats can still have indices registered.
// These need to be destroyed now at the latest.
@@ -503,7 +502,7 @@ SwDoc::~SwDoc()
mpFootnoteInfo->EndListeningAll();
mpEndNoteInfo->EndListeningAll();
- assert(mpDfltTextFormatColl == (*mpTextFormatCollTable)[0]
+ assert(mpDfltTextFormatColl.get() == (*mpTextFormatCollTable)[0]
&& "Default-Text-Collection must always be at the start");
// Optimization: Based on the fact that Standard is always 2nd in the
@@ -512,13 +511,13 @@ SwDoc::~SwDoc()
if( 2 < mpTextFormatCollTable->size() )
mpTextFormatCollTable->DeleteAndDestroy(2, mpTextFormatCollTable->size());
mpTextFormatCollTable->DeleteAndDestroy(1, mpTextFormatCollTable->size());
- delete mpTextFormatCollTable;
+ mpTextFormatCollTable.reset();
- assert(mpDfltGrfFormatColl == (*mpGrfFormatCollTable)[0]
+ assert(mpDfltGrfFormatColl.get() == (*mpGrfFormatCollTable)[0]
&& "DefaultGrfCollection must always be at the start");
mpGrfFormatCollTable->DeleteAndDestroy(1, mpGrfFormatCollTable->size());
- delete mpGrfFormatCollTable;
+ mpGrfFormatCollTable.reset();
// Without explicitly freeing the DocumentDeviceManager
// and relying on the implicit freeing there would be a crash
@@ -570,31 +569,31 @@ SwDoc::~SwDoc()
// Clear the Tables before deleting the defaults, or we crash due to
// dependencies on defaults.
- delete mpFrameFormatTable;
- delete mpSpzFrameFormatTable;
+ mpFrameFormatTable.reset();
+ mpSpzFrameFormatTable.reset();
- delete mpStyleAccess;
+ mpStyleAccess.reset();
- delete mpCharFormatTable;
- delete mpSectionFormatTable;
- delete mpTableFrameFormatTable;
- delete mpDfltTextFormatColl;
- delete mpDfltGrfFormatColl;
- delete mpNumRuleTable;
+ mpCharFormatTable.reset();
+ mpSectionFormatTable.reset();
+ mpTableFrameFormatTable.reset();
+ mpDfltTextFormatColl.reset();
+ mpDfltGrfFormatColl.reset();
+ mpNumRuleTable.reset();
disposeXForms(); // #i113606#, dispose the XForms objects
- delete mpNumberFormatter;
- delete mpFootnoteInfo;
- delete mpEndNoteInfo;
- delete mpLineNumberInfo;
- delete mpFootnoteIdxs;
- delete mpTOXTypes;
- delete mpEmptyPageFormat;
- delete mpColumnContFormat;
- delete mpDfltCharFormat;
- delete mpDfltFrameFormat;
- delete mpLayoutCache;
+ mpNumberFormatter.reset();
+ mpFootnoteInfo.reset();
+ mpEndNoteInfo.reset();
+ mpLineNumberInfo.reset();
+ mpFootnoteIdxs.reset();
+ mpTOXTypes.reset();
+ mpEmptyPageFormat.reset();
+ mpColumnContFormat.reset();
+ mpDfltCharFormat.reset();
+ mpDfltFrameFormat.reset();
+ mpLayoutCache.reset();
SfxItemPool::Free(mpAttrPool);
}
@@ -659,7 +658,7 @@ void SwDoc::ClearDoc()
getIDocumentRedlineAccess().GetRedlineTable().DeleteAndDestroyAll();
getIDocumentRedlineAccess().GetExtraRedlineTable().DeleteAndDestroyAll();
- delete mpACEWord;
+ mpACEWord.reset();
// The BookMarks contain indices to the Content. These must be deleted
// before deleting the Nodes.
@@ -671,7 +670,7 @@ void SwDoc::ClearDoc()
SwNodeIndex aSttIdx( *GetNodes().GetEndOfContent().StartOfSectionNode(), 1 );
// create the first one over and over again (without attributes/style etc.
- SwTextNode* pFirstNd = GetNodes().MakeTextNode( aSttIdx, mpDfltTextFormatColl );
+ SwTextNode* pFirstNd = GetNodes().MakeTextNode( aSttIdx, mpDfltTextFormatColl.get() );
if( getIDocumentLayoutAccess().GetCurrentViewShell() )
{
@@ -741,8 +740,7 @@ void SwDoc::ClearDoc()
GetDocumentFieldsManager().ClearFieldTypes();
- delete mpNumberFormatter;
- mpNumberFormatter = nullptr;
+ mpNumberFormatter.reset();
getIDocumentStylePoolAccess().GetPageDescFromPool( RES_POOLPAGE_STANDARD );
pFirstNd->ChgFormatColl( getIDocumentStylePoolAccess().GetTextCollFromPool( RES_POOLCOLL_STANDARD ));
@@ -783,7 +781,7 @@ void SwDoc::SetOLEObjModified()
void SwDoc::ReadLayoutCache( SvStream& rStream )
{
if( !mpLayoutCache )
- mpLayoutCache = new SwLayoutCache();
+ mpLayoutCache.reset( new SwLayoutCache() );
if( !mpLayoutCache->IsLocked() )
{
mpLayoutCache->GetLockCount() |= 0x8000;
diff --git a/sw/source/core/doc/swstylemanager.cxx b/sw/source/core/doc/swstylemanager.cxx
index e6bbab2822a8..40ca237164b8 100644
--- a/sw/source/core/doc/swstylemanager.cxx
+++ b/sw/source/core/doc/swstylemanager.cxx
@@ -25,6 +25,7 @@
#include <swtypes.hxx>
#include <istyleaccess.hxx>
#include <unordered_map>
+#include <o3tl/make_unique.hxx>
typedef std::unordered_map< OUString,
std::shared_ptr<SfxItemSet> > SwStyleNameCache;
@@ -77,9 +78,9 @@ public:
virtual void clearCaches() override;
};
-IStyleAccess *createStyleManager( SfxItemSet const * pIgnorableParagraphItems )
+std::unique_ptr<IStyleAccess> createStyleManager( SfxItemSet const * pIgnorableParagraphItems )
{
- return new SwStyleManager( pIgnorableParagraphItems );
+ return o3tl::make_unique<SwStyleManager>( pIgnorableParagraphItems );
}
void SwStyleManager::clearCaches()
diff --git a/sw/source/core/doc/swstylemanager.hxx b/sw/source/core/doc/swstylemanager.hxx
index 9b6aa18d4244..b1301b2f13f6 100644
--- a/sw/source/core/doc/swstylemanager.hxx
+++ b/sw/source/core/doc/swstylemanager.hxx
@@ -20,10 +20,13 @@
#ifndef INCLUDED_SW_SOURCE_CORE_DOC_SWSTYLEMANAGER_HXX
#define INCLUDED_SW_SOURCE_CORE_DOC_SWSTYLEMANAGER_HXX
+#include <memory>
+
class IStyleAccess;
class SfxItemSet;
-IStyleAccess *createStyleManager( SfxItemSet const * pIgnorableParagraphItems );
+std::unique_ptr<IStyleAccess> createStyleManager( SfxItemSet const * pIgnorableParagraphItems );
+
#endif // INCLUDED_SW_SOURCE_CORE_DOC_SWSTYLEMANAGER_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/doc/visiturl.cxx b/sw/source/core/doc/visiturl.cxx
index fcc5677ef756..9a17df6b2010 100644
--- a/sw/source/core/doc/visiturl.cxx
+++ b/sw/source/core/doc/visiturl.cxx
@@ -117,7 +117,7 @@ bool SwDoc::IsVisitedURL( const OUString& rURL )
if( !mpURLStateChgd )
{
SwDoc* pD = this;
- pD->mpURLStateChgd = new SwURLStateChanged( this );
+ pD->mpURLStateChgd.reset( new SwURLStateChanged( this ) );
}
}
return bRet;
diff --git a/sw/source/core/docnode/ndsect.cxx b/sw/source/core/docnode/ndsect.cxx
index fcd4e533b179..1bb8146b9f47 100644
--- a/sw/source/core/docnode/ndsect.cxx
+++ b/sw/source/core/docnode/ndsect.cxx
@@ -505,7 +505,7 @@ SwSection* SwDoc::GetCurrSection( const SwPosition& rPos )
SwSectionFormat* SwDoc::MakeSectionFormat()
{
- SwSectionFormat* pNew = new SwSectionFormat( mpDfltFrameFormat, this );
+ SwSectionFormat* pNew = new SwSectionFormat( mpDfltFrameFormat.get(), this );
mpSectionFormatTable->push_back( pNew );
return pNew;
}
diff --git a/sw/source/core/edit/acorrect.cxx b/sw/source/core/edit/acorrect.cxx
index e8f4a72e9e9b..f5dbd66c27a4 100644
--- a/sw/source/core/edit/acorrect.cxx
+++ b/sw/source/core/edit/acorrect.cxx
@@ -34,6 +34,7 @@
#include <viscrs.hxx>
#include <editeng/acorrcfg.hxx>
+#include <o3tl/make_unique.hxx>
using namespace ::com::sun::star;
@@ -416,7 +417,7 @@ void SwAutoCorrDoc::SaveCpltSttWord( ACFlags nFlag, sal_Int32 nPos,
{
sal_uLong nNode = pIdx ? pIdx->GetIndex() : rCursor.GetPoint()->nNode.GetIndex();
LanguageType eLang = GetLanguage(nPos);
- rEditSh.GetDoc()->SetAutoCorrExceptWord( new SwAutoCorrExceptWord( nFlag,
+ rEditSh.GetDoc()->SetAutoCorrExceptWord( o3tl::make_unique<SwAutoCorrExceptWord>( nFlag,
nNode, nPos, rExceptWord, cChar, eLang ));
}