diff options
author | npcdoom <venccsralph@gmail.com> | 2011-02-21 10:57:25 -0800 |
---|---|---|
committer | Joseph Powers <jpowers27@cox.net> | 2011-02-21 10:57:25 -0800 |
commit | c86a8ee55868260bdcdcca4c056e16adb7b3d168 (patch) | |
tree | c8fcfe045e95206437fbcf570fe1c5183482cf62 /sc | |
parent | 0f8cdfc15c2af06775270d50edec47515ff74b2f (diff) |
[PATCH 05/10] Removed deprecated List container.
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/filter/inc/lotattr.hxx | 126 | ||||
-rw-r--r-- | sc/source/filter/lotus/lotattr.cxx | 176 |
2 files changed, 139 insertions, 163 deletions
diff --git a/sc/source/filter/inc/lotattr.hxx b/sc/source/filter/inc/lotattr.hxx index 7357910f51b0..5fdcc8a6ecb9 100644 --- a/sc/source/filter/inc/lotattr.hxx +++ b/sc/source/filter/inc/lotattr.hxx @@ -29,49 +29,52 @@ #ifndef SC_LOTATTR_HXX #define SC_LOTATTR_HXX +#include <boost/ptr_container/ptr_vector.hpp> + #include <tools/solar.h> -#include "patattr.hxx" -#include "scitems.hxx" + #include "address.hxx" +#include "scitems.hxx" -// ----- forwards -------------------------------------------------------- class ScDocument; class ScDocumentPool; +class ScPatternAttr; class SvxBorderLine; class SvxColorItem; class Color; - class LotAttrTable; - struct LotAttrWK3 { - UINT8 nFont; - UINT8 nLineStyle; - UINT8 nFontCol; - UINT8 nBack; + UINT8 nFont; + UINT8 nLineStyle; + UINT8 nFontCol; + UINT8 nBack; - inline BOOL HasStyles( void ); - inline BOOL IsCentered( void ); -}; + inline bool HasStyles () const + { + return ( nFont || nLineStyle || nFontCol || ( nBack & 0x7F ) ); + // !! ohne Center-Bit!! + } + inline bool IsCentered () const + { + return ( nBack & 0x80 ); + } +}; -inline BOOL LotAttrWK3::HasStyles( void ) +class LotAttrCache { - return ( nFont || nLineStyle || nFontCol || ( nBack & 0x7F ) ); - // !! ohne Center-Bit!! -} +public: + LotAttrCache (); -inline BOOL LotAttrWK3::IsCentered( void ) -{ - return ( nBack & 0x80 ); -} + ~LotAttrCache(); + const ScPatternAttr& GetPattAttr( const LotAttrWK3& ); -class LotAttrCache : private List -{ private: + friend class LotAttrTable; struct ENTRY @@ -79,75 +82,76 @@ private: ScPatternAttr* pPattAttr; UINT32 nHash0; - inline ENTRY( const ScPatternAttr& r ) { pPattAttr = new ScPatternAttr( r ); } + ENTRY (const ScPatternAttr &r); - inline ENTRY( ScPatternAttr* p ) { pPattAttr = p; } + ENTRY (ScPatternAttr* p); - inline ~ENTRY() { delete pPattAttr; } + ~ENTRY (); - inline BOOL operator ==( const ENTRY& r ) const { return nHash0 == r.nHash0; } + inline bool operator == (const ENTRY &r) const { return nHash0 == r.nHash0; } - inline BOOL operator ==( const UINT32& r ) const { return nHash0 == r; } + inline bool operator == (const UINT32 &r) const { return nHash0 == r; } }; + inline static void MakeHash( const LotAttrWK3& rAttr, UINT32& rOut ) + { + ( ( UINT8* ) &rOut )[ 0 ] = rAttr.nFont & 0x7F; + ( ( UINT8* ) &rOut )[ 1 ] = rAttr.nLineStyle; + ( ( UINT8* ) &rOut )[ 2 ] = rAttr.nFontCol; + ( ( UINT8* ) &rOut )[ 3 ] = rAttr.nBack; + } + + static void LotusToScBorderLine( UINT8 nLine, SvxBorderLine& ); + + const SvxColorItem& GetColorItem( const UINT8 nLotIndex ) const; + + const Color& GetColor( const UINT8 nLotIndex ) const; + ScDocumentPool* pDocPool; - SvxColorItem* ppColorItems[ 6 ]; // 0 und 7 fehlen! + SvxColorItem* ppColorItems[6]; // 0 und 7 fehlen! SvxColorItem* pBlack; SvxColorItem* pWhite; Color* pColTab; + boost::ptr_vector<ENTRY> aEntries; +}; - inline static void MakeHash( const LotAttrWK3& rAttr, UINT32& rOut ) - { - ( ( UINT8* ) &rOut )[ 0 ] = rAttr.nFont & 0x7F; - ( ( UINT8* ) &rOut )[ 1 ] = rAttr.nLineStyle; - ( ( UINT8* ) &rOut )[ 2 ] = rAttr.nFontCol; - ( ( UINT8* ) &rOut )[ 3 ] = rAttr.nBack; - } - static void LotusToScBorderLine( UINT8 nLine, SvxBorderLine& ); - const SvxColorItem& GetColorItem( const UINT8 nLotIndex ) const; - const Color& GetColor( const UINT8 nLotIndex ) const; + +class LotAttrCol +{ public: - LotAttrCache( void ); - ~LotAttrCache(); - const ScPatternAttr& GetPattAttr( const LotAttrWK3& ); -}; + void SetAttr (const SCROW nRow, const ScPatternAttr&); + void Apply (const SCCOL nCol, const SCTAB nTab, const BOOL bClear = TRUE); + + void Clear (); -class LotAttrCol : private List -{ private: + struct ENTRY { - const ScPatternAttr* pPattAttr; - SCROW nFirstRow; - SCROW nLastRow; + const ScPatternAttr* pPattAttr; + SCROW nFirstRow; + SCROW nLastRow; }; -public: - ~LotAttrCol( void ); - void SetAttr( const SCROW nRow, const ScPatternAttr& ); - void Apply( const SCCOL nCol, const SCTAB nTab, const BOOL bClear = TRUE ); - void Clear( void ); + boost::ptr_vector<ENTRY> aEntries; }; class LotAttrTable { -private: - LotAttrCol pCols[ MAXCOLCOUNT ]; - LotAttrCache aAttrCache; public: - LotAttrTable( void ); - ~LotAttrTable(); - - void SetAttr( const SCCOL nColFirst, const SCCOL nColLast, const SCROW nRow, const LotAttrWK3& ); - void Apply( const SCTAB nTabNum ); -}; + void SetAttr( const SCCOL nColFirst, const SCCOL nColLast, const SCROW nRow, const LotAttrWK3& ); + void Apply( const SCTAB nTabNum ); +private: + LotAttrCol pCols[ MAXCOLCOUNT ]; + LotAttrCache aAttrCache; +}; #endif diff --git a/sc/source/filter/lotus/lotattr.cxx b/sc/source/filter/lotus/lotattr.cxx index 1644ee51856a..bbb6e7b5131d 100644 --- a/sc/source/filter/lotus/lotattr.cxx +++ b/sc/source/filter/lotus/lotattr.cxx @@ -29,66 +29,39 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_sc.hxx" +#include "lotattr.hxx" +#include <boost/bind.hpp> -//------------------------------------------------------------------------ - -#include "scitems.hxx" -#include <svx/algitem.hxx> #include <editeng/boxitem.hxx> #include <editeng/brshitem.hxx> #include <editeng/justifyitem.hxx> +#include <svx/algitem.hxx> -#include "document.hxx" -#include "patattr.hxx" -#include "docpool.hxx" #include "attrib.hxx" - -#include "lotattr.hxx" +#include "docpool.hxx" +#include "document.hxx" #include "lotfntbf.hxx" +#include "patattr.hxx" #include "root.hxx" +#include "scitems.hxx" - - -void LotAttrCache::LotusToScBorderLine( UINT8 nLine, SvxBorderLine& aBL ) +LotAttrCache::ENTRY::ENTRY (const ScPatternAttr &r) + : pPattAttr(new ScPatternAttr(r)) { - static const UINT16 pPara[ 4 ][ 3 ] = - { - { 0,0,0 }, - { DEF_LINE_WIDTH_1, 0, 0 }, - { DEF_LINE_WIDTH_2, 0, 0 }, - { DEF_LINE_WIDTH_1, DEF_LINE_WIDTH_1, DEF_LINE_WIDTH_1 } - }; - - nLine &= 0x03; - - if( nLine ) - { - aBL.SetOutWidth( pPara[ nLine ][ 0 ] ); - aBL.SetInWidth( pPara[ nLine ][ 1 ] ); - aBL.SetDistance( pPara[ nLine ][ 2 ] ); - } } - -const SvxColorItem& LotAttrCache::GetColorItem( const UINT8 nLotIndex ) const +LotAttrCache::ENTRY::ENTRY (ScPatternAttr* p) + : pPattAttr(p) { - DBG_ASSERT( nLotIndex > 0 && nLotIndex < 7, - "-LotAttrCache::GetColorItem(): so nicht!" ); - - return *ppColorItems[ nLotIndex - 1 ]; } - -const Color& LotAttrCache::GetColor( const UINT8 nLotIndex ) const +LotAttrCache::ENTRY::~ENTRY () { - // Farbe <-> Index passt fuer Background, nicht aber fuer Fonts (0 <-> 7)! - DBG_ASSERT( nLotIndex < 8, "*LotAttrCache::GetColor(): Index > 7!" ); - return pColTab[ nLotIndex ]; + delete pPattAttr; } - -LotAttrCache::LotAttrCache( void ) +LotAttrCache::LotAttrCache () { pDocPool = pLotusRoot->pDoc->GetPool(); @@ -116,14 +89,6 @@ LotAttrCache::LotAttrCache( void ) LotAttrCache::~LotAttrCache() { - ENTRY* pAkt = ( ENTRY* ) List::First(); - - while( pAkt ) - { - delete pAkt; - pAkt = ( ENTRY* ) List::Next(); - } - for( UINT16 nCnt = 0 ; nCnt < 6 ; nCnt++ ) delete ppColorItems[ nCnt ]; @@ -137,22 +102,19 @@ LotAttrCache::~LotAttrCache() const ScPatternAttr& LotAttrCache::GetPattAttr( const LotAttrWK3& rAttr ) { UINT32 nRefHash; - ENTRY* pAkt = ( ENTRY* ) List::First(); - MakeHash( rAttr, nRefHash ); - while( pAkt ) - { - if( *pAkt == nRefHash ) - return *pAkt->pPattAttr; + boost::ptr_vector<ENTRY>::const_iterator iter = std::find_if(aEntries.begin(),aEntries.end(), + boost::bind(&ENTRY::nHash0,_1) == nRefHash); - pAkt = ( ENTRY* ) List::Next(); - } + if (iter != aEntries.end()) + return *(iter->pPattAttr); // neues PatternAttribute erzeugen - ScPatternAttr* pNewPatt = new ScPatternAttr( pDocPool ); + ScPatternAttr* pNewPatt = new ScPatternAttr(pDocPool); + SfxItemSet& rItemSet = pNewPatt->GetItemSet(); - pAkt = new ENTRY( pNewPatt ); + ENTRY *pAkt = new ENTRY( pNewPatt ); pAkt->nHash0 = nRefHash; @@ -200,43 +162,75 @@ const ScPatternAttr& LotAttrCache::GetPattAttr( const LotAttrWK3& rAttr ) rItemSet.Put( aHorJustify ); } - List::Insert( pAkt, LIST_APPEND ); + aEntries.push_back(pAkt); return *pNewPatt; - } +} + + +void LotAttrCache::LotusToScBorderLine( UINT8 nLine, SvxBorderLine& aBL ) +{ + static const UINT16 pPara[ 4 ][ 3 ] = + { + { 0,0,0 }, + { DEF_LINE_WIDTH_1, 0, 0 }, + { DEF_LINE_WIDTH_2, 0, 0 }, + { DEF_LINE_WIDTH_1, DEF_LINE_WIDTH_1, DEF_LINE_WIDTH_1 } + }; + nLine &= 0x03; -LotAttrCol::~LotAttrCol() + if( nLine ) + { + aBL.SetOutWidth( pPara[ nLine ][ 0 ] ); + aBL.SetInWidth( pPara[ nLine ][ 1 ] ); + aBL.SetDistance( pPara[ nLine ][ 2 ] ); + } +} + +const SvxColorItem& LotAttrCache::GetColorItem( const UINT8 nLotIndex ) const { - Clear(); + DBG_ASSERT( nLotIndex > 0 && nLotIndex < 7, + "-LotAttrCache::GetColorItem(): so nicht!" ); + + return *ppColorItems[ nLotIndex - 1 ]; } +const Color& LotAttrCache::GetColor( const UINT8 nLotIndex ) const +{ + // Farbe <-> Index passt fuer Background, nicht aber fuer Fonts (0 <-> 7)! + DBG_ASSERT( nLotIndex < 8, "*LotAttrCache::GetColor(): Index > 7!" ); + + return pColTab[ nLotIndex ]; +} void LotAttrCol::SetAttr( const SCROW nRow, const ScPatternAttr& rAttr ) { DBG_ASSERT( ValidRow(nRow), "*LotAttrCol::SetAttr(): ... und rums?!" ); - ENTRY* pAkt = ( ENTRY* ) List::Last(); + boost::ptr_vector<ENTRY>::reverse_iterator iterLast = aEntries.rbegin(); - if( pAkt ) + if(iterLast != aEntries.rend()) { - if( ( pAkt->nLastRow == nRow - 1 ) && ( &rAttr == pAkt->pPattAttr ) ) - pAkt->nLastRow = nRow; + if( ( iterLast->nLastRow == nRow - 1 ) && ( &rAttr == iterLast->pPattAttr ) ) + iterLast->nLastRow = nRow; else { - pAkt = new ENTRY; + ENTRY *pAkt = new ENTRY; pAkt->pPattAttr = &rAttr; pAkt->nFirstRow = pAkt->nLastRow = nRow; - List::Insert( pAkt, LIST_APPEND ); + + aEntries.push_back(pAkt); } } else { // erster Eintrag - pAkt = new ENTRY; + ENTRY *pAkt = new ENTRY; pAkt->pPattAttr = &rAttr; pAkt->nFirstRow = pAkt->nLastRow = nRow; - List::Insert( pAkt, LIST_APPEND ); + + aEntries.push_back(pAkt); } } @@ -244,45 +238,26 @@ void LotAttrCol::SetAttr( const SCROW nRow, const ScPatternAttr& rAttr ) void LotAttrCol::Apply( const SCCOL nColNum, const SCTAB nTabNum, const BOOL /*bClear*/ ) { ScDocument* pDoc = pLotusRoot->pDoc; - ENTRY* pAkt = ( ENTRY* ) List::First(); - - while( pAkt ) - { - pDoc->ApplyPatternAreaTab( nColNum, pAkt->nFirstRow, nColNum, pAkt->nLastRow, - nTabNum, *pAkt->pPattAttr ); - - pAkt = ( ENTRY* ) List::Next(); - } -} - -void LotAttrCol::Clear( void ) -{ - ENTRY* pAkt = ( ENTRY* ) List::First(); - - while( pAkt ) + boost::ptr_vector<ENTRY>::iterator iter; + for (iter = aEntries.begin(); iter != aEntries.end(); ++iter) { - delete pAkt; - pAkt = ( ENTRY* ) List::Next(); + pDoc->ApplyPatternAreaTab(nColNum,iter->nFirstRow,nColNum,iter->nLastRow, + nTabNum, *(iter->pPattAttr)); } } -LotAttrTable::LotAttrTable( void ) +void LotAttrCol::Clear () { + aEntries.clear(); } - -LotAttrTable::~LotAttrTable() -{ -} - - void LotAttrTable::SetAttr( const SCCOL nColFirst, const SCCOL nColLast, const SCROW nRow, const LotAttrWK3& rAttr ) { - const ScPatternAttr& rPattAttr = aAttrCache.GetPattAttr( rAttr ); - SCCOL nColCnt; + const ScPatternAttr &rPattAttr = aAttrCache.GetPattAttr( rAttr ); + SCCOL nColCnt; for( nColCnt = nColFirst ; nColCnt <= nColLast ; nColCnt++ ) pCols[ nColCnt ].SetAttr( nRow, rPattAttr ); @@ -291,12 +266,9 @@ void LotAttrTable::SetAttr( const SCCOL nColFirst, const SCCOL nColLast, const S void LotAttrTable::Apply( const SCTAB nTabNum ) { - SCCOL nColCnt; + SCCOL nColCnt; for( nColCnt = 0 ; nColCnt <= MAXCOL ; nColCnt++ ) pCols[ nColCnt ].Apply( nColCnt, nTabNum ); // macht auch gleich ein Clear() am Ende } - - - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |