01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: /* $Id: FootnoteBodyLayoutManager.java 426576 2006-07-28 15:44:37Z jeremias $ */
19:
20: package org.apache.fop.layoutmgr;
21:
22: import org.apache.fop.area.Area;
23: import org.apache.fop.fo.flow.FootnoteBody;
24:
25: import java.util.LinkedList;
26:
27: /**
28: * Layout manager for footnote bodies.
29: */
30: public class FootnoteBodyLayoutManager extends
31: BlockStackingLayoutManager {
32:
33: /**
34: * Creates a new FootnoteBodyLayoutManager.
35: * @param body the footnote-body element
36: */
37: public FootnoteBodyLayoutManager(FootnoteBody body) {
38: super (body);
39: }
40:
41: /** @see org.apache.fop.layoutmgr.LayoutManager */
42: public void addAreas(PositionIterator parentIter,
43: LayoutContext layoutContext) {
44: LayoutManager childLM = null;
45: LayoutManager lastLM = null;
46: LayoutContext lc = new LayoutContext(0);
47:
48: // "unwrap" the NonLeafPositions stored in parentIter
49: // and put them in a new list;
50: LinkedList positionList = new LinkedList();
51: Position pos;
52: while (parentIter.hasNext()) {
53: pos = (Position) parentIter.next();
54: //log.trace("pos = " + pos.getClass().getName() + "; " + pos);
55: Position innerPosition = pos;
56: if (pos instanceof NonLeafPosition) {
57: innerPosition = ((NonLeafPosition) pos).getPosition();
58: if (innerPosition.getLM() == this ) {
59: // pos was created by this LM and was inside a penalty
60: // allowing or forbidding a page break
61: // nothing to do
62: //log.trace(" penalty");
63: } else {
64: // innerPosition was created by another LM
65: positionList.add(innerPosition);
66: lastLM = innerPosition.getLM();
67: //log.trace(" " + innerPosition.getClass().getName());
68: }
69: }
70: }
71:
72: // the Positions in positionList were inside the elements
73: // created by the LineLM
74: StackingIter childPosIter = new StackingIter(positionList
75: .listIterator());
76:
77: while ((childLM = childPosIter.getNextChildLM()) != null) {
78: // set last area flag
79: lc.setFlags(LayoutContext.LAST_AREA, (layoutContext
80: .isLastArea() && childLM == lastLM));
81: // Add the line areas to Area
82: childLM.addAreas(childPosIter, lc);
83: }
84: }
85:
86: /** @see org.apache.fop.layoutmgr.LayoutManager#addChildArea(org.apache.fop.area.Area) */
87: public void addChildArea(Area childArea) {
88: childArea.setAreaClass(Area.CLASS_FOOTNOTE);
89: parentLM.addChildArea(childArea);
90: }
91:
92: /** @return the FootnoteBody node */
93: protected FootnoteBody getFootnodeBodyFO() {
94: return (FootnoteBody) fobj;
95: }
96:
97: }
|