/** * Worksheet pictures as floating DrawingML objects. * * Pictures are stored above the worksheet grid in a spreadsheet drawing part. * The implementation follows the existing text-box and autoshape drawing * pipeline: package side effects are deferred until worksheet flush/save. * * Picture package-part content-type tokens (`ImageContentType` / * `ImageContentTypes`) are internal. Drawing identity fields on {@link Image} * (`id`, `relationshipId`, `contentType`, `name`, `description`) are also * internal. Public authoring is position and size via * {@link ImagesImpl.add} / `Worksheet.addImage` (format sniffed from bytes). */ import { OpcPackage } from '../core/package/opc-package'; import { OpcRelationship } from '../core/package/relationships'; /** * Content-type string for an image part (`[Content_Types].xml` Override). * @private */ export declare type ImageContentType = 'image/png' | 'image/jpeg' | 'image/gif' | 'image/bmp' | 'image/tiff' | 'image/webp' | 'image/svg+xml' | 'image/emf' | 'image/wmf'; /** * Known image content-type constants used by the media part allocator. * @private */ export declare const ImageContentTypes: Record; export interface ImagePosition { readonly row: number; readonly column: number; /** Width in points (72 points = 1 inch). */ readonly width: number; /** Height in points (72 points = 1 inch). */ readonly height: number; /** Absolute top from sheet origin in points (XlsIO IShape.Top); optional on bags. */ readonly top?: number; /** Absolute left from sheet origin in points (XlsIO IShape.Left); optional on bags. */ readonly left?: number; } /** * Represents an image embedded in a worksheet, letting you set its position * and size. */ export interface Image { /** * @private * Drawing object id (`xdr:cNvPr/@id`), unique within the worksheet drawing. */ readonly id: number; /** * @private * Package relationship id for the image part. */ readonly relationshipId: string | undefined; /** * @private * The picture's package content type — for example `'image/png'` or * `'image/jpeg'`. Detected from bytes on add; not an authoring argument. */ readonly contentType: string; /** The raw bytes of the picture file. */ readonly bytes: Uint8Array; /** * @private * DrawingML `xdr:cNvPr/@name` — for example `'Image 1'`. */ name: string; /** * @private * DrawingML `xdr:cNvPr/@descr` alt text; `undefined` when not set. */ description: string | undefined; /** * The row the picture's top edge is anchored to — 1-based, like Excel * rows. Setting `row` snaps the top edge to the row boundary (zero rowOff). */ row: number; /** * The column the picture's left edge is anchored to — 1-based, like * Excel columns. Setting `column` snaps the left edge to the column * boundary (zero colOff). */ column: number; /** * Absolute distance in points from the top of the sheet (row 1) to the * top edge of the picture (XlsIO `IShape.Top`). Setting `top` rewrites * `row` and DrawingML `xdr:rowOff` from live row heights (Excel-like * defaults when heights are unset). */ top: number; /** * Absolute distance in points from the left of the sheet (column A) to * the left edge of the picture (XlsIO `IShape.Left`). Setting `left` * rewrites `column` and `xdr:colOff` from live column widths. */ left: number; /** Width in points (72 points = 1 inch). Example: `144` = 2 inches. */ width: number; /** Height in points (72 points = 1 inch). Example: `72` = 1 inch. */ height: number; /** * Create an independent copy of this picture, detached from the * worksheet until it is added again. * * @returns the copied picture. */ clone(): Image; } export interface ImagesHost { markDirty(): void; readonly package: OpcPackage; readonly sheetPartName: string | undefined; /** 1-based row height in points; 0 = unset → placement default. */ getRowHeightPt?(row: number): number; /** 1-based column width in OOXML character units; 0 = unset. */ getColumnWidthChars?(column: number): number; } export interface ImagesMaterializeResult { readonly drawingRel: OpcRelationship | undefined; readonly drawingRelationshipId: string | undefined; readonly ownsDrawingElement: boolean; } export declare class ImagesImpl { private readonly entries; private readonly handles; private host; private drawingPartName; private drawingRelId; private loaded; private dirty; private nextId; private nextName; bindHost(host: ImagesHost): void; loadFromPackage(pkg: OpcPackage, sheetPartName: string | undefined): void; readonly images: ReadonlyArray; add(bytes: Uint8Array, row: number, column: number, width: number, height: number): Image; remove(target: Image | number): void; materializeOnFlush(drawingRel: OpcRelationship | undefined): ImagesMaterializeResult; private allocateDrawingPart; private allocateMediaPart; private markDirty; private sheetMetrics; private handleFor; }