blob: f6a919fc7d9afffac2a22204e440edfd5e65e0ae (
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
|
/*
* $Id$
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
*/
package org.apache.fop.fo.flow;
// FOP
import org.apache.fop.fo.*;
import org.apache.fop.fo.properties.*;
import org.apache.fop.fo.pagination.*;
import org.apache.fop.layout.Area;
import org.apache.fop.apps.FOPException;
// Java
import java.util.Enumeration;
public class StaticContent extends Flow {
public static class Maker extends FObj.Maker {
public FObj make(FObj parent,
PropertyList propertyList) throws FOPException {
return new StaticContent(parent, propertyList);
}
}
public static FObj.Maker maker() {
return new StaticContent.Maker();
}
protected StaticContent(FObj parent,
PropertyList propertyList) throws FOPException {
super(parent, propertyList);
((PageSequence)parent).setIsFlowSet(false); // hacquery of sorts
}
public Status layout(Area area) throws FOPException {
return layout(area, null);
}
public Status layout(Area area, Region region) throws FOPException {
int numChildren = this.children.size();
// Set area absolute height so that link rectangles will be drawn correctly in xsl-before and xsl-after
String regionClass = "none";
if (region != null) {
regionClass = region.getRegionClass();
} else {
if (getFlowName().equals("xsl-region-before")) {
regionClass = RegionBefore.REGION_CLASS;
} else if (getFlowName().equals("xsl-region-after")) {
regionClass = RegionAfter.REGION_CLASS;
} else if (getFlowName().equals("xsl-region-start")) {
regionClass = RegionStart.REGION_CLASS;
} else if (getFlowName().equals("xsl-region-end")) {
regionClass = RegionEnd.REGION_CLASS;
}
}
if (area instanceof org.apache.fop.layout.AreaContainer)
((org.apache.fop.layout.AreaContainer)area).setAreaName(regionClass);
if (regionClass.equals(RegionBefore.REGION_CLASS)) {
area.setAbsoluteHeight(-area.getMaxHeight());
} else if (regionClass.equals(RegionAfter.REGION_CLASS)) {
area.setAbsoluteHeight(area.getPage().getBody().getMaxHeight());
}
for (int i = 0; i < numChildren; i++) {
FObj fo = (FObj)children.elementAt(i);
Status status;
if ((status = fo.layout(area)).isIncomplete()) {
// in fact all should be laid out and clip, error etc depending on 'overflow'
log.debug("Warning: Some static content could not fit in the area.");
this.marker = i;
if ((i != 0) && (status.getCode() == Status.AREA_FULL_NONE)) {
status = new Status(Status.AREA_FULL_SOME);
}
return (status);
}
}
resetMarker();
return new Status(Status.OK);
}
protected String getElementName() {
return "fo:static-content";
}
// flowname checking is more stringient for static content currently
protected void setFlowName(String name) throws FOPException {
if (name == null || name.equals("")) {
throw new FOPException("A 'flow-name' is required for "
+ getElementName() + ".");
} else {
super.setFlowName(name);
}
}
}
|