summaryrefslogtreecommitdiff
path: root/sw/qa/extras/uiwriter
diff options
context:
space:
mode:
authorJustin Luth <jluth@mail.com>2022-05-23 18:33:41 +0200
committerMiklos Vajna <vmiklos@collabora.com>2022-06-13 09:51:35 +0200
commit9a2e7bade3aa8b115f1973be532ec86fa0369171 (patch)
tree9685d95f8048e7c92ecc7683cac070d03bb321c0 /sw/qa/extras/uiwriter
parentaa5824b2a6df99ef9d788a8d37bdfa77582375c8 (diff)
tdf#145151 sw IsTableMode NumRule: unselected cells
...should not be affected when setting or deleting numbering. This patch depends on follow-up patches to properly detect if numbering is turned on or off in some cases. This patch prevents numbering from "leaking" into the previous cell if the cells were selected backwards. Perhaps it would be better to fix the selection code itself instead of handling all of these edge cases, but doing that might have unintended consequences that I wouldn't have any insight into. So this is safer. Change-Id: I98e18d6056e93a4d89fdbe75b6237daca7832f41 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134885 Tested-by: Jenkins Reviewed-by: Justin Luth <jluth@mail.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'sw/qa/extras/uiwriter')
-rw-r--r--sw/qa/extras/uiwriter/uiwriter5.cxx84
1 files changed, 84 insertions, 0 deletions
diff --git a/sw/qa/extras/uiwriter/uiwriter5.cxx b/sw/qa/extras/uiwriter/uiwriter5.cxx
index 1e9d5a0b7560..6517b7a32557 100644
--- a/sw/qa/extras/uiwriter/uiwriter5.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter5.cxx
@@ -2870,6 +2870,90 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf93747)
getProperty<OUString>(getParagraphOfText(1, xCellB1->getText()), "ParaStyleName"));
}
+CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf145151)
+{
+ SwDoc* pDoc = createSwDoc();
+ SwWrtShell* pWrtSh = pDoc->GetDocShell()->GetWrtShell();
+
+ uno::Sequence<beans::PropertyValue> aArgs(comphelper::InitPropertySequence(
+ { { "Rows", uno::Any(sal_Int32(2)) }, { "Columns", uno::Any(sal_Int32(2)) } }));
+
+ dispatchCommand(mxComponent, ".uno:InsertTable", aArgs);
+ Scheduler::ProcessEventsToIdle();
+
+ pWrtSh->Insert("Col1");
+
+ // Move the cursor to B1
+ pWrtSh->Right(CRSR_SKIP_CHARS, /*bSelect=*/false, 1, /*bBasicCall=*/false);
+
+ pWrtSh->Insert("Col2");
+
+ uno::Reference<text::XTextTablesSupplier> xTextTablesSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xIndexAccess(xTextTablesSupplier->getTextTables(),
+ uno::UNO_QUERY);
+ uno::Reference<text::XTextTable> xTextTable(xIndexAccess->getByIndex(0), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xIndexAccess->getCount());
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xTextTable->getRows()->getCount());
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xTextTable->getColumns()->getCount());
+
+ uno::Reference<text::XTextRange> xCellA1(xTextTable->getCellByName("A1"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("Col1"), xCellA1->getString());
+
+ uno::Reference<text::XTextRange> xCellB1(xTextTable->getCellByName("B1"), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("Col2"), xCellB1->getString());
+
+ // Select backwards B1 and A1 (select "2loC<cell>" which ends up selecting both cells)
+ pWrtSh->Left(CRSR_SKIP_CHARS, /*bSelect=*/true, 5, /*bBasicCall=*/false);
+
+ // Just select the whole B1
+ pWrtSh->Right(CRSR_SKIP_CHARS, /*bSelect=*/true, 1, /*bBasicCall=*/false);
+
+ dispatchCommand(mxComponent, ".uno:DefaultNumbering", {});
+ Scheduler::ProcessEventsToIdle();
+
+ // B1 should now have a numbering style, but A1 should not be affected.
+ OUString sNumStyleB1
+ = getProperty<OUString>(getParagraphOfText(1, xCellB1->getText()), "NumberingStyleName");
+ CPPUNIT_ASSERT(!sNumStyleB1.isEmpty());
+ CPPUNIT_ASSERT_MESSAGE(
+ "Only cell B1 was selected. A1 should not have any numbering.",
+ getProperty<OUString>(getParagraphOfText(1, xCellA1->getText()), "NumberingStyleName")
+ .isEmpty());
+
+ // Now test removing numbering/bullets
+ // Add A1 to the current B1 selection
+ pWrtSh->Left(CRSR_SKIP_CHARS, /*bSelect=*/true, 1, /*bBasicCall=*/false);
+
+ // Toggle on bullet numbering
+ dispatchCommand(mxComponent, ".uno:DefaultBullet", {});
+ Scheduler::ProcessEventsToIdle();
+
+ // sanity check - both cells have bullets turned on.
+ OUString sNumStyleA1
+ = getProperty<OUString>(getParagraphOfText(1, xCellA1->getText()), "NumberingStyleName");
+ CPPUNIT_ASSERT(!sNumStyleA1.isEmpty());
+ CPPUNIT_ASSERT_EQUAL(
+ sNumStyleA1,
+ getProperty<OUString>(getParagraphOfText(1, xCellB1->getText()), "NumberingStyleName"));
+ CPPUNIT_ASSERT(sNumStyleA1 != sNumStyleB1); // therefore B1 changed from numbering to bullets
+
+ // Just select cell B1
+ pWrtSh->Right(CRSR_SKIP_CHARS, /*bSelect=*/true, 1, /*bBasicCall=*/false);
+
+ // Toggle off bullet numbering
+ dispatchCommand(mxComponent, ".uno:DefaultBullet", {});
+ Scheduler::ProcessEventsToIdle();
+
+ // B1 should now have removed all numbering, while A1 should still have the bullet.
+ CPPUNIT_ASSERT(
+ getProperty<OUString>(getParagraphOfText(1, xCellB1->getText()), "NumberingStyleName")
+ .isEmpty());
+ CPPUNIT_ASSERT_MESSAGE(
+ "Only cell B1 was selected. A1 should still have bullets turned on.",
+ !getProperty<OUString>(getParagraphOfText(1, xCellA1->getText()), "NumberingStyleName")
+ .isEmpty());
+}
+
CPPUNIT_TEST_FIXTURE(SwUiWriterTest5, testTdf126735)
{
SwDoc* pDoc = createSwDoc(DATA_DIRECTORY, "tdf39721.fodt");