diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2013-01-24 23:22:14 +0100 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2013-01-25 13:19:20 +0100 |
commit | 3a1f90a6c7fa0c0604acac6d76f9d4ef3ac20311 (patch) | |
tree | 51924cfd03b41891e9830c2cbc1a6e3958a04d73 /sc | |
parent | improve tests for cached value import (diff) | |
download | core-3a1f90a6c7fa0c0604acac6d76f9d4ef3ac20311.tar.gz core-3a1f90a6c7fa0c0604acac6d76f9d4ef3ac20311.zip |
improve handling of error cells in cahced value import
We are finally able to handle error cells of the type Err:* and the
patch drastically reduces the number of string comparisons needed during
cached value import.
Change-Id: I4c0a2ed2561862615fe745d1a556e4004fd28d8f
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/filter/xml/xmlcelli.cxx | 34 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlcelli.hxx | 6 |
2 files changed, 26 insertions, 14 deletions
diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx index f3265cab55c8..0eeeecb36597 100644 --- a/sc/source/filter/xml/xmlcelli.cxx +++ b/sc/source/filter/xml/xmlcelli.cxx @@ -122,7 +122,9 @@ ScXMLTableRowCellContext::ScXMLTableRowCellContext( ScXMLImport& rImport, bHasTextImport(false), bIsFirstTextImport(false), bSolarMutexLocked(false), - bFormulaTextResult(false) + bFormulaTextResult(false), + mbPossibleErrorCell(false), + mbCheckWithCompilerForError(false) { rtl::math::setNan(&fValue); // NaN by default @@ -729,7 +731,7 @@ void ScXMLTableRowCellContext::SetFormulaCell(ScFormulaCell* pFCell) const { if( bFormulaTextResult && pOUTextValue ) { - if (!GetScImport().IsFormulaErrorConstant(*pOUTextValue)) + if( !IsPossibleErrorString() ) { pFCell->SetHybridString( *pOUTextValue ); pFCell->ResetDirty(); @@ -772,7 +774,7 @@ void ScXMLTableRowCellContext::PutTextCell( const ScAddress& rCurrentPos, if(!aCellString.isEmpty()) { - if (bDoIncrement && !GetScImport().IsFormulaErrorConstant(aCellString)) + if (bDoIncrement && !IsPossibleErrorString()) { pFCell->SetHybridString( aCellString ); pFCell->ResetDirty(); @@ -1119,7 +1121,7 @@ void ScXMLTableRowCellContext::AddFormulaCell( const ScAddress& rCellPos ) ScMatrixRef pMat(new ScMatrix(nMatrixCols, nMatrixRows)); if (bFormulaTextResult && pOUTextValue) { - if (!GetScImport().IsFormulaErrorConstant(*pOUTextValue)) + if (!IsPossibleErrorString()) { pFCell->SetResultMatrix( nMatrixCols, nMatrixRows, pMat, new formula::FormulaStringToken(*pOUTextValue)); @@ -1159,14 +1161,20 @@ void ScXMLTableRowCellContext::AddFormulaCell( const ScAddress& rCellPos ) // - is blank // - has a constant error value beginning with "#" (such as "#VALUE!" or "#N/A") // - has an "Err:[###]" (where "[###]" is an error number) -bool ScXMLTableRowCellContext::HasSpecialCaseFormulaText() const +void ScXMLTableRowCellContext::HasSpecialCaseFormulaText() { - if( pOUTextContent && - ( pOUTextContent->isEmpty() || (pOUTextContent->indexOf("#") > -1) || - (pOUTextContent->indexOf("Err:") > -1) ) - ) - return true; - return false; + if( pOUTextContent ) + { + if ( pOUTextContent->isEmpty() || (pOUTextContent->indexOf("Err:") > -1) ) + mbPossibleErrorCell = true; + else if (pOUTextContent->indexOf("#") > -1) + mbCheckWithCompilerForError = true; + } +} + +bool ScXMLTableRowCellContext::IsPossibleErrorString() const +{ + return mbPossibleErrorCell || ( mbCheckWithCompilerForError && GetScImport().IsFormulaErrorConstant(*pOUTextValue) ); } @@ -1185,8 +1193,8 @@ void ScXMLTableRowCellContext::EndElement() aTextImport->ResetCursor(); } } - - if( bFormulaTextResult && HasSpecialCaseFormulaText() ) + HasSpecialCaseFormulaText(); + if( bFormulaTextResult && (mbPossibleErrorCell || mbCheckWithCompilerForError) ) { pOUTextValue.reset(*pOUTextContent); nCellType = util::NumberFormat::TEXT; diff --git a/sc/source/filter/xml/xmlcelli.hxx b/sc/source/filter/xml/xmlcelli.hxx index 32f0698e9ad4..2bf8b8c6a3e1 100644 --- a/sc/source/filter/xml/xmlcelli.hxx +++ b/sc/source/filter/xml/xmlcelli.hxx @@ -65,6 +65,8 @@ class ScXMLTableRowCellContext : public SvXMLImportContext bool bIsFirstTextImport; bool bSolarMutexLocked; bool bFormulaTextResult; + bool mbPossibleErrorCell; + bool mbCheckWithCompilerForError; const ScXMLImport& GetScImport() const { return (const ScXMLImport&)GetImport(); } ScXMLImport& GetScImport() { return (ScXMLImport&)GetImport(); } @@ -92,7 +94,9 @@ class ScXMLTableRowCellContext : public SvXMLImportContext void PutFormulaCell ( const ScAddress& rScCurrentPos ); void AddFormulaCell ( const ScAddress& rScCellPos ); - bool HasSpecialCaseFormulaText() const; + void HasSpecialCaseFormulaText(); + + bool IsPossibleErrorString() const; public: |