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: ...@@ -658,9 +658,9 @@ private:
void WriteXML(SvStream& rOutput, const EditSelection& rSel); void WriteXML(SvStream& rOutput, const EditSelection& rSel);
void WriteItemAsRTF( const SfxPoolItem& rItem, SvStream& rOutput, sal_Int32 nPara, sal_Int32 nPos, 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, 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 ); sal_Int32 LogicToTwips( sal_Int32 n );
inline short GetXValue( short nXValue ) const; inline short GetXValue( short nXValue ) const;
......
...@@ -240,7 +240,7 @@ ErrCode ImpEditEngine::WriteText( SvStream& rOutput, EditSelection aSel ) ...@@ -240,7 +240,7 @@ ErrCode ImpEditEngine::WriteText( SvStream& rOutput, EditSelection aSel )
} }
bool ImpEditEngine::WriteItemListAsRTF( ItemList& rLst, SvStream& rOutput, sal_Int32 nPara, sal_Int32 nPos, 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(); const SfxPoolItem* pAttrItem = rLst.First();
while ( pAttrItem ) while ( pAttrItem )
...@@ -297,11 +297,11 @@ ErrCode ImpEditEngine::WriteRTF( SvStream& rOutput, EditSelection aSel ) ...@@ -297,11 +297,11 @@ ErrCode ImpEditEngine::WriteRTF( SvStream& rOutput, EditSelection aSel )
rtl_TextEncoding eDestEnc = RTL_TEXTENCODING_MS_1252; rtl_TextEncoding eDestEnc = RTL_TEXTENCODING_MS_1252;
// Generate and write out Font table ... // 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 // default font must be up front, so DEF font in RTF
aFontTable.push_back( new SvxFontItem( aEditDoc.GetItemPool().GetDefaultItem( EE_CHAR_FONTINFO ) ) ); aFontTable.emplace_back( new SvxFontItem( aEditDoc.GetItemPool().GetDefaultItem( EE_CHAR_FONTINFO ) ) );
aFontTable.push_back( new SvxFontItem( aEditDoc.GetItemPool().GetDefaultItem( EE_CHAR_FONTINFO_CJK ) ) ); aFontTable.emplace_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_CTL ) ) );
for ( sal_uInt16 nScriptType = 0; nScriptType < 3; nScriptType++ ) for ( sal_uInt16 nScriptType = 0; nScriptType < 3; nScriptType++ )
{ {
sal_uInt16 nWhich = EE_CHAR_FONTINFO; sal_uInt16 nWhich = EE_CHAR_FONTINFO;
...@@ -327,7 +327,7 @@ ErrCode ImpEditEngine::WriteRTF( SvStream& rOutput, EditSelection aSel ) ...@@ -327,7 +327,7 @@ ErrCode ImpEditEngine::WriteRTF( SvStream& rOutput, EditSelection aSel )
} }
if ( !bAlreadyExist ) 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 ) ...@@ -335,7 +335,7 @@ ErrCode ImpEditEngine::WriteRTF( SvStream& rOutput, EditSelection aSel )
rOutput.WriteChar( '{' ).WriteCharPtr( OOO_STRING_SVTOOLS_RTF_FONTTBL ); rOutput.WriteChar( '{' ).WriteCharPtr( OOO_STRING_SVTOOLS_RTF_FONTTBL );
for ( std::vector<SvxFontItem*>::size_type j = 0; j < aFontTable.size(); j++ ) for ( std::vector<SvxFontItem*>::size_type j = 0; j < aFontTable.size(); j++ )
{ {
SvxFontItem* pFontItem = aFontTable[ j ]; SvxFontItem* pFontItem = aFontTable[ j ].get();
rOutput.WriteChar( '{' ); rOutput.WriteChar( '{' );
rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_F ); rOutput.WriteCharPtr( OOO_STRING_SVTOOLS_RTF_F );
rOutput.WriteUInt32AsString( j ); rOutput.WriteUInt32AsString( j );
...@@ -652,15 +652,14 @@ ErrCode ImpEditEngine::WriteRTF( SvStream& rOutput, EditSelection aSel ) ...@@ -652,15 +652,14 @@ ErrCode ImpEditEngine::WriteRTF( SvStream& rOutput, EditSelection aSel )
rOutput.WriteCharPtr( "}}" ); // 1xparentheses paragraphs, 1xparentheses RTF document rOutput.WriteCharPtr( "}}" ); // 1xparentheses paragraphs, 1xparentheses RTF document
rOutput.Flush(); rOutput.Flush();
for (auto& pItem : aFontTable) aFontTable.clear();
delete pItem;
return rOutput.GetError(); return rOutput.GetError();
} }
void ImpEditEngine::WriteItemAsRTF( const SfxPoolItem& rItem, SvStream& rOutput, sal_Int32 nPara, sal_Int32 nPos, 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(); sal_uInt16 nWhich = rItem.Which();
switch ( nWhich ) 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