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

   Fixes #1499.
   
   `PAPBinTable.rebuild` splits the text into paragraphs at every CR, 0x07 and 
0x0C, and gives each paragraph the PAPXs that *end* inside it. If one of those 
marks falls inside a PAPX interval rather than at its end, no PAPX ends in the 
paragraph. It then got empty default properties, so in the issue's example the 
text before an internal CR in a nested table cell came out as a non-table 
paragraph.
   
   [MS-DOC 
2.4.2](https://learn.microsoft.com/en-us/openspecs/office_file_formats/ms-doc/30461a5b-e3ad-44cd-a3fe-038f86639b13)
 takes paragraph boundaries from the PapxFkp, so a PAPX interval's properties 
cover all of its text. With this change, a paragraph that no PAPX ends in takes 
the properties of the PAPX(s) covering its mark, merged in file order the same 
way as the normal path. Three sprms are left out:
   
   - `sprmPFTtp` (0x2417)
   - `sprmPFInnerTableCell` (0x244B)
   - `sprmPFInnerTtp` (0x244C)
   
   These mark the end of a cell or row, so they belong only to the interval's 
last paragraph. `TableRow` and `Table` split cells and rows on them 
(`isEmbeddedCellMark()` / `isTableRowEnd()`), so copying them to the internal 
paragraph would end the cell or row early. In-table, itap, justification and 
the other sprms are kept. A paragraph that no PAPX covers at all still gets 
defaults and the existing warning.
   
   The issue asks POI to either keep the original property coverage or reject 
the input. Rejecting isn't an option here, because `rebuild` runs on every 
document load and HWPF's paragraph model needs a paragraph per mark. This PR 
takes the first option.
   
   I also pulled the existing sprm merge loop out into `mergeSprms` so both 
paths share it.
   
   Tests: there are three new `TestPAPBinTable` cases. Two cover an internal CR 
in a nested-cell-end PAPX (the issue's example) and in a row-end PAPX; both 
fail without the fix. The third confirms an uncovered paragraph still gets 
defaults. `TestBugs`, `TestProblems` and `TestTableRow` in `hwpf.usermodel` 
still pass.
   
   🤖 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