virtual public LongHashtable Clone() { LongHashtable t = new LongHashtable(); t.count = count; t.loadFactor = loadFactor; t.threshold = threshold; t.table = new LongHashtableEntry[table.Length]; for (int i = table.Length; i-- > 0;) { t.table[i] = (table[i] != null) ? (LongHashtableEntry)table[i].Clone() : null; } return(t); }
/** Creates an independent duplicate. * @param reader the <CODE>PdfReader</CODE> to duplicate */ public PdfReader(PdfReader reader) { this.appendable = reader.appendable; this.consolidateNamedDestinations = reader.consolidateNamedDestinations; this.encrypted = reader.encrypted; this.rebuilt = reader.rebuilt; this.sharedStreams = reader.sharedStreams; this.tampered = reader.tampered; this.password = reader.password; this.pdfVersion = reader.pdfVersion; this.eofPos = reader.eofPos; this.freeXref = reader.freeXref; this.lastXref = reader.lastXref; this.newXrefType = reader.newXrefType; this.tokens = new PRTokeniser(reader.tokens.SafeFile); if (reader.decrypt != null) this.decrypt = new PdfEncryption(reader.decrypt); this.pValue = reader.pValue; this.rValue = reader.rValue; this.xrefObj = new List<PdfObject>(reader.xrefObj); for (int k = 0; k < reader.xrefObj.Count; ++k) { this.xrefObj[k] = DuplicatePdfObject(reader.xrefObj[k], this); } this.pageRefs = new PageRefs(reader.pageRefs, this); this.trailer = (PdfDictionary)DuplicatePdfObject(reader.trailer, this); this.catalog = trailer.GetAsDict(PdfName.ROOT); this.rootPages = catalog.GetAsDict(PdfName.PAGES); this.fileLength = reader.fileLength; this.partial = reader.partial; this.hybridXref = reader.hybridXref; this.objStmToOffset = reader.objStmToOffset; this.xref = reader.xref; this.cryptoRef = (PRIndirectReference)DuplicatePdfObject(reader.cryptoRef, this); this.ownerPasswordUsed = reader.ownerPasswordUsed; }
virtual protected internal bool ReadXRefStream(long ptr) { tokens.Seek(ptr); int thisStream = 0; if (!tokens.NextToken()) return false; if (tokens.TokenType != PRTokeniser.TokType.NUMBER) return false; thisStream = tokens.IntValue; if (!tokens.NextToken() || tokens.TokenType != PRTokeniser.TokType.NUMBER) return false; if (!tokens.NextToken() || !tokens.StringValue.Equals("obj")) return false; PdfObject objecto = ReadPRObject(); PRStream stm = null; if (objecto.IsStream()) { stm = (PRStream)objecto; if (!PdfName.XREF.Equals(stm.Get(PdfName.TYPE))) return false; } else return false; if (trailer == null) { trailer = new PdfDictionary(); trailer.Merge(stm); } stm.Length = ((PdfNumber)stm.Get(PdfName.LENGTH)).IntValue; int size = ((PdfNumber)stm.Get(PdfName.SIZE)).IntValue; PdfArray index; PdfObject obj = stm.Get(PdfName.INDEX); if (obj == null) { index = new PdfArray(); index.Add(new int[]{0, size}); } else index = (PdfArray)obj; PdfArray w = (PdfArray)stm.Get(PdfName.W); long prev = -1; obj = stm.Get(PdfName.PREV); if (obj != null) prev = ((PdfNumber)obj).LongValue; // Each xref pair is a position // type 0 -> -1, 0 // type 1 -> offset, 0 // type 2 -> index, obj num EnsureXrefSize(size * 2); if (objStmMark == null && !partial) objStmMark = new Dictionary<int,IntHashtable>(); if (objStmToOffset == null && partial) objStmToOffset = new LongHashtable(); byte[] b = GetStreamBytes(stm, tokens.File); int bptr = 0; int[] wc = new int[3]; for (int k = 0; k < 3; ++k) wc[k] = w.GetAsNumber(k).IntValue; for (int idx = 0; idx < index.Size; idx += 2) { int start = index.GetAsNumber(idx).IntValue; int length = index.GetAsNumber(idx + 1).IntValue; EnsureXrefSize((start + length) * 2); while (length-- > 0) { int type = 1; if (wc[0] > 0) { type = 0; for (int k = 0; k < wc[0]; ++k) type = (type << 8) + (b[bptr++] & 0xff); } long field2 = 0; for (int k = 0; k < wc[1]; ++k) field2 = (field2 << 8) + (b[bptr++] & 0xff); int field3 = 0; for (int k = 0; k < wc[2]; ++k) field3 = (field3 << 8) + (b[bptr++] & 0xff); int baseb = start * 2; if (xref[baseb] == 0 && xref[baseb + 1] == 0) { switch (type) { case 0: xref[baseb] = -1; break; case 1: xref[baseb] = field2; break; case 2: xref[baseb] = field3; xref[baseb + 1] = field2; if (partial) { objStmToOffset[field2] = 0; } else { IntHashtable seq; if (!objStmMark.TryGetValue((int)field2, out seq)) { seq = new IntHashtable(); seq[field3] = 1; objStmMark[(int)field2] = seq; } else seq[field3] = 1; } break; } } ++start; } } thisStream *= 2; if (thisStream + 1 < xref.Length && xref[thisStream] == 0 && xref[thisStream + 1] == 0) xref[thisStream] = -1; if (prev == -1) return true; return ReadXRefStream(prev); }
public LongHashtable Clone() { LongHashtable t = new LongHashtable(); t.count = count; t.loadFactor = loadFactor; t.threshold = threshold; t.table = new LongHashtableEntry[table.Length]; for (int i = table.Length ; i-- > 0 ; ) { t.table[i] = (table[i] != null) ? (LongHashtableEntry)table[i].Clone() : null; } return t; }