BOOL CVTExtended::procFillColumn(CValue** params) { //param 0 CVTExtIndex *pIndex = GetIndex(params[0]); //param 1 int nDestCol = ColumnNumber(params[1]); //param 2 CValue const& Value = *(params[2]); CVTExtended* pVTExt = CValue2VTExt(Value); CValueTable* pVT = CValue2VT(Value); CPtrArray* ppValueList = CValue2VL(Value); CVTExtIterator* pIterator = pIndex->CreateIterator(); /* // bool bNeedReindex = Indexes.ColumnIndexed(nDestCol); // bool *bChangedRows; // if( bNeedReindex ) // { // bChangedRows = new bool[GetRowsCount()]; // memset((void*)bChangedRows, 0, sizeof(bool) * GetRowsCount()); // } */ if( ppValueList ) { int nValue = 0, nValues = ppValueList->GetSize(); pIterator->First(); while( nValue < nValues && pIterator->Next() ) { CValue *pVal = (CValue*)(ppValueList->GetAt(nValue)); pIterator->CurrentRow()->SetValue(nDestCol, *pVal); Indexes.OnChangeValue(pIterator->CurrentRowIndex(), nDestCol); // if( bNeedReindex ) bChangedRows[pIterator->CurrentRowIndex()] = true; nValue++; } } else if( pVT ) { int nSrcCol = GetVTColumnNumber(pVT, params[3], params[1]); if( nSrcCol < 0 || nSrcCol >= pVT->GetColumnCount() ) RuntimeError("Неверно указана колонка в таблице-источнике!"); int nSrcRow = 0, nSrcRows = pVT->GetRowCount(); pIterator->First(); while( nSrcRow < nSrcRows && pIterator->Next() ) { CValue const& Value = pVT->GetValue(nSrcCol, nSrcRow); pIterator->CurrentRow()->SetValue(nDestCol, Value); Indexes.OnChangeValue(pIterator->CurrentRowIndex(), nDestCol); // if( bNeedReindex ) bChangedRows[pIterator->CurrentRowIndex()] = true; nSrcRow++; } } else if( pVTExt ) { CVTExtIndex *pSrcIndex = pVTExt->GetIndex(params[3]); int nSrcCol = GetVTColumnNumber(pVTExt, params[4], params[1]); if( nSrcCol < 0 || nSrcCol >= pVTExt->GetColumnsCount() ) RuntimeError("Неверно указана колонка в таблице-источнике!"); CVTExtIterator* pSrcIterator = pSrcIndex->CreateIterator(); pIterator->First(); pSrcIterator->First(); while( pIterator->Next() && pSrcIterator->Next() ) { CValue const& Value = pSrcIterator->CurrentRow()->GetValue(nSrcCol); pIterator->CurrentRow()->SetValue(nDestCol, Value); Indexes.OnChangeValue(pIterator->CurrentRowIndex(), nDestCol); // if( bNeedReindex ) bChangedRows[pIterator->CurrentRowIndex()] = true; } delete pSrcIterator; } else { pIterator->First(); while( pIterator->Next() ) { pIterator->CurrentRow()->SetValue(nDestCol, Value); Indexes.OnChangeValue(pIterator->CurrentRowIndex(), nDestCol); // if( bNeedReindex ) bChangedRows[pIterator->CurrentRowIndex()] = true; } } delete pIterator; /* // // if( bNeedReindex ) // { // for( int i = GetRowsCount() - 1; i >= 0; i-- ) // if( bChangedRows[i] ) // Indexes.OnChangeValue(i, nDestCol); // // if( bChangedRows[i] ) Indexes.OnChangeRow(i); // delete[] bChangedRows; // } */ return TRUE; }