summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-06-22 13:10:27 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-06-26 08:08:31 +0200
commit0901f0b88beb50d9d6acc6eccd96fe55d96a6986 (patch)
treeffc14e5d0b681a98b7399a8d21e4592717c7ca43 /sc
parent95d9d5c8d53ec6c3ced3615f9d9420e2698dc04d (diff)
loplugin:useuniqueptr in ScFuncDesc
Change-Id: I2b4843bea22c097d377351833e0215153f6721ad Reviewed-on: https://gerrit.libreoffice.org/56330 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/funcdesc.hxx5
-rw-r--r--sc/source/core/data/funcdesc.cxx45
-rw-r--r--sc/source/core/tool/addincol.cxx6
-rw-r--r--sc/source/ui/app/inputhdl.cxx8
-rw-r--r--sc/source/ui/app/inputwin.cxx6
-rw-r--r--sc/source/ui/formdlg/dwfunctr.cxx4
-rw-r--r--sc/source/ui/unoobj/appluno.cxx16
7 files changed, 43 insertions, 47 deletions
diff --git a/sc/inc/funcdesc.hxx b/sc/inc/funcdesc.hxx
index 8ff400e3afbf..65ce16a7cf2e 100644
--- a/sc/inc/funcdesc.hxx
+++ b/sc/inc/funcdesc.hxx
@@ -27,6 +27,7 @@
#include <formula/IFunctionDescription.hxx>
#include <sal/types.h>
#include <rtl/ustring.hxx>
+#include <boost/optional.hpp>
#include <map>
#include <memory>
@@ -206,8 +207,8 @@ public:
ParameterFlags() : bOptional(false) {}
};
- OUString *pFuncName; /**< Function name */
- OUString *pFuncDesc; /**< Description of function */
+ boost::optional<OUString> mxFuncName; /**< Function name */
+ boost::optional<OUString> mxFuncDesc; /**< Description of function */
std::vector<OUString> maDefArgNames; /**< Parameter name(s) */
std::vector<OUString> maDefArgDescs; /**< Description(s) of parameter(s) */
ParameterFlags *pDefArgFlags; /**< Flags for each parameter */
diff --git a/sc/source/core/data/funcdesc.cxx b/sc/source/core/data/funcdesc.cxx
index 5143be8de956..ef3f999208cf 100644
--- a/sc/source/core/data/funcdesc.cxx
+++ b/sc/source/core/data/funcdesc.cxx
@@ -98,8 +98,6 @@ public:
// class ScFuncDesc:
ScFuncDesc::ScFuncDesc() :
- pFuncName (nullptr),
- pFuncDesc (nullptr),
pDefArgFlags (nullptr),
nFIndex (0),
nCategory (0),
@@ -132,11 +130,8 @@ void ScFuncDesc::Clear()
maDefArgDescs.clear();
pDefArgFlags = nullptr;
- delete pFuncName;
- pFuncName = nullptr;
-
- delete pFuncDesc;
- pFuncDesc = nullptr;
+ mxFuncName.reset();
+ mxFuncDesc.reset();
nFIndex = 0;
nCategory = 0;
@@ -228,9 +223,9 @@ OUString ScFuncDesc::getSignature() const
{
OUStringBuffer aSig;
- if(pFuncName)
+ if(mxFuncName)
{
- aSig.append(*pFuncName);
+ aSig.append(*mxFuncName);
OUString aParamList = GetParamList();
if( !aParamList.isEmpty() )
@@ -253,9 +248,9 @@ OUString ScFuncDesc::getFormula( const ::std::vector< OUString >& _aArguments )
OUStringBuffer aFormula;
- if(pFuncName)
+ if(mxFuncName)
{
- aFormula.append( *pFuncName );
+ aFormula.append( *mxFuncName );
aFormula.append( "(" );
if ( nArgCount > 0 && !_aArguments.empty() && !_aArguments[0].isEmpty())
@@ -299,8 +294,8 @@ sal_uInt16 ScFuncDesc::GetSuppressedArgCount() const
OUString ScFuncDesc::getFunctionName() const
{
OUString sRet;
- if ( pFuncName )
- sRet = *pFuncName;
+ if ( mxFuncName )
+ sRet = *mxFuncName;
return sRet;
}
@@ -312,8 +307,8 @@ const formula::IFunctionCategory* ScFuncDesc::getCategory() const
OUString ScFuncDesc::getDescription() const
{
OUString sRet;
- if ( pFuncDesc )
- sRet = *pFuncDesc;
+ if ( mxFuncDesc )
+ sRet = *mxFuncDesc;
return sRet;
}
@@ -349,10 +344,10 @@ void ScFuncDesc::initArgumentInfo() const
// get the full argument description
// (add-in has to be instantiated to get the type information)
- if ( bIncomplete && pFuncName )
+ if ( bIncomplete && mxFuncName )
{
ScUnoAddInCollection& rAddIns = *ScGlobal::GetAddInCollection();
- OUString aIntName(rAddIns.FindFunction( *pFuncName, true )); // pFuncName is upper-case
+ OUString aIntName(rAddIns.FindFunction( *mxFuncName, true )); // pFuncName is upper-case
if ( !aIntName.isEmpty() )
{
@@ -407,7 +402,7 @@ bool ScFuncDesc::isParameterOptional(sal_uInt32 _nPos) const
bool ScFuncDesc::compareByName(const ScFuncDesc* a, const ScFuncDesc* b)
{
- return (ScGlobal::GetCaseCollator()->compareString(*a->pFuncName, *b->pFuncName ) < 0);
+ return (ScGlobal::GetCaseCollator()->compareString(*a->mxFuncName, *b->mxFuncName ) < 0);
}
#define ENTRY(CODE) CODE, SAL_N_ELEMENTS(CODE)
@@ -850,7 +845,7 @@ ScFunctionList::ScFunctionList()
pDesc->nFIndex = i;
tmpFuncVector.push_back(pDesc);
- nStrLen = (*(pDesc->pFuncName)).getLength();
+ nStrLen = pDesc->mxFuncName->getLength();
if (nStrLen > nMaxFuncNameLen)
nMaxFuncNameLen = nStrLen;
}
@@ -885,14 +880,14 @@ ScFunctionList::ScFunctionList()
pLegacyFuncData->getParamDesc( aArgName, aArgDesc, 0 );
pDesc->nFIndex = nNextId++; // ??? OpCode vergeben
pDesc->nCategory = ID_FUNCTION_GRP_ADDINS;
- pDesc->pFuncName = new OUString(pLegacyFuncData->GetInternalName().toAsciiUpperCase());
+ pDesc->mxFuncName = pLegacyFuncData->GetInternalName().toAsciiUpperCase();
OUStringBuffer aBuf(aArgDesc);
aBuf.append('\n');
aBuf.append("( AddIn: ");
aBuf.append(pLegacyFuncData->GetModuleName());
aBuf.append(" )");
- pDesc->pFuncDesc = new OUString(aBuf.makeStringAndClear());
+ pDesc->mxFuncDesc = aBuf.makeStringAndClear();
pDesc->nArgCount = nArgs;
if (nArgs)
@@ -962,7 +957,7 @@ ScFunctionList::ScFunctionList()
}
tmpFuncVector.push_back(pDesc);
- nStrLen = (*(pDesc->pFuncName)).getLength();
+ nStrLen = pDesc->mxFuncName->getLength();
if ( nStrLen > nMaxFuncNameLen)
nMaxFuncNameLen = nStrLen;
}
@@ -979,7 +974,7 @@ ScFunctionList::ScFunctionList()
if ( pUnoAddIns->FillFunctionDesc( nFunc, *pDesc ) )
{
tmpFuncVector.push_back(pDesc);
- nStrLen = (*(pDesc->pFuncName)).getLength();
+ nStrLen = pDesc->mxFuncName->getLength();
if (nStrLen > nMaxFuncNameLen)
nMaxFuncNameLen = nStrLen;
}
@@ -1244,8 +1239,8 @@ ScFuncRes::ScFuncRes(const ScFuncDescCore &rEntry, ScFuncDesc* pDesc, bool& rbSu
}
}
- pDesc->pFuncName = new OUString(ScCompiler::GetNativeSymbol(static_cast<OpCode>(nOpCode)));
- pDesc->pFuncDesc = new OUString(ScResId(rEntry.pResource[0]));
+ pDesc->mxFuncName = ScCompiler::GetNativeSymbol(static_cast<OpCode>(nOpCode));
+ pDesc->mxFuncDesc = ScResId(rEntry.pResource[0]);
if (nArgs)
{
diff --git a/sc/source/core/tool/addincol.cxx b/sc/source/core/tool/addincol.cxx
index e72c9ccc2f68..62b0a2f96192 100644
--- a/sc/source/core/tool/addincol.cxx
+++ b/sc/source/core/tool/addincol.cxx
@@ -966,7 +966,7 @@ static void lcl_UpdateFunctionList( const ScFunctionList& rFunctionList, const S
for (sal_uLong nPos=0; nPos<nCount; nPos++)
{
const ScFuncDesc* pDesc = rFunctionList.GetFunction( nPos );
- if ( pDesc && pDesc->pFuncName && *pDesc->pFuncName == aCompare )
+ if ( pDesc && pDesc->mxFuncName && *pDesc->mxFuncName == aCompare )
{
ScUnoAddInCollection::FillFunctionDescFromData( rFuncData, *const_cast<ScFuncDesc*>(pDesc) );
break;
@@ -1233,14 +1233,14 @@ bool ScUnoAddInCollection::FillFunctionDescFromData( const ScUnoAddInFuncData& r
// nFIndex is set from outside
- rDesc.pFuncName = new OUString( rFuncData.GetUpperLocal() ); //TODO: upper?
+ rDesc.mxFuncName = rFuncData.GetUpperLocal(); //TODO: upper?
rDesc.nCategory = rFuncData.GetCategory();
rDesc.sHelpId = rFuncData.GetHelpId();
OUString aDesc = rFuncData.GetDescription();
if (aDesc.isEmpty())
aDesc = rFuncData.GetLocalName(); // use name if no description is available
- rDesc.pFuncDesc = new OUString( aDesc );
+ rDesc.mxFuncDesc = aDesc ;
// AddInArgumentType_CALLER is already left out in FuncData
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index 25adf2963ec1..58b416fbb47c 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -828,17 +828,17 @@ void ScInputHandler::GetFormulaData()
for(sal_uLong i=0;i<nListCount;i++)
{
const ScFuncDesc* pDesc = pFuncList->GetFunction( i );
- if ( pDesc->pFuncName )
+ if ( pDesc->mxFuncName )
{
- const sal_Unicode* pName = pDesc->pFuncName->getStr();
- const sal_Int32 nLen = pDesc->pFuncName->getLength();
+ const sal_Unicode* pName = pDesc->mxFuncName->getStr();
+ const sal_Int32 nLen = pDesc->mxFuncName->getLength();
// fdo#75264 fill maFormulaChar with all characters used in formula names
for ( sal_Int32 j = 0; j < nLen; j++ )
{
sal_Unicode c = pName[ j ];
maFormulaChar.insert( c );
}
- OUString aFuncName = *pDesc->pFuncName + aParenthesesReplacement;
+ OUString aFuncName = *pDesc->mxFuncName + aParenthesesReplacement;
pFormulaData->insert(ScTypedStrData(aFuncName, 0.0, ScTypedStrData::Standard));
pDesc->initArgumentInfo();
OUString aEntry = pDesc->getSignature();
diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx
index 5bba4dbe5e03..bd1b7be0d30c 100644
--- a/sc/source/ui/app/inputwin.cxx
+++ b/sc/source/ui/app/inputwin.cxx
@@ -1938,11 +1938,11 @@ void ScPosWnd::FillFunctions()
for (sal_uLong j=0; j<nListCount; j++)
{
const ScFuncDesc* pDesc = pFuncList->GetFunction( j );
- if ( pDesc->nFIndex == nId && pDesc->pFuncName )
+ if ( pDesc->nFIndex == nId && pDesc->mxFuncName )
{
- InsertEntry( *pDesc->pFuncName );
+ InsertEntry( *pDesc->mxFuncName );
if (aFirstName.isEmpty())
- aFirstName = *pDesc->pFuncName;
+ aFirstName = *pDesc->mxFuncName;
break; // Stop searching
}
}
diff --git a/sc/source/ui/formdlg/dwfunctr.cxx b/sc/source/ui/formdlg/dwfunctr.cxx
index 7f7848e5a432..7abb24ee10f3 100644
--- a/sc/source/ui/formdlg/dwfunctr.cxx
+++ b/sc/source/ui/formdlg/dwfunctr.cxx
@@ -189,7 +189,7 @@ void ScFunctionWin::SetDescription()
aBuf.append(":\n\n");
aBuf.append(pDesc->GetParamList());
aBuf.append("\n\n");
- aBuf.append(*pDesc->pFuncDesc);
+ aBuf.append(*pDesc->mxFuncDesc);
aFiFuncDesc->SetText(aBuf.makeStringAndClear());
aFiFuncDesc->StateChanged(StateChangedType::Text);
@@ -230,7 +230,7 @@ void ScFunctionWin::UpdateFunctionList()
while ( pDesc )
{
aFuncList->SetEntryData(
- aFuncList->InsertEntry( *(pDesc->pFuncName) ),
+ aFuncList->InsertEntry( *(pDesc->mxFuncName) ),
const_cast<ScFuncDesc *>(pDesc) );
pDesc = pFuncMgr->Next();
}
diff --git a/sc/source/ui/unoobj/appluno.cxx b/sc/source/ui/unoobj/appluno.cxx
index 1314acb412df..b62ddd6db66a 100644
--- a/sc/source/ui/unoobj/appluno.cxx
+++ b/sc/source/ui/unoobj/appluno.cxx
@@ -535,12 +535,12 @@ static void lcl_FillSequence( uno::Sequence<beans::PropertyValue>& rSequence, co
pArray[1].Value <<= static_cast<sal_Int32>(rDesc.nCategory);
pArray[2].Name = SC_UNONAME_NAME;
- if (rDesc.pFuncName)
- pArray[2].Value <<= *rDesc.pFuncName;
+ if (rDesc.mxFuncName)
+ pArray[2].Value <<= *rDesc.mxFuncName;
pArray[3].Name = SC_UNONAME_DESCRIPTION;
- if (rDesc.pFuncDesc)
- pArray[3].Value <<= *rDesc.pFuncDesc;
+ if (rDesc.mxFuncDesc)
+ pArray[3].Value <<= *rDesc.mxFuncDesc;
pArray[4].Name = SC_UNONAME_ARGUMENTS;
if (!rDesc.maDefArgNames.empty() && !rDesc.maDefArgDescs.empty() && rDesc.pDefArgFlags )
@@ -611,7 +611,7 @@ uno::Any SAL_CALL ScFunctionListObj::getByName( const OUString& aName )
{
const ScFuncDesc* pDesc = pFuncList->GetFunction(nIndex);
//! Case-insensitiv ???
- if ( pDesc && pDesc->pFuncName && aName == *pDesc->pFuncName )
+ if ( pDesc && pDesc->mxFuncName && aName == *pDesc->mxFuncName )
{
uno::Sequence<beans::PropertyValue> aSeq( SC_FUNCDESC_PROPCOUNT );
lcl_FillSequence( aSeq, *pDesc );
@@ -689,8 +689,8 @@ uno::Sequence<OUString> SAL_CALL ScFunctionListObj::getElementNames()
for (sal_uInt32 nIndex=0; nIndex<nCount; ++nIndex)
{
const ScFuncDesc* pDesc = pFuncList->GetFunction(nIndex);
- if ( pDesc && pDesc->pFuncName )
- pAry[nIndex] = *pDesc->pFuncName;
+ if ( pDesc && pDesc->mxFuncName )
+ pAry[nIndex] = *pDesc->mxFuncName;
}
return aSeq;
}
@@ -708,7 +708,7 @@ sal_Bool SAL_CALL ScFunctionListObj::hasByName( const OUString& aName )
{
const ScFuncDesc* pDesc = pFuncList->GetFunction(nIndex);
//! Case-insensitiv ???
- if ( pDesc && pDesc->pFuncName && aName == *pDesc->pFuncName )
+ if ( pDesc && pDesc->mxFuncName && aName == *pDesc->mxFuncName )
return true;
}
}