From 100eb15b4d8529d7a11d98a28742f31f0f792fa1 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 20 Apr 2016 17:44:29 +0200 Subject: tdf#99396 SdrTableObj::EndTextEdit: restore cell format undo items As seen by the user: after finishing the text edit of an Impress table cell, the text changes are still on the undo stack, but the table ones (like background color or vertical alignment) get lost. This happens as SdrUndoManager::SetEndTextEditHdl() removes all undo items from the stack which are created after the start of the text edit, and creates a single item, but that doesn't include the table changes, just the text ones. Fix the problem by creating a copy of the CellUndo objects when it text edit mode, and pushing them to the undo stack in SdrTableObj::EndTextEdit(), which already writes the undo stack and runs after the undo manager cleared the text edit items from the undo stack. Change-Id: I7d2768c86b5b262e98be1d09d7fa08d581430bb5 Reviewed-on: https://gerrit.libreoffice.org/24264 Reviewed-by: Miklos Vajna Tested-by: Jenkins --- svx/source/table/cell.cxx | 5 +++++ svx/source/table/svdotable.cxx | 12 ++++++++++++ 2 files changed, 17 insertions(+) (limited to 'svx') diff --git a/svx/source/table/cell.cxx b/svx/source/table/cell.cxx index 7af8546cc95e..b4ff60a407f1 100644 --- a/svx/source/table/cell.cxx +++ b/svx/source/table/cell.cxx @@ -781,6 +781,11 @@ void Cell::AddUndo() { CellRef xCell( this ); GetModel()->AddUndo( new CellUndo( &rObj, xCell ) ); + + // Undo action for the after-text-edit-ended stack. + SdrTableObj* pTableObj = dynamic_cast(&rObj); + if (pTableObj && pTableObj->IsTextEditActive()) + pTableObj->AddUndo(new CellUndo(pTableObj, xCell)); } } diff --git a/svx/source/table/svdotable.cxx b/svx/source/table/svdotable.cxx index 2bb0e286d6c1..4121fdaf3d6c 100644 --- a/svx/source/table/svdotable.cxx +++ b/svx/source/table/svdotable.cxx @@ -203,6 +203,7 @@ public: CellPos maEditPos; TableStyleSettings maTableStyle; Reference< XIndexAccess > mxTableStyle; + std::vector> maUndos; void SetModel(SdrModel* pOldModel, SdrModel* pNewModel); @@ -1781,7 +1782,14 @@ void SdrTableObj::EndTextEdit(SdrOutliner& rOutl) if(rOutl.IsModified()) { if( GetModel() && GetModel()->IsUndoEnabled() ) + { + // These actions should be on the undo stack after text edit. + for (std::unique_ptr& pAction : mpImpl->maUndos) + GetModel()->AddUndo(pAction.release()); + mpImpl->maUndos.clear(); + GetModel()->AddUndo( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*this) ); + } OutlinerParaObject* pNewText = nullptr; Paragraph* p1stPara = rOutl.GetParagraph( 0 ); @@ -1992,6 +2000,10 @@ WritingMode SdrTableObj::GetWritingMode() const return eWritingMode; } +void SdrTableObj::AddUndo(SdrUndoAction* pUndo) +{ + mpImpl->maUndos.push_back(std::unique_ptr(pUndo)); +} // gets base transformation and rectangle of object. If it's an SdrPathObj it fills the PolyPolygon // with the base geometry and returns TRUE. Otherwise it returns FALSE. -- cgit v1.2.3