cellsChanged()

in packages/core/micro/src/sheetlet.ts [327:370]


    cellsChanged(rowStart: number, colStart: number, rowCount: number, colCount: number) {
        const endR = rowStart + rowCount;
        const endC = colStart + colCount;
        const dirty = this.createDirtier();
        for (let i = rowStart; i < endR; i++) {
            for (let j = colStart; j < endC; j++) {
                const formula = dirty(i, j);
                if (formula) {
                    formula.state = CalcState.Invalid;
                }
                else {
                    this.cache.clear(rowStart, colStart);
                }
                const cell = this.readCache(i, j);
                if (cell && isFormulaCell(cell)) {
                    this.addToChain(cell);
                }
            }
        }
        if (!this.consumer0) {
            return;
        }

        this.chain = rebuild(this.chain, this);
        for (let i = rowStart; i < endR; i++) {
            for (let j = colStart; j < endC; j++) {
                const cell = this.readCache(i, j)
                if (cell && isFormulaCell(cell) && (cell.flags & CalcFlags.PendingNotification)) {
                    cell.flags &= ~CalcFlags.PendingNotification;
                }
            }
        }
        this.consumer0!.cellsChanged(rowStart, colStart, rowCount, colCount, this);
        this.consumers.forEach(consumer => consumer.cellsChanged(rowStart, colStart, rowCount, colCount, this));

        for (let i = 0; i < this.chain.length; i++) {
            const cell = this.chain[i];
            if ((cell.flags & CalcFlags.PendingNotification)) {
                cell.flags &= ~CalcFlags.PendingNotification;
                this.consumer0!.cellsChanged(cell.row, cell.col, 1, 1, this);
                this.consumers.forEach(consumer => consumer.cellsChanged(cell.row, cell.col, 1, 1, this));
            }
        }
    }