Skip to content

Commit

Permalink
[se] Fix pasted table width
Browse files Browse the repository at this point in the history
  • Loading branch information
GoshaZotov committed Oct 27, 2023
1 parent 3499745 commit 7048531
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions common/wordcopypaste.js
Original file line number Diff line number Diff line change
Expand Up @@ -8465,8 +8465,7 @@ PasteProcessor.prototype =
var oDocument = this.oDocument;
var tableNode = node, newNode, headNode;
var bPresentation = !PasteElementsId.g_bIsDocumentCopyPaste;
var bPercentWidth = node.style.width.indexOf('%') !== -1 || node.width.indexOf('%') !== -1;
var nPercentWidth = bPercentWidth ? parseInt(node.style.width || node.width) : 0;
let tBodyNode;

//Ищем если есть tbody
var i, length, j, length2;
Expand Down Expand Up @@ -8494,11 +8493,10 @@ PasteProcessor.prototype =

if (newNode) {
node = newNode;
tableNode = newNode;
tBodyNode = newNode;
} else if (headNode) {
node = headNode;
//tableNode = headNode;
//pPr.repeatHeaderRow = true;
tBodyNode = tableNode;
}

//валидация талиц. В таблице не может быть строк состоящих из вертикально замерженых ячеек.
Expand Down Expand Up @@ -8678,12 +8676,24 @@ PasteProcessor.prototype =
aSumGrid[i] = nSum;
}
//набиваем content
this._ExecuteTable(tableNode, node, table, aSumGrid, nMaxColCount !== nMinColCount ? aColsCountByRow : null, pPr, bUseScaleKoef, dScaleKoef, arrShapes, arrImages, arrTables);
this._ExecuteTable(tBodyNode, node, table, aSumGrid, nMaxColCount !== nMinColCount ? aColsCountByRow : null, pPr, bUseScaleKoef, dScaleKoef, arrShapes, arrImages, arrTables);
table.MoveCursorToStartPos();

if (bPercentWidth) {
table.SetTableProps({TableWidth:-nPercentWidth});
}

if (tableNode) {
let nWidth = null;
if (tableNode.style.width.indexOf('%') !== -1 || tableNode.width.indexOf('%') !== -1) {
nWidth = -1 * parseInt(tableNode.style.width || tableNode.width);
} else {
let nodeStyleWidth = node.style.width;
nWidth = AscCommon.valueToMmType(nodeStyleWidth);
nWidth = nWidth && nWidth.val;
}

if (nWidth != null) {
table.SetTableProps({TableWidth: nWidth});
}
}

if (!bPresentation) {
this.aContent.push(table);
}
Expand Down

0 comments on commit 7048531

Please sign in to comment.