]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Various fixes for ID management.
authorJeremias Maerki <jeremias@apache.org>
Tue, 26 Jul 2005 13:31:53 +0000 (13:31 +0000)
committerJeremias Maerki <jeremias@apache.org>
Tue, 26 Jul 2005 13:31:53 +0000 (13:31 +0000)
Border/Padding/Background for instream-foreign-object and external-graphic.

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

src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java
src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java
src/java/org/apache/fop/layoutmgr/inline/ExternalGraphicLayoutManager.java
src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java
src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java
src/java/org/apache/fop/layoutmgr/inline/InstreamForeignObjectLM.java
src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java
src/java/org/apache/fop/layoutmgr/inline/LeafNodeLayoutManager.java
src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLayoutManager.java
src/java/org/apache/fop/layoutmgr/inline/PageNumberLayoutManager.java

index 493cac7d877fef8d11f117da44ea4336de48d14d..fd0cfe8cc5d261a679eefff63d283364fadb3e72 100644 (file)
@@ -137,6 +137,7 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager {
 
         curPV = makeNewPage(false, false);
 
+        addIDToPage(pageSeq.getId());
         Flow mainFlow = pageSeq.getMainFlow();
         childFLM = getLayoutManagerMaker().
             makeFlowLayoutManager(this, mainFlow);
index 6d5a26f36372352950877dab16f98949541e17ec..498d0ed0b452324e63fca92fc71d2661d55d31f6 100644 (file)
@@ -67,6 +67,7 @@ public class CharacterLayoutManager extends LeafNodeLayoutManager {
     private InlineArea getCharacterInlineArea(Character node) {
         org.apache.fop.area.inline.Character ch =
             new org.apache.fop.area.inline.Character(node.getCharacter());
+        TraitSetter.setProducerID(ch, node.getId());
         TraitSetter.addTextDecoration(ch, fobj.getTextDecoration());
         return ch;
     }
index a0196f8d411bb34223ee1dfb07d68868c430a187..2be4ea14fbded34888d7df33447c4171413db39f 100644 (file)
@@ -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.
@@ -27,6 +27,7 @@ import org.apache.fop.area.inline.InlineArea;
 import org.apache.fop.area.inline.Viewport;
 import org.apache.fop.datatypes.Length;
 import org.apache.fop.fo.flow.ExternalGraphic;
+import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
 import org.apache.fop.layoutmgr.TraitSetter;
 
 /**
@@ -183,6 +184,33 @@ public class ExternalGraphicLayoutManager extends LeafNodeLayoutManager {
             default:
             break;
         }
+        
+        
+        CommonBorderPaddingBackground borderProps = fobj.getCommonBorderPaddingBackground();
+        
+        //Determine extra BPD from borders etc.
+        int beforeBPD = borderProps.getPadding(CommonBorderPaddingBackground.BEFORE, false);
+        beforeBPD += borderProps.getBorderWidth(CommonBorderPaddingBackground.BEFORE,
+                                             false);
+        int afterBPD = borderProps.getPadding(CommonBorderPaddingBackground.AFTER, false);
+        afterBPD += borderProps.getBorderWidth(CommonBorderPaddingBackground.AFTER, false);
+        
+        yoffset += beforeBPD;
+        viewHeight += beforeBPD;
+        viewHeight += afterBPD;
+        
+        //Determine extra IPD from borders etc.
+        int startIPD = borderProps.getPadding(CommonBorderPaddingBackground.START,
+                false/*bNotFirst*/);
+        startIPD += borderProps.getBorderWidth(CommonBorderPaddingBackground.START,
+                 false/*bNotFirst*/);
+        int endIPD = borderProps.getPadding(CommonBorderPaddingBackground.END, false/*bNotLast*/);
+        endIPD += borderProps.getBorderWidth(CommonBorderPaddingBackground.END, false/*bNotLast*/);
+        
+        xoffset += startIPD;
+        viewWidth += startIPD;
+        viewWidth += endIPD;
+        
         placement = new Rectangle2D.Float(xoffset, yoffset, cwidth, cheight);
     }
 
@@ -194,7 +222,9 @@ public class ExternalGraphicLayoutManager extends LeafNodeLayoutManager {
       */
      public InlineArea getExternalGraphicInlineArea() {
          Image imArea = new Image(fobj.getSrc());
+         TraitSetter.setProducerID(imArea, fobj.getId());
          Viewport vp = new Viewport(imArea);
+         TraitSetter.setProducerID(vp, fobj.getId());
          vp.setIPD(viewWidth);
          vp.setBPD(viewHeight);
          vp.setClip(clip);
@@ -208,7 +238,8 @@ public class ExternalGraphicLayoutManager extends LeafNodeLayoutManager {
          return vp;
      }
      
-     protected void addId() {
+    /** @see org.apache.fop.layoutmgr.inline.LeafNodeLayoutManager#addId() */
+    protected void addId() {
          getPSLM().addIDToPage(fobj.getId());
      }
 }
index 76222cf111823d233a33373fc05fcf6418b85a5d..7f0943a9f63583f842eabdef7b795b55b659dce3 100755 (executable)
@@ -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.
@@ -21,6 +21,8 @@ package org.apache.fop.layoutmgr.inline;
 import java.util.ListIterator;
 import java.util.LinkedList;
 
+import org.apache.fop.area.inline.InlineParent;
+import org.apache.fop.fo.flow.Inline;
 import org.apache.fop.fo.flow.InlineLevel;
 import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
 import org.apache.fop.fo.properties.CommonMarginInline;
@@ -58,6 +60,10 @@ public class InlineLayoutManager extends InlineStackingLayoutManager
         initialize();
     }
     
+    private Inline getInlineFO() {
+        return (Inline)fobj;
+    }
+    
     private void initialize() {
         inlineProps = fobj.getCommonMarginInline();
         borderProps = fobj.getCommonBorderPaddingBackground();
@@ -102,6 +108,16 @@ public class InlineLayoutManager extends InlineStackingLayoutManager
         return inlineProps.spaceEnd;
     }
     
+    /** @see org.apache.fop.layoutmgr.inline.InlineStackingLayoutManager#createArea() */
+    protected InlineParent createArea() {
+        InlineParent area = super.createArea(); 
+        TraitSetter.setProducerID(area, getInlineFO().getId());
+        return area;
+    }
+    
+    /**
+     * @see org.apache.fop.layoutmgr.inline.InlineStackingLayoutManager#setTraits(boolean, boolean)
+     */
     protected void setTraits(boolean bNotFirst, boolean bNotLast) {
         
         // Add border and padding to current area and set flags (FIRST, LAST ...)
@@ -114,6 +130,7 @@ public class InlineLayoutManager extends InlineStackingLayoutManager
         }
     }
 
+    /** @see org.apache.fop.layoutmgr.LayoutManager */
     public LinkedList getNextKnuthElements(LayoutContext lc, int alignment) {
         InlineLevelLayoutManager curLM;
 
@@ -314,5 +331,11 @@ public class InlineLayoutManager extends InlineStackingLayoutManager
         }
         return returnList;
     }*/
+    
+    /** @see org.apache.fop.layoutmgr.inline.LeafNodeLayoutManager#addId() */
+    protected void addId() {
+        getPSLM().addIDToPage(getInlineFO().getId());
+    }
+    
 }
 
index 28be05277b954a4b32dedf5cad3f06c27d073bed..0b05cc8aae6d5521b5b3267aef58fc019436aaff 100644 (file)
@@ -181,6 +181,14 @@ public class InlineStackingLayoutManager extends AbstractLayoutManager
         return new InlineParent();
     }
 
+    /**
+     * This method is called by addAreas() so IDs can be added to a page for FOs that 
+     * support the 'id' property.
+     */
+    protected void addId() {
+        // Do nothing here, overriden in subclasses that have an 'id' property.
+    }
+    
     /**
      * Generate and add areas to parent area.
      * Set size of each area. This should only create and return one
@@ -193,6 +201,7 @@ public class InlineStackingLayoutManager extends AbstractLayoutManager
      */
     public void addAreas(PositionIterator parentIter,
                          LayoutContext context) {
+        addId();
         InlineParent parent = createArea();
         parent.setBPD(context.getLineHeight());
         parent.setOffset(0);
index 3b88ac0b1fab6d05d6aac809f884e84e5ea73e76..e0d06dcb5721cf381fdadd9d38b83754db2f6388 100644 (file)
@@ -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.
@@ -25,6 +25,7 @@ import java.awt.geom.Rectangle2D;
 import org.apache.fop.datatypes.Length;
 import org.apache.fop.fo.XMLObj;
 import org.apache.fop.fo.flow.InstreamForeignObject;
+import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
 import org.apache.fop.layoutmgr.TraitSetter;
 import org.apache.fop.area.inline.ForeignObject;
 import org.apache.fop.area.inline.Viewport;
@@ -168,6 +169,31 @@ public class InstreamForeignObjectLM extends LeafNodeLayoutManager {
         int xoffset = fobj.computeXOffset(ipd, cwidth);
         int yoffset = fobj.computeYOffset(bpd, cheight);
 
+        CommonBorderPaddingBackground borderProps = fobj.getCommonBorderPaddingBackground();
+        
+        //Determine extra BPD from borders etc.
+        int beforeBPD = borderProps.getPadding(CommonBorderPaddingBackground.BEFORE, false);
+        beforeBPD += borderProps.getBorderWidth(CommonBorderPaddingBackground.BEFORE,
+                                             false);
+        int afterBPD = borderProps.getPadding(CommonBorderPaddingBackground.AFTER, false);
+        afterBPD += borderProps.getBorderWidth(CommonBorderPaddingBackground.AFTER, false);
+        
+        yoffset += beforeBPD;
+        bpd += beforeBPD;
+        bpd += afterBPD;
+        
+        //Determine extra IPD from borders etc.
+        int startIPD = borderProps.getPadding(CommonBorderPaddingBackground.START,
+                false/*bNotFirst*/);
+        startIPD += borderProps.getBorderWidth(CommonBorderPaddingBackground.START,
+                 false/*bNotFirst*/);
+        int endIPD = borderProps.getPadding(CommonBorderPaddingBackground.END, false/*bNotLast*/);
+        endIPD += borderProps.getBorderWidth(CommonBorderPaddingBackground.END, false/*bNotLast*/);
+        
+        xoffset += startIPD;
+        ipd += startIPD;
+        ipd += endIPD;
+
         Rectangle2D placement = new Rectangle2D.Float(xoffset, yoffset, cwidth, cheight);
 
         org.w3c.dom.Document doc = child.getDOMDocument();
@@ -175,8 +201,10 @@ public class InstreamForeignObjectLM extends LeafNodeLayoutManager {
 
         //fobj.childNodes = null; This is bad for i-f-o in static-content!!!!!
         ForeignObject foreign = new ForeignObject(doc, ns);
+        TraitSetter.setProducerID(foreign, fobj.getId());
 
         Viewport vp = new Viewport(foreign);
+        TraitSetter.setProducerID(vp, fobj.getId());
         vp.setIPD(ipd);
         vp.setBPD(bpd);
         vp.setContentPosition(placement);
index 0bfa38810c7b2dba9864f23a31fab350142818b8..8dc2481c87fc402050bd8f7eb5cad723ded5450a 100644 (file)
@@ -34,6 +34,7 @@ import org.apache.fop.layoutmgr.LayoutContext;
 import org.apache.fop.layoutmgr.LeafPosition;
 import org.apache.fop.layoutmgr.Position;
 import org.apache.fop.layoutmgr.PositionIterator;
+import org.apache.fop.layoutmgr.TraitSetter;
 import org.apache.fop.traits.MinOptMax;
 
 import java.util.List;
@@ -151,6 +152,7 @@ public class LeaderLayoutManager extends LeafNodeLayoutManager {
             }
             leaderArea = fa;
         }
+        TraitSetter.setProducerID(leaderArea, fobj.getId());
         return leaderArea;
      }
 
index 7fe310fe2abdd16d1bd170543a54ea0c91997c07..1bd06564cc9fca1c75002bb70aeb740d1533c860 100644 (file)
@@ -193,6 +193,10 @@ public abstract class LeafNodeLayoutManager extends AbstractLayoutManager
         return curArea;
     }
     
+    /**
+     * This method is called by addAreas() so IDs can be added to a page for FOs that 
+     * support the 'id' property.
+     */
     protected void addId() {
         // Do nothing here, overriden in subclasses that have an 'id' property.
     }
index 3fe902bdfa9c7f49cf9aaaa124750deae843c48a..0957cf36f4fc348118e2bfc53e97f90837f664a7 100644 (file)
@@ -100,6 +100,7 @@ public class PageNumberCitationLayoutManager extends LeafNodeLayoutManager {
             inline.setIPD(width);
             
         }
+        TraitSetter.setProducerID(inline, fobj.getId());
         inline.setBPD(font.getAscender() - font.getDescender());
         inline.setOffset(font.getAscender());
         inline.addTrait(Trait.FONT_NAME, font.getFontName());
index 409efa35a31d8fade3c80b2b5a13231d1c3c9114..dd58e992d2e332fd9c23289d5b32158ba5be2696 100644 (file)
@@ -83,6 +83,7 @@ public class PageNumberLayoutManager extends LeafNodeLayoutManager {
         //TODO or even better: delay area creation until addAreas() stage
         //TextArea is cloned because the LM is reused in static areas and the area can't be.
         TextArea ta = new TextArea();
+        TraitSetter.setProducerID(ta, fobj.getId());
         ta.setIPD(baseArea.getIPD());
         ta.setBPD(baseArea.getBPD());
         ta.setOffset(baseArea.getOffset());