summaryrefslogtreecommitdiff
path: root/sc/source
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2021-08-15 17:35:58 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-08-16 12:07:15 +0200
commiteec42f0dbcc79a4c9f456ce97fa1066b8031ea28 (patch)
treef089f757270293bd94dfac881c62520af76975e0 /sc/source
parenta6ca6215a5ec82e833ebfcd2ebd4455cb504fd8e (diff)
pass OutlinerParaObject around by value
since it uses o3tl::cow_wrapper, so it is really just a wrapper around a pointer, no point in allocating it on the heap Remove assert in SdrText::SetOutlinerParaObject, which was bogus anyhow, because it was comparing pointers, not deep equality. And since we are now being more efficient and avoiding copying of the internal data in OutlinerParaObject, we hit this assert. Change-Id: I6dbfaab5ee2ca05b2001baf63110041e469df9c5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120510 Tested-by: Noel Grandin <noel.grandin@collabora.co.uk> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc/source')
-rw-r--r--sc/source/core/data/postit.cxx17
-rw-r--r--sc/source/filter/excel/xiescher.cxx6
-rw-r--r--sc/source/ui/unoobj/editsrc.cxx6
3 files changed, 16 insertions, 13 deletions
diff --git a/sc/source/core/data/postit.cxx b/sc/source/core/data/postit.cxx
index a4ec79b2c909..c1e13308d455 100644
--- a/sc/source/core/data/postit.cxx
+++ b/sc/source/core/data/postit.cxx
@@ -821,7 +821,7 @@ void ScCaptionPtr::clear()
struct ScCaptionInitData
{
std::unique_ptr< SfxItemSet > mxItemSet; /// Caption object formatting.
- std::unique_ptr< OutlinerParaObject > mxOutlinerObj; /// Text object with all text portion 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.
@@ -900,8 +900,8 @@ const OutlinerParaObject* ScPostIt::GetOutlinerObject() const
{
if( maNoteData.mxCaption )
return maNoteData.mxCaption->GetOutlinerParaObject();
- if( maNoteData.mxInitData )
- return maNoteData.mxInitData->mxOutlinerObj.get();
+ if( maNoteData.mxInitData && maNoteData.mxInitData->mxOutlinerObj )
+ return &*maNoteData.mxInitData->mxOutlinerObj;
return nullptr;
}
@@ -967,7 +967,7 @@ void ScPostIt::ForgetCaption( bool bPreserveData )
ScCaptionInitData* pInitData = new ScCaptionInitData;
const OutlinerParaObject* pOPO = GetOutlinerObject();
if (pOPO)
- pInitData->mxOutlinerObj.reset( new OutlinerParaObject(*pOPO));
+ pInitData->mxOutlinerObj = *pOPO;
pInitData->maSimpleText = GetText();
maNoteData.mxInitData.reset(pInitData);
@@ -1110,7 +1110,7 @@ void ScPostIt::CreateCaption( const ScAddress& rPos, const SdrCaptionObj* pCapti
{
// copy edit text object (object must be inserted into page already)
if( OutlinerParaObject* pOPO = pCaption->GetOutlinerParaObject() )
- maNoteData.mxCaption->SetOutlinerParaObject( std::make_unique<OutlinerParaObject>( *pOPO ) );
+ maNoteData.mxCaption->SetOutlinerParaObject( *pOPO );
// copy formatting items (after text has been copied to apply font formatting)
maNoteData.mxCaption->SetMergedItemSetAndBroadcast( pCaption->GetMergedItemSet() );
// move textbox position relative to new cell, copy textbox size
@@ -1196,7 +1196,7 @@ ScCaptionPtr ScNoteUtil::CreateTempCaption(
if( pNoteCaption && rUserText.isEmpty() )
{
if( OutlinerParaObject* pOPO = pNoteCaption->GetOutlinerParaObject() )
- pCaption->SetOutlinerParaObject( std::make_unique<OutlinerParaObject>( *pOPO ) );
+ pCaption->SetOutlinerParaObject( *pOPO );
// set formatting (must be done after setting text) and resize the box to fit the text
pCaption->SetMergedItemSetAndBroadcast( pNoteCaption->GetMergedItemSet() );
tools::Rectangle aCaptRect( pCaption->GetLogicRect().TopLeft(), pNoteCaption->GetLogicRect().GetSize() );
@@ -1249,7 +1249,10 @@ ScPostIt* ScNoteUtil::CreateNoteFromObjectData(
aNoteData.mxInitData = std::make_shared<ScCaptionInitData>();
ScCaptionInitData& rInitData = *aNoteData.mxInitData;
rInitData.mxItemSet = std::move(pItemSet);
- rInitData.mxOutlinerObj.reset( pOutlinerObj );
+ if (pOutlinerObj)
+ rInitData.mxOutlinerObj = *pOutlinerObj;
+ else
+ rInitData.mxOutlinerObj.reset();
// convert absolute caption position to relative position
rInitData.mbDefaultPosSize = rCaptionRect.IsEmpty();
diff --git a/sc/source/filter/excel/xiescher.cxx b/sc/source/filter/excel/xiescher.cxx
index ea40954e89f3..5732b49bac30 100644
--- a/sc/source/filter/excel/xiescher.cxx
+++ b/sc/source/filter/excel/xiescher.cxx
@@ -1506,9 +1506,9 @@ void XclImpTextObj::DoPreProcessSdrObj( XclImpDffConverter& rDffConv, SdrObject&
// rich text
std::unique_ptr< EditTextObject > xEditObj(
XclImpStringHelper::CreateTextObject( GetRoot(), *maTextData.mxString ) );
- std::unique_ptr<OutlinerParaObject> pOutlineObj(new OutlinerParaObject(std::move(xEditObj)));
- pOutlineObj->SetOutlinerMode( OutlinerMode::TextObject );
- pTextObj->NbcSetOutlinerParaObject( std::move(pOutlineObj) );
+ OutlinerParaObject aOutlineObj(std::move(xEditObj));
+ aOutlineObj.SetOutlinerMode( OutlinerMode::TextObject );
+ pTextObj->NbcSetOutlinerParaObject( std::move(aOutlineObj) );
}
else
{
diff --git a/sc/source/ui/unoobj/editsrc.cxx b/sc/source/ui/unoobj/editsrc.cxx
index 231f080fa9da..f96f9c020125 100644
--- a/sc/source/ui/unoobj/editsrc.cxx
+++ b/sc/source/ui/unoobj/editsrc.cxx
@@ -169,9 +169,9 @@ void ScAnnotationEditSource::UpdateData()
if( SdrObject* pObj = GetCaptionObj() )
{
- std::unique_ptr<OutlinerParaObject> pOPO( new OutlinerParaObject(pEditEngine->CreateTextObject()) );
- pOPO->SetOutlinerMode( OutlinerMode::TextObject );
- pObj->NbcSetOutlinerParaObject( std::move(pOPO) );
+ OutlinerParaObject aOPO( pEditEngine->CreateTextObject() );
+ aOPO.SetOutlinerMode( OutlinerMode::TextObject );
+ pObj->NbcSetOutlinerParaObject( std::move(aOPO) );
pObj->ActionChanged();
}