diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-03-26 18:42:19 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-03-27 00:07:15 -0400 |
commit | e45f3aa3580cb4ba05a778f192c60e42db8a3500 (patch) | |
tree | 496395d035c99ddac9c3b6e3825a59e6ca4800dd | |
parent | aa054eff8ba5a1b7a3eb2a6814564317f0801f70 (diff) |
More on killing direct use of cell classes.
Change-Id: Ie2b6819652f330a493b7f9fe557736b27e402803
-rw-r--r-- | sc/inc/cellvalue.hxx | 4 | ||||
-rw-r--r-- | sc/inc/dociter.hxx | 2 | ||||
-rw-r--r-- | sc/source/core/data/cellvalue.cxx | 32 | ||||
-rw-r--r-- | sc/source/core/data/dociter.cxx | 28 | ||||
-rw-r--r-- | sc/source/core/tool/rangeseq.cxx | 44 | ||||
-rw-r--r-- | sc/source/ui/view/tabvwsh5.cxx | 77 |
6 files changed, 86 insertions, 101 deletions
diff --git a/sc/inc/cellvalue.hxx b/sc/inc/cellvalue.hxx index 84127cd959a6..d4ef3076d0c4 100644 --- a/sc/inc/cellvalue.hxx +++ b/sc/inc/cellvalue.hxx @@ -124,6 +124,10 @@ struct SC_DLLPUBLIC ScRefCellValue bool hasNumeric() const; + double getValue(); + + OUString getString(); + bool isEmpty() const; bool equalsWithoutFormat( const ScRefCellValue& r ) const; diff --git a/sc/inc/dociter.hxx b/sc/inc/dociter.hxx index b50c68ab82ec..7161ac29711f 100644 --- a/sc/inc/dociter.hxx +++ b/sc/inc/dociter.hxx @@ -237,7 +237,7 @@ public: const EditTextObject* getEditText() const; ScFormulaCell* getFormulaCell(); const ScFormulaCell* getFormulaCell() const; - double getValue() const; + double getValue(); ScCellValue getCellValue() const; const ScRefCellValue& getRefCellValue() const; diff --git a/sc/source/core/data/cellvalue.cxx b/sc/source/core/data/cellvalue.cxx index 5b853a32779a..e4f0c2e576b2 100644 --- a/sc/source/core/data/cellvalue.cxx +++ b/sc/source/core/data/cellvalue.cxx @@ -477,6 +477,38 @@ bool ScRefCellValue::hasNumeric() const return hasNumericImpl(meType, mpFormula); } +double ScRefCellValue::getValue() +{ + switch (meType) + { + case CELLTYPE_VALUE: + return mfValue; + case CELLTYPE_FORMULA: + return mpFormula->GetValue(); + default: + ; + } + return 0.0; +} + +OUString ScRefCellValue::getString() +{ + switch (meType) + { + case CELLTYPE_STRING: + return *mpString; + case CELLTYPE_EDIT: + if (mpEditText) + return ScEditUtil::GetString(*mpEditText); + break; + case CELLTYPE_FORMULA: + return mpFormula->GetString(); + default: + ; + } + return EMPTY_OUSTRING; +} + bool ScRefCellValue::isEmpty() const { return meType == CELLTYPE_NOTE || meType == CELLTYPE_NONE; diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx index 8cfa1eb418f4..6d8f758e4215 100644 --- a/sc/source/core/data/dociter.cxx +++ b/sc/source/core/data/dociter.cxx @@ -1060,20 +1060,7 @@ CellType ScCellIterator::getType() const OUString ScCellIterator::getString() { - switch (maCurCell.meType) - { - case CELLTYPE_STRING: - return *maCurCell.mpString; - case CELLTYPE_EDIT: - if (maCurCell.mpEditText) - return ScEditUtil::GetString(*maCurCell.mpEditText); - break; - case CELLTYPE_FORMULA: - return maCurCell.mpFormula->GetString(); - default: - ; - } - return EMPTY_OUSTRING; + return maCurCell.getString(); } const EditTextObject* ScCellIterator::getEditText() const @@ -1091,18 +1078,9 @@ const ScFormulaCell* ScCellIterator::getFormulaCell() const return maCurCell.mpFormula; } -double ScCellIterator::getValue() const +double ScCellIterator::getValue() { - switch (maCurCell.meType) - { - case CELLTYPE_VALUE: - return maCurCell.mfValue; - case CELLTYPE_FORMULA: - return maCurCell.mpFormula->GetValue(); - default: - ; - } - return 0.0; + return maCurCell.getValue(); } ScCellValue ScCellIterator::getCellValue() const diff --git a/sc/source/core/tool/rangeseq.cxx b/sc/source/core/tool/rangeseq.cxx index 114354c896ce..9e08c896749e 100644 --- a/sc/source/core/tool/rangeseq.cxx +++ b/sc/source/core/tool/rangeseq.cxx @@ -243,22 +243,6 @@ sal_Bool ScRangeToSequence::FillStringArray( uno::Any& rAny, const ScMatrix* pMa return sal_True; } -//------------------------------------------------------------------------ - -static double lcl_GetValueFromCell( ScBaseCell& rCell ) -{ - //! ScBaseCell member function? - - CellType eType = rCell.GetCellType(); - if ( eType == CELLTYPE_VALUE ) - return ((ScValueCell&)rCell).GetValue(); - else if ( eType == CELLTYPE_FORMULA ) - return ((ScFormulaCell&)rCell).GetValue(); // called only if result is value - - OSL_FAIL( "GetValueFromCell: wrong type" ); - return 0; -} - sal_Bool ScRangeToSequence::FillMixedArray( uno::Any& rAny, ScDocument* pDoc, const ScRange& rRange, sal_Bool bAllowNV ) { @@ -281,22 +265,24 @@ sal_Bool ScRangeToSequence::FillMixedArray( uno::Any& rAny, ScDocument* pDoc, co uno::Any& rElement = pColAry[nCol]; ScAddress aPos( (SCCOL)(nStartCol+nCol), (SCROW)(nStartRow+nRow), nTab ); - ScBaseCell* pCell = pDoc->GetCell( aPos ); - if ( pCell ) + ScRefCellValue aCell; + aCell.assign(*pDoc, aPos); + + if (aCell.isEmpty()) { - if ( pCell->GetCellType() == CELLTYPE_FORMULA && - ((ScFormulaCell*)pCell)->GetErrCode() != 0 ) - { - // if NV is allowed, leave empty for errors - bHasErrors = sal_True; - } - else if ( pCell->HasValueData() ) - rElement <<= (double) lcl_GetValueFromCell( *pCell ); - else - rElement <<= rtl::OUString( pCell->GetStringData() ); + rElement <<= EMPTY_OUSTRING; + continue; + } + + if (aCell.meType == CELLTYPE_FORMULA && aCell.mpFormula->GetErrCode() != 0) + { + // if NV is allowed, leave empty for errors + bHasErrors = true; } + else if (aCell.hasNumeric()) + rElement <<= aCell.getValue(); else - rElement <<= rtl::OUString(); // empty: empty string + rElement <<= aCell.getString(); } pRowAry[nRow] = aColSeq; } diff --git a/sc/source/ui/view/tabvwsh5.cxx b/sc/source/ui/view/tabvwsh5.cxx index 2eeb98bea7fe..4787b6151a51 100644 --- a/sc/source/ui/view/tabvwsh5.cxx +++ b/sc/source/ui/view/tabvwsh5.cxx @@ -37,7 +37,7 @@ #include "uiitems.hxx" #include "editsh.hxx" #include "hints.hxx" - +#include "cellvalue.hxx" //================================================================== @@ -314,62 +314,47 @@ void ScTabViewShell::MakeNumberInfoItem( ScDocument* pDoc, //------------------------------ // NumberInfo-Item konstruieren: //------------------------------ - ScBaseCell* pCell = NULL; SvxNumberValueType eValType = SVX_VALUE_TYPE_UNDEFINED; double nCellValue = 0; - String aCellString; + OUString aCellString; - pDoc->GetCell( pViewData->GetCurX(), - pViewData->GetCurY(), - pViewData->GetTabNo(), - pCell ); + ScRefCellValue aCell; + aCell.assign(*pDoc, pViewData->GetCurPos()); - if ( pCell ) + switch (aCell.meType) { - switch ( pCell->GetCellType() ) + case CELLTYPE_VALUE: { - case CELLTYPE_VALUE: - { - nCellValue = ((ScValueCell*)pCell)->GetValue(); - eValType = SVX_VALUE_TYPE_NUMBER; - aCellString.Erase(); - } - break; - - case CELLTYPE_STRING: - { - aCellString = ((ScStringCell*)pCell)->GetString(); - eValType = SVX_VALUE_TYPE_STRING; - } - break; + nCellValue = aCell.mfValue; + eValType = SVX_VALUE_TYPE_NUMBER; + } + break; - case CELLTYPE_FORMULA: - { - if ( ((ScFormulaCell*)pCell)->IsValue() ) - { - nCellValue = ((ScFormulaCell*)pCell)->GetValue(); - eValType = SVX_VALUE_TYPE_NUMBER; - } - else - { - nCellValue = 0; - eValType = SVX_VALUE_TYPE_UNDEFINED; - } - aCellString.Erase(); - } - break; + case CELLTYPE_STRING: + { + aCellString = *aCell.mpString; + eValType = SVX_VALUE_TYPE_STRING; + } + break; - default: + case CELLTYPE_FORMULA: + { + if (aCell.mpFormula->IsValue()) + { + nCellValue = aCell.mpFormula->GetValue(); + eValType = SVX_VALUE_TYPE_NUMBER; + } + else + { nCellValue = 0; eValType = SVX_VALUE_TYPE_UNDEFINED; - aCellString.Erase(); + } } - } - else // Zelle noch leer (== nicht erzeugt) - { - nCellValue = 0; - eValType = SVX_VALUE_TYPE_UNDEFINED; - aCellString.Erase(); + break; + + default: + nCellValue = 0; + eValType = SVX_VALUE_TYPE_UNDEFINED; } switch ( eValType ) |