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

   Fixes #1048
   
   Borders set through `XSLFTableCell` left gaps in PowerPoint, especially 
around merged cells. Setting or removing a border now also updates the other 
cell sharing that edge.
   
   ## PowerPoint's behaviour
   
   I tested a deck of table variants in PowerPoint for the web:
   
   - **Shared edges:** the upper cell's bottom border beats the lower cell's 
top border, and the left cell's right border beats the right cell's left 
border. This holds even when the winning border is `noFill` or unset, and unset 
draws as black. Top and left borders set on an inner cell therefore didn't 
show, as the issue reports.
   - **Merged ranges:** borders on merged-away cells don't count. The first 
cell's borders are the ones that apply.
   - **Next to merged-away cells:** those cells don't compete for a shared 
edge, so the neighbour's border shows.
   
   Removing POI's default `noFill` edges doesn't help. The missing edges turn 
black, and every other cell gets a black grid.
   
   ## Changes
   
   - The border setters and `removeBorder` in `XSLFTableCell` also update the 
other cell on the edge, by copying the whole line.
   - The first cell of a merged range updates every neighbour along the range.
   - Setting an outer edge on a merged-away cell also updates the first cell 
and those neighbours. Edges inside a merged range stay on that cell, because 
they aren't visible.
   - `XSLFTable.insertRow` now refreshes the row and column indexes, which were 
stale after an insert. The neighbour lookup relies on them.
   
   There is no new public API.
   
   ## Behaviour to review
   
   - **Other cells change:** a setter now changes another cell's XML, and if 
two cells set the same shared edge, the last call wins. Code that set one side 
of a shared edge produces different XML and may show borders that were hidden 
before.
   - **Merge before setting borders:** `mergeCells` doesn't update existing 
borders, so a border set before a merge won't reach the new neighbours. This is 
in the class Javadoc.
   - **Cells next to a first merged cell:** setting the top border of the cell 
directly below a range's first cell also writes to that first cell's bottom 
border, which applies across the whole range. The same goes for the left border 
of the cell to its right. This wasn't tested in PowerPoint.
   
   ## Testing
   
   - The unmodified `MergedCellBorderProblem.java` from the issue, built with 
this change, shows complete red and blue boxes in PowerPoint for the web. 
Without it, the blue box has no top or left edge.
   - `TestXSLFTable` (5 new tests) and `TestTable` pass locally; I ran only 
these two classes.
   - **Not checked:** desktop PowerPoint, and the XML PowerPoint itself writes 
for such a table.
   
   🤖 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