From e123c772db8a12a37dfa14370b9db7c220f33ef1 Mon Sep 17 00:00:00 2001 From: Paris Oplopoios Date: Thu, 26 Oct 2023 14:28:06 +0300 Subject: sc: Test numeric conditional format text rule exports correctly Change-Id: Ib57ea44912b4cb0be7cbdb127dd7ea6f08ec8392 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158498 Tested-by: Jenkins Reviewed-by: Paris Oplopoios --- sc/qa/unit/subsequent_export_test.cxx | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'sc') diff --git a/sc/qa/unit/subsequent_export_test.cxx b/sc/qa/unit/subsequent_export_test.cxx index 5f5132c299c2..035709a036ac 100644 --- a/sc/qa/unit/subsequent_export_test.cxx +++ b/sc/qa/unit/subsequent_export_test.cxx @@ -2153,6 +2153,37 @@ CPPUNIT_TEST_FIXTURE(ScExportTest, testSheetProtectionXLSB) CPPUNIT_ASSERT(!pTabProtect->isOptionEnabled(ScTableProtection::SELECT_LOCKED_CELLS)); } +CPPUNIT_TEST_FIXTURE(ScExportTest, testConditionalFormatNumberInTextRule) +{ + createScDoc(); + + ScDocument* pDocument = getScDoc(); + ScAddress aAddress(0, 0, 0); + + auto pFormat = std::make_unique(0, pDocument); + ScRange aCondFormatRange(aAddress); + ScRangeList aRangeList(aCondFormatRange); + pFormat->SetRange(aRangeList); + ScCondFormatEntry* pEntry + = new ScCondFormatEntry(ScConditionMode::BeginsWith, "15", "", *pDocument, aAddress, ""); + pFormat->AddEntry(pEntry); + pDocument->AddCondFormat(std::move(pFormat), 0); + + saveAndReload("Calc Office Open XML"); + pDocument = getScDoc(); + + ScConditionalFormat* pCondFormat = pDocument->GetCondFormat(0, 0, 0); + CPPUNIT_ASSERT(pCondFormat); + CPPUNIT_ASSERT_EQUAL(size_t(1), pCondFormat->size()); + const ScFormatEntry* pCondFormatEntry = pCondFormat->GetEntry(0); + CPPUNIT_ASSERT(pCondFormatEntry); + CPPUNIT_ASSERT_EQUAL(ScFormatEntry::Type::Condition, pCondFormatEntry->GetType()); + const ScConditionEntry* pConditionEntry + = static_cast(pCondFormatEntry); + CPPUNIT_ASSERT_EQUAL(ScConditionMode::BeginsWith, pConditionEntry->GetOperation()); + CPPUNIT_ASSERT_EQUAL(OUString("\"15\""), pConditionEntry->GetExpression(aAddress, 0)); +} + namespace { const char* toBorderName(SvxBorderLineStyle eStyle) -- cgit