Got docx not crashing when adding image
This commit is contained in:
@ -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",
|
||||||
|
};
|
||||||
|
}
|
15
src/file/drawing/inline/doc-properties/doc-properties.ts
Normal file
15
src/file/drawing/inline/doc-properties/doc-properties.ts
Normal 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: "",
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
@ -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",
|
||||||
|
};
|
||||||
|
}
|
16
src/file/drawing/inline/effect-extent/effect-extent.ts
Normal file
16
src/file/drawing/inline/effect-extent/effect-extent.ts
Normal 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,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
13
src/file/drawing/inline/extent/extent-attributes.ts
Normal file
13
src/file/drawing/inline/extent/extent-attributes.ts
Normal 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",
|
||||||
|
};
|
||||||
|
}
|
14
src/file/drawing/inline/extent/extent.ts
Normal file
14
src/file/drawing/inline/extent/extent.ts
Normal 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,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
@ -1,8 +1,8 @@
|
|||||||
// http://officeopenxml.com/drwSp-SpPr.php
|
// http://officeopenxml.com/drwSp-SpPr.php
|
||||||
import { XmlComponent } from "file/xml-components";
|
import { XmlComponent } from "file/xml-components";
|
||||||
import { Form } from "./form";
|
import { Form } from "./form";
|
||||||
import { NoFill } from "./no-fill";
|
// import { NoFill } from "./no-fill";
|
||||||
import { Outline } from "./outline/outline";
|
// import { Outline } from "./outline/outline";
|
||||||
import { PresetGeometry } from "./preset-geometry/preset-geometry";
|
import { PresetGeometry } from "./preset-geometry/preset-geometry";
|
||||||
import { ShapePropertiesAttributes } from "./shape-properties-attributes";
|
import { ShapePropertiesAttributes } from "./shape-properties-attributes";
|
||||||
|
|
||||||
@ -17,7 +17,7 @@ export class ShapeProperties extends XmlComponent {
|
|||||||
|
|
||||||
this.root.push(new Form());
|
this.root.push(new Form());
|
||||||
this.root.push(new PresetGeometry());
|
this.root.push(new PresetGeometry());
|
||||||
this.root.push(new NoFill());
|
// this.root.push(new NoFill());
|
||||||
this.root.push(new Outline());
|
// this.root.push(new Outline());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,8 @@
|
|||||||
|
// http://officeopenxml.com/drwPicInline.php
|
||||||
import { XmlComponent } from "file/xml-components";
|
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 { Graphic } from "./graphic";
|
||||||
import { GraphicFrameProperties } from "./graphic-frame/graphic-frame-properties";
|
import { GraphicFrameProperties } from "./graphic-frame/graphic-frame-properties";
|
||||||
import { InlineAttributes } from "./inline-attributes";
|
import { InlineAttributes } from "./inline-attributes";
|
||||||
@ -15,6 +19,9 @@ export class Inline extends XmlComponent {
|
|||||||
distR: 0,
|
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 GraphicFrameProperties());
|
||||||
this.root.push(new Graphic(referenceId));
|
this.root.push(new Graphic(referenceId));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user