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: WrapperLayoutManager.java 535866 2007-05-07 12:22:22Z jeremias $ */
19:
20: package org.apache.fop.layoutmgr.inline;
21:
22: import org.apache.fop.area.inline.InlineArea;
23: import org.apache.fop.fo.flow.Wrapper;
24: import org.apache.fop.layoutmgr.LayoutContext;
25: import org.apache.fop.layoutmgr.PositionIterator;
26: import org.apache.fop.layoutmgr.TraitSetter;
27:
28: /**
29: * This is the layout manager for the fo:wrapper formatting object.
30: */
31: public class WrapperLayoutManager extends LeafNodeLayoutManager {
32:
33: private Wrapper fobj;
34:
35: /**
36: * Creates a new LM for fo:wrapper.
37: * @param node the fo:wrapper
38: */
39: public WrapperLayoutManager(Wrapper node) {
40: super (node);
41: fobj = node;
42: }
43:
44: /** @see org.apache.fop.layoutmgr.inline.LeafNodeLayoutManager */
45: public InlineArea get(LayoutContext context) {
46: // Create a zero-width, zero-height dummy area so this node can
47: // participate in the ID handling. Otherwise, addId() wouldn't
48: // be called. The area must also be added to the tree, because
49: // determination of the X,Y position is done in the renderer.
50: InlineArea area = new InlineArea();
51: String id = fobj.getId();
52: if (id != null && id.length() > 0) {
53: TraitSetter.setProducerID(area, fobj.getId());
54: }
55: return area;
56: }
57:
58: /**
59: * Add the area for this layout manager.
60: * This adds the dummy area to the parent, *if* it has an id
61: * - otherwise it serves no purpose.
62: *
63: * @param posIter the position iterator
64: * @param context the layout context for adding the area
65: */
66: public void addAreas(PositionIterator posIter, LayoutContext context) {
67: String id = fobj.getId();
68: if (id != null && id.length() > 0) {
69: addId();
70: InlineArea area = getEffectiveArea();
71: parentLM.addChildArea(area);
72: }
73: while (posIter.hasNext()) {
74: posIter.next();
75: }
76: }
77:
78: /** @see org.apache.fop.layoutmgr.inline.LeafNodeLayoutManager#addId() */
79: protected void addId() {
80: getPSLM().addIDToPage(fobj.getId());
81: }
82:
83: }
|