[Libreoffice-commits] .: sc/source

Ivan Timofeev ivantimofeev at kemper.freedesktop.org
Thu Mar 15 09:13:38 PDT 2012


 sc/source/filter/html/htmlpars.cxx |    3 ++-
 sc/source/filter/inc/eeparser.hxx  |    8 +++++---
 sc/source/filter/rtf/eeimpars.cxx  |   28 ++++++++++++++++------------
 3 files changed, 23 insertions(+), 16 deletions(-)

New commits:
commit 96328945afe8f920df41741931163ba56b7b2820
Author: Noel Grandin <noel at peralex.com>
Date:   Wed Mar 14 14:00:35 2012 +0200

    Convert tools/table.hxx to std::map in ScEEParser class in SC module

diff --git a/sc/source/filter/html/htmlpars.cxx b/sc/source/filter/html/htmlpars.cxx
index 323e1a2..b9f9fb8 100644
--- a/sc/source/filter/html/htmlpars.cxx
+++ b/sc/source/filter/html/htmlpars.cxx
@@ -58,6 +58,7 @@
 #include <vcl/svapp.hxx>
 #include <tools/urlobj.hxx>
 #include <tools/tenccvt.hxx>
+#include <tools/table.hxx>
 
 #include "htmlpars.hxx"
 #include "global.hxx"
@@ -331,7 +332,7 @@ sal_uLong ScHTMLLayoutParser::Read( SvStream& rStream, const String& rBaseURL )
     {
         aSize.Width() = *pOff - nOff;
         aSize = pDefaultDev->PixelToLogic( aSize, MapMode( MAP_TWIP ) );
-        pColWidths->Insert( j-1, (void*)aSize.Width() );
+        maColWidths[ j-1 ] = aSize.Width();
         nOff = *pOff;
     }
     return nErr;
diff --git a/sc/source/filter/inc/eeparser.hxx b/sc/source/filter/inc/eeparser.hxx
index dc1daf1..9c272d0 100644
--- a/sc/source/filter/inc/eeparser.hxx
+++ b/sc/source/filter/inc/eeparser.hxx
@@ -32,7 +32,6 @@
 #include <tools/string.hxx>
 #include <tools/gen.hxx>
 #include <vcl/graph.hxx>
-#include <tools/table.hxx>
 #include <svl/itemset.hxx>
 #include <editeng/editdata.hxx>
 #include <address.hxx>
@@ -108,6 +107,8 @@ struct ScEEParseEntry
 
 class EditEngine;
 
+typedef std::map<SCCOL, sal_uInt16> ColWidthsMap;
+
 class ScEEParser
 {
 protected:
@@ -116,7 +117,7 @@ protected:
     SfxItemPool*        pDocPool;
     ::std::vector< ScEEParseEntry* > maList;
     ScEEParseEntry*     pActEntry;
-    Table*              pColWidths;
+    ColWidthsMap        maColWidths;
     int                 nLastToken;
     SCCOL               nColCnt;
     SCROW               nRowCnt;
@@ -131,7 +132,8 @@ public:
 
     virtual sal_uLong           Read( SvStream&, const String& rBaseURL ) = 0;
 
-    Table*                  GetColWidths() const { return pColWidths; }
+    const ColWidthsMap&     GetColWidths() const { return maColWidths; }
+    ColWidthsMap&           GetColWidths() { return maColWidths; }
     void                    GetDimensions( SCCOL& nCols, SCROW& nRows ) const
                                 { nCols = nColMax; nRows = nRowMax; }
 
diff --git a/sc/source/filter/rtf/eeimpars.cxx b/sc/source/filter/rtf/eeimpars.cxx
index 2fb0484..d34e135 100644
--- a/sc/source/filter/rtf/eeimpars.cxx
+++ b/sc/source/filter/rtf/eeimpars.cxx
@@ -52,6 +52,7 @@
 #include <unotools/syslocale.hxx>
 #include <unotools/charclass.hxx>
 #include <comphelper/string.hxx>
+#include <tools/table.hxx>
 
 #include "eeimport.hxx"
 #include "global.hxx"
@@ -431,14 +432,17 @@ void ScEEImport::WriteToDocument( sal_Bool bSizeColsRows, double nOutputFactor,
     if ( bSizeColsRows )
     {
         // Spaltenbreiten
-        Table* pColWidths = mpParser->GetColWidths();
-        if ( pColWidths->Count() )
+        ColWidthsMap& rColWidths = mpParser->GetColWidths();
+        if ( !rColWidths.empty() )
         {
             nProgress = 0;
             pProgress->SetState( nProgress, nEndCol - nStartCol + 1 );
             for ( SCCOL nCol = nStartCol; nCol <= nEndCol; nCol++ )
             {
-                sal_uInt16 nWidth = (sal_uInt16)(sal_uLong) pColWidths->Get( nCol );
+                sal_uInt16 nWidth = 0;
+                ColWidthsMap::const_iterator it = rColWidths.find( nCol );
+                if ( it != rColWidths.end() )
+                    nWidth = it->second;
                 if ( nWidth )
                     mpDoc->SetColWidth( nCol, nTab, nWidth );
                 pProgress->SetState( ++nProgress );
@@ -513,20 +517,22 @@ sal_Bool ScEEImport::GraphicSize( SCCOL nCol, SCROW nRow, SCTAB /*nTab*/, ScEEPa
         nDir = pI->nDir;
     }
     // Spaltenbreiten
-    Table* pColWidths = mpParser->GetColWidths();
-    long nThisWidth = (long) pColWidths->Get( nCol );
+    ColWidthsMap& rColWidths = mpParser->GetColWidths();
+    long nThisWidth = 0;
+    ColWidthsMap::const_iterator it = rColWidths.find( nCol );
+    if ( it != rColWidths.end() )
+        nThisWidth = it->second;
     long nColWidths = nThisWidth;
     SCCOL nColSpanCol = nCol + pE->nColOverlap;
     for ( SCCOL nC = nCol + 1; nC < nColSpanCol; nC++ )
     {
-        nColWidths += (long) pColWidths->Get( nC );
+        ColWidthsMap::const_iterator it2 = rColWidths.find( nC   );
+        if ( it2 != rColWidths.end() )
+            nColWidths += it2->second;
     }
     if ( nWidth > nColWidths )
     {   // Differenz nur in der ersten Spalte eintragen
-        if ( nThisWidth )
-            pColWidths->Replace( nCol, (void*)(nWidth - nColWidths + nThisWidth) );
-        else
-            pColWidths->Insert( nCol, (void*)(nWidth - nColWidths) );
+        rColWidths[ nCol ] = nWidth - nColWidths + nThisWidth;
     }
     // Zeilenhoehen, Differenz auf alle betroffenen Zeilen verteilen
     SCROW nRowSpan = pE->nRowOverlap;
@@ -619,7 +625,6 @@ ScEEParser::ScEEParser( EditEngine* pEditP ) :
         pEdit( pEditP ),
         pPool( EditEngine::CreatePool() ),
         pDocPool( new ScDocumentPool ),
-        pColWidths( new Table ),
         nLastToken(0),
         nColCnt(0),
         nRowCnt(0),
@@ -636,7 +641,6 @@ ScEEParser::ScEEParser( EditEngine* pEditP ) :
 ScEEParser::~ScEEParser()
 {
     delete pActEntry;
-    delete pColWidths;
     if ( !maList.empty() ) maList.clear();
 
     // Pool erst loeschen nachdem die Listen geloescht wurden


More information about the Libreoffice-commits mailing list