diff options
author | Daniel Bankston <daniel.e.bankston@gmail.com> | 2012-07-10 15:11:35 -0500 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-07-11 20:37:43 -0400 |
commit | 99314cb07e009279a803799020534dde587ee1a5 (patch) | |
tree | c260458b16cd096b1288ab651fcd6646c3abe812 /sc | |
parent | d880f3d3bf7b6052156e3d6c30f00d22fe66aee1 (diff) |
Reduce some redundant code
Change-Id: I23bf34793c8a1409c8753f572a6122dee2f4128f
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/filter/xml/xmlcelli.cxx | 37 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlcelli.hxx | 2 |
2 files changed, 18 insertions, 21 deletions
diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx index 791f3f0eb10d..c1b7a8516c35 100644 --- a/sc/source/filter/xml/xmlcelli.cxx +++ b/sc/source/filter/xml/xmlcelli.cxx @@ -741,6 +741,19 @@ void ScXMLTableRowCellContext::SetCellRangeSource( const ScAddress& rPosition ) } } +void ScXMLTableRowCellContext::SetFormulaCell(ScFormulaCell* pFCell) const +{ + if(pFCell) + { + if( bFormulaTextResult && pOUTextValue && !pOUTextValue->isEmpty() ) + pFCell->SetHybridString( *pOUTextValue ); + else + pFCell->SetHybridDouble( fValue ); + if( !pFCell->GetCode()->IsRecalcModeAlways() ) + pFCell->ResetDirty(); + } +} + void ScXMLTableRowCellContext::AddTextCellToDoc( const ScAddress& rCurrentPos, const SCCOL nCurrentCol, const ::boost::optional< rtl::OUString >& pOUText ) { @@ -795,12 +808,7 @@ void ScXMLTableRowCellContext::AddNumberCellToDoc( const ScAddress& rCurrentPos if ( pCell && pCell->GetCellType() == CELLTYPE_FORMULA ) { ScFormulaCell* pFCell = static_cast<ScFormulaCell*>(pCell); - if( bFormulaTextResult && pOUTextValue && !pOUTextValue->isEmpty() ) - pFCell->SetHybridString( *pOUTextValue ); - else - pFCell->SetHybridDouble( fValue ); - if( !pFCell->GetCode()->IsRecalcModeAlways() ) - pFCell->ResetDirty(); + SetFormulaCell(pFCell); } } else @@ -1027,12 +1035,7 @@ void ScXMLTableRowCellContext::AddNonMatrixFormulaCell( const ScAddress& rCellPo delete pCode; ScFormulaCell* pFCell = static_cast<ScFormulaCell*>(pNewCell); - if( bFormulaTextResult && pOUTextValue && !pOUTextValue->isEmpty() ) - pFCell->SetHybridString( *pOUTextValue ); - else - pFCell->SetHybridDouble( fValue ); - if( !(pFCell->GetCode()->IsRecalcModeOnLoad() || !pFCell->GetCode()->IsRecalcModeOnLoadOnce()) ) - pFCell->ResetDirty(); + SetFormulaCell(pFCell); } else if ( aText[0] == '\'' && aText.getLength() > 1 ) { @@ -1078,15 +1081,7 @@ void ScXMLTableRowCellContext::AddFormulaCell( const ScAddress& rCellPos ) //add the cached formula result of the first matrix position ScFormulaCell* pFCell = static_cast<ScFormulaCell*>( rXMLImport.GetDocument()->GetCell(rCellPos) ); - if(pFCell) - { - if( bFormulaTextResult && pOUTextValue && !pOUTextValue->isEmpty() ) - pFCell->SetHybridString( *pOUTextValue ); - else - pFCell->SetHybridDouble( fValue ); - if( !pFCell->GetCode()->IsRecalcModeAlways() ) - pFCell->ResetDirty(); - } + SetFormulaCell(pFCell); } } else diff --git a/sc/source/filter/xml/xmlcelli.hxx b/sc/source/filter/xml/xmlcelli.hxx index 3df155ee173b..9b038c6c8d55 100644 --- a/sc/source/filter/xml/xmlcelli.hxx +++ b/sc/source/filter/xml/xmlcelli.hxx @@ -45,6 +45,7 @@ #include <boost/optional.hpp> class ScXMLImport; +class ScFormulaCell; struct ScXMLAnnotationData; class ScXMLTableRowCellContext : public SvXMLImportContext @@ -90,6 +91,7 @@ class ScXMLTableRowCellContext : public SvXMLImportContext bool HasSpecialContent() const; bool CellsAreRepeated() const; + void SetFormulaCell ( ScFormulaCell* pFCell ) const; void AddTextCellToDoc ( const ScAddress& rScCurrentPos, const SCCOL nCurrentCol, const ::boost::optional< rtl::OUString >& pOUText ); void AddNumberCellToDoc ( const ScAddress& rScCurrentPos ); |