/** * Word Document Field Calculation Engine * * Computes and updates field cachedValues based on layout (pagination) results. * Supports PAGE, NUMPAGES, SECTIONPAGES, SECTION, TOC, REF, PAGEREF, SEQ, IF, STYLEREF, * INDEX, = (formula), INCLUDETEXT. * * The engine performs a layout pass via layoutDocument, then traverses the document * body to update each field's cachedValue in an immutable-style manner (deep-cloning * modified portions of the tree). */ import { type LayoutOptions } from "../layout/layout.js"; import type { DocxDocument } from "../types.js"; /** 字段计算选项 */ export interface FieldUpdateOptions { /** 布局选项(传递给 layoutDocument)。 */ readonly layoutOptions?: LayoutOptions; /** 是否更新 TOC(默认 true)。 */ readonly updateToc?: boolean; /** 是否更新页码字段(默认 true)。 */ readonly updatePageFields?: boolean; /** 是否更新交叉引用(默认 true)。 */ readonly updateReferences?: boolean; /** 是否更新序列号(默认 true)。 */ readonly updateSequences?: boolean; } /** * 更新文档中所有字段的 cachedValue。 * * 执行分页布局,然后遍历所有字段更新其缓存值。 * 对于 TOC 字段,会生成完整的目录段落。 * * @param doc - 文档模型(不会被修改,返回新对象) * @param options - 更新选项 * @returns 更新后的文档模型 */ export declare function updateFields(doc: DocxDocument, options?: FieldUpdateOptions): DocxDocument; /** * 仅更新 TOC(目录)字段。 * 扫描文档中的标题(Heading1-9 样式或 outline level), * 生成目录缓存段落。 */ export declare function updateTableOfContents(doc: DocxDocument, options?: FieldUpdateOptions): DocxDocument;