[Libreoffice-commits] core.git: Branch 'private/kohei/xlsx-import-speedup' - sc/qa

Kohei Yoshida kohei.yoshida at collabora.com
Mon Nov 11 08:26:58 PST 2013


 sc/qa/unit/data/xlsx/functions-excel-2010.xlsx |binary
 sc/qa/unit/helper/qahelper.cxx                 |    9 +++++++++
 sc/qa/unit/helper/qahelper.hxx                 |    6 ++++++
 sc/qa/unit/subsequent_filters-test.cxx         |   23 +++++++++++++++++++++++
 4 files changed, 38 insertions(+)

New commits:
commit dbd1a5477b07669b563a48699c3e38c1ba49750b
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Mon Nov 11 11:26:30 2013 -0500

    Add test for importing some of those functions new in Excel 2010.
    
    Change-Id: Ic3577b3ef0edcfa417ae0065499171bf770c2a32

diff --git a/sc/qa/unit/data/xlsx/functions-excel-2010.xlsx b/sc/qa/unit/data/xlsx/functions-excel-2010.xlsx
new file mode 100755
index 0000000..03e570e
Binary files /dev/null and b/sc/qa/unit/data/xlsx/functions-excel-2010.xlsx differ
diff --git a/sc/qa/unit/helper/qahelper.cxx b/sc/qa/unit/helper/qahelper.cxx
index b212846..ccd4263 100644
--- a/sc/qa/unit/helper/qahelper.cxx
+++ b/sc/qa/unit/helper/qahelper.cxx
@@ -430,6 +430,15 @@ bool checkFormula(ScDocument& rDoc, const ScAddress& rPos, const char* pExpected
     return true;
 }
 
+bool isFormulaWithoutError(ScDocument& rDoc, const ScAddress& rPos)
+{
+    ScFormulaCell* pFC = rDoc.GetFormulaCell(rPos);
+    if (!pFC)
+        return false;
+
+    return pFC->GetErrCode() == 0;
+}
+
 OUString toString(
     ScDocument& rDoc, const ScAddress& rPos, ScTokenArray& rArray, formula::FormulaGrammar::Grammar eGram)
 {
diff --git a/sc/qa/unit/helper/qahelper.hxx b/sc/qa/unit/helper/qahelper.hxx
index a6d5a02..657f66b 100644
--- a/sc/qa/unit/helper/qahelper.hxx
+++ b/sc/qa/unit/helper/qahelper.hxx
@@ -121,6 +121,12 @@ SCQAHELPER_DLLPUBLIC ScRangeList getChartRanges(ScDocument& rDoc, const SdrOle2O
 SCQAHELPER_DLLPUBLIC bool checkFormula(ScDocument& rDoc, const ScAddress& rPos, const char* pExpected);
 
 /**
+ * Check if the cell at specified position is a formula cell that doesn't
+ * have an error value.
+ */
+SCQAHELPER_DLLPUBLIC bool isFormulaWithoutError(ScDocument& rDoc, const ScAddress& rPos);
+
+/**
  * Convert formula token array to a formula string.
  */
 SCQAHELPER_DLLPUBLIC OUString toString(
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index 4f7d702..b2dc2b6 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -87,6 +87,7 @@ public:
     void testRangeNameXLSX();
     void testHardRecalcODS();
     void testFunctionsODS();
+    void testFunctionsExcel2010();
     void testCachedFormulaResultsODS();
     void testCachedMatrixFormulaResultsODS();
     void testDatabaseRangesODS();
@@ -155,6 +156,7 @@ public:
     CPPUNIT_TEST(testRangeNameXLSX);
     CPPUNIT_TEST(testHardRecalcODS);
     CPPUNIT_TEST(testFunctionsODS);
+    CPPUNIT_TEST(testFunctionsExcel2010);
     CPPUNIT_TEST(testCachedFormulaResultsODS);
     CPPUNIT_TEST(testCachedMatrixFormulaResultsODS);
     CPPUNIT_TEST(testDatabaseRangesODS);
@@ -371,6 +373,27 @@ void ScFiltersTest::testFunctionsODS()
     xDocSh->DoClose();
 }
 
+void ScFiltersTest::testFunctionsExcel2010()
+{
+    ScDocShellRef xDocSh = loadDoc("functions-excel-2010.", XLSX);
+    CPPUNIT_ASSERT_MESSAGE("Failed to load the document.", xDocSh.Is());
+    ScDocument* pDoc = xDocSh->GetDocument();
+    pDoc->CalcAll(); // perform hard re-calculation.
+
+    // B2:B6 and B8 should all be formula cells, and shouldn't have errors.
+    CPPUNIT_ASSERT_MESSAGE("Expected a formula cell without errro.", isFormulaWithoutError(*pDoc, ScAddress(1,1,0)));
+    CPPUNIT_ASSERT_MESSAGE("Expected a formula cell without errro.", isFormulaWithoutError(*pDoc, ScAddress(1,2,0)));
+    CPPUNIT_ASSERT_MESSAGE("Expected a formula cell without errro.", isFormulaWithoutError(*pDoc, ScAddress(1,3,0)));
+    CPPUNIT_ASSERT_MESSAGE("Expected a formula cell without errro.", isFormulaWithoutError(*pDoc, ScAddress(1,4,0)));
+#if 0 // CHISQ.TEST and F.DIST.RT are not yet supported in the core.
+    CPPUNIT_ASSERT_MESSAGE("Expected a formula cell without errro.", isFormulaWithoutError(*pDoc, ScAddress(1,5,0)));
+    // Skip B7.
+    CPPUNIT_ASSERT_MESSAGE("Expected a formula cell without errro.", isFormulaWithoutError(*pDoc, ScAddress(1,7,0)));
+#endif
+
+    xDocSh->DoClose();
+}
+
 void ScFiltersTest::testCachedFormulaResultsODS()
 {
     {


More information about the Libreoffice-commits mailing list