2018-06-08 16:03:04 +02:00
|
|
|
// http://officeopenxml.com/drwPicFloating-textWrap.php
|
2018-06-09 23:49:01 +01:00
|
|
|
import { XmlAttributeComponent, XmlComponent } from "file/xml-components";
|
2019-01-10 02:10:20 +00:00
|
|
|
import { ITextWrapping, TextWrappingSide } from ".";
|
2018-06-09 23:49:01 +01:00
|
|
|
import { IDistance } from "../drawing";
|
2019-01-10 02:10:20 +00:00
|
|
|
import { IMargins } from "../floating";
|
2018-06-08 16:03:04 +02:00
|
|
|
|
2018-06-09 23:49:01 +01:00
|
|
|
interface IWrapSquareAttributes extends IDistance {
|
2019-01-10 02:10:20 +00:00
|
|
|
readonly wrapText?: TextWrappingSide;
|
|
|
|
readonly distT?: number;
|
|
|
|
readonly distB?: number;
|
|
|
|
readonly distL?: number;
|
|
|
|
readonly distR?: number;
|
2018-06-08 16:03:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
class WrapSquareAttributes extends XmlAttributeComponent<IWrapSquareAttributes> {
|
2018-11-02 02:51:57 +00:00
|
|
|
protected readonly xmlKeys = {
|
2018-06-08 16:03:04 +02:00
|
|
|
distT: "distT",
|
|
|
|
distB: "distB",
|
|
|
|
distL: "distL",
|
|
|
|
distR: "distR",
|
|
|
|
wrapText: "wrapText",
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export class WrapSquare extends XmlComponent {
|
2019-01-10 02:10:20 +00:00
|
|
|
constructor(
|
|
|
|
textWrapping: ITextWrapping,
|
|
|
|
margins: IMargins = {
|
|
|
|
top: 0,
|
|
|
|
bottom: 0,
|
|
|
|
left: 0,
|
|
|
|
right: 0,
|
|
|
|
},
|
|
|
|
) {
|
2018-06-08 16:03:04 +02:00
|
|
|
super("wp:wrapSquare");
|
|
|
|
|
|
|
|
this.root.push(
|
|
|
|
new WrapSquareAttributes({
|
2019-01-10 02:10:20 +00:00
|
|
|
wrapText: textWrapping.side || TextWrappingSide.BOTH_SIDES,
|
|
|
|
distT: margins.top,
|
|
|
|
distB: margins.bottom,
|
|
|
|
distL: margins.left,
|
|
|
|
distR: margins.right,
|
2018-06-08 16:03:04 +02:00
|
|
|
}),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|