diff options
Diffstat (limited to 'sc/source/core/data')
-rw-r--r-- | sc/source/core/data/dociter.cxx | 35 | ||||
-rw-r--r-- | sc/source/core/data/document.cxx | 7 | ||||
-rw-r--r-- | sc/source/core/data/table3.cxx | 5 |
3 files changed, 40 insertions, 7 deletions
diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx index da2c66b87..b23b868b6 100644 --- a/sc/source/core/data/dociter.cxx +++ b/sc/source/core/data/dociter.cxx @@ -507,6 +507,24 @@ ScDBQueryDataIterator::DataAccess::~DataAccess() { } +SCROW ScDBQueryDataIterator::GetRowByColEntryIndex(ScDocument& rDoc, SCTAB nTab, SCCOL nCol, SCSIZE nColRow) +{ + ScColumn* pCol = &(rDoc.pTab[nTab])->aCol[nCol]; + return pCol->pItems[nColRow].nRow; +} + +ScBaseCell* ScDBQueryDataIterator::GetCellByColEntryIndex(ScDocument& rDoc, SCTAB nTab, SCCOL nCol, SCSIZE nColRow) +{ + ScColumn* pCol = &(rDoc.pTab[nTab])->aCol[nCol]; + return pCol->pItems[nColRow].pCell; +} + +ScAttrArray* ScDBQueryDataIterator::GetAttrArrayByCol(ScDocument& rDoc, SCTAB nTab, SCCOL nCol) +{ + ScColumn* pCol = &(rDoc.pTab[nTab])->aCol[nCol]; + return pCol->pAttrArray; +} + // ---------------------------------------------------------------------------- ScDBQueryDataIterator::DataAccessInternal::DataAccessInternal(const ScDBQueryDataIterator* pParent, ScDBQueryParamInternal* pParam, ScDocument* pDoc) : @@ -539,7 +557,6 @@ ScDBQueryDataIterator::DataAccessInternal::~DataAccessInternal() bool ScDBQueryDataIterator::DataAccessInternal::getCurrent(Value& rValue) { - ScColumn* pCol = &(mpDoc->pTab[nTab])->aCol[nCol]; SCCOLROW nFirstQueryField = mpParam->GetEntry(0).nField; for ( ;; ) { @@ -550,13 +567,15 @@ bool ScDBQueryDataIterator::DataAccessInternal::getCurrent(Value& rValue) return false; } - while ( (nColRow < pCol->nCount) && (pCol->pItems[nColRow].nRow < nRow) ) - nColRow++; + SCSIZE nCellCount = mpDoc->GetCellCount(nTab, nCol); + SCROW nThisRow = ScDBQueryDataIterator::GetRowByColEntryIndex(*mpDoc, nTab, nCol, nColRow); + while ( (nColRow < nCellCount) && (nThisRow < nRow) ) + nThisRow = ScDBQueryDataIterator::GetRowByColEntryIndex(*mpDoc, nTab, nCol, ++nColRow); - if ( nColRow < pCol->nCount && pCol->pItems[nColRow].nRow <= mpParam->nRow2 ) + if ( nColRow < nCellCount && nThisRow <= mpParam->nRow2 ) { - nRow = pCol->pItems[nColRow].nRow; - ScBaseCell* pCell = pCol->pItems[nColRow].pCell; + nRow = nThisRow; + ScBaseCell* pCell = ScDBQueryDataIterator::GetCellByColEntryIndex(*mpDoc, nTab, nCol, nColRow); if ( (mpDoc->pTab[nTab])->ValidQuery( nRow, *mpParam, NULL, (nCol == static_cast<SCCOL>(nFirstQueryField) ? pCell : NULL) ) ) { @@ -568,8 +587,10 @@ bool ScDBQueryDataIterator::DataAccessInternal::getCurrent(Value& rValue) rValue.mbIsNumber = true; if ( bCalcAsShown ) { + const ScAttrArray* pNewAttrArray = + ScDBQueryDataIterator::GetAttrArrayByCol(*mpDoc, nTab, nCol); lcl_IterGetNumberFormat( nNumFormat, pAttrArray, - nAttrEndRow, pCol->pAttrArray, nRow, mpDoc ); + nAttrEndRow, pNewAttrArray, nRow, mpDoc ); rValue.mfValue = mpDoc->RoundValueAsShown( rValue.mfValue, nNumFormat ); } nNumFmtType = NUMBERFORMAT_NUMBER; diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx index a2f35773c..19e36a5ec 100644 --- a/sc/source/core/data/document.cxx +++ b/sc/source/core/data/document.cxx @@ -4644,6 +4644,13 @@ ULONG ScDocument::GetCellCount() const return nCellCount; } +SCSIZE ScDocument::GetCellCount(SCTAB nTab, SCCOL nCol) const +{ + if (!ValidTab(nTab) || !pTab[nTab]) + return 0; + + return pTab[nTab]->GetCellCount(nCol); +} ULONG ScDocument::GetCodeCount() const { diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx index b770bbba7..1525f0c62 100644 --- a/sc/source/core/data/table3.cxx +++ b/sc/source/core/data/table3.cxx @@ -1819,6 +1819,11 @@ BOOL ScTable::GetDataEntries(SCCOL nCol, SCROW nRow, TypedScStrCollection& rStri return aCol[nCol].GetDataEntries( nRow, rStrings, bLimit ); } +SCSIZE ScTable::GetCellCount(SCCOL nCol) const +{ + return aCol[nCol].GetCellCount(); +} + ULONG ScTable::GetCellCount() const { ULONG nCellCount = 0; |