now extends XmlComponent

This commit is contained in:
Dolan Miu
2016-04-09 20:16:35 +01:00
parent 84610bd72f
commit f68a2aff56
33 changed files with 180 additions and 371 deletions

View File

@ -1,15 +1,10 @@
import {XmlComponent, Attributes} from "../xml-components";
class Border implements XmlComponent {
private bottom: Array<XmlComponent>;
xmlKeys = {
bottom: 'w:bottom'
}
class Border extends XmlComponent {
constructor() {
this.bottom = new Array<XmlComponent>();
this.bottom.push(new Attributes({
super("w:bottom");
this.root.push(new Attributes({
color: "auto",
space: "1",
val: "single",
@ -18,15 +13,10 @@ class Border implements XmlComponent {
}
}
export class ThematicBreak implements XmlComponent {
private pBdr: Array<XmlComponent>;
xmlKeys = {
pBdr: 'w:pBdr'
}
export class ThematicBreak extends XmlComponent {
constructor() {
this.pBdr = new Array<XmlComponent>();
this.pBdr.push(new Border());
super("w:pBdr");
this.root.push(new Border());
}
}

View File

@ -7,39 +7,29 @@ import {TabStop} from "../tab-stop";
import {Style} from "./style";
import {NumberProperties} from "./unordered-list";
class Alignment implements XmlComponent {
private jc: Array<XmlComponent>;
xmlKeys = {
jc: 'w:jc'
}
class Alignment extends XmlComponent {
constructor(type: string) {
this.jc = new Array<XmlComponent>();
this.jc.push(new Attributes({
super("w:jc");
this.root.push(new Attributes({
val: type
}));
}
}
export class Paragraph implements XmlComponent {
private p: Array<XmlComponent>;
export class Paragraph extends XmlComponent {
private properties: ParagraphProperties;
xmlKeys = {
p: 'w:p'
}
constructor(text?: string) {
this.p = new Array<XmlComponent>();
this.p.push(new Attributes());
super("w:p");
this.root.push(new Attributes());
this.properties = new ParagraphProperties();
this.p.push(this.properties);
this.p.push(new TextRun(text));
this.root.push(this.properties);
this.root.push(new TextRun(text));
}
addText(run: TextRun): Paragraph {
this.p.push(run);
this.root.push(run);
return this;
}

View File

@ -1,18 +1,13 @@
import {XmlComponent, Attributes} from "../xml-components";
import {Run} from "../run";
class Break implements XmlComponent {
private br: Array<XmlComponent>;
xmlKeys = {
br: 'w:br'
}
class Break extends XmlComponent {
constructor() {
this.br = new Array<XmlComponent>();
this.br.push(new Attributes({
super("w:br");
this.root.push(new Attributes({
type: "page"
}))
}));
}
}
@ -20,6 +15,6 @@ export class PageBreak extends Run {
constructor() {
super();
this.r.push(new Break());
this.root.push(new Break());
}
}

View File

@ -1,18 +1,13 @@
import {XmlComponent, Attributes} from "../xml-components";
export class ParagraphProperties implements XmlComponent {
private pPr: Array<XmlComponent>;
xmlKeys = {
pPr: 'w:rPr'
}
export class ParagraphProperties extends XmlComponent {
constructor() {
this.pPr = new Array<XmlComponent>();
this.pPr.push(new Attributes());
super("w:rPr");
this.root.push(new Attributes());
}
push(item: XmlComponent): void {
this.pPr.push(item);
this.root.push(item);
}
}

View File

@ -1,15 +1,10 @@
import {XmlComponent, Attributes} from "../xml-components";
export class Style implements XmlComponent {
private pStyle: Array<XmlComponent>;
xmlKeys = {
pStyle: 'w:pStyle'
}
export class Style extends XmlComponent {
constructor(type: string) {
this.pStyle = new Array<XmlComponent>();
this.pStyle.push(new Attributes({
super("w:pStyle");
this.root.push(new Attributes({
val: type
}));
}

View File

@ -1,45 +1,29 @@
import {XmlComponent, Attributes} from "../xml-components";
import {Style} from "./style";
export class NumberProperties implements XmlComponent {
private numPr: Array<XmlComponent>;
xmlKeys = {
numPr: 'w:numPr'
}
export class NumberProperties extends XmlComponent {
constructor() {
this.numPr = new Array<XmlComponent>();
this.numPr.push(new IndentLevel(0));
this.numPr.push(new NumberId(1));
super("w:numPr");
this.root.push(new IndentLevel(0));
this.root.push(new NumberId(1));
}
}
export class IndentLevel implements XmlComponent {
private ilvl: Array<XmlComponent>;
xmlKeys = {
ilvl: 'w:ilvl'
}
export class IndentLevel extends XmlComponent {
constructor(level: number) {
this.ilvl = new Array<XmlComponent>();
this.ilvl.push(new Attributes({
super("w:ilvl");
this.root.push(new Attributes({
val: level
}));
}
}
export class NumberId implements XmlComponent {
private ilvl: Array<XmlComponent>;
xmlKeys = {
ilvl: 'w:ilvl'
}
export class NumberId extends XmlComponent {
constructor(id: number) {
this.ilvl = new Array<XmlComponent>();
this.ilvl.push(new Attributes({
super("w:numId");
this.root.push(new Attributes({
val: id
}));
}