You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by je...@apache.org on 2005/01/31 22:16:45 UTC

cvs commit: xml-fop/src/java/org/apache/fop/fo/flow Table.java

jeremias    2005/01/31 13:16:45

  Modified:    src/java/org/apache/fop/layoutmgr/table
                        TableLayoutManager.java Body.java Row.java
               src/java/org/apache/fop/layoutmgr LayoutManagerMapping.java
               src/java/org/apache/fop/fo/flow Table.java
  Log:
  Border, Padding and spaces on level fo:table.
  
  Revision  Changes    Path
  1.15      +70 -14    xml-fop/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java
  
  Index: TableLayoutManager.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- TableLayoutManager.java	19 Oct 2004 21:48:17 -0000	1.14
  +++ TableLayoutManager.java	31 Jan 2005 21:16:45 -0000	1.15
  @@ -1,5 +1,5 @@
   /*
  - * Copyright 1999-2004 The Apache Software Foundation.
  + * Copyright 1999-2005 The Apache Software Foundation.
    *
    * Licensed under the Apache License, Version 2.0 (the "License");
    * you may not use this file except in compliance with the License.
  @@ -34,6 +34,7 @@
   import org.apache.fop.area.Area;
   import org.apache.fop.area.Block;
   import org.apache.fop.traits.MinOptMax;
  +import org.apache.fop.traits.SpaceVal;
   
   import java.util.ArrayList;
   import java.util.Iterator;
  @@ -59,7 +60,14 @@
       private List bodyBreaks = new ArrayList();
       private BreakPoss headerBreak;
       private BreakPoss footerBreak;
  +    
  +    private int referenceIPD;
   
  +    //TODO space-before|after: handle space-resolution rules
  +    private MinOptMax spaceBefore;
  +    private MinOptMax spaceAfter;
  +    
  +    
       private class SectionPosition extends LeafPosition {
           protected List list;
           protected SectionPosition(LayoutManager lm, int pos, List l) {
  @@ -106,6 +114,20 @@
           tableFooter.setParent(this);
       }
   
  +    /** @see org.apache.fop.layoutmgr.AbstractLayoutManager#initProperties() */
  +    protected void initProperties() {
  +        super.initProperties();
  +        spaceBefore = new SpaceVal(fobj.getCommonMarginBlock().spaceBefore).getSpace();
  +        spaceAfter = new SpaceVal(fobj.getCommonMarginBlock().spaceAfter).getSpace();
  +    }
  +
  +    private int getIPIndents() {
  +        int iIndents = 0;
  +        iIndents += fobj.getCommonMarginBlock().startIndent.getValue();
  +        iIndents += fobj.getCommonMarginBlock().endIndent.getValue();
  +        return iIndents;
  +    }
  +    
       /**
        * Get the next break possibility.
        * The break possibility depends on the height of the header and footer
  @@ -117,14 +139,29 @@
       public BreakPoss getNextBreakPoss(LayoutContext context) {
           Body curLM; // currently active LM
   
  +        referenceIPD = context.getRefIPD();
  +        if (fobj.getInlineProgressionDimension().getOptimum().getEnum() != EN_AUTO) {
  +            referenceIPD = fobj.getInlineProgressionDimension().getOptimum().getLength().getValue();
  +        }
  +        if (referenceIPD > context.getRefIPD()) {
  +            log.warn("Allocated IPD exceeds available reference IPD");
  +        }
  +        int contentIPD = referenceIPD - getIPIndents();
  +
           MinOptMax stackSize = new MinOptMax();
  -        // if starting add space before
  -        // stackSize.add(spaceBefore);
  +        //Add spacing
  +        if (spaceAfter != null) {
  +            stackSize.add(spaceAfter);
  +        }
  +        if (spaceBefore != null) {
  +            stackSize.add(spaceBefore);
  +        }
  +
           BreakPoss lastPos = null;
   
  -        fobj.setLayoutDimension(PercentBase.BLOCK_IPD, context.getRefIPD());
  +        fobj.setLayoutDimension(PercentBase.BLOCK_IPD, referenceIPD);
           fobj.setLayoutDimension(PercentBase.BLOCK_BPD, context.getStackLimit().opt);
  -        fobj.setLayoutDimension(PercentBase.REFERENCE_AREA_IPD, context.getRefIPD());
  +        fobj.setLayoutDimension(PercentBase.REFERENCE_AREA_IPD, referenceIPD);
           fobj.setLayoutDimension(PercentBase.REFERENCE_AREA_BPD, context.getStackLimit().opt);
   
           // either works out table of column widths or if proportional-column-width function
  @@ -142,10 +179,10 @@
               }
           }
           // sets TABLE_UNITS in case where one or more columns is defined using proportional-column-width
  -        if (sumCols < context.getRefIPD()) {
  +        if (sumCols < contentIPD) {
               if (fobj.getLayoutDimension(PercentBase.TABLE_UNITS).floatValue() == 0.0) {
                   fobj.setLayoutDimension(PercentBase.TABLE_UNITS,
  -                                      (context.getRefIPD() - sumCols) / factors);
  +                                      (contentIPD - sumCols) / factors);
               }
           }
           MinOptMax headerSize = null;
  @@ -236,14 +273,15 @@
        * @return the break possibility containing the stacking size
        */
       protected BreakPoss getHeight(Body lm, LayoutContext context) {
  -        int ipd = context.getRefIPD();
  +        int referenceIPD = context.getRefIPD();
  +        int contentIPD = referenceIPD - getIPIndents();
           BreakPoss bp;
   
           MinOptMax stackSize = new MinOptMax();
   
           LayoutContext childLC = new LayoutContext(0);
           childLC.setStackLimit(context.getStackLimit());
  -        childLC.setRefIPD(ipd);
  +        childLC.setRefIPD(contentIPD);
   
           lm.setColumns(columns);
   
  @@ -274,6 +312,11 @@
           getParentArea(null);
           addID(fobj.getId());
   
  +        // if adjusted space before
  +        double adjust = layoutContext.getSpaceAdjust();
  +        addBlockSpacing(adjust, spaceBefore);
  +        spaceBefore = null;
  +        
           // add column, body then row areas
   
           int tableHeight = 0;
  @@ -286,6 +329,7 @@
               List list = pos.list;
               PositionIterator breakPosIter = new BreakPossPosIter(list, 0, list.size() + 1);
               while ((childLM = (Body)breakPosIter.getNextChildLM()) != null) {
  +                childLM.setXOffset(fobj.getCommonMarginBlock().startIndent.getValue());
                   childLM.addAreas(breakPosIter, lc);
                   tableHeight += childLM.getBodyHeight();
               }
  @@ -300,6 +344,7 @@
                                      lfp.getLeafPos() + 1);
               iStartPos = lfp.getLeafPos() + 1;
               while ((childLM = (Body)breakPosIter.getNextChildLM()) != null) {
  +                childLM.setXOffset(fobj.getCommonMarginBlock().startIndent.getValue());
                   childLM.setYOffset(tableHeight);
                   childLM.addAreas(breakPosIter, lc);
                   tableHeight += childLM.getBodyHeight();
  @@ -312,6 +357,7 @@
               List list = pos.list;
               PositionIterator breakPosIter = new BreakPossPosIter(list, 0, list.size() + 1);
               while ((childLM = (Body)breakPosIter.getNextChildLM()) != null) {
  +                childLM.setXOffset(fobj.getCommonMarginBlock().startIndent.getValue());
                   childLM.setYOffset(tableHeight);
                   childLM.addAreas(breakPosIter, lc);
                   tableHeight += childLM.getBodyHeight();
  @@ -322,9 +368,17 @@
   
           TraitSetter.addBorders(curBlockArea, fobj.getCommonBorderPaddingBackground());
           TraitSetter.addBackground(curBlockArea, fobj.getCommonBorderPaddingBackground());
  +        TraitSetter.addMargins(curBlockArea,
  +                fobj.getCommonBorderPaddingBackground(), 
  +                fobj.getCommonMarginBlock());
  +        TraitSetter.addBreaks(curBlockArea, 
  +                fobj.getBreakBefore(), fobj.getBreakAfter());
   
           flush();
   
  +        // if adjusted space after
  +        addBlockSpacing(adjust, spaceAfter);
  +
           bodyBreaks.clear();
           curBlockArea = null;
       }
  @@ -347,11 +401,12 @@
               curBlockArea = new Block();
               // Set up dimensions
               // Must get dimensions from parent area
  -            Area parentArea = parentLM.getParentArea(curBlockArea);
  -            int referenceIPD = parentArea.getIPD();
  -            curBlockArea.setIPD(referenceIPD);
  -            // Get reference IPD from parentArea
  -            setCurrentArea(curBlockArea); // ??? for generic operations
  +            /*Area parentArea =*/ parentLM.getParentArea(curBlockArea);
  +            
  +            int contentIPD = referenceIPD - getIPIndents();
  +            curBlockArea.setIPD(contentIPD);
  +            
  +            setCurrentArea(curBlockArea);
           }
           return curBlockArea;
       }
  @@ -377,5 +432,6 @@
               reset(null);
           }
       }
  +    
   }
   
  
  
  
  1.12      +13 -1     xml-fop/src/java/org/apache/fop/layoutmgr/table/Body.java
  
  Index: Body.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/table/Body.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- Body.java	20 Oct 2004 13:19:25 -0000	1.11
  +++ Body.java	31 Jan 2005 21:16:45 -0000	1.12
  @@ -1,5 +1,5 @@
   /*
  - * Copyright 1999-2004 The Apache Software Foundation.
  + * Copyright 1999-2005 The Apache Software Foundation.
    * 
    * Licensed under the Apache License, Version 2.0 (the "License");
    * you may not use this file except in compliance with the License.
  @@ -46,6 +46,7 @@
       private boolean rows = true;
       private List columns;
   
  +    private int xoffset;
       private int yoffset;
       private int bodyHeight;
   
  @@ -148,6 +149,15 @@
       }
   
       /**
  +     * Set the x offset of this body within the table.
  +     * This is used to set the row offsets.
  +     * @param value
  +     */
  +    public void setXOffset(int off) {
  +        xoffset = off;
  +    }
  +
  +    /**
        * Set the y offset of this body within the table.
        * This is used to set the row offsets.
        *
  @@ -181,6 +191,7 @@
               iStartPos = lfp.getLeafPos() + 1;
               int lastheight = 0;
               while ((childLM = (Row)breakPosIter.getNextChildLM()) != null) {
  +                childLM.setXOffset(xoffset);
                   childLM.setYOffset(yoffset + rowoffset);
                   childLM.addAreas(breakPosIter, lc);
                   lastheight = childLM.getRowHeight();
  @@ -256,5 +267,6 @@
           TraitSetter.addBackground(curBlockArea, fobj.getCommonBorderPaddingBackground());
           return curBlockArea;
       }
  +
   }
   
  
  
  
  1.16      +17 -4     xml-fop/src/java/org/apache/fop/layoutmgr/table/Row.java
  
  Index: Row.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/table/Row.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- Row.java	20 Oct 2004 13:19:25 -0000	1.15
  +++ Row.java	31 Jan 2005 21:16:45 -0000	1.16
  @@ -1,5 +1,5 @@
   /*
  - * Copyright 1999-2004 The Apache Software Foundation.
  + * Copyright 1999-2005 The Apache Software Foundation.
    * 
    * Licensed under the Apache License, Version 2.0 (the "License");
    * you may not use this file except in compliance with the License.
  @@ -49,6 +49,7 @@
       private List cellList = null;
       private List columns = null;
       private int rowHeight;
  +    private int xoffset;
       private int yoffset;
   
       private class RowPosition extends LeafPosition {
  @@ -248,6 +249,16 @@
       }
   
       /**
  +     * Set the x position offset of this row.
  +     * This is used to set the position of the areas returned by this row.
  +     *
  +     * @param off the x offset
  +     */
  +    public void setXOffset(int off) {
  +        xoffset = off;
  +    }
  +    
  +    /**
        * Set the y position offset of this row.
        * This is used to set the position of the areas returned by this row.
        *
  @@ -277,7 +288,8 @@
               // Add the block areas to Area
   
               int cellcount = 0;
  -            int xoffset = 0;
  +            int x = this.xoffset;
  +            //int x = (TableLayoutManager)getParent()).;
               for (Iterator iter = lfp.cellBreaks.iterator(); iter.hasNext();) {
                   List cellsbr = (List)iter.next();
                   PositionIterator breakPosIter;
  @@ -294,12 +306,12 @@
                   }
   
                   while ((childLM = (Cell)breakPosIter.getNextChildLM()) != null) {
  -                    childLM.setXOffset(xoffset);
  +                    childLM.setXOffset(x);
                       childLM.setYOffset(yoffset);
                       childLM.setRowHeight(rowHeight);
                       childLM.addAreas(breakPosIter, lc);
                   }
  -                xoffset += col.getWidth().getValue();
  +                x += col.getWidth().getValue();
               }
           }
   
  @@ -367,5 +379,6 @@
           TraitSetter.addBackground(block, fobj.getCommonBorderPaddingBackground());
           return block;
       }
  +
   }
   
  
  
  
  1.4       +3 -3      xml-fop/src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java
  
  Index: LayoutManagerMapping.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- LayoutManagerMapping.java	27 Dec 2004 10:13:05 -0000	1.3
  +++ LayoutManagerMapping.java	31 Jan 2005 21:16:45 -0000	1.4
  @@ -1,5 +1,5 @@
   /*
  - * Copyright 2004 The Apache Software Foundation.
  + * Copyright 2004-2005 The Apache Software Foundation.
    * 
    * Licensed under the Apache License, Version 2.0 (the "License");
    * you may not use this file except in compliance with the License.
  @@ -320,7 +320,7 @@
           public void make(FONode node, List lms) {
               Table table = (Table) node;
               TableLayoutManager tlm = new TableLayoutManager(table);
  -            ArrayList columns = table.getColumns();
  +            List columns = table.getColumns();
               if (columns != null) {
                   ArrayList columnLMs = new ArrayList();
                   ListIterator iter = columns.listIterator();
  
  
  
  1.43      +39 -18    xml-fop/src/java/org/apache/fop/fo/flow/Table.java
  
  Index: Table.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/Table.java,v
  retrieving revision 1.42
  retrieving revision 1.43
  diff -u -r1.42 -r1.43
  --- Table.java	24 Dec 2004 12:06:26 -0000	1.42
  +++ Table.java	31 Jan 2005 21:16:45 -0000	1.43
  @@ -1,5 +1,5 @@
   /*
  - * Copyright 1999-2004 The Apache Software Foundation.
  + * Copyright 1999-2005 The Apache Software Foundation.
    * 
    * Licensed under the Apache License, Version 2.0 (the "License");
    * you may not use this file except in compliance with the License.
  @@ -18,13 +18,9 @@
   
   package org.apache.fop.fo.flow;
   
  -// Java
  -import java.util.ArrayList;
   import java.util.List;
  -import java.util.ListIterator;
   
   import org.apache.fop.apps.FOPException;
  -import org.apache.fop.datatypes.Length;
   import org.apache.fop.fo.FONode;
   import org.apache.fop.fo.FObj;
   import org.apache.fop.fo.PropertyList;
  @@ -36,9 +32,6 @@
   import org.apache.fop.fo.properties.KeepProperty;
   import org.apache.fop.fo.properties.LengthPairProperty;
   import org.apache.fop.fo.properties.LengthRangeProperty;
  -import org.apache.fop.layoutmgr.table.Body;
  -import org.apache.fop.layoutmgr.table.Column;
  -import org.apache.fop.layoutmgr.table.TableLayoutManager;
   
   /**
    * Class modelling the fo:table object.
  @@ -62,21 +55,21 @@
       private String id;
       private LengthRangeProperty inlineProgressionDimension;
       private int intrusionDisplace;
  -    private Length height;
  +    //private Length height;
       private KeepProperty keepTogether;
       private KeepProperty keepWithNext;
       private KeepProperty keepWithPrevious;
       private int tableLayout;
       private int tableOmitFooterAtBreak;
       private int tableOmitHeaderAtBreak;
  -    private Length width;
  +    //private Length width;
       private int writingMode;
       // End of property values
   
       private static final int MINCOLWIDTH = 10000; // 10pt
   
       /** collection of columns in this table */
  -    protected ArrayList columns = null;
  +    protected List columns = null;
       private TableBody tableHeader = null;
       private TableBody tableFooter = null;
   
  @@ -108,14 +101,14 @@
           id = pList.get(PR_ID).getString();
           inlineProgressionDimension = pList.get(PR_INLINE_PROGRESSION_DIMENSION).getLengthRange();
           intrusionDisplace = pList.get(PR_INTRUSION_DISPLACE).getEnum();
  -        height = pList.get(PR_HEIGHT).getLength();
  +        //height = pList.get(PR_HEIGHT).getLength();
           keepTogether = pList.get(PR_KEEP_TOGETHER).getKeep();
           keepWithNext = pList.get(PR_KEEP_WITH_NEXT).getKeep();
           keepWithPrevious = pList.get(PR_KEEP_WITH_PREVIOUS).getKeep();
           tableLayout = pList.get(PR_TABLE_LAYOUT).getEnum();
           tableOmitFooterAtBreak = pList.get(PR_TABLE_OMIT_FOOTER_AT_BREAK).getEnum();
           tableOmitHeaderAtBreak = pList.get(PR_TABLE_OMIT_HEADER_AT_BREAK).getEnum();
  -        width = pList.get(PR_WIDTH).getLength();
  +        //width = pList.get(PR_WIDTH).getLength();
           writingMode = pList.get(PR_WRITING_MODE).getEnum();
       }
   
  @@ -140,7 +133,7 @@
       protected void addChildNode(FONode child) throws FOPException {
           if (child.getName().equals("fo:table-column")) {
               if (columns == null) {
  -                columns = new ArrayList();
  +                columns = new java.util.ArrayList();
               }
               columns.add(((TableColumn)child));
           } else if (child.getName().equals("fo:table-footer")) {
  @@ -153,7 +146,7 @@
           }
       }
   
  -    public ArrayList getColumns() {
  +    public List getColumns() {
           return columns;
       }
   
  @@ -166,21 +159,49 @@
       }
   
       /**
  -     * Return the Common Margin Properties-Block.
  +     * @return the "inline-progression-dimension" property.
  +     */
  +    public LengthRangeProperty getInlineProgressionDimension() {
  +        return inlineProgressionDimension;
  +    }
  +
  +    /**
  +     * @return the "block-progression-dimension" property.
  +     */
  +    public LengthRangeProperty getBlockProgressionDimension() {
  +        return blockProgressionDimension;
  +    }
  +    
  +    /**
  +     * @return the Common Margin Properties-Block.
        */
       public CommonMarginBlock getCommonMarginBlock() {
           return commonMarginBlock;
       }
   
       /**
  -     * Return the Common Border, Padding, and Background Properties.
  +     * @return the Common Border, Padding, and Background Properties.
        */
       public CommonBorderPaddingBackground getCommonBorderPaddingBackground() {
           return commonBorderPaddingBackground;
       }
   
       /**
  -     * Return the "id" property.
  +     * @return the "break-after" property.
  +     */
  +    public int getBreakAfter() {
  +        return breakAfter;
  +    }
  +
  +    /**
  +     * @return the "break-before" property.
  +     */
  +    public int getBreakBefore() {
  +        return breakBefore;
  +    }
  +
  +    /**
  +     * @return the "id" property.
        */
       public String getId() {
           return id;
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-cvs-help@xml.apache.org