import type { IDataFieldValue, IFieldsCollectionJSON, IPivotTableRecordFilter, PivotSubtotalTypeEnum } from '@univerjs-pro/engine-pivot'; import type { ICellData, IDisposable, IRange, IUnitRangeName, IUniverInstanceService, Nullable, ObjectMatrix, Styles, Worksheet } from '@univerjs/core'; import type { IRuntimeUnitDataType } from '@univerjs/engine-formula'; import { DataField, DataFieldManager, FieldsCollection } from '@univerjs-pro/engine-pivot'; import { numfmt } from '@univerjs/core'; import type { ICurrentDataMatrix, IDataFieldManagerJSON, IPivotCellPositionInfo, IPivotReportScope, IUnitRangeNameWithSubUnitId, IUpdateInfo } from '../const/type'; import type { SheetsPivotDataSourceModel } from './sheets-pivot-data-source-model'; interface IFeatureDirtyRangeType { [unitId: string]: Nullable<{ [sheetId: string]: IRange[]; }>; } type TPatternInfoRecord = Record>; export declare class SheetsPivotDataFieldManager extends DataFieldManager { compileRecordFilter(filter: IPivotTableRecordFilter): (value: IDataFieldValue) => boolean; /** * the key is pivot table id, the value is the data range info. those data range is one-to-one with the pivot table */ rangeKeyMap: Record; private _reportScopeMap; private readonly _sourceFieldLeases; private _univerInstanceService; _host: SheetsPivotDataSourceModel | null; constructor(host: SheetsPivotDataSourceModel, univerInstanceService: IUniverInstanceService); initDataRanges(): void; retainSourceFields(source: IUnitRangeNameWithSubUnitId): IDisposable; getNoUsedDataFieldIds(excludeCollectionToken: string): string[]; getAutoDisplayNameFunction(): (baseName: string, subtotalType: PivotSubtotalTypeEnum) => string; deleteDataField(dataFieldId: string): void; /** * The field added here is derived, so don’t need to consider rangeKey. * @param {DataField} dataField */ addDataFieldWithoutUnitInfo(dataField: DataField): void; removeCollectionImp(token: string): void; getRangeKey(rangeInfo: IUnitRangeName, colIndex: number): string; getDataFieldByRangeKey(rangeKey: string): DataField | undefined; setRangeKeyMap(rangeKey: string, dataFieldId: string): void; updateRangeKeyMap(oldRangeKey: string, newRangeKey: string): void; addCollectionByJSON(token: string, collectionJSON: IFieldsCollectionJSON, sourceRangeInfo: IUnitRangeNameWithSubUnitId, targetCellInfo?: IPivotCellPositionInfo, reportScope?: IPivotReportScope): IUpdateInfo; getRangeStartEndInfo(range: IRange, sheet: Worksheet): IRange; /** * - when add pivot table, we should create a collection with data range first * @param {IUnitRangeName} dataRangeInfo the data range info * @returns {FieldsCollection} the created collection */ createCollectionWithDataRange(dataRangeInfo: IUnitRangeName): IUpdateInfo; _getAutoName(colIndex: number): string; uniqueDataFieldName(name: IDataFieldValue, colIndex: number): string; getCollection(token: string): FieldsCollection; addCollection(token: string, collection: FieldsCollection, sourceRangeInfo: IUnitRangeNameWithSubUnitId, targetCellInfo?: IPivotCellPositionInfo, reportScope?: IPivotReportScope): void; handleMoveRange(token: string, sourceRangeInfo: IUnitRangeNameWithSubUnitId): void; handleMoveRange(sources: readonly { before: IUnitRangeNameWithSubUnitId; after: IUnitRangeNameWithSubUnitId; }[]): void; getPivotDirtyViewInfo(): { runtimeCellData: IRuntimeUnitDataType; dirtyRanges: IFeatureDirtyRangeType; }; getUpdateRangeDeleteIds(token: string, dataRangeInfo: IUnitRangeName): string[] | undefined; /** * get the matrix value from different matrix, when refresh the data source of pivot table * @param matrix the sheet cell matrix * @param arrayFormulaCellDataMatrix the array formula cell data matrix from run time data * @param unitDataMatrix the unit data matrix from runtime data * @param {number} rowIndex - the row index * @param {number} colIndex - the column index * @returns {Nullable} the resolved cell data */ getMatrixValue(matrix: ObjectMatrix>, arrayFormulaCellDataMatrix: ObjectMatrix> | undefined, unitDataMatrix: ObjectMatrix> | undefined, rowIndex: number, colIndex: number): Nullable; private _getResolvedMatrixValue; refreshDataField(dataFieldId: string, dataRangeInfo: IUnitRangeNameWithSubUnitId, index: number, currentDataMatrix?: ICurrentDataMatrix): void; refreshData(collection: FieldsCollection, list: { index: number; dataField: DataField; }[], dataRangeInfo: IUnitRangeNameWithSubUnitId): void; getRangeKeyList(dataRangeInfo: IUnitRangeName): string[]; /** * - adjust sheet cell value to the type that pivot engine can recognize * @param {Nullable} cellData the cell data * @param {Styles} styles styles in the workbook * @param {TPatternInfoRecord} patternInfoRecord the pattern info record * @returns {IDataFieldValue} the value to add into the data field */ adjustSheetCellData(cellData: Nullable, styles: Styles, patternInfoRecord: TPatternInfoRecord, isArrayFormulaCell?: boolean): IDataFieldValue; getRangeData(dataRangeInfo: IUnitRangeName): { header: (string | null)[]; data: IDataFieldValue[][]; }; toJSON(): IDataFieldManagerJSON; fromJSON(jsonData: IDataFieldManagerJSON): void; dispose(): void; } export {};