public override bool Compare(IAttributeBag attributeBag) { ElementAttributeBag elementAttributeBag = (ElementAttributeBag)attributeBag; IHTMLElement element = elementAttributeBag.IHTMLElement; if (IsTextContainedIn(element.innerText)) { // Get all elements and filter this for TableCells IHTMLTableRow tableRowElement = (IHTMLTableRow)element; IHTMLElementCollection tableCellElements = tableRowElement.cells; if (tableCellElements.length - 1 >= columnIndex) { IHTMLTableCell tableCell = (IHTMLTableCell)tableCellElements.item(columnIndex, null); ICompareElement elementComparer = comparer as ICompareElement; if (elementComparer != null) { return(elementComparer.Compare(new TableCell(elementAttributeBag.DomContainer, tableCell))); } return(base.Compare(new ElementAttributeBag(elementAttributeBag.DomContainer, (IHTMLElement)tableCell))); } } return(false); }
public static void SynchronizeCellWidthForEditing(IHTMLTableCell cell) { if (GetCellWidth(cell) != ((cell as IHTMLElement).offsetWidth)) { cell.width = (cell as IHTMLElement).offsetWidth; } }
/// <summary> /// Get the column of the current cell /// zero based /// </summary> /// <param name="cell"></param> /// <returns></returns> public int GetColIndex(IHTMLTableCell cell) { if (cell == null) { return(0); } int iret = 0; IHTMLTableCell tcell = cell; IHTMLDOMNode node = null; IHTMLElement elem = null; while (true) { node = tcell as IHTMLDOMNode; if (node == null) { break; } elem = PreviousSibling(node); if (elem == null) { break; } tcell = elem as IHTMLTableCell; if (tcell == null) { break; } iret += tcell.colSpan; } return(iret); }
public void Initialize( IHTMLTableCell cell) { Text = Resources.Str_UIHtml_CellProperties; _cells.Add(cell); }
/// <summary> /// Deletes the cell that the user has selected in the designer /// </summary> public void DeleteSelectedCell() { if (this.GetSelectedTableCell() != null) { IHTMLTableCell selectedCell = this.GetSelectedTableCellElement(); IHTMLTableRow selectedRow = (selectedCell as IHTMLElement).parentElement as IHTMLTableRow; selectedRow.deleteCell(selectedCell.cellIndex); } }
/// <summary> /// Inserts a new cell in the selected table /// </summary> public void InsertCell() { IHTMLTableCell selectedCell = this.GetSelectedTableCellElement(); if (selectedCell != null) { IHTMLTableRow row = (selectedCell as IHTMLElement).parentElement as IHTMLTableRow; row.insertCell().innerHTML = " "; } }
public void ProcessCell(IHTMLTableCell cell) { if (_width > 0 && _width.Units != PixelPercentUnits.Undefined) { cell.width = _width.ToString(CultureInfo.InvariantCulture); } else { (cell as IHTMLElement).removeAttribute("width", 0); } }
public void ProcessCell(IHTMLTableCell cell) { if (_width > 0) { cell.width = _width.ToString(CultureInfo.InvariantCulture); } else { (cell as IHTMLElement).removeAttribute("width", 0); } }
private void ProcessColumnCells(IColumnCellProcessor cellProcessor) { // set the specified alignment for each cell in the column foreach (IHTMLTableRow row in _table.rows) { if (row.cells.length > Index) { IHTMLTableCell cell = row.cells.item(Index, Index) as IHTMLTableCell; cellProcessor.ProcessCell(cell); } } }
/// <summary> /// Changes a single property of a cell /// </summary> /// <param name="cell">The cell to modify</param> /// <param name="propertyName">The property to change</param> /// <param name="newValue">The new value of the property</param> public void ChangeCellProperty(IHTMLTableCell cell, CellProperties propertyName, string newValue) { IHTMLElement cellElement = cell as IHTMLElement;; if (cellElement != null) { switch (propertyName) { case CellProperties.BackgroundColor: cellElement.style.backgroundColor = newValue; break; case CellProperties.BorderColor: cellElement.style.borderColor = newValue; break; case CellProperties.BorderSize: if (newValue != null) { cellElement.style.borderWidth = newValue; } break; case CellProperties.Height: if (newValue != null) { cellElement.style.height = newValue; } break; case CellProperties.Width: if (newValue != null) { cellElement.style.width = newValue; } break; case CellProperties.Rowspan: if (newValue != null) { cell.rowSpan = int.Parse(newValue); } break; case CellProperties.Colspan: if (newValue != null) { cell.colSpan = int.Parse(newValue); } break; } } }
public IHTMLElement Row_InsertCol(IHTMLTableRow row, int index) { int col = 0; int span = 0; object obj = 0; IHTMLElementCollection cells = row.cells; IHTMLElement retelem = null; for (int i = 0; true; i++) { obj = i; IHTMLTableCell cell = cells.item(obj, obj) as IHTMLTableCell; if (cell == null) // insert behind the rightmost cell { retelem = Row_InsertCell(row, i); break; } span = cell.colSpan; if (span == col) // insert at the left of the specified cell { retelem = Row_InsertCell(row, i); break; } if ((index > col) && (index < (col + span))) { cell.colSpan = span + 1; // increase cellspan of multi column cell retelem = cell as IHTMLElement; break; } col += span; retelem = null; } //Set width as evenly as possible CalculateCellWidths(cells.length); for (int i = 0; i < cells.length; i++) { obj = i; IHTMLTableCell cell = cells.item(obj, obj) as IHTMLTableCell; if (cell != null) { if ((i + 1) == cells.length) { cell.width = m_lastcellwidth; } else { cell.width = m_cellwidth; } } } return(retelem); }
public void Row_DeleteCol(IHTMLTableRow row, int index) { int col = 0; int span = 0; IHTMLTableCell cell = Row_GetCell(row, 0); IHTMLElement elem = null; while (true) { if (cell == null) { return; } span = cell.colSpan; //cell.cellIndex if (span == 1) { if (col == index) { RemoveNode(cell as IHTMLElement, true); if (Row_GetCellCount(row) == 0) { IHTMLTable table = GetParentTable(row as IHTMLElement) as IHTMLTable; if (table != null) { RemoveNode(table as IHTMLElement, true); } break; } } } else if (span > 1)// cell spans about multiple columns { if (index >= col && index < col + span) { cell.colSpan = span - 1; // reduce cellspan break; } } col += span; //Get next sibiling elem = NextSibiling(cell as IHTMLDOMNode); if (elem != null) { cell = elem as IHTMLTableCell; } else { cell = null; } } }
private void FillTable(IHTMLTable table) { foreach (var r in table.rows) { IHTMLTableRow row = r as IHTMLTableRow; foreach (var c in row.cells) { IHTMLTableCell cell = c as IHTMLTableCell; IHTMLElement elem = c as IHTMLElement; elem.innerText = "r" + row.rowIndex + "c" + cell.cellIndex; } } }
public void ProcessCell(IHTMLTableCell cell) { // mixed means leave the cells alone if (!_backgroundColor.IsMixed) { if (_backgroundColor.Color != Color.Empty) { cell.bgColor = ColorHelper.ColorToString(_backgroundColor.Color); } else { (cell as IHTMLElement).removeAttribute("bgcolor", 0); } } }
public void ProcessCell(IHTMLTableCell cell) { // mixed means leave the cells alone if (_alignment != HorizontalAlignment.Mixed) { if (_alignment != HorizontalAlignment.Left) { cell.align = TableHelper.GetHtmlAlignmentForAlignment(_alignment); } else { (cell as IHTMLElement).removeAttribute("align", 0); } } }
public void ProcessCell(IHTMLTableCell cell) { // mixed means leave the cells alone if (_alignment != VerticalAlignment.Mixed) { if (_alignment != VerticalAlignment.Middle) { cell.vAlign = TableHelper.GetHtmlAlignmentForVAlignment(_alignment); } else { (cell as IHTMLElement).removeAttribute("valign", 0); } } }
private void FindCellRange(MarkupRange selectedRange, out ArrayList selectedCells, out IHTMLTableCell beginCell, out IHTMLTableCell endCell) { // default to null beginCell = null; endCell = null; selectedCells = new ArrayList(); // JJA: fix bug #476623 -- at document initialization the selected markup range // may not yet be positioned so protect ourselves in this case if (!selectedRange.Positioned) { return; } // query for all of the table cells within the range selectedCells.AddRange(selectedRange.GetElements(ElementFilters.TABLE_CELL_ELEMENT, false)); // extract the begin and end cells if (selectedCells.Count == 0) { // see if the selection is contained within a single cell beginCell = selectedRange.Start.GetParentElement(ElementFilters.TABLE_CELL_ELEMENT) as IHTMLTableCell; if (beginCell != null) { // make sure the cell is content editable (it would not be in the case // where the call to GetParentElement went all the way out of the body // and found a cell that was part of the containing template) if (!(beginCell as IHTMLElement3).isContentEditable) { beginCell = null; } } endCell = beginCell; selectedCells.Add(beginCell); } else if (selectedCells.Count == 1) { beginCell = selectedCells[0] as IHTMLTableCell; endCell = selectedCells[0] as IHTMLTableCell; } else { beginCell = selectedCells[0] as IHTMLTableCell; endCell = selectedCells[selectedCells.Count - 1] as IHTMLTableCell; } }
private IHTMLElement GetTargetCell(Point clientPoint) { // maximum amount of scanning buffer is based on cell spacing int maxScanningRange = Math.Max(TableHelper.GetAttributeAsInteger(_table.cellSpacing), 2); // copy client point so we can modify the x-coordinate while scanning Point targetPoint = new Point(clientPoint.X, clientPoint.Y); // if we go past the end of the table allow the cell closest to the cursor // to become the target cell (necessary for sizing the table larger) Point xTargetPoint = new Point(targetPoint.X, targetPoint.Y); IHTMLTableCell targetCell = null; while (targetCell == null && xTargetPoint.X >= (targetPoint.X - maxScanningRange)) // 0 ) { // determine the cell we are over targetCell = _editorContext.ElementFromClientPoint(xTargetPoint) as IHTMLTableCell; // screen cells that don't belong to us if (!HTMLElementHelper.ElementsAreEqual(_table as IHTMLElement, TableHelper.GetContainingTableElement(targetCell as IHTMLElement) as IHTMLElement)) { targetCell = null; } xTargetPoint.X--; } // if we got a target cell then ensure that the point is over the document area if (targetCell != null) { if (_editorContext.PointIsOverDocumentArea(clientPoint)) { return(targetCell as IHTMLElement); } else { return(null); } } else { return(null); } }
/// <summary> /// Inserts a new table in the document /// </summary> /// <param name="id">The ID of the table</param> /// <param name="rows">The number of rows</param> /// <param name="cols">The number of columns</param> /// <param name="borderSize">The border size</param> /// <param name="borderColor">The border color</param> public void InsertTable(string id, int rows, int cols, int borderSize = 0, string borderColor = null) { IHTMLTxtRange range = this.document.selection.createRange() as IHTMLTxtRange; range.pasteHTML("<table id=\"" + id + "\" style=\"position: absolute;\"></table>"); IHTMLTable table = this.GetElementById(id) as IHTMLTable; if (table != null) { for (int i = 0; i < rows; i++) { table.insertRow(i - 1); } table.cellPadding = "10"; foreach (IHTMLTableRow row in table.rows) { for (int i = 0; i < cols; i++) { IHTMLTableCell insertedCell = row.insertCell(i - 1); (insertedCell as IHTMLElement).innerHTML = " "; } } if (borderSize >= 0) { (table as IHTMLElement).style.border = borderSize + "px solid " + borderColor; } else { throw new ArgumentOutOfRangeException("The border size should be a positive number"); } this.AddStyle(id + " td", "border: " + borderSize + "px solid " + borderColor); this.AddStyle(id, (table as IHTMLElement).style.cssText); StringBuilder strBuilder = new StringBuilder(this.HTMLContent); int startIndexToDelete = this.HTMLContent.IndexOf("style=\"", HTMLContent.LastIndexOf("<table")) + 7; int endIndexToDelete = this.HTMLContent.IndexOf("position:", startIndexToDelete); strBuilder.Remove(startIndexToDelete, endIndexToDelete - startIndexToDelete); this.HTMLContent = strBuilder.ToString(); this.MakeInsertedElementMovable(); } }
public void DeleteCol(IHTMLTable table, int colindex) { for (int i = 0; true; i++) { IHTMLTableRow row = GetRow(table, i); if (row == null) { break; } IHTMLTableCell cell = Row_GetCell(row, colindex); if (cell == null) { continue; } RemoveNode(cell as IHTMLElement, true); if (Row_GetCellCount(row) == 0) { RemoveNode(table as IHTMLElement, true); break; } //Accounts for colspan //Row_DeleteCol(row, colindex); IHTMLElementCollection cells = row.cells; CalculateCellWidths(cells.length); for (int j = 0; j < cells.length; j++) { object obj = j; IHTMLTableCell cella = cells.item(obj, obj) as IHTMLTableCell; if (cella != null) { if ((j + 1) == cells.length) { cella.width = m_lastcellwidth; } else { cella.width = m_cellwidth; } } } } }
public static void insertColumn(IHTMLElement m_oHTMLCtxMenu) { HTMLEditHelper htmledit = new HTMLEditHelper(); IHTMLTableCell cell = m_oHTMLCtxMenu as IHTMLTableCell; int index = 0; if (cell != null) { index = cell.cellIndex; } IHTMLTable table = htmledit.GetParentTable(m_oHTMLCtxMenu); if (table == null) { return; } htmledit.InsertCol(table, index); }
public IHTMLElement Row_InsertCell(IHTMLTableRow row, int index, string cellwidth) { IHTMLElement elem = row.insertCell(index) as IHTMLElement; if (elem != null) { elem.innerHTML = HtmlSpace; if (!string.IsNullOrEmpty(cellwidth)) { IHTMLTableCell tcell = elem as IHTMLTableCell; if (tcell != null) { tcell.width = cellwidth; } } } return(elem); }
public static int GetCellWidth(IHTMLTableCell cell) { if (cell.width != null) { try { return(int.Parse(cell.width.ToString(), CultureInfo.InvariantCulture)); } catch { return((cell as IHTMLElement).offsetWidth); } } else { return((cell as IHTMLElement).offsetWidth); } }
public void ProcessCell(IHTMLTableCell cell) { // for the first cell processed, note its alignment if (!_firstCellProcessed) { _verticalAlignment = TableHelper.GetVAlignmentForHtmlAlignment(cell.vAlign); _firstCellProcessed = true; } // for subsequent cells, if any of them differ from the first cell // then the alignment is mixed else if (_verticalAlignment != VerticalAlignment.Mixed) // optimize { if (_verticalAlignment != TableHelper.GetVAlignmentForHtmlAlignment(cell.vAlign)) { _verticalAlignment = VerticalAlignment.Mixed; } } }
public void ProcessCell(IHTMLTableCell cell) { // for the first cell processed, note its color if (!_firstCellProcessed) { _backgroundColor.Color = TableHelper.GetColorForHtmlColor(cell.bgColor); _firstCellProcessed = true; } // for subsequent cells, if any of them differ from the first cell // then the background color is mixed else if (!_backgroundColor.IsMixed) { if (_backgroundColor.Color != TableHelper.GetColorForHtmlColor(cell.bgColor)) { _backgroundColor.IsMixed = true; } } }
public static int GetCellWidth(IHTMLTableCell cell) { if (cell.width != null) { try { return int.Parse(cell.width.ToString(), CultureInfo.InvariantCulture); } catch { return (cell as IHTMLElement).offsetWidth; } } else { return (cell as IHTMLElement).offsetWidth; } }
public static IHTMLTableRow GetContainingRowElement(IHTMLTableCell cell) { // search up the parent heirarchy IHTMLElement element = cell as IHTMLElement; while (element != null) { if (element is IHTMLTableRow) { return element as IHTMLTableRow; } // search parent element = element.parentElement; } // didn't find a table row return null; }
public void ProcessCell(IHTMLTableCell cell) { // for the first cell processed, note its alignment if (!_firstCellProcessed) { _horizontalAlignment = TableHelper.GetAlignmentForHtmlAlignment(cell.align); _firstCellProcessed = true; } // for subsequent cells, if any of them differ from the first cell // then the alignment is mixed else if (_horizontalAlignment != HorizontalAlignment.Mixed) { if (_horizontalAlignment != TableHelper.GetAlignmentForHtmlAlignment(cell.align)) { _horizontalAlignment = HorizontalAlignment.Mixed; } } }
public static void insertRow(IHTMLElement m_oHTMLCtxMenu) { HTMLEditHelper htmledit = new HTMLEditHelper(); IHTMLTableCell cell = m_oHTMLCtxMenu as IHTMLTableCell; IHTMLTableRow row = htmledit.GetParentRow(m_oHTMLCtxMenu); int index = 0; if (row != null) { index = row.rowIndex; } IHTMLTable table = htmledit.GetParentTable(m_oHTMLCtxMenu); if (table == null) { return; } htmledit.InsertRow(table, index, htmledit.Row_GetCellCount(row)); }
/// <summary> /// Gets the IHTMLTableCell object of the selected cell /// </summary> /// <returns>The selected cell as IHTMLTableCell</returns> public IHTMLTableCell GetSelectedTableCellElement() { if (this.GetSelectedElement() != null) { if (this.GetSelectedElementType() == "TD") { IHTMLTableCell selectedCell = this.GetSelectedElement() as IHTMLTableCell; return(selectedCell); } else { return(null); } } else { return(null); } }
private IHTMLTableRow GetContainingRowForCell(IHTMLTableCell tableCell) { // search up the parent heirarchy IHTMLElement element = tableCell as IHTMLElement; while (element != null) { if (element is IHTMLTableRow) { return(element as IHTMLTableRow); } // search parent element = element.parentElement; } // didn't find a row return(null); }
public static IHTMLTableRow GetContainingRowElement(IHTMLTableCell cell) { // search up the parent hierarchy IHTMLElement element = cell as IHTMLElement; while (element != null) { if (element is IHTMLTableRow) { return(element as IHTMLTableRow); } // search parent element = element.parentElement; } // didn't find a table row return(null); }
public HTMLTableColumn(IHTMLTable table, IHTMLTableCell baseCell) { _table = table; _baseCell = baseCell; _index = _baseCell.cellIndex; }
public static void SynchronizeCellWidthForEditing(IHTMLTableCell cell) { if (GetCellWidth(cell) != ((cell as IHTMLElement).offsetWidth)) cell.width = (cell as IHTMLElement).offsetWidth; }
public void Initialize( IHTMLTableCell[] cells) { Text = Resources.Str_UIHtml_CellProperties; _cells.AddRange(cells); }
public void BeginSizing(IHTMLTableCell targetCell) { // set pending state to false _pending = false; // sanity check if (_sizingUndoUnit != null) { Trace.Fail("Never call BeginSizing twice consecutively (must call EndSizing first)"); _sizingUndoUnit.Dispose(); _sizingUndoUnit = null; } // create new undo unit _sizingUndoUnit = _editorContext.CreateUndoUnit(); // calculate left and right columns InitializeSizingContext(targetCell); // make sure we show the sizing cursor ShowSizingCursor(); }
/// <summary> /// Get the column of the current cell /// zero based /// </summary> /// <param name="cell"></param> /// <returns></returns> public int GetColIndex(IHTMLTableCell cell) { if (cell == null) return 0; int iret = 0; IHTMLTableCell tcell = cell; IHTMLDOMNode node = null; IHTMLElement elem = null; while (true) { node = tcell as IHTMLDOMNode; if (node == null) break; elem = PreviousSibling(node); if (elem == null) break; tcell = elem as IHTMLTableCell; if (tcell == null) break; iret += tcell.colSpan; } return iret; }
public void ProcessCell(IHTMLTableCell cell) { // for the first cell processed, note its alignment if (!_firstCellProcessed) { _horizontalAlignment = TableHelper.GetAlignmentForHtmlAlignment(cell.align); _firstCellProcessed = true; } // for subsequent cells, if any of them differ from the first cell // then the alignment is mixed else if (_horizontalAlignment != HorizontalAlignment.Mixed) { if (_horizontalAlignment != TableHelper.GetAlignmentForHtmlAlignment(cell.align)) _horizontalAlignment = HorizontalAlignment.Mixed; } }
public void ProcessCell(IHTMLTableCell cell) { // mixed means leave the cells alone if (_alignment != VerticalAlignment.Mixed) { if (_alignment != VerticalAlignment.Middle) cell.vAlign = TableHelper.GetHtmlAlignmentForVAlignment(_alignment); else (cell as IHTMLElement).removeAttribute("valign", 0); } }
private void SelectCell(IHTMLTableCell cell) { IHTMLElement cellElement = cell as IHTMLElement; // move the selection to the beginning of the cell MarkupRange markupRange = _editorContext.MarkupServices.CreateMarkupRange(cellElement); // if the cell is empty then collapse the selection if (cellElement.innerHTML == null) markupRange.End.MoveToPointer(markupRange.Start); IHTMLTxtRange textRange = markupRange.ToTextRange(); textRange.select(); }
public void ProcessCell(IHTMLTableCell cell) { // mixed means leave the cells alone if (_alignment != HorizontalAlignment.Mixed) { if (_alignment != HorizontalAlignment.Left) cell.align = TableHelper.GetHtmlAlignmentForAlignment(_alignment); else (cell as IHTMLElement).removeAttribute("align", 0); } }
public static void SelectCell(IHtmlEditorComponentContext editorContext, IHTMLTableCell cell) { TableEditor tableEditor = new TableEditor(editorContext); tableEditor.SelectCell(cell); }
private void FillDialogControlsToCellValue( IHTMLTableCell cell) { var cellElement = (IHTMLElement)cell; // -- if (horizontalAlignmentComboBox.SelectedItem != null) { var p = (Pair<string, HorizontalAlignmentType>) horizontalAlignmentComboBox.SelectedItem; if (p.Value != HorizontalAlignmentType.Multiple) { string a = string.Empty; switch (p.Value) { case HorizontalAlignmentType.Standard: a = string.Empty; break; case HorizontalAlignmentType.Center: a = @"center"; break; case HorizontalAlignmentType.Left: a = @"left"; break; case HorizontalAlignmentType.Right: a = @"right"; break; case HorizontalAlignmentType.Justify: a = @"justify"; break; } cell.align = a; } } // -- if (verticalAlignmentComboBox.SelectedItem != null) { var p = (Pair<string, VerticalAlignmentType>) verticalAlignmentComboBox.SelectedItem; if (p.Value != VerticalAlignmentType.Multiple) { var a = string.Empty; switch (p.Value) { case VerticalAlignmentType.Standard: a = string.Empty; break; case VerticalAlignmentType.BaseLine: a = @"baseline"; break; case VerticalAlignmentType.Bottom: a = @"bottom"; break; case VerticalAlignmentType.Top: a = @"top"; break; case VerticalAlignmentType.Middle: a = @"middle"; break; } cell.vAlign = a; } } // -- if (defineWidthCheckBox.CheckState != CheckState.Indeterminate) { string w = widthTextBox.Text; if (widthDropDownControl.SelectedIndex==1) { w += @"%"; } cellElement.setAttribute( @"width", w, 0); } // -- if (defineHeightCheckBox.CheckState != CheckState.Indeterminate) { var h = heightTextBox.Text; if (heightDropDownControl.SelectedIndex==1) { h += @"%"; } cellElement.setAttribute( @"height", h, 0); } // -- if (noWrapCheckBox.CheckState != CheckState.Indeterminate) { cell.noWrap = noWrapCheckBox.CheckState == CheckState.Checked; } // -- // Change the tag name between TH <. TD. if (containsHeadlineCheckBox.CheckState != CheckState.Indeterminate) { string newTagName = containsHeadlineCheckBox.CheckState == CheckState.Checked ? @"th" : @"td"; string tagName = cellElement.tagName.ToLowerInvariant(); if (tagName != newTagName) { var outerHtmlSb = new StringBuilder(cellElement.outerHTML.Trim()); // Replace start. outerHtmlSb[1] = newTagName[0]; outerHtmlSb[2] = newTagName[1]; // Replace end. outerHtmlSb[outerHtmlSb.Length - 3] = newTagName[0]; outerHtmlSb[outerHtmlSb.Length - 2] = newTagName[1]; string outerHtml = outerHtmlSb.ToString(); // -- const int startPos1 = 0; int endPos1 = outerHtml.IndexOf('>'); int startPos2 = outerHtml.LastIndexOf('<'); int endPos2 = outerHtml.Length - 1; Debug.Assert(startPos1 != -1); Debug.Assert(endPos1 != -1); Debug.Assert(startPos2 != -1); Debug.Assert(endPos2 != -1); string newHtmlTag = outerHtml.Substring(startPos1, endPos1 - startPos1 + 1); string newHtmlInnerHtml = outerHtml.Substring(endPos1 + 1, startPos2 - endPos1 - 1); // -- var cellNode = cell as IHTMLDOMNode2; Debug.Assert(cellNode != null); var doc = cellNode.ownerDocument as IHTMLDocument2; Debug.Assert(doc != null); var newElement = doc.createElement( newHtmlTag); newElement.innerHTML = newHtmlInnerHtml; var newNode = newElement as IHTMLDOMNode; // Set the new. var cellNode1 = cell as IHTMLDOMNode; Debug.Assert(cellNode1 != null); cellNode1.replaceNode(newNode); } } }
/// <summary> /// Changes a single property of a cell /// </summary> /// <param name="cell">The cell to modify</param> /// <param name="propertyName">The property to change</param> /// <param name="newValue">The new value of the property</param> public void ChangeCellProperty(IHTMLTableCell cell, CellProperties propertyName, string newValue) { IHTMLElement cellElement = cell as IHTMLElement; ; if (cellElement != null) { switch (propertyName) { case CellProperties.BackgroundColor: cellElement.style.backgroundColor = newValue; break; case CellProperties.BorderColor: cellElement.style.borderColor = newValue; break; case CellProperties.BorderSize: if (newValue != null) { cellElement.style.borderWidth = newValue; } break; case CellProperties.Height: if (newValue != null) { cellElement.style.height = newValue; } break; case CellProperties.Width: if (newValue != null) { cellElement.style.width = newValue; } break; case CellProperties.Rowspan: if(newValue != null) { cell.rowSpan = int.Parse(newValue); } break; case CellProperties.Colspan: if (newValue != null) { cell.colSpan = int.Parse(newValue); } break; } } }
private IHTMLTableRow GetContainingRowForCell(IHTMLTableCell tableCell) { // search up the parent heirarchy IHTMLElement element = tableCell as IHTMLElement; while (element != null) { if (element is IHTMLTableRow) { return element as IHTMLTableRow; } // search parent element = element.parentElement; } // didn't find a row return null; }
private void InitializeSizingContext(IHTMLTableCell targetCell) { IHTMLTableRow row = TableHelper.GetContainingRowElement(targetCell as IHTMLTableCell); IHTMLTableCell leftCell = row.cells.item(_pendingLeftColumnIndex, _pendingLeftColumnIndex) as IHTMLTableCell; _leftColumn = new HTMLTableColumn(_table, leftCell); if (_pendingRightColumnIndex != -1) { IHTMLTableCell rightCell = row.cells.item(_pendingRightColumnIndex, _pendingRightColumnIndex) as IHTMLTableCell; _rightColumn = new HTMLTableColumn(_table, rightCell); } else { _rightColumn = null; } // force a fixup of cell widths on the next call to ContinueSizing // (we do this during ContinueSizing so that table column borders don't // visible "jump" on MouseDown) _cellWidthsFixed = false; }
private void FindCellRange(MarkupRange selectedRange, out ArrayList selectedCells, out IHTMLTableCell beginCell, out IHTMLTableCell endCell) { // default to null beginCell = null; endCell = null; selectedCells = new ArrayList(); // JJA: fix bug #476623 -- at document initialization the selected markup range // may not yet be positioned so protect ourselves in this case if (!selectedRange.Positioned) return; // query for all of the table cells within the range selectedCells.AddRange(selectedRange.GetElements(ElementFilters.TABLE_CELL_ELEMENT, false)); // extract the begin and end cells if (selectedCells.Count == 0) { // see if the selection is contained within a single cell beginCell = selectedRange.Start.GetParentElement(ElementFilters.TABLE_CELL_ELEMENT) as IHTMLTableCell; if (beginCell != null) { // make sure the cell is content editable (it would not be in the case // where the call to GetParentElement went all the way out of the body // and found a cell that was part of the containing template) if (!(beginCell as IHTMLElement3).isContentEditable) beginCell = null; } endCell = beginCell; selectedCells.Add(beginCell); } else if (selectedCells.Count == 1) { beginCell = selectedCells[0] as IHTMLTableCell; endCell = selectedCells[0] as IHTMLTableCell; } else { beginCell = selectedCells[0] as IHTMLTableCell; endCell = selectedCells[selectedCells.Count - 1] as IHTMLTableCell; } }
private IHTMLElement GetSelectedTable(IHTMLTableCell beginCell, IHTMLTableCell endCell, MarkupRange selectionMarkupRange) { // screen null cases if (beginCell == null || endCell == null) return null; // get containing tables IHTMLTable beginTable = TableHelper.GetContainingTableElement(beginCell as IHTMLElement); IHTMLTable endTable = TableHelper.GetContainingTableElement(endCell as IHTMLElement); // see if they are from the same table if (HTMLElementHelper.ElementsAreEqual(beginTable as IHTMLElement, endTable as IHTMLElement)) { return beginTable as IHTMLElement; } else return null; }
public void ProcessCell(IHTMLTableCell cell) { // for the first cell processed, note its alignment if (!_firstCellProcessed) { _verticalAlignment = TableHelper.GetVAlignmentForHtmlAlignment(cell.vAlign); _firstCellProcessed = true; } // for subsequent cells, if any of them differ from the first cell // then the alignment is mixed else if (_verticalAlignment != VerticalAlignment.Mixed) // optimize { if (_verticalAlignment != TableHelper.GetVAlignmentForHtmlAlignment(cell.vAlign)) _verticalAlignment = VerticalAlignment.Mixed; } }