} //GetTableElement /// <summary> /// Get selected or parent table /// </summary> /// <returns>null if not found</returns> public HtmlTable GetTableElement() { // define the table and row elements and obtain there values HtmlTable table = null; HtmlTextRange range = SelectionHelper.GetTextRange(Document); // first see if the table element is selected table = SelectionHelper.GetFirstControl(Document) as HtmlTable; // if table not selected then parse up the selection tree if (table == null && range != null) { HtmlElement element = (HtmlElement)range.parentElement(); // parse up the tree until the table element is found while (element != null && table == null) { if (element is HtmlTable) { table = (HtmlTable)element; } element = (HtmlElement)element.parentElement; } } // return the defined table element return(table); }
// determine if the current selection is a table // return the table element private void GetTableElement(out HtmlTable table, out HtmlTableRow row, out HtmlTableCell cell) { table = null; row = null; cell = null; HtmlTextRange range = SelectionHelper.GetTextRange(Document); try { // first see if the table element is selected table = SelectionHelper.GetFirstControl(Document) as HtmlTable; // if table not selected then parse up the selection tree if (table == null && range != null) { HtmlElement element = (HtmlElement)range.parentElement(); // parse up the tree until the table element is found while (element != null && table == null) { if (element is HtmlTable) { table = (HtmlTable)element; } else if (element is HtmlTableRow) { row = (HtmlTableRow)element; } else if (element is HtmlTableCell) { cell = (HtmlTableCell)element; } element = (HtmlElement)element.parentElement; } } } catch (Exception) { // have unknown error so set return to null table = null; row = null; cell = null; } } //GetTableElement
public static bool IsPlaceholder(mshtml.IHTMLTxtRange rng, bool atomic = false) { if (rng == null) { return(false); } string unused; if (!ParsePlaceholder(rng.text, out unused)) { return(false); } if (!atomic) { return(true); } return(IsPlaceholder(rng.parentElement(), atomic)); }