Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

TableRow.java 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. package org.apache.xml.fop.fo.flow;
  2. // FOP
  3. import org.apache.xml.fop.fo.*;
  4. import org.apache.xml.fop.fo.properties.*;
  5. import org.apache.xml.fop.layout.*;
  6. import org.apache.xml.fop.apps.FOPException;
  7. // Java
  8. import java.util.Vector;
  9. public class TableRow extends FObj {
  10. public static class Maker extends FObj.Maker {
  11. public FObj make(FObj parent, PropertyList propertyList)
  12. throws FOPException {
  13. return new TableRow(parent, propertyList);
  14. }
  15. }
  16. public static FObj.Maker maker() {
  17. return new TableRow.Maker();
  18. }
  19. FontState fs;
  20. int startIndent;
  21. int endIndent;
  22. int spaceBefore;
  23. int spaceAfter;
  24. int widthOfCellsSoFar = 0;
  25. int largestCellHeight = 0;
  26. Vector columns;
  27. BlockArea blockArea;
  28. public TableRow(FObj parent, PropertyList propertyList) {
  29. super(parent, propertyList);
  30. this.name = "fo:table-row";
  31. }
  32. public void setColumns(Vector columns) {
  33. this.columns = columns;
  34. }
  35. public int layout(Area area) throws FOPException {
  36. if (this.marker == BREAK_AFTER) {
  37. return OK;
  38. }
  39. if (this.marker == START) {
  40. String fontFamily =
  41. this.properties.get("font-family").getString();
  42. String fontStyle =
  43. this.properties.get("font-style").getString();
  44. String fontWeight =
  45. this.properties.get("font-weight").getString();
  46. int fontSize =
  47. this.properties.get("font-size").getLength().mvalue();
  48. this.fs = new FontState(area.getFontInfo(), fontFamily,
  49. fontStyle, fontWeight, fontSize);
  50. this.startIndent =
  51. this.properties.get("start-indent").getLength().mvalue();
  52. this.endIndent =
  53. this.properties.get("end-indent").getLength().mvalue();
  54. this.spaceBefore =
  55. this.properties.get("space-before.optimum").getLength().mvalue();
  56. this.spaceAfter =
  57. this.properties.get("space-after.optimum").getLength().mvalue();
  58. if (area instanceof BlockArea) {
  59. area.end();
  60. }
  61. //if (this.isInListBody) {
  62. //startIndent += bodyIndent + distanceBetweenStarts;
  63. //}
  64. this.marker = 0;
  65. }
  66. if ((spaceBefore != 0) && (this.marker ==0)) {
  67. area.addDisplaySpace(spaceBefore);
  68. }
  69. this.blockArea =
  70. new BlockArea(fs, area.getAllocationWidth(),
  71. area.spaceLeft(), startIndent, endIndent, 0,
  72. 0, 0, 0);
  73. blockArea.setPage(area.getPage());
  74. blockArea.start();
  75. int numChildren = this.children.size();
  76. if (numChildren != columns.size()) {
  77. System.err.println("WARNING: Number of children under table-row not equal to number of table-columns");
  78. return OK;
  79. }
  80. for (int i = this.marker; i < numChildren; i++) {
  81. TableCell cell = (TableCell) children.elementAt(i);
  82. //if (this.isInListBody) {
  83. //fo.setIsInListBody();
  84. //fo.setDistanceBetweenStarts(this.distanceBetweenStarts);
  85. //fo.setBodyIndent(this.bodyIndent);
  86. //}
  87. cell.setStartOffset(widthOfCellsSoFar);
  88. int width = ((TableColumn) columns.elementAt(i)).getColumnWidth();
  89. cell.setWidth(width);
  90. widthOfCellsSoFar += width;
  91. int status;
  92. if ((status = cell.layout(blockArea)) != OK) {
  93. this.marker = i;
  94. if ((i != 0) && (status == AREA_FULL_NONE)) {
  95. status = AREA_FULL_SOME;
  96. }
  97. //blockArea.end();
  98. area.addChild(blockArea);
  99. area.increaseHeight(blockArea.getHeight());
  100. return status;
  101. }
  102. int h = cell.getHeight();
  103. blockArea.addDisplaySpace(-h);
  104. if (h > largestCellHeight) {
  105. largestCellHeight = h;
  106. }
  107. }
  108. blockArea.end();
  109. area.addChild(blockArea);
  110. area.addDisplaySpace(largestCellHeight);
  111. area.increaseHeight(largestCellHeight);
  112. if (spaceAfter != 0) {
  113. area.addDisplaySpace(spaceAfter);
  114. }
  115. if (area instanceof BlockArea) {
  116. area.start();
  117. }
  118. return OK;
  119. }
  120. public int getAreaHeight() {
  121. return blockArea.getHeight();
  122. }
  123. }