sc/inc/postit.hxx                   |    5 +++--
 sc/source/core/data/postit.cxx      |   13 ++++++-------
 sc/source/filter/excel/xiescher.cxx |    2 +-
 sc/source/filter/html/htmlpars.cxx  |   18 +++++++++---------
 sc/source/filter/inc/htmlpars.hxx   |    6 +++---
 sc/source/filter/xml/xmlcelli.cxx   |   10 +++++-----
 6 files changed, 27 insertions(+), 27 deletions(-)

New commits:
commit e1600348e49e1538459a0374fd97cd3173d4a4b9
Author:     Noel Grandin <noelgran...@gmail.com>
AuthorDate: Fri Sep 24 08:26:46 2021 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Fri Sep 24 10:50:56 2021 +0200

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

diff --git a/sc/inc/postit.hxx b/sc/inc/postit.hxx
index 7fb61bb6ddd6..ff024e4621ea 100644
--- a/sc/inc/postit.hxx
+++ b/sc/inc/postit.hxx
@@ -20,17 +20,18 @@
 #pragma once
 
 #include <rtl/ustring.hxx>
+#include <svl/itemset.hxx>
 #include "address.hxx"
 #include "scdllapi.h"
 
 #include <memory>
+#include <optional>
 
 class EditTextObject;
 class OutlinerParaObject;
 class SdrCaptionObj;
 class SdrPage;
 
-class SfxItemSet;
 class ScDocument;
 namespace tools { class Rectangle; }
 struct ScCaptionInitData;
@@ -331,7 +332,7 @@ public:
      */
     static ScPostIt*    CreateNoteFromObjectData(
                             ScDocument& rDoc, const ScAddress& rPos,
-                            std::unique_ptr<SfxItemSet> pItemSet,
+                            SfxItemSet&& oItemSet,
                             const OutlinerParaObject& rOutlinerObj,
                             const tools::Rectangle& rCaptionRect, bool bShown 
);
 
diff --git a/sc/source/core/data/postit.cxx b/sc/source/core/data/postit.cxx
index 42649cccf66f..12b5778aead2 100644
--- a/sc/source/core/data/postit.cxx
+++ b/sc/source/core/data/postit.cxx
@@ -820,9 +820,9 @@ void ScCaptionPtr::clear()
 
 struct ScCaptionInitData
 {
-    std::unique_ptr< SfxItemSet >       mxItemSet;          /// Caption object 
formatting.
-    std::optional< OutlinerParaObject >  mxOutlinerObj;      /// Text object 
with all text portion formatting.
-    OUString     maSimpleText;       /// Simple text without formatting.
+    std::optional< SfxItemSet > moItemSet;  /// Caption object formatting.
+    std::optional< OutlinerParaObject > mxOutlinerObj; /// Text object with 
all text portion formatting.
+    OUString            maSimpleText;       /// Simple text without formatting.
     Point               maCaptionOffset;    /// Caption position relative to 
cell corner.
     Size                maCaptionSize;      /// Size of the caption object.
     bool                mbDefaultPosSize;   /// True = use default position 
and size for caption.
@@ -1058,7 +1058,7 @@ void ScPostIt::CreateCaptionFromInitData( const 
ScAddress& rPos ) const
         maNoteData.mxCaption->SetText( xInitData->maSimpleText );
 
     // copy all items or set default items; reset shadow items
-    ScCaptionUtil::SetDefaultItems( *maNoteData.mxCaption, mrDoc, 
xInitData->mxItemSet.get() );
+    ScCaptionUtil::SetDefaultItems( *maNoteData.mxCaption, mrDoc, 
xInitData->moItemSet ? &*xInitData->moItemSet : nullptr );
 
     // set position and size of the caption object
     if( xInitData->mbDefaultPosSize )
@@ -1240,15 +1240,14 @@ ScPostIt* ScNoteUtil::CreateNoteFromCaption(
 }
 
 ScPostIt* ScNoteUtil::CreateNoteFromObjectData(
-        ScDocument& rDoc, const ScAddress& rPos, std::unique_ptr<SfxItemSet> 
pItemSet,
+        ScDocument& rDoc, const ScAddress& rPos, SfxItemSet&& rItemSet,
         const OutlinerParaObject& rOutlinerObj, const tools::Rectangle& 
rCaptionRect,
         bool bShown )
 {
-    OSL_ENSURE( pItemSet, "ScNoteUtil::CreateNoteFromObjectData - item set 
expected" );
     ScNoteData aNoteData( bShown );
     aNoteData.mxInitData = std::make_shared<ScCaptionInitData>();
     ScCaptionInitData& rInitData = *aNoteData.mxInitData;
-    rInitData.mxItemSet = std::move(pItemSet);
+    rInitData.moItemSet.emplace(std::move(rItemSet));
     rInitData.mxOutlinerObj = rOutlinerObj;
 
     // convert absolute caption position to relative position
diff --git a/sc/source/filter/excel/xiescher.cxx 
b/sc/source/filter/excel/xiescher.cxx
index 9ccd3521c391..6677578801e4 100644
--- a/sc/source/filter/excel/xiescher.cxx
+++ b/sc/source/filter/excel/xiescher.cxx
@@ -1866,7 +1866,7 @@ void XclImpNoteObj::DoPreProcessSdrObj( 
XclImpDffConverter& rDffConv, SdrObject&
         // create cell note with all data from drawing object
         ScNoteUtil::CreateNoteFromObjectData(
             GetDoc(), maScPos,
-            rSdrObj.GetMergedItemSet().Clone(),             // new object on 
heap expected
+            rSdrObj.GetMergedItemSet().CloneAsValue(),             // new 
object on heap expected
             *pOutlinerObj,
             rSdrObj.GetLogicRect(),
             ::get_flag( mnNoteFlags, EXC_NOTE_VISIBLE ) );
diff --git a/sc/source/filter/xml/xmlcelli.cxx 
b/sc/source/filter/xml/xmlcelli.cxx
index 238befc186a5..46e6069268e2 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -860,7 +860,7 @@ void ScXMLTableRowCellContext::SetAnnotation(const 
ScAddress& rPos)
         if( pObject )
         {
             // rescue settings from drawing object before the shape is removed
-            ::std::unique_ptr< SfxItemSet > xItemSet( new SfxItemSet( 
pObject->GetMergedItemSet() ) );
+            SfxItemSet aItemSet( pObject->GetMergedItemSet() );
             std::optional<OutlinerParaObject> pOutlinerObj;
             if (auto p = pObject->GetOutlinerParaObject())
                 pOutlinerObj = *p;
@@ -881,14 +881,14 @@ void ScXMLTableRowCellContext::SetAnnotation(const 
ScAddress& rPos)
                 if(!comphelper::LibreOfficeKit::isActive())
                 {
                     pNote = ScNoteUtil::CreateNoteFromObjectData( *pDoc, rPos,
-                    std::move(xItemSet), *pOutlinerObj,
-                    aCaptionRect, mxAnnotationData->mbShown );
+                        std::move(aItemSet), *pOutlinerObj,
+                        aCaptionRect, mxAnnotationData->mbShown );
                 }
                 else
                 {
                     pNote = ScNoteUtil::CreateNoteFromObjectData( *pDoc, rPos,
-                    std::move(xItemSet), *pOutlinerObj,
-                    aCaptionRect, false );
+                        std::move(aItemSet), *pOutlinerObj,
+                        aCaptionRect, false );
                 }
 
             }
commit c183a6eb292b31c7fb24f751630960f2035353c5
Author:     Noel Grandin <noelgran...@gmail.com>
AuthorDate: Thu Sep 23 20:49:28 2021 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Fri Sep 24 10:50:41 2021 +0200

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

diff --git a/sc/source/filter/html/htmlpars.cxx 
b/sc/source/filter/html/htmlpars.cxx
index 991b8c0a1960..85cdff23a885 100644
--- a/sc/source/filter/html/htmlpars.cxx
+++ b/sc/source/filter/html/htmlpars.cxx
@@ -1874,7 +1874,7 @@ ScHTMLTable::~ScHTMLTable()
 const SfxItemSet& ScHTMLTable::GetCurrItemSet() const
 {
     // first try cell item set, then row item set, then table item set
-    return mxDataItemSet ? *mxDataItemSet : (mxRowItemSet ? *mxRowItemSet : 
maTableItemSet);
+    return moDataItemSet ? *moDataItemSet : (moRowItemSet ? *moRowItemSet : 
maTableItemSet);
 }
 
 ScHTMLSize ScHTMLTable::GetSpan( const ScHTMLPos& rCellPos ) const
@@ -1992,7 +1992,7 @@ void ScHTMLTable::RowOn( const HtmlImportInfo& rInfo )
     if( mpParentTable && !mbPreFormText )   // no rows allowed in global and 
preformatted tables
     {
         ImplRowOn();
-        ProcessFormatOptions( *mxRowItemSet, rInfo );
+        ProcessFormatOptions( *moRowItemSet, rInfo );
     }
     CreateNewEntry( rInfo );
 }
@@ -2110,9 +2110,9 @@ void ScHTMLTable::DataOn( const HtmlImportInfo& rInfo )
         ImplDataOn( aSpanSize );
 
         if (nNumberFormat != NUMBERFORMAT_ENTRY_NOT_FOUND)
-            mxDataItemSet->Put( SfxUInt32Item(ATTR_VALUE_FORMAT, 
nNumberFormat) );
+            moDataItemSet->Put( SfxUInt32Item(ATTR_VALUE_FORMAT, 
nNumberFormat) );
 
-        ProcessFormatOptions( *mxDataItemSet, rInfo );
+        ProcessFormatOptions( *moDataItemSet, rInfo );
         CreateNewEntry( rInfo );
         mxCurrEntry->pValStr = std::move(pValStr);
         mxCurrEntry->pNumStr = std::move(pNumStr);
@@ -2139,7 +2139,7 @@ void ScHTMLTable::BodyOn( const HtmlImportInfo& rInfo )
             ImplRowOn();
         if( bPushed || !mbDataOn )
             ImplDataOn( ScHTMLSize( 1, 1 ) );
-        ProcessFormatOptions( *mxDataItemSet, rInfo );
+        ProcessFormatOptions( *moDataItemSet, rInfo );
     }
     CreateNewEntry( rInfo );
 }
@@ -2440,7 +2440,7 @@ void ScHTMLTable::ImplRowOn()
 {
     if( mbRowOn )
         ImplRowOff();
-    mxRowItemSet.reset( new SfxItemSet( maTableItemSet ) );
+    moRowItemSet.emplace( maTableItemSet );
     maCurrCell.mnCol = 0;
     mbRowOn = true;
     mbDataOn = false;
@@ -2452,7 +2452,7 @@ void ScHTMLTable::ImplRowOff()
         ImplDataOff();
     if( mbRowOn )
     {
-        mxRowItemSet.reset();
+        moRowItemSet.reset();
         ++maCurrCell.mnRow;
         mbRowOn = mbDataOn = false;
     }
@@ -2464,7 +2464,7 @@ void ScHTMLTable::ImplDataOn( const ScHTMLSize& rSpanSize 
)
         ImplDataOff();
     if( !mbRowOn )
         ImplRowOn();
-    mxDataItemSet.reset( new SfxItemSet( *mxRowItemSet ) );
+    moDataItemSet.emplace( *moRowItemSet );
     InsertNewCell( rSpanSize );
     mbDataOn = true;
     mbPushEmptyLine = false;
@@ -2474,7 +2474,7 @@ void ScHTMLTable::ImplDataOff()
 {
     if( mbDataOn )
     {
-        mxDataItemSet.reset();
+        moDataItemSet.reset();
         ++maCurrCell.mnCol;
         mpCurrEntryVector = nullptr;
         mbDataOn = false;
diff --git a/sc/source/filter/inc/htmlpars.hxx 
b/sc/source/filter/inc/htmlpars.hxx
index e0c4dad24843..02af4857616e 100644
--- a/sc/source/filter/inc/htmlpars.hxx
+++ b/sc/source/filter/inc/htmlpars.hxx
@@ -21,6 +21,7 @@
 
 #include <memory>
 #include <map>
+#include <optional>
 #include <stack>
 #include <string_view>
 #include <unordered_map>
@@ -446,7 +447,6 @@ protected:
 
 private:
     typedef ::std::unique_ptr< ScHTMLTableMap >         ScHTMLTableMapPtr;
-    typedef ::std::unique_ptr< SfxItemSet >             SfxItemSetPtr;
     typedef ::std::vector< SCCOLROW >                   ScSizeVec;
     typedef ::std::vector< ScHTMLEntry* >               ScHTMLEntryVector;
     typedef ::std::unique_ptr< ScHTMLEntry >            ScHTMLEntryPtr;
@@ -527,8 +527,8 @@ private:
     OUStringBuffer      maCaptionBuffer;    /// Caption buffer of the table 
from <caption> </caption>
     ScHTMLTableAutoId   maTableId;          /// Unique identifier of this 
table.
     SfxItemSet          maTableItemSet;     /// Items for the entire table.
-    SfxItemSetPtr       mxRowItemSet;       /// Items for the current table 
row.
-    SfxItemSetPtr       mxDataItemSet;      /// Items for the current cell.
+    std::optional<SfxItemSet> moRowItemSet;       /// Items for the current 
table row.
+    std::optional<SfxItemSet> moDataItemSet;      /// Items for the current 
cell.
     ScRangeList         maHMergedCells;     /// List of all horizontally 
merged cells.
     ScRangeList         maVMergedCells;     /// List of all vertically merged 
cells.
     ScRangeList         maUsedCells;        /// List of all used cells.

Reply via email to