diff options
author | Jeremias Maerki <jeremias@apache.org> | 2010-12-07 08:34:39 +0000 |
---|---|---|
committer | Jeremias Maerki <jeremias@apache.org> | 2010-12-07 08:34:39 +0000 |
commit | bc3a0d90c10f31bc683582f76d3a7adca3d83b12 (patch) | |
tree | e2ff6de2dee6c57b1b1b0989e3d7af2487849f16 | |
parent | 08804c734357861572c1b3b810ca2ff9104cae72 (diff) | |
download | xmlgraphics-fop-bc3a0d90c10f31bc683582f76d3a7adca3d83b12.tar.gz xmlgraphics-fop-bc3a0d90c10f31bc683582f76d3a7adca3d83b12.zip |
Bugzilla #42034:
Fixed adjustment of inline parent area for justified text containing a forward page reference.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1042934 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | src/java/org/apache/fop/area/LineArea.java | 18 | ||||
-rw-r--r-- | src/java/org/apache/fop/area/inline/InlineArea.java | 5 | ||||
-rw-r--r-- | src/java/org/apache/fop/area/inline/InlineParent.java | 22 | ||||
-rw-r--r-- | status.xml | 3 | ||||
-rw-r--r-- | test/layoutengine/standard-testcases/basic-link_for_toc.xml | 53 |
5 files changed, 90 insertions, 11 deletions
diff --git a/src/java/org/apache/fop/area/LineArea.java b/src/java/org/apache/fop/area/LineArea.java index c89b5be5b..b33b5da14 100644 --- a/src/java/org/apache/fop/area/LineArea.java +++ b/src/java/org/apache/fop/area/LineArea.java @@ -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 diff --git a/src/java/org/apache/fop/area/inline/InlineArea.java b/src/java/org/apache/fop/area/inline/InlineArea.java index 0889d1dad..3450b99be 100644 --- a/src/java/org/apache/fop/area/inline/InlineArea.java +++ b/src/java/org/apache/fop/area/inline/InlineArea.java @@ -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); } diff --git a/src/java/org/apache/fop/area/inline/InlineParent.java b/src/java/org/apache/fop/area/inline/InlineParent.java index 5d4369103..86c9141e6 100644 --- a/src/java/org/apache/fop/area/inline/InlineParent.java +++ b/src/java/org/apache/fop/area/inline/InlineParent.java @@ -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 InlineArea { /** * 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 InlineArea { * * @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 InlineArea { * * @return the list of child areas */ - public List getChildAreas() { + public List<InlineArea> getChildAreas() { return inlines; } @@ -82,14 +82,20 @@ public class InlineParent extends InlineArea { * @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; } } diff --git a/status.xml b/status.xml index d933ef686..e6cd1589c 100644 --- a/status.xml +++ b/status.xml @@ -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> diff --git a/test/layoutengine/standard-testcases/basic-link_for_toc.xml b/test/layoutengine/standard-testcases/basic-link_for_toc.xml new file mode 100644 index 000000000..9966c54b1 --- /dev/null +++ b/test/layoutengine/standard-testcases/basic-link_for_toc.xml @@ -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> |