sc/inc/document.hxx | 3 --- sc/source/core/data/cell.cxx | 3 +-- sc/source/core/data/documen2.cxx | 1 - sc/source/core/data/document.cxx | 1 - sc/source/filter/xml/xmlcelli.cxx | 9 +++------ sc/source/filter/xml/xmlimprt.cxx | 8 +------- sc/source/ui/docshell/docsh.cxx | 14 +++++++++++++- 7 files changed, 18 insertions(+), 21 deletions(-)
New commits: commit 93319669a0c7892af96221bc1e832ba01c5e2d54 Author: Daniel Bankston <[email protected]> Date: Thu Jul 5 18:15:45 2012 -0500 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 diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index 7559a4e..b4df35b 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -371,7 +371,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 @@ -1564,8 +1563,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 4d12292..338b0ab 100644 --- a/sc/source/core/data/cell.cxx +++ b/sc/source/core/data/cell.cxx @@ -1830,8 +1830,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 0921f20..2419859 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 475a49f..b5e5cc1 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 fac8481..86c7034 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 4b4b605..ccce62e 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; @@ -2810,12 +2810,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 8b96ca6..d6b77de 100644 --- a/sc/source/ui/docshell/docsh.cxx +++ b/sc/source/ui/docshell/docsh.cxx @@ -137,6 +137,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; @@ -384,7 +386,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 @@ -443,9 +450,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; _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
