added body

This commit is contained in:
Dolan Miu
2016-03-31 23:01:20 +01:00
parent 4b90e1800b
commit b1b664bfe3
11 changed files with 137 additions and 14 deletions

View File

@ -1,3 +0,0 @@
export class Body {
}

View File

@ -1,11 +0,0 @@
export class Document {
private body: string;
constructor() {
this.body = "ggg";
}
test() {
return "hello";
}
}

View File

@ -0,0 +1,12 @@
import {XmlComponent, Attributes} from "../../xml-components";
export class Columns {
private cols: Array<XmlComponent>;
constructor() {
this.cols = new Array<XmlComponent>();
this.cols.push(new Attributes({
space: "708"
}));
}
}

View File

@ -0,0 +1,12 @@
import {XmlComponent, Attributes} from "../../xml-components";
export class DocumentGrid {
private docGrid: Array<XmlComponent>;
constructor() {
this.docGrid = new Array<XmlComponent>();
this.docGrid.push(new Attributes({
linePitch: "360"
}));
}
}

View File

@ -0,0 +1,19 @@
import {XmlComponent, Attributes} from "../../xml-components";
import {SectionProperties} from "./section-properties";
import {PageSize} from "./page-size";
import {PageMargin} from "./page-margin";
import {Columns} from "./columns";
import {DocumentGrid} from "./doc-grid";
export class Body {
private body: Array<XmlComponent>;
constructor() {
this.body = new Array<XmlComponent>();
this.body.push(new SectionProperties());
this.body.push(new PageSize());
this.body.push(new PageMargin());
this.body.push(new Columns());
this.body.push(new DocumentGrid());
}
}

View File

@ -0,0 +1,18 @@
import {XmlComponent, Attributes} from "../../xml-components";
export class PageMargin {
private pgMar: Array<XmlComponent>;
constructor() {
this.pgMar = new Array<XmlComponent>();
this.pgMar.push(new Attributes({
top: "1440",
right: "1440",
bottom: "1440",
left: "1440",
header: "708",
footer: "708",
gutter: "0"
}));
}
}

View File

@ -0,0 +1,13 @@
import {XmlComponent, Attributes} from "../../xml-components";
export class PageSize {
private pgSz: Array<XmlComponent>;
constructor() {
this.pgSz = new Array<XmlComponent>();
this.pgSz.push(new Attributes({
w: "11906",
h: "16838"
}));
}
}

View File

@ -0,0 +1,14 @@
import {XmlComponent, Attributes} from "../../xml-components";
export class SectionProperties {
private sectPr: Array<XmlComponent>;
constructor() {
this.sectPr = new Array<XmlComponent>();
this.sectPr.push(new Attributes({
rsidR: "00B64E8F",
rsidRPr: "00D842E4",
rsidSect: "000A6AD0"
}));
}
}

15
ts/docx/document/index.ts Normal file
View File

@ -0,0 +1,15 @@
import {XmlComponent, Attributes} from "../xml-components";
export class Document {
private document: Array<XmlComponent>;
constructor() {
this.document = new Array<XmlComponent>();
this.document.push(new Attributes({}));
this.
}
test() {
return "hello";
}
}

View File

@ -8,6 +8,19 @@ interface AttributesProperties {
space?: string; space?: string;
sz?: string; sz?: string;
type?: string; type?: string;
rsidR?: string;
rsidRPr?: string;
rsidSect?: string;
w?: string;
h?: string;
top?: string,
right?: string,
bottom?: string,
left?: string,
header?: string,
footer?: string,
gutter?: string,
linePitch?: string
} }
export class Attributes implements XmlComponent { export class Attributes implements XmlComponent {

21
ts/tests/bodyTest.ts Normal file
View File

@ -0,0 +1,21 @@
/// <reference path="../typings/mocha/mocha.d.ts" />
/// <reference path="../typings/chai/chai.d.ts" />
import {Body} from "../docx/document/body";
import {assert} from "chai";
function jsonify(obj: Object) {
var stringifiedJson = JSON.stringify(obj);
return JSON.parse(stringifiedJson);
}
describe('Body', () => {
var body: Body;
beforeEach(() => {
body = new Body();
});
describe('#constructor()', () => {
});
});