/* * Except for code enclosed in "CUSTOM MODIFICATION", all code and comments below this point * were generated by the Open XML SDK 2.5 Productivity Tool which you can get from here: * https://www.microsoft.com/en-us/download/details.aspx?id=30425 */ // Adds child parts and generates content of the specified part. public static void CreateWebExTaskpanesPart(WebExTaskpanesPart part, string snippetID) { WebExtensionPart webExtensionPart1 = part.AddNewPart <WebExtensionPart>("rId1"); GenerateWebExtensionPart1Content(webExtensionPart1, snippetID); GeneratePartContent(part); }
/* * Except for code enclosed in "CUSTOM MODIFICATION", all code and comments below this point * were generated by the Open XML SDK 2.5 Productivity Tool which you can get from here: * https://www.microsoft.com/en-us/download/details.aspx?id=30425 */ // Adds child parts and generates content of the specified part. public static void CreateWebExTaskpanesPart(WebExTaskpanesPart part, string guid, string version) { WebExtensionPart webExtensionPart1 = part.AddNewPart <WebExtensionPart>("rId1"); GenerateWebExtensionPart1Content(webExtensionPart1, guid, version); GeneratePartContent(part); }
// Generates content of webExtensionPart1. private static void GenerateWebExtensionPart1Content(WebExtensionPart webExtensionPart1, string snippetID) { We.WebExtension webExtension1 = new We.WebExtension() { Id = "{635BF0CD-42CC-4174-B8D2-6D375C9A759E}" }; webExtension1.AddNamespaceDeclaration("we", "http://schemas.microsoft.com/office/webextensions/webextension/2010/11"); We.WebExtensionStoreReference webExtensionStoreReference1 = new We.WebExtensionStoreReference() { Id = "wa104380862", Version = "1.1.0.0", Store = "en-US", StoreType = "OMEX" }; We.WebExtensionReferenceList webExtensionReferenceList1 = new We.WebExtensionReferenceList(); We.WebExtensionPropertyBag webExtensionPropertyBag1 = new We.WebExtensionPropertyBag(); // Add the property that makes the taskpane visible. We.WebExtensionProperty webExtensionProperty1 = new We.WebExtensionProperty() { Name = "Office.AutoShowTaskpaneWithDocument", Value = "true" }; webExtensionPropertyBag1.Append(webExtensionProperty1); // CUSTOM MODIFICATION BEGIN // Add the property that specifies the snippet to import. string snippetToImportValue = string.Format("{{\"type\":\"gist\",\"id\":\"{0}\"}}", snippetID); We.WebExtensionProperty webExtensionProperty2 = new We.WebExtensionProperty() { Name = "SnippetToImport", Value = snippetToImportValue }; webExtensionPropertyBag1.Append(webExtensionProperty2); // CUSTOM MODIFICATION END We.WebExtensionBindingList webExtensionBindingList1 = new We.WebExtensionBindingList(); We.Snapshot snapshot1 = new We.Snapshot(); snapshot1.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships"); webExtension1.Append(webExtensionStoreReference1); webExtension1.Append(webExtensionReferenceList1); webExtension1.Append(webExtensionPropertyBag1); webExtension1.Append(webExtensionBindingList1); webExtension1.Append(snapshot1); webExtensionPart1.WebExtension = webExtension1; }
/// <summary> /// Walks the WebExtension element, invoking the delegates provided on all the Strings and Int32 values /// </summary> /// <param name="wep">WebExtensionPart the element to be walked</param> /// <param name="svCallback">StringValueFoo delegate to be called for StringValues</param> /// <param name="int32Callback">Int32ValueFoo delegate to be called for Int32Values</param> private void WalkWep(WebExtensionPart wep, TypedValueFoo <StringValue> svCallback, TypedValueFoo <Int32Value> int32Callback) { We.WebExtension we = wep.WebExtension; foreach (OpenXmlElement blipKid in we.Snapshot) { // Actually they say (obj.GetType() == typeof(ClassA)) is faster, but we are not in hurry here anyways if (blipKid is A.AlphaBiLevel) { A.AlphaBiLevel abl = blipKid as A.AlphaBiLevel; abl.Threshold = int32Callback(abl.Threshold); } else if (blipKid is A.AlphaCeiling) { } else if (blipKid is A.AlphaFloor) { } else if (blipKid is A.BlipExtensionList) { A.BlipExtensionList bel = blipKid as A.BlipExtensionList; foreach (A.BlipExtension be in bel) { be.Uri = svCallback(be.Uri); } // it's possible to try and access the childs of be, but these are OpenXmlUnknownElement // and it's not possible to modify them in an intelligent way. } } we.Id = svCallback(we.Id); foreach (We.WebExtensionBinding binding in we.WebExtensionBindingList) { binding.AppReference = svCallback(binding.AppReference); binding.Id = svCallback(binding.Id); // UF: how about the Type? } foreach (We.WebExtensionProperty prop in we.WebExtensionPropertyBag) { prop.Name = svCallback(prop.Name); prop.Value = svCallback(prop.Value); } { We.WebExtensionStoreReference refr = we.WebExtensionStoreReference; refr.Id = svCallback(refr.Id); refr.Store = svCallback(refr.Store); refr.StoreType = svCallback(refr.StoreType); refr.Version = svCallback(refr.Version); } foreach (We.WebExtensionStoreReference refr in we.WebExtensionReferenceList) { refr.Id = svCallback(refr.Id); refr.Store = svCallback(refr.Store); refr.StoreType = svCallback(refr.StoreType); refr.Version = svCallback(refr.Version); } }
/// <summary> /// Loads the DOM from the WebExtensionPart. /// </summary> /// <param name="openXmlPart">Specifies the part to be loaded.</param> public void Load(WebExtensionPart openXmlPart) { LoadFromPart(openXmlPart); }
internal WebExtension(WebExtensionPart ownerPart) : base(ownerPart) { }