You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

WrapperLayoutManager.java 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with
  4. * this work for additional information regarding copyright ownership.
  5. * The ASF licenses this file to You under the Apache License, Version 2.0
  6. * (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. *
  9. * 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. /* $Id$ */
  18. package org.apache.fop.layoutmgr.inline;
  19. import org.apache.fop.area.Block;
  20. import org.apache.fop.area.inline.InlineArea;
  21. import org.apache.fop.fo.flow.Wrapper;
  22. import org.apache.fop.layoutmgr.BlockLayoutManager;
  23. import org.apache.fop.layoutmgr.BlockStackingLayoutManager;
  24. import org.apache.fop.layoutmgr.LayoutContext;
  25. import org.apache.fop.layoutmgr.PositionIterator;
  26. import org.apache.fop.layoutmgr.TraitSetter;
  27. /**
  28. * This is the layout manager for the fo:wrapper formatting object.
  29. */
  30. public class WrapperLayoutManager extends LeafNodeLayoutManager {
  31. /**
  32. * Creates a new LM for fo:wrapper.
  33. * @param node the fo:wrapper
  34. */
  35. public WrapperLayoutManager(Wrapper node) {
  36. super(node);
  37. }
  38. /** {@inheritDoc} */
  39. public InlineArea get(LayoutContext context) {
  40. // Create a zero-width, zero-height dummy area so this node can
  41. // participate in the ID handling. Otherwise, addId() wouldn't
  42. // be called. The area must also be added to the tree, because
  43. // determination of the X,Y position is done in the renderer.
  44. InlineArea area = new InlineArea();
  45. if (fobj.hasId()) {
  46. TraitSetter.setProducerID(area, fobj.getId());
  47. }
  48. return area;
  49. }
  50. /**
  51. * Add the area for this layout manager.
  52. * This adds the dummy area to the parent, *if* it has an id
  53. * - otherwise it serves no purpose.
  54. *
  55. * @param posIter the position iterator
  56. * @param context the layout context for adding the area
  57. */
  58. public void addAreas(PositionIterator posIter, LayoutContext context) {
  59. if (fobj.hasId()) {
  60. addId();
  61. if (parentLayoutManager instanceof BlockStackingLayoutManager
  62. && !(parentLayoutManager instanceof BlockLayoutManager)) {
  63. Block helperBlock = new Block();
  64. helperBlock.setChangeBarList(getChangeBarList());
  65. TraitSetter.setProducerID(helperBlock, fobj.getId());
  66. parentLayoutManager.addChildArea(helperBlock);
  67. } else {
  68. InlineArea area = getEffectiveArea(context);
  69. area.setChangeBarList(getChangeBarList());
  70. parentLayoutManager.addChildArea(area);
  71. }
  72. }
  73. while (posIter.hasNext()) {
  74. posIter.next();
  75. }
  76. }
  77. /** {@inheritDoc} */
  78. protected void addId() {
  79. getPSLM().addIDToPage(fobj.getId());
  80. }
  81. }