private void AddFont(string fontname)
{
try
{
Assembly ass = Assembly.GetExecutingAssembly();
Stream stream = ass.GetManifestResourceStream("AODL.Resources.OD.fonts.xml");
XmlDocument fontdoc = new XmlDocument();
fontdoc.Load(stream);
XmlNode exfontnode = this.XmlDoc.SelectSingleNode(
"/office:document-content/office:font-face-decls/style:font-face[@style:name='"+fontname+"']", this.NamespaceManager);
if (exfontnode != null)
return; //Font exist;
XmlNode newfontnode = fontdoc.SelectSingleNode(
"/office:document-content/office:font-face-decls/style:font-face[@style:name='"+fontname+"']", this.NamespaceManager);
if (newfontnode != null)
{
XmlNode fontsnode = this.XmlDoc.SelectSingleNode(
"/office:document-content", this.NamespaceManager);
if (fontsnode != null)
{
foreach(XmlNode xn in fontsnode)
if (xn.Name == "office:font-face-decls")
{
XmlNode node = this.CreateNode("font-face", "style");
foreach(XmlAttribute xa in newfontnode.Attributes)
{
XmlAttribute xanew = this.CreateAttribute(xa.LocalName, xa.Prefix);
xanew.Value = xa.Value;
node.Attributes.Append(xanew);
}
xn.AppendChild(node);
break;
}
}
}
}
catch(Exception)
{
//Should never happen
throw;
}
}