editeng/source/editeng/editdoc.cxx | 26 -------------------------- editeng/source/editeng/impedit.hxx | 5 ++--- editeng/source/editeng/impedit4.cxx | 24 ++++++++++++------------ 3 files changed, 14 insertions(+), 41 deletions(-)
New commits: commit a0cd57b926830e8798a5019b30776e94dd97c8a1 Author: Noel Grandin <[email protected]> Date: Thu Mar 1 10:22:36 2012 +0200 Remove SvxFontTable and use std::vector instead In removing tools/table.hxx usage, remove SvxFontTable and convert to std::vector<SvxFontItem*> because it was only being used as a temporary list, not a map. diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx index 50f96a2..98268d9 100644 --- a/editeng/source/editeng/editdoc.cxx +++ b/editeng/source/editeng/editdoc.cxx @@ -2161,32 +2161,6 @@ bool CharAttribList::DbgCheckAttribs() const } #endif -SvxFontTable::SvxFontTable() -{ -} - -SvxFontTable::~SvxFontTable() -{ - SvxFontItem* pItem = First(); - while( pItem ) - { - delete pItem; - pItem = Next(); - } -} - -sal_uLong SvxFontTable::GetId( const SvxFontItem& rFontItem ) -{ - SvxFontItem* pItem = First(); - while ( pItem ) - { - if ( *pItem == rFontItem ) - return GetCurKey(); - pItem = Next(); - } - DBG_WARNING( "Font not found: GetId()" ); - return 0; -} SvxColorList::SvxColorList() { diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx index 1c008fb..d02a959 100644 --- a/editeng/source/editeng/impedit.hxx +++ b/editeng/source/editeng/impedit.hxx @@ -80,7 +80,6 @@ DBG_NAMEEX( EditEngine ) class EditView; class EditEngine; -class SvxFontTable; class SvxColorList; class SvxSearchItem; @@ -640,9 +639,9 @@ private: sal_uInt32 WriteBin( SvStream& rOutput, EditSelection aSel, sal_Bool bStoreUnicode = sal_False ) const; void WriteItemAsRTF( const SfxPoolItem& rItem, SvStream& rOutput, sal_uInt16 nPara, sal_uInt16 nPos, - SvxFontTable& rFontTable, SvxColorList& rColorList ); + std::vector<SvxFontItem*>& rFontTable, SvxColorList& rColorList ); sal_Bool WriteItemListAsRTF( ItemList& rLst, SvStream& rOutput, sal_uInt16 nPara, sal_uInt16 nPos, - SvxFontTable& rFontTable, SvxColorList& rColorList ); + std::vector<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 f76b0ca..07d8074 100644 --- a/editeng/source/editeng/impedit4.cxx +++ b/editeng/source/editeng/impedit4.cxx @@ -277,7 +277,7 @@ sal_uInt32 ImpEditEngine::WriteText( SvStream& rOutput, EditSelection aSel ) } sal_Bool ImpEditEngine::WriteItemListAsRTF( ItemList& rLst, SvStream& rOutput, sal_uInt16 nPara, sal_uInt16 nPos, - SvxFontTable& rFontTable, SvxColorList& rColorList ) + std::vector<SvxFontItem*>& rFontTable, SvxColorList& rColorList ) { const SfxPoolItem* pAttrItem = rLst.First(); while ( pAttrItem ) @@ -358,11 +358,11 @@ sal_uInt32 ImpEditEngine::WriteRTF( SvStream& rOutput, EditSelection aSel ) rtl_TextEncoding eDestEnc = RTL_TEXTENCODING_MS_1252; // Generate and write out Font table ... - SvxFontTable aFontTable; + std::vector<SvxFontItem*> aFontTable; // default font must be up front, so DEF font in RTF - aFontTable.Insert( 0, new SvxFontItem( (const SvxFontItem&)aEditDoc.GetItemPool().GetDefaultItem( EE_CHAR_FONTINFO ) ) ); - aFontTable.Insert( 1, new SvxFontItem( (const SvxFontItem&)aEditDoc.GetItemPool().GetDefaultItem( EE_CHAR_FONTINFO_CJK ) ) ); - aFontTable.Insert( 2, new SvxFontItem( (const SvxFontItem&)aEditDoc.GetItemPool().GetDefaultItem( EE_CHAR_FONTINFO_CTL ) ) ); + aFontTable.push_back( new SvxFontItem( (const SvxFontItem&)aEditDoc.GetItemPool().GetDefaultItem( EE_CHAR_FONTINFO ) ) ); + aFontTable.push_back( new SvxFontItem( (const SvxFontItem&)aEditDoc.GetItemPool().GetDefaultItem( EE_CHAR_FONTINFO_CJK ) ) ); + aFontTable.push_back( new SvxFontItem( (const SvxFontItem&)aEditDoc.GetItemPool().GetDefaultItem( EE_CHAR_FONTINFO_CTL ) ) ); for ( sal_uInt16 nScriptType = 0; nScriptType < 3; nScriptType++ ) { sal_uInt16 nWhich = EE_CHAR_FONTINFO; @@ -376,14 +376,14 @@ sal_uInt32 ImpEditEngine::WriteRTF( SvStream& rOutput, EditSelection aSel ) while ( pFontItem ) { bool bAlreadyExist = false; - sal_uLong nTestMax = nScriptType ? aFontTable.Count() : 1; + sal_uLong nTestMax = nScriptType ? aFontTable.size() : 1; for ( sal_uLong nTest = 0; !bAlreadyExist && ( nTest < nTestMax ); nTest++ ) { - bAlreadyExist = *aFontTable.Get( nTest ) == *pFontItem; + bAlreadyExist = *aFontTable[ nTest ] == *pFontItem; } if ( !bAlreadyExist ) - aFontTable.Insert( aFontTable.Count(), new SvxFontItem( *pFontItem ) ); + aFontTable.push_back( new SvxFontItem( *pFontItem ) ); pFontItem = (SvxFontItem*)aEditDoc.GetItemPool().GetItem2( nWhich, ++i ); } @@ -391,9 +391,9 @@ sal_uInt32 ImpEditEngine::WriteRTF( SvStream& rOutput, EditSelection aSel ) rOutput << endl << '{' << OOO_STRING_SVTOOLS_RTF_FONTTBL; sal_uInt16 j; - for ( j = 0; j < aFontTable.Count(); j++ ) + for ( j = 0; j < aFontTable.size(); j++ ) { - SvxFontItem* pFontItem = aFontTable.Get( j ); + SvxFontItem* pFontItem = aFontTable[ j ]; rOutput << '{'; rOutput << OOO_STRING_SVTOOLS_RTF_F; rOutput.WriteNumber( static_cast<sal_uInt32>( j ) ); @@ -703,7 +703,7 @@ sal_uInt32 ImpEditEngine::WriteRTF( SvStream& rOutput, EditSelection aSel ) void ImpEditEngine::WriteItemAsRTF( const SfxPoolItem& rItem, SvStream& rOutput, sal_uInt16 nPara, sal_uInt16 nPos, - SvxFontTable& rFontTable, SvxColorList& rColorList ) + std::vector<SvxFontItem*>& rFontTable, SvxColorList& rColorList ) { sal_uInt16 nWhich = rItem.Which(); switch ( nWhich ) @@ -810,7 +810,7 @@ void ImpEditEngine::WriteItemAsRTF( const SfxPoolItem& rItem, SvStream& rOutput, case EE_CHAR_FONTINFO_CJK: case EE_CHAR_FONTINFO_CTL: { - sal_uInt32 n = rFontTable.GetId( (const SvxFontItem&)rItem ); + sal_uInt32 n = std::find(rFontTable.begin(), rFontTable.end(), (SvxFontItem*)&rItem ) - rFontTable.begin(); rOutput << OOO_STRING_SVTOOLS_RTF_F; rOutput.WriteNumber( n ); } _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
