| |
| |
| |
|
|
| import { CHART_NAME, SHAPE_NAME } from './core-enums' |
| import { |
| AddSlideProps, |
| BackgroundProps, |
| FormulaProps, |
| HexColor, |
| IChartMulti, |
| IChartOpts, |
| IChartOptsLib, |
| IOptsChartData, |
| ISlideObject, |
| ISlideRel, |
| ISlideRelChart, |
| ISlideRelMedia, |
| ImageProps, |
| MediaProps, |
| PresLayout, |
| PresSlide, |
| ShapeProps, |
| SlideLayout, |
| SlideNumberProps, |
| TableProps, |
| TableRow, |
| TextProps, |
| TextPropsOptions, |
| } from './core-interfaces' |
| import * as genObj from './gen-objects' |
|
|
| export default class Slide { |
| private readonly _setSlideNum: (value: SlideNumberProps) => void |
|
|
| public addSlide: (options?: AddSlideProps) => PresSlide |
| public getSlide: (slideNum: number) => PresSlide |
| public _name: string |
| public _presLayout: PresLayout |
| public _rels: ISlideRel[] |
| public _relsChart: ISlideRelChart[] |
| public _relsMedia: ISlideRelMedia[] |
| public _rId: number |
| public _slideId: number |
| public _slideLayout: SlideLayout |
| public _slideNum: number |
| public _slideNumberProps: SlideNumberProps |
| public _slideObjects: ISlideObject[] |
| public _newAutoPagedSlides: PresSlide[] |
|
|
| constructor(params: { |
| addSlide: (options?: AddSlideProps) => PresSlide |
| getSlide: (slideNum: number) => PresSlide |
| presLayout: PresLayout |
| setSlideNum: (value: SlideNumberProps) => void |
| slideId: number |
| slideRId: number |
| slideNumber: number |
| slideLayout?: SlideLayout |
| }) { |
| this.addSlide = params.addSlide |
| this.getSlide = params.getSlide |
| this._name = `Slide ${params.slideNumber}` |
| this._presLayout = params.presLayout |
| this._rId = params.slideRId |
| this._rels = [] |
| this._relsChart = [] |
| this._relsMedia = [] |
| this._setSlideNum = params.setSlideNum |
| this._slideId = params.slideId |
| this._slideLayout = params.slideLayout || null |
| this._slideNum = params.slideNumber |
| this._slideObjects = [] |
| |
| |
| |
| |
| this._slideNumberProps = this._slideLayout?._slideNumberProps ? this._slideLayout._slideNumberProps : null |
| } |
|
|
| |
| |
| |
| |
| |
| private _bkgd: string | BackgroundProps |
| public set bkgd(value: string | BackgroundProps) { |
| this._bkgd = value |
| if (!this._background || !this._background.color) { |
| if (!this._background) this._background = {} |
| if (typeof value === 'string') this._background.color = value |
| } |
| } |
|
|
| public get bkgd(): string | BackgroundProps { |
| return this._bkgd |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| private _background: BackgroundProps |
| public set background(props: BackgroundProps) { |
| this._background = props |
| |
| if (props) genObj.addBackgroundDefinition(props, this) |
| } |
|
|
| public get background(): BackgroundProps { |
| return this._background |
| } |
|
|
| |
| |
| |
| |
| private _color: HexColor |
| public set color(value: HexColor) { |
| this._color = value |
| } |
|
|
| public get color(): HexColor { |
| return this._color |
| } |
|
|
| |
| |
| |
| private _hidden: boolean |
| public set hidden(value: boolean) { |
| this._hidden = value |
| } |
|
|
| public get hidden(): boolean { |
| return this._hidden |
| } |
|
|
| |
| |
| |
| public set slideNumber(value: SlideNumberProps) { |
| |
| this._slideNumberProps = value |
| this._setSlideNum(value) |
| } |
|
|
| public get slideNumber(): SlideNumberProps { |
| return this._slideNumberProps |
| } |
|
|
| public get newAutoPagedSlides(): PresSlide[] { |
| return this._newAutoPagedSlides |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| addChart(type: CHART_NAME | IChartMulti[], data: IOptsChartData[], options?: IChartOpts): Slide { |
| |
| |
| const optionsWithType: IChartOptsLib = options || {} |
| optionsWithType._type = type |
| genObj.addChartDefinition(this, type, data, options) |
| return this |
| } |
|
|
| |
| |
| |
| |
| |
| addImage(options: ImageProps): Slide { |
| genObj.addImageDefinition(this, options) |
| return this |
| } |
|
|
| |
| |
| |
| |
| |
| addMedia(options: MediaProps): Slide { |
| genObj.addMediaDefinition(this, options) |
| return this |
| } |
|
|
| |
| |
| |
| |
| |
| |
| addNotes(notes: string): Slide { |
| genObj.addNotesDefinition(this, notes) |
| return this |
| } |
|
|
| |
| |
| |
| |
| |
| |
| addShape(shapeName: SHAPE_NAME, options?: ShapeProps): Slide { |
| |
| |
| |
| |
| |
| genObj.addShapeDefinition(this, shapeName, options) |
| return this |
| } |
|
|
| |
| |
| |
| |
| |
| |
| addTable(tableRows: TableRow[], options?: TableProps): Slide { |
| |
| this._newAutoPagedSlides = genObj.addTableDefinition(this, tableRows, options, this._slideLayout, this._presLayout, this.addSlide, this.getSlide) |
| return this |
| } |
|
|
| |
| |
| |
| |
| |
| |
| addText(text: string | TextProps[], options?: TextPropsOptions): Slide { |
| const textParam = typeof text === 'string' || typeof text === 'number' ? [{ text, options }] : text |
| genObj.addTextDefinition(this, textParam, options, false) |
| return this |
| } |
|
|
| |
| |
| |
| |
| |
| addFormula(options: FormulaProps): Slide { |
| genObj.addFormulaDefinition(this, options) |
| return this |
| } |
| } |
|
|