diff --git a/editeng/inc/editeng/forbiddencharacterstable.hxx b/editeng/inc/editeng/forbiddencharacterstable.hxx index 5d499e8..762548a 100644 --- a/editeng/inc/editeng/forbiddencharacterstable.hxx +++ b/editeng/inc/editeng/forbiddencharacterstable.hxx @@ -29,8 +29,7 @@ #ifndef _FORBIDDENCHARACTERSTABLE_HXX #define _FORBIDDENCHARACTERSTABLE_HXX -#include - +#include #include #include #include @@ -49,18 +48,23 @@ struct ForbiddenCharactersInfo sal_Bool bTemporary; }; -DECLARE_TABLE( SvxForbiddenCharactersTableImpl, ForbiddenCharactersInfo* ) -class EDITENG_DLLPUBLIC SvxForbiddenCharactersTable : public SvxForbiddenCharactersTableImpl, public salhelper::SimpleReferenceObject +class EDITENG_DLLPUBLIC SvxForbiddenCharactersTable : public salhelper::SimpleReferenceObject { +public: + typedef std::map CharInfoMap; private: + CharInfoMap maCharInfoMap; ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxMSF; + ForbiddenCharactersInfo* GetCharInfo( sal_uInt16 nLanguage ) const; public: - SvxForbiddenCharactersTable( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xMSF, sal_uInt16 nISize = 4, sal_uInt16 nGrow = 4 ); - ~SvxForbiddenCharactersTable(); + SvxForbiddenCharactersTable( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xMSF ); + ~SvxForbiddenCharactersTable(); + + inline CharInfoMap& Map() { return maCharInfoMap; } - const com::sun::star::i18n::ForbiddenCharacters* GetForbiddenCharacters( sal_uInt16 nLanuage, sal_Bool bGetDefault ) const; + const com::sun::star::i18n::ForbiddenCharacters* GetForbiddenCharacters( sal_uInt16 nLanguage, sal_Bool bGetDefault ); void SetForbiddenCharacters( sal_uInt16 nLanuage , const com::sun::star::i18n::ForbiddenCharacters& ); void ClearForbiddenCharacters( sal_uInt16 nLanuage ); }; diff --git a/editeng/inc/editeng/svxrtf.hxx b/editeng/inc/editeng/svxrtf.hxx index c79f2bd..fb319c2 100644 --- a/editeng/inc/editeng/svxrtf.hxx +++ b/editeng/inc/editeng/svxrtf.hxx @@ -29,7 +29,6 @@ #ifndef _SVXRTF_HXX #define _SVXRTF_HXX -#include #include #include #include @@ -39,6 +38,7 @@ #include #include #include +#include class Font; class Color; class Graphic; @@ -85,8 +85,8 @@ public: typedef Color* ColorPtr; typedef std::deque< ColorPtr > SvxRTFColorTbl; -DECLARE_TABLE( SvxRTFFontTbl, Font* ) -DECLARE_TABLE( SvxRTFStyleTbl, SvxRTFStyleType* ) +typedef std::map SvxRTFFontTbl; +typedef std::map SvxRTFStyleTbl; typedef SvxRTFItemStackType* SvxRTFItemStackTypePtr; SV_DECL_PTRARR_DEL( SvxRTFItemStackList, SvxRTFItemStackTypePtr, 1 ) diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx index 0161eaa0..43cf491 100644 --- a/editeng/source/editeng/editdoc.cxx +++ b/editeng/source/editeng/editdoc.cxx @@ -2175,27 +2175,39 @@ SvxFontTable::SvxFontTable() SvxFontTable::~SvxFontTable() { - SvxFontItem* pItem = First(); - while( pItem ) - { - delete pItem; - pItem = Next(); - } + for(FontItemMap::iterator it = maFontItemMap.begin(); it != maFontItemMap.end(); ++it) + { + delete it->second; + } } -sal_uLong SvxFontTable::GetId( const SvxFontItem& rFontItem ) +sal_uLong SvxFontTable::GetId( const SvxFontItem& rFontItem ) const { - SvxFontItem* pItem = First(); - while ( pItem ) - { + for(FontItemMap::const_iterator it = maFontItemMap.begin(); it != maFontItemMap.end(); ++it) + { + SvxFontItem* pItem = it->second; if ( *pItem == rFontItem ) - return GetCurKey(); - pItem = Next(); - } + return it->first; + } DBG_WARNING( "Font not found: GetId()" ); return 0; } +void SvxFontTable::Insert( sal_uLong nIdx, SvxFontItem *pFontItem) +{ + maFontItemMap[ nIdx ] = pFontItem; +} + +int SvxFontTable::Count() const +{ + return maFontItemMap.size(); +} + +SvxFontItem* SvxFontTable::Get( sal_uLong nIdx ) +{ + return maFontItemMap[ nIdx ]; +} + SvxColorList::SvxColorList() { } diff --git a/editeng/source/editeng/editdoc.hxx b/editeng/source/editeng/editdoc.hxx index 2b35c3e..b7d1171 100644 --- a/editeng/source/editeng/editdoc.hxx +++ b/editeng/source/editeng/editdoc.hxx @@ -37,7 +37,6 @@ #include #include #include -#include #include #include @@ -141,15 +140,22 @@ SV_DECL_PTRARR( ContentInfoArray, ContentAttribsInfoPtr, 1 ) // ---------------------------------------------------------------------- // class SvxFontTable // ---------------------------------------------------------------------- -DECLARE_TABLE( DummyFontTable, SvxFontItem* ) -class SvxFontTable : public DummyFontTable +class SvxFontTable { public: SvxFontTable(); ~SvxFontTable(); - sal_uLong GetId( const SvxFontItem& rFont ); + sal_uLong GetId( const SvxFontItem& rFont ) const; + void Insert( sal_uLong nIdx, SvxFontItem *pFontItem); + int Count() const; + SvxFontItem* Get( sal_uLong nIdx ); + +private: + typedef std::map FontItemMap; + FontItemMap maFontItemMap; + }; // ---------------------------------------------------------------------- diff --git a/editeng/source/editeng/eertfpar.cxx b/editeng/source/editeng/eertfpar.cxx index d508716..70266d0 100644 --- a/editeng/source/editeng/eertfpar.cxx +++ b/editeng/source/editeng/eertfpar.cxx @@ -371,7 +371,7 @@ void EditRTFParser::SetAttrInDoc( SvxRTFItemStackType &rSet ) if ( rSet.StyleNo() && pImpEditEngine->GetStyleSheetPool() && pImpEditEngine->GetStatus().DoImportRTFStyleSheets() ) { - SvxRTFStyleType* pS = GetStyleTbl().Get( rSet.StyleNo() ); + SvxRTFStyleType* pS = GetStyleTbl()[ rSet.StyleNo() ]; DBG_ASSERT( pS, "Template not defined in RTF!" ); if ( pS ) { @@ -433,9 +433,11 @@ void EditRTFParser::SetAttrInDoc( SvxRTFItemStackType &rSet ) SvxRTFStyleType* EditRTFParser::FindStyleSheet( const XubString& rName ) { - SvxRTFStyleType* pS = GetStyleTbl().First(); - while ( pS && ( pS->sName != rName ) ) - pS = GetStyleTbl().Next(); + SvxRTFStyleTbl aTable = GetStyleTbl(); + SvxRTFStyleTbl::iterator it = aTable.begin(); + SvxRTFStyleType* pS = it->second; + while ( it != aTable.end() && ( (pS = it->second)->sName != rName ) ) + ++it; return pS; } @@ -451,7 +453,7 @@ SfxStyleSheet* EditRTFParser::CreateStyleSheet( SvxRTFStyleType* pRTFStyle ) String aParent; if ( pRTFStyle->nBasedOn ) { - SvxRTFStyleType* pS = GetStyleTbl().Get( pRTFStyle->nBasedOn ); + SvxRTFStyleType* pS = GetStyleTbl()[ pRTFStyle->nBasedOn ]; if ( pS && ( pS !=pRTFStyle ) ) aParent = pS->sName; } @@ -484,13 +486,11 @@ void EditRTFParser::CreateStyleSheets() // the SvxRTFParser haa now created the template... if ( pImpEditEngine->GetStyleSheetPool() && pImpEditEngine->GetStatus().DoImportRTFStyleSheets() ) { - SvxRTFStyleType* pRTFStyle = GetStyleTbl().First(); - while ( pRTFStyle ) - { - CreateStyleSheet( pRTFStyle ); - - pRTFStyle = GetStyleTbl().Next(); - } + SvxRTFStyleTbl aTable = GetStyleTbl(); + for (SvxRTFStyleTbl::iterator it = aTable.begin(); it != aTable.end(); ++it) + { + CreateStyleSheet( it->second ); + } } } diff --git a/editeng/source/misc/forbiddencharacterstable.cxx b/editeng/source/misc/forbiddencharacterstable.cxx index deb8d4d..f01c219 100644 --- a/editeng/source/misc/forbiddencharacterstable.cxx +++ b/editeng/source/misc/forbiddencharacterstable.cxx @@ -34,8 +34,8 @@ #include -SvxForbiddenCharactersTable::SvxForbiddenCharactersTable( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xMSF, sal_uInt16 nISize, sal_uInt16 nGrow ) - : SvxForbiddenCharactersTableImpl( nISize, nGrow ) +SvxForbiddenCharactersTable::SvxForbiddenCharactersTable( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xMSF ) + : maCharInfoMap() { mxMSF = xMSF; } @@ -43,21 +43,19 @@ SvxForbiddenCharactersTable::SvxForbiddenCharactersTable( ::com::sun::star::uno: SvxForbiddenCharactersTable::~SvxForbiddenCharactersTable() { - for ( sal_uLong n = Count(); n; ) - delete GetObject( --n ); + for (CharInfoMap::iterator it = maCharInfoMap.begin(); it != maCharInfoMap.end(); ++it) + delete it->second; } -const com::sun::star::i18n::ForbiddenCharacters* SvxForbiddenCharactersTable::GetForbiddenCharacters( sal_uInt16 nLanguage, sal_Bool bGetDefault ) const +const com::sun::star::i18n::ForbiddenCharacters* SvxForbiddenCharactersTable::GetForbiddenCharacters( sal_uInt16 nLanguage, sal_Bool bGetDefault ) { - ForbiddenCharactersInfo* pInf = Get( nLanguage ); + ForbiddenCharactersInfo* pInf = GetCharInfo( nLanguage ); if ( !pInf && bGetDefault && mxMSF.is() ) { - const SvxForbiddenCharactersTableImpl *pConstImpl = dynamic_cast(this); - SvxForbiddenCharactersTableImpl* pImpl = const_cast(pConstImpl); - pInf = new ForbiddenCharactersInfo; - pImpl->Insert( nLanguage, pInf ); + pInf = new ForbiddenCharactersInfo; + maCharInfoMap[ nLanguage ] = pInf; pInf->bTemporary = sal_True; LocaleDataWrapper aWrapper( mxMSF, SvxCreateLocale( nLanguage ) ); @@ -70,11 +68,11 @@ const com::sun::star::i18n::ForbiddenCharacters* SvxForbiddenCharactersTable::Ge void SvxForbiddenCharactersTable::SetForbiddenCharacters( sal_uInt16 nLanguage, const com::sun::star::i18n::ForbiddenCharacters& rForbiddenChars ) { - ForbiddenCharactersInfo* pInf = Get( nLanguage ); + ForbiddenCharactersInfo* pInf = GetCharInfo( nLanguage ); if ( !pInf ) { pInf = new ForbiddenCharactersInfo; - Insert( nLanguage, pInf ); + maCharInfoMap[ nLanguage ] = pInf; } pInf->bTemporary = sal_False; pInf->aForbiddenChars = rForbiddenChars; @@ -82,12 +80,20 @@ void SvxForbiddenCharactersTable::SetForbiddenCharacters( sal_uInt16 nLanguage, void SvxForbiddenCharactersTable::ClearForbiddenCharacters( sal_uInt16 nLanguage ) { - ForbiddenCharactersInfo* pInf = Get( nLanguage ); + ForbiddenCharactersInfo* pInf = GetCharInfo( nLanguage ); if ( pInf ) { - Remove( nLanguage ); + maCharInfoMap.erase( nLanguage ); delete pInf; } } +ForbiddenCharactersInfo* SvxForbiddenCharactersTable::GetCharInfo( sal_uInt16 nLanguage ) const +{ + CharInfoMap::const_iterator it = maCharInfoMap.find( nLanguage ); + if ( it == maCharInfoMap.end() ) + return NULL; + return it->second; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/editeng/source/misc/svxacorr.cxx b/editeng/source/misc/svxacorr.cxx index ac726c8..651b9eb 100644 --- a/editeng/source/misc/svxacorr.cxx +++ b/editeng/source/misc/svxacorr.cxx @@ -29,7 +29,6 @@ #include #include #include -#include #include #include #include diff --git a/editeng/source/rtf/svxrtf.cxx b/editeng/source/rtf/svxrtf.cxx index 8b9d93c..ffcaf3d 100644 --- a/editeng/source/rtf/svxrtf.cxx +++ b/editeng/source/rtf/svxrtf.cxx @@ -77,7 +77,6 @@ SvxRTFParser::SvxRTFParser( SfxItemPool& rPool, SvStream& rIn, int bReadNewDoc ) : SvRTFParser( rIn, 5 ), rStrm(rIn), - aFontTbl( 16, 4 ), pInsPos( 0 ), pAttrPool( &rPool ), m_xDocProps( i_xDocProps ), @@ -119,9 +118,9 @@ SvxRTFParser::~SvxRTFParser() { if( !aColorTbl.empty() ) ClearColorTbl(); - if( aFontTbl.Count() ) + if( !aFontTbl.empty() ) ClearFontTbl(); - if( aStyleTbl.Count() ) + if( !aStyleTbl.empty() ) ClearStyleTbl(); if( !aAttrStack.empty() ) ClearAttrStack(); @@ -149,9 +148,9 @@ SvParserState SvxRTFParser::CallParser() if( !aColorTbl.empty() ) ClearColorTbl(); - if( aFontTbl.Count() ) + if( !aFontTbl.empty() ) ClearFontTbl(); - if( aStyleTbl.Count() ) + if( !aStyleTbl.empty() ) ClearStyleTbl(); if( !aAttrStack.empty() ) ClearAttrStack(); @@ -194,7 +193,7 @@ void SvxRTFParser::NextToken( int nToken ) case RTF_DEFF: if( bNewDoc ) { - if( aFontTbl.Count() ) + if( !aFontTbl.empty() ) // Can immediately be set SetDefault( nToken, nTokenValue ); else @@ -385,14 +384,18 @@ void SvxRTFParser::ReadStyleTable() { pStyle->sName = DelCharAtEnd( aToken, ';' ); - if( aStyleTbl.Count() ) + if( !aStyleTbl.empty() ) { - SvxRTFStyleType* pOldSt = aStyleTbl.Remove( nStyleNo ); - if( pOldSt ) + SvxRTFStyleTbl::iterator it = aStyleTbl.find( nStyleNo ); + if( it != aStyleTbl.end() ) + { + SvxRTFStyleType* pOldSt = it->second; + aStyleTbl.erase( it ); delete pOldSt; + } } // All data from the font is available, so off to the table - aStyleTbl.Insert( nStyleNo, pStyle ); + aStyleTbl[ nStyleNo ] = pStyle; pStyle = new SvxRTFStyleType( *pAttrPool, &aWhichMap[0] ); pStyle->aAttrSet.Put( GetRTFDefaults() ); nStyleNo = 0; @@ -596,7 +599,7 @@ void SvxRTFParser::ReadFontTable() (sFntNm += ';' ) += sAltNm; pFont->SetName( sFntNm ); - aFontTbl.Insert( nInsFontNo, pFont ); + aFontTbl[ nInsFontNo ] = pFont; pFont = new Font(); pFont->SetCharSet( nSystemChar ); sAltNm.Erase(); @@ -798,14 +801,16 @@ void SvxRTFParser::ClearColorTbl() void SvxRTFParser::ClearFontTbl() { - for( sal_uInt32 nCnt = aFontTbl.Count(); nCnt; ) - delete aFontTbl.GetObject( --nCnt ); + for (SvxRTFFontTbl::iterator it = aFontTbl.begin(); it != aFontTbl.end(); ++it) + delete it->second; + aFontTbl.clear(); } void SvxRTFParser::ClearStyleTbl() { - for( sal_uInt32 nCnt = aStyleTbl.Count(); nCnt; ) - delete aStyleTbl.GetObject( --nCnt ); + for (SvxRTFStyleTbl::iterator it = aStyleTbl.begin(); it != aStyleTbl.end(); ++it) + delete it->second; + aStyleTbl.clear(); } void SvxRTFParser::ClearAttrStack() @@ -833,8 +838,9 @@ String& SvxRTFParser::DelCharAtEnd( String& rStr, const sal_Unicode cDel ) const Font& SvxRTFParser::GetFont( sal_uInt16 nId ) { - const Font* pFont = aFontTbl.Get( nId ); - if( !pFont ) + SvxRTFFontTbl::const_iterator it = aFontTbl.find( nId ); + const Font* pFont; + if( it == aFontTbl.end() ) { const SvxFontItem& rDfltFont = (const SvxFontItem&) pAttrPool->GetDefaultItem( @@ -843,6 +849,8 @@ const Font& SvxRTFParser::GetFont( sal_uInt16 nId ) pDfltFont->SetFamily( rDfltFont.GetFamily() ); pFont = pDfltFont; } + else + pFont = it->second; return *pFont; } @@ -872,10 +880,9 @@ void SvxRTFParser::_ClearStyleAttr( SvxRTFItemStackType& rStkType ) const SfxPoolItem* pItem; SfxWhichIter aIter( rSet ); - SvxRTFStyleType* pStyle; if( !IsChkStyleAttr() || !rStkType.GetAttrSet().Count() || - 0 == ( pStyle = aStyleTbl.Get( rStkType.nStyleNo ) )) + aStyleTbl.find( rStkType.nStyleNo ) == aStyleTbl.end() ) { for( sal_uInt16 nWhich = aIter.GetCurWhich(); nWhich; nWhich = aIter.NextWhich() ) { @@ -889,6 +896,7 @@ void SvxRTFParser::_ClearStyleAttr( SvxRTFItemStackType& rStkType ) { // Delete all Attributes, which are already defined in the Style, // from the current AttrSet. + SvxRTFStyleType* pStyle = aStyleTbl.find( rStkType.nStyleNo )->second; SfxItemSet &rStyleSet = pStyle->aAttrSet; const SfxPoolItem* pSItem; for( sal_uInt16 nWhich = aIter.GetCurWhich(); nWhich; nWhich = aIter.NextWhich() ) diff --git a/editeng/source/uno/UnoForbiddenCharsTable.cxx b/editeng/source/uno/UnoForbiddenCharsTable.cxx index 5bcbf35..2a704a1 100644 --- a/editeng/source/uno/UnoForbiddenCharsTable.cxx +++ b/editeng/source/uno/UnoForbiddenCharsTable.cxx @@ -117,18 +117,19 @@ Sequence< Locale > SAL_CALL SvxUnoForbiddenCharsTable::getLocales() { SolarMutexGuard aGuard; - const sal_Int32 nCount = mxForbiddenChars.is() ? mxForbiddenChars->Count() : 0; + const sal_Int32 nCount = mxForbiddenChars.is() ? mxForbiddenChars->Map().size() : 0; Sequence< Locale > aLocales( nCount ); if( nCount ) { Locale* pLocales = aLocales.getArray(); - for( sal_Int32 nIndex = 0; nIndex < nCount; nIndex++ ) - { - const sal_uLong nLanguage = mxForbiddenChars->GetObjectKey( nIndex ); + for( SvxForbiddenCharactersTable::CharInfoMap::iterator it = mxForbiddenChars->Map().begin(); + it != mxForbiddenChars->Map().end(); ++it) + { + const sal_uLong nLanguage = it->first; SvxLanguageToLocale ( *pLocales++, static_cast < LanguageType > (nLanguage) ); - } + } } return aLocales; diff --git a/sc/inc/chartpos.hxx b/sc/inc/chartpos.hxx index 4d3dccb..d18dd67 100644 --- a/sc/inc/chartpos.hxx +++ b/sc/inc/chartpos.hxx @@ -35,7 +35,9 @@ class ScAddress; -class Table; + +typedef ::std::map RowMap; +typedef ::std::map ColumnsMap; class ScChartPositionMap { @@ -51,7 +53,7 @@ class ScChartPositionMap ScChartPositionMap( SCCOL nChartCols, SCROW nChartRows, SCCOL nColAdd, // header columns SCROW nRowAdd, // header rows - Table& rCols // table with col tables with address* + ColumnsMap& rCols // table with col tables with address* ); ~ScChartPositionMap(); //! deletes all ScAddress* diff --git a/sc/source/core/tool/chartpos.cxx b/sc/source/core/tool/chartpos.cxx index 5b7617a..f90da31 100644 --- a/sc/source/core/tool/chartpos.cxx +++ b/sc/source/core/tool/chartpos.cxx @@ -29,7 +29,7 @@ // INCLUDE --------------------------------------------------------------- -#include +#include #include "chartpos.hxx" #include "document.hxx" @@ -354,7 +354,6 @@ const ScChartPositionMap* ScChartPositioner::GetPositionMap() return pPositionMap; } - void ScChartPositioner::CreatePositionMap() { if ( eGlue == SC_CHARTGLUE_NA && pPositionMap ) @@ -383,10 +382,10 @@ void ScChartPositioner::CreatePositionMap() GlueState(); sal_Bool bNoGlue = (eGlue == SC_CHARTGLUE_NONE); - Table* pCols = new Table; - Table* pNewRowTable = new Table; + ColumnsMap aCols; + RowMap* pNewRowTable; ScAddress* pNewAddress = new ScAddress; - Table* pCol; + RowMap* pCol; ScAddress* pPos; SCROW nNoGlueRow = 0; for ( size_t i = 0, nRanges = aRangeListRef->size(); i < nRanges; ++i ) @@ -402,30 +401,35 @@ void ScChartPositioner::CreatePositionMap() { if ( bNoGlue || eGlue == SC_CHARTGLUE_ROWS ) { // meistens gleiche Cols - if ( (pCol = (Table*) pCols->Get( nInsCol ))==NULL ) + ColumnsMap::iterator it = aCols.find( nInsCol ); + if ( it == aCols.end() ) { - pCols->Insert( nInsCol, pNewRowTable ); + aCols[ nInsCol ] = pNewRowTable; pCol = pNewRowTable; - pNewRowTable = new Table; + pNewRowTable = new RowMap; } + else + pCol = it->second; } else { // meistens neue Cols - if ( pCols->Insert( nInsCol, pNewRowTable ) ) + if ( aCols.count( nInsCol ) == 0) { + aCols[ nInsCol ] = pNewRowTable; pCol = pNewRowTable; - pNewRowTable = new Table; + pNewRowTable = new RowMap; } else - pCol = (Table*) pCols->Get( nInsCol ); + pCol = aCols.find( nInsCol )->second; } // bei anderer Tabelle wurde bereits neuer ColKey erzeugt, // die Zeilen muessen fuer's Dummy fuellen gleich sein! sal_uLong nInsRow = (bNoGlue ? nNoGlueRow : nRow1); for ( nRow = nRow1; nRow <= nRow2; nRow++, nInsRow++ ) { - if ( pCol->Insert( nInsRow, pNewAddress ) ) + if ( pCol->count( nInsRow ) == 0) { + (*pCol)[ nInsRow ] = pNewAddress; pNewAddress->Set( nCol, nRow, nTab ); pNewAddress = new ScAddress; } @@ -439,15 +443,19 @@ void ScChartPositioner::CreatePositionMap() delete pNewRowTable; // Anzahl der Daten - nColCount = static_cast< SCSIZE >( pCols->Count()); - if ( (pCol = (Table*) pCols->First())!=NULL ) + nColCount = static_cast< SCSIZE >( aCols.size()); + if ( nColCount ) { + pCol = aCols.begin()->second; if ( bDummyUpperLeft ) - pCol->Insert( 0, (void*)0 ); // Dummy fuer Beschriftung - nRowCount = static_cast< SCSIZE >( pCol->Count()); + (*pCol)[ 0 ] = NULL; // Dummy fuer Beschriftung + nRowCount = static_cast< SCSIZE >( pCol->size()); } else + { + pCol = NULL; nRowCount = 0; + } if ( nColCount > 0 ) nColCount -= nColAdd; if ( nRowCount > 0 ) @@ -455,25 +463,25 @@ void ScChartPositioner::CreatePositionMap() if ( nColCount==0 || nRowCount==0 ) { // einen Eintrag ohne Daten erzeugen - if ( pCols->Count() > 0 ) - pCol = (Table*) pCols->First(); + if ( !aCols.empty() ) + pCol = aCols.begin()->second; else { - pCol = new Table; - pCols->Insert( 0, pCol ); + pCol = new RowMap; + aCols[ 0 ] = pCol; } nColCount = 1; - if ( pCol->Count() > 0 ) + if ( !pCol->empty() ) { // kann ja eigentlich nicht sein, wenn nColCount==0 || nRowCount==0 - pPos = (ScAddress*) pCol->First(); + pPos = pCol->begin()->second; if ( pPos ) { delete pPos; - pCol->Replace( pCol->GetCurKey(), (void*)0 ); + (*pCol)[ pCol->begin()->first ] = NULL; } } else - pCol->Insert( 0, (void*)0 ); + (*pCol)[ 0 ] = NULL; nRowCount = 1; nColAdd = 0; nRowAdd = 0; @@ -482,33 +490,29 @@ void ScChartPositioner::CreatePositionMap() { if ( bNoGlue ) { // Luecken mit Dummies fuellen, erste Spalte ist Master - Table* pFirstCol = (Table*) pCols->First(); - sal_uLong nCount = pFirstCol->Count(); - pFirstCol->First(); - for ( sal_uLong n = 0; n < nCount; n++, pFirstCol->Next() ) - { - sal_uLong nKey = pFirstCol->GetCurKey(); - pCols->First(); - while ( (pCol = (Table*) pCols->Next())!=NULL ) - pCol->Insert( nKey, (void*)0 ); // keine Daten - } + RowMap* pFirstCol = aCols.begin()->second; + for (RowMap::iterator it = pFirstCol->begin(); it != pFirstCol->end(); ++it) + { + sal_uLong nKey = it->first; + for (ColumnsMap::iterator it2 = aCols.begin(); it2 != aCols.end(); ++it2) + (*(it2->second))[ nKey ] = NULL; // keine Daten + } } } pPositionMap = new ScChartPositionMap( static_cast(nColCount), static_cast(nRowCount), - static_cast(nColAdd), static_cast(nRowAdd), *pCols ); + static_cast(nColAdd), static_cast(nRowAdd), aCols ); // Aufraeumen - for ( pCol = (Table*) pCols->First(); pCol; pCol = (Table*) pCols->Next() ) + for (ColumnsMap::iterator it = aCols.begin(); it != aCols.end(); ++it) { //! nur Tables loeschen, nicht die ScAddress* - delete pCol; - } - delete pCols; + delete it->second; + } } ScChartPositionMap::ScChartPositionMap( SCCOL nChartCols, SCROW nChartRows, - SCCOL nColAdd, SCROW nRowAdd, Table& rCols ) : + SCCOL nColAdd, SCROW nRowAdd, ColumnsMap& rCols ) : ppData( new ScAddress* [ nChartCols * nChartRows ] ), ppColHeader( new ScAddress* [ nChartCols ] ), ppRowHeader( new ScAddress* [ nChartRows ] ), @@ -522,18 +526,23 @@ ScChartPositionMap::ScChartPositionMap( SCCOL nChartCols, SCROW nChartRows, SCCOL nCol; SCROW nRow; - Table* pCol = (Table*) rCols.First(); + ColumnsMap::iterator aColumnsMapIter = rCols.begin(); + RowMap::iterator aColIter = aColumnsMapIter->second->begin(); // Zeilen-Header - pPos = (ScAddress*) pCol->First(); + pPos = aColIter->second; if ( nRowAdd ) - pPos = (ScAddress*) pCol->Next(); + { + ++aColIter; + pPos = aColIter->second; + } if ( nColAdd ) { // eigenstaendig for ( nRow = 0; nRow < nRowCount; nRow++ ) { ppRowHeader[ nRow ] = pPos; - pPos = (ScAddress*) pCol->Next(); + ++aColIter; + pPos = aColIter->second; } } else @@ -541,30 +550,37 @@ ScChartPositionMap::ScChartPositionMap( SCCOL nChartCols, SCROW nChartRows, for ( nRow = 0; nRow < nRowCount; nRow++ ) { ppRowHeader[ nRow ] = ( pPos ? new ScAddress( *pPos ) : NULL ); - pPos = (ScAddress*) pCol->Next(); + ++aColIter; + pPos = aColIter->second; } } if ( nColAdd ) - pCol = (Table*) rCols.Next(); + { + ++aColumnsMapIter; + aColIter = aColumnsMapIter->second->begin(); + } // Daten spaltenweise und Spalten-Header sal_uLong nIndex = 0; for ( nCol = 0; nCol < nColCount; nCol++ ) { - if ( pCol ) + if ( aColIter != aColumnsMapIter->second->end()) { - pPos = (ScAddress*) pCol->First(); + aColIter = aColumnsMapIter->second->begin(); + pPos = aColIter->second; if ( nRowAdd ) { ppColHeader[ nCol ] = pPos; // eigenstaendig - pPos = (ScAddress*) pCol->Next(); + ++aColIter; + pPos = aColIter->second; } else ppColHeader[ nCol ] = ( pPos ? new ScAddress( *pPos ) : NULL ); for ( nRow = 0; nRow < nRowCount; nRow++, nIndex++ ) { ppData[ nIndex ] = pPos; - pPos = (ScAddress*) pCol->Next(); + ++aColIter; + pPos = aColIter->second; } } else @@ -575,7 +591,8 @@ ScChartPositionMap::ScChartPositionMap( SCCOL nChartCols, SCROW nChartRows, ppData[ nIndex ] = NULL; } } - pCol = (Table*) rCols.Next(); + ++aColumnsMapIter; + aColIter = aColumnsMapIter->second->begin(); } } diff --git a/sc/source/filter/html/htmlpars.cxx b/sc/source/filter/html/htmlpars.cxx index 323e1a2..e49eb80 100644 --- a/sc/source/filter/html/htmlpars.cxx +++ b/sc/source/filter/html/htmlpars.cxx @@ -229,7 +229,6 @@ ScHTMLLayoutParser::ScHTMLLayoutParser( aPageSize( aPageSizeP ), aBaseURL( rBaseURL ), xLockedList( new ScRangeList ), - pTables( NULL ), pColOffset( new ScHTMLColOffset ), pLocalColOffset( new ScHTMLColOffset ), nFirstTableCell(0), @@ -279,11 +278,10 @@ ScHTMLLayoutParser::~ScHTMLLayoutParser() delete pLocalColOffset; if ( pColOffset ) delete pColOffset; - if ( pTables ) + if ( !maTables.empty() ) { - for ( Table* pT = (Table*) pTables->First(); pT; pT = (Table*) pTables->Next() ) - delete pT; - delete pTables; + for ( TablesMap::iterator it = maTables.begin(); it != maTables.end(); ++it ) + delete it->second; } } @@ -331,7 +329,7 @@ sal_uLong ScHTMLLayoutParser::Read( SvStream& rStream, const String& rBaseURL ) { aSize.Width() = *pOff - nOff; aSize = pDefaultDev->PixelToLogic( aSize, MapMode( MAP_TWIP ) ); - pColWidths->Insert( j-1, (void*)aSize.Width() ); + maColWidths[ j-1 ] = aSize.Width(); nOff = *pOff; } return nErr; @@ -538,7 +536,7 @@ void ScHTMLLayoutParser::Adjust() SCROW nNextRow = 0; SCROW nCurRow = 0; sal_uInt16 nPageWidth = (sal_uInt16) aPageSize.Width(); - Table* pTab = NULL; + RowMap* pTab = NULL; for ( size_t i = 0, nListSize = maList.size(); i < nListSize; ++i ) { ScEEParseEntry* pE = maList[ i ]; @@ -555,7 +553,7 @@ void ScHTMLLayoutParser::Adjust() } delete pS; nTab = pE->nTab; - pTab = (pTables ? (Table*) pTables->Get( nTab ) : NULL); + pTab = GetRowMap( nTab ); } SCROW nRow = pE->nRow; @@ -566,7 +564,7 @@ void ScHTMLLayoutParser::Adjust() else nCurRow = nNextRow = pE->nRow; SCROW nR; - if ( pTab && ((nR = (SCROW)(sal_uLong)pTab->Get( nCurRow )) != 0) ) + if ( pTab && ((nR = GetRow( pTab, nCurRow )) != 0) ) nNextRow += nR; else nNextRow++; @@ -579,10 +577,10 @@ void ScHTMLLayoutParser::Adjust() aStack.push( new ScHTMLAdjustStackEntry( nLastCol, nNextRow, nCurRow ) ); nTab = pE->nTab; - pTab = (pTables ? (Table*) pTables->Get( nTab ) : NULL); + pTab = GetRowMap( nTab ); // neuer Zeilenabstand SCROW nR; - if ( pTab && ((nR = (SCROW)(sal_uLong)pTab->Get( nCurRow )) != 0) ) + if ( pTab && ((nR = GetRow( pTab, nCurRow )) != 0) ) nNextRow = nCurRow + nR; else nNextRow = nCurRow + 1; @@ -596,7 +594,7 @@ void ScHTMLLayoutParser::Adjust() SCROW nRowSpan = pE->nRowOverlap; for ( SCROW j=0; j < nRowSpan; j++ ) { // aus merged Zeilen resultierendes RowSpan - SCROW nRows = (SCROW)(sal_uLong)pTab->Get( nRow+j ); + SCROW nRows = GetRow( pTab, nRow+j ); if ( nRows > 1 ) { pE->nRowOverlap += nRows - 1; @@ -1227,14 +1225,12 @@ void ScHTMLLayoutParser::TableOff( ImportInfo* pInfo ) { // Groesse der Tabelle an dieser Position eintragen SCROW nRow = pS->nRowCnt; sal_uInt16 nTab = pS->nTable; - if ( !pTables ) - pTables = new Table; // Hoehen der aeusseren Table - Table* pTab1 = (Table*) pTables->Get( nTab ); + RowMap* pTab1 = GetRowMap( nTab ); if ( !pTab1 ) { - pTab1 = new Table; - pTables->Insert( nTab, pTab1 ); + pTab1 = new RowMap; + maTables[ nTab ] = pTab1; } SCROW nRowSpan = pE->nRowOverlap; SCROW nRowKGV; @@ -1252,11 +1248,11 @@ void ScHTMLLayoutParser::TableOff( ImportInfo* pInfo ) nRowKGV = nRowsPerRow1 = nRows; nRowsPerRow2 = 1; } - Table* pTab2 = NULL; + RowMap* pTab2 = NULL; if ( nRowsPerRow2 > 1 ) { // Hoehen der inneren Table - pTab2 = new Table; - pTables->Insert( nTable, pTab2 ); + pTab2 = new RowMap; + maTables[ nTable ] = pTab2; } // void* Data-Entry der Table-Class fuer das // Hoehen-Mapping missbrauchen @@ -1267,11 +1263,11 @@ void ScHTMLLayoutParser::TableOff( ImportInfo* pInfo ) for ( SCROW j=0; j < nRowSpan; j++ ) { sal_uLong nRowKey = nRow + j; - SCROW nR = (SCROW)(sal_uLong)pTab1->Get( nRowKey ); + SCROW nR = GetRow( pTab1, nRowKey ); if ( !nR ) - pTab1->Insert( nRowKey, (void*)(sal_IntPtr)nRowsPerRow1 ); + (*pTab1)[ nRowKey ] = nRowsPerRow1; else if ( nRowsPerRow1 > nR ) - pTab1->Replace( nRowKey, (void*)(sal_IntPtr)nRowsPerRow1 ); + (*pTab1)[ nRowKey ] = nRowsPerRow1; //2do: wie geht das noch besser? else if ( nRowsPerRow1 < nR && nRowSpan == 1 && nTable == nMaxTable ) @@ -1280,11 +1276,11 @@ void ScHTMLLayoutParser::TableOff( ImportInfo* pInfo ) nR += nAdd; if ( (nR % nRows) == 0 ) { // nur wenn abbildbar - SCROW nR2 = (SCROW)(sal_uLong)pTab1->Get( nRowKey+1 ); + SCROW nR2 = GetRow( pTab1, nRowKey+1 ); if ( nR2 > nAdd ) { // nur wenn wirklich Platz - pTab1->Replace( nRowKey, (void*)(sal_IntPtr)nR ); - pTab1->Replace( nRowKey+1, (void*)(sal_IntPtr)(nR2 - nAdd) ); + (*pTab1)[ nRowKey ] = nR; + (*pTab1)[ nRowKey+1 ] = nR2 - nAdd; nRowsPerRow2 = nR / nRows; } } @@ -1295,17 +1291,17 @@ void ScHTMLLayoutParser::TableOff( ImportInfo* pInfo ) { // innen if ( !pTab2 ) { // nRowsPerRow2 kann erhoeht worden sein - pTab2 = new Table; - pTables->Insert( nTable, pTab2 ); + pTab2 = new RowMap; + maTables[ nTable ] = pTab2; } for ( SCROW j=0; j < nRows; j++ ) { sal_uLong nRowKey = nRow + j; - SCROW nR = (SCROW)(sal_uLong)pTab2->Get( nRowKey ); + SCROW nR = GetRow( pTab2, nRowKey ); if ( !nR ) - pTab2->Insert( nRowKey, (void*)(sal_IntPtr)nRowsPerRow2 ); + (*pTab2)[ nRowKey ] = nRowsPerRow2; else if ( nRowsPerRow2 > nR ) - pTab2->Replace( nRowKey, (void*)(sal_IntPtr)nRowsPerRow2 ); + (*pTab2)[ nRowKey ] = nRowsPerRow2; } } } @@ -1368,6 +1364,21 @@ void ScHTMLLayoutParser::TableOff( ImportInfo* pInfo ) } } +ScHTMLLayoutParser::RowMap* ScHTMLLayoutParser::GetRowMap(int nTab) const +{ + TablesMap::const_iterator it = maTables.find( nTab ); + if ( it == maTables.end() ) + return NULL; + return it->second; +} + +SCROW ScHTMLLayoutParser::GetRow(RowMap* pRowMap, SCROW nRow) +{ + RowMap::const_iterator it = pRowMap->find( nRow ); + if ( it == pRowMap->end() ) + return 0; + return it->second; +} void ScHTMLLayoutParser::Image( ImportInfo* pInfo ) { diff --git a/sc/source/filter/inc/eeparser.hxx b/sc/source/filter/inc/eeparser.hxx index dc1daf1..88b0a51 100644 --- a/sc/source/filter/inc/eeparser.hxx +++ b/sc/source/filter/inc/eeparser.hxx @@ -32,12 +32,12 @@ #include #include #include -#include #include #include #include #include #include +#include const sal_Char nHorizontal = 1; const sal_Char nVertical = 2; @@ -110,13 +110,15 @@ class EditEngine; class ScEEParser { +public: + typedef std::map ColumnWidthsMap; protected: EditEngine* pEdit; SfxItemPool* pPool; SfxItemPool* pDocPool; ::std::vector< ScEEParseEntry* > maList; ScEEParseEntry* pActEntry; - Table* pColWidths; + ColumnWidthsMap maColWidths; int nLastToken; SCCOL nColCnt; SCROW nRowCnt; @@ -131,7 +133,7 @@ public: virtual sal_uLong Read( SvStream&, const String& rBaseURL ) = 0; - Table* GetColWidths() const { return pColWidths; } + ColumnWidthsMap& GetColWidths() { return maColWidths; } void GetDimensions( SCCOL& nCols, SCROW& nRows ) const { nCols = nColMax; nRows = nRowMax; } diff --git a/sc/source/filter/inc/htmlpars.hxx b/sc/source/filter/inc/htmlpars.hxx index b8846c4..5d78221 100644 --- a/sc/source/filter/inc/htmlpars.hxx +++ b/sc/source/filter/inc/htmlpars.hxx @@ -167,13 +167,16 @@ class HTMLOption; class ScHTMLLayoutParser : public ScHTMLParser { +public: + typedef std::map RowMap; + typedef std::map TablesMap; private: Size aPageSize; rtl::OUString aBaseURL; ScHTMLTableStack aTableStack; rtl::OUString aString; ScRangeListRef xLockedList; // je Table - Table* pTables; + TablesMap maTables; ScHTMLColOffset* pColOffset; ScHTMLColOffset* pLocalColOffset; // je Table sal_uLong nFirstTableCell; // je Table @@ -228,6 +231,9 @@ private: void AnchorOn( ImportInfo* ); void FontOn( ImportInfo* ); + RowMap* GetRowMap(int nTab) const; + static SCROW GetRow(RowMap*, SCROW); + public: ScHTMLLayoutParser( EditEngine*, const String& rBaseURL, const Size& aPageSize, ScDocument* ); virtual ~ScHTMLLayoutParser(); diff --git a/sc/source/filter/rtf/eeimpars.cxx b/sc/source/filter/rtf/eeimpars.cxx index 2fb0484..145958a 100644 --- a/sc/source/filter/rtf/eeimpars.cxx +++ b/sc/source/filter/rtf/eeimpars.cxx @@ -431,16 +431,15 @@ void ScEEImport::WriteToDocument( sal_Bool bSizeColsRows, double nOutputFactor, if ( bSizeColsRows ) { // Spaltenbreiten - Table* pColWidths = mpParser->GetColWidths(); - if ( pColWidths->Count() ) + ScEEParser::ColumnWidthsMap& rColWidths = mpParser->GetColWidths(); + if ( !rColWidths.empty() ) { nProgress = 0; pProgress->SetState( nProgress, nEndCol - nStartCol + 1 ); for ( SCCOL nCol = nStartCol; nCol <= nEndCol; nCol++ ) { - sal_uInt16 nWidth = (sal_uInt16)(sal_uLong) pColWidths->Get( nCol ); - if ( nWidth ) - mpDoc->SetColWidth( nCol, nTab, nWidth ); + if ( rColWidths.find( nCol ) != rColWidths.end() ) + mpDoc->SetColWidth( nCol, nTab, rColWidths.find( nCol )->second ); pProgress->SetState( ++nProgress ); } } @@ -513,20 +512,23 @@ sal_Bool ScEEImport::GraphicSize( SCCOL nCol, SCROW nRow, SCTAB /*nTab*/, ScEEPa nDir = pI->nDir; } // Spaltenbreiten - Table* pColWidths = mpParser->GetColWidths(); - long nThisWidth = (long) pColWidths->Get( nCol ); + ScEEParser::ColumnWidthsMap& rColWidths = mpParser->GetColWidths(); + long nThisWidth = 0; + if ( rColWidths.find( nCol ) != rColWidths.end() ) + nThisWidth = (long) rColWidths.find( nCol )->second; long nColWidths = nThisWidth; SCCOL nColSpanCol = nCol + pE->nColOverlap; for ( SCCOL nC = nCol + 1; nC < nColSpanCol; nC++ ) { - nColWidths += (long) pColWidths->Get( nC ); + if ( rColWidths.find( nC ) != rColWidths.end() ) + nColWidths += (long) rColWidths.find( nC )->second; } if ( nWidth > nColWidths ) { // Differenz nur in der ersten Spalte eintragen if ( nThisWidth ) - pColWidths->Replace( nCol, (void*)(nWidth - nColWidths + nThisWidth) ); + rColWidths[ nCol ] = nWidth - nColWidths + nThisWidth; else - pColWidths->Insert( nCol, (void*)(nWidth - nColWidths) ); + rColWidths[ nCol ] = nWidth - nColWidths; } // Zeilenhoehen, Differenz auf alle betroffenen Zeilen verteilen SCROW nRowSpan = pE->nRowOverlap; @@ -619,7 +621,6 @@ ScEEParser::ScEEParser( EditEngine* pEditP ) : pEdit( pEditP ), pPool( EditEngine::CreatePool() ), pDocPool( new ScDocumentPool ), - pColWidths( new Table ), nLastToken(0), nColCnt(0), nRowCnt(0), @@ -636,7 +637,6 @@ ScEEParser::ScEEParser( EditEngine* pEditP ) : ScEEParser::~ScEEParser() { delete pActEntry; - delete pColWidths; if ( !maList.empty() ) maList.clear(); // Pool erst loeschen nachdem die Listen geloescht wurden diff --git a/sc/source/ui/unoobj/chart2uno.cxx b/sc/source/ui/unoobj/chart2uno.cxx index 0317f94..1149b58 100644 --- a/sc/source/ui/unoobj/chart2uno.cxx +++ b/sc/source/ui/unoobj/chart2uno.cxx @@ -46,8 +46,9 @@ #include "formula/opcode.hxx" +#include + #include -#include #include #include diff --git a/sw/source/filter/rtf/rtffld.cxx b/sw/source/filter/rtf/rtffld.cxx index 51741e1..62f5fcb 100644 --- a/sw/source/filter/rtf/rtffld.cxx +++ b/sw/source/filter/rtf/rtffld.cxx @@ -595,8 +595,9 @@ int SwRTFParser::MakeFieldInst( String& rFieldStr ) // Font setzen { SvxRTFFontTbl& rTbl = GetFontTbl(); - for( Font* pFont = rTbl.First(); pFont; - pFont = rTbl.Next() ) + for(SvxRTFFontTbl::iterator it = rTbl.begin(); it != rTbl.end(); ++it) + { + Font* pFont = it->second; if( pFont->GetName() == sParam ) { rSet.Put( SvxFontItem( @@ -608,6 +609,7 @@ int SwRTFParser::MakeFieldInst( String& rFieldStr ) RES_CHRATR_FONT )); break; } + } } break; case 'h': case 'H': diff --git a/sw/source/filter/rtf/rtfnum.cxx b/sw/source/filter/rtf/rtfnum.cxx index 07b3319..40b5101 100644 --- a/sw/source/filter/rtf/rtfnum.cxx +++ b/sw/source/filter/rtf/rtfnum.cxx @@ -585,7 +585,7 @@ void SwRTFParser::ReadListOverrideTable() } // search the outline numrule and set it into the doc - if( GetStyleTbl().Count() ) + if( !GetStyleTbl().empty() ) { if( !bStyleTabValid ) MakeStyleTab(); @@ -594,11 +594,12 @@ void SwRTFParser::ReadListOverrideTable() std::map::const_iterator iterColl; sal_uInt16 nRulePos( USHRT_MAX ); const SwNumRule *pNumRule = 0; - SvxRTFStyleType* pStyle = GetStyleTbl().First(); - do { + for(SvxRTFStyleTbl::iterator it = GetStyleTbl().begin(); it != GetStyleTbl().end(); ++it) + { + SvxRTFStyleType* pStyle = it->second; if ( MAXLEVEL > pStyle->nOutlineNo ) { - iterColl = aTxtCollTbl.find( (sal_uInt16)GetStyleTbl().GetCurKey() ); + iterColl = aTxtCollTbl.find( it->first ); if ( iterColl != aTxtCollTbl.end() ) { const SfxItemState eItemState = @@ -634,8 +635,7 @@ void SwRTFParser::ReadListOverrideTable() } pStyle->aAttrSet.ClearItem( FN_PARAM_NUM_LEVEL ); - - } while( 0 != (pStyle = GetStyleTbl().Next()) ); + } } SkipToken( -1 ); // die schliesende Klammer wird "oben" ausgewertet @@ -723,17 +723,15 @@ void SwRTFParser::RemoveUnusedNumRules() const Font* SwRTFParser::FindFontOfItem( const SvxFontItem& rItem ) const { SvxRTFFontTbl& rFntTbl = ((SwRTFParser*)this)->GetFontTbl(); - const Font* pFnt = rFntTbl.First(); - while( pFnt ) + for(SvxRTFFontTbl::const_iterator it = rFntTbl.begin(); it != rFntTbl.end(); ++it) { + const Font* pFnt = it->second; if( pFnt->GetFamily() == rItem.GetFamily() && pFnt->GetName() == rItem.GetFamilyName() && pFnt->GetStyleName() == rItem.GetStyleName() && pFnt->GetPitch() == rItem.GetPitch() && pFnt->GetCharSet() == rItem.GetCharSet() ) return pFnt; - - pFnt = rFntTbl.Next(); } return 0; } diff --git a/sw/source/filter/rtf/swparrtf.cxx b/sw/source/filter/rtf/swparrtf.cxx index 81abb16..7c90295 100644 --- a/sw/source/filter/rtf/swparrtf.cxx +++ b/sw/source/filter/rtf/swparrtf.cxx @@ -2195,8 +2195,9 @@ void SwRTFParser::SetAttrInDoc( SvxRTFItemStackType &rSet ) ((SwFmtCharFmt*)pCharFmt)->GetCharFmt() ) { const String& rName = ((SwFmtCharFmt*)pCharFmt)->GetCharFmt()->GetName(); - SvxRTFStyleType* pStyle = GetStyleTbl().First(); - do { + for(SvxRTFStyleTbl::iterator it = GetStyleTbl().begin(); it != GetStyleTbl().end(); ++it) + { + SvxRTFStyleType* pStyle = it->second; if( pStyle->bIsCharFmt && pStyle->sName == rName ) { // alle Attribute, die schon vom Style definiert sind, aus dem @@ -2218,7 +2219,7 @@ void SwRTFParser::SetAttrInDoc( SvxRTFItemStackType &rSet ) } break; } - } while( 0 != (pStyle = GetStyleTbl().Next()) ); + } pDoc->InsertPoolItem(aPam, *pCharFmt, 0); rSet.GetAttrSet().ClearItem(RES_TXTATR_CHARFMT); //test hack @@ -2734,7 +2735,7 @@ void SwRTFParser::ReadDocControls( int nToken ) void SwRTFParser::MakeStyleTab() { // dann erzeuge aus der SvxStyle-Tabelle die Swg-Collections - if( GetStyleTbl().Count() ) + if( !GetStyleTbl().empty() ) { sal_uInt16 nValidOutlineLevels = 0; if( !IsNewDoc() ) @@ -2746,9 +2747,10 @@ void SwRTFParser::MakeStyleTab() nValidOutlineLevels |= 1 << rColls[ n ]->GetAssignedOutlineStyleLevel();//<-end,zhaojianwei } - SvxRTFStyleType* pStyle = GetStyleTbl().First(); - do { - sal_uInt16 nNo = sal_uInt16( GetStyleTbl().GetCurKey() ); + for(SvxRTFStyleTbl::iterator it = GetStyleTbl().begin(); it != GetStyleTbl().end(); ++it) + { + SvxRTFStyleType* pStyle = it->second; + sal_uInt16 nNo = it->first; if( pStyle->bIsCharFmt ) { if(aCharFmtTbl.find( nNo ) == aCharFmtTbl.end()) @@ -2761,7 +2763,7 @@ void SwRTFParser::MakeStyleTab() MakeStyle( nNo, *pStyle ); } - } while( 0 != (pStyle = GetStyleTbl().Next()) ); + } bStyleTabValid = sal_True; } } @@ -3996,7 +3998,9 @@ SwTxtFmtColl* SwRTFParser::MakeStyle( sal_uInt16 nNo, const SvxRTFStyleType& rSt sal_uInt16 nStyleNo = rStyle.nBasedOn; if( rStyle.bBasedOnIsSet && nStyleNo != nNo ) { - SvxRTFStyleType* pDerivedStyle = GetStyleTbl().Get( nStyleNo ); + SvxRTFStyleType* pDerivedStyle = NULL; + if ( GetStyleTbl().find( nStyleNo ) != GetStyleTbl().end()) + pDerivedStyle = GetStyleTbl().find( nStyleNo )->second; SwTxtFmtColl* pDerivedColl = NULL; std::map::iterator iter = aTxtCollTbl.find(nStyleNo); @@ -4041,7 +4045,10 @@ SwTxtFmtColl* SwRTFParser::MakeStyle( sal_uInt16 nNo, const SvxRTFStyleType& rSt if( iter == aTxtCollTbl.end()) // noch nicht vorhanden, also anlegen { // ist die ueberhaupt als Style vorhanden ? - SvxRTFStyleType* pMkStyle = GetStyleTbl().Get( nStyleNo ); + SvxRTFStyleType* pMkStyle = NULL; + if ( GetStyleTbl().find( nStyleNo ) != GetStyleTbl().end() ) + pMkStyle = GetStyleTbl().find( nStyleNo )->second; + pNext = pMkStyle ? MakeStyle( nStyleNo, *pMkStyle ) : pDoc->GetTxtCollFromPool( RES_POOLCOLL_STANDARD, false ); @@ -4067,7 +4074,10 @@ SwCharFmt* SwRTFParser::MakeCharStyle( sal_uInt16 nNo, const SvxRTFStyleType& rS sal_uInt16 nStyleNo = rStyle.nBasedOn; if( rStyle.bBasedOnIsSet && nStyleNo != nNo ) { - SvxRTFStyleType* pDerivedStyle = GetStyleTbl().Get( nStyleNo ); + SvxRTFStyleType* pDerivedStyle = NULL; + if ( GetStyleTbl().find( nStyleNo ) != GetStyleTbl().end() ) + pDerivedStyle = GetStyleTbl().find( nStyleNo )->second; + SwCharFmt* pDerivedFmt = NULL; std::map::iterator iter = aCharFmtTbl.find( nStyleNo ); diff --git a/sw/source/ui/docvw/srcedtw.cxx b/sw/source/ui/docvw/srcedtw.cxx index 9bd534c..01166f4 100644 --- a/sw/source/ui/docvw/srcedtw.cxx +++ b/sw/source/ui/docvw/srcedtw.cxx @@ -604,16 +604,15 @@ IMPL_LINK( SwSrcEditWindow, SyntaxTimerHdl, Timer *, pTimer ) nCur -= 40; else nCur = 0; - if(aSyntaxLineTable.Count()) + if(!maSyntaxLineTable.empty()) for(sal_uInt16 i = 0; i < 80 && nCount < 40; i++, nCur++) { - void * p = aSyntaxLineTable.Get(nCur); - if(p) + if( maSyntaxLineTable.find( nCur ) != maSyntaxLineTable.end()) { DoSyntaxHighlight( nCur ); - aSyntaxLineTable.Remove( nCur ); + maSyntaxLineTable.erase( nCur ); nCount++; - if(!aSyntaxLineTable.Count()) + if(maSyntaxLineTable.empty()) break; if((Time( Time::SYSTEM ).GetTime() - aSyntaxCheckStart.GetTime()) > MAX_HIGHLIGHTTIME ) { @@ -624,14 +623,12 @@ IMPL_LINK( SwSrcEditWindow, SyntaxTimerHdl, Timer *, pTimer ) } // when there is still anything left by then, go on from the beginning - void* p = aSyntaxLineTable.First(); - while ( p && nCount < MAX_SYNTAX_HIGHLIGHT) + while ( !maSyntaxLineTable.empty() && nCount < MAX_SYNTAX_HIGHLIGHT) { - nLine = (sal_uInt16)aSyntaxLineTable.GetCurKey(); + SyntaxLineTable::iterator it = maSyntaxLineTable.begin(); + nLine = *it; DoSyntaxHighlight( nLine ); - sal_uInt16 nCurKey = (sal_uInt16)aSyntaxLineTable.GetCurKey(); - p = aSyntaxLineTable.Next(); - aSyntaxLineTable.Remove(nCurKey); + maSyntaxLineTable.erase(it); nCount ++; if(Time( Time::SYSTEM ).GetTime() - aSyntaxCheckStart.GetTime() > MAX_HIGHLIGHTTIME) { @@ -640,7 +637,7 @@ IMPL_LINK( SwSrcEditWindow, SyntaxTimerHdl, Timer *, pTimer ) } } - if(aSyntaxLineTable.Count() && !pTimer->IsActive()) + if(!maSyntaxLineTable.empty() && !pTimer->IsActive()) pTimer->Start(); // SyntaxTimerHdl is called when text changed // => good opportunity to determine text width! @@ -681,7 +678,7 @@ void SwSrcEditWindow::DoDelayedSyntaxHighlight( sal_uInt16 nPara ) { if ( !bHighlighting && bDoSyntaxHighlight ) { - aSyntaxLineTable.Insert( nPara, (void*)(sal_uInt16)1 ); + maSyntaxLineTable.insert( nPara ); aSyntaxIdleTimer.Start(); } } diff --git a/sw/source/ui/inc/srcedtw.hxx b/sw/source/ui/inc/srcedtw.hxx index 3439b19..cdaa2e6 100644 --- a/sw/source/ui/inc/srcedtw.hxx +++ b/sw/source/ui/inc/srcedtw.hxx @@ -28,11 +28,12 @@ #ifndef _SRCEDTW_HXX #define _SRCEDTW_HXX +#include + #include #include #include -#include #include namespace com { namespace sun { namespace star { namespace beans { @@ -96,7 +97,8 @@ private: sal_Bool bHighlighting; Timer aSyntaxIdleTimer; - Table aSyntaxLineTable; + typedef std::set SyntaxLineTable; + SyntaxLineTable maSyntaxLineTable; void ImpDoHighlight( const String& rSource, sal_uInt16 nLineOff );