/// <summary> /// Stuff required to create XPath element /// (except for ID, which this method generates) /// </summary> /// <param name="xpath"></param> /// <param name="storeItemID"></param> /// <param name="prefixMappings"></param> /// <param name="questionID"></param> public static xpathsXpath updateXPathsPart( Office.CustomXMLPart xpathsPart, string xpath, string xpathId, string storeItemID, string prefixMappings, string questionID) { //Office.CustomXMLPart xpathsPart = ((WedTaskPane)this.Parent.Parent.Parent).xpathsPart; xpaths xpaths = new xpaths(); xpaths.Deserialize(xpathsPart.XML, out xpaths); xpathsXpath item = new xpathsXpath(); item.id = xpathId; //System.Guid.NewGuid().ToString(); if (!string.IsNullOrWhiteSpace(questionID)) item.questionID = questionID; xpathsXpathDataBinding db = new xpathsXpathDataBinding(); db.xpath = xpath; db.storeItemID = storeItemID; if (!string.IsNullOrWhiteSpace(prefixMappings)) db.prefixMappings = prefixMappings; item.dataBinding = db; xpaths.xpath.Add(item); // Save it in docx string result = xpaths.Serialize(); log.Info(result); CustomXmlUtilities.replaceXmlDoc(xpathsPart, result); return item; }
public xpathsXpath createXpath( string xpath, string xpathId, string storeItemID, string prefixMappings, string questionID) { xpathsXpath item = new xpathsXpath(); item.id = xpathId; //System.Guid.NewGuid().ToString(); if (!string.IsNullOrWhiteSpace(questionID)) { item.questionID = questionID; } xpathsXpathDataBinding db = new xpathsXpathDataBinding(); db.xpath = xpath; db.storeItemID = storeItemID; if (!string.IsNullOrWhiteSpace(prefixMappings)) { db.prefixMappings = prefixMappings; } item.dataBinding = db; xpaths.xpath.Add(item); return(item); }
public override bool Equals(object obj) { xpathsXpathDataBinding other = obj as xpathsXpathDataBinding; return((other.xpathField.Equals(this.xpathField)) && (other.storeItemIDField.Equals(this.storeItemIDField)) && (other.prefixMappingsField.Equals(this.prefixMappingsField))); }
/// <summary> /// Deserializes xml markup from file into an xpathsXpathDataBinding object /// </summary> /// <param name="fileName">string xml file to load and deserialize</param> /// <param name="obj">Output xpathsXpathDataBinding object</param> /// <param name="exception">output Exception value if deserialize failed</param> /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns> public static bool LoadFromFile(string fileName, out xpathsXpathDataBinding obj, out System.Exception exception) { exception = null; obj = default(xpathsXpathDataBinding); try { obj = LoadFromFile(fileName); return(true); } catch (System.Exception ex) { exception = ex; return(false); } }
/// <summary> /// Deserializes workflow markup into an xpathsXpathDataBinding object /// </summary> /// <param name="xml">string workflow markup to deserialize</param> /// <param name="obj">Output xpathsXpathDataBinding object</param> /// <param name="exception">output Exception value if deserialize failed</param> /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns> public static bool Deserialize(string xml, out xpathsXpathDataBinding obj, out System.Exception exception) { exception = null; obj = default(xpathsXpathDataBinding); try { obj = Deserialize(xml); return(true); } catch (System.Exception ex) { exception = ex; return(false); } }
/// <summary> /// Stuff required to create XPath element /// (except for ID, which this method generates) /// </summary> /// <param name="xpath"></param> /// <param name="storeItemID"></param> /// <param name="prefixMappings"></param> /// <param name="questionID"></param> public static xpathsXpath updateXPathsPart( Office.CustomXMLPart xpathsPart, string xpath, string xpathId, string storeItemID, string prefixMappings, string questionID) { //Office.CustomXMLPart xpathsPart = ((WedTaskPane)this.Parent.Parent.Parent).xpathsPart; xpaths xpaths = new xpaths(); xpaths.Deserialize(xpathsPart.XML, out xpaths); xpathsXpath item = new xpathsXpath(); item.id = xpathId; //System.Guid.NewGuid().ToString(); if (!string.IsNullOrWhiteSpace(questionID)) { item.questionID = questionID; } xpathsXpathDataBinding db = new xpathsXpathDataBinding(); db.xpath = xpath; db.storeItemID = storeItemID; if (!string.IsNullOrWhiteSpace(prefixMappings)) { db.prefixMappings = prefixMappings; } item.dataBinding = db; xpaths.xpath.Add(item); // Save it in docx string result = xpaths.Serialize(); log.Info(result); CustomXmlUtilities.replaceXmlDoc(xpathsPart, result); return(item); }
public xpathsXpath createXpath( string xpath, string xpathId, string storeItemID, string prefixMappings, string questionID) { xpathsXpath item = new xpathsXpath(); item.id = xpathId; //System.Guid.NewGuid().ToString(); if (!string.IsNullOrWhiteSpace(questionID)) item.questionID = questionID; xpathsXpathDataBinding db = new xpathsXpathDataBinding(); db.xpath = xpath; db.storeItemID = storeItemID; if (!string.IsNullOrWhiteSpace(prefixMappings)) db.prefixMappings = prefixMappings; item.dataBinding = db; xpaths.xpath.Add(item); return item; }
public static bool LoadFromFile(string fileName, out xpathsXpathDataBinding obj) { System.Exception exception = null; return LoadFromFile(fileName, out obj, out exception); }
/// <summary> /// Deserializes xml markup from file into an xpathsXpathDataBinding object /// </summary> /// <param name="fileName">string xml file to load and deserialize</param> /// <param name="obj">Output xpathsXpathDataBinding object</param> /// <param name="exception">output Exception value if deserialize failed</param> /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns> public static bool LoadFromFile(string fileName, out xpathsXpathDataBinding obj, out System.Exception exception) { exception = null; obj = default(xpathsXpathDataBinding); try { obj = LoadFromFile(fileName); return true; } catch (System.Exception ex) { exception = ex; return false; } }
public static bool Deserialize(string xml, out xpathsXpathDataBinding obj) { System.Exception exception = null; return Deserialize(xml, out obj, out exception); }
/// <summary> /// Deserializes workflow markup into an xpathsXpathDataBinding object /// </summary> /// <param name="xml">string workflow markup to deserialize</param> /// <param name="obj">Output xpathsXpathDataBinding object</param> /// <param name="exception">output Exception value if deserialize failed</param> /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns> public static bool Deserialize(string xml, out xpathsXpathDataBinding obj, out System.Exception exception) { exception = null; obj = default(xpathsXpathDataBinding); try { obj = Deserialize(xml); return true; } catch (System.Exception ex) { exception = ex; return false; } }
public xpathsXpath() { this.dataBindingField = new xpathsXpathDataBinding(); }
public static bool LoadFromFile(string fileName, out xpathsXpathDataBinding obj) { System.Exception exception = null; return(LoadFromFile(fileName, out obj, out exception)); }
public static bool Deserialize(string xml, out xpathsXpathDataBinding obj) { System.Exception exception = null; return(Deserialize(xml, out obj, out exception)); }
public xpathsXpath() { this.dataBindingField = new xpathsXpathDataBinding(); }
/// <summary> /// Create OpenDoPE parts, including optionally, question part. /// </summary> public void process() { Microsoft.Office.Interop.Word.Document document = null; try { document = Globals.ThisAddIn.Application.ActiveDocument; } catch (Exception ex) { Mbox.ShowSimpleMsgBoxError("No document is open/active. Create or open a docx first."); return; } Model model = Model.ModelFactory(document); // Button shouldn't be available if this exists, // but .. if (model.conditionsPart == null) { conditions conditions = new conditions(); string conditionsXml = conditions.Serialize(); model.conditionsPart = addCustomXmlPart(document, conditionsXml); } if (model.componentsPart == null) { components components = new components(); string componentsXml = components.Serialize(); model.componentsPart = addCustomXmlPart(document, componentsXml); } // Add XPath xpaths xpaths = new xpaths(); // Button shouldn't be available if this exists, // but .. if (model.xpathsPart != null) { xpaths.Deserialize(model.xpathsPart.XML, out xpaths); } int idInt = 1; foreach (Word.ContentControl cc in Globals.ThisAddIn.Application.ActiveDocument.ContentControls) { if (cc.XMLMapping.IsMapped) { log.Debug("Adding xpath for " + cc.ID); // then we need to add an XPath string xmXpath = cc.XMLMapping.XPath; xpathsXpath item = new xpathsXpath(); // I make no effort here to check whether the xpath // already exists, since the part shouldn't already exist! item.id = "x" + idInt; xpathsXpathDataBinding db = new xpathsXpathDataBinding(); db.xpath = xmXpath; db.storeItemID = cc.XMLMapping.CustomXMLPart.Id; if (!string.IsNullOrWhiteSpace(cc.XMLMapping.PrefixMappings)) db.prefixMappings = cc.XMLMapping.PrefixMappings; item.dataBinding = db; xpaths.xpath.Add(item); // Write tag TagData td = new TagData(cc.Tag); td.set("od:xpath", item.id); cc.Tag = td.asQueryString(); log.Debug(".. added for " + cc.ID); idInt++; } } string xpathsXml = xpaths.Serialize(); if (model.xpathsPart == null) { model.xpathsPart = addCustomXmlPart(document, xpathsXml); } else { CustomXmlUtilities.replaceXmlDoc(model.xpathsPart, xpathsXml); } Microsoft.Office.Tools.Word.Document extendedDocument = Globals.ThisAddIn.Application.ActiveDocument.GetVstoObject(Globals.Factory); //Microsoft.Office.Tools.CustomTaskPane ctp // = Globals.ThisAddIn.createCTP(document, cxp, xpathsPart, conditionsPart, questionsPart, componentsPart); //extendedDocument.Tag = ctp; //// Want a 2 way association //WedTaskPane wedTaskPane = (WedTaskPane)ctp.Control; //wedTaskPane.associatedDocument = document; //extendedDocument.Shutdown += new EventHandler( // Globals.ThisAddIn.extendedDocument_Shutdown); //taskPane.setupCcEvents(document); log.Debug("Done. Task pane now also open."); }