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

45 lines
1.5 KiB
TypeScript
Raw Normal View History

// http://officeopenxml.com/drwPicInline.php
2018-01-22 20:42:57 +00:00
import { IMediaDataDimensions } 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 { Graphic } from "./../graphic";
import { GraphicFrameProperties } from "./../graphic-frame/graphic-frame-properties";
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-03-24 19:06:10 +00:00
private extent: Extent;
private graphic: Graphic;
constructor(referenceId: number, private dimensions: IMediaDataDimensions) {
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
2018-03-24 19:06:10 +00:00
this.extent = new Extent(dimensions.emus.x, dimensions.emus.y);
this.graphic = new Graphic(referenceId, dimensions.emus.x, dimensions.emus.y);
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 {
2018-04-02 12:55:43 +03:00
const newX = Math.round(this.dimensions.emus.x * factorX);
const newY = Math.round(this.dimensions.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
}
}