2016-03-30 00:28:05 +01:00
|
|
|
import {XmlComponent, Attributes} from "../xml-components";
|
2016-03-29 05:01:33 +01:00
|
|
|
import {ThematicBreak} from "./border";
|
2016-03-30 00:28:05 +01:00
|
|
|
import {PageBreak} from "./page-break";
|
2016-03-30 03:50:53 +01:00
|
|
|
import {TextRun} from "../run/text-run";
|
2016-03-30 00:28:05 +01:00
|
|
|
import {ParagraphProperties} from "./properties";
|
2016-03-30 02:55:11 +01:00
|
|
|
import {TabStop} from "../tab-stop";
|
|
|
|
import {Style} from "./style";
|
|
|
|
import {NumberProperties} from "./unordered-list";
|
2016-03-29 04:10:33 +01:00
|
|
|
|
|
|
|
class Alignment {
|
2016-03-29 22:55:37 +01:00
|
|
|
private jc: Array<XmlComponent>;
|
2016-03-29 04:10:33 +01:00
|
|
|
|
|
|
|
constructor(type: string) {
|
2016-03-29 22:55:37 +01:00
|
|
|
this.jc = new Array<XmlComponent>();
|
2016-03-29 04:50:23 +01:00
|
|
|
this.jc.push(new Attributes({
|
|
|
|
val: type
|
|
|
|
}));
|
2016-03-29 04:10:33 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-28 00:53:24 +01:00
|
|
|
export class Paragraph {
|
2016-03-29 22:55:37 +01:00
|
|
|
private p: Array<XmlComponent>;
|
2016-03-29 04:10:33 +01:00
|
|
|
private properties: ParagraphProperties;
|
|
|
|
|
2016-03-28 03:55:33 +01:00
|
|
|
constructor(text?: string) {
|
2016-03-29 22:55:37 +01:00
|
|
|
this.p = new Array<XmlComponent>();
|
2016-03-28 03:55:33 +01:00
|
|
|
this.p.push(new Attributes());
|
2016-03-29 04:10:33 +01:00
|
|
|
this.properties = new ParagraphProperties();
|
|
|
|
this.p.push(this.properties);
|
2016-03-30 00:28:05 +01:00
|
|
|
this.p.push(new TextRun(text));
|
2016-03-27 02:28:47 +01:00
|
|
|
}
|
2016-03-29 04:10:33 +01:00
|
|
|
|
2016-03-30 00:28:05 +01:00
|
|
|
addText(run: TextRun) {
|
2016-03-29 04:10:33 +01:00
|
|
|
this.p.push(run);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
heading1() {
|
|
|
|
this.properties.push(new Style("Heading1"));
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
heading2() {
|
|
|
|
this.properties.push(new Style("Heading2"));
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
heading3() {
|
|
|
|
this.properties.push(new Style("Heading3"));
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
heading4() {
|
|
|
|
this.properties.push(new Style("Heading4"));
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
heading5() {
|
|
|
|
this.properties.push(new Style("Heading5"));
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
title() {
|
|
|
|
this.properties.push(new Style("Title"));
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
center() {
|
|
|
|
this.properties.push(new Alignment("center"));
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
left() {
|
|
|
|
this.properties.push(new Alignment("left"));
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
right() {
|
|
|
|
this.properties.push(new Alignment("right"));
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
justified() {
|
|
|
|
this.properties.push(new Alignment("both"));
|
|
|
|
return this;
|
|
|
|
}
|
2016-03-29 05:01:33 +01:00
|
|
|
|
2016-03-29 23:36:57 +01:00
|
|
|
thematicBreak() {
|
2016-03-29 05:01:33 +01:00
|
|
|
this.properties.push(new ThematicBreak());
|
|
|
|
return this;
|
|
|
|
}
|
2016-03-29 23:36:57 +01:00
|
|
|
|
2016-03-30 00:28:05 +01:00
|
|
|
pageBreak() {
|
|
|
|
this.properties.push(new PageBreak());
|
|
|
|
return this;
|
|
|
|
}
|
2016-03-30 02:55:11 +01:00
|
|
|
|
|
|
|
addTabStop(tabStop: TabStop) {
|
|
|
|
this.properties.push(tabStop);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
bullet() {
|
|
|
|
this.properties.push(new Style("ListParagraph"));
|
|
|
|
this.properties.push(new NumberProperties());
|
|
|
|
return this;
|
|
|
|
}
|
2016-03-27 02:28:47 +01:00
|
|
|
}
|