summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Bankston <daniel.e.bankston@gmail.com>2012-07-08 12:57:36 -0500
committerKohei Yoshida <kohei.yoshida@gmail.com>2012-07-11 20:37:42 -0400
commitc4878470aa18a4e018173c04bcf9e56eff2cdc3b (patch)
tree7b34eef46ecb0f5a3f670c255777492b5e997465
parent2fbe6e30c4481a4885b3e487bcd5466456a7b1d5 (diff)
Fix problem with cached matrix formula results that contain errors
Change-Id: I9277714780e00e311e6e81a9de6e4d39409d5c9b
-rw-r--r--sc/source/filter/xml/xmlcelli.cxx31
1 files changed, 17 insertions, 14 deletions
diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx
index ed4350ad3e81..9f54f5cd9b7d 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -795,7 +795,10 @@ void ScXMLTableRowCellContext::AddNumberCellToDoc( const ScAddress& rCurrentPos
if ( pCell && pCell->GetCellType() == CELLTYPE_FORMULA )
{
ScFormulaCell* pFCell = static_cast<ScFormulaCell*>(pCell);
- pFCell->SetHybridDouble( fValue );
+ if( bFormulaTextResult && pOUTextValue && !pOUTextValue->isEmpty() )
+ pFCell->SetHybridString( *pOUTextValue );
+ else
+ pFCell->SetHybridDouble( fValue );
pFCell->ResetDirty();
}
}
@@ -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 )
{
if( cellExists(rCellPos) )
@@ -1069,10 +1063,6 @@ void ScXMLTableRowCellContext::AddFormulaCell( const ScAddress& rCellPos )
OSL_ENSURE(((nColsRepeated == 1) && (nRepeatedRows == 1)), "repeated cells with formula not possible now");
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
if(bIsMatrix)
{
@@ -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()
{
if( bHasTextImport && rXMLImport.GetRemoveLastChar() )
@@ -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();
if( aCellPos.Col() > 0 && nRepeatedRows > 1 )
aCellPos.SetRow( aCellPos.Row() - (nRepeatedRows - 1) );