* (used by TableColumn.bind() in case the column-number
* was explicitly specified)
*
+ * @param newIndex the new value for column index
*/
protected void setCurrentColumnIndex(int newIndex) {
columnIndex = newIndex;
private PropertyList savedPropertyList;
- //used for validation
+ /**
+ * used for validation
+ */
protected boolean tableRowsFound = false;
protected boolean tableCellsFound = false;
- //used for initial values of column-number property
+ /**
+ * used for initial values of column-number property
+ */
protected List pendingSpans;
protected BitSet usedColumnIndices = new BitSet();
private int columnIndex = 1;
int colSpan = cell.getNumberColumnsSpanned();
//if there were no explicit columns, pendingSpans
//will not be properly initialized for the first row
- if (firstRow && ((Table) parent).columns == null) {
+ if (firstRow && getTable().columns == null) {
if (pendingSpans == null) {
pendingSpans = new java.util.ArrayList();
}
//take up more than three columnIndices...
int startIndex = columnIndex - 1;
int endIndex = startIndex + colSpan;
- if (((Table) parent).columns != null) {
- List cols = ((Table) parent).columns;
+ if (getTable().columns != null) {
+ List cols = getTable().columns;
int tmpIndex = endIndex;
for (int i = startIndex; i <= tmpIndex; ++i) {
if (i < cols.size() && cols.get(i) == null) {
*
*/
protected void initPendingSpans() {
- if (((Table) parent).columns != null) {
- List tableCols = ((Table) parent).columns;
+ if (getTable().columns != null) {
+ List tableCols = getTable().columns;
pendingSpans = new java.util.ArrayList(tableCols.size());
for (int i = tableCols.size(); --i >= 0;) {
pendingSpans.add(null);
//the updated index is not assigned to any
//column, increment further until the next
//index occupied by a column...
- if (((Table) parent).columns != null) {
- while (columnIndex <= ((Table) parent).columns.size()
- && !((Table) parent).isColumnNumberUsed(columnIndex) ) {
+ if (getTable().columns != null) {
+ while (columnIndex <= getTable().columns.size()
+ && !getTable().isColumnNumberUsed(columnIndex) ) {
columnIndex++;
}
}
*/
protected boolean isColumnNumberUsed(int colNr) {
return usedColumnIndices.get(colNr - 1);
- }
+ }
}
//check if any of the column-numbers occupied by this cell
//are already in use in the current row...
- for( int i = getColumnNumber();
- ++i <= getColumnNumber() + getNumberColumnsSpanned(); ) {
- if( ((TableFObj) parent).isColumnNumberUsed(i - 1) ) {
- throw new FOPException("cell overlaps in column " + (i - 1),
- locator);
+ int i = -1;
+ int columnIndex = columnNumber.getValue();
+ while (++i < getNumberColumnsSpanned()) {
+ //if table has explicit columns and the column-number isn't
+ //assigned to any column, increment further until the next
+ //column is encountered
+ if (getTable().columns != null) {
+ while (columnIndex <= getTable().columns.size()
+ && !getTable().isColumnNumberUsed(columnIndex)) {
+ columnIndex++;
+ }
+ }
+ //if column-number is already in use by another cell
+ //in the current row => error!
+ if (((TableFObj) parent).isColumnNumberUsed(columnIndex)) {
+ throw new FOPException("fo:table-cell overlaps in column "
+ + i, locator);
}
}
//if column-number was explicitly specified, force the parent's current
//column index to the specified value, so that the updated index will
//be the correct initial value for the next cell (see Rec 7.26.8)
- if( pList.getExplicit(PR_COLUMN_NUMBER) != null ) {
+ if (pList.getExplicit(PR_COLUMN_NUMBER) != null) {
((TableFObj) parent).setCurrentColumnIndex(columnNumber.getValue());
}
}
if (!blockItemFound) {
missingChildElementError("marker* (%block;)+");
}
- if( (startsRow() || endsRow())
+ if ((startsRow() || endsRow())
&& getParent().getNameId() == FO_TABLE_ROW ) {
getLogger().warn("starts-row/ends-row for fo:table-cells "
+ "non-applicable for children of an fo:table-row.");
/**
* Set position relative to table (set by body?)
+ *
+ * @param offset new offset
*/
public void setStartOffset(int offset) {
startOffset = offset;
visibility = pList.get(PR_VISIBILITY).getEnum();
super.bind(pList);
- if( pList.getExplicit(PR_COLUMN_NUMBER) != null ) {
+ if (pList.getExplicit(PR_COLUMN_NUMBER) != null) {
if (columnNumber.getValue() <= 0) {
//TODO: This is actually a non-fatal error. See Rec 7.26.8:
//"A positive integer. If a negative or non-integer value
// nearest integer value greater than or equal to 1."
throw new PropertyException("column-number must be 1 or bigger, "
+ "but got " + columnNumber);
- } else if( ((Table) parent).isColumnNumberUsed(columnNumber.getValue()) ) {
+ } else if (getTable().isColumnNumberUsed(columnNumber.getValue())) {
throw new PropertyException("specified column-number \""
+ columnNumber
+ "\" has already been assigned to a previous column");
//to the specified value, so that the updated index
//will be the correct initial value for the next column
//(see Rec 7.26.8)
- ((Table) parent).setCurrentColumnIndex(columnNumber.getValue());
+ getTable().setCurrentColumnIndex(columnNumber.getValue());
}
}
if (numberColumnsRepeated.getValue() <= 0) {
*/
protected static class PendingSpan {
+ /**
+ * member variable holding the number of rows left
+ */
protected int rowsLeft;
/**
return false;
}
+ /**
+ * Checks whether a given column-number is assigned to
+ * an explicit column in the parent table
+ * (overridden for TableBody, TableRow)
+ *
+ * @param colNr the column-number to check
+ * @return true if the table has explicit columns, and
+ * the column-number is in use
+ */
+ protected boolean isColumnNumberUsedInTable(int colNr) {
+ return false;
+ }
+
+ /**
+ * Convenience method to returns a reference
+ * to the base Table instance
+ *
+ * @return the base table instance
+ *
+ */
+ protected Table getTable() {
+ if (this.getNameId() == FO_TABLE) {
+ //node is a Table
+ //=> return itself
+ return (Table) this;
+ } else {
+ //any other Table-node
+ //=> recursive call to parent.getTable()
+ return ((TableFObj) parent).getTable();
+ }
+ }
+
/**
* @return the Common Border, Padding, and Background Properties.
*/
protected void startOfNode() throws FOPException {
pendingSpans = ((TableBody) parent).pendingSpans;
usedColumnIndices = ((TableBody) parent).usedColumnIndices;
- while( usedColumnIndices.get(columnIndex - 1) ) {
+ while (usedColumnIndices.get(columnIndex - 1)) {
columnIndex++;
}
if (childNodes == null) {
missingChildElementError("(table-cell+)");
}
- if( ((TableBody) parent).isFirst(this)
- && ((Table) parent.getParent()).columns == null ) {
+ if (((TableBody) parent).isFirst(this)
+ && getTable().columns == null ) {
//force parent body's pendingSpans
//to the one accumulated after processing this row
((TableBody) parent).pendingSpans = pendingSpans;
TableCell cell = (TableCell) child;
int rowSpan = cell.getNumberRowsSpanned();
int colSpan = cell.getNumberColumnsSpanned();
- if( ((TableBody) parent).isFirst(this)
- && ((Table) parent.getParent()).columns == null ) {
- if( pendingSpans == null ) {
+ if (((TableBody) parent).isFirst(this)
+ && getTable().columns == null ) {
+ if (pendingSpans == null) {
pendingSpans = new java.util.ArrayList();
}
pendingSpans.add(null);
- if( usedColumnIndices == null ) {
+ if (usedColumnIndices == null) {
usedColumnIndices = new BitSet();
}
}
//if the current cell spans more than one row,
//update pending span list for the next row
- if( rowSpan > 1 ) {
- for( int i = colSpan; --i >= 0; ) {
+ if (rowSpan > 1) {
+ for (int i = colSpan; --i >= 0;) {
pendingSpans.set(columnIndex - 1 + i,
new PendingSpan(rowSpan));
}
//take up more than three columnIndices...
int startIndex = columnIndex - 1;
int endIndex = startIndex + colSpan;
- if( ((Table) parent.getParent()).columns != null ) {
- List cols = ((Table) parent.getParent()).columns;
+ if (getTable().columns != null) {
+ List cols = getTable().columns;
int tmpIndex = endIndex;
- for( int i = startIndex; i <= tmpIndex; ++i ) {
- if( i < cols.size() && cols.get(i) == null ) {
+ for (int i = startIndex; i <= tmpIndex; ++i) {
+ if (i < cols.size() && cols.get(i) == null) {
endIndex++;
}
}
}
usedColumnIndices.set(startIndex, endIndex);
//update columnIndex for the next cell
- while( usedColumnIndices.get(columnIndex - 1) ) {
+ while (usedColumnIndices.get(columnIndex - 1)) {
columnIndex++;
}
super.addChildNode(cell);
* in case a column-number was explicitly specified
* (used by TableCell.bind())
*
+ * @param newIndex new value for column index
*/
protected void setCurrentColumnIndex(int newIndex) {
columnIndex = newIndex;
* Checks whether a given column-number is already in use
* for the current row (used by TableCell.bind());
*
+ * @param colNr the column-number to check
* @return true if column-number is already occupied
*/
protected boolean isColumnNumberUsed(int colNr) {
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+ Copyright 2005 The Apache Software Foundation
+
+ Licensed 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: $ -->
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:test="http://xmlgraphics.apache.org/fop/test">
<fo:layout-master-set>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+ Copyright 2005 The Apache Software Foundation
+
+ Licensed 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: $ -->
+<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"
+ xmlns:test="http://xmlgraphics.apache.org/fop/test">
+ <fo:layout-master-set>
+ <fo:simple-page-master master-name="normal" page-width="5in" page-height="5in">
+ <fo:region-body />
+ </fo:simple-page-master>
+ </fo:layout-master-set>
+ <fo:page-sequence master-reference="normal" white-space-collapse="true">
+ <fo:flow flow-name="xsl-region-body">
+ <fo:table table-layout="fixed" border-collapse="separate">
+ <fo:table-column column-width="2in">
+ <test:assert property="column-number" expected="1" />
+ </fo:table-column>
+ <fo:table-column column-width="1in">
+ <test:assert property="column-number" expected="2" />
+ </fo:table-column>
+ <fo:table-column column-width="1in">
+ <test:assert property="column-number" expected="3" />
+ </fo:table-column>
+ <fo:table-column column-width="1in">
+ <test:assert property="column-number" expected="4" />
+ </fo:table-column>
+ <fo:table-body>
+ <fo:table-cell>
+ <test:assert property="column-number" expected="1" />
+ <fo:block>cell1</fo:block>
+ </fo:table-cell>
+ <fo:table-cell>
+ <test:assert property="column-number" expected="2" />
+ <fo:block>cell2</fo:block>
+ </fo:table-cell>
+ <fo:table-cell>
+ <test:assert property="column-number" expected="3" />
+ <fo:block>cell3</fo:block>
+ </fo:table-cell>
+ <fo:table-cell>
+ <test:assert property="column-number" expected="4" />
+ <fo:block>cell4</fo:block>
+ </fo:table-cell>
+ <fo:table-cell>
+ <test:assert property="column-number" expected="5" />
+ <fo:block>cell5</fo:block>
+ </fo:table-cell>
+ <fo:table-cell starts-row="true">
+ <test:assert property="column-number" expected="1" />
+ <fo:block>cell6</fo:block>
+ </fo:table-cell>
+ <fo:table-cell>
+ <test:assert property="column-number" expected="2" />
+ <fo:block>cell7</fo:block>
+ </fo:table-cell>
+ <fo:table-cell ends-row="true">
+ <test:assert property="column-number" expected="3" />
+ <fo:block>cell8</fo:block>
+ </fo:table-cell>
+ <fo:table-cell>
+ <test:assert property="column-number" expected="1" />
+ <fo:block>cell9</fo:block>
+ </fo:table-cell>
+ <fo:table-cell>
+ <test:assert property="column-number" expected="2" />
+ <fo:block>cell10</fo:block>
+ </fo:table-cell>
+ <fo:table-cell>
+ <test:assert property="column-number" expected="3" />
+ <fo:block>cell11</fo:block>
+ </fo:table-cell>
+ <fo:table-cell ends-row="true">
+ <test:assert property="column-number" expected="4" />
+ <fo:block>cell12</fo:block>
+ </fo:table-cell>
+ <fo:table-cell starts-row="true" ends-row="true">
+ <test:assert property="column-number" expected="1" />
+ <fo:block>cell13</fo:block>
+ </fo:table-cell>
+ <fo:table-cell ends-row="true">
+ <test:assert property="column-number" expected="1" />
+ <fo:block>cell14</fo:block>
+ </fo:table-cell>
+ </fo:table-body>
+ </fo:table>
+ </fo:flow>
+ </fo:page-sequence>
+</fo:root>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+ Copyright 2005 The Apache Software Foundation
+
+ Licensed 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: $ -->
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:test="http://xmlgraphics.apache.org/fop/test">
<fo:layout-master-set>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+ Copyright 2005 The Apache Software Foundation
+
+ Licensed 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: $ -->
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:test="http://xmlgraphics.apache.org/fop/test">
<fo:layout-master-set>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+ Copyright 2005 The Apache Software Foundation
+
+ Licensed 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: $ -->
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:test="http://xmlgraphics.apache.org/fop/test">
<fo:layout-master-set>