From c3c23269e41fbdb95525f5944c1f82c5dfb1efae Mon Sep 17 00:00:00 2001 From: Maxim Date: Tue, 17 Oct 2023 20:32:17 +0300 Subject: [PATCH] Change appearance link from PDContentStream to PDXForm in PDAnnot --- .../verapdf/model/impl/pb/pd/PBoxPDAnnot.java | 24 ++++++++----------- .../model/impl/pb/pd/PBoxPDAnnotTest.java | 3 ++- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/pdfbox-validation-model/src/main/java/org/verapdf/model/impl/pb/pd/PBoxPDAnnot.java b/pdfbox-validation-model/src/main/java/org/verapdf/model/impl/pb/pd/PBoxPDAnnot.java index 6e064702..9de2afc2 100644 --- a/pdfbox-validation-model/src/main/java/org/verapdf/model/impl/pb/pd/PBoxPDAnnot.java +++ b/pdfbox-validation-model/src/main/java/org/verapdf/model/impl/pb/pd/PBoxPDAnnot.java @@ -48,10 +48,8 @@ import org.verapdf.model.impl.pb.pd.annotations.PBoxPDPrinterMarkAnnot; import org.verapdf.model.impl.pb.pd.annotations.PBoxPDTrapNetAnnot; import org.verapdf.model.impl.pb.pd.annotations.PBoxPDWidgetAnnot; -import org.verapdf.model.pdlayer.PDAction; -import org.verapdf.model.pdlayer.PDAdditionalActions; -import org.verapdf.model.pdlayer.PDAnnot; -import org.verapdf.model.pdlayer.PDContentStream; +import org.verapdf.model.impl.pb.pd.images.PBoxPDXForm; +import org.verapdf.model.pdlayer.*; import org.verapdf.model.tools.resources.PDInheritableResources; import org.verapdf.pdfa.flavours.PDFAFlavour; @@ -102,7 +100,7 @@ public class PBoxPDAnnot extends PBoxPDObject implements PDAnnot { private final PDFAFlavour flavour; private final PDPage pdPage; - private List appearance = null; + private List appearance = null; private List blendMode = null; private boolean containsTransparency = false; @@ -441,7 +439,7 @@ private List getNumbersFromArray(COSName arrayName) { * @return normal appearance stream (N key in the appearance dictionary) of * the annotation */ - private List getAppearance() { + private List getAppearance() { if (this.appearance == null) { parseAppearance(); } @@ -466,7 +464,7 @@ private void parseAppearance() { COSBase downAppearanceBase = dictionary.getDictionaryObject(COSName.D); COSBase rolloverAppearanceBase = dictionary.getDictionaryObject(COSName.R); if (normalAppearanceBase != null || downAppearanceBase != null || rolloverAppearanceBase != null) { - List appearances = new ArrayList<>(); + List appearances = new ArrayList<>(); addContentStreamsFromAppearanceEntry(normalAppearanceBase, appearances); addContentStreamsFromAppearanceEntry(downAppearanceBase, appearances); addContentStreamsFromAppearanceEntry(rolloverAppearanceBase, appearances); @@ -479,7 +477,7 @@ private void parseAppearance() { } } - private void addContentStreamsFromAppearanceEntry(COSBase appearanceEntry, List appearances) { + private void addContentStreamsFromAppearanceEntry(COSBase appearanceEntry, List appearances) { if (appearanceEntry != null) { PDAppearanceEntry newAppearance = new PDAppearanceEntry(appearanceEntry); if (newAppearance.isStream()) { @@ -493,15 +491,13 @@ private void addContentStreamsFromAppearanceEntry(COSBase appearanceEntry, List< } } - private void addAppearance(List list, PDAppearanceStream toAdd) { + private void addAppearance(List list, PDAppearanceStream toAdd) { if (toAdd != null) { PDInheritableResources resources = PDInheritableResources.getInstance(this.pageResources, toAdd.getResources()); - PBoxPDContentStream stream = new PBoxPDContentStream(toAdd, resources, this.document, this.flavour); - this.containsTransparency |= stream.isContainsTransparency(); - org.apache.pdfbox.pdmodel.graphics.form.PDGroup group = toAdd.getGroup(); - this.containsTransparency |= group != null && COSName.TRANSPARENCY.equals(group.getSubType()); - list.add(stream); + PBoxPDXForm xForm = new PBoxPDXForm(toAdd, resources, this.document, this.flavour); + this.containsTransparency |= xForm.containsTransparency(); + list.add(xForm); } } diff --git a/pdfbox-validation-model/src/test/java/org/verapdf/model/impl/pb/pd/PBoxPDAnnotTest.java b/pdfbox-validation-model/src/test/java/org/verapdf/model/impl/pb/pd/PBoxPDAnnotTest.java index a226a6fd..229d1c08 100644 --- a/pdfbox-validation-model/src/test/java/org/verapdf/model/impl/pb/pd/PBoxPDAnnotTest.java +++ b/pdfbox-validation-model/src/test/java/org/verapdf/model/impl/pb/pd/PBoxPDAnnotTest.java @@ -31,6 +31,7 @@ import org.verapdf.model.impl.pb.pd.actions.PBoxPDGoToAction; import org.verapdf.model.impl.pb.pd.actions.PBoxPDGoToRemoteAction; import org.verapdf.model.impl.pb.pd.actions.PBoxPDNamedAction; +import org.verapdf.model.impl.pb.pd.images.PBoxPDXForm; import org.verapdf.model.pdlayer.PDAnnot; import java.io.IOException; @@ -130,7 +131,7 @@ public void testAppearanceLink() { List action = actual.getLinkedObjects(PBoxPDAnnot.APPEARANCE); Assert.assertEquals(1, action.size()); for (Object object : action) { - Assert.assertEquals(PBoxPDContentStream.CONTENT_STREAM_TYPE, object.getObjectType()); + Assert.assertEquals(PBoxPDXForm.X_FORM_TYPE, object.getObjectType()); } }