DocumentAssembler, OpenXmlRegex, UnicodeMapper bugfixes#46
Open
lowellstewart wants to merge 12 commits intoOpenXmlDev:vNextfrom
Open
DocumentAssembler, OpenXmlRegex, UnicodeMapper bugfixes#46lowellstewart wants to merge 12 commits intoOpenXmlDev:vNextfrom
lowellstewart wants to merge 12 commits intoOpenXmlDev:vNextfrom
Conversation
(when converting DOCX content to Unicode strings)
(now that UnicodeMapper.RunToString supports it well enough to tell whether it's working or not!)
for test cases borrowed from OXPT fork sergey-tihon/Clippit. The bugs driving these cases were fixed independently (using quite different approaches in each fork) but I still wanted to capture the test cases.
* Merge Himanshu's fix into the repository: https://github.com/EricWhiteDev/Open-Xml-PowerTools/pull/15/files * Dispose opened stream * Fix similar bugs * Closed further leaks --------- Co-authored-by: Andrei Atanasiu <[email protected]> Co-authored-by: Markus Rudolph <[email protected]>
Old unit tests passed on .NET Framework but failed on .NET Core Improvement based in part on Codeuctivity/OpenXmlPowerTools
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This pull request aims to fix erroneous handling of
lastRenderedPageBreak elements are included in DOCX files by Word when it saves, I guess as a sort of temporary placeholder to indicate where Word's layout engine last broke content across pages when it laid out the file. They do not represent any part of the document content itself. However, the OpenXmlRegex code was unable to match regexes when the match happened to include one of these elements. I traced the problem back to the implementation of UnicodeMapper.RunToString, where I added some code to ignore these lastRenderedPageBreak elements, and added a unit test to check for proper handling.
Also, Word has a certain way of handling the xml:space attribute on elements, but most of the OpenXmlPowerTools seem to be ignoring that attribute and its meaning. I added a helper method to UnicodeMapper that aims to emulate Word's behavior when converting from XML elements -> Unicode text strings, and a unit test to assert/explain the behavior. I also added code (and a unit test) to DocumentAssembler, so when it inserts content that may begin or end with intentional whitespace, the whitespace actually shows up in the DOCX file (instead of being ignored as it was before).