diff options
author | Daniel Bankston <daniel.e.bankston@gmail.com> | 2012-07-05 18:15:45 -0500 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-07-11 20:37:39 -0400 |
commit | f107e3a5f7cc19957435f1e90617105509394b4d (patch) | |
tree | eff9b1405b9b21bfad9fdc74ac04cc9fb9aeab27 | |
parent | 1cdfb19c2202b56e4de6f10104bb4841372956cb (diff) |
Use cached formula results instead of recalculating
This commit undoes some of previous commit in attempt to be less "hackish".
-When importing LibreOffice generated ODS documents, use cached formula
results instead of always recalcuating.
-For other generators, do hard-recalc.
Still need to:
-Stop matrix formula cells from being set dirty to avoid recalculating them.
-Implement special cases for functions that should always be recalculated.
Change-Id: I959872aa2f446b80f9204ee26e94de7140f1f6f9
-rw-r--r-- | sc/inc/document.hxx | 3 | ||||
-rw-r--r-- | sc/source/core/data/cell.cxx | 3 | ||||
-rw-r--r-- | sc/source/core/data/documen2.cxx | 1 | ||||
-rw-r--r-- | sc/source/core/data/document.cxx | 1 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlcelli.cxx | 9 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlimprt.cxx | 8 | ||||
-rw-r--r-- | sc/source/ui/docshell/docsh.cxx | 14 |
7 files changed, 18 insertions, 21 deletions
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index b5119e14da7a..72d5168bbc32 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -366,7 +366,6 @@ private: bool bInsertingFromOtherDoc; bool bLoadingMedium; bool bImportingXML; // special handling of formula text - bool bImportingLiboGenDoc; //to avoid recalculating formula results of libo generated docs bool bXMLFromWrapper; // distinguish ScXMLImportWrapper from external component bool bCalcingAfterLoad; // in CalcAfterLoad TRUE // don't construct/destruct listeners temporarily @@ -1560,8 +1559,6 @@ public: void SetLoadingMedium( bool bVal ); void SetImportingXML( bool bVal ); bool IsImportingXML() const { return bImportingXML; } - void SetImportingLiboGenDoc( bool bVal ) { bImportingLiboGenDoc = bVal; }; - bool IsImportingLiboGenDoc() const { return bImportingLiboGenDoc; } void SetXMLFromWrapper( bool bVal ); bool IsXMLFromWrapper() const { return bXMLFromWrapper; } void SetCalcingAfterLoad( bool bVal ) { bCalcingAfterLoad = bVal; } diff --git a/sc/source/core/data/cell.cxx b/sc/source/core/data/cell.cxx index e05cde7b9010..c4846c092d25 100644 --- a/sc/source/core/data/cell.cxx +++ b/sc/source/core/data/cell.cxx @@ -1827,8 +1827,7 @@ void ScFormulaCell::SetDirty() void ScFormulaCell::SetDirtyVar() { - if(!pDocument->IsImportingLiboGenDoc()) - bDirty = true; + bDirty = true; // mark the sheet of this cell to be calculated //#FIXME do we need to revert this remnant of old fake vba events? pDocument->AddCalculateTable( aPos.Tab() ); } diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx index 0921f20b5997..241985935641 100644 --- a/sc/source/core/data/documen2.cxx +++ b/sc/source/core/data/documen2.cxx @@ -188,7 +188,6 @@ ScDocument::ScDocument( ScDocumentMode eMode, bInsertingFromOtherDoc( false ), bLoadingMedium( false ), bImportingXML( false ), - bImportingLiboGenDoc( false ), bXMLFromWrapper( false ), bCalcingAfterLoad( false ), bNoListening( false ), diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx index 965f09c544db..f3724d539745 100644 --- a/sc/source/core/data/document.cxx +++ b/sc/source/core/data/document.cxx @@ -3410,7 +3410,6 @@ void ScDocument::CompileXML() if ( pValidationList ) pValidationList->CompileXML(); - SetDirty(); SetAutoCalc( bOldAutoCalc ); } diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx index 15535424e190..efd2c99f065a 100644 --- a/sc/source/filter/xml/xmlcelli.cxx +++ b/sc/source/filter/xml/xmlcelli.cxx @@ -757,8 +757,7 @@ void ScXMLTableRowCellContext::AddTextCellToDoc( const ScAddress& rCurrentPos, pFCell->SetHybridString( *pOUText ); else bDoIncrement = false; - if(rXMLImport.GetDocument()->IsImportingLiboGenDoc()) - pFCell->ResetDirty(); + pFCell->ResetDirty(); } } else @@ -793,8 +792,7 @@ void ScXMLTableRowCellContext::AddNumberCellToDoc( const ScAddress& rCurrentPos { ScFormulaCell* pFCell = static_cast<ScFormulaCell*>(pCell); pFCell->SetHybridDouble( fValue ); - if(rXMLImport.GetDocument()->IsImportingLiboGenDoc()) - pFCell->ResetDirty(); + pFCell->ResetDirty(); } } else @@ -1025,8 +1023,7 @@ void ScXMLTableRowCellContext::AddNonMatrixFormulaCell( const ScAddress& rCellPo pFCell->SetHybridString( *pOUTextValue ); else pFCell->SetHybridDouble( fValue ); - if(pDoc->IsImportingLiboGenDoc()) - pFCell->ResetDirty(); + pFCell->ResetDirty(); } else if ( aText[0] == '\'' && aText.getLength() > 1 ) { diff --git a/sc/source/filter/xml/xmlimprt.cxx b/sc/source/filter/xml/xmlimprt.cxx index 5082f3b3f575..c3e3cd7c7b15 100644 --- a/sc/source/filter/xml/xmlimprt.cxx +++ b/sc/source/filter/xml/xmlimprt.cxx @@ -52,6 +52,7 @@ #include "xmlimprt.hxx" #include "document.hxx" +#include "docsh.hxx" #include "docuno.hxx" #include "nameuno.hxx" #include "xmlbodyi.hxx" @@ -99,7 +100,6 @@ #define SC_REPEAT_ROW "repeat-row" #define SC_FILTER "filter" #define SC_PRINT_RANGE "print-range" -#define SC_LIBO_PROD_NAME "LibreOffice" using namespace com::sun::star; using namespace ::xmloff::token; @@ -2811,12 +2811,6 @@ throw(::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::R xActionLockable->addActionLock(); pDoc->EnableAdjustHeight(false); - - uno::Reference<document::XDocumentPropertiesSupplier> xDPS(GetModel(), uno::UNO_QUERY_THROW); - uno::Reference<document::XDocumentProperties> xDocProps = xDPS->getDocumentProperties(); - rtl::OUString sGenerator(xDocProps->getGenerator()); - if(sGenerator.match(SC_LIBO_PROD_NAME)) - pDoc->SetImportingLiboGenDoc(true); } // XServiceInfo diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx index 528ad183aae4..d60491976826 100644 --- a/sc/source/ui/docshell/docsh.cxx +++ b/sc/source/ui/docshell/docsh.cxx @@ -116,6 +116,8 @@ #include <vector> #include <boost/shared_ptr.hpp> +#define SC_LIBO_PROD_NAME "LibreOffice" + using namespace com::sun::star; using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::UNO_QUERY; @@ -363,7 +365,12 @@ void ScDocShell::AfterXMLLoading(sal_Bool bRet) if (pModificator) { + sal_uInt16 nRecalcState = aDocument.GetHardRecalcState(); + //temporarily set hard-recalc to prevent calling ScFormulaCell::Notify() + //which will set the cells dirty. + aDocument.SetHardRecalcState(2); delete pModificator; + aDocument.SetHardRecalcState(nRecalcState); pModificator = NULL; } else @@ -422,9 +429,14 @@ sal_Bool ScDocShell::LoadXML( SfxMedium* pLoadMedium, const ::com::sun::star::un if ( nError ) pLoadMedium->SetError( nError, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ) ); + uno::Reference<document::XDocumentPropertiesSupplier> xDPS(GetModel(), uno::UNO_QUERY_THROW); + uno::Reference<document::XDocumentProperties> xDocProps = xDPS->getDocumentProperties(); + rtl::OUString sGenerator(xDocProps->getGenerator()); + if(!sGenerator.match(SC_LIBO_PROD_NAME)) + DoHardRecalc(false); + aDocument.SetXMLFromWrapper( false ); AfterXMLLoading(bRet); - aDocument.SetImportingLiboGenDoc(false); //! row heights... return bRet; |