Hello Aspose Team!
We’ve been running into an issue with red swiggly underscores (usually a sign of misspelling) in text that we replaced. This seems to be partially an issue on PPT not re-evaluating text eagerly anymore. However while doing a deeper dive and analyzing the XML I noticed that the function
joinPortionsWithSameFormatting();
will carry over the err flag on a TextRun(Portion) properties if it’s present on the first text run being merged.
For example this source XML where the first TextRun has the err flag set:
<a:p>
<a:r>
<a:rPr lang="en-US" dirty="0" err="1" />
<a:t>customer_name</a:t>
</a:r>
<a:r>
<a:rPr lang="en-US" dirty="0" />
<a:t>}} is a great client</a:t>
</a:r>
</a:p>
Will turn into:
<a:p>
<a:r>
<a:rPr lang="en-US" err="1" />
<a:t>customer_name}} is a great client</a:t>
</a:r>
</a:p>
Notice the Err Flag is still present, even if the subsequent merged TextRuns did not have it.
On the contrary, if the first TextRun doesn’t have the err flag, but subsequent TextRuns do, the err flag is left unset regardless of the subsequent TextRuns, example before:
<a:p>
<a:r>
<a:rPr lang="en-US" dirty="0" />
<a:t>{{</a:t>
</a:r>
<a:r>
<a:rPr lang="en-US" dirty="0" err="1" />
<a:t>customer_name</a:t>
</a:r>
<a:r>
<a:rPr lang="en-US" dirty="0" />
<a:t>}} is a great client</a:t>
</a:r>
</a:p>
After:
<a:p>
<a:r>
<a:rPr lang="en-US" />
<a:t>{{customer_name}} is a great client</a:t>
</a:r>
</a:p>
The code to make this happen super simple:
@Test
void joinPortionsWithSameFormatting_err_flag_issue() {
Presentation presentation = null;
try {
presentation = new Presentation("err_flag_template.pptx");
File outputFile = Files.createTempFile("err_flag_output", ".pptx").toFile();
presentation.joinPortionsWithSameFormatting();
String outputFilePath = "";
try (FileOutputStream outputStream = new FileOutputStream(outputFile)) {
outputFilePath = outputFile.getCanonicalPath();
presentation.save(outputStream, SaveFormat.Pptx);
} catch (IOException e) {
throw new RuntimeException("Unable to write to slide show " + outputFilePath, e);
}
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
if (presentation != null) {
presentation.dispose();
}
}
}
I tested this with Aspose 25.10
Files Attached(sorry order of the example slides are backwards):
err_flag_ppts.zip (47.1 KB)
Can Aspose clear up the err flag in this function? Or provide a way to unset it manually? The IPortionFormat class doesn’t seem to have a way to set/unset the err flag which seems like a gap, and I could not find anything in the documentation relating to it.
The one workaround(in ppt 365) I’ve found is a very tedious process; Right click on red swiggly text → add to dictionary → click out of text box → right click on text again. We have a lot of template/users, and some presentations are easily 30 slides before processing, so being able to unset the flag programmatically would improve our end user experience by a lot.