public static void AddTableCellProperties(TableRow tableRow, TableCell tableCell, bool toppest, bool bottomest, bool leftest, bool rightest, StringBuilder style) { style.Append("width:" + (tableCell.GetWidth() / TWIPS_PER_INCH) + "in;"); style.Append("padding-start:" + (tableRow.GetGapHalf() / TWIPS_PER_INCH) + "in;"); style.Append("padding-end:" + (tableRow.GetGapHalf() / TWIPS_PER_INCH) + "in;"); BorderCode top = tableCell.GetBrcTop() != null && tableCell.GetBrcTop().BorderType != 0 ? tableCell .GetBrcTop() : toppest ? tableRow.GetTopBorder() : tableRow .GetHorizontalBorder(); BorderCode bottom = tableCell.GetBrcBottom() != null && tableCell.GetBrcBottom().BorderType != 0 ? tableCell .GetBrcBottom() : bottomest ? tableRow.GetBottomBorder() : tableRow.GetHorizontalBorder(); BorderCode left = tableCell.GetBrcLeft() != null && tableCell.GetBrcLeft().BorderType != 0 ? tableCell .GetBrcLeft() : leftest ? tableRow.GetLeftBorder() : tableRow .GetVerticalBorder(); BorderCode right = tableCell.GetBrcRight() != null && tableCell.GetBrcRight().BorderType != 0 ? tableCell .GetBrcRight() : rightest ? tableRow.GetRightBorder() : tableRow.GetVerticalBorder(); AddBorder(bottom, "bottom", style); AddBorder(left, "left", style); AddBorder(right, "right", style); AddBorder(top, "top", style); }
public static void SetTableCellProperties(TableRow tableRow, TableCell tableCell, XmlElement XmlElement, bool toppest, bool bottomest, bool leftest, bool rightest) { XmlElement.SetAttribute("width", (tableCell.GetWidth() / TWIPS_PER_INCH) + "in"); XmlElement.SetAttribute("padding-start", (tableRow.GetGapHalf() / TWIPS_PER_INCH) + "in"); XmlElement.SetAttribute("padding-end", (tableRow.GetGapHalf() / TWIPS_PER_INCH) + "in"); BorderCode top = tableCell.GetBrcTop() != null && tableCell.GetBrcTop().BorderType != 0 ? tableCell .GetBrcTop() : toppest ? tableRow.GetTopBorder() : tableRow .GetHorizontalBorder(); BorderCode bottom = tableCell.GetBrcBottom() != null && tableCell.GetBrcBottom().BorderType != 0 ? tableCell .GetBrcBottom() : bottomest ? tableRow.GetBottomBorder() : tableRow.GetHorizontalBorder(); BorderCode left = tableCell.GetBrcLeft() != null && tableCell.GetBrcLeft().BorderType != 0 ? tableCell .GetBrcLeft() : leftest ? tableRow.GetLeftBorder() : tableRow .GetVerticalBorder(); BorderCode right = tableCell.GetBrcRight() != null && tableCell.GetBrcRight().BorderType != 0 ? tableCell .GetBrcRight() : rightest ? tableRow.GetRightBorder() : tableRow.GetVerticalBorder(); SetBorder(XmlElement, bottom, "bottom"); SetBorder(XmlElement, left, "left"); SetBorder(XmlElement, right, "right"); SetBorder(XmlElement, top, "top"); }
private void initCells() { if ( _cellsFound ) return; short expectedCellsCount = _tprops.GetItcMac(); int lastCellStart = 0; List<TableCell> cells = new List<TableCell>( expectedCellsCount + 1 ); for ( int p = 0; p < NumParagraphs; p++ ) { Paragraph paragraph = GetParagraph( p ); String s = paragraph.Text; if ( ( ( s.Length > 0 && s[s.Length - 1]== TABLE_CELL_MARK ) || paragraph .IsEmbeddedCellMark() ) && paragraph.GetTableLevel() == _levelNum ) { TableCellDescriptor tableCellDescriptor = _tprops.GetRgtc() != null && _tprops.GetRgtc().Length > cells.Count ? _tprops .GetRgtc()[cells.Count] : new TableCellDescriptor(); short leftEdge = (_tprops.GetRgdxaCenter() != null && _tprops.GetRgdxaCenter().Length > cells.Count) ? (short)_tprops .GetRgdxaCenter()[cells.Count] : (short)0; short rightEdge = (_tprops.GetRgdxaCenter() != null && _tprops.GetRgdxaCenter().Length > cells.Count + 1) ? (short)_tprops .GetRgdxaCenter()[cells.Count + 1] : (short)0; TableCell tableCell = new TableCell( GetParagraph( lastCellStart ).StartOffset, GetParagraph( p ) .EndOffset, this, _levelNum, tableCellDescriptor, leftEdge, rightEdge - leftEdge ); cells.Add( tableCell ); lastCellStart = p + 1; } } if ( lastCellStart < ( NumParagraphs - 1 ) ) { TableCellDescriptor tableCellDescriptor = _tprops.GetRgtc() != null && _tprops.GetRgtc().Length > cells.Count ? _tprops .GetRgtc()[cells.Count] : new TableCellDescriptor(); short leftEdge = _tprops.GetRgdxaCenter() != null && _tprops.GetRgdxaCenter().Length > cells.Count ? (short)_tprops .GetRgdxaCenter()[cells.Count] : (short)0; short rightEdge = _tprops.GetRgdxaCenter() != null && _tprops.GetRgdxaCenter().Length > cells.Count + 1 ? (short)_tprops .GetRgdxaCenter()[cells.Count + 1] : (short)0; TableCell tableCell = new TableCell( lastCellStart, ( NumParagraphs - 1 ), this, _levelNum, tableCellDescriptor, leftEdge, rightEdge - leftEdge ); cells.Add( tableCell ); } if ( cells.Count>0 ) { TableCell lastCell = cells[cells.Count - 1]; if ( lastCell.NumParagraphs == 1 && ( lastCell.GetParagraph( 0 ).IsTableRowEnd() ) ) { // remove "fake" cell cells.RemoveAt( cells.Count - 1 ); } } if ( cells.Count != expectedCellsCount ) { _tprops.SetItcMac( (short) cells.Count); } _cells = cells.ToArray(); _cellsFound = true; }
private void initCells() { if (_cellsFound) { return; } short expectedCellsCount = _tprops.GetItcMac(); int lastCellStart = 0; List <TableCell> cells = new List <TableCell>( expectedCellsCount + 1); for (int p = 0; p < NumParagraphs; p++) { Paragraph paragraph = GetParagraph(p); String s = paragraph.Text; if (((s.Length > 0 && s[s.Length - 1] == TABLE_CELL_MARK) || paragraph .IsEmbeddedCellMark()) && paragraph.GetTableLevel() == _levelNum) { TableCellDescriptor tableCellDescriptor = _tprops.GetRgtc() != null && _tprops.GetRgtc().Length > cells.Count ? _tprops .GetRgtc()[cells.Count] : new TableCellDescriptor(); short leftEdge = (_tprops.GetRgdxaCenter() != null && _tprops.GetRgdxaCenter().Length > cells.Count) ? (short)_tprops .GetRgdxaCenter()[cells.Count] : (short)0; short rightEdge = (_tprops.GetRgdxaCenter() != null && _tprops.GetRgdxaCenter().Length > cells.Count + 1) ? (short)_tprops .GetRgdxaCenter()[cells.Count + 1] : (short)0; TableCell tableCell = new TableCell(GetParagraph( lastCellStart).StartOffset, GetParagraph(p) .EndOffset, this, _levelNum, tableCellDescriptor, leftEdge, rightEdge - leftEdge); cells.Add(tableCell); lastCellStart = p + 1; } } if (lastCellStart < (NumParagraphs - 1)) { TableCellDescriptor tableCellDescriptor = _tprops.GetRgtc() != null && _tprops.GetRgtc().Length > cells.Count ? _tprops .GetRgtc()[cells.Count] : new TableCellDescriptor(); short leftEdge = _tprops.GetRgdxaCenter() != null && _tprops.GetRgdxaCenter().Length > cells.Count ? (short)_tprops .GetRgdxaCenter()[cells.Count] : (short)0; short rightEdge = _tprops.GetRgdxaCenter() != null && _tprops.GetRgdxaCenter().Length > cells.Count + 1 ? (short)_tprops .GetRgdxaCenter()[cells.Count + 1] : (short)0; TableCell tableCell = new TableCell(lastCellStart, (NumParagraphs - 1), this, _levelNum, tableCellDescriptor, leftEdge, rightEdge - leftEdge); cells.Add(tableCell); } if (cells.Count > 0) { TableCell lastCell = cells[cells.Count - 1]; if (lastCell.NumParagraphs == 1 && (lastCell.GetParagraph(0).IsTableRowEnd())) { // remove "fake" cell cells.RemoveAt(cells.Count - 1); } } if (cells.Count != expectedCellsCount) { _tprops.SetItcMac((short)cells.Count); } _cells = cells.ToArray(); _cellsFound = true; }