From b86d292c6484fdcaefb4cd2afcf71430a1baf199 Mon Sep 17 00:00:00 2001 From: Dolan Miu Date: Tue, 3 May 2016 04:31:08 +0100 Subject: [PATCH] added style components --- ts/styles/style/attributes.ts | 25 +++++++------ ts/styles/style/components.ts | 69 +++++++++++++++++++++++++---------- 2 files changed, 62 insertions(+), 32 deletions(-) diff --git a/ts/styles/style/attributes.ts b/ts/styles/style/attributes.ts index 85f0f23195..8a7b0df1ae 100644 --- a/ts/styles/style/attributes.ts +++ b/ts/styles/style/attributes.ts @@ -1,29 +1,30 @@ import {XmlComponent} from "../../docx/xml-components"; +import {XmlAttributeComponent} from "../../docx/xml-components"; interface StyleAttributesProperties { type?: string; styleId?: string; default?: string; customStyle?: string; + val?: string; } -export class StyleAttributes extends XmlComponent { +export class StyleAttributes extends XmlAttributeComponent { private _attr: Object; - xmlKeys = { - type: "w:type", - styleId: "w:styleId", - default: "w:default", - customStyle: "w:customStyle" - }; - constructor(properties?: StyleAttributesProperties) { - super("_attr"); - this._attr = properties + super({ + type: "w:type", + styleId: "w:styleId", + default: "w:default", + customStyle: "w:customStyle", + val: "w:val" + }); + + this.root = properties; if (!properties) { - this._attr = {}; + this.root = {}; } - this._attr["xmlKeys"] = this.xmlKeys; } } \ No newline at end of file diff --git a/ts/styles/style/components.ts b/ts/styles/style/components.ts index 4440e38750..a58ecd61d6 100644 --- a/ts/styles/style/components.ts +++ b/ts/styles/style/components.ts @@ -1,44 +1,73 @@ import {XmlComponent} from "../../docx/xml-components"; +import {StyleAttributes} from "./attributes"; export class Name extends XmlComponent { - - constructor() { + + constructor(value: string) { super("w:name"); + this.root.push(new StyleAttributes({ + val: value + })); } } -export class BasedOn { - +export class BasedOn extends XmlComponent { + + constructor(value: string) { + super("w:basedOn"); + this.root.push(new StyleAttributes({ + val: value + })); + } } -export class Next { - +export class Next extends XmlComponent { + + constructor(value: string) { + super("w:next"); + this.root.push(new StyleAttributes({ + styleId: "1", + val: value + })); + } } -export class Link { - +export class Link extends XmlComponent { + + constructor(value: string) { + super("w:link"); + this.root.push(new StyleAttributes({ + val: value + })); + } } -export class UiPriority { - +export class UiPriority extends XmlComponent { + + constructor(value: string) { + super("w:uiPriority"); + this.root.push(new StyleAttributes({ + val: value + })); + } } -export class UnhideWhenUsed { - +export class UnhideWhenUsed extends XmlComponent { + } -export class QFormat { - +export class QFormat extends XmlComponent { + } -export class TableProperties { - +export class TableProperties extends XmlComponent { + } -export class RsId { - +export class RsId extends XmlComponent { + } -export class SemiHidden { - +export class SemiHidden extends XmlComponent { + } \ No newline at end of file