/** * Worksheet text boxes (DrawingML `xdr:sp` + `txBody` on sheet drawings). * * Citations: * - docs/specs/text-boxes.md; docs/ooxml-mapping/text-boxes.md * - dml-spreadsheetDrawing.xsd CT_WsDr / CT_OneCellAnchor / CT_Shape * - dml-main.xsd CT_TextBody / CT_TextParagraph / CT_RegularTextRun * - sml CT_Drawing on CT_Worksheet (after smartTags, before legacyDrawing) * * Package side effects (drawing part + sheet relationship) defer to flush/save * (API-RULES R5.1). Foreign anchors (pic, chart, group, connector) are preserved * opaquely in the same drawing part. * * @private implementation; public types exported via index. */ import { OpcPackage } from '../core/package/opc-package'; import { OpcRelationship } from '../core/package/relationships'; /** * Vertical text anchoring inside the box (`a:bodyPr@anchor`). * @private Not re-exported from the package root; public {@link TextBox} * properties use the same string-literal union inline. */ export declare type TextBoxVerticalAlignment = 'top' | 'middle' | 'bottom'; /** * Horizontal paragraph alignment (`a:pPr@algn`). * @private Not re-exported from the package root; public {@link TextBox} * properties use the same string-literal union inline. */ export declare type TextBoxHorizontalAlignment = 'left' | 'center' | 'right' | 'justify'; /** * Represents a text box placed on a worksheet, letting you set its text, * position, size, and appearance. */ export interface TextBox { /** * @private * Drawing `cNvPr@id` (stable within the drawing part for this session). */ readonly id: number; /** The text shown inside the text box. */ text: string; /** * The color the text box is filled with, as a hex value like * `'FFF2CC'` or `'#FFF2CC'`. `undefined` leaves it unfilled. */ fillColor: string | undefined; /** The font face name the text is drawn with — for example `'Calibri'`. */ fontName: string | undefined; /** The font size in points — for example `12`. */ fontSize: number | undefined; /** Whether the text is bold. */ fontBold: boolean; /** The text color as a hex value, like `'333333'` or `'#333333'`. */ fontColor: string | undefined; /** How the text lines up vertically within the box: top, middle, or bottom. */ verticalAlignment: 'top' | 'middle' | 'bottom'; /** How the text lines up horizontally: left, center, right, or justify. */ horizontalAlignment: 'left' | 'center' | 'right' | 'justify'; /** * The row the text box's top edge is anchored to — 1-based, like Excel * rows. */ readonly row: number; /** * The column the text box's left edge is anchored to — 1-based, like * Excel columns. */ readonly column: number; /** * The width of the text box in points (72 pt = 1 in). */ readonly width: number; /** * The height of the text box in points (72 pt = 1 in). */ readonly height: number; } /** Host callbacks for dirty + package access. */ export interface TextBoxesHost { markDirty(): void; readonly package: OpcPackage; readonly sheetPartName: string | undefined; } /** * Internal entry for one text-box shape. * @private */ export interface TextBoxEntry { cNvPrId: number; name: string; /** 0-based OOXML marker row. */ fromRow0: number; /** 0-based OOXML marker col. */ fromCol0: number; rowOffEmu: number; colOffEmu: number; widthEmu: number; heightEmu: number; anchorKind: 'oneCell' | 'twoCell'; toRow0?: number; toCol0?: number; toRowOffEmu?: number; toColOffEmu?: number; editAs?: string; text: string; fillColor?: string | undefined; fontName?: string | undefined; fontSizePt?: number | undefined; fontBold: boolean; fontColor?: string | undefined; verticalAlignment: TextBoxVerticalAlignment; horizontalAlignment: TextBoxHorizontalAlignment; } /** * Result of materializing the drawing part + sheet drawing relationship. * @private */ export interface TextBoxesMaterializeResult { /** Relationships to keep (non-drawing, or updated set without stale drawing). */ readonly sheetRelsWithoutDrawing: ReadonlyArray; /** New or retained drawing relationship, if any anchors remain. */ readonly drawingRel: OpcRelationship | undefined; /** `r:id` for worksheet `` when present. */ readonly drawingRelationshipId: string | undefined; /** Whether the model owns/emits drawing (strip bag duplicates). */ readonly ownsDrawingElement: boolean; } /** * Mutable text-box collection for one worksheet. * @private */ export declare class TextBoxesImpl { private readonly entries; private readonly handles; private host; private foreignAnchorsXml; private drawingPartName; private drawingRelId; private loaded; private dirty; private nextCNvPrId; private nextNameIndex; /** @private */ bindHost(host: TextBoxesHost): void; /** * Load drawing part for this sheet (if any). Call after sheet XML parse. * @private */ loadFromPackage(pkg: OpcPackage, sheetPartName: string | undefined): void; /** Snapshot of live handles in file/add order. */ list(): ReadonlyArray; /** * Add a text box. Geometry is 1-based row/column + positive size in points. * Optional trailing arg: text (default empty). */ add(row: number, column: number, width: number, height: number, text?: string): TextBox; /** * Remove by handle or 0-based index into {@link list}. */ remove(target: TextBox | number): void; /** * True when drawing package state may need rewrite (authored changes or loaded). * @private */ readonly needsDrawingFlush: boolean; /** * True when the model should emit/replace the worksheet `` element. * @private */ readonly ownsDrawingElement: boolean; /** * Write/remove drawing part and compute sheet drawing relationship. * Call during worksheet flush after hyperlink retention filtering. * * @param sheetRelsCurrent Relationships already retained (no hyperlink types * yet mixed — caller passes pre-final list; drawing types are stripped here). * @private */ materializeOnFlush(sheetRelsCurrent: ReadonlyArray): TextBoxesMaterializeResult; private markDirty; private handleFor; } /** * CT_Worksheet successors after `drawing` (for insert index). * Citation: sml CT_Worksheet sequence; PAGE_SETUP_SUCCESSORS from drawing onward. */ export declare const DRAWING_SUCCESSORS: ReadonlyArray; /** * Index to insert modeled `` among after-sheetData siblings. * @private */ export declare function findDrawingInsertIndex(afterSheetDataLocals: ReadonlyArray): number; /** * Serialize worksheet drawing element. * @private */ export declare function serializeDrawingElementXml(relationshipId: string): string; /** * Relative Target from worksheet part to drawing part. * Standard: `/xl/worksheets/sheet1.xml` → `/xl/drawings/drawing1.xml` ⇒ `../drawings/drawing1.xml` * @private */ export declare function relativeTargetFromSheetToDrawing(sheetPartName: string, drawingPartName: string): string;