153 lines
5.1 KiB
Java
153 lines
5.1 KiB
Java
package com.shockwave.pdfium;
|
|
|
|
import android.content.Context;
|
|
import android.graphics.Bitmap;
|
|
import android.graphics.Point;
|
|
import android.graphics.RectF;
|
|
import android.os.ParcelFileDescriptor;
|
|
import com.shockwave.pdfium.util.Size;
|
|
import java.io.FileDescriptor;
|
|
import java.io.IOException;
|
|
import java.lang.reflect.Field;
|
|
import java.util.ArrayList;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import o.C12960fMh;
|
|
|
|
/* loaded from: classes5.dex */
|
|
public class PdfiumCore {
|
|
private static Field a;
|
|
private static final Class c = FileDescriptor.class;
|
|
public static final Object e;
|
|
public int b;
|
|
|
|
public native void nativeCloseDocument(long j);
|
|
|
|
public native void nativeClosePage(long j);
|
|
|
|
public native Integer nativeGetDestPageIndex(long j, long j2);
|
|
|
|
public native RectF nativeGetLinkRect(long j);
|
|
|
|
public native String nativeGetLinkURI(long j, long j2);
|
|
|
|
public native int nativeGetPageCount(long j);
|
|
|
|
public native long[] nativeGetPageLinks(long j);
|
|
|
|
public native Size nativeGetPageSizeByIndex(long j, int i, int i2);
|
|
|
|
public native long nativeLoadPage(long j, int i);
|
|
|
|
public native long nativeOpenDocument(int i, String str);
|
|
|
|
public native Point nativePageCoordsToDevice(long j, int i, int i2, int i3, int i4, int i5, double d, double d2);
|
|
|
|
public native void nativeRenderPageBitmap(long j, Bitmap bitmap, int i, int i2, int i3, int i4, int i5, boolean z);
|
|
|
|
static {
|
|
try {
|
|
System.loadLibrary("k8fd15");
|
|
System.loadLibrary("of2807");
|
|
System.loadLibrary("l88519");
|
|
System.loadLibrary("pe451e");
|
|
System.loadLibrary("qa0d74");
|
|
} catch (UnsatisfiedLinkError unused) {
|
|
}
|
|
e = new Object();
|
|
a = null;
|
|
}
|
|
|
|
private static int aAM_(ParcelFileDescriptor parcelFileDescriptor) {
|
|
try {
|
|
if (a == null) {
|
|
Field declaredField = c.getDeclaredField("descriptor");
|
|
a = declaredField;
|
|
declaredField.setAccessible(true);
|
|
}
|
|
return a.getInt(parcelFileDescriptor.getFileDescriptor());
|
|
} catch (IllegalAccessException | NoSuchFieldException unused) {
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
public PdfiumCore(Context context) {
|
|
this.b = context.getResources().getDisplayMetrics().densityDpi;
|
|
}
|
|
|
|
public final C12960fMh aAO_(ParcelFileDescriptor parcelFileDescriptor, String str) throws IOException {
|
|
C12960fMh c12960fMh = new C12960fMh();
|
|
c12960fMh.b = parcelFileDescriptor;
|
|
synchronized (e) {
|
|
c12960fMh.a = nativeOpenDocument(aAM_(parcelFileDescriptor), str);
|
|
}
|
|
return c12960fMh;
|
|
}
|
|
|
|
public final int c(C12960fMh c12960fMh) {
|
|
int nativeGetPageCount;
|
|
synchronized (e) {
|
|
nativeGetPageCount = nativeGetPageCount(c12960fMh.a);
|
|
}
|
|
return nativeGetPageCount;
|
|
}
|
|
|
|
public final long d(C12960fMh c12960fMh, int i) {
|
|
long nativeLoadPage;
|
|
synchronized (e) {
|
|
nativeLoadPage = nativeLoadPage(c12960fMh.a, i);
|
|
c12960fMh.e.put(Integer.valueOf(i), Long.valueOf(nativeLoadPage));
|
|
}
|
|
return nativeLoadPage;
|
|
}
|
|
|
|
public final Size c(C12960fMh c12960fMh, int i) {
|
|
Size nativeGetPageSizeByIndex;
|
|
synchronized (e) {
|
|
nativeGetPageSizeByIndex = nativeGetPageSizeByIndex(c12960fMh.a, i, this.b);
|
|
}
|
|
return nativeGetPageSizeByIndex;
|
|
}
|
|
|
|
public final void a(C12960fMh c12960fMh) {
|
|
synchronized (e) {
|
|
Iterator<Integer> it = c12960fMh.e.keySet().iterator();
|
|
while (it.hasNext()) {
|
|
nativeClosePage(c12960fMh.e.get(it.next()).longValue());
|
|
}
|
|
c12960fMh.e.clear();
|
|
nativeCloseDocument(c12960fMh.a);
|
|
if (c12960fMh.b != null) {
|
|
try {
|
|
c12960fMh.b.close();
|
|
} catch (IOException unused) {
|
|
}
|
|
c12960fMh.b = null;
|
|
}
|
|
}
|
|
}
|
|
|
|
public final List<C12960fMh.IeS> a(C12960fMh c12960fMh, int i) {
|
|
synchronized (e) {
|
|
ArrayList arrayList = new ArrayList();
|
|
Long l = c12960fMh.e.get(Integer.valueOf(i));
|
|
if (l == null) {
|
|
return arrayList;
|
|
}
|
|
for (long j : nativeGetPageLinks(l.longValue())) {
|
|
Integer nativeGetDestPageIndex = nativeGetDestPageIndex(c12960fMh.a, j);
|
|
String nativeGetLinkURI = nativeGetLinkURI(c12960fMh.a, j);
|
|
RectF nativeGetLinkRect = nativeGetLinkRect(j);
|
|
if (nativeGetLinkRect != null && (nativeGetDestPageIndex != null || nativeGetLinkURI != null)) {
|
|
arrayList.add(new C12960fMh.IeS(nativeGetLinkRect, nativeGetDestPageIndex, nativeGetLinkURI));
|
|
}
|
|
}
|
|
return arrayList;
|
|
}
|
|
}
|
|
|
|
public final Point aAN_(C12960fMh c12960fMh, int i, int i2, int i3, int i4, int i5, double d, double d2) {
|
|
return nativePageCoordsToDevice(c12960fMh.e.get(Integer.valueOf(i)).longValue(), i2, i3, i4, i5, 0, d, d2);
|
|
}
|
|
}
|