Date: prev next · Thread: first prev next last
2011 Archives by date, by thread · List index



From dfba5318bbc65b655bd41b56704e361362509c4e Mon Sep 17 00:00:00 2001
From: Rafael Dominguez <venccsralph@gmail.com>
Date: Thu, 9 Jun 2011 20:12:35 -0430
Subject: [PATCH 1/5] Replace XclExpChTrTabIdBufferList with std::vector<>.

---
 sc/source/filter/inc/XclExpChangeTrack.hxx   |   18 +-----------------
 sc/source/filter/xcl97/XclExpChangeTrack.cxx |   17 ++++++-----------
 2 files changed, 7 insertions(+), 28 deletions(-)

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;
-- 
1.7.3.4

From 617b622a97011d054044ac50a9cbaa605f831c27 Mon Sep 17 00:00:00 2001
From: Rafael Dominguez <venccsralph@gmail.com>
Date: Sat, 11 Jun 2011 20:28:31 -0430
Subject: [PATCH 2/5] Replace XclExpChTrRecordList with std::vector<ExcRecord*>.

---
 sc/source/filter/inc/XclExpChangeTrack.hxx   |   20 +-------
 sc/source/filter/xcl97/XclExpChangeTrack.cxx |   76 ++++++++++----------------
 2 files changed, 30 insertions(+), 66 deletions(-)

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();
 }
-- 
1.7.3.4

From c7ac89068199f2ca70cebd47f046ac3e814c1a1b Mon Sep 17 00:00:00 2001
From: Rafael Dominguez <venccsralph@gmail.com>
Date: Sat, 11 Jun 2011 20:29:26 -0430
Subject: [PATCH 3/5] Replace List with std::vector<StringHashEntry*>.

---
 sc/source/filter/excel/namebuff.cxx |   13 ++++------
 sc/source/filter/inc/namebuff.hxx   |   43 +++++++++++++++-------------------
 2 files changed, 24 insertions(+), 32 deletions(-)

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 );
 }
 
 
-- 
1.7.3.4

From c1fca7338c14cc75094b0d48aa395fffdaec3531 Mon Sep 17 00:00:00 2001
From: Rafael Dominguez <venccsralph@gmail.com>
Date: Sun, 12 Jun 2011 12:08:00 -0430
Subject: [PATCH 4/5] Replace List with std::vector<Cont>.

---
 sc/source/filter/excel/namebuff.cxx |  115 ++++++++++++++--------------------
 sc/source/filter/inc/namebuff.hxx   |    6 +-
 2 files changed, 51 insertions(+), 70 deletions(-)

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 03264d7..bbfb51b 100644
--- a/sc/source/filter/inc/namebuff.hxx
+++ b/sc/source/filter/inc/namebuff.hxx
@@ -259,7 +259,7 @@ inline void RangeNameBufferWK3::Add( const String& rName, const ScRange& aScRang
 
 
 
-class ExtSheetBuffer : private List, public ExcRoot
+class ExtSheetBuffer : public ExcRoot
 {
 private:
     struct Cont
@@ -288,9 +288,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 );
-- 
1.7.3.4

From e8975741a3c506ee4158eb1b3e5acd07d89549cc Mon Sep 17 00:00:00 2001
From: Rafael Dominguez <venccsralph@gmail.com>
Date: Sun, 12 Jun 2011 15:42:34 -0430
Subject: [PATCH 5/5] Replace List with std::vector<ENTRY>.

---
 sc/source/filter/inc/namebuff.hxx |    4 ++-
 sc/source/filter/lotus/tool.cxx   |   57 ++++++++++++++----------------------
 2 files changed, 25 insertions(+), 36 deletions(-)

diff --git a/sc/source/filter/inc/namebuff.hxx b/sc/source/filter/inc/namebuff.hxx
index bbfb51b..aa654bc 100644
--- a/sc/source/filter/inc/namebuff.hxx
+++ b/sc/source/filter/inc/namebuff.hxx
@@ -190,7 +190,7 @@ public:
 
 
 
-class RangeNameBufferWK3 : private List
+class RangeNameBufferWK3
 {
 private:
     struct ENTRY
@@ -213,6 +213,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;
-- 
1.7.3.4


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.