From 324e3ea6f7dde168c715c2d5f78eb8dca7744e07 Mon Sep 17 00:00:00 2001 From: Jeremias Maerki Date: Thu, 24 Apr 2008 16:08:53 +0000 Subject: [PATCH] Fixed regression causing bad positioning of block-containers if used as descendant of a table-cell. This was not caught because of the lack of a test case that would have shown the problem in visual testing with BatchDiffer. See also: http://mail-archives.apache.org/mod_mbox/xmlgraphics-fop-users/200804.mbox/%3c20080424164128.973A.DEV@jeremias-maerki.ch%3e git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/fop-0_95@651302 13f79535-47bb-0310-9956-ffa450edef68 --- .../render/AbstractPathOrientedRenderer.java | 35 ++++++++++ .../apache/fop/render/AbstractRenderer.java | 9 +++ .../apache/fop/render/afp/AFPRenderer.java | 39 +++++++++++ .../apache/fop/render/pcl/PCLRenderer.java | 40 ++++++++++++ .../apache/fop/render/xml/XMLRenderer.java | 14 +++- status.xml | 4 ++ .../table-cell_bc-child.xml | 65 +++++++++++++++++++ 7 files changed, 203 insertions(+), 3 deletions(-) create mode 100644 test/layoutengine/standard-testcases/table-cell_bc-child.xml diff --git a/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java b/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java index 9e13476f6..ca9c6af97 100644 --- a/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java +++ b/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java @@ -521,6 +521,41 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { } } + /** {@inheritDoc} */ + protected void renderReferenceArea(Block block) { + // save position and offset + int saveIP = currentIPPosition; + int saveBP = currentBPPosition; + + //Establish a new coordinate system + AffineTransform at = new AffineTransform(); + at.translate(currentIPPosition, currentBPPosition); + at.translate(block.getXOffset(), block.getYOffset()); + at.translate(0, block.getSpaceBefore()); + + if (!at.isIdentity()) { + saveGraphicsState(); + concatenateTransformationMatrix(mptToPt(at)); + } + + currentIPPosition = 0; + currentBPPosition = 0; + handleBlockTraits(block); + + List children = block.getChildAreas(); + if (children != null) { + renderBlocks(block, children); + } + + if (!at.isIdentity()) { + restoreGraphicsState(); + } + + // stacked and relative blocks effect stacking + currentIPPosition = saveIP; + currentBPPosition = saveBP; + } + /** * Concatenates the current transformation matrix with the given one, therefore establishing * a new coordinate system. diff --git a/src/java/org/apache/fop/render/AbstractRenderer.java b/src/java/org/apache/fop/render/AbstractRenderer.java index 32c4b33c4..7fa62dd11 100644 --- a/src/java/org/apache/fop/render/AbstractRenderer.java +++ b/src/java/org/apache/fop/render/AbstractRenderer.java @@ -481,6 +481,13 @@ public abstract class AbstractRenderer } } + /** + * Renders a block area that represents a reference area. The reference area establishes + * a new coordinate system. + * @param block the block area + */ + protected abstract void renderReferenceArea(Block block); + /** * Renders a list of block areas. * @@ -549,6 +556,8 @@ public abstract class AbstractRenderer // simply move position currentBPPosition += block.getAllocBPD(); } + } else if (Boolean.TRUE.equals(block.getTrait(Trait.IS_REFERENCE_AREA))) { + renderReferenceArea(block); } else { // save position and offset int saveIP = currentIPPosition; diff --git a/src/java/org/apache/fop/render/afp/AFPRenderer.java b/src/java/org/apache/fop/render/afp/AFPRenderer.java index 205873493..cbf0beb3a 100644 --- a/src/java/org/apache/fop/render/afp/AFPRenderer.java +++ b/src/java/org/apache/fop/render/afp/AFPRenderer.java @@ -587,6 +587,45 @@ public class AFPRenderer extends AbstractPathOrientedRenderer { } } + /** {@inheritDoc} */ + protected void renderReferenceArea(Block block) { + //TODO Remove this method once concatenateTransformationMatrix() is implemented + + // save position and offset + int saveIP = currentIPPosition; + int saveBP = currentBPPosition; + + //Establish a new coordinate system + AffineTransform at = new AffineTransform(); + at.translate(currentIPPosition, currentBPPosition); + at.translate(block.getXOffset(), block.getYOffset()); + at.translate(0, block.getSpaceBefore()); + + if (!at.isIdentity()) { + Rectangle2D contentRect + = new Rectangle2D.Double(at.getTranslateX(), at.getTranslateY(), + block.getAllocIPD(), block.getAllocBPD()); + pushViewPortPos(new ViewPortPos(contentRect, new CTM(at))); + } + + currentIPPosition = 0; + currentBPPosition = 0; + handleBlockTraits(block); + + List children = block.getChildAreas(); + if (children != null) { + renderBlocks(block, children); + } + + if (!at.isIdentity()) { + popViewPortPos(); + } + + // stacked and relative blocks effect stacking + currentIPPosition = saveIP; + currentBPPosition = saveBP; + } + /** {@inheritDoc} */ protected void concatenateTransformationMatrix(AffineTransform at) { //Not used here since AFPRenderer defines its own renderBlockViewport() method. diff --git a/src/java/org/apache/fop/render/pcl/PCLRenderer.java b/src/java/org/apache/fop/render/pcl/PCLRenderer.java index 1d606e919..1d46374b1 100644 --- a/src/java/org/apache/fop/render/pcl/PCLRenderer.java +++ b/src/java/org/apache/fop/render/pcl/PCLRenderer.java @@ -1005,6 +1005,46 @@ public class PCLRenderer extends PrintRenderer { //currentFontName = saveFontName; } + /** {@inheritDoc} */ + protected void renderReferenceArea(Block block) { + //TODO This is the same code as in AbstractPathOrientedRenderer + //So there's some optimization potential but not otherwise PCLRenderer is a little + //difficult to derive from AbstractPathOrientedRenderer. Maybe an additional layer + //between PrintRenderer and AbstractPathOrientedRenderer is necessary. + + // save position and offset + int saveIP = currentIPPosition; + int saveBP = currentBPPosition; + + //Establish a new coordinate system + AffineTransform at = new AffineTransform(); + at.translate(currentIPPosition, currentBPPosition); + at.translate(block.getXOffset(), block.getYOffset()); + at.translate(0, block.getSpaceBefore()); + + if (!at.isIdentity()) { + saveGraphicsState(); + concatenateTransformationMatrix(mptToPt(at)); + } + + currentIPPosition = 0; + currentBPPosition = 0; + handleBlockTraits(block); + + List children = block.getChildAreas(); + if (children != null) { + renderBlocks(block, children); + } + + if (!at.isIdentity()) { + restoreGraphicsState(); + } + + // stacked and relative blocks effect stacking + currentIPPosition = saveIP; + currentBPPosition = saveBP; + } + /** * Concatenates the current transformation matrix with the given one, therefore establishing * a new coordinate system. diff --git a/src/java/org/apache/fop/render/xml/XMLRenderer.java b/src/java/org/apache/fop/render/xml/XMLRenderer.java index 66cce0ae1..7798eef92 100644 --- a/src/java/org/apache/fop/render/xml/XMLRenderer.java +++ b/src/java/org/apache/fop/render/xml/XMLRenderer.java @@ -754,9 +754,17 @@ public class XMLRenderer extends PrintRenderer { endElement("flow"); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ + protected void renderReferenceArea(Block block) { + handleBlockTraits(block); + + List children = block.getChildAreas(); + if (children != null) { + renderBlocks(block, children); + } + } + + /** {@inheritDoc} */ protected void renderBlock(Block block) { atts.clear(); addAreaAttributes(block); diff --git a/status.xml b/status.xml index fafd67543..7b5965def 100644 --- a/status.xml +++ b/status.xml @@ -60,6 +60,10 @@ --> + + Fixed regression causing bad positioning of block-containers if used as descendant + of a table-cell. + Fixed text extraction problem with ZapfDingbats and Symbol font in PDF output. diff --git a/test/layoutengine/standard-testcases/table-cell_bc-child.xml b/test/layoutengine/standard-testcases/table-cell_bc-child.xml new file mode 100644 index 000000000..eb199c73b --- /dev/null +++ b/test/layoutengine/standard-testcases/table-cell_bc-child.xml @@ -0,0 +1,65 @@ + + + + + +

+ This test checks the rendering of block viewports in reference areas generated + by table-cells. This does not test the layout engine, only the renderer. +

+
+ + + + + + + + + + + + + + + + No red text should be visible! + + No red text should be visible! + + + + + + No red text should be visible! + + No red text should be visible! + + + + + + + + + + + + +
-- 2.39.5