blob: 5babb90bb22fc66101bea16c1dfe14f033a5baa1 (
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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
|
/*
* 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.ArrayList;
// XML
import org.xml.sax.Attributes;
import org.xml.sax.SAXParseException;
// FOP
import org.apache.fop.apps.FOPException;
import org.apache.fop.datatypes.ColorType;
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.FObj;
import org.apache.fop.layoutmgr.AddLMVisitor;
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. See Sec. 6.7.3 of the XSL-FO Standard.
*/
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 FOPException {
super.addProperties(attlist);
setupID();
getFOInputHandler().startTable(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 void setup() {
// Common Accessibility Properties
CommonAccessibility mAccProps = propMgr.getAccessibilityProps();
// Common Aural Properties
CommonAural mAurProps = propMgr.getAuralProps();
// Common Border, Padding, and Background Properties
CommonBorderAndPadding bap = propMgr.getBorderAndPadding();
CommonBackground bProps = propMgr.getBackgroundProps();
// Common Margin Properties-Block
CommonMarginBlock mProps = propMgr.getMarginProps();
// Common Relative Position Properties
CommonRelativePosition mRelProps =
propMgr.getRelativePositionProps();
// this.propertyList.get("block-progression-dimension");
// this.propertyList.get("border-after-precendence");
// this.propertyList.get("border-before-precedence");
// this.propertyList.get("border-collapse");
// this.propertyList.get("border-end-precendence");
// this.propertyList.get("border-separation");
// this.propertyList.get("border-start-precendence");
// this.propertyList.get("break-after");
// this.propertyList.get("break-before");
setupID();
// this.propertyList.get("inline-progression-dimension");
// this.propertyList.get("height");
// this.propertyList.get("keep-together");
// this.propertyList.get("keep-with-next");
// this.propertyList.get("keep-with-previous");
// this.propertyList.get("table-layout");
// this.propertyList.get("table-omit-footer-at-break");
// this.propertyList.get("table-omit-header-at-break");
// this.propertyList.get("width");
// this.propertyList.get("writing-mode");
this.breakBefore = this.propertyList.get(PR_BREAK_BEFORE).getEnum();
this.breakAfter = this.propertyList.get(PR_BREAK_AFTER).getEnum();
this.spaceBefore = this.propertyList.get(
PR_SPACE_BEFORE | CP_OPTIMUM).getLength().getValue();
this.spaceAfter = this.propertyList.get(
PR_SPACE_AFTER | CP_OPTIMUM).getLength().getValue();
this.backgroundColor =
this.propertyList.get(PR_BACKGROUND_COLOR).getColorType();
this.ipd = this.propertyList.get(
PR_INLINE_PROGRESSION_DIMENSION).getLengthRange();
this.height = this.propertyList.get(PR_HEIGHT).getLength().getValue();
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;
}
/**
* @return false (Table does not generate inline areas)
*/
public boolean generatesInlineAreas() {
return false;
}
/**
* @return true (Table contains Markers)
*/
protected boolean containsMarkers() {
return true;
}
public ArrayList getColumns() {
return columns;
}
public TableBody getTableHeader() {
return tableHeader;
}
public TableBody getTableFooter() {
return tableFooter;
}
/**
* This is a hook for the AddLMVisitor class to be able to access
* this object.
* @param aLMV the AddLMVisitor object that can access this object.
*/
public void acceptVisitor(AddLMVisitor aLMV) {
aLMV.serveTable(this);
}
protected void endOfNode() throws SAXParseException {
getFOInputHandler().endTable(this);
}
public String getName() {
return "fo:table";
}
}
|