From df362d82d20d0301099ff3b43517034b4880bd9c Mon Sep 17 00:00:00 2001 From: Andreas Abraham Date: Thu, 19 Nov 2020 09:24:38 +0100 Subject: Fixed smaller bugs and typos --- .../pdfover/gui/cliarguments/InvisibleProfile.java | 2 +- .../composites/AdvancedConfigurationComposite.java | 12 +++++++- .../composites/SimpleConfigurationComposite.java | 7 +++++ .../signer/pdfas/PdfAs4SignatureParameter.java | 36 ++++++++++++++++------ .../at/asit/pdfover/signer/pdfas/PdfAs4Signer.java | 7 +++-- 5 files changed, 50 insertions(+), 14 deletions(-) diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/InvisibleProfile.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/InvisibleProfile.java index b833ce9d..4bb3890f 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/InvisibleProfile.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/cliarguments/InvisibleProfile.java @@ -54,8 +54,8 @@ public class InvisibleProfile extends Argument { log.info("Set Profile Invisible"); if (args.length > argOffset + 1) { - PdfAs4SignatureParameter.PROFILE_VISIBILITY=false; + log.debug("We are setting the profile visibility to false"); return argOffset + 1; } diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/AdvancedConfigurationComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/AdvancedConfigurationComposite.java index f4b3ae0b..27b0f135 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/AdvancedConfigurationComposite.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/AdvancedConfigurationComposite.java @@ -1002,7 +1002,17 @@ public class AdvancedConfigurationComposite extends BaseConfigurationComposite { * */ public void performSetSignatureProfile(Profile profile) { - this.configurationContainer.setSignatureProfile(profile); + switch (profile){ + case INVISIBLE: + case AMTSSIGNATURBLOCK: + this.performPositionSelection(true); + this.btnAutomatischePositionierung.setEnabled(false); + this.grpPlaceholder.setEnabled(false); + break; + default: + this.btnAutomatischePositionierung.setEnabled(true); + this.grpPlaceholder.setEnabled(true); + } } /* (non-Javadoc) diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SimpleConfigurationComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SimpleConfigurationComposite.java index 7941bc9a..ad0d5eb8 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SimpleConfigurationComposite.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/SimpleConfigurationComposite.java @@ -22,6 +22,7 @@ import java.util.Locale; import javax.imageio.ImageIO; +import at.asit.pdfover.signator.SignaturePosition; import org.eclipse.swt.SWT; import org.eclipse.swt.dnd.DND; import org.eclipse.swt.dnd.DropTarget; @@ -759,6 +760,12 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite { log.debug("Signature Profile {} was selected", selected.getName()); //$NON-NLS-1$ this.configurationContainer.setSignatureProfile(selected); this.cmbSingatureProfiles.select(selected.ordinal()); + + if (selected.equals(Profile.AMTSSIGNATURBLOCK)){ + this.configurationContainer.setDefaultSignaturePosition(new SignaturePosition()); + //TODO also set the radio button in advanced config + } + } void setSignatureProfileSetting(){ diff --git a/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignatureParameter.java b/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignatureParameter.java index 68712db9..08722617 100644 --- a/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignatureParameter.java +++ b/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignatureParameter.java @@ -49,6 +49,8 @@ public class PdfAs4SignatureParameter extends SignatureParameter { /** The profile ID extension for PDF/A compatibility */ private static final String PROFILE_ID_PDFA = "_PDFA"; + private static final String PROFILE_ID_RECOMMENDED = "_RECOMMENDED"; + /** * Visibility of signature block */ @@ -168,17 +170,25 @@ public class PdfAs4SignatureParameter extends SignatureParameter { //Add Signature Param here// String profileId; - - - if (!PROFILE_VISIBILITY || Profile.getProfile(this.profile).equals(Profile.INVISIBLE)) - { - profileId = "INVISIBLE"; - } else { - profileId = Profile.getProfile(this.profile).name(); - profileId += (lang != null && lang.equals("en")) ? - PROFILE_ID_LANG_EN : PROFILE_ID_LANG_DE; + if (!PROFILE_VISIBILITY){ + log.debug("Profile visibility was set to false"); + return Profile.INVISIBLE.name(); } + switch (Profile.getProfile(this.profile)){ + case BASE_LOGO: + case INVISIBLE: + return getProfileName(); + case AMTSSIGNATURBLOCK: + profileId = getProfileName(); + profileId += getLangProfilePart(lang); + profileId += PROFILE_ID_RECOMMENDED; + return profileId; + default: + profileId = getProfileName(); + profileId += getLangProfilePart(lang); + break; + } if (useNote) profileId += PROFILE_ID_NOTE; @@ -191,6 +201,14 @@ public class PdfAs4SignatureParameter extends SignatureParameter { return profileId; } + private String getProfileName(){ + return Profile.getProfile(this.profile).name(); + } + + private String getLangProfilePart(String lang){ + return (lang != null && lang.equals("en")) ? PROFILE_ID_LANG_EN : PROFILE_ID_LANG_DE; + } + @Override public void setSignatureProfile(String profile) { this.profile = profile; diff --git a/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4Signer.java b/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4Signer.java index 5c4782ba..67a8fe7f 100644 --- a/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4Signer.java +++ b/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4Signer.java @@ -5,6 +5,7 @@ import java.util.UUID; import javax.activation.DataSource; +import at.asit.pdfover.commons.Profile; import at.asit.pdfover.signator.ByteArrayDocumentSource; import at.asit.pdfover.signator.SignResult; import at.asit.pdfover.signator.SignResultImpl; @@ -144,6 +145,8 @@ public class PdfAs4Signer implements Signer { sp = new SignaturePosition(); else if (tp.isPauto()) sp = new SignaturePosition(tp.getPosX(), tp.getPosY()); + else if (param.getSignatureProfileId().contains(Profile.AMTSSIGNATURBLOCK.getName())) + sp = new SignaturePosition(); else sp = new SignaturePosition(tp.getPosX(), tp.getPosY(), tp.getPage()); result.setSignaturePosition(sp); @@ -151,9 +154,7 @@ public class PdfAs4Signer implements Signer { result.setSignedDocument(new ByteArrayDocumentSource(sstate.getOutput().toByteArray())); return result; - } catch (PdfAsException e) { - throw new SignatureException(e); - } catch (PDFASError e) { + } catch (PdfAsException | PDFASError e) { throw new SignatureException(e); } } -- cgit v1.2.3