Author: jeremias
Date: Tue Dec  7 08:34:39 2010
New Revision: 1042934

URL: http://svn.apache.org/viewvc?rev=1042934&view=rev
Log:
Bugzilla #42034:
Fixed adjustment of inline parent area for justified text containing a forward 
page reference.

Added:
    
xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/basic-link_for_toc.xml
   (with props)
Modified:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/area/LineArea.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/area/inline/InlineArea.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/area/inline/InlineParent.java
    xmlgraphics/fop/trunk/status.xml

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/area/LineArea.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/area/LineArea.java?rev=1042934&r1=1042933&r2=1042934&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/area/LineArea.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/area/LineArea.java Tue Dec  7 
08:34:39 2010
@@ -19,13 +19,13 @@
 
 package org.apache.fop.area;
 
-import org.apache.fop.area.inline.InlineArea;
-import org.apache.fop.fo.Constants;
-
 import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.fop.area.inline.InlineArea;
+import org.apache.fop.fo.Constants;
+
 /**
  * The line area.
  * This is a line area that contains inline areas.
@@ -59,6 +59,15 @@ public class LineArea extends Area {
             variationFactor = 1.0;
             bAddedToAreaTree = false;
         }
+
+        /** {...@inheritdoc} */
+        public String toString() {
+            return getClass().getSimpleName()
+                + ": diff=" + difference
+                + ", variation=" + variationFactor
+                + ", stretch=" + availableStretch
+                + ", shrink=" + availableShrink;
+        }
     }
 
     private LineAdjustingInfo adjustingInfo = null;
@@ -199,6 +208,9 @@ public class LineArea extends Area {
      */
     public void finalise() {
         if (adjustingInfo.lineAlignment == Constants.EN_JUSTIFY) {
+            if (log.isTraceEnabled()) {
+                log.trace("Applying variation factor to justified line: " + 
adjustingInfo);
+            }
             // justified line: apply the variation factor
             boolean bUnresolvedAreasPresent = false;
             // recursively apply variation factor to descendant areas

Modified: 
xmlgraphics/fop/trunk/src/java/org/apache/fop/area/inline/InlineArea.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/area/inline/InlineArea.java?rev=1042934&r1=1042933&r2=1042934&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/area/inline/InlineArea.java 
(original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/area/inline/InlineArea.java 
Tue Dec  7 08:34:39 2010
@@ -228,6 +228,11 @@ public class InlineArea extends Area {
      * @param ipdVariation the variation
      */
     public void handleIPDVariation(int ipdVariation) {
+        if (log.isTraceEnabled()) {
+            log.trace("Handling IPD variation for " + 
getClass().getSimpleName()
+                    + ": increase by " + ipdVariation + " mpt.");
+        }
+
         increaseIPD(ipdVariation);
         notifyIPDVariation(ipdVariation);
     }

Modified: 
xmlgraphics/fop/trunk/src/java/org/apache/fop/area/inline/InlineParent.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/area/inline/InlineParent.java?rev=1042934&r1=1042933&r2=1042934&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/area/inline/InlineParent.java 
(original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/area/inline/InlineParent.java 
Tue Dec  7 08:34:39 2010
@@ -19,10 +19,9 @@
 
 package org.apache.fop.area.inline;
 
-import org.apache.fop.area.Area;
-
 import java.util.List;
-import java.util.ArrayList;
+
+import org.apache.fop.area.Area;
 
 /**
  * Inline parent area.
@@ -35,7 +34,7 @@ public class InlineParent extends Inline
     /**
      * The list of inline areas added to this inline parent.
      */
-    protected List inlines = new ArrayList();
+    protected List<InlineArea> inlines = new java.util.ArrayList<InlineArea>();
 
     /** Controls whether the IPD is automatically adjusted based on the area's 
children. */
     protected transient boolean autoSize;
@@ -51,13 +50,14 @@ public class InlineParent extends Inline
      *
      * @param childArea the child area to add
      */
+    @Override
     public void addChildArea(Area childArea) {
         if (inlines.size() == 0) {
             autoSize = (getIPD() == 0);
         }
         if (childArea instanceof InlineArea) {
             InlineArea inlineChildArea = (InlineArea) childArea;
-            inlines.add(childArea);
+            inlines.add(inlineChildArea);
             // set the parent area for the child area
             inlineChildArea.setParentArea(this);
             if (autoSize) {
@@ -71,7 +71,7 @@ public class InlineParent extends Inline
      *
      * @return the list of child areas
      */
-    public List getChildAreas() {
+    public List<InlineArea> getChildAreas() {
         return inlines;
     }
 
@@ -82,14 +82,20 @@ public class InlineParent extends Inline
      * @param lineShrink      the total shrink of the line
      * @return true if there is an UnresolvedArea descendant
      */
+    @Override
     public boolean applyVariationFactor(double variationFactor,
                                         int lineStretch, int lineShrink) {
         boolean bUnresolvedAreasPresent = false;
+        int cumulativeIPD = 0;
         // recursively apply variation factor to descendant areas
         for (int i = 0, len = inlines.size(); i < len; i++) {
-            bUnresolvedAreasPresent |= ((InlineArea)inlines.get(i))
-                .applyVariationFactor(variationFactor, lineStretch, 
lineShrink);
+            InlineArea inline = inlines.get(i);
+            bUnresolvedAreasPresent |= inline.applyVariationFactor(
+                    variationFactor, lineStretch, lineShrink);
+            cumulativeIPD += inline.getIPD();  //Update this area's IPD based 
on changes to children
         }
+        setIPD(cumulativeIPD);
+
         return bUnresolvedAreasPresent;
     }
 }

Modified: xmlgraphics/fop/trunk/status.xml
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/status.xml?rev=1042934&r1=1042933&r2=1042934&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/status.xml (original)
+++ xmlgraphics/fop/trunk/status.xml Tue Dec  7 08:34:39 2010
@@ -58,6 +58,9 @@
       documents. Example: the fix of marks layering will be such a case when 
it's done.
     -->
     <release version="FOP Trunk" date="TBD">
+      <action context="Layout" dev="JM" type="fix" fixes-bug="42034">
+        Fixed adjustment of inline parent area for justified text containing a 
forward page reference.
+      </action>
       <action context="Layout" dev="AD" type="fix" fixes-bug="38264">
         Fixed behavior when combining hyphenation with preserved linefeeds or 
whitespace.
       </action>

Added: 
xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/basic-link_for_toc.xml
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/basic-link_for_toc.xml?rev=1042934&view=auto
==============================================================================
--- 
xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/basic-link_for_toc.xml
 (added)
+++ 
xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/basic-link_for_toc.xml
 Tue Dec  7 08:34:39 2010
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<!-- $Id$ -->
+<testcase>
+  <info>
+    <p>
+      This test checks fo:basic-link in conjunction with text-align="justify" 
and an
+      fo:page-number-citation.
+    </p>
+  </info>
+  <fo>
+    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format";>
+      <fo:layout-master-set>
+        <fo:simple-page-master master-name="normal" page-width="5in" 
page-height="5in">
+          <fo:region-body/>
+        </fo:simple-page-master>
+      </fo:layout-master-set>
+      <fo:page-sequence master-reference="normal">
+        <fo:flow flow-name="xsl-region-body">
+          <fo:block text-align="justify">
+            You can read about Apache FOP in
+            <fo:basic-link 
external-destination="http://xmlgraphics.apache.org/fop/";
+            >chapter 1 on page <fo:page-number-citation 
ref-id="1"/></fo:basic-link>.
+            Apache FOP is open source, BTW.
+          </fo:block>
+          <fo:block id="1"/>
+        </fo:flow>
+      </fo:page-sequence>
+    </fo:root>
+  </fo>
+  <checks>
+    <eval expected="http://xmlgraphics.apache.org/fop/"; 
xpath="substring-after(//flow/block[1]/lineArea/inlineparent/@external-link,'dest=')"/>
+    <eval expected="360000" xpath="//flow/block[1]/lineArea/@ipd"/>
+    <eval expected="104440" 
xpath="//flow/block[1]/lineArea/inlineparent/text[1]/@ipd"/>
+    <eval expected="6672" 
xpath="//flow/block[1]/lineArea/inlineparent/text[2]/@ipd"/>
+    <eval expected="111112" 
xpath="//flow/block[1]/lineArea/inlineparent/@ipd"/>
+  </checks>
+</testcase>

Propchange: 
xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/basic-link_for_toc.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/basic-link_for_toc.xml
------------------------------------------------------------------------------
    svn:keywords = Id



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to