diff options
-rw-r--r-- | sd/qa/unit/data/tdf99396.odp | bin | 0 -> 10956 bytes | |||
-rw-r--r-- | sd/qa/unit/misc-tests.cxx | 29 | ||||
-rw-r--r-- | svx/source/table/tablecontroller.cxx | 18 |
3 files changed, 46 insertions, 1 deletions
diff --git a/sd/qa/unit/data/tdf99396.odp b/sd/qa/unit/data/tdf99396.odp Binary files differnew file mode 100644 index 000000000000..636260020c02 --- /dev/null +++ b/sd/qa/unit/data/tdf99396.odp diff --git a/sd/qa/unit/misc-tests.cxx b/sd/qa/unit/misc-tests.cxx index 4747cf3ffe9e..105c071d1a8e 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 b98feb21c87b..aba6dedfc148 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(); } } |