summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-02-28 15:50:29 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-03-05 12:44:32 +0100
commit4245454d0c3d6df2d0e0a75aed6f22f0a26ce3e2 (patch)
treec7e708889fed58868c9f31fa4fc4bbb6d44171e3
parent05a195ffca41bc3883627b9503ade8cdd0b6d909 (diff)
loplugin:useuniqueptr in SdrPowerPointImport
Change-Id: I9a8d1669cbd94f73dc75e4b7339910f8201e06aa Reviewed-on: https://gerrit.libreoffice.org/50695 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--filter/source/msfilter/svdfppt.cxx32
-rw-r--r--include/filter/msfilter/svdfppt.hxx8
-rw-r--r--sd/source/filter/ppt/pptin.cxx49
3 files changed, 41 insertions, 48 deletions
diff --git a/filter/source/msfilter/svdfppt.cxx b/filter/source/msfilter/svdfppt.cxx
index 8de6562a9c71..c9997744421b 100644
--- a/filter/source/msfilter/svdfppt.cxx
+++ b/filter/source/msfilter/svdfppt.cxx
@@ -1498,9 +1498,9 @@ SdrPowerPointImport::SdrPowerPointImport( PowerPointImportParam& rParam, const O
// TODO:: PPT_PST_TxPFStyleAtom
// read SlidePersists
- m_pMasterPages = new PptSlidePersistList;
- m_pSlidePages = new PptSlidePersistList;
- m_pNotePages = new PptSlidePersistList;
+ m_pMasterPages.reset( new PptSlidePersistList );
+ m_pSlidePages.reset( new PptSlidePersistList );
+ m_pNotePages.reset( new PptSlidePersistList );
// now always creating the handout page, it will be the first in our masterpage list
std::unique_ptr<PptSlidePersistEntry> pE(new PptSlidePersistEntry);
@@ -1655,13 +1655,9 @@ SdrPowerPointImport::SdrPowerPointImport( PowerPointImportParam& rParam, const O
SdrPowerPointImport::~SdrPowerPointImport()
{
- for (SdHyperlinkEntry* i : aHyperList) {
- delete i;
- }
- aHyperList.clear();
- delete m_pMasterPages;
- delete m_pSlidePages;
- delete m_pNotePages;
+ m_pMasterPages.reset();
+ m_pSlidePages.reset();
+ m_pNotePages.reset();
}
bool PPTConvertOCXControls::ReadOCXStream( tools::SvRef<SotStorage>& rSrc,
@@ -2196,11 +2192,11 @@ bool SdrPowerPointImport::ReadFontCollection()
PptSlidePersistList* SdrPowerPointImport::GetPageList(PptPageKind ePageKind) const
{
if ( ePageKind == PPT_MASTERPAGE )
- return m_pMasterPages;
+ return m_pMasterPages.get();
if ( ePageKind == PPT_SLIDEPAGE )
- return m_pSlidePages;
+ return m_pSlidePages.get();
if ( ePageKind == PPT_NOTEPAGE )
- return m_pNotePages;
+ return m_pNotePages.get();
return nullptr;
}
@@ -6874,9 +6870,9 @@ PPTTextObj::PPTTextObj( SvStream& rIn, SdrPowerPointImport& rSdrPowerPointImport
{
PptInteractiveInfoAtom aInteractiveInfoAtom;
ReadPptInteractiveInfoAtom( rIn, aInteractiveInfoAtom );
- for (SdHyperlinkEntry* pHyperlink : rSdrPowerPointImport.aHyperList)
+ for (SdHyperlinkEntry& rHyperlink : rSdrPowerPointImport.aHyperList)
{
- if ( pHyperlink->nIndex == aInteractiveInfoAtom.nExHyperlinkId )
+ if ( rHyperlink.nIndex == aInteractiveInfoAtom.nExHyperlinkId )
{
if (!aTextHd.SeekToEndOfRecord(rIn))
{
@@ -6898,11 +6894,11 @@ PPTTextObj::PPTTextObj( SvStream& rIn, SdrPowerPointImport& rSdrPowerPointImport
xEntry.reset(new PPTFieldEntry);
xEntry->nPos = static_cast<sal_uInt16>(nStartPos);
xEntry->nTextRangeEnd = static_cast<sal_uInt16>(nEndPos);
- OUString aTarget( pHyperlink->aTarget );
- if ( !pHyperlink->aConvSubString.isEmpty() )
+ OUString aTarget( rHyperlink.aTarget );
+ if ( !rHyperlink.aConvSubString.isEmpty() )
{
aTarget += "#";
- aTarget += pHyperlink->aConvSubString;
+ aTarget += rHyperlink.aConvSubString;
}
xEntry->xField1.reset(new SvxFieldItem( SvxURLField( aTarget, OUString(), SvxURLFormat::Repr ), EE_FEATURE_FIELD ));
}
diff --git a/include/filter/msfilter/svdfppt.hxx b/include/filter/msfilter/svdfppt.hxx
index 6dda302f4691..fe6a294cd9b1 100644
--- a/include/filter/msfilter/svdfppt.hxx
+++ b/include/filter/msfilter/svdfppt.hxx
@@ -558,7 +558,7 @@ protected:
bool bOk;
PptUserEditAtom aUserEditAtom;
PptColorSchemeAtom aPageColors;
- ::std::vector< SdHyperlinkEntry* > aHyperList;
+ ::std::vector< SdHyperlinkEntry > aHyperList;
std::unique_ptr<sal_uInt32[]>
pPersistPtr;
sal_uInt32 nPersistPtrCnt;
@@ -566,9 +566,9 @@ protected:
const PPTStyleSheet* pPPTStyleSheet; // this is the current stylesheet;
const PPTStyleSheet* pDefaultSheet; // this is a sheet we are using if no masterpage can be found, but that should
// never happen just preventing a crash
- PptSlidePersistList* m_pMasterPages;
- PptSlidePersistList* m_pSlidePages;
- PptSlidePersistList* m_pNotePages;
+ std::unique_ptr<PptSlidePersistList> m_pMasterPages;
+ std::unique_ptr<PptSlidePersistList> m_pSlidePages;
+ std::unique_ptr<PptSlidePersistList> m_pNotePages;
sal_uInt16 nAktPageNum;
sal_uLong nDocStreamPos;
sal_uInt16 nPageColorsNum;
diff --git a/sd/source/filter/ppt/pptin.cxx b/sd/source/filter/ppt/pptin.cxx
index 3e8c16943e92..249de3d1d09e 100644
--- a/sd/source/filter/ppt/pptin.cxx
+++ b/sd/source/filter/ppt/pptin.cxx
@@ -393,41 +393,40 @@ bool ImplSdPPTImport::Import()
nPropCount /= 6; // 6 properties per hyperlink
- SdHyperlinkEntry* pHyperlink = nullptr;
+ SdHyperlinkEntry aHyperlink;
for ( i = 0; i < nPropCount; i++ )
{
- pHyperlink = new SdHyperlinkEntry;
- pHyperlink->nIndex = 0;
+ aHyperlink.nIndex = 0;
aPropItem.ReadUInt32( nType );
if ( nType != VT_I4 )
break;
- aPropItem.ReadInt32( pHyperlink->nPrivate1 )
+ aPropItem.ReadInt32( aHyperlink.nPrivate1 )
.ReadUInt32( nType );
if ( nType != VT_I4 )
break;
- aPropItem.ReadInt32( pHyperlink->nPrivate2 )
+ aPropItem.ReadInt32( aHyperlink.nPrivate2 )
.ReadUInt32( nType );
if ( nType != VT_I4 )
break;
- aPropItem.ReadInt32( pHyperlink->nPrivate3 )
+ aPropItem.ReadInt32( aHyperlink.nPrivate3 )
.ReadUInt32( nType );
if ( nType != VT_I4 )
break;
- aPropItem.ReadInt32( pHyperlink->nInfo );
- if ( !aPropItem.Read( pHyperlink->aTarget ) )
+ aPropItem.ReadInt32( aHyperlink.nInfo );
+ if ( !aPropItem.Read( aHyperlink.aTarget ) )
break;
// Convert '\\' notation to 'smb://'
- INetURLObject aUrl( pHyperlink->aTarget, INetProtocol::File );
- pHyperlink->aTarget = aUrl.GetMainURL( INetURLObject::DecodeMechanism::NONE );
+ INetURLObject aUrl( aHyperlink.aTarget, INetProtocol::File );
+ aHyperlink.aTarget = aUrl.GetMainURL( INetURLObject::DecodeMechanism::NONE );
- if ( !aPropItem.Read( pHyperlink->aSubAdress ) )
+ if ( !aPropItem.Read( aHyperlink.aSubAdress ) )
break;
- if ( !pHyperlink->aSubAdress.isEmpty() ) // get the converted subaddress
+ if ( !aHyperlink.aSubAdress.isEmpty() ) // get the converted subaddress
{
sal_uInt32 nPageNumber = 0;
- OUString aString( pHyperlink->aSubAdress );
+ OUString aString( aHyperlink.aSubAdress );
OString aStringAry[ 3 ];
size_t nTokenCount = 0;
sal_Int32 nPos = 0;
@@ -497,23 +496,21 @@ bool ImplSdPPTImport::Import()
if ( bDocInternalSubAddress )
{
if ( nPageNumber < maSlideNameList.size() )
- pHyperlink->aConvSubString = maSlideNameList[ nPageNumber ];
- if ( pHyperlink->aConvSubString.isEmpty() )
+ aHyperlink.aConvSubString = maSlideNameList[ nPageNumber ];
+ if ( aHyperlink.aConvSubString.isEmpty() )
{
- pHyperlink->aConvSubString = SdResId( STR_PAGE ) + " " + ( mpDoc->CreatePageNumValue( static_cast<sal_uInt16>(nPageNumber) + 1 ) );
+ aHyperlink.aConvSubString = SdResId( STR_PAGE ) + " " + ( mpDoc->CreatePageNumValue( static_cast<sal_uInt16>(nPageNumber) + 1 ) );
}
} else {
// if sub address is given but not internal, use it as it is
- if ( pHyperlink->aConvSubString.isEmpty() )
+ if ( aHyperlink.aConvSubString.isEmpty() )
{
- pHyperlink->aConvSubString = aString;
+ aHyperlink.aConvSubString = aString;
}
}
}
- aHyperList.push_back( pHyperlink );
+ aHyperList.push_back( aHyperlink );
}
- if ( i != nPropCount )
- delete pHyperlink;
}
}
}
@@ -532,7 +529,7 @@ bool ImplSdPPTImport::Import()
if ( SeekToRec( rStCtrl, PPT_PST_ExObjList, maDocHd.GetRecEndFilePos(), &aHyperHd ) )
{
sal_uInt32 nExObjHyperListLen = aHyperHd.GetRecEndFilePos();
- for (SdHyperlinkEntry* pPtr : aHyperList)
+ for (SdHyperlinkEntry & entry : aHyperList)
{
DffRecordHeader aHyperE;
if ( !SeekToRec( rStCtrl, PPT_PST_ExHyperlink, nExObjHyperListLen, &aHyperE ) )
@@ -540,7 +537,7 @@ bool ImplSdPPTImport::Import()
if ( !SeekToRec( rStCtrl, PPT_PST_ExHyperlinkAtom, nExObjHyperListLen ) )
break;
rStCtrl.SeekRel( 8 );
- rStCtrl.ReadUInt32( pPtr->nIndex );
+ rStCtrl.ReadUInt32( entry.nIndex );
if (!aHyperE.SeekToEndOfRecord(rStCtrl))
break;
}
@@ -2111,9 +2108,9 @@ void ImplSdPPTImport::FillSdAnimationInfo( SdAnimationInfo* pInfo, PptInteractiv
case 0x04 :
{
SdHyperlinkEntry* pPtr = nullptr;
- for (SdHyperlinkEntry* pEntry : aHyperList) {
- if ( pEntry->nIndex == pIAtom->nExHyperlinkId ) {
- pPtr = pEntry;
+ for (SdHyperlinkEntry & entry : aHyperList) {
+ if ( entry.nIndex == pIAtom->nExHyperlinkId ) {
+ pPtr = &entry;
break;
}
}