summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2023-12-18 15:19:49 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2023-12-18 15:51:10 +0100
commita66ffb4409b950c6847ab7ca7f6522f13338c3c4 (patch)
tree3deba6c227abc6e5fe525c7695e18690c706aa59 /sw
parent5bc7d0186d1a70990377a2f4c630fe11e2dfd166 (diff)
unique_ptr->optional in SwDoc::ExecMacro
Change-Id: I343e6ce50dcc6aac2182c11e5ca093f22c58c418 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160914 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw')
-rw-r--r--sw/source/core/doc/docbasic.cxx20
1 files changed, 10 insertions, 10 deletions
diff --git a/sw/source/core/doc/docbasic.cxx b/sw/source/core/doc/docbasic.cxx
index 697559b0b469..19f757535d09 100644
--- a/sw/source/core/doc/docbasic.cxx
+++ b/sw/source/core/doc/docbasic.cxx
@@ -36,16 +36,16 @@
using namespace ::com::sun::star::uno;
-static Sequence<Any> *lcl_docbasic_convertArgs( SbxArray& rArgs )
+static std::optional<Sequence<Any>> lcl_docbasic_convertArgs( SbxArray& rArgs )
{
- Sequence<Any> *pRet = nullptr;
+ std::optional<Sequence<Any>> oRet;
sal_uInt32 nCount = rArgs.Count();
if( nCount > 1 )
{
nCount--;
- pRet = new Sequence<Any>( nCount );
- Any *pUnoArgs = pRet->getArray();
+ oRet.emplace( nCount );
+ Any *pUnoArgs = oRet->getArray();
for( sal_uInt32 i=0; i<nCount; i++ )
{
SbxVariable* pVar = rArgs.Get(i + 1);
@@ -70,7 +70,7 @@ static Sequence<Any> *lcl_docbasic_convertArgs( SbxArray& rArgs )
}
}
- return pRet;
+ return oRet;
}
void SwDoc::ExecMacro( const SvxMacro& rMacro, OUString* pRet, SbxArray* pArgs )
@@ -99,17 +99,17 @@ void SwDoc::ExecMacro( const SvxMacro& rMacro, OUString* pRet, SbxArray* pArgs )
break;
case EXTENDED_STYPE:
{
- std::unique_ptr<Sequence<Any> > pUnoArgs;
+ std::optional<Sequence<Any> > oUnoArgs;
if( pArgs )
{
// better to rename the local function to lcl_translateBasic2Uno and
// a much shorter routine can be found in sfx2/source/doc/objmisc.cxx
- pUnoArgs.reset(lcl_docbasic_convertArgs( *pArgs ));
+ oUnoArgs = lcl_docbasic_convertArgs( *pArgs );
}
- if (!pUnoArgs)
+ if (!oUnoArgs)
{
- pUnoArgs.reset(new Sequence< Any > (0));
+ oUnoArgs.emplace(0);
}
// TODO - return value is not handled
@@ -120,7 +120,7 @@ void SwDoc::ExecMacro( const SvxMacro& rMacro, OUString* pRet, SbxArray* pArgs )
SAL_INFO("sw", "SwDoc::ExecMacro URL is " << rMacro.GetMacName() );
mpDocShell->CallXScript(
- rMacro.GetMacName(), *pUnoArgs, aRet, aOutArgsIndex, aOutArgs);
+ rMacro.GetMacName(), *oUnoArgs, aRet, aOutArgsIndex, aOutArgs);
break;
}