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";
export class Columns implements XmlComponent {
private cols: Array<XmlComponent>;
xmlKeys = {
cols: 'w:cols'
}
export class Columns extends XmlComponent {
constructor() {
this.cols = new Array<XmlComponent>();
this.cols.push(new Attributes({
super("w:cols");
this.root.push(new Attributes({
space: "708"
}));
}

View File

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

View File

@ -1,20 +1,15 @@
import {XmlComponent, Attributes} from "../../xml-components";
import {SectionProperties} from "./section-properties";
export class Body implements XmlComponent {
private body: Array<XmlComponent>;
xmlKeys = {
body: 'w:body'
}
export class Body extends XmlComponent {
constructor() {
this.body = new Array<XmlComponent>();
//this.body.push(new SectionProperties()); not actually needed
super("w:body");
//this.root.push(new SectionProperties()); not actually needed
}
push(component: XmlComponent) {
//this.body.splice(this.body.length - 1, 0, component);
this.body.push(component);
//this.root.splice(this.body.length - 1, 0, component);
this.root.push(component);
}
}

View File

@ -1,15 +1,10 @@
import {XmlComponent, Attributes} from "../../xml-components";
export class PageMargin implements XmlComponent {
private pgMar: Array<XmlComponent>;
xmlKeys = {
pgMar: 'w:pgMar'
}
export class PageMargin extends XmlComponent {
constructor() {
this.pgMar = new Array<XmlComponent>();
this.pgMar.push(new Attributes({
super("w:pgMar");
this.root.push(new Attributes({
top: "1440",
right: "1440",
bottom: "1440",

View File

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

View File

@ -4,23 +4,18 @@ import {PageMargin} from "./page-margin";
import {Columns} from "./columns";
import {DocumentGrid} from "./doc-grid";
export class SectionProperties implements XmlComponent {
private sectPr: Array<XmlComponent>;
xmlKeys = {
sectPr: 'w:sectPr'
}
export class SectionProperties extends XmlComponent {
constructor() {
this.sectPr = new Array<XmlComponent>();
this.sectPr.push(new Attributes({
super("w:sectPr");
this.root.push(new Attributes({
rsidR: "00B64E8F",
rsidRPr: "00D842E4",
rsidSect: "000A6AD0"
}));
this.sectPr.push(new PageSize());
this.sectPr.push(new PageMargin());
this.sectPr.push(new Columns());
this.sectPr.push(new DocumentGrid());
this.root.push(new PageSize());
this.root.push(new PageMargin());
this.root.push(new Columns());
this.root.push(new DocumentGrid());
}
}

View File

@ -3,8 +3,7 @@ import {DocumentAttributes} from "../xml-components/document-attributes"
import {Body} from "./body";
import {Paragraph} from "../paragraph";
export class Document implements XmlComponent {
private document: Array<XmlComponent>;
export class Document extends XmlComponent {
private body: Body;
xmlKeys = {
@ -13,8 +12,8 @@ export class Document implements XmlComponent {
};
constructor() {
this.document = new Array<XmlComponent>();
this.document.push(new DocumentAttributes({
super("w:document");
this.root.push(new DocumentAttributes({
wpc: 'http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas',
mc: 'http://schemas.openxmlformats.org/markup-compatibility/2006',
o: 'urn:schemas-microsoft-com:office:office',
@ -34,7 +33,7 @@ export class Document implements XmlComponent {
Ignorable: 'w14 w15 wp14'
}));
this.body = new Body();
this.document.push(this.body);
this.root.push(this.body);
}
addParagraph(paragraph: Paragraph) {