/** * Style Resolution (Effective/Computed Style) * * Resolve the effective style for a paragraph by walking the style inheritance chain. */ import type { DocxDocument, Paragraph, ParagraphProperties, Run, RunProperties, TableLook, TableProperties } from "../types.js"; /** Context for style resolution when a paragraph is inside a table. */ export interface StyleResolveContext { /** If the paragraph is inside a table, provide table context. */ readonly tableContext?: { readonly tableStyleId?: string; readonly tblLook?: TableLook; readonly rowIndex: number; readonly colIndex: number; readonly totalRows: number; readonly totalCols: number; }; } /** Resolved paragraph properties with all inherited values merged. */ export interface ResolvedParagraphStyle { /** The style chain (from most specific to base). */ readonly chain: readonly string[]; /** Merged paragraph properties (inherited + own). */ readonly paragraphProperties: ParagraphProperties; /** Merged run properties (inherited + own). */ readonly runProperties: RunProperties; } /** * Resolve the effective (computed) style for a paragraph by walking the style inheritance chain. * * Merges properties from the document defaults → base style chain → table conditional formats → paragraph's own properties. * * @param doc - The document containing styles and defaults. * @param para - The paragraph to resolve styles for. * @param context - Optional context providing table position for conditional format overlay. * @returns The fully resolved paragraph style with all inherited properties merged. */ export declare function resolveStyle(doc: DocxDocument, para: Paragraph, context?: StyleResolveContext): ResolvedParagraphStyle; /** Resolved run style with full inheritance chain. */ export interface ResolvedRunStyle { /** Style chain (most specific → base). */ readonly chain: readonly string[]; /** Merged run properties. */ readonly runProperties: RunProperties; } /** * Resolve the effective style for a single Run by walking the character * style inheritance chain. * * Resolution order (low → high specificity): * 1. Document defaults * 2. Paragraph's resolved style (if `paragraphRunProperties` provided) * 3. Run's character style chain (if `run.properties.style` is set) * 4. Run's own direct properties * * @param doc - The document containing styles. * @param run - The run to resolve. * @param paragraphRunProperties - Optional inherited run properties from the * parent paragraph's resolved style. Pass `resolveStyle(doc, para).runProperties` * to layer the paragraph style on top of doc defaults. * @returns The fully resolved run style. */ export declare function resolveRunStyle(doc: DocxDocument, run: Run, paragraphRunProperties?: RunProperties): ResolvedRunStyle; /** Resolved numbering level information. */ export interface ResolvedNumberingLevel { /** The level index (0-8). */ readonly level: number; /** Number format. */ readonly format?: string; /** Level text template (e.g. `"%1."`). */ readonly text?: string; /** Justification. */ readonly justification?: string; /** Run properties for the numbering text itself (bullet/number marker). */ readonly runProperties?: RunProperties; /** Paragraph properties from the level (indent, alignment, etc.). */ readonly paragraphProperties?: ParagraphProperties; } /** * Resolve the numbering level for a paragraph that has a numbering reference. * * Walks: paragraph.numbering → numberingInstances → abstractNumberings → level definition. * Also applies `LevelOverride` if present. * * @param doc - The document. * @param para - The paragraph (must have `numbering` set). * @returns The resolved level, or undefined if no numbering or level not found. */ export declare function resolveNumberingLevel(doc: DocxDocument, para: Paragraph): ResolvedNumberingLevel | undefined; /** * Resolve table-level styles for a given table. * * Walks the table style inheritance chain (basedOn) to merge table properties. * * @param doc - The document. * @param tableStyleId - The starting table style ID. * @returns The merged table-level style chain. */ export declare function resolveTableStyle(doc: DocxDocument, tableStyleId: string): { chain: string[]; paragraphProperties: ParagraphProperties; runProperties: RunProperties; tableProperties?: TableProperties; };