summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2017-04-22 10:10:00 -0400
committerKohei Yoshida <libreoffice@kohei.us>2017-04-25 01:48:16 +0200
commite4f28aea21ce7e8f960cc2062f83715549be215e (patch)
tree6858630a61dc31f4691df945ec88fa88a5e076d1
parent7c80ea40fab3cb8e8893d14e80e7bb7f63f0dbb0 (diff)
tdf#107310: add unit test for this.
I decided to add this to the filters test since it's the ods import code that sets the cells in hybrid "zero as empty string" mode. Change-Id: Icb34733e8550b655fbd70be718af5006b257a3e3 Reviewed-on: https://gerrit.libreoffice.org/36818 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Kohei Yoshida <libreoffice@kohei.us>
-rw-r--r--sc/qa/unit/data/ods/custom-numfmt-hybrid-cell.odsbin0 -> 7823 bytes
-rw-r--r--sc/qa/unit/subsequent_filters-test.cxx33
2 files changed, 33 insertions, 0 deletions
diff --git a/sc/qa/unit/data/ods/custom-numfmt-hybrid-cell.ods b/sc/qa/unit/data/ods/custom-numfmt-hybrid-cell.ods
new file mode 100644
index 000000000000..1e3fac470137
--- /dev/null
+++ b/sc/qa/unit/data/ods/custom-numfmt-hybrid-cell.ods
Binary files differ
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index 177d84185d6a..93853a4c68ce 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -205,6 +205,7 @@ public:
void testRichTextContentODS();
void testMiscRowHeights();
void testOptimalHeightReset();
+ void testCustomNumFormatHybridCellODS();
void testPrintRangeODS();
void testOutlineODS();
@@ -323,6 +324,7 @@ public:
CPPUNIT_TEST(testMiscRowHeights);
CPPUNIT_TEST(testOptimalHeightReset);
+ CPPUNIT_TEST(testCustomNumFormatHybridCellODS);
CPPUNIT_TEST(testPrintRangeODS);
CPPUNIT_TEST(testOutlineODS);
CPPUNIT_TEST(testColumnStyleXLSX);
@@ -3146,6 +3148,37 @@ void ScFiltersTest::testOptimalHeightReset()
xDocSh->DoClose();
}
+void ScFiltersTest::testCustomNumFormatHybridCellODS()
+{
+ ScDocShellRef xDocSh = loadDoc("custom-numfmt-hybrid-cell.", FORMAT_ODS, false);
+ ScDocument& rDoc = xDocSh->GetDocument();
+ rDoc.SetAutoCalc(true);
+
+ // All of B14, B16 and B18 should be displaying empty strings by virture
+ // of the custom number format being set on those cells.
+
+ for (SCROW nRow : {13, 15, 17})
+ {
+ ScAddress aPos(1, nRow, 0);
+ OUString aStr = rDoc.GetString(aPos);
+ CPPUNIT_ASSERT(aStr.isEmpty());
+ }
+
+ // Now, set value of 1 to B15. This should trigger re-calc on B18 and B18
+ // should now show a value of 1.
+ rDoc.SetValue(ScAddress(1,15,0), 1.0);
+
+ OUString aStr = rDoc.GetString(ScAddress(1,17,0));
+ CPPUNIT_ASSERT_EQUAL(OUString("1"), aStr);
+
+ // Make sure the cell doesn't have an error value.
+ ScFormulaCell* pFC = rDoc.GetFormulaCell(ScAddress(1,17,0));
+ CPPUNIT_ASSERT(pFC);
+ CPPUNIT_ASSERT(pFC->GetErrCode() == FormulaError::NONE);
+
+ xDocSh->DoClose();
+}
+
void ScFiltersTest::testPrintRangeODS()
{
ScDocShellRef xDocSh = loadDoc("print-range.", FORMAT_ODS);