]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Fix some bugs in table and cell border drawing and cell width calculations
authorKaren Lease <klease@apache.org>
Fri, 20 Jul 2001 21:00:08 +0000 (21:00 +0000)
committerKaren Lease <klease@apache.org>
Fri, 20 Jul 2001 21:00:08 +0000 (21:00 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@194362 13f79535-47bb-0310-9956-ffa450edef68

src/org/apache/fop/fo/flow/Table.java
src/org/apache/fop/fo/flow/TableCell.java
src/org/apache/fop/fo/flow/TableColumn.java

index 8468dc0cf3ab3715d7a5115a9835e560782677ac..e522a1b9afcfbc163ae94574e511c231eb63f3e7 100644 (file)
@@ -1,52 +1,7 @@
 /*-- $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
- APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
- INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
- DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
- OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
- 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
- Software Foundation, please see <http://www.apache.org/>.
-
+ * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * For details on use and redistribution please refer to the
+ * LICENSE file included with these sources.
  */
 
 package org.apache.fop.fo.flow;
@@ -353,7 +308,7 @@ public class Table extends FObj {
                                for (int i = 0; i < numChildren; i++) {
                                                FONode fo = (FONode) children.elementAt(i);
                                                if (fo instanceof TableColumn) {
-                                                               ((TableColumn) fo).setHeight(areaContainer.getHeight());
+                                                               ((TableColumn) fo).setHeight(areaContainer.getContentHeight());
                                                }
                                }
                }
@@ -372,4 +327,45 @@ public class Table extends FObj {
                                                return 0; // not laid out yet
                }
 
+//             /**
+//              * Return the last TableRow in the header or null if no header or
+//              * no header in non-first areas.
+//              * @param bForInitialArea If true, return the header row for the
+//              * initial table area, else for a continuation area, taking into
+//              * account the omit-header-at-break property.
+//              */
+//             TableRow getLastHeaderRow(boolean bForInitialArea) {
+//                             // Check omit...
+//                             if ((tableHeader != null)  &&
+//                                             (bForInitialArea || omitHeaderAtBreak == false)) {
+//                                             return tableHeader.children.lastElement();
+//                             }
+//                             return null;
+//             }
+
+//             /**
+//              * Return the first TableRow in the footer or null if no footer or
+//              * no footer in non-last areas.
+//              * @param bForFinalArea If true, return the footer row for the
+//              * final table area, else for a non-final area, taking into
+//              * account the omit-footer-at-break property.
+//              */
+//             TableRow getLastFooterRow(boolean bForFinalArea) {
+//                             if ((tableFooter != null) &&
+//                                             (bForFinalArea || omitFooterAtBreak == false)) {
+//                                             return tableFooter.children.firstElement();
+//                             }
+//                             return null;
+//             }
+
+
+//             /**
+//              * Return border information for the side (start/end) of the column
+//              * whose number is iColNumber (first column = 1).
+//              * ATTENTION: for now we assume columns are in order in the array!
+//              */
+//             BorderInfo getColumnBorder(BorderInfo.Side side, int iColNumber) {
+//                             TableColumn col = (TableColumn)columns.elementAt(iColNumber);
+//                             return col.getBorderInfo(side);
+//             }
 }
index b1cab472b746f2b31209f13485e5ebbdd12f4a19..c5a8a067628681196551c2e942a4ba5ffea56084 100644 (file)
@@ -40,13 +40,25 @@ public class TableCell extends FObj {
                 */
                protected int startOffset;
 
-               /** Dimension of content rectangle in inline-progression-direction */
+               /** Dimension of allocation rectangle in inline-progression-direction,
+                *  determined by the width of the column(s) occupied by the cell
+                */
                protected int width;
 
                /** Offset of content rectangle, in block-progression-direction,
                 * relative to the row.
                 */
-               protected int beforeOffset;
+               protected int beforeOffset=0;
+
+               /** Offset of content rectangle, in inline-progression-direction,
+                * relative to the column start edge.
+                */
+               protected int startAdjust=0;
+
+               /** Adjust to theoretical column width to obtain content width
+                * relative to the column start edge.
+                */
+               protected int widthAdjust=0;
 
                /* For collapsed border style */
                protected int borderHeight = 0;
@@ -120,6 +132,9 @@ public class TableCell extends FObj {
 
                        bSepBorders = (this.properties.get("border-collapse").getEnum() ==
                                                                                                        BorderCollapse.SEPARATE);
+
+                       calcBorders(propMgr.getBorderAndPadding());
+
                        // Vertical cell alignment
                        verticalAlign = this.properties.get("display-align").getEnum();
                        if (verticalAlign == DisplayAlign.AUTO) {
@@ -145,7 +160,7 @@ public class TableCell extends FObj {
 //                                             }
 
                                                // Calculate cell borders
-                                               calcBorders(propMgr.getBorderAndPadding());
+                                               // calcBorders(propMgr.getBorderAndPadding());
 
                                                area.getIDReferences().createID(id);
 
@@ -169,8 +184,9 @@ public class TableCell extends FObj {
                                // and padding are outside of this rectangle.
                                this.cellArea =
                                                new AreaContainer(propMgr.getFontState(area.getFontInfo()),
-                                                                                                                       startOffset, beforeOffset,
-                                                                                                                       width, spaceLeft,
+                                                                                                                       startOffset+startAdjust,
+                                                                                                                       beforeOffset,
+                                                                                                                       width-widthAdjust, spaceLeft,
                                                                                                                        Position.RELATIVE);
 
                                cellArea.foCreator=this;        // G Seshadri
@@ -306,15 +322,14 @@ public class TableCell extends FObj {
                                                 * but it inherits.
                                                 */
                                                int iSep = properties.get("border-separation.inline-progression-direction").getLength().mvalue();
-                                               int contentOffset = iSep/2 + bp.getBorderLeftWidth(false) +
+                                               this.startAdjust = iSep/2 + bp.getBorderLeftWidth(false) +
                                                                bp.getPaddingLeft(false);
                                                /*
                                                int contentOffset = iSep + bp.getBorderStartWidth(false) +
                                                                bp.getPaddingStart(false);
                                                */
-                                               this.startOffset += contentOffset;
-                                               this.width -= (contentOffset + iSep - iSep/2 +
-                                                               bp.getBorderRightWidth(false) + bp.getPaddingRight(false));
+                                               this.widthAdjust = startAdjust + iSep - iSep/2 +
+                                                               bp.getBorderRightWidth(false) + bp.getPaddingRight(false);
                                                // bp.getBorderEndWidth(false) + bp.getPaddingEnd(false);
                                                // Offset of content rectangle in the block-progression direction
                                                m_borderSeparation =
@@ -376,10 +391,10 @@ public class TableCell extends FObj {
                                                int borderBefore = bp.getBorderTopWidth(false);
                                                int borderAfter  = bp.getBorderBottomWidth(false);
 
-                                               int contentOffset = borderStart/2 + bp.getPaddingLeft(false);
+                                               this.startAdjust = borderStart/2 + bp.getPaddingLeft(false);
 
-                                               this.startOffset += contentOffset;
-                                               this.width -= (contentOffset + borderEnd/2 + bp.getPaddingRight(false));
+                                               this.widthAdjust = startAdjust + borderEnd/2 +
+                                                               bp.getPaddingRight(false);
                                                this.beforeOffset = borderBefore/2 + bp.getPaddingTop(false);
                                                // Half border height to fix overestimate of area size!
                                                this.borderHeight = (borderBefore + borderAfter)/2;
index 5bde1115ee6f63829c98752d9689626026c36f1c..c6c6dda922e99aff080f2bcebf998fd4efa54975 100644 (file)
@@ -127,11 +127,13 @@ public class TableColumn extends FObj {
                                }
                        }
 
+                       // KL: don't take table borders into account!
        this.areaContainer =
                        new AreaContainer(propMgr.getFontState(area.getFontInfo()),
-                                                                                               columnOffset - area.getBorderLeftWidth(),
-                                                                                               -area.getBorderTopWidth(), columnWidth,
-                               area.getHeight(), Position.RELATIVE);
+                                                                                               columnOffset /*- area.getBorderLeftWidth()*/,
+                                                                                               /*-area.getBorderTopWidth()*/ 0, columnWidth,
+                                                                                               area.getContentHeight(), Position.RELATIVE);
+       //      area.getHeight(), Position.RELATIVE);
        areaContainer.foCreator=this;   // G Seshadri
        areaContainer.setPage(area.getPage());
        areaContainer.setBorderAndPadding(propMgr.getBorderAndPadding());