// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space
package com.lowagie.text.pdf;
import com.lowagie.text.*;
import com.lowagie.text.exceptions.*;
import com.lowagie.text.pdf.interfaces.PdfViewerPreferences;
import com.lowagie.text.pdf.internal.PdfViewerPreferencesImp;
import java.io.*;
import java.net.URL;
import java.security.Key;
import java.security.MessageDigest;
import java.security.cert.Certificate;
import java.util.*;
import java.util.zip.InflaterInputStream;
import org.bouncycastle.cms.*;
// Referenced classes of package com.lowagie.text.pdf:
// PRTokeniser, RandomAccessFileOrArray, PdfEncryption, PdfObject,
// PdfDictionary, PRIndirectReference, PdfReaderInstance, PRAcroForm,
// PdfArray, PdfName, PdfString, PdfNumber,
// PdfIndirectReference, PdfNull, PdfBoolean, PRStream,
// IntHashtable, PdfLiteral, LZWDecoder, AcroFields,
// PdfEncodings, BaseFont, PdfNameTree, PdfAnnotation,
// SequenceList, PdfWriter
public class PdfReader
implements PdfViewerPreferences
{
static class PageRefs
{
private PdfReader reader;
private IntHashtable refsp;
private ArrayList refsn;
private ArrayList pageInh;
private int lastPageRead;
private int sizep;
private boolean keepPages;
int size()
{
if (refsn != null)
return refsn.size();
else
return sizep;
}
void readPages()
throws IOException
{
if (refsn != null)
{
return;
} else
{
refsp = null;
refsn = new ArrayList();
pageInh = new ArrayList();
iteratePages((PRIndirectReference)reader.catalog.get(PdfName.PAGES));
pageInh = null;
reader.rootPages.put(PdfName.COUNT, new PdfNumber(refsn.size()));
return;
}
}
void reReadPages()
throws IOException
{
refsn = null;
readPages();
}
public PdfDictionary getPageN(int i)
{
PRIndirectReference prindirectreference = getPageOrigRef(i);
return (PdfDictionary)PdfReader.getPdfObject(prindirectreference);
}
public PdfDictionary getPageNRelease(int i)
{
PdfDictionary pdfdictionary = getPageN(i);
releasePage(i);
return pdfdictionary;
}
public PRIndirectReference getPageOrigRefRelease(int i)
{
PRIndirectReference prindirectreference = getPageOrigRef(i);
releasePage(i);
return prindirectreference;
}
public PRIndirectReference getPageOrigRef(int i)
{
if (--i < 0 || i >= size())
return null;
if (refsn != null)
return (PRIndirectReference)refsn.get(i);
int j;
PRIndirectReference prindirectreference;
j = refsp.get(i);
if (j != 0)
break MISSING_BLOCK_LABEL_115;
prindirectreference = getSinglePage(i);
if (reader.lastXrefPartial == -1)
lastPageRead = -1;
else
lastPageRead = i;
reader.lastXrefPartial = -1;
refsp.put(i, prindirectreference.getNumber());
if (keepPages)
lastPageRead = -1;
return prindirectreference;
if (lastPageRead != i)
lastPageRead = -1;
if (keepPages)
lastPageRead = -1;
return new PRIndirectReference(reader, j);
Exception exception;
exception;
throw new ExceptionConverter(exception);
}
void keepPages()
{
if (refsp == null || keepPages)
{
return;
} else
{
keepPages = true;
refsp.clear();
return;
}
}
public void releasePage(int i)
{
if (refsp == null)
return;
if (--i < 0 || i >= size())
return;
if (i != lastPageRead)
{
return;
} else
{
lastPageRead = -1;
reader.lastXrefPartial = refsp.get(i);
reader.releaseLastXrefPartial();
refsp.remove(i);
return;
}
}
public void resetReleasePage()
{
if (refsp == null)
{
return;
} else
{
lastPageRead = -1;
return;
}
}
void insertPage(int i, PRIndirectReference prindirectreference)
{
i--;
if (refsn != null)
{
if (i >= refsn.size())
refsn.add(prindirectreference);
else
refsn.add(i, prindirectreference);
} else
{
sizep++;
lastPageRead = -1;
if (i >= size())
{
refsp.put(size(), prindirectreference.getNumber());
} else
{
IntHashtable inthashtable = new IntHashtable((refsp.size() + 1) * 2);
IntHashtable.Entry entry;
int j;
for (Iterator iterator = refsp.getEntryIterator(); iterator.hasNext(); inthashtable.put(j < i ? j : j + 1, entry.getValue()))
{
entry = (IntHashtable.Entry)iterator.next();
j = entry.getKey();
}
inthashtable.put(i, prindirectreference.getNumber());
refsp = inthashtable;
}
}
}
private void pushPageAttributes(PdfDictionary pdfdictionary)
{
PdfDictionary pdfdictionary1 = new PdfDictionary();
if (!pageInh.isEmpty())
pdfdictionary1.putAll((PdfDictionary)pageInh.get(pageInh.size() - 1));
for (int i = 0; i < PdfReader.pageInhCandidates.length; i++)
{
PdfObject pdfobject = pdfdictionary.get(PdfReader.pageInhCandidates[i]);
if (pdfobject != null)
pdfdictionary1.put(PdfReader.pageInhCandidates[i], pdfobject);
}
pageInh.add(pdfdictionary1);
}
private void popPageAttributes()
{
pageInh.remove(pageInh.size() - 1);
}
private void iteratePages(PRIndirectReference prindirectreference)
throws IOException
{
PdfDictionary pdfdictionary = (PdfDictionary)PdfReader.getPdfObject(prindirectreference);
PdfArray pdfarray = pdfdictionary.getAsArray(PdfName.KIDS);
if (pdfarray == null)
{
pdfdictionary.put(PdfName.TYPE, PdfName.PAGE);
PdfDictionary pdfdictionary1 = (PdfDictionary)pageInh.get(pageInh.size() - 1);
Iterator iterator = pdfdictionary1.getKeys().iterator();
do
{
if (!iterator.hasNext())
break;
PdfName pdfname = (PdfName)iterator.next();
if (pdfdictionary.get(pdfname) == null)
pdfdictionary.put(pdfname, pdfdictionary1.get(pdfname));
} while (true);
if (pdfdictionary.get(PdfName.MEDIABOX) == null)
{
PdfArray pdfarray1 = new PdfArray(new float[] {
0.0F, 0.0F, PageSize.LETTER.getRight(), PageSize.LETTER.getTop()
});
pdfdictionary.put(PdfName.MEDIABOX, pdfarray1);
}
refsn.add(prindirectreference);
} else
{
pdfdictionary.put(PdfName.TYPE, PdfName.PAGES);
pushPageAttributes(pdfdictionary);
int i = 0;
do
{
if (i >= pdfarray.size())
break;
PdfObject pdfobject = pdfarray.getPdfObject(i);
if (!pdfobject.isIndirect())
{
for (; i < pdfarray.size(); pdfarray.remove(i));
break;
}
iteratePages((PRIndirectReference)pdfobject);
i++;
} while (true);
popPageAttributes();
}
}
protected PRIndirectReference getSinglePage(int i)
{
PdfDictionary pdfdictionary;
PdfDictionary pdfdictionary1;
int j;
pdfdictionary = new PdfDictionary();
pdfdictionary1 = reader.rootPages;
j = 0;
_L2:
for (int k = 0; k < PdfReader.pageInhCandidates.length; k++)
{
PdfObject pdfobject = pdfdictionary1.get(PdfReader.pageInhCandidates[k]);
if (pdfobject != null)
pdfdictionary.put(PdfReader.pageInhCandidates[k], pdfobject);
}
PdfArray pdfarray = (PdfArray)PdfReader.getPdfObjectRelease(pdfdictionary1.get(PdfName.KIDS));
java.util.ListIterator listiterator = pdfarray.listIterator();
do
{
int i1;
if (listiterator.hasNext())
{
label0:
{
PRIndirectReference prindirectreference = (PRIndirectReference)listiterator.next();
PdfDictionary pdfdictionary2 = (PdfDictionary)PdfReader.getPdfObject(prindirectreference);
int l = reader.lastXrefPartial;
PdfObject pdfobject1 = PdfReader.getPdfObjectRelease(pdfdictionary2.get(Pdf