blob: 4c532f67fd29b9e25e96649d7523fa080b5c64c0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
|
/*
* Copyright 1999-2004 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$ */
package org.apache.fop.fo.flow;
// Java
import java.util.List;
import java.util.ListIterator;
import java.util.ArrayList;
// XML
import org.xml.sax.Attributes;
import org.xml.sax.SAXParseException;
// FOP
import org.apache.fop.datatypes.ColorType;
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.FObj;
import org.apache.fop.layoutmgr.table.TableLayoutManager;
import org.apache.fop.layoutmgr.table.Body;
import org.apache.fop.layoutmgr.table.Column;
import org.apache.fop.fo.properties.CommonAccessibility;
import org.apache.fop.fo.properties.CommonAural;
import org.apache.fop.fo.properties.CommonBackground;
import org.apache.fop.fo.properties.CommonBorderAndPadding;
import org.apache.fop.fo.properties.CommonMarginBlock;
import org.apache.fop.fo.properties.CommonRelativePosition;
import org.apache.fop.fo.properties.LengthRangeProperty;
/**
* Class modelling the fo:table object.
*/
public class Table extends FObj {
private static final int MINCOLWIDTH = 10000; // 10pt
/** collection of columns in this table */
protected ArrayList columns = null;
private TableBody tableHeader = null;
private TableBody tableFooter = null;
private boolean omitHeaderAtBreak = false;
private boolean omitFooterAtBreak = false;
private int breakBefore;
private int breakAfter;
private int spaceBefore;
private int spaceAfter;
private ColorType backgroundColor;
private LengthRangeProperty ipd;
private int height;
private boolean bAutoLayout = false;
private int contentWidth = 0; // Sum of column widths
/** Optimum inline-progression-dimension */
private int optIPD;
/** Minimum inline-progression-dimension */
private int minIPD;
/** Maximum inline-progression-dimension */
private int maxIPD;
/**
* @param parent FONode that is the parent of this object
*/
public Table(FONode parent) {
super(parent);
}
/**
* @see org.apache.fop.fo.FObj#addProperties
*/
protected void addProperties(Attributes attlist) throws SAXParseException {
super.addProperties(attlist);
this.breakBefore = this.propertyList.get(PR_BREAK_BEFORE).getEnum();
this.breakAfter = this.propertyList.get(PR_BREAK_AFTER).getEnum();
this.spaceBefore = getPropLength(PR_SPACE_BEFORE | CP_OPTIMUM);
this.spaceAfter = getPropLength(PR_SPACE_AFTER | CP_OPTIMUM);
this.backgroundColor =
this.propertyList.get(PR_BACKGROUND_COLOR).getColorType();
this.ipd = this.propertyList.get(
PR_INLINE_PROGRESSION_DIMENSION).getLengthRange();
this.height = getPropLength(PR_HEIGHT);
this.bAutoLayout = (this.propertyList.get(
PR_TABLE_LAYOUT).getEnum() == TableLayout.AUTO);
this.omitHeaderAtBreak = this.propertyList.get(
PR_TABLE_OMIT_HEADER_AT_BREAK).getEnum()
== TableOmitHeaderAtBreak.TRUE;
this.omitFooterAtBreak = this.propertyList.get(
PR_TABLE_OMIT_FOOTER_AT_BREAK).getEnum()
== TableOmitFooterAtBreak.TRUE;
getFOInputHandler().startTable(this);
}
protected void endOfNode() throws SAXParseException {
getFOInputHandler().endTable(this);
}
/**
* @see org.apache.fop.fo.FONode#addChildNode(FONode)
*/
protected void addChildNode(FONode child) {
if (child.getName().equals("fo:table-column")) {
if (columns == null) {
columns = new ArrayList();
}
columns.add(((TableColumn)child));
} else if (child.getName().equals("fo:table-footer")) {
tableFooter = (TableBody)child;
} else if (child.getName().equals("fo:table-header")) {
tableHeader = (TableBody)child;
} else {
// add bodies
super.addChildNode(child);
}
}
private ArrayList getColumns() {
return columns;
}
private TableBody getTableHeader() {
return tableHeader;
}
private TableBody getTableFooter() {
return tableFooter;
}
/**
* @see org.apache.fop.fo.FObj#addLayoutManager(List)
* @todo see if can/should move much of this logic into TableLayoutManager
* and/or TableBody and TableColumn FO subclasses.
*/
public void addLayoutManager(List list) {
TableLayoutManager tlm = new TableLayoutManager(this);
ArrayList columns = getColumns();
if (columns != null) {
ArrayList columnLMs = new ArrayList();
ListIterator iter = columns.listIterator();
while (iter.hasNext()) {
columnLMs.add(getTableColumnLayoutManager((TableColumn)iter.next()));
}
tlm.setColumns(columnLMs);
}
if (getTableHeader() != null) {
tlm.setTableHeader(getTableBodyLayoutManager(getTableHeader()));
}
if (getTableFooter() != null) {
tlm.setTableFooter(getTableBodyLayoutManager(getTableFooter()));
}
list.add(tlm);
}
public Column getTableColumnLayoutManager(TableColumn node) {
Column clm = new Column(node);
return clm;
}
public Body getTableBodyLayoutManager(TableBody node) {
Body blm = new Body(node);
return blm;
}
/**
* @see org.apache.fop.fo.FObj#getName()
*/
public String getName() {
return "fo:table";
}
/**
* @see org.apache.fop.fo.FObj#getNameId()
*/
public int getNameId() {
return FO_TABLE;
}
}
|