remove deprecated mutable drawing functions: scale, setXY
This commit is contained in:
@ -28,8 +28,4 @@ export class Drawing extends XmlComponent {
|
|||||||
this.root.push(new Anchor(imageData, imageData.transformation, drawingOptions));
|
this.root.push(new Anchor(imageData, imageData.transformation, drawingOptions));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public scale(factorX: number, factorY: number): void {
|
|
||||||
this.inline.scale(factorX, factorY);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -15,11 +15,4 @@ export class Extent extends XmlComponent {
|
|||||||
|
|
||||||
this.root.push(this.attributes);
|
this.root.push(this.attributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
public setXY(x: number, y: number): void {
|
|
||||||
this.attributes.set({
|
|
||||||
cx: x,
|
|
||||||
cy: y,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -49,5 +49,9 @@ describe("HorizontalPosition", () => {
|
|||||||
],
|
],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should require one of align or offset", () => {
|
||||||
|
expect(() => new HorizontalPosition({})).to.throw();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -20,8 +20,4 @@ export class GraphicData extends XmlComponent {
|
|||||||
|
|
||||||
this.root.push(this.pic);
|
this.root.push(this.pic);
|
||||||
}
|
}
|
||||||
|
|
||||||
public setXY(x: number, y: number): void {
|
|
||||||
this.pic.setXY(x, y);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -8,8 +8,6 @@ import { PicAttributes } from "./pic-attributes";
|
|||||||
import { ShapeProperties } from "./shape-properties/shape-properties";
|
import { ShapeProperties } from "./shape-properties/shape-properties";
|
||||||
|
|
||||||
export class Pic extends XmlComponent {
|
export class Pic extends XmlComponent {
|
||||||
private readonly shapeProperties: ShapeProperties;
|
|
||||||
|
|
||||||
constructor(mediaData: IMediaData, transform: IMediaDataTransformation) {
|
constructor(mediaData: IMediaData, transform: IMediaDataTransformation) {
|
||||||
super("pic:pic");
|
super("pic:pic");
|
||||||
|
|
||||||
@ -19,14 +17,8 @@ export class Pic extends XmlComponent {
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
this.shapeProperties = new ShapeProperties(transform);
|
|
||||||
|
|
||||||
this.root.push(new NonVisualPicProperties());
|
this.root.push(new NonVisualPicProperties());
|
||||||
this.root.push(new BlipFill(mediaData));
|
this.root.push(new BlipFill(mediaData));
|
||||||
this.root.push(new ShapeProperties(transform));
|
this.root.push(new ShapeProperties(transform));
|
||||||
}
|
}
|
||||||
|
|
||||||
public setXY(x: number, y: number): void {
|
|
||||||
this.shapeProperties.setXY(x, y);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -15,11 +15,4 @@ export class Extents extends XmlComponent {
|
|||||||
|
|
||||||
this.root.push(this.attributes);
|
this.root.push(this.attributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
public setXY(x: number, y: number): void {
|
|
||||||
this.attributes.set({
|
|
||||||
cx: x,
|
|
||||||
cy: y,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -37,8 +37,4 @@ export class Form extends XmlComponent {
|
|||||||
this.root.push(new Offset());
|
this.root.push(new Offset());
|
||||||
this.root.push(this.extents);
|
this.root.push(this.extents);
|
||||||
}
|
}
|
||||||
|
|
||||||
public setXY(x: number, y: number): void {
|
|
||||||
this.extents.setXY(x, y);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -26,8 +26,4 @@ export class ShapeProperties extends XmlComponent {
|
|||||||
// this.root.push(new NoFill());
|
// this.root.push(new NoFill());
|
||||||
// this.root.push(new Outline());
|
// this.root.push(new Outline());
|
||||||
}
|
}
|
||||||
|
|
||||||
public setXY(x: number, y: number): void {
|
|
||||||
this.form.setXY(x, y);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -26,8 +26,4 @@ export class Graphic extends XmlComponent {
|
|||||||
|
|
||||||
this.root.push(this.data);
|
this.root.push(this.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public setXY(x: number, y: number): void {
|
|
||||||
this.data.setXY(x, y);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ export class Inline extends XmlComponent {
|
|||||||
private readonly extent: Extent;
|
private readonly extent: Extent;
|
||||||
private readonly graphic: Graphic;
|
private readonly graphic: Graphic;
|
||||||
|
|
||||||
constructor(mediaData: IMediaData, private readonly transform: IMediaDataTransformation) {
|
constructor(mediaData: IMediaData, transform: IMediaDataTransformation) {
|
||||||
super("wp:inline");
|
super("wp:inline");
|
||||||
|
|
||||||
this.root.push(
|
this.root.push(
|
||||||
@ -33,12 +33,4 @@ export class Inline extends XmlComponent {
|
|||||||
this.root.push(new GraphicFrameProperties());
|
this.root.push(new GraphicFrameProperties());
|
||||||
this.root.push(this.graphic);
|
this.root.push(this.graphic);
|
||||||
}
|
}
|
||||||
|
|
||||||
public scale(factorX: number, factorY: number): void {
|
|
||||||
const newX = Math.round(this.transform.emus.x * factorX);
|
|
||||||
const newY = Math.round(this.transform.emus.y * factorY);
|
|
||||||
|
|
||||||
this.extent.setXY(newX, newY);
|
|
||||||
this.graphic.setXY(newX, newY);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -82,6 +82,11 @@ describe("Border", () => {
|
|||||||
],
|
],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should not add empty borders element if there are no borders defined", () => {
|
||||||
|
const tb = new Border({});
|
||||||
|
expect(() => new Formatter().format(tb)).to.throw();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// http://officeopenxml.com/WPborders.php
|
// http://officeopenxml.com/WPborders.php
|
||||||
import { BorderElement, BorderStyle, IBorderOptions } from "file/border";
|
import { BorderElement, BorderStyle, IBorderOptions } from "file/border";
|
||||||
import { XmlComponent } from "file/xml-components";
|
import { IgnoreIfEmptyXmlComponent, XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
export interface IBordersOptions {
|
export interface IBordersOptions {
|
||||||
readonly top?: IBorderOptions;
|
readonly top?: IBorderOptions;
|
||||||
@ -9,7 +9,7 @@ export interface IBordersOptions {
|
|||||||
readonly right?: IBorderOptions;
|
readonly right?: IBorderOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Border extends XmlComponent {
|
export class Border extends IgnoreIfEmptyXmlComponent {
|
||||||
constructor(options: IBordersOptions) {
|
constructor(options: IBordersOptions) {
|
||||||
super("w:pBdr");
|
super("w:pBdr");
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user