Kaydet (Commit) c4878470 authored tarafından Daniel Bankston's avatar Daniel Bankston Kaydeden (comit) Kohei Yoshida

Fix problem with cached matrix formula results that contain errors

Change-Id: I9277714780e00e311e6e81a9de6e4d39409d5c9b
üst 2fbe6e30
...@@ -795,7 +795,10 @@ void ScXMLTableRowCellContext::AddNumberCellToDoc( const ScAddress& rCurrentPos ...@@ -795,7 +795,10 @@ void ScXMLTableRowCellContext::AddNumberCellToDoc( const ScAddress& rCurrentPos
if ( pCell && pCell->GetCellType() == CELLTYPE_FORMULA ) if ( pCell && pCell->GetCellType() == CELLTYPE_FORMULA )
{ {
ScFormulaCell* pFCell = static_cast<ScFormulaCell*>(pCell); ScFormulaCell* pFCell = static_cast<ScFormulaCell*>(pCell);
pFCell->SetHybridDouble( fValue ); if( bFormulaTextResult && pOUTextValue && !pOUTextValue->isEmpty() )
pFCell->SetHybridString( *pOUTextValue );
else
pFCell->SetHybridDouble( fValue );
pFCell->ResetDirty(); pFCell->ResetDirty();
} }
} }
...@@ -1052,15 +1055,6 @@ void ScXMLTableRowCellContext::AddNonMatrixFormulaCell( const ScAddress& rCellPo ...@@ -1052,15 +1055,6 @@ void ScXMLTableRowCellContext::AddNonMatrixFormulaCell( const ScAddress& rCellPo
} }
} }
namespace{
bool isErrOrNA(const rtl::OUString& rStr)
{
return (rStr.indexOf("Err:") > -1) || (rStr.indexOf("#N/A") > -1);
}
}
void ScXMLTableRowCellContext::AddFormulaCell( const ScAddress& rCellPos ) void ScXMLTableRowCellContext::AddFormulaCell( const ScAddress& rCellPos )
{ {
if( cellExists(rCellPos) ) if( cellExists(rCellPos) )
...@@ -1069,10 +1063,6 @@ void ScXMLTableRowCellContext::AddFormulaCell( const ScAddress& rCellPos ) ...@@ -1069,10 +1063,6 @@ void ScXMLTableRowCellContext::AddFormulaCell( const ScAddress& rCellPos )
OSL_ENSURE(((nColsRepeated == 1) && (nRepeatedRows == 1)), "repeated cells with formula not possible now"); OSL_ENSURE(((nColsRepeated == 1) && (nRepeatedRows == 1)), "repeated cells with formula not possible now");
rXMLImport.GetStylesImportHelper()->AddCell(rCellPos); rXMLImport.GetStylesImportHelper()->AddCell(rCellPos);
//if this is an "Err:###" or "#N/A" then use text:p value
if( bFormulaTextResult && pOUTextContent && isErrOrNA(*pOUTextContent) )
pOUTextValue.reset(*pOUTextContent);
//add matrix //add matrix
if(bIsMatrix) if(bIsMatrix)
{ {
...@@ -1115,6 +1105,15 @@ void ScXMLTableRowCellContext::AddFormulaCell( const ScAddress& rCellPos ) ...@@ -1115,6 +1105,15 @@ void ScXMLTableRowCellContext::AddFormulaCell( const ScAddress& rCellPos )
} }
} }
namespace{
bool isErrOrNA(const rtl::OUString& rStr)
{
return (rStr.indexOf("Err:") > -1) || (rStr.indexOf("#N/A") > -1);
}
}
void ScXMLTableRowCellContext::EndElement() void ScXMLTableRowCellContext::EndElement()
{ {
if( bHasTextImport && rXMLImport.GetRemoveLastChar() ) if( bHasTextImport && rXMLImport.GetRemoveLastChar() )
...@@ -1131,6 +1130,10 @@ void ScXMLTableRowCellContext::EndElement() ...@@ -1131,6 +1130,10 @@ void ScXMLTableRowCellContext::EndElement()
} }
} }
//if this is an "Err:###" or "#N/A" then use text:p value
if( bFormulaTextResult && pOUTextContent && isErrOrNA(*pOUTextContent) )
pOUTextValue.reset(*pOUTextContent);
ScAddress aCellPos = rXMLImport.GetTables().GetCurrentCellPos(); ScAddress aCellPos = rXMLImport.GetTables().GetCurrentCellPos();
if( aCellPos.Col() > 0 && nRepeatedRows > 1 ) if( aCellPos.Col() > 0 && nRepeatedRows > 1 )
aCellPos.SetRow( aCellPos.Row() - (nRepeatedRows - 1) ); aCellPos.SetRow( aCellPos.Row() - (nRepeatedRows - 1) );
......
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