From e7937417473f161ff16cfcdbd044b2baffdb99fb Mon Sep 17 00:00:00 2001 From: Finn Bock Date: Wed, 22 Sep 2004 13:12:38 +0000 Subject: [PATCH] Gets rid of currentBlockIPPosition. Use currentIPPosition instead and restore it after each block-level area. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197961 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/fop/render/AbstractRenderer.java | 32 ++++++++----------- .../apache/fop/render/awt/AWTRenderer.java | 4 +-- .../apache/fop/render/pdf/PDFRenderer.java | 16 +++++----- .../org/apache/fop/render/ps/PSRenderer.java | 4 +-- .../apache/fop/render/svg/SVGRenderer.java | 11 +++---- 5 files changed, 30 insertions(+), 37 deletions(-) diff --git a/src/java/org/apache/fop/render/AbstractRenderer.java b/src/java/org/apache/fop/render/AbstractRenderer.java index 48d46b6b7..cc340fc70 100644 --- a/src/java/org/apache/fop/render/AbstractRenderer.java +++ b/src/java/org/apache/fop/render/AbstractRenderer.java @@ -97,11 +97,6 @@ public abstract class AbstractRenderer */ protected int currentIPPosition = 0; - /** - * current inline progression position in block - */ - protected int currentBlockIPPosition = 0; - /** * the block progression position of the containing block used for * absolutely positioned blocks @@ -264,7 +259,6 @@ public abstract class AbstractRenderer // set origin for the region to 0,0. currentBPPosition = 0; currentIPPosition = 0; - currentBlockIPPosition = currentIPPosition; RegionReference region = port.getRegion(); handleRegionTraits(port); @@ -469,6 +463,8 @@ public abstract class AbstractRenderer * @param blocks The block areas */ protected void renderBlocks(Block parent, List blocks) { + int saveIP = currentIPPosition; + // the position of the containing block is used for // absolutely positioned areas int contBP = currentBPPosition; @@ -479,6 +475,7 @@ public abstract class AbstractRenderer for (int count = 0; count < blocks.size(); count++) { Object obj = blocks.get(count); if (obj instanceof Block) { + currentIPPosition = saveIP; containingBPPosition = contBP; containingIPPosition = contIP; renderBlock((Block) obj); @@ -488,11 +485,11 @@ public abstract class AbstractRenderer // a line area is rendered from the top left position // of the line, each inline object is offset from there LineArea line = (LineArea) obj; - currentBlockIPPosition = - currentIPPosition + line.getStartIndent(); + currentIPPosition = saveIP + line.getStartIndent(); renderLineArea(line); currentBPPosition += line.getAllocBPD(); } + currentIPPosition = saveIP; } } @@ -534,9 +531,9 @@ public abstract class AbstractRenderer renderBlocks(block, children); // stacked and relative blocks effect stacking + currentIPPosition = saveIP; currentBPPosition = saveBP + block.getAllocBPD(); } - currentIPPosition = saveIP; } } @@ -576,7 +573,7 @@ public abstract class AbstractRenderer /** @see org.apache.fop.render.Renderer */ protected void renderCharacter(Character ch) { - currentBlockIPPosition += ch.getAllocIPD(); + currentIPPosition += ch.getAllocIPD(); } /** @see org.apache.fop.render.Renderer */ @@ -585,27 +582,27 @@ public abstract class AbstractRenderer // for the current block by the width or height of the space // it may also have styling (only on this object) that needs // handling - currentBlockIPPosition += space.getAllocIPD(); + currentIPPosition += space.getAllocIPD(); } /** @see org.apache.fop.render.Renderer */ protected void renderLeader(Leader area) { - currentBlockIPPosition += area.getAllocIPD(); + currentIPPosition += area.getAllocIPD(); } /** @see org.apache.fop.render.Renderer */ protected void renderText(TextArea text) { - currentBlockIPPosition += text.getAllocIPD(); + currentIPPosition += text.getAllocIPD(); } /** @see org.apache.fop.render.Renderer */ protected void renderInlineParent(InlineParent ip) { - int saveIP = currentBlockIPPosition; + int saveIP = currentIPPosition; Iterator iter = ip.getChildAreas().iterator(); while (iter.hasNext()) { renderInlineArea((InlineArea) iter.next()); } - currentBlockIPPosition = saveIP + ip.getAllocIPD(); + currentIPPosition = saveIP + ip.getAllocIPD(); } /** @see org.apache.fop.render.Renderer */ @@ -621,7 +618,7 @@ public abstract class AbstractRenderer } else if (content instanceof ForeignObject) { renderForeignObject((ForeignObject) content, contpos); } - currentBlockIPPosition += viewport.getAllocIPD(); + currentIPPosition += viewport.getAllocIPD(); currentBPPosition = saveBP; } @@ -640,14 +637,11 @@ public abstract class AbstractRenderer /** @see org.apache.fop.render.Renderer */ public void renderContainer(Container cont) { int saveIP = currentIPPosition; - currentIPPosition = currentBlockIPPosition; - int saveBlockIP = currentBlockIPPosition; int saveBP = currentBPPosition; List blocks = cont.getBlocks(); renderBlocks(null, blocks); currentIPPosition = saveIP; - currentBlockIPPosition = saveBlockIP; currentBPPosition = saveBP; } diff --git a/src/java/org/apache/fop/render/awt/AWTRenderer.java b/src/java/org/apache/fop/render/awt/AWTRenderer.java index 23fce2b3e..e6ce03acb 100644 --- a/src/java/org/apache/fop/render/awt/AWTRenderer.java +++ b/src/java/org/apache/fop/render/awt/AWTRenderer.java @@ -448,7 +448,7 @@ public class AWTRenderer extends AbstractRenderer implements Printable, Pageable graphics.setFont(new java.awt.Font("monospaced", java.awt.Font.PLAIN, 10)); - int rx = currentBlockIPPosition; + int rx = currentIPPosition; int bl = currentBPPosition + text.getOffset(); int newx = (int) (rx + 500) / 1000; @@ -459,7 +459,7 @@ public class AWTRenderer extends AbstractRenderer implements Printable, Pageable graphics.drawString(s, 220, 200); // TODO: render text decorations - currentBlockIPPosition += text.getAllocIPD(); + currentIPPosition += text.getAllocIPD(); } /** @see org.apache.fop.render.AbstractRenderer */ diff --git a/src/java/org/apache/fop/render/pdf/PDFRenderer.java b/src/java/org/apache/fop/render/pdf/PDFRenderer.java index 73407c088..25e17b201 100644 --- a/src/java/org/apache/fop/render/pdf/PDFRenderer.java +++ b/src/java/org/apache/fop/render/pdf/PDFRenderer.java @@ -889,7 +889,7 @@ public class PDFRenderer extends PrintRenderer { * @param ip the inline parent area */ public void renderInlineParent(InlineParent ip) { - float start = (currentBlockIPPosition + ipMarginOffset) / 1000f; + float start = (currentIPPosition + ipMarginOffset) / 1000f; float top = (ip.getOffset() + currentBPPosition + bpMarginOffset) / 1000f; float width = ip.getIPD() / 1000f; float height = ip.getBPD() / 1000f; @@ -956,7 +956,7 @@ public class PDFRenderer extends PrintRenderer { // word.getOffset() = only height of text itself // currentBlockIPPosition: 0 for beginning of line; nonzero // where previous line area failed to take up entire allocated space - int rx = currentBlockIPPosition + ipMarginOffset; + int rx = currentIPPosition + ipMarginOffset; int bl = currentBPPosition + bpMarginOffset + ch.getOffset(); /* System.out.println("Text = " + ch.getTextArea() + @@ -1027,7 +1027,7 @@ public class PDFRenderer extends PrintRenderer { // word.getOffset() = only height of text itself // currentBlockIPPosition: 0 for beginning of line; nonzero // where previous line area failed to take up entire allocated space - int rx = currentBlockIPPosition + ipMarginOffset; + int rx = currentIPPosition + ipMarginOffset; int bl = currentBPPosition + bpMarginOffset + text.getOffset(); /* System.out.println("Text = " + text.getTextArea() + @@ -1283,7 +1283,7 @@ public class PDFRenderer extends PrintRenderer { saveGraphicsState(); currentStream.add(((float) w) + " 0 0 " + ((float) -h) + " " - + (((float) currentBlockIPPosition + ipMarginOffset) / 1000f + x) + " " + + (((float) currentIPPosition + ipMarginOffset) / 1000f + x) + " " + (((float)(currentBPPosition + bpMarginOffset + 1000 * h)) / 1000f + y) + " cm\n" + "/Im" + xobj + " Do\n"); restoreGraphicsState(); @@ -1318,7 +1318,7 @@ public class PDFRenderer extends PrintRenderer { context.setProperty(PDFXMLHandler.PDF_CONTEXT, currentContext); context.setProperty(PDFXMLHandler.PDF_STREAM, currentStream); context.setProperty(PDFXMLHandler.PDF_XPOS, - new Integer(currentBlockIPPosition + (int) pos.getX())); + new Integer(currentIPPosition + (int) pos.getX())); context.setProperty(PDFXMLHandler.PDF_YPOS, new Integer(currentBPPosition + (int) pos.getY())); context.setProperty(PDFXMLHandler.PDF_FONT_INFO, fontInfo); @@ -1341,7 +1341,7 @@ public class PDFRenderer extends PrintRenderer { public void renderViewport(Viewport viewport) { closeText(); - float x = currentBlockIPPosition / 1000f; + float x = currentIPPosition / 1000f; float y = (currentBPPosition + viewport.getOffset()) / 1000f; float width = viewport.getIPD() / 1000f; float height = viewport.getBPD() / 1000f; @@ -1389,9 +1389,9 @@ public class PDFRenderer extends PrintRenderer { alt = true; break; } - float startx = ((float) currentBlockIPPosition) / 1000f; + float startx = ((float) currentIPPosition) / 1000f; float starty = ((currentBPPosition + area.getOffset()) / 1000f); - float endx = (currentBlockIPPosition + area.getIPD()) / 1000f; + float endx = (currentIPPosition + area.getIPD()) / 1000f; if (!alt) { currentStream.add(area.getRuleThickness() / 1000f + " w\n"); drawLine(startx, starty, endx, starty); diff --git a/src/java/org/apache/fop/render/ps/PSRenderer.java b/src/java/org/apache/fop/render/ps/PSRenderer.java index 4d5cd074b..88d313f06 100644 --- a/src/java/org/apache/fop/render/ps/PSRenderer.java +++ b/src/java/org/apache/fop/render/ps/PSRenderer.java @@ -452,7 +452,7 @@ public class PSRenderer extends AbstractRenderer { Typeface f = (Typeface) fontInfo.getFonts().get(fontname); //Determine position - int rx = currentBlockIPPosition; + int rx = currentIPPosition; int bl = currentBPPosition + area.getOffset(); useFont(fontname, fontsize); @@ -830,7 +830,7 @@ public class PSRenderer extends AbstractRenderer { context.setProperty(PSXMLHandler.PS_HEIGHT, new Integer((int) pos.getHeight())); context.setProperty(PSXMLHandler.PS_XPOS, - new Integer(currentBlockIPPosition + (int) pos.getX())); + new Integer(currentIPPosition + (int) pos.getX())); context.setProperty(PSXMLHandler.PS_YPOS, new Integer(currentBPPosition + (int) pos.getY())); //context.setProperty("strokeSVGText", options.get("strokeSVGText")); diff --git a/src/java/org/apache/fop/render/svg/SVGRenderer.java b/src/java/org/apache/fop/render/svg/SVGRenderer.java index b10c6b902..8d3db34f3 100644 --- a/src/java/org/apache/fop/render/svg/SVGRenderer.java +++ b/src/java/org/apache/fop/render/svg/SVGRenderer.java @@ -337,8 +337,7 @@ public class SVGRenderer extends AbstractRenderer implements XMLHandler { Element view = svgDocument.createElementNS(SVG_NAMESPACE, "svg"); Node newsvg = svgDocument.importNode(svg, true); //view.setAttributeNS(null, "viewBox", "0 0 "); - view.setAttributeNS(null, "x", - "" + currentBlockIPPosition / 1000f); + view.setAttributeNS(null, "x", "" + currentIPPosition / 1000f); view.setAttributeNS(null, "y", "" + currentBPPosition / 1000f); // this fixes a problem where the xmlns is repeated sometimes @@ -377,10 +376,10 @@ public class SVGRenderer extends AbstractRenderer implements XMLHandler { break; } Element line = SVGUtilities.createLine(svgDocument, - currentBlockIPPosition / 1000, + currentIPPosition / 1000, (currentBPPosition + area.getOffset() - area.getRuleThickness() / 2) / 1000, - (currentBlockIPPosition + area.getIPD()) / 1000, + (currentIPPosition + area.getIPD()) / 1000, (currentBPPosition + area.getOffset() - area.getRuleThickness() / 2) / 1000); line.setAttributeNS(null, "style", style); @@ -394,7 +393,7 @@ public class SVGRenderer extends AbstractRenderer implements XMLHandler { */ public void renderText(TextArea text) { Element textElement = SVGUtilities.createText(svgDocument, - currentBlockIPPosition / 1000, + currentIPPosition / 1000, (currentBPPosition + text.getOffset()) / 1000, text.getTextArea()); currentPageG.appendChild(textElement); @@ -407,7 +406,7 @@ public class SVGRenderer extends AbstractRenderer implements XMLHandler { */ public void renderCharacter(org.apache.fop.area.inline.Character ch) { Element text = SVGUtilities.createText(svgDocument, - currentBlockIPPosition / 1000, + currentIPPosition / 1000, (currentBPPosition + ch.getOffset()) / 1000, "" + ch.getChar()); currentPageG.appendChild(text); -- 2.39.5