2.3 Remove Extra Column Declarations

<..remove child spaces from row..>
 tblCell = tblRow.getFirstChild();
 while( tblCell != null){
   d = tblCell.getNextSibling();
   if( justSpace(tblCell) ){  tblRow.removeChild(tblCell);  }
   tblCell = d;
 }
-_-_-

<..n := max number of cols..>
 int n = 0;
 tblRow = node.getFirstChild();
 while( tblRow != null ){
    if(
        (tblRow.getNodeType() == Node.ELEMENT_NODE)
      &&
         tblRow.getNodeName().equals("table:table-row")
    ){
       <.m := number of columns.>
       if( m > n ){ n = m; }
    }
    tblRow = tblRow.getNextSibling();
 }
-_-_-

<..m := number of columns..>
 int m = 0;
 tblCell = tblRow.getFirstChild();
 while( tblCell != null ){
    if(
        (tblCell.getNodeType() == Node.ELEMENT_NODE)
      &&
         tblCell.getNodeName().equals("table:table-cell")
    ){
       m++;
       <.table:table-cell -= empty text:p.>
    }
    tblCell = tblCell.getNextSibling();
 }
-_-_-

<..remove extra col declarations..>
 tblRow = node.getFirstChild();
 while( tblRow != null ){
    d = tblRow.getNextSibling();
    if(
        (tblRow.getNodeType() == Node.ELEMENT_NODE)
      &&
         tblRow.getNodeName().equals("table:table-column")
    ){
       n--;
       if( n < 0 ){
         tblRow.getParentNode().removeChild(tblRow);
   }  }
   tblRow = d;
 }
-_-_-