import type { DataField, FieldsCollection, IFieldsCollectionJSON, IPivotTableSnapshot, PivotView } from '@univerjs-pro/engine-pivot'; import type { IPivotCacheHandle } from '@univerjs-pro/pivot-cache'; import type { IRange, IUnitRangeName, Nullable } from '@univerjs/core'; import type { IMoveRangeMutationParams, ISetRangeValuesMutationParams } from '@univerjs/sheets'; import type { ICollectionChangeInfo, ICurrentDataMatrix, IDataFieldManagerJSON, IInitializePivotRuntimeParams, IPivotBlockedRange, IPivotCellPositionInfo, IPivotMutationDirtyViewInfo, IPivotReportScope, IPivotTableConfig, IPivotTableJson, IPivotWorkerItemCache, ISendPivotConfigLocalMutationParams, IUnitRangeNameWithSubUnitId, IUpdateInfo } from '../const/type'; import type { IViewTranslateCtx } from './view-util'; import { PivotTable } from '@univerjs-pro/engine-pivot'; import { Disposable, ICommandService, Injector, IResourceManagerService, IUniverInstanceService, LifecycleService, ObjectMatrix } from '@univerjs/core'; import { IFeatureCalculationManagerService } from '@univerjs/engine-formula'; import { PivotTableOperationEnum } from '../const/type'; import { SheetsPivotCacheService } from '../services/sheets-pivot-cache.service'; import { captureWorksheetContentWrites } from '../util'; import { SheetsPivotDataFieldManager } from './sheets-pivot-data-field-manager'; type WorksheetCellWriteCheck = (row: number, column: number) => boolean; export declare class SheetsPivotDataSourceModel extends Disposable { private readonly _injector; private readonly _univerInstanceService; readonly _lifecycleService: LifecycleService; private readonly _commandService; private _resourceManagerService; private readonly _sheetsPivotCacheService; private readonly _sourceCalculation?; private _model; private readonly _runtimeUnits; private _pivotTableInstanceCache; private _viewData; private _viewTranslateContextCache; private _textInfo; private _direction; private _collectionChange$; collectionChange$: import("rxjs").Observable; private _viewData$; viewData$: import("rxjs").Observable<{ unitId: string; subUnitId: string; pivotTableId: string; }>; private _fieldsCollectionChange$; fieldsCollectionChange$: import("rxjs").Observable>; private _dataFieldManagerCollection; private readonly _sourceLeases; needSameDeleteModel: { deleteUnitId: (unitId: string) => void; }[]; /** * - this property is used to store the dirty pivot table collection which need to be marked dirty when mutations is executed */ private _queryingMap; constructor(_injector: Injector, _univerInstanceService: IUniverInstanceService, _lifecycleService: LifecycleService, _commandService: ICommandService, _resourceManagerService: IResourceManagerService, _sheetsPivotCacheService: SheetsPivotCacheService, _sourceCalculation?: IFeatureCalculationManagerService | undefined); captureWorksheetContentWrites(params: ISetRangeValuesMutationParams): ReturnType; handleWorksheetCellChange({ unitId, subUnitId, cellValue }: ISetRangeValuesMutationParams, written?: ObjectMatrix): void; private _excludeWorksheetOutputCells; handleWorksheetRangeChange(unitId: string, subUnitId: string, ranges: IRange[], wasWritten?: WorksheetCellWriteCheck, defer?: boolean): void; getTextInfo(): Record; getRuntimeId(unitId: string): string | undefined; private _getRuntimeIds; initializeRuntime(params: IInitializePivotRuntimeParams): boolean; setTextInfo(textInfo: Record, direction: 'ltr' | 'rtl'): void; handleMoveRange(params: IMoveRangeMutationParams): void; broadcastCollectionChange(info: ICollectionChangeInfo): void; getDataFieldManager(unitId: string): SheetsPivotDataFieldManager; getCollection(unitId: string, token: string): FieldsCollection; getUpdateRangeDeleteIds(unitId: string, token: string, dataRangeInfo: IUnitRangeName): string[] | undefined; private _ensurePivotMap; private _updateModelCache; private _deleteModelCache; private _updatePivotTableInstanceCache; private _deletePivotTableInstanceCache; private _ensureViewDataMap; updateConfig(info: ISendPivotConfigLocalMutationParams): void; updateView(unitId: string, subUnitId: string, type: PivotTableOperationEnum, pivotTableId: string, view: Nullable, pivotConfig: Nullable, collectionConfig?: IDataFieldManagerJSON, ignoreDirty?: boolean, wasWritten?: WorksheetCellWriteCheck): void; /** * - the function is used to save the dirty view data and range for formula calculation * @param {IViewTranslateCtx} ctx the dirty context * @param {boolean} ignoreDirty the flag to ignore the dirty view area, only in handleSourceRangeChange , we get a dirty change from the source range change, we need ignore the dirty view area,because the dirty view area has done immediately */ updateViewData(ctx: IViewTranslateCtx, ignoreDirty: boolean, wasWritten?: WorksheetCellWriteCheck): IPivotBlockedRange | undefined; private _projectViewCache; private _protectBlockedAnchor; private _publishDisplacedPivot; private _retryReleasedPivotRanges; private _retryBlockedReports; private _getBlockingCellRange; private _getWorksheetOccupancy; private _getBlockingMergeRange; private _getBlockingPivotRange; addPivotTable(unitId: string, subUnitId: string, pivotTableId: string, pivotTable: PivotTable, pivotTableConfig: IPivotTableConfig): void; removePivotTable(unitId: string, subUnitId: string, pivotTableId: string): void; setPivotTable(unitId: string, subUnitId: string, pivotTableId: string, pivotTableConfig: IPivotTableConfig): void; movePivotTableWithinWorkbook(unitId: string, fromSheetId: string, pivotTableId: string, config: IPivotTableConfig): void; getWorksheetOutputRanges(unitId: string, subUnitId: string, pivotTableId: string): IRange[] | undefined; updatePivotTableSourceRange(unitId: string, subUnitId: string, pivotTableId: string, sourceRangeInfo: IUnitRangeNameWithSubUnitId, preferredPivotCacheId?: string): boolean; getPivotTableConfig(unitId: string, subUnitId: string, pivotTableId: string): IPivotTableConfig | undefined; /** * - get the pivot table model json config * @param {string} unitId * @param {string} subUnitId * @param {string} pivotTableId - the pivot table id * @returns {IPivotTableSnapshot|undefined} the pivot table model json config */ getPivotTableModelConfig(unitId: string, subUnitId: string, pivotTableId: string): IPivotTableSnapshot | undefined; getPivotTableInstance(pivotTableId: string): PivotTable | undefined; getPivotCacheId(unitId: string, pivotTableId: string): string | undefined; getPivotCacheHandle(unitId: string, pivotTableId: string): IPivotCacheHandle | undefined; /** Prepare owned report state and derived cell matrices without publishing partial reports. */ preparePivotBatch(updates: readonly { unitId: string; subUnitId: string; pivotTableId: string; pivot: PivotTable; config: IPivotTableConfig; view: PivotView; }[]): { commit(): void; publish(): void; }; acquireSource(unitId: string, pivotCacheId: string): IPivotCacheHandle; /** Rebuild a retained source even when it has no surviving report collection. */ refreshSource(unitId: string, pivotCacheId: string, cycle?: object, matrix?: ICurrentDataMatrix): void; deleteUnitId(unitId: string): void; addCollectionByJSON(token: string, collectionJSON: IFieldsCollectionJSON, sourceRangeInfo: IUnitRangeNameWithSubUnitId, targetCellInfo?: IPivotCellPositionInfo, reportScope?: IPivotReportScope): IUpdateInfo; /** * - this function just create a collection with data range info, but wil not add it to the dataFieldManager */ createCollectionWithDataRange(dataRangeInfo: IUnitRangeNameWithSubUnitId): IUpdateInfo; refreshData(collection: FieldsCollection, updateDataFieldList: { index: number; dataField: DataField; }[], dataRangeInfo: IUnitRangeNameWithSubUnitId): void; removeDataField(unitId: string, dataFieldId: string): void; removeCollections(unitId: string, token: string): void; syncCollectionConfig(unitId: string): void; getSubUnitPivotConfigs(unitId: string, subUnitId: string): Map | undefined; getTargetByPivotId(pivotTableId: string): { unitId: string; subUnitId: string; } | null; sideEffectUpdateWorkerCache(unitId: string, subUnitId: string, pivotTableId: string, workerCache?: IPivotWorkerItemCache): void; dispose(): void; getViewData(unitId: string, subUnitId: string, pivotTableId: string): IPivotWorkerItemCache | null; addDirtyPivotTable(dirtyInfo: IPivotMutationDirtyViewInfo): void; updateDirtyPivotTable(dirtyInfo: IPivotMutationDirtyViewInfo): void; /** * trigger the pivot table query * @param dirtyInfo */ queryDirtyPivotTable(dirtyInfo: IPivotMutationDirtyViewInfo, wasWritten?: WorksheetCellWriteCheck): void; toJSON(unitId: string): IPivotTableJson; fromJSON(jsonData: IPivotTableJson): void; private _initSnapshot; } export {};