From e7486da571264b21eba4724902db64b94da789c1 Mon Sep 17 00:00:00 2001 From: Simon Pepping Date: Sat, 7 Oct 2006 14:29:54 +0000 Subject: [PATCH] Fixed layout of forward page number citation references in fo:inline git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@453920 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/fop/area/inline/InlineArea.java | 24 ++++++------------- .../apache/fop/area/inline/InlineParent.java | 5 +++- .../org/apache/fop/area/inline/TextArea.java | 17 ------------- .../fop/area/inline/UnresolvedPageNumber.java | 2 +- .../inline/PageNumberLayoutManager.java | 2 +- .../page-number-citation_basic_2.xml | 2 -- 6 files changed, 13 insertions(+), 39 deletions(-) diff --git a/src/java/org/apache/fop/area/inline/InlineArea.java b/src/java/org/apache/fop/area/inline/InlineArea.java index 892ad6062..5e31adf22 100644 --- a/src/java/org/apache/fop/area/inline/InlineArea.java +++ b/src/java/org/apache/fop/area/inline/InlineArea.java @@ -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) { diff --git a/src/java/org/apache/fop/area/inline/InlineParent.java b/src/java/org/apache/fop/area/inline/InlineParent.java index 016154989..4b55d45be 100644 --- a/src/java/org/apache/fop/area/inline/InlineParent.java +++ b/src/java/org/apache/fop/area/inline/InlineParent.java @@ -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()); } } } diff --git a/src/java/org/apache/fop/area/inline/TextArea.java b/src/java/org/apache/fop/area/inline/TextArea.java index 5e3d3da39..703d6a436 100644 --- a/src/java/org/apache/fop/area/inline/TextArea.java +++ b/src/java/org/apache/fop/area/inline/TextArea.java @@ -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); - } - } - } diff --git a/src/java/org/apache/fop/area/inline/UnresolvedPageNumber.java b/src/java/org/apache/fop/area/inline/UnresolvedPageNumber.java index 2f83afdda..db94ce6a1 100644 --- a/src/java/org/apache/fop/area/inline/UnresolvedPageNumber.java +++ b/src/java/org/apache/fop/area/inline/UnresolvedPageNumber.java @@ -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 { diff --git a/src/java/org/apache/fop/layoutmgr/inline/PageNumberLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/PageNumberLayoutManager.java index ff751bcd8..51783fc1e 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/PageNumberLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/PageNumberLayoutManager.java @@ -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()); } diff --git a/test/layoutengine/standard-testcases/page-number-citation_basic_2.xml b/test/layoutengine/standard-testcases/page-number-citation_basic_2.xml index 12e610e6a..03fb52544 100644 --- a/test/layoutengine/standard-testcases/page-number-citation_basic_2.xml +++ b/test/layoutengine/standard-testcases/page-number-citation_basic_2.xml @@ -44,9 +44,7 @@ - -- 2.39.5