summaryrefslogtreecommitdiff
path: root/sw/source
diff options
context:
space:
mode:
Diffstat (limited to 'sw/source')
-rw-r--r--sw/source/core/crsr/swcrsr.cxx8
-rw-r--r--sw/source/core/doc/DocumentContentOperationsManager.cxx6
-rw-r--r--sw/source/core/docnode/node.cxx11
-rw-r--r--sw/source/core/docnode/swbaslnk.cxx7
-rw-r--r--sw/source/core/frmedt/tblsel.cxx9
-rw-r--r--sw/source/core/table/swnewtable.cxx3
-rw-r--r--sw/source/core/text/itradj.cxx17
-rw-r--r--sw/source/core/unocore/unocrsrhelper.cxx41
-rw-r--r--sw/source/core/unocore/unostyle.cxx27
-rw-r--r--sw/source/filter/html/htmlforw.cxx8
10 files changed, 60 insertions, 77 deletions
diff --git a/sw/source/core/crsr/swcrsr.cxx b/sw/source/core/crsr/swcrsr.cxx
index 5fce21744cc1..578af2c3ecc5 100644
--- a/sw/source/core/crsr/swcrsr.cxx
+++ b/sw/source/core/crsr/swcrsr.cxx
@@ -51,6 +51,7 @@
#include <statstr.hrc>
#include <redline.hxx>
#include <txatbase.hxx>
+#include <memory>
using namespace ::com::sun::star::i18n;
@@ -748,14 +749,14 @@ static sal_uLong lcl_FindSelection( SwFindParas& rParas, SwCursor* pCurCrsr,
// only create progress bar for ShellCrsr
bool bIsUnoCrsr = dynamic_cast<SwUnoCrsr*>(pCurCrsr) != nullptr;
- _PercentHdl* pPHdl = nullptr;
+ std::unique_ptr<_PercentHdl> pPHdl;
sal_uInt16 nCrsrCnt = 0;
if( FND_IN_SEL & eFndRngs )
{
while( pCurCrsr != ( pTmpCrsr = pTmpCrsr->GetNext() ))
++nCrsrCnt;
if( nCrsrCnt && !bIsUnoCrsr )
- pPHdl = new _PercentHdl( 0, nCrsrCnt, pDoc->GetDocShell() );
+ pPHdl.reset(new _PercentHdl( 0, nCrsrCnt, pDoc->GetDocShell() ));
}
else
pSaveCrsr = static_cast<SwPaM*>(pSaveCrsr->GetPrev());
@@ -773,7 +774,7 @@ static sal_uLong lcl_FindSelection( SwFindParas& rParas, SwCursor* pCurCrsr,
aRegion.Exchange();
if( !nCrsrCnt && !pPHdl && !bIsUnoCrsr )
- pPHdl = new _PercentHdl( aRegion );
+ pPHdl.reset(new _PercentHdl( aRegion ));
// as long as found and not at same position
while( *pSttPos <= *pEndPos &&
@@ -854,7 +855,6 @@ static sal_uLong lcl_FindSelection( SwFindParas& rParas, SwCursor* pCurCrsr,
if( nFound && !pFndRing ) // if no ring should be created
pFndRing = pCurCrsr->Create();
- delete pPHdl;
pDoc->GetIDocumentUndoRedo().DoUndo(bDoesUndo);
return nFound;
}
diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx
index ec341ecda61c..f7897d7539aa 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -73,6 +73,7 @@
#include <svx/svdouno.hxx>
#include <editeng/formatbreakitem.hxx>
#include <com/sun/star/i18n/Boundary.hpp>
+#include <memory>
using namespace ::com::sun::star::i18n;
@@ -294,7 +295,7 @@ namespace
{
SwDoc* pDestDoc = rCpyPam.GetDoc();
SwPosition* pCpyStt = rCpyPam.Start(), *pCpyEnd = rCpyPam.End();
- SwPaM* pDelPam = nullptr;
+ std::unique_ptr<SwPaM> pDelPam;
const SwPosition *pStt = rPam.Start(), *pEnd = rPam.End();
// We have to count the "non-copied" nodes
sal_uLong nDelCount = 0;
@@ -325,7 +326,7 @@ namespace
default:
{
- pDelPam = new SwPaM( *pCpyStt, pDelPam );
+ pDelPam.reset(new SwPaM( *pCpyStt, pDelPam.get() ));
if( *pStt < *pRStt )
{
lcl_NonCopyCount( rPam, aCorrIdx, pRStt->nNode.GetIndex(), nDelCount );
@@ -360,7 +361,6 @@ namespace
break;
delete pDelPam->GetNext();
} while( true );
- delete pDelPam;
pDestDoc->getIDocumentRedlineAccess().SetRedlineMode_intern( eOld );
}
diff --git a/sw/source/core/docnode/node.cxx b/sw/source/core/docnode/node.cxx
index 6b2eac765d70..6b9ef815b1a2 100644
--- a/sw/source/core/docnode/node.cxx
+++ b/sw/source/core/docnode/node.cxx
@@ -66,6 +66,7 @@
#include <IDocumentLayoutAccess.hxx>
#include <calbck.hxx>
#include "ndole.hxx"
+#include <memory>
using namespace ::com::sun::star::i18n;
@@ -149,10 +150,10 @@ bool Put( std::shared_ptr<const SfxItemSet>& rpAttrSet, const SwContentNode& rNo
SwAttrSet aNewSet( static_cast<const SwAttrSet&>(*rpAttrSet) );
// #i76273# Robust
- SfxItemSet* pStyleNames = nullptr;
+ std::unique_ptr<SfxItemSet> pStyleNames;
if ( SfxItemState::SET == rSet.GetItemState( RES_FRMATR_STYLE_NAME, false ) )
{
- pStyleNames = new SfxItemSet( *aNewSet.GetPool(), RES_FRMATR_STYLE_NAME, RES_FRMATR_CONDITIONAL_STYLE_NAME );
+ pStyleNames.reset(new SfxItemSet( *aNewSet.GetPool(), RES_FRMATR_STYLE_NAME, RES_FRMATR_CONDITIONAL_STYLE_NAME ));
pStyleNames->Put( aNewSet );
}
@@ -162,7 +163,6 @@ bool Put( std::shared_ptr<const SfxItemSet>& rpAttrSet, const SwContentNode& rNo
if ( pStyleNames )
{
aNewSet.Put( *pStyleNames );
- delete pStyleNames;
}
if ( bRet )
@@ -197,10 +197,10 @@ bool Put_BC( std::shared_ptr<const SfxItemSet>& rpAttrSet,
SwAttrSet aNewSet( static_cast<const SwAttrSet&>(*rpAttrSet) );
// #i76273# Robust
- SfxItemSet* pStyleNames = nullptr;
+ std::unique_ptr<SfxItemSet> pStyleNames;
if ( SfxItemState::SET == rSet.GetItemState( RES_FRMATR_STYLE_NAME, false ) )
{
- pStyleNames = new SfxItemSet( *aNewSet.GetPool(), RES_FRMATR_STYLE_NAME, RES_FRMATR_CONDITIONAL_STYLE_NAME );
+ pStyleNames.reset(new SfxItemSet( *aNewSet.GetPool(), RES_FRMATR_STYLE_NAME, RES_FRMATR_CONDITIONAL_STYLE_NAME ));
pStyleNames->Put( aNewSet );
}
@@ -215,7 +215,6 @@ bool Put_BC( std::shared_ptr<const SfxItemSet>& rpAttrSet,
if ( pStyleNames )
{
aNewSet.Put( *pStyleNames );
- delete pStyleNames;
}
if ( bRet )
diff --git a/sw/source/core/docnode/swbaslnk.cxx b/sw/source/core/docnode/swbaslnk.cxx
index 9831eec9d2be..d96b397df9a6 100644
--- a/sw/source/core/docnode/swbaslnk.cxx
+++ b/sw/source/core/docnode/swbaslnk.cxx
@@ -51,6 +51,7 @@
#include <cntfrm.hxx>
#include <htmltbl.hxx>
#include <calbck.hxx>
+#include <memory>
using namespace com::sun::star;
@@ -292,9 +293,9 @@ static bool SetGrfFlySize( const Size& rGrfSz, SwGrfNode* pGrfNd, const Size& rO
{
bool bRet = false;
SwViewShell *pSh = pGrfNd->GetDoc()->getIDocumentLayoutAccess().GetCurrentViewShell();
- CurrShell *pCurr = nullptr;
+ std::unique_ptr<CurrShell> pCurr;
if ( pGrfNd->GetDoc()->GetEditShell() )
- pCurr = new CurrShell( pSh );
+ pCurr.reset(new CurrShell( pSh ));
Size aSz = rOrigGrfSize;
if ( !(aSz.Width() && aSz.Height()) &&
@@ -366,8 +367,6 @@ static bool SetGrfFlySize( const Size& rGrfSz, SwGrfNode* pGrfNd, const Size& rO
pGrfNd->SetTwipSize( rGrfSz );
}
- delete pCurr;
-
return bRet;
}
diff --git a/sw/source/core/frmedt/tblsel.cxx b/sw/source/core/frmedt/tblsel.cxx
index ae6065c2f94d..098be6bf7132 100644
--- a/sw/source/core/frmedt/tblsel.cxx
+++ b/sw/source/core/frmedt/tblsel.cxx
@@ -48,6 +48,7 @@
#include <frmtool.hxx>
#include <calbck.hxx>
#include <deque>
+#include <memory>
// see also swtable.cxx
#define COLFUZZY 20L
@@ -2036,14 +2037,13 @@ static void lcl_InsertRow( SwTableLine &rLine, SwLayoutFrm *pUpper, SwFrm *pSibl
static void _FndBoxCopyCol( SwTableBox* pBox, _FndPara* pFndPara )
{
- _FndBox* pFndBox = new _FndBox( pBox, pFndPara->pFndLine );
+ std::unique_ptr<_FndBox> pFndBox(new _FndBox( pBox, pFndPara->pFndLine ));
if( pBox->GetTabLines().size() )
{
- _FndPara aPara( *pFndPara, pFndBox );
+ _FndPara aPara( *pFndPara, pFndBox.get() );
ForEach_FndLineCopyCol( pFndBox->GetBox()->GetTabLines(), &aPara );
if( pFndBox->GetLines().empty() )
{
- delete pFndBox;
return;
}
}
@@ -2051,11 +2051,10 @@ static void _FndBoxCopyCol( SwTableBox* pBox, _FndPara* pFndPara )
{
if( pFndPara->rBoxes.find( pBox ) == pFndPara->rBoxes.end())
{
- delete pFndBox;
return;
}
}
- pFndPara->pFndLine->GetBoxes().push_back(std::unique_ptr<_FndBox>(pFndBox));
+ pFndPara->pFndLine->GetBoxes().push_back( std::move(pFndBox) );
}
static void _FndLineCopyCol( SwTableLine* pLine, _FndPara* pFndPara )
diff --git a/sw/source/core/table/swnewtable.cxx b/sw/source/core/table/swnewtable.cxx
index 1c4f3961d2d7..150fbc0acbdb 100644
--- a/sw/source/core/table/swnewtable.cxx
+++ b/sw/source/core/table/swnewtable.cxx
@@ -1328,7 +1328,7 @@ static sal_uInt16 lcl_CalculateSplitLineHeights( SwSplitLines &rCurr, SwSplitLin
}
SwTwips nHeight = 0;
- SwTwips* pLines = new SwTwips[ nLast + 1 - nFirst ];
+ std::unique_ptr<SwTwips[]> pLines(new SwTwips[ nLast + 1 - nFirst ]);
for( sal_uInt16 i = nFirst; i <= nLast; ++i )
{
bool bLayoutAvailable = false;
@@ -1349,7 +1349,6 @@ static sal_uInt16 lcl_CalculateSplitLineHeights( SwSplitLines &rCurr, SwSplitLin
}
++pSplit;
}
- delete[] pLines;
return nFirst;
}
diff --git a/sw/source/core/text/itradj.cxx b/sw/source/core/text/itradj.cxx
index d4f18ed048f3..2d9cc7a37e71 100644
--- a/sw/source/core/text/itradj.cxx
+++ b/sw/source/core/text/itradj.cxx
@@ -30,6 +30,7 @@
#include "pordrop.hxx"
#include "pormulti.hxx"
#include <portab.hxx>
+#include <memory>
#define MIN_TAB_WIDTH 60
@@ -128,9 +129,9 @@ static bool lcl_CheckKashidaPositions( SwScriptInfo& rSI, SwTextSizeInfo& rInf,
// kashida positions found in SwScriptInfo are not necessarily valid in every font
// if two characters are replaced by a ligature glyph, there will be no place for a kashida
- sal_Int32* pKashidaPos = new sal_Int32[ rKashidas ];
- sal_Int32* pKashidaPosDropped = new sal_Int32[ rKashidas ];
- rSI.GetKashidaPositions ( nIdx, rItr.GetLength(), pKashidaPos );
+ std::unique_ptr<sal_Int32[]> pKashidaPos( new sal_Int32[ rKashidas ] );
+ std::unique_ptr<sal_Int32[]> pKashidaPosDropped( new sal_Int32[ rKashidas ] );
+ rSI.GetKashidaPositions ( nIdx, rItr.GetLength(), pKashidaPos.get() );
sal_Int32 nKashidaIdx = 0;
while ( rKashidas && nIdx < nEnd )
{
@@ -151,8 +152,6 @@ static bool lcl_CheckKashidaPositions( SwScriptInfo& rSI, SwTextSizeInfo& rInf,
// Kashida glyph looks suspicious, skip Kashida justification
if ( rInf.GetOut()->GetMinKashida() <= 0 )
{
- delete[] pKashidaPos;
- delete[] pKashidaPosDropped;
return false;
}
@@ -167,12 +166,12 @@ static bool lcl_CheckKashidaPositions( SwScriptInfo& rSI, SwTextSizeInfo& rInf,
ComplexTextLayoutMode nOldLayout = rInf.GetOut()->GetLayoutMode();
rInf.GetOut()->SetLayoutMode ( nOldLayout | TEXT_LAYOUT_BIDI_RTL );
nKashidasDropped = rInf.GetOut()->ValidateKashidas ( rInf.GetText(), nIdx, nNext - nIdx,
- nKashidasInAttr, pKashidaPos + nKashidaIdx,
- pKashidaPosDropped );
+ nKashidasInAttr, pKashidaPos.get() + nKashidaIdx,
+ pKashidaPosDropped.get() );
rInf.GetOut()->SetLayoutMode ( nOldLayout );
if ( nKashidasDropped )
{
- rSI.MarkKashidasInvalid(nKashidasDropped, pKashidaPosDropped);
+ rSI.MarkKashidasInvalid(nKashidasDropped, pKashidaPosDropped.get());
rKashidas -= nKashidasDropped;
nGluePortion -= nKashidasDropped;
}
@@ -181,8 +180,6 @@ static bool lcl_CheckKashidaPositions( SwScriptInfo& rSI, SwTextSizeInfo& rInf,
}
nIdx = nNext;
}
- delete[] pKashidaPos;
- delete[] pKashidaPosDropped;
// return false if all kashidas have been eliminated
return (rKashidas > 0);
diff --git a/sw/source/core/unocore/unocrsrhelper.cxx b/sw/source/core/unocore/unocrsrhelper.cxx
index 17c67ffa5954..8763a8304946 100644
--- a/sw/source/core/unocore/unocrsrhelper.cxx
+++ b/sw/source/core/unocore/unocrsrhelper.cxx
@@ -21,6 +21,7 @@
#include <map>
#include <algorithm>
+#include <memory>
#include <com/sun/star/beans/PropertyState.hpp>
#include <com/sun/star/embed/ElementModes.hpp>
@@ -955,7 +956,7 @@ void InsertFile(SwUnoCrsr* pUnoCrsr, const OUString& rURL,
throw (lang::IllegalArgumentException, io::IOException,
uno::RuntimeException, std::exception)
{
- SfxMedium* pMed = nullptr;
+ std::unique_ptr<SfxMedium> pMed;
SwDoc* pDoc = pUnoCrsr->GetDoc();
SwDocShell* pDocSh = pDoc->GetDocShell();
utl::MediaDescriptor aMediaDescriptor( rOptions );
@@ -1003,43 +1004,39 @@ void InsertFile(SwUnoCrsr* pUnoCrsr, const OUString& rURL,
{
if( xInputStream.is() && !xReadStorage.is())
{
- pMed = new SfxMedium;
+ pMed.reset(new SfxMedium);
pMed->setStreamToLoadFrom(xInputStream, true );
}
else
- pMed = xReadStorage.is() ?
+ pMed.reset(xReadStorage.is() ?
new SfxMedium(xReadStorage, sBaseURL, nullptr ) :
- new SfxMedium(sFileName, StreamMode::READ, nullptr, nullptr );
+ new SfxMedium(sFileName, StreamMode::READ, nullptr, nullptr ));
if( !sBaseURL.isEmpty() )
pMed->GetItemSet()->Put( SfxStringItem( SID_DOC_BASEURL, sBaseURL ) );
SfxFilterMatcher aMatcher( rFact.GetFilterContainer()->GetName() );
ErrCode nErr = aMatcher.GuessFilter(*pMed, &pFilter, SfxFilterFlags::NONE);
if ( nErr || !pFilter)
- DELETEZ(pMed);
- else
- pMed->SetFilter( pFilter );
+ return;
+ pMed->SetFilter( pFilter );
}
else
{
- if(!pMed)
+ if( xInputStream.is() && !xReadStorage.is())
+ {
+ pMed.reset(new SfxMedium);
+ pMed->setStreamToLoadFrom(xInputStream, true );
+ pMed->SetFilter( pFilter );
+ }
+ else
{
- if( xInputStream.is() && !xReadStorage.is())
+ if( xReadStorage.is() )
{
- pMed = new SfxMedium;
- pMed->setStreamToLoadFrom(xInputStream, true );
+ pMed.reset(new SfxMedium(xReadStorage, sBaseURL, nullptr ));
pMed->SetFilter( pFilter );
}
else
- {
- if( xReadStorage.is() )
- {
- pMed = new SfxMedium(xReadStorage, sBaseURL, nullptr );
- pMed->SetFilter( pFilter );
- }
- else
- pMed = new SfxMedium(sFileName, StreamMode::READ, pFilter, nullptr);
- }
+ pMed.reset(new SfxMedium(sFileName, StreamMode::READ, pFilter, nullptr));
}
if(!sFilterOptions.isEmpty())
pMed->GetItemSet()->Put( SfxStringItem( SID_FILE_FILTEROPTIONS, sFilterOptions ) );
@@ -1047,9 +1044,6 @@ void InsertFile(SwUnoCrsr* pUnoCrsr, const OUString& rURL,
pMed->GetItemSet()->Put( SfxStringItem( SID_DOC_BASEURL, sBaseURL ) );
}
- if( !pMed )
- return;
-
// this sourcecode is not responsible for the lifetime of the shell, SfxObjectShellLock should not be used
SfxObjectShellRef aRef( pDocSh );
@@ -1091,7 +1085,6 @@ void InsertFile(SwUnoCrsr* pUnoCrsr, const OUString& rURL,
}
}
- delete pMed;
}
// insert text and scan for CR characters in order to insert
diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx
index 24134bf53801..20de3d335ecd 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -1944,14 +1944,14 @@ static void lcl_SetStyleProperty(const SfxItemPropertySimpleEntry& rEntry,
throw lang::IllegalArgumentException();
SfxItemSet& rStyleSet = rBase.GetItemSet();
- SwFormatPageDesc* pNewDesc = nullptr;
+ std::unique_ptr<SwFormatPageDesc> pNewDesc;
const SfxPoolItem* pItem;
if(SfxItemState::SET == rStyleSet.GetItemState( RES_PAGEDESC, true, &pItem ) )
{
- pNewDesc = new SwFormatPageDesc(*static_cast<const SwFormatPageDesc*>(pItem));
+ pNewDesc.reset( new SwFormatPageDesc(*static_cast<const SwFormatPageDesc*>(pItem)) );
}
- if(!pNewDesc)
- pNewDesc = new SwFormatPageDesc();
+ else
+ pNewDesc.reset( new SwFormatPageDesc );
OUString uDescName;
aValue >>= uDescName;
OUString sDescName;
@@ -1981,7 +1981,6 @@ static void lcl_SetStyleProperty(const SfxItemPropertySimpleEntry& rEntry,
rStyleSet.Put(*pNewDesc);
}
- delete pNewDesc;
bDone = true;
break;
}
@@ -2126,12 +2125,12 @@ static void lcl_SetStyleProperty(const SfxItemPropertySimpleEntry& rEntry,
if(aValue >>= sTmp)
{
SfxItemSet& rStyleSet = rBase.GetItemSet();
- SwFormatRuby* pRuby = nullptr;
+ std::unique_ptr<SwFormatRuby> pRuby;
const SfxPoolItem* pItem;
if(SfxItemState::SET == rStyleSet.GetItemState( RES_TXTATR_CJK_RUBY, true, &pItem ) )
- pRuby = new SwFormatRuby(*static_cast<const SwFormatRuby*>(pItem));
- if(!pRuby)
- pRuby = new SwFormatRuby(OUString());
+ pRuby.reset(new SwFormatRuby(*static_cast<const SwFormatRuby*>(pItem)));
+ else
+ pRuby.reset(new SwFormatRuby(OUString()));
OUString sStyle;
SwStyleNameMapper::FillUIName(sTmp, sStyle, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, true );
pRuby->SetCharFormatName( sTmp );
@@ -2142,7 +2141,6 @@ static void lcl_SetStyleProperty(const SfxItemPropertySimpleEntry& rEntry,
pRuby->SetCharFormatId(nId);
}
rStyleSet.Put(*pRuby);
- delete pRuby;
}
else
throw lang::IllegalArgumentException();
@@ -2157,12 +2155,12 @@ static void lcl_SetStyleProperty(const SfxItemPropertySimpleEntry& rEntry,
{
SfxItemSet& rStyleSet = rBase.GetItemSet();
- SwFormatDrop* pDrop = nullptr;
+ std::unique_ptr<SwFormatDrop> pDrop;
const SfxPoolItem* pItem;
if(SfxItemState::SET == rStyleSet.GetItemState( RES_PARATR_DROP, true, &pItem ) )
- pDrop = new SwFormatDrop(*static_cast<const SwFormatDrop*>(pItem));
- if(!pDrop)
- pDrop = new SwFormatDrop();
+ pDrop.reset(new SwFormatDrop(*static_cast<const SwFormatDrop*>(pItem)));
+ else
+ pDrop.reset( new SwFormatDrop );
OUString uStyle;
aValue >>= uStyle;
OUString sStyle;
@@ -2174,7 +2172,6 @@ static void lcl_SetStyleProperty(const SfxItemPropertySimpleEntry& rEntry,
else
throw lang::IllegalArgumentException();
rStyleSet.Put(*pDrop);
- delete pDrop;
}
else
throw lang::IllegalArgumentException();
diff --git a/sw/source/filter/html/htmlforw.cxx b/sw/source/filter/html/htmlforw.cxx
index 37a8a73ee162..4388f16d093f 100644
--- a/sw/source/filter/html/htmlforw.cxx
+++ b/sw/source/filter/html/htmlforw.cxx
@@ -63,6 +63,7 @@
#include "htmlform.hxx"
#include "frmfmt.hxx"
#include <rtl/strbuf.hxx>
+#include <memory>
using namespace ::com::sun::star;
@@ -1292,15 +1293,14 @@ static void AddControl( HTMLControls& rControls,
if( xForm.is() )
{
uno::Reference< container::XIndexContainer > xFormComps( xForm, uno::UNO_QUERY );
- HTMLControl *pHCntrl = new HTMLControl( xFormComps, nNodeIdx );
- HTMLControls::const_iterator it = rControls.find( pHCntrl );
+ std::unique_ptr<HTMLControl> pHCntrl(new HTMLControl( xFormComps, nNodeIdx ));
+ HTMLControls::const_iterator it = rControls.find( pHCntrl.get() );
if( it == rControls.end() )
- rControls.insert( pHCntrl );
+ rControls.insert( pHCntrl.release() );
else
{
if( (*it)->xFormComps==xFormComps )
(*it)->nCount++;
- delete pHCntrl;
}
}
}