Kaydet (Commit) 3a1f90a6 authored tarafından Markus Mohrhard's avatar Markus Mohrhard

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
üst 255bec20
......@@ -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;
......
......@@ -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:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment