From 5962867b411bc53bf14938b0312414f040986b54 Mon Sep 17 00:00:00 2001 From: Tobias Kellner Date: Mon, 10 Oct 2016 18:35:33 +0200 Subject: Cache (and scale) custom emblem images --- .../pdfover/gui/composites/SimpleConfigurationComposite.java | 4 ++-- .../at/asit/pdfover/gui/utils/SignaturePlaceholderCache.java | 12 +++++++++++- .../asit/pdfover/gui/workflow/states/PositioningState.java | 4 ++-- .../pdfover/gui/workflow/states/PrepareSigningState.java | 6 +++--- 4 files changed, 18 insertions(+), 8 deletions(-) (limited to 'pdf-over-gui') 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 a124c86d..4c02c044 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 @@ -70,7 +70,7 @@ import at.asit.pdfover.gui.workflow.config.ConfigManipulator; import at.asit.pdfover.gui.workflow.config.ConfigurationContainer; import at.asit.pdfover.gui.workflow.config.PersistentConfigProvider; import at.asit.pdfover.gui.workflow.states.State; -import at.asit.pdfover.signator.FileNameEmblem; +import at.asit.pdfover.signator.CachedFileNameEmblem; import at.asit.pdfover.signator.SignatureParameter; /** @@ -619,7 +619,7 @@ public class SimpleConfigurationComposite extends BaseConfigurationComposite { param.setSignaturePdfACompat(this.configurationContainer.getSignaturePdfACompat()); if (image != null && !image.trim().isEmpty()) { logo = new ImageData(image); - param.setEmblem(new FileNameEmblem(image)); + param.setEmblem(new CachedFileNameEmblem(image)); } img = SignaturePlaceholderCache.getSWTPlaceholder(param); diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/SignaturePlaceholderCache.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/SignaturePlaceholderCache.java index 87ce24ee..306f74b7 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/SignaturePlaceholderCache.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/utils/SignaturePlaceholderCache.java @@ -33,6 +33,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import at.asit.pdfover.gui.Constants; +import at.asit.pdfover.signator.CachedFileNameEmblem; +import at.asit.pdfover.signator.Emblem; import at.asit.pdfover.signator.SignatureParameter; /** @@ -71,7 +73,15 @@ public class SignaturePlaceholderCache { final String sigNoteProp = "NOTE"; //$NON-NLS-1$ String sigLang = param.getSignatureLanguage(); - String sigEmbl = (param.getEmblem() == null ? "" : param.getEmblem().getFileName()); //$NON-NLS-1$ + String sigEmbl = ""; //$NON-NLS-1$ + if (param.getEmblem() != null) { + Emblem embl = param.getEmblem(); + if (embl instanceof CachedFileNameEmblem) { + sigEmbl = ((CachedFileNameEmblem) embl).getOriginalFileName(); + } else { + sigEmbl = embl.getFileName(); + } + } String sigPdfA = param.getSignaturePdfACompat() ? Constants.TRUE : Constants.FALSE; String sigNote = param.getProperty("SIG_NOTE"); //$NON-NLS-1$ if (sigNote == null) 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 ae1303c8..32b335a7 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 @@ -36,8 +36,8 @@ 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.CachedFileNameEmblem; import at.asit.pdfover.signator.Emblem; -import at.asit.pdfover.signator.FileNameEmblem; import at.asit.pdfover.signator.SignatureParameter; import at.asit.pdfover.signator.SignaturePosition; @@ -104,7 +104,7 @@ public class PositioningState extends State { // Update possibly changed values ConfigProvider config = stateMachine.getConfigProvider(); SignatureParameter param = stateMachine.getPDFSigner().getPDFSigner().newParameter(); - Emblem emblem = new FileNameEmblem(config.getDefaultEmblem()); + Emblem emblem = new CachedFileNameEmblem(config.getDefaultEmblem()); param.setEmblem(emblem); if(config.getSignatureNote() != null && !config.getSignatureNote().isEmpty()) { param.setProperty("SIG_NOTE", config.getSignatureNote()); //$NON-NLS-1$ 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 45636568..155073d6 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 @@ -26,14 +26,14 @@ import org.slf4j.LoggerFactory; import at.asit.pdfover.gui.MainWindow.Buttons; import at.asit.pdfover.gui.MainWindowBehavior; import at.asit.pdfover.gui.composites.WaitingComposite; -import at.asit.pdfover.gui.controls.ErrorDialog; import at.asit.pdfover.gui.controls.Dialog.BUTTONS; +import at.asit.pdfover.gui.controls.ErrorDialog; import at.asit.pdfover.gui.utils.Messages; 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.BKUs; -import at.asit.pdfover.signator.FileNameEmblem; +import at.asit.pdfover.signator.CachedFileNameEmblem; import at.asit.pdfover.signator.PDFFileDocumentSource; import at.asit.pdfover.signator.SignatureParameter; import at.asit.pdfover.signator.Signer; @@ -144,7 +144,7 @@ public class PrepareSigningState extends State { if (configuration.getDefaultEmblem() != null && !configuration.getDefaultEmblem().isEmpty()) { - this.state.signatureParameter.setEmblem(new FileNameEmblem( + this.state.signatureParameter.setEmblem(new CachedFileNameEmblem( configuration.getDefaultEmblem())); } -- cgit v1.2.3