summaryrefslogtreecommitdiff
path: root/sc/source/filter/lotus/lotattr.cxx
diff options
context:
space:
mode:
authornpcdoom <venccsralph@gmail.com>2011-02-21 10:57:25 -0800
committerJoseph Powers <jpowers27@cox.net>2011-02-21 10:57:25 -0800
commitc86a8ee55868260bdcdcca4c056e16adb7b3d168 (patch)
treec8fcfe045e95206437fbcf570fe1c5183482cf62 /sc/source/filter/lotus/lotattr.cxx
parent0f8cdfc15c2af06775270d50edec47515ff74b2f (diff)
[PATCH 05/10] Removed deprecated List container.
Diffstat (limited to 'sc/source/filter/lotus/lotattr.cxx')
-rw-r--r--sc/source/filter/lotus/lotattr.cxx176
1 files changed, 74 insertions, 102 deletions
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: */