(frameNode: SafeXmlNode)
| 104 | * Parse a graphicFrame XML node containing a table into TableNodeData. |
| 105 | */ |
| 106 | export function parseTableNode(frameNode: SafeXmlNode): TableNodeData { |
| 107 | const base = parseBaseProps(frameNode) |
| 108 | const tbl = findTable(frameNode) |
| 109 | |
| 110 | // --- Column widths --- |
| 111 | const tblGrid = tbl.child('tblGrid') |
| 112 | const columns: number[] = [] |
| 113 | for (const gridCol of tblGrid.children('gridCol')) { |
| 114 | columns.push(emuToPx(gridCol.numAttr('w') ?? 0)) |
| 115 | } |
| 116 | |
| 117 | // --- Rows --- |
| 118 | const rows: TableRow[] = [] |
| 119 | for (const trNode of tbl.children('tr')) { |
| 120 | rows.push(parseRow(trNode)) |
| 121 | } |
| 122 | |
| 123 | // --- Table properties --- |
| 124 | const tblPr = tbl.child('tblPr') |
| 125 | const tableStyleId = extractTableStyleId(tblPr) |
| 126 | |
| 127 | return { |
| 128 | ...base, |
| 129 | nodeType: 'table', |
| 130 | columns, |
| 131 | rows, |
| 132 | properties: tblPr.exists() ? tblPr : undefined, |
| 133 | tableStyleId, |
| 134 | } |
| 135 | } |
no test coverage detected