浏览代码

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;
}
}

正在加载...
取消
保存