Got docx not crashing when adding image

This commit is contained in:
Dolan
2018-01-16 01:31:47 +00:00
parent f7c2072cff
commit 7c31b72f99
8 changed files with 101 additions and 4 deletions

View File

@ -0,0 +1,15 @@
import { XmlAttributeComponent } from "file/xml-components";
export interface IDocPropertiesAttributes {
id?: number;
name?: string;
descr?: string;
}
export class DocPropertiesAttributes extends XmlAttributeComponent<IDocPropertiesAttributes> {
protected xmlKeys = {
id: "id",
name: "name",
descr: "descr",
};
}

View File

@ -0,0 +1,15 @@
import { XmlComponent } from "file/xml-components";
import { DocPropertiesAttributes } from "./doc-properties-attributes";
export class DocProperties extends XmlComponent {
constructor() {
super("wp:docPr");
this.root.push(new DocPropertiesAttributes({
id: 0,
name: "",
descr: "",
}));
}
}

View File

@ -0,0 +1,17 @@
import { XmlAttributeComponent } from "file/xml-components";
export interface IEffectExtentAttributes {
b?: number;
l?: number;
r?: number;
t?: number;
}
export class EffectExtentAttributes extends XmlAttributeComponent<IEffectExtentAttributes> {
protected xmlKeys = {
b: "b",
l: "l",
r: "r",
t: "t",
};
}

View File

@ -0,0 +1,16 @@
import { XmlComponent } from "file/xml-components";
import { EffectExtentAttributes } from "./effect-extent-attributes";
export class EffectExtent extends XmlComponent {
constructor() {
super("wp:effectExtent");
this.root.push(new EffectExtentAttributes({
b: 0,
l: 0,
r: 0,
t: 0,
}));
}
}

View File

@ -0,0 +1,13 @@
import { XmlAttributeComponent } from "file/xml-components";
export interface IExtentAttributes {
cx?: number;
cy?: number;
}
export class ExtentAttributes extends XmlAttributeComponent<IExtentAttributes> {
protected xmlKeys = {
cx: "cx",
cy: "cy",
};
}

View File

@ -0,0 +1,14 @@
import { XmlComponent } from "file/xml-components";
import { ExtentAttributes } from "./extent-attributes";
export class Extent extends XmlComponent {
constructor() {
super("wp:extent");
this.root.push(new ExtentAttributes({
cx: 3162300,
cy: 2857500,
}));
}
}

View File

@ -1,8 +1,8 @@
// http://officeopenxml.com/drwSp-SpPr.php
import { XmlComponent } from "file/xml-components";
import { Form } from "./form";
import { NoFill } from "./no-fill";
import { Outline } from "./outline/outline";
// import { NoFill } from "./no-fill";
// import { Outline } from "./outline/outline";
import { PresetGeometry } from "./preset-geometry/preset-geometry";
import { ShapePropertiesAttributes } from "./shape-properties-attributes";
@ -17,7 +17,7 @@ export class ShapeProperties extends XmlComponent {
this.root.push(new Form());
this.root.push(new PresetGeometry());
this.root.push(new NoFill());
this.root.push(new Outline());
// this.root.push(new NoFill());
// this.root.push(new Outline());
}
}

View File

@ -1,4 +1,8 @@
// http://officeopenxml.com/drwPicInline.php
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";
import { InlineAttributes } from "./inline-attributes";
@ -15,6 +19,9 @@ export class Inline extends XmlComponent {
distR: 0,
}));
this.root.push(new Extent());
this.root.push(new EffectExtent());
this.root.push(new DocProperties());
this.root.push(new GraphicFrameProperties());
this.root.push(new Graphic(referenceId));
}