pjfanning opened a new pull request, #1431:
URL: https://github.com/apache/poi/pull/1431

   Follow-up to #971 and #1430 (bug 66263).
   
   **`getTableCell(CTTc)` returned `null` for cells in SDT rows.** The 
implementations in `XWPFDocument`, `XWPFHeaderFooter`, `XWPFTableCell`, 
`XWPFComment` and `XWPFAbstractFootnoteEndnote` expected `CTTc → CTRow → 
CTTbl`. A row wrapped in a content control has `CTSdtContentRow` as its parent, 
so the lookup failed. All five now use a package-private 
`XWPFTable.getParentTable(CTRow)`, which looks through any 
`w:sdt`/`w:sdtContent` levels.
   
   **Simplified row insert and remove in `XWPFTable`.** `addRow(row, pos)`, 
`insertNewTableRow(pos)` and `removeRow(pos)` each repeated the same ~35-line 
block: check whether the parent is a `CTTbl` or `CTSdtContentRow`, find the 
index with `indexOf`, then fall back. Now:
   - insert: `insertNewTrBefore` opens a cursor on the next row and calls 
`beginElement("tr", ns)`, which inserts into whatever holds that row
   - remove: `cursor.removeXml()` on the row, then the existing empty-SDT 
cleanup
   
   Rows outside a table or SDT row are handled the same as before: insert 
appends to the table, and remove only drops the row from `tableRows`.
   
   The javadoc for `addRow(row, pos)` and `insertNewTableRow(pos)` now says 
that inserting before a row that sits in an SDT puts the new row inside that 
SDT.
   
   Tests: `getTableCell` for a document table and for a nested table in an SDT 
row, and insertion before an SDT row and before a top-level row.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to