import type { Sheet } from './sheet'; import { SheetCollection } from './sheet_collection'; import { type UnitAddress, type UnitStructuredReference, type UnitRange, Parser } from '../../treb-parser/src/index'; import type { IArea, ICellAddress, Table, CellStyle, CellValue } from '../../treb-base-types/src/index'; import { Area } from '../../treb-base-types/src/index'; import type { SerializedNamed } from './named'; import { NamedRangeManager } from './named'; import type { ConnectedElementType, MacroFunction } from './types'; import type { LanguageModel } from './language-model'; /** * */ export declare class DataModel { readonly parser: Parser; /** moved from embedded spreadsheet */ language_model?: LanguageModel; /** document metadata */ document_name?: string; /** * document metadata. this is opaque to everyone except the user, so * we're intentionally leaving it as unknown except where users have * direct access (embedded spreadsheet). */ user_data?: unknown; /** * */ readonly sheets: SheetCollection; /** new composite collection (TODO: add macro functions too?) */ readonly named: NamedRangeManager; /** macro functions are functions written in spreadsheet language */ readonly macro_functions: Map; /** index for views */ view_count: number; /** * base style properties moved to model, so we can have a single * and consistent reference. */ theme_style_properties: CellStyle; /** * tables are global, because we need to reference them by name; and they * need unique names, so we need to keep track of names. name matching is * icase so we lc the names before inserting. */ tables: Map; /** * we're wrapping up the get name method so we can check for a sheet * name -- we have the list of sheet names. we could pass that to the * name list manager but it's easier for us to intercept the call. * I thought about wrapping up more API functions here, but that seems * unecessary atm. */ GetName(name: string, scope: number): import("./named").Named | undefined; /** * @param force_locale - always parse assuming a locale like en-us (comma * argument separators). the current thinking is that this is required for * XLSX import, although that might be incorrect. */ UnserializeNames(names: SerializedNamed[], active_sheet?: Sheet, force_locale?: boolean): void; /** * serialize names. ranges are easy, but make sure there's a sheet name * in each address (and remove the ID). expressions are a little more * complicated. */ SerializeNames(active_sheet?: Sheet): SerializedNamed[]; /** * putting this here temporarily. it should probably move into a table * manager class or something like that. */ ResolveStructuredReference(ref: UnitStructuredReference, context: ICellAddress): UnitAddress | UnitRange | undefined; /** * return an address label for this address (single cell or range). * * this is doing something unexpected: for dynamic arrays, it seems * to be filling out the full array. this could be an issue with how * we're calling it in the specific case of external editors. * * there should be no case where this is actually intended, because * the resulting label is garbage. nevertheless, I don't want to change * any existing behavior so we will move it behind a flag and default to * prior behavior. if necessary later we can change the default/remove the * old behavior. * * @param address * @param active_sheet */ AddressToLabel(address: ICellAddress | IArea, correct_dynamic_arrays?: boolean): string; /** * returns false if the sheet cannot be resolved, which probably * means the name changed (that's the case we are working on with * this fix). */ ResolveSheetID(expr: UnitAddress | UnitRange, context?: ICellAddress, active_sheet?: Sheet): boolean; /** wrapper method ensures it always returns an Area (instance, not interface) */ ResolveArea(address: string | ICellAddress | IArea, active_sheet: Sheet, options?: { r1c1?: boolean; }): Area; /** * moved from embedded sheet. also modified to preserve ranges, so it * might return a range (area). if you are expecting the old behavior * you need to check (perhaps we could have a wrapper, or make it optional?) * * Q: why does this not go in grid? or model? (...) * Q: why are we not preserving absoute/relative? (...) * */ ResolveAddress(address: string | ICellAddress | IArea, active_sheet: Sheet, options?: { r1c1?: boolean; }): ICellAddress | IArea; AddConnectedElement(connected_element: ConnectedElementType): number; RemoveConnectedElement(id: number): ConnectedElementType | undefined; /** * identifier for connected elements, used to manage. these need to be * unique in the lifetime of a model instance, but no more than that. */ protected connected_element_id: number; /** * these are intentionally NOT serialized. they're ephemeral, created * at runtime and not persistent. * * @internal */ connected_elements: Map; /** * maps common language (english) -> local language. this should * be passed in (actually set via a function). */ private language_map?; /** * maps local language -> common (english). this should be constructed * when the forward function is passed in, so there's a 1-1 correspondence. */ private reverse_language_map?; /** * set the language translation map. this is a set of function names * (in english) -> the local equivalent. both should be in canonical form, * as that will be used when we translate one way or the other. */ SetLanguageMap(language_map?: Record): void; /** * translate function from common (english) -> local language. this could * be inlined (assuming it's only called in one place), but we are breaking * it out so we can develop/test/manage it. */ TranslateFunction(value: string, options?: { r1c1?: boolean; }): string; /** * translate from local language -> common (english). * @see TranslateFunction */ UntranslateFunction(value: string, options?: { r1c1?: boolean; }): string; UntranslateData(value: CellValue | CellValue[] | CellValue[][], options?: { r1c1?: boolean; }): CellValue | CellValue[] | CellValue[][]; /** * translation back and forth is the same operation, with a different * (inverted) map. although it still might be worth inlining depending * on cost. * * FIXME: it's about time we started using proper maps, we dropped * support for IE11 some time ago. */ private TranslateInternal; /** * this is not public _yet_ * * @internal */ SetLanguage(model?: LanguageModel): void; }