aboutsummaryrefslogtreecommitdiffstats
path: root/fop-core/src
diff options
context:
space:
mode:
authorSimon Steiner <ssteiner@apache.org>2021-10-26 12:13:04 +0000
committerSimon Steiner <ssteiner@apache.org>2021-10-26 12:13:04 +0000
commit69b7c5ffcc683fa0462a3284a352af07caa59362 (patch)
treef36f52b9ce57576857d768f5caaa3a1e66f3acd6 /fop-core/src
parent1d69d983df29dd46aa85abbe831d146dc7cece32 (diff)
downloadxmlgraphics-fop-69b7c5ffcc683fa0462a3284a352af07caa59362.tar.gz
xmlgraphics-fop-69b7c5ffcc683fa0462a3284a352af07caa59362.zip
FOP-3032: Allow to embed native PDF in AFP
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1894579 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'fop-core/src')
-rw-r--r--fop-core/src/main/java/org/apache/fop/render/afp/AFPImageHandlerRawStream.java10
-rw-r--r--fop-core/src/test/java/org/apache/fop/render/afp/AFPImageHandlerRawStreamTestCase.java43
2 files changed, 50 insertions, 3 deletions
diff --git a/fop-core/src/main/java/org/apache/fop/render/afp/AFPImageHandlerRawStream.java b/fop-core/src/main/java/org/apache/fop/render/afp/AFPImageHandlerRawStream.java
index f32f7305b..36e5a9db2 100644
--- a/fop-core/src/main/java/org/apache/fop/render/afp/AFPImageHandlerRawStream.java
+++ b/fop-core/src/main/java/org/apache/fop/render/afp/AFPImageHandlerRawStream.java
@@ -44,6 +44,7 @@ public class AFPImageHandlerRawStream extends AbstractAFPImageHandlerRawStream {
ImageFlavor.RAW_JPEG,
ImageFlavor.RAW_TIFF,
ImageFlavor.RAW_EPS,
+ ImageFlavor.RAW
};
/** logging instance */
@@ -89,10 +90,13 @@ public class AFPImageHandlerRawStream extends AbstractAFPImageHandlerRawStream {
&& (image == null
|| image instanceof ImageRawJPEG
|| image instanceof ImageRawEPS
- || ((image instanceof ImageRawStream)
- && (MimeConstants.MIME_TIFF.equals(
- ((ImageRawStream)image).getMimeType()))));
+ || (image instanceof ImageRawStream && isCompatible((ImageRawStream)image)));
}
return false;
}
+
+ private boolean isCompatible(ImageRawStream rawStream) {
+ return MimeConstants.MIME_TIFF.equals(rawStream.getMimeType())
+ || MimeConstants.MIME_PDF.equals(rawStream.getMimeType());
+ }
}
diff --git a/fop-core/src/test/java/org/apache/fop/render/afp/AFPImageHandlerRawStreamTestCase.java b/fop-core/src/test/java/org/apache/fop/render/afp/AFPImageHandlerRawStreamTestCase.java
new file mode 100644
index 000000000..9a9ea8558
--- /dev/null
+++ b/fop-core/src/test/java/org/apache/fop/render/afp/AFPImageHandlerRawStreamTestCase.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+package org.apache.fop.render.afp;
+
+import java.io.InputStream;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import org.apache.xmlgraphics.image.loader.ImageFlavor;
+import org.apache.xmlgraphics.image.loader.MimeEnabledImageFlavor;
+import org.apache.xmlgraphics.image.loader.impl.ImageRawStream;
+
+import org.apache.fop.afp.AFPPaintingState;
+import org.apache.fop.apps.MimeConstants;
+
+public class AFPImageHandlerRawStreamTestCase {
+ @Test
+ public void testIsCompatible() {
+ AFPPaintingState state = new AFPPaintingState();
+ state.setNativeImagesSupported(true);
+ AFPRenderingContext context = new AFPRenderingContext(null, null, state, null, null);
+ MimeEnabledImageFlavor flavor = new MimeEnabledImageFlavor(ImageFlavor.RAW, MimeConstants.MIME_PDF);
+ ImageRawStream stream = new ImageRawStream(null, flavor, (InputStream) null);
+ Assert.assertTrue(new AFPImageHandlerRawStream().isCompatible(context, stream));
+ }
+}