@@ -73,52 +73,54 @@ protected CollapsedTableBorders collapseAllBordersAndEmptyRows() {
73
73
CellRenderer [] currentRow ;
74
74
int [] rowspansToDeduct = new int [numberOfColumns ];
75
75
int numOfRowsToRemove = 0 ;
76
- for (int row = startRow - largeTableIndexOffset ; row <= finishRow - largeTableIndexOffset ; row ++) {
77
- currentRow = rows .isEmpty () ? null : rows .get (row );
78
- boolean hasCells = false ;
79
- for (int col = 0 ; col < numberOfColumns ; col ++) {
80
- if (null != currentRow && null != currentRow [col ]) {
81
- int colspan = (int ) currentRow [col ].getPropertyAsInteger (Property .COLSPAN );
82
- if (rowspansToDeduct [col ] > 0 ) {
83
- int rowspan = (int ) currentRow [col ].getPropertyAsInteger (Property .ROWSPAN ) - rowspansToDeduct [col ];
84
- if (rowspan < 1 ) {
85
- Logger logger = LoggerFactory .getLogger (TableRenderer .class );
86
- logger .warn (LogMessageConstant .UNEXPECTED_BEHAVIOUR_DURING_TABLE_ROW_COLLAPSING );
87
- rowspan = 1 ;
76
+ if (!rows .isEmpty ()) {
77
+ for (int row = startRow - largeTableIndexOffset ; row <= finishRow - largeTableIndexOffset ; row ++) {
78
+ currentRow = rows .get (row );
79
+ boolean hasCells = false ;
80
+ for (int col = 0 ; col < numberOfColumns ; col ++) {
81
+ if (null != currentRow && null != currentRow [col ]) {
82
+ int colspan = (int ) currentRow [col ].getPropertyAsInteger (Property .COLSPAN );
83
+ if (rowspansToDeduct [col ] > 0 ) {
84
+ int rowspan = (int ) currentRow [col ].getPropertyAsInteger (Property .ROWSPAN ) - rowspansToDeduct [col ];
85
+ if (rowspan < 1 ) {
86
+ Logger logger = LoggerFactory .getLogger (TableRenderer .class );
87
+ logger .warn (LogMessageConstant .UNEXPECTED_BEHAVIOUR_DURING_TABLE_ROW_COLLAPSING );
88
+ rowspan = 1 ;
89
+ }
90
+ currentRow [col ].setProperty (Property .ROWSPAN , rowspan );
91
+ if (0 != numOfRowsToRemove ) {
92
+ removeRows (row - numOfRowsToRemove , numOfRowsToRemove );
93
+ row -= numOfRowsToRemove ;
94
+ numOfRowsToRemove = 0 ;
95
+ }
88
96
}
89
- currentRow [col ].setProperty (Property .ROWSPAN , rowspan );
90
- if (0 != numOfRowsToRemove ) {
91
- removeRows (row - numOfRowsToRemove , numOfRowsToRemove );
92
- row -= numOfRowsToRemove ;
93
- numOfRowsToRemove = 0 ;
97
+ buildBordersArrays (currentRow [col ], row , col , rowspansToDeduct );
98
+ hasCells = true ;
99
+ for (int i = 0 ; i < colspan ; i ++) {
100
+ rowspansToDeduct [col + i ] = 0 ;
101
+ }
102
+ col += colspan - 1 ;
103
+ } else {
104
+ if (horizontalBorders .get (row ).size () <= col ) {
105
+ horizontalBorders .get (row ).add (null );
94
106
}
95
- }
96
- buildBordersArrays (currentRow [col ], row , col , rowspansToDeduct );
97
- hasCells = true ;
98
- for (int i = 0 ; i < colspan ; i ++) {
99
- rowspansToDeduct [col + i ] = 0 ;
100
- }
101
- col += colspan - 1 ;
102
- } else {
103
- if (horizontalBorders .get (row ).size () <= col ) {
104
- horizontalBorders .get (row ).add (null );
105
107
}
106
108
}
107
- }
108
- if (!hasCells ) {
109
- if (row == rows .size () - 1 ) {
110
- removeRows (row - rowspansToDeduct [0 ], rowspansToDeduct [0 ]);
111
- // delete current row
112
- rows .remove (row - rowspansToDeduct [0 ]);
113
- setFinishRow (finishRow - 1 );
114
-
115
- Logger logger = LoggerFactory .getLogger (TableRenderer .class );
116
- logger .warn (LogMessageConstant .LAST_ROW_IS_NOT_COMPLETE );
117
- } else {
118
- for (int i = 0 ; i < numberOfColumns ; i ++) {
119
- rowspansToDeduct [i ]++;
109
+ if (!hasCells ) {
110
+ if (row == rows .size () - 1 ) {
111
+ removeRows (row - rowspansToDeduct [0 ], rowspansToDeduct [0 ]);
112
+ // delete current row
113
+ rows .remove (row - rowspansToDeduct [0 ]);
114
+ setFinishRow (finishRow - 1 );
115
+
116
+ Logger logger = LoggerFactory .getLogger (TableRenderer .class );
117
+ logger .warn (LogMessageConstant .LAST_ROW_IS_NOT_COMPLETE );
118
+ } else {
119
+ for (int i = 0 ; i < numberOfColumns ; i ++) {
120
+ rowspansToDeduct [i ]++;
121
+ }
122
+ numOfRowsToRemove ++;
120
123
}
121
- numOfRowsToRemove ++;
122
124
}
123
125
}
124
126
}
0 commit comments