Fix exception when updating drawing hyperlinks and fix ignored tooltips#2378
Open
lievendf wants to merge 1 commit into
Open
Fix exception when updating drawing hyperlinks and fix ignored tooltips#2378lievendf wants to merge 1 commit into
lievendf wants to merge 1 commit into
Conversation
84d26db to
f331367
Compare
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.
Summary
This PR fixes two bugs in
ExcelDrawing.cswhen working with hyperlinks on drawings (shapes, pictures, etc.):NullReferenceExceptionorInvalidOperationException) when changing an existing hyperlink to a new one.What was wrong?
The Exception:
When you changed a drawing's hyperlink, the setter tried to delete the old link using
ZipPackage.DeletePart(...). However, drawing hyperlinks are just XML relationships (.rels), not actual physical files inside the ZIP package. This caused an exception:NullReferenceException(because the target URI is null).InvalidOperationException: Part does not exist.The Tooltip Bug:
When writing the tooltip to the drawing's XML, the code checked
if (Hyperlink is ExcelHyperLink excelLink). At this point, the backing field hadn't been updated yet, soHyperlinkreturned the old hyperlink instead of the new one. This meant any new tooltip you set was ignored.How this PR fixes it
valueinstead of the oldHyperlinkproperty:Added Tests
Added a unit test
DrawingHyperlinkUpdate_ShouldNotThrowExceptioninHyperlinkTest.csthat: