sd/qa/unit/data/tdf99396.odp |binary sd/qa/unit/misc-tests.cxx | 29 +++++++++++++++++++++++++++++ svx/source/table/tablecontroller.cxx | 18 +++++++++++++++++- 3 files changed, 46 insertions(+), 1 deletion(-)
New commits: commit 6819992113947e7a6272bf750fee712c2df41905 Author: Miklos Vajna <[email protected]> Date: Tue Apr 19 17:56:24 2016 +0200 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. Change-Id: I3dfd203faf5c579da2937fedab5647129a8e903a Reviewed-on: https://gerrit.libreoffice.org/24247 Reviewed-by: Miklos Vajna <[email protected]> Tested-by: Jenkins <[email protected]> diff --git a/sd/qa/unit/data/tdf99396.odp b/sd/qa/unit/data/tdf99396.odp new file mode 100644 index 0000000..6362600 Binary files /dev/null and b/sd/qa/unit/data/tdf99396.odp differ diff --git a/sd/qa/unit/misc-tests.cxx b/sd/qa/unit/misc-tests.cxx index 4747cf3..105c071 100644 --- a/sd/qa/unit/misc-tests.cxx +++ b/sd/qa/unit/misc-tests.cxx @@ -24,12 +24,16 @@ #include <FactoryIds.hxx> #include <sdmod.hxx> #include <tools/shl.hxx> +#include <svx/sdr/table/tablecontroller.hxx> +#include <sfx2/request.hxx> +#include <svx/svxids.hrc> #include <ImpressViewShellBase.hxx> #include <SlideSorterViewShell.hxx> #include <SlideSorter.hxx> #include <controller/SlideSorterController.hxx> #include <controller/SlsClipboard.hxx> #include <controller/SlsPageSelector.hxx> +#include <undo/undomanager.hxx> #include <chrono> using namespace ::com::sun::star; @@ -40,10 +44,12 @@ class SdMiscTest : public SdModelTestBase public: void testTdf96206(); void testTdf96708(); + void testTdf99396(); CPPUNIT_TEST_SUITE(SdMiscTest); CPPUNIT_TEST(testTdf96206); CPPUNIT_TEST(testTdf96708); + CPPUNIT_TEST(testTdf99396); CPPUNIT_TEST_SUITE_END(); private: @@ -135,6 +141,29 @@ void SdMiscTest::testTdf96708() xDocSh->DoClose(); } +void SdMiscTest::testTdf99396() +{ + // Load the document and select the table. + sd::DrawDocShellRef xDocSh = Load(m_directories.getURLFromSrc("/sd/qa/unit/data/tdf99396.odp"), ODP); + sd::ViewShell *pViewShell = xDocSh->GetViewShell(); + SdPage* pPage = pViewShell->GetActualPage(); + SdrObject* pObject = pPage->GetObj(0); + SdrView* pView = pViewShell->GetView(); + pView->MarkObj(pObject, pView->GetSdrPageView()); + + // Make sure that the undo stack is empty. + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), xDocSh->GetDoc()->GetUndoManager()->GetUndoActionCount()); + + // Set the vertical alignment of the cells to bottom. + sdr::table::SvxTableController* pTableController = dynamic_cast<sdr::table::SvxTableController*>(pView->getSelectionController().get()); + SfxRequest aRequest(pViewShell->GetViewFrame(), SID_TABLE_VERT_BOTTOM); + pTableController->Execute(aRequest); + // This was 0, it wasn't possible to undo a vertical alignment change. + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), xDocSh->GetDoc()->GetUndoManager()->GetUndoActionCount()); + + xDocSh->DoClose(); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SdMiscTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/svx/source/table/tablecontroller.cxx b/svx/source/table/tablecontroller.cxx index b98feb2..aba6ded 100644 --- a/svx/source/table/tablecontroller.cxx +++ b/svx/source/table/tablecontroller.cxx @@ -1172,6 +1172,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 ); @@ -1198,11 +1205,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(); } } _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
