void addColumnStyles(
      final ImageElementContext context,
      final Section columns,
      final int columnPos,
      final int colSpan) {
    final Node[] columnDefs = columns.getNodeArray();
    int columnCounter = 0;
    for (Node columnDef : columnDefs) {
      final Element column = (Element) columnDef;

      if (!ObjectUtilities.equal(column.getNamespace(), OfficeNamespaces.TABLE_NS)
          || !ObjectUtilities.equal(column.getType(), OfficeToken.TABLE_COLUMN)) {
        continue;
      }
      if (columnCounter >= columnPos) {
        final String colStyle =
            (String) column.getAttribute(OfficeNamespaces.TABLE_NS, OfficeToken.STYLE_NAME);
        context.setColStyle(columnCounter - columnPos, colStyle);
      }

      columnCounter += 1;

      if (columnCounter >= (columnPos + colSpan)) {
        break;
      }
    }
  }
 private LayoutController findParentCell() {
   LayoutController parent = getParent();
   while (parent != null) {
     final Object node = parent.getNode();
     if (node instanceof Element) {
       final Element element = (Element) node;
       if (OfficeNamespaces.TABLE_NS.equals(element.getNamespace())
           && "table-cell".equals(element.getType())) {
         return parent;
       }
     }
     parent = parent.getParent();
   }
   return null;
 }
  private int findNodeInSection(
      final Section tableRow, final Element tableCell, final String secondType) {
    int retval = 0;
    final Node[] nodes = tableRow.getNodeArray();
    final String namespace = tableCell.getNamespace();
    final String type = tableCell.getType();
    for (final Node node : nodes) {
      if (!(node instanceof Element)) {
        continue;
      }
      final Element child = (Element) node;
      if (!ObjectUtilities.equal(child.getNamespace(), namespace)
          || (!ObjectUtilities.equal(child.getType(), type)
              && (secondType == null || !ObjectUtilities.equal(child.getType(), secondType)))) {
        continue;
      }

      if (node == tableCell) {
        return retval;
      }
      retval += 1;
    }
    return -1;
  }
  void addRowStyles(
      final ImageElementContext context, final Section table, final int rowPos, final int rowSpan) {
    final Node[] rows = table.getNodeArray();
    int rowCounter = 0;
    for (Node row1 : rows) {
      final Element row = (Element) row1;

      if (!ObjectUtilities.equal(row.getNamespace(), OfficeNamespaces.TABLE_NS)
          || !ObjectUtilities.equal(row.getType(), OfficeToken.TABLE_ROW)) {
        continue;
      }
      if (rowCounter >= rowPos) {
        final String rowStyle =
            (String) row.getAttribute(OfficeNamespaces.TABLE_NS, OfficeToken.STYLE_NAME);
        context.setRowStyle(rowCounter - rowPos, rowStyle);
      }

      rowCounter += 1;

      if (rowCounter >= (rowPos + rowSpan)) {
        break;
      }
    }
  }