}
try {
- Integer iWidth = new Integer(tc.getColumnWidth().getValue() / 1000);
+ Integer iWidth =
+ new Integer(tc.getColumnWidth().getValue() / 1000);
String strWidth = iWidth.toString() + "pt";
- Float width = new Float(FoUnitsConverter.getInstance().convertToTwips(strWidth));
+ Float width = new Float(
+ FoUnitsConverter.getInstance().convertToTwips(strWidth));
builderContext.getTableContext().setNextColumnWidth(width);
- builderContext.getTableContext().setNextColumnRowSpanning(new Integer(0), null);
+ builderContext.getTableContext().setNextColumnRowSpanning(
+ new Integer(0), null);
+ builderContext.getTableContext().setNextFirstSpanningCol(false);
} catch (Exception e) {
log.error("startColumn: " + e.getMessage());
throw new RuntimeException(e.getMessage());
if (bDefer) {
return;
}
+
+ try {
+ TableContext tctx = builderContext.getTableContext();
+ final RtfTableRow row = (RtfTableRow)builderContext.getContainer(RtfTableRow.class,
+ true, null);
+
+ //while the current column is in row-spanning, act as if
+ //a vertical merged cell would have been specified.
+ while (tctx.getNumberOfColumns() > tctx.getColumnIndex()
+ && tctx.getColumnRowSpanningNumber().intValue() > 0) {
+ RtfTableCell vCell = row.newTableCellMergedVertically(
+ (int)tctx.getColumnWidth(),
+ tctx.getColumnRowSpanningAttrs());
+
+ if (!tctx.getFirstSpanningCol()) {
+ vCell.setHMerge(RtfTableCell.MERGE_WITH_PREVIOUS);
+ }
+
+ tctx.selectNextColumn();
+ }
+ } catch (Exception e) {
+ log.error("endRow: " + e.getMessage());
+ throw new RuntimeException(e.getMessage());
+ }
+
builderContext.popContainer();
builderContext.getTableContext().decreaseRowSpannings();
//a vertical merged cell would have been specified.
while (tctx.getNumberOfColumns() > tctx.getColumnIndex()
&& tctx.getColumnRowSpanningNumber().intValue() > 0) {
- row.newTableCellMergedVertically((int)tctx.getColumnWidth(),
+ RtfTableCell vCell = row.newTableCellMergedVertically(
+ (int)tctx.getColumnWidth(),
tctx.getColumnRowSpanningAttrs());
+
+ if (!tctx.getFirstSpanningCol()) {
+ vCell.setHMerge(RtfTableCell.MERGE_WITH_PREVIOUS);
+ }
+
tctx.selectNextColumn();
}
// create an RtfTableCell in the current RtfTableRow
RtfAttributes atts = TableAttributesConverter.convertCellAttributes(tc);
RtfTableCell cell = row.newTableCell((int)width, atts);
+
+ //process number-rows-spanned attribute
+ if (numberRowsSpanned > 1) {
+ // Start vertical merge
+ cell.setVMerge(RtfTableCell.MERGE_START);
-// process number-columns-spanned attribute
+ // set the number of rows spanned
+ tctx.setCurrentColumnRowSpanning(new Integer(numberRowsSpanned),
+ cell.getRtfAttributes());
+ } else {
+ tctx.setCurrentColumnRowSpanning(
+ new Integer(numberRowsSpanned), null);
+ }
+
+ //process number-columns-spanned attribute
if (numberColumnsSpanned > 0) {
// Get the number of columns spanned
RtfTable table = row.getTable();
+ tctx.setCurrentFirstSpanningCol(true);
// We widthdraw one cell because the first cell is already created
// (it's the current cell) !
- int i = numberColumnsSpanned - 1;
- while (i > 0) {
+ for (int i = 0; i < numberColumnsSpanned - 1; ++i) {
tctx.selectNextColumn();
- row.newTableCellMergedHorizontally(
+ tctx.setCurrentFirstSpanningCol(false);
+ RtfTableCell hCell = row.newTableCellMergedHorizontally(
0, null);
- i--;
+ if (numberRowsSpanned > 1) {
+ // Start vertical merge
+ hCell.setVMerge(RtfTableCell.MERGE_START);
+
+ // set the number of rows spanned
+ tctx.setCurrentColumnRowSpanning(
+ new Integer(numberRowsSpanned),
+ cell.getRtfAttributes());
+ } else {
+ tctx.setCurrentColumnRowSpanning(
+ new Integer(numberRowsSpanned), null);
+ }
}
}
- //process number-rows-spanned attribute
- if (numberRowsSpanned > 1) {
- // Start vertical merge
- cell.setVMerge(RtfTableCell.MERGE_START);
-
- // set the number of rows spanned
- tctx.setCurrentColumnRowSpanning(new Integer(numberRowsSpanned),
- cell.getRtfAttributes());
- } else {
- tctx.setCurrentColumnRowSpanning(new Integer(numberRowsSpanned), null);
- }
-
builderContext.pushContainer(cell);
} catch (Exception e) {
log.error("startCell: " + e.getMessage());
private int colIndex;
/**
- * Added by Peter Herweg on 2002-06-29
* This ArrayList contains one element for each column in the table.
* value == 0 means there is no row-spanning
* value > 0 means there is row-spanning
private final List colRowSpanningNumber = new java.util.ArrayList();
/**
- * Added by Peter Herweg on 2002-06-29
* If there has a vertical merged cell to be created, its attributes are
* inherited from the corresponding MERGE_START-cell.
* For this purpose the attributes of a cell are stored in this array, as soon
* as a number-rows-spanned attribute has been found.
*/
private final List colRowSpanningAttrs = new java.util.ArrayList();
+
+ /**
+ * This ArrayList contains one element for each column in the table.
+ * value == true means, it's the first of multiple spanned columns
+ * value == false meanst, it's NOT the first of multiple spanned columns
+ */
+ private final List colFirstSpanningCol = new java.util.ArrayList();
private boolean bNextRowBelongsToHeader = false;
public Integer getColumnRowSpanningNumber() {
return (Integer)colRowSpanningNumber.get(colIndex);
}
+
+ /**
+ *
+ * @return true, if it's the first of multiple spanning columns
+ */
+ public boolean getFirstSpanningCol() {
+ Boolean b = (Boolean) colFirstSpanningCol.get(colIndex);
+ return b.booleanValue();
+ }
/**
*
colRowSpanningNumber.add(iRowSpanning);
colRowSpanningAttrs.add(colIndex, attrs);
}
+
+ /**
+ *
+ * @param bFirstSpanningCol specifies, if it's the first of
+ * multiple spanned columns
+ */
+ public void setCurrentFirstSpanningCol(
+ boolean bFirstSpanningCol) {
+
+ if (colIndex < colRowSpanningNumber.size()) {
+ colFirstSpanningCol.set(colIndex, new Boolean(bFirstSpanningCol));
+ } else {
+ colFirstSpanningCol.add(new Boolean(bFirstSpanningCol));
+ }
+ }
+
+ /**
+ *
+ * @param bFirstSpanningCol specifies, if it's the first of
+ * multiple spanned columns
+ */
+ public void setNextFirstSpanningCol(
+ boolean bFirstSpanningCol) {
+ colFirstSpanningCol.add(new Boolean(bFirstSpanningCol));
+ }
/**
* Added by Peter Herweg on 2002-06-29
if (i.intValue() == 0) {
colRowSpanningAttrs.set(z, null);
+ colFirstSpanningCol.set(z, new Boolean(false));
}
}
}
colIndex = index;
}
- /** Added by Boris Poudérous on 07/22/2002 */
+ /**
+ * @return Index of current column
+ */
public int getColumnIndex() {
return colIndex;
}
/** - end - */
- /** Added by Boris Poudérous on 07/22/2002 */
+ /**
+ * @return Number of columns
+ */
public int getNumberOfColumns() {
return colWidths.size();
}