Fixed null pointer exception for tables with unbalanced rows
git-svn-id: svn://svn.code.sf.net/p/writer2latex/code/trunk@104 f0f2a975-2e09-46c8-9428-3b39399b9f3c
This commit is contained in:
parent
9fc63c43cb
commit
fa991ae966
6 changed files with 160 additions and 131 deletions
|
@ -2,6 +2,8 @@ Changelog for Writer2LaTeX version 1.0 -> 1.2
|
|||
|
||||
---------- version 1.1.7 ----------
|
||||
|
||||
[all] Bugfix: Fixed null pointer exception for tables with unbalanced rows
|
||||
|
||||
[w2l] Added the attribute break-after to paragraph style maps with values none, line and par (default)
|
||||
|
||||
[w2x] Bugfix: Positioning of text boxes (left, right, center, floating) now works correctly
|
||||
|
|
|
@ -104,7 +104,6 @@ public class ParConverter extends StyleConverter {
|
|||
String sStyleName = node.getAttribute(XMLString.TEXT_STYLE_NAME);
|
||||
String sDisplayName = ofr.getParStyles().getDisplayName(sStyleName);
|
||||
|
||||
|
||||
// Check for strict handling of styles
|
||||
if (config.otherStyles()!=LaTeXConfig.ACCEPT && !config.getParStyleMap().contains(sDisplayName)) {
|
||||
if (config.otherStyles()==LaTeXConfig.WARNING) {
|
||||
|
@ -340,7 +339,6 @@ public class ParConverter extends StyleConverter {
|
|||
if (sAfter.length()>0 && !"}".equals(sAfter)) { ba.add("","\n"); }
|
||||
}
|
||||
nBreakAfter = styleMap.getBreakAfter(sName);
|
||||
System.out.println(sName+"-"+nBreakAfter);
|
||||
}
|
||||
|
||||
// Update context
|
||||
|
|
|
@ -16,11 +16,11 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
* Copyright: 2002-2010 by Henrik Just
|
||||
* Copyright: 2002-2011 by Henrik Just
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.2 (2010-04-29)
|
||||
* Version 1.2 (2011-04-20)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -440,6 +440,7 @@ public class TableConverter extends ConverterHelper {
|
|||
int nCol = 0;
|
||||
while (nCol<nColCount) {
|
||||
Element cell = (Element) table.getCell(nRow,nCol);
|
||||
if (cell!=null) {
|
||||
if (XMLString.TABLE_TABLE_CELL.equals(cell.getNodeName())) {
|
||||
Context icCell = (Context) icRow.clone();
|
||||
BeforeAfter baCell = new BeforeAfter();
|
||||
|
@ -459,6 +460,10 @@ public class TableConverter extends ConverterHelper {
|
|||
}
|
||||
nCol+=nColSpan;
|
||||
}
|
||||
else { // Non-existing cell, ignore (assuming it is a trailing cell)
|
||||
nCol++;
|
||||
}
|
||||
}
|
||||
ldp.append("\\\\");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,11 +16,11 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
* Copyright: 2002-2009 by Henrik Just
|
||||
* Copyright: 2002-2011 by Henrik Just
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.0 (2009-05-22)
|
||||
* Version 1.2 (2011-04-20)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -82,7 +82,7 @@ public class TableFormatter extends ConverterHelper {
|
|||
// Collect chars to be counted in this column
|
||||
for (int nRow=0; nRow<nRowCount; nRow++) {
|
||||
Element cell = table.getCell(nRow, nCol);
|
||||
if (Misc.isElement(cell, XMLString.TABLE_TABLE_CELL)) {
|
||||
if (cell!=null && Misc.isElement(cell, XMLString.TABLE_TABLE_CELL)) {
|
||||
// Now we're here: Collect alignment
|
||||
if (OfficeReader.isSingleParagraph(cell)) {
|
||||
Node par = Misc.getChildByTagName(cell,XMLString.TEXT_P);
|
||||
|
@ -160,6 +160,7 @@ public class TableFormatter extends ConverterHelper {
|
|||
int nCol = 0;
|
||||
while (nCol<nColCount) {
|
||||
Node cell = table.getCell(nRow,nCol);
|
||||
if (cell!=null) {
|
||||
String sStyleName = Misc.getAttribute(cell,XMLString.TABLE_STYLE_NAME);
|
||||
StyleWithProperties style = ofr.getCellStyle(sStyleName);
|
||||
int nColSpan = Misc.getPosInteger(Misc.getAttribute(cell,
|
||||
|
@ -198,6 +199,10 @@ public class TableFormatter extends ConverterHelper {
|
|||
nCol++;
|
||||
} while (--nColSpan>0);
|
||||
}
|
||||
else { // Non-existing cell, treat as empty cell with no borders
|
||||
nCol++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Step 5: Create global vertical borders based on simple majority
|
||||
|
|
|
@ -16,11 +16,11 @@
|
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
||||
* MA 02111-1307 USA
|
||||
*
|
||||
* Copyright: 2002-2008 by Henrik Just
|
||||
* Copyright: 2002-2011 by Henrik Just
|
||||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.0 (2008-09-07)
|
||||
* Version 1.2 (2011-04-20)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -97,6 +97,7 @@ public class TableView {
|
|||
for (int nCol=0; nCol<=range.getLastCol(); nCol++) {
|
||||
if (nViewCol<nColCount && nColMap[nViewCol]<nCol) { nViewCol++; }
|
||||
Element cell = reader.getCell(nRow,nCol);
|
||||
if (cell!=null) {
|
||||
if (Misc.isElement(cell,XMLString.TABLE_TABLE_CELL)) {
|
||||
int nRowSpan = Misc.getPosInteger(cell.getAttribute(XMLString.TABLE_NUMBER_ROWS_SPANNED),1);
|
||||
int nColSpan = Misc.getPosInteger(cell.getAttribute(XMLString.TABLE_NUMBER_COLUMNS_SPANNED),1);
|
||||
|
@ -116,7 +117,7 @@ public class TableView {
|
|||
cells[nViewRow][nViewCol].nColSpan = j-nViewCol;
|
||||
}
|
||||
}
|
||||
if (Misc.isElement(cell,XMLString.TABLE_COVERED_TABLE_CELL)) {
|
||||
else if (Misc.isElement(cell,XMLString.TABLE_COVERED_TABLE_CELL)) {
|
||||
// Don't overwrite, the position may be occupied with a relocated cell
|
||||
if (cells[nViewRow][nViewCol].cell==null) {
|
||||
cells[nViewRow][nViewCol].cell=cell;
|
||||
|
@ -125,6 +126,19 @@ public class TableView {
|
|||
}
|
||||
}
|
||||
}
|
||||
else { // Non-existing cell, treat as empty
|
||||
// Test if the cell belongs the view
|
||||
if (nViewRow<nRowCount && nRowMap[nViewRow]<nRow+1 &&
|
||||
nViewCol<nColCount && nColMap[nViewCol]<nCol+1) {
|
||||
cells[nViewRow][nViewCol].cell=null;
|
||||
cells[nViewRow][nViewCol].nOriginalRow=nRow;
|
||||
cells[nViewRow][nViewCol].nOriginalCol=nCol;
|
||||
cells[nViewRow][nViewCol].nRowSpan = 1;
|
||||
cells[nViewRow][nViewCol].nColSpan = 1;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
*
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Version 1.2 (2011-03-21)
|
||||
* Version 1.2 (2011-04-20)
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -251,7 +251,8 @@ public class TableConverter extends ConverterHelper {
|
|||
|
||||
for (int nCol=0; nCol<view.getColCount(); nCol++) {
|
||||
Node cell = view.getCell(nRow,nCol);
|
||||
if (cell!=null && XMLString.TABLE_TABLE_CELL.equals(cell.getNodeName())) {
|
||||
if (cell!=null) {
|
||||
if (XMLString.TABLE_TABLE_CELL.equals(cell.getNodeName())) {
|
||||
// Create cell
|
||||
Element td = converter.createElement("td");
|
||||
tr.appendChild(td);
|
||||
|
@ -298,6 +299,10 @@ public class TableConverter extends ConverterHelper {
|
|||
// covered table cells are not part of xhtml table model
|
||||
}
|
||||
}
|
||||
else {
|
||||
// non-existing cell, not needed in the xhtml table model (it will probably be a trailing cell)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue