Skip to content

Commit

Permalink
Merge pull request #90 from wangx036/main
Browse files Browse the repository at this point in the history
2个BUG修复
  • Loading branch information
shps951023 authored Nov 2, 2024
2 parents 3428cbd + b37b543 commit 57de2a5
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/MiniWord/MiniWord.Implment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ private static object GetObjVal(object objSource, string propNames)
/// <exception cref="Exception"></exception>
private static object GetObjVal(object objSource, string[] propNames)
{
if(objSource == null) return null;

var nextPropNames = propNames.Skip(1).ToArray();
if (objSource is IDictionary)
{
Expand Down Expand Up @@ -777,15 +779,17 @@ private static void ReplaceIfStatements(OpenXmlElement rootXmlElement, List<Open

for (int i = paragraphIfIndex + 1; i <= paragraphEndIfIndex - 1; i++)
{
if(rootXmlElement.ChildElements.Any(c=>c == elementList[i])) rootXmlElement.RemoveChild(elementList[i]);
elementList[i].Remove();
}
}
if(rootXmlElement.ChildElements.Any(c => c == ifP))
rootXmlElement.RemoveChild(ifP);
if (rootXmlElement.ChildElements.Any(c => c == endIfP))
rootXmlElement.RemoveChild(endIfP);
// 从paragraphs中移除,防止死循环
paragraphs.Remove(ifP);
paragraphs.Remove(endIfP);
// 从doc元素移除
if (ifP.Parent != null)
ifP.Remove();
if (endIfP.Parent != null)
endIfP.Remove();
}
}

Expand Down

0 comments on commit 57de2a5

Please sign in to comment.