Page 1 of 1

importXHTML issue with tables (TableHelper.setupTblGrid)

PostPosted: Fri Dec 18, 2015 4:50 am
by User444
I recently encountered a problem with XHTML import. There was a table that was causing an ArrayIndexOutOfBoundsException exception in importXHTML, https://github.com/plutext/docx4j-ImportXHTML/blob/master/src/main/java/org/docx4j/convert/in/xhtml/TableHelper.java#L209.

There's a loop:
Code: Select all
for (int i=1; i<=cssTable.numEffCols(); i++)
Shouldn't it be
Code: Select all
for (int i=0; i<cssTable.numEffCols(); i++)
?

The table in question was:

Code: Select all
<div class="row section">
   <div class="col-md-12">
      <table>
         <tbody>
            <tr>
               <td>
                  <table style="width: 100%; float: left;" cellspacing="0">
                     <tbody>
                        <tr>
                           <td style="width: 270px; text-align: left; vertical-align: top;">
                              <span style="color: #993300; font-size: 10pt;">
                                 <strong>
                                    <span style="font-size: 12pt;">
                                       

                                       Title1
                                    </span>
                                     
                                 </strong>
                              </span>
                             

                              Text1. 
                           </td>
                           <td style="width: 270px; text-align: left; vertical-align: top;">
                              <strong>
                                 

                                 

                                 Text2: 
                              </strong>
                             

                              <ul>
                                 <li>Item1 </li>
                                 <li>Item2 </li>
                                 <li>Item3 </li>
                                 <li>Item4 </li>
                                 <li>Item5 </li>
                              </ul>
                           </td>
                        </tr>
                     </tbody>
                  </table>
                 

                 

                 

                 

                 

                 

                 

                 

                 

                 

                 

                 

                 

                 

                 

                 

                 

                  <strong>
                     Text3
                     

                  </strong>
                  <ol>
                     <li>Text4 </li>
                  </ol>
                  __________________________________________________________________________________________________________
               </td>
            </tr>
         </tbody>
      </table>
   </div>
</div>


Thank you.

Re: importXHTML issue with tables (TableHelper.setupTblGrid)

PostPosted: Thu Dec 24, 2015 1:09 pm
by jason
I don't think so.

It seems to be something to do with how getCol is calculated for the nested table, but only when it is nested.

When it is nested, numEffCols() returns 2.

When it isn't, it returns 0.