2017-03-08 20:35:26 +00:00
|
|
|
import { Attributes, XmlComponent } 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-05-18 17:06:21 +01:00
|
|
|
import {MaxRightTabStop, LeftTabStop} from "./tab-stop";
|
2016-03-30 02:55:11 +01:00
|
|
|
import {Style} from "./style";
|
|
|
|
import {NumberProperties} from "./unordered-list";
|
2017-03-08 18:23:00 +01:00
|
|
|
import { Num } from "../../numbering/num";
|
2016-03-29 04:10:33 +01:00
|
|
|
|
2016-04-09 20:16:35 +01:00
|
|
|
class Alignment extends XmlComponent {
|
2016-03-29 04:10:33 +01:00
|
|
|
|
|
|
|
constructor(type: string) {
|
2016-04-09 20:16:35 +01:00
|
|
|
super("w:jc");
|
|
|
|
this.root.push(new Attributes({
|
2016-03-29 04:50:23 +01:00
|
|
|
val: type
|
|
|
|
}));
|
2016-03-29 04:10:33 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-09 20:16:35 +01:00
|
|
|
export class Paragraph extends XmlComponent {
|
2016-03-29 04:10:33 +01:00
|
|
|
private properties: ParagraphProperties;
|
2016-04-21 23:04:15 +01:00
|
|
|
|
2016-03-28 03:55:33 +01:00
|
|
|
constructor(text?: string) {
|
2016-04-09 20:16:35 +01:00
|
|
|
super("w:p");
|
2016-03-29 04:10:33 +01:00
|
|
|
this.properties = new ParagraphProperties();
|
2016-04-09 20:16:35 +01:00
|
|
|
this.root.push(this.properties);
|
2016-04-21 23:04:15 +01:00
|
|
|
if (text !== undefined) {
|
|
|
|
this.root.push(new TextRun(text));
|
|
|
|
}
|
2016-03-27 02:28:47 +01:00
|
|
|
}
|
2016-03-29 04:10:33 +01:00
|
|
|
|
2016-03-30 04:31:53 +01:00
|
|
|
addText(run: TextRun): Paragraph {
|
2016-04-09 20:16:35 +01:00
|
|
|
this.root.push(run);
|
2016-03-29 04:10:33 +01:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2016-03-30 04:31:53 +01:00
|
|
|
heading1(): Paragraph {
|
2016-03-29 04:10:33 +01:00
|
|
|
this.properties.push(new Style("Heading1"));
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2016-03-30 04:31:53 +01:00
|
|
|
heading2(): Paragraph {
|
2016-03-29 04:10:33 +01:00
|
|
|
this.properties.push(new Style("Heading2"));
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2016-03-30 04:31:53 +01:00
|
|
|
heading3(): Paragraph {
|
2016-03-29 04:10:33 +01:00
|
|
|
this.properties.push(new Style("Heading3"));
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2016-03-30 04:31:53 +01:00
|
|
|
heading4(): Paragraph {
|
2016-03-29 04:10:33 +01:00
|
|
|
this.properties.push(new Style("Heading4"));
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2016-03-30 04:31:53 +01:00
|
|
|
heading5(): Paragraph {
|
2016-03-29 04:10:33 +01:00
|
|
|
this.properties.push(new Style("Heading5"));
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2016-03-30 04:31:53 +01:00
|
|
|
title(): Paragraph {
|
2016-03-29 04:10:33 +01:00
|
|
|
this.properties.push(new Style("Title"));
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2016-03-30 04:31:53 +01:00
|
|
|
center(): Paragraph {
|
2016-03-29 04:10:33 +01:00
|
|
|
this.properties.push(new Alignment("center"));
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2016-03-30 04:31:53 +01:00
|
|
|
left(): Paragraph {
|
2016-03-29 04:10:33 +01:00
|
|
|
this.properties.push(new Alignment("left"));
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2016-03-30 04:31:53 +01:00
|
|
|
right(): Paragraph {
|
2016-03-29 04:10:33 +01:00
|
|
|
this.properties.push(new Alignment("right"));
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2016-03-30 04:31:53 +01:00
|
|
|
justified(): Paragraph {
|
2016-03-29 04:10:33 +01:00
|
|
|
this.properties.push(new Alignment("both"));
|
|
|
|
return this;
|
|
|
|
}
|
2016-03-29 05:01:33 +01:00
|
|
|
|
2016-03-30 04:31:53 +01:00
|
|
|
thematicBreak(): Paragraph {
|
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 04:31:53 +01:00
|
|
|
pageBreak(): Paragraph {
|
2016-03-30 00:28:05 +01:00
|
|
|
this.properties.push(new PageBreak());
|
|
|
|
return this;
|
|
|
|
}
|
2016-03-30 02:55:11 +01:00
|
|
|
|
2016-05-18 17:06:21 +01:00
|
|
|
maxRightTabStop(): Paragraph {
|
|
|
|
this.properties.push(new MaxRightTabStop());
|
|
|
|
return this;
|
|
|
|
}
|
2016-05-26 15:08:34 +01:00
|
|
|
|
2016-05-18 17:06:21 +01:00
|
|
|
leftTabStop(position: number): Paragraph {
|
2016-05-26 15:08:34 +01:00
|
|
|
this.properties.push(new LeftTabStop(position));
|
2016-03-30 02:55:11 +01:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2016-03-30 04:31:53 +01:00
|
|
|
bullet(): Paragraph {
|
2016-03-30 02:55:11 +01:00
|
|
|
this.properties.push(new Style("ListParagraph"));
|
2017-03-07 19:14:57 +01:00
|
|
|
this.properties.push(new NumberProperties(1, 0));
|
2016-03-30 02:55:11 +01:00
|
|
|
return this;
|
|
|
|
}
|
2017-03-08 18:23:00 +01:00
|
|
|
|
|
|
|
public setNumbering(numbering: Num, indentLevel: number): Paragraph {
|
|
|
|
this.properties.push(new Style("ListParagraph"));
|
|
|
|
this.properties.push(new NumberProperties(numbering.id, indentLevel));
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
}
|