[Libreoffice-commits] .: binfilter/bf_sc binfilter/inc

Joseph Powers jpowers at kemper.freedesktop.org
Thu Jan 13 21:47:28 PST 2011


 binfilter/bf_sc/source/core/tool/sc_rangelst.cxx |   20 ++--
 binfilter/bf_sc/source/ui/unoobj/sc_chartuno.cxx |    4 
 binfilter/inc/bf_sc/rangelst.hxx                 |  110 ++++++++++++++++++++---
 3 files changed, 112 insertions(+), 22 deletions(-)

New commits:
commit 39f10b2cf4c87591ecc1bfe6833f6118096f8525
Author: Joseph Powers <jpowers27 at cox.net>
Date:   Thu Jan 13 21:47:22 2011 -0800

    Remove DECLARE_LIST( ScRangeListBase, ScRangePtr )

diff --git a/binfilter/bf_sc/source/core/tool/sc_rangelst.cxx b/binfilter/bf_sc/source/core/tool/sc_rangelst.cxx
index 147cf91..459b5df 100644
--- a/binfilter/bf_sc/source/core/tool/sc_rangelst.cxx
+++ b/binfilter/bf_sc/source/core/tool/sc_rangelst.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
@@ -46,15 +46,16 @@ namespace binfilter {
 
 /*N*/ ScRangeList::~ScRangeList()
 /*N*/ {
-/*N*/ 	for ( ScRangePtr pR = First(); pR; pR = Next() )
-/*N*/ 		delete pR;
+        for ( size_t i = 0, n = maList.size(); i < n; ++i )
+            delete maList[ i ];
+        maList.clear();
 /*N*/ }
 
 /*N*/ void ScRangeList::RemoveAll()
 /*N*/ {
-/*N*/ 	for ( ScRangePtr pR = First(); pR; pR = Next() )
-/*N*/ 		delete pR;
-/*N*/ 	Clear();
+        for ( size_t i = 0, n = maList.size(); i < n; ++i )
+            delete maList[ i ];
+        maList.clear();
 /*N*/ }
 
 /*N*/ USHORT ScRangeList::Parse( const String& rStr, ScDocument* pDoc, USHORT nMask )
@@ -273,8 +274,7 @@ namespace binfilter {
 
 
 /*N*/ ScRangeList::ScRangeList( const ScRangeList& rList )
-/*N*/     : ScRangeListBase()
-/*N*/     , SvRefBase()
+/*N*/     : SvRefBase()
 /*N*/ {
 /*N*/ 	ULONG nLclCount = rList.Count();
 /*N*/ 	for ( ULONG j = 0; j < nLclCount; j++ )
@@ -287,11 +287,11 @@ namespace binfilter {
 /*N*/ ScRangeList& ScRangeList::operator=(const ScRangeList& rList)
 /*N*/ {
 /*N*/ 	RemoveAll();
-/*N*/ 
+/*N*/
 /*N*/ 	ULONG nLclCount = rList.Count();
 /*N*/ 	for ( ULONG j = 0; j < nLclCount; j++ )
 /*N*/ 		Append( *rList.GetObject( j ) );
-/*N*/ 
+/*N*/
 /*N*/ 	return *this;
 /*N*/ }
 
diff --git a/binfilter/bf_sc/source/ui/unoobj/sc_chartuno.cxx b/binfilter/bf_sc/source/ui/unoobj/sc_chartuno.cxx
index 41a15c1..887e231 100644
--- a/binfilter/bf_sc/source/ui/unoobj/sc_chartuno.cxx
+++ b/binfilter/bf_sc/source/ui/unoobj/sc_chartuno.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
@@ -575,7 +575,7 @@ void SAL_CALL ScChartObj::setRanges( const uno::Sequence<table::CellRangeAddress
     }
     ScRangeListRef xNewRanges( pList );
 
-    if ( !xOldRanges.Is() || *xOldRanges != *xNewRanges )
+    if ( !xOldRanges.Is() || (*xOldRanges) != (*xNewRanges) )
         Update_Impl( xNewRanges, bColHeaders, bRowHeaders );
 }
 
diff --git a/binfilter/inc/bf_sc/rangelst.hxx b/binfilter/inc/bf_sc/rangelst.hxx
index a21ba6b..831fa0d 100644
--- a/binfilter/inc/bf_sc/rangelst.hxx
+++ b/binfilter/inc/bf_sc/rangelst.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
@@ -30,25 +30,27 @@
 #define SC_RANGELST_HXX
 
 #include "global.hxx"
+#include <vector>
+
 namespace binfilter {
 
 class ScDocument;
 
 typedef ScRange* ScRangePtr;
-DECLARE_LIST( ScRangeListBase, ScRangePtr )
-class ScRangeList : public ScRangeListBase, public SvRefBase
+typedef ::std::vector< ScRangePtr > ScRangeListBase;
+
+class ScRangeList : public SvRefBase
 {
+private:
+    ScRangeListBase maList;
+    size_t current;
+
 public:
                     ScRangeList() {}
                     ScRangeList( const ScRangeList& rList );
     virtual 		~ScRangeList();
     ScRangeList&	operator=(const ScRangeList& rList);
     void			RemoveAll();
-    void			Append( const ScRange& rRange )
-                    {
-                        ScRangePtr pR = new ScRange( rRange );
-                        Insert( pR, LIST_APPEND );
-                    }
     USHORT			Parse( const String&, ScDocument* = NULL,
                             USHORT nMask = SCA_VALID );
     void 			Format( String&, USHORT nFlags = 0, ScDocument* = NULL ) const;
@@ -56,8 +58,96 @@ public:
     BOOL 			UpdateReference( UpdateRefMode, ScDocument*,
                                     const ScRange& rWhere,
                                     short nDx, short nDy, short nDz );
-/*N*/ 	BOOL			Load( SvStream&, USHORT nVer );
-/*N*/ 	BOOL			Store( SvStream& ) const;
+    BOOL			Load( SvStream&, USHORT nVer );
+    BOOL			Store( SvStream& ) const;
+
+    size_t          Count() const { return maList.size(); }
+    size_t          GetCurPos() const { return current; }
+
+    size_t          GetPos( ScRange* item )
+                    {
+                        for ( size_t i = 0, n = maList.size(); i < n; ++i )
+                            if ( maList[ i ] == item ) return i;
+                        return size_t(-1);
+                    }
+
+    void            Seek( size_t i ) { current = i; }
+
+    ScRange*        First()
+                    {
+                        current = 0;
+                        return maList.empty() ? NULL : maList[ current ];
+                    }
+
+    ScRange*        Next()
+                    {
+                        if ( current+1 < maList.size() )
+                        {
+                            ++current;
+                            return maList[ current ];
+                        }
+                        return NULL;
+                    }
+
+    ScRange*        GetObject( size_t i )
+                    {
+                        if ( i >= maList.size() ) return NULL;
+                        return maList[ i ];
+                    }
+
+    ScRange*        GetObject( size_t i ) const
+                    {
+                        if ( i >= maList.size() ) return NULL;
+                        return maList[ i ];
+                    }
+
+    ScRange*        Remove( size_t i )
+                    {
+                        if ( i < maList.size() )
+                        {
+                            ScRangeListBase::iterator it = maList.begin();
+                            ::std::advance( it, i );
+                            maList.erase( it );
+                            current = i;
+                        }
+                        return NULL;
+                    }
+
+    void            Insert( ScRange* item, size_t i )
+                    {
+                        if ( i < maList.size() )
+                        {
+                            ScRangeListBase::iterator it = maList.begin();
+                            ::std::advance( it, i );
+                            maList.insert( it, item );
+                            current = i;
+                        }
+                        else
+                        {
+                            current = maList.size();
+                            maList.push_back( item );
+                        }
+                    }
+
+    void			Append( const ScRange& rRange )
+                    {
+                        ScRangePtr pR = new ScRange( rRange );
+                        maList.push_back( pR );
+                    }
+
+    bool            operator ==( const ScRangeList& rList ) const
+                    {
+                        if ( maList.size() != rList.Count() ) return false;
+                        for ( size_t i = 0, n = maList.size(); i < n; ++i )
+                            if ( maList[ i ] != rList.GetObject( i ) ) return false;
+                        return true;
+                    }
+
+    bool            operator !=( const ScRangeList& rList ) const
+                    {
+                        return !( *this == rList );
+                    }
+
 };
 SV_DECL_IMPL_REF( ScRangeList );
 


More information about the Libreoffice-commits mailing list