// ======================================== // method // ======================================== public override void Execute() { var model = _target.Model as MemoTable; var row = model.Rows.ElementAt(_rowIndex); _cell = row.Cells.ElementAt(_columnIndex); _oldColumnSpan = _cell.ColumnSpan; _oldRowSpan = _cell.RowSpan; _cell.ColumnSpan = _columnSpan; _cell.RowSpan = _rowSpan; }
private void ParseTR(HtmlNode node) { if (Logger.IsDebugEnabled) { Logger.Debug(string.Format("tr: {0}, {1}", node.Name, node.InnerText)); } _currentTableRow = _currentTable.AddRow(); if (!node.ChildNodes.Any(child => IsTHOrTD(child))) { /// thやtdの内trのrowspan消費 var newRowSpans = new Dictionary <int, int>(); foreach (var key in _currentRowSpans.Keys) { var rs = _currentRowSpans[key] - 1; if (rs > 1) { newRowSpans[key] = rs; } } _currentRowSpans = newRowSpans; } var colspan = 1; var rowspan = 1; var col = 0; foreach (var child in node.ChildNodes) { switch (child.Name.ToLowerInvariant()) { case "th": case "td": colspan = GetSpan(child, "colspan"); rowspan = GetSpan(child, "rowspan"); if (_isFirstRow) { for (int i = 0; i < colspan; ++i) { _currentTable.AddColumn(); } } if (_currentRowSpans.ContainsKey(col)) { var c = col; while (_currentRowSpans.ContainsKey(c)) { _currentRowSpans[c] = _currentRowSpans[c] - 1; if (_currentRowSpans[c] <= 1) { _currentRowSpans.Remove(c); } ++c; } col = c; } //if (col < _currentTableRow.Cells.Count()) { _currentCell = _currentTableRow.Cells.ElementAt(col); _currentCell.ColumnSpan = colspan; _currentCell.RowSpan = rowspan; ParseTHTD(child); //} if (rowspan > 1) { for (int c = col, clen = col + colspan; c < clen; ++c) { _currentRowSpans[c] = rowspan; } } col += colspan; break; } } /// trのth/tdより後ろにあるrowspan消費 if (col < _currentTable.ColumnCount) { var newRowSpans = new Dictionary <int, int>(); foreach (var key in _currentRowSpans.Keys) { if (key >= col) { var rs = _currentRowSpans[key] - 1; if (rs > 1) { newRowSpans[key] = rs; } } } _currentRowSpans = newRowSpans; } _currentTableRow = null; _isFirstRow = false; }