sw/source/core/layout/frmtool.cxx | 8 ++++---- sw/source/core/layout/paintfrm.cxx | 8 +++----- sw/source/core/text/frmform.cxx | 6 +++--- sw/source/core/text/frmpaint.cxx | 16 ++++++---------- sw/source/core/text/txtdrop.cxx | 7 +++---- sw/source/core/text/txtfly.cxx | 8 ++++---- sw/source/core/text/txtftn.cxx | 3 +-- sw/source/core/txtnode/fntcache.cxx | 8 ++++---- sw/source/core/txtnode/fntcap.cxx | 16 ++++++++-------- 9 files changed, 36 insertions(+), 44 deletions(-)
New commits: commit 152e2e6943adf46f12c04cf76dc435e48c1f1c74 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Wed Jan 9 15:38:12 2019 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Fri Jan 11 10:20:11 2019 +0100 use unique_ptr in sw Change-Id: I471875142391e537a4301dfe42beb8f8803ff46b Reviewed-on: https://gerrit.libreoffice.org/66036 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sw/source/core/layout/frmtool.cxx b/sw/source/core/layout/frmtool.cxx index f086f7cc3cf8..29554a5a6607 100644 --- a/sw/source/core/layout/frmtool.cxx +++ b/sw/source/core/layout/frmtool.cxx @@ -1346,7 +1346,7 @@ void InsertCnt_( SwLayoutFrame *pLay, SwDoc *pDoc, const SwFrameFormats *pTable = pDoc->GetSpzFrameFormats(); SwFrame *pFrame = nullptr; std::unique_ptr<SwActualSection> pActualSection; - SwLayHelper *pPageMaker; + std::unique_ptr<SwLayHelper> pPageMaker; //If the layout will be created (bPages == true) we do head on the progress //Flys and DrawObjects are not connected immediately, this @@ -1355,8 +1355,8 @@ void InsertCnt_( SwLayoutFrame *pLay, SwDoc *pDoc, { // Attention: the SwLayHelper class uses references to the content-, // page-, layout-frame etc. and may change them! - pPageMaker = new SwLayHelper( pDoc, pFrame, pPrv, pPage, pLay, - pActualSection, nIndex, 0 == nEndIndex ); + pPageMaker.reset(new SwLayHelper( pDoc, pFrame, pPrv, pPage, pLay, + pActualSection, nIndex, 0 == nEndIndex )); if( bStartPercent ) { const sal_uLong nPageCount = pPageMaker->CalcPageCount(); @@ -1747,7 +1747,7 @@ void InsertCnt_( SwLayoutFrame *pLay, SwDoc *pDoc, if( pPageMaker ) { pPageMaker->CheckFlyCache( pPage ); - delete pPageMaker; + pPageMaker.reset(); if( pDoc->GetLayoutCache() ) { #ifdef DBG_UTIL diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx index 815497059439..671916cf4194 100644 --- a/sw/source/core/layout/paintfrm.cxx +++ b/sw/source/core/layout/paintfrm.cxx @@ -6214,12 +6214,12 @@ void SwFrame::PaintSwFrameBackground( const SwRect &rRect, const SwPageFrame *pP if ( aRect.HasArea() ) { - SvxBrushItem* pNewItem = nullptr; + std::unique_ptr<SvxBrushItem> pNewItem; if( pCol ) { - pNewItem = new SvxBrushItem( *pCol, RES_BACKGROUND ); - pItem = pNewItem; + pNewItem.reset(new SvxBrushItem( *pCol, RES_BACKGROUND )); + pItem = pNewItem.get(); aFillAttributes.reset(new drawinglayer::attribute::SdrAllFillAttributesHelper(*pCol)); } @@ -6287,8 +6287,6 @@ void SwFrame::PaintSwFrameBackground( const SwRect &rRect, const SwPageFrame *pP bConsiderBackgroundTransparency ); } } - if( pCol ) - delete pNewItem; } } else diff --git a/sw/source/core/text/frmform.cxx b/sw/source/core/text/frmform.cxx index b9f1cde74d03..3217fa2fab8e 100644 --- a/sw/source/core/text/frmform.cxx +++ b/sw/source/core/text/frmform.cxx @@ -1307,7 +1307,7 @@ void SwTextFrame::Format_( SwTextFormatter &rLine, SwTextFormatInfo &rInf, SwCharRange &rReformat = pPara->GetReformat(); SwRepaint &rRepaint = pPara->GetRepaint(); - SwRepaint *pFreeze = nullptr; + std::unique_ptr<SwRepaint> pFreeze; // Due to performance reasons we set rReformat to COMPLETE_STRING in Init() // In this case we adjust rReformat @@ -1566,7 +1566,7 @@ void SwTextFrame::Format_( SwTextFormatter &rLine, SwTextFormatInfo &rInf, { while( rLine.Next() ) ; //Nothing - pFreeze = new SwRepaint( rRepaint ); // to minimize painting + pFreeze.reset(new SwRepaint( rRepaint )); // to minimize painting } else break; @@ -1578,7 +1578,7 @@ void SwTextFrame::Format_( SwTextFormatter &rLine, SwTextFormatInfo &rInf, if( pFreeze ) { rRepaint = *pFreeze; - delete pFreeze; + pFreeze.reset(); } if( !rLine.IsStop() ) diff --git a/sw/source/core/text/frmpaint.cxx b/sw/source/core/text/frmpaint.cxx index 66c742f0a7d2..aeac33ab9da0 100644 --- a/sw/source/core/text/frmpaint.cxx +++ b/sw/source/core/text/frmpaint.cxx @@ -464,17 +464,17 @@ bool SwTextFrame::PaintEmpty( const SwRect &rRect, bool bCheck ) const return false; else if( pSh->GetWin() ) { - SwFont *pFnt; + std::unique_ptr<SwFont> pFnt; const SwTextNode& rTextNode = *GetTextNodeForParaProps(); if ( rTextNode.HasSwAttrSet() ) { const SwAttrSet *pAttrSet = &( rTextNode.GetSwAttrSet() ); - pFnt = new SwFont( pAttrSet, rTextNode.getIDocumentSettingAccess() ); + pFnt.reset(new SwFont( pAttrSet, rTextNode.getIDocumentSettingAccess() )); } else { SwFontAccess aFontAccess( &rTextNode.GetAnyFormatColl(), pSh ); - pFnt = new SwFont( aFontAccess.Get()->GetFont() ); + pFnt.reset(new SwFont( aFontAccess.Get()->GetFont() )); } const IDocumentRedlineAccess& rIDRA = rTextNode.getIDocumentRedlineAccess(); @@ -516,14 +516,12 @@ bool SwTextFrame::PaintEmpty( const SwRect &rRect, bool bCheck ) const if ( rSpace.GetTextFirstLineOfst() > 0 ) aPos.AdjustX(rSpace.GetTextFirstLineOfst() ); - SwSaveClip *pClip; + std::unique_ptr<SwSaveClip> pClip; if( IsUndersized() ) { - pClip = new SwSaveClip( pSh->GetOut() ); + pClip.reset(new SwSaveClip( pSh->GetOut() )); pClip->ChgClip( rRect ); } - else - pClip = nullptr; aPos.AdjustY(pFnt->GetAscent( pSh, *pSh->GetOut() ) ); @@ -554,15 +552,13 @@ bool SwTextFrame::PaintEmpty( const SwRect &rRect, bool bCheck ) const aDrawInf.SetGrammarCheck( nullptr ); aDrawInf.SetSmartTags( nullptr ); aDrawInf.SetFrame( this ); - aDrawInf.SetFont( pFnt ); + aDrawInf.SetFont( pFnt.get() ); aDrawInf.SetSnapToGrid( false ); pFnt->SetColor(NON_PRINTING_CHARACTER_COLOR); pFnt->DrawText_( aDrawInf ); } - delete pClip; } - delete pFnt; return true; } } diff --git a/sw/source/core/text/txtdrop.cxx b/sw/source/core/text/txtdrop.cxx index 0582c8ca3d04..99df1d7fe026 100644 --- a/sw/source/core/text/txtdrop.cxx +++ b/sw/source/core/text/txtdrop.cxx @@ -400,20 +400,19 @@ void SwDropPortion::Paint( const SwTextPaintInfo &rInf ) const rInf.DrawBackground( *this ); // make sure that font is not rotated - SwFont* pTmpFont = nullptr; + std::unique_ptr<SwFont> pTmpFont; if ( rInf.GetFont()->GetOrientation( rInf.GetTextFrame()->IsVertical() ) ) { - pTmpFont = new SwFont( *rInf.GetFont() ); + pTmpFont.reset(new SwFont( *rInf.GetFont() )); pTmpFont->SetVertical( 0, rInf.GetTextFrame()->IsVertical() ); } - SwFontSave aFontSave( rInf, pTmpFont ); + SwFontSave aFontSave( rInf, pTmpFont.get() ); // for text inside drop portions we let vcl handle the text directions SwLayoutModeModifier aLayoutModeModifier( *rInf.GetOut() ); aLayoutModeModifier.SetAuto(); SwTextPortion::Paint( rInf ); - delete pTmpFont; } } diff --git a/sw/source/core/text/txtfly.cxx b/sw/source/core/text/txtfly.cxx index ddeaa99b05db..1fbf696c4cf5 100644 --- a/sw/source/core/text/txtfly.cxx +++ b/sw/source/core/text/txtfly.cxx @@ -221,7 +221,7 @@ const SwRect SwContourCache::ContourRect( const SwFormat* pFormat, mvItems.pop_back(); } ::basegfx::B2DPolyPolygon aPolyPolygon; - ::basegfx::B2DPolyPolygon* pPolyPolygon = nullptr; + std::unique_ptr<::basegfx::B2DPolyPolygon> pPolyPolygon; if ( auto pVirtFlyDrawObj = dynamic_cast< const SwVirtFlyDrawObj *>( pObj ) ) { @@ -242,13 +242,13 @@ const SwRect SwContourCache::ContourRect( const SwFormat* pFormat, } ::basegfx::B2DPolyPolygon aContourPoly(pObj->TakeContour()); - pPolyPolygon = new ::basegfx::B2DPolyPolygon(aContourPoly); + pPolyPolygon.reset(new ::basegfx::B2DPolyPolygon(aContourPoly)); } const SvxLRSpaceItem &rLRSpace = pFormat->GetLRSpace(); const SvxULSpaceItem &rULSpace = pFormat->GetULSpace(); CacheItem item { pObj, // due to #37347 the Object must be entered only after GetContour() - o3tl::make_unique<TextRanger>( aPolyPolygon, pPolyPolygon, 20, + o3tl::make_unique<TextRanger>( aPolyPolygon, pPolyPolygon.get(), 20, static_cast<sal_uInt16>(rLRSpace.GetLeft()), static_cast<sal_uInt16>(rLRSpace.GetRight()), pFormat->GetSurround().IsOutside(), false, pFrame->IsVertical() ) }; @@ -256,7 +256,7 @@ const SwRect SwContourCache::ContourRect( const SwFormat* pFormat, mvItems[0].mxTextRanger->SetUpper( rULSpace.GetUpper() ); mvItems[0].mxTextRanger->SetLower( rULSpace.GetLower() ); - delete pPolyPolygon; + pPolyPolygon.reset(); nPntCnt += mvItems[0].mxTextRanger->GetPointCount(); while( nPntCnt > POLY_MAX && mvItems.size() > POLY_MIN ) diff --git a/sw/source/core/text/txtftn.cxx b/sw/source/core/text/txtftn.cxx index 0014d09831e2..6c32d30b9795 100644 --- a/sw/source/core/text/txtftn.cxx +++ b/sw/source/core/text/txtftn.cxx @@ -737,9 +737,8 @@ void SwTextFrame::ConnectFootnote( SwTextFootnote *pFootnote, const SwTwips nDea if( bBrutal ) { pBoss->RemoveFootnote( pSrcFrame, pFootnote, false ); - SwSaveFootnoteHeight *pHeight = bEnd ? nullptr : new SwSaveFootnoteHeight( pBoss, nDeadLine ); + std::unique_ptr<SwSaveFootnoteHeight> pHeight(bEnd ? nullptr : new SwSaveFootnoteHeight( pBoss, nDeadLine )); pBoss->AppendFootnote( this, pFootnote ); - delete pHeight; } } diff --git a/sw/source/core/txtnode/fntcache.cxx b/sw/source/core/txtnode/fntcache.cxx index c2eb371af994..ee6735ec3244 100644 --- a/sw/source/core/txtnode/fntcache.cxx +++ b/sw/source/core/txtnode/fntcache.cxx @@ -1968,16 +1968,16 @@ Size SwFntObj::GetTextSize( SwDrawTextInfo& rInf ) aTextSize.setWidth( m_pPrinter->GetTextWidth( rInf.GetText(), sal_Int32(rInf.GetIdx()), sal_Int32(nLn))); aTextSize.setHeight( m_pPrinter->GetTextHeight() ); - long* pKernArray = new long[sal_Int32(nLn)]; + std::unique_ptr<long[]> pKernArray(new long[sal_Int32(nLn)]); CreateScrFont( *rInf.GetShell(), rInf.GetOut() ); if( !GetScrFont()->IsSameInstance( rInf.GetOut().GetFont() ) ) rInf.GetOut().SetFont( *m_pScrFont ); long nScrPos; - m_pPrinter->GetTextArray(rInf.GetText(), pKernArray, + m_pPrinter->GetTextArray(rInf.GetText(), pKernArray.get(), sal_Int32(rInf.GetIdx()), sal_Int32(nLn)); if( bCompress ) - rInf.SetKanaDiff( rInf.GetScriptInfo()->Compress( pKernArray, + rInf.SetKanaDiff( rInf.GetScriptInfo()->Compress( pKernArray.get(), rInf.GetIdx(), nLn, rInf.GetKanaComp(), static_cast<sal_uInt16>(m_aFont.GetFontSize().Height()) ,lcl_IsFullstopCentered( rInf.GetOut() ) ) ); else @@ -2027,7 +2027,7 @@ Size SwFntObj::GetTextSize( SwDrawTextInfo& rInf ) } } - delete[] pKernArray; + pKernArray.reset(); aTextSize.setWidth( nScrPos ); } else diff --git a/sw/source/core/txtnode/fntcap.cxx b/sw/source/core/txtnode/fntcap.cxx index 12be40860253..dc090742b0e2 100644 --- a/sw/source/core/txtnode/fntcap.cxx +++ b/sw/source/core/txtnode/fntcap.cxx @@ -486,9 +486,9 @@ void SwSubFont::DoOnCapitals( SwDoCapitals &rDo ) rDo.SetCapInf( aCapInf ); SwFntObj *pOldLast = pLastFont; - SwFntAccess *pBigFontAccess = nullptr; + std::unique_ptr<SwFntAccess> pBigFontAccess; SwFntObj *pBigFont; - SwFntAccess *pSpaceFontAccess = nullptr; + std::unique_ptr<SwFntAccess> pSpaceFontAccess; SwFntObj *pSpaceFont = nullptr; const void* nFontCacheId2 = nullptr; @@ -508,8 +508,8 @@ void SwSubFont::DoOnCapitals( SwDoCapitals &rDo ) if ( bWordWise ) { aFont.SetWordLineMode( false ); - pSpaceFontAccess = new SwFntAccess( nFontCacheId2, nIndex2, &aFont, - rDo.GetInf().GetShell() ); + pSpaceFontAccess.reset(new SwFntAccess( nFontCacheId2, nIndex2, &aFont, + rDo.GetInf().GetShell() )); pSpaceFont = pSpaceFontAccess->Get(); } else @@ -521,8 +521,8 @@ void SwSubFont::DoOnCapitals( SwDoCapitals &rDo ) aFont.SetStrikeout( STRIKEOUT_NONE ); nFontCacheId2 = nullptr; nIndex2 = 0; - pBigFontAccess = new SwFntAccess( nFontCacheId2, nIndex2, &aFont, - rDo.GetInf().GetShell() ); + pBigFontAccess.reset(new SwFntAccess( nFontCacheId2, nIndex2, &aFont, + rDo.GetInf().GetShell() )); pBigFont = pBigFontAccess->Get(); } else @@ -733,7 +733,7 @@ void SwSubFont::DoOnCapitals( SwDoCapitals &rDo ) // clean up: if( pBigFont != pOldLast ) - delete pBigFontAccess; + pBigFontAccess.reset(); if( bTextLines ) { @@ -744,7 +744,7 @@ void SwSubFont::DoOnCapitals( SwDoCapitals &rDo ) static_cast<SwDoDrawCapital&>( rDo ).DrawSpace( aStartPos ); } if ( bWordWise ) - delete pSpaceFontAccess; + pSpaceFontAccess.reset(); } pLastFont = pOldLast; pLastFont->SetDevFont( rDo.GetInf().GetShell(), rDo.GetOut() ); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits