summaryrefslogtreecommitdiff
path: root/basic
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2014-06-25 12:38:14 -0400
committerKohei Yoshida <kohei.yoshida@collabora.com>2014-06-25 15:03:46 -0400
commite14abb13dc7e314840ea09dd78e96c816aee6456 (patch)
treedc75b810ff5a00ea9b99b1d5f11b13668d1dceed /basic
parentff0ecb262181b2969e552037a4a4455deb33f925 (diff)
Use boost::optional to store alias name.
Change-Id: I809b21ea156061a265c0d83d58534df10bc273bc
Diffstat (limited to 'basic')
-rw-r--r--basic/source/runtime/runtime.cxx12
-rw-r--r--basic/source/sbx/sbxarray.cxx43
2 files changed, 23 insertions, 32 deletions
diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx
index 138a796d035b..bfa5bc55a3ed 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 1b901c30f495..57a55a3361dc 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);
}
}
}