editeng/source/accessibility/AccessibleHyperlink.cxx | 3 -- editeng/source/accessibility/AccessibleHyperlink.hxx | 4 ++- editeng/source/editeng/editdoc.cxx | 8 ++---- editeng/source/editeng/editdoc.hxx | 2 - editeng/source/editeng/editeng.cxx | 13 ++++------- editeng/source/editeng/editundo.cxx | 4 --- editeng/source/editeng/editundo.hxx | 9 ++++--- editeng/source/editeng/editview.cxx | 7 ++---- editeng/source/editeng/eehtml.cxx | 6 +---- editeng/source/editeng/eehtml.hxx | 3 +- editeng/source/editeng/eerdll.cxx | 3 -- editeng/source/editeng/impedit.hxx | 2 - editeng/source/editeng/impedit3.cxx | 4 +-- editeng/source/editeng/impedit5.cxx | 9 ++----- editeng/source/items/bulitem.cxx | 22 +++++-------------- editeng/source/items/flditem.cxx | 11 ++++----- editeng/source/items/frmitems.cxx | 18 ++++++--------- editeng/source/items/numitem.cxx | 8 ++---- editeng/source/misc/acorrcfg.cxx | 8 ++---- editeng/source/misc/unolingu.cxx | 17 ++++---------- editeng/source/outliner/outliner.cxx | 4 +-- editeng/source/outliner/outlobj.cxx | 1 editeng/source/outliner/outlvw.cxx | 3 -- editeng/source/uno/unotext2.cxx | 5 ---- editeng/source/xml/xmltxtexp.cxx | 9 +++---- include/editeng/acorrcfg.hxx | 7 +++--- include/editeng/bulletitem.hxx | 3 +- include/editeng/editdata.hxx | 7 +++--- include/editeng/editeng.hxx | 2 - include/editeng/editview.hxx | 5 ++-- include/editeng/eerdll.hxx | 5 ++-- include/editeng/flditem.hxx | 6 ++--- include/editeng/lineitem.hxx | 7 +++--- include/editeng/numitem.hxx | 5 ++-- include/editeng/outliner.hxx | 6 +---- include/editeng/outlobj.hxx | 7 +++--- include/editeng/unotext.hxx | 2 - 37 files changed, 105 insertions(+), 140 deletions(-)
New commits: commit cd8fdb46fd9a215532688585f3466d36b1daa1ac Author: Noel Grandin <noel.gran...@collabora.co.uk> Date: Wed Jan 11 12:53:32 2017 +0200 new loplugin: useuniqueptr: editeng Change-Id: I6df65eab882780d996ee996b5fef8020186b6d98 Reviewed-on: https://gerrit.libreoffice.org/32958 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/editeng/source/accessibility/AccessibleHyperlink.cxx b/editeng/source/accessibility/AccessibleHyperlink.cxx index 0dddfce..fd4443c 100644 --- a/editeng/source/accessibility/AccessibleHyperlink.cxx +++ b/editeng/source/accessibility/AccessibleHyperlink.cxx @@ -39,7 +39,7 @@ namespace accessibility AccessibleHyperlink::AccessibleHyperlink( SvxAccessibleTextAdapter& r, SvxFieldItem* p, sal_Int32 nP, sal_uInt16 nR, sal_Int32 nStt, sal_Int32 nEnd, const OUString& rD ) : rTA( r ) { - pFld = p; + pFld.reset( p ); nPara = nP; nRealIdx = nR; nStartIdx = nStt; @@ -49,7 +49,6 @@ namespace accessibility AccessibleHyperlink::~AccessibleHyperlink() { - delete pFld; } // XAccessibleAction diff --git a/editeng/source/accessibility/AccessibleHyperlink.hxx b/editeng/source/accessibility/AccessibleHyperlink.hxx index 9dda555..08201df 100644 --- a/editeng/source/accessibility/AccessibleHyperlink.hxx +++ b/editeng/source/accessibility/AccessibleHyperlink.hxx @@ -29,6 +29,8 @@ #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/accessibility/XAccessibleHyperlink.hpp> +#include <memory> + class SvxFieldItem; class SvxAccessibleTextAdapter; @@ -40,7 +42,7 @@ namespace accessibility private: SvxAccessibleTextAdapter& rTA; - SvxFieldItem* pFld; + std::unique_ptr<SvxFieldItem> pFld; sal_Int32 nPara; // EE values sal_uInt16 nRealIdx; // EE values sal_Int32 nStartIdx, nEndIdx; // translated values diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx index e0a1784..b2b4390 100644 --- a/editeng/source/editeng/editdoc.cxx +++ b/editeng/source/editeng/editdoc.cxx @@ -537,19 +537,17 @@ ExtraPortionInfo::ExtraPortionInfo() ExtraPortionInfo::~ExtraPortionInfo() { - delete[] pOrgDXArray; } void ExtraPortionInfo::SaveOrgDXArray( const long* pDXArray, sal_Int32 nLen ) { - delete[] pOrgDXArray; if (pDXArray) { - pOrgDXArray = new long[nLen]; - memcpy( pOrgDXArray, pDXArray, nLen * sizeof(long) ); + pOrgDXArray.reset(new long[nLen]); + memcpy( pOrgDXArray.get(), pDXArray, nLen * sizeof(long) ); } else - pOrgDXArray = nullptr; + pOrgDXArray.reset(); } ParaPortion::ParaPortion( ContentNode* pN ) : diff --git a/editeng/source/editeng/editdoc.hxx b/editeng/source/editeng/editdoc.hxx index 5d0e6f5..5366468 100644 --- a/editeng/source/editeng/editdoc.hxx +++ b/editeng/source/editeng/editdoc.hxx @@ -370,7 +370,7 @@ struct ExtraPortionInfo bool bFirstCharIsRightPunktuation; bool bCompressed; - long* pOrgDXArray; + std::unique_ptr<long[]> pOrgDXArray; ::std::vector< sal_Int32 > lineBreaksList; diff --git a/editeng/source/editeng/editeng.cxx b/editeng/source/editeng/editeng.cxx index 8f37954..6619f6e 100644 --- a/editeng/source/editeng/editeng.cxx +++ b/editeng/source/editeng/editeng.cxx @@ -94,12 +94,11 @@ static SfxItemPool* pGlobalPool=nullptr; EditEngine::EditEngine( SfxItemPool* pItemPool ) { - pImpEditEngine = new ImpEditEngine( this, pItemPool ); + pImpEditEngine.reset( new ImpEditEngine( this, pItemPool ) ); } EditEngine::~EditEngine() { - delete pImpEditEngine; } void EditEngine::EnableUndo( bool bEnable ) @@ -2772,22 +2771,20 @@ bool EditEngine::IsPageOverflow() { EFieldInfo::EFieldInfo() { - pFieldItem = nullptr; } -EFieldInfo::EFieldInfo( const SvxFieldItem& rFieldItem, sal_Int32 nPara, sal_Int32 nPos ) : aPosition( nPara, nPos ) +EFieldInfo::EFieldInfo( const SvxFieldItem& rFieldItem, sal_Int32 nPara, sal_Int32 nPos ) : + pFieldItem( new SvxFieldItem( rFieldItem ) ), + aPosition( nPara, nPos ) { - pFieldItem = new SvxFieldItem( rFieldItem ); } EFieldInfo::~EFieldInfo() { - delete pFieldItem; } EFieldInfo::EFieldInfo( const EFieldInfo& rFldInfo ) - : pFieldItem(nullptr) { *this = rFldInfo; } @@ -2797,7 +2794,7 @@ EFieldInfo& EFieldInfo::operator= ( const EFieldInfo& rFldInfo ) if( this == &rFldInfo ) return *this; - pFieldItem = rFldInfo.pFieldItem ? new SvxFieldItem( *rFldInfo.pFieldItem ) : nullptr; + pFieldItem.reset( rFldInfo.pFieldItem ? new SvxFieldItem( *rFldInfo.pFieldItem ) : nullptr ); aCurrentText = rFldInfo.aCurrentText; aPosition = rFldInfo.aPosition; diff --git a/editeng/source/editeng/editundo.cxx b/editeng/source/editeng/editundo.cxx index c96174f..925cf1f 100644 --- a/editeng/source/editeng/editundo.cxx +++ b/editeng/source/editeng/editundo.cxx @@ -371,13 +371,12 @@ EditUndoInsertFeature::EditUndoInsertFeature( EditEngine* pEE, const EPaM& rEPaM, const SfxPoolItem& rFeature) : EditUndo(EDITUNDO_INSERTFEATURE, pEE), aEPaM(rEPaM) { - pFeature = rFeature.Clone(); + pFeature.reset( rFeature.Clone() ); DBG_ASSERT( pFeature, "Feature could not be duplicated: EditUndoInsertFeature" ); } EditUndoInsertFeature::~EditUndoInsertFeature() { - delete pFeature; } void EditUndoInsertFeature::Undo() @@ -593,7 +592,6 @@ EditUndoTransliteration::EditUndoTransliteration(EditEngine* pEE, const ESelecti EditUndoTransliteration::~EditUndoTransliteration() { - delete pTxtObj; } void EditUndoTransliteration::Undo() diff --git a/editeng/source/editeng/editundo.hxx b/editeng/source/editeng/editundo.hxx index f85ee12..9e798a7 100644 --- a/editeng/source/editeng/editundo.hxx +++ b/editeng/source/editeng/editundo.hxx @@ -134,8 +134,8 @@ public: class EditUndoInsertFeature : public EditUndo { private: - EPaM aEPaM; - SfxPoolItem* pFeature; + EPaM aEPaM; + std::unique_ptr<SfxPoolItem> pFeature; public: EditUndoInsertFeature(EditEngine* pEE, const EPaM& rEPaM, const SfxPoolItem& rFeature); @@ -251,7 +251,8 @@ private: ESelection aNewESel; sal_Int32 nMode; - EditTextObject* pTxtObj; + std::unique_ptr<EditTextObject> + pTxtObj; OUString aText; public: @@ -259,7 +260,7 @@ public: virtual ~EditUndoTransliteration() override; void SetText( const OUString& rText ) { aText = rText; } - void SetText( EditTextObject* pObj ) { pTxtObj = pObj; } + void SetText( EditTextObject* pObj ) { pTxtObj.reset( pObj ); } void SetNewSelection( const ESelection& rSel ) { aNewESel = rSel; } virtual void Undo() override; diff --git a/editeng/source/editeng/editview.cxx b/editeng/source/editeng/editview.cxx index 732f774..897569e 100644 --- a/editeng/source/editeng/editview.cxx +++ b/editeng/source/editeng/editview.cxx @@ -155,17 +155,16 @@ LanguageType EditView::CheckLanguage( EditView::EditView( EditEngine* pEng, vcl::Window* pWindow ) { - pImpEditView = new ImpEditView( this, pEng, pWindow ); + pImpEditView.reset( new ImpEditView( this, pEng, pWindow ) ); } EditView::~EditView() { - delete pImpEditView; } ImpEditEngine* EditView::GetImpEditEngine() const { - return pImpEditView->pEditEngine->pImpEditEngine; + return pImpEditView->pEditEngine->pImpEditEngine.get(); } EditEngine* EditView::GetEditEngine() const @@ -291,7 +290,7 @@ void EditView::GetSelectionRectangles(std::vector<Rectangle>& rLogicRects) const void EditView::Paint( const Rectangle& rRect, OutputDevice* pTargetDevice ) { - pImpEditView->pEditEngine->pImpEditEngine->Paint( pImpEditView, rRect, pTargetDevice ); + pImpEditView->pEditEngine->pImpEditEngine->Paint( pImpEditView.get(), rRect, pTargetDevice ); } void EditView::SetEditEngine( EditEngine* pEditEng ) diff --git a/editeng/source/editeng/eehtml.cxx b/editeng/source/editeng/eehtml.cxx index 44aabf8..be16f03 100644 --- a/editeng/source/editeng/eehtml.cxx +++ b/editeng/source/editeng/eehtml.cxx @@ -67,7 +67,6 @@ EditHTMLParser::EditHTMLParser( SvStream& rIn, const OUString& rBaseURL, SvKeyVa EditHTMLParser::~EditHTMLParser() { - delete pCurAnchor; } SvParserState EditHTMLParser::CallParser(EditEngine* pEE, const EditPaM& rPaM) @@ -780,7 +779,7 @@ void EditHTMLParser::AnchorStart() aRootURL.GetNewAbsURL( aRef, &aTargetURL ); aURL = aTargetURL.GetMainURL( INetURLObject::DecodeMechanism::ToIUri ); } - pCurAnchor = new AnchorInfo; + pCurAnchor.reset( new AnchorInfo ); pCurAnchor->aHRef = aURL; } } @@ -794,8 +793,7 @@ void EditHTMLParser::AnchorEnd() SvxFieldItem aFld( SvxURLField( pCurAnchor->aHRef, pCurAnchor->aText, SVXURLFORMAT_REPR ), EE_FEATURE_FIELD ); aCurSel = mpEditEngine->InsertField(aCurSel, aFld); bFieldsInserted = true; - delete pCurAnchor; - pCurAnchor = nullptr; + pCurAnchor.reset(); if (mpEditEngine->IsImportHandlerSet()) { diff --git a/editeng/source/editeng/eehtml.hxx b/editeng/source/editeng/eehtml.hxx index 08563bc..633c453 100644 --- a/editeng/source/editeng/eehtml.hxx +++ b/editeng/source/editeng/eehtml.hxx @@ -39,7 +39,8 @@ private: EditSelection aCurSel; OUString aBaseURL; EditEngine* mpEditEngine; - AnchorInfo* pCurAnchor; + std::unique_ptr<AnchorInfo> + pCurAnchor; bool bInPara:1; bool bWasInPara:1; // Remember bInPara before HeadingStart, because afterwards it will be gone. diff --git a/editeng/source/editeng/eerdll.cxx b/editeng/source/editeng/eerdll.cxx index 08d95aa..558c475 100644 --- a/editeng/source/editeng/eerdll.cxx +++ b/editeng/source/editeng/eerdll.cxx @@ -200,13 +200,12 @@ EditResId::EditResId(sal_uInt16 nId) } EditDLL::EditDLL() + : pGlobalData( new GlobalEditData ) { - pGlobalData = new GlobalEditData; } EditDLL::~EditDLL() { - delete pGlobalData; } static ResMgr* pResMgr=nullptr; diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx index 6f97901..b47421f 100644 --- a/editeng/source/editeng/impedit.hxx +++ b/editeng/source/editeng/impedit.hxx @@ -144,7 +144,7 @@ struct DragAndDropInfo struct ImplIMEInfos { OUString aOldTextAfterStartPos; - ExtTextInputAttr* pAttribs; + std::unique_ptr<ExtTextInputAttr[]> pAttribs; EditPaM aPos; sal_Int32 nLen; bool bCursor; diff --git a/editeng/source/editeng/impedit3.cxx b/editeng/source/editeng/impedit3.cxx index cd90dbb..59022d7 100644 --- a/editeng/source/editeng/impedit3.cxx +++ b/editeng/source/editeng/impedit3.cxx @@ -447,7 +447,7 @@ void ImpEditEngine::FormatDoc() { for (EditView* pView : aEditViews) { - ImpEditView* pImpView = pView->pImpEditView; + ImpEditView* pImpView = pView->pImpEditView.get(); if ( pImpView->DoAutoHeight() ) { Size aSz( pImpView->GetOutputArea().GetWidth(), nCurTextHeight ); @@ -4481,7 +4481,7 @@ void ImpEditEngine::ImplExpandCompressedPortions( EditLine* pLine, ParaPortion* DBG_ASSERT( nTxtPortionStart >= pLine->GetStart(), "Portion doesn't belong to the line!!!" ); long* pDXArray = pLine->GetCharPosArray().data() + (nTxtPortionStart - pLine->GetStart()); if ( pTP->GetExtraInfos()->pOrgDXArray ) - memcpy( pDXArray, pTP->GetExtraInfos()->pOrgDXArray, (pTP->GetLen()-1)*sizeof(sal_Int32) ); + memcpy( pDXArray, pTP->GetExtraInfos()->pOrgDXArray.get(), (pTP->GetLen()-1)*sizeof(sal_Int32) ); ImplCalcAsianCompression( pParaPortion->GetNode(), pTP, nTxtPortionStart, pDXArray, (sal_uInt16)nCompressPercent, true ); } } diff --git a/editeng/source/editeng/impedit5.cxx b/editeng/source/editeng/impedit5.cxx index 100af46..0d30081 100644 --- a/editeng/source/editeng/impedit5.cxx +++ b/editeng/source/editeng/impedit5.cxx @@ -825,21 +825,18 @@ ImplIMEInfos::ImplIMEInfos( const EditPaM& rPos, const OUString& rOldTextAfterSt ImplIMEInfos::~ImplIMEInfos() { - delete[] pAttribs; } void ImplIMEInfos::CopyAttribs( const ExtTextInputAttr* pA, sal_uInt16 nL ) { nLen = nL; - delete[] pAttribs; - pAttribs = new ExtTextInputAttr[ nL ]; - memcpy( pAttribs, pA, nL*sizeof(ExtTextInputAttr) ); + pAttribs.reset( new ExtTextInputAttr[ nL ] ); + memcpy( pAttribs.get(), pA, nL*sizeof(ExtTextInputAttr) ); } void ImplIMEInfos::DestroyAttribs() { - delete[] pAttribs; - pAttribs = nullptr; + pAttribs.reset(); nLen = 0; } diff --git a/editeng/source/items/bulitem.cxx b/editeng/source/items/bulitem.cxx index 1283f32..1e2e6a8 100644 --- a/editeng/source/items/bulitem.cxx +++ b/editeng/source/items/bulitem.cxx @@ -133,7 +133,7 @@ SvxBulletItem::SvxBulletItem( SvStream& rStrm, sal_uInt16 _nWhich ) nStyle = SvxBulletStyle::NONE; } else - pGraphicObject = new GraphicObject( aBmp ); + pGraphicObject.reset( new GraphicObject( aBmp ) ); } sal_Int32 nTmp(0); @@ -159,7 +159,8 @@ SvxBulletItem::SvxBulletItem( SvStream& rStrm, sal_uInt16 _nWhich ) SvxBulletItem::SvxBulletItem( const SvxBulletItem& rItem) : SfxPoolItem( rItem ) { aFont = rItem.aFont; - pGraphicObject = ( rItem.pGraphicObject ? new GraphicObject( *rItem.pGraphicObject ) : nullptr ); + if (rItem.pGraphicObject) + pGraphicObject.reset( new GraphicObject( *rItem.pGraphicObject ) ); aPrevText = rItem.aPrevText; aFollowText = rItem.aFollowText; nStart = rItem.nStart; @@ -172,7 +173,6 @@ SvxBulletItem::SvxBulletItem( const SvxBulletItem& rItem) : SfxPoolItem( rItem ) SvxBulletItem::~SvxBulletItem() { - delete pGraphicObject; } @@ -273,12 +273,7 @@ SvStream& SvxBulletItem::Store( SvStream& rStrm, sal_uInt16 /*nItemVersion*/ ) c if( ( nStyle == SvxBulletStyle::BMP ) && ( !pGraphicObject || ( GraphicType::NONE == pGraphicObject->GetType() ) || ( GraphicType::Default == pGraphicObject->GetType() ) ) ) { - if( pGraphicObject ) - { - delete( const_cast< SvxBulletItem* >( this )->pGraphicObject ); - const_cast< SvxBulletItem* >( this )->pGraphicObject = nullptr; - } - + const_cast< SvxBulletItem* >( this )->pGraphicObject.reset(); const_cast< SvxBulletItem* >( this )->nStyle = SvxBulletStyle::NONE; } @@ -366,16 +361,11 @@ void SvxBulletItem::SetGraphicObject( const GraphicObject& rGraphicObject ) { if( ( GraphicType::NONE == rGraphicObject.GetType() ) || ( GraphicType::Default == rGraphicObject.GetType() ) ) { - if( pGraphicObject ) - { - delete pGraphicObject; - pGraphicObject = nullptr; - } + pGraphicObject.reset(); } else { - delete pGraphicObject; - pGraphicObject = new GraphicObject( rGraphicObject ); + pGraphicObject.reset( new GraphicObject( rGraphicObject ) ); } } diff --git a/editeng/source/items/flditem.cxx b/editeng/source/items/flditem.cxx index 8edcd9c..6ff64b9 100644 --- a/editeng/source/items/flditem.cxx +++ b/editeng/source/items/flditem.cxx @@ -271,28 +271,27 @@ MetaAction* SvxFieldData::createEndComment() SvxFieldItem::SvxFieldItem( SvxFieldData* pFld, const sal_uInt16 nId ) : SfxPoolItem( nId ) + , pField( pFld ) // belongs directly to the item { - pField = pFld; // belongs directly to the item } SvxFieldItem::SvxFieldItem( const SvxFieldData& rField, const sal_uInt16 nId ) : SfxPoolItem( nId ) + , pField( rField.Clone() ) { - pField = rField.Clone(); } SvxFieldItem::SvxFieldItem( const SvxFieldItem& rItem ) : SfxPoolItem ( rItem ) + , pField( rItem.GetField() ? rItem.GetField()->Clone() : nullptr ) { - pField = rItem.GetField() ? rItem.GetField()->Clone() : nullptr; } SvxFieldItem::~SvxFieldItem() { - delete pField; } @@ -332,7 +331,7 @@ SvStream& SvxFieldItem::Store( SvStream& rStrm, sal_uInt16 /*nItemVersion*/ ) co WriteSvPersistBase( aPStrm , &aDummyData ); } else - WriteSvPersistBase( aPStrm, pField ); + WriteSvPersistBase( aPStrm, pField.get() ); return rStrm; } @@ -343,7 +342,7 @@ bool SvxFieldItem::operator==( const SfxPoolItem& rItem ) const assert(SfxPoolItem::operator==(rItem)); const SvxFieldData* pOtherFld = static_cast<const SvxFieldItem&>(rItem).GetField(); - if( pField == pOtherFld ) + if( pField.get() == pOtherFld ) return true; if( pField == nullptr || pOtherFld == nullptr ) return false; diff --git a/editeng/source/items/frmitems.cxx b/editeng/source/items/frmitems.cxx index 501dd71..f8b6695 100644 --- a/editeng/source/items/frmitems.cxx +++ b/editeng/source/items/frmitems.cxx @@ -3082,16 +3082,15 @@ SvxLineItem::SvxLineItem( const sal_uInt16 nId ) : SvxLineItem::SvxLineItem( const SvxLineItem& rCpy ) : - SfxPoolItem ( rCpy ) { - pLine = rCpy.GetLine() ? new SvxBorderLine( *rCpy.GetLine() ) : nullptr; + if (rCpy.GetLine()) + pLine.reset( new SvxBorderLine( *rCpy.GetLine() ) ); } SvxLineItem::~SvxLineItem() { - delete pLine; } @@ -3107,7 +3106,7 @@ bool SvxLineItem::operator==( const SfxPoolItem& rAttr ) const { assert(SfxPoolItem::operator==(rAttr)); - return CmpBrdLn( pLine, static_cast<const SvxLineItem&>(rAttr).GetLine() ); + return CmpBrdLn( pLine.get(), static_cast<const SvxLineItem&>(rAttr).GetLine() ); } @@ -3123,7 +3122,7 @@ bool SvxLineItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemId ) const nMemId &= ~CONVERT_TWIPS; if ( nMemId == 0 ) { - rVal = uno::makeAny( SvxBoxItem::SvxLineToLine(pLine, bConvert) ); + rVal = uno::makeAny( SvxBoxItem::SvxLineToLine(pLine.get(), bConvert) ); return true; } else if ( pLine ) @@ -3155,9 +3154,9 @@ bool SvxLineItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemId ) if ( lcl_extractBorderLine(rVal, aLine) ) { if ( !pLine ) - pLine = new SvxBorderLine; + pLine.reset( new SvxBorderLine ); if( !SvxBoxItem::LineToSvxLine(aLine, *pLine, bConvert) ) - DELETEZ( pLine ); + pLine.reset(); return true; } return false; @@ -3165,7 +3164,7 @@ bool SvxLineItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemId ) else if ( rVal >>= nVal ) { if ( !pLine ) - pLine = new SvxBorderLine; + pLine.reset( new SvxBorderLine ); switch ( nMemId ) { @@ -3250,8 +3249,7 @@ SfxPoolItem* SvxLineItem::Create( SvStream& rStrm, sal_uInt16 ) const void SvxLineItem::SetLine( const SvxBorderLine* pNew ) { - delete pLine; - pLine = pNew ? new SvxBorderLine( *pNew ) : nullptr; + pLine.reset( pNew ? new SvxBorderLine( *pNew ) : nullptr ); } #define LOAD_GRAPHIC ((sal_uInt16)0x0001) diff --git a/editeng/source/items/numitem.cxx b/editeng/source/items/numitem.cxx index 3d7a3b4..0045d99 100644 --- a/editeng/source/items/numitem.cxx +++ b/editeng/source/items/numitem.cxx @@ -918,12 +918,11 @@ SfxPoolItem* SvxNumBulletItem::Create(SvStream &rStream, sal_uInt16 /*nItemVersi SvxNumBulletItem::SvxNumBulletItem(const SvxNumBulletItem& rCopy) : SfxPoolItem(rCopy.Which()) { - pNumRule = new SvxNumRule(*rCopy.pNumRule); + pNumRule.reset( new SvxNumRule(*rCopy.pNumRule) ); } SvxNumBulletItem::~SvxNumBulletItem() { - delete pNumRule; } bool SvxNumBulletItem::operator==( const SfxPoolItem& rCopy) const @@ -949,7 +948,7 @@ SvStream& SvxNumBulletItem::Store(SvStream &rStream, sal_uInt16 /*nItemVersion bool SvxNumBulletItem::QueryValue( css::uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const { - rVal <<= SvxCreateNumRule( pNumRule ); + rVal <<= SvxCreateNumRule( pNumRule.get() ); return true; } @@ -968,8 +967,7 @@ bool SvxNumBulletItem::PutValue( const css::uno::Any& rVal, sal_uInt8 /*nMemberI delete pNewRule; pNewRule = pConverted; } - delete pNumRule; - pNumRule = pNewRule; + pNumRule.reset( pNewRule ); return true; } catch(const lang::IllegalArgumentException&) diff --git a/editeng/source/misc/acorrcfg.cxx b/editeng/source/misc/acorrcfg.cxx index fd227fc..a2b0cef 100644 --- a/editeng/source/misc/acorrcfg.cxx +++ b/editeng/source/misc/acorrcfg.cxx @@ -66,7 +66,7 @@ SvxAutoCorrCfg::SvxAutoCorrCfg() : aPath.insertName("acor"); *pS = aPath.GetMainURL(INetURLObject::DecodeMechanism::ToIUri); } - pAutoCorrect = new SvxAutoCorrect( sSharePath, sUserPath ); + pAutoCorrect.reset( new SvxAutoCorrect( sSharePath, sUserPath ) ); aBaseConfig.Load(true); aSwConfig.Load(true); @@ -74,20 +74,18 @@ SvxAutoCorrCfg::SvxAutoCorrCfg() : SvxAutoCorrCfg::~SvxAutoCorrCfg() { - delete pAutoCorrect; } void SvxAutoCorrCfg::SetAutoCorrect(SvxAutoCorrect *const pNew) { - if (pNew != pAutoCorrect) + if (pNew != pAutoCorrect.get()) { if (pNew && (pAutoCorrect->GetFlags() != pNew->GetFlags())) { aBaseConfig.SetModified(); aSwConfig.SetModified(); } - delete pAutoCorrect; - pAutoCorrect = pNew; + pAutoCorrect.reset( pNew ); } } diff --git a/editeng/source/misc/unolingu.cxx b/editeng/source/misc/unolingu.cxx index e8af808..c0a446b 100644 --- a/editeng/source/misc/unolingu.cxx +++ b/editeng/source/misc/unolingu.cxx @@ -75,16 +75,15 @@ static uno::Reference< XLinguServiceManager2 > GetLngSvcMgr_Impl() class ThesDummy_Impl : public cppu::WeakImplHelper< XThesaurus > { - uno::Reference< XThesaurus > xThes; // the real one... - Sequence< lang::Locale > *pLocaleSeq; + uno::Reference< XThesaurus > xThes; // the real one... + std::unique_ptr<Sequence< lang::Locale >> pLocaleSeq; void GetCfgLocales(); void GetThes_Impl(); public: - ThesDummy_Impl() : pLocaleSeq(nullptr) {} - virtual ~ThesDummy_Impl() override; + ThesDummy_Impl() {} // XSupportedLocales virtual css::uno::Sequence< css::lang::Locale > SAL_CALL @@ -105,12 +104,6 @@ public: }; -ThesDummy_Impl::~ThesDummy_Impl() -{ - delete pLocaleSeq; -} - - void ThesDummy_Impl::GetCfgLocales() { if (!pLocaleSeq) @@ -120,7 +113,7 @@ void ThesDummy_Impl::GetCfgLocales() Sequence < OUString > aNodeNames( aCfg.GetNodeNames( aNode ) ); const OUString *pNodeNames = aNodeNames.getConstArray(); sal_Int32 nLen = aNodeNames.getLength(); - pLocaleSeq = new Sequence< lang::Locale >( nLen ); + pLocaleSeq.reset( new Sequence< lang::Locale >( nLen ) ); lang::Locale *pLocale = pLocaleSeq->getArray(); for (sal_Int32 i = 0; i < nLen; ++i) { @@ -140,7 +133,7 @@ void ThesDummy_Impl::GetThes_Impl() if (xThes.is()) { // no longer needed... - delete pLocaleSeq; pLocaleSeq = nullptr; + pLocaleSeq.reset(); } } } diff --git a/editeng/source/outliner/outliner.cxx b/editeng/source/outliner/outliner.cxx index 3e50f60..ca1bdf3 100644 --- a/editeng/source/outliner/outliner.cxx +++ b/editeng/source/outliner/outliner.cxx @@ -1290,7 +1290,7 @@ size_t Outliner::InsertView( OutlinerView* pView, size_t nIndex ) advance( it, nIndex ); ActualIndex = nIndex; } - pEditEngine->InsertView( pView->pEditView, nIndex ); + pEditEngine->InsertView( pView->pEditView.get(), nIndex ); return ActualIndex; } @@ -1302,7 +1302,7 @@ void Outliner::RemoveView( OutlinerView* pView ) if ( *it == pView ) { pView->pEditView->HideCursor(); // HACK - pEditEngine->RemoveView( pView->pEditView ); + pEditEngine->RemoveView( pView->pEditView.get() ); aViewList.erase( it ); break; } diff --git a/editeng/source/outliner/outlobj.cxx b/editeng/source/outliner/outlobj.cxx index 3eba88e..539e4c2 100644 --- a/editeng/source/outliner/outlobj.cxx +++ b/editeng/source/outliner/outlobj.cxx @@ -53,7 +53,6 @@ OutlinerParaObjData::OutlinerParaObjData( const OutlinerParaObjData& r ): OutlinerParaObjData::~OutlinerParaObjData() { - delete mpEditTextObject; } bool OutlinerParaObjData::operator==(const OutlinerParaObjData& rCandidate) const diff --git a/editeng/source/outliner/outlvw.cxx b/editeng/source/outliner/outlvw.cxx index 9d2a82b..2c176c2 100644 --- a/editeng/source/outliner/outlvw.cxx +++ b/editeng/source/outliner/outlvw.cxx @@ -52,13 +52,12 @@ OutlinerView::OutlinerView( Outliner* pOut, vcl::Window* pWin ) { pOwner = pOut; - pEditView = new EditView( pOut->pEditEngine, pWin ); + pEditView.reset( new EditView( pOut->pEditEngine, pWin ) ); pEditView->SetSelectionMode( EE_SELMODE_TXTONLY ); } OutlinerView::~OutlinerView() { - delete pEditView; } void OutlinerView::Paint( const Rectangle& rRect, OutputDevice* pTargetDevice ) diff --git a/editeng/source/uno/unotext2.cxx b/editeng/source/uno/unotext2.cxx index a5d593e..e56443a 100644 --- a/editeng/source/uno/unotext2.cxx +++ b/editeng/source/uno/unotext2.cxx @@ -45,15 +45,12 @@ SvxUnoTextContentEnumeration::SvxUnoTextContentEnumeration( const SvxUnoTextBase { mxParentText = const_cast<SvxUnoTextBase*>(&_rText); if( mrText.GetEditSource() ) - mpEditSource = mrText.GetEditSource()->Clone(); - else - mpEditSource = nullptr; + mpEditSource.reset( mrText.GetEditSource()->Clone() ); mnNextParagraph = 0; } SvxUnoTextContentEnumeration::~SvxUnoTextContentEnumeration() throw() { - delete mpEditSource; } // container::XEnumeration diff --git a/editeng/source/xml/xmltxtexp.cxx b/editeng/source/xml/xmltxtexp.cxx index 9b4c6f3..710f0ac 100644 --- a/editeng/source/xml/xmltxtexp.cxx +++ b/editeng/source/xml/xmltxtexp.cxx @@ -62,8 +62,8 @@ class SvxEditEngineSourceImpl; class SvxEditEngineSourceImpl : public salhelper::SimpleReferenceObject { private: - EditEngine* mpEditEngine; - SvxTextForwarder* mpTextForwarder; + EditEngine* mpEditEngine; + std::unique_ptr<SvxTextForwarder> mpTextForwarder; virtual ~SvxEditEngineSourceImpl() override; @@ -81,15 +81,14 @@ SvxEditEngineSourceImpl::SvxEditEngineSourceImpl( EditEngine* pEditEngine ) SvxEditEngineSourceImpl::~SvxEditEngineSourceImpl() { - delete mpTextForwarder; } SvxTextForwarder* SvxEditEngineSourceImpl::GetTextForwarder() { if (!mpTextForwarder) - mpTextForwarder = new SvxEditEngineForwarder( *mpEditEngine ); + mpTextForwarder.reset( new SvxEditEngineForwarder( *mpEditEngine ) ); - return mpTextForwarder; + return mpTextForwarder.get(); } // SvxTextEditSource diff --git a/include/editeng/acorrcfg.hxx b/include/editeng/acorrcfg.hxx index 6eef058..8a79f0c 100644 --- a/include/editeng/acorrcfg.hxx +++ b/include/editeng/acorrcfg.hxx @@ -21,6 +21,7 @@ #include <editeng/editengdllapi.h> #include <unotools/configitem.hxx> +#include <memory> class SvxAutoCorrect; class SvxAutoCorrCfg; @@ -65,7 +66,7 @@ class EDITENG_DLLPUBLIC SvxAutoCorrCfg final friend class SvxBaseAutoCorrCfg; friend class SvxSwAutoCorrCfg; - SvxAutoCorrect* pAutoCorrect; + std::unique_ptr<SvxAutoCorrect> pAutoCorrect; SvxBaseAutoCorrCfg aBaseConfig; SvxSwAutoCorrCfg aSwConfig; @@ -91,8 +92,8 @@ public: aSwConfig.Commit(); } - SvxAutoCorrect* GetAutoCorrect() { return pAutoCorrect; } - const SvxAutoCorrect* GetAutoCorrect() const { return pAutoCorrect; } + SvxAutoCorrect* GetAutoCorrect() { return pAutoCorrect.get(); } + const SvxAutoCorrect* GetAutoCorrect() const { return pAutoCorrect.get(); } // the pointer is transferred to the possession of the ConfigItems! void SetAutoCorrect( SvxAutoCorrect* ); diff --git a/include/editeng/bulletitem.hxx b/include/editeng/bulletitem.hxx index 98c872b..63bc582 100644 --- a/include/editeng/bulletitem.hxx +++ b/include/editeng/bulletitem.hxx @@ -45,7 +45,8 @@ enum class SvxBulletStyle class EDITENG_DLLPUBLIC SvxBulletItem : public SfxPoolItem { vcl::Font aFont; - GraphicObject* pGraphicObject; + std::unique_ptr<GraphicObject> + pGraphicObject; OUString aPrevText; OUString aFollowText; sal_uInt16 nStart; diff --git a/include/editeng/editdata.hxx b/include/editeng/editdata.hxx index 34187ec..178cf5d 100644 --- a/include/editeng/editdata.hxx +++ b/include/editeng/editdata.hxx @@ -23,6 +23,7 @@ #include <rtl/ustring.hxx> #include <editeng/editengdllapi.h> +#include <memory> class SfxItemSet; class SfxPoolItem; @@ -188,9 +189,9 @@ inline void ESelection::Adjust() struct EDITENG_DLLPUBLIC EFieldInfo { - SvxFieldItem* pFieldItem; - OUString aCurrentText; - EPosition aPosition; + std::unique_ptr<SvxFieldItem> pFieldItem; + OUString aCurrentText; + EPosition aPosition; EFieldInfo(); EFieldInfo( const SvxFieldItem& rFieldItem, sal_Int32 nPara, sal_Int32 nPos ); diff --git a/include/editeng/editeng.hxx b/include/editeng/editeng.hxx index f95b798..38dbad1 100644 --- a/include/editeng/editeng.hxx +++ b/include/editeng/editeng.hxx @@ -158,7 +158,7 @@ public: typedef std::vector<EditView*> ViewsType; private: - ImpEditEngine* pImpEditEngine; + std::unique_ptr<ImpEditEngine> pImpEditEngine; EditEngine( const EditEngine& ) = delete; EditEngine& operator=( const EditEngine& ) = delete; diff --git a/include/editeng/editview.hxx b/include/editeng/editview.hxx index 361558b..95b3228 100644 --- a/include/editeng/editview.hxx +++ b/include/editeng/editview.hxx @@ -89,11 +89,12 @@ public: typedef std::vector<VclPtr<vcl::Window>> OutWindowSet; public: // Needed for Undo - ImpEditView* GetImpEditView() const { return pImpEditView; } + ImpEditView* GetImpEditView() const { return pImpEditView.get(); } ImpEditEngine* GetImpEditEngine() const; private: - ImpEditView* pImpEditView; + std::unique_ptr<ImpEditView> + pImpEditView; OUString aDicNameSingle; EditView( const EditView& ) = delete; diff --git a/include/editeng/eerdll.hxx b/include/editeng/eerdll.hxx index bbf2a6c..74034f2 100644 --- a/include/editeng/eerdll.hxx +++ b/include/editeng/eerdll.hxx @@ -24,6 +24,7 @@ class GlobalEditData; #include <tools/resid.hxx> #include <editeng/editengdllapi.h> +#include <memory> class EDITENG_DLLPUBLIC EditResId: public ResId { @@ -33,14 +34,14 @@ public: class EditDLL { - GlobalEditData* pGlobalData; + std::unique_ptr<GlobalEditData> pGlobalData; public: EditDLL(); ~EditDLL(); static ResMgr* GetResMgr(); - GlobalEditData* GetGlobalData() const { return pGlobalData; } + GlobalEditData* GetGlobalData() const { return pGlobalData.get(); } static EditDLL& Get(); }; diff --git a/include/editeng/flditem.hxx b/include/editeng/flditem.hxx index d7c43ff..50ac2fd 100644 --- a/include/editeng/flditem.hxx +++ b/include/editeng/flditem.hxx @@ -67,9 +67,9 @@ public: class EDITENG_DLLPUBLIC SvxFieldItem : public SfxPoolItem { private: - SvxFieldData* pField; + std::unique_ptr<SvxFieldData> pField; - EDITENG_DLLPRIVATE SvxFieldItem( SvxFieldData* pField, const sal_uInt16 nId ); + EDITENG_DLLPRIVATE SvxFieldItem( SvxFieldData* pField, const sal_uInt16 nId ); public: static SfxPoolItem* CreateDefault(); @@ -83,7 +83,7 @@ public: virtual SfxPoolItem* Create( SvStream&, sal_uInt16 nVer ) const override; virtual SvStream& Store( SvStream& , sal_uInt16 nItemVersion ) const override; - const SvxFieldData* GetField() const { return pField; } + const SvxFieldData* GetField() const { return pField.get(); } static SvClassManager& GetClassManager(); }; diff --git a/include/editeng/lineitem.hxx b/include/editeng/lineitem.hxx index fa328a0..cf04858 100644 --- a/include/editeng/lineitem.hxx +++ b/include/editeng/lineitem.hxx @@ -59,11 +59,12 @@ public: virtual void ScaleMetrics( long nMult, long nDiv ) override; virtual bool HasMetrics() const override; - const editeng::SvxBorderLine* GetLine () const { return pLine; } - void SetLine ( const editeng::SvxBorderLine *pNew ); + const editeng::SvxBorderLine* + GetLine() const { return pLine.get(); } + void SetLine( const editeng::SvxBorderLine *pNew ); private: - editeng::SvxBorderLine* pLine; + std::unique_ptr<editeng::SvxBorderLine> pLine; }; diff --git a/include/editeng/numitem.hxx b/include/editeng/numitem.hxx index 86d8b05..fd1a01d 100644 --- a/include/editeng/numitem.hxx +++ b/include/editeng/numitem.hxx @@ -33,6 +33,7 @@ #include <unotools/fontcvt.hxx> #include <editeng/editengdllapi.h> #include <o3tl/typed_flags_set.hxx> +#include <memory> class SvxBrushItem; namespace vcl { class Font; } @@ -291,7 +292,7 @@ public: class EDITENG_DLLPUBLIC SvxNumBulletItem : public SfxPoolItem { - SvxNumRule* pNumRule; + std::unique_ptr<SvxNumRule> pNumRule; public: explicit SvxNumBulletItem(SvxNumRule& rRule); SvxNumBulletItem(SvxNumRule& rRule, sal_uInt16 nWhich ); @@ -304,7 +305,7 @@ public: virtual SvStream& Store(SvStream &rStream, sal_uInt16 nItemVersion ) const override; virtual bool operator==( const SfxPoolItem& ) const override; - SvxNumRule* GetNumRule() const {return pNumRule;} + SvxNumRule* GetNumRule() const {return pNumRule.get();} 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; diff --git a/include/editeng/outliner.hxx b/include/editeng/outliner.hxx index dad3d11..fea6253 100644 --- a/include/editeng/outliner.hxx +++ b/include/editeng/outliner.hxx @@ -192,10 +192,8 @@ class EDITENG_DLLPUBLIC OutlinerView final { friend class Outliner; -private: - - Outliner* pOwner; - EditView* pEditView; + Outliner* pOwner; + std::unique_ptr<EditView> pEditView; enum class MouseTarget { Text = 0, diff --git a/include/editeng/outlobj.hxx b/include/editeng/outlobj.hxx index 86a10e1..b296d79 100644 --- a/include/editeng/outlobj.hxx +++ b/include/editeng/outlobj.hxx @@ -25,6 +25,7 @@ #include <rtl/ustring.hxx> #include <rsc/rscsfx.hxx> #include <o3tl/cow_wrapper.hxx> +#include <memory> class EditTextObject; enum class OutlinerMode; @@ -36,9 +37,9 @@ enum class OutlinerMode; struct OutlinerParaObjData { // data members - EditTextObject* mpEditTextObject; - ParagraphDataVector maParagraphDataVector; - bool mbIsEditDoc; + std::unique_ptr<EditTextObject> mpEditTextObject; + ParagraphDataVector maParagraphDataVector; + bool mbIsEditDoc; // constuctor OutlinerParaObjData( EditTextObject* pEditTextObject, const ParagraphDataVector& rParagraphDataVector, bool bIsEditDoc ); diff --git a/include/editeng/unotext.hxx b/include/editeng/unotext.hxx index fd0ecce..69046be 100644 --- a/include/editeng/unotext.hxx +++ b/include/editeng/unotext.hxx @@ -485,7 +485,7 @@ class SvxUnoTextContentEnumeration : public ::cppu::WeakAggImplHelper1< css::con { private: css::uno::Reference< css::text::XText > mxParentText; - SvxEditSource* mpEditSource; + std::unique_ptr<SvxEditSource> mpEditSource; sal_Int32 mnNextParagraph; const SvxUnoTextBase& mrText; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits