public AssociationNode(WordDocument doc, string guid, string name, string endName, string endMP, string associationType, string connectionType) { IsRemained = true; AssociationGUID = guid; AssociationConnectionType = connectionType; _doc = doc; AssociationXmlNode = WordHelpers.CreateCustomNode(doc, Definitions.CLASS_ASSOC_SECTION, guid, connectionType); XmlNode assocNameNode = WordHelpers.CreateCustomNode(doc, Definitions.CLASS_ASSOC_NAME); if (associationType.Equals(Constants.Association)) assocNameNode.AppendChild(WordHelpers.CreateTextChildNode(doc, Definitions.CLASS_ASSOC_NAME_PREFIX, name, Definitions.CLASS_ASSOC_NAME)); else assocNameNode.AppendChild(WordHelpers.CreateTextChildNode(doc, Definitions.CLASS_COMPOSITION_NAME_PREFIX, name, Definitions.CLASS_ASSOC_NAME)); AssociationXmlNode.AppendChild(assocNameNode); XmlNode assocDescrNode = WordHelpers.CreateCustomNode(doc, Definitions.CLASS_ASSOC_DESCR); assocDescrNode.AppendChild(WordHelpers.CreateTextChildNode(doc, Definitions.CLASS_ASSOC_DESCR_PREFIX, string.Empty, Definitions.CLASS_ASSOC_DESCR)); AssociationXmlNode.AppendChild(assocDescrNode); XmlNode assocNameEndNode = WordHelpers.CreateCustomNode(doc, Definitions.CLASS_ASSOC_NAME_END); assocNameEndNode.AppendChild(WordHelpers.CreateTextChildNode(doc, Definitions.CLASS_ASSOC_NAME_END_PREFIX, endName, Definitions.CLASS_ASSOC_NAME_END)); AssociationXmlNode.AppendChild(assocNameEndNode); XmlNode assocMultNode = WordHelpers.CreateCustomNode(doc, Definitions.CLASS_ASSOC_MULT); assocMultNode.AppendChild(WordHelpers.CreateTextChildNode(doc, Definitions.CLASS_ASSOC_MULT_PREFIX, endMP, Definitions.CLASS_ASSOC_MULT)); AssociationXmlNode.AppendChild(assocMultNode); XmlNode assocTypeNode = WordHelpers.CreateCustomNode(doc, Definitions.CLASS_ASSOC_TYPE); assocTypeNode.AppendChild(WordHelpers.CreateTextChildNode(doc, Definitions.CLASS_ASSOC_TYPE_PREFIX, associationType, Definitions.CLASS_ASSOC_TYPE)); AssociationXmlNode.AppendChild(assocTypeNode); }
public AssociationNode(WordDocument doc, XmlNode node) { IsRemained = false; AssociationXmlNode = node; _doc = doc; XmlNode property = WordHelpers.GetCustomXmlPropertyNode(node); if (property != null) { foreach (XmlNode attribute in property.ChildNodes) { if (attribute.Attributes[0].Value.Equals(Definitions.ATTR_GUID)) { AssociationGUID = attribute.Attributes[1].Value; } else if (attribute.Attributes[0].Value.Equals(Definitions.ATTR_CONNECTION_TYPE)) { AssociationConnectionType = attribute.Attributes[1].Value; } } } else { throw new BadCustomXml(); } }
public static XmlNode CreateCustomNode(WordDocument doc, string elementName, int id) { XmlNode customNode = doc.CreateNode(XmlNodeType.Element, "w:customXml", Definitions.WORD_PROCESSING_ML); XmlAttribute attr = doc.CreateAttribute("w:element", Definitions.WORD_PROCESSING_ML); attr.Value = elementName; customNode.Attributes.Append(attr); attr = doc.CreateAttribute("w:object_id", Definitions.WORD_PROCESSING_ML); attr.Value = id.ToString(); customNode.Attributes.Append(attr); return customNode; }
public static XmlNode CreateTextChildNode(WordDocument doc, string text) { XmlElement tagParagraph = doc.CreateElement("w:p", Definitions.WORD_PROCESSING_ML); XmlElement tagRun = doc.CreateElement("w:r", Definitions.WORD_PROCESSING_ML); tagParagraph.AppendChild(tagRun); XmlElement tagText = doc.CreateElement("w:t", Definitions.WORD_PROCESSING_ML); tagRun.AppendChild(tagText); XmlNode nodeText = doc.CreateNode(XmlNodeType.Text, "w:t", Definitions.WORD_PROCESSING_ML); nodeText.Value = text; tagText.AppendChild(nodeText); return tagParagraph; }
public AttributeNode(WordDocument doc, string attribute) { AttrName = attribute; AttributeXMLNode = WordHelpers.CreateCustomNode(doc, Definitions.CLASS_ATTR_SECTION); XmlNode attrNameNode = WordHelpers.CreateCustomNode(doc, Definitions.CLASS_ATTR_NAME); attrNameNode.AppendChild(WordHelpers.CreateTextChildNode(doc, Definitions.CLASS_ATTR_NAME_PREFIX, attribute, Definitions.CLASS_ATTR_NAME)); AttributeXMLNode.AppendChild(attrNameNode); XmlNode attrDescrNode = WordHelpers.CreateCustomNode(doc, Definitions.CLASS_ATTR_DESCR); attrDescrNode.AppendChild(WordHelpers.CreateTextChildNode(doc, Definitions.CLASS_ATTR_NAME_DESCR_PREFIX, string.Empty, Definitions.CLASS_ATTR_DESCR)); AttributeXMLNode.AppendChild(attrDescrNode); }
public AttributeNode(WordDocument doc, XmlNode node) { AttributeXMLNode = node; if (node.ChildNodes.Count > 0) { string attrString = WordHelpers.CalcText(WordHelpers.GetCustomChild(AttributeXMLNode, Definitions.CLASS_ATTR_NAME), Definitions.CLASS_ATTR_NAME_PREFIX); if (attrString != null && attrString.Contains(Definitions.CLASS_ATTR_NAME_PREFIX) && attrString.Length > Definitions.CLASS_ATTR_NAME_PREFIX.Length) { AttrName = attrString.Substring(Definitions.CLASS_ATTR_NAME_PREFIX.Length); return; } else { throw new BadCustomXml(); } } }