diff options
Diffstat (limited to 'src')
18 files changed, 124 insertions, 85 deletions
diff --git a/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java b/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java index 8da4b3973..54f6170db 100644 --- a/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java +++ b/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java @@ -834,10 +834,8 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { * @param url the URI/URL of the image * @param pos the position of the image * @param foreignAttributes an optional Map with foreign attributes, may be null - * @param ptr used for accessibility */ - protected abstract void drawImage(String url, Rectangle2D pos, Map foreignAttributes, - String ptr); + protected abstract void drawImage(String url, Rectangle2D pos, Map foreignAttributes); /** * Draw an image at the indicated location. @@ -845,7 +843,7 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer { * @param pos the position of the image */ protected final void drawImage(String url, Rectangle2D pos) { - drawImage(url, pos, null, ""); + drawImage(url, pos, null); } /** diff --git a/src/java/org/apache/fop/render/AbstractRenderer.java b/src/java/org/apache/fop/render/AbstractRenderer.java index 8f60ace2f..ed7682221 100644 --- a/src/java/org/apache/fop/render/AbstractRenderer.java +++ b/src/java/org/apache/fop/render/AbstractRenderer.java @@ -738,13 +738,11 @@ public abstract class AbstractRenderer currentBPPosition += viewport.getOffset(); Rectangle2D contpos = viewport.getContentPosition(); if (content instanceof Image) { - String ptr = (String) viewport.getTrait(Trait.PTR); - renderImage((Image) content, contpos, ptr); + renderImage((Image) content, contpos); } else if (content instanceof Container) { renderContainer((Container) content); } else if (content instanceof ForeignObject) { - String ptr = (String) viewport.getTrait(Trait.PTR); - renderForeignObject((ForeignObject) content, contpos, ptr); + renderForeignObject((ForeignObject) content, contpos); } else if (content instanceof InlineBlockParent) { renderInlineBlockParent((InlineBlockParent) content); } @@ -757,10 +755,9 @@ public abstract class AbstractRenderer * * @param image The image * @param pos The target position of the image - * @param ptr used for accessibility * (todo) Make renderImage() protected */ - public void renderImage(Image image, Rectangle2D pos, String ptr) { + public void renderImage(Image image, Rectangle2D pos) { // Default: do nothing. // Some renderers (ex. Text) don't support images. } @@ -784,10 +781,9 @@ public abstract class AbstractRenderer * * @param fo The foreign object area * @param pos The target position of the foreign object - * @param ptr used for accessibility * (todo) Make renderForeignObject() protected */ - protected void renderForeignObject(ForeignObject fo, Rectangle2D pos, String ptr) { + protected void renderForeignObject(ForeignObject fo, Rectangle2D pos) { // Default: do nothing. // Some renderers (ex. Text) don't support foreign objects. } diff --git a/src/java/org/apache/fop/render/afp/AFPPainter.java b/src/java/org/apache/fop/render/afp/AFPPainter.java index 3efe5cbb4..a92be9d6e 100644 --- a/src/java/org/apache/fop/render/afp/AFPPainter.java +++ b/src/java/org/apache/fop/render/afp/AFPPainter.java @@ -184,7 +184,7 @@ public class AFPPainter extends AbstractIFPainter { } /** {@inheritDoc} */ - public void drawImage(String uri, Rectangle rect, String ptr) throws IFException { + public void drawImage(String uri, Rectangle rect) throws IFException { String name = documentHandler.getPageSegmentNameFor(uri); if (name != null) { float[] srcPts = {rect.x, rect.y}; @@ -196,7 +196,7 @@ public class AFPPainter extends AbstractIFPainter { } /** {@inheritDoc} */ - public void drawImage(Document doc, Rectangle rect, String ptr) throws IFException { + public void drawImage(Document doc, Rectangle rect) throws IFException { drawImageUsingDocument(doc, rect); } @@ -313,7 +313,7 @@ public class AFPPainter extends AbstractIFPainter { /** {@inheritDoc} */ public void drawText(int x, int y, final int letterSpacing, final int wordSpacing, final int[] dx, - final String text, final String ptr) throws IFException { + final String text) throws IFException { final int fontSize = this.state.getFontSize(); getPaintingState().setFontSize(fontSize); diff --git a/src/java/org/apache/fop/render/afp/AFPRenderer.java b/src/java/org/apache/fop/render/afp/AFPRenderer.java index 7e34d361c..94fd05dc8 100644 --- a/src/java/org/apache/fop/render/afp/AFPRenderer.java +++ b/src/java/org/apache/fop/render/afp/AFPRenderer.java @@ -395,7 +395,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer implements AFPCust ImageFlavor.GRAPHICS2D, ImageFlavor.BUFFERED_IMAGE, ImageFlavor.RENDERED_IMAGE }; /** {@inheritDoc} */ - public void drawImage(String uri, Rectangle2D pos, Map foreignAttributes, String ptr) { + public void drawImage(String uri, Rectangle2D pos, Map foreignAttributes) { uri = URISpecification.getURL(uri); paintingState.setImageUri(uri); @@ -526,7 +526,7 @@ public class AFPRenderer extends AbstractPathOrientedRenderer implements AFPCust /** {@inheritDoc} */ public void renderImage(Image image, Rectangle2D pos) { - drawImage(image.getURL(), pos, image.getForeignAttributes(),""); + drawImage(image.getURL(), pos, image.getForeignAttributes()); } /** {@inheritDoc} */ diff --git a/src/java/org/apache/fop/render/intermediate/IFContext.java b/src/java/org/apache/fop/render/intermediate/IFContext.java index b05db1369..30989d04f 100644 --- a/src/java/org/apache/fop/render/intermediate/IFContext.java +++ b/src/java/org/apache/fop/render/intermediate/IFContext.java @@ -43,6 +43,8 @@ public class IFContext { /** foreign attributes: Map<QName, Object> */ private Map foreignAttributes = Collections.EMPTY_MAP; + private String structurePointer; + /** * Main constructor. * @param ua the user agent @@ -108,4 +110,20 @@ public class IFContext { setForeignAttributes(null); } + public void setStructurePointer(String ptr) { + this.structurePointer = ptr; + } + + public void resetStructurePointer() { + setStructurePointer(null); + } + + public String getStructurePointer() { + return this.structurePointer; + } + + public boolean hasStructurePointer() { + return (this.structurePointer != null) && (structurePointer.length() > 0); + } + } diff --git a/src/java/org/apache/fop/render/intermediate/IFPainter.java b/src/java/org/apache/fop/render/intermediate/IFPainter.java index 163fe16a1..6369b0251 100644 --- a/src/java/org/apache/fop/render/intermediate/IFPainter.java +++ b/src/java/org/apache/fop/render/intermediate/IFPainter.java @@ -153,11 +153,10 @@ public interface IFPainter { * @param wordSpacing additional spacing between words (may be 0) * @param dx an array of adjustment values for each character in X-direction (may be null) * @param text the text - * @param ptr used for accessibility * @throws IFException if an error occurs while handling this event */ void drawText(int x, int y, int letterSpacing, int wordSpacing, - int[] dx, String text, String ptr) throws IFException; + int[] dx, String text) throws IFException; /** * Restricts the current clipping region with the given rectangle. @@ -206,20 +205,18 @@ public interface IFPainter { * an fo:external-graphic in XSL-FO. * @param uri the image's URI * @param rect the rectangle in which the image shall be painted - * @param ptr used for accessibility * @throws IFException if an error occurs while handling this event */ - void drawImage(String uri, Rectangle rect, String ptr) throws IFException; + void drawImage(String uri, Rectangle rect) throws IFException; /** * Draws an image (represented by a DOM document) inside a given rectangle. This is the * equivalent to an fo:instream-foreign-object in XSL-FO. * @param doc the DOM document containing the foreign object * @param rect the rectangle in which the image shall be painted - * @param ptr used for accessibility * @throws IFException if an error occurs while handling this event */ - void drawImage(Document doc, Rectangle rect, String ptr) throws IFException; + void drawImage(Document doc, Rectangle rect) throws IFException; //Note: For now, all foreign objects are handled as DOM documents. At the moment, all known //implementations use a DOM anyway, so optimizing this to work with SAX wouldn't result in //any performance benefits. The IFRenderer itself has a DOM anyway. Only the IFParser could diff --git a/src/java/org/apache/fop/render/intermediate/IFParser.java b/src/java/org/apache/fop/render/intermediate/IFParser.java index 47e24445c..5dbe6e46c 100644 --- a/src/java/org/apache/fop/render/intermediate/IFParser.java +++ b/src/java/org/apache/fop/render/intermediate/IFParser.java @@ -173,6 +173,14 @@ public class IFParser implements IFConstants { documentHandler.getContext().resetForeignAttributes(); } + private void establishStructurePointer(String ptr) { + documentHandler.getContext().setStructurePointer(ptr); + } + + private void resetStructurePointer() { + documentHandler.getContext().resetStructurePointer(); + } + /** {@inheritDoc} */ public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { @@ -482,7 +490,9 @@ public class IFParser implements IFConstants { int wordSpacing = (s != null ? Integer.parseInt(s) : 0); int[] dx = XMLUtil.getAttributeAsIntArray(lastAttributes, "dx"); String ptr = lastAttributes.getValue("ptr"); // used for accessibility - painter.drawText(x, y, letterSpacing, wordSpacing, dx, content.toString(), ptr); + establishStructurePointer(ptr); + painter.drawText(x, y, letterSpacing, wordSpacing, dx, content.toString()); + resetStructurePointer(); } public boolean ignoreCharacters() { @@ -578,9 +588,10 @@ public class IFParser implements IFConstants { Map foreignAttributes = getForeignAttributes(lastAttributes); establishForeignAttributes(foreignAttributes); String ptr = lastAttributes.getValue("ptr"); // used for accessibility + establishStructurePointer(ptr); if (foreignObject != null) { painter.drawImage(foreignObject, - new Rectangle(x, y, width, height), ptr); + new Rectangle(x, y, width, height)); foreignObject = null; } else { String uri = lastAttributes.getValue( @@ -588,9 +599,10 @@ public class IFParser implements IFConstants { if (uri == null) { throw new IFException("xlink:href is missing on image", null); } - painter.drawImage(uri, new Rectangle(x, y, width, height), ptr); + painter.drawImage(uri, new Rectangle(x, y, width, height)); } resetForeignAttributes(); + resetStructurePointer(); inForeignObject = false; } diff --git a/src/java/org/apache/fop/render/intermediate/IFRenderer.java b/src/java/org/apache/fop/render/intermediate/IFRenderer.java index 664f1324a..905277f1b 100644 --- a/src/java/org/apache/fop/render/intermediate/IFRenderer.java +++ b/src/java/org/apache/fop/render/intermediate/IFRenderer.java @@ -53,6 +53,7 @@ import org.apache.fop.Version; import org.apache.fop.apps.FOPException; import org.apache.fop.apps.MimeConstants; import org.apache.fop.area.Area; +import org.apache.fop.area.AreaTreeObject; import org.apache.fop.area.Block; import org.apache.fop.area.BlockViewport; import org.apache.fop.area.BookmarkData; @@ -500,7 +501,10 @@ public class IFRenderer extends AbstractPathOrientedRenderer { documentHandler.endDocumentHeader(); this.inPageSequence = true; } + establishForeignAttributes(pageSequence.getForeignAttributes()); documentHandler.startPageSequence(null); + resetForeignAttributes(); + processExtensionAttachments(pageSequence); } catch (IFException e) { handleIFException(e); } @@ -557,13 +561,7 @@ public class IFRenderer extends AbstractPathOrientedRenderer { documentHandler.startPageHeader(); //Add page attachments to page header - if (page.hasExtensionAttachments()) { - for (Iterator iter = page.getExtensionAttachments().iterator(); - iter.hasNext();) { - ExtensionAttachment attachment = (ExtensionAttachment) iter.next(); - this.documentHandler.handleExtensionObject(attachment); - } - } + processExtensionAttachments(page); documentHandler.endPageHeader(); this.painter = documentHandler.startPageContent(); @@ -590,6 +588,16 @@ public class IFRenderer extends AbstractPathOrientedRenderer { } } + private void processExtensionAttachments(AreaTreeObject area) throws IFException { + if (area.hasExtensionAttachments()) { + for (Iterator iter = area.getExtensionAttachments().iterator(); + iter.hasNext();) { + ExtensionAttachment attachment = (ExtensionAttachment) iter.next(); + this.documentHandler.handleExtensionObject(attachment); + } + } + } + private void establishForeignAttributes(Map foreignAttributes) { documentHandler.getContext().setForeignAttributes(foreignAttributes); } @@ -598,6 +606,14 @@ public class IFRenderer extends AbstractPathOrientedRenderer { documentHandler.getContext().resetForeignAttributes(); } + private void establishStructurePointer(String ptr) { + documentHandler.getContext().setStructurePointer(ptr); + } + + private void resetStructurePointer() { + documentHandler.getContext().resetStructurePointer(); + } + /** {@inheritDoc} */ protected void saveGraphicsState() { graphicContextStack.push(graphicContext); @@ -818,17 +834,20 @@ public class IFRenderer extends AbstractPathOrientedRenderer { currentIPPosition = saveIP; currentBPPosition = saveBP; - currentBPPosition += (bv.getAllocBPD()); + currentBPPosition += bv.getAllocBPD(); } viewportDimensionStack.pop(); } /** {@inheritDoc} */ public void renderViewport(Viewport viewport) { + String ptr = (String) viewport.getTrait(Trait.PTR); + establishStructurePointer(ptr); Dimension dim = new Dimension(viewport.getIPD(), viewport.getBPD()); viewportDimensionStack.push(dim); super.renderViewport(viewport); viewportDimensionStack.pop(); + resetStructurePointer(); } /** {@inheritDoc} */ @@ -966,6 +985,7 @@ public class IFRenderer extends AbstractPathOrientedRenderer { String fontName = getInternalFontNameForArea(text); int size = ((Integer) text.getTrait(Trait.FONT_SIZE)).intValue(); String ptr = (String)text.getTrait(Trait.PTR); // used for accessibility + establishStructurePointer(ptr); // This assumes that *all* CIDFonts use a /ToUnicode mapping Typeface tf = getTypeface(fontName); @@ -984,9 +1004,10 @@ public class IFRenderer extends AbstractPathOrientedRenderer { textUtil.setStartPosition(rx, bl); textUtil.setSpacing(text.getTextLetterSpaceAdjust(), text.getTextWordSpaceAdjust()); super.renderText(text); - textUtil.setPtr(ptr); // used for accessibility + textUtil.flush(); renderTextDecoration(tf, size, text, bl, rx); + resetStructurePointer(); } /** {@inheritDoc} */ @@ -1061,20 +1082,11 @@ public class IFRenderer extends AbstractPathOrientedRenderer { private int startx, starty; private int tls, tws; private final boolean combined = false; - private String ptr = null; // used for accessibility void addChar(char ch) { text.append(ch); } - /** - * used for accessibility - * @param inPtr to be stored - */ - public void setPtr(String inPtr) { - ptr = inPtr; - } - void adjust(int adjust) { if (adjust != 0) { int idx = text.length(); @@ -1117,9 +1129,9 @@ public class IFRenderer extends AbstractPathOrientedRenderer { System.arraycopy(dx, 0, effDX, 0, size); } if (combined) { - painter.drawText(startx, starty, 0, 0, effDX, text.toString(), ptr); + painter.drawText(startx, starty, 0, 0, effDX, text.toString()); } else { - painter.drawText(startx, starty, tls, tws, effDX, text.toString(), ptr); + painter.drawText(startx, starty, tls, tws, effDX, text.toString()); } } catch (IFException e) { handleIFException(e); @@ -1130,12 +1142,12 @@ public class IFRenderer extends AbstractPathOrientedRenderer { } /** {@inheritDoc} */ - public void renderImage(Image image, Rectangle2D pos, String ptr) { - drawImage(image.getURL(), pos, image.getForeignAttributes(), ptr); + public void renderImage(Image image, Rectangle2D pos) { + drawImage(image.getURL(), pos, image.getForeignAttributes()); } /** {@inheritDoc} */ - protected void drawImage(String uri, Rectangle2D pos, Map foreignAttributes, String ptr) { + protected void drawImage(String uri, Rectangle2D pos, Map foreignAttributes) { Rectangle posInt = new Rectangle( currentIPPosition + (int)pos.getX(), currentBPPosition + (int)pos.getY(), @@ -1144,7 +1156,7 @@ public class IFRenderer extends AbstractPathOrientedRenderer { uri = URISpecification.getURL(uri); try { establishForeignAttributes(foreignAttributes); - painter.drawImage(uri, posInt, ptr); + painter.drawImage(uri, posInt); resetForeignAttributes(); } catch (IFException ife) { handleIFException(ife); @@ -1152,7 +1164,7 @@ public class IFRenderer extends AbstractPathOrientedRenderer { } /** {@inheritDoc} */ - public void renderForeignObject(ForeignObject fo, Rectangle2D pos, String ptr) { + public void renderForeignObject(ForeignObject fo, Rectangle2D pos) { endTextObject(); Rectangle posInt = new Rectangle( currentIPPosition + (int)pos.getX(), @@ -1162,7 +1174,7 @@ public class IFRenderer extends AbstractPathOrientedRenderer { Document doc = fo.getDocument(); try { establishForeignAttributes(fo.getForeignAttributes()); - painter.drawImage(doc, posInt, ptr); + painter.drawImage(doc, posInt); resetForeignAttributes(); } catch (IFException ife) { handleIFException(ife); diff --git a/src/java/org/apache/fop/render/intermediate/IFSerializer.java b/src/java/org/apache/fop/render/intermediate/IFSerializer.java index 248492a96..2f5524c2c 100644 --- a/src/java/org/apache/fop/render/intermediate/IFSerializer.java +++ b/src/java/org/apache/fop/render/intermediate/IFSerializer.java @@ -267,7 +267,7 @@ public class IFSerializer extends AbstractXMLWritingIFDocumentHandler if (id != null) { atts.addAttribute(XML_NAMESPACE, "id", "xml:id", XMLUtil.CDATA, id); } - + addForeignAttributes(atts); handler.startElement(EL_PAGE_SEQUENCE, atts); if (this.getUserAgent().isAccessibilityEnabled()) { if (doc == null) { @@ -463,7 +463,7 @@ public class IFSerializer extends AbstractXMLWritingIFDocumentHandler } /** {@inheritDoc} */ - public void drawImage(String uri, Rectangle rect, String ptr) throws IFException { + public void drawImage(String uri, Rectangle rect) throws IFException { try { AttributesImpl atts = new AttributesImpl(); addAttribute(atts, XLINK_HREF, uri); @@ -472,6 +472,7 @@ public class IFSerializer extends AbstractXMLWritingIFDocumentHandler addAttribute(atts, "width", Integer.toString(rect.width)); addAttribute(atts, "height", Integer.toString(rect.height)); addForeignAttributes(atts); + String ptr = getContext().getStructurePointer(); if (ptr != null) { addAttribute(atts, "ptr", ptr); // used for accessibility } @@ -493,7 +494,7 @@ public class IFSerializer extends AbstractXMLWritingIFDocumentHandler } /** {@inheritDoc} */ - public void drawImage(Document doc, Rectangle rect, String ptr) throws IFException { + public void drawImage(Document doc, Rectangle rect) throws IFException { try { AttributesImpl atts = new AttributesImpl(); addAttribute(atts, "x", Integer.toString(rect.x)); @@ -501,6 +502,7 @@ public class IFSerializer extends AbstractXMLWritingIFDocumentHandler addAttribute(atts, "width", Integer.toString(rect.width)); addAttribute(atts, "height", Integer.toString(rect.height)); addForeignAttributes(atts); + String ptr = getContext().getStructurePointer(); if (ptr != null) { addAttribute(atts, "ptr", ptr); // used for accessibility } @@ -602,7 +604,7 @@ public class IFSerializer extends AbstractXMLWritingIFDocumentHandler /** {@inheritDoc} */ public void drawText(int x, int y, int letterSpacing, int wordSpacing, - int[] dx, String text, String ptr) throws IFException { + int[] dx, String text) throws IFException { try { AttributesImpl atts = new AttributesImpl(); XMLUtil.addAttribute(atts, XMLConstants.XML_SPACE, "preserve"); @@ -617,6 +619,7 @@ public class IFSerializer extends AbstractXMLWritingIFDocumentHandler if (dx != null) { addAttribute(atts, "dx", IFUtil.toString(dx)); } + String ptr = getContext().getStructurePointer(); if (ptr != null) { addAttribute(atts, "ptr", ptr); // used for accessibility } diff --git a/src/java/org/apache/fop/render/java2d/Java2DPainter.java b/src/java/org/apache/fop/render/java2d/Java2DPainter.java index da3108973..55c5b8015 100644 --- a/src/java/org/apache/fop/render/java2d/Java2DPainter.java +++ b/src/java/org/apache/fop/render/java2d/Java2DPainter.java @@ -156,7 +156,7 @@ public class Java2DPainter extends AbstractIFPainter { } /** {@inheritDoc} */ - public void drawImage(String uri, Rectangle rect, String ptr) throws IFException { + public void drawImage(String uri, Rectangle rect) throws IFException { drawImageUsingURI(uri, rect); } @@ -168,7 +168,7 @@ public class Java2DPainter extends AbstractIFPainter { } /** {@inheritDoc} */ - public void drawImage(Document doc, Rectangle rect, String ptr) throws IFException { + public void drawImage(Document doc, Rectangle rect) throws IFException { drawImageUsingDocument(doc, rect); } @@ -208,7 +208,7 @@ public class Java2DPainter extends AbstractIFPainter { } /** {@inheritDoc} */ - public void drawText(int x, int y, int letterSpacing, int wordSpacing, int[] dx, String text, String ptr) + public void drawText(int x, int y, int letterSpacing, int wordSpacing, int[] dx, String text) throws IFException { g2dState.updateColor(state.getTextColor()); FontTriplet triplet = new FontTriplet( diff --git a/src/java/org/apache/fop/render/java2d/Java2DRenderer.java b/src/java/org/apache/fop/render/java2d/Java2DRenderer.java index 74c709278..933398125 100644 --- a/src/java/org/apache/fop/render/java2d/Java2DRenderer.java +++ b/src/java/org/apache/fop/render/java2d/Java2DRenderer.java @@ -875,7 +875,7 @@ public abstract class Java2DRenderer extends AbstractPathOrientedRenderer implem ImageFlavor.XML_DOM}; /** {@inheritDoc} */ - protected void drawImage(String uri, Rectangle2D pos, Map foreignAttributes, String ptr) { + protected void drawImage(String uri, Rectangle2D pos, Map foreignAttributes) { int x = currentIPPosition + (int)Math.round(pos.getX()); int y = currentBPPosition + (int)Math.round(pos.getY()); diff --git a/src/java/org/apache/fop/render/pcl/PCLPainter.java b/src/java/org/apache/fop/render/pcl/PCLPainter.java index 57810fb38..da4f6a656 100644 --- a/src/java/org/apache/fop/render/pcl/PCLPainter.java +++ b/src/java/org/apache/fop/render/pcl/PCLPainter.java @@ -154,7 +154,7 @@ public class PCLPainter extends AbstractIFPainter implements PCLConstants { } /** {@inheritDoc} */ - public void drawImage(String uri, Rectangle rect, String ptr) throws IFException { + public void drawImage(String uri, Rectangle rect) throws IFException { drawImageUsingURI(uri, rect); } @@ -176,7 +176,7 @@ public class PCLPainter extends AbstractIFPainter implements PCLConstants { } /** {@inheritDoc} */ - public void drawImage(Document doc, Rectangle rect, String ptr) throws IFException { + public void drawImage(Document doc, Rectangle rect) throws IFException { drawImageUsingDocument(doc, rect); } @@ -312,9 +312,8 @@ public class PCLPainter extends AbstractIFPainter implements PCLConstants { } /** {@inheritDoc} */ - public void drawText(int x, int y, int letterSpacing, int wordSpacing, int[] dx, String text, String ptr) + public void drawText(int x, int y, int letterSpacing, int wordSpacing, int[] dx, String text) throws IFException { - //Note: ptr is ignored as it is only needed for accessibility try { FontTriplet triplet = new FontTriplet( state.getFontFamily(), state.getFontStyle(), state.getFontWeight()); @@ -475,7 +474,7 @@ public class PCLPainter extends AbstractIFPainter implements PCLConstants { Java2DPainter painter = new Java2DPainter(g2d, getContext(), parent.getFontInfo(), state); try { - painter.drawText(x, y, letterSpacing, wordSpacing, dx, text, ""); + painter.drawText(x, y, letterSpacing, wordSpacing, dx, text); } catch (IFException e) { //This should never happen with the Java2DPainter throw new RuntimeException("Unexpected error while painting text", e); diff --git a/src/java/org/apache/fop/render/pdf/PDFPainter.java b/src/java/org/apache/fop/render/pdf/PDFPainter.java index 3fdfccd2e..3ab32114c 100644 --- a/src/java/org/apache/fop/render/pdf/PDFPainter.java +++ b/src/java/org/apache/fop/render/pdf/PDFPainter.java @@ -129,11 +129,12 @@ public class PDFPainter extends AbstractIFPainter { } /** {@inheritDoc} */ - public void drawImage(String uri, Rectangle rect, String ptr) + public void drawImage(String uri, Rectangle rect) throws IFException { PDFXObject xobject = getPDFDoc().getXObject(uri); if (xobject != null) { - if (accessEnabled && ptr.length() > 0) { + if (accessEnabled && getContext().hasStructurePointer()) { + String ptr = getContext().getStructurePointer(); mcid = this.documentHandler.getMCID(); mcid++; // fix for Acro Checker this.documentHandler.incMCID(); // simulating a parent text element @@ -152,7 +153,8 @@ public class PDFPainter extends AbstractIFPainter { } return; } - if (accessEnabled && ptr.length() > 0) { + if (accessEnabled && getContext().hasStructurePointer()) { + String ptr = getContext().getStructurePointer(); mcid = this.documentHandler.getMCID(); mcid++; // fix for Acro Checker this.documentHandler.incMCID(); // simulating a parent text element @@ -221,8 +223,9 @@ public class PDFPainter extends AbstractIFPainter { } /** {@inheritDoc} */ - public void drawImage(Document doc, Rectangle rect, String ptr) throws IFException { - if (accessEnabled && ptr.length() > 0) { + public void drawImage(Document doc, Rectangle rect) throws IFException { + if (accessEnabled && getContext().hasStructurePointer()) { + String ptr = getContext().getStructurePointer(); mcid = this.documentHandler.getMCID(); mcid++; // fix for Acro Checker this.documentHandler.incMCID(); // simulating a parent text element @@ -330,9 +333,10 @@ public class PDFPainter extends AbstractIFPainter { /** {@inheritDoc} */ public void drawText(int x, int y, int letterSpacing, int wordSpacing, int[] dx, - String text, String ptr) + String text) throws IFException { - if (accessEnabled ) { + if (accessEnabled) { + String ptr = getContext().getStructurePointer(); int mcId; String structElType = ""; if (ptr != null && ptr.length() > 0) { diff --git a/src/java/org/apache/fop/render/pdf/PDFRenderer.java b/src/java/org/apache/fop/render/pdf/PDFRenderer.java index c6b4d4977..2c166f679 100644 --- a/src/java/org/apache/fop/render/pdf/PDFRenderer.java +++ b/src/java/org/apache/fop/render/pdf/PDFRenderer.java @@ -1074,7 +1074,7 @@ public class PDFRenderer extends AbstractPathOrientedRenderer implements PDFConf } /** {@inheritDoc} */ - protected void drawImage(String url, Rectangle2D pos, Map foreignAttributes, String ptr) { + protected void drawImage(String url, Rectangle2D pos, Map foreignAttributes) { endTextObject(); putImage(url, pos, foreignAttributes); } diff --git a/src/java/org/apache/fop/render/ps/PSPainter.java b/src/java/org/apache/fop/render/ps/PSPainter.java index 807bf50b4..cb88f4670 100644 --- a/src/java/org/apache/fop/render/ps/PSPainter.java +++ b/src/java/org/apache/fop/render/ps/PSPainter.java @@ -176,7 +176,7 @@ public class PSPainter extends AbstractIFPainter { } /** {@inheritDoc} */ - public void drawImage(String uri, Rectangle rect, String ptr) throws IFException { + public void drawImage(String uri, Rectangle rect) throws IFException { try { endTextObject(); } catch (IOException ioe) { @@ -186,7 +186,7 @@ public class PSPainter extends AbstractIFPainter { } /** {@inheritDoc} */ - public void drawImage(Document doc, Rectangle rect, String ptr) throws IFException { + public void drawImage(Document doc, Rectangle rect) throws IFException { try { endTextObject(); } catch (IOException ioe) { @@ -338,7 +338,7 @@ public class PSPainter extends AbstractIFPainter { /** {@inheritDoc} */ public void drawText(int x, int y, int letterSpacing, int wordSpacing, - int[] dx, String text, String ptr) throws IFException { + int[] dx, String text) throws IFException { try { //Note: dy is currently ignored PSGenerator generator = getGenerator(); diff --git a/src/java/org/apache/fop/render/ps/PSRenderer.java b/src/java/org/apache/fop/render/ps/PSRenderer.java index 5b918156b..19fcd8af8 100644 --- a/src/java/org/apache/fop/render/ps/PSRenderer.java +++ b/src/java/org/apache/fop/render/ps/PSRenderer.java @@ -345,7 +345,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer } /** {@inheritDoc} */ - protected void drawImage(String uri, Rectangle2D pos, Map foreignAttributes, String ptr) { + protected void drawImage(String uri, Rectangle2D pos, Map foreignAttributes) { endTextObject(); int x = currentIPPosition + (int)Math.round(pos.getX()); int y = currentBPPosition + (int)Math.round(pos.getY()); @@ -1233,7 +1233,7 @@ public class PSRenderer extends AbstractPathOrientedRenderer * {@inheritDoc} */ public void renderImage(Image image, Rectangle2D pos) { - drawImage(image.getURL(), pos, image.getForeignAttributes(), ""); + drawImage(image.getURL(), pos, image.getForeignAttributes()); } /** diff --git a/src/java/org/apache/fop/render/txt/TXTRenderer.java b/src/java/org/apache/fop/render/txt/TXTRenderer.java index 2170a67d2..3e2fab230 100644 --- a/src/java/org/apache/fop/render/txt/TXTRenderer.java +++ b/src/java/org/apache/fop/render/txt/TXTRenderer.java @@ -28,6 +28,8 @@ import java.io.OutputStream; import java.util.List; import java.util.Map; +import org.apache.xmlgraphics.util.UnitConv; + import org.apache.fop.apps.FOPException; import org.apache.fop.area.Area; import org.apache.fop.area.CTM; @@ -37,7 +39,6 @@ import org.apache.fop.area.inline.TextArea; import org.apache.fop.render.AbstractPathOrientedRenderer; import org.apache.fop.render.txt.border.AbstractBorderElement; import org.apache.fop.render.txt.border.BorderManager; -import org.apache.xmlgraphics.util.UnitConv; /** * Renderer that renders areas to plain text. @@ -443,7 +444,7 @@ public class TXTRenderer extends AbstractPathOrientedRenderer { } /** {@inheritDoc} */ - protected void drawImage(String url, Rectangle2D pos, Map foreignAttributes, String ptr) { + protected void drawImage(String url, Rectangle2D pos, Map foreignAttributes) { //No images are painted here } diff --git a/src/sandbox/org/apache/fop/render/svg/SVGPainter.java b/src/sandbox/org/apache/fop/render/svg/SVGPainter.java index cb0547391..c31190eba 100644 --- a/src/sandbox/org/apache/fop/render/svg/SVGPainter.java +++ b/src/sandbox/org/apache/fop/render/svg/SVGPainter.java @@ -193,7 +193,7 @@ public class SVGPainter extends AbstractIFPainter implements SVGConstants { } /** {@inheritDoc} */ - public void drawImage(String uri, Rectangle rect, String ptr) throws IFException { + public void drawImage(String uri, Rectangle rect) throws IFException { try { establish(MODE_NORMAL); @@ -243,7 +243,7 @@ public class SVGPainter extends AbstractIFPainter implements SVGConstants { } /** {@inheritDoc} */ - public void drawImage(Document doc, Rectangle rect, String ptr) throws IFException { + public void drawImage(Document doc, Rectangle rect) throws IFException { try { establish(MODE_NORMAL); @@ -326,9 +326,8 @@ public class SVGPainter extends AbstractIFPainter implements SVGConstants { /** {@inheritDoc} */ - public void drawText(int x, int y, int letterSpacing, int wordSpacing, int[] dx, - String text, String ptr) throws IFException { - //Note: ptr is ignored as it is only needed for accessibility + public void drawText(int x, int y, int letterSpacing, int wordSpacing, int[] dx, + String text) throws IFException { try { establish(MODE_TEXT); AttributesImpl atts = new AttributesImpl(); |