now extends XmlComponent
This commit is contained in:
@ -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"
|
||||
}));
|
||||
}
|
||||
|
@ -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"
|
||||
}));
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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",
|
||||
|
@ -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"
|
||||
}));
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
@ -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) {
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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
|
||||
}));
|
||||
}
|
||||
|
@ -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
|
||||
}));
|
||||
}
|
||||
|
@ -1,45 +1,30 @@
|
||||
import {XmlComponent, Attributes} from "../xml-components";
|
||||
|
||||
export class Bold implements XmlComponent {
|
||||
private b: Array<XmlComponent>;
|
||||
|
||||
xmlKeys = {
|
||||
b: 'w:b'
|
||||
}
|
||||
|
||||
export class Bold extends XmlComponent {
|
||||
|
||||
constructor() {
|
||||
this.b = new Array<XmlComponent>();
|
||||
this.b.push(new Attributes({
|
||||
super("w:b");
|
||||
this.root.push(new Attributes({
|
||||
val: true
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
export class Italics {
|
||||
private i: Array<XmlComponent>;
|
||||
|
||||
xmlKeys = {
|
||||
i: 'w:i'
|
||||
}
|
||||
export class Italics extends XmlComponent {
|
||||
|
||||
constructor() {
|
||||
this.i = new Array<XmlComponent>();
|
||||
this.i.push(new Attributes({
|
||||
super("w:i");
|
||||
this.root.push(new Attributes({
|
||||
val: true
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
export class Underline {
|
||||
private u: Array<XmlComponent>;
|
||||
|
||||
xmlKeys = {
|
||||
u: 'w:u'
|
||||
}
|
||||
export class Underline extends XmlComponent {
|
||||
|
||||
constructor() {
|
||||
this.u = new Array<XmlComponent>();
|
||||
this.u.push(new Attributes({
|
||||
super("w:u");
|
||||
this.root.push(new Attributes({
|
||||
val: true
|
||||
}));
|
||||
}
|
||||
|
@ -2,18 +2,14 @@ import {XmlComponent, Attributes} from "../xml-components";
|
||||
import {RunProperties} from "./properties";
|
||||
import {Bold, Italics, Underline} from "./emphasis";
|
||||
|
||||
export class Run implements XmlComponent {
|
||||
protected r: Array<XmlComponent>;
|
||||
export class Run extends XmlComponent {
|
||||
private properties: RunProperties;
|
||||
|
||||
xmlKeys = {
|
||||
r: 'w:r'
|
||||
}
|
||||
|
||||
constructor() {
|
||||
this.r = new Array<XmlComponent>();
|
||||
super("w:r");
|
||||
this.properties = new RunProperties();
|
||||
this.r.push(this.properties);
|
||||
this.root.push(this.properties);
|
||||
}
|
||||
|
||||
bold(): Run {
|
||||
|
@ -1,17 +1,12 @@
|
||||
import {XmlComponent, Attributes} from "../xml-components";
|
||||
|
||||
export class RunProperties implements XmlComponent {
|
||||
private rPr: Array<XmlComponent>;
|
||||
|
||||
xmlKeys = {
|
||||
rPr: 'w:rPr'
|
||||
}
|
||||
export class RunProperties extends XmlComponent {
|
||||
|
||||
constructor() {
|
||||
this.rPr = new Array<XmlComponent>();
|
||||
super("w:rPr");
|
||||
}
|
||||
|
||||
push(item: XmlComponent): void {
|
||||
this.rPr.push(item);
|
||||
this.root.push(item);
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,6 @@ export class TextRun extends Run {
|
||||
|
||||
constructor(text: string) {
|
||||
super();
|
||||
this.r.push(new Text(text));
|
||||
this.root.push(new Text(text));
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
import {XmlComponent, Attributes} from "./xml-components";
|
||||
|
||||
export class TabStop implements XmlComponent{
|
||||
export class TabStop extends XmlComponent{
|
||||
xmlKeys = {}
|
||||
}
|
||||
|
@ -1,11 +1,12 @@
|
||||
import {XmlComponent} from "./";
|
||||
|
||||
export abstract class BaseAttributes implements XmlComponent {
|
||||
export abstract class BaseAttributes extends XmlComponent {
|
||||
private _attr: Object;
|
||||
|
||||
xmlKeys = {};
|
||||
|
||||
constructor(xmlKeys: Object, properties?: any) {
|
||||
super("_attr");
|
||||
this._attr = properties
|
||||
|
||||
if (!properties) {
|
||||
|
@ -26,7 +26,7 @@ interface DocumentAttributesProperties {
|
||||
type?: string;
|
||||
}
|
||||
|
||||
export class DocumentAttributes implements XmlComponent {
|
||||
export class DocumentAttributes extends XmlComponent {
|
||||
private _attr: Object;
|
||||
|
||||
xmlKeys = {
|
||||
@ -56,6 +56,7 @@ export class DocumentAttributes implements XmlComponent {
|
||||
};
|
||||
|
||||
constructor(properties?: DocumentAttributesProperties) {
|
||||
super("_attr");
|
||||
this._attr = properties
|
||||
|
||||
if (!properties) {
|
||||
|
@ -1,5 +1,11 @@
|
||||
export interface XmlComponent {
|
||||
xmlKeys: Object;
|
||||
export abstract class XmlComponent {
|
||||
protected root: Array<XmlComponent>;
|
||||
protected rootKey: string;
|
||||
|
||||
constructor(rootKey: string) {
|
||||
this.root = new Array<XmlComponent>();
|
||||
this.rootKey = rootKey;
|
||||
}
|
||||
}
|
||||
|
||||
interface AttributesProperties {
|
||||
@ -23,7 +29,7 @@ interface AttributesProperties {
|
||||
linePitch?: string;
|
||||
}
|
||||
|
||||
export class Attributes implements XmlComponent {
|
||||
export class Attributes extends XmlComponent {
|
||||
private _attr: Object;
|
||||
|
||||
xmlKeys = {
|
||||
@ -48,6 +54,7 @@ export class Attributes implements XmlComponent {
|
||||
};
|
||||
|
||||
constructor(properties?: AttributesProperties) {
|
||||
super("_attr");
|
||||
this._attr = properties
|
||||
|
||||
if (!properties) {
|
||||
@ -58,7 +65,7 @@ export class Attributes implements XmlComponent {
|
||||
}
|
||||
}
|
||||
|
||||
export class Text implements XmlComponent {
|
||||
export class Text extends XmlComponent {
|
||||
private t: string;
|
||||
|
||||
xmlKeys = {
|
||||
@ -66,6 +73,7 @@ export class Text implements XmlComponent {
|
||||
}
|
||||
|
||||
constructor(text: string) {
|
||||
super("w:t");
|
||||
this.t = text;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user