diff options
author | Tobias Kellner <tobias.kellner@iaik.tugraz.at> | 2014-12-12 13:48:28 +0100 |
---|---|---|
committer | Tobias Kellner <tobias.kellner@iaik.tugraz.at> | 2014-12-12 13:48:28 +0100 |
commit | 683f42f194a30e70d4d09f4bac779d15526e1436 (patch) | |
tree | 44e74d6f290a623af9a21c06fad02a9847774ec4 /pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow | |
parent | b1d832da0a2b9da58d94c529ab8d0e4aabcb4c0b (diff) | |
download | mocca-683f42f194a30e70d4d09f4bac779d15526e1436.tar.gz mocca-683f42f194a30e70d4d09f4bac779d15526e1436.tar.bz2 mocca-683f42f194a30e70d4d09f4bac779d15526e1436.zip |
Make PDF/A compatibility configurable
Diffstat (limited to 'pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow')
8 files changed, 128 insertions, 48 deletions
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigManipulator.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigManipulator.java index d04d59c1..346c59ae 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigManipulator.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigManipulator.java @@ -109,7 +109,13 @@ public interface ConfigManipulator { * Sets the signature locale to be used * @param locale the signature locale */ - public void setSignLocale(Locale locale); + public void setSignatureLocale(Locale locale); + + /** + * Set the signature PDF/A compatibility setting + * @param compat whether to use PDF/A compatibility + */ + public void setSignaturePdfACompat(boolean compat); /** * Sets whether to automatically check for application updates diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigProvider.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigProvider.java index c9a8d616..d4489e27 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigProvider.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigProvider.java @@ -148,7 +148,13 @@ public interface ConfigProvider { * Gets the configured locale * @return the configured locale */ - public Locale getSignLocale(); + public Locale getSignatureLocale(); + + /** + * Get the signature PDF/A compatibility setting + * @return the signature PDF/A compatibility setting + */ + public boolean getSignaturePdfACompat(); /** * Gets whether to automatically check for application updates diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigProviderImpl.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigProviderImpl.java index b5175141..5ec55555 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigProviderImpl.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigProviderImpl.java @@ -119,14 +119,18 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, if (targetLocale != null) { setLocale(targetLocale); } + + String signatureLocaleString = config.getProperty(Constants.CFG_SIGNATURE_LOCALE); - String signlocalString = config.getProperty(Constants.CFG_SIGNATURE_LOCALE); - - Locale signtargetLocale = LocaleSerializer.parseFromString(signlocalString); - if (signtargetLocale != null) { - setSignLocale(signtargetLocale); + Locale signatureTargetLocale = LocaleSerializer.parseFromString(signatureLocaleString); + if (signatureTargetLocale != null) { + setSignatureLocale(signatureTargetLocale); } - + + String compat = config.getProperty(Constants.CFG_SIGNATURE_PDFA_COMPAT); + if (compat != null) + setSignaturePdfACompat(!compat.equalsIgnoreCase(Constants.FALSE)); + String bkuUrl = config .getProperty(Constants.CFG_MOBILE_BKU_URL); @@ -288,16 +292,16 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, Properties props = new Properties(); props.clear(); - props.setProperty(Constants.CFG_BKU, this.getDefaultBKUPersistent().toString()); - props.setProperty(Constants.CFG_PROXY_HOST, this.getProxyHostPersistent()); + props.setProperty(Constants.CFG_BKU, getDefaultBKUPersistent().toString()); + props.setProperty(Constants.CFG_PROXY_HOST, getProxyHostPersistent()); props.setProperty(Constants.CFG_PROXY_PORT, Integer.toString(getProxyPortPersistent())); - props.setProperty(Constants.CFG_PROXY_USER, this.getProxyUserPersistent()); - props.setProperty(Constants.CFG_PROXY_PASS, this.getProxyPassPersistent()); - props.setProperty(Constants.CFG_EMBLEM, this.getDefaultEmblemPersistent()); - props.setProperty(Constants.CFG_SIGNATURE_NOTE, this.getSignatureNote()); - props.setProperty(Constants.CFG_MOBILE_NUMBER, this.getDefaultMobileNumberPersistent()); - props.setProperty(Constants.CFG_OUTPUT_FOLDER, this.getDefaultOutputFolderPersistent()); + props.setProperty(Constants.CFG_PROXY_USER, getProxyUserPersistent()); + props.setProperty(Constants.CFG_PROXY_PASS, getProxyPassPersistent()); + props.setProperty(Constants.CFG_EMBLEM, getDefaultEmblemPersistent()); + props.setProperty(Constants.CFG_SIGNATURE_NOTE, getSignatureNote()); + props.setProperty(Constants.CFG_MOBILE_NUMBER, getDefaultMobileNumberPersistent()); + props.setProperty(Constants.CFG_OUTPUT_FOLDER, getDefaultOutputFolderPersistent()); props.setProperty(Constants.CFG_SIGNATURE_PLACEHOLDER_TRANSPARENCY, Integer.toString(getPlaceholderTransparency())); @@ -309,13 +313,15 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, props.setProperty(Constants.CFG_LOCALE, LocaleSerializer.getParsableString(configLocale)); } - Locale signLocale = this.getSignLocale(); - if(signLocale != null) { - props.setProperty(Constants.CFG_SIGNATURE_LOCALE, LocaleSerializer.getParsableString(signLocale)); + Locale signatureLocale = this.getSignatureLocale(); + if(signatureLocale != null) { + props.setProperty(Constants.CFG_SIGNATURE_LOCALE, LocaleSerializer.getParsableString(signatureLocale)); } - SignaturePosition pos = getDefaultSignaturePositionPersistent(); + if (!getSignaturePdfACompat()) + props.setProperty(Constants.CFG_SIGNATURE_PDFA_COMPAT, Constants.FALSE); + SignaturePosition pos = getDefaultSignaturePositionPersistent(); if (pos == null) { props.setProperty(Constants.CFG_SIGNATURE_POSITION, ""); //$NON-NLS-1$ } else if (pos.useAutoPositioning()) { @@ -999,29 +1005,45 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator, } /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.ConfigManipulator#setSignLocale(java.util.Locale) + * @see at.asit.pdfover.gui.workflow.ConfigManipulator#setSignatureLocale(java.util.Locale) */ @Override - public void setSignLocale(Locale locale) { + public void setSignatureLocale(Locale locale) { if(locale == null) { - this.configuration.setSignLocale(Messages.getDefaultLocale()); + this.configuration.setSignatureLocale(Messages.getDefaultLocale()); } else { - this.configuration.setSignLocale(locale); + this.configuration.setSignatureLocale(locale); } } /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.ConfigProvider#getSignLocale() + * @see at.asit.pdfover.gui.workflow.ConfigProvider#getSignatureLocale() */ @Override - public Locale getSignLocale() { - Locale locale = this.configuration.getSignLocale(); + public Locale getSignatureLocale() { + Locale locale = this.configuration.getSignatureLocale(); if (locale == null) locale = Messages.getDefaultLocale(); return locale; } /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.config.ConfigManipulator#setSignaturePdfACompat(boolean) + */ + @Override + public void setSignaturePdfACompat(boolean compat) { + this.configuration.setSignaturePdfACompat(compat); + } + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.config.ConfigProvider#getSignaturePdfACompat() + */ + @Override + public boolean getSignaturePdfACompat() { + return this.configuration.getSignaturePdfACompat(); + } + + /* (non-Javadoc) * @see at.asit.pdfover.gui.workflow.config.ConfigManipulator#setUpdateCheck(boolean) */ @Override diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationContainer.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationContainer.java index 24cd46bb..6d5e888e 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationContainer.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationContainer.java @@ -187,13 +187,25 @@ public interface ConfigurationContainer { * Gets the signature locale * @return the signature locale */ - public Locale getSignLocale(); + public Locale getSignatureLocale(); /** * Sets the signature locale * @param locale the signature locale */ - public void setSignLocale(Locale locale); + public void setSignatureLocale(Locale locale); + + /** + * Gets the signature PDF/A compatibility setting + * @return the signature PDF/A compatibility setting + */ + public boolean getSignaturePdfACompat(); + + /** + * Sets the signature PDF/A compatibility setting + * @param compat the signature PDF/A compatibility setting + */ + public void setSignaturePdfACompat(boolean compat); /** * Gets the mobile BKU URL diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationContainerImpl.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationContainerImpl.java index 83f35b65..726e5b4b 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationContainerImpl.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/ConfigurationContainerImpl.java @@ -77,7 +77,10 @@ public class ConfigurationContainerImpl implements ConfigurationContainer { protected Locale locale = null; /** Holds the signature locale */ - protected Locale signLocale = null; + protected Locale signatureLocale = null; + + /** Holds the PDF/A compatibility setting */ + protected boolean pdfACompat = true; /** Holds the output folder */ protected String folder = null; @@ -360,20 +363,38 @@ public class ConfigurationContainerImpl implements ConfigurationContainer { /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.ConfigurationContainer#getSignLocale() + * @see at.asit.pdfover.gui.workflow.ConfigurationContainer#getSignatureLocale() + */ + @Override + public Locale getSignatureLocale() { + return this.signatureLocale; + } + + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.ConfigurationContainer#setSignatureLocale(java.util.Locale) + */ + @Override + public void setSignatureLocale(Locale locale) { + this.signatureLocale = locale; + } + + + /* (non-Javadoc) + * @see at.asit.pdfover.gui.workflow.config.ConfigurationContainer#getSignaturePdfACompat() */ @Override - public Locale getSignLocale() { - return this.signLocale; + public boolean getSignaturePdfACompat() { + return this.pdfACompat; } /* (non-Javadoc) - * @see at.asit.pdfover.gui.workflow.ConfigurationContainer#setSignLocale(java.util.Locale) + * @see at.asit.pdfover.gui.workflow.config.ConfigurationContainer#setSignaturePdfACompat(boolean) */ @Override - public void setSignLocale(Locale locale) { - this.signLocale = locale; + public void setSignaturePdfACompat(boolean compat) { + this.pdfACompat = compat; } diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/PersistentConfigProvider.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/PersistentConfigProvider.java index 9b857fa7..26a98def 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/PersistentConfigProvider.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/config/PersistentConfigProvider.java @@ -125,7 +125,13 @@ public interface PersistentConfigProvider { * Gets the configured locale * @return the configured locale */ - public Locale getSignLocale(); + public Locale getSignatureLocale(); + + /** + * Get the signature PDF/A compatibility setting + * @return the signature PDF/A compatibility setting + */ + public boolean getSignaturePdfACompat(); /** * Gets whether to automatically check for application updates diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java index 6c3d11a8..ae1303c8 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java @@ -35,6 +35,7 @@ import at.asit.pdfover.gui.utils.Messages; import at.asit.pdfover.gui.utils.SignaturePlaceholderCache; import at.asit.pdfover.gui.workflow.StateMachine; import at.asit.pdfover.gui.workflow.Status; +import at.asit.pdfover.gui.workflow.config.ConfigProvider; import at.asit.pdfover.signator.Emblem; import at.asit.pdfover.signator.FileNameEmblem; import at.asit.pdfover.signator.SignatureParameter; @@ -93,27 +94,30 @@ public class PositioningState extends State { } private PositioningComposite getPositioningComposite(PDFFile document) { + StateMachine stateMachine = getStateMachine(); if (this.positionComposite == null) { this.positionComposite = - getStateMachine().getGUIProvider().createComposite(PositioningComposite.class, SWT.RESIZE, this); - log.debug("Displaying " + getStateMachine().getStatus().getDocument()); //$NON-NLS-1$ + stateMachine.getGUIProvider().createComposite(PositioningComposite.class, SWT.RESIZE, this); + log.debug("Displaying " + stateMachine.getStatus().getDocument()); //$NON-NLS-1$ this.positionComposite.displayDocument(document); } // Update possibly changed values - SignatureParameter param = getStateMachine().getPDFSigner().getPDFSigner().newParameter(); - Emblem emblem = new FileNameEmblem(getStateMachine().getConfigProvider().getDefaultEmblem()); + ConfigProvider config = stateMachine.getConfigProvider(); + SignatureParameter param = stateMachine.getPDFSigner().getPDFSigner().newParameter(); + Emblem emblem = new FileNameEmblem(config.getDefaultEmblem()); param.setEmblem(emblem); - if(getStateMachine().getConfigProvider().getSignatureNote() != null && !getStateMachine().getConfigProvider().getSignatureNote().isEmpty()) { - param.setProperty("SIG_NOTE", getStateMachine().getConfigProvider().getSignatureNote()); //$NON-NLS-1$ + if(config.getSignatureNote() != null && !config.getSignatureNote().isEmpty()) { + param.setProperty("SIG_NOTE", config.getSignatureNote()); //$NON-NLS-1$ } - - param.setSignatureLanguage(getStateMachine().getConfigProvider().getSignLocale().getLanguage()); - + + param.setSignatureLanguage(config.getSignatureLocale().getLanguage()); + param.setSignaturePdfACompat(config.getSignaturePdfACompat()); + this.positionComposite.setPlaceholder( SignaturePlaceholderCache.getPlaceholder(param), param.getPlaceholderDimension().getWidth(), param.getPlaceholderDimension().getHeight(), - getStateMachine().getConfigProvider().getPlaceholderTransparency()); + config.getPlaceholderTransparency()); if (this.previousPosition != null && !this.previousPosition.useAutoPositioning()) this.positionComposite.setPosition( this.previousPosition.getX(), diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareSigningState.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareSigningState.java index d64c1843..21664d85 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareSigningState.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PrepareSigningState.java @@ -155,9 +155,12 @@ public class PrepareSigningState extends State { } this.state.signatureParameter - .setSignatureLanguage(configuration.getSignLocale() + .setSignatureLanguage(configuration.getSignatureLocale() .getLanguage()); + this.state.signatureParameter + .setSignaturePdfACompat(configuration.getSignaturePdfACompat()); + this.state.signingState = this.state.signer .prepare(this.state.signatureParameter); |