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 bc...@apache.org on 2004/01/29 20:45:48 UTC

cvs commit: xml-fop/src/java/org/apache/fop/render/ps PSRenderer.java

bckfnn      2004/01/29 11:45:48

  Modified:    src/java/org/apache/fop/render AbstractRenderer.java
               src/java/org/apache/fop/render/pdf PDFRenderer.java
               src/java/org/apache/fop/render/ps PSRenderer.java
  Log:
  Handle SPACE_START trait for block areas.
  
  PR: 25802.
  
  Revision  Changes    Path
  1.20      +20 -10    xml-fop/src/java/org/apache/fop/render/AbstractRenderer.java
  
  Index: AbstractRenderer.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/render/AbstractRenderer.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- AbstractRenderer.java	17 Jan 2004 19:29:46 -0000	1.19
  +++ AbstractRenderer.java	29 Jan 2004 19:45:48 -0000	1.20
  @@ -374,7 +374,7 @@
       protected void renderRegion(RegionReference region) {
           List blocks = region.getBlocks();
   
  -        renderBlocks(blocks);
  +        renderBlocks(null, blocks);
   
       }
   
  @@ -406,7 +406,7 @@
       protected void renderBeforeFloat(BeforeFloat bf) {
           List blocks = bf.getChildAreas();
           if (blocks != null) {
  -            renderBlocks(blocks);
  +            renderBlocks(null, blocks);
               Block sep = bf.getSeparator();
               if (sep != null) {
                   renderBlock(sep);
  @@ -426,7 +426,7 @@
               if (sep != null) {
                   renderBlock(sep);
               }
  -            renderBlocks(blocks);
  +            renderBlocks(null, blocks);
           }
       }
   
  @@ -471,7 +471,7 @@
           // the normal flow reference area contains stacked blocks
           List blocks = flow.getChildAreas();
           if (blocks != null) {
  -            renderBlocks(blocks);
  +            renderBlocks(null, blocks);
           }
       }
   
  @@ -506,7 +506,7 @@
   
               startVParea(ctm);
               handleBlockTraits(bv);
  -            renderBlocks(children);
  +            renderBlocks(bv, children);
               endVParea();
   
               // clip if necessary
  @@ -514,16 +514,26 @@
               currentIPPosition = saveIP;
               currentBPPosition = saveBP;
           } else {
  -            renderBlocks(children);
  +            // save position and offset
  +            int saveIP = currentIPPosition;
  +            int saveBP = currentBPPosition;
  +
  +            handleBlockTraits(bv);
  +            renderBlocks(bv, children);
  +
  +            currentIPPosition = saveIP;
  +            currentBPPosition = saveBP + bv.getHeight();
           }
       }
   
       /**
        * Renders a list of block areas.
        *
  +     * @param parent  the parent block if the parent is a block, otherwise
  +     *                a null value. 
        * @param blocks  The block areas
        */
  -    protected void renderBlocks(List blocks) {
  +    protected void renderBlocks(Block parent, List blocks) {
           // the position of the containing block is used for
           // absolutely positioned areas
           int contBP = currentBPPosition;
  @@ -575,7 +585,7 @@
   
                   handleBlockTraits(block);
   
  -                renderBlocks(children);
  +                renderBlocks(block, children);
   
                   // absolute blocks do not effect the layout
                   currentBPPosition = saveBP;
  @@ -586,7 +596,7 @@
   
                   handleBlockTraits(block);
   
  -                renderBlocks(children);
  +                renderBlocks(block, children);
   
                   // stacked and relative blocks effect stacking
                   currentBPPosition = saveBP + block.getHeight();
  @@ -649,7 +659,7 @@
           int saveBP = currentBPPosition;
   
           List blocks = cont.getBlocks();
  -        renderBlocks(blocks);
  +        renderBlocks(null, blocks);
           currentIPPosition = saveIP;
           currentBlockIPPosition = saveBlockIP;
           currentBPPosition = saveBP;
  
  
  
  1.30      +51 -20    xml-fop/src/java/org/apache/fop/render/pdf/PDFRenderer.java
  
  Index: PDFRenderer.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/render/pdf/PDFRenderer.java,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- PDFRenderer.java	25 Jan 2004 14:40:14 -0000	1.29
  +++ PDFRenderer.java	29 Jan 2004 19:45:48 -0000	1.30
  @@ -504,15 +504,39 @@
       }
   
       /**
  -     * @see org.apache.fop.render.AbstractRenderer#renderBlock(Block)
  +     * @see org.apache.fop.render.AbstractRenderer#renderBlocks(Block, List)
        */
  -    protected void renderBlock(Block block) {
  -        int marginOffset = IPMarginOffset;
  -        super.renderBlock(block);
  -        // super.renderBlock() may render child blocks (with their own offsets)
  -        // so need to restore (this parent's) IPMarginOffset when finished.
  -        IPMarginOffset = marginOffset;
  -	}
  +    protected void renderBlocks(Block block, List blocks) {
  +        int saveIPMargin = IPMarginOffset;
  +        int saveBPMargin = BPMarginOffset;
  +        if (block != null) {
  +            Integer spaceStart = (Integer) block.getTrait(Trait.SPACE_START); 
  +            if (spaceStart != null) {
  +                IPMarginOffset += spaceStart.intValue();
  +            }
  +
  +            Integer paddingStart = (Integer) block.getTrait(Trait.PADDING_START);
  +            if (paddingStart != null) {
  +                IPMarginOffset += paddingStart.intValue();
  +            }
  +            Integer paddingBefore= (Integer) block.getTrait(Trait.PADDING_BEFORE);
  +            if (paddingBefore != null) {
  +                BPMarginOffset += paddingBefore.intValue();
  +            }
  +
  +            BorderProps borderStartWidth = (BorderProps) block.getTrait(Trait.BORDER_START);
  +            if (borderStartWidth != null) {
  +                IPMarginOffset += borderStartWidth.width;
  +            }
  +            BorderProps borderBeforeWidth = (BorderProps) block.getTrait(Trait.BORDER_BEFORE);
  +            if (borderBeforeWidth != null) {
  +                BPMarginOffset += borderBeforeWidth.width;
  +            }
  +        }
  +        super.renderBlocks(block, blocks);
  +        IPMarginOffset = saveIPMargin;
  +        BPMarginOffset = saveBPMargin;
  +    }
   
       /**
        * Handle the traits for a region
  @@ -550,15 +574,23 @@
   		/*  IPMarginOffset for a particular block = region border + 
            *  region padding + parent block padding + current block padding
            */
  -        Integer paddingStart = (Integer) block.getTrait(Trait.PADDING_START);
  -        if (paddingStart != null) {
  -            IPMarginOffset += paddingStart.intValue();
  -        }
   
           float startx = (currentIPPosition + IPMarginOffset) / 1000f;
           float starty = (currentBPPosition + BPMarginOffset) / 1000f;
  +        float width = block.getWidth() / 1000f;
  +
  +        Integer spaceStart = (Integer) block.getTrait(Trait.SPACE_START); 
  +        if (spaceStart != null) {
  +            startx += spaceStart.floatValue() / 1000;
  +            width -= spaceStart.floatValue() / 1000;
  +        }
  +        Integer spaceEnd = (Integer) block.getTrait(Trait.SPACE_END); 
  +        if (spaceEnd != null) {
  +            width -= spaceEnd.floatValue() / 1000;
  +        }
  +
           drawBackAndBorders(block, startx, starty,
  -            block.getWidth() / 1000f, block.getHeight() / 1000f);
  +            width, block.getHeight() / 1000f);
       }
   
       /**
  @@ -730,7 +762,7 @@
   
               startVParea(ctm);
               handleBlockTraits(bv);
  -            renderBlocks(children);
  +            renderBlocks(bv, children);
               endVParea();
   
               if (bv.getClip()) {
  @@ -780,7 +812,7 @@
                   startVParea(ctm);
               }
               handleBlockTraits(bv);
  -            renderBlocks(children);
  +            renderBlocks(bv, children);
               if (ctm != null) {
                   endVParea();
               }
  @@ -836,8 +868,8 @@
        * @param ip the inline parent area
        */
       public void renderInlineParent(InlineParent ip) {
  -        float start = currentBlockIPPosition / 1000f;
  -        float top = (ip.getOffset() + currentBPPosition) / 1000f;
  +        float start = (currentBlockIPPosition + IPMarginOffset) / 1000f;
  +        float top = (ip.getOffset() + currentBPPosition + BPMarginOffset) / 1000f;
           float width = ip.getWidth() / 1000f;
           float height = ip.getHeight() / 1000f;
           drawBackAndBorders(ip, start, top, width, height);
  @@ -1175,11 +1207,10 @@
           saveGraphicsState();
           currentStream.add(((float) w) + " 0 0 "
                             + ((float) -h) + " "
  -                          + (((float) currentBlockIPPosition) / 1000f + x) + " "
  -                          + (((float)(currentBPPosition + 1000 * h)) / 1000f
  +                          + (((float) currentBlockIPPosition + IPMarginOffset) / 1000f + x) + " "
  +                          + (((float)(currentBPPosition + BPMarginOffset + 1000 * h)) / 1000f
                             + y) + " cm\n" + "/Im" + xobj + " Do\n");
           restoreGraphicsState();
  -
       }
   
       /**
  
  
  
  1.23      +2 -2      xml-fop/src/java/org/apache/fop/render/ps/PSRenderer.java
  
  Index: PSRenderer.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/render/ps/PSRenderer.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- PSRenderer.java	25 Jan 2004 14:40:14 -0000	1.22
  +++ PSRenderer.java	29 Jan 2004 19:45:48 -0000	1.23
  @@ -565,7 +565,7 @@
   
               startVParea(ctm);
               handleBlockTraits(bv);
  -            renderBlocks(children);
  +            renderBlocks(bv, children);
               endVParea();
   
               if (bv.getClip()) {
  @@ -615,7 +615,7 @@
                   startVParea(ctm);
               }
               handleBlockTraits(bv);
  -            renderBlocks(children);
  +            renderBlocks(bv, children);
               if (ctm != null) {
                   endVParea();
               }
  
  
  

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