[Libreoffice-commits] core.git: Branch 'distro/nisz/libreoffice-7-0' - sc/qa sc/source
Tibor Nagy (via logerrit)
logerrit at kemper.freedesktop.org
Wed Mar 3 07:39:11 UTC 2021
sc/qa/unit/data/xlsx/tdf120749.xlsx |binary
sc/qa/unit/subsequent_filters-test.cxx | 38 +++++++++++++++++++++++++++++++++
sc/source/filter/inc/extlstcontext.hxx | 1
sc/source/filter/oox/extlstcontext.cxx | 33 +++++++++++++++++++++++++++-
4 files changed, 71 insertions(+), 1 deletion(-)
New commits:
commit dfe64f1a4cafb5afa8fa00e4901a65f1fa92c77c
Author: Tibor Nagy <nagy.tibor2 at nisz.hu>
AuthorDate: Sun Dec 20 19:45:50 2020 +0100
Commit: Gabor Kelemen <kelemen.gabor2 at nisz.hu>
CommitDate: Wed Mar 3 08:38:39 2021 +0100
tdf#120749 XLSX: fix "begins/ends with" conditional
formatting when using "Given text" type and cell reference.
Follow-up of commit 583e2bfba2d72ac8afe7261c23f380daf5486889
(tdf#139021 XLSX export: fix "contains" conditional formatting).
Co-authored-by: Attila Szűcs (NISZ)
Change-Id: Idf5d46469765454a11311bd6ec1d85c85b89e26f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108058
Tested-by: László Németh <nemeth at numbertext.org>
Reviewed-by: László Németh <nemeth at numbertext.org>
(cherry picked from commit 879ea123514ce6808212dfbef7e1d226e9d5fd9b)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108592
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli at libreoffice.org>
(cherry picked from commit 75596e1254f284fca22efc8e6cba158bd6c50b15)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111872
Tested-by: Gabor Kelemen <kelemen.gabor2 at nisz.hu>
Reviewed-by: Gabor Kelemen <kelemen.gabor2 at nisz.hu>
diff --git a/sc/qa/unit/data/xlsx/tdf120749.xlsx b/sc/qa/unit/data/xlsx/tdf120749.xlsx
new file mode 100644
index 000000000000..de601234d3be
Binary files /dev/null and b/sc/qa/unit/data/xlsx/tdf120749.xlsx differ
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index 66c092276e3d..5f7dcf412d9e 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 testCondFormatBeginsAndEndsWithXLSX();
void testExtCondFormatXLSX();
void testUpdateCircleInMergedCellODS();
void testDeleteCircleInMergedCellODS();
@@ -276,6 +277,7 @@ public:
void testDeleteCirclesInRowAndCol();
CPPUNIT_TEST_SUITE(ScFiltersTest);
+ CPPUNIT_TEST(testCondFormatBeginsAndEndsWithXLSX);
CPPUNIT_TEST(testExtCondFormatXLSX);
CPPUNIT_TEST(testUpdateCircleInMergedCellODS);
CPPUNIT_TEST(testDeleteCircleInMergedCellODS);
@@ -490,6 +492,42 @@ void testRangeNameImpl(const ScDocument& rDoc)
}
+void ScFiltersTest::testCondFormatBeginsAndEndsWithXLSX()
+{
+ ScDocShellRef xDocSh = loadDoc("tdf120749.", FORMAT_XLSX);
+ CPPUNIT_ASSERT_MESSAGE("Failed to load tdf120749.xlsx", xDocSh.is());
+
+ ScDocument& rDoc = xDocSh->GetDocument();
+
+ // begins with and ends with 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::testExtCondFormatXLSX()
{
ScDocShellRef xDocSh = loadDoc("tdf122102.", FORMAT_XLSX);
diff --git a/sc/source/filter/inc/extlstcontext.hxx b/sc/source/filter/inc/extlstcontext.hxx
index 4c7b697299e8..8e4f3e5278b8 100644
--- a/sc/source/filter/inc/extlstcontext.hxx
+++ b/sc/source/filter/inc/extlstcontext.hxx
@@ -52,6 +52,7 @@ public:
virtual void onEndElement() override;
private:
+ sal_Int32 nFormulaCount;
OUString aChars; // Characters of between xml elements.
OUString rStyle; // Style of the corresponding condition
sal_Int32 nPriority; // Priority of last cfRule element.
diff --git a/sc/source/filter/oox/extlstcontext.cxx b/sc/source/filter/oox/extlstcontext.cxx
index 0a694e00fd2d..2f0c6c475c9a 100644
--- a/sc/source/filter/oox/extlstcontext.cxx
+++ b/sc/source/filter/oox/extlstcontext.cxx
@@ -80,8 +80,26 @@ void ExtCfRuleContext::onStartElement( const AttributeList& rAttribs )
}
}
+namespace {
+ bool IsSpecificTextCondMode(ScConditionMode eMode)
+ {
+ switch (eMode)
+ {
+ case ScConditionMode::BeginsWith:
+ case ScConditionMode::EndsWith:
+ case ScConditionMode::ContainsText:
+ case ScConditionMode::NotContainsText:
+ return true;
+ default:
+ break;
+ }
+ return false;
+ }
+}
+
ExtConditionalFormattingContext::ExtConditionalFormattingContext(WorksheetContextBase& rFragment)
: WorksheetContextBase(rFragment)
+ , nFormulaCount(0)
, nPriority(-1)
, eOperator(ScConditionMode::NONE)
, isPreviousElementF(false)
@@ -145,6 +163,16 @@ ContextHandlerRef ExtConditionalFormattingContext::onCreateContext(sal_Int32 nEl
eOperator = ScConditionMode::NotContainsText;
return this;
}
+ else if(aType == "beginsWith")
+ {
+ eOperator = ScConditionMode::BeginsWith;
+ return this;
+ }
+ else if(aType == "endsWith")
+ {
+ eOperator = ScConditionMode::EndsWith;
+ return this;
+ }
else
{
SAL_WARN("sc", "unhandled XLS14_TOKEN(cfRule) with type: " << aType);
@@ -156,6 +184,8 @@ ContextHandlerRef ExtConditionalFormattingContext::onCreateContext(sal_Int32 nEl
}
else if (nElement == XM_TOKEN( sqref ) || nElement == XM_TOKEN( f ))
{
+ if(nElement == XM_TOKEN( f ))
+ nFormulaCount++;
return this;
}
@@ -191,13 +221,14 @@ void ExtConditionalFormattingContext::onEndElement()
{
case XM_TOKEN(f):
{
- if(!aChars.startsWith("ISERROR(SEARCH(") && !aChars.startsWith("NOT(ISERROR(SEARCH("))
+ if(!IsSpecificTextCondMode(eOperator) || nFormulaCount == 2)
rFormulas.push_back(aChars);
}
break;
case XLS14_TOKEN( cfRule ):
{
getStyles().getExtDxfs().forEachMem( &Dxf::finalizeImport );
+ nFormulaCount = 0;
}
break;
case XM_TOKEN(sqref):
More information about the Libreoffice-commits
mailing list