From c751dda6d26a2b0bbb1eb4c0ea1b0bc7a0e7f42d Mon Sep 17 00:00:00 2001 From: pdanner Date: Mon, 7 Mar 2011 15:47:33 +0000 Subject: add more defense if link struct cannot be found git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@775 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c --- .../knowcenter/wag/egov/egiz/pdf/StructContentHelper.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/main/java/at/knowcenter/wag') diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/pdf/StructContentHelper.java b/src/main/java/at/knowcenter/wag/egov/egiz/pdf/StructContentHelper.java index 859d2c0..8fe9e62 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/pdf/StructContentHelper.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/pdf/StructContentHelper.java @@ -62,6 +62,8 @@ public class StructContentHelper implements StructContentWriter { private int linkMcid = -1; private String linkUrlString = null; private boolean isTagged = false; + private Map linkPosMap = new HashMap(); + private Map tmpMap = new HashMap(); private PdfStamper stamper; private PdfStamperImp stamperImp; @@ -234,7 +236,7 @@ public class StructContentHelper implements StructContentWriter { * @throws PresentableException */ void buildVerifyLinkStructData(PdfTemplate sigBlockObj, ActualTablePos atp) throws PresentableException { - if (!this.isTagged || !this.isLinkMarked()) return; + if (!this.isTagged || !this.isLinkMarked() || !isLinkFound()) return; try { PdfNumber parentTreeKey = getNewParentTreeKey(); @@ -242,7 +244,7 @@ public class StructContentHelper implements StructContentWriter { PdfArray annots = obrainAnnotsFromPage(); PdfIndirectReference linkAnnotRef = createLinkAnnot(parentTreeKey, atp); - annots.add(linkAnnotRef); + annots.add(linkAnnotRef); PdfIndirectReference objr = createObjrStructElem(linkAnnotRef); PdfIndirectReference mcr = createMcrStructElem(this.linkMcid, sigBlockObj.getIndirectReference()); @@ -280,6 +282,10 @@ public class StructContentHelper implements StructContentWriter { } } + private boolean isLinkFound() { + return this.linkUrlString != null && this.verifyLinkCellPos != null && this.linkPosMap.size() > 0 && this.linkMcid >= 0; + } + /** * Build new StructParent entry for signature annotation. * @return @@ -412,13 +418,11 @@ public class StructContentHelper implements StructContentWriter { public void storeCurrentPosAsLink() { this.verifyLinkCellPos = new Rectangle(this.tempMarkedPos); } - - private Map tmpMap = new HashMap(); + public void putVal(String key, Object val) { tmpMap.put(key, val); } - private Map linkPosMap; public void storeVals() { linkPosMap = new HashMap(tmpMap); } -- cgit v1.2.3