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
|
|
|
|
2016-04-03 01:44:18 +01:00
|
|
|
class Alignment implements XmlComponent {
|
2016-03-29 22:55:37 +01:00
|
|
|
private jc: Array<XmlComponent>;
|
2016-04-03 01:44:18 +01:00
|
|
|
|
|
|
|
xmlKeys = {
|
|
|
|
jc: 'w:jc'
|
|
|
|
}
|
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-04-03 01:44:18 +01:00
|
|
|
export class Paragraph implements XmlComponent {
|
2016-03-29 22:55:37 +01:00
|
|
|
private p: Array<XmlComponent>;
|
2016-03-29 04:10:33 +01:00
|
|
|
private properties: ParagraphProperties;
|
2016-04-03 01:44:18 +01:00
|
|
|
|
|
|
|
xmlKeys = {
|
|
|
|
p: 'w:p'
|
|
|
|
}
|
2016-03-29 04:10:33 +01:00
|
|
|
|
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 04:31:53 +01:00
|
|
|
addText(run: TextRun): Paragraph {
|
2016-03-29 04:10:33 +01:00
|
|
|
this.p.push(run);
|
|
|
|
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-03-30 04:31:53 +01:00
|
|
|
addTabStop(tabStop: TabStop): Paragraph {
|
2016-03-30 02:55:11 +01:00
|
|
|
this.properties.push(tabStop);
|
|
|
|
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"));
|
|
|
|
this.properties.push(new NumberProperties());
|
|
|
|
return this;
|
|
|
|
}
|
2016-03-27 02:28:47 +01:00
|
|
|
}
|