Mandatory Sections

This commit is contained in:
Dolan Miu
2019-07-31 08:48:02 +01:00
parent bf80311ef7
commit ac5b15d0e3
63 changed files with 1194 additions and 1588 deletions

View File

@ -1,12 +1,8 @@
// tslint:disable:object-literal-key-quotes
import { assert, expect } from "chai";
import { Formatter } from "export/formatter";
import { assert } from "chai";
import { ImageParagraph } from "./image";
import { EMPTY_OBJECT } from "file/xml-components";
describe("Image", () => {
let image: ImageParagraph;
@ -40,190 +36,4 @@ describe("Image", () => {
assert.isTrue(true);
});
});
describe("#scale()", () => {
it("should set the scale of the object properly", () => {
image.scale(2);
const tree = new Formatter().format(image);
expect(tree).to.deep.equal({
"w:p": [
{
"w:r": [
{
"w:drawing": [
{
"wp:inline": [
{
_attr: {
distB: 0,
distL: 0,
distR: 0,
distT: 0,
},
},
{
"wp:extent": {
_attr: {
cx: 20,
cy: 20,
},
},
},
{
"wp:effectExtent": {
_attr: {
b: 0,
l: 0,
r: 0,
t: 0,
},
},
},
{
"wp:docPr": {
_attr: {
descr: "",
id: 0,
name: "",
},
},
},
{
"wp:cNvGraphicFramePr": [
{
"a:graphicFrameLocks": {
_attr: {
noChangeAspect: 1,
"xmlns:a": "http://schemas.openxmlformats.org/drawingml/2006/main",
},
},
},
],
},
{
"a:graphic": [
{
_attr: {
"xmlns:a": "http://schemas.openxmlformats.org/drawingml/2006/main",
},
},
{
"a:graphicData": [
{
_attr: {
uri: "http://schemas.openxmlformats.org/drawingml/2006/picture",
},
},
{
"pic:pic": [
{
_attr: {
"xmlns:pic":
"http://schemas.openxmlformats.org/drawingml/2006/picture",
},
},
{
"pic:nvPicPr": [
{
"pic:cNvPr": {
_attr: {
desc: "",
id: 0,
name: "",
},
},
},
{
"pic:cNvPicPr": [
{
"a:picLocks": {
_attr: {
noChangeArrowheads: 1,
noChangeAspect: 1,
},
},
},
],
},
],
},
{
"pic:blipFill": [
{
"a:blip": {
_attr: {
cstate: "none",
"r:embed": "rId{test.png}",
},
},
},
{
"a:srcRect": EMPTY_OBJECT,
},
{
"a:stretch": [
{
"a:fillRect": EMPTY_OBJECT,
},
],
},
],
},
{
"pic:spPr": [
{
_attr: {
bwMode: "auto",
},
},
{
"a:xfrm": [
{
"a:ext": {
_attr: {
cx: 10,
cy: 10,
},
},
},
{
"a:off": {
_attr: {
x: 0,
y: 0,
},
},
},
],
},
{
"a:prstGeom": [
{
_attr: {
prst: "rect",
},
},
{
"a:avLst": EMPTY_OBJECT,
},
],
},
],
},
],
},
],
},
],
},
],
},
],
},
],
},
],
});
});
});
});

View File

@ -12,10 +12,6 @@ export class ImageParagraph extends Paragraph {
this.root.push(this.pictureRun);
}
public scale(factorX: number, factorY?: number): void {
this.pictureRun.scale(factorX, factorY);
}
public get Run(): PictureRun {
return this.pictureRun;
}

View File

@ -4,8 +4,6 @@ import { IMediaData } from "../../media/data";
import { Run } from "../run";
export class PictureRun extends Run {
private readonly drawing: Drawing;
constructor(imageData: IMediaData, drawingOptions?: IDrawingOptions) {
super({});
@ -13,12 +11,8 @@ export class PictureRun extends Run {
throw new Error("imageData cannot be undefined");
}
this.drawing = new Drawing(imageData, drawingOptions);
const drawing = new Drawing(imageData, drawingOptions);
this.root.push(this.drawing);
}
public scale(factorX: number = 1, factorY: number = factorX): void {
this.drawing.scale(factorX, factorY);
this.root.push(drawing);
}
}