Description
When calling paragraph.raw_text() on a Paragraph with changes that are not yet accepted, the expected behavior in to see the paragraph’s text as if all the tracked changes had been accepted. But tracked changes corresponding to a "move" operation are duplicated.
Steps to reproduce
- Create a Word document manually with 2 different lines
- Print the text with
paragraph.raw_text() -> output gives the same 2 lines
- Activate the Track Changes feature, and then cut and paste the second line -> it is considered "moved"
- Print the text again -> output gives 3 lines, with the second one being duplicated
Expected behavior
The second line should not be printed twice.
## Suggestion
A moved element in a docx file corresponds to a "w:moveFrom" followed by a "w:moveTo" element in the document.xml
IMO, those XML elements should be added to the XMLElement and ParagraphChild enums. This requires a bit of refactor. Then, the raw_text method from Paragraph should be added a new match arm for the ParagraphChild::MoveTo case, which would print the Run’s text.
I’ve made a quick fix myself for my needs, I will submit a PR soon with my changes. The fix seems to solve the problem for my very precise needs, but it is definitely not enough for it to be accepted and it needs some more work. It also adds quite a lot of duplicate code, so there is probably a better way to achieve it using Traits.
Desktop
- OS: Debian 12
- Version: "0.4.18-rc19"
Description
When calling
paragraph.raw_text()on aParagraphwith changes that are not yet accepted, the expected behavior in to see the paragraph’s text as if all the tracked changes had been accepted. But tracked changes corresponding to a "move" operation are duplicated.Steps to reproduce
paragraph.raw_text()-> output gives the same 2 linesExpected behavior
The second line should not be printed twice.
## Suggestion
A moved element in a docx file corresponds to a "w:moveFrom" followed by a "w:moveTo" element in the document.xml
IMO, those XML elements should be added to the
XMLElementandParagraphChildenums. This requires a bit of refactor. Then, theraw_textmethod fromParagraphshould be added a new match arm for theParagraphChild::MoveTocase, which would print the Run’s text.I’ve made a quick fix myself for my needs, I will submit a PR soon with my changes. The fix seems to solve the problem for my very precise needs, but it is definitely not enough for it to be accepted and it needs some more work. It also adds quite a lot of duplicate code, so there is probably a better way to achieve it using Traits.
Desktop