diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-06-25 17:08:28 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-06-27 08:32:32 +0200 |
commit | 20dfe973a8c1ef0d873aca735711e288734c5cba (patch) | |
tree | 657bcda31158008b94193414ee77d07d5314db57 /sd | |
parent | 5be0637827cd987b7b7dda7ca2c54a3548d9ef51 (diff) |
loplugin:useuniqueptr in PortionObj
Change-Id: I79fcbaa12def04aa36bdf1928638b70ad490448c
Reviewed-on: https://gerrit.libreoffice.org/56494
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sd')
-rw-r--r-- | sd/source/filter/eppt/epptso.cxx | 2 | ||||
-rw-r--r-- | sd/source/filter/eppt/pptx-text.cxx | 22 | ||||
-rw-r--r-- | sd/source/filter/eppt/text.hxx | 4 |
3 files changed, 12 insertions, 16 deletions
diff --git a/sd/source/filter/eppt/epptso.cxx b/sd/source/filter/eppt/epptso.cxx index 4ebeafe3c48e..69d520e7b742 100644 --- a/sd/source/filter/eppt/epptso.cxx +++ b/sd/source/filter/eppt/epptso.cxx @@ -1108,7 +1108,7 @@ void PPTWriter::ImplWriteTextStyleAtom( SvStream& rOut, int nTextInstance, sal_u const PortionObj& rPortion = *(*it).get(); if ( rPortion.mpFieldEntry ) { - const FieldEntry* pFieldEntry = rPortion.mpFieldEntry; + const FieldEntry* pFieldEntry = rPortion.mpFieldEntry.get(); switch ( pFieldEntry->nFieldType >> 28 ) { diff --git a/sd/source/filter/eppt/pptx-text.cxx b/sd/source/filter/eppt/pptx-text.cxx index 90011a09be3d..00e8c483c327 100644 --- a/sd/source/filter/eppt/pptx-text.cxx +++ b/sd/source/filter/eppt/pptx-text.cxx @@ -120,7 +120,7 @@ PortionObj::PortionObj(css::uno::Reference< css::text::XTextRange > & rXTextRang nFieldType = ImplGetTextField( rXTextRange, mXPropSet, aURL ); if ( nFieldType ) { - mpFieldEntry = new FieldEntry( nFieldType, 0, mnTextSize ); + mpFieldEntry.reset( new FieldEntry( nFieldType, 0, mnTextSize ) ); if ( nFieldType >> 28 == 4 ) { mpFieldEntry->aRepresentation = aString; @@ -141,7 +141,7 @@ PortionObj::PortionObj(css::uno::Reference< css::text::XTextRange > & rXTextRang mnTextSize = 1; if ( bLast ) mnTextSize++; - mpText = new sal_uInt16[ mnTextSize ]; + mpText.reset( new sal_uInt16[ mnTextSize ] ); mpText[ 0 ] = 0x2a; } else @@ -155,7 +155,7 @@ PortionObj::PortionObj(css::uno::Reference< css::text::XTextRange > & rXTextRang mnTextSize++; bRTL_endingParen = true; } - mpText = new sal_uInt16[ mnTextSize ]; + mpText.reset( new sal_uInt16[ mnTextSize ] ); sal_uInt16 nChar; for ( sal_Int32 i = 0; i < aString.getLength(); i++ ) { @@ -261,7 +261,7 @@ void PortionObj::ImplGetPortionValues( FontCollection& rFontCollection, bool bGe sal_Int16 nScriptType = SvtLanguageOptions::FromSvtScriptTypeToI18N( SvtLanguageOptions::GetScriptTypeOfLanguage( Application::GetSettings().GetLanguageTag().getLanguageType() ) ); if ( mpText && mnTextSize && xPPTBreakIter.is() ) { - OUString sT( reinterpret_cast<sal_Unicode *>(mpText), mnTextSize ); + OUString sT( reinterpret_cast<sal_Unicode *>(mpText.get()), mnTextSize ); nScriptType = xPPTBreakIter->getScriptType( sT, 0 ); } if ( nScriptType != css::i18n::ScriptType::COMPLEX ) @@ -440,8 +440,8 @@ void PortionObj::ImplGetPortionValues( FontCollection& rFontCollection, bool bGe void PortionObj::ImplClear() { - delete mpFieldEntry; - delete[] mpText; + mpFieldEntry.reset(); + mpText.reset(); } void PortionObj::ImplConstruct( const PortionObj& rPortionObj ) @@ -465,16 +465,12 @@ void PortionObj::ImplConstruct( const PortionObj& rPortionObj ) if ( rPortionObj.mpText ) { - mpText = new sal_uInt16[ mnTextSize ]; - memcpy( mpText, rPortionObj.mpText, mnTextSize << 1 ); + mpText.reset( new sal_uInt16[ mnTextSize ] ); + memcpy( mpText.get(), rPortionObj.mpText.get(), mnTextSize << 1 ); } - else - mpText = nullptr; if ( rPortionObj.mpFieldEntry ) - mpFieldEntry = new FieldEntry( *( rPortionObj.mpFieldEntry ) ); - else - mpFieldEntry = nullptr; + mpFieldEntry.reset( new FieldEntry( *( rPortionObj.mpFieldEntry ) ) ); } sal_uInt32 PortionObj::ImplCalculateTextPositions( sal_uInt32 nCurrentTextPosition ) diff --git a/sd/source/filter/eppt/text.hxx b/sd/source/filter/eppt/text.hxx index d9e40f2ac91d..0928e9b72dba 100644 --- a/sd/source/filter/eppt/text.hxx +++ b/sd/source/filter/eppt/text.hxx @@ -144,8 +144,8 @@ class PortionObj final : public PropStateValue sal_uInt32 mnTextSize; bool mbLastPortion; - sal_uInt16* mpText; - FieldEntry* mpFieldEntry; + std::unique_ptr<sal_uInt16[]> mpText; + std::unique_ptr<FieldEntry> mpFieldEntry; PortionObj( css::uno::Reference< css::text::XTextRange > & rXTextRangeRef, bool bLast, FontCollection& rFontCollection ); |