[Libreoffice-commits] .: sc/source

Joseph Powers jpowers at kemper.freedesktop.org
Fri Dec 3 06:35:04 PST 2010


 sc/source/filter/html/htmlimp.cxx  |    8 ++-
 sc/source/filter/html/htmlpars.cxx |   80 +++++++++++++++++++++++++------------
 sc/source/filter/inc/eeparser.hxx  |   19 ++++----
 sc/source/filter/inc/htmlpars.hxx  |    8 +--
 sc/source/filter/rtf/eeimpars.cxx  |   17 ++++---
 sc/source/filter/rtf/rtfparse.cxx  |   48 ++++++++++++----------
 6 files changed, 112 insertions(+), 68 deletions(-)

New commits:
commit da35b3b3a1198d3e8094858b8bcadb9affe8756f
Author: Joseph Powers <jpowers27 at cox.net>
Date:   Fri Dec 3 06:33:07 2010 -0800

    Remove DECLARE_LIST( ScEEParseList, ScEEParseEntry* ) from ScEEParser

diff --git a/sc/source/filter/html/htmlimp.cxx b/sc/source/filter/html/htmlimp.cxx
index b1ad5a1..ffcd0ed 100644
--- a/sc/source/filter/html/htmlimp.cxx
+++ b/sc/source/filter/html/htmlimp.cxx
@@ -2,7 +2,7 @@
 /*************************************************************************
  *
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- * 
+ *
  * Copyright 2000, 2010 Oracle and/or its affiliates.
  *
  * OpenOffice.org - a multi-platform office productivity suite
@@ -136,7 +136,7 @@ void ScHTMLImport::InsertRangeName( ScDocument* pDoc, const String& rName, const
         delete pRangeData;
 }
 
-void ScHTMLImport::WriteToDocument( 
+void ScHTMLImport::WriteToDocument(
     BOOL bSizeColsRows, double nOutputFactor, SvNumberFormatter* pFormatter, bool bConvertDate )
 {
     ScEEImport::WriteToDocument( bSizeColsRows, nOutputFactor, pFormatter, bConvertDate );
@@ -150,8 +150,10 @@ void ScHTMLImport::WriteToDocument(
     pGlobTable->ApplyCellBorders( mpDoc, maRange.aStart );
 
     // correct cell borders for merged cells
-    for ( ScEEParseEntry* pEntry = pParser->First(); pEntry; pEntry = pParser->Next() )
+    size_t ListSize = pParser->ListSize();
+    for ( size_t i = 0; i < ListSize; ++i )
     {
+        const ScEEParseEntry* pEntry = pParser->ListEntry( i );
         if( (pEntry->nColOverlap > 1) || (pEntry->nRowOverlap > 1) )
         {
             SCTAB nTab = maRange.aStart.Tab();
diff --git a/sc/source/filter/html/htmlpars.cxx b/sc/source/filter/html/htmlpars.cxx
index 5769454..d5a2ccf 100644
--- a/sc/source/filter/html/htmlpars.cxx
+++ b/sc/source/filter/html/htmlpars.cxx
@@ -126,9 +126,19 @@ ScHTMLLayoutParser::ScHTMLLayoutParser( EditEngine* pEditP, const String& rBaseU
 ScHTMLLayoutParser::~ScHTMLLayoutParser()
 {
     ScHTMLTableStackEntry* pS;
+    size_t ListSize = maList.size();
     while ( (pS = aTableStack.Pop()) != 0 )
     {
-        if ( pList->GetPos( pS->pCellEntry ) == LIST_ENTRY_NOTFOUND )
+        bool found = false;
+        for ( size_t i = 0; i < ListSize; ++i )
+        {
+            if ( pS->pCellEntry == maList[ i ] )
+            {
+                found = true;
+                break;
+            }
+        }
+        if ( !found )
             delete pS->pCellEntry;
         if ( pS->pLocalColOffset != pLocalColOffset )
             delete pS->pLocalColOffset;
@@ -398,8 +408,10 @@ void ScHTMLLayoutParser::Adjust()
     SCROW nCurRow = 0;
     USHORT nPageWidth = (USHORT) aPageSize.Width();
     Table* pTab = NULL;
-    for ( ScEEParseEntry* pE = pList->First(); pE; pE = pList->Next() )
+    size_t ListSize = maList.size();
+    for ( size_t i = 0; i < ListSize; ++i )
     {
+        ScEEParseEntry* pE = maList[ i ];
         if ( pE->nTab < nTab )
         {   // Table beendet
             if ( (pS = aStack.Pop()) != 0 )
@@ -539,30 +551,31 @@ void ScHTMLLayoutParser::SetWidths()
             MakeColNoRef( pLocalColOffset, nOff, 0, 0, 0 );
         }
         nTableWidth = (USHORT)((*pLocalColOffset)[pLocalColOffset->Count() -1 ] - (*pLocalColOffset)[0]);
-        pE = pList->Seek( nFirstTableCell );
-        while ( pE )
+        size_t ListSize = maList.size();
+        for ( size_t i = nFirstTableCell; i < ListSize; ++i )
         {
+            pE = maList[ i ];
             if ( pE->nTab == nTable )
             {
                 pE->nOffset = (USHORT) (*pLocalColOffset)[pE->nCol - nColCntStart];
                 pE->nWidth = 0;     // to be recalculated later
             }
-            pE = pList->Next();
         }
     }
     else
     {   // einige mit einige ohne Width
-        pE = pList->Seek( nFirstTableCell );
         // #36350# wieso eigentlich kein pE ?!?
-        if ( pE )
+        if ( nFirstTableCell < maList.size() )
         {
             USHORT* pOffsets = new USHORT[ nColsPerRow+1 ];
             memset( pOffsets, 0, (nColsPerRow+1) * sizeof(USHORT) );
             USHORT* pWidths = new USHORT[ nColsPerRow ];
             memset( pWidths, 0, nColsPerRow * sizeof(USHORT) );
             pOffsets[0] = nColOffsetStart;
-            while ( pE )
+            size_t ListSize = maList.size();
+            for ( size_t i = nFirstTableCell; i < ListSize; ++i )
             {
+                pE = maList[ i ];
                 if ( pE->nTab == nTable && pE->nWidth )
                 {
                     nCol = pE->nCol - nColCntStart;
@@ -599,7 +612,6 @@ void ScHTMLLayoutParser::SetWidths()
                         }
                     }
                 }
-                pE = pList->Next();
             }
             USHORT nWidths = 0;
             USHORT nUnknown = 0;
@@ -632,9 +644,10 @@ void ScHTMLLayoutParser::SetWidths()
             }
             nTableWidth = pOffsets[nColsPerRow] - pOffsets[0];
 
-            pE = pList->Seek( nFirstTableCell );
-            while ( pE )
+            ListSize = maList.size();
+            for ( size_t i = nFirstTableCell; i < ListSize; ++i )
             {
+                pE = maList[ i ];
                 if ( pE->nTab == nTable )
                 {
                     nCol = pE->nCol - nColCntStart;
@@ -648,7 +661,6 @@ void ScHTMLLayoutParser::SetWidths()
                         pE->nWidth = pOffsets[nCol] - pE->nOffset;
                     }
                 }
-                pE = pList->Next();
             }
 
             delete [] pWidths;
@@ -661,9 +673,10 @@ void ScHTMLLayoutParser::SetWidths()
         if ( aPageSize.Width() < nMax )
             aPageSize.Width() = nMax;
     }
-    pE = pList->Seek( nFirstTableCell );
-    while ( pE )
+    size_t ListSize = maList.size();
+    for ( size_t i = nFirstTableCell; i < ListSize; ++i )
     {
+        pE = maList[ i ];
         if ( pE->nTab == nTable )
         {
             if ( !pE->nWidth )
@@ -673,7 +686,6 @@ void ScHTMLLayoutParser::SetWidths()
             }
             MakeCol( pColOffset, pE->nOffset, pE->nWidth, nOffsetTolerance, nOffsetTolerance );
         }
-        pE = pList->Next();
     }
 }
 
@@ -713,9 +725,19 @@ void ScHTMLLayoutParser::CloseEntry( ImportInfo* pInfo )
     if ( bTabInTabCell )
     {   // in TableOff vom Stack geholt
         bTabInTabCell = FALSE;
-        if ( pList->GetPos( pActEntry ) == LIST_ENTRY_NOTFOUND )
+        size_t ListSize = maList.size();
+        bool found = false;
+        for ( size_t i = 0; i < ListSize; ++i )
+        {
+            if ( pActEntry == maList[ i ] )
+            {
+                found = true;
+                break;
+            }
+        }
+        if ( !found )
             delete pActEntry;
-        NewActEntry( pList->Last() );   // neuer freifliegender pActEntry
+        NewActEntry( maList.back() );   // neuer freifliegender pActEntry
         return ;
     }
     if ( pActEntry->nTab == 0 )
@@ -745,7 +767,7 @@ void ScHTMLLayoutParser::CloseEntry( ImportInfo* pInfo )
     }
     if ( rSel.HasRange() )
         pActEntry->aItemSet.Put( SfxBoolItem( ATTR_LINEBREAK, TRUE ) );
-    pList->Insert( pActEntry, LIST_APPEND );
+    maList.push_back( pActEntry );
     NewActEntry( pActEntry );   // neuer freifliegender pActEntry
 }
 
@@ -1097,7 +1119,7 @@ void ScHTMLLayoutParser::TableOn( ImportInfo* pInfo )
             nColOffsetStart = nColOffset;
         }
 
-        ScEEParseEntry* pE = pList->Last();
+        ScEEParseEntry* pE = maList.back();
         NewActEntry( pE );      // neuer freifliegender pActEntry
         xLockedList = new ScRangeList;
     }
@@ -1144,7 +1166,7 @@ void ScHTMLLayoutParser::TableOn( ImportInfo* pInfo )
     }
     nTable = ++nMaxTable;
     bFirstRow = TRUE;
-    nFirstTableCell = pList->Count();
+    nFirstTableCell = maList.size();
 
     pLocalColOffset = new ScHTMLColOffset;
     MakeColNoRef( pLocalColOffset, nColOffsetStart, 0, 0, 0 );
@@ -1985,7 +2007,12 @@ ScHTMLTable::ScHTMLTable( ScHTMLTable& rParentTable, const ImportInfo& rInfo, bo
     CreateNewEntry( rInfo );
 }
 
-ScHTMLTable::ScHTMLTable( SfxItemPool& rPool, EditEngine& rEditEngine, ScEEParseList& rEEParseList, ScHTMLTableId& rnUnusedId ) :
+ScHTMLTable::ScHTMLTable(
+    SfxItemPool& rPool,
+    EditEngine& rEditEngine,
+    ::std::vector< ScEEParseEntry* >& rEEParseList,
+    ScHTMLTableId& rnUnusedId
+) :
     mpParentTable( 0 ),
     maTableId( rnUnusedId ),
     maTableItemSet( rPool ),
@@ -2336,7 +2363,7 @@ void ScHTMLTable::ImplPushEntryToList( ScHTMLEntryList& rEntryList, ScHTMLEntryP
     // HTML entry list does not own the entries
     rEntryList.push_back( rxEntry.get() );
     // mrEEParseList (reference to member of ScEEParser) owns the entries
-    mrEEParseList.Insert( rxEntry.release(), LIST_APPEND );
+    mrEEParseList.push_back( rxEntry.release() );
 }
 
 bool ScHTMLTable::PushEntry( ScHTMLEntryPtr& rxEntry )
@@ -2766,7 +2793,12 @@ void ScHTMLTable::RecalcDocPos( const ScHTMLPos& rBasePos )
 
 // ============================================================================
 
-ScHTMLGlobalTable::ScHTMLGlobalTable( SfxItemPool& rPool, EditEngine& rEditEngine, ScEEParseList& rEEParseList, ScHTMLTableId& rnUnusedId ) :
+ScHTMLGlobalTable::ScHTMLGlobalTable(
+    SfxItemPool& rPool,
+    EditEngine& rEditEngine,
+    ::std::vector< ScEEParseEntry* >& rEEParseList,
+    ScHTMLTableId& rnUnusedId
+) :
     ScHTMLTable( rPool, rEditEngine, rEEParseList, rnUnusedId )
 {
 }
@@ -2792,7 +2824,7 @@ ScHTMLQueryParser::ScHTMLQueryParser( EditEngine* pEditEngine, ScDocument* pDoc
     mnUnusedId( SC_HTML_GLOBAL_TABLE ),
     mbTitleOn( false )
 {
-    mxGlobTable.reset( new ScHTMLGlobalTable( *pPool, *pEdit, *pList, mnUnusedId ) );
+    mxGlobTable.reset( new ScHTMLGlobalTable( *pPool, *pEdit, maList, mnUnusedId ) );
     mpCurrTable = mxGlobTable.get();
 }
 
diff --git a/sc/source/filter/inc/eeparser.hxx b/sc/source/filter/inc/eeparser.hxx
index d65a4d2..e485921 100644
--- a/sc/source/filter/inc/eeparser.hxx
+++ b/sc/source/filter/inc/eeparser.hxx
@@ -37,6 +37,7 @@
 #include <editeng/editdata.hxx>
 #include <address.hxx>
 #include <boost/ptr_container/ptr_vector.hpp>
+#include <vector>
 
 const sal_Char nHorizontal = 1;
 const sal_Char nVertical = 2;
@@ -105,7 +106,6 @@ struct ScEEParseEntry
                                     maImageList.clear();
                             }
 };
-DECLARE_LIST( ScEEParseList, ScEEParseEntry* )
 
 
 class EditEngine;
@@ -116,7 +116,7 @@ protected:
     EditEngine*			pEdit;
     SfxItemPool*		pPool;
     SfxItemPool*		pDocPool;
-    ScEEParseList*		pList;
+    ::std::vector< ScEEParseEntry* > maList;
     ScEEParseEntry*		pActEntry;
     Table*				pColWidths;
     int					nLastToken;
@@ -131,14 +131,15 @@ public:
                         ScEEParser( EditEngine* );
     virtual				~ScEEParser();
 
-    virtual ULONG       Read( SvStream&, const String& rBaseURL ) = 0;
+    virtual ULONG           Read( SvStream&, const String& rBaseURL ) = 0;
 
-    void				GetDimensions( SCCOL& nCols, SCROW& nRows ) const
-                            { nCols = nColMax; nRows = nRowMax; }
-    ULONG				Count() const	{ return pList->Count(); }
-    ScEEParseEntry*		First() const	{ return pList->First(); }
-    ScEEParseEntry*		Next() const	{ return pList->Next(); }
-    Table*				GetColWidths() const { return pColWidths; }
+    Table*                  GetColWidths() const { return pColWidths; }
+    void                    GetDimensions( SCCOL& nCols, SCROW& nRows ) const
+                                { nCols = nColMax; nRows = nRowMax; }
+
+    inline size_t           ListSize() const{ return maList.size(); }
+    ScEEParseEntry*         ListEntry( size_t index ) { return maList[ index ]; }
+    const ScEEParseEntry*   ListEntry( size_t index ) const { return maList[ index ]; }
 };
 
 
diff --git a/sc/source/filter/inc/htmlpars.hxx b/sc/source/filter/inc/htmlpars.hxx
index 0c4e323..007e0e2 100644
--- a/sc/source/filter/inc/htmlpars.hxx
+++ b/sc/source/filter/inc/htmlpars.hxx
@@ -2,7 +2,7 @@
 /*************************************************************************
  *
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- * 
+ *
  * Copyright 2000, 2010 Oracle and/or its affiliates.
  *
  * OpenOffice.org - a multi-platform office productivity suite
@@ -442,7 +442,7 @@ protected:
     explicit            ScHTMLTable(
                             SfxItemPool& rPool,
                             EditEngine& rEditEngine,
-                            ScEEParseList& rEEParseList,
+                            ::std::vector< ScEEParseEntry* >& rEEParseList,
                             ScHTMLTableId& rnUnusedId );
 
     /** Fills all empty cells in this and nested tables with dummy parse entries. */
@@ -542,7 +542,7 @@ private:
     ScRangeList         maVMergedCells;     /// List of all vertically merged cells.
     ScRangeList         maUsedCells;        /// List of all used cells.
     EditEngine&         mrEditEngine;       /// Edit engine (from ScEEParser).
-    ScEEParseList&      mrEEParseList;      /// List that owns the parse entries (from ScEEParser).
+    ::std::vector< ScEEParseEntry* >& mrEEParseList;      /// List that owns the parse entries (from ScEEParser).
     ScHTMLEntryMap      maEntryMap;         /// List of entries for each cell.
     ScHTMLEntryList*    mpCurrEntryList;    /// Current entry list from map for faster access.
     ScHTMLEntryPtr      mxCurrEntry;        /// Working entry, not yet inserted in a list.
@@ -566,7 +566,7 @@ public:
     explicit            ScHTMLGlobalTable(
                             SfxItemPool& rPool,
                             EditEngine& rEditEngine,
-                            ScEEParseList& rEEParseList,
+                            ::std::vector< ScEEParseEntry* >& rEEParseList,
                             ScHTMLTableId& rnUnusedId );
 
     virtual             ~ScHTMLGlobalTable();
diff --git a/sc/source/filter/rtf/eeimpars.cxx b/sc/source/filter/rtf/eeimpars.cxx
index b4e9653..818d8cc 100644
--- a/sc/source/filter/rtf/eeimpars.cxx
+++ b/sc/source/filter/rtf/eeimpars.cxx
@@ -131,7 +131,7 @@ ULONG ScEEImport::Read( SvStream& rStream, const String& rBaseURL )
 void ScEEImport::WriteToDocument( BOOL bSizeColsRows, double nOutputFactor, SvNumberFormatter* pFormatter, bool bConvertDate )
 {
     ScProgress* pProgress = new ScProgress( mpDoc->GetDocumentShell(),
-        ScGlobal::GetRscString( STR_LOAD_DOC ), mpParser->Count() );
+        ScGlobal::GetRscString( STR_LOAD_DOC ), mpParser->ListSize() );
     ULONG nProgress = 0;
 
     SCCOL nStartCol, nEndCol;
@@ -160,8 +160,10 @@ void ScEEImport::WriteToDocument( BOOL bSizeColsRows, double nOutputFactor, SvNu
     }
     ScDocumentPool* pDocPool = mpDoc->GetPool();
     ScRangeName* pRangeNames = mpDoc->GetRangeName();
-    for ( pE = mpParser->First(); pE; pE = mpParser->Next() )
+    size_t ListSize = mpParser->ListSize();
+    for ( size_t i = 0; i < ListSize; ++i )
     {
+        pE = mpParser->ListEntry( i );
         SCROW nRow = nStartRow + pE->nRow;
         if ( nRow != nLastMergedRow )
             nMergeColAdd = 0;
@@ -452,9 +454,11 @@ void ScEEImport::WriteToDocument( BOOL bSizeColsRows, double nOutputFactor, SvNu
     }
     if ( bHasGraphics )
     {	// Grafiken einfuegen
-        for ( pE = mpParser->First(); pE; pE = mpParser->Next() )
+        size_t ListSize = mpParser->ListSize();
+        for ( size_t i = 0; i < ListSize; ++i )
         {
-            if ( pE->maImageList.size() )
+            pE = mpParser->ListEntry( i );
+            if ( !pE->maImageList.empty() )
             {
                 SCCOL nCol = pE->nCol;
                 SCROW nRow = pE->nRow;
@@ -603,7 +607,6 @@ ScEEParser::ScEEParser( EditEngine* pEditP ) :
         pEdit( pEditP ),
         pPool( EditEngine::CreatePool() ),
         pDocPool( new ScDocumentPool ),
-        pList( new ScEEParseList ),
         pColWidths( new Table ),
         nLastToken(0),
         nColCnt(0),
@@ -622,9 +625,7 @@ ScEEParser::~ScEEParser()
 {
     delete pActEntry;
     delete pColWidths;
-    for ( ScEEParseEntry* pE = pList->First(); pE; pE = pList->Next() )
-        delete pE;
-    delete pList;
+    if ( !maList.empty() ) maList.clear();
 
     // Pool erst loeschen nachdem die Listen geloescht wurden
     pPool->SetSecondaryPool( NULL );
diff --git a/sc/source/filter/rtf/rtfparse.cxx b/sc/source/filter/rtf/rtfparse.cxx
index bc1113b..f0cca62 100644
--- a/sc/source/filter/rtf/rtfparse.cxx
+++ b/sc/source/filter/rtf/rtfparse.cxx
@@ -2,7 +2,7 @@
 /*************************************************************************
  *
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- * 
+ *
  * Copyright 2000, 2010 Oracle and/or its affiliates.
  *
  * OpenOffice.org - a multi-platform office productivity suite
@@ -92,18 +92,23 @@ ULONG ScRTFParser::Read( SvStream& rStream, const String& rBaseURL )
     ULONG nErr = pEdit->Read( rStream, rBaseURL, EE_FORMAT_RTF );
     if ( nLastToken == RTF_PAR )
     {
-        ScEEParseEntry* pE = pList->Last();
-        if ( pE
-                // komplett leer
-            && (( pE->aSel.nStartPara == pE->aSel.nEndPara
-                    && pE->aSel.nStartPos == pE->aSel.nEndPos)
-                // leerer Paragraph
-                || ( pE->aSel.nStartPara + 1 == pE->aSel.nEndPara
-                    && pE->aSel.nStartPos == pEdit->GetTextLen( pE->aSel.nStartPara )
-                    && pE->aSel.nEndPos == 0 )) )
-        {	// den letzten leeren Absatz nicht uebernehmen
-            pList->Remove();
-            delete pE;
+        if ( !maList.empty() )
+        {
+            ScEEParseEntry* pE = maList.back();
+            if (    // komplett leer
+                (  (  pE->aSel.nStartPara == pE->aSel.nEndPara
+                   && pE->aSel.nStartPos  == pE->aSel.nEndPos
+                   )
+                ||  // leerer Paragraph
+                   (  pE->aSel.nStartPara + 1 == pE->aSel.nEndPara
+                   && pE->aSel.nStartPos      == pEdit->GetTextLen( pE->aSel.nStartPara )
+                   && pE->aSel.nEndPos        == 0
+                   )
+                )
+               )
+            {	// den letzten leeren Absatz nicht uebernehmen
+                maList.pop_back();
+            }
         }
     }
     ColAdjust();
@@ -158,9 +163,10 @@ void ScRTFParser::ColAdjust()
     {
         SCCOL nCol = 0;
         ScEEParseEntry* pE;
-        pE = pList->Seek( nStartAdjust );
-        while ( pE )
+        size_t ListSize = maList.size();
+        for ( size_t i = nStartAdjust; i < ListSize; ++ i )
         {
+            pE = maList[ i ];
             if ( pE->nCol == 0 )
                 nCol = 0;
             pE->nCol = nCol;
@@ -175,7 +181,6 @@ void ScRTFParser::ColAdjust()
             }
             if ( nCol > nColMax )
                 nColMax = nCol;
-            pE = pList->Next();
         }
         nStartAdjust = (ULONG)~0;
         pColTwips->Remove( (USHORT)0, pColTwips->Count() );
@@ -362,14 +367,17 @@ void ScRTFParser::ProcToken( ImportInfo* pInfo )
                 EntryEnd( pActEntry, pInfo->aSelection );
 
                 if ( nStartAdjust == (ULONG)~0 )
-                    nStartAdjust = pList->Count();
-                pList->Insert( pActEntry, LIST_APPEND );
+                    nStartAdjust = maList.size();
+                maList.push_back( pActEntry );
                 NewActEntry( pActEntry );	// neuer freifliegender pActEntry
             }
             else
             {	// aktuelle Twips der MergeCell zuweisen
-                if ( (pE = pList->Last()) != 0 )
+                if ( !maList.empty() )
+                {
+                    pE = maList.back();
                     pE->nTwips = pActDefault->nTwips;
+                }
                 // Selection des freifliegenden pActEntry anpassen
                 // Paragraph -1 wg. Textaufbruch in EditEngine waehrend Parse
                 pActEntry->aSel.nStartPara = pInfo->aSelection.nEndPara - 1;
@@ -392,7 +400,7 @@ void ScRTFParser::ProcToken( ImportInfo* pInfo )
                 pActEntry->nCol = 0;
                 pActEntry->nRow = nRowCnt;
                 EntryEnd( pActEntry, pInfo->aSelection );
-                pList->Insert( pActEntry, LIST_APPEND );
+                maList.push_back( pActEntry );
                 NewActEntry( pActEntry );	// new pActEntry
                 NextRow();
             }


More information about the Libreoffice-commits mailing list