summaryrefslogtreecommitdiff
path: root/sd/qa/unit/misc-tests.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sd/qa/unit/misc-tests.cxx')
-rw-r--r--sd/qa/unit/misc-tests.cxx34
1 files changed, 29 insertions, 5 deletions
diff --git a/sd/qa/unit/misc-tests.cxx b/sd/qa/unit/misc-tests.cxx
index ba888c280601..dc2f4324c240 100644
--- a/sd/qa/unit/misc-tests.cxx
+++ b/sd/qa/unit/misc-tests.cxx
@@ -70,7 +70,7 @@ public:
void testTdf96206();
void testTdf96708();
void testTdf99396();
- void testTdf99396TextEdit();
+ void testTableObjectUndoTest();
void testFillGradient();
void testTdf44774();
void testTdf38225();
@@ -93,7 +93,7 @@ public:
CPPUNIT_TEST(testTdf96206);
CPPUNIT_TEST(testTdf96708);
CPPUNIT_TEST(testTdf99396);
- CPPUNIT_TEST(testTdf99396TextEdit);
+ CPPUNIT_TEST(testTableObjectUndoTest);
CPPUNIT_TEST(testFillGradient);
CPPUNIT_TEST(testTdf44774);
CPPUNIT_TEST(testTdf38225);
@@ -251,8 +251,10 @@ void SdMiscTest::testTdf99396()
xDocSh->DoClose();
}
-void SdMiscTest::testTdf99396TextEdit()
+void SdMiscTest::testTableObjectUndoTest()
{
+ // See tdf#99396 for the issue
+
// Load the document and select the table.
sd::DrawDocShellRef xDocSh = Load(m_directories.getURLFromSrc(u"/sd/qa/unit/data/tdf99396.odp"), ODP);
sd::ViewShell* pViewShell = xDocSh->GetViewShell();
@@ -278,14 +280,26 @@ void SdMiscTest::testTdf99396TextEdit()
const SfxItemSet* pArgs = aRequest.GetArgs();
pView->SetAttributes(*pArgs);
}
+ const auto& pLocalUndoManager = pView->getViewLocalUndoManager();
+ CPPUNIT_ASSERT_EQUAL(size_t(1), pLocalUndoManager->GetUndoActionCount());
+ CPPUNIT_ASSERT_EQUAL(OUString("Apply attributes"), pLocalUndoManager->GetUndoActionComment());
{
auto pTableController = dynamic_cast<sdr::table::SvxTableController*>(pView->getSelectionController().get());
CPPUNIT_ASSERT(pTableController);
SfxRequest aRequest(pViewShell->GetViewFrame(), SID_TABLE_VERT_BOTTOM);
pTableController->Execute(aRequest);
}
+ // Global change "Format cell" is applied only - Change the vertical alignment to "Bottom"
+ CPPUNIT_ASSERT_EQUAL(size_t(1), xDocSh->GetDoc()->GetUndoManager()->GetUndoActionCount());
+ CPPUNIT_ASSERT_EQUAL(OUString("Format cell"), xDocSh->GetDoc()->GetUndoManager()->GetUndoActionComment());
+
pView->SdrEndTextEdit();
+ // End of text edit, so the text edit action is added to the undo stack
+ CPPUNIT_ASSERT_EQUAL(size_t(2), xDocSh->GetDoc()->GetUndoManager()->GetUndoActionCount());
+ CPPUNIT_ASSERT_EQUAL(OUString("Edit text of Table"), xDocSh->GetDoc()->GetUndoManager()->GetUndoActionComment(0));
+ CPPUNIT_ASSERT_EQUAL(OUString("Format cell"), xDocSh->GetDoc()->GetUndoManager()->GetUndoActionComment(1));
+
// Check that the result is what we expect.
{
uno::Reference<table::XTable> xTable = pTableObject->getTable();
@@ -303,6 +317,10 @@ void SdMiscTest::testTdf99396TextEdit()
// Now undo.
xDocSh->GetUndoManager()->Undo();
+ // Undoing the last action - one left
+ CPPUNIT_ASSERT_EQUAL(size_t(1), xDocSh->GetDoc()->GetUndoManager()->GetUndoActionCount());
+ CPPUNIT_ASSERT_EQUAL(OUString("Format cell"), xDocSh->GetDoc()->GetUndoManager()->GetUndoActionComment(0));
+
// Check again that the result is what we expect.
{
uno::Reference<table::XTable> xTable = pTableObject->getTable();
@@ -318,6 +336,9 @@ void SdMiscTest::testTdf99396TextEdit()
CPPUNIT_ASSERT_EQUAL(SvxAdjust::Center, pAdjust->GetAdjust());
}
+ Scheduler::ProcessEventsToIdle();
+ CPPUNIT_ASSERT_EQUAL(size_t(1), xDocSh->GetDoc()->GetUndoManager()->GetUndoActionCount());
+ CPPUNIT_ASSERT_EQUAL(OUString("Format cell"), xDocSh->GetDoc()->GetUndoManager()->GetUndoActionComment(0));
/*
* now test tdf#103950 - Undo does not revert bundled font size changes for table cells
@@ -328,8 +349,11 @@ void SdMiscTest::testTdf99396TextEdit()
SfxRequest aRequest(pViewShell->GetViewFrame(), SID_GROW_FONT_SIZE);
static_cast<sd::DrawViewShell*>(pViewShell)->ExecChar(aRequest);
}
- CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), xDocSh->GetDoc()->GetUndoManager()->GetUndoActionCount());
-
+ Scheduler::ProcessEventsToIdle();
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(3), xDocSh->GetDoc()->GetUndoManager()->GetUndoActionCount());
+ CPPUNIT_ASSERT_EQUAL(OUString("Apply attributes to Table"), xDocSh->GetDoc()->GetUndoManager()->GetUndoActionComment(0));
+ CPPUNIT_ASSERT_EQUAL(OUString("Grow font size"), xDocSh->GetDoc()->GetUndoManager()->GetUndoActionComment(1));
+ CPPUNIT_ASSERT_EQUAL(OUString("Format cell"), xDocSh->GetDoc()->GetUndoManager()->GetUndoActionComment(2));
xDocSh->DoClose();
}