diff --git a/src/file/drawing/drawing.ts b/src/file/drawing/drawing.ts index d42f403cf2..472f4f9fe7 100644 --- a/src/file/drawing/drawing.ts +++ b/src/file/drawing/drawing.ts @@ -28,8 +28,4 @@ export class Drawing extends XmlComponent { this.root.push(new Anchor(imageData, imageData.transformation, drawingOptions)); } } - - public scale(factorX: number, factorY: number): void { - this.inline.scale(factorX, factorY); - } } diff --git a/src/file/drawing/extent/extent.ts b/src/file/drawing/extent/extent.ts index 500571425b..1945fd0eae 100644 --- a/src/file/drawing/extent/extent.ts +++ b/src/file/drawing/extent/extent.ts @@ -15,11 +15,4 @@ export class Extent extends XmlComponent { this.root.push(this.attributes); } - - public setXY(x: number, y: number): void { - this.attributes.set({ - cx: x, - cy: y, - }); - } } diff --git a/src/file/drawing/floating/horizontal-position.spec.ts b/src/file/drawing/floating/horizontal-position.spec.ts index 705e637dd5..7e9a6223d4 100644 --- a/src/file/drawing/floating/horizontal-position.spec.ts +++ b/src/file/drawing/floating/horizontal-position.spec.ts @@ -49,5 +49,9 @@ describe("HorizontalPosition", () => { ], }); }); + + it("should require one of align or offset", () => { + expect(() => new HorizontalPosition({})).to.throw(); + }); }); }); diff --git a/src/file/drawing/inline/graphic/graphic-data/graphic-data.ts b/src/file/drawing/inline/graphic/graphic-data/graphic-data.ts index 9a4c9a32de..b1a8337690 100644 --- a/src/file/drawing/inline/graphic/graphic-data/graphic-data.ts +++ b/src/file/drawing/inline/graphic/graphic-data/graphic-data.ts @@ -20,8 +20,4 @@ export class GraphicData extends XmlComponent { this.root.push(this.pic); } - - public setXY(x: number, y: number): void { - this.pic.setXY(x, y); - } } diff --git a/src/file/drawing/inline/graphic/graphic-data/pic/pic.ts b/src/file/drawing/inline/graphic/graphic-data/pic/pic.ts index 280dd8796e..df1254331e 100644 --- a/src/file/drawing/inline/graphic/graphic-data/pic/pic.ts +++ b/src/file/drawing/inline/graphic/graphic-data/pic/pic.ts @@ -8,8 +8,6 @@ import { PicAttributes } from "./pic-attributes"; import { ShapeProperties } from "./shape-properties/shape-properties"; export class Pic extends XmlComponent { - private readonly shapeProperties: ShapeProperties; - constructor(mediaData: IMediaData, transform: IMediaDataTransformation) { 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 BlipFill(mediaData)); this.root.push(new ShapeProperties(transform)); } - - public setXY(x: number, y: number): void { - this.shapeProperties.setXY(x, y); - } } diff --git a/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/form/extents/extents.ts b/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/form/extents/extents.ts index 55bf8bae0b..f17c8de426 100644 --- a/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/form/extents/extents.ts +++ b/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/form/extents/extents.ts @@ -15,11 +15,4 @@ export class Extents extends XmlComponent { this.root.push(this.attributes); } - - public setXY(x: number, y: number): void { - this.attributes.set({ - cx: x, - cy: y, - }); - } } diff --git a/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/form/form.ts b/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/form/form.ts index 163af208d6..541f862cd5 100644 --- a/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/form/form.ts +++ b/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/form/form.ts @@ -37,8 +37,4 @@ export class Form extends XmlComponent { this.root.push(new Offset()); this.root.push(this.extents); } - - public setXY(x: number, y: number): void { - this.extents.setXY(x, y); - } } diff --git a/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/shape-properties.ts b/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/shape-properties.ts index 769e242205..2d22b00796 100644 --- a/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/shape-properties.ts +++ b/src/file/drawing/inline/graphic/graphic-data/pic/shape-properties/shape-properties.ts @@ -26,8 +26,4 @@ export class ShapeProperties extends XmlComponent { // this.root.push(new NoFill()); // this.root.push(new Outline()); } - - public setXY(x: number, y: number): void { - this.form.setXY(x, y); - } } diff --git a/src/file/drawing/inline/graphic/graphic.ts b/src/file/drawing/inline/graphic/graphic.ts index 3df31e3346..ca0d23a3a5 100644 --- a/src/file/drawing/inline/graphic/graphic.ts +++ b/src/file/drawing/inline/graphic/graphic.ts @@ -26,8 +26,4 @@ export class Graphic extends XmlComponent { this.root.push(this.data); } - - public setXY(x: number, y: number): void { - this.data.setXY(x, y); - } } diff --git a/src/file/drawing/inline/inline.ts b/src/file/drawing/inline/inline.ts index 2b124fc524..a42fec0b23 100644 --- a/src/file/drawing/inline/inline.ts +++ b/src/file/drawing/inline/inline.ts @@ -12,7 +12,7 @@ export class Inline extends XmlComponent { private readonly extent: Extent; private readonly graphic: Graphic; - constructor(mediaData: IMediaData, private readonly transform: IMediaDataTransformation) { + constructor(mediaData: IMediaData, transform: IMediaDataTransformation) { super("wp:inline"); this.root.push( @@ -33,12 +33,4 @@ export class Inline extends XmlComponent { this.root.push(new GraphicFrameProperties()); 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); - } } diff --git a/src/file/paragraph/formatting/border.spec.ts b/src/file/paragraph/formatting/border.spec.ts index 701698ced0..33e026f7c4 100644 --- a/src/file/paragraph/formatting/border.spec.ts +++ b/src/file/paragraph/formatting/border.spec.ts @@ -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(); + }); }); }); diff --git a/src/file/paragraph/formatting/border.ts b/src/file/paragraph/formatting/border.ts index fd29cd34ee..b84b24df99 100644 --- a/src/file/paragraph/formatting/border.ts +++ b/src/file/paragraph/formatting/border.ts @@ -1,6 +1,6 @@ // http://officeopenxml.com/WPborders.php import { BorderElement, BorderStyle, IBorderOptions } from "file/border"; -import { XmlComponent } from "file/xml-components"; +import { IgnoreIfEmptyXmlComponent, XmlComponent } from "file/xml-components"; export interface IBordersOptions { readonly top?: IBorderOptions; @@ -9,7 +9,7 @@ export interface IBordersOptions { readonly right?: IBorderOptions; } -export class Border extends XmlComponent { +export class Border extends IgnoreIfEmptyXmlComponent { constructor(options: IBordersOptions) { super("w:pBdr");