We faced the following issue after updating the Aspose Words library from version 7.0.0 to 16.8.0:
java.lang.IllegalStateException: Cannot perform further replacements since the document has been changed
when we called class Range, method public int replace(Pattern pattern, IReplacingCallback handler, boolean isForward).
Based on recommendation here: <a href="https://forum.aspose.com/t/30498</a> we changed the calling from</div><div><br></div><div><i>doc.getRange().replace(TAG_PATTERN, masterEvaluator, true);</i></div><div><br></div><div>to </div><div><br></div><div><i>FindReplaceOptions options = new FindReplaceOptions();</i></div><div><i>options.setDirection(FindReplaceDirection.FORWARD);</i></div><div><i>options.ReplacingCallback = masterEvaluator;</i></div><div><i>doc.getRange().replace(TAG_PATTERN, "", options);
This however caused another problem:
If we have a tag inside of MS Word's table, then this tag is passed to IReplacingCallback (masterEvaluator in our implementation) after all other tags are processed. This causes a lot of problems for us as we rely on the exact order of our tags (especially in the list).
Could you please confirm if this is the known issue in the version 16.8.0 and/or there is a workaround?
Please find the simple template that can be used for reproducing the issue (the tags are incorrectly processed in the following order: LIST: LICENCES, NAME, LIST:END, REF)