[Libreoffice-commits] core.git: 4 commits - basic/source include/basic

Kohei Yoshida kohei.yoshida at collabora.com
Wed Jun 25 12:03:51 PDT 2014


 basic/source/runtime/runtime.cxx |   12 -
 basic/source/sbx/sbxarray.cxx    |  347 ++++++++++++++++++---------------------
 include/basic/sbx.hxx            |    8 
 3 files changed, 178 insertions(+), 189 deletions(-)

New commits:
commit ec1636fa09ad14072b9d38150279cba0b75a71f9
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Wed Jun 25 14:39:35 2014 -0400

    Remove this weird inheritance from smart-pointer-wrapped class.
    
    SbxVarEntry is now its own class.
    
    Change-Id: I5c5ce1990fa83930acced1d507f5b0de60bf221e

diff --git a/basic/source/sbx/sbxarray.cxx b/basic/source/sbx/sbxarray.cxx
index 57a55a3..96f1bbc 100644
--- a/basic/source/sbx/sbxarray.cxx
+++ b/basic/source/sbx/sbxarray.cxx
@@ -32,10 +32,10 @@ struct SbxDim {                 // an array-dimension:
     sal_Int32 nSize;            // Number of elements
 };
 
-class SbxVarEntry : public SbxVariableRef {
-public:
+struct SbxVarEntry
+{
+    SbxVariableRef mpVar;
     boost::optional<OUString> maAlias;
-    SbxVarEntry() : SbxVariableRef() {}
 };
 
 TYPEINIT1(SbxArray,SbxBase)
@@ -70,11 +70,11 @@ SbxArray& SbxArray::operator=( const SbxArray& rArray )
         for( sal_uInt32 i = 0; i < pSrc->size(); i++ )
         {
             SbxVarEntry* pSrcRef = (*pSrc)[i];
-            const SbxVariable* pSrc_ = *pSrcRef;
+            SbxVariableRef pSrc_ = pSrcRef->mpVar;
             if( !pSrc_ )
                 continue;
             SbxVarEntry* pDstRef = new SbxVarEntry;
-            *((SbxVariableRef*) pDstRef) = *((SbxVariableRef*) pSrcRef);
+            pDstRef->mpVar = pSrcRef->mpVar;
 
             if (pSrcRef->maAlias)
                 pDstRef->maAlias.reset(*pSrcRef->maAlias);
@@ -84,7 +84,7 @@ SbxArray& SbxArray::operator=( const SbxArray& rArray )
                 // Convert no objects
                 if( eType != SbxOBJECT || pSrc_->GetClass() != SbxCLASS_OBJECT )
                 {
-                    ((SbxVariable*) pSrc_)->Convert( eType );
+                    pSrc_->Convert(eType);
                 }
             }
             mpVarEntries->push_back( pDstRef );
@@ -146,7 +146,7 @@ SbxVariableRef& SbxArray::GetRef32( sal_uInt32 nIdx )
     {
         mpVarEntries->push_back(new SbxVarEntry);
     }
-    return *((*mpVarEntries)[nIdx]);
+    return (*mpVarEntries)[nIdx]->mpVar;
 }
 
 SbxVariableRef& SbxArray::GetRef( sal_uInt16 nIdx )
@@ -163,7 +163,7 @@ SbxVariableRef& SbxArray::GetRef( sal_uInt16 nIdx )
     {
         mpVarEntries->push_back(new SbxVarEntry);
     }
-    return *((*mpVarEntries)[nIdx]);
+    return (*mpVarEntries)[nIdx]->mpVar;
 }
 
 SbxVariable* SbxArray::Get32( sal_uInt32 nIdx )
@@ -280,7 +280,7 @@ void SbxArray::Insert32( SbxVariable* pVar, sal_uInt32 nIdx )
     }
     if( eType != SbxVARIANT && pVar )
     {
-        (*p)->Convert( eType );
+        p->mpVar->Convert(eType);
     }
     if( nIdx == nSize )
     {
@@ -307,7 +307,7 @@ void SbxArray::Remove32( sal_uInt32 nIdx )
 {
     if( nIdx < mpVarEntries->size() )
     {
-        SbxVariableRef* pRef = (*mpVarEntries)[nIdx];
+        SbxVarEntry* pRef = (*mpVarEntries)[nIdx];
         mpVarEntries->erase( mpVarEntries->begin() + nIdx );
         delete pRef;
         SetFlag( SBX_MODIFIED );
@@ -318,7 +318,7 @@ void SbxArray::Remove( sal_uInt16 nIdx )
 {
     if( nIdx < mpVarEntries->size() )
     {
-        SbxVariableRef* pRef = (*mpVarEntries)[nIdx];
+        SbxVarEntry* pRef = (*mpVarEntries)[nIdx];
         mpVarEntries->erase( mpVarEntries->begin() + nIdx );
         delete pRef;
         SetFlag( SBX_MODIFIED );
@@ -331,8 +331,8 @@ void SbxArray::Remove( SbxVariable* pVar )
     {
         for( sal_uInt32 i = 0; i < mpVarEntries->size(); i++ )
         {
-            SbxVariableRef* pRef = (*mpVarEntries)[i];
-            if( *pRef == pVar )
+            SbxVarEntry* pRef = (*mpVarEntries)[i];
+            if (&pRef->mpVar == pVar)
             {
                 Remove32( i ); break;
             }
@@ -345,41 +345,45 @@ void SbxArray::Remove( SbxVariable* pVar )
 
 void SbxArray::Merge( SbxArray* p )
 {
-    if( p )
+    if (!p)
+        return;
+
+    for (sal_uInt16 i = 0; i < p->Count(); ++i)
     {
-        sal_uInt32 nSize = p->Count();
-        for( sal_uInt32 i = 0; i < nSize; i++ )
+        SbxVarEntry* pEntry1 = (*p->mpVarEntries)[i];
+        if (!pEntry1->mpVar)
+            continue;
+
+        OUString aName = pEntry1->mpVar->GetName();
+        sal_uInt16 nHash = pEntry1->mpVar->GetHashCode();
+
+        // Is the element by the same name already inside?
+        // Then overwrite!
+        for (size_t j = 0; j < mpVarEntries->size(); ++j)
         {
-            SbxVarEntry* pRef1 = (*(p->mpVarEntries))[i];
-            // Is the element by name already inside?
-            // Then overwrite!
-            SbxVariable* pVar = *pRef1;
-            if( pVar )
+            SbxVarEntry* pEntry2 = (*mpVarEntries)[j];
+            if (!pEntry2->mpVar)
+                continue;
+
+            if (pEntry2->mpVar->GetHashCode() == nHash &&
+                pEntry2->mpVar->GetName().equalsIgnoreAsciiCase(aName))
             {
-                OUString aName = pVar->GetName();
-                sal_uInt16 nHash = pVar->GetHashCode();
-                for( sal_uInt32 j = 0; j < mpVarEntries->size(); j++ )
-                {
-                    SbxVariableRef* pRef2 = (*mpVarEntries)[j];
-                    if( (*pRef2)->GetHashCode() == nHash
-                        && (*pRef2)->GetName().equalsIgnoreAsciiCase( aName ) )
-                    {
-                        *pRef2 = pVar; pRef1 = NULL;
-                        break;
-                    }
-                }
-                if( pRef1 )
-                {
-                    SbxVarEntry* pRef = new SbxVarEntry;
-                    mpVarEntries->push_back(pRef);
-                    *((SbxVariableRef*) pRef) = *((SbxVariableRef*) pRef1);
-                    if (pRef1->maAlias)
-                    {
-                        pRef->maAlias.reset(*pRef1->maAlias);
-                    }
-                }
+                // Take this element and clear the original.
+                pEntry2->mpVar = pEntry1->mpVar;
+                pEntry1->mpVar.Clear();
+                break;
             }
         }
+
+        if (pEntry1->mpVar)
+        {
+            // We don't have element with the same name.  Add a new entry.
+            SbxVarEntry* pNewEntry = new SbxVarEntry;
+            mpVarEntries->push_back(pNewEntry);
+            pNewEntry->mpVar = pEntry1->mpVar;
+            if (pEntry1->maAlias)
+                pNewEntry->maAlias.reset(*pEntry1->maAlias);
+        }
     }
 }
 
@@ -389,42 +393,45 @@ void SbxArray::Merge( SbxArray* p )
 SbxVariable* SbxArray::FindUserData( sal_uInt32 nData )
 {
     SbxVariable* p = NULL;
-    for( sal_uInt32 i = 0; i < mpVarEntries->size(); i++ )
+    for (size_t i = 0; i < mpVarEntries->size(); ++i)
     {
-        SbxVariableRef* pRef = (*mpVarEntries)[i];
-        SbxVariable* pVar = *pRef;
-        if( pVar )
+        SbxVarEntry* pEntry = (*mpVarEntries)[i];
+        if (!pEntry->mpVar)
+            continue;
+
+        if (pEntry->mpVar->IsVisible() && pEntry->mpVar->GetUserData() == nData)
         {
-            if( pVar->IsVisible() && pVar->GetUserData() == nData )
-            {
-                p = pVar;
-                p->ResetFlag( SBX_EXTFOUND );
-                break;  // JSM 1995-10-06
-            }
-            // Did we have an array/object with extended search?
-            else if( pVar->IsSet( SBX_EXTSEARCH ) )
+            p = &pEntry->mpVar;
+            p->ResetFlag( SBX_EXTFOUND );
+            break;  // JSM 1995-10-06
+        }
+
+        // Did we have an array/object with extended search?
+        if (pEntry->mpVar->IsSet(SBX_EXTSEARCH))
+        {
+            switch (pEntry->mpVar->GetClass())
             {
-                switch( pVar->GetClass() )
+                case SbxCLASS_OBJECT:
                 {
-                    case SbxCLASS_OBJECT:
-                    {
-                        // Objects are not allowed to scan their parent.
-                        sal_uInt16 nOld = pVar->GetFlags();
-                        pVar->ResetFlag( SBX_GBLSEARCH );
-                        p = ((SbxObject*) pVar)->FindUserData( nData );
-                        pVar->SetFlags( nOld );
-                        break;
-                    }
-                    case SbxCLASS_ARRAY:
-                        p = ((SbxArray*) pVar)->FindUserData( nData );
-                        break;
-                    default: break;
-                }
-                if( p )
-                {
-                    p->SetFlag( SBX_EXTFOUND );
-                    break;
+                    // Objects are not allowed to scan their parent.
+                    sal_uInt16 nOld = pEntry->mpVar->GetFlags();
+                    pEntry->mpVar->ResetFlag(SBX_GBLSEARCH);
+                    p = static_cast<SbxObject&>(*pEntry->mpVar).FindUserData(nData);
+                    pEntry->mpVar->SetFlags(nOld);
                 }
+                break;
+                case SbxCLASS_ARRAY:
+                    // Casting SbxVariable to SbxArray?  Really?
+                    p = reinterpret_cast<SbxArray&>(*pEntry->mpVar).FindUserData(nData);
+                break;
+                default:
+                    ;
+            }
+
+            if (p)
+            {
+                p->SetFlag(SBX_EXTFOUND);
+                break;
             }
         }
     }
@@ -444,44 +451,47 @@ SbxVariable* SbxArray::Find( const OUString& rName, SbxClassType t )
     sal_uInt16 nHash = SbxVariable::MakeHashCode( rName );
     for( sal_uInt32 i = 0; i < nCount; i++ )
     {
-        SbxVariableRef* pRef = (*mpVarEntries)[i];
-        SbxVariable* pVar = *pRef;
-        if( pVar && pVar->IsVisible() )
+        SbxVarEntry* pEntry = (*mpVarEntries)[i];
+        if (!pEntry->mpVar || !pEntry->mpVar->IsVisible())
+            continue;
+
+        // The very secure search works as well, if there is no hashcode!
+        sal_uInt16 nVarHash = pEntry->mpVar->GetHashCode();
+        if ( (!nVarHash || nVarHash == nHash)
+            && (t == SbxCLASS_DONTCARE || pEntry->mpVar->GetClass() == t)
+            && (pEntry->mpVar->GetName().equalsIgnoreAsciiCase(rName)))
+        {
+            p = &pEntry->mpVar;
+            p->ResetFlag(SBX_EXTFOUND);
+            break;
+        }
+
+        // Did we have an array/object with extended search?
+        if (bExtSearch && pEntry->mpVar->IsSet(SBX_EXTSEARCH))
         {
-            // The very secure search works as well, if there is no hashcode!
-            sal_uInt16 nVarHash = pVar->GetHashCode();
-            if( ( !nVarHash || nVarHash == nHash )
-                && ( t == SbxCLASS_DONTCARE || pVar->GetClass() == t )
-                && ( pVar->GetName().equalsIgnoreAsciiCase( rName ) ) )
+            switch (pEntry->mpVar->GetClass())
             {
-                p = pVar;
-                p->ResetFlag( SBX_EXTFOUND );
+                case SbxCLASS_OBJECT:
+                {
+                    // Objects are not allowed to scan their parent.
+                    sal_uInt16 nOld = pEntry->mpVar->GetFlags();
+                    pEntry->mpVar->ResetFlag(SBX_GBLSEARCH);
+                    p = static_cast<SbxObject&>(*pEntry->mpVar).Find(rName, t);
+                    pEntry->mpVar->SetFlags(nOld);
+                }
+                break;
+                case SbxCLASS_ARRAY:
+                    // Casting SbxVariable to SbxArray?  Really?
+                    p = reinterpret_cast<SbxArray&>(*pEntry->mpVar).Find(rName, t);
                 break;
+                default:
+                    ;
             }
-            // Did we have an array/object with extended search?
-            else if( bExtSearch && pVar->IsSet( SBX_EXTSEARCH ) )
+
+            if (p)
             {
-                switch( pVar->GetClass() )
-                {
-                    case SbxCLASS_OBJECT:
-                    {
-                        // Objects are not allowed to scan their parent.
-                        sal_uInt16 nOld = pVar->GetFlags();
-                        pVar->ResetFlag( SBX_GBLSEARCH );
-                        p = ((SbxObject*) pVar)->Find( rName, t );
-                        pVar->SetFlags( nOld );
-                        break;
-                    }
-                    case SbxCLASS_ARRAY:
-                        p = ((SbxArray*) pVar)->Find( rName, t );
-                        break;
-                    default: break;
-                }
-                if( p )
-                {
-                    p->SetFlag( SBX_EXTFOUND );
-                    break;
-                }
+                p->SetFlag(SBX_EXTFOUND);
+                break;
             }
         }
     }
@@ -526,20 +536,18 @@ bool SbxArray::StoreData( SvStream& rStrm ) const
     // Which elements are even defined?
     for( n = 0; n < mpVarEntries->size(); n++ )
     {
-        SbxVariableRef* pRef = (*mpVarEntries)[n];
-        SbxVariable* p = *pRef;
-        if( p && !( p->GetFlags() & SBX_DONTSTORE ) )
+        SbxVarEntry* pEntry = (*mpVarEntries)[n];
+        if (pEntry->mpVar && !(pEntry->mpVar->GetFlags() & SBX_DONTSTORE))
             nElem++;
     }
     rStrm.WriteUInt16( (sal_uInt16) nElem );
     for( n = 0; n < mpVarEntries->size(); n++ )
     {
-        SbxVariableRef* pRef = (*mpVarEntries)[n];
-        SbxVariable* p = *pRef;
-        if( p && !( p->GetFlags() & SBX_DONTSTORE ) )
+        SbxVarEntry* pEntry = (*mpVarEntries)[n];
+        if (pEntry->mpVar && !(pEntry->mpVar->GetFlags() & SBX_DONTSTORE))
         {
             rStrm.WriteUInt16( (sal_uInt16) n );
-            if( !p->Store( rStrm ) )
+            if (!pEntry->mpVar->Store(rStrm))
                 return false;
         }
     }
diff --git a/include/basic/sbx.hxx b/include/basic/sbx.hxx
index 0e1c8d2..6fa85b9 100644
--- a/include/basic/sbx.hxx
+++ b/include/basic/sbx.hxx
@@ -115,7 +115,7 @@ public:
 // The variables convert from SbxVariablen. Put()/Insert() into the
 // declared datatype, if they are not SbxVARIANT.
 
-class SbxVarEntry;
+struct SbxVarEntry;
 
 class BASIC_DLLPUBLIC SbxArray : public SbxBase
 {
commit e14abb13dc7e314840ea09dd78e96c816aee6456
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Wed Jun 25 12:38:14 2014 -0400

    Use boost::optional to store alias name.
    
    Change-Id: I809b21ea156061a265c0d83d58534df10bc273bc

diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx
index 138a796..bfa5bc5 100644
--- a/basic/source/runtime/runtime.cxx
+++ b/basic/source/runtime/runtime.cxx
@@ -3717,10 +3717,10 @@ void SbiRuntime::SetupArgs( SbxVariable* p, sal_uInt32 nOp1 )
                             for( i = 1 ; i < nArgCount ; i++ )
                             {
                                 SbxVariable* pVar = refArgv->Get( i );
-                                const OUString& rName = refArgv->GetAlias( i );
-                                if( !rName.isEmpty() )
+                                OUString aName = refArgv->GetAlias(i);
+                                if (!aName.isEmpty())
                                 {
-                                    pNames[i] = rName;
+                                    pNames[i] = aName;
                                 }
                                 pArg->Put( pVar, nCurPar++ );
                             }
@@ -3774,15 +3774,15 @@ void SbiRuntime::SetupArgs( SbxVariable* p, sal_uInt32 nOp1 )
                 for( i = 1 ; i < nArgCount ; i++ )
                 {
                     SbxVariable* pVar = refArgv->Get( i );
-                    const OUString& rName = refArgv->GetAlias( i );
-                    if( !rName.isEmpty() )
+                    OUString aName = refArgv->GetAlias(i);
+                    if (!aName.isEmpty())
                     {
                         // nCurPar is set to the found parameter
                         sal_uInt16 j = 1;
                         const SbxParamInfo* pParam = pInfo->GetParam( j );
                         while( pParam )
                         {
-                            if( pParam->aName.equalsIgnoreAsciiCase( rName ) )
+                            if( pParam->aName.equalsIgnoreAsciiCase( aName ) )
                             {
                                 nCurPar = j;
                                 break;
diff --git a/basic/source/sbx/sbxarray.cxx b/basic/source/sbx/sbxarray.cxx
index 1b901c3..57a55a3 100644
--- a/basic/source/sbx/sbxarray.cxx
+++ b/basic/source/sbx/sbxarray.cxx
@@ -21,6 +21,9 @@
 #include <basic/sbx.hxx>
 #include "runtime.hxx"
 #include <vector>
+
+#include <boost/optional.hpp>
+
 using namespace std;
 
 struct SbxDim {                 // an array-dimension:
@@ -31,9 +34,8 @@ struct SbxDim {                 // an array-dimension:
 
 class SbxVarEntry : public SbxVariableRef {
 public:
-    OUString* pAlias;
-    SbxVarEntry() : SbxVariableRef(), pAlias( NULL ) {}
-   ~SbxVarEntry() { delete pAlias; }
+    boost::optional<OUString> maAlias;
+    SbxVarEntry() : SbxVariableRef() {}
 };
 
 TYPEINIT1(SbxArray,SbxBase)
@@ -73,10 +75,10 @@ SbxArray& SbxArray::operator=( const SbxArray& rArray )
                 continue;
             SbxVarEntry* pDstRef = new SbxVarEntry;
             *((SbxVariableRef*) pDstRef) = *((SbxVariableRef*) pSrcRef);
-            if( pSrcRef->pAlias )
-            {
-                pDstRef->pAlias = new OUString( *pSrcRef->pAlias );
-            }
+
+            if (pSrcRef->maAlias)
+                pDstRef->maAlias.reset(*pSrcRef->maAlias);
+
             if( eType != SbxVARIANT )
             {
                 // Convert no objects
@@ -234,23 +236,19 @@ void SbxArray::Put( SbxVariable* pVar, sal_uInt16 nIdx )
     }
 }
 
-const OUString& SbxArray::GetAlias( sal_uInt16 nIdx )
+OUString SbxArray::GetAlias( sal_uInt16 nIdx )
 {
-static const OUString sEmpty("");
-
     if( !CanRead() )
     {
         SetError( SbxERR_PROP_WRITEONLY );
-        return sEmpty;
+        return OUString();
     }
     SbxVarEntry& rRef = (SbxVarEntry&) GetRef( nIdx );
 
-    if ( !rRef.pAlias )
-    {
-        return sEmpty;
-    }
+    if (!rRef.maAlias)
+        return OUString();
 
-    return *rRef.pAlias;
+    return *rRef.maAlias;
 }
 
 void SbxArray::PutAlias( const OUString& rAlias, sal_uInt16 nIdx )
@@ -262,14 +260,7 @@ void SbxArray::PutAlias( const OUString& rAlias, sal_uInt16 nIdx )
     else
     {
         SbxVarEntry& rRef = (SbxVarEntry&) GetRef( nIdx );
-        if( !rRef.pAlias )
-        {
-            rRef.pAlias = new OUString( rAlias );
-        }
-        else
-        {
-            *rRef.pAlias = rAlias;
-        }
+        rRef.maAlias.reset(rAlias);
     }
 }
 
@@ -382,9 +373,9 @@ void SbxArray::Merge( SbxArray* p )
                     SbxVarEntry* pRef = new SbxVarEntry;
                     mpVarEntries->push_back(pRef);
                     *((SbxVariableRef*) pRef) = *((SbxVariableRef*) pRef1);
-                    if( pRef1->pAlias )
+                    if (pRef1->maAlias)
                     {
-                        pRef->pAlias = new OUString( *pRef1->pAlias );
+                        pRef->maAlias.reset(*pRef1->maAlias);
                     }
                 }
             }
diff --git a/include/basic/sbx.hxx b/include/basic/sbx.hxx
index 1549bfb..0e1c8d2 100644
--- a/include/basic/sbx.hxx
+++ b/include/basic/sbx.hxx
@@ -152,7 +152,7 @@ public:
     void                 Remove( sal_uInt16 );
     void                 Remove( SbxVariable* );
     void                 Merge( SbxArray* );
-    const OUString&      GetAlias( sal_uInt16 );
+    OUString             GetAlias( sal_uInt16 );
     void                 PutAlias( const OUString&, sal_uInt16 );
     SbxVariable*         FindUserData( sal_uInt32 nUserData );
     virtual SbxVariable* Find( const OUString&, SbxClassType );
commit ff0ecb262181b2969e552037a4a4455deb33f925
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Wed Jun 25 12:18:49 2014 -0400

    pData -> mpVarEntries.
    
    pData is a nightmare with grepping as it's too generic of a name.
    
    Change-Id: I01b3f1b503f21ee13c97733fa66804874a2cddc4

diff --git a/basic/source/sbx/sbxarray.cxx b/basic/source/sbx/sbxarray.cxx
index 494b321..1b901c3 100644
--- a/basic/source/sbx/sbxarray.cxx
+++ b/basic/source/sbx/sbxarray.cxx
@@ -43,7 +43,7 @@ TYPEINIT1(SbxDimArray,SbxArray)
 
 SbxArray::SbxArray( SbxDataType t ) : SbxBase()
 {
-    pData = new VarEntriesType;
+    mpVarEntries = new VarEntriesType;
     eType = t;
     if( t != SbxVARIANT )
         SetFlag( SBX_FIXED );
@@ -52,7 +52,7 @@ SbxArray::SbxArray( SbxDataType t ) : SbxBase()
 SbxArray::SbxArray( const SbxArray& rArray ) :
     SvRefBase( rArray ), SbxBase()
 {
-    pData = new VarEntriesType;
+    mpVarEntries = new VarEntriesType;
     if( rArray.eType != SbxVARIANT )
         SetFlag( SBX_FIXED );
     *this = rArray;
@@ -64,7 +64,7 @@ SbxArray& SbxArray::operator=( const SbxArray& rArray )
     {
         eType = rArray.eType;
         Clear();
-        VarEntriesType* pSrc = rArray.pData;
+        VarEntriesType* pSrc = rArray.mpVarEntries;
         for( sal_uInt32 i = 0; i < pSrc->size(); i++ )
         {
             SbxVarEntry* pSrcRef = (*pSrc)[i];
@@ -85,7 +85,7 @@ SbxArray& SbxArray::operator=( const SbxArray& rArray )
                     ((SbxVariable*) pSrc_)->Convert( eType );
                 }
             }
-            pData->push_back( pDstRef );
+            mpVarEntries->push_back( pDstRef );
         }
     }
     return *this;
@@ -94,7 +94,7 @@ SbxArray& SbxArray::operator=( const SbxArray& rArray )
 SbxArray::~SbxArray()
 {
     Clear();
-    delete pData;
+    delete mpVarEntries;
 }
 
 SbxDataType SbxArray::GetType() const
@@ -109,23 +109,23 @@ SbxClassType SbxArray::GetClass() const
 
 void SbxArray::Clear()
 {
-    sal_uInt32 nSize = pData->size();
+    sal_uInt32 nSize = mpVarEntries->size();
     for( sal_uInt32 i = 0 ; i < nSize ; i++ )
     {
-        SbxVarEntry* pEntry = (*pData)[i];
+        SbxVarEntry* pEntry = (*mpVarEntries)[i];
         delete pEntry;
     }
-    pData->clear();
+    mpVarEntries->clear();
 }
 
 sal_uInt32 SbxArray::Count32() const
 {
-    return pData->size();
+    return mpVarEntries->size();
 }
 
 sal_uInt16 SbxArray::Count() const
 {
-    sal_uInt32 nCount = pData->size();
+    sal_uInt32 nCount = mpVarEntries->size();
     DBG_ASSERT( nCount <= SBX_MAXINDEX, "SBX: Array-Index > SBX_MAXINDEX" );
     return (sal_uInt16)nCount;
 }
@@ -140,11 +140,11 @@ SbxVariableRef& SbxArray::GetRef32( sal_uInt32 nIdx )
         SetError( SbxERR_BOUNDS );
         nIdx = 0;
     }
-    while( pData->size() <= nIdx )
+    while( mpVarEntries->size() <= nIdx )
     {
-        pData->push_back(new SbxVarEntry);
+        mpVarEntries->push_back(new SbxVarEntry);
     }
-    return *((*pData)[nIdx]);
+    return *((*mpVarEntries)[nIdx]);
 }
 
 SbxVariableRef& SbxArray::GetRef( sal_uInt16 nIdx )
@@ -157,11 +157,11 @@ SbxVariableRef& SbxArray::GetRef( sal_uInt16 nIdx )
         SetError( SbxERR_BOUNDS );
         nIdx = 0;
     }
-    while( pData->size() <= nIdx )
+    while( mpVarEntries->size() <= nIdx )
     {
-        pData->push_back(new SbxVarEntry);
+        mpVarEntries->push_back(new SbxVarEntry);
     }
-    return *((*pData)[nIdx]);
+    return *((*mpVarEntries)[nIdx]);
 }
 
 SbxVariable* SbxArray::Get32( sal_uInt32 nIdx )
@@ -275,14 +275,14 @@ void SbxArray::PutAlias( const OUString& rAlias, sal_uInt16 nIdx )
 
 void SbxArray::Insert32( SbxVariable* pVar, sal_uInt32 nIdx )
 {
-    DBG_ASSERT( pData->size() <= SBX_MAXINDEX32, "SBX: Array gets too big" );
-    if( pData->size() > SBX_MAXINDEX32 )
+    DBG_ASSERT( mpVarEntries->size() <= SBX_MAXINDEX32, "SBX: Array gets too big" );
+    if( mpVarEntries->size() > SBX_MAXINDEX32 )
     {
             return;
     }
     SbxVarEntry* p = new SbxVarEntry;
     *((SbxVariableRef*) p) = pVar;
-    size_t nSize = pData->size();
+    size_t nSize = mpVarEntries->size();
     if( nIdx > nSize )
     {
         nIdx = nSize;
@@ -293,19 +293,19 @@ void SbxArray::Insert32( SbxVariable* pVar, sal_uInt32 nIdx )
     }
     if( nIdx == nSize )
     {
-        pData->push_back( p );
+        mpVarEntries->push_back( p );
     }
     else
     {
-        pData->insert( pData->begin() + nIdx, p );
+        mpVarEntries->insert( mpVarEntries->begin() + nIdx, p );
     }
     SetFlag( SBX_MODIFIED );
 }
 
 void SbxArray::Insert( SbxVariable* pVar, sal_uInt16 nIdx )
 {
-    DBG_ASSERT( pData->size() <= 0x3FF0, "SBX: Array gets too big" );
-    if( pData->size() > 0x3FF0 )
+    DBG_ASSERT( mpVarEntries->size() <= 0x3FF0, "SBX: Array gets too big" );
+    if( mpVarEntries->size() > 0x3FF0 )
     {
         return;
     }
@@ -314,10 +314,10 @@ void SbxArray::Insert( SbxVariable* pVar, sal_uInt16 nIdx )
 
 void SbxArray::Remove32( sal_uInt32 nIdx )
 {
-    if( nIdx < pData->size() )
+    if( nIdx < mpVarEntries->size() )
     {
-        SbxVariableRef* pRef = (*pData)[nIdx];
-        pData->erase( pData->begin() + nIdx );
+        SbxVariableRef* pRef = (*mpVarEntries)[nIdx];
+        mpVarEntries->erase( mpVarEntries->begin() + nIdx );
         delete pRef;
         SetFlag( SBX_MODIFIED );
     }
@@ -325,10 +325,10 @@ void SbxArray::Remove32( sal_uInt32 nIdx )
 
 void SbxArray::Remove( sal_uInt16 nIdx )
 {
-    if( nIdx < pData->size() )
+    if( nIdx < mpVarEntries->size() )
     {
-        SbxVariableRef* pRef = (*pData)[nIdx];
-        pData->erase( pData->begin() + nIdx );
+        SbxVariableRef* pRef = (*mpVarEntries)[nIdx];
+        mpVarEntries->erase( mpVarEntries->begin() + nIdx );
         delete pRef;
         SetFlag( SBX_MODIFIED );
     }
@@ -338,9 +338,9 @@ void SbxArray::Remove( SbxVariable* pVar )
 {
     if( pVar )
     {
-        for( sal_uInt32 i = 0; i < pData->size(); i++ )
+        for( sal_uInt32 i = 0; i < mpVarEntries->size(); i++ )
         {
-            SbxVariableRef* pRef = (*pData)[i];
+            SbxVariableRef* pRef = (*mpVarEntries)[i];
             if( *pRef == pVar )
             {
                 Remove32( i ); break;
@@ -359,7 +359,7 @@ void SbxArray::Merge( SbxArray* p )
         sal_uInt32 nSize = p->Count();
         for( sal_uInt32 i = 0; i < nSize; i++ )
         {
-            SbxVarEntry* pRef1 = (*(p->pData))[i];
+            SbxVarEntry* pRef1 = (*(p->mpVarEntries))[i];
             // Is the element by name already inside?
             // Then overwrite!
             SbxVariable* pVar = *pRef1;
@@ -367,9 +367,9 @@ void SbxArray::Merge( SbxArray* p )
             {
                 OUString aName = pVar->GetName();
                 sal_uInt16 nHash = pVar->GetHashCode();
-                for( sal_uInt32 j = 0; j < pData->size(); j++ )
+                for( sal_uInt32 j = 0; j < mpVarEntries->size(); j++ )
                 {
-                    SbxVariableRef* pRef2 = (*pData)[j];
+                    SbxVariableRef* pRef2 = (*mpVarEntries)[j];
                     if( (*pRef2)->GetHashCode() == nHash
                         && (*pRef2)->GetName().equalsIgnoreAsciiCase( aName ) )
                     {
@@ -380,7 +380,7 @@ void SbxArray::Merge( SbxArray* p )
                 if( pRef1 )
                 {
                     SbxVarEntry* pRef = new SbxVarEntry;
-                    pData->push_back(pRef);
+                    mpVarEntries->push_back(pRef);
                     *((SbxVariableRef*) pRef) = *((SbxVariableRef*) pRef1);
                     if( pRef1->pAlias )
                     {
@@ -398,9 +398,9 @@ void SbxArray::Merge( SbxArray* p )
 SbxVariable* SbxArray::FindUserData( sal_uInt32 nData )
 {
     SbxVariable* p = NULL;
-    for( sal_uInt32 i = 0; i < pData->size(); i++ )
+    for( sal_uInt32 i = 0; i < mpVarEntries->size(); i++ )
     {
-        SbxVariableRef* pRef = (*pData)[i];
+        SbxVariableRef* pRef = (*mpVarEntries)[i];
         SbxVariable* pVar = *pRef;
         if( pVar )
         {
@@ -446,14 +446,14 @@ SbxVariable* SbxArray::FindUserData( sal_uInt32 nData )
 SbxVariable* SbxArray::Find( const OUString& rName, SbxClassType t )
 {
     SbxVariable* p = NULL;
-    sal_uInt32 nCount = pData->size();
+    sal_uInt32 nCount = mpVarEntries->size();
     if( !nCount )
         return NULL;
     bool bExtSearch = IsSet( SBX_EXTSEARCH );
     sal_uInt16 nHash = SbxVariable::MakeHashCode( rName );
     for( sal_uInt32 i = 0; i < nCount; i++ )
     {
-        SbxVariableRef* pRef = (*pData)[i];
+        SbxVariableRef* pRef = (*mpVarEntries)[i];
         SbxVariable* pVar = *pRef;
         if( pVar && pVar->IsVisible() )
         {
@@ -533,17 +533,17 @@ bool SbxArray::StoreData( SvStream& rStrm ) const
     sal_uInt32 nElem = 0;
     sal_uInt32 n;
     // Which elements are even defined?
-    for( n = 0; n < pData->size(); n++ )
+    for( n = 0; n < mpVarEntries->size(); n++ )
     {
-        SbxVariableRef* pRef = (*pData)[n];
+        SbxVariableRef* pRef = (*mpVarEntries)[n];
         SbxVariable* p = *pRef;
         if( p && !( p->GetFlags() & SBX_DONTSTORE ) )
             nElem++;
     }
     rStrm.WriteUInt16( (sal_uInt16) nElem );
-    for( n = 0; n < pData->size(); n++ )
+    for( n = 0; n < mpVarEntries->size(); n++ )
     {
-        SbxVariableRef* pRef = (*pData)[n];
+        SbxVariableRef* pRef = (*mpVarEntries)[n];
         SbxVariable* p = *pRef;
         if( p && !( p->GetFlags() & SBX_DONTSTORE ) )
         {
diff --git a/include/basic/sbx.hxx b/include/basic/sbx.hxx
index 55022a8..1549bfb 100644
--- a/include/basic/sbx.hxx
+++ b/include/basic/sbx.hxx
@@ -127,7 +127,7 @@ class BASIC_DLLPUBLIC SbxArray : public SbxBase
     friend SbxObject* cloneTypeObjectImpl( const SbxObject& rTypeObj );
     BASIC_DLLPRIVATE void PutDirect( SbxVariable* pVar, sal_uInt32 nIdx );
 
-    VarEntriesType* pData;          // The variables
+    VarEntriesType* mpVarEntries;          // The variables
 
 protected:
     SbxDataType eType;            // Data type of the array
commit bb6d9b0123dcde32fe260f6d1c3e567d1ddfcb35
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Wed Jun 25 12:13:32 2014 -0400

    Remove this class that only derives from std::vector and not much else.
    
    Change-Id: Ibc584f4148cec49a9ac34a240cc2fa3e87daf443

diff --git a/basic/source/sbx/sbxarray.cxx b/basic/source/sbx/sbxarray.cxx
index 61ff86e..494b321 100644
--- a/basic/source/sbx/sbxarray.cxx
+++ b/basic/source/sbx/sbxarray.cxx
@@ -36,15 +36,6 @@ public:
    ~SbxVarEntry() { delete pAlias; }
 };
 
-typedef SbxVarEntry* SbxVarEntryPtr;
-typedef vector< SbxVarEntryPtr > SbxVarEntryPtrVector;
-class SbxVarRefs : public SbxVarEntryPtrVector
-{
-public:
-    SbxVarRefs( void ) {}
-};
-
-
 TYPEINIT1(SbxArray,SbxBase)
 TYPEINIT1(SbxDimArray,SbxArray)
 
@@ -52,7 +43,7 @@ TYPEINIT1(SbxDimArray,SbxArray)
 
 SbxArray::SbxArray( SbxDataType t ) : SbxBase()
 {
-    pData = new SbxVarRefs;
+    pData = new VarEntriesType;
     eType = t;
     if( t != SbxVARIANT )
         SetFlag( SBX_FIXED );
@@ -61,7 +52,7 @@ SbxArray::SbxArray( SbxDataType t ) : SbxBase()
 SbxArray::SbxArray( const SbxArray& rArray ) :
     SvRefBase( rArray ), SbxBase()
 {
-    pData = new SbxVarRefs;
+    pData = new VarEntriesType;
     if( rArray.eType != SbxVARIANT )
         SetFlag( SBX_FIXED );
     *this = rArray;
@@ -73,14 +64,14 @@ SbxArray& SbxArray::operator=( const SbxArray& rArray )
     {
         eType = rArray.eType;
         Clear();
-        SbxVarRefs* pSrc = rArray.pData;
+        VarEntriesType* pSrc = rArray.pData;
         for( sal_uInt32 i = 0; i < pSrc->size(); i++ )
         {
-            SbxVarEntryPtr pSrcRef = (*pSrc)[i];
+            SbxVarEntry* pSrcRef = (*pSrc)[i];
             const SbxVariable* pSrc_ = *pSrcRef;
             if( !pSrc_ )
                 continue;
-            SbxVarEntryPtr pDstRef = new SbxVarEntry;
+            SbxVarEntry* pDstRef = new SbxVarEntry;
             *((SbxVariableRef*) pDstRef) = *((SbxVariableRef*) pSrcRef);
             if( pSrcRef->pAlias )
             {
@@ -151,8 +142,7 @@ SbxVariableRef& SbxArray::GetRef32( sal_uInt32 nIdx )
     }
     while( pData->size() <= nIdx )
     {
-        const SbxVarEntryPtr p = new SbxVarEntry;
-        pData->push_back( p );
+        pData->push_back(new SbxVarEntry);
     }
     return *((*pData)[nIdx]);
 }
@@ -169,8 +159,7 @@ SbxVariableRef& SbxArray::GetRef( sal_uInt16 nIdx )
     }
     while( pData->size() <= nIdx )
     {
-        const SbxVarEntryPtr p = new SbxVarEntry;
-        pData->push_back( p );
+        pData->push_back(new SbxVarEntry);
     }
     return *((*pData)[nIdx]);
 }
@@ -291,9 +280,9 @@ void SbxArray::Insert32( SbxVariable* pVar, sal_uInt32 nIdx )
     {
             return;
     }
-    SbxVarEntryPtr p = new SbxVarEntry;
+    SbxVarEntry* p = new SbxVarEntry;
     *((SbxVariableRef*) p) = pVar;
-    SbxVarEntryPtrVector::size_type nSize = pData->size();
+    size_t nSize = pData->size();
     if( nIdx > nSize )
     {
         nIdx = nSize;
@@ -370,7 +359,7 @@ void SbxArray::Merge( SbxArray* p )
         sal_uInt32 nSize = p->Count();
         for( sal_uInt32 i = 0; i < nSize; i++ )
         {
-            SbxVarEntryPtr pRef1 = (*(p->pData))[i];
+            SbxVarEntry* pRef1 = (*(p->pData))[i];
             // Is the element by name already inside?
             // Then overwrite!
             SbxVariable* pVar = *pRef1;
@@ -390,9 +379,8 @@ void SbxArray::Merge( SbxArray* p )
                 }
                 if( pRef1 )
                 {
-                    SbxVarEntryPtr pRef = new SbxVarEntry;
-                    const SbxVarEntryPtr pTemp = pRef;
-                    pData->push_back( pTemp );
+                    SbxVarEntry* pRef = new SbxVarEntry;
+                    pData->push_back(pRef);
                     *((SbxVariableRef*) pRef) = *((SbxVariableRef*) pRef1);
                     if( pRef1->pAlias )
                     {
diff --git a/include/basic/sbx.hxx b/include/basic/sbx.hxx
index c642e12..55022a8 100644
--- a/include/basic/sbx.hxx
+++ b/include/basic/sbx.hxx
@@ -115,17 +115,19 @@ public:
 // The variables convert from SbxVariablen. Put()/Insert() into the
 // declared datatype, if they are not SbxVARIANT.
 
-class SbxVarRefs;
+class SbxVarEntry;
 
 class BASIC_DLLPUBLIC SbxArray : public SbxBase
 {
+    typedef std::vector<SbxVarEntry*> VarEntriesType;
+
 // #100883 Method to set method directly to parameter array
     friend class SbMethod;
     friend class SbClassModuleObject;
     friend SbxObject* cloneTypeObjectImpl( const SbxObject& rTypeObj );
     BASIC_DLLPRIVATE void PutDirect( SbxVariable* pVar, sal_uInt32 nIdx );
 
-    SbxVarRefs*   pData;          // The variables
+    VarEntriesType* pData;          // The variables
 
 protected:
     SbxDataType eType;            // Data type of the array


More information about the Libreoffice-commits mailing list