Add pdf_was_repaired() and java reflection.
authorRobin Watts <[email protected]>
Wed, 7 Oct 2020 10:12:41 +0000 (11:12 +0100)
committerRobin Watts <[email protected]>
Wed, 7 Oct 2020 10:33:07 +0000 (11:33 +0100)
include/mupdf/pdf/document.h
platform/java/jni/pdfdocument.c
platform/java/mupdf_native.h
platform/java/src/com/artifex/mupdf/fitz/PDFDocument.java
source/pdf/pdf-form.c

index b9c58ac03010f57a3df30819077b10370105089c..296c5a13ee397598ae4cf20ca8b6f3c9e918c16f 100644 (file)
@@ -243,6 +243,11 @@ void pdf_set_layer_config_as_default(fz_context *ctx, pdf_document *doc);
 */
 int pdf_has_unsaved_changes(fz_context *ctx, pdf_document *doc);
 
+/*
+       Determine if this PDF has been repaired since opening.
+*/
+int pdf_was_repaired(fz_context *ctx, pdf_document *doc);
+
 /* Object that can perform the cryptographic operation necessary for document signing */
 typedef struct pdf_pkcs7_signer pdf_pkcs7_signer;
 
index b41983a72fcaf5193c1299aacff177b4c9322e79..c7270ad7d05da193dc3aa86f410c036a19104d22 100644 (file)
@@ -671,6 +671,15 @@ FUN(PDFDocument_hasUnsavedChanges)(JNIEnv *env, jobject self)
        return pdf_has_unsaved_changes(ctx, pdf) ? JNI_TRUE : JNI_FALSE;
 }
 
+JNIEXPORT jboolean JNICALL
+FUN(PDFDocument_wasRepaired)(JNIEnv *env, jobject self)
+{
+       fz_context *ctx = get_context(env);
+       pdf_document *pdf = from_PDFDocument(env, self);
+       if (!ctx || !pdf) return JNI_FALSE;
+       return pdf_was_repaired(ctx, pdf) ? JNI_TRUE : JNI_FALSE;
+}
+
 JNIEXPORT jboolean JNICALL
 FUN(PDFDocument_canBeSavedIncrementally)(JNIEnv *env, jobject self)
 {
index adfaf236817300be40d2f4c74cb7f82acd2da248..6cff8a564a3848e93c3a36c20e07c6ee743b1509 100644 (file)
@@ -2072,6 +2072,14 @@ JNIEXPORT jobject JNICALL Java_com_artifex_mupdf_fitz_PDFDocument_addFont
 JNIEXPORT jboolean JNICALL Java_com_artifex_mupdf_fitz_PDFDocument_hasUnsavedChanges
   (JNIEnv *, jobject);
 
+/*
+ * Class:     com_artifex_mupdf_fitz_PDFDocument
+ * Method:    wasRepaired
+ * Signature: ()Z
+ */
+JNIEXPORT jboolean JNICALL Java_com_artifex_mupdf_fitz_PDFDocument_wasRepaired
+  (JNIEnv *, jobject);
+
 /*
  * Class:     com_artifex_mupdf_fitz_PDFDocument
  * Method:    canBeSavedIncrementally
index 389d16e528ed5548b2744d3ac508ca46a016fa37..5d00bf9d86e5b6ff03efa4df6777ebaff1842ccf 100644 (file)
@@ -102,6 +102,7 @@ public class PDFDocument extends Document
        public native PDFObject addCJKFont(Font font, int ordering, int wmode, boolean serif);
        public native PDFObject addFont(Font font);
        public native boolean hasUnsavedChanges();
+       public native boolean wasRepaired();
        public native boolean canBeSavedIncrementally();
 
        public native void save(String filename, String options);
index 178d80b0827d56784c1a60a0361fe9d356e86606..6fc7ee04be51a3fa5ac19c793814725751874a0d 100644 (file)
@@ -480,6 +480,11 @@ int pdf_has_unsaved_changes(fz_context *ctx, pdf_document *doc)
        return doc->dirty;
 }
 
+int pdf_was_repaired(fz_context *ctx, pdf_document *doc)
+{
+       return doc->repair_attempted;
+}
+
 int pdf_toggle_widget(fz_context *ctx, pdf_widget *widget)
 {
        switch (pdf_widget_type(ctx, widget))