basic/source/classes/sbxmod.cxx                |   12 ++++++------
 basic/source/comp/io.cxx                       |   16 +++++++---------
 basic/source/comp/parser.cxx                   |    6 +++---
 basic/source/uno/namecont.cxx                  |   14 +++++++-------
 basic/source/uno/scriptcont.cxx                |    4 ++--
 cui/source/dialogs/screenshotannotationdlg.cxx |    6 +++---
 hwpfilter/source/hwpread.cxx                   |    3 +--
 i18npool/source/collator/gencoll_rule.cxx      |    6 +++---
 sc/source/ui/docshell/tablink.cxx              |   12 ++++++------
 sw/source/core/crsr/viscrs.cxx                 |   10 +++++-----
 sw/source/uibase/dbui/dbmgr.cxx                |    4 ++--
 11 files changed, 45 insertions(+), 48 deletions(-)

New commits:
commit cf14352cd8eeb202f0b3a57a14909435818931bb
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Thu Oct 31 11:23:06 2024 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Fri Nov 1 07:27:27 2024 +0100

    no need to heap allocate these
    
    Change-Id: I28127f5943a80aca1689d5982cd1f6e6e11eb2c5
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175863
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx
index 81faaaa05f1f..1120207b5906 100644
--- a/basic/source/classes/sbxmod.cxx
+++ b/basic/source/classes/sbxmod.cxx
@@ -1704,18 +1704,18 @@ void 
SbModule::GetCodeCompleteDataFromParse(CodeCompleteDataCache& aCache)
     ErrorHdlResetter aErrHdl;
     SbxBase::ResetError();
 
-    auto pParser = 
std::make_unique<SbiParser>(static_cast<StarBASIC*>(GetParent()), this );
-    pParser->SetCodeCompleting(true);
+    SbiParser aParser(static_cast<StarBASIC*>(GetParent()), this );
+    aParser.SetCodeCompleting(true);
 
-    while( pParser->Parse() ) {}
-    SbiSymPool* pPool = pParser->pPool;
+    while( aParser.Parse() ) {}
+    SbiSymPool* pPool = aParser.pPool;
     aCache.Clear();
     for( sal_uInt16 i = 0; i < pPool->GetSize(); ++i )
     {
         SbiSymDef* pSymDef = pPool->Get(i);
         //std::cerr << "i: " << i << ", type: " << pSymDef->GetType() << "; 
name:" << pSymDef->GetName() << std::endl;
         if( (pSymDef->GetType() != SbxEMPTY) && (pSymDef->GetType() != 
SbxNULL) )
-            aCache.InsertGlobalVar( pSymDef->GetName(), 
pParser->aGblStrings.Find(pSymDef->GetTypeId()) );
+            aCache.InsertGlobalVar( pSymDef->GetName(), 
aParser.aGblStrings.Find(pSymDef->GetTypeId()) );
 
         SbiSymPool& rChildPool = pSymDef->GetPool();
         for(sal_uInt16 j = 0; j < rChildPool.GetSize(); ++j )
@@ -1723,7 +1723,7 @@ void 
SbModule::GetCodeCompleteDataFromParse(CodeCompleteDataCache& aCache)
             SbiSymDef* pChildSymDef = rChildPool.Get(j);
             //std::cerr << "j: " << j << ", type: " << pChildSymDef->GetType() 
<< "; name:" << pChildSymDef->GetName() << std::endl;
             if( (pChildSymDef->GetType() != SbxEMPTY) && 
(pChildSymDef->GetType() != SbxNULL) )
-                aCache.InsertLocalVar( pSymDef->GetName(), 
pChildSymDef->GetName(), pParser->aGblStrings.Find(pChildSymDef->GetTypeId()) );
+                aCache.InsertLocalVar( pSymDef->GetName(), 
pChildSymDef->GetName(), aParser.aGblStrings.Find(pChildSymDef->GetTypeId()) );
         }
     }
 }
diff --git a/basic/source/comp/io.cxx b/basic/source/comp/io.cxx
index 716d8ee95dda..672a04d83f7c 100644
--- a/basic/source/comp/io.cxx
+++ b/basic/source/comp/io.cxx
@@ -53,9 +53,7 @@ void SbiParser::Print()
     {
         if( !IsEoln( Peek() ) )
         {
-            auto pExpr = std::make_unique<SbiExpression>(this);
-            pExpr->Gen();
-            pExpr.reset();
+            SbiExpression(this).Gen();
             Peek();
             aGen.Gen( eCurTok == COMMA ? SbiOpcode::PRINTF_ : 
SbiOpcode::BPRINT_ );
         }
@@ -82,7 +80,7 @@ void SbiParser::Write()
 
     while( !bAbort )
     {
-        auto pExpr = std::make_unique<SbiExpression>(this);
+        std::optional<SbiExpression> pExpr(std::in_place, this);
         pExpr->Gen();
         pExpr.reset();
         aGen.Gen( SbiOpcode::BWRITE_ );
@@ -130,7 +128,7 @@ void SbiParser::Line()
 void SbiParser::LineInput()
 {
     Channel( true );
-    auto pExpr = std::make_unique<SbiExpression>( this, SbOPERAND );
+    std::optional<SbiExpression> pExpr( std::in_place, this, SbOPERAND );
     if( !pExpr->IsVariable() )
         Error( ERRCODE_BASIC_VAR_EXPECTED );
     if( pExpr->GetType() != SbxVARIANT && pExpr->GetType() != SbxSTRING )
@@ -147,7 +145,7 @@ void SbiParser::Input()
 {
     aGen.Gen( SbiOpcode::RESTART_ );
     Channel( true );
-    auto pExpr = std::make_unique<SbiExpression>( this, SbOPERAND );
+    std::optional<SbiExpression> pExpr( std::in_place, this, SbOPERAND );
     while( !bAbort )
     {
         if( !pExpr->IsVariable() )
@@ -157,7 +155,7 @@ void SbiParser::Input()
         if( Peek() == COMMA )
         {
             Next();
-            pExpr.reset(new SbiExpression( this, SbOPERAND ));
+            pExpr.emplace( this, SbOPERAND );
         }
         else break;
     }
@@ -236,7 +234,7 @@ void SbiParser::Open()
     }
     TestToken( AS );
     // channel number
-    auto pChan = std::make_unique<SbiExpression>( this );
+    SbiExpression aChan( this );
     std::unique_ptr<SbiExpression> pLen;
     if( Peek() == SYMBOL )
     {
@@ -253,7 +251,7 @@ void SbiParser::Open()
     // channel number
     // file name
     pLen->Gen();
-    pChan->Gen();
+    aChan.Gen();
     aFileName.Gen();
     aGen.Gen( SbiOpcode::OPEN_, static_cast<sal_uInt32>(nMode), 
static_cast<sal_uInt32>(nFlags) );
     bInStatement = false;
diff --git a/basic/source/comp/parser.cxx b/basic/source/comp/parser.cxx
index cc6ee0b7cc5c..73896f616df3 100644
--- a/basic/source/comp/parser.cxx
+++ b/basic/source/comp/parser.cxx
@@ -597,11 +597,11 @@ void SbiParser::Set()
     if( eTok == NEW )
     {
         Next();
-        auto pTypeDef = std::make_unique<SbiSymDef>( OUString() );
-        TypeDecl( *pTypeDef, true );
+        SbiSymDef aTypeDef( u""_ustr );
+        TypeDecl( aTypeDef, true );
 
         aLvalue.Gen();
-        aGen.Gen( SbiOpcode::CREATE_, pDef->GetId(), pTypeDef->GetTypeId() );
+        aGen.Gen( SbiOpcode::CREATE_, pDef->GetId(), aTypeDef.GetTypeId() );
         aGen.Gen( SbiOpcode::SETCLASS_, pDef->GetTypeId() );
     }
     else
diff --git a/basic/source/uno/namecont.cxx b/basic/source/uno/namecont.cxx
index e90be0c4849a..ca2fb19f4f26 100644
--- a/basic/source/uno/namecont.cxx
+++ b/basic/source/uno/namecont.cxx
@@ -796,12 +796,12 @@ void SfxLibraryContainer::init_Impl( const OUString& 
rInitialDocumentURL,
             source.sSystemId    = aFileName;
 
             // start parsing
-            auto pLibArray = std::make_unique<::xmlscript::LibDescriptorArray> 
( );
+            ::xmlscript::LibDescriptorArray aLibArray;
 
             Reference< XParser > xParser = xml::sax::Parser::create(mxContext);
             try
             {
-                xParser->setDocumentHandler( 
::xmlscript::importLibraryContainer( pLibArray.get() ) );
+                xParser->setDocumentHandler( 
::xmlscript::importLibraryContainer( &aLibArray ) );
                 xParser->parseStream( source );
             }
             catch ( const xml::sax::SAXException& )
@@ -815,10 +815,10 @@ void SfxLibraryContainer::init_Impl( const OUString& 
rInitialDocumentURL,
                 return;
             }
 
-            sal_Int32 nLibCount = pLibArray->mnLibCount;
+            sal_Int32 nLibCount = aLibArray.mnLibCount;
             for( sal_Int32 i = 0 ; i < nLibCount ; i++ )
             {
-                ::xmlscript::LibDescriptor& rLib = pLibArray->mpLibs[i];
+                ::xmlscript::LibDescriptor& rLib = aLibArray.mpLibs[i];
 
                 // Check storage URL
                 OUString aStorageURL = rLib.aStorageURL;
@@ -1859,7 +1859,7 @@ void SfxLibraryContainer::storeLibraries_Impl( const 
uno::Reference< embed::XSto
     int iArray = 0;
     pName = aNames.getConstArray();
     ::xmlscript::LibDescriptor aLibDescriptorForExtensionLibs;
-    auto pLibArray = std::make_unique< ::xmlscript::LibDescriptorArray > ( 
nLibsToSave );
+    ::xmlscript::LibDescriptorArray aLibArray( nLibsToSave );
     for( ; pName != pNamesEnd; ++pName )
     {
         SfxLibrary* pImplLib = getImplLib( *pName );
@@ -1869,7 +1869,7 @@ void SfxLibraryContainer::storeLibraries_Impl( const 
uno::Reference< embed::XSto
         }
         const bool bExtensionLib = pImplLib->mbExtension;
         ::xmlscript::LibDescriptor& rLib = bExtensionLib ?
-              aLibDescriptorForExtensionLibs : pLibArray->mpLibs[iArray];
+              aLibDescriptorForExtensionLibs : aLibArray.mpLibs[iArray];
         if( !bExtensionLib )
         {
             iArray++;
@@ -2112,7 +2112,7 @@ void SfxLibraryContainer::storeLibraries_Impl( const 
uno::Reference< embed::XSto
 
     try
     {
-        xmlscript::exportLibraryContainer( xWriter, pLibArray.get() );
+        xmlscript::exportLibraryContainer( xWriter, &aLibArray );
         if ( bStorage )
         {
             uno::Reference< embed::XTransactedObject > xTransact( 
xTargetLibrariesStor, uno::UNO_QUERY_THROW );
diff --git a/basic/source/uno/scriptcont.cxx b/basic/source/uno/scriptcont.cxx
index 4f90fecd3e13..ac755302d261 100644
--- a/basic/source/uno/scriptcont.cxx
+++ b/basic/source/uno/scriptcont.cxx
@@ -335,11 +335,11 @@ void SfxScriptLibraryContainer::importFromOldStorage( 
const OUString& aFile )
     rtl::Reference<SotStorage> xStorage(new SotStorage(false, aFile));
     if( xStorage->GetError() == ERRCODE_NONE )
     {
-        auto pBasicManager = std::make_unique<BasicManager> ( *xStorage, aFile 
);
+        BasicManager aBasicManager( *xStorage, aFile );
 
         // Set info
         LibraryContainerInfo aInfo( this, nullptr, this );
-        pBasicManager->SetLibraryContainerInfo( aInfo );
+        aBasicManager.SetLibraryContainerInfo( aInfo );
     }
 }
 
diff --git a/cui/source/dialogs/screenshotannotationdlg.cxx 
b/cui/source/dialogs/screenshotannotationdlg.cxx
index 8fc2ea362b32..c321931f8f49 100644
--- a/cui/source/dialogs/screenshotannotationdlg.cxx
+++ b/cui/source/dialogs/screenshotannotationdlg.cxx
@@ -278,11 +278,11 @@ IMPL_LINK_NOARG(ScreenshotAnnotationDlg_Impl, 
saveButtonHandler, weld::Button&,
     // get a suggestion for the filename from buildable name
     OUString aDerivedFileName = mrParentDialog.get_buildable_name();
 
-    auto xFileDlg = 
std::make_unique<sfx2::FileDialogHelper>(ui::dialogs::TemplateDescription::FILESAVE_AUTOEXTENSION,
+    sfx2::FileDialogHelper 
aFileDlg(ui::dialogs::TemplateDescription::FILESAVE_AUTOEXTENSION,
                                                              
FileDialogFlags::NONE, mpParentWindow);
-    xFileDlg->SetContext(sfx2::FileDialogHelper::ScreenshotAnnotation);
+    aFileDlg.SetContext(sfx2::FileDialogHelper::ScreenshotAnnotation);
 
-    const uno::Reference< ui::dialogs::XFilePicker3 > xFilePicker = 
xFileDlg->GetFilePicker();
+    const uno::Reference< ui::dialogs::XFilePicker3 > xFilePicker = 
aFileDlg.GetFilePicker();
 
     xFilePicker->setTitle(maSaveAsText);
 
diff --git a/hwpfilter/source/hwpread.cxx b/hwpfilter/source/hwpread.cxx
index 98a8e56aa5e5..671834e37d9d 100644
--- a/hwpfilter/source/hwpread.cxx
+++ b/hwpfilter/source/hwpread.cxx
@@ -501,10 +501,9 @@ bool Picture::Read(HWPFile & hwpf)
 
         if (pictype == PICTYPE_DRAW)
         {
-            auto xGuard(std::make_unique<ChangeMemGuard>(follow.data(), 
follow_block_size));
+            ChangeMemGuard aGuard(follow.data(), follow_block_size);
             LoadDrawingObjectBlock(this, hwpf);
             style.cell = picinfo.picdraw.hdo;
-            xGuard.reset();
         }
         else if (follow_block_size >= 4)
         {
diff --git a/i18npool/source/collator/gencoll_rule.cxx 
b/i18npool/source/collator/gencoll_rule.cxx
index 76f8987e36d1..c034d7e24393 100644
--- a/i18npool/source/collator/gencoll_rule.cxx
+++ b/i18npool/source/collator/gencoll_rule.cxx
@@ -112,15 +112,15 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
     //UCollator *coll = ucol_openRules(Obuf.getStr(), Obuf.getLength(), 
UCOL_OFF,
     //        UCOL_DEFAULT_STRENGTH, &parseError, &status);
 
-    auto coll = 
std::make_unique<icu::RuleBasedCollator>(reinterpret_cast<const UChar 
*>(Obuf.getStr()), status);
+    icu::RuleBasedCollator coll(reinterpret_cast<const UChar 
*>(Obuf.getStr()), status);
 
     if (U_SUCCESS(status)) {
         std::vector<uint8_t> data;
-        int32_t len = coll->cloneBinary(nullptr, 0, status);
+        int32_t len = coll.cloneBinary(nullptr, 0, status);
         if (status == U_BUFFER_OVERFLOW_ERROR) {
             data.resize(len);
             status = U_ZERO_ERROR;
-            len = coll->cloneBinary(data.data(), len, status);
+            len = coll.cloneBinary(data.data(), len, status);
         }
         if (U_SUCCESS(status))
             data_write(argv[2], argv[3], data.data(), len);
diff --git a/sc/source/ui/docshell/tablink.cxx 
b/sc/source/ui/docshell/tablink.cxx
index 3732bddf949f..f6d3182e1759 100644
--- a/sc/source/ui/docshell/tablink.cxx
+++ b/sc/source/ui/docshell/tablink.cxx
@@ -431,21 +431,21 @@ bool ScDocumentLoader::GetFilterName( const OUString& 
rFileName,
     //  Filter detection
 
     std::shared_ptr<const SfxFilter> pSfxFilter;
-    auto pMedium = std::make_unique<SfxMedium>( rFileName, 
StreamMode::STD_READ );
-    if (pMedium->GetErrorIgnoreWarning() == ERRCODE_NONE && 
!comphelper::IsFuzzing())
+    SfxMedium aMedium( rFileName, StreamMode::STD_READ );
+    if (aMedium.GetErrorIgnoreWarning() == ERRCODE_NONE && 
!comphelper::IsFuzzing())
     {
         if ( bWithInteraction )
-            pMedium->UseInteractionHandler(true);   // #i73992# no longer 
called from GuessFilter
+            aMedium.UseInteractionHandler(true);   // #i73992# no longer 
called from GuessFilter
 
         SfxFilterMatcher aMatcher(u"scalc"_ustr);
         if( bWithContent )
-            aMatcher.GuessFilter( *pMedium, pSfxFilter );
+            aMatcher.GuessFilter( aMedium, pSfxFilter );
         else
-            aMatcher.GuessFilterIgnoringContent( *pMedium, pSfxFilter );
+            aMatcher.GuessFilterIgnoringContent( aMedium, pSfxFilter );
     }
 
     bool bOK = false;
-    if ( pMedium->GetErrorIgnoreWarning() == ERRCODE_NONE )
+    if ( aMedium.GetErrorIgnoreWarning() == ERRCODE_NONE )
     {
         if ( pSfxFilter )
             rFilter = pSfxFilter->GetFilterName();
diff --git a/sw/source/core/crsr/viscrs.cxx b/sw/source/core/crsr/viscrs.cxx
index 25de24892a8d..33894da0440f 100644
--- a/sw/source/core/crsr/viscrs.cxx
+++ b/sw/source/core/crsr/viscrs.cxx
@@ -659,14 +659,14 @@ void SwSelPaintRects::HighlightContentControl()
         }
         if (pCurContentControlAtCursor)
         {
-            auto pCursorForContentControl = std::make_unique<SwShellCursor>(
+            SwShellCursor aCursorForContentControl(
                 *GetShell(), SwPosition(*pTextNode, 
pCurContentControlAtCursor->GetStart()));
-            pCursorForContentControl->SetMark();
-            pCursorForContentControl->GetMark()->Assign(
+            aCursorForContentControl.SetMark();
+            aCursorForContentControl.GetMark()->Assign(
                 *pTextNode, *(pCurContentControlAtCursor->End()));
 
-            pCursorForContentControl->FillRects();
-            SwRects* pRects = pCursorForContentControl.get();
+            aCursorForContentControl.FillRects();
+            SwRects* pRects = &aCursorForContentControl;
             for (const auto& rRect : *pRects)
             {
                 tools::Rectangle aRect(rRect.SVRect());
diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx
index fd1b7bd1f6db..a651b20b8520 100644
--- a/sw/source/uibase/dbui/dbmgr.cxx
+++ b/sw/source/uibase/dbui/dbmgr.cxx
@@ -793,10 +793,10 @@ static void lcl_SaveDebugDoc( SfxObjectShell 
*xTargetDocShell,
     // aTempFile is not deleted, but that seems to be intentional
     utl::TempFileNamed aTempFile( basename, true, u".odt", &sTempDirURL );
     INetURLObject aTempFileURL( aTempFile.GetURL() );
-    auto pDstMed = std::make_unique<SfxMedium>(
+    SfxMedium aDstMed(
         aTempFileURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ),
         StreamMode::STD_READWRITE );
-    bool bAnyError = !xTargetDocShell->DoSaveAs( *pDstMed );
+    bool bAnyError = !xTargetDocShell->DoSaveAs( aDstMed );
     // xObjectShell->DoSaveCompleted crashes the mail merge unit tests, so 
skip it
     bAnyError |= (ERRCODE_NONE != xTargetDocShell->GetErrorIgnoreWarning());
     if( bAnyError )

Reply via email to