[Libreoffice-commits] .: sc/source

Joseph Powers jpowers at kemper.freedesktop.org
Sat Dec 4 21:08:43 PST 2010


 sc/source/filter/inc/rtfparse.hxx |    6 +++---
 sc/source/filter/rtf/rtfparse.cxx |   34 ++++++++++++++++++++--------------
 2 files changed, 23 insertions(+), 17 deletions(-)

New commits:
commit 53701cb2f54887a09b6b63a258e8b73b096ca832
Author: Joseph Powers <jpowers27 at cox.net>
Date:   Sat Dec 4 21:08:36 2010 -0800

    Remove DECLARE_LIST( ScRTFDefaultList, ScRTFCellDefault* )

diff --git a/sc/source/filter/inc/rtfparse.hxx b/sc/source/filter/inc/rtfparse.hxx
index d4580c6..472c715 100644
--- a/sc/source/filter/inc/rtfparse.hxx
+++ b/sc/source/filter/inc/rtfparse.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
@@ -32,6 +32,7 @@
 #include "eeparser.hxx"
 
 #ifdef SC_RTFPARSE_CXX
+#include <boost/ptr_container/ptr_vector.hpp>
 
 struct ScRTFCellDefault
 {
@@ -43,9 +44,8 @@ struct ScRTFCellDefault
                         ScRTFCellDefault( SfxItemPool* pPool ) :
                             aItemSet( *pPool ), nColOverlap(1) {}
 };
+typedef boost::ptr_vector< ScRTFCellDefault > ScRTFDefaultList;
 
-DECLARE_LIST( ScRTFDefaultList, ScRTFCellDefault* )
-// Remove: (const unsigned short &) not sufficiently different from (unsigned short)
 // deswegen ULONG, typedef bringt's auch nicht :-(
 SV_DECL_VARARR_SORT( ScRTFColTwips, ULONG, 16, 4)
 
diff --git a/sc/source/filter/rtf/rtfparse.cxx b/sc/source/filter/rtf/rtfparse.cxx
index e9d7cf1..513b0b5 100644
--- a/sc/source/filter/rtf/rtfparse.cxx
+++ b/sc/source/filter/rtf/rtfparse.cxx
@@ -79,8 +79,7 @@ ScRTFParser::~ScRTFParser()
 {
     delete pInsDefault;
     delete pColTwips;
-    for ( ScRTFCellDefault* pD = pDefaultList->First(); pD; pD = pDefaultList->Next() )
-        delete pD;
+    pDefaultList->clear();
     delete pDefaultList;
 }
 
@@ -240,8 +239,10 @@ void ScRTFParser::NewCellRow( ImportInfo* /*pInfo*/ )
         ScRTFCellDefault* pD;
         bNewDef = FALSE;
         // rechts nicht buendig? => neue Tabelle
-        if ( nLastWidth
-          && ((pD = pDefaultList->Last()) != 0) && pD->nTwips != nLastWidth )
+        if (  nLastWidth
+           && ( (pD = &(pDefaultList->back())) != 0 )
+           && pD->nTwips != nLastWidth
+           )
         {
             SCCOL n1, n2;
             if ( !( SeekTwips( nLastWidth, &n1 )
@@ -249,15 +250,17 @@ void ScRTFParser::NewCellRow( ImportInfo* /*pInfo*/ )
                 ColAdjust();
         }
         // TwipCols aufbauen, erst nach nLastWidth Vergleich!
-        for ( pD = pDefaultList->First(); pD; pD = pDefaultList->Next() )
+        size_t ListSize = pDefaultList->size();
+        for ( size_t i = 0; i < ListSize; ++i )
         {
+            pD = &( pDefaultList->at( i ) );
             SCCOL n;
             if ( !SeekTwips( pD->nTwips, &n ) )
                 pColTwips->Insert( pD->nTwips );
         }
     }
     pDefMerge = NULL;
-    pActDefault = pDefaultList->First();
+    pActDefault = &(pDefaultList->front());
     DBG_ASSERT( pActDefault, "NewCellRow: pActDefault==0" );
 }
 
@@ -297,12 +300,10 @@ void ScRTFParser::ProcToken( ImportInfo* pInfo )
     {
         case RTF_TROWD:			// denotes table row defauls, before RTF_CELLX
         {
-            if ( (pD = pDefaultList->Last()) != 0 )
+            if ( (pD = &(pDefaultList->back())) != 0 )
                 nLastWidth = pD->nTwips;
             nColCnt = 0;
-            for ( pD = pDefaultList->First(); pD; pD = pDefaultList->Next() )
-                delete pD;
-            pDefaultList->Clear();
+            pDefaultList->clear();
             pDefMerge = NULL;
             nLastToken = pInfo->nToken;
         }
@@ -315,8 +316,10 @@ void ScRTFParser::ProcToken( ImportInfo* pInfo )
         break;
         case RTF_CLMRG:			// A cell to be merged with the preceding cell
         {
-            if ( !pDefMerge )
-                pDefMerge = pDefaultList->Last();
+            if ( !pDefMerge
+               && !(pDefaultList->empty())
+               )
+                pDefMerge = &( pDefaultList->back() );
             DBG_ASSERT( pDefMerge, "RTF_CLMRG: pDefMerge==0" );
             if ( pDefMerge )		// sonst rottes RTF
                 pDefMerge->nColOverlap++;	// mehrere nacheinander moeglich
@@ -329,7 +332,7 @@ void ScRTFParser::ProcToken( ImportInfo* pInfo )
             bNewDef = TRUE;
             pInsDefault->nCol = nColCnt;
             pInsDefault->nTwips = pInfo->nTokenValue;	// rechter Zellenrand
-            pDefaultList->Insert( pInsDefault, LIST_APPEND );
+            pDefaultList->push_back( pInsDefault );
             // neuer freifliegender pInsDefault
             pInsDefault = new ScRTFCellDefault( pPool );
             if ( ++nColCnt > nColMax )
@@ -381,7 +384,10 @@ void ScRTFParser::ProcToken( ImportInfo* pInfo )
                 // Paragraph -1 wg. Textaufbruch in EditEngine waehrend Parse
                 pActEntry->aSel.nStartPara = pInfo->aSelection.nEndPara - 1;
             }
-            pActDefault = pDefaultList->Next();
+            if ( pDefaultList->empty() )
+                pActDefault = NULL;
+            else
+                pActDefault = &( pDefaultList->back() );
             nLastToken = pInfo->nToken;
         }
         break;


More information about the Libreoffice-commits mailing list