pptx-automizer
Version:
A template based pptx generator
96 lines (95 loc) • 4.06 kB
TypeScript
/**
* @file ModifyShapeHelper provides utility functions for manipulating PowerPoint shapes
* through XML modifications.
*/
import { ReplaceText, ReplaceTextOptions } from '../types/modify-types';
import { ShapeCoordinates } from '../types/shape-types';
import { ElementVisualType, PlaceholderInfo, ShapeBackgroundInfo, XmlElement } from '../types/xml-types';
/**
* Helper class for modifying PowerPoint shapes in XML structure
* Provides various methods for manipulating shape appearance, position, and content
*/
export default class ModifyShapeHelper {
/**
* Set solid fill of modified shape to accent6 color
*
* @param element - XML element representing the shape
*/
static setSolidFill: (element: XmlElement) => void;
/**
* Set text content of a shape
*
* @param text - Text string to set as shape content
* @returns Function that accepts an XML element to modify
*/
static setText: (text: string) => (element: XmlElement) => void;
/**
* Set content to bulleted list within a shape
*
* @param list - Array or string content for the bullet list
* @returns Function that accepts an XML element to modify
*/
static setBulletList: (list: any) => (element: XmlElement) => void;
/**
* Replace tagged text content within modified shape
*
* @param replaceText - Single replacement or array of replacements
* @param options - Optional configuration for text replacement
* @returns Function that accepts an XML element to modify
*/
static replaceText: (replaceText: ReplaceText | ReplaceText[], options?: ReplaceTextOptions) => (element: XmlElement) => void;
/**
* Creates missing transformation elements (a:off and a:ext) with default values
* Ensures that a shape has the required XML structure for positioning and sizing
*
* @param element - The XML element to check and modify
* @returns The xfrm element that contains or will contain the transformation data
*/
static ensureTransformElements: (element: XmlElement) => XmlElement | null;
/**
* Set absolute position and size of a shape
*
* @param pos - Object containing position and size coordinates
* @returns Function that accepts an XML element to modify
*/
static setPosition: (pos: ShapeCoordinates) => (element: XmlElement) => void;
/**
* Incrementally update position and size of a shape by adding delta values
*
* @param pos - Object containing delta values for position and size
* @returns Function that accepts an XML element to modify
*/
static updatePosition: (pos: ShapeCoordinates) => (element: XmlElement) => void;
/**
* Rotate a shape by a given angle in degrees
*
* @param degrees - Rotation angle in degrees (positive = clockwise, negative = counterclockwise)
* @returns Function that accepts an XML element to modify
*/
static rotate: (degrees: number) => (element: XmlElement) => void;
/**
* Apply rounded corners to a shape with a specified corner radius
*
* @param degree - Corner radius in EMU units (1 cm = 360000 EMU)
* @returns Function that accepts an XML element to modify
*/
static roundedCorners: (degree: number) => (element: XmlElement) => void;
/**
* Determines the type of visual element in PowerPoint
* @param element The XML element to check
* @returns A string identifying the element type
*/
static getElementVisualType(element: XmlElement): ElementVisualType;
/**
* Forward placeholder info function
* @param element The XML element to check
* @returns The PlaceholderInfo object
*/
static getElementPlaceholderInfo(element: XmlElement): PlaceholderInfo;
/**
* Check if the given element has a background which is non-transparent
* @param element The XML element to check
* @returns ShapeBackgroundInfo
*/
static elementHasBackground(element: XmlElement): ShapeBackgroundInfo;
}