Browse Source

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 years ago
parent
commit
998c9f43e4
1 changed files with 35 additions and 0 deletions
  1. 35
    0
      DocX/DocX.cs

+ 35
- 0
DocX/DocX.cs View File

static internal XNamespace a = "http://schemas.openxmlformats.org/drawingml/2006/main"; 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 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"; internal static XNamespace n = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering";
#endregion #endregion
embed.SetValue(new_Id); 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; break;
embed.SetValue(new_Id); 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);
}
}
} }
} }
embed.SetValue(local_Id); 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; break;
} }
} }

Loading…
Cancel
Save