sw/source/core/doc/docbasic.cxx |   20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

New commits:
commit a66ffb4409b950c6847ab7ca7f6522f13338c3c4
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Mon Dec 18 15:19:49 2023 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Mon Dec 18 15:51:10 2023 +0100

    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.gran...@collabora.co.uk>

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;
         }

Reply via email to