]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
fixes a problem with spaces before and after a body in table
authorKeiron Liddle <keiron@apache.org>
Fri, 12 Jan 2001 04:48:28 +0000 (04:48 +0000)
committerKeiron Liddle <keiron@apache.org>
Fri, 12 Jan 2001 04:48:28 +0000 (04:48 +0000)
also properly sets the width of the table to the sum of the columns

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@193969 13f79535-47bb-0310-9956-ffa450edef68

src/org/apache/fop/fo/flow/Table.java
src/org/apache/fop/fo/flow/TableBody.java
src/org/apache/fop/fo/flow/TableCell.java
src/org/apache/fop/layout/Area.java

index 9a3393529907588846668d0a891bff8154534ab4..cfe2771df7ce0fc1f8818c6c0adc165473acce92 100644 (file)
@@ -215,6 +215,8 @@ public class Table extends FObj {
                 offset += c.getColumnWidth();
             }
         }
+        areaContainer.setAllocationWidth(offset);
+
         for (int i = this.marker; i < numChildren; i++) {
             FONode fo = (FONode) children.elementAt(i);
             if (fo instanceof TableHeader) {
index 87c317ad45366cc4949c137d168c62cf13d203b4..c03ce5695aea40bc31bcaef2757c8b59ecfc1726 100644 (file)
@@ -155,7 +155,7 @@ public class TableBody extends FObj {
         }
 
         if ((spaceBefore != 0) && (this.marker == 0)) {
-            area.addDisplaySpace(spaceBefore);
+            area.increaseHeight(spaceBefore);
         }
 
         if (marker == 0) {
@@ -267,13 +267,12 @@ public class TableBody extends FObj {
         area.addChild(areaContainer);
         areaContainer.end();
 
-        /* should this be combined into above? */
         area.increaseHeight(areaContainer.getHeight());
 
         area.setAbsoluteHeight(areaContainer.getAbsoluteHeight());
 
         if (spaceAfter != 0) {
-            area.addDisplaySpace(spaceAfter);
+            area.increaseHeight(spaceAfter);
         }
 
         if (area instanceof BlockArea) {
index 5543af2f3ddaa341f5a5bb1b826d53b45cb08b49..ecdd81359998242996b18b25b602d3ac94a808ea 100644 (file)
@@ -101,7 +101,7 @@ public class TableCell extends FObj {
 
     protected int height = 0;
     protected int top;
-    protected int verticalAlign = 0;
+    protected int verticalAlign = VerticalAlign.BASELINE;
 
     boolean setup = false;
 
@@ -243,7 +243,7 @@ public class TableCell extends FObj {
        }
 
        if ((spaceBefore != 0) && (this.marker ==0)) {
-           area.addDisplaySpace(spaceBefore);
+           area.increaseHeight(spaceBefore);
        }
 
         if ( marker==0 ) {
@@ -253,7 +253,7 @@ public class TableCell extends FObj {
 
        this.areaContainer =
            new AreaContainer(fs, startOffset - area.borderWidthLeft,
-                              - area.borderWidthTop,
+                              - area.borderWidthTop + ((this.marker ==0) ? spaceBefore : 0),
                           width, area.spaceLeft(), Position.RELATIVE);
        areaContainer.setPage(area.getPage());
        areaContainer.setPadding(paddingTop, paddingLeft, paddingBottom,
@@ -293,17 +293,17 @@ public class TableCell extends FObj {
        areaContainer.end();
        area.addChild(areaContainer);
 
-       height = getHeight();
+       height = areaContainer.getHeight();
        top = areaContainer.getCurrentYPosition();
        // reset absoluteHeight to beginning of row
-       area.setHeight(getHeight());
+       area.setHeight(areaContainer.getHeight() + spaceBefore + spaceAfter);
        area.setAbsoluteHeight(originalAbsoluteHeight);
 
        return new Status(Status.OK);
     }
 
     public int getHeight() {
-       return areaContainer.getHeight();
+       return areaContainer.getHeight() + spaceBefore + spaceAfter;
     }
     
     public void setRowHeight(int h) {
@@ -311,11 +311,11 @@ public class TableCell extends FObj {
            switch(verticalAlign) {
                case VerticalAlign.MIDDLE:
                    areaContainer.setHeight(height);
-                   areaContainer.setYPosition(top + h / 2 - height / 2);
+                   areaContainer.setYPosition(spaceBefore + top + h / 2 - height / 2);
                break;
                case VerticalAlign.BASELINE:
                    default:
-                   areaContainer.setHeight(h);
+                   areaContainer.setHeight(h - (spaceBefore + spaceAfter));
                break;
            }
     }
index 2ecee588ea2776ee5ecc16c7d428e05462917000..22489857a6fc6e6a7281adde683f86bf133584c3 100644 (file)
@@ -1,36 +1,36 @@
-/*-- $Id$ -- 
+/*-- $Id$ --
 
  ============================================================================
                    The Apache Software License, Version 1.1
  ============================================================================
+
     Copyright (C) 1999 The Apache Software Foundation. All rights reserved.
+
  Redistribution and use in source and binary forms, with or without modifica-
  tion, are permitted provided that the following conditions are met:
+
  1. Redistributions of  source code must  retain the above copyright  notice,
     this list of conditions and the following disclaimer.
+
  2. Redistributions in binary form must reproduce the above copyright notice,
     this list of conditions and the following disclaimer in the documentation
     and/or other materials provided with the distribution.
+
  3. The end-user documentation included with the redistribution, if any, must
     include  the following  acknowledgment:  "This product includes  software
     developed  by the  Apache Software Foundation  (http://www.apache.org/)."
     Alternately, this  acknowledgment may  appear in the software itself,  if
     and wherever such third-party acknowledgments normally appear.
+
  4. The names "FOP" and  "Apache Software Foundation"  must not be used to
     endorse  or promote  products derived  from this  software without  prior
     written permission. For written permission, please contact
     apache@apache.org.
+
  5. Products  derived from this software may not  be called "Apache", nor may
     "Apache" appear  in their name,  without prior written permission  of the
     Apache Software Foundation.
+
  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
  ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
  (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
  This software  consists of voluntary contributions made  by many individuals
  on  behalf of the Apache Software  Foundation and was  originally created by
- James Tauber <jtauber@jtauber.com>. For more  information on the Apache 
+ James Tauber <jtauber@jtauber.com>. For more  information on the Apache
  Software Foundation, please see <http://www.apache.org/>.
+
  */
 
 package org.apache.fop.layout;
@@ -64,17 +64,17 @@ abstract public class Area extends Box {
     protected FontState fontState;
 
     protected Vector children = new Vector();
-       
+
     /* max size in line-progression-direction */
     protected int maxHeight;
 
     protected int currentHeight = 0;
-    
+
     // used to keep track of the current x position within a table.  Required for drawing rectangle links.
     protected int tableCellXOffset = 0;
-    
+
     // used to keep track of the absolute height on the page.  Required for drawing rectangle links.
-    private int absoluteHeight = 0;  
+    private int absoluteHeight = 0;
 
     protected int contentRectangleWidth;
 
@@ -90,7 +90,7 @@ abstract public class Area extends Box {
     protected int paddingLeft;
     protected int paddingBottom;
     protected int paddingRight;
-    
+
     public int borderWidthTop;
     public int borderWidthLeft;
     public int borderWidthRight;
@@ -105,203 +105,210 @@ abstract public class Area extends Box {
     public ColorType borderColorBottom;
 
     public Area (FontState fontState) {
-       this.fontState = fontState;
+        this.fontState = fontState;
     }
 
     public Area (FontState fontState, int allocationWidth, int maxHeight) {
-       this.fontState = fontState;
-       this.allocationWidth = allocationWidth;
+        this.fontState = fontState;
+        this.allocationWidth = allocationWidth;
         this.contentRectangleWidth = allocationWidth;
-       this.maxHeight = maxHeight;
+        this.maxHeight = maxHeight;
     }
 
     public void addChild(Box child) {
-       this.children.addElement(child);
-       child.parent = this;
+        this.children.addElement(child);
+        child.parent = this;
     }
-    
+
     public void addChildAtStart(Box child) {
-       this.children.insertElementAt(child,0);
-       child.parent = this;
+        this.children.insertElementAt(child, 0);
+        child.parent = this;
     }
-       
+
     public void addDisplaySpace(int size) {
-       this.addChild(new DisplaySpace(size));
+        this.addChild(new DisplaySpace(size));
         this.absoluteHeight += size;
-       this.currentHeight += size;
+        this.currentHeight += size;
     }
 
     public FontInfo getFontInfo() {
-       return this.page.getFontInfo();
+        return this.page.getFontInfo();
     }
-       
+
     public void end() {
     }
-    
+
     public int getAllocationWidth() {
-       return this.allocationWidth - paddingLeft - paddingRight - borderWidthLeft - borderWidthRight;
+        return this.allocationWidth - paddingLeft - paddingRight -
+               borderWidthLeft - borderWidthRight;
+    }
+
+    public void setAllocationWidth(int w) {
+        this.allocationWidth = w;
+        this.contentRectangleWidth = this.allocationWidth;
     }
-    
+
     public Vector getChildren() {
-       return this.children;
+        return this.children;
     }
-       
+
     public int getContentWidth() {
-       return contentRectangleWidth - paddingLeft - paddingRight - borderWidthLeft - borderWidthRight;
+        return contentRectangleWidth - paddingLeft - paddingRight -
+               borderWidthLeft - borderWidthRight;
     }
 
     public FontState getFontState() {
-       return this.fontState;
+        return this.fontState;
     }
 
     public int getContentHeight() {
-       return this.currentHeight;
+        return this.currentHeight;
     }
 
     public int getHeight() {
-       return this.currentHeight + paddingTop + paddingBottom + borderWidthTop + borderWidthBottom;
+        return this.currentHeight + paddingTop + paddingBottom +
+               borderWidthTop + borderWidthBottom;
     }
 
     public int getMaxHeight() {
-       return this.maxHeight - paddingTop - paddingBottom - borderWidthTop - borderWidthBottom;
+        return this.maxHeight - paddingTop - paddingBottom -
+               borderWidthTop - borderWidthBottom;
     }
 
     public Page getPage() {
-       return this.page;
+        return this.page;
     }
 
     public ColorType getBackgroundColor() {
-       return this.backgroundColor;
+        return this.backgroundColor;
     }
 
     public int getPaddingTop() {
-       return this.paddingTop;
+        return this.paddingTop;
     }
 
     public int getPaddingLeft() {
-       return this.paddingLeft;
+        return this.paddingLeft;
     }
 
     public int getPaddingBottom() {
-       return this.paddingBottom;
+        return this.paddingBottom;
     }
 
     public int getPaddingRight() {
-       return this.paddingRight;
+        return this.paddingRight;
     }
 
-    public int getTableCellXOffset()
-    {
+    public int getTableCellXOffset() {
         return tableCellXOffset;
     }
-    
-    public void setTableCellXOffset(int offset)
-    {
-        tableCellXOffset=offset;
+
+    public void setTableCellXOffset(int offset) {
+        tableCellXOffset = offset;
     }
-    
-    public int getAbsoluteHeight()
-    {
+
+    public int getAbsoluteHeight() {
         return absoluteHeight;
     }
 
-    public void setAbsoluteHeight(int value)
-    {
-        absoluteHeight=value;
+    public void setAbsoluteHeight(int value) {
+        absoluteHeight = value;
+    }
+
+    public void increaseAbsoluteHeight(int value) {
+        absoluteHeight += value;
     }
 
-    public void increaseAbsoluteHeight(int value)
-    {
-        absoluteHeight+=value;
-    } 
-    
     public void increaseHeight(int amount) {
-       this.currentHeight += amount;
+        this.currentHeight += amount;
         this.absoluteHeight += amount;
     }
 
     public void removeChild(Area area) {
-       this.currentHeight -= area.getHeight();
+        this.currentHeight -= area.getHeight();
         this.absoluteHeight -= area.getHeight();
-       this.children.removeElement(area);
+        this.children.removeElement(area);
     }
-       
+
     public void removeChild(DisplaySpace spacer) {
-       this.currentHeight -= spacer.getSize();
+        this.currentHeight -= spacer.getSize();
         this.absoluteHeight -= spacer.getSize();
-       this.children.removeElement(spacer);
+        this.children.removeElement(spacer);
     }
 
     public void remove() {
-       this.parent.removeChild(this);
+        this.parent.removeChild(this);
     }
 
     public void setPage(Page page) {
-       this.page = page;
+        this.page = page;
     }
 
     public void setBackgroundColor(ColorType bgColor) {
-       this.backgroundColor = bgColor;
+        this.backgroundColor = bgColor;
     }
 
     public void setPadding(int top, int left, int bottom, int right) {
-       this.paddingTop = top;
-       this.paddingLeft = left;
-       this.paddingBottom = bottom;
-       this.paddingRight = right;
+        this.paddingTop = top;
+        this.paddingLeft = left;
+        this.paddingBottom = bottom;
+        this.paddingRight = right;
     }
 
     public void setBorderWidth(int top, int left, int bottom, int right) {
-       this.borderWidthTop = top;
-       this.borderWidthLeft = left;
-       this.borderWidthBottom = bottom;
-       this.borderWidthRight = right;
+        this.borderWidthTop = top;
+        this.borderWidthLeft = left;
+        this.borderWidthBottom = bottom;
+        this.borderWidthRight = right;
     }
 
     public void setBorderStyle(int top, int left, int bottom, int right) {
-       this.borderStyleTop = top;
-       this.borderStyleLeft = left;
-       this.borderStyleBottom = bottom;
-       this.borderStyleRight = right;
+        this.borderStyleTop = top;
+        this.borderStyleLeft = left;
+        this.borderStyleBottom = bottom;
+        this.borderStyleRight = right;
     }
 
-    public void setBorderColor(ColorType top, ColorType left, ColorType bottom, ColorType right) {
-       this.borderColorTop = top;
-       this.borderColorLeft = left;
-       this.borderColorBottom = bottom;
-       this.borderColorRight = right;
+    public void setBorderColor(ColorType top, ColorType left,
+                               ColorType bottom, ColorType right) {
+        this.borderColorTop = top;
+        this.borderColorLeft = left;
+        this.borderColorBottom = bottom;
+        this.borderColorRight = right;
     }
 
     public int spaceLeft() {
-       return maxHeight - currentHeight;
+        return maxHeight - currentHeight;
     }
 
     public void start() {
     }
-    
+
     public void setHeight(int height) {
-      if (height > currentHeight)
-        currentHeight = height;
-        absoluteHeight = height;        
-      if (currentHeight > getMaxHeight())
-        currentHeight = getMaxHeight();
-        absoluteHeight = getMaxHeight();        
-    }
-    
+        if (height > currentHeight)
+            currentHeight = height;
+        absoluteHeight = height;
+
+        if (currentHeight > getMaxHeight())
+            currentHeight = getMaxHeight();
+        absoluteHeight = getMaxHeight();
+
+    }
+
     public void setMaxHeight(int height) {
-      this.maxHeight = height;
+        this.maxHeight = height;
     }
-    
+
     public Area getParent() {
-      return this.parent;
+        return this.parent;
     }
 
     public void setIDReferences(IDReferences idReferences) {
-      this.idReferences = idReferences;
+        this.idReferences = idReferences;
     }
 
     public IDReferences getIDReferences() {
-      return idReferences;
+        return idReferences;
     }
 
 }