pjfanning opened a new pull request, #1584: URL: https://github.com/apache/poi/pull/1584
Three fixes in XSSF hyperlink handling. **Re-adding a removed hyperlink (regression from #1579)** `removeHyperlink` now deletes the hyperlink's relationship, but the `XSSFHyperlink` kept it. Adding the same object to a cell again, e.g. to move it (`h = cell.getHyperlink(); cell.removeHyperlink(); other.setHyperlink(h)`), wrote an `r:id` that no longer existed, and reading the file back failed with "references relation rIdN, but that didn't exist!". - When the sheet is written, the relationship is generated again if it belonged to this sheet and has been removed. The old target is reused, since the location is still written as a separate attribute. - `removeHyperlink` clears the hyperlink's sheet, so a later `setAddress` doesn't add an orphan relationship to the sheet it was removed from. - `removeHyperlinkRelation` only removes a relationship that is still the one the hyperlink holds. **`XSSFSheet.removeHyperlink(int, int)` column mix-up** The pieces above and below the removed cell used `row` where they should have used `column`, so they covered the wrong columns. This only went unnoticed where the cell's row and column are equal, as in the existing test (C3). **`XSSFWorkbook.cloneSheet` copied hyperlink relationships to the workbook** The source sheet's hyperlink relationships were added to the workbook part instead of the cloned sheet. Because the ids are the sheet's, they replaced the workbook's own relationships with the same ids (e.g. `rId1`, often a sheet). They are now added to the cloned sheet. Tests: `testAddRemovedLoadedHyperlinkAgain`, `testSetAddressOfRemovedHyperlink`, `testCloneSheetWithLoadedHyperlinkKeepsWorkbookRelationships`, plus D2 and B4 cases in `testRemoveSharedHyperlinkFromOneCell`. Not run locally; relying on CI. 🤖 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]
