remove more duplicate classes; add additional values functions; clean up tests
This commit is contained in:
@ -129,6 +129,19 @@ export class TableFloatOptionsAttributes extends XmlAttributeComponent<ITableFlo
|
||||
};
|
||||
}
|
||||
|
||||
// <xsd:complexType name="CT_TblPPr">
|
||||
// <xsd:attribute name="leftFromText" type="s:ST_TwipsMeasure"/>
|
||||
// <xsd:attribute name="rightFromText" type="s:ST_TwipsMeasure"/>
|
||||
// <xsd:attribute name="topFromText" type="s:ST_TwipsMeasure"/>
|
||||
// <xsd:attribute name="bottomFromText" type="s:ST_TwipsMeasure"/>
|
||||
// <xsd:attribute name="vertAnchor" type="ST_VAnchor"/>
|
||||
// <xsd:attribute name="horzAnchor" type="ST_HAnchor"/>
|
||||
// <xsd:attribute name="tblpXSpec" type="s:ST_XAlign"/>
|
||||
// <xsd:attribute name="tblpX" type="ST_SignedTwipsMeasure"/>
|
||||
// <xsd:attribute name="tblpYSpec" type="s:ST_YAlign"/>
|
||||
// <xsd:attribute name="tblpY" type="ST_SignedTwipsMeasure"/>
|
||||
// </xsd:complexType>
|
||||
|
||||
export class TableFloatProperties extends XmlComponent {
|
||||
constructor(options: ITableFloatOptions) {
|
||||
super("w:tblpPr");
|
||||
|
@ -9,6 +9,15 @@ class TableLayoutAttributes extends XmlAttributeComponent<{ readonly type: Table
|
||||
protected readonly xmlKeys = { type: "w:type" };
|
||||
}
|
||||
|
||||
// <xsd:complexType name="CT_TblLayoutType">
|
||||
// <xsd:attribute name="type" type="ST_TblLayoutType"/>
|
||||
// </xsd:complexType>
|
||||
// <xsd:simpleType name="ST_TblLayoutType">
|
||||
// <xsd:restriction base="xsd:string">
|
||||
// <xsd:enumeration value="fixed"/>
|
||||
// <xsd:enumeration value="autofit"/>
|
||||
// </xsd:restriction>
|
||||
// </xsd:simpleType>
|
||||
export class TableLayout extends XmlComponent {
|
||||
constructor(type: TableLayoutType) {
|
||||
super("w:tblLayout");
|
||||
|
@ -5,6 +5,16 @@ export enum OverlapType {
|
||||
OVERLAP = "overlap",
|
||||
}
|
||||
|
||||
// <xsd:complexType name="CT_TblOverlap">
|
||||
// <xsd:attribute name="val" type="ST_TblOverlap" use="required"/>
|
||||
// </xsd:complexType>
|
||||
// <xsd:simpleType name="ST_TblOverlap">
|
||||
// <xsd:restriction base="xsd:string">
|
||||
// <xsd:enumeration value="never"/>
|
||||
// <xsd:enumeration value="overlap"/>
|
||||
// </xsd:restriction>
|
||||
// </xsd:simpleType>
|
||||
|
||||
class TableOverlapAttributes extends XmlAttributeComponent<{ readonly val: OverlapType }> {
|
||||
protected readonly xmlKeys = { val: "w:val" };
|
||||
}
|
||||
|
@ -21,7 +21,7 @@
|
||||
// <xsd:element name="tblDescription" type="CT_String" minOccurs="0" maxOccurs="1"/>
|
||||
// </xsd:sequence>
|
||||
// </xsd:complexType>
|
||||
import { IgnoreIfEmptyXmlComponent } from "file/xml-components";
|
||||
import { IgnoreIfEmptyXmlComponent, OnOffElement, StringValueElement } from "file/xml-components";
|
||||
|
||||
import { Alignment, AlignmentType } from "../../paragraph";
|
||||
import { IShadingAttributesProperties, Shading } from "../../shading";
|
||||
@ -30,8 +30,6 @@ import { ITableBordersOptions, TableBorders } from "./table-borders";
|
||||
import { ITableCellMarginOptions, TableCellMargin, TableCellMarginElementType } from "./table-cell-margin";
|
||||
import { ITableFloatOptions, TableFloatProperties } from "./table-float-properties";
|
||||
import { TableLayout, TableLayoutType } from "./table-layout";
|
||||
import { TableStyle } from "./table-style";
|
||||
import { VisuallyRightToLeft } from "./visually-right-to-left";
|
||||
|
||||
export interface ITablePropertiesOptions {
|
||||
readonly width?: ITableWidthProperties;
|
||||
@ -51,15 +49,15 @@ export class TableProperties extends IgnoreIfEmptyXmlComponent {
|
||||
super("w:tblPr");
|
||||
|
||||
if (options.style) {
|
||||
this.root.push(new TableStyle(options.style));
|
||||
this.root.push(new StringValueElement("w:tblStyle", options.style));
|
||||
}
|
||||
|
||||
if (options.float) {
|
||||
this.root.push(new TableFloatProperties(options.float));
|
||||
}
|
||||
|
||||
if (options.visuallyRightToLeft) {
|
||||
this.root.push(new VisuallyRightToLeft());
|
||||
if (options.visuallyRightToLeft !== undefined) {
|
||||
this.root.push(new OnOffElement("w:bidiVisual", options.visuallyRightToLeft));
|
||||
}
|
||||
|
||||
if (options.width) {
|
||||
|
@ -1,22 +0,0 @@
|
||||
import { expect } from "chai";
|
||||
|
||||
import { Formatter } from "export/formatter";
|
||||
|
||||
import { TableStyle } from "./table-style";
|
||||
|
||||
describe("TableStyle", () => {
|
||||
describe("#constructor", () => {
|
||||
it("should create", () => {
|
||||
const tableStyle = new TableStyle("test-id");
|
||||
const tree = new Formatter().format(tableStyle);
|
||||
|
||||
expect(tree).to.deep.equal({
|
||||
"w:tblStyle": {
|
||||
_attr: {
|
||||
"w:val": "test-id",
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
@ -1,13 +0,0 @@
|
||||
import { Attributes, XmlComponent } from "file/xml-components";
|
||||
|
||||
export class TableStyle extends XmlComponent {
|
||||
constructor(styleId: string) {
|
||||
super("w:tblStyle");
|
||||
|
||||
this.root.push(
|
||||
new Attributes({
|
||||
val: styleId,
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
import { expect } from "chai";
|
||||
|
||||
import { Formatter } from "export/formatter";
|
||||
import { VisuallyRightToLeft } from "./visually-right-to-left";
|
||||
|
||||
describe("VisuallyRightToLeft", () => {
|
||||
it("should create", () => {
|
||||
const visuallyRightToLeft = new VisuallyRightToLeft();
|
||||
const tree = new Formatter().format(visuallyRightToLeft);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:bidiVisual": {},
|
||||
});
|
||||
});
|
||||
});
|
@ -1,8 +0,0 @@
|
||||
// https://c-rex.net/projects/samples/ooxml/e1/Part4/OOXML_P4_DOCX_bidiVisual_topic_ID0EOXIQ.html
|
||||
import { XmlComponent } from "file/xml-components";
|
||||
|
||||
export class VisuallyRightToLeft extends XmlComponent {
|
||||
constructor() {
|
||||
super("w:bidiVisual");
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user