8 using System.Diagnostics;
9 using System.Globalization;
11 using System.Runtime.Serialization.Formatters.Binary;
14 using Microsoft.Office.Core;
15 using Microsoft.Office.Interop.Word;
34 Log.Debug(
string.Format(CultureInfo.InvariantCulture,
"ControlsStorage - Store : controls count {0}", controls.Length));
37 using (MemoryStream memStream =
new MemoryStream())
39 BinaryFormatter formatter =
new BinaryFormatter();
40 formatter.Serialize(memStream, controls);
42 XmlDocument doc =
new XmlDocument();
44 doc.AppendChild(root);
47 controlsDataNode.InnerXml = Convert.ToBase64String(memStream.GetBuffer(), 0, (int) memStream.Length);
48 root.AppendChild(controlsDataNode);
56 Debug.Assert(parts.Count == 1);
60 document.CustomXMLParts.Add(xml, Type.Missing);
69 Log.Debug(
string.Format(CultureInfo.InvariantCulture,
"ControlsStorage - Load : document {0}", document));
74 if (parts !=
null && parts.Count > 0)
76 Debug.Assert(parts.Count == 1);
77 CustomXMLPart part = parts[1];
78 XmlDocument doc =
new XmlDocument();
79 doc.LoadXml(part.XML);
81 XmlNamespaceManager nsmgr =
new XmlNamespaceManager(doc.NameTable);
84 XmlElement controlsElement =
85 doc.SelectSingleNode(String.Format(CultureInfo.CurrentUICulture,
"//sc:{0}",
ControlsNodeName),
87 if (controlsElement !=
null)
89 byte[] data = Convert.FromBase64String(controlsElement.InnerXml);
90 BinaryFormatter formatter =
new BinaryFormatter();
Class that stores a list of property values for a saved control.
const string ControlsStorageNamespace
const string RootNodeName
static void Store(_Document document, ControlProperties[] controls)
static ControlProperties [] Load(_Document document)
const string ControlsNodeName