summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-01-31 14:46:38 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-02-01 12:15:22 +0000
commit2489000d3fd66319a8355fd4e37cfdfda47296d0 (patch)
treecaad79e7b5bec3863604b20190b682c0d73d2b25 /sw
parent595848c85acc2609fcc48a40c7a9f216a2722cd8 (diff)
loplugin:useuniqueptr extend to check local vars
just the simple and obvious case for now, of a local var being allocated and deleted inside a single local block, and the delete happening at the end of the block Change-Id: I3a7a094da543debdcd2374737c2ecff91d644625 Reviewed-on: https://gerrit.libreoffice.org/33749 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/access/accfrmobjmap.cxx11
-rw-r--r--sw/source/core/access/accpara.cxx7
-rw-r--r--sw/source/core/crsr/crsrsh.cxx7
-rw-r--r--sw/source/core/doc/doccomp.cxx19
-rw-r--r--sw/source/core/frmedt/fecopy.cxx9
-rw-r--r--sw/source/core/layout/paintfrm.cxx3
-rw-r--r--sw/source/core/text/pormulti.cxx5
-rw-r--r--sw/source/core/txtnode/fntcache.cxx72
-rw-r--r--sw/source/core/unocore/unodraw.cxx5
-rw-r--r--sw/source/filter/html/swhtml.cxx4
-rw-r--r--sw/source/filter/ww8/wrtw8esh.cxx7
-rw-r--r--sw/source/filter/ww8/wrtww8.cxx8
-rw-r--r--sw/source/filter/ww8/wrtww8gr.cxx3
-rw-r--r--sw/source/filter/ww8/ww8par2.cxx7
-rw-r--r--sw/source/filter/ww8/ww8scan.cxx36
-rw-r--r--sw/source/ui/chrdlg/chardlg.cxx3
-rw-r--r--sw/source/uibase/dialog/SwSpellDialogChildWindow.cxx7
17 files changed, 90 insertions, 123 deletions
diff --git a/sw/source/core/access/accfrmobjmap.cxx b/sw/source/core/access/accfrmobjmap.cxx
index 28511ab4b3b7..43da30d7dbad 100644
--- a/sw/source/core/access/accfrmobjmap.cxx
+++ b/sw/source/core/access/accfrmobjmap.cxx
@@ -103,20 +103,17 @@ SwAccessibleChildMap::SwAccessibleChildMap( const SwRect& rVisArea,
if ( pAccImpl &&
pAccImpl->HasAdditionalAccessibleChildren() )
{
- std::vector< vcl::Window* >* pAdditionalChildren =
- new std::vector< vcl::Window* >();
- pAccImpl->GetAdditionalAccessibleChildren( pAdditionalChildren );
+ std::vector< vcl::Window* > aAdditionalChildren;
+ pAccImpl->GetAdditionalAccessibleChildren( &aAdditionalChildren );
sal_Int32 nCounter( 0 );
- for ( std::vector< vcl::Window* >::iterator aIter = pAdditionalChildren->begin();
- aIter != pAdditionalChildren->end();
+ for ( std::vector< vcl::Window* >::iterator aIter = aAdditionalChildren.begin();
+ aIter != aAdditionalChildren.end();
++aIter )
{
aLower = (*aIter);
insert( ++nCounter, SwAccessibleChildMapKey::XWINDOW, aLower );
}
-
- delete pAdditionalChildren;
}
}
}
diff --git a/sw/source/core/access/accpara.cxx b/sw/source/core/access/accpara.cxx
index 624928acbc4a..fa4913fe92cf 100644
--- a/sw/source/core/access/accpara.cxx
+++ b/sw/source/core/access/accpara.cxx
@@ -1922,15 +1922,12 @@ void SwAccessibleParagraph::_getRunAttributesImpl(
SwPaM* pPaM( nullptr );
{
const SwTextNode* pTextNode( GetTextNode() );
- SwPosition* pStartPos = new SwPosition( *pTextNode );
+ std::unique_ptr<SwPosition> pStartPos( new SwPosition( *pTextNode ) );
pStartPos->nContent.Assign( const_cast<SwTextNode*>(pTextNode), nIndex );
- SwPosition* pEndPos = new SwPosition( *pTextNode );
+ std::unique_ptr<SwPosition> pEndPos( new SwPosition( *pTextNode ) );
pEndPos->nContent.Assign( const_cast<SwTextNode*>(pTextNode), nIndex+1 );
pPaM = new SwPaM( *pStartPos, *pEndPos );
-
- delete pStartPos;
- delete pEndPos;
}
// retrieve character attributes for the created PaM <pPaM>
diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index 4b1d6b78904d..5d2b9994990e 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -2585,7 +2585,7 @@ void SwCursorShell::ParkCursor( const SwNodeIndex &rIdx )
SwNode *pNode = &rIdx.GetNode();
// create a new PaM
- SwPaM * pNew = new SwPaM( *GetCursor()->GetPoint() );
+ std::unique_ptr<SwPaM> pNew( new SwPaM( *GetCursor()->GetPoint() ) );
if( pNode->GetStartNode() )
{
if( ( pNode = pNode->StartOfSectionNode())->IsTableNode() )
@@ -2612,9 +2612,9 @@ void SwCursorShell::ParkCursor( const SwNodeIndex &rIdx )
{
SwCursorShell* pSh = static_cast<SwCursorShell*>(&rTmp);
if( pSh->m_pCursorStack )
- pSh->ParkPams( pNew, &pSh->m_pCursorStack );
+ pSh->ParkPams( pNew.get(), &pSh->m_pCursorStack );
- pSh->ParkPams( pNew, &pSh->m_pCurrentCursor );
+ pSh->ParkPams( pNew.get(), &pSh->m_pCurrentCursor );
if( pSh->m_pTableCursor )
{
// set table cursor always to 0 and the current one always to
@@ -2629,7 +2629,6 @@ void SwCursorShell::ParkCursor( const SwNodeIndex &rIdx )
}
}
}
- delete pNew;
}
/** Copy constructor
diff --git a/sw/source/core/doc/doccomp.cxx b/sw/source/core/doc/doccomp.cxx
index 7cef79e726a4..5adbb5fbbbaf 100644
--- a/sw/source/core/doc/doccomp.cxx
+++ b/sw/source/core/doc/doccomp.cxx
@@ -588,8 +588,8 @@ Compare::Compare( sal_uLong nDiff, CompareData& rData1, CompareData& rData2 )
MovedData *pMD1, *pMD2;
// Look for the differing lines
{
- sal_Char* pDiscard1 = new sal_Char[ rData1.GetLineCount() ];
- sal_Char* pDiscard2 = new sal_Char[ rData2.GetLineCount() ];
+ std::unique_ptr<sal_Char[]> pDiscard1( new sal_Char[ rData1.GetLineCount() ] );
+ std::unique_ptr<sal_Char[]> pDiscard2( new sal_Char[ rData2.GetLineCount() ] );
sal_uLong* pCount1 = new sal_uLong[ nDiff ];
sal_uLong* pCount2 = new sal_uLong[ nDiff ];
@@ -602,20 +602,17 @@ Compare::Compare( sal_uLong nDiff, CompareData& rData1, CompareData& rData2 )
// All which occur only once now have either been inserted or deleted.
// All which are also contained in the other one have been moved.
- SetDiscard( rData1, pDiscard1, pCount2 );
- SetDiscard( rData2, pDiscard2, pCount1 );
+ SetDiscard( rData1, pDiscard1.get(), pCount2 );
+ SetDiscard( rData2, pDiscard2.get(), pCount1 );
// forget the arrays again
delete [] pCount1; delete [] pCount2;
- CheckDiscard( rData1.GetLineCount(), pDiscard1 );
- CheckDiscard( rData2.GetLineCount(), pDiscard2 );
+ CheckDiscard( rData1.GetLineCount(), pDiscard1.get() );
+ CheckDiscard( rData2.GetLineCount(), pDiscard2.get() );
- pMD1 = new MovedData( rData1, pDiscard1 );
- pMD2 = new MovedData( rData2, pDiscard2 );
-
- // forget the arrays again
- delete [] pDiscard1; delete [] pDiscard2;
+ pMD1 = new MovedData( rData1, pDiscard1.get() );
+ pMD2 = new MovedData( rData2, pDiscard2.get() );
}
{
diff --git a/sw/source/core/frmedt/fecopy.cxx b/sw/source/core/frmedt/fecopy.cxx
index dc95e72bbb92..18678ce7a2ce 100644
--- a/sw/source/core/frmedt/fecopy.cxx
+++ b/sw/source/core/frmedt/fecopy.cxx
@@ -1317,14 +1317,14 @@ void SwFEShell::Paste( SvStream& rStrm, SwPasteSdr nAction, const Point* pPt )
StartUndo();
SvtPathOptions aPathOpt;
- FmFormModel* pModel = new FmFormModel( aPathOpt.GetPalettePath(),
- nullptr, GetDoc()->GetDocShell() );
+ std::unique_ptr<FmFormModel> pModel( new FmFormModel( aPathOpt.GetPalettePath(),
+ nullptr, GetDoc()->GetDocShell() ) );
pModel->GetItemPool().FreezeIdRanges();
rStrm.Seek(0);
uno::Reference< io::XInputStream > xInputStream( new utl::OInputStreamWrapper( rStrm ) );
- SvxDrawingLayerImport( pModel, xInputStream );
+ SvxDrawingLayerImport( pModel.get(), xInputStream );
if ( !Imp()->HasDrawView() )
Imp()->MakeDrawView();
@@ -1496,7 +1496,7 @@ void SwFEShell::Paste( SvStream& rStrm, SwPasteSdr nAction, const Point* pPt )
// #i50824#
// method <lcl_RemoveOleObjsFromSdrModel> replaced by <lcl_ConvertSdrOle2ObjsToSdrGrafObjs>
- lcl_ConvertSdrOle2ObjsToSdrGrafObjs( pModel );
+ lcl_ConvertSdrOle2ObjsToSdrGrafObjs( pModel.get() );
pView->Paste(*pModel, aPos, nullptr, SdrInsertFlags::NONE);
const size_t nCnt = pView->GetMarkedObjectList().GetMarkCount();
@@ -1530,7 +1530,6 @@ void SwFEShell::Paste( SvStream& rStrm, SwPasteSdr nAction, const Point* pPt )
}
EndUndo();
EndAllAction();
- delete pModel;
}
bool SwFEShell::Paste(const Graphic &rGrf, const OUString& rURL)
diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index 90c1f3ba6c35..27c722b5d270 100644
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -7749,12 +7749,11 @@ Graphic SwDrawFrameFormat::MakeGraphic( ImageMap* )
if ( pMod )
{
SdrObject *pObj = FindSdrObject();
- SdrView *pView = new SdrView( pMod );
+ std::unique_ptr<SdrView> pView( new SdrView( pMod ) );
SdrPageView *pPgView = pView->ShowSdrPage(pView->GetModel()->GetPage(0));
pView->MarkObj( pObj, pPgView );
aRet = pView->GetMarkedObjBitmapEx();
pView->HideSdrPage();
- delete pView;
}
return aRet;
}
diff --git a/sw/source/core/text/pormulti.cxx b/sw/source/core/text/pormulti.cxx
index 39bdf05d6163..9927020edad7 100644
--- a/sw/source/core/text/pormulti.cxx
+++ b/sw/source/core/text/pormulti.cxx
@@ -339,14 +339,13 @@ void SwDoubleLinePortion::PaintBracket( SwTextPaintInfo &rInf,
aBlank.Width( nChWidth );
aBlank.Height( pBracket->nHeight );
{
- SwFont* pTmpFnt = new SwFont( *rInf.GetFont() );
+ std::unique_ptr<SwFont> pTmpFnt( new SwFont( *rInf.GetFont() ) );
SwFontScript nAct = bOpen ? pBracket->nPreScript : pBracket->nPostScript;
if( SW_SCRIPTS > nAct )
pTmpFnt->SetActual( nAct );
pTmpFnt->SetProportion( 100 );
- SwFontSave aSave( rInf, pTmpFnt );
+ SwFontSave aSave( rInf, pTmpFnt.get() );
aBlank.Paint( rInf );
- delete pTmpFnt;
}
if( bOpen )
rInf.X( rInf.X() + PreWidth() );
diff --git a/sw/source/core/txtnode/fntcache.cxx b/sw/source/core/txtnode/fntcache.cxx
index 152e92c81d14..b3dbcb661c0c 100644
--- a/sw/source/core/txtnode/fntcache.cxx
+++ b/sw/source/core/txtnode/fntcache.cxx
@@ -1183,8 +1183,8 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
// Simple kerning is handled by DrawStretchText
if( rInf.GetSpace() || rInf.GetKanaComp() )
{
- long *pKernArray = new long[ rInf.GetLen() ];
- rInf.GetOut().GetTextArray( rInf.GetText(), pKernArray,
+ std::unique_ptr<long[]> pKernArray( new long[ rInf.GetLen() ] );
+ rInf.GetOut().GetTextArray( rInf.GetText(), pKernArray.get(),
rInf.GetIdx(), rInf.GetLen() );
if( bStretch )
@@ -1230,7 +1230,7 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
pSI && pSI->CountCompChg() &&
lcl_IsMonoSpaceFont( rInf.GetOut() ) )
{
- pSI->Compress( pKernArray, rInf.GetIdx(), rInf.GetLen(),
+ pSI->Compress( pKernArray.get(), rInf.GetIdx(), rInf.GetLen(),
rInf.GetKanaComp(),
(sal_uInt16)m_aFont.GetFontSize().Height(), lcl_IsFullstopCentered( rInf.GetOut() ), &aTextOriginPos );
bSpecialJust = true;
@@ -1243,7 +1243,7 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
if (!MsLangId::isKorean(aLang))
{
- SwScriptInfo::CJKJustify( rInf.GetText(), pKernArray, nullptr,
+ SwScriptInfo::CJKJustify( rInf.GetText(), pKernArray.get(), nullptr,
rInf.GetIdx(), rInf.GetLen(), aLang, nSpaceAdd );
bSpecialJust = true;
@@ -1257,7 +1257,7 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
if ( SwScriptInfo::IsArabicText( rInf.GetText(), rInf.GetIdx(), rInf.GetLen() ) )
{
if ( pSI && pSI->CountKashida() &&
- pSI->KashidaJustify( pKernArray, nullptr, rInf.GetIdx(),
+ pSI->KashidaJustify( pKernArray.get(), nullptr, rInf.GetIdx(),
rInf.GetLen(), nSpaceAdd ) != -1 )
{
bSpecialJust = true;
@@ -1275,7 +1275,7 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
{
// Use rInf.GetSpace() because it has more precision than
// nSpaceAdd:
- SwScriptInfo::ThaiJustify( rInf.GetText(), pKernArray, nullptr,
+ SwScriptInfo::ThaiJustify( rInf.GetText(), pKernArray.get(), nullptr,
rInf.GetIdx(), rInf.GetLen(),
rInf.GetNumberOfBlanks(),
rInf.GetSpace() );
@@ -1310,18 +1310,18 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
pKernArray[0] = rInf.GetWidth() + nSpaceAdd;
rInf.GetOut().DrawTextArray( aTextOriginPos, rInf.GetText(),
- pKernArray, rInf.GetIdx(), 1 );
+ pKernArray.get(), rInf.GetIdx(), 1 );
}
else
{
pKernArray[ rInf.GetLen() - 2 ] += nSpaceAdd;
rInf.GetOut().DrawTextArray( aTextOriginPos, rInf.GetText(),
- pKernArray, rInf.GetIdx(), rInf.GetLen() );
+ pKernArray.get(), rInf.GetIdx(), rInf.GetLen() );
}
}
else
rInf.GetOut().DrawTextArray( aTextOriginPos, rInf.GetText(),
- pKernArray, rInf.GetIdx(), rInf.GetLen() );
+ pKernArray.get(), rInf.GetIdx(), rInf.GetLen() );
}
else
{
@@ -1347,7 +1347,6 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
rInf.GetOut().DrawText( aTmpPos, rInf.GetText(),
rInf.GetIdx() + j, i - j );
}
- delete[] pKernArray;
}
else if( bStretch )
{
@@ -1390,13 +1389,13 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
bool bBullet = rInf.GetBullet();
if( m_bSymbol )
bBullet = false;
- long* pKernArray = new long[ rInf.GetLen() ];
+ std::unique_ptr<long[]> pKernArray( new long[ rInf.GetLen() ] );
CreateScrFont( *rInf.GetShell(), rInf.GetOut() );
long nScrPos;
// get screen array
- long* pScrArray = new long[ rInf.GetLen() ];
- rInf.GetOut().GetTextArray( rInf.GetText(), pScrArray,
+ std::unique_ptr<long[]> pScrArray( new long[ rInf.GetLen() ] );
+ rInf.GetOut().GetTextArray( rInf.GetText(), pScrArray.get(),
rInf.GetIdx(), rInf.GetLen() );
// OLE: no printer available
@@ -1409,12 +1408,12 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
if( !m_pPrtFont->IsSameInstance( m_pPrinter->GetFont() ) )
m_pPrinter->SetFont( *m_pPrtFont );
}
- m_pPrinter->GetTextArray( rInf.GetText(), pKernArray, rInf.GetIdx(),
+ m_pPrinter->GetTextArray( rInf.GetText(), pKernArray.get(), rInf.GetIdx(),
rInf.GetLen() );
}
else
{
- rInf.GetOut().GetTextArray( rInf.GetText(), pKernArray,
+ rInf.GetOut().GetTextArray( rInf.GetText(), pKernArray.get(),
rInf.GetIdx(), rInf.GetLen() );
}
@@ -1434,10 +1433,10 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
lcl_IsMonoSpaceFont( rInf.GetOut() ) )
{
Point aTmpPos( aTextOriginPos );
- pSI->Compress( pScrArray, rInf.GetIdx(), rInf.GetLen(),
+ pSI->Compress( pScrArray.get(), rInf.GetIdx(), rInf.GetLen(),
rInf.GetKanaComp(),
(sal_uInt16)m_aFont.GetFontSize().Height(), lcl_IsFullstopCentered( rInf.GetOut() ), &aTmpPos );
- pSI->Compress( pKernArray, rInf.GetIdx(), rInf.GetLen(),
+ pSI->Compress( pKernArray.get(), rInf.GetIdx(), rInf.GetLen(),
rInf.GetKanaComp(),
(sal_uInt16)m_aFont.GetFontSize().Height(), lcl_IsFullstopCentered( rInf.GetOut() ), &aTextOriginPos );
}
@@ -1449,7 +1448,7 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
if (!MsLangId::isKorean(aLang))
{
- SwScriptInfo::CJKJustify( rInf.GetText(), pKernArray, pScrArray,
+ SwScriptInfo::CJKJustify( rInf.GetText(), pKernArray.get(), pScrArray.get(),
rInf.GetIdx(), rInf.GetLen(), aLang, nSpaceAdd );
nSpaceAdd = 0;
@@ -1462,7 +1461,7 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
if ( SwScriptInfo::IsArabicText( rInf.GetText(), rInf.GetIdx(), rInf.GetLen() ) )
{
if ( pSI && pSI->CountKashida() &&
- pSI->KashidaJustify( pKernArray, pScrArray, rInf.GetIdx(),
+ pSI->KashidaJustify( pKernArray.get(), pScrArray.get(), rInf.GetIdx(),
rInf.GetLen(), nSpaceAdd ) != -1 )
nSpaceAdd = 0;
else
@@ -1477,8 +1476,8 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
if ( LANGUAGE_THAI == aLang )
{
- SwScriptInfo::ThaiJustify( rInf.GetText(), pKernArray,
- pScrArray, rInf.GetIdx(),
+ SwScriptInfo::ThaiJustify( rInf.GetText(), pKernArray.get(),
+ pScrArray.get(), rInf.GetIdx(),
rInf.GetLen(),
rInf.GetNumberOfBlanks(),
rInf.GetSpace() );
@@ -1555,9 +1554,9 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
rInf.GetFrame()->SwitchHorizontalToVertical( aTextOriginPos );
rInf.GetOut().DrawTextArray( aTextOriginPos, rInf.GetText(),
- pKernArray, rInf.GetIdx(), 1 );
+ pKernArray.get(), rInf.GetIdx(), 1 );
if( bBullet )
- rInf.GetOut().DrawTextArray( aTextOriginPos, *pStr, pKernArray,
+ rInf.GetOut().DrawTextArray( aTextOriginPos, *pStr, pKernArray.get(),
rInf.GetIdx() ? 1 : 0, 1 );
}
else
@@ -1712,7 +1711,7 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
{
CalcLinePosData aCalcLinePosData(rInf, GetFont(),
nCnt, bSwitchH2V, bSwitchL2R,
- nHalfSpace, pKernArray, bBidiPor);
+ nHalfSpace, pKernArray.get(), bBidiPor);
SwForbidden aForbidden;
// draw line for smart tag data
@@ -1746,7 +1745,7 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
sal_Int32 nTmpIdx = bBullet ?
( rInf.GetIdx() ? 1 : 0 ) :
rInf.GetIdx();
- rInf.GetOut().DrawTextArray( aTextOriginPos, *pStr, pKernArray + nOffs,
+ rInf.GetOut().DrawTextArray( aTextOriginPos, *pStr, pKernArray.get() + nOffs,
nTmpIdx + nOffs , nLen - nOffs );
if (bBullet)
{
@@ -1784,7 +1783,7 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
pKernArray [ i - 1 ] -= nAdd;
}
}
- rInf.GetOut().DrawTextArray( aTextOriginPos, aBulletOverlay, pKernArray + nOffs,
+ rInf.GetOut().DrawTextArray( aTextOriginPos, aBulletOverlay, pKernArray.get() + nOffs,
nTmpIdx + nOffs , nLen - nOffs );
pTmpFont->SetColor( aPreviousColor );
@@ -1795,8 +1794,6 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
}
}
}
- delete[] pScrArray;
- delete[] pKernArray;
}
}
@@ -1920,8 +1917,8 @@ Size SwFntObj::GetTextSize( SwDrawTextInfo& rInf )
nScrPos = pKernArray[ nLn - 1 ];
else
{
- long* pScrArray = new long[ rInf.GetLen() ];
- rInf.GetOut().GetTextArray( rInf.GetText(), pScrArray,
+ std::unique_ptr<long[]> pScrArray( new long[ rInf.GetLen() ] );
+ rInf.GetOut().GetTextArray( rInf.GetText(), pScrArray.get(),
rInf.GetIdx(), rInf.GetLen() );
nScrPos = pScrArray[ 0 ];
sal_Int32 nCnt = rInf.GetText().getLength();
@@ -1958,7 +1955,6 @@ Size SwFntObj::GetTextSize( SwDrawTextInfo& rInf )
nChPrev = nCh;
pKernArray[i-1] = nScrPos - nScr;
}
- delete[] pScrArray;
}
delete[] pKernArray;
@@ -1970,14 +1966,13 @@ Size SwFntObj::GetTextSize( SwDrawTextInfo& rInf )
rInf.GetOut().SetFont( *m_pPrtFont );
if( bCompress )
{
- long* pKernArray = new long[nLn];
- rInf.GetOut().GetTextArray( rInf.GetText(), pKernArray,
+ std::unique_ptr<long[]> pKernArray( new long[nLn] );
+ rInf.GetOut().GetTextArray( rInf.GetText(), pKernArray.get(),
rInf.GetIdx(), nLn );
- rInf.SetKanaDiff( rInf.GetScriptInfo()->Compress( pKernArray,
+ rInf.SetKanaDiff( rInf.GetScriptInfo()->Compress( pKernArray.get(),
rInf.GetIdx(), nLn, rInf.GetKanaComp(),
(sal_uInt16) m_aFont.GetFontSize().Height() ,lcl_IsFullstopCentered( rInf.GetOut() ) ) );
aTextSize.Width() = pKernArray[ nLn - 1 ];
- delete[] pKernArray;
}
else
{
@@ -2467,10 +2462,10 @@ sal_Int32 SwFont::GetTextBreak( SwDrawTextInfo& rInf, long nTextWidth )
nLn = 1;
else if( nLn > 2 * nTextBreak2 )
nLn = 2 * nTextBreak2;
- long* pKernArray = new long[ nLn ];
- rInf.GetOut().GetTextArray( rInf.GetText(), pKernArray,
+ std::unique_ptr<long[]> pKernArray( new long[ nLn ] );
+ rInf.GetOut().GetTextArray( rInf.GetText(), pKernArray.get(),
rInf.GetIdx(), nLn );
- if( rInf.GetScriptInfo()->Compress( pKernArray, rInf.GetIdx(), nLn,
+ if( rInf.GetScriptInfo()->Compress( pKernArray.get(), rInf.GetIdx(), nLn,
rInf.GetKanaComp(), (sal_uInt16)GetHeight( m_nActual ),
lcl_IsFullstopCentered( rInf.GetOut() ) ) )
{
@@ -2486,7 +2481,6 @@ sal_Int32 SwFont::GetTextBreak( SwDrawTextInfo& rInf, long nTextWidth )
if( rInf.GetHyphPos() )
*rInf.GetHyphPos() += nTextBreak2 - nTmpBreak; // It's not perfect
}
- delete[] pKernArray;
}
nTextBreak2 = nTextBreak2 + rInf.GetIdx();
diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx
index 35f794a6a206..6681928cce63 100644
--- a/sw/source/core/unocore/unodraw.cxx
+++ b/sw/source/core/unocore/unodraw.cxx
@@ -1124,8 +1124,8 @@ void SwXShape::setPropertyValue(const OUString& rPropertyName, const uno::Any& a
}
else
{
- SwUnoInternalPaM* pInternalPam =
- new SwUnoInternalPaM( *(pFormat->GetDoc()) );
+ std::unique_ptr<SwUnoInternalPaM> pInternalPam(
+ new SwUnoInternalPaM( *(pFormat->GetDoc()) ));
uno::Reference< text::XTextRange > xRg;
aValue >>= xRg;
if (::sw::XTextRangeToSwPaM(*pInternalPam, xRg) )
@@ -1170,7 +1170,6 @@ void SwXShape::setPropertyValue(const OUString& rPropertyName, const uno::Any& a
{
throw uno::RuntimeException();
}
- delete pInternalPam;
}
}
else if (pEntry->nWID == FN_TEXT_BOX)
diff --git a/sw/source/filter/html/swhtml.cxx b/sw/source/filter/html/swhtml.cxx
index b990071ed6c1..7ba89d09b621 100644
--- a/sw/source/filter/html/swhtml.cxx
+++ b/sw/source/filter/html/swhtml.cxx
@@ -2633,7 +2633,7 @@ SwViewShell *SwHTMLParser::CheckActionViewShell()
void SwHTMLParser::SetAttr_( bool bChkEnd, bool bBeforeTable,
HTMLAttrs *pPostIts )
{
- SwPaM* pAttrPam = new SwPaM( *m_pPam->GetPoint() );
+ std::unique_ptr<SwPaM> pAttrPam( new SwPaM( *m_pPam->GetPoint() ) );
const SwNodeIndex& rEndIdx = m_pPam->GetPoint()->nNode;
const sal_Int32 nEndCnt = m_pPam->GetPoint()->nContent.GetIndex();
HTMLAttr* pAttr;
@@ -2970,8 +2970,6 @@ void SwHTMLParser::SetAttr_( bool bChkEnd, bool bBeforeTable,
aFields.pop_front();
delete pAttr;
}
-
- delete pAttrPam;
}
void SwHTMLParser::NewAttr( HTMLAttr **ppAttr, const SfxPoolItem& rItem )
diff --git a/sw/source/filter/ww8/wrtw8esh.cxx b/sw/source/filter/ww8/wrtw8esh.cxx
index 9f50c201a7b1..2b8a8b24a277 100644
--- a/sw/source/filter/ww8/wrtw8esh.cxx
+++ b/sw/source/filter/ww8/wrtw8esh.cxx
@@ -275,10 +275,9 @@ void SwBasicEscherEx::WriteHyperlinkWithinFly( SvMemoryStream& rStrm, const SwFo
sal_uInt32 const nLen = tmpStrm.remainingSize();
if(nLen >0)
{
- sal_uInt8* pBuffer = new sal_uInt8[ nLen ];
- tmpStrm.ReadBytes(pBuffer, nLen);
- rStrm.WriteBytes(pBuffer, nLen);
- delete[] pBuffer;
+ std::unique_ptr<sal_uInt8[]> pBuffer( new sal_uInt8[ nLen ] );
+ tmpStrm.ReadBytes(pBuffer.get(), nLen);
+ rStrm.WriteBytes(pBuffer.get(), nLen);
}
}
void SwBasicEscherEx::PreWriteHyperlinkWithinFly(const SwFrameFormat& rFormat,EscherPropertyContainer& rPropOpt)
diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx
index 994a7b111ab7..4710b544d616 100644
--- a/sw/source/filter/ww8/wrtww8.cxx
+++ b/sw/source/filter/ww8/wrtww8.cxx
@@ -3715,12 +3715,10 @@ void WW8Export::RestoreMacroCmds()
pFib->m_lcbCmds = pStream->Tell();
pStream->Seek(0);
- sal_uInt8 *pBuffer = new sal_uInt8[pFib->m_lcbCmds];
- bool bReadOk = checkRead(*pStream, pBuffer, pFib->m_lcbCmds);
+ std::unique_ptr<sal_uInt8[]> pBuffer( new sal_uInt8[pFib->m_lcbCmds] );
+ bool bReadOk = checkRead(*pStream, pBuffer.get(), pFib->m_lcbCmds);
if (bReadOk)
- pTableStrm->WriteBytes(pBuffer, pFib->m_lcbCmds);
- delete[] pBuffer;
-
+ pTableStrm->WriteBytes(pBuffer.get(), pFib->m_lcbCmds);
}
delete pStream;
diff --git a/sw/source/filter/ww8/wrtww8gr.cxx b/sw/source/filter/ww8/wrtww8gr.cxx
index a19451e493ac..959c9a2702d6 100644
--- a/sw/source/filter/ww8/wrtww8gr.cxx
+++ b/sw/source/filter/ww8/wrtww8gr.cxx
@@ -335,7 +335,7 @@ void WW8Export::OutputLinkedOLE( const OUString& rOleId )
xOleDst->Commit();
// Ouput the cPicLocation attribute
- ww::bytes* pBuf = new ww::bytes();
+ std::unique_ptr<ww::bytes> pBuf( new ww::bytes );
SwWW8Writer::InsUInt16( *pBuf, NS_sprm::LN_CPicLocation );
SwWW8Writer::InsUInt32( *pBuf, rOleId.copy( 1 ).toInt32() );
@@ -349,7 +349,6 @@ void WW8Export::OutputLinkedOLE( const OUString& rOleId )
pBuf->push_back( 1 );
m_pChpPlc->AppendFkpEntry( Strm().Tell(), pBuf->size(), pBuf->data() );
- delete pBuf;
}
}
}
diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx
index 4d20e6781628..c1e1cb6c912a 100644
--- a/sw/source/filter/ww8/ww8par2.cxx
+++ b/sw/source/filter/ww8/ww8par2.cxx
@@ -3614,10 +3614,9 @@ void WW8RStyle::ImportSprms(std::size_t nPosFc, short nLen, bool bPap)
if (checkSeek(*pStStrm, nPosFc))
{
- sal_uInt8 *pSprms = new sal_uInt8[nLen];
- nLen = pStStrm->ReadBytes(pSprms, nLen);
- ImportSprms(pSprms, nLen, bPap);
- delete[] pSprms;
+ std::unique_ptr<sal_uInt8[]> pSprms( new sal_uInt8[nLen] );
+ nLen = pStStrm->ReadBytes(pSprms.get(), nLen);
+ ImportSprms(pSprms.get(), nLen, bPap);
}
}
diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx
index 3d221b268f09..0f98f30e84d2 100644
--- a/sw/source/filter/ww8/ww8scan.cxx
+++ b/sw/source/filter/ww8/ww8scan.cxx
@@ -5923,8 +5923,8 @@ void WW8Fib::WriteHeader(SvStream& rStrm)
bool bVer8 = 8 == m_nVersion;
size_t nUnencryptedHdr = bVer8 ? 0x44 : 0x24;
- sal_uInt8 *pDataPtr = new sal_uInt8[ nUnencryptedHdr ];
- sal_uInt8 *pData = pDataPtr;
+ std::unique_ptr<sal_uInt8[]> pDataPtr( new sal_uInt8[ nUnencryptedHdr ] );
+ sal_uInt8 *pData = pDataPtr.get();
memset( pData, 0, nUnencryptedHdr );
const sal_uInt64 nPos = rStrm.Tell();
@@ -5999,8 +5999,7 @@ void WW8Fib::WriteHeader(SvStream& rStrm)
// Marke: "rglw" Beginning of the array of longs
Set_UInt32( pData, m_cbMac );
- rStrm.WriteBytes(pDataPtr, nUnencryptedHdr);
- delete[] pDataPtr;
+ rStrm.WriteBytes(pDataPtr.get(), nUnencryptedHdr);
}
void WW8Fib::Write(SvStream& rStrm)
@@ -6011,8 +6010,8 @@ void WW8Fib::Write(SvStream& rStrm)
size_t nUnencryptedHdr = bVer8 ? 0x44 : 0x24;
- sal_uInt8 *pDataPtr = new sal_uInt8[ m_fcMin - nUnencryptedHdr ];
- sal_uInt8 *pData = pDataPtr;
+ std::unique_ptr<sal_uInt8[]> pDataPtr( new sal_uInt8[ m_fcMin - nUnencryptedHdr ] );
+ sal_uInt8 *pData = pDataPtr.get();
memset( pData, 0, m_fcMin - nUnencryptedHdr );
const sal_uInt64 nPos = rStrm.Tell();
@@ -6243,8 +6242,7 @@ void WW8Fib::Write(SvStream& rStrm)
Set_UInt32( pData, 0);
}
- rStrm.WriteBytes(pDataPtr, m_fcMin - nUnencryptedHdr);
- delete[] pDataPtr;
+ rStrm.WriteBytes(pDataPtr.get(), m_fcMin - nUnencryptedHdr);
}
rtl_TextEncoding WW8Fib::GetFIBCharset(sal_uInt16 chs, sal_uInt16 nLidLocale)
@@ -6815,8 +6813,8 @@ WW8Fonts::WW8Fonts( SvStream& rSt, WW8Fib& rFib )
sal_Int32 nFFn = rFib.m_lcbSttbfffn - 2;
// allocate Font Array
- sal_uInt8* pA = new sal_uInt8[nFFn];
- memset(pA, 0, nFFn);
+ std::unique_ptr<sal_uInt8[]> pA( new sal_uInt8[nFFn] );
+ memset(pA.get(), 0, nFFn);
ww::WordVersion eVersion = rFib.GetFIBVersion();
@@ -6832,9 +6830,9 @@ WW8Fonts::WW8Fonts( SvStream& rSt, WW8Fib& rFib )
rSt.SeekRel( 2 );
// read all font information
- nFFn = rSt.ReadBytes(pA, nFFn);
- sal_uInt8 * const pEnd = pA + nFFn;
- const sal_uInt16 nCalcMax = calcMaxFonts(pA, nFFn);
+ nFFn = rSt.ReadBytes(pA.get(), nFFn);
+ sal_uInt8 * const pEnd = pA.get() + nFFn;
+ const sal_uInt16 nCalcMax = calcMaxFonts(pA.get(), nFFn);
if (eVersion < ww::eWW8)
nMax = nCalcMax;
@@ -6853,7 +6851,7 @@ WW8Fonts::WW8Fonts( SvStream& rSt, WW8Fib& rFib )
if( eVersion <= ww::eWW2 )
{
- sal_uInt8 const * pVer2 = pA;
+ sal_uInt8 const * pVer2 = pA.get();
sal_uInt16 i = 0;
for(; i<nMax; ++i, ++p)
{
@@ -6894,7 +6892,7 @@ WW8Fonts::WW8Fonts( SvStream& rSt, WW8Fib& rFib )
}
else if( eVersion < ww::eWW8 )
{
- sal_uInt8 const * pVer6 = pA;
+ sal_uInt8 const * pVer6 = pA.get();
sal_uInt16 i = 0;
for(; i<nMax; ++i, ++p)
{
@@ -6976,7 +6974,7 @@ WW8Fonts::WW8Fonts( SvStream& rSt, WW8Fib& rFib )
const sal_uInt8 cbMinFFNPayload = 41;
sal_uInt16 nValidFonts = 0;
sal_Int32 nRemainingFFn = nFFn;
- sal_uInt8* pRaw = pA;
+ sal_uInt8* pRaw = pA.get();
for (sal_uInt16 i=0; i < nMax && nRemainingFFn; ++i, ++p)
{
//pRaw[0] is cbFfnM1, the alleged total length of FFN - 1
@@ -7047,7 +7045,6 @@ WW8Fonts::WW8Fonts( SvStream& rSt, WW8Fib& rFib )
nMax = std::min(nMax, nValidFonts);
}
}
- delete[] pA;
}
const WW8_FFN* WW8Fonts::GetFont( sal_uInt16 nNum ) const
@@ -7158,8 +7155,8 @@ WW8Dop::WW8Dop(SvStream& rSt, sal_Int16 nFib, sal_Int32 nPos, sal_uInt32 nSize)
fDontUseHTMLAutoSpacing = true; //default
fAcetateShowAtn = true; //default
const sal_uInt32 nMaxDopSize = 0x268;
- sal_uInt8* pDataPtr = new sal_uInt8[ nMaxDopSize ];
- sal_uInt8* pData = pDataPtr;
+ std::unique_ptr<sal_uInt8[]> pDataPtr( new sal_uInt8[ nMaxDopSize ] );
+ sal_uInt8* pData = pDataPtr.get();
sal_uInt32 nRead = nMaxDopSize < nSize ? nMaxDopSize : nSize;
if (nSize < 2 || !checkSeek(rSt, nPos) || nRead != rSt.ReadBytes(pData, nRead))
@@ -7367,7 +7364,6 @@ WW8Dop::WW8Dop(SvStream& rSt, sal_Int16 nFib, sal_Int32 nPos, sal_uInt32 nSize)
}
}
}
- delete[] pDataPtr;
}
WW8Dop::WW8Dop()
diff --git a/sw/source/ui/chrdlg/chardlg.cxx b/sw/source/ui/chrdlg/chardlg.cxx
index e1e6cefc0a76..5eb7cbce9f60 100644
--- a/sw/source/ui/chrdlg/chardlg.cxx
+++ b/sw/source/ui/chrdlg/chardlg.cxx
@@ -168,7 +168,7 @@ SwCharURLPage::SwCharURLPage(vcl::Window* pParent, const SfxItemSet& rCoreSet)
::FillCharStyleListBox(*m_pVisitedLB, pView->GetDocShell());
::FillCharStyleListBox(*m_pNotVisitedLB, pView->GetDocShell());
- TargetList* pList = new TargetList;
+ std::unique_ptr<TargetList> pList( new TargetList );
const SfxFrame& rFrame = pView->GetViewFrame()->GetFrame();
rFrame.GetTargetList(*pList);
if ( !pList->empty() )
@@ -180,7 +180,6 @@ SwCharURLPage::SwCharURLPage(vcl::Window* pParent, const SfxItemSet& rCoreSet)
m_pTargetFrameLB->InsertEntry( pList->at( i ) );
}
}
- delete pList;
}
SwCharURLPage::~SwCharURLPage()
diff --git a/sw/source/uibase/dialog/SwSpellDialogChildWindow.cxx b/sw/source/uibase/dialog/SwSpellDialogChildWindow.cxx
index 99f26ebd23c2..a2b4f6c8d20a 100644
--- a/sw/source/uibase/dialog/SwSpellDialogChildWindow.cxx
+++ b/sw/source/uibase/dialog/SwSpellDialogChildWindow.cxx
@@ -772,9 +772,9 @@ bool SwSpellDialogChildWindow::FindNextDrawTextError_Impl(SwWrtShell& rSh)
aTmpOutliner.SetPaperSize( pTextObj->GetLogicRect().GetSize() );
aTmpOutliner.SetSpeller( xSpell );
- OutlinerView* pOutlView = new OutlinerView( &aTmpOutliner, &(rView.GetEditWin()) );
+ std::unique_ptr<OutlinerView> pOutlView( new OutlinerView( &aTmpOutliner, &(rView.GetEditWin()) ) );
pOutlView->GetOutliner()->SetRefDevice( rSh.getIDocumentDeviceAccess().getPrinter( false ) );
- aTmpOutliner.InsertView( pOutlView );
+ aTmpOutliner.InsertView( pOutlView.get() );
Point aPt;
Size aSize(1,1);
Rectangle aRect( aPt, aSize );
@@ -782,8 +782,7 @@ bool SwSpellDialogChildWindow::FindNextDrawTextError_Impl(SwWrtShell& rSh)
aTmpOutliner.SetText( *pParaObj );
aTmpOutliner.ClearModifyFlag();
bHasSpellError = EE_SPELL_OK != aTmpOutliner.HasSpellErrors();
- aTmpOutliner.RemoveView( pOutlView );
- delete pOutlView;
+ aTmpOutliner.RemoveView( pOutlView.get() );
}
if(bHasSpellError)
{