sc/qa/unit/copy_paste_test.cxx | 51 ++++++++++++++++++++++++ sc/qa/unit/data/ods/tdf113500_autofillMixed.ods |binary sc/source/core/data/table4.cxx | 15 ------- 3 files changed, 51 insertions(+), 15 deletions(-)
New commits: commit 4bcfa22a66deef210535391cfc3f683851b1b3f7 Author: Attila Szűcs <szucs.atti...@nisz.hu> AuthorDate: Fri Nov 13 13:22:21 2020 +0100 Commit: László Németh <nem...@numbertext.org> CommitDate: Tue Nov 17 12:24:00 2020 +0100 tdf#113500 sc: fix autofill of same mixed values for example selecting two cells with the same text content "A1", and autofilling them must result "A1", "A1"... instead of "A2", "A2", "A3", A3"... Remove an obsolete fix in FillAnalyse(). As 0 increment is handled by both user list and mixed sequence cases, there is no need to pre-check that the elements are the same. Now FillAnalyse will return with the proper FILL_LINEAR (or user list) instead of FILL_SIMPLE that caused the unnecessary +1 increment. See commit d64bd977a430182826252695f041a6ddd62e45ef (tdf#137653 tdf#137624 sc: fix autofill user list sequence) and commit 5af699cf62b2313980add377a777c49dc1e7ae2a (don't deduce increment from multiple equal list entries). Co-authored-by: Tibor Nagy (NISZ) Change-Id: I0750816375486b5b95fb2e0fcfdb9b1d6c8ce7d5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105791 Tested-by: László Németh <nem...@numbertext.org> Reviewed-by: László Németh <nem...@numbertext.org> diff --git a/sc/qa/unit/copy_paste_test.cxx b/sc/qa/unit/copy_paste_test.cxx index 03d10e90aa08..62ee0bcc53f0 100644 --- a/sc/qa/unit/copy_paste_test.cxx +++ b/sc/qa/unit/copy_paste_test.cxx @@ -49,6 +49,7 @@ public: void tdf137621_autofillMergedBool(); void tdf137205_autofillDatesInMergedCells(); void tdf137653_137654_autofillUserlist(); + void tdf113500_autofillMixed(); void tdf137625_autofillMergedUserlist(); CPPUNIT_TEST_SUITE(ScCopyPasteTest); @@ -64,6 +65,7 @@ public: CPPUNIT_TEST(tdf137621_autofillMergedBool); CPPUNIT_TEST(tdf137205_autofillDatesInMergedCells); CPPUNIT_TEST(tdf137653_137654_autofillUserlist); + CPPUNIT_TEST(tdf113500_autofillMixed); CPPUNIT_TEST(tdf137625_autofillMergedUserlist); CPPUNIT_TEST_SUITE_END(); @@ -820,6 +822,55 @@ void ScCopyPasteTest::tdf137653_137654_autofillUserlist() } } +void ScCopyPasteTest::tdf113500_autofillMixed() +{ + ScDocShellRef xDocSh = loadDocAndSetupModelViewController("tdf113500_autofillMixed.", FORMAT_ODS, true); + ScDocument& rDoc = xDocSh->GetDocument(); + + // Get the document controller + ScTabViewShell* pView = xDocSh->GetBestViewShell(false); + CPPUNIT_ASSERT(pView != nullptr); + + // fillauto userlist, these areas contain only merged cells + pView->FillAuto(FILL_TO_RIGHT, 4, 5, 6, 7, 3); //E6:G8 + pView->FillAuto(FILL_TO_LEFT, 4, 5, 6, 7, 3); //E6:G8 + pView->FillAuto(FILL_TO_BOTTOM, 1, 18, 3, 19, 2); //B19:D20 + pView->FillAuto(FILL_TO_TOP, 1, 18, 3, 19, 2); //B19:D20 + + // compare the results of fill-right / -left with the reference stored in the test file + // this compares the whole area blindly, for specific test cases, check the test file + // do not check the 3. row: a1,b2,a3. It is an other bug to fix + for (int nCol = 1; nCol <= 9; nCol++) + { + for (int nRow = 5; nRow <= 6; nRow++) + { + CellType nType1 = rDoc.GetCellType(ScAddress(nCol, nRow, 0)); + CellType nType2 = rDoc.GetCellType(ScAddress(nCol, nRow + 4, 0)); + OUString aStr1 = rDoc.GetString(nCol, nRow, 0); + OUString aStr2 = rDoc.GetString(nCol, nRow + 4, 0); + + CPPUNIT_ASSERT_EQUAL(nType1, nType2); + CPPUNIT_ASSERT_EQUAL(aStr1, aStr2); + } + } + + // compare the results of fill-up / -down + // do not check the 2. column: 1st,3st. It is an other bug to fix + for (int nCol = 1; nCol <= 3; nCol+=2) + { + for (int nRow = 16; nRow <= 21; nRow++) + { + CellType nType1 = rDoc.GetCellType(ScAddress(nCol, nRow, 0)); + CellType nType2 = rDoc.GetCellType(ScAddress(nCol + 4, nRow, 0)); + OUString aStr1 = rDoc.GetString(nCol, nRow, 0); + OUString aStr2 = rDoc.GetString(nCol + 4, nRow, 0); + + CPPUNIT_ASSERT_EQUAL(nType1, nType2); + CPPUNIT_ASSERT_EQUAL(aStr1, aStr2); + } + } +} + void ScCopyPasteTest::tdf137625_autofillMergedUserlist() { ScDocShellRef xDocSh = loadDocAndSetupModelViewController("tdf137625_autofillMergedUserlist.", FORMAT_ODS, true); diff --git a/sc/qa/unit/data/ods/tdf113500_autofillMixed.ods b/sc/qa/unit/data/ods/tdf113500_autofillMixed.ods new file mode 100644 index 000000000000..4ae07872ddca Binary files /dev/null and b/sc/qa/unit/data/ods/tdf113500_autofillMixed.ods differ diff --git a/sc/source/core/data/table4.cxx b/sc/source/core/data/table4.cxx index 9dc648f510ad..2e29cecff86b 100644 --- a/sc/source/core/data/table4.cxx +++ b/sc/source/core/data/table4.cxx @@ -621,21 +621,6 @@ void ScTable::FillAnalyse( SCCOL nCol1, SCROW nRow1, SCCOL nCol2, SCROW nRow2, OUString aStr; GetString(nCol, nRow, aStr); - // fdo#39500 don't deduce increment from multiple equal list entries - bool bAllSame = true; - for (SCSIZE i = 0; i < nCount; ++i) - { - OUString aTestStr; - GetString(static_cast<SCCOL>(nCol + i* nAddX), static_cast<SCROW>(nRow + i * nAddY), aTestStr); - if(aStr != aTestStr) - { - bAllSame = false; - break; - } - } - if(bAllSame && nCount > 1) - return; - rListData = const_cast<ScUserListData*>(ScGlobal::GetUserList()->GetData(aStr)); if (rListData) { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits