From e7daec61ada474e3d6f049dd2acd467549226e03 Mon Sep 17 00:00:00 2001 From: Simon Steiner Date: Thu, 4 Jul 2019 13:48:41 +0000 Subject: [PATCH] FOP-2762: Serialisation issues with accessibility and conserve-memory git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1862557 13f79535-47bb-0310-9956-ffa450edef68 --- fop-core/src/main/java/org/apache/fop/pdf/PDFName.java | 4 +++- .../src/main/java/org/apache/fop/pdf/PDFStructElem.java | 8 ++++++-- .../java/org/apache/fop/pdf/StandardStructureTypes.java | 4 +++- .../org/apache/fop/render/pdf/PageSequenceStructElem.java | 1 + .../java/org/apache/fop/render/pdf/TableStructElem.java | 1 + .../org/apache/fop/render/ConserveMemoryTestCase.java | 1 + 6 files changed, 15 insertions(+), 4 deletions(-) diff --git a/fop-core/src/main/java/org/apache/fop/pdf/PDFName.java b/fop-core/src/main/java/org/apache/fop/pdf/PDFName.java index 23294cc54..444a8ce3e 100644 --- a/fop-core/src/main/java/org/apache/fop/pdf/PDFName.java +++ b/fop-core/src/main/java/org/apache/fop/pdf/PDFName.java @@ -21,14 +21,16 @@ package org.apache.fop.pdf; import java.io.IOException; import java.io.OutputStream; +import java.io.Serializable; import org.apache.commons.io.output.CountingOutputStream; /** * Class representing a PDF name object. */ -public class PDFName extends PDFObject { +public class PDFName extends PDFObject implements Serializable { + private static final long serialVersionUID = -968412396459739925L; private String name; /** diff --git a/fop-core/src/main/java/org/apache/fop/pdf/PDFStructElem.java b/fop-core/src/main/java/org/apache/fop/pdf/PDFStructElem.java index 19864f6e3..603402ac2 100644 --- a/fop-core/src/main/java/org/apache/fop/pdf/PDFStructElem.java +++ b/fop-core/src/main/java/org/apache/fop/pdf/PDFStructElem.java @@ -22,6 +22,7 @@ package org.apache.fop.pdf; import java.io.IOException; import java.io.OutputStream; +import java.io.Serializable; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -35,8 +36,9 @@ import org.apache.fop.util.LanguageTags; * Class representing a PDF Structure Element. */ public class PDFStructElem extends StructureHierarchyMember - implements StructureTreeElement, CompressedObject { + implements StructureTreeElement, CompressedObject, Serializable { + private static final long serialVersionUID = -3055241807589202532L; private StructureType structureType; protected PDFStructElem parentElement; @@ -246,7 +248,7 @@ public class PDFStructElem extends StructureHierarchyMember } public int output(OutputStream stream) throws IOException { - if (getDocument().getProfile().getPDFUAMode().isEnabled()) { + if (getDocument() != null && getDocument().getProfile().getPDFUAMode().isEnabled()) { if (entries.containsKey("Alt") && "".equals(get("Alt"))) { put("Alt", "No alternate text specified"); } else if (kids != null) { @@ -275,6 +277,8 @@ public class PDFStructElem extends StructureHierarchyMember */ public static class Placeholder extends PDFStructElem { + private static final long serialVersionUID = -2397980642558372068L; + @Override public void outputInline(OutputStream out, StringBuilder textBuffer) throws IOException { if (kids != null) { diff --git a/fop-core/src/main/java/org/apache/fop/pdf/StandardStructureTypes.java b/fop-core/src/main/java/org/apache/fop/pdf/StandardStructureTypes.java index 69550119a..8283f32c6 100644 --- a/fop-core/src/main/java/org/apache/fop/pdf/StandardStructureTypes.java +++ b/fop-core/src/main/java/org/apache/fop/pdf/StandardStructureTypes.java @@ -19,6 +19,7 @@ package org.apache.fop.pdf; +import java.io.Serializable; import java.util.HashMap; import java.util.Map; @@ -98,8 +99,9 @@ public final class StandardStructureTypes { public static final StructureType FORM = new StructureTypeImpl("Form"); } - private static class StructureTypeImpl implements StructureType { + private static class StructureTypeImpl implements StructureType, Serializable { + private static final long serialVersionUID = 8577475043360334210L; private final PDFName name; protected StructureTypeImpl(String name) { diff --git a/fop-core/src/main/java/org/apache/fop/render/pdf/PageSequenceStructElem.java b/fop-core/src/main/java/org/apache/fop/render/pdf/PageSequenceStructElem.java index c660d2496..2024270ae 100644 --- a/fop-core/src/main/java/org/apache/fop/render/pdf/PageSequenceStructElem.java +++ b/fop-core/src/main/java/org/apache/fop/render/pdf/PageSequenceStructElem.java @@ -29,6 +29,7 @@ import org.apache.fop.pdf.StructureType; public class PageSequenceStructElem extends PDFStructElem { + private static final long serialVersionUID = -9146602678931267198L; private List regionBefores = new ArrayList(); private List regionAfters = new ArrayList(); diff --git a/fop-core/src/main/java/org/apache/fop/render/pdf/TableStructElem.java b/fop-core/src/main/java/org/apache/fop/render/pdf/TableStructElem.java index c44acb25c..0df8baade 100644 --- a/fop-core/src/main/java/org/apache/fop/render/pdf/TableStructElem.java +++ b/fop-core/src/main/java/org/apache/fop/render/pdf/TableStructElem.java @@ -25,6 +25,7 @@ import org.apache.fop.pdf.StructureType; class TableStructElem extends PDFStructElem { + private static final long serialVersionUID = -3550873504343680465L; private PDFStructElem tableFooter; public TableStructElem(PDFObject parent, StructureType structureType) { diff --git a/fop-core/src/test/java/org/apache/fop/render/ConserveMemoryTestCase.java b/fop-core/src/test/java/org/apache/fop/render/ConserveMemoryTestCase.java index ae1b974b3..f4dcd7ef2 100644 --- a/fop-core/src/test/java/org/apache/fop/render/ConserveMemoryTestCase.java +++ b/fop-core/src/test/java/org/apache/fop/render/ConserveMemoryTestCase.java @@ -58,6 +58,7 @@ public class ConserveMemoryTestCase { FopFactory fopFactory = FopFactory.newInstance(new File(".").toURI()); FOUserAgent userAgent = fopFactory.newFOUserAgent(); userAgent.setConserveMemoryPolicy(true); + userAgent.setAccessibility(true); Fop fop = fopFactory.newFop("application/pdf", userAgent, new ByteArrayOutputStream()); Transformer transformer = TransformerFactory.newInstance().newTransformer(); Source src = new StreamSource(new ByteArrayInputStream(fo.getBytes())); -- 2.39.5