Add more run properties and Universal measure
This commit is contained in:
@ -1,39 +1,14 @@
|
||||
// http://officeopenxml.com/WPindentation.php
|
||||
import { XmlAttributeComponent, XmlComponent } from "@file/xml-components";
|
||||
import { signedTwipsMeasureValue, twipsMeasureValue } from "@util/values";
|
||||
import { NextAttributeComponent, XmlComponent } from "@file/xml-components";
|
||||
import { PositiveUniversalMeasure, signedTwipsMeasureValue, twipsMeasureValue, UniversalMeasure } from "@util/values";
|
||||
|
||||
export interface IIndentAttributesProperties {
|
||||
readonly start?: number | string;
|
||||
readonly end?: number | string;
|
||||
readonly left?: number | string;
|
||||
readonly right?: number | string;
|
||||
readonly hanging?: number | string;
|
||||
readonly firstLine?: number | string;
|
||||
}
|
||||
|
||||
// <xsd:complexType name="CT_Ind">
|
||||
// <xsd:attribute name="start" type="ST_SignedTwipsMeasure" use="optional"/>
|
||||
// <xsd:attribute name="startChars" type="ST_DecimalNumber" use="optional"/>
|
||||
// <xsd:attribute name="end" type="ST_SignedTwipsMeasure" use="optional"/>
|
||||
// <xsd:attribute name="endChars" type="ST_DecimalNumber" use="optional"/>
|
||||
// <xsd:attribute name="left" type="ST_SignedTwipsMeasure" use="optional"/>
|
||||
// <xsd:attribute name="leftChars" type="ST_DecimalNumber" use="optional"/>
|
||||
// <xsd:attribute name="right" type="ST_SignedTwipsMeasure" use="optional"/>
|
||||
// <xsd:attribute name="rightChars" type="ST_DecimalNumber" use="optional"/>
|
||||
// <xsd:attribute name="hanging" type="s:ST_TwipsMeasure" use="optional"/>
|
||||
// <xsd:attribute name="hangingChars" type="ST_DecimalNumber" use="optional"/>
|
||||
// <xsd:attribute name="firstLine" type="s:ST_TwipsMeasure" use="optional"/>
|
||||
// <xsd:attribute name="firstLineChars" type="ST_DecimalNumber" use="optional"/>
|
||||
// </xsd:complexType>
|
||||
class IndentAttributes extends XmlAttributeComponent<IIndentAttributesProperties> {
|
||||
protected readonly xmlKeys = {
|
||||
start: "w:start",
|
||||
end: "w:end",
|
||||
left: "w:left",
|
||||
right: "w:right",
|
||||
hanging: "w:hanging",
|
||||
firstLine: "w:firstLine",
|
||||
};
|
||||
readonly start?: number | UniversalMeasure;
|
||||
readonly end?: number | UniversalMeasure;
|
||||
readonly left?: number | UniversalMeasure;
|
||||
readonly right?: number | UniversalMeasure;
|
||||
readonly hanging?: number | PositiveUniversalMeasure;
|
||||
readonly firstLine?: number | PositiveUniversalMeasure;
|
||||
}
|
||||
|
||||
// <xsd:complexType name="CT_PPrBase">
|
||||
@ -43,14 +18,53 @@ class IndentAttributes extends XmlAttributeComponent<IIndentAttributesProperties
|
||||
export class Indent extends XmlComponent {
|
||||
public constructor({ start, end, left, right, hanging, firstLine }: IIndentAttributesProperties) {
|
||||
super("w:ind");
|
||||
// <xsd:complexType name="CT_Ind">
|
||||
// <xsd:attribute name="start" type="ST_SignedTwipsMeasure" use="optional"/>
|
||||
// <xsd:attribute name="startChars" type="ST_DecimalNumber" use="optional"/>
|
||||
// <xsd:attribute name="end" type="ST_SignedTwipsMeasure" use="optional"/>
|
||||
// <xsd:attribute name="endChars" type="ST_DecimalNumber" use="optional"/>
|
||||
// <xsd:attribute name="left" type="ST_SignedTwipsMeasure" use="optional"/>
|
||||
// <xsd:attribute name="leftChars" type="ST_DecimalNumber" use="optional"/>
|
||||
// <xsd:attribute name="right" type="ST_SignedTwipsMeasure" use="optional"/>
|
||||
// <xsd:attribute name="rightChars" type="ST_DecimalNumber" use="optional"/>
|
||||
// <xsd:attribute name="hanging" type="s:ST_TwipsMeasure" use="optional"/>
|
||||
// <xsd:attribute name="hangingChars" type="ST_DecimalNumber" use="optional"/>
|
||||
// <xsd:attribute name="firstLine" type="s:ST_TwipsMeasure" use="optional"/>
|
||||
// <xsd:attribute name="firstLineChars" type="ST_DecimalNumber" use="optional"/>
|
||||
// </xsd:complexType>
|
||||
this.root.push(
|
||||
new IndentAttributes({
|
||||
start: start === undefined ? undefined : signedTwipsMeasureValue(start),
|
||||
end: end === undefined ? undefined : signedTwipsMeasureValue(end),
|
||||
left: left === undefined ? undefined : signedTwipsMeasureValue(left),
|
||||
right: right === undefined ? undefined : signedTwipsMeasureValue(right),
|
||||
hanging: hanging === undefined ? undefined : twipsMeasureValue(hanging),
|
||||
firstLine: firstLine === undefined ? undefined : twipsMeasureValue(firstLine),
|
||||
new NextAttributeComponent<{
|
||||
readonly start?: number | UniversalMeasure;
|
||||
readonly end?: number | UniversalMeasure;
|
||||
readonly left?: number | UniversalMeasure;
|
||||
readonly right?: number | UniversalMeasure;
|
||||
readonly hanging?: number | PositiveUniversalMeasure;
|
||||
readonly firstLine?: number | PositiveUniversalMeasure;
|
||||
}>({
|
||||
start: {
|
||||
key: "w:start",
|
||||
value: start === undefined ? undefined : signedTwipsMeasureValue(start),
|
||||
},
|
||||
end: {
|
||||
key: "w:end",
|
||||
value: end === undefined ? undefined : signedTwipsMeasureValue(end),
|
||||
},
|
||||
left: {
|
||||
key: "w:left",
|
||||
value: left === undefined ? undefined : signedTwipsMeasureValue(left),
|
||||
},
|
||||
right: {
|
||||
key: "w:right",
|
||||
value: right === undefined ? undefined : signedTwipsMeasureValue(right),
|
||||
},
|
||||
hanging: {
|
||||
key: "w:hanging",
|
||||
value: hanging === undefined ? undefined : twipsMeasureValue(hanging),
|
||||
},
|
||||
firstLine: {
|
||||
key: "w:firstLine",
|
||||
value: firstLine === undefined ? undefined : twipsMeasureValue(firstLine),
|
||||
},
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user