[Libreoffice-commits] .: 9 commits - sc/source
Kohei Yoshida
kohei at kemper.freedesktop.org
Tue Jun 14 20:43:42 PDT 2011
sc/source/filter/excel/namebuff.cxx | 128 ++++++++++-----------------
sc/source/filter/inc/XclExpChangeTrack.hxx | 38 --------
sc/source/filter/inc/namebuff.hxx | 52 ++++------
sc/source/filter/lotus/tool.cxx | 57 ++++--------
sc/source/filter/xcl97/XclExpChangeTrack.cxx | 93 +++++++------------
5 files changed, 134 insertions(+), 234 deletions(-)
New commits:
commit 8f5e059688e34a9db11190f175c2d6c173a18a31
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Tue Jun 14 23:36:36 2011 -0400
ENTRY -> Entry. Let's not use all CAPS for class/struct names.
diff --git a/sc/source/filter/inc/namebuff.hxx b/sc/source/filter/inc/namebuff.hxx
index 1f83a28..fd39682 100644
--- a/sc/source/filter/inc/namebuff.hxx
+++ b/sc/source/filter/inc/namebuff.hxx
@@ -188,7 +188,7 @@ public:
class RangeNameBufferWK3
{
private:
- struct ENTRY
+ struct Entry
{
StringHashEntry aStrHashEntry;
ScComplexRefData aScComplexRefDataRel;
@@ -196,7 +196,7 @@ private:
sal_uInt16 nAbsInd; // == 0 -> noch keine Abs-Name!
sal_uInt16 nRelInd;
sal_Bool bSingleRef;
- ENTRY( const String& rName, const String& rScName, const ScComplexRefData& rCRD ) :
+ Entry( const String& rName, const String& rScName, const ScComplexRefData& rCRD ) :
aStrHashEntry( rName ),
aScComplexRefDataRel( rCRD ),
aScAbsName( rScName )
@@ -208,7 +208,7 @@ private:
ScTokenArray* pScTokenArray;
sal_uInt16 nIntCount;
- std::vector<ENTRY> maEntries;
+ std::vector<Entry> maEntries;
public:
RangeNameBufferWK3( void );
diff --git a/sc/source/filter/lotus/tool.cxx b/sc/source/filter/lotus/tool.cxx
index 0f3b17e..b7de080 100644
--- a/sc/source/filter/lotus/tool.cxx
+++ b/sc/source/filter/lotus/tool.cxx
@@ -533,7 +533,7 @@ void RangeNameBufferWK3::Add( const String& rOrgName, const ScComplexRefData& rC
String aScName( rOrgName );
ScfTools::ConvertToScDefinedName( aScName );
- ENTRY aInsert( rOrgName, aScName, rCRD );
+ Entry aInsert( rOrgName, aScName, rCRD );
pScTokenArray->Clear();
@@ -566,7 +566,7 @@ sal_Bool RangeNameBufferWK3::FindRel( const String& rRef, sal_uInt16& rIndex )
{
StringHashEntry aRef( rRef );
- std::vector<ENTRY>::const_iterator itr;
+ std::vector<Entry>::const_iterator itr;
for ( itr = maEntries.begin(); itr != maEntries.end(); ++itr )
{
if ( aRef == itr->aStrHashEntry )
@@ -585,7 +585,7 @@ sal_Bool RangeNameBufferWK3::FindAbs( const String& rRef, sal_uInt16& rIndex )
String aTmp( rRef );
StringHashEntry aRef( aTmp.Erase( 0, 1 ) ); // ohne '$' suchen!
- std::vector<ENTRY>::iterator itr;
+ std::vector<Entry>::iterator itr;
for ( itr = maEntries.begin(); itr != maEntries.end(); ++itr )
{
if ( aRef == itr->aStrHashEntry )
commit 09102bf9aa29901691ab7349e3310a7ba3ec5d09
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Tue Jun 14 23:34:08 2011 -0400
Let's not use 'p' prefix for iterators.
'p' is reserved for pointers, and iterators are not pointers.
diff --git a/sc/source/filter/lotus/tool.cxx b/sc/source/filter/lotus/tool.cxx
index 20a2dd1..0f3b17e 100644
--- a/sc/source/filter/lotus/tool.cxx
+++ b/sc/source/filter/lotus/tool.cxx
@@ -566,12 +566,12 @@ sal_Bool RangeNameBufferWK3::FindRel( const String& rRef, sal_uInt16& rIndex )
{
StringHashEntry aRef( rRef );
- std::vector<ENTRY>::const_iterator pIter;
- for ( pIter = maEntries.begin(); pIter != maEntries.end(); ++pIter )
+ std::vector<ENTRY>::const_iterator itr;
+ for ( itr = maEntries.begin(); itr != maEntries.end(); ++itr )
{
- if ( aRef == pIter->aStrHashEntry )
+ if ( aRef == itr->aStrHashEntry )
{
- rIndex = pIter->nRelInd;
+ rIndex = itr->nRelInd;
return true;
}
}
@@ -585,37 +585,37 @@ sal_Bool RangeNameBufferWK3::FindAbs( const String& rRef, sal_uInt16& rIndex )
String aTmp( rRef );
StringHashEntry aRef( aTmp.Erase( 0, 1 ) ); // ohne '$' suchen!
- std::vector<ENTRY>::iterator pIter;
- for ( pIter = maEntries.begin(); pIter != maEntries.end(); ++pIter )
+ std::vector<ENTRY>::iterator itr;
+ for ( itr = maEntries.begin(); itr != maEntries.end(); ++itr )
{
- if ( aRef == pIter->aStrHashEntry )
+ if ( aRef == itr->aStrHashEntry )
{
// eventuell neuen Range Name aufbauen
- if( pIter->nAbsInd )
- rIndex = pIter->nAbsInd;
+ if( itr->nAbsInd )
+ rIndex = itr->nAbsInd;
else
{
- ScSingleRefData* pRef = &pIter->aScComplexRefDataRel.Ref1;
+ ScSingleRefData* pRef = &itr->aScComplexRefDataRel.Ref1;
pScTokenArray->Clear();
pRef->SetColRel( false );
pRef->SetRowRel( false );
pRef->SetTabRel( sal_True );
- if( pIter->bSingleRef )
+ if( itr->bSingleRef )
pScTokenArray->AddSingleReference( *pRef );
else
{
- pRef = &pIter->aScComplexRefDataRel.Ref2;
+ pRef = &itr->aScComplexRefDataRel.Ref2;
pRef->SetColRel( false );
pRef->SetRowRel( false );
pRef->SetTabRel( sal_True );
- pScTokenArray->AddDoubleReference( pIter->aScComplexRefDataRel );
+ pScTokenArray->AddDoubleReference( itr->aScComplexRefDataRel );
}
- ScRangeData* pData = new ScRangeData( pLotusRoot->pDoc, pIter->aScAbsName, *pScTokenArray );
+ ScRangeData* pData = new ScRangeData( pLotusRoot->pDoc, itr->aScAbsName, *pScTokenArray );
- rIndex = pIter->nAbsInd = nIntCount;
+ rIndex = itr->nAbsInd = nIntCount;
pData->SetIndex( rIndex );
nIntCount++;
commit 37ff161c899fd95fb53c2df06f269ecd93ba8214
Author: Rafael Dominguez <venccsralph at gmail.com>
Date: Sun Jun 12 15:42:34 2011 -0430
Replace List with std::vector<ENTRY>.
diff --git a/sc/source/filter/inc/namebuff.hxx b/sc/source/filter/inc/namebuff.hxx
index 2e8dad4..1f83a28 100644
--- a/sc/source/filter/inc/namebuff.hxx
+++ b/sc/source/filter/inc/namebuff.hxx
@@ -185,7 +185,7 @@ public:
-class RangeNameBufferWK3 : private List
+class RangeNameBufferWK3
{
private:
struct ENTRY
@@ -208,6 +208,8 @@ private:
ScTokenArray* pScTokenArray;
sal_uInt16 nIntCount;
+ std::vector<ENTRY> maEntries;
+
public:
RangeNameBufferWK3( void );
virtual ~RangeNameBufferWK3();
diff --git a/sc/source/filter/lotus/tool.cxx b/sc/source/filter/lotus/tool.cxx
index a28b2a8..20a2dd1 100644
--- a/sc/source/filter/lotus/tool.cxx
+++ b/sc/source/filter/lotus/tool.cxx
@@ -524,14 +524,6 @@ RangeNameBufferWK3::RangeNameBufferWK3( void )
RangeNameBufferWK3::~RangeNameBufferWK3()
{
- ENTRY* pDel = ( ENTRY* ) List::First();
-
- while( pDel )
- {
- delete pDel;
- pDel = ( ENTRY* ) List::Next();
- }
-
delete pScTokenArray;
}
@@ -541,9 +533,7 @@ void RangeNameBufferWK3::Add( const String& rOrgName, const ScComplexRefData& rC
String aScName( rOrgName );
ScfTools::ConvertToScDefinedName( aScName );
- register ENTRY* pInsert = new ENTRY( rOrgName, aScName, rCRD );
-
- List::Insert( pInsert, CONTAINER_APPEND );
+ ENTRY aInsert( rOrgName, aScName, rCRD );
pScTokenArray->Clear();
@@ -553,20 +543,21 @@ void RangeNameBufferWK3::Add( const String& rOrgName, const ScComplexRefData& rC
if( rRef1.nCol == rRef2.nCol && rRef1.nRow == rRef2.nRow && rRef1.nTab == rRef2.nTab )
{
pScTokenArray->AddSingleReference( rCRD.Ref1 );
- pInsert->bSingleRef = sal_True;
+ aInsert.bSingleRef = sal_True;
}
else
{
pScTokenArray->AddDoubleReference( rCRD );
- pInsert->bSingleRef = false;
+ aInsert.bSingleRef = false;
}
ScRangeData* pData = new ScRangeData( pLotusRoot->pDoc, aScName, *pScTokenArray );
- pInsert->nRelInd = nIntCount;
+ aInsert.nRelInd = nIntCount;
pData->SetIndex( nIntCount );
nIntCount++;
+ maEntries.push_back( aInsert );
pLotusRoot->pScRangeName->insert( pData );
}
@@ -575,16 +566,14 @@ sal_Bool RangeNameBufferWK3::FindRel( const String& rRef, sal_uInt16& rIndex )
{
StringHashEntry aRef( rRef );
- ENTRY* pFind = ( ENTRY* ) List::First();
-
- while( pFind )
+ std::vector<ENTRY>::const_iterator pIter;
+ for ( pIter = maEntries.begin(); pIter != maEntries.end(); ++pIter )
{
- if( aRef == pFind->aStrHashEntry )
+ if ( aRef == pIter->aStrHashEntry )
{
- rIndex = pFind->nRelInd;
- return sal_True;
+ rIndex = pIter->nRelInd;
+ return true;
}
- pFind = ( ENTRY* ) List::Next();
}
return false;
@@ -596,47 +585,45 @@ sal_Bool RangeNameBufferWK3::FindAbs( const String& rRef, sal_uInt16& rIndex )
String aTmp( rRef );
StringHashEntry aRef( aTmp.Erase( 0, 1 ) ); // ohne '$' suchen!
- ENTRY* pFind = ( ENTRY* ) List::First();
-
- while( pFind )
+ std::vector<ENTRY>::iterator pIter;
+ for ( pIter = maEntries.begin(); pIter != maEntries.end(); ++pIter )
{
- if( aRef == pFind->aStrHashEntry )
+ if ( aRef == pIter->aStrHashEntry )
{
// eventuell neuen Range Name aufbauen
- if( pFind->nAbsInd )
- rIndex = pFind->nAbsInd;
+ if( pIter->nAbsInd )
+ rIndex = pIter->nAbsInd;
else
{
- ScSingleRefData* pRef = &pFind->aScComplexRefDataRel.Ref1;
+ ScSingleRefData* pRef = &pIter->aScComplexRefDataRel.Ref1;
pScTokenArray->Clear();
pRef->SetColRel( false );
pRef->SetRowRel( false );
pRef->SetTabRel( sal_True );
- if( pFind->bSingleRef )
+ if( pIter->bSingleRef )
pScTokenArray->AddSingleReference( *pRef );
else
{
- pRef = &pFind->aScComplexRefDataRel.Ref2;
+ pRef = &pIter->aScComplexRefDataRel.Ref2;
pRef->SetColRel( false );
pRef->SetRowRel( false );
pRef->SetTabRel( sal_True );
- pScTokenArray->AddDoubleReference( pFind->aScComplexRefDataRel );
+ pScTokenArray->AddDoubleReference( pIter->aScComplexRefDataRel );
}
- ScRangeData* pData = new ScRangeData( pLotusRoot->pDoc, pFind->aScAbsName, *pScTokenArray );
+ ScRangeData* pData = new ScRangeData( pLotusRoot->pDoc, pIter->aScAbsName, *pScTokenArray );
- rIndex = pFind->nAbsInd = nIntCount;
+ rIndex = pIter->nAbsInd = nIntCount;
pData->SetIndex( rIndex );
nIntCount++;
pLotusRoot->pScRangeName->insert( pData );
}
- return sal_True;
+ return true;
}
- pFind = ( ENTRY* ) List::Next();
}
return false;
commit 91e37a65377b7b6376c2a3cda204aee739a9c711
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Tue Jun 14 22:46:48 2011 -0400
Don't forget nExcIndex is 1-based.
The old code had nExcIndex-- line but that was not accounted for in
the new code.
diff --git a/sc/source/filter/excel/namebuff.cxx b/sc/source/filter/excel/namebuff.cxx
index cccd60c..ada66d0 100644
--- a/sc/source/filter/excel/namebuff.cxx
+++ b/sc/source/filter/excel/namebuff.cxx
@@ -182,7 +182,7 @@ sal_Bool ExtSheetBuffer::GetScTabIndex( sal_uInt16 nExcIndex, sal_uInt16& rScInd
if ( !nExcIndex || nExcIndex > maEntries.size() )
return false;
- Cont* pCur = &(maEntries[ nExcIndex ]);
+ Cont* pCur = &maEntries[ nExcIndex - 1 ];
sal_uInt16& rTabNum = pCur->nTabNum;
if( rTabNum < 0xFFFD )
commit b90cb3ff658b7657ea9d047fe6064434b6e5d379
Author: Rafael Dominguez <venccsralph at gmail.com>
Date: Sun Jun 12 12:08:00 2011 -0430
Replace List with std::vector<Cont>.
diff --git a/sc/source/filter/excel/namebuff.cxx b/sc/source/filter/excel/namebuff.cxx
index 4a933cd..cccd60c 100644
--- a/sc/source/filter/excel/namebuff.cxx
+++ b/sc/source/filter/excel/namebuff.cxx
@@ -166,23 +166,11 @@ String ShrfmlaBuffer::CreateName( const ScRange& r )
return aName;
}
-
-ExtSheetBuffer::~ExtSheetBuffer()
-{
- Cont *pAkt = ( Cont * ) List::First();
- while( pAkt )
- {
- delete pAkt;
- pAkt = ( Cont * ) List::Next();
- }
-}
-
-
sal_Int16 ExtSheetBuffer::Add( const String& rFPAN, const String& rTN, const sal_Bool bSWB )
{
- List::Insert( new Cont( rFPAN, rTN, bSWB ), LIST_APPEND );
+ maEntries.push_back( Cont( rFPAN, rTN, bSWB ) );
// return 1-based index of EXTERNSHEET
- return static_cast< sal_Int16 >( List::Count() );
+ return static_cast< sal_Int16 >( maEntries.size() );
}
@@ -191,51 +179,50 @@ sal_Bool ExtSheetBuffer::GetScTabIndex( sal_uInt16 nExcIndex, sal_uInt16& rScInd
OSL_ENSURE( nExcIndex,
"*ExtSheetBuffer::GetScTabIndex(): Sheet-Index == 0!" );
- nExcIndex--;
- Cont* pCur = ( Cont * ) List::GetObject( nExcIndex );
+ if ( !nExcIndex || nExcIndex > maEntries.size() )
+ return false;
+
+ Cont* pCur = &(maEntries[ nExcIndex ]);
sal_uInt16& rTabNum = pCur->nTabNum;
- if( pCur )
+ if( rTabNum < 0xFFFD )
{
- if( rTabNum < 0xFFFD )
- {
- rScIndex = rTabNum;
- return sal_True;
- }
+ rScIndex = rTabNum;
+ return sal_True;
+ }
- if( rTabNum == 0xFFFF )
- {// neue Tabelle erzeugen
- SCTAB nNewTabNum;
- if( pCur->bSWB )
- {// Tabelle ist im selben Workbook!
- if( pExcRoot->pIR->GetDoc().GetTable( pCur->aTab, nNewTabNum ) )
+ if( rTabNum == 0xFFFF )
+ {// neue Tabelle erzeugen
+ SCTAB nNewTabNum;
+ if( pCur->bSWB )
+ {// Tabelle ist im selben Workbook!
+ if( pExcRoot->pIR->GetDoc().GetTable( pCur->aTab, nNewTabNum ) )
+ {
+ rScIndex = rTabNum = static_cast<sal_uInt16>(nNewTabNum);
+ return sal_True;
+ }
+ else
+ rTabNum = 0xFFFD;
+ }
+ else if( pExcRoot->pIR->GetDocShell() )
+ {// Tabelle ist 'echt' extern
+ if( pExcRoot->pIR->GetExtDocOptions().GetDocSettings().mnLinkCnt == 0 )
+ {
+ String aURL( ScGlobal::GetAbsDocName( pCur->aFile,
+ pExcRoot->pIR->GetDocShell() ) );
+ String aTabName( ScGlobal::GetDocTabName( aURL, pCur->aTab ) );
+ if( pExcRoot->pIR->GetDoc().LinkExternalTab( nNewTabNum, aTabName, aURL, pCur->aTab ) )
{
rScIndex = rTabNum = static_cast<sal_uInt16>(nNewTabNum);
return sal_True;
}
else
- rTabNum = 0xFFFD;
+ rTabNum = 0xFFFE; // Tabelle einmal nicht angelegt -> wird
+ // wohl auch nicht mehr gehen...
}
- else if( pExcRoot->pIR->GetDocShell() )
- {// Tabelle ist 'echt' extern
- if( pExcRoot->pIR->GetExtDocOptions().GetDocSettings().mnLinkCnt == 0 )
- {
- String aURL( ScGlobal::GetAbsDocName( pCur->aFile,
- pExcRoot->pIR->GetDocShell() ) );
- String aTabName( ScGlobal::GetDocTabName( aURL, pCur->aTab ) );
- if( pExcRoot->pIR->GetDoc().LinkExternalTab( nNewTabNum, aTabName, aURL, pCur->aTab ) )
- {
- rScIndex = rTabNum = static_cast<sal_uInt16>(nNewTabNum);
- return sal_True;
- }
- else
- rTabNum = 0xFFFE; // Tabelle einmal nicht angelegt -> wird
- // wohl auch nicht mehr gehen...
- }
- else
- rTabNum = 0xFFFE;
+ else
+ rTabNum = 0xFFFE;
- }
}
}
@@ -246,41 +233,33 @@ sal_Bool ExtSheetBuffer::GetScTabIndex( sal_uInt16 nExcIndex, sal_uInt16& rScInd
sal_Bool ExtSheetBuffer::IsLink( const sal_uInt16 nExcIndex ) const
{
OSL_ENSURE( nExcIndex > 0, "*ExtSheetBuffer::IsLink(): Index muss >0 sein!" );
- Cont* pRet = ( Cont * ) List::GetObject( nExcIndex - 1 );
- if( pRet )
- return pRet->bLink;
- else
+ if (!nExcIndex || nExcIndex > maEntries.size() )
return false;
+
+ return maEntries[ nExcIndex -1 ].bLink;
}
sal_Bool ExtSheetBuffer::GetLink( const sal_uInt16 nExcIndex, String& rAppl, String& rDoc ) const
{
OSL_ENSURE( nExcIndex > 0, "*ExtSheetBuffer::GetLink(): Index muss >0 sein!" );
- Cont* pRet = ( Cont * ) List::GetObject( nExcIndex - 1 );
- if( pRet )
- {
- rAppl = pRet->aFile;
- rDoc = pRet->aTab;
- return sal_True;
- }
- else
+ if (!nExcIndex || nExcIndex > maEntries.size() )
return false;
+
+ const Cont &rRet = maEntries[ nExcIndex -1 ];
+
+ rAppl = rRet.aFile;
+ rDoc = rRet.aTab;
+
+ return true;
}
void ExtSheetBuffer::Reset( void )
{
- Cont *pAkt = ( Cont * ) List::First();
- while( pAkt )
- {
- delete pAkt;
- pAkt = ( Cont * ) List::Next();
- }
-
- List::Clear();
+ maEntries.clear();
}
diff --git a/sc/source/filter/inc/namebuff.hxx b/sc/source/filter/inc/namebuff.hxx
index a79ef1f..2e8dad4 100644
--- a/sc/source/filter/inc/namebuff.hxx
+++ b/sc/source/filter/inc/namebuff.hxx
@@ -254,7 +254,7 @@ inline void RangeNameBufferWK3::Add( const String& rName, const ScRange& aScRang
-class ExtSheetBuffer : private List, public ExcRoot
+class ExtSheetBuffer : public ExcRoot
{
private:
struct Cont
@@ -283,9 +283,11 @@ private:
bLink = false;
}
};
+
+ std::vector<Cont> maEntries;
+
public:
inline ExtSheetBuffer( RootData* );
- virtual ~ExtSheetBuffer();
sal_Int16 Add( const String& rFilePathAndName,
const String& rTabName, const sal_Bool bSameWorkbook = false );
commit ae809c4db314400fb7aca0ea667d283a03608332
Author: Kohei Yoshida <kyoshida at novell.com>
Date: Tue Jun 14 22:24:08 2011 -0400
Fixed incorrect boundary checks & simplified the code a bit.
n == nBase acceptable, also n == maHashes.size() is an out-of-bound
condition thus should return NULL.
diff --git a/sc/source/filter/inc/namebuff.hxx b/sc/source/filter/inc/namebuff.hxx
index 03264d7..a79ef1f 100644
--- a/sc/source/filter/inc/namebuff.hxx
+++ b/sc/source/filter/inc/namebuff.hxx
@@ -134,15 +134,10 @@ inline NameBuffer::NameBuffer( RootData* p, sal_uInt16 nNewBase ) : ExcRoot( p )
inline const String* NameBuffer::Get ( sal_uInt16 n ) const
{
- const String* pObj = NULL;
+ if( n < nBase || n >= maHashes.size() )
+ return NULL;
- if( n > nBase )
- {
- if ( n < maHashes.size() )
- pObj = &(maHashes[n]->aString);
- }
-
- return pObj;
+ return &(maHashes[n]->aString);
}
commit 5c0a49d54fb2919862f173361aea28968a230767
Author: Rafael Dominguez <venccsralph at gmail.com>
Date: Sat Jun 11 20:29:26 2011 -0430
Replace List with std::vector<StringHashEntry*>.
diff --git a/sc/source/filter/excel/namebuff.cxx b/sc/source/filter/excel/namebuff.cxx
index 79bb865..4a933cd 100644
--- a/sc/source/filter/excel/namebuff.cxx
+++ b/sc/source/filter/excel/namebuff.cxx
@@ -67,22 +67,19 @@ sal_uInt32 StringHashEntry::MakeHashCode( const String& r )
NameBuffer::~NameBuffer()
{
- register StringHashEntry* pDel = ( StringHashEntry* ) List::First();
- while( pDel )
- {
- delete pDel;
- pDel = ( StringHashEntry* ) List::Next();
- }
+ std::vector<StringHashEntry*>::iterator pIter;
+ for ( pIter = maHashes.begin(); pIter != maHashes.end(); ++pIter )
+ delete *pIter;
}
//void NameBuffer::operator <<( const SpString &rNewString )
void NameBuffer::operator <<( const String &rNewString )
{
- OSL_ENSURE( Count() + nBase < 0xFFFF,
+ OSL_ENSURE( maHashes.size() + nBase < 0xFFFF,
"*NameBuffer::GetLastIndex(): Ich hab' die Nase voll!" );
- List::Insert( new StringHashEntry( rNewString ), LIST_APPEND );
+ maHashes.push_back( new StringHashEntry( rNewString ) );
}
diff --git a/sc/source/filter/inc/namebuff.hxx b/sc/source/filter/inc/namebuff.hxx
index 1f591ba..03264d7 100644
--- a/sc/source/filter/inc/namebuff.hxx
+++ b/sc/source/filter/inc/namebuff.hxx
@@ -102,29 +102,24 @@ inline sal_Bool StringHashEntry::operator ==( const StringHashEntry& r ) const
-class NameBuffer : private List, public ExcRoot
+class NameBuffer : public ExcRoot
{
private:
sal_uInt16 nBase; // Index-Basis
+ std::vector<StringHashEntry*> maHashes;
+
public:
-// inline NameBuffer( void ); //prevent empty rootdata
+
inline NameBuffer( RootData* );
inline NameBuffer( RootData*, sal_uInt16 nNewBase );
virtual ~NameBuffer();
- inline const String* Get( sal_uInt16 nIndex );
- inline sal_uInt16 GetLastIndex( void );
+ inline const String* Get( sal_uInt16 nIndex ) const;
+ inline sal_uInt16 GetLastIndex() const;
inline void SetBase( sal_uInt16 nNewBase = 0 );
void operator <<( const String& rNewString );
};
-//prevent empty rootdata
-//inline NameBuffer::NameBuffer( void )
-//{
-// nBase = 0;
-//}
-
-
inline NameBuffer::NameBuffer( RootData* p ) : ExcRoot( p )
{
nBase = 0;
@@ -137,27 +132,27 @@ inline NameBuffer::NameBuffer( RootData* p, sal_uInt16 nNewBase ) : ExcRoot( p )
}
-inline const String* NameBuffer::Get( sal_uInt16 n )
+inline const String* NameBuffer::Get ( sal_uInt16 n ) const
{
- if( n < nBase )
- return NULL;
- else
- {
- StringHashEntry* pObj = ( StringHashEntry* ) List::GetObject( n );
+ const String* pObj = NULL;
- if( pObj )
- return &pObj->aString;
- else
- return NULL;
+ if( n > nBase )
+ {
+ if ( n < maHashes.size() )
+ pObj = &(maHashes[n]->aString);
}
+
+ return pObj;
}
-inline sal_uInt16 NameBuffer::GetLastIndex( void )
+inline sal_uInt16 NameBuffer::GetLastIndex () const
{
- OSL_ENSURE( Count() + nBase <= 0xFFFF, "*NameBuffer::GetLastIndex(): Ich hab' die Nase voll!" );
+ int size = maHashes.size() + nBase;
+
+ OSL_ENSURE( size <= 0xFFFF, "*NameBuffer::GetLastIndex(): Ich hab' die Nase voll!" );
- return ( sal_uInt16 ) ( Count() + nBase );
+ return static_cast<sal_uInt16>( size );
}
commit 3cc0f60dfff6738232597530afe6bf290f665751
Author: Rafael Dominguez <venccsralph at gmail.com>
Date: Sat Jun 11 20:28:31 2011 -0430
Replace XclExpChTrRecordList with std::vector<ExcRecord*>.
diff --git a/sc/source/filter/inc/XclExpChangeTrack.hxx b/sc/source/filter/inc/XclExpChangeTrack.hxx
index 412108a..5158d03 100644
--- a/sc/source/filter/inc/XclExpChangeTrack.hxx
+++ b/sc/source/filter/inc/XclExpChangeTrack.hxx
@@ -615,30 +615,12 @@ private:
};
//___________________________________________________________________
-// XclExpChTrRecordList - list of "Revision Log" stream records
-
-class XclExpChTrRecordList : private List
-{
-private:
- inline ExcRecord* First() { return (ExcRecord*) List::First(); }
- inline ExcRecord* Next() { return (ExcRecord*) List::Next(); }
-
-public:
- virtual ~XclExpChTrRecordList();
-
- using List::Count;
- void Append( ExcRecord* pNewRec );
- void Save( XclExpStream& rStrm );
- void SaveXml( XclExpXmlStream& rStrm );
-};
-
-//___________________________________________________________________
// XclExpChangeTrack - exports the "Revision Log" stream
class XclExpChangeTrack : protected XclExpRoot
{
private:
- XclExpChTrRecordList aRecList;
+ std::vector<ExcRecord*> aRecList; // list of "Revision Log" stream records
XclExpChTrActionStack aActionStack;
XclExpChTrTabIdBuffer* pTabIdBuffer;
std::vector<XclExpChTrTabIdBuffer*> maBuffers;
diff --git a/sc/source/filter/xcl97/XclExpChangeTrack.cxx b/sc/source/filter/xcl97/XclExpChangeTrack.cxx
index 9de5f8b..e5a54cc 100644
--- a/sc/source/filter/xcl97/XclExpChangeTrack.cxx
+++ b/sc/source/filter/xcl97/XclExpChangeTrack.cxx
@@ -1342,33 +1342,6 @@ void XclExpChTrActionStack::Push( XclExpChTrAction* pNewRec )
//___________________________________________________________________
-XclExpChTrRecordList::~XclExpChTrRecordList()
-{
- for( ExcRecord* pRec = First(); pRec; pRec = Next() )
- delete pRec;
-}
-
-void XclExpChTrRecordList::Append( ExcRecord* pNewRec )
-{
- OSL_ENSURE( pNewRec, "XclExpChTrRecordList::Append - NULL pointer" );
- if( pNewRec )
- List::Insert( pNewRec, LIST_APPEND );
-}
-
-void XclExpChTrRecordList::Save( XclExpStream& rStrm )
-{
- for( ExcRecord* pRec = First(); pRec; pRec = Next() )
- pRec->Save( rStrm );
-}
-
-void XclExpChTrRecordList::SaveXml( XclExpXmlStream& rStrm )
-{
- for( ExcRecord* pRec = First(); pRec; pRec = Next() )
- pRec->SaveXml( rStrm );
-}
-
-//___________________________________________________________________
-
class ExcXmlRecord : public ExcRecord
{
public:
@@ -1456,7 +1429,6 @@ void EndHeaderElement::SaveXml( XclExpXmlStream& rStrm )
XclExpChangeTrack::XclExpChangeTrack( const XclExpRoot& rRoot ) :
XclExpRoot( rRoot ),
- aRecList(),
aActionStack(),
pTabIdBuffer( NULL ),
pTempDoc( NULL ),
@@ -1500,10 +1472,10 @@ XclExpChangeTrack::XclExpChangeTrack( const XclExpRoot& rRoot ) :
// build record list
pHeader = new XclExpChTrHeader;
- aRecList.Append( new StartXmlElement( XML_headers, StartXmlElement::WRITE_NAMESPACES ) );
- aRecList.Append( pHeader );
- aRecList.Append( new XclExpChTr0x0195 );
- aRecList.Append( new XclExpChTr0x0194( *pTempChangeTrack ) );
+ aRecList.push_back( new StartXmlElement( XML_headers, StartXmlElement::WRITE_NAMESPACES ) );
+ aRecList.push_back( pHeader );
+ aRecList.push_back( new XclExpChTr0x0195 );
+ aRecList.push_back( new XclExpChTr0x0194( *pTempChangeTrack ) );
String sLastUsername;
DateTime aLastDateTime;
@@ -1517,37 +1489,41 @@ XclExpChangeTrack::XclExpChangeTrack( const XclExpRoot& rRoot ) :
{
if( nIndex != 1 )
{
- aRecList.Append( new EndXmlElement( XML_revisions ) );
- aRecList.Append( new EndHeaderElement() );
+ aRecList.push_back( new EndXmlElement( XML_revisions ) );
+ aRecList.push_back( new EndHeaderElement() );
}
lcl_GenerateGUID( aGUID, bValidGUID );
sLastUsername = pAction->GetUsername();
aLastDateTime = pAction->GetDateTime();
- aRecList.Append( new StartXmlElement( XML_header, 0 ) );
- aRecList.Append( new XclExpChTrInfo( sLastUsername, aLastDateTime, aGUID, nLogNumber++ ) );
- aRecList.Append( new XclExpChTrTabId( pAction->GetTabIdBuffer(), true ) );
- aRecList.Append( new StartXmlElement( XML_revisions, StartXmlElement::WRITE_NAMESPACES | StartXmlElement::CLOSE_ELEMENT ) );
+ aRecList.push_back( new StartXmlElement( XML_header, 0 ) );
+ aRecList.push_back( new XclExpChTrInfo( sLastUsername, aLastDateTime, aGUID, nLogNumber++ ) );
+ aRecList.push_back( new XclExpChTrTabId( pAction->GetTabIdBuffer(), true ) );
+ aRecList.push_back( new StartXmlElement( XML_revisions, StartXmlElement::WRITE_NAMESPACES | StartXmlElement::CLOSE_ELEMENT ) );
pHeader->SetGUID( aGUID );
}
pAction->SetIndex( nIndex );
- aRecList.Append( pAction );
+ aRecList.push_back( pAction );
}
pHeader->SetGUID( aGUID );
pHeader->SetCount( nIndex - 1 );
if( nLogNumber > 1 )
{
- aRecList.Append( new EndXmlElement( XML_revisions ) );
- aRecList.Append( new EndHeaderElement() );
+ aRecList.push_back( new EndXmlElement( XML_revisions ) );
+ aRecList.push_back( new EndHeaderElement() );
}
- aRecList.Append( new EndXmlElement( XML_headers ) );
- aRecList.Append( new ExcEof );
+ aRecList.push_back( new EndXmlElement( XML_headers ) );
+ aRecList.push_back( new ExcEof );
}
XclExpChangeTrack::~XclExpChangeTrack()
{
+ std::vector<ExcRecord*>::iterator prIter;
+ for ( prIter = aRecList.begin(); prIter != aRecList.end(); ++prIter )
+ delete *prIter;
+
std::vector<XclExpChTrTabIdBuffer*>::iterator pIter;
for ( pIter = maBuffers.begin(); pIter != maBuffers.end(); ++pIter )
delete *pIter;
@@ -1641,7 +1617,7 @@ sal_Bool XclExpChangeTrack::WriteUserNamesStream()
void XclExpChangeTrack::Write()
{
- if( !aRecList.Count() )
+ if( aRecList.empty() )
return;
if( WriteUserNamesStream() )
@@ -1651,7 +1627,11 @@ void XclExpChangeTrack::Write()
if( xSvStrm.Is() )
{
XclExpStream aXclStrm( *xSvStrm, GetRoot(), EXC_MAXRECSIZE_BIFF8 + 8 );
- aRecList.Save( aXclStrm );
+
+ std::vector<ExcRecord*>::iterator pIter;
+ for ( pIter = aRecList.begin(); pIter != aRecList.end(); ++pIter )
+ (*pIter)->Save(aXclStrm);
+
xSvStrm->Commit();
}
}
@@ -1678,7 +1658,7 @@ static void lcl_WriteUserNamesXml( XclExpXmlStream& rWorkbookStrm )
void XclExpChangeTrack::WriteXml( XclExpXmlStream& rWorkbookStrm )
{
- if( !aRecList.Count() )
+ if( aRecList.empty() )
return;
lcl_WriteUserNamesXml( rWorkbookStrm );
@@ -1694,7 +1674,9 @@ void XclExpChangeTrack::WriteXml( XclExpXmlStream& rWorkbookStrm )
// contents of XclExpChangeTrack::WriteUserNamesStream()).
rWorkbookStrm.PushStream( pRevisionHeaders );
- aRecList.SaveXml( rWorkbookStrm );
+ std::vector<ExcRecord*>::iterator pIter;
+ for ( pIter = aRecList.begin(); pIter != aRecList.end(); ++pIter )
+ (*pIter)->SaveXml(rWorkbookStrm);
rWorkbookStrm.PopStream();
}
commit 9d1609bff06565370d0f66e306529be5d78c6358
Author: Rafael Dominguez <venccsralph at gmail.com>
Date: Thu Jun 9 20:12:35 2011 -0430
Replace XclExpChTrTabIdBufferList with std::vector<>.
diff --git a/sc/source/filter/inc/XclExpChangeTrack.hxx b/sc/source/filter/inc/XclExpChangeTrack.hxx
index 2c71432..412108a 100644
--- a/sc/source/filter/inc/XclExpChangeTrack.hxx
+++ b/sc/source/filter/inc/XclExpChangeTrack.hxx
@@ -314,22 +314,6 @@ public:
};
//___________________________________________________________________
-// XclExpChTrTabIdBufferList
-
-class XclExpChTrTabIdBufferList : private List
-{
-private:
- inline XclExpChTrTabIdBuffer* First() { return (XclExpChTrTabIdBuffer*) List::First(); }
- inline XclExpChTrTabIdBuffer* Next() { return (XclExpChTrTabIdBuffer*) List::Next(); }
-
-public:
- virtual ~XclExpChTrTabIdBufferList();
-
- inline void Append( XclExpChTrTabIdBuffer* pNew )
- { List::Insert( pNew, LIST_APPEND ); }
-};
-
-//___________________________________________________________________
// XclExpChTrTabId - tab id record
class XclExpChTrTabId : public ExcRecord
@@ -656,8 +640,8 @@ class XclExpChangeTrack : protected XclExpRoot
private:
XclExpChTrRecordList aRecList;
XclExpChTrActionStack aActionStack;
- XclExpChTrTabIdBufferList aTabIdBufferList;
XclExpChTrTabIdBuffer* pTabIdBuffer;
+ std::vector<XclExpChTrTabIdBuffer*> maBuffers;
ScDocument* pTempDoc; // empty document
diff --git a/sc/source/filter/xcl97/XclExpChangeTrack.cxx b/sc/source/filter/xcl97/XclExpChangeTrack.cxx
index d28fc21..9de5f8b 100644
--- a/sc/source/filter/xcl97/XclExpChangeTrack.cxx
+++ b/sc/source/filter/xcl97/XclExpChangeTrack.cxx
@@ -537,14 +537,6 @@ void XclExpChTrTabIdBuffer::Remove()
//___________________________________________________________________
-XclExpChTrTabIdBufferList::~XclExpChTrTabIdBufferList()
-{
- for( XclExpChTrTabIdBuffer* pBuffer = First(); pBuffer; pBuffer = Next() )
- delete pBuffer;
-}
-
-//___________________________________________________________________
-
XclExpChTrTabId::XclExpChTrTabId( const XclExpChTrTabIdBuffer& rBuffer, bool bInRevisionHeaders )
: nTabCount( rBuffer.GetBufferCount() )
, mbInRevisionHeaders( bInRevisionHeaders )
@@ -1466,7 +1458,6 @@ XclExpChangeTrack::XclExpChangeTrack( const XclExpRoot& rRoot ) :
XclExpRoot( rRoot ),
aRecList(),
aActionStack(),
- aTabIdBufferList(),
pTabIdBuffer( NULL ),
pTempDoc( NULL ),
nNewAction( 1 ),
@@ -1482,7 +1473,7 @@ XclExpChangeTrack::XclExpChangeTrack( const XclExpRoot& rRoot ) :
return;
pTabIdBuffer = new XclExpChTrTabIdBuffer( GetTabInfo().GetXclTabCount() );
- aTabIdBufferList.Append( pTabIdBuffer );
+ maBuffers.push_back( pTabIdBuffer );
// calculate final table order (tab id list)
const ScChangeAction* pScAction;
@@ -1557,6 +1548,10 @@ XclExpChangeTrack::XclExpChangeTrack( const XclExpRoot& rRoot ) :
XclExpChangeTrack::~XclExpChangeTrack()
{
+ std::vector<XclExpChTrTabIdBuffer*>::iterator pIter;
+ for ( pIter = maBuffers.begin(); pIter != maBuffers.end(); ++pIter )
+ delete *pIter;
+
if( pTempDoc )
delete pTempDoc;
}
@@ -1612,7 +1607,7 @@ void XclExpChangeTrack::PushActionRecord( const ScChangeAction& rAction )
pXclAction = new XclExpChTrInsertTab( rAction, GetRoot(), *pTabIdBuffer );
XclExpChTrTabIdBuffer* pNewBuffer = new XclExpChTrTabIdBuffer( *pTabIdBuffer );
pNewBuffer->Remove();
- aTabIdBufferList.Append( pNewBuffer );
+ maBuffers.push_back( pNewBuffer );
pTabIdBuffer = pNewBuffer;
}
break;
More information about the Libreoffice-commits
mailing list