summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@suse.com>2011-11-01 11:49:42 -0400
committerKohei Yoshida <kohei.yoshida@suse.com>2011-11-01 11:51:45 -0400
commit5d02007469d84b248bb623196cca95d431f7ed11 (patch)
tree5a095dcc8a7010fbc309254d05742fb5cac63889
parent18a22145c62efc6b75b74803c4a17a5ebd64d037 (diff)
fdo#40110: Correctly map external ranges into matrix instances.
This is a simple silly mistake; the matrix representation of the external range should've preserved the original range; not the data range which can be smaller than the originally requested range.
-rw-r--r--sc/source/ui/docshell/externalrefmgr.cxx79
1 files changed, 39 insertions, 40 deletions
diff --git a/sc/source/ui/docshell/externalrefmgr.cxx b/sc/source/ui/docshell/externalrefmgr.cxx
index c80653193daf..408feb6d6fb5 100644
--- a/sc/source/ui/docshell/externalrefmgr.cxx
+++ b/sc/source/ui/docshell/externalrefmgr.cxx
@@ -1412,8 +1412,8 @@ static ScTokenArray* lcl_convertToTokenArray(const ScDocument* pSrcDoc, ScRange&
pUsedRange.reset(new ScRange(nDataCol1, nDataRow1, 0, nDataCol2, nDataRow2, 0));
ScMatrixRef xMat = new ScMatrix(
- static_cast<SCSIZE>(nDataCol2-nDataCol1+1),
- static_cast<SCSIZE>(nDataRow2-nDataRow1+1));
+ static_cast<SCSIZE>(nCol2-nCol1+1),
+ static_cast<SCSIZE>(nRow2-nRow1+1), ScMatrix::SPARSE_EMPTY);
for (SCCOL nCol = nDataCol1; nCol <= nDataCol2; ++nCol)
{
@@ -1423,53 +1423,52 @@ static ScTokenArray* lcl_convertToTokenArray(const ScDocument* pSrcDoc, ScRange&
ScBaseCell* pCell;
pSrcDoc->GetCell(nCol, nRow, nTab, pCell);
if (!pCell || pCell->HasEmptyData())
- xMat->PutEmpty(nC, nR);
- else
+ // Skip empty cells. Matrix's default values are empty elements.
+ continue;
+
+ switch (pCell->GetCellType())
{
- switch (pCell->GetCellType())
+ case CELLTYPE_EDIT:
+ {
+ String aStr;
+ static_cast<ScEditCell*>(pCell)->GetString(aStr);
+ xMat->PutString(aStr, nC, nR);
+ }
+ break;
+ case CELLTYPE_STRING:
+ {
+ String aStr;
+ static_cast<ScStringCell*>(pCell)->GetString(aStr);
+ xMat->PutString(aStr, nC, nR);
+ }
+ break;
+ case CELLTYPE_VALUE:
+ {
+ double fVal = static_cast<ScValueCell*>(pCell)->GetValue();
+ xMat->PutDouble(fVal, nC, nR);
+ }
+ break;
+ case CELLTYPE_FORMULA:
{
- case CELLTYPE_EDIT:
+ ScFormulaCell* pFCell = static_cast<ScFormulaCell*>(pCell);
+ sal_uInt16 nError = pFCell->GetErrCode();
+ if (nError)
+ xMat->PutDouble( CreateDoubleError( nError), nC, nR);
+ else if (pFCell->IsValue())
{
- String aStr;
- static_cast<ScEditCell*>(pCell)->GetString(aStr);
- xMat->PutString(aStr, nC, nR);
+ double fVal = pFCell->GetValue();
+ xMat->PutDouble(fVal, nC, nR);
}
- break;
- case CELLTYPE_STRING:
+ else
{
String aStr;
- static_cast<ScStringCell*>(pCell)->GetString(aStr);
+ pFCell->GetString(aStr);
xMat->PutString(aStr, nC, nR);
}
- break;
- case CELLTYPE_VALUE:
- {
- double fVal = static_cast<ScValueCell*>(pCell)->GetValue();
- xMat->PutDouble(fVal, nC, nR);
- }
- break;
- case CELLTYPE_FORMULA:
- {
- ScFormulaCell* pFCell = static_cast<ScFormulaCell*>(pCell);
- sal_uInt16 nError = pFCell->GetErrCode();
- if (nError)
- xMat->PutDouble( CreateDoubleError( nError), nC, nR);
- else if (pFCell->IsValue())
- {
- double fVal = pFCell->GetValue();
- xMat->PutDouble(fVal, nC, nR);
- }
- else
- {
- String aStr;
- pFCell->GetString(aStr);
- xMat->PutString(aStr, nC, nR);
- }
- }
- break;
- default:
- OSL_FAIL("attempted to convert an unknown cell type.");
}
+ break;
+ default:
+ OSL_FAIL("attempted to convert an unknown cell type.");
}
}
}