2020-10-27 01:54:40 +00:00
|
|
|
// http://officeopenxml.com/WPdocument.php
|
|
|
|
// http://www.datypic.com/sc/ooxml/e-w_background-1.html
|
2022-06-26 23:26:42 +01:00
|
|
|
import { XmlAttributeComponent, XmlComponent } from "@file/xml-components";
|
|
|
|
import { hexColorValue, uCharHexNumber } from "@util/values";
|
2020-10-27 01:54:40 +00:00
|
|
|
|
2021-05-25 03:41:12 +03:00
|
|
|
// <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>
|
|
|
|
|
2020-10-27 01:54:40 +00:00
|
|
|
export class DocumentBackgroundAttributes extends XmlAttributeComponent<{
|
2021-11-12 10:21:01 +01:00
|
|
|
readonly color?: string;
|
2020-10-27 01:54:40 +00:00
|
|
|
readonly themeColor?: string;
|
|
|
|
readonly themeShade?: string;
|
|
|
|
readonly themeTint?: string;
|
|
|
|
}> {
|
|
|
|
protected readonly xmlKeys = {
|
|
|
|
color: "w:color",
|
|
|
|
themeColor: "w:themeColor",
|
|
|
|
themeShade: "w:themeShade",
|
|
|
|
themeTint: "w:themeTint",
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface IDocumentBackgroundOptions {
|
|
|
|
readonly color?: string;
|
|
|
|
readonly themeColor?: string;
|
|
|
|
readonly themeShade?: string;
|
|
|
|
readonly themeTint?: string;
|
|
|
|
}
|
|
|
|
|
2021-05-25 03:41:12 +03:00
|
|
|
// <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>
|
|
|
|
|
2020-10-27 01:54:40 +00:00
|
|
|
export class DocumentBackground extends XmlComponent {
|
2022-08-31 07:52:27 +01:00
|
|
|
public constructor(options: IDocumentBackgroundOptions) {
|
2020-10-27 01:54:40 +00:00
|
|
|
super("w:background");
|
|
|
|
|
|
|
|
this.root.push(
|
|
|
|
new DocumentBackgroundAttributes({
|
2021-11-12 10:21:01 +01:00
|
|
|
color: options.color === undefined ? undefined : hexColorValue(options.color),
|
2020-10-27 01:54:40 +00:00
|
|
|
themeColor: options.themeColor,
|
2021-05-25 03:41:12 +03:00
|
|
|
themeShade: options.themeShade === undefined ? undefined : uCharHexNumber(options.themeShade),
|
|
|
|
themeTint: options.themeTint === undefined ? undefined : uCharHexNumber(options.themeTint),
|
2020-10-27 01:54:40 +00:00
|
|
|
}),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|