Fix ordering of elements in table-cell-borders and section-properties
This commit is contained in:
@ -43,13 +43,13 @@ describe("Body", () => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{ "w:cols": { _attr: { "w:space": 708, "w:sep": false, "w:num": 1 } } },
|
|
||||||
{ "w:docGrid": { _attr: { "w:linePitch": 360 } } },
|
|
||||||
{
|
{
|
||||||
"w:pgNumType": {
|
"w:pgNumType": {
|
||||||
_attr: {},
|
_attr: {},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{ "w:cols": { _attr: { "w:space": 708, "w:sep": false, "w:num": 1 } } },
|
||||||
|
{ "w:docGrid": { _attr: { "w:linePitch": 360 } } },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@ -61,8 +61,10 @@ describe("SectionProperties", () => {
|
|||||||
|
|
||||||
expect(Object.keys(tree)).to.deep.equal(["w:sectPr"]);
|
expect(Object.keys(tree)).to.deep.equal(["w:sectPr"]);
|
||||||
expect(tree["w:sectPr"]).to.be.an.instanceof(Array);
|
expect(tree["w:sectPr"]).to.be.an.instanceof(Array);
|
||||||
expect(tree["w:sectPr"][0]).to.deep.equal({ "w:pgSz": { _attr: { "w:h": 16838, "w:w": 11906, "w:orient": "portrait" } } });
|
expect(tree["w:sectPr"][0]).to.deep.equal({ "w:headerReference": { _attr: { "r:id": "rId100", "w:type": "default" } } });
|
||||||
expect(tree["w:sectPr"][1]).to.deep.equal({
|
expect(tree["w:sectPr"][1]).to.deep.equal({ "w:footerReference": { _attr: { "r:id": "rId200", "w:type": "even" } } });
|
||||||
|
expect(tree["w:sectPr"][2]).to.deep.equal({ "w:pgSz": { _attr: { "w:h": 16838, "w:w": 11906, "w:orient": "portrait" } } });
|
||||||
|
expect(tree["w:sectPr"][3]).to.deep.equal({
|
||||||
"w:pgMar": {
|
"w:pgMar": {
|
||||||
_attr: {
|
_attr: {
|
||||||
"w:bottom": 1440,
|
"w:bottom": 1440,
|
||||||
@ -77,11 +79,11 @@ describe("SectionProperties", () => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(tree["w:sectPr"][2]).to.deep.equal({ "w:cols": { _attr: { "w:space": 708, "w:sep": true, "w:num": 1 } } });
|
expect(tree["w:sectPr"][4]).to.deep.equal({ "w:pgNumType": { _attr: { "w:fmt": "cardinalText", "w:start": 10 } } });
|
||||||
expect(tree["w:sectPr"][3]).to.deep.equal({ "w:docGrid": { _attr: { "w:linePitch": 360 } } });
|
expect(tree["w:sectPr"][5]).to.deep.equal({ "w:cols": { _attr: { "w:space": 708, "w:sep": true, "w:num": 1 } } });
|
||||||
expect(tree["w:sectPr"][4]).to.deep.equal({ "w:headerReference": { _attr: { "r:id": "rId100", "w:type": "default" } } });
|
expect(tree["w:sectPr"][6]).to.deep.equal({ "w:vAlign": { _attr: { "w:val": "top" } } });
|
||||||
expect(tree["w:sectPr"][5]).to.deep.equal({ "w:footerReference": { _attr: { "r:id": "rId200", "w:type": "even" } } });
|
expect(tree["w:sectPr"][7]).to.deep.equal({ "w:titlePg": { _attr: { "w:val": "1" } } });
|
||||||
expect(tree["w:sectPr"][6]).to.deep.equal({ "w:pgNumType": { _attr: { "w:fmt": "cardinalText", "w:start": 10 } } });
|
expect(tree["w:sectPr"][8]).to.deep.equal({ "w:docGrid": { _attr: { "w:linePitch": 360 } } });
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should create section properties with no options", () => {
|
it("should create section properties with no options", () => {
|
||||||
@ -104,8 +106,8 @@ describe("SectionProperties", () => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
expect(tree["w:sectPr"][2]).to.deep.equal({ "w:cols": { _attr: { "w:space": 708, "w:sep": false, "w:num": 1 } } });
|
expect(tree["w:sectPr"][3]).to.deep.equal({ "w:cols": { _attr: { "w:space": 708, "w:sep": false, "w:num": 1 } } });
|
||||||
expect(tree["w:sectPr"][3]).to.deep.equal({ "w:docGrid": { _attr: { "w:linePitch": 360 } } });
|
expect(tree["w:sectPr"][4]).to.deep.equal({ "w:docGrid": { _attr: { "w:linePitch": 360 } } });
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should create section properties with changed options", () => {
|
it("should create section properties with changed options", () => {
|
||||||
|
@ -89,20 +89,16 @@ export class SectionProperties extends XmlComponent {
|
|||||||
}: ISectionPropertiesOptions = {}) {
|
}: ISectionPropertiesOptions = {}) {
|
||||||
super("w:sectPr");
|
super("w:sectPr");
|
||||||
|
|
||||||
this.root.push(new PageSize(width, height, orientation));
|
|
||||||
this.root.push(new PageMargin(top, right, bottom, left, header, footer, gutter, mirror));
|
|
||||||
this.root.push(new Columns(space, count, separate));
|
|
||||||
this.root.push(new DocumentGrid(linePitch));
|
|
||||||
|
|
||||||
this.addHeaders(headerWrapperGroup);
|
this.addHeaders(headerWrapperGroup);
|
||||||
this.addFooters(footerWrapperGroup);
|
this.addFooters(footerWrapperGroup);
|
||||||
|
|
||||||
this.root.push(new PageNumberType(pageNumberStart, pageNumberFormatType, pageNumberSeparator));
|
if (type) {
|
||||||
|
this.root.push(new Type(type));
|
||||||
if (lineNumberCountBy || lineNumberStart || lineNumberRestart || lineNumberDistance) {
|
|
||||||
this.root.push(new LineNumberType(lineNumberCountBy, lineNumberStart, lineNumberRestart, lineNumberDistance));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.root.push(new PageSize(width, height, orientation));
|
||||||
|
this.root.push(new PageMargin(top, right, bottom, left, header, footer, gutter, mirror));
|
||||||
|
|
||||||
if (pageBorders || pageBorderTop || pageBorderRight || pageBorderBottom || pageBorderLeft) {
|
if (pageBorders || pageBorderTop || pageBorderRight || pageBorderBottom || pageBorderLeft) {
|
||||||
this.root.push(
|
this.root.push(
|
||||||
new PageBorders({
|
new PageBorders({
|
||||||
@ -115,17 +111,23 @@ export class SectionProperties extends XmlComponent {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (titlePage) {
|
if (lineNumberCountBy || lineNumberStart || lineNumberRestart || lineNumberDistance) {
|
||||||
this.root.push(new TitlePage());
|
this.root.push(new LineNumberType(lineNumberCountBy, lineNumberStart, lineNumberRestart, lineNumberDistance));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.root.push(new PageNumberType(pageNumberStart, pageNumberFormatType, pageNumberSeparator));
|
||||||
|
|
||||||
|
this.root.push(new Columns(space, count, separate));
|
||||||
|
|
||||||
if (verticalAlign) {
|
if (verticalAlign) {
|
||||||
this.root.push(new SectionVerticalAlign(verticalAlign));
|
this.root.push(new SectionVerticalAlign(verticalAlign));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type) {
|
if (titlePage) {
|
||||||
this.root.push(new Type(type));
|
this.root.push(new TitlePage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.root.push(new DocumentGrid(linePitch));
|
||||||
}
|
}
|
||||||
|
|
||||||
private addHeaders(headers: IHeaderFooterGroup<HeaderWrapper>): void {
|
private addHeaders(headers: IHeaderFooterGroup<HeaderWrapper>): void {
|
||||||
|
@ -25,8 +25,8 @@ describe("File", () => {
|
|||||||
|
|
||||||
const tree = new Formatter().format(doc.Document.View.Body);
|
const tree = new Formatter().format(doc.Document.View.Body);
|
||||||
|
|
||||||
expect(tree["w:body"][0]["w:sectPr"][4]["w:headerReference"]._attr["w:type"]).to.equal("default");
|
expect(tree["w:body"][0]["w:sectPr"][0]["w:headerReference"]._attr["w:type"]).to.equal("default");
|
||||||
expect(tree["w:body"][0]["w:sectPr"][5]["w:footerReference"]._attr["w:type"]).to.equal("default");
|
expect(tree["w:body"][0]["w:sectPr"][1]["w:footerReference"]._attr["w:type"]).to.equal("default");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should create with first headers and footers", () => {
|
it("should create with first headers and footers", () => {
|
||||||
@ -45,8 +45,8 @@ describe("File", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const tree = new Formatter().format(doc.Document.View.Body);
|
const tree = new Formatter().format(doc.Document.View.Body);
|
||||||
expect(tree["w:body"][0]["w:sectPr"][4]["w:headerReference"]._attr["w:type"]).to.equal("first");
|
expect(tree["w:body"][0]["w:sectPr"][0]["w:headerReference"]._attr["w:type"]).to.equal("first");
|
||||||
expect(tree["w:body"][0]["w:sectPr"][5]["w:footerReference"]._attr["w:type"]).to.equal("first");
|
expect(tree["w:body"][0]["w:sectPr"][1]["w:footerReference"]._attr["w:type"]).to.equal("first");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should create with correct headers", () => {
|
it("should create with correct headers", () => {
|
||||||
@ -70,13 +70,13 @@ describe("File", () => {
|
|||||||
|
|
||||||
const tree = new Formatter().format(doc.Document.View.Body);
|
const tree = new Formatter().format(doc.Document.View.Body);
|
||||||
|
|
||||||
expect(tree["w:body"][0]["w:sectPr"][4]["w:headerReference"]._attr["w:type"]).to.equal("default");
|
expect(tree["w:body"][0]["w:sectPr"][0]["w:headerReference"]._attr["w:type"]).to.equal("default");
|
||||||
expect(tree["w:body"][0]["w:sectPr"][5]["w:headerReference"]._attr["w:type"]).to.equal("first");
|
expect(tree["w:body"][0]["w:sectPr"][1]["w:headerReference"]._attr["w:type"]).to.equal("first");
|
||||||
expect(tree["w:body"][0]["w:sectPr"][6]["w:headerReference"]._attr["w:type"]).to.equal("even");
|
expect(tree["w:body"][0]["w:sectPr"][2]["w:headerReference"]._attr["w:type"]).to.equal("even");
|
||||||
|
|
||||||
expect(tree["w:body"][0]["w:sectPr"][7]["w:footerReference"]._attr["w:type"]).to.equal("default");
|
expect(tree["w:body"][0]["w:sectPr"][3]["w:footerReference"]._attr["w:type"]).to.equal("default");
|
||||||
expect(tree["w:body"][0]["w:sectPr"][8]["w:footerReference"]._attr["w:type"]).to.equal("first");
|
expect(tree["w:body"][0]["w:sectPr"][4]["w:footerReference"]._attr["w:type"]).to.equal("first");
|
||||||
expect(tree["w:body"][0]["w:sectPr"][9]["w:footerReference"]._attr["w:type"]).to.equal("even");
|
expect(tree["w:body"][0]["w:sectPr"][5]["w:footerReference"]._attr["w:type"]).to.equal("even");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should add child", () => {
|
it("should add child", () => {
|
||||||
@ -135,6 +135,11 @@ describe("File", () => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"w:pgNumType": {
|
||||||
|
_attr: {},
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"w:cols": {
|
"w:cols": {
|
||||||
_attr: {
|
_attr: {
|
||||||
@ -151,11 +156,6 @@ describe("File", () => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"w:pgNumType": {
|
|
||||||
_attr: {},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@ -568,15 +568,6 @@ describe("TableCell", () => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"w:bottom": {
|
|
||||||
_attr: {
|
|
||||||
"w:color": "blue",
|
|
||||||
"w:sz": 3,
|
|
||||||
"w:val": "double",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"w:left": {
|
"w:left": {
|
||||||
_attr: {
|
_attr: {
|
||||||
@ -586,6 +577,15 @@ describe("TableCell", () => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"w:bottom": {
|
||||||
|
_attr: {
|
||||||
|
"w:color": "blue",
|
||||||
|
"w:sz": 3,
|
||||||
|
"w:val": "double",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"w:right": {
|
"w:right": {
|
||||||
_attr: {
|
_attr: {
|
||||||
|
@ -77,12 +77,12 @@ export class TableCell extends XmlComponent {
|
|||||||
if (options.borders.top) {
|
if (options.borders.top) {
|
||||||
properties.Borders.addTopBorder(options.borders.top.style, options.borders.top.size, options.borders.top.color);
|
properties.Borders.addTopBorder(options.borders.top.style, options.borders.top.size, options.borders.top.color);
|
||||||
}
|
}
|
||||||
if (options.borders.bottom) {
|
|
||||||
properties.Borders.addBottomBorder(options.borders.bottom.style, options.borders.bottom.size, options.borders.bottom.color);
|
|
||||||
}
|
|
||||||
if (options.borders.left) {
|
if (options.borders.left) {
|
||||||
properties.Borders.addLeftBorder(options.borders.left.style, options.borders.left.size, options.borders.left.color);
|
properties.Borders.addLeftBorder(options.borders.left.style, options.borders.left.size, options.borders.left.color);
|
||||||
}
|
}
|
||||||
|
if (options.borders.bottom) {
|
||||||
|
properties.Borders.addBottomBorder(options.borders.bottom.style, options.borders.bottom.size, options.borders.bottom.color);
|
||||||
|
}
|
||||||
if (options.borders.right) {
|
if (options.borders.right) {
|
||||||
properties.Borders.addRightBorder(options.borders.right.style, options.borders.right.size, options.borders.right.color);
|
properties.Borders.addRightBorder(options.borders.right.style, options.borders.right.size, options.borders.right.color);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user