import java.util.List;
import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
-import org.apache.fop.layoutmgr.table.GridUnit;
/**
* A class that implements the border-collapsing model.
--- /dev/null
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.fo.flow.table;
+
+import org.apache.fop.fo.Constants;
+import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
+
+/**
+ * GridUnit subclass for empty grid units.
+ */
+public class EmptyGridUnit extends GridUnit {
+
+ private TableRow row;
+ private TableBody body;
+
+ /**
+ * @param table the containing table
+ * @param startRow index of the row this grid unit belongs to, 0-based
+ * @param startCol column index, 0-based
+ */
+ public EmptyGridUnit(Table table, int startRow, int startCol) {
+ super(table, table.getColumn(startCol), startCol, 0, 0);
+ }
+
+ /** {@inheritDoc} */
+ protected void setBorder(int side) {
+ resolvedBorders[side] = new BorderSpecification(
+ new CommonBorderPaddingBackground.BorderInfo(Constants.EN_NONE, null, null),
+ Constants.FO_TABLE_CELL);
+ }
+
+ /** {@inheritDoc} */
+ public PrimaryGridUnit getPrimary() {
+ throw new UnsupportedOperationException();
+// return this; TODO
+ }
+
+ /** {@inheritDoc} */
+ public boolean isPrimary() {
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ public TableBody getBody() {
+ return this.body;
+ }
+
+ /** {@inheritDoc} */
+ public TableRow getRow() {
+ return this.row;
+ }
+
+ /** {@inheritDoc} */
+ public boolean isLastGridUnitColSpan() {
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ public boolean isLastGridUnitRowSpan() {
+ return true;
+ }
+}
import java.util.ListIterator;
import org.apache.fop.fo.ValidationException;
-import org.apache.fop.layoutmgr.table.EmptyGridUnit;
-import org.apache.fop.layoutmgr.table.GridUnit;
-import org.apache.fop.layoutmgr.table.PrimaryGridUnit;
/**
--- /dev/null
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.fo.flow.table;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.fop.fo.FONode;
+import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
+import org.apache.fop.fo.properties.CommonBorderPaddingBackground.BorderInfo;
+import org.apache.fop.layoutmgr.table.CollapsingBorderModel;
+
+/**
+ * This class represents one grid unit inside a table.
+ */
+public class GridUnit {
+
+ private static Log log = LogFactory.getLog(GridUnit.class);
+
+ /** Indicates that the grid unit is in the first column. */
+ public static final int IN_FIRST_COLUMN = 0;
+
+ /** Indicates that the grid unit is in the last column. */
+ public static final int IN_LAST_COLUMN = 1;
+
+ /** Indicates that the grid unit is in the first row of the table. */
+ public static final int FIRST_IN_TABLE = 2;
+
+ /**
+ * Indicates that the grid unit is in the first row of the table part (header, footer,
+ * body).
+ */
+ public static final int FIRST_IN_PART = 3;
+
+ /**
+ * Indicates that the grid unit is in the last row of the table part (header, footer,
+ * body).
+ */
+ public static final int LAST_IN_PART = 4;
+
+ /** Indicates that the grid unit is in the last row of the table. */
+ public static final int LAST_IN_TABLE = 5;
+
+ /** Indicates that the primary grid unit has a pending keep-with-next. */
+ public static final int KEEP_WITH_NEXT_PENDING = 6;
+
+ /** Indicates that the primary grid unit has a pending keep-with-previous. */
+ public static final int KEEP_WITH_PREVIOUS_PENDING = 7;
+
+ /** Primary grid unit */
+ private PrimaryGridUnit primary;
+
+ /** Table cell which occupies this grid unit */
+ protected TableCell cell;
+
+ /** Table row which occupies this grid unit (may be null) */
+ private TableRow row;
+
+ /** Table column that this grid unit belongs to */
+ private TableColumn column;
+
+ /** start index of grid unit within row in column direction */
+ private int startCol;
+
+ /** index of grid unit within cell in column direction */
+ private int colSpanIndex;
+
+ /** index of grid unit within cell in row direction */
+ private int rowSpanIndex;
+
+ /** effective borders for a cell slot */
+ private CommonBorderPaddingBackground effectiveBorders;
+
+ /** flags for the grid unit */
+ private byte flags = 0;
+
+ protected BorderSpecification[] resolvedBorders;
+
+ private CollapsingBorderModel collapsingBorderModel;
+
+ /**
+ * Creates a new grid unit.
+ *
+ * @param table the containing table
+ * @param column table column this grid unit belongs to
+ * @param startCol index of the column this grid unit belongs to
+ * @param colSpanIndex index of this grid unit in the span, in column direction
+ * @param rowSpanIndex index of this grid unit in the span, in row direction
+ */
+ protected GridUnit(Table table, TableColumn column, int startCol, int colSpanIndex,
+ int rowSpanIndex) {
+ this(column, startCol, colSpanIndex, rowSpanIndex);
+ setBorders(table);
+ }
+
+ /**
+ * Creates a new grid unit.
+ *
+ * @param cell table cell which occupies this grid unit
+ * @param column table column this grid unit belongs to
+ * @param startCol index of the column this grid unit belongs to
+ * @param colSpanIndex index of this grid unit in the span, in column direction
+ * @param rowSpanIndex index of this grid unit in the span, in row direction
+ */
+ protected GridUnit(TableCell cell, TableColumn column, int startCol, int colSpanIndex,
+ int rowSpanIndex) {
+ this(column, startCol, colSpanIndex, rowSpanIndex);
+ this.cell = cell;
+ setBorders(cell.getTable());
+ }
+
+ /**
+ * Creates a new grid unit.
+ *
+ * @param primary the before-start grid unit of the cell containing this grid unit
+ * @param column table column this grid unit belongs to
+ * @param startCol index of the column this grid unit belongs to
+ * @param colSpanIndex index of this grid unit in the span, in column direction
+ * @param rowSpanIndex index of this grid unit in the span, in row direction
+ */
+ public GridUnit(PrimaryGridUnit primary, TableColumn column, int startCol, int colSpanIndex,
+ int rowSpanIndex) {
+ this(primary.getCell(), column, startCol, colSpanIndex, rowSpanIndex);
+ this.primary = primary;
+ }
+
+ private GridUnit(TableColumn column, int startCol, int colSpanIndex, int rowSpanIndex) {
+ this.column = column;
+ this.startCol = startCol;
+ this.colSpanIndex = colSpanIndex;
+ this.rowSpanIndex = rowSpanIndex;
+ }
+
+ private void setBorders(Table table/*TODO*/) {
+ if (table.isSeparateBorderModel()) {
+ assignBorderForSeparateBorderModel();
+ } else {
+ resolvedBorders = new BorderSpecification[4];
+ collapsingBorderModel = CollapsingBorderModel.getBorderModelFor(table
+ .getBorderCollapse());
+ if (rowSpanIndex == 0) {
+ setBorder(CommonBorderPaddingBackground.BEFORE);
+ }
+ if (isLastGridUnitRowSpan()) {
+ setBorder(CommonBorderPaddingBackground.AFTER);
+ }
+ if (colSpanIndex == 0) {
+ setBorder(CommonBorderPaddingBackground.START);
+ }
+ if (isLastGridUnitColSpan()) {
+ setBorder(CommonBorderPaddingBackground.END);
+ }
+ }
+ }
+
+ protected void setBorder(int side) {
+ resolvedBorders[side] = cell.resolvedBorders[side];
+ }
+
+ public TableCell getCell() {
+ return cell;
+ }
+
+ public TableColumn getColumn() {
+ return column;
+ }
+
+ public TableRow getRow() {
+ if (row != null) {
+ return row;
+ } else if (getCell().getParent() instanceof TableRow) {
+ return (TableRow) getCell().getParent();
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Sets the table-row FO, if applicable.
+ *
+ * @param row the table-row FO
+ */
+ public void setRow(TableRow row) {
+ this.row = row;
+ }
+
+ public TableBody getBody() {
+ FONode node = getCell();
+ while (node != null && !(node instanceof TableBody)) {
+ node = node.getParent();
+ }
+ return (TableBody) node;
+ }
+
+ /**
+ * Returns the before-start grid unit of the cell containing this grid unit.
+ *
+ * @return the before-start grid unit of the cell containing this grid unit.
+ */
+ public PrimaryGridUnit getPrimary() {
+ return primary;
+ }
+
+ /**
+ * Is this grid unit the before-start grid unit of the cell?
+ *
+ * @return true if this grid unit is the before-start grid unit of the cell
+ */
+ public boolean isPrimary() {
+ return false;
+ }
+
+ /**
+ * Does this grid unit belong to an empty cell?
+ *
+ * @return true if this grid unit belongs to an empty cell
+ */
+ public boolean isEmpty() {
+ return cell == null;
+ }
+
+ public int getStartCol() {
+ return startCol;
+ }
+
+ /** @return true if the grid unit is the last in column spanning direction */
+ public boolean isLastGridUnitColSpan() {
+ return (colSpanIndex == cell.getNumberColumnsSpanned() - 1);
+ }
+
+ /** @return true if the grid unit is the last in row spanning direction */
+ public boolean isLastGridUnitRowSpan() {
+ return (rowSpanIndex == cell.getNumberRowsSpanned() - 1);
+ }
+
+ /**
+ * @return the index of the grid unit inside a cell in row direction
+ */
+ public int getRowSpanIndex() {
+ return rowSpanIndex;
+ }
+
+ /**
+ * @return the index of the grid unit inside a cell in column direction
+ */
+ public int getColSpanIndex() {
+ return colSpanIndex;
+ }
+
+ /**
+ * Returns a BorderInfo instance for a side of the currently applicable cell before
+ * border resolution (i.e. the value from the FO). A return value of null indicates an
+ * empty cell. See CollapsingBorderModel(EyeCatching) where this method is used.
+ *
+ * @param side for which side to return the BorderInfo
+ * @return the requested BorderInfo instance or null if the grid unit is an empty cell
+ */
+ public BorderInfo getOriginalBorderInfoForCell(int side) {
+ if (cell != null) {
+ return cell.getCommonBorderPaddingBackground().getBorderInfo(side);
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * @return the resolved normal borders for this grid unit
+ */
+ public CommonBorderPaddingBackground getBorders() {
+ // TODO
+ if (effectiveBorders == null) {
+ effectiveBorders = new CommonBorderPaddingBackground();
+ setBorderInfo(CommonBorderPaddingBackground.BEFORE);
+ setBorderInfo(CommonBorderPaddingBackground.AFTER);
+ setBorderInfo(CommonBorderPaddingBackground.START);
+ setBorderInfo(CommonBorderPaddingBackground.END);
+ if (cell != null) {
+ effectiveBorders.setPadding(cell.getCommonBorderPaddingBackground());
+ }
+ if (log.isDebugEnabled()) {
+ log.debug(this + " resolved borders: " + "before="
+ + effectiveBorders.getBorderBeforeWidth(false) + ", " + "after="
+ + effectiveBorders.getBorderAfterWidth(false) + ", " + "start="
+ + effectiveBorders.getBorderStartWidth(false) + ", " + "end="
+ + effectiveBorders.getBorderEndWidth(false));
+ }
+ }
+ return effectiveBorders;
+ }
+
+ private void setBorderInfo(int side) {
+ if (resolvedBorders[side] != null) {
+ effectiveBorders.setBorderInfo(resolvedBorders[side].getBorderInfo(), side);
+ }
+ }
+
+ /**
+ * @return true if the grid unit has any borders.
+ */
+ public boolean hasBorders() {
+ return (getBorders() != null) && getBorders().hasBorder();
+ }
+
+ /**
+ * Assigns the borders from the given cell to this cell info. Used in case of separate
+ * border model.
+ */
+ public void assignBorderForSeparateBorderModel() {
+ if (cell != null) {
+ effectiveBorders = cell.getCommonBorderPaddingBackground();
+ }
+ }
+
+ /**
+ * Resolve collapsing borders for the given cell. Used in case of the collapsing
+ * border model.
+ *
+ * @param other neighbouring grid unit
+ * @param side the side to resolve (one of
+ * CommonBorderPaddingBackground.BEFORE|AFTER|START|END)
+ */
+ public void resolveBorder(GridUnit other, int side) {
+ BorderSpecification resolvedBorder = collapsingBorderModel.determineWinner(
+ resolvedBorders[side], other.resolvedBorders[CollapsingBorderModel
+ .getOtherSide(side)]);
+ if (resolvedBorder != null) {
+ this.resolvedBorders[side] = resolvedBorder;
+ other.resolvedBorders[CollapsingBorderModel.getOtherSide(side)] = resolvedBorder;
+ }
+ }
+
+ /**
+ * Resolves the border on the given side of this grid unit, comparing it against the
+ * same border of the given parent element.
+ *
+ * @param side the side to resolve (one of
+ * CommonBorderPaddingBackground.BEFORE|AFTER|START|END)
+ * @param parent the parent element holding a competing border
+ */
+ public void resolveBorder(int side, TableFObj parent) {
+ resolvedBorders[side] = collapsingBorderModel.determineWinner(resolvedBorders[side],
+ parent.resolvedBorders[side]);
+ }
+
+ /**
+ * Returns a flag for this GridUnit.
+ *
+ * @param which the requested flag
+ * @return the value of the flag
+ */
+ public boolean getFlag(int which) {
+ return (flags & (1 << which)) != 0;
+ }
+
+ /**
+ * Sets a flag on a GridUnit.
+ *
+ * @param which the flag to set
+ * @param value the new value for the flag
+ */
+ public void setFlag(int which, boolean value) {
+ if (value) {
+ flags |= (1 << which); // set flag
+ } else {
+ flags &= ~(1 << which); // clear flag
+ }
+ }
+
+ /**
+ * Sets the given flag on this grid unit.
+ *
+ * @param which the flag to set
+ */
+ public void setFlag(int which) {
+ setFlag(which, true);
+ }
+
+ /** {@inheritDoc} */
+ public String toString() {
+ StringBuffer buffer = new StringBuffer();
+ if (isEmpty()) {
+ buffer.append("EMPTY");
+ } else if (isPrimary()) {
+ buffer.append("Primary");
+ }
+ buffer.append("GridUnit:");
+ if (colSpanIndex > 0) {
+ buffer.append(" colSpan=").append(colSpanIndex);
+ if (isLastGridUnitColSpan()) {
+ buffer.append("(last)");
+ }
+ }
+ if (rowSpanIndex > 0) {
+ buffer.append(" rowSpan=").append(rowSpanIndex);
+ if (isLastGridUnitRowSpan()) {
+ buffer.append("(last)");
+ }
+ }
+ buffer.append(" startCol=").append(startCol);
+ if (!isPrimary() && getPrimary() != null) {
+ buffer.append(" primary=").append(getPrimary().getStartRow());
+ buffer.append("/").append(getPrimary().getStartCol());
+ if (getPrimary().getCell() != null) {
+ buffer.append(" id=" + getPrimary().getCell().getId());
+ }
+ }
+ buffer.append(" flags=").append(Integer.toBinaryString(flags));
+ return buffer.toString();
+ }
+
+}
--- /dev/null
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.fo.flow.table;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.fop.layoutmgr.table.TableCellLayoutManager;
+
+/**
+ * This class represents a primary grid unit of a spanned cell. This is the "before-start"
+ * (top-left, usually) grid unit of the span.
+ */
+public class PrimaryGridUnit extends GridUnit {
+
+ private static Log log = LogFactory.getLog(PrimaryGridUnit.class);
+
+ /** Cell layout manager. */
+ private TableCellLayoutManager cellLM;
+ /** List of Knuth elements representing the contents of the cell. */
+ private LinkedList elements;
+ /** Index of row where this cell starts */
+ private int startRow;
+ /** Links to the spanned grid units. (List of GridUnit arrays, one array represents a row) */
+ private List rows;
+ /** The calculated size of the cell's content. (cached value) */
+ private int contentLength = -1;
+
+ /**
+ * Creates a new primary grid unit.
+ *
+ * @param cell table cell which occupies this grid unit
+ * @param column table column this grid unit belongs to
+ * @param startCol index of the column this grid unit belongs to, zero-based
+ * @param startRow index of the row this grid unit belongs to, zero-based
+ */
+ public PrimaryGridUnit(TableCell cell, TableColumn column, int startCol, int startRow) {
+ super(cell, column, startCol, 0, 0);
+ this.startRow = startRow;
+ log.trace("PrimaryGridUnit created, row " + startRow + " col " + startCol);
+ }
+
+ public TableCellLayoutManager getCellLM() {
+ assert cellLM != null;
+ return cellLM;
+ }
+
+ /** {@inheritDoc} */
+ public PrimaryGridUnit getPrimary() {
+ return this;
+ }
+
+ /** {@inheritDoc} */
+ public boolean isPrimary() {
+ return true;
+ }
+
+ /**
+ * Sets the Knuth elements for the table cell containing this grid unit.
+ *
+ * @param elements a list of ListElement (?)
+ */
+ public void setElements(LinkedList elements) {
+ this.elements = elements;
+ }
+
+ public LinkedList getElements() {
+ return this.elements;
+ }
+
+ /**
+ * @return half the maximum before border width of this cell.
+ */
+ public int getHalfMaxBeforeBorderWidth() {
+ int value = 0;
+ if (getRows() != null) {
+ int before = 0;
+ //first row for before borders
+ GridUnit[] row = (GridUnit[])getRows().get(0);
+ for (int i = 0; i < row.length; i++) {
+ if (row[i].hasBorders()) {
+ before = Math.max(before,
+ row[i].getBorders().getBorderBeforeWidth(false));
+ }
+ }
+ value += before / 2;
+ } else {
+ if (hasBorders()) {
+ value += getBorders().getBorderBeforeWidth(false) / 2;
+ }
+ }
+ return value;
+ }
+
+ /**
+ * @return half the maximum after border width of this cell.
+ */
+ public int getHalfMaxAfterBorderWidth() {
+ int value = 0;
+ if (getRows() != null) {
+ //Last row for after borders
+ int after = 0;
+ GridUnit[] row = (GridUnit[])getRows().get(getRows().size() - 1);
+ for (int i = 0; i < row.length; i++) {
+ if (row[i].hasBorders()) {
+ after = Math.max(after, row[i].getBorders().getBorderAfterWidth(false));
+ }
+ }
+ value += after / 2;
+ } else {
+ if (hasBorders()) {
+ value += getBorders().getBorderAfterWidth(false) / 2;
+ }
+ }
+ return value;
+ }
+
+ /**
+ * @return the sum of half the maximum before and after border
+ * widths of this cell.
+ */
+ public int getHalfMaxBorderWidth() {
+ return getHalfMaxBeforeBorderWidth() + getHalfMaxAfterBorderWidth();
+ }
+
+ /** @param value The length of the cell content to remember. */
+ public void setContentLength(int value) {
+ this.contentLength = value;
+ }
+
+ /** @return the length of the cell content. */
+ public int getContentLength() {
+ return contentLength;
+ }
+
+ /** @return true if cell/row has an explicit BPD/height */
+ public boolean hasBPD() {
+ if (!getCell().getBlockProgressionDimension().getOptimum(null).isAuto()) {
+ return true;
+ }
+ if (getRow() != null
+ && !getRow().getBlockProgressionDimension().getOptimum(null).isAuto()) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Returns the grid units belonging to the same span as this one.
+ *
+ * @return a list of GridUnit[], each array corresponds to a row
+ */
+ public List getRows() {
+ return this.rows;
+ }
+
+ public void addRow(GridUnit[] row) {
+ if (rows == null) {
+ rows = new java.util.ArrayList();
+ }
+ rows.add(row);
+ }
+
+ /**
+ * Returns the index of the row this grid unit belongs to.
+ *
+ * @return the index of the row this grid unit belongs to.
+ */
+ public int getStartRow() {
+ return this.startRow;
+ }
+
+ /**
+ * Returns the widths of the start- and end-borders of the span this grid unit belongs
+ * to.
+ *
+ * @return a two-element array containing the widths of the start-border then the
+ * end-border
+ */
+ public int[] getStartEndBorderWidths() {
+ int[] widths = new int[2];
+ if (rows == null) {
+ widths[0] = getBorders().getBorderStartWidth(false);
+ widths[1] = getBorders().getBorderEndWidth(false);
+ } else {
+ for (int i = 0; i < rows.size(); i++) {
+ GridUnit[] gridUnits = (GridUnit[])rows.get(i);
+ widths[0] = Math.max(widths[0],
+ (gridUnits[0]).
+ getBorders().getBorderStartWidth(false));
+ widths[1] = Math.max(widths[1],
+ (gridUnits[gridUnits.length - 1]).
+ getBorders().getBorderEndWidth(false));
+ }
+ }
+ return widths;
+ }
+
+ /** {@inheritDoc} */
+ public String toString() {
+ StringBuffer sb = new StringBuffer(super.toString());
+ sb.append(" startRow=").append(startRow);
+ return sb.toString();
+ }
+
+ /** @return true if this cell spans over more than one grid unit. */
+ public boolean hasSpanning() {
+ return (getCell().getNumberColumnsSpanned() > 1)
+ || (getCell().getNumberRowsSpanned() > 1);
+ }
+
+ /**
+ * Creates a cellLM for the corresponding table-cell. A new one must be created
+ * for each new static-content (TODO).
+ */
+ public void createCellLM() {
+ cellLM = new TableCellLayoutManager(cell, this);
+ }
+
+}
package org.apache.fop.fo.flow.table;
import org.apache.fop.fo.ValidationException;
-import org.apache.fop.layoutmgr.table.GridUnit;
/**
* A class that creates groups of rows belonging to a same set of spans. The first row of
import java.util.List;
import java.util.ListIterator;
+import org.apache.fop.fo.flow.table.GridUnit;
+import org.apache.fop.fo.flow.table.PrimaryGridUnit;
import org.apache.fop.layoutmgr.ElementListUtils;
import org.apache.fop.layoutmgr.KnuthBox;
import org.apache.fop.layoutmgr.KnuthElement;
* @param side the side on the current cell
* @return the adjacent side on the neighbouring cell
*/
- static int getOtherSide(int side) {
+ public/*TODO*/ static int getOtherSide(int side) {
switch (side) {
case CommonBorderPaddingBackground.BEFORE:
return CommonBorderPaddingBackground.AFTER;
import java.util.Iterator;
import java.util.List;
+import org.apache.fop.fo.flow.table.GridUnit;
import org.apache.fop.fo.flow.table.TableRow;
import org.apache.fop.traits.MinOptMax;
+++ /dev/null
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* $Id$ */
-
-package org.apache.fop.layoutmgr.table;
-
-import org.apache.fop.fo.Constants;
-import org.apache.fop.fo.flow.table.BorderSpecification;
-import org.apache.fop.fo.flow.table.Table;
-import org.apache.fop.fo.flow.table.TableBody;
-import org.apache.fop.fo.flow.table.TableRow;
-import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
-
-/**
- * GridUnit subclass for empty grid units.
- */
-public class EmptyGridUnit extends GridUnit {
-
- private TableRow row;
- private TableBody body;
-
- /**
- * @param table the containing table
- * @param startRow index of the row this grid unit belongs to, 0-based
- * @param startCol column index, 0-based
- */
- public EmptyGridUnit(Table table, int startRow, int startCol) {
- super(table, table.getColumn(startCol), startCol, 0, 0);
- }
-
- /** {@inheritDoc} */
- protected void setBorder(int side) {
- resolvedBorders[side] = new BorderSpecification(
- new CommonBorderPaddingBackground.BorderInfo(Constants.EN_NONE, null, null),
- Constants.FO_TABLE_CELL);
- }
-
- /** {@inheritDoc} */
- public PrimaryGridUnit getPrimary() {
- throw new UnsupportedOperationException();
-// return this; TODO
- }
-
- /** {@inheritDoc} */
- public boolean isPrimary() {
- return true;
- }
-
- /** {@inheritDoc} */
- public TableBody getBody() {
- return this.body;
- }
-
- /** {@inheritDoc} */
- public TableRow getRow() {
- return this.row;
- }
-
- /** {@inheritDoc} */
- public boolean isLastGridUnitColSpan() {
- return true;
- }
-
- /** {@inheritDoc} */
- public boolean isLastGridUnitRowSpan() {
- return true;
- }
-}
+++ /dev/null
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* $Id$ */
-
-package org.apache.fop.layoutmgr.table;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.fop.fo.FONode;
-import org.apache.fop.fo.flow.table.BorderSpecification;
-import org.apache.fop.fo.flow.table.Table;
-import org.apache.fop.fo.flow.table.TableBody;
-import org.apache.fop.fo.flow.table.TableCell;
-import org.apache.fop.fo.flow.table.TableColumn;
-import org.apache.fop.fo.flow.table.TableFObj;
-import org.apache.fop.fo.flow.table.TableRow;
-import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
-import org.apache.fop.fo.properties.CommonBorderPaddingBackground.BorderInfo;
-
-/**
- * This class represents one grid unit inside a table.
- */
-public class GridUnit {
-
- private static Log log = LogFactory.getLog(GridUnit.class);
-
- /** Indicates that the grid unit is in the first column. */
- public static final int IN_FIRST_COLUMN = 0;
-
- /** Indicates that the grid unit is in the last column. */
- public static final int IN_LAST_COLUMN = 1;
-
- /** Indicates that the grid unit is in the first row of the table. */
- public static final int FIRST_IN_TABLE = 2;
-
- /**
- * Indicates that the grid unit is in the first row of the table part (header, footer,
- * body).
- */
- public static final int FIRST_IN_PART = 3;
-
- /**
- * Indicates that the grid unit is in the last row of the table part (header, footer,
- * body).
- */
- public static final int LAST_IN_PART = 4;
-
- /** Indicates that the grid unit is in the last row of the table. */
- public static final int LAST_IN_TABLE = 5;
-
- /** Indicates that the primary grid unit has a pending keep-with-next. */
- public static final int KEEP_WITH_NEXT_PENDING = 6;
-
- /** Indicates that the primary grid unit has a pending keep-with-previous. */
- public static final int KEEP_WITH_PREVIOUS_PENDING = 7;
-
- /** Primary grid unit */
- private PrimaryGridUnit primary;
-
- /** Table cell which occupies this grid unit */
- protected TableCell cell;
-
- /** Table row which occupies this grid unit (may be null) */
- private TableRow row;
-
- /** Table column that this grid unit belongs to */
- private TableColumn column;
-
- /** start index of grid unit within row in column direction */
- private int startCol;
-
- /** index of grid unit within cell in column direction */
- private int colSpanIndex;
-
- /** index of grid unit within cell in row direction */
- private int rowSpanIndex;
-
- /** effective borders for a cell slot */
- private CommonBorderPaddingBackground effectiveBorders;
-
- /** flags for the grid unit */
- private byte flags = 0;
-
- protected BorderSpecification[] resolvedBorders;
-
- private CollapsingBorderModel collapsingBorderModel;
-
- /**
- * Creates a new grid unit.
- *
- * @param table the containing table
- * @param column table column this grid unit belongs to
- * @param startCol index of the column this grid unit belongs to
- * @param colSpanIndex index of this grid unit in the span, in column direction
- * @param rowSpanIndex index of this grid unit in the span, in row direction
- */
- protected GridUnit(Table table, TableColumn column, int startCol, int colSpanIndex,
- int rowSpanIndex) {
- this(column, startCol, colSpanIndex, rowSpanIndex);
- setBorders(table);
- }
-
- /**
- * Creates a new grid unit.
- *
- * @param cell table cell which occupies this grid unit
- * @param column table column this grid unit belongs to
- * @param startCol index of the column this grid unit belongs to
- * @param colSpanIndex index of this grid unit in the span, in column direction
- * @param rowSpanIndex index of this grid unit in the span, in row direction
- */
- protected GridUnit(TableCell cell, TableColumn column, int startCol, int colSpanIndex,
- int rowSpanIndex) {
- this(column, startCol, colSpanIndex, rowSpanIndex);
- this.cell = cell;
- setBorders(cell.getTable());
- }
-
- /**
- * Creates a new grid unit.
- *
- * @param primary the before-start grid unit of the cell containing this grid unit
- * @param column table column this grid unit belongs to
- * @param startCol index of the column this grid unit belongs to
- * @param colSpanIndex index of this grid unit in the span, in column direction
- * @param rowSpanIndex index of this grid unit in the span, in row direction
- */
- public GridUnit(PrimaryGridUnit primary, TableColumn column, int startCol, int colSpanIndex,
- int rowSpanIndex) {
- this(primary.getCell(), column, startCol, colSpanIndex, rowSpanIndex);
- this.primary = primary;
- }
-
- private GridUnit(TableColumn column, int startCol, int colSpanIndex, int rowSpanIndex) {
- this.column = column;
- this.startCol = startCol;
- this.colSpanIndex = colSpanIndex;
- this.rowSpanIndex = rowSpanIndex;
- }
-
- private void setBorders(Table table/*TODO*/) {
- if (table.isSeparateBorderModel()) {
- assignBorderForSeparateBorderModel();
- } else {
- resolvedBorders = new BorderSpecification[4];
- collapsingBorderModel = CollapsingBorderModel.getBorderModelFor(table
- .getBorderCollapse());
- if (rowSpanIndex == 0) {
- setBorder(CommonBorderPaddingBackground.BEFORE);
- }
- if (isLastGridUnitRowSpan()) {
- setBorder(CommonBorderPaddingBackground.AFTER);
- }
- if (colSpanIndex == 0) {
- setBorder(CommonBorderPaddingBackground.START);
- }
- if (isLastGridUnitColSpan()) {
- setBorder(CommonBorderPaddingBackground.END);
- }
- }
- }
-
- protected void setBorder(int side) {
- resolvedBorders[side] = cell.resolvedBorders[side];
- }
-
- public TableCell getCell() {
- return cell;
- }
-
- public TableColumn getColumn() {
- return column;
- }
-
- public TableRow getRow() {
- if (row != null) {
- return row;
- } else if (getCell().getParent() instanceof TableRow) {
- return (TableRow) getCell().getParent();
- } else {
- return null;
- }
- }
-
- /**
- * Sets the table-row FO, if applicable.
- *
- * @param row the table-row FO
- */
- public void setRow(TableRow row) {
- this.row = row;
- }
-
- public TableBody getBody() {
- FONode node = getCell();
- while (node != null && !(node instanceof TableBody)) {
- node = node.getParent();
- }
- return (TableBody) node;
- }
-
- /**
- * Returns the before-start grid unit of the cell containing this grid unit.
- *
- * @return the before-start grid unit of the cell containing this grid unit.
- */
- public PrimaryGridUnit getPrimary() {
- return primary;
- }
-
- /**
- * Is this grid unit the before-start grid unit of the cell?
- *
- * @return true if this grid unit is the before-start grid unit of the cell
- */
- public boolean isPrimary() {
- return false;
- }
-
- /**
- * Does this grid unit belong to an empty cell?
- *
- * @return true if this grid unit belongs to an empty cell
- */
- public boolean isEmpty() {
- return cell == null;
- }
-
- public int getStartCol() {
- return startCol;
- }
-
- /** @return true if the grid unit is the last in column spanning direction */
- public boolean isLastGridUnitColSpan() {
- return (colSpanIndex == cell.getNumberColumnsSpanned() - 1);
- }
-
- /** @return true if the grid unit is the last in row spanning direction */
- public boolean isLastGridUnitRowSpan() {
- return (rowSpanIndex == cell.getNumberRowsSpanned() - 1);
- }
-
- /**
- * @return the index of the grid unit inside a cell in row direction
- */
- public int getRowSpanIndex() {
- return rowSpanIndex;
- }
-
- /**
- * @return the index of the grid unit inside a cell in column direction
- */
- public int getColSpanIndex() {
- return colSpanIndex;
- }
-
- /**
- * Returns a BorderInfo instance for a side of the currently applicable cell before
- * border resolution (i.e. the value from the FO). A return value of null indicates an
- * empty cell. See CollapsingBorderModel(EyeCatching) where this method is used.
- *
- * @param side for which side to return the BorderInfo
- * @return the requested BorderInfo instance or null if the grid unit is an empty cell
- */
- public BorderInfo getOriginalBorderInfoForCell(int side) {
- if (cell != null) {
- return cell.getCommonBorderPaddingBackground().getBorderInfo(side);
- } else {
- return null;
- }
- }
-
- /**
- * @return the resolved normal borders for this grid unit
- */
- public CommonBorderPaddingBackground getBorders() {
- // TODO
- if (effectiveBorders == null) {
- effectiveBorders = new CommonBorderPaddingBackground();
- setBorderInfo(CommonBorderPaddingBackground.BEFORE);
- setBorderInfo(CommonBorderPaddingBackground.AFTER);
- setBorderInfo(CommonBorderPaddingBackground.START);
- setBorderInfo(CommonBorderPaddingBackground.END);
- if (cell != null) {
- effectiveBorders.setPadding(cell.getCommonBorderPaddingBackground());
- }
- if (log.isDebugEnabled()) {
- log.debug(this + " resolved borders: " + "before="
- + effectiveBorders.getBorderBeforeWidth(false) + ", " + "after="
- + effectiveBorders.getBorderAfterWidth(false) + ", " + "start="
- + effectiveBorders.getBorderStartWidth(false) + ", " + "end="
- + effectiveBorders.getBorderEndWidth(false));
- }
- }
- return effectiveBorders;
- }
-
- private void setBorderInfo(int side) {
- if (resolvedBorders[side] != null) {
- effectiveBorders.setBorderInfo(resolvedBorders[side].getBorderInfo(), side);
- }
- }
-
- /**
- * @return true if the grid unit has any borders.
- */
- public boolean hasBorders() {
- return (getBorders() != null) && getBorders().hasBorder();
- }
-
- /**
- * Assigns the borders from the given cell to this cell info. Used in case of separate
- * border model.
- */
- public void assignBorderForSeparateBorderModel() {
- if (cell != null) {
- effectiveBorders = cell.getCommonBorderPaddingBackground();
- }
- }
-
- /**
- * Resolve collapsing borders for the given cell. Used in case of the collapsing
- * border model.
- *
- * @param other neighbouring grid unit
- * @param side the side to resolve (one of
- * CommonBorderPaddingBackground.BEFORE|AFTER|START|END)
- */
- public void resolveBorder(GridUnit other, int side) {
- BorderSpecification resolvedBorder = collapsingBorderModel.determineWinner(
- resolvedBorders[side], other.resolvedBorders[CollapsingBorderModel
- .getOtherSide(side)]);
- if (resolvedBorder != null) {
- this.resolvedBorders[side] = resolvedBorder;
- other.resolvedBorders[CollapsingBorderModel.getOtherSide(side)] = resolvedBorder;
- }
- }
-
- /**
- * Resolves the border on the given side of this grid unit, comparing it against the
- * same border of the given parent element.
- *
- * @param side the side to resolve (one of
- * CommonBorderPaddingBackground.BEFORE|AFTER|START|END)
- * @param parent the parent element holding a competing border
- */
- public void resolveBorder(int side, TableFObj parent) {
- resolvedBorders[side] = collapsingBorderModel.determineWinner(resolvedBorders[side],
- parent.resolvedBorders[side]);
- }
-
- /**
- * Returns a flag for this GridUnit.
- *
- * @param which the requested flag
- * @return the value of the flag
- */
- public boolean getFlag(int which) {
- return (flags & (1 << which)) != 0;
- }
-
- /**
- * Sets a flag on a GridUnit.
- *
- * @param which the flag to set
- * @param value the new value for the flag
- */
- public void setFlag(int which, boolean value) {
- if (value) {
- flags |= (1 << which); // set flag
- } else {
- flags &= ~(1 << which); // clear flag
- }
- }
-
- /**
- * Sets the given flag on this grid unit.
- *
- * @param which the flag to set
- */
- public void setFlag(int which) {
- setFlag(which, true);
- }
-
- /** {@inheritDoc} */
- public String toString() {
- StringBuffer buffer = new StringBuffer();
- if (isEmpty()) {
- buffer.append("EMPTY");
- } else if (isPrimary()) {
- buffer.append("Primary");
- }
- buffer.append("GridUnit:");
- if (colSpanIndex > 0) {
- buffer.append(" colSpan=").append(colSpanIndex);
- if (isLastGridUnitColSpan()) {
- buffer.append("(last)");
- }
- }
- if (rowSpanIndex > 0) {
- buffer.append(" rowSpan=").append(rowSpanIndex);
- if (isLastGridUnitRowSpan()) {
- buffer.append("(last)");
- }
- }
- buffer.append(" startCol=").append(startCol);
- if (!isPrimary() && getPrimary() != null) {
- buffer.append(" primary=").append(getPrimary().getStartRow());
- buffer.append("/").append(getPrimary().getStartCol());
- if (getPrimary().getCell() != null) {
- buffer.append(" id=" + getPrimary().getCell().getId());
- }
- }
- buffer.append(" flags=").append(Integer.toBinaryString(flags));
- return buffer.toString();
- }
-
-}
package org.apache.fop.layoutmgr.table;
+import org.apache.fop.fo.flow.table.GridUnit;
+import org.apache.fop.fo.flow.table.PrimaryGridUnit;
+
/**
* Represents a non-dividable part of a grid unit. Used by the table stepper.
*/
+++ /dev/null
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* $Id$ */
-
-package org.apache.fop.layoutmgr.table;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.fop.fo.flow.table.TableCell;
-import org.apache.fop.fo.flow.table.TableColumn;
-
-/**
- * This class represents a primary grid unit of a spanned cell. This is the "before-start"
- * (top-left, usually) grid unit of the span.
- */
-public class PrimaryGridUnit extends GridUnit {
-
- private static Log log = LogFactory.getLog(PrimaryGridUnit.class);
-
- /** Cell layout manager. */
- private TableCellLayoutManager cellLM;
- /** List of Knuth elements representing the contents of the cell. */
- private LinkedList elements;
- /** Index of row where this cell starts */
- private int startRow;
- /** Links to the spanned grid units. (List of GridUnit arrays, one array represents a row) */
- private List rows;
- /** The calculated size of the cell's content. (cached value) */
- private int contentLength = -1;
-
- /**
- * Creates a new primary grid unit.
- *
- * @param cell table cell which occupies this grid unit
- * @param column table column this grid unit belongs to
- * @param startCol index of the column this grid unit belongs to, zero-based
- * @param startRow index of the row this grid unit belongs to, zero-based
- */
- public PrimaryGridUnit(TableCell cell, TableColumn column, int startCol, int startRow) {
- super(cell, column, startCol, 0, 0);
- this.startRow = startRow;
- log.trace("PrimaryGridUnit created, row " + startRow + " col " + startCol);
- }
-
- public TableCellLayoutManager getCellLM() {
- assert cellLM != null;
- return cellLM;
- }
-
- /** {@inheritDoc} */
- public PrimaryGridUnit getPrimary() {
- return this;
- }
-
- /** {@inheritDoc} */
- public boolean isPrimary() {
- return true;
- }
-
- /**
- * Sets the Knuth elements for the table cell containing this grid unit.
- *
- * @param elements a list of ListElement (?)
- */
- public void setElements(LinkedList elements) {
- this.elements = elements;
- }
-
- public LinkedList getElements() {
- return this.elements;
- }
-
- /**
- * @return half the maximum before border width of this cell.
- */
- public int getHalfMaxBeforeBorderWidth() {
- int value = 0;
- if (getRows() != null) {
- int before = 0;
- //first row for before borders
- GridUnit[] row = (GridUnit[])getRows().get(0);
- for (int i = 0; i < row.length; i++) {
- if (row[i].hasBorders()) {
- before = Math.max(before,
- row[i].getBorders().getBorderBeforeWidth(false));
- }
- }
- value += before / 2;
- } else {
- if (hasBorders()) {
- value += getBorders().getBorderBeforeWidth(false) / 2;
- }
- }
- return value;
- }
-
- /**
- * @return half the maximum after border width of this cell.
- */
- public int getHalfMaxAfterBorderWidth() {
- int value = 0;
- if (getRows() != null) {
- //Last row for after borders
- int after = 0;
- GridUnit[] row = (GridUnit[])getRows().get(getRows().size() - 1);
- for (int i = 0; i < row.length; i++) {
- if (row[i].hasBorders()) {
- after = Math.max(after, row[i].getBorders().getBorderAfterWidth(false));
- }
- }
- value += after / 2;
- } else {
- if (hasBorders()) {
- value += getBorders().getBorderAfterWidth(false) / 2;
- }
- }
- return value;
- }
-
- /**
- * @return the sum of half the maximum before and after border
- * widths of this cell.
- */
- public int getHalfMaxBorderWidth() {
- return getHalfMaxBeforeBorderWidth() + getHalfMaxAfterBorderWidth();
- }
-
- /** @param value The length of the cell content to remember. */
- public void setContentLength(int value) {
- this.contentLength = value;
- }
-
- /** @return the length of the cell content. */
- public int getContentLength() {
- return contentLength;
- }
-
- /** @return true if cell/row has an explicit BPD/height */
- public boolean hasBPD() {
- if (!getCell().getBlockProgressionDimension().getOptimum(null).isAuto()) {
- return true;
- }
- if (getRow() != null
- && !getRow().getBlockProgressionDimension().getOptimum(null).isAuto()) {
- return true;
- }
- return false;
- }
-
- /**
- * Returns the grid units belonging to the same span as this one.
- *
- * @return a list of GridUnit[], each array corresponds to a row
- */
- public List getRows() {
- return this.rows;
- }
-
- public void addRow(GridUnit[] row) {
- if (rows == null) {
- rows = new java.util.ArrayList();
- }
- rows.add(row);
- }
-
- /**
- * Returns the index of the row this grid unit belongs to.
- *
- * @return the index of the row this grid unit belongs to.
- */
- public int getStartRow() {
- return this.startRow;
- }
-
- /**
- * Returns the widths of the start- and end-borders of the span this grid unit belongs
- * to.
- *
- * @return a two-element array containing the widths of the start-border then the
- * end-border
- */
- public int[] getStartEndBorderWidths() {
- int[] widths = new int[2];
- if (rows == null) {
- widths[0] = getBorders().getBorderStartWidth(false);
- widths[1] = getBorders().getBorderEndWidth(false);
- } else {
- for (int i = 0; i < rows.size(); i++) {
- GridUnit[] gridUnits = (GridUnit[])rows.get(i);
- widths[0] = Math.max(widths[0],
- (gridUnits[0]).
- getBorders().getBorderStartWidth(false));
- widths[1] = Math.max(widths[1],
- (gridUnits[gridUnits.length - 1]).
- getBorders().getBorderEndWidth(false));
- }
- }
- return widths;
- }
-
- /** {@inheritDoc} */
- public String toString() {
- StringBuffer sb = new StringBuffer(super.toString());
- sb.append(" startRow=").append(startRow);
- return sb.toString();
- }
-
- /** @return true if this cell spans over more than one grid unit. */
- public boolean hasSpanning() {
- return (getCell().getNumberColumnsSpanned() > 1)
- || (getCell().getNumberRowsSpanned() > 1);
- }
-
- /**
- * Creates a cellLM for the corresponding table-cell. A new one must be created
- * for each new static-content (TODO).
- */
- public void createCellLM() {
- cellLM = new TableCellLayoutManager(cell, this);
- }
-
-}
import org.apache.commons.logging.LogFactory;
import org.apache.fop.fo.Constants;
import org.apache.fop.fo.FONode;
+import org.apache.fop.fo.flow.table.GridUnit;
+import org.apache.fop.fo.flow.table.PrimaryGridUnit;
import org.apache.fop.fo.flow.table.TableRow;
import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
import org.apache.fop.fo.properties.LengthRangeProperty;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.fop.fo.flow.table.GridUnit;
+import org.apache.fop.fo.flow.table.PrimaryGridUnit;
import org.apache.fop.fo.flow.table.TableRow;
import org.apache.fop.fo.properties.LengthRangeProperty;
import org.apache.fop.layoutmgr.ElementListUtils;
import org.apache.commons.logging.LogFactory;
import org.apache.fop.datatypes.PercentBaseContext;
import org.apache.fop.fo.FONode;
+import org.apache.fop.fo.flow.table.GridUnit;
+import org.apache.fop.fo.flow.table.PrimaryGridUnit;
import org.apache.fop.fo.flow.table.Table;
import org.apache.fop.fo.flow.table.TableCell;
import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
import org.apache.fop.datatypes.PercentBaseContext;
import org.apache.fop.fo.Constants;
import org.apache.fop.fo.FObj;
+import org.apache.fop.fo.flow.table.GridUnit;
import org.apache.fop.fo.flow.table.Table;
import org.apache.fop.fo.flow.table.TableBody;
import org.apache.fop.fo.flow.table.TableRow;
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.FONode.FONodeIterator;
import org.apache.fop.fo.flow.Marker;
+import org.apache.fop.fo.flow.table.GridUnit;
+import org.apache.fop.fo.flow.table.PrimaryGridUnit;
import org.apache.fop.fo.flow.table.Table;
import org.apache.fop.fo.flow.table.TableBody;
import org.apache.fop.fo.flow.table.TableCell;
import org.apache.commons.logging.LogFactory;
import org.apache.fop.fo.Constants;
import org.apache.fop.fo.FONode;
+import org.apache.fop.fo.flow.table.GridUnit;
+import org.apache.fop.fo.flow.table.PrimaryGridUnit;
import org.apache.fop.fo.flow.table.TableRow;
import org.apache.fop.layoutmgr.BreakElement;
import org.apache.fop.layoutmgr.KnuthBox;