[Libreoffice-commits] core.git: sc/inc sc/source
Noel Grandin
noel at peralex.com
Thu Dec 12 10:18:39 PST 2013
sc/inc/funcdesc.hxx | 4 -
sc/source/core/data/funcdesc.cxx | 79 +++++++++++++++++---------------------
sc/source/core/tool/addincol.cxx | 14 +++---
sc/source/ui/formdlg/dwfunctr.cxx | 4 -
sc/source/ui/unoobj/appluno.cxx | 10 +---
5 files changed, 52 insertions(+), 59 deletions(-)
New commits:
commit f7b675475b88d35728ddc1b38eaf26ea5600a30e
Author: Noel Grandin <noel at peralex.com>
Date: Thu Dec 12 16:31:45 2013 +0200
Convert OUString** to std::vector<OUString> in ScFuncDesc
There is no point in storing a ref-counted value type like OUString by
pointer.
And while we're there, convert array to std::vector
Change-Id: I5c0d3b7276e28956ec98852b52a6eaeb5a13dfed
Reviewed-on: https://gerrit.libreoffice.org/7057
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/sc/inc/funcdesc.hxx b/sc/inc/funcdesc.hxx
index fb892ec..ed4a85c 100644
--- a/sc/inc/funcdesc.hxx
+++ b/sc/inc/funcdesc.hxx
@@ -200,8 +200,8 @@ public:
OUString *pFuncName; /**< Function name */
OUString *pFuncDesc; /**< Description of function */
- OUString **ppDefArgNames; /**< Parameter name(s) */
- OUString **ppDefArgDescs; /**< Description(s) of parameter(s) */
+ std::vector<OUString> maDefArgNames; /**< Parameter name(s) */
+ std::vector<OUString> maDefArgDescs; /**< Description(s) of parameter(s) */
ParameterFlags *pDefArgFlags; /**< Flags for each parameter */
sal_uInt16 nFIndex; /**< Unique function index */
sal_uInt16 nCategory; /**< Function category */
diff --git a/sc/source/core/data/funcdesc.cxx b/sc/source/core/data/funcdesc.cxx
index f93fe0c..1262925 100644
--- a/sc/source/core/data/funcdesc.cxx
+++ b/sc/source/core/data/funcdesc.cxx
@@ -66,8 +66,6 @@ public:
ScFuncDesc::ScFuncDesc() :
pFuncName (NULL),
pFuncDesc (NULL),
- ppDefArgNames (NULL),
- ppDefArgDescs (NULL),
pDefArgFlags (NULL),
nFIndex (0),
nCategory (0),
@@ -90,18 +88,11 @@ void ScFuncDesc::Clear()
nArgs -= VAR_ARGS - 1;
if (nArgs)
{
- for (sal_uInt16 i=0; i<nArgs; i++ )
- {
- delete ppDefArgNames[i];
- delete ppDefArgDescs[i];
- }
- delete [] ppDefArgNames;
- delete [] ppDefArgDescs;
delete [] pDefArgFlags;
}
nArgCount = 0;
- ppDefArgNames = NULL;
- ppDefArgDescs = NULL;
+ maDefArgNames.clear();
+ maDefArgDescs.clear();
pDefArgFlags = NULL;
delete pFuncName;
@@ -136,7 +127,7 @@ OUString ScFuncDesc::GetParamList() const
else
{
nLastAdded = i;
- aSig.append(*(ppDefArgNames[i]));
+ aSig.append(maDefArgNames[i]);
if ( i != nArgCount-1 )
{
aSig.append(sep);
@@ -157,7 +148,7 @@ OUString ScFuncDesc::GetParamList() const
{
if (!pDefArgFlags[nArg].bSuppress)
{
- aSig.append(*(ppDefArgNames[nArg]));
+ aSig.append(maDefArgNames[nArg]);
aSig.append(sep);
aSig.appendAscii( " " );
}
@@ -166,11 +157,11 @@ OUString ScFuncDesc::GetParamList() const
* there were, we'd have to cope with it here and above for the fix
* parameters. For now parameters are always added, so no special
* treatment of a trailing "; " necessary. */
- aSig.append(*(ppDefArgNames[nFix]));
+ aSig.append(maDefArgNames[nFix]);
aSig.append('1');
aSig.append(sep);
aSig.append(' ');
- aSig.append(*(ppDefArgNames[nFix]));
+ aSig.append(maDefArgNames[nFix]);
aSig.append('2');
aSig.append(sep);
aSig.appendAscii(" ... ");
@@ -182,23 +173,23 @@ OUString ScFuncDesc::GetParamList() const
{
if (!pDefArgFlags[nArg].bSuppress)
{
- aSig.append(*(ppDefArgNames[nArg]));
+ aSig.append(maDefArgNames[nArg]);
aSig.append(sep);
aSig.appendAscii( " " );
}
}
- aSig.append(*(ppDefArgNames[nFix]));
+ aSig.append(maDefArgNames[nFix]);
aSig.append('1');
aSig.appendAscii( ", " );
- aSig.append(*(ppDefArgNames[nFix+1]));
+ aSig.append(maDefArgNames[nFix+1]);
aSig.append('1');
aSig.append(sep);
aSig.appendAscii( " " );
- aSig.append(*(ppDefArgNames[nFix]));
+ aSig.append(maDefArgNames[nFix]);
aSig.append('2');
aSig.appendAscii( ", " );
- aSig.append(*(ppDefArgNames[nFix+1]));
+ aSig.append(maDefArgNames[nFix+1]);
aSig.append('2');
aSig.append(sep);
aSig.appendAscii( " ... " );
@@ -373,12 +364,12 @@ sal_uInt32 ScFuncDesc::getParameterCount() const
OUString ScFuncDesc::getParameterName(sal_uInt32 _nPos) const
{
- return *(ppDefArgNames[_nPos]);
+ return maDefArgNames[_nPos];
}
OUString ScFuncDesc::getParameterDescription(sal_uInt32 _nPos) const
{
- return *(ppDefArgDescs[_nPos]);
+ return maDefArgDescs[_nPos];
}
bool ScFuncDesc::isParameterOptional(sal_uInt32 _nPos) const
@@ -483,63 +474,65 @@ ScFunctionList::ScFunctionList() :
pDesc->nArgCount = nArgs;
if (nArgs)
{
+ pDesc->maDefArgNames.clear();
+ pDesc->maDefArgNames.resize(nArgs);
+ pDesc->maDefArgDescs.clear();
+ pDesc->maDefArgDescs.resize(nArgs);
pDesc->pDefArgFlags = new ScFuncDesc::ParameterFlags[nArgs];
- pDesc->ppDefArgNames = new OUString*[nArgs];
- pDesc->ppDefArgDescs = new OUString*[nArgs];
for (sal_uInt16 j = 0; j < nArgs; ++j)
{
pDesc->pDefArgFlags[j].bOptional = false;
pDesc->pDefArgFlags[j].bSuppress = false;
pAddInFuncData->getParamDesc( aArgName, aArgDesc, j+1 );
if ( !aArgName.isEmpty() )
- pDesc->ppDefArgNames[j] = new OUString( aArgName );
+ pDesc->maDefArgNames[j] = aArgName;
else
{
switch (pAddInFuncData->GetParamType(j+1))
{
case PTR_DOUBLE:
- pDesc->ppDefArgNames[j] = new OUString( aDefArgNameValue );
+ pDesc->maDefArgNames[j] = aDefArgNameValue;
break;
case PTR_STRING:
- pDesc->ppDefArgNames[j] = new OUString( aDefArgNameString );
+ pDesc->maDefArgNames[j] = aDefArgNameString;
break;
case PTR_DOUBLE_ARR:
- pDesc->ppDefArgNames[j] = new OUString( aDefArgNameValues );
+ pDesc->maDefArgNames[j] = aDefArgNameValues;
break;
case PTR_STRING_ARR:
- pDesc->ppDefArgNames[j] = new OUString( aDefArgNameStrings );
+ pDesc->maDefArgNames[j] = aDefArgNameStrings;
break;
case PTR_CELL_ARR:
- pDesc->ppDefArgNames[j] = new OUString( aDefArgNameCells );
+ pDesc->maDefArgNames[j] = aDefArgNameCells;
break;
default:
- pDesc->ppDefArgNames[j] = new OUString( aDefArgNameNone );
+ pDesc->maDefArgNames[j] = aDefArgNameNone;
break;
}
}
if ( !aArgDesc.isEmpty() )
- pDesc->ppDefArgDescs[j] = new OUString( aArgDesc );
+ pDesc->maDefArgDescs[j] = aArgDesc;
else
{
switch (pAddInFuncData->GetParamType(j+1))
{
case PTR_DOUBLE:
- pDesc->ppDefArgDescs[j] = new OUString( aDefArgDescValue );
+ pDesc->maDefArgDescs[j] = aDefArgDescValue;
break;
case PTR_STRING:
- pDesc->ppDefArgDescs[j] = new OUString( aDefArgDescString );
+ pDesc->maDefArgDescs[j] = aDefArgDescString;
break;
case PTR_DOUBLE_ARR:
- pDesc->ppDefArgDescs[j] = new OUString( aDefArgDescValues );
+ pDesc->maDefArgDescs[j] = aDefArgDescValues;
break;
case PTR_STRING_ARR:
- pDesc->ppDefArgDescs[j] = new OUString( aDefArgDescStrings );
+ pDesc->maDefArgDescs[j] = aDefArgDescStrings;
break;
case PTR_CELL_ARR:
- pDesc->ppDefArgDescs[j] = new OUString( aDefArgDescCells );
+ pDesc->maDefArgDescs[j] = aDefArgDescCells;
break;
default:
- pDesc->ppDefArgDescs[j] = new OUString( aDefArgDescNone );
+ pDesc->maDefArgDescs[j] = aDefArgDescNone;
break;
}
}
@@ -897,12 +890,14 @@ ScFuncRes::ScFuncRes( ResId &aRes, ScFuncDesc* pDesc, bool & rbSuppressed )
if (nArgs)
{
- pDesc->ppDefArgNames = new OUString*[nArgs];
- pDesc->ppDefArgDescs = new OUString*[nArgs];
+ pDesc->maDefArgNames.clear();
+ pDesc->maDefArgNames.resize(nArgs);
+ pDesc->maDefArgDescs.clear();
+ pDesc->maDefArgDescs.resize(nArgs);
for (sal_uInt16 i = 0; i < nArgs; ++i)
{
- pDesc->ppDefArgNames[i] = new OUString(SC_RESSTR(2*(i+1) ));
- pDesc->ppDefArgDescs[i] = new OUString(SC_RESSTR(2*(i+1)+1));
+ pDesc->maDefArgNames[i] = SC_RESSTR(2*(i+1) );
+ pDesc->maDefArgDescs[i] = SC_RESSTR(2*(i+1)+1);
}
}
diff --git a/sc/source/core/tool/addincol.cxx b/sc/source/core/tool/addincol.cxx
index 2e10096..03e222c 100644
--- a/sc/source/core/tool/addincol.cxx
+++ b/sc/source/core/tool/addincol.cxx
@@ -1265,22 +1265,24 @@ bool ScUnoAddInCollection::FillFunctionDescFromData( const ScUnoAddInFuncData& r
bool bMultiple = false;
const ScAddInArgDesc* pArgs = rFuncData.GetArguments();
- rDesc.ppDefArgNames = new OUString*[nArgCount];
- rDesc.ppDefArgDescs = new OUString*[nArgCount];
+ rDesc.maDefArgNames.clear();
+ rDesc.maDefArgNames.resize(nArgCount);
+ rDesc.maDefArgDescs.clear();
+ rDesc.maDefArgDescs.resize(nArgCount);
rDesc.pDefArgFlags = new ScFuncDesc::ParameterFlags[nArgCount];
for ( long nArg=0; nArg<nArgCount; nArg++ )
{
- rDesc.ppDefArgNames[nArg] = new OUString( pArgs[nArg].aName );
- rDesc.ppDefArgDescs[nArg] = new OUString( pArgs[nArg].aDescription );
+ rDesc.maDefArgNames[nArg] = pArgs[nArg].aName;
+ rDesc.maDefArgDescs[nArg] = pArgs[nArg].aDescription;
rDesc.pDefArgFlags[nArg].bOptional = pArgs[nArg].bOptional;
rDesc.pDefArgFlags[nArg].bSuppress = false;
// no empty names...
- if ( rDesc.ppDefArgNames[nArg]->isEmpty() )
+ if ( rDesc.maDefArgNames[nArg].isEmpty() )
{
OUString aDefName("arg");
aDefName += OUString::number( nArg+1 );
- *rDesc.ppDefArgNames[nArg] = aDefName;
+ rDesc.maDefArgNames[nArg] = aDefName;
}
// last argument repeated?
diff --git a/sc/source/ui/formdlg/dwfunctr.cxx b/sc/source/ui/formdlg/dwfunctr.cxx
index 7967163..1d9fc51 100644
--- a/sc/source/ui/formdlg/dwfunctr.cxx
+++ b/sc/source/ui/formdlg/dwfunctr.cxx
@@ -865,7 +865,7 @@ void ScFunctionDockWin::DoEnter(sal_Bool /* bOk */) //@@ ???
{
// NOTE: Theoretically the first parameter could have the
// suppress flag as well, but practically it doesn't.
- aFirstArgStr = *(pDesc->ppDefArgNames[0]);
+ aFirstArgStr = pDesc->maDefArgNames[0];
aFirstArgStr = comphelper::string::strip(aFirstArgStr, ' ');
aFirstArgStr = aFirstArgStr.replaceAll(" ", "_");
aArgStr = aFirstArgStr;
@@ -885,7 +885,7 @@ void ScFunctionDockWin::DoEnter(sal_Bool /* bOk */) //@@ ???
if (!pDesc->pDefArgFlags[nArg].bSuppress)
{
aArgStr += aArgSep;
- OUString sTmp(*(pDesc->ppDefArgNames[nArg]));
+ OUString sTmp = pDesc->maDefArgNames[nArg];
sTmp = comphelper::string::strip(sTmp, ' ');
sTmp = sTmp.replaceAll(" ", "_");
aArgStr += sTmp;
diff --git a/sc/source/ui/unoobj/appluno.cxx b/sc/source/ui/unoobj/appluno.cxx
index a93c4f9..6687301 100644
--- a/sc/source/ui/unoobj/appluno.cxx
+++ b/sc/source/ui/unoobj/appluno.cxx
@@ -797,7 +797,7 @@ static void lcl_FillSequence( uno::Sequence<beans::PropertyValue>& rSequence, co
pArray[3].Value <<= OUString( *rDesc.pFuncDesc );
pArray[4].Name = OUString( SC_UNONAME_ARGUMENTS );
- if (rDesc.ppDefArgNames && rDesc.ppDefArgDescs && rDesc.pDefArgFlags )
+ if (!rDesc.maDefArgNames.empty() && !rDesc.maDefArgDescs.empty() && rDesc.pDefArgFlags )
{
sal_uInt16 nCount = rDesc.nArgCount;
if (nCount >= PAIRED_VAR_ARGS)
@@ -818,13 +818,9 @@ static void lcl_FillSequence( uno::Sequence<beans::PropertyValue>& rSequence, co
{
if (!rDesc.pDefArgFlags[i].bSuppress)
{
- OUString aArgName;
- if (rDesc.ppDefArgNames[i]) aArgName = *rDesc.ppDefArgNames[i];
- OUString aArgDesc;
- if (rDesc.ppDefArgDescs[i]) aArgDesc = *rDesc.ppDefArgDescs[i];
sheet::FunctionArgument aArgument;
- aArgument.Name = aArgName;
- aArgument.Description = aArgDesc;
+ aArgument.Name = rDesc.maDefArgNames[i];
+ aArgument.Description = rDesc.maDefArgDescs[i];
aArgument.IsOptional = rDesc.pDefArgFlags[i].bOptional;
pArgAry[j++] = aArgument;
}
More information about the Libreoffice-commits
mailing list