summaryrefslogtreecommitdiff
path: root/Build/source/libs/xpdf/xpdf-3.02-PATCHES/patch-40-objectStream-support-for-pdftosrc
blob: 773080db9f505c5b643d8ae9dc6bb9bdbdbdea8d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
	Patches for pdfTeX / luaTeX / XeTeX

	Object stream support for pdftosrc

	from:
		Han The Thanh <thanh@pdftex.org>

diff -ur xpdf-3.02.orig/xpdf/XRef.cc xpdf-3.02/xpdf/XRef.cc
--- xpdf-3.02.orig/xpdf/XRef.cc	2009-08-14 23:05:08.000000000 +0200
+++ xpdf-3.02/xpdf/XRef.cc	2009-10-15 14:32:25.000000000 +0200
@@ -5,6 +5,9 @@
 // Copyright 1996-2003 Glyph & Cog, LLC
 //
 //========================================================================
+//  Modified for TeX Live by Peter Breitenlohner <tex-live@tug.org>
+//  See top-level ChangeLog for a list of all modifications
+//========================================================================
 
 #include <aconf.h>
 
@@ -45,37 +48,9 @@
 // ObjectStream
 //------------------------------------------------------------------------
 
-class ObjectStream {
-public:
-
-  // Create an object stream, using object number <objStrNum>,
-  // generation 0.
-  ObjectStream(XRef *xref, int objStrNumA);
-
-  GBool isOk() { return ok; }
-
-  ~ObjectStream();
-
-  // Return the object number of this object stream.
-  int getObjStrNum() { return objStrNum; }
-
-  // Get the <objIdx>th object from this stream, which should be
-  // object number <objNum>, generation 0.
-  Object *getObject(int objIdx, int objNum, Object *obj);
-
-private:
-
-  int objStrNum;		// object number of the object stream
-  int nObjects;			// number of objects in the stream
-  Object *objs;			// the objects (length = nObjects)
-  int *objNums;			// the object numbers (length = nObjects)
-  GBool ok;
-};
-
 ObjectStream::ObjectStream(XRef *xref, int objStrNumA) {
   Stream *str;
   Parser *parser;
-  int *offsets;
   Object objStr, obj1, obj2;
   int first, i;
 
@@ -83,6 +58,7 @@
   nObjects = 0;
   objs = NULL;
   objNums = NULL;
+  offsets = NULL;
   ok = gFalse;
 
   if (!xref->fetch(objStrNum, 0, &objStr)->isStream()) {
@@ -104,6 +80,7 @@
     goto err1;
   }
   first = obj1.getInt();
+  firstOffset = objStr.getStream()->getBaseStream()->getStart() + first;
   obj1.free();
   if (first < 0) {
     goto err1;
@@ -132,7 +109,7 @@
       obj1.free();
       obj2.free();
       delete parser;
-      gfree(offsets);
+//    gfree(offsets);
       goto err1;
     }
     objNums[i] = obj1.getInt();
@@ -142,7 +119,7 @@
     if (objNums[i] < 0 || offsets[i] < 0 ||
 	(i > 0 && offsets[i] < offsets[i-1])) {
       delete parser;
-      gfree(offsets);
+//    gfree(offsets);
       goto err1;
     }
   }
@@ -171,7 +148,7 @@
     delete parser;
   }
 
-  gfree(offsets);
+//gfree(offsets);
   ok = gTrue;
 
  err1:
@@ -188,6 +165,7 @@
     delete[] objs;
   }
   gfree(objNums);
+  gfree(offsets);
 }
 
 Object *ObjectStream::getObject(int objIdx, int objNum, Object *obj) {
diff -ur xpdf-3.02.orig/xpdf/XRef.h xpdf-3.02/xpdf/XRef.h
--- xpdf-3.02.orig/xpdf/XRef.h	2007-02-27 23:05:52.000000000 +0100
+++ xpdf-3.02/xpdf/XRef.h	2009-10-15 14:32:30.000000000 +0200
@@ -5,6 +5,9 @@
 // Copyright 1996-2003 Glyph & Cog, LLC
 //
 //========================================================================
+//  Modified for TeX Live by Peter Breitenlohner <tex-live@tug.org>
+//  See top-level ChangeLog for a list of all modifications
+//========================================================================
 
 #ifndef XREF_H
 #define XREF_H
@@ -21,7 +24,39 @@
 class Dict;
 class Stream;
 class Parser;
-class ObjectStream;
+
+class ObjectStream {
+public:
+
+  // Create an object stream, using object number <objStrNum>,
+  // generation 0.
+  ObjectStream(XRef *xref, int objStrNumA);
+
+  GBool isOk() { return ok; }
+
+  ~ObjectStream();
+
+  // Return the object number of this object stream.
+  int getObjStrNum() { return objStrNum; }
+
+  // Get the <objIdx>th object from this stream, which should be
+  // object number <objNum>, generation 0.
+  Object *getObject(int objIdx, int objNum, Object *obj);
+
+  int *getOffsets() { return offsets; }
+  Guint getFirstOffset() { return firstOffset; }
+
+private:
+
+  int objStrNum;		// object number of the object stream
+  int nObjects;			// number of objects in the stream
+  Object *objs;			// the objects (length = nObjects)
+  int *objNums;			// the object numbers (length = nObjects)
+  int *offsets;			// the object offsets (length = nObjects)
+  Guint firstOffset;
+  GBool ok;
+};
+
 
 //------------------------------------------------------------------------
 // XRef
@@ -96,6 +131,7 @@
   int getSize() { return size; }
   XRefEntry *getEntry(int i) { return &entries[i]; }
   Object *getTrailerDict() { return &trailerDict; }
+  ObjectStream *getObjStr() { return objStr; }
 
 private: