diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-03-26 22:07:12 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-03-27 00:07:16 -0400 |
commit | 22571debb0071b0a134f9e4aff3db0f98fd19ca6 (patch) | |
tree | bd3a2111b44969c966ef7d9056cf7b4b3fbdadf3 /sc | |
parent | eff4f0c0aa8f91ff5ea65cb44b35cfc901524198 (diff) |
GetInputString() now takes ScRefCellValue instead of ScBaseCell.
Change-Id: Ibf746351eb111a03be4f00ec719a4428c5fe47a4
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/cellform.hxx | 4 | ||||
-rw-r--r-- | sc/source/core/data/column3.cxx | 20 | ||||
-rw-r--r-- | sc/source/core/data/dociter.cxx | 31 | ||||
-rw-r--r-- | sc/source/core/data/table3.cxx | 5 | ||||
-rw-r--r-- | sc/source/core/tool/cellform.cxx | 66 | ||||
-rw-r--r-- | sc/source/ui/docshell/docsh.cxx | 8 | ||||
-rw-r--r-- | sc/source/ui/unoobj/cellsuno.cxx | 6 |
7 files changed, 68 insertions, 72 deletions
diff --git a/sc/inc/cellform.hxx b/sc/inc/cellform.hxx index c7083ec163f0..15f233e13027 100644 --- a/sc/inc/cellform.hxx +++ b/sc/inc/cellform.hxx @@ -53,8 +53,8 @@ public: Color** ppColor, SvNumberFormatter& rFormatter, bool bNullVals = true, bool bFormula = false, ScForceTextFmt eForceTextFmt = ftDontForce, bool bUseStarFormat = false ); - static void GetInputString( ScBaseCell* pCell, sal_uLong nFormat, rtl::OUString& rString, - SvNumberFormatter& rFormatter ); + static void GetInputString( + ScRefCellValue& rCell, sal_uLong nFormat, OUString& rString, SvNumberFormatter& rFormatter ); }; diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx index 8a70ce6c6097..aa04f39c8067 100644 --- a/sc/source/core/data/column3.cxx +++ b/sc/source/core/data/column3.cxx @@ -1527,9 +1527,11 @@ void ScColumn::GetFilterEntries(SCROW nStartRow, SCROW nEndRow, std::vector<ScTy break; ScBaseCell* pCell = maItems[nIndex].pCell; + ScRefCellValue aCell; + aCell.assign(*maItems[nIndex].pCell); sal_uLong nFormat = GetNumberFormat( nRow ); - ScCellFormat::GetInputString( pCell, nFormat, aString, *pFormatter ); + ScCellFormat::GetInputString(aCell, nFormat, aString, *pFormatter); if ( pDocument->HasStringData( nCol, nRow, nTab ) ) { @@ -1778,11 +1780,12 @@ void ScColumn::GetInputString( SCROW nRow, rtl::OUString& rString ) const SCSIZE nIndex; if (Search(nRow, nIndex)) { - ScBaseCell* pCell = maItems[nIndex].pCell; - if (pCell->GetCellType() != CELLTYPE_NOTE) + ScRefCellValue aCell; + aCell.assign(*maItems[nIndex].pCell); + if (aCell.meType != CELLTYPE_NOTE) { sal_uLong nFormat = GetNumberFormat( nRow ); - ScCellFormat::GetInputString( pCell, nFormat, rString, *(pDocument->GetFormatTable()) ); + ScCellFormat::GetInputString(aCell, nFormat, rString, *(pDocument->GetFormatTable())); } else rString = rtl::OUString(); @@ -1996,14 +1999,15 @@ xub_StrLen ScColumn::GetMaxNumberStringLen( Search( nRowStart, nIndex ); while ( nIndex < maItems.size() && (nRow = maItems[nIndex].nRow) <= nRowEnd ) { - ScBaseCell* pCell = maItems[nIndex].pCell; - CellType eType = pCell->GetCellType(); + ScRefCellValue aCell; + aCell.assign(*maItems[nIndex].pCell); + CellType eType = aCell.meType; if ( eType == CELLTYPE_VALUE || (eType == CELLTYPE_FORMULA - && ((ScFormulaCell*)pCell)->IsValue()) ) + && aCell.mpFormula->IsValue()) ) { sal_uLong nFormat = (sal_uLong) ((SfxUInt32Item*) GetAttr( nRow, ATTR_VALUE_FORMAT ))->GetValue(); - ScCellFormat::GetInputString( pCell, nFormat, aString, *pNumFmt ); + ScCellFormat::GetInputString(aCell, nFormat, aString, *pNumFmt); xub_StrLen nLen = aString.getLength(); if ( nLen ) { diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx index 6d8f758e4215..dadf5016365a 100644 --- a/sc/source/core/data/dociter.cxx +++ b/sc/source/core/data/dociter.cxx @@ -1482,6 +1482,7 @@ ScBaseCell* ScQueryCellIterator::BinarySearch() if (!pCol->maItems.size()) return 0; + ScRefCellValue aCell; ScBaseCell* pCell; SCSIZE nHi, nLo; CollatorWrapper* pCollator = (mpParam->bCaseSens ? ScGlobal::GetCaseCollator() : @@ -1503,8 +1504,8 @@ ScBaseCell* ScQueryCellIterator::BinarySearch() { rtl::OUString aCellStr; sal_uLong nFormat = pCol->GetNumberFormat( pCol->maItems[nLo].nRow); - ScCellFormat::GetInputString( pCol->maItems[nLo].pCell, nFormat, aCellStr, - rFormatter); + aCell.assign(*pCol->maItems[nLo].pCell); + ScCellFormat::GetInputString(aCell, nFormat, aCellStr, rFormatter); sal_Int32 nTmp = pCollator->compareString(aCellStr, rEntry.GetQueryItem().maString); if ((rEntry.eOp == SC_LESS_EQUAL && nTmp > 0) || (rEntry.eOp == SC_GREATER_EQUAL && nTmp < 0) || @@ -1529,27 +1530,24 @@ ScBaseCell* ScQueryCellIterator::BinarySearch() aLastInRangeString.Assign( sal_Unicode(0xFFFF)); if (nLastInRange < pCol->maItems.size()) { - pCell = pCol->maItems[nLastInRange].pCell; - if (pCell->HasStringData()) + aCell.assign(*pCol->maItems[nLastInRange].pCell); + if (aCell.hasString()) { sal_uLong nFormat = pCol->GetNumberFormat( pCol->maItems[nLastInRange].nRow); - rtl::OUString aStr; - ScCellFormat::GetInputString( pCell, nFormat, aStr, - rFormatter); + OUString aStr; + ScCellFormat::GetInputString(aCell, nFormat, aStr, rFormatter); aLastInRangeString = aStr; } else { - switch ( pCell->GetCellType() ) + switch (aCell.meType) { case CELLTYPE_VALUE : - fLastInRangeValue = - static_cast<ScValueCell*>(pCell)->GetValue(); - break; + fLastInRangeValue = aCell.mfValue; + break; case CELLTYPE_FORMULA : - fLastInRangeValue = - static_cast<ScFormulaCell*>(pCell)->GetValue(); - break; + fLastInRangeValue = aCell.mpFormula->GetValue(); + break; default: { // added to avoid warnings @@ -1639,8 +1637,9 @@ ScBaseCell* ScQueryCellIterator::BinarySearch() { rtl::OUString aCellStr; sal_uLong nFormat = pCol->GetNumberFormat( pCol->maItems[i].nRow); - ScCellFormat::GetInputString( pCol->maItems[i].pCell, nFormat, aCellStr, - rFormatter); + aCell.assign(*pCol->maItems[i].pCell); + ScCellFormat::GetInputString(aCell, nFormat, aCellStr, rFormatter); + nRes = pCollator->compareString(aCellStr, rEntry.GetQueryItem().maString); if (nRes < 0 && bLessEqual) { diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx index f8e4413d7d15..a16d945d0d0f 100644 --- a/sc/source/core/data/table3.cxx +++ b/sc/source/core/data/table3.cxx @@ -52,6 +52,7 @@ #include "segmenttree.hxx" #include "subtotalparam.hxx" #include "docpool.hxx" +#include "cellvalue.hxx" #include <vector> #include <boost/unordered_set.hpp> @@ -1367,7 +1368,9 @@ public: else if (pCell->GetCellType() != CELLTYPE_NOTE) { sal_uLong nFormat = mrTab.GetNumberFormat( static_cast<SCCOL>(rEntry.nField), nRow ); - ScCellFormat::GetInputString(pCell, nFormat, aCellStr, *mrDoc.GetFormatTable()); + ScRefCellValue aCell; + aCell.assign(*pCell); + ScCellFormat::GetInputString(aCell, nFormat, aCellStr, *mrDoc.GetFormatTable()); } } else diff --git a/sc/source/core/tool/cellform.cxx b/sc/source/core/tool/cellform.cxx index 8d0a9038eb8d..d60627b11a05 100644 --- a/sc/source/core/tool/cellform.cxx +++ b/sc/source/core/tool/cellform.cxx @@ -231,60 +231,42 @@ OUString ScCellFormat::GetString( return aString; } -void ScCellFormat::GetInputString( ScBaseCell* pCell, sal_uLong nFormat, OUString& rString, - SvNumberFormatter& rFormatter ) +void ScCellFormat::GetInputString( + ScRefCellValue& rCell, sal_uLong nFormat, OUString& rString, SvNumberFormatter& rFormatter ) { - if (&rFormatter==NULL) + if (&rFormatter == NULL) { - rString = OUString(); + rString = EMPTY_OUSTRING; return; } - String aString = rString; - CellType eType = pCell->GetCellType(); - switch(eType) + OUString aString = rString; + switch (rCell.meType) { case CELLTYPE_STRING: - { - aString = ((ScStringCell*)pCell)->GetString(); - } - break; case CELLTYPE_EDIT: - { - aString = ((ScEditCell*)pCell)->GetString(); - } - break; + aString = rCell.getString(); + break; case CELLTYPE_VALUE: - { - double nValue = ((ScValueCell*)pCell)->GetValue(); - rFormatter.GetInputLineString( nValue, nFormat, aString ); - } - break; + rFormatter.GetInputLineString(rCell.mfValue, nFormat, aString ); + break; case CELLTYPE_FORMULA: - { - if (((ScFormulaCell*)pCell)->IsEmptyDisplayedAsString()) - { - aString.Erase(); - } - else if (((ScFormulaCell*)pCell)->IsValue()) - { - double nValue = ((ScFormulaCell*)pCell)->GetValue(); - rFormatter.GetInputLineString( nValue, nFormat, aString ); - } - else - { - aString = ((ScFormulaCell*)pCell)->GetString(); - } + { + ScFormulaCell* pFC = rCell.mpFormula; + if (pFC->IsEmptyDisplayedAsString()) + aString = EMPTY_OUSTRING; + else if (pFC->IsValue()) + rFormatter.GetInputLineString(pFC->GetValue(), nFormat, aString); + else + aString = pFC->GetString(); - sal_uInt16 nErrCode = ((ScFormulaCell*)pCell)->GetErrCode(); - if (nErrCode != 0) - { - aString.Erase(); - } - } - break; + sal_uInt16 nErrCode = pFC->GetErrCode(); + if (nErrCode != 0) + aString = EMPTY_OUSTRING; + } + break; default: - aString.Erase(); + aString = EMPTY_OUSTRING; break; } rString = aString; diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx index cf4bcacdb551..b87bb7b4583b 100644 --- a/sc/source/ui/docshell/docsh.cxx +++ b/sc/source/ui/docshell/docsh.cxx @@ -1921,7 +1921,9 @@ void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt } else { - ScCellFormat::GetInputString( pCell, nFormat, aString, rFormatter ); + ScRefCellValue aCell; + aCell.assign(*pCell); + ScCellFormat::GetInputString(aCell, nFormat, aString, rFormatter); bString = false; } } @@ -1971,7 +1973,9 @@ void ScDocShell::AsciiSave( SvStream& rStream, const ScImportOptions& rAsciiOpt } else { - ScCellFormat::GetInputString( pCell, nFormat, aString, rFormatter ); + ScRefCellValue aCell; + aCell.assign(*pCell); + ScCellFormat::GetInputString(aCell, nFormat, aString, rFormatter); bString = false; } } diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx index aa403d7ae677..45e41da5066f 100644 --- a/sc/source/ui/unoobj/cellsuno.cxx +++ b/sc/source/ui/unoobj/cellsuno.cxx @@ -1427,7 +1427,11 @@ static String lcl_GetInputString( ScDocument* pDoc, const ScAddress& rPosition, } } else - ScCellFormat::GetInputString( pCell, nNumFmt, aVal, *pFormatter ); + { + ScRefCellValue aCell; + aCell.assign(*pCell); + ScCellFormat::GetInputString(aCell, nNumFmt, aVal, *pFormatter); + } // ggf. ein ' davorhaengen wie in ScTabViewShell::UpdateInputHandler if ( eType == CELLTYPE_STRING || eType == CELLTYPE_EDIT ) |