summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2021-09-24 08:26:46 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-09-24 10:50:56 +0200
commite1600348e49e1538459a0374fd97cd3173d4a4b9 (patch)
tree0fce6d86a668841fe2c64b025b4c1f3373866fa4
parentc183a6eb292b31c7fb24f751630960f2035353c5 (diff)
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.grandin@collabora.co.uk>
-rw-r--r--sc/inc/postit.hxx5
-rw-r--r--sc/source/core/data/postit.cxx13
-rw-r--r--sc/source/filter/excel/xiescher.cxx2
-rw-r--r--sc/source/filter/xml/xmlcelli.cxx10
4 files changed, 15 insertions, 15 deletions
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 );
}
}