Skip to content

Commit

Permalink
[de] Add compatibility dependent test for table flow
Browse files Browse the repository at this point in the history
  • Loading branch information
KirillovIlya committed Nov 28, 2024
1 parent 38685d7 commit 0bea6aa
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 14 deletions.
30 changes: 18 additions & 12 deletions tests/word/document-calculation/table/table-flow.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,11 @@ $(function ()
}
});

QUnit.test("Test simple situation with table wrap", function (assert)
QUnit.test("Single flow-image on the left side", function(assert)
{
let paragraph = AscTest.CreateParagraph();
logicDocument.PushToContent(paragraph);
paragraph.SetParagraphSpacing({Before: 0, After : 0});

AscTest.Recalculate();
assert.deepEqual(paragraph.GetPageBounds(0), new AscWord.CDocumentBounds(lField, 50, rField, 50 + AscTest.FontHeight), "Check page bounds of the first paragraph");
paragraph.SetParagraphSpacing({Before : 0, After : 0});

let table = AscTest.CreateTable(3, 3, [100, 100, 100]);
logicDocument.PushToContent(table);
Expand All @@ -99,24 +96,33 @@ $(function ()
table.GetRow(1).SetHeight(20, Asc.linerule_AtLeast);
table.GetRow(2).SetHeight(20, Asc.linerule_AtLeast);

// Test a normal situation
AscTest.Recalculate();

let tableTop = 50 + AscTest.FontHeight;
AscTest.SetCompatibilityMode(AscCommon.document_compatibility_mode_Word15);

// Test a normal situation
AscTest.Recalculate();
assert.strictEqual(table.GetPagesCount(), 1, "Check table page count");
checkBounds(table.getRowBounds(0, 0), new AscWord.CDocumentBounds(lField, tableTop, rField, tableTop + 20), "Check first row bounds");
checkBounds(table.getRowBounds(1, 0), new AscWord.CDocumentBounds(lField, tableTop + 20, rField, tableTop + 40), "Check second row bounds");
checkBounds(table.getRowBounds(2, 0), new AscWord.CDocumentBounds(lField, tableTop + 40, rField, tableTop + 60), "Check third row bounds");
checkBounds(table.getRowBounds(1, 0), new AscWord.CDocumentBounds(lField, tableTop + 20, rField, tableTop + 40), "Check second row bounds");
checkBounds(table.getRowBounds(2, 0), new AscWord.CDocumentBounds(lField, tableTop + 40, rField, tableTop + 60), "Check third row bounds");

addImageToParagraph(paragraph, lField, tableTop, 50, 50);

AscTest.SetCompatibilityMode(AscCommon.document_compatibility_mode_Word15);

AscTest.Recalculate();
assert.strictEqual(table.GetPagesCount(), 1, "Check table page count");
checkBounds(table.getRowBounds(0, 0), new AscWord.CDocumentBounds(lField, tableTop + 60, rField, tableTop + 80), "Check first row bounds");
checkBounds(table.getRowBounds(1, 0), new AscWord.CDocumentBounds(lField, tableTop + 80, rField, tableTop + 100), "Check second row bounds");
checkBounds(table.getRowBounds(2, 0), new AscWord.CDocumentBounds(lField, tableTop + 100, rField, tableTop + 120), "Check third row bounds");
checkBounds(table.getRowBounds(1, 0), new AscWord.CDocumentBounds(lField, tableTop + 80, rField, tableTop + 100), "Check second row bounds");
checkBounds(table.getRowBounds(2, 0), new AscWord.CDocumentBounds(lField, tableTop + 100, rField, tableTop + 120), "Check third row bounds");

AscTest.SetCompatibilityMode(AscCommon.document_compatibility_mode_Word14);

AscTest.Recalculate();
assert.strictEqual(table.GetPagesCount(), 1, "Check table page count");
checkBounds(table.getRowBounds(0, 0), new AscWord.CDocumentBounds(lField + 60, tableTop, rField, tableTop + 20), "Check first row bounds");
checkBounds(table.getRowBounds(1, 0), new AscWord.CDocumentBounds(lField + 60, tableTop + 20, rField, tableTop + 40), "Check second row bounds");
checkBounds(table.getRowBounds(2, 0), new AscWord.CDocumentBounds(lField + 60, tableTop + 40, rField, tableTop + 60), "Check third row bounds");
});

});
17 changes: 15 additions & 2 deletions word/Editor/Table.js
Original file line number Diff line number Diff line change
Expand Up @@ -2254,7 +2254,7 @@ CTable.prototype.GetPageBounds = function(nCurPage)
{
return this.Get_PageBounds(nCurPage);
};
CTable.prototype.getRowBounds = function(iRow, relPage)
CTable.prototype.getRowBounds = function(iRow, relPage, offsetCorrection)
{
let page = this.Pages[relPage];
let rowInfo = this.RowsInfo[iRow];
Expand All @@ -2264,10 +2264,23 @@ CTable.prototype.getRowBounds = function(iRow, relPage)
|| undefined === rowInfo.Y[relPage])
return new CDocumentBounds(0, 0, 0, 0);

let lCorrection = this.GetTableOffsetCorrection();
let rCorrection = this.GetRightTableOffsetCorrection();

if (offsetCorrection)
{
return new CDocumentBounds(
rowInfo.X0 + page.X_origin + lCorrection,
rowInfo.Y[relPage],
rowInfo.X1 + page.X_origin,
rowInfo.Y[relPage] + rowInfo.H[relPage]
);
}

return new CDocumentBounds(
rowInfo.X0 + page.X_origin,
rowInfo.Y[relPage],
rowInfo.X1 + page.X_origin,
rowInfo.X1 + page.X_origin + lCorrection - rCorrection,
rowInfo.Y[relPage] + rowInfo.H[relPage]
);
};
Expand Down

0 comments on commit 0bea6aa

Please sign in to comment.