Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*
  2. * $Id$
  3. * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
  4. * For details on use and redistribution please refer to the
  5. * LICENSE file included with these sources.
  6. */
  7. package org.apache.fop.fo.flow;
  8. // FOP
  9. import org.apache.fop.fo.*;
  10. import org.apache.fop.layout.*;
  11. import org.apache.fop.apps.FOPException;
  12. import org.apache.fop.fo.properties.*;
  13. import org.apache.fop.messaging.*;
  14. // Java
  15. import java.util.ArrayList;
  16. public class Footnote extends FObj {
  17. public Footnote(FONode parent) {
  18. super(parent);
  19. }
  20. public Status layout(Area area) throws FOPException {
  21. FONode inline = null;
  22. FONode fbody = null;
  23. if (this.marker == START) {
  24. this.marker = 0;
  25. }
  26. int numChildren = this.children.size();
  27. for (int i = this.marker; i < numChildren; i++) {
  28. FONode fo = (FONode)children.get(i);
  29. if (fo instanceof Inline) {
  30. inline = fo;
  31. Status status = fo.layout(area);
  32. if (status.isIncomplete()) {
  33. return status;
  34. }
  35. } else if (inline != null && fo instanceof FootnoteBody) {
  36. // add footnote to current page or next if it can't fit
  37. fbody = fo;
  38. if (area instanceof BlockArea) {
  39. ((BlockArea)area).addFootnote((FootnoteBody)fbody);
  40. } else {
  41. Page page = area.getPage();
  42. layoutFootnote(page, (FootnoteBody)fbody, area);
  43. }
  44. }
  45. }
  46. if (fbody == null) {
  47. log.error("no footnote-body in footnote");
  48. }
  49. if (area instanceof BlockArea) {}
  50. return new Status(Status.OK);
  51. }
  52. public static boolean layoutFootnote(Page p, FootnoteBody fb, Area area) {
  53. try {
  54. BodyAreaContainer bac = p.getBody();
  55. AreaContainer footArea = bac.getFootnoteReferenceArea();
  56. footArea.setIDReferences(bac.getIDReferences());
  57. int basePos = footArea.getCurrentYPosition()
  58. - footArea.getHeight();
  59. int oldHeight = footArea.getHeight();
  60. if (area != null) {
  61. footArea.setMaxHeight(area.getMaxHeight() - area.getHeight()
  62. + footArea.getHeight());
  63. } else {
  64. footArea.setMaxHeight(bac.getMaxHeight()
  65. + footArea.getHeight());
  66. }
  67. Status status = fb.layout(footArea);
  68. if (status.isIncomplete()) {
  69. // add as a pending footnote
  70. return false;
  71. } else {
  72. if (area != null) {
  73. area.setMaxHeight(area.getMaxHeight()
  74. - footArea.getHeight() + oldHeight);
  75. }
  76. // bac.setMaxHeight(bac.getMaxHeight() - footArea.getHeight() + oldHeight);
  77. if (bac.getFootnoteState() == 0) {
  78. Area ar = bac.getMainReferenceArea();
  79. //decreaseMaxHeight(ar, footArea.getHeight() - oldHeight);
  80. footArea.setYPosition(basePos + footArea.getHeight());
  81. }
  82. }
  83. } catch (FOPException fope) {
  84. return false;
  85. }
  86. return true;
  87. }
  88. /* protected static void decreaseMaxHeight(Area ar, int change) {
  89. ar.setMaxHeight(ar.getMaxHeight() - change);
  90. ArrayList childs = ar.getChildren();
  91. for (Iterator en = childs.iterator(); en.hasNext(); ) {
  92. Object obj = en.next();
  93. if (obj instanceof Area) {
  94. Area childArea = (Area)obj;
  95. decreaseMaxHeight(childArea, change);
  96. }
  97. }
  98. }
  99. */
  100. }