]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Fixed layout of forward page number citation references in fo:inline
authorSimon Pepping <spepping@apache.org>
Sat, 7 Oct 2006 14:29:54 +0000 (14:29 +0000)
committerSimon Pepping <spepping@apache.org>
Sat, 7 Oct 2006 14:29:54 +0000 (14:29 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@453920 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/area/inline/InlineArea.java
src/java/org/apache/fop/area/inline/InlineParent.java
src/java/org/apache/fop/area/inline/TextArea.java
src/java/org/apache/fop/area/inline/UnresolvedPageNumber.java
src/java/org/apache/fop/layoutmgr/inline/PageNumberLayoutManager.java
test/layoutengine/standard-testcases/page-number-citation_basic_2.xml

index 892ad60625147cd805937ba43f1e06b12eb6f886..5e31adf222d295ab3f445c63b11b6a5bc7f7f1a7 100644 (file)
@@ -113,11 +113,6 @@ public class InlineArea extends Area {
      */
     public void setParentArea(Area parentArea) {
         this.parentArea = parentArea;
-        // notify the parent area about ipd variations
-        if (storedIPDVariation > 0) {
-            notifyIPDVariation(storedIPDVariation);
-            storedIPDVariation = 0;
-        }
     }
 
     /**
@@ -161,16 +156,6 @@ public class InlineArea extends Area {
         return getBooleanTrait(Trait.BLINK);
     }
     
-    /**
-     * set the ipd and notify the parent area about the variation;
-     * this happens when a page-number or a page-number-citation
-     * is resolved to its actual value
-     * @param newIPD the new ipd of the area
-     */
-    public void updateIPD(int newIPD) {
-        // default behaviour: do nothing
-    }
-    
     /**
      * recursively apply the variation factor to all descendant areas
      * @param variationFactor the variation factor that must be applied to adjustments
@@ -184,14 +169,19 @@ public class InlineArea extends Area {
         return false;
     }
     
-    /**
+    public void handleIPDVariation(int ipdVariation) {
+        increaseIPD(ipdVariation);
+        notifyIPDVariation(ipdVariation);
+    }
+    
+        /**
      * notify the parent area about the ipd variation of this area
      * or of a descendant area
      * @param ipdVariation the difference between new and old ipd
      */
     protected void notifyIPDVariation(int ipdVariation) {
         if (getParentArea() instanceof InlineArea) {
-            ((InlineArea) getParentArea()).notifyIPDVariation(ipdVariation);
+            ((InlineArea) getParentArea()).handleIPDVariation(ipdVariation);
         } else if (getParentArea() instanceof LineArea) {
             ((LineArea) getParentArea()).handleIPDVariation(ipdVariation);
         } else if (getParentArea() == null) {
index 016154989ca394a7dbc9a42893656d0a31d56a18..4b55d45be77e721c27e238956a1477ecf0e1ec07 100644 (file)
@@ -53,9 +53,12 @@ public class InlineParent extends InlineArea {
             autoSize = (getIPD() == 0);
         }
         if (childArea instanceof InlineArea) {
+            InlineArea inlineChildArea = (InlineArea) childArea;
             inlines.add(childArea);
+            // set the parent area for the child area
+            inlineChildArea.setParentArea(this);
             if (autoSize) {
-                increaseIPD(((InlineArea) childArea).getAllocIPD());
+                increaseIPD(inlineChildArea.getAllocIPD());
             }
         }
     }
index 5e3d3da39c8720b4f3aea0c08aeef5069fcf4d3c..703d6a436e1a71f375f5b38bc6c8b3d502e67259 100644 (file)
@@ -109,22 +109,5 @@ public class TextArea extends AbstractTextArea {
         return text.toString();
     }
 
-    /**
-     * set the ipd and notify the parent area about the variation;
-     * this happens when a page-number or a page-number-citation
-     * is resolved to its actual value
-     * @param newIPD the new ipd of the area
-     */
-    public void updateIPD(int newIPD) {
-        // remember the old ipd
-        int oldIPD = getIPD();
-        // set the new ipd
-        setIPD(newIPD);
-        // check if the line needs to be adjusted because of the ipd variation
-        if (newIPD != oldIPD) {
-            notifyIPDVariation(newIPD - oldIPD);
-        }
-    }
-
 }
 
index 2f83afddae5fede1fc6ab351118fcda2e2cd38c0..db94ce6a12f9341ceef52709badcdd4b876db94f 100644 (file)
@@ -107,7 +107,7 @@ public class UnresolvedPageNumber extends TextArea implements Resolvable {
             addWord(text, 0);
             // update ipd
             if (font != null) {
-                updateIPD(font.getWordWidth(text));
+                handleIPDVariation(font.getWordWidth(text) - getIPD());
                 // set the Font object to null, as we don't need it any more
                 font = null;
             } else {
index ff751bcd8b37628199574d040b4d362ea3b1aa49..51783fc1e91fed89db9c8fc33938a8a5d3a91b04 100644 (file)
@@ -110,7 +110,7 @@ public class PageNumberLayoutManager extends LeafNodeLayoutManager {
         area.removeText();
         area.addWord(getCurrentPV().getPageNumberString(), 0);
         // update the ipd of the area
-        area.updateIPD(getStringWidth(area.getText()));
+        area.handleIPDVariation(getStringWidth(area.getText()) - area.getIPD());
         // update the width stored in the AreaInfo object
         areaInfo.ipdArea = new MinOptMax(area.getIPD());
     }
index 12e610e6a2010c3293f7c07da24384520e336fb2..03fb525446cf7c6ffabcceae2b65843a8dfa5065 100644 (file)
@@ -44,9 +44,7 @@
     <eval expected="112" xpath="//pageViewport[@nr=111]/page/regionViewport/regionBody/mainReference/span/flow/block[1]/lineArea/text[2]"/>
     <eval expected="20016" xpath="//pageViewport[@nr=111]/page/regionViewport/regionBody/mainReference/span/flow/block[1]/lineArea/text[2]/@ipd"/>
     <!-- Check the text and width of the inlineparent area -->
-    <!-- disabled until this feature is fixed
     <eval expected="112" xpath="//pageViewport[@nr=111]/page/regionViewport/regionBody/mainReference/span/flow/block[2]/lineArea/inlineparent"/>
     <eval expected="20016" xpath="//pageViewport[@nr=111]/page/regionViewport/regionBody/mainReference/span/flow/block[2]/lineArea/inlineparent/@ipd"/>
-    -->
   </checks>
 </testcase>