[Libreoffice-commits] .: 2 commits - sc/source

Fridrich Strba fridrich at kemper.freedesktop.org
Wed Mar 21 22:45:47 PDT 2012


 sc/source/filter/html/htmlpars.cxx |   86 +++++++++++++++++++++++--------------
 sc/source/filter/inc/eeimport.hxx  |    6 +-
 sc/source/filter/inc/htmlpars.hxx  |    6 ++
 sc/source/filter/rtf/eeimpars.cxx  |   18 +++----
 4 files changed, 71 insertions(+), 45 deletions(-)

New commits:
commit 7d7e2c3636661c52ff708eb7799f481db5f98dfc
Author: Noel Grandin <noel at peralex.com>
Date:   Mon Mar 19 11:12:51 2012 +0200

    Convert tools/table.hxx to std::map in class ScHTMLLayoutParser

diff --git a/sc/source/filter/html/htmlpars.cxx b/sc/source/filter/html/htmlpars.cxx
index b9f9fb8..aaae381 100644
--- a/sc/source/filter/html/htmlpars.cxx
+++ b/sc/source/filter/html/htmlpars.cxx
@@ -282,8 +282,8 @@ ScHTMLLayoutParser::~ScHTMLLayoutParser()
         delete pColOffset;
     if ( pTables )
     {
-        for ( Table* pT = (Table*) pTables->First(); pT; pT = (Table*) pTables->Next() )
-            delete pT;
+        for( OuterMap::const_iterator it = pTables->begin(); it != pTables->end(); ++it)
+            delete it->second;
         delete pTables;
     }
 }
@@ -539,7 +539,7 @@ void ScHTMLLayoutParser::Adjust()
     SCROW nNextRow = 0;
     SCROW nCurRow = 0;
     sal_uInt16 nPageWidth = (sal_uInt16) aPageSize.Width();
-    Table* pTab = NULL;
+    InnerMap* pTab = NULL;
     for ( size_t i = 0, nListSize = maList.size(); i < nListSize; ++i )
     {
         ScEEParseEntry* pE = maList[ i ];
@@ -556,7 +556,12 @@ void ScHTMLLayoutParser::Adjust()
             }
             delete pS;
             nTab = pE->nTab;
-            pTab = (pTables ? (Table*) pTables->Get( nTab ) : NULL);
+            if (pTables)
+            {
+                OuterMap::const_iterator it = pTables->find( nTab );
+                if ( it != pTables->end() )
+                    pTab = it->second;
+            }
 
         }
         SCROW nRow = pE->nRow;
@@ -566,8 +571,14 @@ void ScHTMLLayoutParser::Adjust()
                 pE->nRow = nCurRow = nNextRow;
             else
                 nCurRow = nNextRow = pE->nRow;
-            SCROW nR;
-            if ( pTab && ((nR = (SCROW)(sal_uLong)pTab->Get( nCurRow )) != 0) )
+            SCROW nR = 0;
+            if ( pTab )
+            {
+                InnerMap::const_iterator it = pTab->find( nCurRow );
+                if ( it != pTab->end() )
+                    nR = it->second;
+            }
+            if ( nR )
                 nNextRow += nR;
             else
                 nNextRow++;
@@ -580,10 +591,21 @@ void ScHTMLLayoutParser::Adjust()
             aStack.push( new ScHTMLAdjustStackEntry(
                 nLastCol, nNextRow, nCurRow ) );
             nTab = pE->nTab;
-            pTab = (pTables ? (Table*) pTables->Get( nTab ) : NULL);
+            if ( pTables )
+            {
+                OuterMap::const_iterator it = pTables->find( nTab );
+                if ( it != pTables->end() )
+                    pTab = it->second;
+            }
             // neuer Zeilenabstand
-            SCROW nR;
-            if ( pTab && ((nR = (SCROW)(sal_uLong)pTab->Get( nCurRow )) != 0) )
+            SCROW nR = 0;
+            if ( pTab )
+            {
+                InnerMap::const_iterator it = pTab->find( nCurRow );
+                if ( it != pTab->end() )
+                    nR = it->second;
+            }
+            if ( nR )
                 nNextRow = nCurRow + nR;
             else
                 nNextRow = nCurRow + 1;
@@ -597,7 +619,10 @@ 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 = 0;
+                    InnerMap::const_iterator it = pTab->find( nRow+j );
+                    if ( it != pTab->end() )
+                        nRows = it->second;
                     if ( nRows > 1 )
                     {
                         pE->nRowOverlap += nRows - 1;
@@ -1229,14 +1254,17 @@ void ScHTMLLayoutParser::TableOff( ImportInfo* pInfo )
                 SCROW nRow = pS->nRowCnt;
                 sal_uInt16 nTab = pS->nTable;
                 if ( !pTables )
-                    pTables = new Table;
+                    pTables = new OuterMap;
                 // Hoehen der aeusseren Table
-                Table* pTab1 = (Table*) pTables->Get( nTab );
-                if ( !pTab1 )
+                OuterMap::const_iterator it = pTables->find( nTab );
+                InnerMap* pTab1;
+                if ( it == pTables->end() )
                 {
-                    pTab1 = new Table;
-                    pTables->Insert( nTab, pTab1 );
+                    pTab1 = new InnerMap;
+                    (*pTables)[ nTab ] = pTab1;
                 }
+                else
+                    pTab1 = it->second;
                 SCROW nRowSpan = pE->nRowOverlap;
                 SCROW nRowKGV;
                 SCROW nRowsPerRow1;    // aeussere Table
@@ -1253,11 +1281,11 @@ void ScHTMLLayoutParser::TableOff( ImportInfo* pInfo )
                     nRowKGV = nRowsPerRow1 = nRows;
                     nRowsPerRow2 = 1;
                 }
-                Table* pTab2 = NULL;
+                InnerMap* pTab2 = NULL;
                 if ( nRowsPerRow2 > 1 )
                 {   // Hoehen der inneren Table
-                    pTab2 = new Table;
-                    pTables->Insert( nTable, pTab2 );
+                    pTab2 = new InnerMap;
+                    (*pTables)[ nTable ] = pTab2;
                 }
                 // void* Data-Entry der Table-Class fuer das
                 // Hoehen-Mapping missbrauchen
@@ -1268,11 +1296,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 = (*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 )
@@ -1281,11 +1309,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 = (*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;
                                     }
                                 }
@@ -1296,17 +1324,13 @@ void ScHTMLLayoutParser::TableOff( ImportInfo* pInfo )
                     {   // innen
                         if ( !pTab2 )
                         {   // nRowsPerRow2 kann erhoeht worden sein
-                            pTab2 = new Table;
-                            pTables->Insert( nTable, pTab2 );
+                            pTab2 = new InnerMap;
+                            (*pTables)[ nTable ] = pTab2;
                         }
                         for ( SCROW j=0; j < nRows; j++ )
                         {
                             sal_uLong nRowKey = nRow + j;
-                            SCROW nR = (SCROW)(sal_uLong)pTab2->Get( nRowKey );
-                            if ( !nR )
-                                pTab2->Insert( nRowKey, (void*)(sal_IntPtr)nRowsPerRow2 );
-                            else if ( nRowsPerRow2 > nR )
-                                pTab2->Replace( nRowKey, (void*)(sal_IntPtr)nRowsPerRow2 );
+                            (*pTab2)[ nRowKey ] = nRowsPerRow2;
                         }
                     }
                 }
diff --git a/sc/source/filter/inc/htmlpars.hxx b/sc/source/filter/inc/htmlpars.hxx
index 24032b3..30f72c9 100644
--- a/sc/source/filter/inc/htmlpars.hxx
+++ b/sc/source/filter/inc/htmlpars.hxx
@@ -39,7 +39,6 @@
 
 #include "rangelst.hxx"
 #include "eeparser.hxx"
-#include "tools/table.hxx"
 
 const sal_uInt32 SC_HTML_FONTSIZES = 7;        // wie Export, HTML-Options
 
@@ -166,6 +165,10 @@ class EditEngine;
 class ScDocument;
 class HTMLOption;
 
+// TODO these need better names
+typedef ::std::map<SCROW, SCROW> InnerMap;
+typedef ::std::map<sal_uInt16, InnerMap*> OuterMap;
+
 class ScHTMLLayoutParser : public ScHTMLParser
 {
 private:
@@ -174,7 +177,7 @@ private:
     ScHTMLTableStack    aTableStack;
     rtl::OUString       aString;
     ScRangeListRef      xLockedList;        // je Table
-    Table*              pTables;
+    OuterMap*           pTables;
     ScHTMLColOffset*    pColOffset;
     ScHTMLColOffset*    pLocalColOffset;    // je Table
     sal_uLong               nFirstTableCell;    // je Table
commit 157b2fa62490df3143be1317f752ce405ee60000
Author: Noel Grandin <noel at peralex.com>
Date:   Mon Mar 19 09:54:38 2012 +0200

    Convert tools/table.hxx usage to std::map in ScEEImport class

diff --git a/sc/source/filter/inc/eeimport.hxx b/sc/source/filter/inc/eeimport.hxx
index ed74cc2..cc3e681 100644
--- a/sc/source/filter/inc/eeimport.hxx
+++ b/sc/source/filter/inc/eeimport.hxx
@@ -32,15 +32,17 @@
 #include "address.hxx"
 #include "filter.hxx"
 #include "scdllapi.h"
+#include <map>
 
 class ScDocument;
 class ScEEParser;
 class ScTabEditEngine;
 class SvStream;
-class Table;
 
 struct ScEEParseEntry;
 
+typedef std::map<SCROW, long> RowHeightMap;
+
 class ScEEImport : public ScEEAbsImport
 {
 protected:
@@ -48,7 +50,7 @@ protected:
     ScDocument*         mpDoc;
     ScEEParser*         mpParser;
     ScTabEditEngine*    mpEngine;
-    Table*              mpRowHeights;
+    RowHeightMap        maRowHeights;
 
     sal_Bool                GraphicSize( SCCOL nCol, SCROW nRow, SCTAB nTab,
                                      ScEEParseEntry* );
diff --git a/sc/source/filter/inc/htmlpars.hxx b/sc/source/filter/inc/htmlpars.hxx
index b8846c4..24032b3 100644
--- a/sc/source/filter/inc/htmlpars.hxx
+++ b/sc/source/filter/inc/htmlpars.hxx
@@ -39,6 +39,7 @@
 
 #include "rangelst.hxx"
 #include "eeparser.hxx"
+#include "tools/table.hxx"
 
 const sal_uInt32 SC_HTML_FONTSIZES = 7;        // wie Export, HTML-Options
 
diff --git a/sc/source/filter/rtf/eeimpars.cxx b/sc/source/filter/rtf/eeimpars.cxx
index d34e135..6b8df27 100644
--- a/sc/source/filter/rtf/eeimpars.cxx
+++ b/sc/source/filter/rtf/eeimpars.cxx
@@ -52,7 +52,6 @@
 #include <unotools/syslocale.hxx>
 #include <unotools/charclass.hxx>
 #include <comphelper/string.hxx>
-#include <tools/table.hxx>
 
 #include "eeimport.hxx"
 #include "global.hxx"
@@ -79,8 +78,7 @@ extern void ScLimitSizeOnDrawPage( Size& rSize, Point& rPos, const Size& rPage )
 ScEEImport::ScEEImport( ScDocument* pDocP, const ScRange& rRange ) :
     maRange( rRange ),
     mpDoc( pDocP ),
-    mpParser( NULL ),
-    mpRowHeights( new Table )
+    mpParser( NULL )
 {
     const ScPatternAttr* pPattern = mpDoc->GetPattern(
         maRange.aStart.Col(), maRange.aStart.Row(), maRange.aStart.Tab() );
@@ -95,7 +93,6 @@ ScEEImport::~ScEEImport()
     // Reihenfolge wichtig, sonst knallt's irgendwann irgendwo in irgendeinem Dtor!
     // Ist gewaehrleistet, da ScEEImport Basisklasse ist
     delete mpEngine;        // nach Parser!
-    delete mpRowHeights;
 }
 
 
@@ -458,11 +455,12 @@ void ScEEImport::WriteToDocument( sal_Bool bSizeColsRows, double nOutputFactor,
         mpDoc->SetOptimalHeight( 0, nEndRow, 0,
             static_cast< sal_uInt16 >( ScGlobal::nLastRowHeightExtra ), &aVirtDev,
             nPPTX, nPPTY, aZoom, aZoom, false );
-        if ( mpRowHeights->Count() )
+        if ( !maRowHeights.empty() )
         {
             for ( SCROW nRow = nStartRow; nRow <= nEndRow; nRow++ )
             {
-                sal_uInt16 nHeight = (sal_uInt16)(sal_uLong) mpRowHeights->Get( nRow );
+                RowHeightMap::const_iterator it = maRowHeights.find( nRow );
+                sal_uInt16 nHeight = it == maRowHeights.end() ? 0 : it->second;
                 if ( nHeight > mpDoc->GetRowHeight( nRow, nTab ) )
                     mpDoc->SetRowHeight( nRow, nTab, nHeight );
             }
@@ -541,13 +539,11 @@ sal_Bool ScEEImport::GraphicSize( SCCOL nCol, SCROW nRow, SCTAB /*nTab*/, ScEEPa
         nHeight = 1;        // fuer eindeutigen Vergleich
     for ( SCROW nR = nRow; nR < nRow + nRowSpan; nR++ )
     {
-        long nRowHeight = (long) mpRowHeights->Get( nR );
+        RowHeightMap::const_iterator it2 = maRowHeights.find( nR );
+        long nRowHeight = it2 == maRowHeights.end() ? 0 : it2->second;
         if ( nHeight > nRowHeight )
         {
-            if ( nRowHeight )
-                mpRowHeights->Replace( nR, (void*)nHeight );
-            else
-                mpRowHeights->Insert( nR, (void*)nHeight );
+            maRowHeights[ nR ] = nHeight;
         }
     }
     return bHasGraphics;


More information about the Libreoffice-commits mailing list