2017-09-22 14:46:19 +01:00
|
|
|
// http://officeopenxml.com/WPborders.php
|
2017-12-30 20:25:16 +00:00
|
|
|
import { Attributes, XmlComponent } from "file/xml-components";
|
2016-03-29 04:50:23 +01:00
|
|
|
|
2018-08-19 11:59:38 -04:00
|
|
|
class BorderProperty extends XmlComponent {
|
2018-08-19 19:37:36 -04:00
|
|
|
public setProperties(color: string, space: string, value: string, size: string): XmlComponent {
|
2018-08-19 11:59:38 -04:00
|
|
|
const attrs = new Attributes({
|
2018-08-19 19:37:36 -04:00
|
|
|
color: color,
|
2018-08-19 11:59:38 -04:00
|
|
|
space: space,
|
|
|
|
val: value,
|
2018-08-19 19:37:36 -04:00
|
|
|
sz: size,
|
2018-08-19 11:59:38 -04:00
|
|
|
});
|
|
|
|
this.root.push(attrs);
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export class Border extends XmlComponent {
|
2016-03-29 04:50:23 +01:00
|
|
|
constructor() {
|
2018-08-19 11:59:38 -04:00
|
|
|
super("w:pBdr");
|
|
|
|
}
|
|
|
|
|
2018-08-19 19:37:36 -04:00
|
|
|
public addTopBorder(color: string = "auto", space: string = "1", value: string = "single", size: string = "6"): XmlComponent {
|
2018-08-19 11:59:38 -04:00
|
|
|
const top = new BorderProperty("w:top");
|
2018-08-19 19:37:36 -04:00
|
|
|
top.setProperties(color, space, value, size);
|
2018-08-19 11:59:38 -04:00
|
|
|
this.root.push(top);
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2018-08-19 19:37:36 -04:00
|
|
|
public addBottomBorder(color: string = "auto", space: string = "1", value: string = "single", size: string = "6"): XmlComponent {
|
2018-08-19 11:59:38 -04:00
|
|
|
const bottom = new BorderProperty("w:bottom");
|
2018-08-19 19:37:36 -04:00
|
|
|
bottom.setProperties(color, space, value, size);
|
2018-08-19 11:59:38 -04:00
|
|
|
this.root.push(bottom);
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2018-08-19 19:37:36 -04:00
|
|
|
public addLeftBorder(color: string = "auto", space: string = "1", value: string = "single", size: string = "6"): XmlComponent {
|
2018-08-19 11:59:38 -04:00
|
|
|
const left = new BorderProperty("w:left");
|
2018-08-19 19:37:36 -04:00
|
|
|
left.setProperties(color, space, value, size);
|
2018-08-19 11:59:38 -04:00
|
|
|
this.root.push(left);
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2018-08-19 19:37:36 -04:00
|
|
|
public addRightBorder(color: string = "auto", space: string = "1", value: string = "single", size: string = "6"): XmlComponent {
|
2018-08-19 11:59:38 -04:00
|
|
|
const right = new BorderProperty("w:right");
|
2018-08-19 19:37:36 -04:00
|
|
|
right.setProperties(color, space, value, size);
|
2018-08-19 11:59:38 -04:00
|
|
|
this.root.push(right);
|
|
|
|
|
|
|
|
return this;
|
2016-03-29 04:50:23 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-09 20:16:35 +01:00
|
|
|
export class ThematicBreak extends XmlComponent {
|
2016-03-29 04:50:23 +01:00
|
|
|
constructor() {
|
2016-04-09 20:16:35 +01:00
|
|
|
super("w:pBdr");
|
2018-08-19 11:59:38 -04:00
|
|
|
const bottom = new BorderProperty("w:bottom");
|
2018-08-19 19:37:36 -04:00
|
|
|
bottom.setProperties("auto", "1", "single", "6");
|
2018-08-19 11:59:38 -04:00
|
|
|
this.root.push(bottom);
|
2016-03-29 04:50:23 +01:00
|
|
|
}
|
2017-03-08 21:36:09 +00:00
|
|
|
}
|