Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

FootnoteBodyLayoutManager.java 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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;
  19. import java.util.LinkedList;
  20. import org.apache.fop.area.Area;
  21. import org.apache.fop.fo.flow.FootnoteBody;
  22. /**
  23. * Layout manager for footnote bodies.
  24. */
  25. public class FootnoteBodyLayoutManager extends BlockStackingLayoutManager {
  26. /**
  27. * Creates a new FootnoteBodyLayoutManager.
  28. * @param body the footnote-body element
  29. */
  30. public FootnoteBodyLayoutManager(FootnoteBody body) {
  31. super(body);
  32. }
  33. /** {@inheritDoc} */
  34. @Override
  35. public void addAreas(PositionIterator parentIter, LayoutContext layoutContext) {
  36. LayoutManager childLM;
  37. LayoutManager lastLM = null;
  38. LayoutContext lc = LayoutContext.newInstance();
  39. // "unwrap" the NonLeafPositions stored in parentIter
  40. // and put them in a new list;
  41. LinkedList<Position> positionList = new LinkedList<Position>();
  42. Position pos;
  43. while (parentIter.hasNext()) {
  44. pos = parentIter.next();
  45. Position innerPosition;
  46. if (pos instanceof NonLeafPosition) {
  47. innerPosition = pos.getPosition();
  48. if (innerPosition.getLM() == this) {
  49. // pos was created by this LM and was inside a penalty
  50. // allowing or forbidding a page break
  51. // nothing to do
  52. } else {
  53. // innerPosition was created by another LM
  54. positionList.add(innerPosition);
  55. lastLM = innerPosition.getLM();
  56. }
  57. }
  58. }
  59. // the Positions in positionList were inside the elements
  60. // created by the LineLM
  61. PositionIterator childPosIter = new PositionIterator(positionList.listIterator());
  62. while ((childLM = childPosIter.getNextChildLM()) != null) {
  63. // set last area flag
  64. lc.setFlags(LayoutContext.LAST_AREA,
  65. (layoutContext.isLastArea() && childLM == lastLM));
  66. // Add the line areas to Area
  67. childLM.addAreas(childPosIter, lc);
  68. }
  69. }
  70. /** {@inheritDoc} */
  71. @Override
  72. public void addChildArea(Area childArea) {
  73. childArea.setAreaClass(Area.CLASS_FOOTNOTE);
  74. parentLayoutManager.addChildArea(childArea);
  75. }
  76. /** @return the FootnoteBody node */
  77. protected FootnoteBody getFootnodeBodyFO() {
  78. return (FootnoteBody) fobj;
  79. }
  80. /** {@inheritDoc} */
  81. @Override
  82. public Keep getKeepTogether() {
  83. return getParentKeepTogether();
  84. }
  85. /** {@inheritDoc} */
  86. @Override
  87. public Keep getKeepWithNext() {
  88. return Keep.KEEP_AUTO;
  89. }
  90. /** {@inheritDoc} */
  91. @Override
  92. public Keep getKeepWithPrevious() {
  93. return Keep.KEEP_AUTO;
  94. }
  95. }