import type { OfficeEntryMap } from '../../shared/ooxml/archive'; import { type OfficeRelationship } from '../../shared/ooxml/media'; import { type OfficeTheme } from '../../shared/ooxml/theme'; import type { OfficeResourceSource } from '../resource-store/types'; import type { WordBookmarkTarget } from '../word/types'; import { type DocxReviewParseState } from './parseDocxComments'; import { type DocxNumberingCatalog, type DocxNumberingReference } from './parseDocxNumbering'; import type { DocxCharacterSpacingControl, DocxImage, DocxPage, DocxTabStop, DocxTableCell, DocxTextStyle } from './types'; /** DOCX 缺少页面设置时使用的默认页面尺寸和边距。 */ export declare const DEFAULT_DOCX_PAGE: DocxPage; /** 枚举 DOCX 解析可能处于的状态。 */ export type DocxPackageState = { /** 压缩包或复合文档包含的条目。 */ entries: OfficeEntryMap; /** 按关系标识索引的 OOXML 关系。 */ relationships: Record>; /** 按 OOXML 包内路径索引的媒体资源映射。 */ mediaByPath: Record; /** 按媒体文件名索引的资源映射。 */ mediaByName: Record; }; /** 汇总 DOCX 解析各步骤共享的上下文。 */ export type DocxParseContext = { /** 解析各 DOCX 部件时共享的包状态。 */ packageState: DocxPackageState; /** 按关系标识索引的 DOCX 主文档关系。 */ documentRels: Record; /** 文档使用的主题颜色和字体配置。 */ theme: OfficeTheme; /** 文档网格推导出的默认正文行高,单位为标准化渲染像素。 */ defaultLineHeight?: number; /** 文档网格单行的实际高度,供表格等局部排版遵循吸附规则。 */ documentGridLineHeight?: number; /** 源文档声明的东亚标点字符间距压缩方式。 */ characterSpacingControl?: DocxCharacterSpacingControl; /** DOCX 自动编号定义及当前解析计数状态。 */ numbering: DocxNumberingCatalog; /** 按样式标识索引的 DOCX 样式目录。 */ styles: DocxStyleCatalog; /** 解析过程中已收集的图片资源。 */ images: DocxImage[]; /** 解析过程中按源名称收集的书签定位信息。 */ bookmarks: Record; /** 解析正文期间持续收集的批注范围和修订记录。 */ review: DocxReviewParseState; /** 按脚注源标识索引的页面连续编号。 */ footnoteLabels: Record; /** 按尾注源标识索引的页面连续编号。 */ endnoteLabels: Record; /** 下一张图片使用的零基索引。 */ imageIndex: number; /** 图表在所属图表集合中的索引。 */ chartIndex: number; /** 下一个形状使用的零基索引。 */ shapeIndex: number; }; /** 读取 DOCX 容器节点下块级内容时使用的选项。 */ export type ReadBlockChildrenOptions = { /** 是否位于形状内部;用于选择局部坐标和排版规则。 */ insideShape?: boolean; /** 是否位于表格单元格内部。 */ insideTable?: boolean; /** 表格样式向单元格段落提供的上下文格式。 */ paragraphContextStyle?: DocxTextStyle; /** 是否位于页眉或页脚区域;这些段落不属于正文大纲。 */ insidePageRegion?: boolean; }; /** DOCX 单个段落或字符样式的继承和排版属性。 */ export type DocxStyleDefinition = { /** 样式适用的对象类型。 */ kind: 'paragraph' | 'character' | 'table'; /** 源 styles.xml 中声明的样式名称。 */ name?: string; /** 当前样式继承的父样式标识。 */ basedOn?: string; /** 样式直接声明的大纲级别,使用从 0 开始的内部表示。 */ outlineLevel?: number; /** 样式直接声明的自动编号引用;null 表示明确取消父样式编号。 */ numbering?: DocxNumberingReference | null; /** 样式直接声明的制表位。 */ tabStops?: DocxTabStop[]; /** 样式是否要求文字吸附文档网格。 */ snapToGrid?: boolean; /** 样式是否要求当前段落与下一段同页。 */ keepNext?: boolean; /** 样式是否要求段落全部行保持同页。 */ keepLines?: boolean; /** 样式是否启用段落跨页孤行控制。 */ widowControl?: boolean; /** 相邻同样式段落之间是否忽略段前和段后间距。 */ contextualSpacing?: boolean; /** 是否在东亚文字与西文之间自动留出间距。 */ autoSpaceLatin?: boolean; /** 是否在东亚文字与数字之间自动留出间距。 */ autoSpaceNumber?: boolean; /** 表格样式为单元格声明的默认内边距。 */ tableCellMargins?: Pick; /** 表格样式声明的外框和内部网格线。 */ tableBorders?: DocxTableBorders; /** 当前内容使用的渲染样式。 */ style: DocxTextStyle; }; /** 表格外框和内部网格线的渲染样式。 */ export type DocxTableBorders = { /** 上边框。 */ top?: string; /** 右边框。 */ right?: string; /** 下边框。 */ bottom?: string; /** 左边框。 */ left?: string; /** 内部横向网格线。 */ insideHorizontal?: string; /** 内部纵向网格线。 */ insideVertical?: string; }; /** 按样式标识索引的 DOCX 样式目录。 */ export type DocxStyleCatalog = { /** 默认段落、文本与样式标识配置。 */ defaults: { /** 默认段落样式。 */ paragraph?: DocxTextStyle; /** 默认文字样式。 */ run?: DocxTextStyle; /** 默认段落样式标识。 */ paragraphStyleId?: string; /** 默认表格样式标识。 */ tableStyleId?: string; }; /** 按业务键索引的 映射。 */ styles: Record; /** 按样式缓存继承后的大纲级别,null 表示没有大纲语义。 */ outlineLevelCache: Map; /** 按样式缓存 TOC 判定,避免为每个段落重复遍历继承链。 */ tocStyleCache: Map; }; /** 根据已读取条目和可选懒媒体索引建立 DOCX 包上下文。 */ export declare function buildDocxPackageState(entries: OfficeEntryMap, lazyMedia?: { byPath: Record; byName: Record; }): DocxPackageState; export declare function twipToPx(value?: string | number): number | undefined; export declare function positiveTwipToPx(value?: string | number): number | undefined; export declare function vmlUnitToPx(value?: string | number): number | undefined; export declare function readCssDeclaration(style: string | undefined, name: string): string | undefined; export declare function readCssSize(style: string | undefined, name: string, scale?: number): number | undefined; export declare function readCssPosition(style: string | undefined, name: 'left' | 'top'): number | undefined; export declare function parseHexColor(value?: string): string | undefined; /** 将输入标准化为 `normalizeCssColor` 返回的结构。 */ export declare function normalizeCssColor(value?: string): string | undefined; export declare function readVal(node: Element | null | undefined): string | undefined; /** 将 Word 对齐值映射为统一文本样式。 */ export declare function mapAlignment(value?: string): DocxTextStyle['align'] | undefined; export declare function clamp255(value: number): number; /** 读取 DrawingML 直接色、主题色及其明暗变换。 */ export declare function readDrawingColor(node: Element | null | undefined, theme: OfficeTheme): string | undefined; export declare function readShading(node: Element | null | undefined, theme: OfficeTheme): string | undefined; export declare function readBorder(node: Element | null | undefined): string | undefined; export declare function readOnOff(node: Element | null | undefined): boolean | undefined; /** 读取表格样式或表格实例声明的网格线。 */ export declare function readDocxTableBorders(tblPr: Element | null | undefined): DocxTableBorders; /** 合并 `mergeTextStyle` 接收的多份数据。 */ export declare function mergeTextStyle(...styles: Array): DocxTextStyle | undefined; /** 解析并确定 `resolveDocxStyle` 对应的引用或配置。 */ export declare function resolveDocxStyle(styleId: string | undefined, catalog: DocxStyleCatalog, seen?: Set): DocxTextStyle | undefined; /** 沿表格样式继承链合并默认单元格边距。 */ export declare function resolveDocxTableCellMargins(styleId: string | undefined, catalog: DocxStyleCatalog, seen?: Set): DocxStyleDefinition['tableCellMargins'] | undefined; /** 沿表格样式继承链合并外框和内部网格线。 */ export declare function resolveDocxTableBorders(styleId: string | undefined, catalog: DocxStyleCatalog, seen?: Set): DocxTableBorders | undefined; /** 解析并确定 `resolveParagraphStyle` 对应的引用或配置。 */ export declare function resolveParagraphStyle(pPr: Element | null | undefined, catalog: DocxStyleCatalog, theme: OfficeTheme, contextStyle?: DocxTextStyle): { align: "center" | "left" | "right" | "justify" | undefined; spacingBefore: number | undefined; spacingAfter: number | undefined; indentLeft: number | undefined; indentRight: number | undefined; firstLineIndent: number | undefined; lineHeight: number | undefined; lineHeightRule: "auto" | "exact" | "atLeast" | undefined; backgroundColor: string | undefined; borderTop: string | undefined; borderRight: string | undefined; borderBottom: string | undefined; borderLeft: string | undefined; paddingTop: number | undefined; paddingRight: number | undefined; paddingBottom: number | undefined; paddingLeft: number | undefined; styleId: string | undefined; numbering: DocxNumberingReference | undefined; tabStops: DocxTabStop[] | undefined; snapToGrid: boolean | undefined; keepNext: boolean | undefined; keepLines: boolean | undefined; widowControl: boolean | undefined; contextualSpacing: boolean | undefined; autoSpaceLatin: boolean | undefined; autoSpaceNumber: boolean | undefined; outlineLevel: number | undefined; isTocStyle: boolean; style: DocxTextStyle | undefined; paragraphMarkStyle: DocxTextStyle | undefined; }; /** 按 Word 优先级合并文档默认、段落继承、字符样式与 run 直接格式。 */ export declare function resolveRunStyle(rPr: Element | null | undefined, catalog: DocxStyleCatalog, theme: OfficeTheme, inheritedStyle?: DocxTextStyle): DocxTextStyle | undefined; export declare function inlineInheritedStyle(style: DocxTextStyle | undefined): DocxTextStyle | undefined; /** 创建 DOCX 主解析上下文时使用的选项。 */ export type CreateDocxParseContextOptions = { /** DOCX 主文档中的正文根节点。 */ bodyNode?: Element | null; /** 解析上下文可访问的媒体资源索引。 */ media?: { /** 按压缩包路径索引的媒体资源。 */ byPath: Record; /** 按资源文件名索引的媒体资源。 */ byName: Record; }; }; /** 为物化和流式解析建立完全相同的样式、主题、关系及媒体上下文。 */ export declare function createDocxParseContext(entries: OfficeEntryMap, options?: CreateDocxParseContextOptions): DocxParseContext;