public CssSpacingBox(CssBox tableBox, ref CssBox extendedBox, int startRow) : base(tableBox, new HtmlTag("none", false, new Dictionary<string, string> { { "colspan", "1" } })) { _extendedBox = extendedBox; Display = CssConstants.None; _startRow = startRow; _endRow = startRow + Int32.Parse(extendedBox.GetAttribute("rowspan", "1")) - 1; }
/// <summary> /// Gets the span attribute of the tag of the specified box /// </summary> /// <param name="b"></param> private static int GetSpan(CssBox b) { double f = CssValueParser.ParseNumber(b.GetAttribute("span"), 1); return Math.Max(1, Convert.ToInt32(f)); }
/// <summary> /// Gets the rowspan of the specified box /// </summary> /// <param name="b"></param> private static int GetRowSpan(CssBox b) { string att = b.GetAttribute("rowspan", "1"); int rowspan; if (!int.TryParse(att, out rowspan)) { return 1; } return rowspan; }
/// <summary> /// Gets the colspan of the specified box /// </summary> /// <param name="b"></param> private static int GetColSpan(CssBox b) { string att = b.GetAttribute("colspan", "1"); int colspan; if (!int.TryParse(att, out colspan)) { return 1; } return colspan; }
/// <summary> /// returns the box with the attribute "clickable" that has been clicked /// </summary> /// <param name="box"></param> /// <param name="location"></param> /// <returns></returns> public static CssBox SearchClickedBox(CssBox box, RPoint location) { if (box != null) { if (box.GetAttribute("clickable") != "" && box.ClientRectangle.Contains(location)) return box; if (box.ClientRectangle.IsEmpty || box.ClientRectangle.Contains(location)) { foreach (var childBox in box.Boxes) { var foundBox = SearchClickedBox(childBox, location); if (foundBox != null) return foundBox; } } } return null; }
/// <summary> /// Get attribute value by given key starting search from given box, search up the tree until /// attribute found or root. /// </summary> /// <param name="box">the box to start lookup at</param> /// <param name="attribute">the attribute to get</param> /// <returns>the value of the attribute or null if not found</returns> public static string GetAttribute(CssBox box, string attribute) { string value = null; while (box != null && value == null) { value = box.GetAttribute(attribute, null); box = box.ParentBox; } return value; }