diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2016-04-19 17:38:14 +0200 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2016-04-26 08:03:21 +0000 |
commit | 64b2f209b72c5a5662afcb0ac1706b882e0e059b (patch) | |
tree | 3a3b57a6b837ab4abc1e1bcefdcc979feba836b9 /svx | |
parent | 8d3dd678bf9fd50a736cc0ff956f1efd7e660502 (diff) |
tdf#99396 SvxTableController::SetVertical: implement undo support
All the table and cell objects know how to undo this change, what was
missing is the begin/end undo calls and the broadcast of the cell
format change.
(cherry picked from commits 3057b5cdb989d44613518900b25ebad8b7c600a2,
d60d70d92cec7bbc471f8f0c653d443282227d34,
6819992113947e7a6272bf750fee712c2df41905 and
100eb15b4d8529d7a11d98a28742f31f0f792fa1)
Conflicts:
sd/qa/unit/misc-tests.cxx
Change-Id: I3dfd203faf5c579da2937fedab5647129a8e903a
Reviewed-on: https://gerrit.libreoffice.org/24276
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Andras Timar <andras.timar@collabora.com>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/table/cell.cxx | 5 | ||||
-rw-r--r-- | svx/source/table/svdotable.cxx | 12 | ||||
-rw-r--r-- | svx/source/table/tablecontroller.cxx | 18 |
3 files changed, 34 insertions, 1 deletions
diff --git a/svx/source/table/cell.cxx b/svx/source/table/cell.cxx index b2d1604a0bdc..c783cb1fb7d6 100644 --- a/svx/source/table/cell.cxx +++ b/svx/source/table/cell.cxx @@ -799,6 +799,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 15bbb7f640c3..5b979febf860 100644 --- a/svx/source/table/svdotable.cxx +++ b/svx/source/table/svdotable.cxx @@ -205,6 +205,7 @@ public: CellPos maEditPos; TableStyleSettings maTableStyle; Reference< XIndexAccess > mxTableStyle; + std::vector<std::unique_ptr<SdrUndoAction>> maUndos; void SetModel(SdrModel* pOldModel, SdrModel* pNewModel); @@ -1860,7 +1861,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 ); @@ -2085,6 +2093,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 diff --git a/svx/source/table/tablecontroller.cxx b/svx/source/table/tablecontroller.cxx index 0238e851e4ff..beb75e035f04 100644 --- a/svx/source/table/tablecontroller.cxx +++ b/svx/source/table/tablecontroller.cxx @@ -1177,6 +1177,13 @@ void SvxTableController::SetVertical( sal_uInt16 nSId ) { TableModelNotifyGuard aGuard( mxTable.get() ); + bool bUndo = mpModel && mpModel->IsUndoEnabled(); + if (bUndo) + { + mpModel->BegUndo(ImpGetResStr(STR_TABLE_NUMFORMAT)); + mpModel->AddUndo(mpModel->GetSdrUndoFactory().CreateUndoAttrObject(*pTableObj)); + } + CellPos aStart, aEnd; getSelectedCells( aStart, aEnd ); @@ -1203,11 +1210,20 @@ void SvxTableController::SetVertical( sal_uInt16 nSId ) { CellRef xCell( dynamic_cast< Cell* >( mxTable->getCellByPosition( nCol, nRow ).get() ) ); if( xCell.is() ) - xCell->SetMergedItem(aItem); + { + if (bUndo) + xCell->AddUndo(); + SfxItemSet aSet(xCell->GetItemSet()); + aSet.Put(aItem); + xCell->SetMergedItemSetAndBroadcast(aSet, /*bClearAllItems=*/false); + } } } UpdateTableShape(); + + if (bUndo) + mpModel->EndUndo(); } } |