[Libreoffice-commits] core.git: editeng/source
Noel Grandin (via logerrit)
logerrit at kemper.freedesktop.org
Thu Mar 28 11:34:05 UTC 2019
editeng/source/editeng/impedit.hxx | 4 ++--
editeng/source/editeng/impedit4.cxx | 19 +++++++++----------
2 files changed, 11 insertions(+), 12 deletions(-)
New commits:
commit e74de110d16c95414fac7541c8fe6541d4597113
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Thu Mar 28 09:39:49 2019 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Thu Mar 28 12:33:40 2019 +0100
loplugin:useuniqueptr in ImpEditEngine::WriteItemListAsRTF
Change-Id: I50188d81743f1daaf96412b3cd70c150c8d72502
Reviewed-on: https://gerrit.libreoffice.org/69879
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
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 )
More information about the Libreoffice-commits
mailing list