public Node(StyleAttributes styleAttributes) { firstChild = null; lastChild = null; nextSibling = null; prevSibling = null; parent_ = null; upperNode = null; lowerNode = null; glyph = null; namespaceURI = ""; isVisible = true; isGlyph = false; skip = false; literalCaret = 0; literalStart = 0; isAppend = false; fontFamily = ""; tokenType = Tokens.ID; yOffset = 0; displayStyle = false; scriptLevel_ = 0; style_ = null; literalText = ""; type_ = null; attrs = null; tagDeleted = false; if (styleAttributes != null) { style_ = new StyleAttributes(); styleAttributes.CopyTo(style_); } }
public void SetStyle(StyleAttributes styleAttributes) { if (style_ == null) { style_ = new StyleAttributes(); } styleAttributes.CopyTo(style_); style_.canOverride = true; if (HasChildren()) { NodesList list = GetChildrenNodes(); for (Node child = list.Next(); child != null; child = list.Next()) { if (child.type_.type != ElementType.Entity) { child.SetStyle(styleAttributes); } } } }
public StyleAttributes CascadeOverride(StyleAttributes baseAttrs) { StyleAttributes own = null; StyleAttributes result = null; if (baseAttrs != null) { result = new StyleAttributes(); baseAttrs.CopyTo(result); } own = style_; if (own != null) { if (result == null) { result = new StyleAttributes(); own.CopyTo(result); return result; } if (!own.canOverride) { return result; } if (own.displayStyle != DisplayStyle.AUTOMATIC) { result.displayStyle = own.displayStyle; } if (own.scriptLevel != ScriptLevel.NONE) { result.scriptLevel = own.scriptLevel; } if (own.hasColor) { result.color = own.color; result.hasColor = true; } if (own.hasBackground) { result.background = own.background; result.hasBackground = true; } if (own.hasSize) { result.scale = own.scale; result.size = own.size; result.hasSize = true; } if (own.IsStyled) { result.isBold = own.isBold; result.isItalic = own.isItalic; } result.isUnderline = false; if (own.isNormal) { result.isNormal = true; } if (own.isScript) { result.isScript = true; } if (own.isSans) { result.isSans = true; } if (own.isFractur) { result.isFractur = true; } if (own.isDoubleStruck) { result.isDoubleStruck = true; } if (own.isMonospace) { result.isMonospace = true; } } return result; }
public Node ParseMstyle(XmlNode XMLNode, Types mTypes, EntityManager mEntities, bool bAll, StyleAttributes styleAttributes) { StyleAttributes s = null; if ((XMLNode.Attributes == null) || (XMLNode.Attributes.Count <= 0)) { return Parse(XMLNode, mTypes, mEntities, bAll, styleAttributes, true); } Node node = new Node(); node.type_ = mTypes["mstyle"]; node.attrs = new AttributeList(); for (int i = 0; i < XMLNode.Attributes.Count; i++) { node.attrs.Add(new Attribute(XMLNode.Attributes[i].Name, XMLNode.Attributes[i].Value, "")); } StyleAttributes fromNode = new StyleAttributes(); s = new StyleAttributes(); fromNode = AttributeBuilder.StyleAttrsFromNode(node, true); if (fromNode != null) { if (styleAttributes != null) { node.style_ = new StyleAttributes(); fromNode.CopyTo(node.style_); node.style_.canOverride = true; s = node.CascadeOverride(styleAttributes); } else { fromNode.CopyTo(s); } } else { if (styleAttributes != null) styleAttributes.CopyTo(s); } s.canOverride = true; XMLNode.Attributes.RemoveAll(); return Parse(XMLNode, mTypes, mEntities, bAll, s, true); }