use unique_ptr in sw

Change-Id: I471875142391e537a4301dfe42beb8f8803ff46b
Reviewed-on: https://gerrit.libreoffice.org/66036
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin
2019-01-09 15:38:12 +02:00
parent 3d14462e23
commit 152e2e6943
9 changed files with 36 additions and 44 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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() )

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -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 )

View File

@@ -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;
}
}

View File

@@ -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

View File

@@ -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() );