[gs-commits] mupdf 1.16.1.99 jni: Add API to check for external links.

[email protected] (Tor Andersson) Tue, 22 Oct 2019 11:29:11 +0000 (UTC)
Newsgroups gmane.comp.printing.ghostscript.cvs
Message-ID <[email protected]>
commit 8e32bd6cfe0d67b78705754339d2245513703793
Author: Sebastian Rasmussen <[email protected]>
Date:   Tue Oct 22 05:38:51 2019 +0200

    jni: Add API to check for external links.
    
    Previously Link.uri was assigned for external links only.
    Internal links used to have Link.page.
    
    Since the new Location API was added Link.uri must always
    be assigned since it contains a uri describing a link to
    an internal page.
    
    This means MuPDF now has to expose an API to distinguish
    external from internal links. This is implemented in java
    to avoid round-tripping through JNI.

diff --git a/platform/java/mupdf_native.c b/platform/java/mupdf_native.c
index 9eaaab4..a3e0742 100644
--- a/platform/java/mupdf_native.c
+++ b/platform/java/mupdf_native.c
@@ -5804,11 +5804,8 @@ FUN(Page_getLinks)(JNIEnv *env, jobject self)
 		jbounds = to_Rect_safe(ctx, env, link->rect);
 		if (!jbounds) return NULL;
 
-		if (fz_is_external_link(ctx, link->uri))
-		{
-			juri = (*env)->NewStringUTF(env, link->uri);
-			if (!juri) return NULL;
-		}
+		juri = (*env)->NewStringUTF(env, link->uri);
+		if (!juri) return NULL;
 
 		jlink = (*env)->NewObject(env, cls_Link, mid_Link_init, jbounds, juri);
 		(*env)->DeleteLocalRef(env, jbounds);
diff --git a/platform/java/src/com/artifex/mupdf/fitz/Link.java b/platform/java/src/com/artifex/mupdf/fitz/Link.java
index 5e30598..cb57f0b 100644
--- a/platform/java/src/com/artifex/mupdf/fitz/Link.java
+++ b/platform/java/src/com/artifex/mupdf/fitz/Link.java
@@ -10,6 +10,18 @@ public class Link
 		this.uri = uri;
 	}
 
+	public boolean isExternal() {
+		for (int i = 0; i < uri.length(); i++)
+		{
+			char c = uri.charAt(i);
+			if (c >= 'a' && c <= 'z')
+				continue;
+			else
+				return c == ':';
+		}
+		return false;
+	}
+
 	public String toString() {
 		return "Link(bounds="+bounds+",uri="+uri+")";
 	}

http://git.ghostscript.com/?p=mupdf.git;a=commit;h=8e32bd6cfe0d67b78705754339d2245513703793

--
MuPDF library
Artifex Software, Inc.