[Libreoffice-commits] .: sc/source

Kohei Yoshida kohei at kemper.freedesktop.org
Thu Jun 2 18:13:14 PDT 2011


 sc/source/ui/inc/areasave.hxx  |   32 ++++++++++---------
 sc/source/ui/undo/areasave.cxx |   66 +++++++++++++++++++----------------------
 2 files changed, 49 insertions(+), 49 deletions(-)

New commits:
commit 93e39790d5e41f52468517b0bb44f8077392797a
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Thu Jun 2 21:12:35 2011 -0400

    Removed dependency of ScCollection and ScDataObject.

diff --git a/sc/source/ui/inc/areasave.hxx b/sc/source/ui/inc/areasave.hxx
index 8dbe355..592d4b0 100644
--- a/sc/source/ui/inc/areasave.hxx
+++ b/sc/source/ui/inc/areasave.hxx
@@ -29,15 +29,15 @@
 #ifndef SC_AREASAVE_HXX
 #define SC_AREASAVE_HXX
 
-#include "collect.hxx"
-#include "global.hxx"
 #include "address.hxx"
 
+#include <boost/ptr_container/ptr_vector.hpp>
+
 class ScDocument;
 class ScAreaLink;
 
 
-class ScAreaLinkSaver : public ScDataObject
+class ScAreaLinkSaver
 {
 private:
     ::rtl::OUString aFileName;
@@ -48,11 +48,9 @@ private:
     sal_uLong nRefresh;
 
 public:
-                ScAreaLinkSaver( const ScAreaLink& rSource );
-                ScAreaLinkSaver( const ScAreaLinkSaver& rCopy );
-    virtual		~ScAreaLinkSaver();
-
-    virtual	ScDataObject*	Clone() const;
+    ScAreaLinkSaver( const ScAreaLink& rSource );
+    ScAreaLinkSaver( const ScAreaLinkSaver& rCopy );
+    ~ScAreaLinkSaver();
 
     bool        IsEqual( const ScAreaLink& rCompare ) const;
     bool        IsEqualSource( const ScAreaLink& rCompare ) const;
@@ -62,22 +60,26 @@ public:
 };
 
 
-class ScAreaLinkSaveCollection : public ScCollection
+class ScAreaLinkSaveCollection
 {
+    typedef ::boost::ptr_vector<ScAreaLinkSaver> DataType;
+    DataType maData;
 public:
-                ScAreaLinkSaveCollection();
-                ScAreaLinkSaveCollection( const ScAreaLinkSaveCollection& rCopy );
-    virtual		~ScAreaLinkSaveCollection();
+    ScAreaLinkSaveCollection();
+    ScAreaLinkSaveCollection( const ScAreaLinkSaveCollection& r );
+    ~ScAreaLinkSaveCollection();
 
-    virtual	ScDataObject*	Clone() const;
-
-    ScAreaLinkSaver*	operator[](sal_uInt16 nIndex) const {return (ScAreaLinkSaver*)At(nIndex);}
 
     bool        IsEqual( const ScDocument* pDoc ) const;
     void		Restore( ScDocument* pDoc ) const;
 
     // returns NULL if empty
     static ScAreaLinkSaveCollection* CreateFromDoc( const ScDocument* pDoc );
+
+    const ScAreaLinkSaver* operator[](size_t nIndex) const;
+    size_t size() const;
+    void clear();
+    void push_back(ScAreaLinkSaver* p);
 };
 
 
diff --git a/sc/source/ui/undo/areasave.cxx b/sc/source/ui/undo/areasave.cxx
index c8a137e..dfd0393 100644
--- a/sc/source/ui/undo/areasave.cxx
+++ b/sc/source/ui/undo/areasave.cxx
@@ -54,7 +54,6 @@ ScAreaLinkSaver::ScAreaLinkSaver( const ScAreaLink& rSource ) :
 }
 
 ScAreaLinkSaver::ScAreaLinkSaver( const ScAreaLinkSaver& rCopy ) :
-    ScDataObject(),
     aFileName	( rCopy.aFileName ),
     aFilterName	( rCopy.aFilterName ),
     aOptions	( rCopy.aOptions ),
@@ -64,14 +63,7 @@ ScAreaLinkSaver::ScAreaLinkSaver( const ScAreaLinkSaver& rCopy ) :
 {
 }
 
-ScAreaLinkSaver::~ScAreaLinkSaver()
-{
-}
-
-ScDataObject*	ScAreaLinkSaver::Clone() const
-{
-    return new ScAreaLinkSaver( *this );
-}
+ScAreaLinkSaver::~ScAreaLinkSaver() {}
 
 bool ScAreaLinkSaver::IsEqualSource( const ScAreaLink& rCompare ) const
 {
@@ -113,25 +105,12 @@ void ScAreaLinkSaver::InsertNewLink( ScDocument* pDoc ) const
     }
 }
 
-// -----------------------------------------------------------------------
-
-ScAreaLinkSaveCollection::ScAreaLinkSaveCollection()
-{
-}
-
-ScAreaLinkSaveCollection::ScAreaLinkSaveCollection( const ScAreaLinkSaveCollection& rCopy ) :
-    ScCollection( rCopy )
-{
-}
+ScAreaLinkSaveCollection::ScAreaLinkSaveCollection() {}
 
-ScAreaLinkSaveCollection::~ScAreaLinkSaveCollection()
-{
-}
+ScAreaLinkSaveCollection::ScAreaLinkSaveCollection( const ScAreaLinkSaveCollection& r ) :
+    maData(r.maData) {}
 
-ScDataObject*	ScAreaLinkSaveCollection::Clone() const
-{
-    return new ScAreaLinkSaveCollection( *this );
-}
+ScAreaLinkSaveCollection::~ScAreaLinkSaveCollection() {}
 
 bool ScAreaLinkSaveCollection::IsEqual( const ScDocument* pDoc ) const
 {
@@ -141,7 +120,7 @@ bool ScAreaLinkSaveCollection::IsEqual( const ScDocument* pDoc ) const
     sfx2::LinkManager* pLinkManager = const_cast<ScDocument*>(pDoc)->GetLinkManager();
     if (pLinkManager)
     {
-        sal_uInt16 nPos = 0;
+        size_t nPos = 0;
         const ::sfx2::SvBaseLinks& rLinks = pLinkManager->GetLinks();
         sal_uInt16 nLinkCount = rLinks.Count();
         for (sal_uInt16 i=0; i<nLinkCount; i++)
@@ -149,13 +128,13 @@ bool ScAreaLinkSaveCollection::IsEqual( const ScDocument* pDoc ) const
             ::sfx2::SvBaseLink* pBase = *rLinks[i];
             if (pBase->ISA(ScAreaLink))
             {
-                if ( nPos >= GetCount() || !(*this)[nPos]->IsEqual( *(ScAreaLink*)pBase ) )
+                if ( nPos >= size() || !(*this)[nPos]->IsEqual( *(ScAreaLink*)pBase ) )
                     return false;
 
                 ++nPos;
             }
         }
-        if ( nPos < GetCount() )
+        if ( nPos < size() )
             return false;           // fewer links in the document than in the save collection
     }
 
@@ -188,10 +167,10 @@ void ScAreaLinkSaveCollection::Restore( ScDocument* pDoc ) const
     if (pLinkManager)
     {
         const ::sfx2::SvBaseLinks& rLinks = pLinkManager->GetLinks();
-        sal_uInt16 nSaveCount = GetCount();
-        for (sal_uInt16 nPos=0; nPos<nSaveCount; nPos++)
+        size_t nSaveCount = size();
+        for (size_t nPos=0; nPos<nSaveCount; ++nPos)
         {
-            ScAreaLinkSaver* pSaver = (*this)[nPos];
+            const ScAreaLinkSaver* pSaver = (*this)[nPos];
             ScAreaLink* pLink = lcl_FindLink( rLinks, *pSaver );
             if ( pLink )
                 pSaver->WriteToLink( *pLink );          // restore output position
@@ -219,8 +198,7 @@ ScAreaLinkSaveCollection* ScAreaLinkSaveCollection::CreateFromDoc( const ScDocum
                     pColl = new ScAreaLinkSaveCollection;
 
                 ScAreaLinkSaver* pSaver = new ScAreaLinkSaver( *(ScAreaLink*)pBase );
-                if (!pColl->Insert(pSaver))
-                    delete pSaver;
+                pColl->push_back(pSaver);
             }
         }
     }
@@ -228,4 +206,24 @@ ScAreaLinkSaveCollection* ScAreaLinkSaveCollection::CreateFromDoc( const ScDocum
     return pColl;
 }
 
+const ScAreaLinkSaver* ScAreaLinkSaveCollection::operator [](size_t nIndex) const
+{
+    return &maData[nIndex];
+}
+
+size_t ScAreaLinkSaveCollection::size() const
+{
+    return maData.size();
+}
+
+void ScAreaLinkSaveCollection::clear()
+{
+    maData.clear();
+}
+
+void ScAreaLinkSaveCollection::push_back(ScAreaLinkSaver* p)
+{
+    maData.push_back(p);
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list