diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-07-14 14:36:52 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-07-17 07:23:22 +0200 |
commit | db3860062ebf4109f48139c2556ff4041aff5d6e (patch) | |
tree | b6ab4df909c8922e48a9c4eefa9a8f0f6a47c41f /sw | |
parent | 846f557fd591626931a9dadb38180786e090104c (diff) |
extend loplugin useuniqueptr to OUString pointers
Change-Id: Ieb5bab3895e1edaff497c4a1a88303ccac097edc
Reviewed-on: https://gerrit.libreoffice.org/39948
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/doc/DocumentRedlineManager.cxx | 9 | ||||
-rw-r--r-- | sw/source/core/inc/DocumentRedlineManager.hxx | 3 | ||||
-rw-r--r-- | sw/source/core/inc/UndoDelete.hxx | 3 | ||||
-rw-r--r-- | sw/source/core/inc/UndoInsert.hxx | 9 | ||||
-rw-r--r-- | sw/source/core/undo/undel.cxx | 12 | ||||
-rw-r--r-- | sw/source/core/undo/unins.cxx | 36 | ||||
-rw-r--r-- | sw/source/uibase/inc/toxmgr.hxx | 80 |
7 files changed, 65 insertions, 87 deletions
diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx b/sw/source/core/doc/DocumentRedlineManager.cxx index d4f117ebc66b..601a57db22fe 100644 --- a/sw/source/core/doc/DocumentRedlineManager.cxx +++ b/sw/source/core/doc/DocumentRedlineManager.cxx @@ -2659,15 +2659,11 @@ void DocumentRedlineManager::SetAutoFormatRedlineComment( const OUString* pText, m_rDoc.SetAutoFormatRedline( nullptr != pText ); if( pText ) { - if( !mpAutoFormatRedlnComment ) - mpAutoFormatRedlnComment = new OUString( *pText ); - else - *mpAutoFormatRedlnComment = *pText; + mpAutoFormatRedlnComment.reset( new OUString( *pText ) ); } else { - delete mpAutoFormatRedlnComment; - mpAutoFormatRedlnComment = nullptr; + mpAutoFormatRedlnComment.reset(); } mnAutoFormatRedlnCommentNo = nSeqNo; @@ -2697,7 +2693,6 @@ DocumentRedlineManager::~DocumentRedlineManager() { delete mpRedlineTable; mpRedlineTable = nullptr; delete mpExtraRedlineTable; mpExtraRedlineTable = nullptr; - delete mpAutoFormatRedlnComment; mpAutoFormatRedlnComment = nullptr; } } diff --git a/sw/source/core/inc/DocumentRedlineManager.hxx b/sw/source/core/inc/DocumentRedlineManager.hxx index 2a5c1cd24d1f..eeea5f23ace9 100644 --- a/sw/source/core/inc/DocumentRedlineManager.hxx +++ b/sw/source/core/inc/DocumentRedlineManager.hxx @@ -21,6 +21,7 @@ #define INCLUDED_SW_SOURCE_CORE_INC_DOCUMENTREDLINEMANAGER_HXX #include <IDocumentRedlineAccess.hxx> +#include <memory> class SwDoc; @@ -131,7 +132,7 @@ private: RedlineFlags meRedlineFlags; //< Current Redline Mode. SwRedlineTable *mpRedlineTable; //< List of all Ranged Redlines. SwExtraRedlineTable *mpExtraRedlineTable; //< List of all Extra Redlines. - OUString *mpAutoFormatRedlnComment; //< Comment for Redlines inserted via AutoFormat. + std::unique_ptr<OUString> mpAutoFormatRedlnComment; //< Comment for Redlines inserted via AutoFormat. bool mbIsRedlineMove; //< true: Redlines are moved into to / out of the section. bool mbReadlineChecked; //< true: if the query was already shown sal_uInt16 mnAutoFormatRedlnCommentNo; /**< SeqNo for conjoining of AutoFormat-Redlines. diff --git a/sw/source/core/inc/UndoDelete.hxx b/sw/source/core/inc/UndoDelete.hxx index 2a0c9fc5ffef..a29993610cd2 100644 --- a/sw/source/core/inc/UndoDelete.hxx +++ b/sw/source/core/inc/UndoDelete.hxx @@ -23,6 +23,7 @@ #include <undobj.hxx> #include <rtl/ustring.hxx> #include <tools/mempool.hxx> +#include <memory> class SwRedlineSaveDatas; class SwTextNode; @@ -37,7 +38,7 @@ class SwUndoDelete , private SwUndoSaveContent { SwNodeIndex* m_pMvStt; // Position of Nodes in UndoNodes-Array - OUString *m_pSttStr, *m_pEndStr; + std::unique_ptr<OUString> m_pSttStr, m_pEndStr; SwRedlineSaveDatas* m_pRedlSaveData; std::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndoStart; std::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndoEnd; diff --git a/sw/source/core/inc/UndoInsert.hxx b/sw/source/core/inc/UndoInsert.hxx index 9af50eb0efdb..7ee2266e8508 100644 --- a/sw/source/core/inc/UndoInsert.hxx +++ b/sw/source/core/inc/UndoInsert.hxx @@ -41,7 +41,8 @@ class SwUndoInsert: public SwUndo, private SwUndoSaveContent { /// start of Content in UndoNodes for Redo std::unique_ptr<SwNodeIndex> m_pUndoNodeIndex; - OUString *pText, *pUndoText; + OUString *pText; + std::unique_ptr<OUString> pUndoText; SwRedlineData* pRedlData; sal_uLong nNode; sal_Int32 nContent, nLen; @@ -135,9 +136,9 @@ private: class SwUndoReRead : public SwUndo { - Graphic *pGrf; - OUString *pNm; - OUString *pFltr; + std::unique_ptr<Graphic> pGrf; + std::unique_ptr<OUString> pNm; + std::unique_ptr<OUString> pFltr; sal_uLong nPos; MirrorGraph nMirr; diff --git a/sw/source/core/undo/undel.cxx b/sw/source/core/undo/undel.cxx index 94a86342db6d..dcde4a7fc246 100644 --- a/sw/source/core/undo/undel.cxx +++ b/sw/source/core/undo/undel.cxx @@ -384,7 +384,7 @@ bool SwUndoDelete::SaveContent( const SwPosition* pStt, const SwPosition* pEnd, // delete now also the text (all attribute changes are added to // UNDO history) - m_pSttStr = new OUString( pSttTextNd->GetText().copy(nSttContent, nLen)); + m_pSttStr.reset( new OUString( pSttTextNd->GetText().copy(nSttContent, nLen)) ); pSttTextNd->EraseText( pStt->nContent, nLen ); if( pSttTextNd->GetpSwpHints() ) pSttTextNd->GetpSwpHints()->DeRegister(); @@ -419,8 +419,8 @@ bool SwUndoDelete::SaveContent( const SwPosition* pStt, const SwPosition* pEnd, // delete now also the text (all attribute changes are added to // UNDO history) - m_pEndStr = new OUString( pEndTextNd->GetText().copy( 0, - pEnd->nContent.GetIndex() )); + m_pEndStr.reset( new OUString( pEndTextNd->GetText().copy( 0, + pEnd->nContent.GetIndex() )) ); pEndTextNd->EraseText( aEndIdx, pEnd->nContent.GetIndex() ); if( pEndTextNd->GetpSwpHints() ) pEndTextNd->GetpSwpHints()->DeRegister(); @@ -518,8 +518,6 @@ bool SwUndoDelete::CanGrouping( SwDoc* pDoc, const SwPaM& rDelPam ) SwUndoDelete::~SwUndoDelete() { - delete m_pSttStr; - delete m_pEndStr; if( m_pMvStt ) // Delete also the selection from UndoNodes array { // Insert saves content in IconSection @@ -706,9 +704,9 @@ SwRewriter SwUndoDelete::GetRewriter() const { OUString * pStr = nullptr; if (m_pSttStr != nullptr) - pStr = m_pSttStr; + pStr = m_pSttStr.get(); else if (m_pEndStr != nullptr) - pStr = m_pEndStr; + pStr = m_pEndStr.get(); if (pStr != nullptr) { diff --git a/sw/source/core/undo/unins.cxx b/sw/source/core/undo/unins.cxx index f6ff3e80ee4b..c9d311a3d782 100644 --- a/sw/source/core/undo/unins.cxx +++ b/sw/source/core/undo/unins.cxx @@ -101,7 +101,7 @@ void SwUndoInsert::Init(const SwNodeIndex & rNd) SetRedlineFlags( pDoc->getIDocumentRedlineAccess().GetRedlineFlags() ); } - pUndoText = GetTextFromDoc(); + pUndoText.reset( GetTextFromDoc() ); bCacheComment = false; } @@ -203,7 +203,6 @@ SwUndoInsert::~SwUndoInsert() else // the inserted text delete pText; delete pRedlData; - delete pUndoText; } void SwUndoInsert::UndoImpl(::sw::UndoRedoContext & rContext) @@ -290,7 +289,7 @@ void SwUndoInsert::UndoImpl(::sw::UndoRedoContext & rContext) pPam->GetPoint()->nNode.GetNode().GetContentNode(), nCnt ); } - DELETEZ(pUndoText); + pUndoText.reset(); } void SwUndoInsert::RedoImpl(::sw::UndoRedoContext & rContext) @@ -373,7 +372,7 @@ void SwUndoInsert::RedoImpl(::sw::UndoRedoContext & rContext) } } - pUndoText = GetTextFromDoc(); + pUndoText.reset( GetTextFromDoc() ); } void SwUndoInsert::RepeatImpl(::sw::RepeatContext & rContext) @@ -462,7 +461,7 @@ SwRewriter SwUndoInsert::GetRewriter() const if (pText) pStr = pText; else if (pUndoText) - pStr = pUndoText; + pStr = pUndoText.get(); if (pStr) { @@ -796,9 +795,6 @@ SwUndoReRead::SwUndoReRead( const SwPaM& rPam, const SwGrfNode& rGrfNd ) SwUndoReRead::~SwUndoReRead() { - delete pGrf; - delete pNm; - delete pFltr; } void SwUndoReRead::SetAndSave(::sw::UndoRedoContext & rContext) @@ -810,9 +806,9 @@ void SwUndoReRead::SetAndSave(::sw::UndoRedoContext & rContext) return ; // cache the old values - Graphic* pOldGrf = pGrf; - OUString* pOldNm = pNm; - OUString* pOldFltr = pFltr; + std::unique_ptr<Graphic> pOldGrf( pGrf ? new Graphic(*pGrf) : nullptr); + std::unique_ptr<OUString> pOldNm( pNm ? new OUString(*pNm) : nullptr); + std::unique_ptr<OUString> pOldFltr( pFltr ? new OUString(*pFltr) : nullptr); MirrorGraph nOldMirr = nMirr; // since all of them are cleared/modified by SaveGraphicData: SaveGraphicData( *pGrfNd ); @@ -820,13 +816,10 @@ void SwUndoReRead::SetAndSave(::sw::UndoRedoContext & rContext) if( pOldNm ) { pGrfNd->ReRead( *pOldNm, pFltr ? *pFltr : OUString() ); - delete pOldNm; - delete pOldFltr; } else { - pGrfNd->ReRead( OUString(), OUString(), pOldGrf ); - delete pOldGrf; + pGrfNd->ReRead( OUString(), OUString(), pOldGrf.get() ); } if( MirrorGraph::Dont != nOldMirr ) @@ -849,15 +842,16 @@ void SwUndoReRead::SaveGraphicData( const SwGrfNode& rGrfNd ) { if( rGrfNd.IsGrfLink() ) { - pNm = new OUString; - pFltr = new OUString; - rGrfNd.GetFileFilterNms( pNm, pFltr ); - pGrf = nullptr; + pNm.reset( new OUString ); + pFltr.reset( new OUString ); + rGrfNd.GetFileFilterNms( pNm.get(), pFltr.get() ); + pGrf.reset(); } else { - pGrf = new Graphic( rGrfNd.GetGrf(true) ); - pNm = pFltr = nullptr; + pGrf.reset( new Graphic( rGrfNd.GetGrf(true) ) ); + pNm.reset(); + pFltr.reset(); } nMirr = rGrfNd.GetSwAttrSet().GetMirrorGrf().GetValue(); } diff --git a/sw/source/uibase/inc/toxmgr.hxx b/sw/source/uibase/inc/toxmgr.hxx index 65dd2e5ebe48..b15972d3cf55 100644 --- a/sw/source/uibase/inc/toxmgr.hxx +++ b/sw/source/uibase/inc/toxmgr.hxx @@ -23,6 +23,7 @@ #include "swdllapi.h" #include "tox.hxx" #include <authfld.hxx> +#include <memory> class SwWrtShell; class SwForm; @@ -36,9 +37,12 @@ class SW_DLLPUBLIC SwTOXDescription OUString m_sSequenceName; OUString m_sMainEntryCharStyle; OUString m_sAutoMarkURL; - OUString* m_pTitle; - OUString* m_pTOUName; - SwForm* m_pForm; + std::unique_ptr<OUString> + m_pTitle; + std::unique_ptr<OUString> + m_pTOUName; + std::unique_ptr<SwForm> + m_pForm; SwTOXElement m_nContent; SwTOIOptions m_nIndexOptions; SwTOOElements m_nOLEOptions; @@ -84,12 +88,6 @@ public: m_bIsAuthSequence(false), m_bSortByDocument(true) {} - ~SwTOXDescription() - { - delete m_pTitle; - delete m_pForm; - delete m_pTOUName; - } TOXTypes GetTOXType() const { return m_eTOXType;} @@ -101,14 +99,14 @@ public: const OUString& GetAutoMarkURL() const { return m_sAutoMarkURL;} void SetAutoMarkURL(const OUString& rSet) {m_sAutoMarkURL = rSet;} - void SetTitle(const OUString& pSet) {delete m_pTitle; m_pTitle = new OUString(pSet);} - const OUString* GetTitle() const {return m_pTitle; } + void SetTitle(const OUString& pSet) { m_pTitle.reset( new OUString(pSet) );} + const OUString* GetTitle() const {return m_pTitle.get(); } - void SetTOUName(const OUString& pSet) {delete m_pTOUName; m_pTOUName = new OUString(pSet);} - const OUString* GetTOUName() const {return m_pTOUName; } + void SetTOUName(const OUString& pSet) { m_pTOUName.reset( new OUString(pSet) );} + const OUString* GetTOUName() const {return m_pTOUName.get(); } - void SetForm(const SwForm& rSet) {delete m_pForm; m_pForm = new SwForm(rSet);} - const SwForm* GetForm() const {return m_pForm;} + void SetForm(const SwForm& rSet) { m_pForm.reset( new SwForm(rSet) );} + const SwForm* GetForm() const {return m_pForm.get();} void SetContentOptions(SwTOXElement nSet) { m_nContent = nSet;} SwTOXElement GetContentOptions() const { return m_nContent;} @@ -176,14 +174,14 @@ class SwTOXMarkDescription int nLevel; bool bMainEntry; - OUString* pPrimKey; - OUString* pSecKey; - OUString* pAltStr; - OUString* pTOUName; + std::unique_ptr<OUString> pPrimKey; + std::unique_ptr<OUString> pSecKey; + std::unique_ptr<OUString> pAltStr; + std::unique_ptr<OUString> pTOUName; - OUString* pPhoneticReadingOfAltStr; - OUString* pPhoneticReadingOfPrimKey; - OUString* pPhoneticReadingOfSecKey; + std::unique_ptr<OUString> pPhoneticReadingOfAltStr; + std::unique_ptr<OUString> pPhoneticReadingOfPrimKey; + std::unique_ptr<OUString> pPhoneticReadingOfSecKey; SwTOXMarkDescription(SwTOXMarkDescription&) = delete; SwTOXMarkDescription & operator= (SwTOXMarkDescription&) = delete; @@ -203,16 +201,6 @@ public: pPhoneticReadingOfSecKey(nullptr) { } - ~SwTOXMarkDescription() - { - delete pPrimKey; - delete pSecKey; - delete pAltStr; - delete pTOUName; - delete pPhoneticReadingOfAltStr; - delete pPhoneticReadingOfPrimKey; - delete pPhoneticReadingOfSecKey; - } TOXTypes GetTOXType()const {return eTOXType;} @@ -223,32 +211,32 @@ public: bool IsMainEntry() const {return bMainEntry;} void SetPrimKey(const OUString& rSet) - {delete pPrimKey; pPrimKey = new OUString(rSet);} - const OUString* GetPrimKey() const {return pPrimKey;} + { pPrimKey.reset( new OUString(rSet) );} + const OUString* GetPrimKey() const {return pPrimKey.get();} void SetSecKey(const OUString& rSet) - {delete pSecKey; pSecKey = new OUString(rSet);} - const OUString* GetSecKey() const { return pSecKey; } + { pSecKey.reset( new OUString(rSet) );} + const OUString* GetSecKey() const { return pSecKey.get(); } void SetAltStr(const OUString& rSet) - {delete pAltStr; pAltStr = new OUString(rSet);} - const OUString* GetAltStr() const { return pAltStr; } + { pAltStr.reset( new OUString(rSet) );} + const OUString* GetAltStr() const { return pAltStr.get(); } void SetTOUName(const OUString& rSet) - {delete pTOUName; pTOUName = new OUString(rSet);} - const OUString* GetTOUName() const {return pTOUName;} + { pTOUName.reset( new OUString(rSet) );} + const OUString* GetTOUName() const {return pTOUName.get();} void SetPhoneticReadingOfAltStr(const OUString& rSet) - {delete pPhoneticReadingOfAltStr; pPhoneticReadingOfAltStr = new OUString(rSet);} - const OUString* GetPhoneticReadingOfAltStr() const { return pPhoneticReadingOfAltStr; } + { pPhoneticReadingOfAltStr.reset( new OUString(rSet) );} + const OUString* GetPhoneticReadingOfAltStr() const { return pPhoneticReadingOfAltStr.get(); } void SetPhoneticReadingOfPrimKey(const OUString& rSet) - {delete pPhoneticReadingOfPrimKey; pPhoneticReadingOfPrimKey = new OUString(rSet);} - const OUString* GetPhoneticReadingOfPrimKey() const { return pPhoneticReadingOfPrimKey; } + { pPhoneticReadingOfPrimKey.reset( new OUString(rSet) );} + const OUString* GetPhoneticReadingOfPrimKey() const { return pPhoneticReadingOfPrimKey.get(); } void SetPhoneticReadingOfSecKey(const OUString& rSet) - {delete pPhoneticReadingOfSecKey; pPhoneticReadingOfSecKey = new OUString(rSet);} - const OUString* GetPhoneticReadingOfSecKey() const { return pPhoneticReadingOfSecKey; } + { pPhoneticReadingOfSecKey.reset( new OUString(rSet) );} + const OUString* GetPhoneticReadingOfSecKey() const { return pPhoneticReadingOfSecKey.get(); } }; class SW_DLLPUBLIC SwTOXMgr |