Kaydet (Commit) e74de110 authored tarafından Noel Grandin's avatar Noel Grandin

loplugin:useuniqueptr in ImpEditEngine::WriteItemListAsRTF

Change-Id: I50188d81743f1daaf96412b3cd70c150c8d72502
Reviewed-on: https://gerrit.libreoffice.org/69879
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst ee5b332e
......@@ -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;
......
......@@ -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 )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment