sw/source/core/inc/UndoTable.hxx | 2 sw/source/core/undo/untbl.cxx | 13 ++- sw/source/core/unocore/unodraw.cxx | 126 ++++++++++++++++--------------------- 3 files changed, 65 insertions(+), 76 deletions(-)
New commits: commit 696568099bd319b14f6c0cb90f49e71191fcf6d1 Author: Michael Stahl <[email protected]> Date: Thu Feb 1 10:19:53 2018 +0100 sw: convert DELETEZ to std::unique_ptr in SwUndoTableNumFormat Change-Id: Ia1123e2b5f4b3bb2d827d2cdbeff485c3c2a56da Reviewed-on: https://gerrit.libreoffice.org/49080 Tested-by: Jenkins <[email protected]> Reviewed-by: Michael Stahl <[email protected]> diff --git a/sw/source/core/inc/UndoTable.hxx b/sw/source/core/inc/UndoTable.hxx index b48ffb4c330c..269644245dd0 100644 --- a/sw/source/core/inc/UndoTable.hxx +++ b/sw/source/core/inc/UndoTable.hxx @@ -253,7 +253,7 @@ public: class SwUndoTableNumFormat : public SwUndo { SfxItemSet *m_pBoxSet; - SwHistory* m_pHistory; + std::unique_ptr<SwHistory> m_pHistory; OUString m_aStr, m_aNewFormula; sal_uLong m_nFormatIdx, m_nNewFormatIdx; diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx index 924016037b52..511cf51986c6 100644 --- a/sw/source/core/undo/untbl.cxx +++ b/sw/source/core/undo/untbl.cxx @@ -2144,7 +2144,6 @@ SwUndoTableNumFormat::SwUndoTableNumFormat( const SwTableBox& rBox, const SfxItemSet* pNewSet ) : SwUndo(SwUndoId::TBLNUMFMT, rBox.GetFrameFormat()->GetDoc()) , m_pBoxSet(nullptr) - , m_pHistory(nullptr) , m_nFormatIdx(getSwDefaultTextFormat()) , m_nNewFormatIdx(0) , m_fNum(0.0) @@ -2162,8 +2161,8 @@ SwUndoTableNumFormat::SwUndoTableNumFormat( const SwTableBox& rBox, { SwTextNode* pTNd = pDoc->GetNodes()[ m_nNodePos ]->GetTextNode(); - m_pHistory = new SwHistory; - SwRegHistory aRHst( *rBox.GetSttNd(), m_pHistory ); + m_pHistory.reset(new SwHistory); + SwRegHistory aRHst( *rBox.GetSttNd(), m_pHistory.get() ); // always save all text atttibutes because of possibly overlapping // areas of on/off m_pHistory->CopyAttr( pTNd->GetpSwpHints(), m_nNodePos, 0, @@ -2204,13 +2203,15 @@ SwUndoTableNumFormat::SwUndoTableNumFormat( const SwTableBox& rBox, } // is a history needed at all? - if( m_pHistory && !m_pHistory->Count() ) - DELETEZ( m_pHistory ); + if (m_pHistory && !m_pHistory->Count()) + { + m_pHistory.reset(); + } } SwUndoTableNumFormat::~SwUndoTableNumFormat() { - delete m_pHistory; + m_pHistory.reset(); delete m_pBoxSet; } commit e2d0e55918296e5a5414c1ea9a6a8a7614aa0e4b Author: Michael Stahl <[email protected]> Date: Thu Feb 1 10:18:55 2018 +0100 sw: convert DELETEZ to std::unique_ptr in unodraw.cxx Change-Id: I89aaf157ded42ea3e968c706e4431f03d8f19ed7 Reviewed-on: https://gerrit.libreoffice.org/49078 Tested-by: Jenkins <[email protected]> Reviewed-by: Michael Stahl <[email protected]> diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx index ba98ccffdece..7102805291fe 100644 --- a/sw/source/core/unocore/unodraw.cxx +++ b/sw/source/core/unocore/unodraw.cxx @@ -75,18 +75,18 @@ using namespace ::com::sun::star; class SwShapeDescriptor_Impl { bool m_isInReading; - SwFormatHoriOrient* pHOrient; - SwFormatVertOrient* pVOrient; - SwFormatAnchor* pAnchor; - SwFormatSurround* pSurround; - SvxULSpaceItem* pULSpace; - SvxLRSpaceItem* pLRSpace; + std::unique_ptr<SwFormatHoriOrient> m_pHOrient; + std::unique_ptr<SwFormatVertOrient> m_pVOrient; + std::unique_ptr<SwFormatAnchor> m_pAnchor; + std::unique_ptr<SwFormatSurround> m_pSurround; + std::unique_ptr<SvxULSpaceItem> m_pULSpace; + std::unique_ptr<SvxLRSpaceItem> m_pLRSpace; bool bOpaque; uno::Reference< text::XTextRange > xTextRange; // #i26791# - SwFormatFollowTextFlow* mpFollowTextFlow; + std::unique_ptr<SwFormatFollowTextFlow> m_pFollowTextFlow; // #i28701# - SwFormatWrapInfluenceOnObjPos* pWrapInfluenceOnObjPos; + std::unique_ptr<SwFormatWrapInfluenceOnObjPos> m_pWrapInfluenceOnObjPos; // #i28749# sal_Int16 mnPositionLayoutDir; @@ -99,90 +99,76 @@ public: public: SwShapeDescriptor_Impl(SwDoc const*const pDoc) : m_isInReading(pDoc && pDoc->IsInReading()) - , // #i32349# - no defaults, in order to determine on // adding a shape, if positioning attributes are set or not. - pHOrient( nullptr ), - pVOrient( nullptr ), - pAnchor(nullptr), - pSurround(nullptr), - pULSpace(nullptr), - pLRSpace(nullptr), - bOpaque(false), + , bOpaque(false) // #i26791# - mpFollowTextFlow( new SwFormatFollowTextFlow( false ) ), + , m_pFollowTextFlow( new SwFormatFollowTextFlow(false) ) // #i28701# #i35017# - pWrapInfluenceOnObjPos( new SwFormatWrapInfluenceOnObjPos( - text::WrapInfluenceOnPosition::ONCE_CONCURRENT ) ), + , m_pWrapInfluenceOnObjPos( new SwFormatWrapInfluenceOnObjPos( + text::WrapInfluenceOnPosition::ONCE_CONCURRENT) ) // #i28749# - mnPositionLayoutDir( text::PositionLayoutDir::PositionInLayoutDirOfAnchor ), - bInitializedPropertyNotifier(false) + , mnPositionLayoutDir(text::PositionLayoutDir::PositionInLayoutDirOfAnchor) + , bInitializedPropertyNotifier(false) {} - ~SwShapeDescriptor_Impl() - { - delete pHOrient; - delete pVOrient; - delete pAnchor; - delete pSurround; - delete pULSpace; - delete pLRSpace; - // #i26791# - delete mpFollowTextFlow; - // #i28701# - delete pWrapInfluenceOnObjPos; - } SwFormatAnchor* GetAnchor(bool bCreate = false) { - if(bCreate && !pAnchor) + if (bCreate && !m_pAnchor) { - pAnchor = new SwFormatAnchor(RndStdIds::FLY_AS_CHAR); + m_pAnchor.reset(new SwFormatAnchor(RndStdIds::FLY_AS_CHAR)); } - return pAnchor; + return m_pAnchor.get(); } SwFormatHoriOrient* GetHOrient(bool bCreate = false) { - if (bCreate && !pHOrient) + if (bCreate && !m_pHOrient) { // #i26791# - pHOrient = new SwFormatHoriOrient( 0, text::HoriOrientation::NONE, text::RelOrientation::FRAME ); + m_pHOrient.reset(new SwFormatHoriOrient(0, text::HoriOrientation::NONE, text::RelOrientation::FRAME)); } - return pHOrient; + return m_pHOrient.get(); } SwFormatVertOrient* GetVOrient(bool bCreate = false) { - if(bCreate && !pVOrient) + if (bCreate && !m_pVOrient) { if (m_isInReading && // tdf#113938 extensions might rely on old default - (!GetAnchor(true) || pAnchor->GetAnchorId() == RndStdIds::FLY_AS_CHAR)) + (!GetAnchor(true) || m_pAnchor->GetAnchorId() == RndStdIds::FLY_AS_CHAR)) { // for as-char, NONE ("from-top") is not a good default - pVOrient = new SwFormatVertOrient(0, text::VertOrientation::TOP, text::RelOrientation::FRAME); + m_pVOrient.reset(new SwFormatVertOrient(0, text::VertOrientation::TOP, text::RelOrientation::FRAME)); } else { // #i26791# - pVOrient = new SwFormatVertOrient(0, text::VertOrientation::NONE, text::RelOrientation::FRAME); + m_pVOrient.reset(new SwFormatVertOrient(0, text::VertOrientation::NONE, text::RelOrientation::FRAME)); } } - return pVOrient; + return m_pVOrient.get(); } SwFormatSurround* GetSurround(bool bCreate = false) { - if(bCreate && !pSurround) - pSurround = new SwFormatSurround(); - return pSurround; + if (bCreate && !m_pSurround) + { + m_pSurround.reset(new SwFormatSurround()); + } + return m_pSurround.get(); } SvxLRSpaceItem* GetLRSpace(bool bCreate = false) { - if(bCreate && !pLRSpace) - pLRSpace = new SvxLRSpaceItem(RES_LR_SPACE); - return pLRSpace; + if (bCreate && !m_pLRSpace) + { + m_pLRSpace.reset(new SvxLRSpaceItem(RES_LR_SPACE)); + } + return m_pLRSpace.get(); } SvxULSpaceItem* GetULSpace(bool bCreate = false) { - if(bCreate && !pULSpace) - pULSpace = new SvxULSpaceItem(RES_UL_SPACE); - return pULSpace; + if (bCreate && !m_pULSpace) + { + m_pULSpace.reset(new SvxULSpaceItem(RES_UL_SPACE)); + } + return m_pULSpace.get(); } uno::Reference< text::XTextRange > & GetTextRange() { @@ -196,24 +182,26 @@ public: { return bOpaque; } - void RemoveHOrient(){DELETEZ(pHOrient);} - void RemoveVOrient(){DELETEZ(pVOrient);} - void RemoveAnchor(){DELETEZ(pAnchor);} - void RemoveSurround(){DELETEZ(pSurround);} - void RemoveULSpace(){DELETEZ(pULSpace);} - void RemoveLRSpace(){DELETEZ(pLRSpace);} + void RemoveHOrient() { m_pHOrient.reset(); } + void RemoveVOrient() { m_pVOrient.reset(); } + void RemoveAnchor() { m_pAnchor.reset(); } + void RemoveSurround() { m_pSurround.reset(); } + void RemoveULSpace() { m_pULSpace.reset(); } + void RemoveLRSpace() { m_pLRSpace.reset(); } void SetOpaque(bool bSet){bOpaque = bSet;} // #i26791# SwFormatFollowTextFlow* GetFollowTextFlow( bool _bCreate = false ) { - if ( _bCreate && !mpFollowTextFlow ) - mpFollowTextFlow = new SwFormatFollowTextFlow( false ); - return mpFollowTextFlow; + if (_bCreate && !m_pFollowTextFlow) + { + m_pFollowTextFlow.reset(new SwFormatFollowTextFlow(false)); + } + return m_pFollowTextFlow.get(); } void RemoveFollowTextFlow() { - DELETEZ(mpFollowTextFlow); + m_pFollowTextFlow.reset(); } // #i28749# @@ -242,17 +230,17 @@ public: SwFormatWrapInfluenceOnObjPos* GetWrapInfluenceOnObjPos( const bool _bCreate = false ) { - if ( _bCreate && !pWrapInfluenceOnObjPos ) + if (_bCreate && !m_pWrapInfluenceOnObjPos) { - pWrapInfluenceOnObjPos = new SwFormatWrapInfluenceOnObjPos( + m_pWrapInfluenceOnObjPos.reset(new SwFormatWrapInfluenceOnObjPos( // #i35017# - text::WrapInfluenceOnPosition::ONCE_CONCURRENT ); + text::WrapInfluenceOnPosition::ONCE_CONCURRENT)); } - return pWrapInfluenceOnObjPos; + return m_pWrapInfluenceOnObjPos.get(); } void RemoveWrapInfluenceOnObjPos() { - DELETEZ(pWrapInfluenceOnObjPos); + m_pWrapInfluenceOnObjPos.reset(); } }; _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
