svn commit: r1808735 - /xmlgraphics/fop-pdf-images/trunk/src/java/org/apache/fop/render/pdf/pdfbox/PSPDFGraphics2D.java
[email protected] Mon, 18 Sep 2017 15:43:30 -0000
Newsgroups
gmane.text.xml.fop.cvs
Message-ID
<[email protected] >
Author: ssteiner
Date: Mon Sep 18 15:43:30 2017
New Revision: 1808735
URL: http://svn.apache.org/viewvc?rev=1808735&view=rev
Log:
FOP-2739: Avoid rastering PDF with Smask to image
Modified:
xmlgraphics/fop-pdf-images/trunk/src/java/org/apache/fop/render/pdf/pdfbox/PSPDFGraphics2D.java
Modified: xmlgraphics/fop-pdf-images/trunk/src/java/org/apache/fop/render/pdf/pdfbox/PSPDFGraphics2D.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop-pdf-images/trunk/src/java/org/apache/fop/render/pdf/pdfbox/PSPDFGraphics2D.java?rev=1808735&r1=1808734&r2=1808735&view=diff
==============================================================================
--- xmlgraphics/fop-pdf-images/trunk/src/java/org/apache/fop/render/pdf/pdfbox/PSPDFGraphics2D.java (original)
+++ xmlgraphics/fop-pdf-images/trunk/src/java/org/apache/fop/render/pdf/pdfbox/PSPDFGraphics2D.java Mon Sep 18 15:43:30 2017
@@ -41,6 +41,8 @@ import java.io.DataOutputStream;
import java.io.IOException;
import java.lang.reflect.Field;
import java.net.URI;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -152,24 +154,30 @@ public class PSPDFGraphics2D extends PSG
}
}
} else if (paint.getClass().getSimpleName().equals("TilingPaint")) {
- try {
- Field f = paint.getClass().getDeclaredField("paint");
- f.setAccessible(true);
- TexturePaint texturePaint = (TexturePaint) f.get(paint);
- f = paint.getClass().getDeclaredField("patternMatrix");
- f.setAccessible(true);
- Matrix matrix = (Matrix) f.get(paint);
- Rectangle2D rect = getTransformedRect(matrix, texturePaint.getAnchorRect());
- texturePaint = new TexturePaint(texturePaint.getImage(), rect);
- super.applyPaint(texturePaint, fill);
- } catch (NoSuchFieldException e) {
- throw new RuntimeException(e);
- } catch (IllegalAccessException e) {
- throw new RuntimeException(e);
- }
+ TexturePaint texturePaint = (TexturePaint) getField(paint, "paint");
+ Matrix matrix = (Matrix) getField(paint, "patternMatrix");
+ Rectangle2D rect = getTransformedRect(matrix, texturePaint.getAnchorRect());
+ texturePaint = new TexturePaint(texturePaint.getImage(), rect);
+ super.applyPaint(texturePaint, fill);
}
}
+ private static Object getField(final Paint paint, final String field) {
+ return AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
+ try {
+ Field f = paint.getClass().getDeclaredField(field);
+ f.setAccessible(true);
+ return f.get(paint);
+ } catch (NoSuchFieldException e) {
+ throw new RuntimeException(e);
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ });
+ }
+
private static Rectangle2D getTransformedRect(Matrix matrix, Rectangle2D anchorRect) {
double x = anchorRect.getX();
double y = anchorRect.getY();