/** * Worksheet autoshapes (DrawingML preset shapes, `prstSp` anchors). * * Citations: * - docs/specs/autoshapes.md; docs/ooxml-mapping/autoshapes.md * - dml-spreadsheetDrawing.xsd CT_WsDr / CT_OneCellAnchor / CT_Shape * - dml-main.xsd CT_PresetGeometry2D (prst attribute) * - sml CT_Drawing on CT_Worksheet * * 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 alongside modeled autoshapes. * * @private implementation; public types exported via index. */ import { OpcPackage } from '../core/package/opc-package'; import { OpcRelationship } from '../core/package/relationships'; /** * Specifies the kind of built-in shape to draw, such as a rectangle, oval, * arrow, or star. */ export declare enum AutoShapeType { /** A four-sided shape with square corners. */ Rectangle = "rect", /** A rectangle with rounded corners. */ RoundedRectangle = "roundRect", /** An ellipse that can be wider or taller than it is long. */ Oval = "ellipse", /** An ellipse whose width and height are forced equal, producing a circle. */ Circle = "ellipse", /** A triangle. */ Triangle = "triangle", /** A four-sided shape rotated 45 degrees, like a diamond. */ Diamond = "diamond", /** A five-sided shape. */ Pentagon = "pentagon", /** A six-sided shape. */ Hexagon = "hexagon", /** An eight-sided shape. */ Octagon = "octagon", /** A five-pointed star. */ Star5 = "star5", /** A ten-pointed star. */ Star10 = "star10", /** A three-dimensional box. */ Cube = "cube", /** A three-dimensional cylinder. */ Cylinder = "cylinder", /** A three-dimensional cone. */ Cone = "cone", /** A three-dimensional pyramid. */ Pyramid = "pyramid", /** A heart. */ Heart = "heart", /** A crescent moon. */ Moon = "moon", /** A sun. */ Sun = "sun", /** A cloud. */ Cloud = "cloud", /** An open curved arc. */ Arc = "arc", /** A block arrow pointing right. */ RightArrow = "rtTriangle", /** A block arrow pointing left. */ LeftArrow = "ltTriangle", /** A block arrow pointing up. */ UpArrow = "triangle", /** A block arrow pointing down. */ DownArrow = "invTriangle" } /** * The dash pattern a shape's outline is drawn with. Assign one of these * values to the shape's line formatting. */ export declare enum ShapeLineStyle { /** An unbroken, continuous line. */ Solid = "solid", /** Short dashes with gaps between them. */ Dash = "dash", /** A pattern of dots. */ Dot = "dot", /** Alternating dashes and dots. */ DashDot = "dashDot", /** A dash followed by two dots. */ DashDotDot = "dashDotDot", /** Long dashes with gaps between them. */ LongDash = "lgDash", /** Alternating long and short dashes. */ DashLongDash = "dashLongDash", /** No outline at all. */ None = "none" } /** * The kind of fill a shape's background uses. Assign one of these values * to the shape's fill type. */ export declare enum ShapeFillType { /** A single flat color. */ Solid = "solidFill", /** A smooth blend between two or more colors. */ Gradient = "gradFill", /** A repeating motif, like stripes or checks. */ Pattern = "pattFill" } /** * The direction a gradient fill blends its colors in. Assign one of these * values to the gradient settings of a shape's fill. */ export declare enum ExcelGradientStyle { /** Blend the colors along a straight line, from one edge to the other. */ Linear = "linear", /** Blend the colors outward from a center point, like concentric rings. */ Radial = "radial" } /** * Describes a shape's outline, including its color, weight, and dash style. */ export interface ShapeLineFormat { /** * The outline color as a hex value, like `'4472C4'` or `'#4472C4'`. * `undefined` draws no outline. */ color: string | undefined; /** * The thickness of the outline in pixels — kept between 1 and 10. */ weight: number; /** The dash pattern the outline is drawn with. */ dashStyle: ShapeLineStyle; } /** * Describes how a shape is filled, whether with a solid color, gradient, or * pattern, including its colors and transparency. */ export interface ShapeFill { /** * The kind of fill: a flat color, a smooth color blend, or a repeating * pattern. */ type: ShapeFillType; /** * The fill's main color as a hex value, like `'4472C4'` — used by solid * and pattern fills. */ foreColor: string | undefined; /** * The color behind the pattern, as a hex value — used by pattern fills. */ backColor: string | undefined; /** * How see-through the fill is, in percent — `0` fully opaque, `100` * fully transparent. `undefined` uses the library default. */ transparency: number | undefined; } /** * Holds the text inside a shape, along with its alignment and font * formatting. */ export interface ShapeTextFrame { /** The text shown inside the shape. */ text: string; /** How the text lines up horizontally: left, center, right, or justify. */ horizontalAlignment: 'left' | 'center' | 'right' | 'justify'; /** How the text lines up vertically within the shape. */ verticalAlignment: 'top' | 'middle' | 'bottom'; /** The font the shape's text is drawn with. */ font: { /** The font face name — for example `'Calibri'`. */ name: string | undefined; /** The font size in points — for example `12`. */ size: number | undefined; /** Whether the text is bold. */ bold: boolean; /** Whether the text is italic. */ italic: boolean; /** The text color as a hex value, like `'333333'`. */ color: string | undefined; }; } /** * Represents a shape placed on a worksheet, letting you set its position, * size, appearance, and text. */ export interface Shape { /** The shape's numeric id, unique within the worksheet's drawing. */ readonly id: number; /** * The row the shape's top edge is anchored to — 1-based, like Excel * rows. */ row: number; /** * The column the shape's left edge is anchored to — 1-based, like * Excel columns. */ column: number; /** * The width of the shape in points (72 pt = 1 in). */ width: number; /** * The height of the shape in points (72 pt = 1 in). */ height: number; /** How far the shape is turned, in degrees clockwise (0–360). */ rotation: number; /** * The shape's background fill. `undefined` uses the default — a white * solid fill. */ fill: ShapeFill | undefined; /** The shape's outline. `undefined` draws no outline. */ line: ShapeLineFormat | undefined; /** The text shown inside the shape and how it is formatted. */ textFrame: ShapeTextFrame; /** * The name that identifies the shape. `undefined` lets the library * generate one. */ name: string | undefined; /** * The alt text describing the shape for accessibility tools; * `undefined` when not set. */ altText: string | undefined; /** The kind of shape — for example a rectangle, ellipse, or star. */ readonly type: AutoShapeType; /** Whether the shape is visible on the worksheet. */ isVisible: boolean; /** Whether the shape moves when its anchor cells move or resize. */ isMoveWithCell: boolean; /** Whether the shape grows and shrinks with its anchor cells. */ isSizeWithCell: boolean; } /** * Represents the shapes on a worksheet, letting you add or remove * rectangles, ovals, arrows, and other built-in shapes. */ export interface ShapesCollection { /** All shapes on the worksheet, in the order they were added. */ readonly shapes: ReadonlyArray; /** * Add a shape to the worksheet. Position it by cell and size it in * points (72 pt = 1 in), then set fill, outline, and text formatting * on the returned shape. * * @param type - The kind of shape to add, like `AutoShapeType.Rectangle`. * @param row - The 1-based row the shape's top edge is anchored to. * @param column - The 1-based column the shape's left edge is anchored to. * @param width - The shape width in points, like `144` (2 in). * @param height - The shape height in points, like `72` (1 in). * @param text - The text shown inside the shape, when any. * @param name - The name identifying the shape; generated when omitted. * @param altText - The alt text for accessibility tools, when any. * @param rotation - How far to turn the shape, in degrees clockwise. * @param moveWithCell - Whether the shape moves with its anchor cells. * Default `true`. * @param sizeWithCell - Whether the shape resizes with its anchor cells. * Default `false`. * @returns the newly created shape. */ addShape(type: AutoShapeType, row: number, column: number, width: number, height: number, text?: string, name?: string, altText?: string, rotation?: number, moveWithCell?: boolean, sizeWithCell?: boolean): Shape; /** * Remove a shape from the worksheet. * * @param target - The shape to remove, or its zero-based position among * the worksheet's shapes. */ removeShape(target: Shape | number): void; } /** Host callbacks for dirty + package access. */ export interface AutoShapesHost { markDirty(): void; readonly package: OpcPackage; readonly sheetPartName: string | undefined; } /** * Internal entry for one autoshape. * @private */ export interface AutoShapeEntry { cNvPrId: number; name: string; type: AutoShapeType; /** 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; rotation: number; text: string; textHorizontalAlignment: 'left' | 'center' | 'right' | 'justify'; textVerticalAlignment: 'top' | 'middle' | 'bottom'; fontName: string | undefined; fontSizePt: number | undefined; fontBold: boolean; fontItalic: boolean; fontColor: string | undefined; fill: ShapeFill; line: ShapeLineFormat; altText: string | undefined; isVisible: boolean; isMoveWithCell: boolean; isSizeWithCell: boolean; } /** * Result of materializing the drawing part + sheet drawing relationship. * @private */ export interface AutoShapesMaterializeResult { /** 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 autoshapes collection for one worksheet. * @private */ export declare class AutoShapesImpl implements ShapesCollection { 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: AutoShapesHost): 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. */ readonly shapes: ReadonlyArray; /** * Add a preset autoshape. Geometry is 1-based row/column + positive size in points. * Optional trailing args: text, name, altText, rotation (default 0), * moveWithCell (default true), sizeWithCell (default false). * Nested fill/line/text formatting is set on the returned {@link Shape}. */ addShape(type: AutoShapeType, row: number, column: number, width: number, height: number, text?: string, name?: string, altText?: string, rotation?: number, moveWithCell?: boolean, sizeWithCell?: boolean): Shape; /** * Remove by handle or 0-based index into shapes. */ removeShape(target: Shape | number): void; /** * True when drawing package state may need rewrite. * @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. * @private */ materializeOnFlush(sheetRelsCurrent: ReadonlyArray): AutoShapesMaterializeResult; private markDirty; private handleFor; } /** * CT_Worksheet successors after `drawing` (for insert index). */ export declare const DRAWING_SUCCESSORS: ReadonlyArray;