sc/qa/unit/data/xlsx/tdf122102.xlsx |binary sc/qa/unit/subsequent_filters-test.cxx | 38 +++++++++++++++++++++++++++++++++ sc/source/filter/oox/extlstcontext.cxx | 13 ++++++++++- 3 files changed, 50 insertions(+), 1 deletion(-)
New commits: commit 4bca4f507c064c18880bd8283aaba567865d2462 Author: Tibor Nagy <nagy.tib...@nisz.hu> AuthorDate: Tue Dec 15 18:58:33 2020 +0100 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Thu Dec 17 12:06:02 2020 +0100 tdf#122102 XLSX import: fix "contains" conditional formatting when using "Given text" type and cell reference with "contains text" or "not contains text" conditions. Co-authored-by: Attila Szűcs (NISZ) Change-Id: Ifbd34ef9f7ee948b6ac42a890bd52f3fb8486aec Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107791 Tested-by: László Németh <nem...@numbertext.org> Reviewed-by: László Németh <nem...@numbertext.org> (cherry picked from commit 0101975f8eac650bb87c4af81157cb33a6309e0e) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107810 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/sc/qa/unit/data/xlsx/tdf122102.xlsx b/sc/qa/unit/data/xlsx/tdf122102.xlsx new file mode 100644 index 000000000000..bc1db82d78a7 Binary files /dev/null and b/sc/qa/unit/data/xlsx/tdf122102.xlsx differ diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx index 0730a77971be..28db571e66de 100644 --- a/sc/qa/unit/subsequent_filters-test.cxx +++ b/sc/qa/unit/subsequent_filters-test.cxx @@ -106,6 +106,7 @@ public: virtual void tearDown() override; //ods, xls, xlsx filter tests + void testExtCondFormatXLSX(); void testUpdateCircleInMergedCellODS(); void testDeleteCircleInMergedCellODS(); void testBooleanFormatXLSX(); @@ -296,6 +297,7 @@ public: void testDeleteCirclesInRowAndCol(); CPPUNIT_TEST_SUITE(ScFiltersTest); + CPPUNIT_TEST(testExtCondFormatXLSX); CPPUNIT_TEST(testUpdateCircleInMergedCellODS); CPPUNIT_TEST(testDeleteCircleInMergedCellODS); CPPUNIT_TEST(testBooleanFormatXLSX); @@ -530,6 +532,42 @@ void testRangeNameImpl(const ScDocument& rDoc) } +void ScFiltersTest::testExtCondFormatXLSX() +{ + ScDocShellRef xDocSh = loadDoc("tdf122102.", FORMAT_XLSX); + CPPUNIT_ASSERT_MESSAGE("Failed to load tdf122102.xlsx", xDocSh.is()); + + ScDocument& rDoc = xDocSh->GetDocument(); + + // contains text and not contains text conditions + ScConditionalFormat* pFormatA1 = rDoc.GetCondFormat(0, 0, 0); + CPPUNIT_ASSERT(pFormatA1); + ScConditionalFormat* pFormatA2 = rDoc.GetCondFormat(0, 1, 0); + CPPUNIT_ASSERT(pFormatA2); + ScConditionalFormat* pFormatA3 = rDoc.GetCondFormat(0, 2, 0); + CPPUNIT_ASSERT(pFormatA3); + ScConditionalFormat* pFormatA4 = rDoc.GetCondFormat(0, 3, 0); + CPPUNIT_ASSERT(pFormatA4); + + ScRefCellValue aCellA1(rDoc, ScAddress(0, 0, 0)); + OUString aCellStyleA1 = pFormatA1->GetCellStyle(aCellA1, ScAddress(0, 0, 0)); + CPPUNIT_ASSERT(!aCellStyleA1.isEmpty()); + + ScRefCellValue aCellA2(rDoc, ScAddress(0, 1, 0)); + OUString aCellStyleA2 = pFormatA2->GetCellStyle(aCellA2, ScAddress(0, 1, 0)); + CPPUNIT_ASSERT(!aCellStyleA2.isEmpty()); + + ScRefCellValue aCellA3(rDoc, ScAddress(0, 2, 0)); + OUString aCellStyleA3 = pFormatA3->GetCellStyle(aCellA3, ScAddress(0, 2, 0)); + CPPUNIT_ASSERT(!aCellStyleA3.isEmpty()); + + ScRefCellValue aCellA4(rDoc, ScAddress(0, 3, 0)); + OUString aCellStyleA4 = pFormatA4->GetCellStyle(aCellA4, ScAddress(0, 3, 0)); + CPPUNIT_ASSERT(!aCellStyleA4.isEmpty()); + + xDocSh->DoClose(); +} + void ScFiltersTest::testUpdateCircleInMergedCellODS() { ScDocShellRef xDocSh = loadDoc("updateCircleInMergedCell.", FORMAT_ODS); diff --git a/sc/source/filter/oox/extlstcontext.cxx b/sc/source/filter/oox/extlstcontext.cxx index fadb4365265b..b413e9e58029 100644 --- a/sc/source/filter/oox/extlstcontext.cxx +++ b/sc/source/filter/oox/extlstcontext.cxx @@ -135,6 +135,16 @@ ContextHandlerRef ExtConditionalFormattingContext::onCreateContext(sal_Int32 nEl eOperator = CondFormatBuffer::convertToInternalOperator(aToken); return this; } + else if(aType == "containsText") + { + eOperator = ScConditionMode::ContainsText; + return this; + } + else if(aType == "notContainsText") + { + eOperator = ScConditionMode::NotContainsText; + return this; + } else { SAL_WARN("sc", "unhandled XLS14_TOKEN(cfRule) with type: " << aType); @@ -181,7 +191,8 @@ void ExtConditionalFormattingContext::onEndElement() { case XM_TOKEN(f): { - rFormulas.push_back(aChars); + if(!aChars.startsWith("ISERROR(SEARCH(") && !aChars.startsWith("NOT(ISERROR(SEARCH(")) + rFormulas.push_back(aChars); } break; case XLS14_TOKEN( cfRule ): _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits