( excelRender: ExcelRender, currentSheet: Sheet, excelRenderOptions: ExcelRenderOptions, canvas: SheetCanvas, displayData: DisplayData[], linkPositionCache: LinkPosition[] )
| 10 | * 绘制所有单元格的主入口 |
| 11 | */ |
| 12 | export function drawCells( |
| 13 | excelRender: ExcelRender, |
| 14 | currentSheet: Sheet, |
| 15 | excelRenderOptions: ExcelRenderOptions, |
| 16 | canvas: SheetCanvas, |
| 17 | displayData: DisplayData[], |
| 18 | linkPositionCache: LinkPosition[] |
| 19 | ) { |
| 20 | const cellInfoMap: Map<string, CellInfoWithSize> = new Map(); |
| 21 | for (const data of displayData) { |
| 22 | const {row, col, width, height} = data; |
| 23 | if (width <= 0 || height <= 0) { |
| 24 | continue; |
| 25 | } |
| 26 | const cellInfo = currentSheet.getCellInfo(row, col); |
| 27 | if (cellInfo) { |
| 28 | cellInfoMap.set(`${row},${col}`, { |
| 29 | ...JSON.parse(JSON.stringify(cellInfo)), |
| 30 | width, |
| 31 | height |
| 32 | }); |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | canvas.autoClip(cellInfoMap); |
| 37 | |
| 38 | for (const data of displayData) { |
| 39 | const {row, col, x, y, width, height, needClear} = data; |
| 40 | if (width <= 0 || height <= 0) { |
| 41 | continue; |
| 42 | } |
| 43 | const key = `${row},${col}`; |
| 44 | if (cellInfoMap.has(key)) { |
| 45 | const cellInfo = cellInfoMap.get(key)!; |
| 46 | canvas.drawCell( |
| 47 | excelRender, |
| 48 | cellInfo, |
| 49 | x, |
| 50 | y, |
| 51 | width, |
| 52 | height, |
| 53 | excelRenderOptions.indentSize, |
| 54 | PADDING_SIZE, |
| 55 | needClear, |
| 56 | linkPositionCache |
| 57 | ); |
| 58 | } |
| 59 | } |
| 60 | } |
no test coverage detected