summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2013-12-05 09:29:35 -0500
committerKohei Yoshida <kohei.yoshida@collabora.com>2013-12-05 09:31:07 -0500
commit830a7f501b12c1c34753a656491050a252043974 (patch)
tree81a80f523bf9ff6d20d6461343cc0f1425a5e926 /sc
parent52bcb7e80a8e0f38fedd1a991fdcd4bce03d30da (diff)
New test document to handle Excel's wrong shared formula range.
This is but just one example out of many out in the wild... Change-Id: Ia542cff0e583bdcc397d0ee6ee3eaaa84f64fe4f
Diffstat (limited to 'sc')
-rw-r--r--sc/qa/unit/data/xls/shared-formula-gap.xlsbin0 -> 13824 bytes
-rw-r--r--sc/qa/unit/filters-test.cxx34
2 files changed, 33 insertions, 1 deletions
diff --git a/sc/qa/unit/data/xls/shared-formula-gap.xls b/sc/qa/unit/data/xls/shared-formula-gap.xls
new file mode 100644
index 000000000000..762e3935f567
--- /dev/null
+++ b/sc/qa/unit/data/xls/shared-formula-gap.xls
Binary files differ
diff --git a/sc/qa/unit/filters-test.cxx b/sc/qa/unit/filters-test.cxx
index d12ea6098687..bec9f76d0dfd 100644
--- a/sc/qa/unit/filters-test.cxx
+++ b/sc/qa/unit/filters-test.cxx
@@ -349,8 +349,8 @@ void ScFiltersTest::testContentXLS_XML()
void ScFiltersTest::testSharedFormulaXLS()
{
ScDocShellRef xDocSh = loadDoc("shared-formula.", XLS);
+ CPPUNIT_ASSERT(xDocSh.Is());
ScDocument* pDoc = xDocSh->GetDocument();
- CPPUNIT_ASSERT(pDoc);
xDocSh->DoHardRecalc(true);
// Check the results of formula cells in the shared formula range.
for (SCROW i = 1; i <= 18; ++i)
@@ -367,6 +367,38 @@ void ScFiltersTest::testSharedFormulaXLS()
CPPUNIT_ASSERT_MESSAGE("Incorrect group geometry.", xGroup->mpTopCell->aPos.Row() == 1 && xGroup->mnLength == 18);
xDocSh->DoClose();
+
+ // The following file contains shared formula whose range is inaccurate.
+ // Excel can easily mess up shared formula ranges, so we need to be able
+ // to handle these wrong ranges that Excel stores.
+
+ xDocSh = loadDoc("shared-formula-gap.", XLS);
+ CPPUNIT_ASSERT(xDocSh.Is());
+ pDoc = xDocSh->GetDocument();
+ pDoc->CalcAll();
+
+ if (!checkFormula(*pDoc, ScAddress(1,0,0), "A1*20"))
+ CPPUNIT_FAIL("Wrong formula.");
+
+ if (!checkFormula(*pDoc, ScAddress(1,1,0), "A2*20"))
+ CPPUNIT_FAIL("Wrong formula.");
+
+ if (!checkFormula(*pDoc, ScAddress(1,2,0), "A3*20"))
+ CPPUNIT_FAIL("Wrong formula.");
+
+ // There is an intentional gap at row 4.
+
+ if (!checkFormula(*pDoc, ScAddress(1,4,0), "A5*20"))
+ CPPUNIT_FAIL("Wrong formula.");
+
+ if (!checkFormula(*pDoc, ScAddress(1,5,0), "A6*20"))
+ CPPUNIT_FAIL("Wrong formula.");
+
+ if (!checkFormula(*pDoc, ScAddress(1,6,0), "A7*20"))
+ CPPUNIT_FAIL("Wrong formula.");
+
+ if (!checkFormula(*pDoc, ScAddress(1,7,0), "A8*20"))
+ CPPUNIT_FAIL("Wrong formula.");
}
void ScFiltersTest::testSharedFormulaXLSX()