update file/document and section-properties

This commit is contained in:
Tom Hunkapiller
2021-05-25 03:41:12 +03:00
parent e198f0752a
commit 63cea76eac
54 changed files with 861 additions and 659 deletions

View File

@ -1,7 +1,30 @@
// http://officeopenxml.com/WPdocument.php
// http://www.datypic.com/sc/ooxml/e-w_background-1.html
import { hexColorValue, uCharHexNumber } from "file/values";
import { XmlAttributeComponent, XmlComponent } from "file/xml-components";
// <xsd:simpleType name="ST_ThemeColor">
// <xsd:restriction base="xsd:string">
// <xsd:enumeration value="dark1"/>
// <xsd:enumeration value="light1"/>
// <xsd:enumeration value="dark2"/>
// <xsd:enumeration value="light2"/>
// <xsd:enumeration value="accent1"/>
// <xsd:enumeration value="accent2"/>
// <xsd:enumeration value="accent3"/>
// <xsd:enumeration value="accent4"/>
// <xsd:enumeration value="accent5"/>
// <xsd:enumeration value="accent6"/>
// <xsd:enumeration value="hyperlink"/>
// <xsd:enumeration value="followedHyperlink"/>
// <xsd:enumeration value="none"/>
// <xsd:enumeration value="background1"/>
// <xsd:enumeration value="text1"/>
// <xsd:enumeration value="background2"/>
// <xsd:enumeration value="text2"/>
// </xsd:restriction>
// </xsd:simpleType>
export class DocumentBackgroundAttributes extends XmlAttributeComponent<{
readonly color: string;
readonly themeColor?: string;
@ -23,16 +46,32 @@ export interface IDocumentBackgroundOptions {
readonly themeTint?: string;
}
// <xsd:complexType name="CT_Background">
// <xsd:sequence>
// <xsd:sequence maxOccurs="unbounded">
// <xsd:any processContents="lax" namespace="urn:schemas-microsoft-com:vml" minOccurs="0"
// maxOccurs="unbounded"/>
// <xsd:any processContents="lax" namespace="urn:schemas-microsoft-com:office:office"
// minOccurs="0" maxOccurs="unbounded"/>
// </xsd:sequence>
// <xsd:element name="drawing" type="CT_Drawing" minOccurs="0"/>
// </xsd:sequence>
// <xsd:attribute name="color" type="ST_HexColor" use="optional" default="auto"/>
// <xsd:attribute name="themeColor" type="ST_ThemeColor" use="optional"/>
// <xsd:attribute name="themeTint" type="ST_UcharHexNumber" use="optional"/>
// <xsd:attribute name="themeShade" type="ST_UcharHexNumber" use="optional"/>
// </xsd:complexType>
export class DocumentBackground extends XmlComponent {
constructor(options: IDocumentBackgroundOptions) {
super("w:background");
this.root.push(
new DocumentBackgroundAttributes({
color: options.color ? options.color : "FFFFFF",
color: hexColorValue(options.color ? options.color : "FFFFFF"),
themeColor: options.themeColor,
themeShade: options.themeShade,
themeTint: options.themeTint,
themeShade: options.themeShade === undefined ? undefined : uCharHexNumber(options.themeShade),
themeTint: options.themeTint === undefined ? undefined : uCharHexNumber(options.themeTint),
}),
);
}