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

Daniel Bankston dbank at kemper.freedesktop.org
Wed Jul 11 11:12:30 PDT 2012


 sc/qa/unit/data/ods/volatile.ods       |binary
 sc/qa/unit/subsequent_filters-test.cxx |   24 ++++++++++++++++++++++++
 sc/source/core/data/cell.cxx           |    4 ++++
 sc/source/filter/xml/xmlcelli.cxx      |   33 +++++++++++++++------------------
 sc/source/filter/xml/xmlcelli.hxx      |    2 ++
 sc/source/ui/docshell/docsh.cxx        |    2 ++
 6 files changed, 47 insertions(+), 18 deletions(-)

New commits:
commit 58d870236487e09a7ffd6676854306d90ff5b31a
Author: Daniel Bankston <daniel.e.bankston at gmail.com>
Date:   Wed Jul 11 01:54:46 2012 -0500

    Add test for volatile functions for ODS import
    
    Change-Id: If2f85e32ddeb9f25b4a355ce5451dc04925bbbc9

diff --git a/sc/qa/unit/data/ods/volatile.ods b/sc/qa/unit/data/ods/volatile.ods
new file mode 100644
index 0000000..6278de7
Binary files /dev/null and b/sc/qa/unit/data/ods/volatile.ods differ
diff --git a/sc/qa/unit/subsequent_filters-test.cxx b/sc/qa/unit/subsequent_filters-test.cxx
index 537b565..1ebb359 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 testVolatileFunctionsODS();
     void testCachedMatrixFormulaResultsODS();
     void testDatabaseRangesODS();
     void testDatabaseRangesXLS();
@@ -137,6 +138,7 @@ public:
     CPPUNIT_TEST(testHardRecalcODS);
     CPPUNIT_TEST(testFunctionsODS);
     CPPUNIT_TEST(testCachedFormulaResultsODS);
+    CPPUNIT_TEST(testVolatileFunctionsODS);
     CPPUNIT_TEST(testCachedMatrixFormulaResultsODS);
     CPPUNIT_TEST(testDatabaseRangesODS);
     CPPUNIT_TEST(testDatabaseRangesXLS);
@@ -378,6 +380,28 @@ void ScFiltersTest::testCachedFormulaResultsODS()
     xDocSh->DoClose();
 }
 
+void ScFiltersTest::testVolatileFunctionsODS()
+{
+    const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("volatile."));
+    ScDocShellRef xDocSh = loadDoc( aFileNameBase, ODS );
+
+    CPPUNIT_ASSERT_MESSAGE("Failed to load volatile.ods", xDocSh.Is());
+    ScDocument* pDoc = xDocSh->GetDocument();
+
+    //we want to me sure that volatile functions are always recalculated
+    //regardless of cached results.  if you update the ods file, you must
+    //update the values here.
+    //if NOW() is recacluated, then it should never equal sTodayCache
+    OUString sTodayCache("07/11/12 12:28 AM");
+    OUString sTodayRecalc(pDoc->GetString(0,1,0));
+    CPPUNIT_ASSERT(sTodayCache != sTodayRecalc);
+
+    OUString sTodayRecalcRef(pDoc->GetString(2,1,0));
+    CPPUNIT_ASSERT(sTodayCache != sTodayRecalcRef);
+
+    xDocSh->DoClose();
+}
+
 void ScFiltersTest::testCachedMatrixFormulaResultsODS()
 {
     const rtl::OUString aFileNameBase(RTL_CONSTASCII_USTRINGPARAM("matrix."));
commit e559d58ffcf0fa0019b0ae001786d021af79813b
Author: Daniel Bankston <daniel.e.bankston at gmail.com>
Date:   Tue Jul 10 23:54:03 2012 -0500

    Always Recalc volatile formula cells in import
    
    -Previous method was flawed. It actually works now.
    -Thanks to Kohei and Markus for helping me with this.
    -Thanks to Markus for finally coming up with the actual solution.
    
    Change-Id: Iad28da12c548c583df14ab7d71f4cee8ccc3552a

diff --git a/sc/source/core/data/cell.cxx b/sc/source/core/data/cell.cxx
index 338b0ab..421f401 100644
--- a/sc/source/core/data/cell.cxx
+++ b/sc/source/core/data/cell.cxx
@@ -1099,6 +1099,10 @@ void ScFormulaCell::CompileXML( ScProgress& rProgress )
     //  (for macro warning, CompileXML is called at the end of loading XML file)
     if ( !pDocument->GetHasMacroFunc() && pCode->HasOpCodeRPN( ocMacro ) )
         pDocument->SetHasMacroFunc( true );
+
+    //volatile cells must be added here for import
+    if( pCode->IsRecalcModeAlways() )
+        pDocument->PutInFormulaTree(this);
 }
 
 
diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx
index e78ec68..53adbc2 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -749,8 +749,7 @@ void ScXMLTableRowCellContext::SetFormulaCell(ScFormulaCell* pFCell) const
             pFCell->SetHybridString( *pOUTextValue );
         else
             pFCell->SetHybridDouble( fValue );
-        if( !pFCell->GetCode()->IsRecalcModeAlways() )
-            pFCell->ResetDirty();
+        pFCell->ResetDirty();
     }
 }
 
@@ -773,8 +772,7 @@ void ScXMLTableRowCellContext::AddTextCellToDoc( const ScAddress& rCurrentPos,
                 pFCell->SetHybridString( *pOUText );
             else
                 bDoIncrement = false;
-            if( !pFCell->GetCode()->IsRecalcModeAlways() )
-                pFCell->ResetDirty();
+            pFCell->ResetDirty();
         }
     }
     else
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index 6c3bb24..838fd13 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -458,6 +458,8 @@ sal_Bool ScDocShell::LoadXML( SfxMedium* pLoadMedium, const ::com::sun::star::un
     rtl::OUString sGenerator(xDocProps->getGenerator());
     if(sGenerator.indexOf(SC_LIBO_PROD_NAME) == -1)
         DoHardRecalc(false);
+    else //still need to recalc volatile formula cells
+        DoRecalc(false);
 
     aDocument.SetXMLFromWrapper( false );
     AfterXMLLoading(bRet);
commit 1f7b58aeb1cfd2428c185108133606fb894ca04f
Author: Daniel Bankston <daniel.e.bankston at gmail.com>
Date:   Tue Jul 10 15:11:35 2012 -0500

    Reduce some redundant code
    
    Change-Id: I23bf34793c8a1409c8753f572a6122dee2f4128f

diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx
index 99f00bd..e78ec68 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -741,6 +741,19 @@ void ScXMLTableRowCellContext::SetCellRangeSource( const ScAddress& rPosition )
     }
 }
 
+void ScXMLTableRowCellContext::SetFormulaCell(ScFormulaCell* pFCell) const
+{
+    if(pFCell)
+    {
+        if( bFormulaTextResult && pOUTextValue && !pOUTextValue->isEmpty() )
+            pFCell->SetHybridString( *pOUTextValue );
+        else
+            pFCell->SetHybridDouble( fValue );
+        if( !pFCell->GetCode()->IsRecalcModeAlways() )
+            pFCell->ResetDirty();
+    }
+}
+
 void ScXMLTableRowCellContext::AddTextCellToDoc( const ScAddress& rCurrentPos,
         const SCCOL nCurrentCol, const ::boost::optional< rtl::OUString >& pOUText )
 {
@@ -795,12 +808,7 @@ void ScXMLTableRowCellContext::AddNumberCellToDoc( const ScAddress& rCurrentPos
         if ( pCell && pCell->GetCellType() == CELLTYPE_FORMULA )
         {
             ScFormulaCell* pFCell = static_cast<ScFormulaCell*>(pCell);
-            if( bFormulaTextResult && pOUTextValue && !pOUTextValue->isEmpty() )
-                pFCell->SetHybridString( *pOUTextValue );
-            else
-                pFCell->SetHybridDouble( fValue );
-            if( !pFCell->GetCode()->IsRecalcModeAlways() )
-                pFCell->ResetDirty();
+            SetFormulaCell(pFCell);
         }
     }
     else
@@ -1027,12 +1035,7 @@ void ScXMLTableRowCellContext::AddNonMatrixFormulaCell( const ScAddress& rCellPo
             delete pCode;
 
             ScFormulaCell* pFCell = static_cast<ScFormulaCell*>(pNewCell);
-            if( bFormulaTextResult && pOUTextValue && !pOUTextValue->isEmpty() )
-                pFCell->SetHybridString( *pOUTextValue );
-            else
-                pFCell->SetHybridDouble( fValue );
-            if( !(pFCell->GetCode()->IsRecalcModeOnLoad() || !pFCell->GetCode()->IsRecalcModeOnLoadOnce()) )
-                pFCell->ResetDirty();
+            SetFormulaCell(pFCell);
         }
         else if ( aText[0] == '\'' && aText.getLength() > 1 )
         {
@@ -1078,15 +1081,7 @@ void ScXMLTableRowCellContext::AddFormulaCell( const ScAddress& rCellPos )
                 //add the cached formula result of the first matrix position
                 ScFormulaCell* pFCell =
                     static_cast<ScFormulaCell*>( rXMLImport.GetDocument()->GetCell(rCellPos) );
-                if(pFCell)
-                {
-                    if( bFormulaTextResult && pOUTextValue && !pOUTextValue->isEmpty() )
-                        pFCell->SetHybridString( *pOUTextValue );
-                    else
-                        pFCell->SetHybridDouble( fValue );
-                    if( !pFCell->GetCode()->IsRecalcModeAlways() )
-                        pFCell->ResetDirty();
-                }
+                SetFormulaCell(pFCell);
             }
         }
         else
diff --git a/sc/source/filter/xml/xmlcelli.hxx b/sc/source/filter/xml/xmlcelli.hxx
index 3df155e..9b038c6 100644
--- a/sc/source/filter/xml/xmlcelli.hxx
+++ b/sc/source/filter/xml/xmlcelli.hxx
@@ -45,6 +45,7 @@
 #include <boost/optional.hpp>
 
 class ScXMLImport;
+class ScFormulaCell;
 struct ScXMLAnnotationData;
 
 class ScXMLTableRowCellContext : public SvXMLImportContext
@@ -90,6 +91,7 @@ class ScXMLTableRowCellContext : public SvXMLImportContext
     bool HasSpecialContent() const;
     bool CellsAreRepeated() const;
 
+    void SetFormulaCell             ( ScFormulaCell* pFCell ) const;
     void AddTextCellToDoc           ( const ScAddress& rScCurrentPos, const SCCOL nCurrentCol,
                                       const ::boost::optional< rtl::OUString >& pOUText );
     void AddNumberCellToDoc         ( const ScAddress& rScCurrentPos );
commit 2f21028dd24f0b3883ad50cae9e1a577faa19c13
Author: Daniel Bankston <daniel.e.bankston at gmail.com>
Date:   Tue Jul 10 13:55:39 2012 -0500

    Always recalc certain functions on import
    
    Change-Id: Ie8cffc4a856328dd658714726de7ca77028a33a7

diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx
index fc20f36..99f00bd 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -760,7 +760,8 @@ void ScXMLTableRowCellContext::AddTextCellToDoc( const ScAddress& rCurrentPos,
                 pFCell->SetHybridString( *pOUText );
             else
                 bDoIncrement = false;
-            pFCell->ResetDirty();
+            if( !pFCell->GetCode()->IsRecalcModeAlways() )
+                pFCell->ResetDirty();
         }
     }
     else
@@ -798,7 +799,8 @@ void ScXMLTableRowCellContext::AddNumberCellToDoc( const ScAddress& rCurrentPos
                 pFCell->SetHybridString( *pOUTextValue );
             else
                 pFCell->SetHybridDouble( fValue );
-            pFCell->ResetDirty();
+            if( !pFCell->GetCode()->IsRecalcModeAlways() )
+                pFCell->ResetDirty();
         }
     }
     else
@@ -1029,7 +1031,8 @@ void ScXMLTableRowCellContext::AddNonMatrixFormulaCell( const ScAddress& rCellPo
                 pFCell->SetHybridString( *pOUTextValue );
             else
                 pFCell->SetHybridDouble( fValue );
-            pFCell->ResetDirty();
+            if( !(pFCell->GetCode()->IsRecalcModeOnLoad() || !pFCell->GetCode()->IsRecalcModeOnLoadOnce()) )
+                pFCell->ResetDirty();
         }
         else if ( aText[0] == '\'' && aText.getLength() > 1 )
         {
@@ -1081,7 +1084,8 @@ void ScXMLTableRowCellContext::AddFormulaCell( const ScAddress& rCellPos )
                         pFCell->SetHybridString( *pOUTextValue );
                     else
                         pFCell->SetHybridDouble( fValue );
-                    pFCell->ResetDirty();
+                    if( !pFCell->GetCode()->IsRecalcModeAlways() )
+                        pFCell->ResetDirty();
                 }
             }
         }


More information about the Libreoffice-commits mailing list