diff options
author | Noel Grandin <noel@peralex.com> | 2012-01-20 12:08:55 -0500 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@suse.com> | 2012-01-20 17:07:19 -0500 |
commit | cc86807e41d44a8f64b74dfc89ddb85cd48a7197 (patch) | |
tree | a6a028ed9cfcbaae52ac31b7c308cd977fda2f04 | |
parent | 5708d3dcb065247d5774dafbd7911bb5bab72849 (diff) |
Replace open-coded array with std::vector in ScColumn.
-rw-r--r-- | sc/inc/column.hxx | 7 | ||||
-rw-r--r-- | sc/source/core/data/column.cxx | 440 | ||||
-rw-r--r-- | sc/source/core/data/column2.cxx | 206 | ||||
-rw-r--r-- | sc/source/core/data/column3.cxx | 354 | ||||
-rw-r--r-- | sc/source/core/data/dociter.cxx | 105 | ||||
-rw-r--r-- | sc/source/core/data/fillinfo.cxx | 6 |
6 files changed, 504 insertions, 614 deletions
diff --git a/sc/inc/column.hxx b/sc/inc/column.hxx index f86bf9baadaf..5000bae9de48 100644 --- a/sc/inc/column.hxx +++ b/sc/inc/column.hxx @@ -35,6 +35,7 @@ #include "rangenam.hxx" #include <set> +#include <vector> namespace editeng { class SvxBorderLine; } @@ -105,9 +106,7 @@ private: SCCOL nCol; SCTAB nTab; - SCSIZE nCount; - SCSIZE nLimit; - ColEntry* pItems; + std::vector<ColEntry> aItems; ScAttrArray* pAttrArray; ScDocument* pDocument; @@ -257,7 +256,7 @@ public: double GetValue( SCROW nRow ) const; void GetFormula( SCROW nRow, rtl::OUString& rFormula ) const; CellType GetCellType( SCROW nRow ) const; - SCSIZE GetCellCount() const { return nCount; } + SCSIZE GetCellCount() const { return aItems.size(); } sal_uInt32 GetWeightedCount() const; sal_uInt32 GetCodeCount() const; // RPN-Code in formulas sal_uInt16 GetErrCode( SCROW nRow ) const; diff --git a/sc/source/core/data/column.cxx b/sc/source/core/data/column.cxx index 933abf26655c..133ccb2b3c5e 100644 --- a/sc/source/core/data/column.cxx +++ b/sc/source/core/data/column.cxx @@ -84,9 +84,6 @@ ScColumn::DoubleAllocSwitch::~DoubleAllocSwitch() ScColumn::ScColumn() : nCol( 0 ), - nCount( 0 ), - nLimit( 0 ), - pItems( NULL ), pAttrArray( NULL ), pDocument( NULL ) { @@ -118,14 +115,14 @@ SCsROW ScColumn::GetNextUnprotected( SCROW nRow, bool bUp ) const sal_uInt16 ScColumn::GetBlockMatrixEdges( SCROW nRow1, SCROW nRow2, sal_uInt16 nMask ) const { // nothing:0, inside:1, bottom:2, left:4, top:8, right:16, open:32 - if ( !pItems ) + if ( aItems.empty() ) return 0; if ( nRow1 == nRow2 ) { SCSIZE nIndex; if ( Search( nRow1, nIndex ) ) { - ScBaseCell* pCell = pItems[nIndex].pCell; + ScBaseCell* pCell = aItems[nIndex].pCell; if ( pCell->GetCellType() == CELLTYPE_FORMULA && ((ScFormulaCell*)pCell)->GetMatrixFlag() ) { @@ -142,9 +139,9 @@ sal_uInt16 ScColumn::GetBlockMatrixEdges( SCROW nRow1, SCROW nRow2, sal_uInt16 n sal_uInt16 nEdges = 0; SCSIZE nIndex; Search( nRow1, nIndex ); - while ( nIndex < nCount && pItems[nIndex].nRow <= nRow2 ) + while ( nIndex < aItems.size() && aItems[nIndex].nRow <= nRow2 ) { - ScBaseCell* pCell = pItems[nIndex].pCell; + ScBaseCell* pCell = aItems[nIndex].pCell; if ( pCell->GetCellType() == CELLTYPE_FORMULA && ((ScFormulaCell*)pCell)->GetMatrixFlag() ) { @@ -191,9 +188,9 @@ bool ScColumn::HasSelectionMatrixFragment(const ScMarkData& rMark) const sal_uInt16 nEdges; SCSIZE nIndex; Search( nTop, nIndex ); - while ( !bFound && nIndex < nCount && pItems[nIndex].nRow <= nBottom ) + while ( !bFound && nIndex < aItems.size() && aItems[nIndex].nRow <= nBottom ) { - ScBaseCell* pCell = pItems[nIndex].pCell; + ScBaseCell* pCell = aItems[nIndex].pCell; if ( pCell->GetCellType() == CELLTYPE_FORMULA && ((ScFormulaCell*)pCell)->GetMatrixFlag() ) { @@ -697,39 +694,39 @@ void ScColumn::ApplyAttr( SCROW nRow, const SfxPoolItem& rAttr ) bool ScColumn::Search( SCROW nRow, SCSIZE& nIndex ) const { - if ( !pItems || !nCount ) + if ( aItems.empty() ) { nIndex = 0; return false; } - SCROW nMinRow = pItems[0].nRow; + SCROW nMinRow = aItems[0].nRow; if ( nRow <= nMinRow ) { nIndex = 0; return nRow == nMinRow; } - SCROW nMaxRow = pItems[nCount-1].nRow; + SCROW nMaxRow = aItems[aItems.size()-1].nRow; if ( nRow >= nMaxRow ) { if ( nRow == nMaxRow ) { - nIndex = nCount - 1; + nIndex = aItems.size() - 1; return true; } else { - nIndex = nCount; + nIndex = aItems.size(); return false; } } long nOldLo, nOldHi; long nLo = nOldLo = 0; - long nHi = nOldHi = Min(static_cast<long>(nCount)-1, static_cast<long>(nRow) ); + long nHi = nOldHi = Min(static_cast<long>(aItems.size())-1, static_cast<long>(nRow) ); long i = 0; bool bFound = false; // quite continuous distribution? => interpolating search - bool bInterpol = (static_cast<SCSIZE>(nMaxRow - nMinRow) < nCount * 2); + bool bInterpol = (static_cast<SCSIZE>(nMaxRow - nMinRow) < aItems.size() * 2); SCROW nR; while ( !bFound && nLo <= nHi ) @@ -738,16 +735,16 @@ bool ScColumn::Search( SCROW nRow, SCSIZE& nIndex ) const i = (nLo+nHi) / 2; // no effort, no division by zero else { // interpolating search - long nLoRow = pItems[nLo].nRow; // no unsigned underflow upon substraction + long nLoRow = aItems[nLo].nRow; // no unsigned underflow upon substraction i = nLo + (long)((long)(nRow - nLoRow) * (nHi - nLo) - / (pItems[nHi].nRow - nLoRow)); - if ( i < 0 || static_cast<SCSIZE>(i) >= nCount ) + / (aItems[nHi].nRow - nLoRow)); + if ( i < 0 || static_cast<SCSIZE>(i) >= aItems.size() ) { // oops ... i = (nLo+nHi) / 2; bInterpol = false; } } - nR = pItems[i].nRow; + nR = aItems[i].nRow; if ( nR < nRow ) { nLo = i+1; @@ -792,7 +789,7 @@ ScBaseCell* ScColumn::GetCell( SCROW nRow ) const { SCSIZE nIndex; if (Search(nRow, nIndex)) - return pItems[nIndex].pCell; + return aItems[nIndex].pCell; return NULL; } @@ -801,29 +798,10 @@ void ScColumn::Resize( SCSIZE nSize ) { if (nSize > sal::static_int_cast<SCSIZE>(MAXROWCOUNT)) nSize = MAXROWCOUNT; - if (nSize < nCount) - nSize = nCount; + if (nSize < aItems.size()) + nSize = aItems.size(); - ColEntry* pNewItems; - if (nSize) - { - SCSIZE nNewSize = nSize + COLUMN_DELTA - 1; - nNewSize -= nNewSize % COLUMN_DELTA; - nLimit = nNewSize; - pNewItems = new ColEntry[nLimit]; - } - else - { - nLimit = 0; - pNewItems = NULL; - } - if (pItems) - { - if (pNewItems) - memmove( pNewItems, pItems, nCount * sizeof(ColEntry) ); - delete[] pItems; - } - pItems = pNewItems; + aItems.reserve(nSize); } // SwapRow zum Sortieren @@ -857,12 +835,12 @@ void ScColumn::SwapRow(SCROW nRow1, SCROW nRow2) ScBaseCell* pCell1 = 0; SCSIZE nIndex1; if ( Search( nRow1, nIndex1 ) ) - pCell1 = pItems[nIndex1].pCell; + pCell1 = aItems[nIndex1].pCell; ScBaseCell* pCell2 = 0; SCSIZE nIndex2; if ( Search( nRow2, nIndex2 ) ) - pCell2 = pItems[nIndex2].pCell; + pCell2 = aItems[nIndex2].pCell; // no cells found, nothing to do if ( !pCell1 && !pCell2 ) @@ -897,8 +875,8 @@ void ScColumn::SwapRow(SCROW nRow1, SCROW nRow2) { /* Both cells exist, no formula cells involved, a simple swap can be performed (but keep broadcasters and notes at old position). */ - pItems[nIndex1].pCell = pCell2; - pItems[nIndex2].pCell = pCell1; + aItems[nIndex1].pCell = pCell2; + aItems[nIndex2].pCell = pCell1; SvtBroadcaster* pBC2 = pCell2->ReleaseBroadcaster(); pCell1->TakeBroadcaster( pBC2 ); @@ -910,15 +888,12 @@ void ScColumn::SwapRow(SCROW nRow1, SCROW nRow2) if ( pDummyCell ) { // insert dummy note cell (without note) containing old broadcaster - pItems[nIndex1].pCell = pDummyCell; + aItems[nIndex1].pCell = pDummyCell; } else { // remove ColEntry at old position - --nCount; - memmove( &pItems[nIndex1], &pItems[nIndex1 + 1], (nCount - nIndex1) * sizeof(ColEntry) ); - pItems[nCount].nRow = 0; - pItems[nCount].pCell = 0; + aItems.erase( aItems.begin() + nIndex1 ); } // insert ColEntry at new position @@ -1008,12 +983,12 @@ void ScColumn::SwapCell( SCROW nRow, ScColumn& rCol) ScBaseCell* pCell1 = 0; SCSIZE nIndex1; if ( Search( nRow, nIndex1 ) ) - pCell1 = pItems[nIndex1].pCell; + pCell1 = aItems[nIndex1].pCell; ScBaseCell* pCell2 = 0; SCSIZE nIndex2; if ( rCol.Search( nRow, nIndex2 ) ) - pCell2 = rCol.pItems[nIndex2].pCell; + pCell2 = rCol.aItems[nIndex2].pCell; // reverse call if own cell is missing (ensures own existing cell in following code) if( !pCell1 ) @@ -1031,8 +1006,8 @@ void ScColumn::SwapCell( SCROW nRow, ScColumn& rCol) if ( pCell2 ) { // Tauschen - pItems[nIndex1].pCell = pCell2; - rCol.pItems[nIndex2].pCell = pCell1; + aItems[nIndex1].pCell = pCell2; + rCol.aItems[nIndex2].pCell = pCell1; // Referenzen aktualisieren SCsCOL dx = rCol.nCol - nCol; if ( pFmlaCell1 ) @@ -1053,10 +1028,7 @@ void ScColumn::SwapCell( SCROW nRow, ScColumn& rCol) else { // Loeschen - --nCount; - memmove( &pItems[nIndex1], &pItems[nIndex1 + 1], (nCount - nIndex1) * sizeof(ColEntry) ); - pItems[nCount].nRow = 0; - pItems[nCount].pCell = 0; + aItems.erase(aItems.begin() + nIndex1); // Referenzen aktualisieren SCsCOL dx = rCol.nCol - nCol; if ( pFmlaCell1 ) @@ -1077,10 +1049,10 @@ bool ScColumn::TestInsertCol( SCROW nStartRow, SCROW nEndRow) const if (!IsEmpty()) { bool bTest = true; - if (pItems) - for (SCSIZE i=0; (i<nCount) && bTest; i++) - bTest = (pItems[i].nRow < nStartRow) || (pItems[i].nRow > nEndRow) - || pItems[i].pCell->IsBlank(); + if ( !aItems.empty() ) + for (SCSIZE i=0; (i<aItems.size()) && bTest; i++) + bTest = (aItems[i].nRow < nStartRow) || (aItems[i].nRow > nEndRow) + || aItems[i].pCell->IsBlank(); // AttrArray testet nur zusammengefasste @@ -1100,9 +1072,9 @@ bool ScColumn::TestInsertRow( SCSIZE nSize ) const { // AttrArray only looks for merged cells - if ( pItems && nCount ) + if ( !aItems.empty() ) return ( nSize <= sal::static_int_cast<SCSIZE>(MAXROW) && - pItems[nCount-1].nRow <= MAXROW-(SCROW)nSize && pAttrArray->TestInsertRow( nSize ) ); + aItems[aItems.size()-1].nRow <= MAXROW-(SCROW)nSize && pAttrArray->TestInsertRow( nSize ) ); else return pAttrArray->TestInsertRow( nSize ); } @@ -1114,43 +1086,43 @@ void ScColumn::InsertRow( SCROW nStartRow, SCSIZE nSize ) //! Search - if ( !pItems || !nCount ) + if ( aItems.empty() ) return; SCSIZE i; Search( nStartRow, i ); - if ( i >= nCount ) + if ( i >= aItems.size() ) return ; bool bOldAutoCalc = pDocument->GetAutoCalc(); pDocument->SetAutoCalc( false ); // Mehrfachberechnungen vermeiden - SCSIZE nNewCount = nCount; + SCSIZE nNewCount = aItems.size(); bool bCountChanged = false; ScAddress aAdr( nCol, 0, nTab ); ScHint aHint( SC_HINT_DATACHANGED, aAdr, NULL ); // only areas (ScBaseCell* == NULL) ScAddress& rAddress = aHint.GetAddress(); // for sparse occupation use single broadcasts, not ranges - bool bSingleBroadcasts = (((pItems[nCount-1].nRow - pItems[i].nRow) / - (nCount - i)) > 1); + bool bSingleBroadcasts = (((aItems[aItems.size()-1].nRow - aItems[i].nRow) / + (aItems.size() - i)) > 1); if ( bSingleBroadcasts ) { SCROW nLastBroadcast = MAXROW+1; - for ( ; i < nCount; i++) + for ( ; i < aItems.size(); i++) { - SCROW nOldRow = pItems[i].nRow; - // Aenderung Quelle broadcasten + SCROW nOldRow = aItems[i].nRow; + // Change source broadcaster if ( nLastBroadcast != nOldRow ) - { // direkt aufeinanderfolgende nicht doppelt broadcasten + { // Do not broadcast a direct sequence twice rAddress.SetRow( nOldRow ); pDocument->AreaBroadcast( aHint ); } - SCROW nNewRow = (pItems[i].nRow += nSize); - // Aenderung Ziel broadcasten + SCROW nNewRow = (aItems[i].nRow += nSize); + // Change target broadcaster rAddress.SetRow( nNewRow ); pDocument->AreaBroadcast( aHint ); nLastBroadcast = nNewRow; - ScBaseCell* pCell = pItems[i].pCell; + ScBaseCell* pCell = aItems[i].pCell; if ( pCell->GetCellType() == CELLTYPE_FORMULA ) ((ScFormulaCell*)pCell)->aPos.SetRow( nNewRow ); if ( nNewRow > MAXROW && !bCountChanged ) @@ -1162,12 +1134,12 @@ void ScColumn::InsertRow( SCROW nStartRow, SCSIZE nSize ) } else { - rAddress.SetRow( pItems[i].nRow ); + rAddress.SetRow( aItems[i].nRow ); ScRange aRange( rAddress ); - for ( ; i < nCount; i++) + for ( ; i < aItems.size(); i++) { - SCROW nNewRow = (pItems[i].nRow += nSize); - ScBaseCell* pCell = pItems[i].pCell; + SCROW nNewRow = (aItems[i].nRow += nSize); + ScBaseCell* pCell = aItems[i].pCell; if ( pCell->GetCellType() == CELLTYPE_FORMULA ) ((ScFormulaCell*)pCell)->aPos.SetRow( nNewRow ); if ( nNewRow > MAXROW && !bCountChanged ) @@ -1178,21 +1150,21 @@ void ScColumn::InsertRow( SCROW nStartRow, SCSIZE nSize ) } } if ( !bCountChanged ) - aRange.aEnd.SetRow( pItems[nCount-1].nRow ); + aRange.aEnd.SetRow( aItems[aItems.size()-1].nRow ); pDocument->AreaBroadcastInRange( aRange, aHint ); } if (bCountChanged) { - SCSIZE nDelCount = nCount - nNewCount; + SCSIZE nDelCount = aItems.size() - nNewCount; ScBaseCell** ppDelCells = new ScBaseCell*[nDelCount]; SCROW* pDelRows = new SCROW[nDelCount]; for (i = 0; i < nDelCount; i++) { - ppDelCells[i] = pItems[nNewCount+i].pCell; - pDelRows[i] = pItems[nNewCount+i].nRow; + ppDelCells[i] = aItems[nNewCount+i].pCell; + pDelRows[i] = aItems[nNewCount+i].nRow; } - nCount = nNewCount; + aItems.resize( nNewCount ); for (i = 0; i < nDelCount; i++) { @@ -1223,8 +1195,8 @@ void ScColumn::CopyToClip(SCROW nRow1, SCROW nRow2, ScColumn& rColumn, bool bKee SCSIZE i; SCSIZE nBlockCount = 0; SCSIZE nStartIndex = 0, nEndIndex = 0; - for (i = 0; i < nCount; i++) - if ((pItems[i].nRow >= nRow1) && (pItems[i].nRow <= nRow2)) + for (i = 0; i < aItems.size(); i++) + if ((aItems[i].nRow >= nRow1) && (aItems[i].nRow <= nRow2)) { if (!nBlockCount) nStartIndex = i; @@ -1234,9 +1206,9 @@ void ScColumn::CopyToClip(SCROW nRow1, SCROW nRow2, ScColumn& rColumn, bool bKee // im Clipboard muessen interpretierte Zellen stehen, um andere Formate // (Text, Grafik...) erzueugen zu koennen - if ( pItems[i].pCell->GetCellType() == CELLTYPE_FORMULA ) + if ( aItems[i].pCell->GetCellType() == CELLTYPE_FORMULA ) { - ScFormulaCell* pFCell = (ScFormulaCell*) pItems[i].pCell; + ScFormulaCell* pFCell = (ScFormulaCell*) aItems[i].pCell; if (pFCell->GetDirty() && pDocument->GetAutoCalc()) pFCell->Interpret(); } @@ -1250,9 +1222,9 @@ void ScColumn::CopyToClip(SCROW nRow1, SCROW nRow2, ScColumn& rColumn, bool bKee ScAddress aDestPos( rColumn.nCol, 0, rColumn.nTab ); for (i = nStartIndex; i <= nEndIndex; i++) { - aOwnPos.SetRow( pItems[i].nRow ); - aDestPos.SetRow( pItems[i].nRow ); - ScBaseCell* pNewCell = pItems[i].pCell->CloneWithNote( aOwnPos, *rColumn.pDocument, aDestPos, nCloneFlags ); + aOwnPos.SetRow( aItems[i].nRow ); + aDestPos.SetRow( aItems[i].nRow ); + ScBaseCell* pNewCell = aItems[i].pCell->CloneWithNote( aOwnPos, *rColumn.pDocument, aDestPos, nCloneFlags ); rColumn.Append( aDestPos.Row(), pNewCell ); } } @@ -1309,8 +1281,8 @@ void ScColumn::CopyToColumn(SCROW nRow1, SCROW nRow2, sal_uInt16 nFlags, bool bM SCSIZE i; SCSIZE nBlockCount = 0; SCSIZE nStartIndex = 0, nEndIndex = 0; - for (i = 0; i < nCount; i++) - if ((pItems[i].nRow >= nRow1) && (pItems[i].nRow <= nRow2)) + for (i = 0; i < aItems.size(); i++) + if ((aItems[i].nRow >= nRow1) && (aItems[i].nRow <= nRow2)) { if (!nBlockCount) nStartIndex = i; @@ -1324,7 +1296,7 @@ void ScColumn::CopyToColumn(SCROW nRow1, SCROW nRow2, sal_uInt16 nFlags, bool bM ScAddress aDestPos( rColumn.nCol, 0, rColumn.nTab ); for (i = nStartIndex; i <= nEndIndex; i++) { - aDestPos.SetRow( pItems[i].nRow ); + aDestPos.SetRow( aItems[i].nRow ); ScBaseCell* pNew = bAsLink ? CreateRefCell( rColumn.pDocument, aDestPos, i, nFlags ) : CloneCell( i, nFlags, *rColumn.pDocument, aDestPos ); @@ -1340,13 +1312,13 @@ void ScColumn::CopyToColumn(SCROW nRow1, SCROW nRow2, sal_uInt16 nFlags, bool bM static_cast<ScStringCell*>(pNew)->GetString(aStr); if (aStr.Len() == 0) // A string cell with empty string. Delete the cell itself. - rColumn.Delete(pItems[i].nRow); + rColumn.Delete(aItems[i].nRow); else // non-empty string cell - rColumn.Insert(pItems[i].nRow, pNew); + rColumn.Insert(aItems[i].nRow, pNew); } else - rColumn.Insert(pItems[i].nRow, pNew); + rColumn.Insert(aItems[i].nRow, pNew); } } } @@ -1373,15 +1345,15 @@ void ScColumn::CopyUpdated( const ScColumn& rPosCol, ScColumn& rDestCol ) const ScAddress aOwnPos( nCol, 0, nTab ); ScAddress aDestPos( rDestCol.nCol, 0, rDestCol.nTab ); - SCSIZE nPosCount = rPosCol.nCount; + SCSIZE nPosCount = rPosCol.aItems.size(); for (SCSIZE nPosIndex = 0; nPosIndex < nPosCount; nPosIndex++) { - aOwnPos.SetRow( rPosCol.pItems[nPosIndex].nRow ); + aOwnPos.SetRow( rPosCol.aItems[nPosIndex].nRow ); aDestPos.SetRow( aOwnPos.Row() ); SCSIZE nThisIndex; if ( Search( aDestPos.Row(), nThisIndex ) ) { - ScBaseCell* pNew = pItems[nThisIndex].pCell->CloneWithNote( aOwnPos, rDestDoc, aDestPos ); + ScBaseCell* pNew = aItems[nThisIndex].pCell->CloneWithNote( aOwnPos, rDestDoc, aDestPos ); rDestCol.Insert( aDestPos.Row(), pNew ); } } @@ -1492,19 +1464,7 @@ void ScColumn::MarkScenarioIn( ScMarkData& rDestMark ) const void ScColumn::SwapCol(ScColumn& rCol) { - SCSIZE nTemp; - - nTemp = rCol.nCount; - rCol.nCount = nCount; - nCount = nTemp; - - nTemp = rCol.nLimit; - rCol.nLimit = nLimit; - nLimit = nTemp; - - ColEntry* pTempItems = rCol.pItems; - rCol.pItems = pItems; - pItems = pTempItems; + aItems.swap(rCol.aItems); ScAttrArray* pTempAttr = rCol.pAttrArray; rCol.pAttrArray = pAttrArray; @@ -1515,20 +1475,18 @@ void ScColumn::SwapCol(ScColumn& rCol) rCol.pAttrArray->SetCol(rCol.nCol); SCSIZE i; - if (pItems) - for (i = 0; i < nCount; i++) - { - ScFormulaCell* pCell = (ScFormulaCell*) pItems[i].pCell; - if( pCell->GetCellType() == CELLTYPE_FORMULA) - pCell->aPos.SetCol(nCol); - } - if (rCol.pItems) - for (i = 0; i < rCol.nCount; i++) - { - ScFormulaCell* pCell = (ScFormulaCell*) rCol.pItems[i].pCell; - if( pCell->GetCellType() == CELLTYPE_FORMULA) - pCell->aPos.SetCol(rCol.nCol); - } + for (i = 0; i < aItems.size(); i++) + { + ScFormulaCell* pCell = (ScFormulaCell*) aItems[i].pCell; + if( pCell->GetCellType() == CELLTYPE_FORMULA) + pCell->aPos.SetCol(nCol); + } + for (i = 0; i < rCol.aItems.size(); i++) + { + ScFormulaCell* pCell = (ScFormulaCell*) rCol.aItems[i].pCell; + if( pCell->GetCellType() == CELLTYPE_FORMULA) + pCell->aPos.SetCol(rCol.nCol); + } } @@ -1536,19 +1494,19 @@ void ScColumn::MoveTo(SCROW nStartRow, SCROW nEndRow, ScColumn& rCol) { pAttrArray->MoveTo(nStartRow, nEndRow, *rCol.pAttrArray); - if (pItems) + if ( !aItems.empty() ) { ::std::vector<SCROW> aRows; bool bConsecutive = true; SCSIZE i; Search( nStartRow, i); // i points to start row or position thereafter SCSIZE nStartPos = i; - for ( ; i < nCount && pItems[i].nRow <= nEndRow; ++i) + for ( ; i < aItems.size() && aItems[i].nRow <= nEndRow; ++i) { - SCROW nRow = pItems[i].nRow; + SCROW nRow = aItems[i].nRow; aRows.push_back( nRow); - rCol.Insert( nRow, pItems[i].pCell); - if (nRow != pItems[i].nRow) + rCol.Insert( nRow, aItems[i].pCell); + if (nRow != aItems[i].nRow) { // Listener inserted bConsecutive = false; Search( nRow, i); @@ -1568,10 +1526,10 @@ void ScColumn::MoveTo(SCROW nStartRow, SCROW nEndRow, ScColumn& rCol) bool bFirst = true; nStopPos = 0; for (::std::vector<SCROW>::const_iterator it( aRows.begin()); - it != aRows.end() && nStopPos < nCount; ++it, + it != aRows.end() && nStopPos < aItems.size(); ++it, ++nStopPos) { - if (!bFirst && *it != pItems[nStopPos].nRow) + if (!bFirst && *it != aItems[nStopPos].nRow) { aEntries.push_back( PosPair(nStartPos, nStopPos)); bFirst = true; @@ -1598,19 +1556,15 @@ void ScColumn::MoveTo(SCROW nStartRow, SCROW nEndRow, ScColumn& rCol) nStartPos = (*it).first; nStopPos = (*it).second; for (i=nStartPos; i<nStopPos; ++i) - pItems[i].pCell = pNoteCell; + aItems[i].pCell = pNoteCell; for (i=nStartPos; i<nStopPos; ++i) { - rAddress.SetRow( pItems[i].nRow ); + rAddress.SetRow( aItems[i].nRow ); pDocument->AreaBroadcast( aHint ); } - nCount -= nStopPos - nStartPos; - memmove( &pItems[nStartPos], &pItems[nStopPos], - (nCount - nStartPos) * sizeof(ColEntry) ); + aItems.erase(aItems.begin() + nStartPos, aItems.begin() + nStopPos - 1); } pNoteCell->Delete(); - pItems[nCount].nRow = 0; - pItems[nCount].pCell = NULL; } } } @@ -1621,7 +1575,7 @@ bool ScColumn::UpdateReference( UpdateRefMode eUpdateRefMode, SCCOL nCol1, SCROW ScDocument* pUndoDoc ) { bool bUpdated = false; - if (pItems) + if ( !aItems.empty() ) { ScRange aRange( ScAddress( nCol1, nRow1, nTab1 ), ScAddress( nCol2, nRow2, nTab2 ) ); @@ -1630,7 +1584,7 @@ bool ScColumn::UpdateReference( UpdateRefMode eUpdateRefMode, SCCOL nCol1, SCROW SCSIZE nIndex; if ( Search( nRow1, nIndex ) ) { - ScFormulaCell* pCell = (ScFormulaCell*) pItems[nIndex].pCell; + ScFormulaCell* pCell = (ScFormulaCell*) aItems[nIndex].pCell; if( pCell->GetCellType() == CELLTYPE_FORMULA) bUpdated |= pCell->UpdateReference( eUpdateRefMode, aRange, nDx, nDy, nDz, pUndoDoc ); @@ -1646,17 +1600,17 @@ bool ScColumn::UpdateReference( UpdateRefMode eUpdateRefMode, SCCOL nCol1, SCROW { SCSIZE i; Search( nRow1, i ); - for ( ; i < nCount; i++ ) + for ( ; i < aItems.size(); i++ ) { - SCROW nRow = pItems[i].nRow; + SCROW nRow = aItems[i].nRow; if ( nRow > nRow2 ) break; - ScBaseCell* pCell = pItems[i].pCell; + ScBaseCell* pCell = aItems[i].pCell; if( pCell->GetCellType() == CELLTYPE_FORMULA) { bUpdated |= ((ScFormulaCell*)pCell)->UpdateReference( eUpdateRefMode, aRange, nDx, nDy, nDz, pUndoDoc ); - if ( nRow != pItems[i].nRow ) + if ( nRow != aItems[i].nRow ) Search( nRow, i ); // Listener removed/inserted? } } @@ -1664,18 +1618,18 @@ bool ScColumn::UpdateReference( UpdateRefMode eUpdateRefMode, SCCOL nCol1, SCROW else { SCSIZE i = 0; - for ( ; i < nCount; i++ ) + for ( ; i < aItems.size(); i++ ) { - ScBaseCell* pCell = pItems[i].pCell; + ScBaseCell* pCell = aItems[i].pCell; if( pCell->GetCellType() == CELLTYPE_FORMULA) { - SCROW nRow = pItems[i].nRow; + SCROW nRow = aItems[i].nRow; // When deleting rows on several sheets, the formula's position may be updated with the first call, // so the undo position must be passed from here. ScAddress aUndoPos( nCol, nRow, nTab ); bUpdated |= ((ScFormulaCell*)pCell)->UpdateReference( eUpdateRefMode, aRange, nDx, nDy, nDz, pUndoDoc, &aUndoPos ); - if ( nRow != pItems[i].nRow ) + if ( nRow != aItems[i].nRow ) Search( nRow, i ); // Listener removed/inserted? } } @@ -1689,15 +1643,15 @@ bool ScColumn::UpdateReference( UpdateRefMode eUpdateRefMode, SCCOL nCol1, SCROW void ScColumn::UpdateTranspose( const ScRange& rSource, const ScAddress& rDest, ScDocument* pUndoDoc ) { - if (pItems) - for (SCSIZE i=0; i<nCount; i++) + if ( !aItems.empty() ) + for (SCSIZE i=0; i<aItems.size(); i++) { - ScBaseCell* pCell = pItems[i].pCell; + ScBaseCell* pCell = aItems[i].pCell; if (pCell->GetCellType() == CELLTYPE_FORMULA) { - SCROW nRow = pItems[i].nRow; + SCROW nRow = aItems[i].nRow; ((ScFormulaCell*)pCell)->UpdateTranspose( rSource, rDest, pUndoDoc ); - if ( nRow != pItems[i].nRow ) + if ( nRow != aItems[i].nRow ) Search( nRow, i ); // Listener geloescht/eingefuegt? } } @@ -1706,15 +1660,15 @@ void ScColumn::UpdateTranspose( const ScRange& rSource, const ScAddress& rDest, void ScColumn::UpdateGrow( const ScRange& rArea, SCCOL nGrowX, SCROW nGrowY ) { - if (pItems) - for (SCSIZE i=0; i<nCount; i++) + if ( !aItems.empty() ) + for (SCSIZE i=0; i<aItems.size(); i++) { - ScBaseCell* pCell = pItems[i].pCell; + ScBaseCell* pCell = aItems[i].pCell; if (pCell->GetCellType() == CELLTYPE_FORMULA) { - SCROW nRow = pItems[i].nRow; + SCROW nRow = aItems[i].nRow; ((ScFormulaCell*)pCell)->UpdateGrow( rArea, nGrowX, nGrowY ); - if ( nRow != pItems[i].nRow ) + if ( nRow != aItems[i].nRow ) Search( nRow, i ); // Listener geloescht/eingefuegt? } } @@ -1728,22 +1682,22 @@ void ScColumn::UpdateInsertTab( SCTAB nTable, SCTAB nNewSheets ) nTab += nNewSheets; pAttrArray->SetTab(nTab); } - if( pItems ) + if ( !aItems.empty() ) UpdateInsertTabOnlyCells( nTable, nNewSheets ); } void ScColumn::UpdateInsertTabOnlyCells( SCTAB nTable, SCTAB nNewSheets ) { - if (pItems) - for (SCSIZE i = 0; i < nCount; i++) + if ( !aItems.empty() ) + for (SCSIZE i = 0; i < aItems.size(); i++) { - ScFormulaCell* pCell = (ScFormulaCell*) pItems[i].pCell; + ScFormulaCell* pCell = (ScFormulaCell*) aItems[i].pCell; if( pCell->GetCellType() == CELLTYPE_FORMULA) { - SCROW nRow = pItems[i].nRow; + SCROW nRow = aItems[i].nRow; pCell->UpdateInsertTab(nTable, nNewSheets); - if ( nRow != pItems[i].nRow ) + if ( nRow != aItems[i].nRow ) Search( nRow, i ); // Listener geloescht/eingefuegt? } } @@ -1752,15 +1706,15 @@ void ScColumn::UpdateInsertTabOnlyCells( SCTAB nTable, SCTAB nNewSheets ) void ScColumn::UpdateInsertTabAbs(SCTAB nTable) { - if (pItems) - for (SCSIZE i = 0; i < nCount; i++) + if ( !aItems.empty() ) + for (SCSIZE i = 0; i < aItems.size(); i++) { - ScFormulaCell* pCell = (ScFormulaCell*) pItems[i].pCell; + ScFormulaCell* pCell = (ScFormulaCell*) aItems[i].pCell; if( pCell->GetCellType() == CELLTYPE_FORMULA) { - SCROW nRow = pItems[i].nRow; + SCROW nRow = aItems[i].nRow; pCell->UpdateInsertTabAbs(nTable); - if ( nRow != pItems[i].nRow ) + if ( nRow != aItems[i].nRow ) Search( nRow, i ); // Listener geloescht/eingefuegt? } } @@ -1775,19 +1729,19 @@ void ScColumn::UpdateDeleteTab( SCTAB nTable, bool bIsMove, ScColumn* pRefUndo, pAttrArray->SetTab(nTab); } - if (pItems) - for (SCSIZE i = 0; i < nCount; i++) - if ( pItems[i].pCell->GetCellType() == CELLTYPE_FORMULA ) + if ( !aItems.empty() ) + for (SCSIZE i = 0; i < aItems.size(); i++) + if ( aItems[i].pCell->GetCellType() == CELLTYPE_FORMULA ) { - SCROW nRow = pItems[i].nRow; - ScFormulaCell* pOld = (ScFormulaCell*)pItems[i].pCell; + SCROW nRow = aItems[i].nRow; + ScFormulaCell* pOld = (ScFormulaCell*)aItems[i].pCell; /* Do not copy cell note to the undo document. Undo will copy back the formula cell while keeping the original note. */ ScBaseCell* pSave = pRefUndo ? pOld->CloneWithoutNote( *pDocument ) : 0; bool bChanged = pOld->UpdateDeleteTab(nTable, bIsMove, nSheets); - if ( nRow != pItems[i].nRow ) + if ( nRow != aItems[i].nRow ) Search( nRow, i ); // Listener geloescht/eingefuegt? if (pRefUndo) @@ -1805,15 +1759,15 @@ void ScColumn::UpdateMoveTab( SCTAB nOldPos, SCTAB nNewPos, SCTAB nTabNo ) { nTab = nTabNo; pAttrArray->SetTab( nTabNo ); - if (pItems) - for (SCSIZE i = 0; i < nCount; i++) + if ( !aItems.empty() ) + for (SCSIZE i = 0; i < aItems.size(); i++) { - ScFormulaCell* pCell = (ScFormulaCell*) pItems[i].pCell; + ScFormulaCell* pCell = (ScFormulaCell*) aItems[i].pCell; if ( pCell->GetCellType() == CELLTYPE_FORMULA ) { - SCROW nRow = pItems[i].nRow; + SCROW nRow = aItems[i].nRow; pCell->UpdateMoveTab( nOldPos, nNewPos, nTabNo ); - if ( nRow != pItems[i].nRow ) + if ( nRow != aItems[i].nRow ) Search( nRow, i ); // Listener geloescht/eingefuegt? } } @@ -1822,15 +1776,15 @@ void ScColumn::UpdateMoveTab( SCTAB nOldPos, SCTAB nNewPos, SCTAB nTabNo ) void ScColumn::UpdateCompile( bool bForceIfNameInUse ) { - if (pItems) - for (SCSIZE i = 0; i < nCount; i++) + if ( !aItems.empty() ) + for (SCSIZE i = 0; i < aItems.size(); i++) { - ScFormulaCell* p = (ScFormulaCell*) pItems[i].pCell; + ScFormulaCell* p = (ScFormulaCell*) aItems[i].pCell; if( p->GetCellType() == CELLTYPE_FORMULA ) { - SCROW nRow = pItems[i].nRow; + SCROW nRow = aItems[i].nRow; p->UpdateCompile( bForceIfNameInUse ); - if ( nRow != pItems[i].nRow ) + if ( nRow != aItems[i].nRow ) Search( nRow, i ); // Listener geloescht/eingefuegt? } } @@ -1841,10 +1795,10 @@ void ScColumn::SetTabNo(SCTAB nNewTab) { nTab = nNewTab; pAttrArray->SetTab( nNewTab ); - if (pItems) - for (SCSIZE i = 0; i < nCount; i++) + if ( !aItems.empty() ) + for (SCSIZE i = 0; i < aItems.size(); i++) { - ScFormulaCell* p = (ScFormulaCell*) pItems[i].pCell; + ScFormulaCell* p = (ScFormulaCell*) aItems[i].pCell; if( p->GetCellType() == CELLTYPE_FORMULA ) p->aPos.SetTab( nNewTab ); } @@ -1852,27 +1806,27 @@ void ScColumn::SetTabNo(SCTAB nNewTab) void ScColumn::FindRangeNamesInUse(SCROW nRow1, SCROW nRow2, std::set<sal_uInt16>& rIndexes) const { - if (pItems) - for (SCSIZE i = 0; i < nCount; i++) - if ((pItems[i].nRow >= nRow1) && - (pItems[i].nRow <= nRow2) && - (pItems[i].pCell->GetCellType() == CELLTYPE_FORMULA)) - ((ScFormulaCell*)pItems[i].pCell)->FindRangeNamesInUse(rIndexes); + if ( !aItems.empty() ) + for (SCSIZE i = 0; i < aItems.size(); i++) + if ((aItems[i].nRow >= nRow1) && + (aItems[i].nRow <= nRow2) && + (aItems[i].pCell->GetCellType() == CELLTYPE_FORMULA)) + ((ScFormulaCell*)aItems[i].pCell)->FindRangeNamesInUse(rIndexes); } void ScColumn::ReplaceRangeNamesInUse(SCROW nRow1, SCROW nRow2, const ScRangeData::IndexMap& rMap ) { - if (pItems) - for (SCSIZE i = 0; i < nCount; i++) + if ( !aItems.empty() ) + for (SCSIZE i = 0; i < aItems.size(); i++) { - if ((pItems[i].nRow >= nRow1) && - (pItems[i].nRow <= nRow2) && - (pItems[i].pCell->GetCellType() == CELLTYPE_FORMULA)) + if ((aItems[i].nRow >= nRow1) && + (aItems[i].nRow <= nRow2) && + (aItems[i].pCell->GetCellType() == CELLTYPE_FORMULA)) { - SCROW nRow = pItems[i].nRow; - ((ScFormulaCell*)pItems[i].pCell)->ReplaceRangeNamesInUse( rMap ); - if ( nRow != pItems[i].nRow ) + SCROW nRow = aItems[i].nRow; + ((ScFormulaCell*)aItems[i].pCell)->ReplaceRangeNamesInUse( rMap ); + if ( nRow != aItems[i].nRow ) Search( nRow, i ); // Listener geloescht/eingefuegt? } } @@ -1880,9 +1834,9 @@ void ScColumn::ReplaceRangeNamesInUse(SCROW nRow1, SCROW nRow2, void ScColumn::SetDirtyVar() { - for (SCSIZE i=0; i<nCount; i++) + for (SCSIZE i=0; i<aItems.size(); i++) { - ScFormulaCell* p = (ScFormulaCell*) pItems[i].pCell; + ScFormulaCell* p = (ScFormulaCell*) aItems[i].pCell; if( p->GetCellType() == CELLTYPE_FORMULA ) p->SetDirtyVar(); } @@ -1894,9 +1848,9 @@ void ScColumn::SetDirty() // wird nur dokumentweit verwendet, kein FormulaTrack bool bOldAutoCalc = pDocument->GetAutoCalc(); pDocument->SetAutoCalc( false ); // Mehrfachberechnungen vermeiden - for (SCSIZE i=0; i<nCount; i++) + for (SCSIZE i=0; i<aItems.size(); i++) { - ScFormulaCell* p = (ScFormulaCell*) pItems[i].pCell; + ScFormulaCell* p = (ScFormulaCell*) aItems[i].pCell; if( p->GetCellType() == CELLTYPE_FORMULA ) { p->SetDirtyVar(); @@ -1910,7 +1864,7 @@ void ScColumn::SetDirty() void ScColumn::SetDirty( const ScRange& rRange ) { // broadcastet alles innerhalb eines Range, mit FormulaTrack - if ( !pItems || !nCount ) + if ( aItems.empty() ) return ; bool bOldAutoCalc = pDocument->GetAutoCalc(); pDocument->SetAutoCalc( false ); // Mehrfachberechnungen vermeiden @@ -1920,9 +1874,9 @@ void ScColumn::SetDirty( const ScRange& rRange ) SCROW nRow; SCSIZE nIndex; Search( rRange.aStart.Row(), nIndex ); - while ( nIndex < nCount && (nRow = pItems[nIndex].nRow) <= nRow2 ) + while ( nIndex < aItems.size() && (nRow = aItems[nIndex].nRow) <= nRow2 ) { - ScBaseCell* pCell = pItems[nIndex].pCell; + ScBaseCell* pCell = aItems[nIndex].pCell; if ( pCell->GetCellType() == CELLTYPE_FORMULA ) ((ScFormulaCell*)pCell)->SetDirty(); else @@ -1939,7 +1893,7 @@ void ScColumn::SetDirty( const ScRange& rRange ) void ScColumn::SetTableOpDirty( const ScRange& rRange ) { - if ( !pItems || !nCount ) + if ( aItems.empty() ) return ; bool bOldAutoCalc = pDocument->GetAutoCalc(); pDocument->SetAutoCalc( false ); // no multiple recalculation @@ -1949,9 +1903,9 @@ void ScColumn::SetTableOpDirty( const ScRange& rRange ) SCROW nRow; SCSIZE nIndex; Search( rRange.aStart.Row(), nIndex ); - while ( nIndex < nCount && (nRow = pItems[nIndex].nRow) <= nRow2 ) + while ( nIndex < aItems.size() && (nRow = aItems[nIndex].nRow) <= nRow2 ) { - ScBaseCell* pCell = pItems[nIndex].pCell; + ScBaseCell* pCell = aItems[nIndex].pCell; if ( pCell->GetCellType() == CELLTYPE_FORMULA ) ((ScFormulaCell*)pCell)->SetTableOpDirty(); else @@ -1970,9 +1924,9 @@ void ScColumn::SetDirtyAfterLoad() { bool bOldAutoCalc = pDocument->GetAutoCalc(); pDocument->SetAutoCalc( false ); // Mehrfachberechnungen vermeiden - for (SCSIZE i=0; i<nCount; i++) + for (SCSIZE i=0; i<aItems.size(); i++) { - ScFormulaCell* p = (ScFormulaCell*) pItems[i].pCell; + ScFormulaCell* p = (ScFormulaCell*) aItems[i].pCell; #if 1 // Simply set dirty and append to FormulaTree, without broadcasting, // which is a magnitude faster. This is used to calculate the entire @@ -2003,9 +1957,9 @@ void ScColumn::SetRelNameDirty() { bool bOldAutoCalc = pDocument->GetAutoCalc(); pDocument->SetAutoCalc( false ); // Mehrfachberechnungen vermeiden - for (SCSIZE i=0; i<nCount; i++) + for (SCSIZE i=0; i<aItems.size(); i++) { - ScFormulaCell* p = (ScFormulaCell*) pItems[i].pCell; + ScFormulaCell* p = (ScFormulaCell*) aItems[i].pCell; if( p->GetCellType() == CELLTYPE_FORMULA && p->HasRelNameReference() ) p->SetDirty(); } @@ -2015,10 +1969,10 @@ void ScColumn::SetRelNameDirty() void ScColumn::CalcAll() { - if (pItems) - for (SCSIZE i=0; i<nCount; i++) + if ( !aItems.empty() ) + for (SCSIZE i=0; i<aItems.size(); i++) { - ScBaseCell* pCell = pItems[i].pCell; + ScBaseCell* pCell = aItems[i].pCell; if (pCell->GetCellType() == CELLTYPE_FORMULA) { #if OSL_DEBUG_LEVEL > 1 @@ -2042,19 +1996,19 @@ void ScColumn::CalcAll() void ScColumn::CompileAll() { - if (pItems) - for (SCSIZE i = 0; i < nCount; i++) + if ( !aItems.empty() ) + for (SCSIZE i = 0; i < aItems.size(); i++) { - ScBaseCell* pCell = pItems[i].pCell; + ScBaseCell* pCell = aItems[i].pCell; if ( pCell->GetCellType() == CELLTYPE_FORMULA ) { - SCROW nRow = pItems[i].nRow; + SCROW nRow = aItems[i].nRow; // fuer unbedingtes kompilieren // bCompile=true und pCode->nError=0 ((ScFormulaCell*)pCell)->GetCode()->SetCodeError( 0 ); ((ScFormulaCell*)pCell)->SetCompile( true ); ((ScFormulaCell*)pCell)->CompileTokenArray(); - if ( nRow != pItems[i].nRow ) + if ( nRow != aItems[i].nRow ) Search( nRow, i ); // Listener geloescht/eingefuegt? } } @@ -2063,15 +2017,15 @@ void ScColumn::CompileAll() void ScColumn::CompileXML( ScProgress& rProgress ) { - if (pItems) - for (SCSIZE i = 0; i < nCount; i++) + if ( !aItems.empty() ) + for (SCSIZE i = 0; i < aItems.size(); i++) { - ScBaseCell* pCell = pItems[i].pCell; + ScBaseCell* pCell = aItems[i].pCell; if ( pCell->GetCellType() == CELLTYPE_FORMULA ) { - SCROW nRow = pItems[i].nRow; + SCROW nRow = aItems[i].nRow; ((ScFormulaCell*)pCell)->CompileXML( rProgress ); - if ( nRow != pItems[i].nRow ) + if ( nRow != aItems[i].nRow ) Search( nRow, i ); // Listener geloescht/eingefuegt? } } @@ -2080,10 +2034,10 @@ void ScColumn::CompileXML( ScProgress& rProgress ) void ScColumn::CalcAfterLoad() { - if (pItems) - for (SCSIZE i = 0; i < nCount; i++) + if ( !aItems.empty() ) + for (SCSIZE i = 0; i < aItems.size(); i++) { - ScBaseCell* pCell = pItems[i].pCell; + ScBaseCell* pCell = aItems[i].pCell; if ( pCell->GetCellType() == CELLTYPE_FORMULA ) ((ScFormulaCell*)pCell)->CalcAfterLoad(); } @@ -2092,13 +2046,13 @@ void ScColumn::CalcAfterLoad() void ScColumn::ResetChanged( SCROW nStartRow, SCROW nEndRow ) { - if (pItems) + if ( !aItems.empty() ) { SCSIZE nIndex; Search(nStartRow,nIndex); - while (nIndex<nCount && pItems[nIndex].nRow <= nEndRow) + while (nIndex<aItems.size() && aItems[nIndex].nRow <= nEndRow) { - ScBaseCell* pCell = pItems[nIndex].pCell; + ScBaseCell* pCell = aItems[nIndex].pCell; if (pCell->GetCellType() == CELLTYPE_FORMULA) ((ScFormulaCell*)pCell)->ResetChanged(); ++nIndex; @@ -2114,9 +2068,9 @@ bool ScColumn::HasEditCells(SCROW nStartRow, SCROW nEndRow, SCROW& rFirst) const SCROW nRow = 0; SCSIZE nIndex; Search(nStartRow,nIndex); - while ( (nIndex < nCount) ? ((nRow=pItems[nIndex].nRow) <= nEndRow) : false ) + while ( (nIndex < aItems.size()) ? ((nRow=aItems[nIndex].nRow) <= nEndRow) : false ) { - ScBaseCell* pCell = pItems[nIndex].pCell; + ScBaseCell* pCell = aItems[nIndex].pCell; CellType eCellType = pCell->GetCellType(); if ( eCellType == CELLTYPE_EDIT || IsAmbiguousScriptNonZero( pDocument->GetScriptType(nCol, nRow, nTab, pCell) ) || diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx index 22d3da4ba709..5dd5685afe6c 100644 --- a/sc/source/core/data/column2.cxx +++ b/sc/source/core/data/column2.cxx @@ -105,7 +105,7 @@ long ScColumn::GetNeededSize( SCROW nRow, OutputDevice* pDev, double nPPT = bWidth ? nPPTX : nPPTY; if (Search(nRow,nIndex)) { - ScBaseCell* pCell = pItems[nIndex].pCell; + ScBaseCell* pCell = aItems[nIndex].pCell; const ScPatternAttr* pPattern = rOptions.pPattern; if (!pPattern) pPattern = pAttrArray->GetPattern( nRow ); @@ -544,7 +544,7 @@ sal_uInt16 ScColumn::GetOptimalColWidth( OutputDevice* pDev, double nPPTX, doubl const ScMarkData* pMarkData, const ScColWidthParam* pParam ) { - if (nCount == 0) + if ( aItems.empty() ) return nOldWidth; sal_uInt16 nWidth = (sal_uInt16) (nOldWidth * nPPTX); @@ -579,11 +579,11 @@ sal_uInt16 ScColumn::GetOptimalColWidth( OutputDevice* pDev, double nPPTX, doubl xub_StrLen nLongLen = 0; while (aDataIter.Next(nIndex)) { - if (nIndex >= nCount) + if (nIndex >= aItems.size()) // Out-of-bound reached. No need to keep going. break; - ScBaseCell* pCell = pItems[nIndex].pCell; + ScBaseCell* pCell = aItems[nIndex].pCell; rtl::OUString aValStr; ScCellFormat::GetString( pCell, nFormat, aValStr, &pColor, *pFormatter, true, false, ftCheck ); @@ -611,9 +611,9 @@ sal_uInt16 ScColumn::GetOptimalColWidth( OutputDevice* pDev, double nPPTX, doubl while (aDataIter.Next( nIndex )) { - SCROW nRow = pItems[nIndex].nRow; + SCROW nRow = aItems[nIndex].nRow; - sal_uInt8 nScript = pDocument->GetScriptType( nCol, nRow, nTab, pItems[nIndex].pCell ); + sal_uInt8 nScript = pDocument->GetScriptType( nCol, nRow, nTab, aItems[nIndex].pCell ); if (nScript == 0) nScript = ScGlobal::GetDefaultScriptType(); const ScPatternAttr* pPattern = GetPattern( nRow ); @@ -778,9 +778,9 @@ void ScColumn::GetOptimalHeight( SCROW nStartRow, SCROW nEndRow, sal_uInt16* pHe SCSIZE nIndex; Search(nStart,nIndex); - while ( nIndex < nCount && (nRow=pItems[nIndex].nRow) <= nEnd ) + while ( nIndex < aItems.size() && (nRow=aItems[nIndex].nRow) <= nEnd ) { - sal_uInt8 nScript = pDocument->GetScriptType( nCol, nRow, nTab, pItems[nIndex].pCell ); + sal_uInt8 nScript = pDocument->GetScriptType( nCol, nRow, nTab, aItems[nIndex].pCell ); if ( nScript != nDefScript ) { if ( nScript == SCRIPTTYPE_ASIAN ) @@ -816,7 +816,7 @@ void ScColumn::GetOptimalHeight( SCROW nStartRow, SCROW nEndRow, sal_uInt16* pHe SCSIZE nIndex; Search(nStart,nIndex); - while ( (nIndex < nCount) ? ((nRow=pItems[nIndex].nRow) <= nEnd) : false ) + while ( (nIndex < aItems.size()) ? ((nRow=aItems[nIndex].nRow) <= nEnd) : false ) { // Zellhoehe nur berechnen, wenn sie spaeter auch gebraucht wird (#37928#) @@ -904,10 +904,10 @@ void ScColumn::RemoveAutoSpellObj() { ScTabEditEngine* pEngine = NULL; - for (SCSIZE i=0; i<nCount; i++) - if ( pItems[i].pCell->GetCellType() == CELLTYPE_EDIT ) + for (SCSIZE i=0; i<aItems.size(); i++) + if ( aItems[i].pCell->GetCellType() == CELLTYPE_EDIT ) { - ScEditCell* pOldCell = (ScEditCell*) pItems[i].pCell; + ScEditCell* pOldCell = (ScEditCell*) aItems[i].pCell; const EditTextObject* pData = pOldCell->GetData(); // keine Abfrage auf HasOnlineSpellErrors, damit es auch // nach dem Laden funktioniert @@ -935,7 +935,7 @@ void ScColumn::RemoveAutoSpellObj() ScBaseCell* pNewCell = new ScStringCell( aText ); pNewCell->TakeBroadcaster( pOldCell->ReleaseBroadcaster() ); pNewCell->TakeNote( pOldCell->ReleaseNote() ); - pItems[i].pCell = pNewCell; + aItems[i].pCell = pNewCell; delete pOldCell; } } @@ -949,10 +949,10 @@ void ScColumn::RemoveEditAttribs( SCROW nStartRow, SCROW nEndRow ) SCSIZE i; Search( nStartRow, i ); - for (; i<nCount && pItems[i].nRow <= nEndRow; i++) - if ( pItems[i].pCell->GetCellType() == CELLTYPE_EDIT ) + for (; i<aItems.size() && aItems[i].nRow <= nEndRow; i++) + if ( aItems[i].pCell->GetCellType() == CELLTYPE_EDIT ) { - ScEditCell* pOldCell = (ScEditCell*) pItems[i].pCell; + ScEditCell* pOldCell = (ScEditCell*) aItems[i].pCell; const EditTextObject* pData = pOldCell->GetData(); // Fuer den Test auf harte Formatierung (ScEditAttrTester) sind die Defaults @@ -1005,7 +1005,7 @@ void ScColumn::RemoveEditAttribs( SCROW nStartRow, SCROW nEndRow ) ScBaseCell* pNewCell = new ScStringCell( aText ); pNewCell->TakeBroadcaster( pOldCell->ReleaseBroadcaster() ); pNewCell->TakeNote( pOldCell->ReleaseNote() ); - pItems[i].pCell = pNewCell; + aItems[i].pCell = pNewCell; delete pOldCell; } } @@ -1018,10 +1018,10 @@ void ScColumn::RemoveEditAttribs( SCROW nStartRow, SCROW nEndRow ) bool ScColumn::TestTabRefAbs(SCTAB nTable) { bool bRet = false; - if (pItems) - for (SCSIZE i = 0; i < nCount; i++) - if ( pItems[i].pCell->GetCellType() == CELLTYPE_FORMULA ) - if (((ScFormulaCell*)pItems[i].pCell)->TestTabRefAbs(nTable)) + if ( !aItems.empty() ) + for (SCSIZE i = 0; i < aItems.size(); i++) + if ( aItems[i].pCell->GetCellType() == CELLTYPE_FORMULA ) + if (((ScFormulaCell*)aItems[i].pCell)->TestTabRefAbs(nTable)) bRet = true; return bRet; } @@ -1042,12 +1042,12 @@ ScColumnIterator::~ScColumnIterator() bool ScColumnIterator::Next( SCROW& rRow, ScBaseCell*& rpCell ) { - if ( nPos < pColumn->nCount ) + if ( nPos < pColumn->aItems.size() ) { - rRow = pColumn->pItems[nPos].nRow; + rRow = pColumn->aItems[nPos].nRow; if ( rRow <= nBottom ) { - rpCell = pColumn->pItems[nPos].pCell; + rpCell = pColumn->aItems[nPos].pCell; ++nPos; return true; } @@ -1103,10 +1103,10 @@ bool ScMarkedDataIter::Next( SCSIZE& rIndex ) bAll = false; // nur beim ersten Versuch } - if ( nPos >= pColumn->nCount ) + if ( nPos >= pColumn->aItems.size() ) return false; - if ( pColumn->pItems[nPos].nRow <= nBottom ) + if ( pColumn->aItems[nPos].nRow <= nBottom ) bFound = true; else bNext = true; @@ -1122,20 +1122,20 @@ bool ScMarkedDataIter::Next( SCSIZE& rIndex ) bool ScColumn::IsEmptyData() const { - return (nCount == 0); + return (aItems.empty()); } bool ScColumn::IsEmptyVisData(bool bNotes) const { - if (!pItems || nCount == 0) + if ( aItems.empty() ) return true; else { bool bVisData = false; SCSIZE i; - for (i=0; i<nCount && !bVisData; i++) + for (i=0; i<aItems.size() && !bVisData; i++) { - ScBaseCell* pCell = pItems[i].pCell; + ScBaseCell* pCell = aItems[i].pCell; if ( pCell->GetCellType() != CELLTYPE_NOTE || (bNotes && pCell->HasNote()) ) bVisData = true; } @@ -1150,10 +1150,10 @@ SCSIZE ScColumn::VisibleCount( SCROW nStartRow, SCROW nEndRow ) const SCSIZE nVisCount = 0; SCSIZE nIndex; Search( nStartRow, nIndex ); - while ( nIndex < nCount && pItems[nIndex].nRow <= nEndRow ) + while ( nIndex < aItems.size() && aItems[nIndex].nRow <= nEndRow ) { - if ( pItems[nIndex].nRow >= nStartRow && - pItems[nIndex].pCell->GetCellType() != CELLTYPE_NOTE ) + if ( aItems[nIndex].nRow >= nStartRow && + aItems[nIndex].pCell->GetCellType() != CELLTYPE_NOTE ) { ++nVisCount; } @@ -1165,18 +1165,18 @@ SCSIZE ScColumn::VisibleCount( SCROW nStartRow, SCROW nEndRow ) const SCROW ScColumn::GetLastVisDataPos(bool bNotes) const { SCROW nRet = 0; - if (pItems) + if ( !aItems.empty() ) { SCSIZE i; bool bFound = false; - for (i=nCount; i>0 && !bFound; ) + for (i=aItems.size(); i>0 && !bFound; ) { --i; - ScBaseCell* pCell = pItems[i].pCell; + ScBaseCell* pCell = aItems[i].pCell; if ( pCell->GetCellType() != CELLTYPE_NOTE || (bNotes && pCell->HasNote()) ) { bFound = true; - nRet = pItems[i].nRow; + nRet = aItems[i].nRow; } } } @@ -1186,17 +1186,17 @@ SCROW ScColumn::GetLastVisDataPos(bool bNotes) const SCROW ScColumn::GetFirstVisDataPos(bool bNotes) const { SCROW nRet = 0; - if (pItems) + if ( !aItems.empty() ) { SCSIZE i; bool bFound = false; - for (i=0; i<nCount && !bFound; i++) + for (i=0; i<aItems.size() && !bFound; i++) { - ScBaseCell* pCell = pItems[i].pCell; + ScBaseCell* pCell = aItems[i].pCell; if ( pCell->GetCellType() != CELLTYPE_NOTE || (bNotes && pCell->HasNote()) ) { bFound = true; - nRet = pItems[i].nRow; + nRet = aItems[i].nRow; } } } @@ -1207,7 +1207,7 @@ bool ScColumn::HasVisibleDataAt(SCROW nRow) const { SCSIZE nIndex; if (Search(nRow, nIndex)) - if (!pItems[nIndex].pCell->IsBlank()) + if (!aItems[nIndex].pCell->IsBlank()) return true; return false; @@ -1228,14 +1228,14 @@ bool ScColumn::IsEmpty() const bool ScColumn::IsEmptyBlock(SCROW nStartRow, SCROW nEndRow, bool bIgnoreNotes) const { - if ( nCount == 0 || !pItems ) + if ( aItems.empty() ) return true; SCSIZE nIndex; Search( nStartRow, nIndex ); - while ( nIndex < nCount && pItems[nIndex].nRow <= nEndRow ) + while ( nIndex < aItems.size() && aItems[nIndex].nRow <= nEndRow ) { - if ( !pItems[nIndex].pCell->IsBlank( bIgnoreNotes ) ) // found a cell + if ( !aItems[nIndex].pCell->IsBlank( bIgnoreNotes ) ) // found a cell return false; // not empty ++nIndex; } @@ -1247,35 +1247,35 @@ SCSIZE ScColumn::GetEmptyLinesInBlock( SCROW nStartRow, SCROW nEndRow, ScDirecti SCSIZE nLines = 0; bool bFound = false; SCSIZE i; - if (pItems && (nCount > 0)) + if ( !aItems.empty() ) { if (eDir == DIR_BOTTOM) { - i = nCount; + i = aItems.size(); while (!bFound && (i > 0)) { i--; - if ( pItems[i].nRow < nStartRow ) + if ( aItems[i].nRow < nStartRow ) break; - bFound = pItems[i].nRow <= nEndRow && !pItems[i].pCell->IsBlank(); + bFound = aItems[i].nRow <= nEndRow && !aItems[i].pCell->IsBlank(); } if (bFound) - nLines = static_cast<SCSIZE>(nEndRow - pItems[i].nRow); + nLines = static_cast<SCSIZE>(nEndRow - aItems[i].nRow); else nLines = static_cast<SCSIZE>(nEndRow - nStartRow); } else if (eDir == DIR_TOP) { i = 0; - while (!bFound && (i < nCount)) + while (!bFound && (i < aItems.size())) { - if ( pItems[i].nRow > nEndRow ) + if ( aItems[i].nRow > nEndRow ) break; - bFound = pItems[i].nRow >= nStartRow && !pItems[i].pCell->IsBlank(); + bFound = aItems[i].nRow >= nStartRow && !aItems[i].pCell->IsBlank(); i++; } if (bFound) - nLines = static_cast<SCSIZE>(pItems[i-1].nRow - nStartRow); + nLines = static_cast<SCSIZE>(aItems[i-1].nRow - nStartRow); else nLines = static_cast<SCSIZE>(nEndRow - nStartRow); } @@ -1287,16 +1287,16 @@ SCSIZE ScColumn::GetEmptyLinesInBlock( SCROW nStartRow, SCROW nEndRow, ScDirecti SCROW ScColumn::GetFirstDataPos() const { - if (nCount) - return pItems[0].nRow; + if ( !aItems.empty() ) + return aItems[0].nRow; else return 0; } SCROW ScColumn::GetLastDataPos() const { - if (nCount) - return pItems[nCount-1].nRow; + if ( !aItems.empty() ) + return aItems[aItems.size()-1].nRow; else return 0; } @@ -1304,13 +1304,13 @@ SCROW ScColumn::GetLastDataPos() const bool ScColumn::GetPrevDataPos(SCROW& rRow) const { bool bFound = false; - SCSIZE i = nCount; + SCSIZE i = aItems.size(); while (!bFound && (i > 0)) { --i; - bFound = (pItems[i].nRow < rRow); + bFound = (aItems[i].nRow < rRow); if (bFound) - rRow = pItems[i].nRow; + rRow = aItems[i].nRow; } return bFound; } @@ -1321,9 +1321,9 @@ bool ScColumn::GetNextDataPos(SCROW& rRow) const // greater than rRow if (Search( rRow, nIndex )) ++nIndex; // next cell - bool bMore = ( nIndex < nCount ); + bool bMore = ( nIndex < aItems.size() ); if ( bMore ) - rRow = pItems[nIndex].nRow; + rRow = aItems[nIndex].nRow; return bMore; } @@ -1334,7 +1334,7 @@ void ScColumn::FindDataAreaPos(SCROW& rRow, long nMovY) const SCSIZE nIndex; bool bThere = Search(rRow, nIndex); - if (bThere && pItems[nIndex].pCell->IsBlank()) + if (bThere && aItems[nIndex].pCell->IsBlank()) bThere = false; if (bThere) @@ -1343,17 +1343,17 @@ void ScColumn::FindDataAreaPos(SCROW& rRow, long nMovY) const SCSIZE nOldIndex = nIndex; if (bForward) { - if (nIndex<nCount-1) + if (nIndex<aItems.size()-1) { ++nIndex; - while (nIndex<nCount-1 && pItems[nIndex].nRow==nLast+1 - && !pItems[nIndex].pCell->IsBlank()) + while (nIndex<aItems.size()-1 && aItems[nIndex].nRow==nLast+1 + && !aItems[nIndex].pCell->IsBlank()) { ++nIndex; ++nLast; } - if (nIndex==nCount-1) - if (pItems[nIndex].nRow==nLast+1 && !pItems[nIndex].pCell->IsBlank()) + if (nIndex==aItems.size()-1) + if (aItems[nIndex].nRow==nLast+1 && !aItems[nIndex].pCell->IsBlank()) ++nLast; } } @@ -1362,14 +1362,14 @@ void ScColumn::FindDataAreaPos(SCROW& rRow, long nMovY) const if (nIndex>0) { --nIndex; - while (nIndex>0 && pItems[nIndex].nRow+1==nLast - && !pItems[nIndex].pCell->IsBlank()) + while (nIndex>0 && aItems[nIndex].nRow+1==nLast + && !aItems[nIndex].pCell->IsBlank()) { --nIndex; --nLast; } if (nIndex==0) - if (pItems[nIndex].nRow+1==nLast && !pItems[nIndex].pCell->IsBlank()) + if (aItems[nIndex].nRow+1==nLast && !aItems[nIndex].pCell->IsBlank()) --nLast; } } @@ -1386,19 +1386,19 @@ void ScColumn::FindDataAreaPos(SCROW& rRow, long nMovY) const { if (bForward) { - while (nIndex<nCount && pItems[nIndex].pCell->IsBlank()) + while (nIndex<aItems.size() && aItems[nIndex].pCell->IsBlank()) ++nIndex; - if (nIndex<nCount) - rRow = pItems[nIndex].nRow; + if (nIndex<aItems.size()) + rRow = aItems[nIndex].nRow; else rRow = MAXROW; } else { - while (nIndex>0 && pItems[nIndex-1].pCell->IsBlank()) + while (nIndex>0 && aItems[nIndex-1].pCell->IsBlank()) --nIndex; if (nIndex>0) - rRow = pItems[nIndex-1].nRow; + rRow = aItems[nIndex-1].nRow; else rRow = 0; } @@ -1412,7 +1412,7 @@ bool ScColumn::HasDataAt(SCROW nRow) const SCSIZE nIndex; if (Search(nRow, nIndex)) - if (!pItems[nIndex].pCell->IsBlank()) + if (!aItems[nIndex].pCell->IsBlank()) return true; return false; @@ -1469,7 +1469,7 @@ void ScColumn::FindUsed( SCROW nStartRow, SCROW nEndRow, bool* pUsed ) const SCROW nRow = 0; SCSIZE nIndex; Search( nStartRow, nIndex ); - while ( (nIndex < nCount) ? ((nRow=pItems[nIndex].nRow) <= nEndRow) : false ) + while ( (nIndex < aItems.size()) ? ((nRow=aItems[nIndex].nRow) <= nEndRow) : false ) { pUsed[nRow-nStartRow] = true; ++nIndex; @@ -1484,7 +1484,7 @@ void ScColumn::StartListening( SvtListener& rLst, SCROW nRow ) SCSIZE nIndex; if (Search(nRow,nIndex)) { - pCell = pItems[nIndex].pCell; + pCell = aItems[nIndex].pCell; pBC = pCell->GetBroadcaster(); } else @@ -1509,7 +1509,7 @@ void ScColumn::MoveListeners( SvtBroadcaster& rSource, SCROW nDestRow ) SCSIZE nIndex; if (Search(nDestRow,nIndex)) { - pCell = pItems[nIndex].pCell; + pCell = aItems[nIndex].pCell; pBC = pCell->GetBroadcaster(); } else @@ -1540,7 +1540,7 @@ void ScColumn::EndListening( SvtListener& rLst, SCROW nRow ) SCSIZE nIndex; if (Search(nRow,nIndex)) { - ScBaseCell* pCell = pItems[nIndex].pCell; + ScBaseCell* pCell = aItems[nIndex].pCell; SvtBroadcaster* pBC = pCell->GetBroadcaster(); if (pBC) { @@ -1559,10 +1559,10 @@ void ScColumn::EndListening( SvtListener& rLst, SCROW nRow ) void ScColumn::CompileDBFormula() { - if (pItems) - for (SCSIZE i = 0; i < nCount; i++) + if ( !aItems.empty() ) + for (SCSIZE i = 0; i < aItems.size(); i++) { - ScBaseCell* pCell = pItems[i].pCell; + ScBaseCell* pCell = aItems[i].pCell; if ( pCell->GetCellType() == CELLTYPE_FORMULA ) ((ScFormulaCell*) pCell)->CompileDBFormula(); } @@ -1570,10 +1570,10 @@ void ScColumn::CompileDBFormula() void ScColumn::CompileDBFormula( bool bCreateFormulaString ) { - if (pItems) - for (SCSIZE i = 0; i < nCount; i++) + if ( !aItems.empty() ) + for (SCSIZE i = 0; i < aItems.size(); i++) { - ScBaseCell* pCell = pItems[i].pCell; + ScBaseCell* pCell = aItems[i].pCell; if ( pCell->GetCellType() == CELLTYPE_FORMULA ) ((ScFormulaCell*) pCell)->CompileDBFormula( bCreateFormulaString ); } @@ -1581,10 +1581,10 @@ void ScColumn::CompileDBFormula( bool bCreateFormulaString ) void ScColumn::CompileNameFormula( bool bCreateFormulaString ) { - if (pItems) - for (SCSIZE i = 0; i < nCount; i++) + if ( !aItems.empty() ) + for (SCSIZE i = 0; i < aItems.size(); i++) { - ScBaseCell* pCell = pItems[i].pCell; + ScBaseCell* pCell = aItems[i].pCell; if ( pCell->GetCellType() == CELLTYPE_FORMULA ) ((ScFormulaCell*) pCell)->CompileNameFormula( bCreateFormulaString ); } @@ -1592,10 +1592,10 @@ void ScColumn::CompileNameFormula( bool bCreateFormulaString ) void ScColumn::CompileColRowNameFormula() { - if (pItems) - for (SCSIZE i = 0; i < nCount; i++) + if ( !aItems.empty() ) + for (SCSIZE i = 0; i < aItems.size(); i++) { - ScBaseCell* pCell = pItems[i].pCell; + ScBaseCell* pCell = aItems[i].pCell; if ( pCell->GetCellType() == CELLTYPE_FORMULA ) ((ScFormulaCell*) pCell)->CompileColRowNameFormula(); } @@ -1690,11 +1690,11 @@ void ScColumn::UpdateSelectionFunction( const ScMarkData& rMark, ScMarkedDataIter aDataIter(this, &rMark, false); while (aDataIter.Next( nIndex )) { - SCROW nRow = pItems[nIndex].nRow; + SCROW nRow = aItems[nIndex].nRow; bool bRowHidden = rHiddenRows.getValue(nRow); if ( !bRowHidden ) if ( !bDoExclude || nRow < nExStartRow || nRow > nExEndRow ) - lcl_UpdateSubTotal( rData, pItems[nIndex].pCell ); + lcl_UpdateSubTotal( rData, aItems[nIndex].pCell ); } } @@ -1705,12 +1705,12 @@ void ScColumn::UpdateAreaFunction( ScFunctionData& rData, { SCSIZE nIndex; Search( nStartRow, nIndex ); - while ( nIndex<nCount && pItems[nIndex].nRow<=nEndRow ) + while ( nIndex<aItems.size() && aItems[nIndex].nRow<=nEndRow ) { - SCROW nRow = pItems[nIndex].nRow; + SCROW nRow = aItems[nIndex].nRow; bool bRowHidden = rHiddenRows.getValue(nRow); if ( !bRowHidden ) - lcl_UpdateSubTotal( rData, pItems[nIndex].pCell ); + lcl_UpdateSubTotal( rData, aItems[nIndex].pCell ); ++nIndex; } } @@ -1721,9 +1721,9 @@ sal_uInt32 ScColumn::GetWeightedCount() const // Notizen werden nicht gezaehlt - for (SCSIZE i=0; i<nCount; i++) + for (SCSIZE i=0; i<aItems.size(); i++) { - ScBaseCell* pCell = pItems[i].pCell; + ScBaseCell* pCell = aItems[i].pCell; switch ( pCell->GetCellType() ) { case CELLTYPE_VALUE: @@ -1750,9 +1750,9 @@ sal_uInt32 ScColumn::GetCodeCount() const { sal_uInt32 nCodeCount = 0; - for (SCSIZE i=0; i<nCount; i++) + for (SCSIZE i=0; i<aItems.size(); i++) { - ScBaseCell* pCell = pItems[i].pCell; + ScBaseCell* pCell = aItems[i].pCell; if ( pCell->GetCellType() == CELLTYPE_FORMULA ) nCodeCount += ((ScFormulaCell*)pCell)->GetCode()->GetCodeLen(); } diff --git a/sc/source/core/data/column3.cxx b/sc/source/core/data/column3.cxx index fbeb9519cfa3..5c140bbe2403 100644 --- a/sc/source/core/data/column3.cxx +++ b/sc/source/core/data/column3.cxx @@ -72,9 +72,9 @@ bool ScColumn::bDoubleAlloc = false; // fuer Import: Groesse beim Allozieren void ScColumn::Insert( SCROW nRow, ScBaseCell* pNewCell ) { sal_Bool bIsAppended = false; - if (pItems && nCount>0) + if ( !aItems.empty() ) { - if (pItems[nCount-1].nRow < nRow) + if (aItems[aItems.size()-1].nRow < nRow) { Append(nRow, pNewCell ); bIsAppended = sal_True; @@ -85,7 +85,7 @@ void ScColumn::Insert( SCROW nRow, ScBaseCell* pNewCell ) SCSIZE nIndex; if (Search(nRow, nIndex)) { - ScBaseCell* pOldCell = pItems[nIndex].pCell; + ScBaseCell* pOldCell = aItems[nIndex].pCell; // move broadcaster and note to new cell, if not existing in new cell if (pOldCell->HasBroadcaster() && !pNewCell->HasBroadcaster()) @@ -97,42 +97,17 @@ void ScColumn::Insert( SCROW nRow, ScBaseCell* pNewCell ) { pOldCell->EndListeningTo( pDocument ); // falls in EndListening NoteCell in gleicher Col zerstoert - if ( nIndex >= nCount || pItems[nIndex].nRow != nRow ) + if ( nIndex >= aItems.size() || aItems[nIndex].nRow != nRow ) Search(nRow, nIndex); } pOldCell->Delete(); - pItems[nIndex].pCell = pNewCell; + aItems[nIndex].pCell = pNewCell; } else { - if (nCount + 1 > nLimit) - { - if (bDoubleAlloc) - { - if (nLimit < COLUMN_DELTA) - nLimit = COLUMN_DELTA; - else - { - nLimit *= 2; - if ( nLimit > sal::static_int_cast<SCSIZE>(MAXROWCOUNT) ) - nLimit = MAXROWCOUNT; - } - } - else - nLimit += COLUMN_DELTA; - - ColEntry* pNewItems = new ColEntry[nLimit]; - if (pItems) - { - memmove( pNewItems, pItems, nCount * sizeof(ColEntry) ); - delete[] pItems; - } - pItems = pNewItems; - } - memmove( &pItems[nIndex + 1], &pItems[nIndex], (nCount - nIndex) * sizeof(ColEntry) ); - pItems[nIndex].pCell = pNewCell; - pItems[nIndex].nRow = nRow; - ++nCount; + aItems.insert(aItems.begin() + nIndex, ColEntry()); + aItems[nIndex].pCell = pNewCell; + aItems[nIndex].nRow = nRow; } } // Bei aus Clipboard sind hier noch falsche (alte) Referenzen! @@ -173,33 +148,9 @@ void ScColumn::Insert( SCROW nRow, sal_uInt32 nNumberFormat, ScBaseCell* pCell ) void ScColumn::Append( SCROW nRow, ScBaseCell* pCell ) { - if (nCount + 1 > nLimit) - { - if (bDoubleAlloc) - { - if (nLimit < COLUMN_DELTA) - nLimit = COLUMN_DELTA; - else - { - nLimit *= 2; - if ( nLimit > sal::static_int_cast<SCSIZE>(MAXROWCOUNT) ) - nLimit = MAXROWCOUNT; - } - } - else - nLimit += COLUMN_DELTA; - - ColEntry* pNewItems = new ColEntry[nLimit]; - if (pItems) - { - memmove( pNewItems, pItems, nCount * sizeof(ColEntry) ); - delete[] pItems; - } - pItems = pNewItems; - } - pItems[nCount].pCell = pCell; - pItems[nCount].nRow = nRow; - ++nCount; + aItems.push_back(ColEntry()); + aItems[aItems.size() - 1].pCell = pCell; + aItems[aItems.size() - 1].nRow = nRow; } @@ -209,9 +160,9 @@ void ScColumn::Delete( SCROW nRow ) if (Search(nRow, nIndex)) { - ScBaseCell* pCell = pItems[nIndex].pCell; + ScBaseCell* pCell = aItems[nIndex].pCell; ScNoteCell* pNoteCell = new ScNoteCell; - pItems[nIndex].pCell = pNoteCell; // Dummy fuer Interpret + aItems[nIndex].pCell = pNoteCell; // Dummy fuer Interpret pDocument->Broadcast( ScHint( SC_HINT_DYING, ScAddress( nCol, nRow, nTab ), pCell ) ); if ( SvtBroadcaster* pBC = pCell->ReleaseBroadcaster() ) @@ -221,10 +172,7 @@ void ScColumn::Delete( SCROW nRow ) else { pNoteCell->Delete(); - --nCount; - memmove( &pItems[nIndex], &pItems[nIndex + 1], (nCount - nIndex) * sizeof(ColEntry) ); - pItems[nCount].nRow = 0; - pItems[nCount].pCell = NULL; + aItems.erase(aItems.end() - 1); // Soll man hier den Speicher freigeben (delta)? Wird dann langsamer! } pCell->EndListeningTo( pDocument ); @@ -235,16 +183,13 @@ void ScColumn::Delete( SCROW nRow ) void ScColumn::DeleteAtIndex( SCSIZE nIndex ) { - ScBaseCell* pCell = pItems[nIndex].pCell; + ScBaseCell* pCell = aItems[nIndex].pCell; ScNoteCell* pNoteCell = new ScNoteCell; - pItems[nIndex].pCell = pNoteCell; // Dummy fuer Interpret + aItems[nIndex].pCell = pNoteCell; // Dummy fuer Interpret pDocument->Broadcast( ScHint( SC_HINT_DYING, - ScAddress( nCol, pItems[nIndex].nRow, nTab ), pCell ) ); + ScAddress( nCol, aItems[nIndex].nRow, nTab ), pCell ) ); pNoteCell->Delete(); - --nCount; - memmove( &pItems[nIndex], &pItems[nIndex + 1], (nCount - nIndex) * sizeof(ColEntry) ); - pItems[nCount].nRow = 0; - pItems[nCount].pCell = NULL; + aItems.erase(aItems.begin() + nIndex); pCell->EndListeningTo( pDocument ); pCell->Delete(); } @@ -252,15 +197,9 @@ void ScColumn::DeleteAtIndex( SCSIZE nIndex ) void ScColumn::FreeAll() { - if (pItems) - { - for (SCSIZE i = 0; i < nCount; i++) - pItems[i].pCell->Delete(); - delete[] pItems; - pItems = NULL; - } - nCount = 0; - nLimit = 0; + for (SCSIZE i = 0; i < aItems.size(); i++) + aItems[i].pCell->Delete(); + aItems.clear(); } @@ -268,12 +207,12 @@ void ScColumn::DeleteRow( SCROW nStartRow, SCSIZE nSize ) { pAttrArray->DeleteRow( nStartRow, nSize ); - if ( !pItems || !nCount ) + if ( aItems.empty() ) return ; SCSIZE nFirstIndex; Search( nStartRow, nFirstIndex ); - if ( nFirstIndex >= nCount ) + if ( nFirstIndex >= aItems.size() ) return ; sal_Bool bOldAutoCalc = pDocument->GetAutoCalc(); @@ -285,7 +224,7 @@ void ScColumn::DeleteRow( SCROW nStartRow, SCSIZE nSize ) SCSIZE nEndIndex = 0; SCSIZE i; - for ( i = nFirstIndex; i < nCount && pItems[i].nRow <= nEndRow; i++ ) + for ( i = nFirstIndex; i < aItems.size() && aItems[i].nRow <= nEndRow; i++ ) { if (!bFound) { @@ -294,7 +233,7 @@ void ScColumn::DeleteRow( SCROW nStartRow, SCSIZE nSize ) } nEndIndex = i; - ScBaseCell* pCell = pItems[i].pCell; + ScBaseCell* pCell = aItems[i].pCell; SvtBroadcaster* pBC = pCell->GetBroadcaster(); if (pBC) { @@ -308,7 +247,7 @@ void ScColumn::DeleteRow( SCROW nStartRow, SCSIZE nSize ) { DeleteRange( nStartIndex, nEndIndex, IDF_CONTENTS ); Search( nStartRow, i ); - if ( i >= nCount ) + if ( i >= aItems.size() ) { pDocument->SetAutoCalc( bOldAutoCalc ); return ; @@ -321,18 +260,18 @@ void ScColumn::DeleteRow( SCROW nStartRow, SCSIZE nSize ) ScHint aHint( SC_HINT_DATACHANGED, aAdr, NULL ); // only areas (ScBaseCell* == NULL) ScAddress& rAddress = aHint.GetAddress(); // for sparse occupation use single broadcasts, not ranges - sal_Bool bSingleBroadcasts = (((pItems[nCount-1].nRow - pItems[i].nRow) / - (nCount - i)) > 1); + sal_Bool bSingleBroadcasts = (((aItems[aItems.size()-1].nRow - aItems[i].nRow) / + (aItems.size() - i)) > 1); if ( bSingleBroadcasts ) { SCROW nLastBroadcast = MAXROW+1; - for ( ; i < nCount; i++ ) + for ( ; i < aItems.size(); i++ ) { - SCROW nOldRow = pItems[i].nRow; + SCROW nOldRow = aItems[i].nRow; // Aenderung Quelle broadcasten rAddress.SetRow( nOldRow ); pDocument->AreaBroadcast( aHint ); - SCROW nNewRow = (pItems[i].nRow -= nSize); + SCROW nNewRow = (aItems[i].nRow -= nSize); // Aenderung Ziel broadcasten if ( nLastBroadcast != nNewRow ) { // direkt aufeinanderfolgende nicht doppelt broadcasten @@ -340,20 +279,20 @@ void ScColumn::DeleteRow( SCROW nStartRow, SCSIZE nSize ) pDocument->AreaBroadcast( aHint ); } nLastBroadcast = nOldRow; - ScBaseCell* pCell = pItems[i].pCell; + ScBaseCell* pCell = aItems[i].pCell; if ( pCell->GetCellType() == CELLTYPE_FORMULA ) ((ScFormulaCell*)pCell)->aPos.SetRow( nNewRow ); } } else { - rAddress.SetRow( pItems[i].nRow ); + rAddress.SetRow( aItems[i].nRow ); ScRange aRange( rAddress ); - aRange.aEnd.SetRow( pItems[nCount-1].nRow ); - for ( ; i < nCount; i++ ) + aRange.aEnd.SetRow( aItems[aItems.size()-1].nRow ); + for ( ; i < aItems.size(); i++ ) { - SCROW nNewRow = (pItems[i].nRow -= nSize); - ScBaseCell* pCell = pItems[i].pCell; + SCROW nNewRow = (aItems[i].nRow -= nSize); + ScBaseCell* pCell = aItems[i].pCell; if ( pCell->GetCellType() == CELLTYPE_FORMULA ) ((ScFormulaCell*)pCell)->aPos.SetRow( nNewRow ); } @@ -374,7 +313,7 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe bool bNoCaptions = (nDelFlag & IDF_NOCAPTIONS) != 0; if (bDeleteNote && bNoCaptions) for ( SCSIZE nIdx = nStartIndex; nIdx <= nEndIndex; ++nIdx ) - if ( ScPostIt* pNote = pItems[ nIdx ].pCell->GetNote() ) + if ( ScPostIt* pNote = aItems[ nIdx ].pCell->GetNote() ) pNote->ForgetCaption(); ScHint aHint( SC_HINT_DYING, ScAddress( nCol, 0, nTab ), 0 ); @@ -385,7 +324,7 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe aDelCells.reserve( nEndIndex - nStartIndex + 1 ); typedef mdds::flat_segment_tree<SCSIZE, bool> RemovedSegments_t; - RemovedSegments_t aRemovedSegments(nStartIndex, nCount, false); + RemovedSegments_t aRemovedSegments(nStartIndex, aItems.size(), false); SCSIZE nFirst(nStartIndex); // dummy replacement for old cells, to prevent that interpreter uses old cell @@ -394,9 +333,9 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe for ( SCSIZE nIdx = nStartIndex; nIdx <= nEndIndex; ++nIdx ) { // all content is deleted and cell does not contain broadcaster - if (((nDelFlag & IDF_CONTENTS) == IDF_CONTENTS) && !pItems[ nIdx ].pCell->GetBroadcaster()) + if (((nDelFlag & IDF_CONTENTS) == IDF_CONTENTS) && !aItems[ nIdx ].pCell->GetBroadcaster()) { - ScBaseCell* pOldCell = pItems[ nIdx ].pCell; + ScBaseCell* pOldCell = aItems[ nIdx ].pCell; if (pOldCell->GetCellType() == CELLTYPE_FORMULA) { // cache formula cell, will be deleted below @@ -405,8 +344,8 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe else { // interpret in broadcast must not use the old cell - pItems[ nIdx ].pCell = pDummyCell.get(); - aHint.GetAddress().SetRow( pItems[ nIdx ].nRow ); + aItems[ nIdx ].pCell = pDummyCell.get(); + aHint.GetAddress().SetRow( aItems[ nIdx ].nRow ); aHint.SetCell( pOldCell ); pDocument->Broadcast( aHint ); pOldCell->Delete(); @@ -416,7 +355,7 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe else { bool bDelete = false; - ScBaseCell* pOldCell = pItems[nIdx].pCell; + ScBaseCell* pOldCell = aItems[nIdx].pCell; CellType eCellType = pOldCell->GetCellType(); if ((nDelFlag & IDF_CONTENTS) == IDF_CONTENTS) bDelete = true; @@ -435,7 +374,7 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe if( !bDelete && (nValFlags != 0) ) { sal_uLong nIndex = (sal_uLong)((SfxUInt32Item*)GetAttr( - pItems[nIdx].nRow, ATTR_VALUE_FORMAT ))->GetValue(); + aItems[nIdx].nRow, ATTR_VALUE_FORMAT ))->GetValue(); short nType = pDocument->GetFormatTable()->GetType(nIndex); bool bIsDate = (nType == NUMBERFORMAT_DATE) || (nType == NUMBERFORMAT_TIME) || (nType == NUMBERFORMAT_DATETIME); @@ -477,16 +416,16 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe } // remove cell entry in cell item list - SCROW nOldRow = pItems[nIdx].nRow; + SCROW nOldRow = aItems[nIdx].nRow; if (pNoteCell) { // replace old cell with the replacement note cell - pItems[nIdx].pCell = pNoteCell; + aItems[nIdx].pCell = pNoteCell; // ... so it's not really deleted bDelete = false; } else - pItems[nIdx].pCell = pDummyCell.get(); + aItems[nIdx].pCell = pDummyCell.get(); // cache formula cells (will be deleted later), delete cell of other type if (eCellType == CELLTYPE_FORMULA) @@ -507,7 +446,7 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe { // delete cell note if (bDeleteNote) - pItems[nIdx].pCell->DeleteNote(); + aItems[nIdx].pCell->DeleteNote(); } if (!bDelete) @@ -551,20 +490,20 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe { // previous segment(s) removed, move tail SCSIZE const nEndSegment(aIt->first); memmove( - &pItems[nStartSegment - nShift], - &pItems[nEndSegment - nShift], - (nCount - nEndSegment) * sizeof(ColEntry)); + &aItems[nStartSegment - nShift], + &aItems[nEndSegment - nShift], + (aItems.size() - nEndSegment) * sizeof(ColEntry)); nShift += nEndSegment - nStartSegment; bRemoved = false; } } ++aIt; } - // The last removed segment up to nCount is discarded, there's nothing - // following to be moved. + // The last removed segment up to aItems.size() is discarded, there's + // nothing following to be moved. if (bRemoved) - nShift += nCount - nStartSegment; - nCount -= nShift; + nShift += aItems.size() - nStartSegment; + aItems.erase(aItems.end() - nShift, aItems.end()); } // *** delete all formula cells *** @@ -608,17 +547,17 @@ void ScColumn::DeleteArea(SCROW nStartRow, SCROW nEndRow, sal_uInt16 nDelFlag) nContMask |= IDF_NOCAPTIONS; sal_uInt16 nContFlag = nDelFlag & nContMask; - if (pItems && nCount>0 && nContFlag) + if ( !aItems.empty() && nContFlag) { if (nStartRow==0 && nEndRow==MAXROW) - DeleteRange( 0, nCount-1, nContFlag ); + DeleteRange( 0, aItems.size()-1, nContFlag ); else { sal_Bool bFound=false; SCSIZE nStartIndex = 0; SCSIZE nEndIndex = 0; - for (SCSIZE i = 0; i < nCount; i++) - if ((pItems[i].nRow >= nStartRow) && (pItems[i].nRow <= nEndRow)) + for (SCSIZE i = 0; i < aItems.size(); i++) + if ((aItems[i].nRow >= nStartRow) && (aItems[i].nRow <= nEndRow)) { if (!bFound) { @@ -655,7 +594,7 @@ ScFormulaCell* ScColumn::CreateRefCell( ScDocument* pDestDoc, const ScAddress& r // auch bei IDF_CONTENTS komplett, wegen Notes / Broadcastern sal_Bool bMatch = false; - ScBaseCell* pCell = pItems[nIndex].pCell; + ScBaseCell* pCell = aItems[nIndex].pCell; CellType eCellType = pCell->GetCellType(); switch ( eCellType ) { @@ -668,7 +607,7 @@ ScFormulaCell* ScColumn::CreateRefCell( ScDocument* pDestDoc, const ScAddress& r else if ( nValFlags ) { sal_uLong nNumIndex = (sal_uLong)((SfxUInt32Item*)GetAttr( - pItems[nIndex].nRow, ATTR_VALUE_FORMAT ))->GetValue(); + aItems[nIndex].nRow, ATTR_VALUE_FORMAT ))->GetValue(); short nTyp = pDocument->GetFormatTable()->GetType(nNumIndex); if ((nTyp == NUMBERFORMAT_DATE) || (nTyp == NUMBERFORMAT_TIME) || (nTyp == NUMBERFORMAT_DATETIME)) bMatch = ((nFlags & IDF_DATETIME) != 0); @@ -692,7 +631,7 @@ ScFormulaCell* ScColumn::CreateRefCell( ScDocument* pDestDoc, const ScAddress& r // Referenz einsetzen ScSingleRefData aRef; aRef.nCol = nCol; - aRef.nRow = pItems[nIndex].nRow; + aRef.nRow = aItems[nIndex].nRow; aRef.nTab = nTab; aRef.InitFlags(); // -> alles absolut aRef.SetFlag3D(true); @@ -725,20 +664,20 @@ void ScColumn::CopyFromClip(SCROW nRow1, SCROW nRow2, long nDy, SCSIZE nStartIndex; rColumn.Search( nRow1-nDy, nStartIndex ); - while ( nStartIndex < rColumn.nCount && rColumn.pItems[nStartIndex].nRow <= nRow2-nDy ) + while ( nStartIndex < rColumn.aItems.size() && rColumn.aItems[nStartIndex].nRow <= nRow2-nDy ) { SCSIZE nEndIndex = nStartIndex; - if ( rColumn.pItems[nStartIndex].pCell->GetCellType() != CELLTYPE_NOTE ) + if ( rColumn.aItems[nStartIndex].pCell->GetCellType() != CELLTYPE_NOTE ) { - SCROW nStartRow = rColumn.pItems[nStartIndex].nRow; + SCROW nStartRow = rColumn.aItems[nStartIndex].nRow; SCROW nEndRow = nStartRow; // find consecutive non-empty cells while ( nEndRow < nRow2-nDy && - nEndIndex+1 < rColumn.nCount && - rColumn.pItems[nEndIndex+1].nRow == nEndRow+1 && - rColumn.pItems[nEndIndex+1].pCell->GetCellType() != CELLTYPE_NOTE ) + nEndIndex+1 < rColumn.aItems.size() && + rColumn.aItems[nEndIndex+1].nRow == nEndRow+1 && + rColumn.aItems[nEndIndex+1].pCell->GetCellType() != CELLTYPE_NOTE ) { ++nEndIndex; ++nEndRow; @@ -761,7 +700,7 @@ void ScColumn::CopyFromClip(SCROW nRow1, SCROW nRow2, long nDy, //! IDF_ALL muss immer mehr Flags enthalten, als bei "Inhalte Einfuegen" //! einzeln ausgewaehlt werden koennen! - Resize( nCount + static_cast<SCSIZE>(nRow2-nRow1+1) ); + Resize( aItems.size() + static_cast<SCSIZE>(nRow2-nRow1+1) ); ScAddress aDestPos( nCol, 0, nTab ); // Row wird angepasst @@ -787,7 +726,7 @@ void ScColumn::CopyFromClip(SCROW nRow1, SCROW nRow2, long nDy, return; } - SCSIZE nColCount = rColumn.nCount; + SCSIZE nColCount = rColumn.aItems.size(); // ignore IDF_FORMULA - "all contents but no formulas" results in the same number of cells if ((nInsFlag & ( IDF_CONTENTS & ~IDF_FORMULA )) == ( IDF_CONTENTS & ~IDF_FORMULA ) && nRow2-nRow1 >= 64) @@ -795,9 +734,8 @@ void ScColumn::CopyFromClip(SCROW nRow1, SCROW nRow2, long nDy, //! Always do the Resize from the outside, where the number of repetitions is known //! (then it can be removed here) - SCSIZE nNew = nCount + nColCount; - if ( nLimit < nNew ) - Resize( nNew ); + SCSIZE nNew = aItems.size() + nColCount; + Resize( nNew ); } // IDF_ADDNOTES must be passed without other content flags than IDF_NOTE @@ -806,7 +744,7 @@ void ScColumn::CopyFromClip(SCROW nRow1, SCROW nRow2, long nDy, sal_Bool bAtEnd = false; for (SCSIZE i = 0; i < nColCount && !bAtEnd; i++) { - SCsROW nDestRow = rColumn.pItems[i].nRow + nDy; + SCsROW nDestRow = rColumn.aItems[i].nRow + nDy; if ( nDestRow > (SCsROW) nRow2 ) bAtEnd = sal_True; else if ( nDestRow >= (SCsROW) nRow1 ) @@ -827,14 +765,14 @@ void ScColumn::CopyFromClip(SCROW nRow1, SCROW nRow2, long nDy, if (pAddNoteCell) { // do nothing if source cell does not contain a note - const ScBaseCell* pSourceCell = rColumn.pItems[i].pCell; + const ScBaseCell* pSourceCell = rColumn.aItems[i].pCell; const ScPostIt* pSourceNote = pSourceCell ? pSourceCell->GetNote() : 0; if (pSourceNote) { OSL_ENSURE( !pAddNoteCell->HasNote(), "ScColumn::CopyFromClip - unexpected note at destination cell" ); bool bCloneCaption = (nInsFlag & IDF_NOCAPTIONS) == 0; // #i52342# if caption is cloned, the note must be constructed with the destination document - ScAddress aSourcePos( rColumn.nCol, rColumn.pItems[i].nRow, rColumn.nTab ); + ScAddress aSourcePos( rColumn.nCol, rColumn.aItems[i].nRow, rColumn.nTab ); ScPostIt* pNewNote = pSourceNote->Clone( aSourcePos, *pDocument, aDestPos, bCloneCaption ); pAddNoteCell->TakeNote( pNewNote ); } @@ -882,7 +820,7 @@ ScBaseCell* ScColumn::CloneCell(SCSIZE nIndex, sal_uInt16 nFlags, ScDocument& rD bool bForceFormula = false; ScBaseCell* pNew = 0; - ScBaseCell& rSource = *pItems[nIndex].pCell; + ScBaseCell& rSource = *aItems[nIndex].pCell; switch (rSource.GetCellType()) { case CELLTYPE_NOTE: @@ -898,7 +836,7 @@ ScBaseCell* ScColumn::CloneCell(SCSIZE nIndex, sal_uInt16 nFlags, ScDocument& rD case CELLTYPE_VALUE: // note will be cloned below - if (lclCanCloneValue( *pDocument, *this, pItems[nIndex].nRow, bCloneValue, bCloneDateTime )) + if (lclCanCloneValue( *pDocument, *this, aItems[nIndex].nRow, bCloneValue, bCloneDateTime )) pNew = rSource.CloneWithoutNote( rDestDoc, rDestPos ); break; @@ -937,7 +875,7 @@ ScBaseCell* ScColumn::CloneCell(SCSIZE nIndex, sal_uInt16 nFlags, ScDocument& rD } else if (rForm.IsValue()) { - if (lclCanCloneValue( *pDocument, *this, pItems[nIndex].nRow, bCloneValue, bCloneDateTime )) + if (lclCanCloneValue( *pDocument, *this, aItems[nIndex].nRow, bCloneValue, bCloneDateTime )) { double nVal = rForm.GetValue(); pNew = new ScValueCell(nVal); @@ -973,7 +911,7 @@ ScBaseCell* ScColumn::CloneCell(SCSIZE nIndex, sal_uInt16 nFlags, ScDocument& rD { bool bCloneCaption = (nFlags & IDF_NOCAPTIONS) == 0; // #i52342# if caption is cloned, the note must be constructed with the destination document - ScAddress aOwnPos( nCol, pItems[nIndex].nRow, nTab ); + ScAddress aOwnPos( nCol, aItems[nIndex].nRow, nTab ); ScPostIt* pNewNote = pNote->Clone( aOwnPos, rDestDoc, rDestPos, bCloneCaption ); if (!pNew) pNew = new ScNoteCell( pNewNote ); @@ -1048,7 +986,7 @@ void ScColumn::MixData( SCROW nRow1, SCROW nRow2, sal_uInt16 nFunction, bool bSkipEmpty, ScColumn& rSrcCol ) { - SCSIZE nSrcCount = rSrcCol.nCount; + SCSIZE nSrcCount = rSrcCol.aItems.size(); SCSIZE nIndex; Search( nRow1, nIndex ); @@ -1058,11 +996,11 @@ void ScColumn::MixData( SCROW nRow1, SCROW nRow2, rSrcCol.Search( nRow1, nSrcIndex ); //! Testen, ob Daten ganz vorne SCROW nNextThis = MAXROW+1; - if ( nIndex < nCount ) - nNextThis = pItems[nIndex].nRow; + if ( nIndex < aItems.size() ) + nNextThis = aItems[nIndex].nRow; SCROW nNextSrc = MAXROW+1; if ( nSrcIndex < nSrcCount ) - nNextSrc = rSrcCol.pItems[nSrcIndex].nRow; + nNextSrc = rSrcCol.aItems[nSrcIndex].nRow; while ( nNextThis <= nRow2 || nNextSrc <= nRow2 ) { @@ -1074,10 +1012,10 @@ void ScColumn::MixData( SCROW nRow1, SCROW nRow2, sal_Bool bDelete = false; if ( nSrcIndex < nSrcCount && nNextSrc == nRow ) - pSrc = rSrcCol.pItems[nSrcIndex].pCell; + pSrc = rSrcCol.aItems[nSrcIndex].pCell; - if ( nIndex < nCount && nNextThis == nRow ) - pDest = pItems[nIndex].pCell; + if ( nIndex < aItems.size() && nNextThis == nRow ) + pDest = aItems[nIndex].pCell; OSL_ENSURE( pSrc || pDest, "Nanu ?" ); @@ -1201,19 +1139,19 @@ void ScColumn::MixData( SCROW nRow1, SCROW nRow2, if (pNew) nNextThis = nRow; // nIndex zeigt jetzt genau auf nRow else - nNextThis = ( nIndex < nCount ) ? pItems[nIndex].nRow : MAXROW+1; + nNextThis = ( nIndex < aItems.size() ) ? aItems[nIndex].nRow : MAXROW+1; } if ( nNextThis == nRow ) { ++nIndex; - nNextThis = ( nIndex < nCount ) ? pItems[nIndex].nRow : MAXROW+1; + nNextThis = ( nIndex < aItems.size() ) ? aItems[nIndex].nRow : MAXROW+1; } if ( nNextSrc == nRow ) { ++nSrcIndex; nNextSrc = ( nSrcIndex < nSrcCount ) ? - rSrcCol.pItems[nSrcIndex].nRow : + rSrcCol.aItems[nSrcIndex].nRow : MAXROW+1; } } @@ -1228,15 +1166,15 @@ ScAttrIterator* ScColumn::CreateAttrIterator( SCROW nStartRow, SCROW nEndRow ) c void ScColumn::StartAllListeners() { - if (pItems) - for (SCSIZE i = 0; i < nCount; i++) + if ( !aItems.empty() ) + for (SCSIZE i = 0; i < aItems.size(); i++) { - ScBaseCell* pCell = pItems[i].pCell; + ScBaseCell* pCell = aItems[i].pCell; if ( pCell->GetCellType() == CELLTYPE_FORMULA ) { - SCROW nRow = pItems[i].nRow; + SCROW nRow = aItems[i].nRow; ((ScFormulaCell*)pCell)->StartListeningTo( pDocument ); - if ( nRow != pItems[i].nRow ) + if ( nRow != aItems[i].nRow ) Search( nRow, i ); // Listener eingefuegt? } } @@ -1245,19 +1183,19 @@ void ScColumn::StartAllListeners() void ScColumn::StartNeededListeners() { - if (pItems) + if ( !aItems.empty() ) { - for (SCSIZE i = 0; i < nCount; i++) + for (SCSIZE i = 0; i < aItems.size(); i++) { - ScBaseCell* pCell = pItems[i].pCell; + ScBaseCell* pCell = aItems[i].pCell; if ( pCell->GetCellType() == CELLTYPE_FORMULA ) { ScFormulaCell* pFCell = static_cast<ScFormulaCell*>(pCell); if (pFCell->NeedsListening()) { - SCROW nRow = pItems[i].nRow; + SCROW nRow = aItems[i].nRow; pFCell->StartListeningTo( pDocument ); - if ( nRow != pItems[i].nRow ) + if ( nRow != aItems[i].nRow ) Search( nRow, i ); // Listener eingefuegt? } } @@ -1268,14 +1206,14 @@ void ScColumn::StartNeededListeners() void ScColumn::BroadcastInArea( SCROW nRow1, SCROW nRow2 ) { - if ( pItems ) + if ( !aItems.empty() ) { SCROW nRow; SCSIZE nIndex; Search( nRow1, nIndex ); - while ( nIndex < nCount && (nRow = pItems[nIndex].nRow) <= nRow2 ) + while ( nIndex < aItems.size() && (nRow = aItems[nIndex].nRow) <= nRow2 ) { - ScBaseCell* pCell = pItems[nIndex].pCell; + ScBaseCell* pCell = aItems[nIndex].pCell; if ( pCell->GetCellType() == CELLTYPE_FORMULA ) ((ScFormulaCell*)pCell)->SetDirty(); else @@ -1289,17 +1227,17 @@ void ScColumn::BroadcastInArea( SCROW nRow1, SCROW nRow2 ) void ScColumn::StartListeningInArea( SCROW nRow1, SCROW nRow2 ) { - if ( pItems ) + if ( !aItems.empty() ) { SCROW nRow; SCSIZE nIndex; Search( nRow1, nIndex ); - while ( nIndex < nCount && (nRow = pItems[nIndex].nRow) <= nRow2 ) + while ( nIndex < aItems.size() && (nRow = aItems[nIndex].nRow) <= nRow2 ) { - ScBaseCell* pCell = pItems[nIndex].pCell; + ScBaseCell* pCell = aItems[nIndex].pCell; if ( pCell->GetCellType() == CELLTYPE_FORMULA ) ((ScFormulaCell*)pCell)->StartListeningTo( pDocument ); - if ( nRow != pItems[nIndex].nRow ) + if ( nRow != aItems[nIndex].nRow ) Search( nRow, nIndex ); // durch Listening eingefuegt nIndex++; } @@ -1375,17 +1313,17 @@ bool ScColumn::SetString( SCROW nRow, SCTAB nTabP, const String& rString, sal_Bool bIsText = false; if ( bIsLoading ) { - if ( pItems && nCount ) + if ( !aItems.empty() ) { String aStr; - SCSIZE i = nCount; + SCSIZE i = aItems.size(); SCSIZE nStop = (i >= 3 ? i - 3 : 0); // die letzten Zellen vergleichen, ob gleicher String // und IsNumberFormat eingespart werden kann do { i--; - ScBaseCell* pCell = pItems[i].pCell; + ScBaseCell* pCell = aItems[i].pCell; switch ( pCell->GetCellType() ) { case CELLTYPE_STRING : @@ -1396,7 +1334,7 @@ bool ScColumn::SetString( SCROW nRow, SCTAB nTabP, const String& rString, case CELLTYPE_NOTE : // durch =Formel referenziert break; default: - if ( i == nCount - 1 ) + if ( i == aItems.size() - 1 ) i = 0; // wahrscheinlich ganze Spalte kein String } @@ -1501,7 +1439,7 @@ bool ScColumn::SetString( SCROW nRow, SCTAB nTabP, const String& rString, } } - if ( bIsLoading && (!nCount || nRow > pItems[nCount-1].nRow) ) + if ( bIsLoading && (aItems.empty() || nRow > aItems[aItems.size()-1].nRow) ) { // Search einsparen und ohne Umweg ueber Insert, Listener aufbauen // und Broadcast kommt eh erst nach dem Laden if ( pNewCell ) @@ -1512,7 +1450,7 @@ bool ScColumn::SetString( SCROW nRow, SCTAB nTabP, const String& rString, SCSIZE i; if (Search(nRow, i)) { - ScBaseCell* pOldCell = pItems[i].pCell; + ScBaseCell* pOldCell = aItems[i].pCell; ScPostIt* pNote = pOldCell->ReleaseNote(); SvtBroadcaster* pBC = pOldCell->ReleaseBroadcaster(); if (pNewCell || pNote || pBC) @@ -1531,11 +1469,11 @@ bool ScColumn::SetString( SCROW nRow, SCTAB nTabP, const String& rString, { pOldCell->EndListeningTo( pDocument ); // falls in EndListening NoteCell in gleicher Col zerstoert - if ( i >= nCount || pItems[i].nRow != nRow ) + if ( i >= aItems.size() || aItems[i].nRow != nRow ) Search(nRow, i); } pOldCell->Delete(); - pItems[i].pCell = pNewCell; // ersetzen + aItems[i].pCell = pNewCell; // ersetzen if ( pNewCell->GetCellType() == CELLTYPE_FORMULA ) { pNewCell->StartListeningTo( pDocument ); @@ -1573,9 +1511,9 @@ void ScColumn::GetFilterEntries(SCROW nStartRow, SCROW nEndRow, TypedScStrCollec Search( nStartRow, nIndex ); - while ( (nIndex < nCount) ? ((nRow=pItems[nIndex].nRow) <= nEndRow) : false ) + while ( (nIndex < aItems.size()) ? ((nRow=aItems[nIndex].nRow) <= nEndRow) : false ) { - ScBaseCell* pCell = pItems[nIndex].pCell; + ScBaseCell* pCell = aItems[nIndex].pCell; TypedStrData* pData = NULL; sal_uLong nFormat = GetNumberFormat( nRow ); @@ -1667,11 +1605,11 @@ bool ScColumn::GetDataEntries(SCROW nStartRow, TypedScStrCollection& rStrings, b if (bThisUsed) ++nDownIndex; // Startzelle ueberspringen - while ( nUpIndex || nDownIndex < nCount ) + while ( nUpIndex || nDownIndex < aItems.size() ) { if ( nUpIndex ) // nach oben { - ScBaseCell* pCell = pItems[nUpIndex-1].pCell; + ScBaseCell* pCell = aItems[nUpIndex-1].pCell; CellType eType = pCell->GetCellType(); if (eType == CELLTYPE_STRING || eType == CELLTYPE_EDIT) // nur Strings interessieren { @@ -1694,9 +1632,9 @@ bool ScColumn::GetDataEntries(SCROW nStartRow, TypedScStrCollection& rStrings, b --nUpIndex; } - if ( nDownIndex < nCount ) // nach unten + if ( nDownIndex < aItems.size() ) // nach unten { - ScBaseCell* pCell = pItems[nDownIndex].pCell; + ScBaseCell* pCell = aItems[nDownIndex].pCell; CellType eType = pCell->GetCellType(); if (eType == CELLTYPE_STRING || eType == CELLTYPE_EDIT) // nur Strings interessieren { @@ -1742,21 +1680,21 @@ void ScColumn::RemoveProtected( SCROW nStartRow, SCROW nEndRow ) else if ( pAttr->GetHideFormula() ) { Search( nTop, nIndex ); - while ( nIndex<nCount && pItems[nIndex].nRow<=nBottom ) + while ( nIndex<aItems.size() && aItems[nIndex].nRow<=nBottom ) { - if ( pItems[nIndex].pCell->GetCellType() == CELLTYPE_FORMULA ) + if ( aItems[nIndex].pCell->GetCellType() == CELLTYPE_FORMULA ) { - ScFormulaCell* pFormula = (ScFormulaCell*)pItems[nIndex].pCell; + ScFormulaCell* pFormula = (ScFormulaCell*)aItems[nIndex].pCell; if (pFormula->IsValue()) { double nVal = pFormula->GetValue(); - pItems[nIndex].pCell = new ScValueCell( nVal ); + aItems[nIndex].pCell = new ScValueCell( nVal ); } else { String aString; pFormula->GetString(aString); - pItems[nIndex].pCell = new ScStringCell( aString ); + aItems[nIndex].pCell = new ScStringCell( aString ); } delete pFormula; } @@ -1797,7 +1735,7 @@ void ScColumn::GetString( SCROW nRow, rtl::OUString& rString ) const Color* pColor; if (Search(nRow, nIndex)) { - ScBaseCell* pCell = pItems[nIndex].pCell; + ScBaseCell* pCell = aItems[nIndex].pCell; if (pCell->GetCellType() != CELLTYPE_NOTE) { sal_uLong nFormat = GetNumberFormat( nRow ); @@ -1816,7 +1754,7 @@ void ScColumn::GetInputString( SCROW nRow, rtl::OUString& rString ) const SCSIZE nIndex; if (Search(nRow, nIndex)) { - ScBaseCell* pCell = pItems[nIndex].pCell; + ScBaseCell* pCell = aItems[nIndex].pCell; if (pCell->GetCellType() != CELLTYPE_NOTE) { sal_uLong nFormat = GetNumberFormat( nRow ); @@ -1835,7 +1773,7 @@ double ScColumn::GetValue( SCROW nRow ) const SCSIZE nIndex; if (Search(nRow, nIndex)) { - ScBaseCell* pCell = pItems[nIndex].pCell; + ScBaseCell* pCell = aItems[nIndex].pCell; switch (pCell->GetCellType()) { case CELLTYPE_VALUE: @@ -1863,7 +1801,7 @@ void ScColumn::GetFormula( SCROW nRow, rtl::OUString& rFormula ) const SCSIZE nIndex; if (Search(nRow, nIndex)) { - ScBaseCell* pCell = pItems[nIndex].pCell; + ScBaseCell* pCell = aItems[nIndex].pCell; if (pCell->GetCellType() == CELLTYPE_FORMULA) ((ScFormulaCell*)pCell)->GetFormula( rFormula ); else @@ -1878,7 +1816,7 @@ CellType ScColumn::GetCellType( SCROW nRow ) const { SCSIZE nIndex; if (Search(nRow, nIndex)) - return pItems[nIndex].pCell->GetCellType(); + return aItems[nIndex].pCell->GetCellType(); return CELLTYPE_NONE; } @@ -1888,7 +1826,7 @@ sal_uInt16 ScColumn::GetErrCode( SCROW nRow ) const SCSIZE nIndex; if (Search(nRow, nIndex)) { - ScBaseCell* pCell = pItems[nIndex].pCell; + ScBaseCell* pCell = aItems[nIndex].pCell; if (pCell->GetCellType() == CELLTYPE_FORMULA) return ((ScFormulaCell*)pCell)->GetErrCode(); } @@ -1900,7 +1838,7 @@ bool ScColumn::HasStringData( SCROW nRow ) const { SCSIZE nIndex; if (Search(nRow, nIndex)) - return (pItems[nIndex].pCell)->HasStringData(); + return (aItems[nIndex].pCell)->HasStringData(); return false; } @@ -1909,7 +1847,7 @@ bool ScColumn::HasValueData( SCROW nRow ) const { SCSIZE nIndex; if (Search(nRow, nIndex)) - return (pItems[nIndex].pCell)->HasValueData(); + return (aItems[nIndex].pCell)->HasValueData(); return false; } @@ -1917,13 +1855,13 @@ bool ScColumn::HasStringCells( SCROW nStartRow, SCROW nEndRow ) const { // TRUE, wenn String- oder Editzellen im Bereich - if ( pItems ) + if ( !aItems.empty() ) { SCSIZE nIndex; Search( nStartRow, nIndex ); - while ( nIndex < nCount && pItems[nIndex].nRow <= nEndRow ) + while ( nIndex < aItems.size() && aItems[nIndex].nRow <= nEndRow ) { - CellType eType = pItems[nIndex].pCell->GetCellType(); + CellType eType = aItems[nIndex].pCell->GetCellType(); if ( eType == CELLTYPE_STRING || eType == CELLTYPE_EDIT ) return sal_True; ++nIndex; @@ -1936,7 +1874,7 @@ bool ScColumn::HasStringCells( SCROW nStartRow, SCROW nEndRow ) const ScPostIt* ScColumn::GetNote( SCROW nRow ) { SCSIZE nIndex; - return Search( nRow, nIndex ) ? pItems[ nIndex ].pCell->GetNote() : 0; + return Search( nRow, nIndex ) ? aItems[ nIndex ].pCell->GetNote() : 0; } @@ -1944,7 +1882,7 @@ void ScColumn::TakeNote( SCROW nRow, ScPostIt* pNote ) { SCSIZE nIndex; if( Search( nRow, nIndex ) ) - pItems[ nIndex ].pCell->TakeNote( pNote ); + aItems[ nIndex ].pCell->TakeNote( pNote ); else Insert( nRow, new ScNoteCell( pNote ) ); } @@ -1956,7 +1894,7 @@ ScPostIt* ScColumn::ReleaseNote( SCROW nRow ) SCSIZE nIndex; if( Search( nRow, nIndex ) ) { - ScBaseCell* pCell = pItems[ nIndex ].pCell; + ScBaseCell* pCell = aItems[ nIndex ].pCell; pNote = pCell->ReleaseNote(); if( (pCell->GetCellType() == CELLTYPE_NOTE) && !pCell->GetBroadcaster() ) DeleteAtIndex( nIndex ); @@ -1974,7 +1912,7 @@ void ScColumn::DeleteNote( SCROW nRow ) sal_Int32 ScColumn::GetMaxStringLen( SCROW nRowStart, SCROW nRowEnd, CharSet eCharSet ) const { sal_Int32 nStringLen = 0; - if ( pItems ) + if ( !aItems.empty() ) { rtl::OUString aString; rtl::OString aOString; @@ -1983,9 +1921,9 @@ sal_Int32 ScColumn::GetMaxStringLen( SCROW nRowStart, SCROW nRowEnd, CharSet eCh SCSIZE nIndex; SCROW nRow; Search( nRowStart, nIndex ); - while ( nIndex < nCount && (nRow = pItems[nIndex].nRow) <= nRowEnd ) + while ( nIndex < aItems.size() && (nRow = aItems[nIndex].nRow) <= nRowEnd ) { - ScBaseCell* pCell = pItems[nIndex].pCell; + ScBaseCell* pCell = aItems[nIndex].pCell; if ( pCell->GetCellType() != CELLTYPE_NOTE ) { Color* pColor; @@ -2028,16 +1966,16 @@ xub_StrLen ScColumn::GetMaxNumberStringLen( // In case of unlimited precision, use 2 instead. nPrecision = 2; - if ( pItems ) + if ( !aItems.empty() ) { rtl::OUString aString; SvNumberFormatter* pNumFmt = pDocument->GetFormatTable(); SCSIZE nIndex; SCROW nRow; Search( nRowStart, nIndex ); - while ( nIndex < nCount && (nRow = pItems[nIndex].nRow) <= nRowEnd ) + while ( nIndex < aItems.size() && (nRow = aItems[nIndex].nRow) <= nRowEnd ) { - ScBaseCell* pCell = pItems[nIndex].pCell; + ScBaseCell* pCell = aItems[nIndex].pCell; CellType eType = pCell->GetCellType(); if ( eType == CELLTYPE_VALUE || (eType == CELLTYPE_FORMULA && ((ScFormulaCell*)pCell)->IsValue()) ) diff --git a/sc/source/core/data/dociter.cxx b/sc/source/core/data/dociter.cxx index fd6bd286d725..435cf7c1ac3c 100644 --- a/sc/source/core/data/dociter.cxx +++ b/sc/source/core/data/dociter.cxx @@ -128,7 +128,7 @@ sal_Bool ScDocumentIterator::GetThisCol() do { - nColRow = (nColPos < pCol->nCount) ? pCol->pItems[nColPos].nRow : MAXROW+1; + nColRow = (nColPos < pCol->aItems.size()) ? pCol->aItems[nColPos].nRow : MAXROW+1; if (nColRow < nRow) ++nColPos; } @@ -137,7 +137,7 @@ sal_Bool ScDocumentIterator::GetThisCol() if (nColRow == nRow) { bFound = sal_True; - pCell = pCol->pItems[nColPos].pCell; + pCell = pCol->aItems[nColPos].pCell; pPattern = pAtt->pData[nAttrPos].pPattern; } else if ( pAtt->pData[nAttrPos].pPattern != pDefPattern ) @@ -311,19 +311,19 @@ sal_Bool ScValueIterator::GetThis(double& rValue, sal_uInt16& rErr) } } pCol = &(pDoc->maTabs[nTab])->aCol[nCol]; - } while ( pCol->nCount == 0 ); + } while ( pCol->aItems.size() == 0 ); pCol->Search( nRow, nColRow ); } - while (( nColRow < pCol->nCount ) && ( pCol->pItems[nColRow].nRow < nRow )) + while (( nColRow < pCol->aItems.size() ) && ( pCol->aItems[nColRow].nRow < nRow )) nColRow++; - if ( nColRow < pCol->nCount && pCol->pItems[nColRow].nRow <= nEndRow ) + if ( nColRow < pCol->aItems.size() && pCol->aItems[nColRow].nRow <= nEndRow ) { - nRow = pCol->pItems[nColRow].nRow + 1; + nRow = pCol->aItems[nColRow].nRow + 1; if ( !bSubTotal || !pDoc->maTabs[nTab]->RowFiltered( nRow-1 ) ) { - ScBaseCell* pCell = pCol->pItems[nColRow].pCell; + ScBaseCell* pCell = pCol->aItems[nColRow].pCell; ++nColRow; switch (pCell->GetCellType()) { @@ -343,13 +343,13 @@ sal_Bool ScValueIterator::GetThis(double& rValue, sal_uInt16& rErr) // wenn in der selben Spalte gleich noch eine Value-Cell folgt, die // auch noch im Block liegt, den Wert jetzt schon holen // - if ( nColRow < pCol->nCount && - pCol->pItems[nColRow].nRow <= nEndRow && - pCol->pItems[nColRow].pCell->GetCellType() == CELLTYPE_VALUE && + if ( nColRow < pCol->aItems.size() && + pCol->aItems[nColRow].nRow <= nEndRow && + pCol->aItems[nColRow].pCell->GetCellType() == CELLTYPE_VALUE && !bSubTotal ) { - fNextValue = ((ScValueCell*)pCol->pItems[nColRow].pCell)->GetValue(); - nNextRow = pCol->pItems[nColRow].nRow; + fNextValue = ((ScValueCell*)pCol->aItems[nColRow].pCell)->GetValue(); + nNextRow = pCol->aItems[nColRow].nRow; bNextValid = sal_True; if ( bCalcAsShown ) { @@ -422,12 +422,12 @@ void ScValueIterator::GetCurNumFmtInfo( short& nType, sal_uLong& nIndex ) const ScBaseCell* pCell; SCSIZE nIdx = nColRow - 1; // there might be rearranged something, so be on the safe side - if ( nIdx < pCol->nCount && pCol->pItems[nIdx].nRow == nRow ) - pCell = pCol->pItems[nIdx].pCell; + if ( nIdx < pCol->aItems.size() && pCol->aItems[nIdx].nRow == nRow ) + pCell = pCol->aItems[nIdx].pCell; else { if ( pCol->Search( nRow, nIdx ) ) - pCell = pCol->pItems[nIdx].pCell; + pCell = pCol->aItems[nIdx].pCell; else pCell = NULL; } @@ -478,7 +478,7 @@ SCROW ScDBQueryDataIterator::GetRowByColEntryIndex(ScDocument& rDoc, SCTAB nTab, if (nTab >= rDoc.GetTableCount()) OSL_FAIL("try to access index out of bounds, FIX IT"); ScColumn* pCol = &rDoc.maTabs[nTab]->aCol[nCol]; - return pCol->pItems[nColRow].nRow; + return pCol->aItems[nColRow].nRow; } ScBaseCell* ScDBQueryDataIterator::GetCellByColEntryIndex(ScDocument& rDoc, SCTAB nTab, SCCOL nCol, SCSIZE nColRow) @@ -486,7 +486,7 @@ ScBaseCell* ScDBQueryDataIterator::GetCellByColEntryIndex(ScDocument& rDoc, SCTA if (nTab >= rDoc.GetTableCount()) OSL_FAIL("try to access index out of bounds, FIX IT"); ScColumn* pCol = &rDoc.maTabs[nTab]->aCol[nCol]; - return pCol->pItems[nColRow].pCell; + return pCol->aItems[nColRow].pCell; } ScAttrArray* ScDBQueryDataIterator::GetAttrArrayByCol(ScDocument& rDoc, SCTAB nTab, SCCOL nCol) @@ -1040,19 +1040,19 @@ ScBaseCell* ScCellIterator::GetThis() return NULL; // Ende und Aus } pCol = &(pDoc->maTabs[nTab])->aCol[nCol]; - } while ( pCol->nCount == 0 ); + } while ( pCol->aItems.size() == 0 ); pCol->Search( nRow, nColRow ); } - while ( (nColRow < pCol->nCount) && (pCol->pItems[nColRow].nRow < nRow) ) + while ( (nColRow < pCol->aItems.size()) && (pCol->aItems[nColRow].nRow < nRow) ) nColRow++; - if ( nColRow < pCol->nCount && pCol->pItems[nColRow].nRow <= nEndRow ) + if ( nColRow < pCol->aItems.size() && pCol->aItems[nColRow].nRow <= nEndRow ) { - nRow = pCol->pItems[nColRow].nRow; + nRow = pCol->aItems[nColRow].nRow; if ( !bSubTotal || !pDoc->maTabs[nTab]->RowFiltered( nRow ) ) { - ScBaseCell* pCell = pCol->pItems[nColRow].pCell; + ScBaseCell* pCell = pCol->aItems[nColRow].pCell; if ( bSubTotal && pCell->GetCellType() == CELLTYPE_FORMULA && ((ScFormulaCell*)pCell)->IsSubTotal() ) @@ -1152,20 +1152,20 @@ ScBaseCell* ScQueryCellIterator::GetThis() nFirstQueryField = rEntry.nField; } pCol = &(pDoc->maTabs[nTab])->aCol[nCol]; - } while ( pCol->nCount == 0 ); + } while ( pCol->aItems.size() == 0 ); pCol->Search( nRow, nColRow ); bFirstStringIgnore = bIgnoreMismatchOnLeadingStrings && !mpParam->bHasHeader && rItem.meType == ScQueryEntry::ByString && mpParam->bByRow; } - while ( nColRow < pCol->nCount && pCol->pItems[nColRow].nRow < nRow ) + while ( nColRow < pCol->aItems.size() && pCol->aItems[nColRow].nRow < nRow ) nColRow++; - if ( nColRow < pCol->nCount && - (nRow = pCol->pItems[nColRow].nRow) <= mpParam->nRow2 ) + if ( nColRow < pCol->aItems.size() && + (nRow = pCol->aItems[nColRow].nRow) <= mpParam->nRow2 ) { - ScBaseCell* pCell = pCol->pItems[nColRow].pCell; + ScBaseCell* pCell = pCol->aItems[nColRow].pCell; if ( pCell->GetCellType() == CELLTYPE_NOTE ) ++nRow; else if (bAllStringIgnore && pCell->HasStringData()) @@ -1394,7 +1394,7 @@ ScBaseCell* ScQueryCellIterator::BinarySearch() OSL_FAIL("try to access index out of bounds, FIX IT"); nCol = mpParam->nCol1; ScColumn* pCol = &(pDoc->maTabs[nTab])->aCol[nCol]; - if (!pCol->nCount) + if (!pCol->aItems.size()) return 0; ScBaseCell* pCell; @@ -1413,13 +1413,12 @@ ScBaseCell* ScQueryCellIterator::BinarySearch() nRow = mpParam->nRow1; if (mpParam->bHasHeader) nRow++; - const ColEntry* pItems = pCol->pItems; if (pCol->Search( nRow, nLo ) && bFirstStringIgnore && - pItems[nLo].pCell->HasStringData()) + pCol->aItems[nLo].pCell->HasStringData()) { rtl::OUString aCellStr; - sal_uLong nFormat = pCol->GetNumberFormat( pItems[nLo].nRow); - ScCellFormat::GetInputString( pItems[nLo].pCell, nFormat, aCellStr, + sal_uLong nFormat = pCol->GetNumberFormat( pCol->aItems[nLo].nRow); + ScCellFormat::GetInputString( pCol->aItems[nLo].pCell, nFormat, aCellStr, rFormatter); sal_Int32 nTmp = pCollator->compareString(aCellStr, rEntry.GetQueryItem().maString); if ((rEntry.eOp == SC_LESS_EQUAL && nTmp > 0) || @@ -1429,8 +1428,8 @@ ScBaseCell* ScQueryCellIterator::BinarySearch() } if (!pCol->Search( mpParam->nRow2, nHi ) && nHi>0) --nHi; - while (bAllStringIgnore && nLo <= nHi && nLo < pCol->nCount && - pItems[nLo].pCell->HasStringData()) + while (bAllStringIgnore && nLo <= nHi && nLo < pCol->aItems.size() && + pCol->aItems[nLo].pCell->HasStringData()) ++nLo; // Bookkeeping values for breaking up the binary search in case the data @@ -1443,12 +1442,12 @@ ScBaseCell* ScQueryCellIterator::BinarySearch() String aLastInRangeString; if (!bLessEqual) aLastInRangeString.Assign( sal_Unicode(0xFFFF)); - if (nLastInRange < pCol->nCount) + if (nLastInRange < pCol->aItems.size()) { - pCell = pItems[nLastInRange].pCell; + pCell = pCol->aItems[nLastInRange].pCell; if (pCell->HasStringData()) { - sal_uLong nFormat = pCol->GetNumberFormat( pItems[nLastInRange].nRow); + sal_uLong nFormat = pCol->GetNumberFormat( pCol->aItems[nLastInRange].nRow); rtl::OUString aStr; ScCellFormat::GetInputString( pCell, nFormat, aStr, rFormatter); @@ -1481,7 +1480,7 @@ ScBaseCell* ScQueryCellIterator::BinarySearch() { SCSIZE nMid = (nLo+nHi)/2; SCSIZE i = nMid; - while (i <= nHi && pItems[i].pCell->GetCellType() == CELLTYPE_NOTE) + while (i <= nHi && pCol->aItems[i].pCell->GetCellType() == CELLTYPE_NOTE) ++i; if (i > nHi) { @@ -1491,14 +1490,14 @@ ScBaseCell* ScQueryCellIterator::BinarySearch() bDone = true; continue; // while } - sal_Bool bStr = pItems[i].pCell->HasStringData(); + sal_Bool bStr = pCol->aItems[i].pCell->HasStringData(); nRes = 0; // compares are content<query:-1, content>query:1 // Cell value comparison similar to ScTable::ValidQuery() if (!bStr && !bByString) { double nCellVal; - pCell = pItems[i].pCell; + pCell = pCol->aItems[i].pCell; switch ( pCell->GetCellType() ) { case CELLTYPE_VALUE : @@ -1552,8 +1551,8 @@ ScBaseCell* ScQueryCellIterator::BinarySearch() else if (bStr && bByString) { rtl::OUString aCellStr; - sal_uLong nFormat = pCol->GetNumberFormat( pItems[i].nRow); - ScCellFormat::GetInputString( pItems[i].pCell, nFormat, aCellStr, + sal_uLong nFormat = pCol->GetNumberFormat( pCol->aItems[i].nRow); + ScCellFormat::GetInputString( pCol->aItems[i].pCell, nFormat, aCellStr, rFormatter); nRes = pCollator->compareString(aCellStr, rEntry.GetQueryItem().maString); if (nRes < 0 && bLessEqual) @@ -1643,17 +1642,17 @@ ScBaseCell* ScQueryCellIterator::BinarySearch() // --nLo with nLastInRange == nLo-1. Both conditions combined yield: nLo = nLastInRange; } - if (nLo < pCol->nCount && pCol->pItems[nLo].nRow <= mpParam->nRow2) + if (nLo < pCol->aItems.size() && pCol->aItems[nLo].nRow <= mpParam->nRow2) { - nRow = pItems[nLo].nRow; - pCell = pItems[nLo].pCell; + nRow = pCol->aItems[nLo].nRow; + pCell = pCol->aItems[nLo].pCell; nColRow = nLo; } else { nRow = mpParam->nRow2 + 1; pCell = 0; - nColRow = pCol->nCount - 1; + nColRow = pCol->aItems.size() - 1; } return pCell; } @@ -1701,9 +1700,9 @@ void ScHorizontalCellIterator::SetTab( SCTAB nTabP ) SCSIZE nIndex; pCol->Search( nStartRow, nIndex ); - if ( nIndex < pCol->nCount ) + if ( nIndex < pCol->aItems.size() ) { - pNextRows[i-nStartCol] = pCol->pItems[nIndex].nRow; + pNextRows[i-nStartCol] = pCol->aItems[nIndex].nRow; pNextIndices[i-nStartCol] = nIndex; } else @@ -1726,11 +1725,11 @@ ScBaseCell* ScHorizontalCellIterator::GetNext( SCCOL& rCol, SCROW& rRow ) ScColumn* pCol = &pDoc->maTabs[nTab]->aCol[nCol]; SCSIZE nIndex = pNextIndices[nCol-nStartCol]; - OSL_ENSURE( nIndex < pCol->nCount, "ScHorizontalCellIterator::GetNext: nIndex out of range" ); - ScBaseCell* pCell = pCol->pItems[nIndex].pCell; - if ( ++nIndex < pCol->nCount ) + OSL_ENSURE( nIndex < pCol->aItems.size(), "ScHorizontalCellIterator::GetNext: nIndex out of range" ); + ScBaseCell* pCell = pCol->aItems[nIndex].pCell; + if ( ++nIndex < pCol->aItems.size() ) { - pNextRows[nCol-nStartCol] = pCol->pItems[nIndex].nRow; + pNextRows[nCol-nStartCol] = pCol->aItems[nIndex].nRow; pNextIndices[nCol-nStartCol] = nIndex; } else @@ -1920,7 +1919,7 @@ void ScHorizontalValueIterator::GetCurNumFmtInfo( short& nType, sal_uLong& nInde const ScBaseCell* pCell; SCSIZE nCurIndex; if ( pCol->Search( nCurRow, nCurIndex ) ) - pCell = pCol->pItems[nCurIndex].pCell; + pCell = pCol->aItems[nCurIndex].pCell; else pCell = NULL; if ( pCell && pCell->GetCellType() == CELLTYPE_FORMULA ) diff --git a/sc/source/core/data/fillinfo.cxx b/sc/source/core/data/fillinfo.cxx index fab616115b53..6729290738b9 100644 --- a/sc/source/core/data/fillinfo.cxx +++ b/sc/source/core/data/fillinfo.cxx @@ -390,8 +390,8 @@ void ScDocument::FillInfo( ScTableInfo& rTabInfo, SCCOL nX1, SCROW nY1, SCCOL nX bool bHiddenRow = true; SCROW nHiddenEndRow = -1; (void) pThisCol->Search( nY1, nUIndex ); - while ( nUIndex < pThisCol->nCount && - (nThisRow=pThisCol->pItems[nUIndex].nRow) <= nY2 ) + while ( nUIndex < pThisCol->aItems.size() && + (nThisRow=pThisCol->aItems[nUIndex].nRow) <= nY2 ) { if (nThisRow > nHiddenEndRow) bHiddenRow = RowHidden( nThisRow, nTab, NULL, &nHiddenEndRow); @@ -403,7 +403,7 @@ void ScDocument::FillInfo( ScTableInfo& rTabInfo, SCCOL nX1, SCROW nY1, SCCOL nX RowInfo* pThisRowInfo = &pRowInfo[nArrY]; CellInfo* pInfo = &pThisRowInfo->pCellInfo[nArrX]; - pInfo->pCell = pThisCol->pItems[nUIndex].pCell; + pInfo->pCell = pThisCol->aItems[nUIndex].pCell; if (pInfo->pCell->GetCellType() != CELLTYPE_NOTE) { pThisRowInfo->bEmptyText = false; // Zeile nicht leer |