summaryrefslogtreecommitdiff
path: root/editeng/source/editeng
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2019-03-28 09:39:49 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-03-28 12:33:40 +0100
commite74de110d16c95414fac7541c8fe6541d4597113 (patch)
tree85dd56c536e2ab40953e0700cbda694c826c8fa3 /editeng/source/editeng
parentee5b332e34962b79ecd24e9fd111d307aabcbf7d (diff)
loplugin:useuniqueptr in ImpEditEngine::WriteItemListAsRTF
Change-Id: I50188d81743f1daaf96412b3cd70c150c8d72502 Reviewed-on: https://gerrit.libreoffice.org/69879 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'editeng/source/editeng')
-rw-r--r--editeng/source/editeng/impedit.hxx4
-rw-r--r--editeng/source/editeng/impedit4.cxx19
2 files changed, 11 insertions, 12 deletions
diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx
index a1e332f6db05..3ff954d9bf79 100644
--- a/editeng/source/editeng/impedit.hxx
+++ b/editeng/source/editeng/impedit.hxx
@@ -658,9 +658,9 @@ private:
void WriteXML(SvStream& rOutput, const EditSelection& rSel);
void WriteItemAsRTF( const SfxPoolItem& rItem, SvStream& rOutput, sal_Int32 nPara, sal_Int32 nPos,
- std::vector<SvxFontItem*>& rFontTable, SvxColorList& rColorList );
+ std::vector<std::unique_ptr<SvxFontItem>>& rFontTable, SvxColorList& rColorList );
bool WriteItemListAsRTF( ItemList& rLst, SvStream& rOutput, sal_Int32 nPara, sal_Int32 nPos,
- std::vector<SvxFontItem*>& rFontTable, SvxColorList& rColorList );
+ std::vector<std::unique_ptr<SvxFontItem>>& rFontTable, SvxColorList& rColorList );
sal_Int32 LogicToTwips( sal_Int32 n );
inline short GetXValue( short nXValue ) const;
diff --git a/editeng/source/editeng/impedit4.cxx b/editeng/source/editeng/impedit4.cxx
index b26d2856ceee..8a9c4d31d1c7 100644
--- a/editeng/source/editeng/impedit4.cxx
+++ b/editeng/source/editeng/impedit4.cxx
@@ -240,7 +240,7 @@ ErrCode ImpEditEngine::WriteText( SvStream& rOutput, EditSelection aSel )
}
bool ImpEditEngine::WriteItemListAsRTF( ItemList& rLst, SvStream& rOutput, sal_Int32 nPara, sal_Int32 nPos,
- std::vector<SvxFontItem*>& rFontTable, SvxColorList& rColorList )
+ std::vector<std::unique_ptr<SvxFontItem>>& rFontTable, SvxColorList& rColorList )
{
const SfxPoolItem* pAttrItem = rLst.First();
while ( pAttrItem )
@@ -297,11 +297,11 @@ ErrCode ImpEditEngine::WriteRTF( SvStream& rOutput, EditSelection aSel )
rtl_TextEncoding eDestEnc = RTL_TEXTENCODING_MS_1252;
// Generate and write out Font table ...
- std::vector<SvxFontItem*> aFontTable;
+ std::vector<std::unique_ptr<SvxFontItem>> aFontTable;
// default font must be up front, so DEF font in RTF
- aFontTable.push_back( new SvxFontItem( aEditDoc.GetItemPool().GetDefaultItem( EE_CHAR_FONTINFO ) ) );
- aFontTable.push_back( new SvxFontItem( aEditDoc.GetItemPool().GetDefaultItem( EE_CHAR_FONTINFO_CJK ) ) );
- aFontTable.push_back( new SvxFontItem( aEditDoc.GetItemPool().GetDefaultItem( EE_CHAR_FONTINFO_CTL ) ) );
+ aFontTable.emplace_back( new SvxFontItem( aEditDoc.GetItemPool().GetDefaultItem( EE_CHAR_FONTINFO ) ) );
+ aFontTable.emplace_back( new SvxFontItem( aEditDoc.GetItemPool().GetDefaultItem( EE_CHAR_FONTINFO_CJK ) ) );
+ aFontTable.emplace_back( new SvxFontItem( aEditDoc.GetItemPool().GetDefaultItem( EE_CHAR_FONTINFO_CTL ) ) );
for ( sal_uInt16 nScriptType = 0; nScriptType < 3; nScriptType++ )
{
sal_uInt16 nWhich = EE_CHAR_FONTINFO;
@@ -327,7 +327,7 @@ ErrCode ImpEditEngine::WriteRTF( SvStream& rOutput, EditSelection aSel )
}
if ( !bAlreadyExist )
- aFontTable.push_back( new SvxFontItem( *pFontItem ) );
+ aFontTable.emplace_back( new SvxFontItem( *pFontItem ) );
}
}
@@ -335,7 +335,7 @@ ErrCode ImpEditEngine::WriteRTF( SvStream& rOutput, EditSelection aSel )
rOutput.WriteChar( '{' ).WriteCharPtr( OOO_STRING_SVTOOLS_RTF_FONTTBL );
for ( std::vector<SvxFontItem*>::size_type j = 0; j < aFontTable.size(); j++ )
{
- SvxFontItem* pFontItem = aFontTable[ j ];
+ SvxFontItem* pFontItem = aFontTable[ j ].get();
rOutput.WriteChar( '{' );
rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_F );
rOutput.WriteUInt32AsString( j );
@@ -652,15 +652,14 @@ ErrCode ImpEditEngine::WriteRTF( SvStream& rOutput, EditSelection aSel )
rOutput.WriteCharPtr( "}}" ); // 1xparentheses paragraphs, 1xparentheses RTF document
rOutput.Flush();
- for (auto& pItem : aFontTable)
- delete pItem;
+ aFontTable.clear();
return rOutput.GetError();
}
void ImpEditEngine::WriteItemAsRTF( const SfxPoolItem& rItem, SvStream& rOutput, sal_Int32 nPara, sal_Int32 nPos,
- std::vector<SvxFontItem*>& rFontTable, SvxColorList& rColorList )
+ std::vector<std::unique_ptr<SvxFontItem>>& rFontTable, SvxColorList& rColorList )
{
sal_uInt16 nWhich = rItem.Which();
switch ( nWhich )