소스 검색

Patch provided by Annika89

This patch adds support for images inside <v:shape> tags (besides the already supported images inside <w:drawing> tags). InsertDocument method no longer results in a corrupt/invalid document when an inserted document contains an image that is inside <v:shape> rather than <w:drawing> tags.
master
MadBoy_cp 12 년 전
부모
커밋
998c9f43e4
1개의 변경된 파일35개의 추가작업 그리고 0개의 파일을 삭제
  1. 35
    0
      DocX/DocX.cs

+ 35
- 0
DocX/DocX.cs 파일 보기

@@ -29,6 +29,8 @@ namespace Novacode
static internal XNamespace a = "http://schemas.openxmlformats.org/drawingml/2006/main";
static internal XNamespace c = "http://schemas.openxmlformats.org/drawingml/2006/chart";
static internal XNamespace v = "urn:schemas-microsoft-com:vml";
internal static XNamespace n = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering";
#endregion
@@ -1179,6 +1181,17 @@ namespace Novacode
embed.SetValue(new_Id);
}
}
// Replace all instances of remote_Id in the local document with local_Id (for shapes as well)
var v_elems = remote_mainDoc.Descendants(XName.Get("imagedata", DocX.v.NamespaceName));
foreach (var elem in v_elems)
{
XAttribute id = elem.Attribute(XName.Get("id", DocX.r.NamespaceName));
if (id != null && id.Value == remote_Id)
{
id.SetValue(new_Id);
}
}
}
break;
@@ -1224,6 +1237,17 @@ namespace Novacode
embed.SetValue(new_Id);
}
}
// Replace all instances of remote_Id in the local document with local_Id (for shapes as well)
var v_elems = remote_mainDoc.Descendants(XName.Get("imagedata", DocX.v.NamespaceName));
foreach (var elem in v_elems)
{
XAttribute id = elem.Attribute(XName.Get("id", DocX.r.NamespaceName));
if (id != null && id.Value == remote_Id)
{
id.SetValue(new_Id);
}
}
}
}
@@ -1602,6 +1626,17 @@ namespace Novacode
embed.SetValue(local_Id);
}
}
// Replace all instances of remote_Id in the local document with local_Id (for shapes as well)
var v_elems = remote_mainDoc.Descendants(XName.Get("imagedata", DocX.v.NamespaceName));
foreach (var elem in v_elems)
{
XAttribute id = elem.Attribute(XName.Get("id", DocX.r.NamespaceName));
if (id != null && id.Value == remote_Id)
{
id.SetValue(local_Id);
}
}
break;
}
}

Loading…
취소
저장