Feature: Replace text in text-boxes #36
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi,
this is my attempt at thombergs/docx-stamper#97. The approaches from thombergs/docx-stamper#97 did not quite work, because they broke some tests.
I added it in a more conservative way: I search through all P elements in the document and find those, which are children of Text-Boxes. This is added as an additional helper method
ParagraphUtil.getAllTextBoxes(document)
.In the
CoordinatesWalker.walk()
method I runwalkContent
on those elements after the other content is processed. This way I did not break any tests. I added a test document with two simple text-boxes and it works.Things I noticed:
ParagraphUtil.getAllTextBoxes(document)
finds all text-box paragraphs (in the test-document) twice with different parents. However this doesn't seem to be a problem (I guess the text is processed the first time and the second time it already contains the processed text)However since the current implementation just ignores text-boxes this is IMHO safe to add, because it just adds functionality, which may not work in complex cases.