summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Heher <jakob.heher@iaik.tugraz.at>2022-11-17 12:19:04 +0100
committerJakob Heher <jakob.heher@iaik.tugraz.at>2022-11-17 12:19:04 +0100
commitb34cefbc33a3afc26dece74ea8bc42c5054efd5b (patch)
tree408ec9e7153219aa6d5880857f43e3d70bb2ffcf
parentf28f118f6824c0a9c7b4816dfdb95339d874141d (diff)
downloadpdf-over-b34cefbc33a3afc26dece74ea8bc42c5054efd5b.tar.gz
pdf-over-b34cefbc33a3afc26dece74ea8bc42c5054efd5b.tar.bz2
pdf-over-b34cefbc33a3afc26dece74ea8bc42c5054efd5b.zip
handle invisible profile signature previews better
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/SimpleConfigurationComposite.java3
-rw-r--r--pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/states/PositioningState.java3
-rw-r--r--pdf-over-signer/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignatureParameter.java2
-rw-r--r--pdf-over-signer/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignaturePlaceholder.java11
4 files changed, 14 insertions, 5 deletions
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/SimpleConfigurationComposite.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/SimpleConfigurationComposite.java
index 2947c387..cf24dca3 100644
--- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/SimpleConfigurationComposite.java
+++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/composites/configuration/SimpleConfigurationComposite.java
@@ -490,7 +490,8 @@ public class SimpleConfigurationComposite extends ConfigurationCompositeBase {
return;
if (this.sigPreview != null)
this.sigPreview.dispose();
- this.sigPreview = new Image(this.getDisplay(), p.getSWTImage());
+ if (p.hasImage())
+ this.sigPreview = new Image(this.getDisplay(), p.getSWTImage());
this.cSigPreview.redraw();
});
});
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 13b83999..b56fb6d7 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
@@ -121,7 +121,8 @@ public class PositioningState extends State {
param.targetLogoSize = Math.min(120.0, config.getLogoOnlyTargetSize()); // TODO WORKAROUND FOR #117
PdfAs4SignaturePlaceholder.For(param, (p) -> {
- this.positionComposite.setPlaceholder(p.getAWTImage());
+ if (p.hasImage())
+ this.positionComposite.setPlaceholder(p.getAWTImage());
});
if (this.previousPosition != null && !this.previousPosition.useAutoPositioning())
diff --git a/pdf-over-signer/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignatureParameter.java b/pdf-over-signer/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignatureParameter.java
index 0229acb6..ee8c2741 100644
--- a/pdf-over-signer/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignatureParameter.java
+++ b/pdf-over-signer/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignatureParameter.java
@@ -126,7 +126,7 @@ public class PdfAs4SignatureParameter {
Image placeholder = pdfas.generateVisibleSignaturePreview(param, cert, 72 * 4);
// WORKAROUND for #110, manually paint a black border
- if (!this.signatureProfile.equals(Profile.BASE_LOGO))
+ if ((placeholder != null) && !this.signatureProfile.equals(Profile.BASE_LOGO))
{
Graphics2D ctx = (Graphics2D)placeholder.getGraphics();
ctx.setColor(Color.BLACK);
diff --git a/pdf-over-signer/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignaturePlaceholder.java b/pdf-over-signer/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignaturePlaceholder.java
index facdd47e..04bbcfdf 100644
--- a/pdf-over-signer/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignaturePlaceholder.java
+++ b/pdf-over-signer/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4SignaturePlaceholder.java
@@ -5,6 +5,7 @@ import java.util.Comparator;
import java.util.TreeMap;
import java.util.function.Consumer;
+import at.asit.pdfover.commons.Profile;
import at.asit.pdfover.commons.utils.ImageUtil;
/**
@@ -36,6 +37,7 @@ public final class PdfAs4SignaturePlaceholder implements Runnable {
}
private java.awt.image.BufferedImage awtImageData;
+ public boolean hasImage() { return ((this.awtImageData != null) && (this.swtImageData != null)); }
/** AWT image data for the placeholder */
public java.awt.image.BufferedImage getAWTImage() { return this.awtImageData; }
private org.eclipse.swt.graphics.ImageData swtImageData;
@@ -58,8 +60,13 @@ public final class PdfAs4SignaturePlaceholder implements Runnable {
@Override
public void run() {
- this.awtImageData = (java.awt.image.BufferedImage) this.param.getPlaceholder();
- this.swtImageData = ImageUtil.convertToSWT(this.awtImageData);
+ if (!Profile.INVISIBLE.name().equals(this.param.getPdfAsSignatureProfileId())) {
+ this.awtImageData = (java.awt.image.BufferedImage) this.param.getPlaceholder();
+ this.swtImageData = ImageUtil.convertToSWT(this.awtImageData);
+ } else {
+ this.awtImageData = null;
+ this.swtImageData = null;
+ }
ArrayList<Consumer<PdfAs4SignaturePlaceholder>> _callbacks;
synchronized (this) {
_callbacks = this.callbacks;