diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-08-19 10:00:01 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-08-19 11:53:13 +0200 |
commit | 55c4bfc5717c6f915e8760eec95be76813d5fce8 (patch) | |
tree | 5d83d6f74efa0b58bb7e27b0b8b8d8f803f8c061 | |
parent | e545598e738407019419a4c0fc252314d8f434d4 (diff) |
use std::optional<OutlinerParaObject> 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 <noel.grandin@collabora.co.uk>
-rw-r--r-- | include/svx/svdundo.hxx | 4 | ||||
-rw-r--r-- | svx/source/svdraw/svdundo.cxx | 4 | ||||
-rw-r--r-- | svx/source/table/tableundo.cxx | 10 | ||||
-rw-r--r-- | svx/source/table/tableundo.hxx | 3 |
4 files changed, 9 insertions, 12 deletions
diff --git a/include/svx/svdundo.hxx b/include/svx/svdundo.hxx index ccfa69476bba..0064aa85c6c5 100644 --- a/include/svx/svdundo.hxx +++ b/include/svx/svdundo.hxx @@ -154,10 +154,10 @@ protected: bool bHaveToTakeRedoSet; // When assigning TextItems to a drawing object with text: - std::unique_ptr<OutlinerParaObject> pTextUndo; + std::optional<OutlinerParaObject> pTextUndo; // #i8508# // The text rescue mechanism needs also to be implemented for redo actions. - std::unique_ptr<OutlinerParaObject> pTextRedo; + std::optional<OutlinerParaObject> pTextRedo; // If we have a group object: std::unique_ptr<SdrUndoGroup> pUndoGroup; 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<OutlinerParaObject> mpOutlinerParaObject; OUString msFormula; double mfValue; @@ -66,7 +66,6 @@ private: Data() : mpProperties(nullptr) - , mpOutlinerParaObject(nullptr) , mfValue(0) , mnError(0) , mbMerged(false) |