]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
For area.Blocks created in BlockLayoutManager.getParentArea(), I set the
authorGlen Mazza <gmazza@apache.org>
Sun, 25 Apr 2004 04:45:28 +0000 (04:45 +0000)
committerGlen Mazza <gmazza@apache.org>
Sun, 25 Apr 2004 04:45:28 +0000 (04:45 +0000)
width of the Block to that of its parent block.

This fixes a layout problem where

<fo:table-cell><fo:block border-bottom="1pt solid black">some text</ ></ >

was causing a line to draw across the entire page, because the cell width present in
fo:table-cell's Block was not copied into the inner fo:block's Block.  (This problem did not
occur if the border-bottom attribute was set in fo:table-cell.)

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

src/java/org/apache/fop/area/inline/TextArea.java
src/java/org/apache/fop/fo/FObj.java
src/java/org/apache/fop/layoutmgr/AddLMVisitor.java
src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java
src/java/org/apache/fop/layoutmgr/TextLayoutManager.java
src/java/org/apache/fop/render/pdf/PDFRenderer.java
src/java/org/apache/fop/render/xml/XMLRenderer.java

index 077769a1df39dfa6bbad9aa754517f6c026c4239..110eaa03fb3185798ed6d54b6d19b1f57ad089fe 100644 (file)
@@ -27,7 +27,7 @@ public class TextArea extends InlineArea {
      * The text for this inline area
      */
     protected String text;
-    private int iTSadjust = 0;
+    private int iTextSpaceAdjust = 0;
 
     /**
      * Create a text inline area
@@ -58,8 +58,8 @@ public class TextArea extends InlineArea {
      *
      * @return the text space adjustment
      */
-    public int getTSadjust() {
-        return iTSadjust;
+    public int getTextSpaceAdjust() {
+        return iTextSpaceAdjust;
     }
 
     /**
@@ -67,8 +67,8 @@ public class TextArea extends InlineArea {
      *
      * @param iTSadjust the text space adjustment
      */
-    public void setTSadjust(int iTSadjust) {
-        this.iTSadjust = iTSadjust;
+    public void setTextSpaceAdjust(int iTSadjust) {
+        iTextSpaceAdjust = iTSadjust;
     }
 }
 
index 8a66a2f7df91c2e9f0746da981e5307497e6015c..db2bc953dba2bca04e1a016b8a47fd6b598d0ce1 100644 (file)
@@ -448,12 +448,15 @@ public class FObj extends FONode implements Constants {
         fotv.serveFObj(this);
     }
     
-    /**
-     * Return a string representation of the fo element. 
+
+    /*
+     * Return a string representation of the fo element.
+     * Deactivated in order to see precise ID of each fo element created
+     *    (helpful for debugging)
      */
-    public String toString() {
+/*    public String toString() {
         return getName() + " at line " + line + ":" + column;
     }
-    
+*/    
 }
 
index c180a7e95dd0469b955ea576e2ce8bbabe4a5836..990dbafe6667f0995e68a53a2d1399b14d0d098e 100644 (file)
@@ -282,11 +282,7 @@ public class AddLMVisitor implements FOTreeVisitor {
      }
 
      public void serveBlock(Block node) {
-         BlockLayoutManager blm = new BlockLayoutManager();
-         blm.setUserAgent(node.getUserAgent());
-         blm.setFObj(node);
-         TextInfo ti = node.getPropertyManager().getTextLayoutProps(node.getFOTreeControl());
-         blm.setBlockTextInfo(ti);
+         BlockLayoutManager blm = new BlockLayoutManager(node);
          currentLMList.add(blm);
      }
 
index 490f731d4db2ac2c33b578b0a13c682b704d1cdd..3929fc4cb2f8b80eec6fadc1a98447a12e18a2cf 100644 (file)
@@ -28,6 +28,7 @@ import org.apache.fop.fo.TextInfo;
 import org.apache.fop.fo.PropertyManager;
 import org.apache.fop.area.Area;
 import org.apache.fop.area.Block;
+import org.apache.fop.area.BlockParent;
 import org.apache.fop.area.LineArea;
 import org.apache.fop.traits.LayoutProps;
 import org.apache.fop.fo.properties.CommonBorderAndPadding;
@@ -68,6 +69,20 @@ public class BlockLayoutManager extends BlockStackingLayoutManager {
 
     protected List childBreaks = new java.util.ArrayList();
 
+    public BlockLayoutManager(org.apache.fop.fo.flow.Block inBlock) {
+        super.setFObj(inBlock);
+        childLMiter = new BlockLMiter(this, childLMiter);
+        userAgent = inBlock.getUserAgent();
+        setBlockTextInfo(inBlock.getPropertyManager().getTextLayoutProps(
+            inBlock.getFOTreeControl()));
+    }
+
+    private void setBlockTextInfo(TextInfo ti) {
+        lead = ti.fs.getAscender();
+        follow = -ti.fs.getDescender();
+        lineHeight = ti.lineHeight;
+    }
+
     /**
      * Iterator for Block layout.
      * This iterator combines consecutive inline areas and
@@ -126,25 +141,6 @@ public class BlockLayoutManager extends BlockStackingLayoutManager {
         }
     }
 
-    public BlockLayoutManager() {
-    }
-
-    /**
-     * Set the FO object for this layout manager
-     *
-     * @param fo the fo for this layout manager
-     */
-    public void setFObj(FObj fo) {
-        super.setFObj(fo);
-        childLMiter = new BlockLMiter(this, childLMiter);
-    }
-
-    public void setBlockTextInfo(TextInfo ti) {
-        lead = ti.fs.getAscender();
-        follow = -ti.fs.getDescender();
-        lineHeight = ti.lineHeight;
-    }
-
     /**
      * This method provides a hook for a LayoutManager to intialize traits
      * for the areas it will create, based on Properties set on its FO.
@@ -325,10 +321,17 @@ public class BlockLayoutManager extends BlockStackingLayoutManager {
             // Set up dimensions
             // Must get dimensions from parent area
             Area parentArea = parentLM.getParentArea(curBlockArea);
+
+            // Get reference IPD from parentArea
             int referenceIPD = parentArea.getIPD();
             curBlockArea.setIPD(referenceIPD);
-            curBlockArea.setWidth(referenceIPD);
-            // Get reference IPD from parentArea
+            
+            // Set the width of the block based on the parent block
+            if (parentArea instanceof BlockParent) {
+                curBlockArea.setWidth(((BlockParent) parentArea).getWidth());
+            } else {
+                curBlockArea.setWidth(referenceIPD);
+            }
             setCurrentArea(curBlockArea); // ??? for generic operations
         }
         return curBlockArea;
index ae6987258f4102e0a033264771b5c1c392e43726..f7badde2f3bed67010e39e8ee0246196454191b1 100644 (file)
@@ -499,7 +499,7 @@ public class TextLayoutManager extends AbstractLayoutManager {
             if (iWScount > 0) {
                 //getLogger().error("Adjustment per word-space= " +
                 //                   iAdjust / iWScount);
-                t.setTSadjust(iAdjust / iWScount);
+                t.setTextSpaceAdjust(iAdjust / iWScount);
                 //System.err.println("TextLayoutManager> word spaces= " + iWScount + " adjustment per word space= " + (iAdjust/iWScount));
             }
             word = t;
index a5570351be6e487e232ef3987fb23a6480c75963..ed35a16fefc0df8b607c2c41b7b3d0b150820507 100644 (file)
@@ -939,11 +939,12 @@ public class PDFRenderer extends PrintRenderer {
         //  where previous line area failed to take up entire allocated space
         int rx = currentBlockIPPosition + ipMarginOffset;
         int bl = currentBPPosition + bpMarginOffset + text.getOffset();
-/*
-        System.out.println("\nBlockIP Position: " + currentBlockIPPosition +
+
+/*        System.out.println("Text = " + text.getTextArea() +
+                       "; text width: " + text.getWidth() +
+               "; BlockIP Position: " + currentBlockIPPosition +
             "; currentBPPosition: " + currentBPPosition +
-            "; offset: " + text.getOffset() +
-            "; Text = " + text.getTextArea());
+            "; offset: " + text.getOffset());
 */
         // Set letterSpacing
         //float ls = fs.getLetterSpacing() / this.currentFontSize;
@@ -953,14 +954,14 @@ public class PDFRenderer extends PrintRenderer {
             closeText();
 
             pdf.append("1 0 0 -1 " + (rx / 1000f) + " " + (bl / 1000f) + " Tm "
-                       + (text.getTSadjust()/1000f) + " Tw [" + startText);
+                       + (text.getTextSpaceAdjust()/1000f) + " Tw [" + startText);
             prevWordY = bl;
             textOpen = true;
         } else {
                 closeText();
 
                 pdf.append("1 0 0 -1 " + (rx / 1000f) + " " + (bl / 1000f) + " Tm "
-                           + (text.getTSadjust()/1000f) + " Tw [" + startText);
+                           + (text.getTextSpaceAdjust()/1000f) + " Tw [" + startText);
                 textOpen = true;
         }
         prevWordWidth = text.getWidth();
index c50bf4398c0123d6e0072c20766a745ad3f3471c..c3b7340c4b46f7ce3a9beacc06458bb71f823d64 100644 (file)
@@ -426,7 +426,7 @@ public class XMLRenderer extends AbstractRenderer {
         if (map != null) {
             prop = " props=\"" + getPropString(map) + "\"";
         }
-        writeElement("<text tsadjust=\"" + text.getTSadjust() + "\""
+        writeElement("<text tsadjust=\"" + text.getTextSpaceAdjust() + "\""
              + prop + ">" + text.getTextArea() + "</text>");
         super.renderText(text);
     }