diff options
Diffstat (limited to 'svx/source/table')
-rw-r--r-- | svx/source/table/cell.cxx | 16 | ||||
-rw-r--r-- | svx/source/table/cell.hxx | 2 | ||||
-rw-r--r-- | svx/source/table/tableundo.cxx | 48 | ||||
-rw-r--r-- | svx/source/table/tableundo.hxx | 5 |
4 files changed, 52 insertions, 19 deletions
diff --git a/svx/source/table/cell.cxx b/svx/source/table/cell.cxx index 158f9aced4..40e1456ffd 100644 --- a/svx/source/table/cell.cxx +++ b/svx/source/table/cell.cxx @@ -678,6 +678,9 @@ void Cell::SetOutlinerParaObject( OutlinerParaObject* pTextObject ) { SdrText::SetOutlinerParaObject( pTextObject ); maSelection.nStartPara = 0xffff; + + if( pTextObject == 0 ) + ForceOutlinerParaObject( OUTLINERMODE_TEXTOBJECT ); } // ----------------------------------------------------------------------------- @@ -694,15 +697,22 @@ void Cell::AddUndo() // ----------------------------------------------------------------------------- -sdr::properties::TextProperties* Cell::CloneProperties( SdrObject& rNewObj, Cell& rNewCell ) +sdr::properties::TextProperties* Cell::CloneProperties( sdr::properties::TextProperties* pProperties, SdrObject& rNewObj, Cell& rNewCell ) { - if( mpProperties ) - return new sdr::properties::CellProperties( *static_cast<sdr::properties::CellProperties*>(mpProperties), rNewObj, &rNewCell ); + if( pProperties ) + return new sdr::properties::CellProperties( *static_cast<sdr::properties::CellProperties*>(pProperties), rNewObj, &rNewCell ); else return 0; } // ----------------------------------------------------------------------------- + +sdr::properties::TextProperties* Cell::CloneProperties( SdrObject& rNewObj, Cell& rNewCell ) +{ + return CloneProperties(mpProperties,rNewObj,rNewCell); +} + +// ----------------------------------------------------------------------------- // XInterface // ----------------------------------------------------------------------------- diff --git a/svx/source/table/cell.hxx b/svx/source/table/cell.hxx index 8299aa5342..35aa44b1af 100644 --- a/svx/source/table/cell.hxx +++ b/svx/source/table/cell.hxx @@ -202,6 +202,8 @@ public: sdr::properties::TextProperties* CloneProperties( SdrObject& rNewObj, Cell& rNewCell ); + static sdr::properties::TextProperties* CloneProperties( sdr::properties::TextProperties* pProperties, SdrObject& rNewObj, Cell& rNewCell ); + void notifyModified(); protected: diff --git a/svx/source/table/tableundo.cxx b/svx/source/table/tableundo.cxx index b39d44ad43..a6c5ff1e3b 100644 --- a/svx/source/table/tableundo.cxx +++ b/svx/source/table/tableundo.cxx @@ -40,6 +40,7 @@ #include "tablerow.hxx" #include "tablecolumn.hxx" + // ----------------------------------------------------------------------------- using ::rtl::OUString; @@ -56,22 +57,36 @@ CellUndo::CellUndo( const SdrObjectWeakRef& xObjRef, const CellRef& xCell ) , mxCell( xCell ) , mbUndo( true ) { - - getDataFromCell( maUndoData ); + if( mxCell.is() && mxObjRef.is() ) + { + getDataFromCell( maUndoData ); + mxObjRef->AddObjectUser( *this ); + } } CellUndo::~CellUndo() { - if( mbUndo ) - { - delete maUndoData.mpProperties; - delete maUndoData.mpOutlinerParaObject; - } - else - { - delete maRedoData.mpProperties; - delete maRedoData.mpOutlinerParaObject; - } + if( mxObjRef.is() ) + mxObjRef->RemoveObjectUser( *this ); + dispose(); +} + +void CellUndo::dispose() +{ + mxCell.clear(); + delete maUndoData.mpProperties; + maUndoData.mpProperties = 0; + delete maRedoData.mpProperties; + maRedoData.mpProperties = 0; + delete maUndoData.mpOutlinerParaObject; + maUndoData.mpOutlinerParaObject = 0; + delete maRedoData.mpOutlinerParaObject; + maRedoData.mpOutlinerParaObject = 0; +} + +void CellUndo::ObjectInDestruction(const SdrObject& ) +{ + dispose(); } void CellUndo::Undo() @@ -88,7 +103,7 @@ void CellUndo::Undo() void CellUndo::Redo() { - if( mxCell.is() && mbUndo ) + if( mxCell.is() && !mbUndo ) { setDataToCell( maRedoData ); mbUndo = true; @@ -110,8 +125,11 @@ BOOL CellUndo::Merge( SfxUndoAction *pNextAction ) void CellUndo::setDataToCell( const Data& rData ) { - mxCell->mpProperties = rData.mpProperties; - + delete mxCell->mpProperties; + if( rData.mpProperties ) + mxCell->mpProperties = Cell::CloneProperties( rData.mpProperties, *mxObjRef.get(), *mxCell.get() ); + else + mxCell->mpProperties = 0; if( rData.mpOutlinerParaObject ) mxCell->SetOutlinerParaObject( rData.mpOutlinerParaObject->Clone() ); diff --git a/svx/source/table/tableundo.hxx b/svx/source/table/tableundo.hxx index 8ab12a9428..36e71a254f 100644 --- a/svx/source/table/tableundo.hxx +++ b/svx/source/table/tableundo.hxx @@ -50,7 +50,7 @@ class OutlinerParaObject; namespace sdr { namespace table { -class CellUndo : public SdrUndoAction +class CellUndo : public SdrUndoAction, public sdr::ObjectUser { public: CellUndo( const SdrObjectWeakRef& xObjRef, const CellRef& xCell ); @@ -60,6 +60,9 @@ public: virtual void Redo(); virtual BOOL Merge( SfxUndoAction *pNextAction ); + void dispose(); + virtual void ObjectInDestruction(const SdrObject& rObject); + private: struct Data { |