From e126edb6ed0c2aaefe0ebd72909d2f2346198f65 Mon Sep 17 00:00:00 2001 From: Vincent Hennebert Date: Tue, 16 Nov 2010 12:18:15 +0000 Subject: [PATCH] Do not re-create an AlignmentContext instance if one already exists. Fixes a bug when the changing IPD hack is triggered and the getNextKnuthElements method is called a second time git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1035609 13f79535-47bb-0310-9956-ffa450edef68 --- .../layoutmgr/inline/LineLayoutManager.java | 12 ++-- .../flow_changing-ipd_image.xml | 60 +++++++++++++++++++ 2 files changed, 67 insertions(+), 5 deletions(-) create mode 100644 test/layoutengine/standard-testcases/flow_changing-ipd_image.xml diff --git a/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java index cbae691b1..964a4e2a5 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java @@ -559,11 +559,13 @@ public class LineLayoutManager extends InlineStackingLayoutManager /** {@inheritDoc} */ public List getNextKnuthElements(LayoutContext context, int alignment) { - FontInfo fi = fobj.getFOEventHandler().getFontInfo(); - FontTriplet[] fontkeys = fobj.getCommonFont().getFontState(fi); - Font fs = fi.getFontInstance(fontkeys[0], fobj.getCommonFont().fontSize.getValue(this)); - alignmentContext = new AlignmentContext(fs, lineHeight.getValue(this), - context.getWritingMode()); + if (alignmentContext == null) { + FontInfo fi = fobj.getFOEventHandler().getFontInfo(); + FontTriplet[] fontkeys = fobj.getCommonFont().getFontState(fi); + Font fs = fi.getFontInstance(fontkeys[0], fobj.getCommonFont().fontSize.getValue(this)); + alignmentContext = new AlignmentContext(fs, lineHeight.getValue(this), + context.getWritingMode()); + } context.setAlignmentContext(alignmentContext); ipd = context.getRefIPD(); diff --git a/test/layoutengine/standard-testcases/flow_changing-ipd_image.xml b/test/layoutengine/standard-testcases/flow_changing-ipd_image.xml new file mode 100644 index 000000000..37014f49a --- /dev/null +++ b/test/layoutengine/standard-testcases/flow_changing-ipd_image.xml @@ -0,0 +1,60 @@ + + + + + +

+ This test checks that an image is properly positioned after a page break triggering changing + IPD. +

+
+ + + + + + + + + + + + + + + + + + + First block + Block before the page break. + Block after the page break. + + + + + + + + + + +
-- 2.39.5