Skip to content

Commit

Permalink
#45: fixes (int)null cast in SetImage
Browse files Browse the repository at this point in the history
  • Loading branch information
dgwaldo authored Apr 16, 2024
1 parent 77b52f0 commit 28206cb
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions OpenXMLTemplates/ControlReplacers/ControlReplacer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -245,12 +245,14 @@ protected static void SetImage(OpenXmlElement element, string newValue, Wordproc
return;

var index = 0;
try
{
index = (int)variableSource.GetVariable("index");
}
catch (VariableNotFoundException)
try
{
var vsIndex = variableSource.GetVariable("index");
if (vsIndex != null)
{
index = (int)vsIndex;
}
} catch (VariableNotFoundException) {
}

var tagName = element.First().GetFirstChild<Tag>().Val.Value;
Expand Down Expand Up @@ -321,4 +323,4 @@ protected virtual void OnInnerControlReplacementEnqueued(ControlReplacementExecu

#endregion
}
}
}

0 comments on commit 28206cb

Please sign in to comment.