Add scalable image feature
This commit is contained in:
@ -3,6 +3,8 @@ import { GraphicDataAttributes } from "./graphic-data-attribute";
|
||||
import { Pic } from "./pic";
|
||||
|
||||
export class GraphicData extends XmlComponent {
|
||||
private pic: Pic;
|
||||
|
||||
constructor(referenceId: number, x: number, y: number) {
|
||||
super("a:graphicData");
|
||||
|
||||
@ -12,6 +14,12 @@ export class GraphicData extends XmlComponent {
|
||||
}),
|
||||
);
|
||||
|
||||
this.root.push(new Pic(referenceId, x, y));
|
||||
this.pic = new Pic(referenceId, x, y);
|
||||
|
||||
this.root.push(this.pic);
|
||||
}
|
||||
|
||||
public setXY(x: number, y: number): void {
|
||||
this.pic.setXY(x, y);
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,8 @@ import { PicAttributes } from "./pic-attributes";
|
||||
import { ShapeProperties } from "./shape-properties/shape-properties";
|
||||
|
||||
export class Pic extends XmlComponent {
|
||||
private shapeProperties: ShapeProperties;
|
||||
|
||||
constructor(referenceId: number, x: number, y: number) {
|
||||
super("pic:pic");
|
||||
|
||||
@ -14,8 +16,15 @@ export class Pic extends XmlComponent {
|
||||
xmlns: "http://schemas.openxmlformats.org/drawingml/2006/picture",
|
||||
}),
|
||||
);
|
||||
|
||||
this.shapeProperties = new ShapeProperties(x, y);
|
||||
|
||||
this.root.push(new NonVisualPicProperties());
|
||||
this.root.push(new BlipFill(referenceId));
|
||||
this.root.push(new ShapeProperties(x, y));
|
||||
}
|
||||
|
||||
public setXY(x: number, y: number): void {
|
||||
this.shapeProperties.setXY(x, y);
|
||||
}
|
||||
}
|
||||
|
@ -3,14 +3,23 @@ import { XmlComponent } from "file/xml-components";
|
||||
import { ExtentsAttributes } from "./extents-attributes";
|
||||
|
||||
export class Extents extends XmlComponent {
|
||||
private attributes: ExtentsAttributes;
|
||||
|
||||
constructor(x: number, y: number) {
|
||||
super("a:ext");
|
||||
|
||||
this.root.push(
|
||||
new ExtentsAttributes({
|
||||
cx: x,
|
||||
cy: y,
|
||||
}),
|
||||
);
|
||||
this.attributes = new ExtentsAttributes({
|
||||
cx: x,
|
||||
cy: y,
|
||||
});
|
||||
|
||||
this.root.push(this.attributes);
|
||||
}
|
||||
|
||||
public setXY(x: number, y: number): void {
|
||||
this.attributes.set({
|
||||
cx: x,
|
||||
cy: y,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -4,10 +4,18 @@ import { Extents } from "./extents/extents";
|
||||
import { Offset } from "./offset/off";
|
||||
|
||||
export class Form extends XmlComponent {
|
||||
private extents: Extents;
|
||||
|
||||
constructor(x: number, y: number) {
|
||||
super("a:xfrm");
|
||||
|
||||
this.root.push(new Extents(x, y));
|
||||
this.extents = new Extents(x, y);
|
||||
|
||||
this.root.push(this.extents);
|
||||
this.root.push(new Offset());
|
||||
}
|
||||
|
||||
public setXY(x: number, y: number): void {
|
||||
this.extents.setXY(x, y);
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,8 @@ import { PresetGeometry } from "./preset-geometry/preset-geometry";
|
||||
import { ShapePropertiesAttributes } from "./shape-properties-attributes";
|
||||
|
||||
export class ShapeProperties extends XmlComponent {
|
||||
private form: Form;
|
||||
|
||||
constructor(x: number, y: number) {
|
||||
super("pic:spPr");
|
||||
|
||||
@ -16,9 +18,15 @@ export class ShapeProperties extends XmlComponent {
|
||||
}),
|
||||
);
|
||||
|
||||
this.root.push(new Form(x, y));
|
||||
this.form = new Form(x, y);
|
||||
|
||||
this.root.push(this.form);
|
||||
this.root.push(new PresetGeometry());
|
||||
// this.root.push(new NoFill());
|
||||
// this.root.push(new Outline());
|
||||
}
|
||||
|
||||
public setXY(x: number, y: number): void {
|
||||
this.form.setXY(x, y);
|
||||
}
|
||||
}
|
||||
|
33
src/file/drawing/inline/graphic/graphic.ts
Normal file
33
src/file/drawing/inline/graphic/graphic.ts
Normal file
@ -0,0 +1,33 @@
|
||||
import { XmlAttributeComponent, XmlComponent } from "file/xml-components";
|
||||
import { GraphicData } from "./graphic-data";
|
||||
|
||||
interface IGraphicProperties {
|
||||
a: string;
|
||||
}
|
||||
|
||||
class GraphicAttributes extends XmlAttributeComponent<IGraphicProperties> {
|
||||
protected xmlKeys = {
|
||||
a: "xmlns:a",
|
||||
};
|
||||
}
|
||||
|
||||
export class Graphic extends XmlComponent {
|
||||
private data: GraphicData;
|
||||
|
||||
constructor(referenceId: number, x: number, y: number) {
|
||||
super("a:graphic");
|
||||
this.root.push(
|
||||
new GraphicAttributes({
|
||||
a: "http://schemas.openxmlformats.org/drawingml/2006/main",
|
||||
}),
|
||||
);
|
||||
|
||||
this.data = new GraphicData(referenceId, x, y);
|
||||
|
||||
this.root.push(this.data);
|
||||
}
|
||||
|
||||
public setXY(x: number, y: number): void {
|
||||
this.data.setXY(x, y);
|
||||
}
|
||||
}
|
@ -1,24 +1 @@
|
||||
import { XmlAttributeComponent, XmlComponent } from "file/xml-components";
|
||||
import { GraphicData } from "./graphic-data";
|
||||
|
||||
interface IGraphicProperties {
|
||||
a: string;
|
||||
}
|
||||
|
||||
class GraphicAttributes extends XmlAttributeComponent<IGraphicProperties> {
|
||||
protected xmlKeys = {
|
||||
a: "xmlns:a",
|
||||
};
|
||||
}
|
||||
|
||||
export class Graphic extends XmlComponent {
|
||||
constructor(referenceId: number, x: number, y: number) {
|
||||
super("a:graphic");
|
||||
this.root.push(
|
||||
new GraphicAttributes({
|
||||
a: "http://schemas.openxmlformats.org/drawingml/2006/main",
|
||||
}),
|
||||
);
|
||||
this.root.push(new GraphicData(referenceId, x, y));
|
||||
}
|
||||
}
|
||||
export * from "./graphic";
|
||||
|
Reference in New Issue
Block a user