[Libreoffice-commits] .: svx/source

Joseph Powers jpowers at kemper.freedesktop.org
Thu Jan 6 08:16:48 PST 2011


 svx/source/form/fmexpl.cxx             |   53 ++++++++++++++++++++++++++-------
 svx/source/form/navigatortree.cxx      |   20 ++++++------
 svx/source/form/navigatortreemodel.cxx |   44 ++++++++++-----------------
 svx/source/inc/fmexpl.hxx              |   16 ++++++++-
 4 files changed, 83 insertions(+), 50 deletions(-)

New commits:
commit e6e116d2f3d9f9e881c61e0ac89415143c6e23bb
Author: Joseph Powers <jpowers27 at cox.net>
Date:   Thu Jan 6 08:03:28 2011 -0800

    Remove DECLARE_LIST( FmEntryDataBaseList, FmEntryData* )

diff --git a/svx/source/form/fmexpl.cxx b/svx/source/form/fmexpl.cxx
index e140771..6505bc9 100644
--- a/svx/source/form/fmexpl.cxx
+++ b/svx/source/form/fmexpl.cxx
@@ -210,6 +210,43 @@ FmEntryDataList::~FmEntryDataList()
     DBG_DTOR(FmEntryDataList,NULL);
 }
 
+//------------------------------------------------------------------------
+FmEntryData* FmEntryDataList::remove( FmEntryData* pItem )
+{
+    for ( FmEntryDataBaseList::iterator it = maEntryDataList.begin();
+          it < maEntryDataList.end();
+          ++it
+        )
+    {
+        if ( *it == pItem )
+        {
+            maEntryDataList.erase( it );
+            break;
+        }
+    }
+    return pItem;
+}
+
+//------------------------------------------------------------------------
+void FmEntryDataList::insert( FmEntryData* pItem, size_t Index )
+{
+    if ( Index < maEntryDataList.size() )
+    {
+        FmEntryDataBaseList::iterator it = maEntryDataList.begin();
+        ::std::advance( it, Index );
+        maEntryDataList.insert( it, pItem );
+    }
+    else
+        maEntryDataList.push_back( pItem );
+}
+
+//------------------------------------------------------------------------
+void FmEntryDataList::clear()
+{
+    for ( size_t i = 0, n = maEntryDataList.size(); i < n; ++i )
+        delete maEntryDataList[ i ];
+    maEntryDataList.clear();
+}
 
 //========================================================================
 // class FmEntryData
@@ -255,12 +292,12 @@ FmEntryData::FmEntryData( const FmEntryData& rEntryData )
     pParent = rEntryData.GetParent();
 
     FmEntryData* pChildData;
-    sal_uInt32 nEntryCount = rEntryData.GetChildList()->Count();
-    for( sal_uInt32 i=0; i<nEntryCount; i++ )
+    size_t nEntryCount = rEntryData.GetChildList()->size();
+    for( size_t i = 0; i < nEntryCount; i++ )
     {
-        pChildData = rEntryData.GetChildList()->GetObject(i);
+        pChildData = rEntryData.GetChildList()->at( i );
         FmEntryData* pNewChildData = pChildData->Clone();
-        pChildList->Insert( pNewChildData, LIST_APPEND );
+        pChildList->insert( pNewChildData, size_t(-1) );
     }
 
     m_xNormalizedIFace = rEntryData.m_xNormalizedIFace;
@@ -272,13 +309,7 @@ FmEntryData::FmEntryData( const FmEntryData& rEntryData )
 void FmEntryData::Clear()
 {
     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen at sun.com", "FmEntryData::Clear" );
-    for (;;)
-    {
-        FmEntryData* pEntryData = GetChildList()->Remove(ULONG(0));
-        if (pEntryData == NULL)
-            break;
-        delete pEntryData;
-    }
+    GetChildList()->clear();
 }
 
 //------------------------------------------------------------------------
diff --git a/svx/source/form/navigatortree.cxx b/svx/source/form/navigatortree.cxx
index 8e9853b..b9d486e 100644
--- a/svx/source/form/navigatortree.cxx
+++ b/svx/source/form/navigatortree.cxx
@@ -724,11 +724,11 @@ namespace svxform
         //////////////////////////////////////////////////////////////////////
         // Childs einfuegen
         FmEntryDataList* pChildList = pEntryData->GetChildList();
-        sal_uInt32 nChildCount = pChildList->Count();
+        size_t nChildCount = pChildList->size();
         FmEntryData* pChildData;
-        for( sal_uInt32 i=0; i<nChildCount; i++ )
+        for( size_t i = 0; i < nChildCount; i++ )
         {
-            pChildData = pChildList->GetObject(i);
+            pChildData = pChildList->at( i );
             Insert( pChildData, LIST_APPEND );
         }
 
@@ -1171,9 +1171,9 @@ namespace svxform
 
             // beim Vater austragen
             if (pCurrentParentUserData)
-                pCurrentParentUserData->GetChildList()->Remove(pCurrentUserData);
+                pCurrentParentUserData->GetChildList()->remove( pCurrentUserData );
             else
-                GetNavModel()->GetRootList()->Remove(pCurrentUserData);
+                GetNavModel()->GetRootList()->remove( pCurrentUserData );
 
             // aus dem Container entfernen
             sal_Int32 nIndex = getElementPos(Reference< XIndexAccess > (xContainer, UNO_QUERY), xCurrentChild);
@@ -1243,9 +1243,9 @@ namespace svxform
 
             // dann dem Parent das neue Child
             if (pTargetData)
-                pTargetData->GetChildList()->Insert(pCurrentUserData, nIndex);
+                pTargetData->GetChildList()->insert( pCurrentUserData, nIndex );
             else
-                GetNavModel()->GetRootList()->Insert(pCurrentUserData, nIndex);
+                GetNavModel()->GetRootList()->insert( pCurrentUserData, nIndex );
 
             // dann bei mir selber bekanntgeben und neu selektieren
             SvLBoxEntry* pNew = Insert( pCurrentUserData, nIndex );
@@ -1895,7 +1895,7 @@ namespace svxform
             // if the entry still has children, we skipped deletion of one of those children.
             // This may for instance be because the shape is in a hidden layer, where we're unable
             // to remove it
-            if ( pCurrent->GetChildList()->Count() )
+            if ( pCurrent->GetChildList()->size() )
                 continue;
 
             // noch ein kleines Problem, bevor ich das ganz loesche : wenn es eine Form ist und die Shell diese als CurrentObject
@@ -2224,9 +2224,9 @@ namespace svxform
         FmEntryDataList* pChildList = pFormData->GetChildList();
         FmEntryData* pEntryData;
         FmControlData* pControlData;
-        for( sal_uInt32 i=0; i < pChildList->Count(); ++i )
+        for( size_t i = 0; i < pChildList->size(); ++i )
         {
-            pEntryData = pChildList->GetObject(i);
+            pEntryData = pChildList->at( i );
             if( pEntryData->ISA(FmControlData) )
             {
                 pControlData = (FmControlData*)pEntryData;
diff --git a/svx/source/form/navigatortreemodel.cxx b/svx/source/form/navigatortreemodel.cxx
index 4967941..cb9024d 100644
--- a/svx/source/form/navigatortreemodel.cxx
+++ b/svx/source/form/navigatortreemodel.cxx
@@ -271,15 +271,7 @@ namespace svxform
 
         //////////////////////////////////////////////////////////////////////
         // RootList loeschen
-        FmEntryData* pChildData;
-        FmEntryDataList* pRootList = GetRootList();
-
-        for( sal_uInt32 i=pRootList->Count(); i>0; i-- )
-        {
-            pChildData = pRootList->GetObject(i-1);
-            pRootList->Remove( pChildData );
-            delete pChildData;
-        }
+        GetRootList()->clear();
 
         //////////////////////////////////////////////////////////////////////
         // UI benachrichtigen
@@ -383,9 +375,9 @@ namespace svxform
         }
 
         if (pFolder)
-            pFolder->GetChildList()->Insert( pEntry, nRelPos );
+            pFolder->GetChildList()->insert( pEntry, nRelPos );
         else
-            GetRootList()->Insert( pEntry, nRelPos );
+            GetRootList()->insert( pEntry, nRelPos );
 
         //////////////////////////////////////////////////////////////////////
         // UI benachrichtigen
@@ -466,13 +458,13 @@ namespace svxform
 
         // beim Vater austragen
         if (pFolder)
-            pFolder->GetChildList()->Remove(pEntry);
+            pFolder->GetChildList()->remove( pEntry );
         else
         {
-            GetRootList()->Remove(pEntry);
+            GetRootList()->remove( pEntry );
             //////////////////////////////////////////////////////////////////////
             // Wenn keine Form mehr in der Root, an der Shell CurForm zuruecksetzen
-            if (!GetRootList()->Count())
+            if ( !GetRootList()->size() )
                 m_pFormShell->GetImpl()->forgetCurrentForm();
         }
 
@@ -498,10 +490,9 @@ namespace svxform
             return;
 
         FmEntryDataList*    pChildList = pFormData->GetChildList();
-        sal_uInt32 nCount = pChildList->Count();
-        for (sal_uInt32 i = nCount; i > 0; i--)
+        for ( size_t i = pChildList->size(); i > 0; )
         {
-            FmEntryData* pEntryData = pChildList->GetObject(i - 1);
+            FmEntryData* pEntryData = pChildList->at( --i );
 
             //////////////////////////////////////////////////////////////////////
             // Child ist Form -> rekursiver Aufruf
@@ -545,15 +536,14 @@ namespace svxform
         //////////////////////////////////////////////////////////////////////
         // Alle Eintraege dieses Zweiges loeschen
         FmEntryDataList* pChildList = pParentData->GetChildList();
-        FmEntryData* pChildData;
 
-        for( sal_uInt32 i=pChildList->Count(); i>0; i-- )
+        for( size_t i = pChildList->size(); i > 0; )
         {
-            pChildData = pChildList->GetObject(i-1);
+            FmEntryData* pChildData = pChildList->at( --i );
             if( pChildData->ISA(FmFormData) )
                 ClearBranch( (FmFormData*)pChildData );
 
-            pChildList->Remove( pChildData );
+            pChildList->remove( pChildData );
         }
     }
 
@@ -695,9 +685,9 @@ namespace svxform
         // normalize
         Reference< XInterface > xIFace( xElement, UNO_QUERY );
 
-        for (sal_uInt16 i=0; i < pDataList->Count(); i++)
+        for ( size_t i = 0; i < pDataList->size(); i++ )
         {
-            FmEntryData* pEntryData = pDataList->GetObject(i);
+            FmEntryData* pEntryData = pDataList->at( i );
             if ( pEntryData->GetElement().get() == xIFace.get() )
                 return pEntryData;
             else if (bRecurs)
@@ -724,9 +714,9 @@ namespace svxform
         FmEntryData* pEntryData;
         FmEntryData* pChildData;
 
-        for( sal_uInt16 i=0; i<pDataList->Count(); i++ )
+        for( size_t i = 0; i < pDataList->size(); i++ )
         {
-            pEntryData = pDataList->GetObject(i);
+            pEntryData = pDataList->at( i );
             aEntryText = pEntryData->GetText();
 
             if (rText == aEntryText)
@@ -991,9 +981,9 @@ namespace svxform
         ::rtl::OUString aChildText;
         FmEntryData* pChildData;
 
-        for( sal_uInt16 i=0; i<pChildList->Count(); i++ )
+        for( size_t i = 0; i < pChildList->size(); i++ )
         {
-            pChildData = pChildList->GetObject(i);
+            pChildData = pChildList->at( i );
             aChildText = pChildData->GetText();
 
             //////////////////////////////////////////////////////////////////////
diff --git a/svx/source/inc/fmexpl.hxx b/svx/source/inc/fmexpl.hxx
index 30c4fe3..cc8a5f3 100644
--- a/svx/source/inc/fmexpl.hxx
+++ b/svx/source/inc/fmexpl.hxx
@@ -60,6 +60,7 @@
 #include <svx/fmview.hxx>
 
 #include "fmexch.hxx"
+#include <vector>
 
 class SdrObjListIter;
 class FmFormShell;
@@ -204,13 +205,24 @@ public:
 };
 
 //========================================================================
-DECLARE_LIST( FmEntryDataBaseList, FmEntryData* )
+typedef ::std::vector< FmEntryData* > FmEntryDataBaseList;
 
-class FmEntryDataList : public FmEntryDataBaseList
+class FmEntryDataList
 {
+private:
+    FmEntryDataBaseList maEntryDataList;
+
 public:
     FmEntryDataList();
     virtual ~FmEntryDataList();
+
+    FmEntryData*    at( size_t Index )
+        { return ( Index < maEntryDataList.size() ) ? maEntryDataList[ Index ] : NULL; }
+
+    size_t          size() const { return maEntryDataList.size(); }
+    FmEntryData*    remove( FmEntryData* pItem );
+    void            insert( FmEntryData* pItem, size_t Index );
+    void            clear();
 };
 
 //========================================================================


More information about the Libreoffice-commits mailing list