summaryrefslogtreecommitdiff
path: root/sc/source/ui/unoobj
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2013-03-20 22:24:57 -0400
committerKohei Yoshida <kohei.yoshida@gmail.com>2013-03-22 21:49:20 -0400
commit0327a7cdddb88a4841dc1be63fa0ce78ab35fc2d (patch)
tree944b4a0583a3425f02886dd6e6f9a2c1144dca92 /sc/source/ui/unoobj
parent6de145fdfa60737b4d3c4cb164caab5a44aa6c45 (diff)
More on reducing the use of ScDocument::PutCell().
I'm getting tired of this already... Change-Id: I77c4f82fc61c9371e8a07fa559088851667949d6
Diffstat (limited to 'sc/source/ui/unoobj')
-rw-r--r--sc/source/ui/unoobj/cellsuno.cxx42
-rw-r--r--sc/source/ui/unoobj/funcuno.cxx12
2 files changed, 35 insertions, 19 deletions
diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
index 298b61a9055f..04e7dec72bba 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -1198,6 +1198,8 @@ static sal_Bool lcl_PutDataArray( ScDocShell& rDocShell, const ScRange& rRange,
const uno::Any* pColArr = rColSeq.getConstArray();
for (long nCol=0; nCol<nCols; nCol++)
{
+ ScAddress aPos(nDocCol, nDocRow, nTab);
+
const uno::Any& rElement = pColArr[nCol];
switch( rElement.getValueTypeClass() )
{
@@ -1220,7 +1222,7 @@ static sal_Bool lcl_PutDataArray( ScDocShell& rDocShell, const ScRange& rRange,
{
double fVal(0.0);
rElement >>= fVal;
- pDoc->SetValue( nDocCol, nDocRow, nTab, fVal );
+ pDoc->SetValue(aPos, fVal);
}
break;
@@ -1229,7 +1231,11 @@ static sal_Bool lcl_PutDataArray( ScDocShell& rDocShell, const ScRange& rRange,
rtl::OUString aUStr;
rElement >>= aUStr;
if ( !aUStr.isEmpty() )
- pDoc->PutCell( nDocCol, nDocRow, nTab, new ScStringCell( aUStr ) );
+ {
+ ScSetStringParam aParam;
+ aParam.setTextInput();
+ pDoc->SetString(aPos, aUStr, &aParam);
+ }
}
break;
@@ -1241,9 +1247,7 @@ static sal_Bool lcl_PutDataArray( ScDocShell& rDocShell, const ScRange& rRange,
{
ScTokenArray aTokenArray;
ScTokenConversion::ConvertToTokenArray( *pDoc, aTokenArray, aTokens );
- ScAddress aPos( nDocCol, nDocRow, nTab );
- ScBaseCell* pNewCell = new ScFormulaCell( pDoc, aPos, &aTokenArray );
- pDoc->PutCell( aPos, pNewCell );
+ pDoc->SetFormula(aPos, aTokenArray);
}
else
bError = true;
@@ -3200,9 +3204,9 @@ void SAL_CALL ScCellRangesBase::setData( const uno::Sequence< uno::Sequence<doub
{
double fVal = pArray[nCol];
if ( fVal == DBL_MIN )
- pDoc->PutCell( *pPos, NULL ); // empty cell
+ pDoc->SetEmptyCell(*pPos);
else
- pDoc->SetValue( pPos->Col(), pPos->Row(), pPos->Tab(), pArray[nCol] );
+ pDoc->SetValue(*pPos, pArray[nCol]);
}
}
}
@@ -3266,11 +3270,15 @@ void SAL_CALL ScCellRangesBase::setRowDescriptions(
static_cast<SCSIZE>(nRow) );
if (pPos)
{
- String aStr = pArray[nRow];
- if ( aStr.Len() )
- pDoc->PutCell( *pPos, new ScStringCell( aStr ) );
+ const OUString& aStr = pArray[nRow];
+ if (aStr.isEmpty())
+ pDoc->SetEmptyCell(*pPos);
else
- pDoc->PutCell( *pPos, NULL ); // empty cell
+ {
+ ScSetStringParam aParam;
+ aParam.setTextInput();
+ pDoc->SetString(*pPos, aStr, &aParam);
+ }
}
}
@@ -3334,11 +3342,15 @@ void SAL_CALL ScCellRangesBase::setColumnDescriptions(
sal::static_int_cast<SCCOL>(nCol) );
if (pPos)
{
- String aStr(pArray[nCol]);
- if ( aStr.Len() )
- pDoc->PutCell( *pPos, new ScStringCell( aStr ) );
+ const OUString& aStr = pArray[nCol];
+ if (aStr.isEmpty())
+ pDoc->SetEmptyCell(*pPos);
else
- pDoc->PutCell( *pPos, NULL ); // empty cell
+ {
+ ScSetStringParam aParam;
+ aParam.setTextInput();
+ pDoc->SetString(*pPos, aStr, &aParam);
+ }
}
}
diff --git a/sc/source/ui/unoobj/funcuno.cxx b/sc/source/ui/unoobj/funcuno.cxx
index 90d3b01dbdc1..776f946ce164 100644
--- a/sc/source/ui/unoobj/funcuno.cxx
+++ b/sc/source/ui/unoobj/funcuno.cxx
@@ -42,6 +42,7 @@
#include "attrib.hxx"
#include "clipparam.hxx"
#include "dociter.hxx"
+#include "stringutil.hxx"
using namespace com::sun::star;
@@ -417,9 +418,12 @@ public:
}
void visitElem( long nCol, long nRow, const rtl::OUString& elem )
{
- if ( !elem.isEmpty() )
- mpDoc->PutCell( (SCCOL) nCol, (SCROW) nRow, 0,
- new ScStringCell( elem ) );
+ if (!elem.isEmpty())
+ {
+ ScSetStringParam aParam;
+ aParam.setTextInput();
+ mpDoc->SetString(ScAddress(nCol,nRow,0), elem, &aParam);
+ }
}
void visitElem( long nCol, long nRow, const uno::Any& rElement )
{
@@ -674,7 +678,7 @@ uno::Any SAL_CALL ScFunctionAccess::callFunction( const rtl::OUString& aName,
// other API compatibility grammars.
ScFormulaCell* pFormula = new ScFormulaCell( pDoc, aFormulaPos,
&aTokenArr, formula::FormulaGrammar::GRAM_PODF_A1, (sal_uInt8)(mbArray ? MM_FORMULA : MM_NONE) );
- pDoc->PutCell( aFormulaPos, pFormula ); //! necessary?
+ pDoc->SetFormulaCell(aFormulaPos, pFormula);
// call GetMatrix before GetErrCode because GetMatrix always recalculates
// if there is no matrix result