2021-05-23 07:14:00 +03:00
|
|
|
// Note that the border type is identical in all places,
|
|
|
|
// regardless of where it's used like paragraph/table/etc.
|
2021-05-23 08:00:49 +03:00
|
|
|
// PageBorders are a superset, but we're not using any of those extras.
|
2021-05-23 07:14:00 +03:00
|
|
|
//
|
|
|
|
// http://officeopenxml.com/WPborders.php
|
|
|
|
// http://officeopenxml.com/WPtableBorders.php
|
|
|
|
// http://officeopenxml.com/WPtableCellProperties-Borders.php
|
2021-05-23 08:00:49 +03:00
|
|
|
// http://officeopenxml.com/WPsectionBorders.php
|
2021-05-23 07:14:00 +03:00
|
|
|
//
|
|
|
|
// This describes the CT_Border type.
|
|
|
|
// <xsd:complexType name="CT_Border">
|
|
|
|
// <xsd:attribute name="val" type="ST_Border" use="required"/>
|
|
|
|
// <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:attribute name="sz" type="ST_EighthPointMeasure" use="optional"/>
|
|
|
|
// <xsd:attribute name="space" type="ST_PointMeasure" use="optional" default="0"/>
|
|
|
|
// <xsd:attribute name="shadow" type="s:ST_OnOff" use="optional"/>
|
|
|
|
// <xsd:attribute name="frame" type="s:ST_OnOff" use="optional"/>
|
|
|
|
// </xsd:complexType>
|
2022-06-26 23:26:42 +01:00
|
|
|
import { XmlAttributeComponent, XmlComponent } from "@file/xml-components";
|
|
|
|
import { eighthPointMeasureValue, hexColorValue, pointMeasureValue } from "@util/values";
|
2021-05-23 07:14:00 +03:00
|
|
|
|
|
|
|
export interface IBorderOptions {
|
|
|
|
readonly style: BorderStyle;
|
2021-05-26 09:27:05 +03:00
|
|
|
/** Border color, in hex (eg 'FF00AA') */
|
2021-05-23 07:14:00 +03:00
|
|
|
readonly color?: string;
|
2021-05-26 09:27:05 +03:00
|
|
|
/** Size of the border in 1/8 pt */
|
2021-05-23 07:14:00 +03:00
|
|
|
readonly size?: number;
|
2021-05-26 09:27:05 +03:00
|
|
|
/** Spacing offset. Values are specified in pt */
|
2021-05-23 07:14:00 +03:00
|
|
|
readonly space?: number;
|
|
|
|
}
|
|
|
|
|
|
|
|
export class BorderElement extends XmlComponent {
|
2021-05-24 12:00:04 +03:00
|
|
|
constructor(elementName: string, { color, size, space, style }: IBorderOptions) {
|
2021-05-23 07:14:00 +03:00
|
|
|
super(elementName);
|
2021-05-24 08:42:34 +03:00
|
|
|
this.root.push(
|
2021-05-24 11:28:10 +03:00
|
|
|
new BordersAttributes({
|
2021-05-24 12:00:04 +03:00
|
|
|
style,
|
|
|
|
color: color === undefined ? undefined : hexColorValue(color),
|
|
|
|
size: size === undefined ? undefined : eighthPointMeasureValue(size),
|
|
|
|
space: space === undefined ? undefined : pointMeasureValue(space),
|
2021-05-24 08:42:34 +03:00
|
|
|
}),
|
|
|
|
);
|
2021-05-23 07:14:00 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-24 11:28:10 +03:00
|
|
|
class BordersAttributes extends XmlAttributeComponent<IBorderOptions> {
|
2021-05-23 07:14:00 +03:00
|
|
|
protected readonly xmlKeys = {
|
|
|
|
style: "w:val",
|
|
|
|
color: "w:color",
|
|
|
|
size: "w:sz",
|
|
|
|
space: "w:space",
|
|
|
|
};
|
|
|
|
}
|
2021-05-23 08:00:49 +03:00
|
|
|
|
|
|
|
export enum BorderStyle {
|
|
|
|
SINGLE = "single",
|
|
|
|
DASH_DOT_STROKED = "dashDotStroked",
|
|
|
|
DASHED = "dashed",
|
|
|
|
DASH_SMALL_GAP = "dashSmallGap",
|
|
|
|
DOT_DASH = "dotDash",
|
|
|
|
DOT_DOT_DASH = "dotDotDash",
|
|
|
|
DOTTED = "dotted",
|
|
|
|
DOUBLE = "double",
|
|
|
|
DOUBLE_WAVE = "doubleWave",
|
|
|
|
INSET = "inset",
|
|
|
|
NIL = "nil",
|
|
|
|
NONE = "none",
|
|
|
|
OUTSET = "outset",
|
|
|
|
THICK = "thick",
|
|
|
|
THICK_THIN_LARGE_GAP = "thickThinLargeGap",
|
|
|
|
THICK_THIN_MEDIUM_GAP = "thickThinMediumGap",
|
|
|
|
THICK_THIN_SMALL_GAP = "thickThinSmallGap",
|
|
|
|
THIN_THICK_LARGE_GAP = "thinThickLargeGap",
|
|
|
|
THIN_THICK_MEDIUM_GAP = "thinThickMediumGap",
|
|
|
|
THIN_THICK_SMALL_GAP = "thinThickSmallGap",
|
|
|
|
THIN_THICK_THIN_LARGE_GAP = "thinThickThinLargeGap",
|
|
|
|
THIN_THICK_THIN_MEDIUM_GAP = "thinThickThinMediumGap",
|
|
|
|
THIN_THICK_THIN_SMALL_GAP = "thinThickThinSmallGap",
|
|
|
|
THREE_D_EMBOSS = "threeDEmboss",
|
|
|
|
THREE_D_ENGRAVE = "threeDEngrave",
|
|
|
|
TRIPLE = "triple",
|
|
|
|
WAVE = "wave",
|
|
|
|
}
|