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.

Table.java 8.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. /*
  2. * $Id$
  3. * ============================================================================
  4. * The Apache Software License, Version 1.1
  5. * ============================================================================
  6. *
  7. * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
  8. *
  9. * Redistribution and use in source and binary forms, with or without modifica-
  10. * tion, are permitted provided that the following conditions are met:
  11. *
  12. * 1. Redistributions of source code must retain the above copyright notice,
  13. * this list of conditions and the following disclaimer.
  14. *
  15. * 2. Redistributions in binary form must reproduce the above copyright notice,
  16. * this list of conditions and the following disclaimer in the documentation
  17. * and/or other materials provided with the distribution.
  18. *
  19. * 3. The end-user documentation included with the redistribution, if any, must
  20. * include the following acknowledgment: "This product includes software
  21. * developed by the Apache Software Foundation (http://www.apache.org/)."
  22. * Alternately, this acknowledgment may appear in the software itself, if
  23. * and wherever such third-party acknowledgments normally appear.
  24. *
  25. * 4. The names "FOP" and "Apache Software Foundation" must not be used to
  26. * endorse or promote products derived from this software without prior
  27. * written permission. For written permission, please contact
  28. * apache@apache.org.
  29. *
  30. * 5. Products derived from this software may not be called "Apache", nor may
  31. * "Apache" appear in their name, without prior written permission of the
  32. * Apache Software Foundation.
  33. *
  34. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  35. * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  36. * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  37. * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
  38. * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
  39. * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  40. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  41. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  42. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  43. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  44. * ============================================================================
  45. *
  46. * This software consists of voluntary contributions made by many individuals
  47. * on behalf of the Apache Software Foundation and was originally created by
  48. * James Tauber <jtauber@jtauber.com>. For more information on the Apache
  49. * Software Foundation, please see <http://www.apache.org/>.
  50. */
  51. package org.apache.fop.fo.flow;
  52. // Java
  53. import java.util.ArrayList;
  54. import java.util.List;
  55. // FOP
  56. import org.apache.fop.datatypes.ColorType;
  57. import org.apache.fop.datatypes.LengthRange;
  58. import org.apache.fop.fo.FONode;
  59. import org.apache.fop.fo.FObj;
  60. import org.apache.fop.fo.properties.TableLayout;
  61. import org.apache.fop.fo.properties.TableOmitFooterAtBreak;
  62. import org.apache.fop.fo.properties.TableOmitHeaderAtBreak;
  63. import org.apache.fop.layout.AccessibilityProps;
  64. import org.apache.fop.layout.AuralProps;
  65. import org.apache.fop.layout.BackgroundProps;
  66. import org.apache.fop.layout.BorderAndPadding;
  67. import org.apache.fop.layout.MarginProps;
  68. import org.apache.fop.layout.RelativePositionProps;
  69. import org.apache.fop.layoutmgr.table.TableLayoutManager;
  70. public class Table extends FObj {
  71. private static final int MINCOLWIDTH = 10000; // 10pt
  72. protected ArrayList columns = null;
  73. private TableBody tableHeader = null;
  74. private TableBody tableFooter = null;
  75. private boolean omitHeaderAtBreak = false;
  76. private boolean omitFooterAtBreak = false;
  77. private int breakBefore;
  78. private int breakAfter;
  79. private int spaceBefore;
  80. private int spaceAfter;
  81. private ColorType backgroundColor;
  82. private LengthRange ipd;
  83. private int height;
  84. private boolean bAutoLayout = false;
  85. private int contentWidth = 0; // Sum of column widths
  86. /** Optimum inline-progression-dimension */
  87. private int optIPD;
  88. /** Minimum inline-progression-dimension */
  89. private int minIPD;
  90. /** Maximum inline-progression-dimension */
  91. private int maxIPD;
  92. public Table(FONode parent) {
  93. super(parent);
  94. }
  95. protected void addChild(FONode child) {
  96. if (child.getName().equals("fo:table-column")) {
  97. if (columns == null) {
  98. columns = new ArrayList();
  99. }
  100. columns.add(((TableColumn)child).getLayoutManager());
  101. } else if (child.getName().equals("fo:table-footer")) {
  102. tableFooter = (TableBody)child;
  103. } else if (child.getName().equals("fo:table-header")) {
  104. tableHeader = (TableBody)child;
  105. } else {
  106. // add bodies
  107. super.addChild(child);
  108. }
  109. }
  110. /**
  111. * Return a LayoutManager responsible for laying out this FObj's content.
  112. * Must override in subclasses if their content can be laid out.
  113. */
  114. public void addLayoutManager(List list) {
  115. TableLayoutManager tlm = new TableLayoutManager();
  116. tlm.setUserAgent(getUserAgent());
  117. tlm.setFObj(this);
  118. tlm.setColumns(columns);
  119. if (tableHeader != null) {
  120. tlm.setTableHeader(tableHeader.getLayoutManager());
  121. }
  122. if (tableFooter != null) {
  123. tlm.setTableFooter(tableFooter.getLayoutManager());
  124. }
  125. list.add(tlm);
  126. }
  127. public void setup() {
  128. // Common Accessibility Properties
  129. AccessibilityProps mAccProps = propMgr.getAccessibilityProps();
  130. // Common Aural Properties
  131. AuralProps mAurProps = propMgr.getAuralProps();
  132. // Common Border, Padding, and Background Properties
  133. BorderAndPadding bap = propMgr.getBorderAndPadding();
  134. BackgroundProps bProps = propMgr.getBackgroundProps();
  135. // Common Margin Properties-Block
  136. MarginProps mProps = propMgr.getMarginProps();
  137. // Common Relative Position Properties
  138. RelativePositionProps mRelProps =
  139. propMgr.getRelativePositionProps();
  140. // this.properties.get("block-progression-dimension");
  141. // this.properties.get("border-after-precendence");
  142. // this.properties.get("border-before-precedence");
  143. // this.properties.get("border-collapse");
  144. // this.properties.get("border-end-precendence");
  145. // this.properties.get("border-separation");
  146. // this.properties.get("border-start-precendence");
  147. // this.properties.get("break-after");
  148. // this.properties.get("break-before");
  149. setupID();
  150. // this.properties.get("inline-progression-dimension");
  151. // this.properties.get("height");
  152. // this.properties.get("keep-together");
  153. // this.properties.get("keep-with-next");
  154. // this.properties.get("keep-with-previous");
  155. // this.properties.get("table-layout");
  156. // this.properties.get("table-omit-footer-at-break");
  157. // this.properties.get("table-omit-header-at-break");
  158. // this.properties.get("width");
  159. // this.properties.get("writing-mode");
  160. this.breakBefore = this.properties.get("break-before").getEnum();
  161. this.breakAfter = this.properties.get("break-after").getEnum();
  162. this.spaceBefore = this.properties.get(
  163. "space-before.optimum").getLength().getValue();
  164. this.spaceAfter = this.properties.get(
  165. "space-after.optimum").getLength().getValue();
  166. this.backgroundColor =
  167. this.properties.get("background-color").getColorType();
  168. this.ipd = this.properties.get(
  169. "inline-progression-dimension").getLengthRange();
  170. this.height = this.properties.get("height").getLength().getValue();
  171. this.bAutoLayout = (this.properties.get(
  172. "table-layout").getEnum() == TableLayout.AUTO);
  173. this.omitHeaderAtBreak = this.properties.get(
  174. "table-omit-header-at-break").getEnum()
  175. == TableOmitHeaderAtBreak.TRUE;
  176. this.omitFooterAtBreak = this.properties.get(
  177. "table-omit-footer-at-break").getEnum()
  178. == TableOmitFooterAtBreak.TRUE;
  179. }
  180. public boolean generatesInlineAreas() {
  181. return false;
  182. }
  183. protected boolean containsMarkers() {
  184. return true;
  185. }
  186. }