[Libreoffice-commits] .: 3 commits - idl/inc idl/source

Jan Holesovsky kendy at kemper.freedesktop.org
Tue Mar 29 09:31:22 PDT 2011


 idl/inc/object.hxx            |    3 ++
 idl/inc/slot.hxx              |    2 -
 idl/inc/types.hxx             |    2 -
 idl/source/objects/object.cxx |   47 ++++++++++++++++++++------------
 idl/source/objects/slot.cxx   |   61 +++++++++++++++++++++---------------------
 5 files changed, 65 insertions(+), 50 deletions(-)

New commits:
commit aa3e5fb2e8da0899a8c53f63b3d7779b3f98a8cf
Author: Jan Holesovsky <kendy at suse.cz>
Date:   Tue Mar 29 18:12:25 2011 +0200

    Revert "Remove DECLARE_LIST( SvSlotElementList, SvSlotElement* )"
    
    This reverts commit a06dbfc4d1252d453b737cde32bad2ecc56e56b1.

diff --git a/idl/inc/object.hxx b/idl/inc/object.hxx
index 6c25ade..6b3d6cf 100755
--- a/idl/inc/object.hxx
+++ b/idl/inc/object.hxx
@@ -29,9 +29,11 @@
 #ifndef _OBJECT_HXX
 #define _OBJECT_HXX
 
+#define _SVSTDARR_ULONGS
 #include <types.hxx>
 #include <slot.hxx>
 #include <vector>
+#include <tools/list.hxx>
 
 struct SvSlotElement
 {
@@ -42,6 +44,7 @@ struct SvSlotElement
                 , aPrefix( rPrefix )
              {}
 };
+DECLARE_LIST( SvSlotElementList, SvSlotElement* )
 
 class SvMetaClass;
 typedef ::std::vector< SvMetaClass* > SvMetaClassList;
diff --git a/idl/inc/slot.hxx b/idl/inc/slot.hxx
index 5683ada..e2840cc 100755
--- a/idl/inc/slot.hxx
+++ b/idl/inc/slot.hxx
@@ -82,7 +82,6 @@ class SvMetaSlot : public SvMetaAttribute
     void			WriteSlot( const ByteString & rShellName,
                             sal_uInt16 nCount, const ByteString & rSlotId,
                             SvSlotElementList &rList,
-                            SvSlotElementList::iterator pCurSlot,
                             const ByteString & rPrefix,
                                SvIdlDataBase & rBase, SvStream & rOutStm );
     virtual void    Write( SvIdlDataBase & rBase,
@@ -256,7 +255,6 @@ public:
     sal_uInt16      		WriteSlotMap( const ByteString & rShellName,
                                     sal_uInt16 nCount,
                                     SvSlotElementList&,
-                                    SvSlotElementList::iterator pCurSlot,
                                     const ByteString &,
                                     SvIdlDataBase & rBase,
                                     SvStream & rOutStm );
diff --git a/idl/inc/types.hxx b/idl/inc/types.hxx
index 6f0de27..79b1391 100755
--- a/idl/inc/types.hxx
+++ b/idl/inc/types.hxx
@@ -32,8 +32,8 @@
 #include <tools/ref.hxx>
 #include <basobj.hxx>
 
+class SvSlotElementList;
 struct SvSlotElement;
-typedef std::vector<SvSlotElement*> SvSlotElementList;
 
 SV_DECL_REF(SvMetaType)
 SV_DECL_REF(SvMetaAttribute)
diff --git a/idl/source/objects/object.cxx b/idl/source/objects/object.cxx
index cb0e25a..8adab56 100755
--- a/idl/source/objects/object.cxx
+++ b/idl/source/objects/object.cxx
@@ -443,10 +443,10 @@ sal_uInt16 SvMetaClass::WriteSlotParamArray( SvIdlDataBase & rBase,
                                         SvStream & rOutStm )
 {
     sal_uInt16 nCount = 0;
-    SvMetaSlot *pAttr = NULL;
-    for(SvSlotElementList::iterator it = rSlotList.begin(); it != rSlotList.end(); ++it)
+    for( sal_uLong n = 0; n < rSlotList.Count(); n++ )
     {
-        pAttr = (*it)->xSlot;
+        SvSlotElement *pEle = rSlotList.GetObject( n );
+        SvMetaSlot *pAttr = pEle->xSlot;
         nCount = nCount + pAttr->WriteSlotParamArray( rBase, rOutStm );
     }
 
@@ -459,12 +459,13 @@ sal_uInt16 SvMetaClass::WriteSlots( const ByteString & rShellName,
                                 SvStream & rOutStm )
 {
     sal_uInt16 nSCount = 0;
-    SvMetaSlot *pAttr = NULL;
-    for(SvSlotElementList::iterator it = rSlotList.begin(); it != rSlotList.end(); ++it)
+    for( sal_uLong n = 0; n < rSlotList.Count(); n++ )
     {
-        pAttr = (*it)->xSlot;
+        rSlotList.Seek(n);
+        SvSlotElement * pEle = rSlotList.GetCurObject();
+        SvMetaSlot * pAttr = pEle->xSlot;
         nSCount = nSCount + pAttr->WriteSlotMap( rShellName, nCount + nSCount,
-                                        rSlotList, it, (*it)->aPrefix, rBase,
+                                        rSlotList, pEle->aPrefix, rBase,
                                         rOutStm );
     }
 
@@ -559,8 +560,13 @@ void SvMetaClass::WriteSlotStubs( const ByteString & rShellName,
                                 ByteStringList & rList,
                                 SvStream & rOutStm )
 {
-    for(SvSlotElementList::iterator it = rSlotList.begin(); it != rSlotList.end(); ++it)
-        (*it)->xSlot->WriteSlotStubs( rShellName, rList, rOutStm );
+    // write all attributes
+    for( sal_uLong n = 0; n < rSlotList.Count(); n++ )
+    {
+        SvSlotElement *pEle = rSlotList.GetObject( n );
+        SvMetaSlot *pAttr = pEle->xSlot;
+        pAttr->WriteSlotStubs( rShellName, rList, rOutStm );
+    }
 }
 
 void SvMetaClass::WriteSfx( SvIdlDataBase & rBase, SvStream & rOutStm )
@@ -586,12 +592,14 @@ void SvMetaClass::WriteSfx( SvIdlDataBase & rBase, SvStream & rOutStm )
     SvMetaClassList classList;
     SvSlotElementList aSlotList;
     InsertSlots(aSlotList, aSuperList, classList, ByteString(), rBase);
+    for (sal_uInt32 n=0; n<aSlotList.Count(); n++ )
+    {
+        SvSlotElement *pEle = aSlotList.GetObject( n );
+        SvMetaSlot *pSlot = pEle->xSlot;
+        pSlot->SetListPos(n);
+    }
 
-    sal_uInt32 k = 0;
-    for(SvSlotElementList::iterator it = aSlotList.begin(); it != aSlotList.end(); ++it, ++k)
-        (*it)->xSlot->SetListPos(k);
-
-    sal_uLong nSlotCount = aSlotList.size();
+    sal_uLong nSlotCount = aSlotList.Count();
 
     // write all attributes
     sal_uInt16 nArgCount = WriteSlotParamArray( rBase, aSlotList, rOutStm );
@@ -633,11 +641,16 @@ void SvMetaClass::WriteSfx( SvIdlDataBase & rBase, SvStream & rOutStm )
     }
     rOutStm << endl << "};" << endl << "#endif" << endl << endl;
 
-    for(SvSlotElementList::iterator it = aSlotList.begin(); it != aSlotList.end(); ++it)
+    for( sal_uLong n=0; n<aSlotList.Count(); n++ )
     {
-        (*it)->xSlot->ResetSlotPointer();
-        delete *it;
+        aSlotList.Seek(n);
+        SvSlotElement* pEle = aSlotList.GetCurObject();
+        SvMetaSlot* pAttr = pEle->xSlot;
+        pAttr->ResetSlotPointer();
     }
+
+    for ( sal_uLong n=0; n<aSlotList.Count(); n++ )
+        delete aSlotList.GetObject(n);
 }
 
 void SvMetaClass::WriteHelpIds( SvIdlDataBase & rBase, SvStream & rOutStm,
diff --git a/idl/source/objects/slot.cxx b/idl/source/objects/slot.cxx
index a640289..06c161c 100755
--- a/idl/source/objects/slot.cxx
+++ b/idl/source/objects/slot.cxx
@@ -936,14 +936,14 @@ void SvMetaSlot::Insert( SvSlotElementList& rList, const ByteString & rPrefix,
 {
     // get insert position through binary search in slotlist
     sal_uInt16 nId = (sal_uInt16) GetSlotId().GetValue();
-    sal_uInt16 nListCount = (sal_uInt16) rList.size();
+    sal_uInt16 nListCount = (sal_uInt16) rList.Count();
     sal_uInt16 nPos;
     sal_uLong m;  // for inner "for" loop
 
     if ( !nListCount )
         nPos = 0;
     else if ( nListCount == 1 )
-        nPos = rList[0]->xSlot->GetSlotId().GetValue() >= nId ? 0 : 1;
+        nPos = rList.GetObject(0)->xSlot->GetSlotId().GetValue() >= nId ? 0 : 1;
     else
     {
         sal_uInt16 nMid = 0, nLow = 0;
@@ -953,7 +953,7 @@ void SvMetaSlot::Insert( SvSlotElementList& rList, const ByteString & rPrefix,
         {
             nMid = (nLow + nHigh) >> 1;
             DBG_ASSERT( nMid < nListCount, "bsearch ist buggy" );
-            int nDiff = (int) nId - (int) rList[nMid]->xSlot->GetSlotId().GetValue();
+            int nDiff = (int) nId - (int) rList.GetObject(nMid)->xSlot->GetSlotId().GetValue();
             if ( nDiff < 0)
             {
                 if ( nMid == 0 )
@@ -977,16 +977,16 @@ void SvMetaSlot::Insert( SvSlotElementList& rList, const ByteString & rPrefix,
     DBG_ASSERT( nPos <= nListCount,
         "nPos too large" );
     DBG_ASSERT( nPos == nListCount || nId <=
-        (sal_uInt16) rList[nPos]->xSlot->GetSlotId().GetValue(),
+        (sal_uInt16) rList.GetObject(nPos)->xSlot->GetSlotId().GetValue(),
         "Successor has lower SlotId" );
     DBG_ASSERT( nPos == 0 || nId >
-        (sal_uInt16) rList[nPos-1]->xSlot->GetSlotId().GetValue(),
+        (sal_uInt16) rList.GetObject(nPos-1)->xSlot->GetSlotId().GetValue(),
         "Predecessor has higher SlotId" );
     DBG_ASSERT( nPos+1 >= nListCount || nId <
-        (sal_uInt16) rList[nPos+1]->xSlot->GetSlotId().GetValue(),
+        (sal_uInt16) rList.GetObject(nPos+1)->xSlot->GetSlotId().GetValue(),
         "Successor has lower SlotId" );
 
-    rList.insert(rList.begin()+nPos, new SvSlotElement( this, rPrefix ));
+    rList.Insert( new SvSlotElement( this, rPrefix ), nPos );
 
     // iron out EnumSlots
     SvMetaTypeEnum * pEnum = NULL;
@@ -1052,17 +1052,19 @@ void SvMetaSlot::Insert( SvSlotElementList& rList, const ByteString & rPrefix,
         pLinkedSlot = pFirstEnumSlot;
 
         // concatenate slaves among themselves
+        rList.Seek((sal_uLong)0);
         xEnumSlot = pFirstEnumSlot;
-
-        for (SvSlotElementList::const_iterator it = rList.begin(); it != rList.end(); ++it)
+        SvSlotElement *pEle;
+        do
         {
-            if ((*it)->xSlot->pLinkedSlot == this)
+            pEle = rList.Next();
+            if ( pEle && pEle->xSlot->pLinkedSlot == this )
             {
-                xEnumSlot->pNextSlot = (*it)->xSlot;
-                xEnumSlot = (*it)->xSlot;
+                xEnumSlot->pNextSlot = pEle->xSlot;
+                xEnumSlot = pEle->xSlot;
             }
         }
-
+        while ( pEle );
         xEnumSlot->pNextSlot = pFirstEnumSlot;
     }
 }
@@ -1134,7 +1136,6 @@ void SvMetaSlot::WriteSlotStubs( const ByteString & rShellName,
 void SvMetaSlot::WriteSlot( const ByteString & rShellName, sal_uInt16 nCount,
                             const ByteString & rSlotId,
                             SvSlotElementList& rSlotList,
-                            SvSlotElementList::iterator pCurSlot,
                             const ByteString & rPrefix,
                             SvIdlDataBase & rBase, SvStream & rOutStm )
 {
@@ -1191,24 +1192,30 @@ void SvMetaSlot::WriteSlot( const ByteString & rShellName, sal_uInt16 nCount,
     {
         // look for the next slot with the same StateMethod like me
         // the slotlist is set to the current slot
-        for (SvSlotElementList::iterator it = pCurSlot+1; it != rSlotList.end(); ++it)
+        SvSlotElement * pEle = rSlotList.Next();
+        pNextSlot = pEle ? &pEle->xSlot : NULL;
+        while ( pNextSlot )
         {
-            pNextSlot = (*it)->xSlot;
-
-            if (!pNextSlot || (!pNextSlot->pNextSlot && pNextSlot->GetStateMethod() == GetStateMethod()) )
+            if ( !pNextSlot->pNextSlot &&
+                pNextSlot->GetStateMethod() == GetStateMethod() )
                 break;
+            pEle = rSlotList.Next();
+            pNextSlot = pEle ? &pEle->xSlot : NULL;
         }
 
         if ( !pNextSlot )
         {
             // There is no slot behind me that has the same ExecMethod.
             // So I search for the first slot with it (could be myself).
-            for (SvSlotElementList::iterator it = rSlotList.begin(); it != pCurSlot; ++it)
+            pEle = rSlotList.First();
+            pNextSlot = pEle ? &pEle->xSlot : NULL;
+            while ( pNextSlot != this )
             {
-                pNextSlot = (*it)->xSlot;
-
-                if (pNextSlot == this || (!pNextSlot->pEnumValue && pNextSlot->GetStateMethod() == GetStateMethod()) )
+                if ( !pNextSlot->pEnumValue &&
+                    pNextSlot->GetStateMethod() == GetStateMethod() )
                     break;
+                pEle = rSlotList.Next();
+                pNextSlot = pEle ? &pEle->xSlot : NULL;
             }
         }
 
@@ -1429,7 +1436,6 @@ sal_uInt16 SvMetaSlot::WriteSlotParamArray( SvIdlDataBase & rBase, SvStream & rO
 
 sal_uInt16 SvMetaSlot::WriteSlotMap( const ByteString & rShellName, sal_uInt16 nCount,
                                 SvSlotElementList& rSlotList,
-                                SvSlotElementList::iterator pCurSlot,
                                 const ByteString & rPrefix,
                                 SvIdlDataBase & rBase,
                                 SvStream & rOutStm )
@@ -1450,7 +1456,7 @@ sal_uInt16 SvMetaSlot::WriteSlotMap( const ByteString & rShellName, sal_uInt16 n
         nSCount = (sal_uInt16)pType->GetAttrCount();
     }
 
-    WriteSlot( rShellName, nCount, slotId, rSlotList, pCurSlot, rPrefix, rBase, rOutStm );
+    WriteSlot( rShellName, nCount, slotId, rSlotList, rPrefix, rBase, rOutStm );
     return nSCount;
 }
 
commit a2f33cdef8073be30c8622fff7e7ab16934e1ffc
Author: Jan Holesovsky <kendy at suse.cz>
Date:   Tue Mar 29 18:12:23 2011 +0200

    Revert "tweak list access to prevent iterating past end"
    
    This reverts commit df8759a593bf11fc626b19f2ea797731824200d1.

diff --git a/idl/source/objects/slot.cxx b/idl/source/objects/slot.cxx
index ab27d1b..a640289 100755
--- a/idl/source/objects/slot.cxx
+++ b/idl/source/objects/slot.cxx
@@ -1191,10 +1191,7 @@ void SvMetaSlot::WriteSlot( const ByteString & rShellName, sal_uInt16 nCount,
     {
         // look for the next slot with the same StateMethod like me
         // the slotlist is set to the current slot
-
-        SvSlotElementList::iterator it = ( pCurSlot != rSlotList.end() ) ? ++pCurSlot : rSlotList.end();
-
-        for ( ; it != rSlotList.end(); ++it)
+        for (SvSlotElementList::iterator it = pCurSlot+1; it != rSlotList.end(); ++it)
         {
             pNextSlot = (*it)->xSlot;
 
commit 145c687c0a97806f441d7d5826bc737308c5abdd
Author: Jan Holesovsky <kendy at suse.cz>
Date:   Tue Mar 29 18:12:08 2011 +0200

    Revert "WaE: declaration of 'it' shadows a previous local"
    
    This reverts commit b6702790cda29c6b2e7b5ed24fe2a4e2110cf021.

diff --git a/idl/source/objects/slot.cxx b/idl/source/objects/slot.cxx
index 7bcc6d1..ab27d1b 100755
--- a/idl/source/objects/slot.cxx
+++ b/idl/source/objects/slot.cxx
@@ -1192,16 +1192,14 @@ void SvMetaSlot::WriteSlot( const ByteString & rShellName, sal_uInt16 nCount,
         // look for the next slot with the same StateMethod like me
         // the slotlist is set to the current slot
 
-        {
-            SvSlotElementList::iterator it = ( pCurSlot != rSlotList.end() ) ? ++pCurSlot : rSlotList.end();
+        SvSlotElementList::iterator it = ( pCurSlot != rSlotList.end() ) ? ++pCurSlot : rSlotList.end();
 
-            for ( ; it != rSlotList.end(); ++it)
-            {
-                pNextSlot = (*it)->xSlot;
+        for ( ; it != rSlotList.end(); ++it)
+        {
+            pNextSlot = (*it)->xSlot;
 
-                if (!pNextSlot || (!pNextSlot->pNextSlot && pNextSlot->GetStateMethod() == GetStateMethod()) )
-                    break;
-            }
+            if (!pNextSlot || (!pNextSlot->pNextSlot && pNextSlot->GetStateMethod() == GetStateMethod()) )
+                break;
         }
 
         if ( !pNextSlot )


More information about the Libreoffice-commits mailing list