Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/TableCell.java9
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/TableLayoutGrid.java3
-rw-r--r--org.eclipse.vex.core/src/org/eclipse/vex/core/internal/visualization/CssBasedBoxModelBuilder.java20
3 files changed, 25 insertions, 7 deletions
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/TableCell.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/TableCell.java
index 938532f8..9c4c1551 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/TableCell.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/TableCell.java
@@ -31,6 +31,7 @@ public class TableCell extends BaseBox implements IStructuralBox, IDecoratorBox<
private String columnName;
private String startColumnName;
private String endColumnName;
+ private int horizontalSpan = 1;
private int verticalSpan = 1;
private GridArea gridArea;
@@ -149,6 +150,14 @@ public class TableCell extends BaseBox implements IStructuralBox, IDecoratorBox<
this.endColumnName = endColumnName;
}
+ public int getHorizontalSpan() {
+ return horizontalSpan;
+ }
+
+ public void setHorizontalSpan(final int horizontalSpan) {
+ this.horizontalSpan = horizontalSpan;
+ }
+
public int getVerticalSpan() {
return verticalSpan;
}
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/TableLayoutGrid.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/TableLayoutGrid.java
index cd40f5f2..6f99e57e 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/TableLayoutGrid.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/boxes/TableLayoutGrid.java
@@ -125,6 +125,7 @@ public class TableLayoutGrid {
currentRow = rows.size();
row.setRowIndex(currentRow);
nextColumn = 1;
+ updateNextColumn();
return currentRow;
}
@@ -141,7 +142,7 @@ public class TableLayoutGrid {
}
private void addNextCellOnCurrentRow(final TableCell cell) {
- final GridArea area = new GridArea(currentRow, nextColumn, currentRow + cell.getVerticalSpan() - 1, nextColumn);
+ final GridArea area = new GridArea(currentRow, nextColumn, currentRow + cell.getVerticalSpan() - 1, nextColumn + cell.getHorizontalSpan() - 1);
occupy(area, cell);
cell.setGridArea(area);
cell.setLayoutGrid(this);
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/visualization/CssBasedBoxModelBuilder.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/visualization/CssBasedBoxModelBuilder.java
index 14c2d241..9ccc2b52 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/visualization/CssBasedBoxModelBuilder.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/visualization/CssBasedBoxModelBuilder.java
@@ -282,7 +282,7 @@ public class CssBasedBoxModelBuilder implements IBoxModelBuilder {
if ("colspec".equals(element.getLocalName())) {
name = toString(element.getAttribute("colname"));
- startIndex = toInt(element.getAttribute("colnum"));
+ startIndex = toInt(element.getAttribute("colnum"), 0);
endIndex = startIndex;
startName = null;
endName = null;
@@ -338,7 +338,7 @@ public class CssBasedBoxModelBuilder implements IBoxModelBuilder {
if ("entry".equals(element.getLocalName())) {
configureCALSCell(element, cell);
} else if ("th".equals(element.getLocalName()) || "td".equals(element.getLocalName())) {
- // TODO HTML table
+ configureHTMLCell(element, cell);
}
return wrapWithNodeReference(element, childrenResults, cell);
@@ -361,17 +361,25 @@ public class CssBasedBoxModelBuilder implements IBoxModelBuilder {
}
final IAttribute moreRows = element.getAttribute("morerows");
- cell.setVerticalSpan(1 + toInt(moreRows));
+ cell.setVerticalSpan(1 + toInt(moreRows, 0));
+ }
+
+ private static void configureHTMLCell(final IElement element, final TableCell cell) {
+ final IAttribute colSpan = element.getAttribute("colspan");
+ cell.setHorizontalSpan(toInt(colSpan, 1));
+
+ final IAttribute rowSpan = element.getAttribute("rowspan");
+ cell.setVerticalSpan(toInt(rowSpan, 1));
}
- private static int toInt(final IAttribute attribute) {
+ private static int toInt(final IAttribute attribute, final int defaultValue) {
if (attribute == null) {
- return 0;
+ return defaultValue;
}
try {
return Integer.parseInt(attribute.getValue());
} catch (final NumberFormatException e) {
- return 0;
+ return defaultValue;
}
}

Back to the top