[Libreoffice-commits] .: Branch 'feature/gsoc-calc-perf2' - 2 commits - sc/qa sc/source

Daniel Bankston dbank at kemper.freedesktop.org
Sun Jul 8 10:58:47 PDT 2012


 sc/qa/unit/data/contentCSV/matrix2.csv |    2 ++
 sc/qa/unit/data/ods/matrix.ods         |binary
 sc/qa/unit/subsequent_filters-test.cxx |   23 ++++++++++++++++++++++-
 sc/source/filter/xml/xmlcelli.cxx      |   31 +++++++++++++++++--------------
 4 files changed, 41 insertions(+), 15 deletions(-)

New commits:
commit 191c4bf8a6ee43bbac25f5a0f83181c74fac8390
Author: Daniel Bankston <daniel.e.bankston at gmail.com>
Date:   Sun Jul 8 12:57:36 2012 -0500

    Fix problem with cached matrix formula results that contain errors
    
    Change-Id: I9277714780e00e311e6e81a9de6e4d39409d5c9b

diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx
index 67ca9c7..e5c81e0 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -795,7 +795,10 @@ void ScXMLTableRowCellContext::AddNumberCellToDoc( const ScAddress& rCurrentPos
         if ( pCell && pCell->GetCellType() == CELLTYPE_FORMULA )
         {
             ScFormulaCell* pFCell = static_cast<ScFormulaCell*>(pCell);
-            pFCell->SetHybridDouble( fValue );
+            if( bFormulaTextResult && pOUTextValue && !pOUTextValue->isEmpty() )
+                pFCell->SetHybridString( *pOUTextValue );
+            else
+                pFCell->SetHybridDouble( fValue );
             pFCell->ResetDirty();
         }
     }
@@ -1052,15 +1055,6 @@ void ScXMLTableRowCellContext::AddNonMatrixFormulaCell( const ScAddress& rCellPo
     }
 }
 
-namespace{
-
-bool isErrOrNA(const rtl::OUString& rStr)
-{
-    return (rStr.indexOf("Err:")  > -1) || (rStr.indexOf("#N/A") > -1);
-}
-
-}
-
 void ScXMLTableRowCellContext::AddFormulaCell( const ScAddress& rCellPos )
 {
     if( cellExists(rCellPos) )
@@ -1069,10 +1063,6 @@ void ScXMLTableRowCellContext::AddFormulaCell( const ScAddress& rCellPos )
         OSL_ENSURE(((nColsRepeated == 1) && (nRepeatedRows == 1)), "repeated cells with formula not possible now");
         rXMLImport.GetStylesImportHelper()->AddCell(rCellPos);
 
-        //if this is an "Err:###" or "#N/A" then use text:p value
-        if( bFormulaTextResult && pOUTextContent && isErrOrNA(*pOUTextContent) )
-            pOUTextValue.reset(*pOUTextContent);
-
         //add matrix
         if(bIsMatrix)
         {
@@ -1115,6 +1105,15 @@ void ScXMLTableRowCellContext::AddFormulaCell( const ScAddress& rCellPos )
     }
 }
 
+namespace{
+
+bool isErrOrNA(const rtl::OUString& rStr)
+{
+    return (rStr.indexOf("Err:")  > -1) || (rStr.indexOf("#N/A") > -1);
+}
+
+}
+
 void ScXMLTableRowCellContext::EndElement()
 {
     if( bHasTextImport && rXMLImport.GetRemoveLastChar() )
@@ -1131,6 +1130,10 @@ void ScXMLTableRowCellContext::EndElement()
         }
     }
 
+    //if this is an "Err:###" or "#N/A" then use text:p value
+    if( bFormulaTextResult && pOUTextContent && isErrOrNA(*pOUTextContent) )
+        pOUTextValue.reset(*pOUTextContent);
+
     ScAddress aCellPos = rXMLImport.GetTables().GetCurrentCellPos();
     if( aCellPos.Col() > 0 && nRepeatedRows > 1 )
         aCellPos.SetRow( aCellPos.Row() - (nRepeatedRows - 1) );
commit 8fd6bdaa4fcffce595675f79e2e75bc8a795e0c2
Author: Daniel Bankston <daniel.e.bankston at gmail.com>
Date:   Sun Jul 8 12:45:52 2012 -0500

    Add test for cached matrix formula results
    
    -Includes test case for cached formula result errors
    
    Change-Id: I446240daffdbd6cd7ebd3c3b8dc2305c789d8519

diff --git a/sc/qa/unit/data/contentCSV/matrix2.csv b/sc/qa/unit/data/contentCSV/matrix2.csv
new file mode 100644
index 0000000..44b3f71
--- /dev/null
+++ b/sc/qa/unit/data/contentCSV/matrix2.csv
@@ -0,0 +1,2 @@
+Matrix with errors:,,
+Err:502,Err:502,Err:502
diff --git a/sc/qa/unit/data/ods/matrix.ods b/sc/qa/unit/data/ods/matrix.ods
index 3c9f16a..7b69691 100644
Binary files a/sc/qa/unit/data/ods/matrix.ods and b/sc/qa/unit/data/ods/matrix.ods differ
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index ce0133f..537b565 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -103,6 +103,7 @@ public:
     void testHardRecalcODS();
     void testFunctionsODS();
     void testCachedFormulaResultsODS();
+    void testCachedMatrixFormulaResultsODS();
     void testDatabaseRangesODS();
     void testDatabaseRangesXLS();
     void testDatabaseRangesXLSX();
@@ -136,6 +137,7 @@ public:
     CPPUNIT_TEST(testHardRecalcODS);
     CPPUNIT_TEST(testFunctionsODS);
     CPPUNIT_TEST(testCachedFormulaResultsODS);
+    CPPUNIT_TEST(testCachedMatrixFormulaResultsODS);
     CPPUNIT_TEST(testDatabaseRangesODS);
     CPPUNIT_TEST(testDatabaseRangesXLS);
     CPPUNIT_TEST(testDatabaseRangesXLSX);
@@ -313,7 +315,7 @@ void ScFiltersTest::testHardRecalcODS()
     ScDocShellRef xDocSh = loadDoc( aFileNameBase, ODS );
     xDocSh->DoHardRecalc(true);
 
-    CPPUNIT_ASSERT_MESSAGE("Failed to load functions.*", xDocSh.Is());
+    CPPUNIT_ASSERT_MESSAGE("Failed to load hard-recalc.*", xDocSh.Is());
     ScDocument* pDoc = xDocSh->GetDocument();
     rtl::OUString aCSVFileName;
 
@@ -376,6 +378,25 @@ void ScFiltersTest::testCachedFormulaResultsODS()
     xDocSh->DoClose();
 }
 
+void ScFiltersTest::testCachedMatrixFormulaResultsODS()
+{
+    const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("matrix."));
+    ScDocShellRef xDocSh = loadDoc( aFileNameBase, ODS);
+
+    CPPUNIT_ASSERT_MESSAGE("Failed to load matrix.*", xDocSh.Is());
+    ScDocument* pDoc = xDocSh->GetDocument();
+
+    //test matrix
+    rtl::OUString aCSVFileName;
+    createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("matrix.")), aCSVFileName);
+    testFile(aCSVFileName, pDoc, 0);
+    //test matrix with errors
+    createCSVPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("matrix2.")), aCSVFileName);
+    testFile(aCSVFileName, pDoc, 1);
+
+    xDocSh->DoClose();
+}
+
 namespace {
 
 void testDBRanges_Impl(ScDocument* pDoc, sal_Int32 nFormat)


More information about the Libreoffice-commits mailing list