diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-04-20 17:44:29 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-04-20 17:17:19 +0000 |
commit | 100eb15b4d8529d7a11d98a28742f31f0f792fa1 (patch) | |
tree | f0de11fb70b685bf58a3e7a39e64bb00ff55e400 /svx | |
parent | e8425c48102321d4f5a8bd687c8ca1ac7bae797e (diff) |
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 <vmiklos@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/table/cell.cxx | 5 | ||||
-rw-r--r-- | svx/source/table/svdotable.cxx | 12 |
2 files changed, 17 insertions, 0 deletions
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<sdr::table::SdrTableObj*>(&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<std::unique_ptr<SdrUndoAction>> 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<SdrUndoAction>& 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<SdrUndoAction>(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. |