From 55c4bfc5717c6f915e8760eec95be76813d5fce8 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 19 Aug 2021 10:00:01 +0200 Subject: use std::optional in SdrUndoAttrObj it is a COW object, no need to allocate separately on heap Change-Id: Ibfecb263eedb6ef5eca8122e80a564cb1e872db1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120699 Tested-by: Jenkins Reviewed-by: Noel Grandin --- svx/source/svdraw/svdundo.cxx | 4 ++-- svx/source/table/tableundo.cxx | 10 ++++------ svx/source/table/tableundo.hxx | 3 +-- 3 files changed, 7 insertions(+), 10 deletions(-) (limited to 'svx') diff --git a/svx/source/svdraw/svdundo.cxx b/svx/source/svdraw/svdundo.cxx index 2eea31d23237..51f35d8e80c7 100644 --- a/svx/source/svdraw/svdundo.cxx +++ b/svx/source/svdraw/svdundo.cxx @@ -279,7 +279,7 @@ SdrUndoAttrObj::SdrUndoAttrObj(SdrObject& rNewObj, bool bStyleSheet1, bool bSave { auto p = pObj->GetOutlinerParaObject(); if(p) - pTextUndo.reset( new OutlinerParaObject(*p) ); + pTextUndo = *p; } } @@ -316,7 +316,7 @@ void SdrUndoAttrObj::Undo() // #i8508# auto p = pObj->GetOutlinerParaObject(); if(p) - pTextRedo.reset( new OutlinerParaObject(*p) ); + pTextRedo = *p; } } diff --git a/svx/source/table/tableundo.cxx b/svx/source/table/tableundo.cxx index 2840562a4acf..66641469dd09 100644 --- a/svx/source/table/tableundo.cxx +++ b/svx/source/table/tableundo.cxx @@ -61,10 +61,8 @@ void CellUndo::dispose() maUndoData.mpProperties = nullptr; delete maRedoData.mpProperties; maRedoData.mpProperties = nullptr; - delete maUndoData.mpOutlinerParaObject; - maUndoData.mpOutlinerParaObject = nullptr; - delete maRedoData.mpOutlinerParaObject; - maRedoData.mpOutlinerParaObject = nullptr; + maUndoData.mpOutlinerParaObject.reset(); + maRedoData.mpOutlinerParaObject.reset(); } void CellUndo::ObjectInDestruction(const SdrObject& ) @@ -136,9 +134,9 @@ void CellUndo::getDataFromCell( Data& rData ) rData.mpProperties = mxCell->CloneProperties( *mxObjRef, *mxCell); if( mxCell->GetOutlinerParaObject() ) - rData.mpOutlinerParaObject = new OutlinerParaObject(*mxCell->GetOutlinerParaObject()); + rData.mpOutlinerParaObject = *mxCell->GetOutlinerParaObject(); else - rData.mpOutlinerParaObject = nullptr; + rData.mpOutlinerParaObject.reset(); rData.msFormula = mxCell->msFormula; rData.mfValue = mxCell->mfValue; diff --git a/svx/source/table/tableundo.hxx b/svx/source/table/tableundo.hxx index 861251963658..822f5ec642fa 100644 --- a/svx/source/table/tableundo.hxx +++ b/svx/source/table/tableundo.hxx @@ -55,7 +55,7 @@ private: struct Data { sdr::properties::TextProperties* mpProperties; - OutlinerParaObject* mpOutlinerParaObject; + std::optional mpOutlinerParaObject; OUString msFormula; double mfValue; @@ -66,7 +66,6 @@ private: Data() : mpProperties(nullptr) - , mpOutlinerParaObject(nullptr) , mfValue(0) , mnError(0) , mbMerged(false) -- cgit