basic/source/classes/sb.cxx                            |   30 ++++++++---------
 basic/source/inc/sbintern.hxx                          |   12 +++---
 basic/source/inc/stdobj.hxx                            |    5 +-
 basic/source/runtime/stdobj.cxx                        |    6 +--
 sc/source/filter/excel/xilink.cxx                      |    6 +--
 sc/source/filter/inc/xcl97esc.hxx                      |    3 +
 sc/source/filter/inc/xilink.hxx                        |    3 +
 sc/source/filter/xcl97/xcl97esc.cxx                    |    4 +-
 sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx |    8 ++--
 sc/source/filter/xml/XMLChangeTrackingImportHelper.hxx |    2 -
 sc/source/filter/xml/xmlimprt.cxx                      |   10 ++---
 sc/source/filter/xml/xmlimprt.hxx                      |    4 +-
 12 files changed, 49 insertions(+), 44 deletions(-)

New commits:
commit 4d0d98238b427b98310b6d0624e21bbec6d553f8
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Thu Mar 2 11:13:28 2023 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Thu Mar 2 12:23:47 2023 +0000

    flatten some classes in sc
    
    no need to allocate separately where the contained class is only one
    pointer big
    
    Change-Id: Ibd31ff94c6fae6683d2784173057290dd547954e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148087
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sc/source/filter/excel/xilink.cxx 
b/sc/source/filter/excel/xilink.cxx
index ada9bb1a36b0..10933aecf9c5 100644
--- a/sc/source/filter/excel/xilink.cxx
+++ b/sc/source/filter/excel/xilink.cxx
@@ -399,7 +399,7 @@ XclImpExtName::XclImpExtName( XclImpSupbook& rSupbook, 
XclImpStream& rStrm, XclS
             }
         break;
         case xlExtOLE:
-            mpMOper.reset( new MOper(rSupbook.GetSharedStringPool(), rStrm) );
+            moMOper.emplace( rSupbook.GetSharedStringPool(), rStrm );
         break;
         default:
             ;
@@ -472,7 +472,7 @@ bool extractSheetAndRange(const OUString& rName, OUString& 
rSheet, OUString& rRa
 bool XclImpExtName::CreateOleData(const ScDocument& rDoc, const OUString& rUrl,
                                   sal_uInt16& rFileId, OUString& rTabName, 
ScRange& rRange) const
 {
-    if (!mpMOper)
+    if (!moMOper)
         return false;
 
     OUString aSheet, aRangeStr;
@@ -488,7 +488,7 @@ bool XclImpExtName::CreateOleData(const ScDocument& rDoc, 
const OUString& rUrl,
         // We don't support multi-sheet range for this.
         return false;
 
-    const ScMatrix& rCache = mpMOper->GetCache();
+    const ScMatrix& rCache = moMOper->GetCache();
     SCSIZE nC, nR;
     rCache.GetDimensions(nC, nR);
     if (!nC || !nR)
diff --git a/sc/source/filter/inc/xcl97esc.hxx 
b/sc/source/filter/inc/xcl97esc.hxx
index d7724d758981..3a0a606113a7 100644
--- a/sc/source/filter/inc/xcl97esc.hxx
+++ b/sc/source/filter/inc/xcl97esc.hxx
@@ -20,6 +20,7 @@
 #pragma once
 
 #include <memory>
+#include <optional>
 #include <stack>
 #include <filter/msfilter/escherex.hxx>
 #include "xeroot.hxx"
@@ -37,7 +38,7 @@ private:
     virtual SvStream*   ImplQueryPictureStream() override;
 
 private:
-    ::std::unique_ptr< ::utl::TempFileFast > mxPicTempFile;
+    ::std::optional< ::utl::TempFileFast > moPicTempFile;
     SvStream* mpPicStrm;
 };
 
diff --git a/sc/source/filter/inc/xilink.hxx b/sc/source/filter/inc/xilink.hxx
index cdfef4c82397..686f928ff1c6 100644
--- a/sc/source/filter/inc/xilink.hxx
+++ b/sc/source/filter/inc/xilink.hxx
@@ -20,6 +20,7 @@
 #pragma once
 
 #include <memory>
+#include <optional>
 #include <map>
 #include "xllink.hxx"
 #include "xiroot.hxx"
@@ -154,7 +155,7 @@ private:
     typedef ::std::unique_ptr< ScTokenArray >       TokenArrayPtr;
 
     XclImpCachedMatrixPtr  mxDdeMatrix;     /// Cached results of the DDE link.
-    std::unique_ptr<MOper> mpMOper;         /// Cached values for OLE link
+    std::optional<MOper>   moMOper;         /// Cached values for OLE link
     TokenArrayPtr          mxArray;         /// Formula tokens for external 
name.
     OUString               maName;          /// The name of the external name.
     sal_uInt32             mnStorageId;     /// Storage ID for OLE object 
storages.
diff --git a/sc/source/filter/xcl97/xcl97esc.cxx 
b/sc/source/filter/xcl97/xcl97esc.cxx
index 03336e90b577..99d4db7ca53f 100644
--- a/sc/source/filter/xcl97/xcl97esc.cxx
+++ b/sc/source/filter/xcl97/xcl97esc.cxx
@@ -75,8 +75,8 @@ XclEscherExGlobal::XclEscherExGlobal( const XclExpRoot& rRoot 
)
 
 SvStream* XclEscherExGlobal::ImplQueryPictureStream()
 {
-    mxPicTempFile.reset( new ::utl::TempFileFast );
-    mpPicStrm = mxPicTempFile->GetStream( StreamMode::READWRITE );
+    moPicTempFile.emplace();
+    mpPicStrm = moPicTempFile->GetStream( StreamMode::READWRITE );
     mpPicStrm->SetEndian( SvStreamEndian::LITTLE );
     return mpPicStrm;
 }
diff --git a/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx 
b/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx
index b8737d663d97..efe429b49faa 100644
--- a/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx
+++ b/sc/source/filter/xml/XMLChangeTrackingImportHelper.cxx
@@ -285,7 +285,7 @@ void 
ScXMLChangeTrackingImportHelper::SetInsertionCutOff(const sal_uInt32 nID, c
     if ((pCurrentAction->nActionType == SC_CAT_DELETE_COLS) ||
         (pCurrentAction->nActionType == SC_CAT_DELETE_ROWS))
     {
-        static_cast<ScMyDelAction*>(pCurrentAction.get())->pInsCutOff.reset( 
new ScMyInsertionCutOff(nID, nPosition) );
+        
static_cast<ScMyDelAction*>(pCurrentAction.get())->moInsCutOff.emplace( nID, 
nPosition );
     }
     else
     {
@@ -505,17 +505,17 @@ void 
ScXMLChangeTrackingImportHelper::SetDeletionDependencies(ScMyDelAction* pAc
             pAction->aGeneratedList.clear();
         }
     }
-    if (pAction->pInsCutOff)
+    if (pAction->moInsCutOff)
     {
         OSL_ENSURE(((pAction->nActionType == SC_CAT_DELETE_COLS) ||
             (pAction->nActionType == SC_CAT_DELETE_ROWS) ||
             (pAction->nActionType == SC_CAT_DELETE_TABS)), "wrong action 
type");
-        ScChangeAction* pChangeAction = 
pTrack->GetAction(pAction->pInsCutOff->nID);
+        ScChangeAction* pChangeAction = 
pTrack->GetAction(pAction->moInsCutOff->nID);
         if (pChangeAction && pChangeAction->IsInsertType())
         {
             ScChangeActionIns* pInsAction = 
static_cast<ScChangeActionIns*>(pChangeAction);
             if (pDelAct)
-                pDelAct->SetCutOffInsert(pInsAction, 
static_cast<sal_Int16>(pAction->pInsCutOff->nPosition));
+                pDelAct->SetCutOffInsert(pInsAction, 
static_cast<sal_Int16>(pAction->moInsCutOff->nPosition));
         }
         else
         {
diff --git a/sc/source/filter/xml/XMLChangeTrackingImportHelper.hxx 
b/sc/source/filter/xml/XMLChangeTrackingImportHelper.hxx
index 5d9c97738688..e9f2525e91c5 100644
--- a/sc/source/filter/xml/XMLChangeTrackingImportHelper.hxx
+++ b/sc/source/filter/xml/XMLChangeTrackingImportHelper.hxx
@@ -129,7 +129,7 @@ struct ScMyInsAction : public ScMyBaseAction
 struct ScMyDelAction : public ScMyBaseAction
 {
     std::vector<ScMyGenerated> aGeneratedList;
-    std::unique_ptr<ScMyInsertionCutOff> pInsCutOff;
+    std::optional<ScMyInsertionCutOff> moInsCutOff;
     std::vector<ScMyMoveCutOff> aMoveCutOffs;
     sal_Int32 nD;
 
diff --git a/sc/source/filter/xml/xmlimprt.cxx 
b/sc/source/filter/xml/xmlimprt.cxx
index 467b8820db55..1f5002964684 100644
--- a/sc/source/filter/xml/xmlimprt.cxx
+++ b/sc/source/filter/xml/xmlimprt.cxx
@@ -397,7 +397,7 @@ ScXMLImport::~ScXMLImport() noexcept
     //call SvXMLImport dtor contents before deleting pSolarMutexGuard
     cleanup();
 
-    pSolarMutexGuard.reset();
+    moSolarMutexGuard.reset();
 }
 
 void ScXMLImport::initialize( const css::uno::Sequence<css::uno::Any>& 
aArguments )
@@ -1529,8 +1529,8 @@ void ScXMLImport::LockSolarMutex()
 
     if (nSolarMutexLocked == 0)
     {
-        OSL_ENSURE(!pSolarMutexGuard, "Solar Mutex is locked");
-        pSolarMutexGuard.reset(new SolarMutexGuard());
+        OSL_ENSURE(!moSolarMutexGuard, "Solar Mutex is locked");
+        moSolarMutexGuard.emplace();
     }
     ++nSolarMutexLocked;
 }
@@ -1542,8 +1542,8 @@ void ScXMLImport::UnlockSolarMutex()
         nSolarMutexLocked--;
         if (nSolarMutexLocked == 0)
         {
-            OSL_ENSURE(pSolarMutexGuard, "Solar Mutex is always unlocked");
-            pSolarMutexGuard.reset();
+            OSL_ENSURE(moSolarMutexGuard, "Solar Mutex is always unlocked");
+            moSolarMutexGuard.reset();
         }
     }
 }
diff --git a/sc/source/filter/xml/xmlimprt.hxx 
b/sc/source/filter/xml/xmlimprt.hxx
index 4481b5ebdb40..7fdd00a65065 100644
--- a/sc/source/filter/xml/xmlimprt.hxx
+++ b/sc/source/filter/xml/xmlimprt.hxx
@@ -23,6 +23,7 @@
 #include <xmloff/xmlprmap.hxx>
 #include "xmlsubti.hxx"
 #include <formula/grammar.hxx>
+#include <vcl/svapp.hxx>
 #include <dociter.hxx>
 
 #include <com/sun/star/sheet/ValidationAlertStyle.hpp>
@@ -60,7 +61,6 @@ class ScDrawObjData;
 class SvXMLTokenMap;
 class XMLShapeImportHelper;
 class ScXMLChangeTrackingImportHelper;
-class SolarMutexGuard;
 
 struct ScMyNamedExpression
 {
@@ -146,7 +146,7 @@ class ScXMLImport: public SvXMLImport
     ScMyLabelRanges            maMyLabelRanges;
     ScMyImportValidations      maValidations;
     std::unique_ptr<ScMyImpDetectiveOpArray>    pDetectiveOpArray;
-    std::unique_ptr<SolarMutexGuard>        pSolarMutexGuard;
+    std::optional<SolarMutexGuard> moSolarMutexGuard;
 
     std::unique_ptr<XMLNumberFormatAttributesExportHelper> 
pNumberFormatAttributesExportHelper;
     std::unique_ptr<ScMyStyleNumberFormats> pStyleNumberFormats;
commit 1f5797e0c0cc0425e29b7a945485ac146fec0085
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Thu Mar 2 11:20:01 2023 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Thu Mar 2 12:23:37 2023 +0000

    flatten some classes in basic
    
    no need to allocate separately where the contained class is only one
    pointer big
    
    Change-Id: If5fac0b0e20f80bffebc8611791d07888cbec1e5
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148089
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/basic/source/classes/sb.cxx b/basic/source/classes/sb.cxx
index 0296e2238ca1..7f02e65d9b55 100644
--- a/basic/source/classes/sb.cxx
+++ b/basic/source/classes/sb.cxx
@@ -901,18 +901,18 @@ StarBASIC::StarBASIC( StarBASIC* p, bool bIsDocBasic  )
 
     if( !GetSbData()->nInst++ )
     {
-        GetSbData()->pSbFac.reset( new SbiFactory );
-        AddFactory( GetSbData()->pSbFac.get() );
-        GetSbData()->pTypeFac.reset(new SbTypeFactory);
-        AddFactory( GetSbData()->pTypeFac.get() );
+        GetSbData()->pSbFac.emplace();
+        AddFactory( &*GetSbData()->pSbFac );
+        GetSbData()->pTypeFac.emplace();
+        AddFactory( &*GetSbData()->pTypeFac );
         GetSbData()->pClassFac.reset(new SbClassFactory);
         AddFactory( GetSbData()->pClassFac.get() );
-        GetSbData()->pOLEFac.reset(new SbOLEFactory);
-        AddFactory( GetSbData()->pOLEFac.get() );
-        GetSbData()->pFormFac.reset(new SbFormFactory);
-        AddFactory( GetSbData()->pFormFac.get() );
-        GetSbData()->pUnoFac.reset( new SbUnoFactory );
-        AddFactory( GetSbData()->pUnoFac.get() );
+        GetSbData()->pOLEFac.emplace();
+        AddFactory( &*GetSbData()->pOLEFac );
+        GetSbData()->pFormFac.emplace();
+        AddFactory( &*GetSbData()->pFormFac );
+        GetSbData()->pUnoFac.emplace();
+        AddFactory( &*GetSbData()->pUnoFac );
     }
     pRtl = new SbiStdObject(SB_RTLNAME, this );
     // Search via StarBasic is always global
@@ -940,17 +940,17 @@ StarBASIC::~StarBASIC()
 
     if( !--GetSbData()->nInst )
     {
-        RemoveFactory( GetSbData()->pSbFac.get() );
+        RemoveFactory( &*GetSbData()->pSbFac );
         GetSbData()->pSbFac.reset();
-        RemoveFactory( GetSbData()->pUnoFac.get() );
+        RemoveFactory( &*GetSbData()->pUnoFac );
         GetSbData()->pUnoFac.reset();
-        RemoveFactory( GetSbData()->pTypeFac.get() );
+        RemoveFactory( &*GetSbData()->pTypeFac );
         GetSbData()->pTypeFac.reset();
         RemoveFactory( GetSbData()->pClassFac.get() );
         GetSbData()->pClassFac.reset();
-        RemoveFactory( GetSbData()->pOLEFac.get() );
+        RemoveFactory( &*GetSbData()->pOLEFac );
         GetSbData()->pOLEFac.reset();
-        RemoveFactory( GetSbData()->pFormFac.get() );
+        RemoveFactory( &*GetSbData()->pFormFac );
         GetSbData()->pFormFac.reset();
 
         if( SbiGlobals::pGlobals )
diff --git a/basic/source/inc/sbintern.hxx b/basic/source/inc/sbintern.hxx
index b00ba29f5521..5ed41d5fb138 100644
--- a/basic/source/inc/sbintern.hxx
+++ b/basic/source/inc/sbintern.hxx
@@ -21,9 +21,11 @@
 
 #include <basic/sbstar.hxx>
 #include <sbxfac.hxx>
+#include "sbunoobj.hxx"
 #include <unotools/transliterationwrapper.hxx>
 #include <comphelper/errcode.hxx>
 #include <config_features.h>
+#include <optional>
 
 namespace utl
 {
@@ -105,15 +107,15 @@ struct SbiGlobals
     static SbiGlobals* pGlobals;
     SbiInstance*    pInst;          // all active runtime instances
 #if HAVE_FEATURE_SCRIPTING
-    std::unique_ptr<SbiFactory>   pSbFac;    // StarBASIC-Factory
-    std::unique_ptr<SbUnoFactory> pUnoFac;   // Factory for Uno-Structs at DIM 
AS NEW
-    std::unique_ptr<SbTypeFactory>
+    std::optional<SbiFactory>   pSbFac;    // StarBASIC-Factory
+    std::optional<SbUnoFactory> pUnoFac;   // Factory for Uno-Structs at DIM 
AS NEW
+    std::optional<SbTypeFactory>
                     pTypeFac;       // Factory for user defined types
     std::unique_ptr<SbClassFactory>
                     pClassFac;      // Factory for user defined classes (based 
on class modules)
-    std::unique_ptr<SbOLEFactory>
+    std::optional<SbOLEFactory>
                     pOLEFac;        // Factory for OLE types
-    std::unique_ptr<SbFormFactory>
+    std::optional<SbFormFactory>
                     pFormFac;       // Factory for user forms
     std::unique_ptr<BasicManager> pAppBasMgr;
 #endif
diff --git a/basic/source/inc/stdobj.hxx b/basic/source/inc/stdobj.hxx
index 18df1fbbdda7..824cb90ea1a2 100644
--- a/basic/source/inc/stdobj.hxx
+++ b/basic/source/inc/stdobj.hxx
@@ -20,13 +20,14 @@
 #pragma once
 
 #include <basic/sbxobj.hxx>
+#include <sbstdobj.hxx>
+#include <optional>
 
 class StarBASIC;
-class SbStdFactory;
 
 class SbiStdObject final : public SbxObject
 {
-    std::unique_ptr<SbStdFactory> pStdFactory;
+    std::optional<SbStdFactory> pStdFactory;
 
     virtual ~SbiStdObject() override;
     using SbxVariable::GetInfo;
diff --git a/basic/source/runtime/stdobj.cxx b/basic/source/runtime/stdobj.cxx
index 97e9ceede1e9..5b123d00d5a2 100644
--- a/basic/source/runtime/stdobj.cxx
+++ b/basic/source/runtime/stdobj.cxx
@@ -934,15 +934,15 @@ SbiStdObject::SbiStdObject( const OUString& r, StarBASIC* 
pb ) : SbxObject( r )
 
     SetParent( pb );
 
-    pStdFactory.reset( new SbStdFactory );
-    SbxBase::AddFactory( pStdFactory.get() );
+    pStdFactory.emplace();
+    SbxBase::AddFactory( &*pStdFactory );
 
     Insert( new SbStdClipboard );
 }
 
 SbiStdObject::~SbiStdObject()
 {
-    SbxBase::RemoveFactory( pStdFactory.get() );
+    SbxBase::RemoveFactory( &*pStdFactory );
     pStdFactory.reset();
 }
 

Reply via email to