diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2021-08-15 17:35:58 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-08-16 12:07:15 +0200 |
commit | eec42f0dbcc79a4c9f456ce97fa1066b8031ea28 (patch) | |
tree | f089f757270293bd94dfac881c62520af76975e0 /sd | |
parent | a6ca6215a5ec82e833ebfcd2ebd4455cb504fd8e (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 'sd')
-rw-r--r-- | sd/inc/textapi.hxx | 2 | ||||
-rw-r--r-- | sd/source/core/drawdoc4.cxx | 4 | ||||
-rw-r--r-- | sd/source/core/sdpage.cxx | 5 | ||||
-rw-r--r-- | sd/source/core/text/textapi.cxx | 12 | ||||
-rw-r--r-- | sd/source/ui/annotations/annotationmanager.cxx | 2 | ||||
-rw-r--r-- | sd/source/ui/annotations/annotationwindow.cxx | 4 | ||||
-rw-r--r-- | sd/source/ui/docshell/docshel4.cxx | 2 | ||||
-rw-r--r-- | sd/source/ui/func/fuexpand.cxx | 4 | ||||
-rw-r--r-- | sd/source/ui/func/fuinsert.cxx | 2 | ||||
-rw-r--r-- | sd/source/ui/func/fuinsfil.cxx | 2 | ||||
-rw-r--r-- | sd/source/ui/func/fumorph.cxx | 4 | ||||
-rw-r--r-- | sd/source/ui/unoidl/unoobj.cxx | 2 | ||||
-rw-r--r-- | sd/source/ui/view/DocumentRenderer.cxx | 4 | ||||
-rw-r--r-- | sd/source/ui/view/drviews2.cxx | 2 | ||||
-rw-r--r-- | sd/source/ui/view/drviews8.cxx | 2 | ||||
-rw-r--r-- | sd/source/ui/view/drviews9.cxx | 2 | ||||
-rw-r--r-- | sd/source/ui/view/drviewse.cxx | 2 | ||||
-rw-r--r-- | sd/source/ui/view/outlnvsh.cxx | 4 | ||||
-rw-r--r-- | sd/source/ui/view/outlview.cxx | 2 | ||||
-rw-r--r-- | sd/source/ui/view/sdview4.cxx | 2 | ||||
-rw-r--r-- | sd/source/ui/view/viewshe2.cxx | 2 |
21 files changed, 33 insertions, 34 deletions
diff --git a/sd/inc/textapi.hxx b/sd/inc/textapi.hxx index 090cab889b4f..70110349053a 100644 --- a/sd/inc/textapi.hxx +++ b/sd/inc/textapi.hxx @@ -39,7 +39,7 @@ public: /// @throws css::uno::RuntimeException void dispose(); - std::unique_ptr<OutlinerParaObject> CreateText(); + std::optional<OutlinerParaObject> CreateText(); void SetText( OutlinerParaObject const & rText ); OUString GetText() const; diff --git a/sd/source/core/drawdoc4.cxx b/sd/source/core/drawdoc4.cxx index e41e43daf06c..bda437336226 100644 --- a/sd/source/core/drawdoc4.cxx +++ b/sd/source/core/drawdoc4.cxx @@ -986,10 +986,10 @@ void SdDrawDocument::SpellObject(SdrTextObj* pObj) if (mbHasOnlineSpellErrors) { - std::unique_ptr<OutlinerParaObject> pOPO = pOutl->CreateParaObject(); + std::optional<OutlinerParaObject> pOPO = pOutl->CreateParaObject(); if (pOPO) { - if (!( *pOPO == *pObj->GetOutlinerParaObject() ) || + if ( *pOPO != *pObj->GetOutlinerParaObject() || !pObj->GetOutlinerParaObject()->isWrongListEqual( *pOPO )) { sd::ModifyGuard aGuard( this ); diff --git a/sd/source/core/sdpage.cxx b/sd/source/core/sdpage.cxx index 55ee1a8a280d..c1bd4d178558 100644 --- a/sd/source/core/sdpage.cxx +++ b/sd/source/core/sdpage.cxx @@ -2084,9 +2084,8 @@ static SdrObject* convertPresentationObjectImpl(SdPage& rPage, SdrObject* pSourc SdOutliner* pOutl = rModel.GetInternalOutliner(); pOutl->Clear(); pOutl->SetText( *pOutlParaObj ); - std::unique_ptr<OutlinerParaObject> pNew = pOutl->CreateParaObject(); - pOutlParaObj = pNew.get(); - pNewObj->SetOutlinerParaObject( std::move(pNew) ); + pNewObj->SetOutlinerParaObject( pOutl->CreateParaObject() ); + pOutlParaObj = pNewObj->GetOutlinerParaObject(); pOutl->Clear(); pNewObj->SetEmptyPresObj(false); diff --git a/sd/source/core/text/textapi.cxx b/sd/source/core/text/textapi.cxx index ca20ac440db3..f9f0d9ba91a7 100644 --- a/sd/source/core/text/textapi.cxx +++ b/sd/source/core/text/textapi.cxx @@ -53,8 +53,8 @@ public: virtual void Redo() override; protected: - std::unique_ptr<OutlinerParaObject> mpOldText; - std::unique_ptr<OutlinerParaObject> mpNewText; + std::optional<OutlinerParaObject> mpOldText; + std::optional<OutlinerParaObject> mpNewText; rtl::Reference< TextApiObject > mxTextObj; }; @@ -109,7 +109,7 @@ public: void Dispose(); void SetText( OutlinerParaObject const & rText ); - std::unique_ptr<OutlinerParaObject> CreateText(); + std::optional<OutlinerParaObject> CreateText(); OUString GetText() const; SdDrawDocument* GetDoc() { return m_xImpl->mpDoc; } }; @@ -160,7 +160,7 @@ void TextApiObject::dispose() } -std::unique_ptr<OutlinerParaObject> TextApiObject::CreateText() +std::optional<OutlinerParaObject> TextApiObject::CreateText() { return mpSource->CreateText(); } @@ -257,12 +257,12 @@ void TextAPIEditSource::SetText( OutlinerParaObject const & rText ) } } -std::unique_ptr<OutlinerParaObject> TextAPIEditSource::CreateText() +std::optional<OutlinerParaObject> TextAPIEditSource::CreateText() { if (m_xImpl->mpDoc && m_xImpl->mpOutliner) return m_xImpl->mpOutliner->CreateParaObject(); else - return nullptr; + return std::nullopt; } OUString TextAPIEditSource::GetText() const diff --git a/sd/source/ui/annotations/annotationmanager.cxx b/sd/source/ui/annotations/annotationmanager.cxx index ca1fe2d84f24..6d248b35e89e 100644 --- a/sd/source/ui/annotations/annotationmanager.cxx +++ b/sd/source/ui/annotations/annotationmanager.cxx @@ -597,7 +597,7 @@ void AnnotationManagerImpl::ExecuteReplyToAnnotation( SfxRequest const & rReq ) if (!sReplyText.isEmpty()) aOutliner.Insert(sReplyText); - std::unique_ptr< OutlinerParaObject > pOPO( aOutliner.CreateParaObject() ); + std::optional< OutlinerParaObject > pOPO( aOutliner.CreateParaObject() ); pTextApi->SetText(*pOPO); OUString sReplyAuthor; diff --git a/sd/source/ui/annotations/annotationwindow.cxx b/sd/source/ui/annotations/annotationwindow.cxx index 0022b84c9625..31d1891c2e0e 100644 --- a/sd/source/ui/annotations/annotationwindow.cxx +++ b/sd/source/ui/annotations/annotationwindow.cxx @@ -506,7 +506,7 @@ void AnnotationWindow::setAnnotation( const Reference< XAnnotation >& xAnnotatio if( pTextApi ) { - std::unique_ptr< OutlinerParaObject > pOPO( pTextApi->CreateText() ); + std::optional< OutlinerParaObject > pOPO( pTextApi->CreateText() ); mpOutliner->SetText(*pOPO); } @@ -574,7 +574,7 @@ void AnnotationWindow::SaveToDocument() if( pTextApi ) { - std::unique_ptr<OutlinerParaObject> pOPO = mpOutliner->CreateParaObject(); + std::optional<OutlinerParaObject> pOPO = mpOutliner->CreateParaObject(); if( pOPO ) { if( mpDoc->IsUndoEnabled() ) diff --git a/sd/source/ui/docshell/docshel4.cxx b/sd/source/ui/docshell/docshel4.cxx index 18c48afd441f..c154340f0a6a 100644 --- a/sd/source/ui/docshell/docshel4.cxx +++ b/sd/source/ui/docshell/docshel4.cxx @@ -561,7 +561,7 @@ bool DrawDocShell::SaveAs( SfxMedium& rMedium ) SdrOutliner* pOutl = mpViewShell->GetView()->GetTextEditOutliner(); if( pObj && pOutl && pOutl->IsModified() ) { - std::unique_ptr<OutlinerParaObject> pNewText = pOutl->CreateParaObject( 0, pOutl->GetParagraphCount() ); + std::optional<OutlinerParaObject> pNewText = pOutl->CreateParaObject( 0, pOutl->GetParagraphCount() ); pObj->SetOutlinerParaObject( std::move(pNewText) ); pOutl->ClearModifyFlag(); } diff --git a/sd/source/ui/func/fuexpand.cxx b/sd/source/ui/func/fuexpand.cxx index 833d628742e0..7b499db91786 100644 --- a/sd/source/ui/func/fuexpand.cxx +++ b/sd/source/ui/func/fuexpand.cxx @@ -183,7 +183,7 @@ void FuExpandPage::DoExecute( SfxRequest& ) if (!pTextObj) continue; - std::unique_ptr<OutlinerParaObject> pOutlinerParaObject = aOutliner.CreateParaObject( nParaPos, 1); + std::optional<OutlinerParaObject> pOutlinerParaObject = aOutliner.CreateParaObject( nParaPos, 1); pOutlinerParaObject->SetOutlinerMode(OutlinerMode::TitleObject); if( pOutlinerParaObject->GetDepth(0) != -1 ) @@ -213,7 +213,7 @@ void FuExpandPage::DoExecute( SfxRequest& ) if (pOutlineObj) { // create structuring text objects - std::unique_ptr<OutlinerParaObject> pOPO = aOutliner.CreateParaObject(++nParaPos, nChildCount); + std::optional<OutlinerParaObject> pOPO = aOutliner.CreateParaObject(++nParaPos, nChildCount); std::unique_ptr<SdrOutliner> pTempOutl = SdrMakeOutliner(OutlinerMode::OutlineObject, *mpDoc); pTempOutl->SetText( *pOPO ); diff --git a/sd/source/ui/func/fuinsert.cxx b/sd/source/ui/func/fuinsert.cxx index 07d1417e0161..f8f5625e7763 100644 --- a/sd/source/ui/func/fuinsert.cxx +++ b/sd/source/ui/func/fuinsert.cxx @@ -546,7 +546,7 @@ void FuInsertOLE::DoExecute( SfxRequest& rReq ) // the empty OLE object gets a new IPObj bInsertNewObject = false; pObj->SetEmptyPresObj(false); - static_cast<SdrOle2Obj*>(pObj)->SetOutlinerParaObject(nullptr); + static_cast<SdrOle2Obj*>(pObj)->SetOutlinerParaObject(std::nullopt); static_cast<SdrOle2Obj*>(pObj)->SetObjRef(xObj); static_cast<SdrOle2Obj*>(pObj)->SetPersistName(aName); static_cast<SdrOle2Obj*>(pObj)->SetName(aName); diff --git a/sd/source/ui/func/fuinsfil.cxx b/sd/source/ui/func/fuinsfil.cxx index aec950b0c779..d776e07f1246 100644 --- a/sd/source/ui/func/fuinsfil.cxx +++ b/sd/source/ui/func/fuinsfil.cxx @@ -480,7 +480,7 @@ void FuInsertFile::InsTextOrRTFinDrMode(SfxMedium* pMedium) } } - std::unique_ptr<OutlinerParaObject> pOPO = aOutliner.CreateParaObject(); + std::optional<OutlinerParaObject> pOPO = aOutliner.CreateParaObject(); if (pOutlinerView) { diff --git a/sd/source/ui/func/fumorph.cxx b/sd/source/ui/func/fumorph.cxx index cf51719d3857..9782c3f0c27e 100644 --- a/sd/source/ui/func/fumorph.cxx +++ b/sd/source/ui/func/fumorph.cxx @@ -86,8 +86,8 @@ void FuMorph::DoExecute( SfxRequest& ) SdrObject* pCloneObj2(pObj2->CloneSdrObject(pObj2->getSdrModelFromSdrObject())); // delete text at clone, otherwise we do not get a correct PathObj - pCloneObj1->SetOutlinerParaObject(nullptr); - pCloneObj2->SetOutlinerParaObject(nullptr); + pCloneObj1->SetOutlinerParaObject(std::nullopt); + pCloneObj2->SetOutlinerParaObject(std::nullopt); // create path objects SdrObjectUniquePtr pPolyObj1 = pCloneObj1->ConvertToPolyObj(false, false); diff --git a/sd/source/ui/unoidl/unoobj.cxx b/sd/source/ui/unoidl/unoobj.cxx index 49bdbc6e94b6..78bc5cd6b9dd 100644 --- a/sd/source/ui/unoidl/unoobj.cxx +++ b/sd/source/ui/unoidl/unoobj.cxx @@ -897,7 +897,7 @@ void SdXShape::SetEmptyPresObj(bool bEmpty) const bool bVertical = pOutlinerParaObject && pOutlinerParaObject->IsEffectivelyVertical(); // really delete SdrOutlinerObj at pObj - pObj->NbcSetOutlinerParaObject(nullptr); + pObj->NbcSetOutlinerParaObject(std::nullopt); if( bVertical ) if (auto pTextObj = dynamic_cast<SdrTextObj*>( pObj ) ) pTextObj->SetVerticalWriting( true ); diff --git a/sd/source/ui/view/DocumentRenderer.cxx b/sd/source/ui/view/DocumentRenderer.cxx index ed93441139a1..2aa37302eb03 100644 --- a/sd/source/ui/view/DocumentRenderer.cxx +++ b/sd/source/ui/view/DocumentRenderer.cxx @@ -1095,7 +1095,7 @@ namespace { { public: OutlinerPrinterPage ( - std::unique_ptr<OutlinerParaObject> pParaObject, + std::optional<OutlinerParaObject> pParaObject, const MapMode& rMapMode, const OUString& rsPageString, const Point& rPageStringOffset, @@ -1148,7 +1148,7 @@ namespace { } private: - std::unique_ptr<OutlinerParaObject> mpParaObject; + std::optional<OutlinerParaObject> mpParaObject; }; } diff --git a/sd/source/ui/view/drviews2.cxx b/sd/source/ui/view/drviews2.cxx index 7a1c81c89bf7..5a1a75e4670c 100644 --- a/sd/source/ui/view/drviews2.cxx +++ b/sd/source/ui/view/drviews2.cxx @@ -2490,7 +2490,7 @@ void DrawViewShell::FuTemporary(SfxRequest& rReq) OutlinerMode nOutlMode = pOutl->GetOutlinerMode(); pOutl->SetStyleSheet( 0, nullptr ); pOutl->QuickInsertField( *pFieldItem, ESelection() ); - std::unique_ptr<OutlinerParaObject> pOutlParaObject = pOutl->CreateParaObject(); + std::optional<OutlinerParaObject> pOutlParaObject = pOutl->CreateParaObject(); SdrRectObj* pRectObj = new SdrRectObj( *GetDoc(), diff --git a/sd/source/ui/view/drviews8.cxx b/sd/source/ui/view/drviews8.cxx index b6c043e91109..10703fbc4158 100644 --- a/sd/source/ui/view/drviews8.cxx +++ b/sd/source/ui/view/drviews8.cxx @@ -105,7 +105,7 @@ void DrawViewShell::ScannerEvent() { bInsertNewObject = false; pGrafObj->SetEmptyPresObj(false); - pGrafObj->SetOutlinerParaObject(nullptr); + pGrafObj->SetOutlinerParaObject(std::nullopt); pGrafObj->SetGraphic( Graphic( aScanBmp ) ); } } diff --git a/sd/source/ui/view/drviews9.cxx b/sd/source/ui/view/drviews9.cxx index 0909d8536fcd..4ba735f153cd 100644 --- a/sd/source/ui/view/drviews9.cxx +++ b/sd/source/ui/view/drviews9.cxx @@ -150,7 +150,7 @@ void DrawViewShell::ExecGallery(SfxRequest const & rReq) SdrGrafObj* pNewGrafObj(pGrafObj->CloneSdrObject(pGrafObj->getSdrModelFromSdrObject())); pNewGrafObj->SetEmptyPresObj(false); - pNewGrafObj->SetOutlinerParaObject(nullptr); + pNewGrafObj->SetOutlinerParaObject(std::nullopt); pNewGrafObj->SetGraphic(aGraphic); OUString aStr = mpDrawView->GetDescriptionOfMarkedObjects() + diff --git a/sd/source/ui/view/drviewse.cxx b/sd/source/ui/view/drviewse.cxx index 3acc0b882c3d..b1016470bc42 100644 --- a/sd/source/ui/view/drviewse.cxx +++ b/sd/source/ui/view/drviewse.cxx @@ -1489,7 +1489,7 @@ void DrawViewShell::InsertURLField(const OUString& rURL, const OUString& rText, aURLField.SetTargetFrame(rTarget); SvxFieldItem aURLItem(aURLField, EE_FEATURE_FIELD); pOutl->QuickInsertField( aURLItem, ESelection() ); - std::unique_ptr<OutlinerParaObject> pOutlParaObject = pOutl->CreateParaObject(); + std::optional<OutlinerParaObject> pOutlParaObject = pOutl->CreateParaObject(); SdrRectObj* pRectObj = new SdrRectObj( GetView()->getSdrModelFromSdrView(), diff --git a/sd/source/ui/view/outlnvsh.cxx b/sd/source/ui/view/outlnvsh.cxx index 7a77c2a7275e..f4d1b15d7888 100644 --- a/sd/source/ui/view/outlnvsh.cxx +++ b/sd/source/ui/view/outlnvsh.cxx @@ -1582,7 +1582,7 @@ void OutlineViewShell::UpdateTitleObject( SdPage* pPage, Paragraph const * pPara } // if we have a title object and a text, set the text - std::unique_ptr<OutlinerParaObject> pOPO; + std::optional<OutlinerParaObject> pOPO; if (pTO) pOPO = rOutliner.CreateParaObject(rOutliner.GetAbsPos(pPara), 1); if (pOPO) @@ -1645,7 +1645,7 @@ void OutlineViewShell::UpdateOutlineObject( SdPage* pPage, Paragraph* pPara ) return; ::Outliner& rOutliner = pOlView->GetOutliner(); - std::unique_ptr<OutlinerParaObject> pOPO; + std::optional<OutlinerParaObject> pOPO; SdrTextObj* pTO = nullptr; OutlinerMode eOutlinerMode = OutlinerMode::TitleObject; diff --git a/sd/source/ui/view/outlview.cxx b/sd/source/ui/view/outlview.cxx index 6234d7bfe298..eae262aa26a7 100644 --- a/sd/source/ui/view/outlview.cxx +++ b/sd/source/ui/view/outlview.cxx @@ -1319,7 +1319,7 @@ SvtScriptType OutlineView::GetScriptType() const { SvtScriptType nScriptType = ::sd::View::GetScriptType(); - std::unique_ptr<OutlinerParaObject> pTempOPObj = mrOutliner.CreateParaObject(); + std::optional<OutlinerParaObject> pTempOPObj = mrOutliner.CreateParaObject(); if(pTempOPObj) { nScriptType = pTempOPObj->GetTextObject().GetScriptType(); diff --git a/sd/source/ui/view/sdview4.cxx b/sd/source/ui/view/sdview4.cxx index bc6e48286889..00e27a641c01 100644 --- a/sd/source/ui/view/sdview4.cxx +++ b/sd/source/ui/view/sdview4.cxx @@ -127,7 +127,7 @@ SdrGrafObj* View::InsertGraphic( const Graphic& rGraphic, sal_Int8& rAction, { ::tools::Rectangle aRect( pNewGrafObj->GetLogicRect() ); pNewGrafObj->AdjustToMaxRect( aRect ); - pNewGrafObj->SetOutlinerParaObject(nullptr); + pNewGrafObj->SetOutlinerParaObject(std::nullopt); pNewGrafObj->SetEmptyPresObj(false); } diff --git a/sd/source/ui/view/viewshe2.cxx b/sd/source/ui/view/viewshe2.cxx index 0837c0ecbb8a..607768ec726c 100644 --- a/sd/source/ui/view/viewshe2.cxx +++ b/sd/source/ui/view/viewshe2.cxx @@ -691,7 +691,7 @@ bool ViewShell::ActivateObject(SdrOle2Obj* pObj, sal_Int32 nVerb) { // OLE object is no longer empty pObj->SetEmptyPresObj(false); - pObj->SetOutlinerParaObject(nullptr); + pObj->SetOutlinerParaObject(std::nullopt); pObj->ClearGraphic(); // the empty OLE object gets a new IPObj |