diff --git a/ts/styles/defaults/index.ts b/ts/styles/defaults/index.ts new file mode 100644 index 0000000000..77204a8bde --- /dev/null +++ b/ts/styles/defaults/index.ts @@ -0,0 +1,17 @@ +import {XmlComponent} from "../../docx/xml-components"; +import {ParagraphPropertiesDefaults} from "./paragraph-properties"; +import {RunPropertiesDefaults} from "./run-properties"; + +export class DocumentDefaults implements XmlComponent { + private docDefaults: Array; + + xmlKeys = { + docDefaults: "w:docDefaults" + } + + constructor() { + this.docDefaults = new Array(); + this.docDefaults.push(new RunPropertiesDefaults()); + this.docDefaults.push(new ParagraphPropertiesDefaults()); + } +} \ No newline at end of file diff --git a/ts/styles/defaults/paragraph-properties.ts b/ts/styles/defaults/paragraph-properties.ts new file mode 100644 index 0000000000..0e3b031e0b --- /dev/null +++ b/ts/styles/defaults/paragraph-properties.ts @@ -0,0 +1,15 @@ +import {XmlComponent} from "../../docx/xml-components"; +import {ParagraphProperties} from "../../docx/paragraph/properties"; + +export class ParagraphPropertiesDefaults implements XmlComponent { + private pPrDefault: Array; + + xmlKeys = { + pPrDefault: "w:pPrDefault" + } + + constructor() { + this.pPrDefault = new Array(); + this.pPrDefault.push(new ParagraphProperties()); + } +} \ No newline at end of file diff --git a/ts/styles/defaults/run-properties.ts b/ts/styles/defaults/run-properties.ts new file mode 100644 index 0000000000..eb22772fcf --- /dev/null +++ b/ts/styles/defaults/run-properties.ts @@ -0,0 +1,15 @@ +import {XmlComponent} from "../../docx/xml-components"; +import {RunProperties} from "../../docx/run/properties"; + +export class RunPropertiesDefaults implements XmlComponent { + private rPrDefault: Array; + + xmlKeys = { + rPrDefault: "w:rPrDefault" + } + + constructor() { + this.rPrDefault = new Array(); + this.rPrDefault.push(new RunProperties()); + } +} \ No newline at end of file diff --git a/ts/style/index.ts b/ts/styles/index.ts similarity index 58% rename from ts/style/index.ts rename to ts/styles/index.ts index 8be9352d9b..6419bc4155 100644 --- a/ts/style/index.ts +++ b/ts/styles/index.ts @@ -1,9 +1,13 @@ import {XmlComponent} from "../docx/xml-components"; import {DocumentAttributes} from "../docx/xml-components/document-attributes" +import {DocumentDefaults} from "./defaults"; +import {LatentStyles} from "./latent-styles"; +import {LatentStyleException} from "./latent-styles/exceptions"; +import {LatentStyleExceptionAttributes} from "./latent-styles/exceptions/attributes"; export class Style implements XmlComponent { private styles: Array; - + xmlKeys = { styles: 'w:styles' } @@ -18,5 +22,15 @@ export class Style implements XmlComponent { w15: 'http://schemas.microsoft.com/office/word/2012/wordml', Ignorable: 'w14 w15' })) + this.styles.push(new DocumentDefaults()); + var latentStyles = new LatentStyles(); + //latentStyles.push(new LatentStyleException(new LatentStyleExceptionAttributes({ + // name: "Normal" + //}))); + this.styles.push(latentStyles); + } + + push(style: XmlComponent): void { + this.styles.push(style); } } \ No newline at end of file diff --git a/ts/styles/latent-styles/exceptions/attributes.ts b/ts/styles/latent-styles/exceptions/attributes.ts new file mode 100644 index 0000000000..31c4aa1d35 --- /dev/null +++ b/ts/styles/latent-styles/exceptions/attributes.ts @@ -0,0 +1,30 @@ +import {XmlComponent} from "../../../docx/xml-components"; + +interface LatentStyleExceptionAttributesProperties { + name?: string; + uiPriority?: string, + qFormat?: string, + semiHidden?: string, + unhideWhenUsed?: string +} + +export class LatentStyleExceptionAttributes implements XmlComponent { + private _attr: Object; + + xmlKeys = { + name: "w:name", + uiPriority: "w:uiPriority", + qFormat: "w:qFormat", + semiHidden: "w:semiHidden", + unhideWhenUsed: "w:unhideWhenUsed" + }; + + constructor(properties?: LatentStyleExceptionAttributesProperties) { + this._attr = properties + + if (!properties) { + this._attr = {}; + } + this._attr["xmlKeys"] = this.xmlKeys; + } +} \ No newline at end of file diff --git a/ts/styles/latent-styles/exceptions/index.ts b/ts/styles/latent-styles/exceptions/index.ts new file mode 100644 index 0000000000..c52cd0ceca --- /dev/null +++ b/ts/styles/latent-styles/exceptions/index.ts @@ -0,0 +1,15 @@ +import {XmlComponent} from "../../../docx/xml-components"; +import {LatentStyleExceptionAttributes} from "./attributes"; + +export class LatentStyleException implements XmlComponent { + private lsdException: Array; + + xmlKeys = { + lsdException: "w:lsdException" + } + + constructor(attributes: LatentStyleExceptionAttributes) { + this.lsdException = new Array(); + this.lsdException.push(attributes); + } +} \ No newline at end of file diff --git a/ts/styles/latent-styles/index.ts b/ts/styles/latent-styles/index.ts new file mode 100644 index 0000000000..47ad8db6ba --- /dev/null +++ b/ts/styles/latent-styles/index.ts @@ -0,0 +1,18 @@ +import {XmlComponent} from "../../docx/xml-components"; +import {LatentStyleException} from "./exceptions"; + +export class LatentStyles implements XmlComponent { + private latentStyles: Array; + + xmlKeys = { + latentStyles: "w:latentStyles" + } + + constructor() { + this.latentStyles = new Array(); + } + + push(latentException: LatentStyleException): void { + this.latentStyles.push(latentException); + } +} \ No newline at end of file diff --git a/ts/style/default.ts b/ts/styles/sample/index.ts similarity index 100% rename from ts/style/default.ts rename to ts/styles/sample/index.ts diff --git a/ts/tests/styleTest.ts b/ts/tests/paragraphStyleTest.ts similarity index 100% rename from ts/tests/styleTest.ts rename to ts/tests/paragraphStyleTest.ts