Files
docx-js/src/file/drawing/inline/inline.ts

45 lines
1.6 KiB
TypeScript
Raw Normal View History

// http://officeopenxml.com/drwPicInline.php
2021-03-15 02:41:37 +00:00
import { IMediaData, IMediaDataTransformation } from "file/media";
2018-01-11 01:47:09 +00:00
import { XmlComponent } from "file/xml-components";
import { DocProperties } from "./../doc-properties/doc-properties";
import { EffectExtent } from "./../effect-extent/effect-extent";
import { Extent } from "./../extent/extent";
import { GraphicFrameProperties } from "./../graphic-frame/graphic-frame-properties";
2018-06-09 23:49:01 +01:00
import { Graphic } from "./../inline/graphic";
2018-01-16 00:43:00 +00:00
import { InlineAttributes } from "./inline-attributes";
2018-01-11 01:47:09 +00:00
export class Inline extends XmlComponent {
2018-08-07 01:38:15 +01:00
private readonly extent: Extent;
private readonly graphic: Graphic;
2018-03-24 19:06:10 +00:00
2021-03-15 02:41:37 +00:00
constructor(mediaData: IMediaData, private readonly transform: IMediaDataTransformation) {
2018-01-11 01:47:09 +00:00
super("wp:inline");
2018-01-23 01:33:12 +00:00
this.root.push(
new InlineAttributes({
distT: 0,
distB: 0,
distL: 0,
distR: 0,
}),
);
2018-01-16 00:43:00 +00:00
2021-03-15 02:41:37 +00:00
this.extent = new Extent(transform.emus.x, transform.emus.y);
this.graphic = new Graphic(mediaData, transform);
2018-03-24 19:06:10 +00:00
this.root.push(this.extent);
this.root.push(new EffectExtent());
this.root.push(new DocProperties());
2018-01-11 01:47:09 +00:00
this.root.push(new GraphicFrameProperties());
2018-03-24 19:06:10 +00:00
this.root.push(this.graphic);
}
public scale(factorX: number, factorY: number): void {
2021-03-15 02:41:37 +00:00
const newX = Math.round(this.transform.emus.x * factorX);
const newY = Math.round(this.transform.emus.y * factorY);
2018-03-24 19:06:10 +00:00
this.extent.setXY(newX, newY);
this.graphic.setXY(newX, newY);
2018-01-11 01:47:09 +00:00
}
}