Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(273)

Side by Side Diff: experimental/PdfViewer/autogen/SkPdfImageDictionary_autogen.h

Issue 17748002: Basic support for Type3 Fonts in Pdf + various refactorings (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 #ifndef __DEFINED__SkPdfImageDictionary
2 #define __DEFINED__SkPdfImageDictionary
3
4 #include "SkPdfUtils.h"
5 #include "SkPdfEnums_autogen.h"
6 #include "SkPdfArray_autogen.h"
7 #include "SkPdfXObjectDictionary_autogen.h"
8
9 // Additional entries specific to an image dictionary
10 class SkPdfImageDictionary : public SkPdfXObjectDictionary {
11 public:
12 virtual SkPdfObjectType getType() const { return kImageDictionary_SkPdfObjectT ype;}
13 virtual SkPdfObjectType getTypeEnd() const { return (SkPdfObjectType)(kImageDi ctionary_SkPdfObjectType + 1);}
14 public:
15 virtual SkPdfImageDictionary* asImageDictionary() {return this;}
16 virtual const SkPdfImageDictionary* asImageDictionary() const {return this;}
17
18 private:
19 virtual SkPdfType1FormDictionary* asType1FormDictionary() {return NULL;}
20 virtual const SkPdfType1FormDictionary* asType1FormDictionary() const {return NULL;}
21
22 public:
23 private:
24 public:
25 SkPdfImageDictionary(const PdfMemDocument* podofoDoc = NULL, const PdfObject* podofoObj = NULL) : SkPdfXObjectDictionary(podofoDoc, podofoObj) {}
26
27 SkPdfImageDictionary(const SkPdfImageDictionary& from) : SkPdfXObjectDictionar y(from.fPodofoDoc, from.fPodofoObj) {}
28
29 virtual bool valid() const {return true;}
30
31 SkPdfImageDictionary& operator=(const SkPdfImageDictionary& from) {this->fPodo foDoc = from.fPodofoDoc; this->fPodofoObj = from.fPodofoObj; return *this;}
32
33 /** (Optional) The type of PDF object that this dictionary describes; if
34 * present, must be XObject for an image XObject.
35 **/
36 bool has_Type() const {
37 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Type" , "", NULL));
38 }
39
40 std::string Type() const {
41 std::string ret;
42 if (NameFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Type", "", &ret)) return ret;
43 // TODO(edisonn): warn about missing required field, assert for known good p dfs
44 return "";
45 }
46
47 /** (Required) The type of XObject that this dictionary describes; must be
48 * Image for an image XObject.
49 **/
50 bool has_Subtype() const {
51 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Subty pe", "", NULL));
52 }
53
54 std::string Subtype() const {
55 std::string ret;
56 if (NameFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Subtype", " ", &ret)) return ret;
57 // TODO(edisonn): warn about missing required field, assert for known good p dfs
58 return "";
59 }
60
61 /** (Required) The width of the image, in samples.
62 **/
63 bool has_Width() const {
64 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Width ", "", NULL));
65 }
66
67 long Width() const {
68 long ret;
69 if (LongFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Width", "", &ret)) return ret;
70 // TODO(edisonn): warn about missing required field, assert for known good p dfs
71 return 0;
72 }
73
74 /** (Required) The height of the image, in samples.
75 **/
76 bool has_Height() const {
77 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Heigh t", "", NULL));
78 }
79
80 long Height() const {
81 long ret;
82 if (LongFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Height", "" , &ret)) return ret;
83 // TODO(edisonn): warn about missing required field, assert for known good p dfs
84 return 0;
85 }
86
87 /** (Required except for image masks; not allowed for image masks) The color
88 * space in which image samples are specified. This may be any type of color
89 * space except Pattern.
90 **/
91 bool has_ColorSpace() const {
92 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Color Space", "", NULL));
93 }
94
95 bool isColorSpaceAName() const {
96 SkPdfObject* ret = NULL;
97 if (!ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "ColorSpa ce", "", &ret)) return false;
98 return ret->podofo()->GetDataType() == ePdfDataType_Name;
99 }
100
101 std::string getColorSpaceAsName() const {
102 std::string ret = "";
103 if (NameFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "ColorSpace" , "", &ret)) return ret;
104 // TODO(edisonn): warn about missing required field, assert for known good p dfs
105 return "";
106 }
107
108 bool isColorSpaceAArray() const {
109 SkPdfObject* ret = NULL;
110 if (!ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "ColorSpa ce", "", &ret)) return false;
111 return ret->podofo()->GetDataType() == ePdfDataType_Array;
112 }
113
114 SkPdfArray* getColorSpaceAsArray() const {
115 SkPdfArray* ret = NULL;
116 if (ArrayFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "ColorSpace ", "", &ret)) return ret;
117 // TODO(edisonn): warn about missing required field, assert for known good p dfs
118 return NULL;
119 }
120
121 /** (Required except for image masks; optional for image masks) The number of
122 * bits used to represent each color component. Only a single value may be
123 * specified; the number of bits is the same for all color components. Valid
124 * values are 1, 2, 4, and 8. If ImageMask is true, this entry is optional, and if
125 * specified, its value must be 1.
126 * If the image stream uses a filter, the value of BitsPerComponent must be
127 * consistent with the size of the data samples that the filter delivers. In pa r-
128 * ticular, a CCITTFaxDecode or JBIG2Decode filter always delivers 1-bit sam-
129 * ples, a RunLengthDecode or DCTDecode filter delivers 8-bit samples, and
130 * an LZWDecode or FlateDecode filter delivers samples of a specified size if
131 * a predictor function is used.
132 **/
133 bool has_BitsPerComponent() const {
134 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "BitsP erComponent", "", NULL));
135 }
136
137 long BitsPerComponent() const {
138 long ret;
139 if (LongFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "BitsPerComp onent", "", &ret)) return ret;
140 // TODO(edisonn): warn about missing required field, assert for known good p dfs
141 return 0;
142 }
143
144 /** (Optional; PDF 1.1) The name of a color rendering intent to be used in
145 * rendering the image (see "Rendering Intents" on page 197). Default value:
146 * the current rendering intent in the graphics state.
147 **/
148 bool has_Intent() const {
149 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Inten t", "", NULL));
150 }
151
152 std::string Intent() const {
153 std::string ret;
154 if (NameFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Intent", "" , &ret)) return ret;
155 // TODO(edisonn): warn about missing required field, assert for known good p dfs
156 return "";
157 }
158
159 /** (Optional) A flag indicating whether the image is to be treated as an image
160 * mask (see Section 4.8.5, "Masked Images"). If this flag is true, the value o f
161 * BitsPerComponent must be 1 and Mask and ColorSpace should not be
162 * specified; unmasked areas will be painted using the current nonstroking
163 * color. Default value: false.
164 **/
165 bool has_ImageMask() const {
166 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Image Mask", "", NULL));
167 }
168
169 bool ImageMask() const {
170 bool ret;
171 if (BoolFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "ImageMask", "", &ret)) return ret;
172 // TODO(edisonn): warn about missing required field, assert for known good p dfs
173 return false;
174 }
175
176 /** (Optional except for image masks; not allowed for image masks; PDF 1.3) An
177 * image XObject defining an image mask to be applied to this image (see
178 * "Explicit Masking" on page 277), or an array specifying a range of colors
179 * to be applied to it as a color key mask (see "Color Key Masking" on page
180 * 277). If ImageMask is true, this entry must not be present. (See
181 * implementation note 35 in Appendix H.)
182 **/
183 bool has_Mask() const {
184 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Mask" , "", NULL));
185 }
186
187 bool isMaskAStream() const {
188 SkPdfObject* ret = NULL;
189 if (!ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Mask", " ", &ret)) return false;
190 return ret->podofo()->HasStream();
191 }
192
193 SkPdfStream* getMaskAsStream() const {
194 SkPdfStream* ret = NULL;
195 if (StreamFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Mask", "" , &ret)) return ret;
196 // TODO(edisonn): warn about missing required field, assert for known good p dfs
197 return NULL;
198 }
199
200 bool isMaskAArray() const {
201 SkPdfObject* ret = NULL;
202 if (!ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Mask", " ", &ret)) return false;
203 return ret->podofo()->GetDataType() == ePdfDataType_Array;
204 }
205
206 SkPdfArray* getMaskAsArray() const {
207 SkPdfArray* ret = NULL;
208 if (ArrayFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Mask", "", &ret)) return ret;
209 // TODO(edisonn): warn about missing required field, assert for known good p dfs
210 return NULL;
211 }
212
213 /** (Optional; PDF 1.4) A subsidiary image XObject defining a soft-mask
214 * image (see "Soft-Mask Images" on page 447) to be used as a source of
215 * mask shape or mask opacity values in the transparent imaging model. The
216 * alpha source parameter in the graphics state determines whether the mask
217 * values are interpreted as shape or opacity.
218 * If present, this entry overrides the current soft mask in the graphics state ,
219 * as well as the image's Mask entry, if any. (However, the other transparency-
220 * related graphics state parameters-blend mode and alpha constant-
221 * remain in effect.) If SMask is absent, the image has no associated soft mask
222 * (although the current soft mask in the graphics state may still apply).
223 **/
224 bool has_SMask() const {
225 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "SMask ", "", NULL));
226 }
227
228 SkPdfStream* SMask() const {
229 SkPdfStream* ret;
230 if (StreamFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "SMask", " ", &ret)) return ret;
231 // TODO(edisonn): warn about missing required field, assert for known good p dfs
232 return NULL;
233 }
234
235 /** (Optional) An array of numbers describing how to map image samples
236 * into the range of values appropriate for the image's color space (see
237 * "Decode Arrays" on page 271). If ImageMask is true, the array must be
238 * either [0 1] or [1 0]; otherwise, its length must be twice the number of
239 * color components required by ColorSpace. Default value: see "Decode
240 * Arrays" on page 271.
241 **/
242 bool has_Decode() const {
243 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Decod e", "", NULL));
244 }
245
246 SkPdfArray* Decode() const {
247 SkPdfArray* ret;
248 if (ArrayFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Decode", " ", &ret)) return ret;
249 // TODO(edisonn): warn about missing required field, assert for known good p dfs
250 return NULL;
251 }
252
253 /** (Optional) A flag indicating whether image interpolation is to be per-
254 * formed (see "Image Interpolation" on page 273). Default value: false.
255 **/
256 bool has_Interpolate() const {
257 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Inter polate", "", NULL));
258 }
259
260 bool Interpolate() const {
261 bool ret;
262 if (BoolFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Interpolate ", "", &ret)) return ret;
263 // TODO(edisonn): warn about missing required field, assert for known good p dfs
264 return false;
265 }
266
267 /** (Optional; PDF 1.3) An array of alternate image dictionaries for this image
268 * (see "Alternate Images" on page 273). The order of elements within the
269 * array has no significance. This entry may not be present in an image
270 * XObject that is itself an alternate image.
271 **/
272 bool has_Alternates() const {
273 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Alter nates", "", NULL));
274 }
275
276 SkPdfArray* Alternates() const {
277 SkPdfArray* ret;
278 if (ArrayFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Alternates ", "", &ret)) return ret;
279 // TODO(edisonn): warn about missing required field, assert for known good p dfs
280 return NULL;
281 }
282
283 /** (Required in PDF 1.0; optional otherwise) The name by which this image
284 * XObject is referenced in the XObject subdictionary of the current resource
285 * dictionary (see Section 3.7.2, "Resource Dictionaries").
286 * Note: This entry is obsolescent and its use is no longer recommended. (See
287 * implementation note 36 in Appendix H.)
288 **/
289 bool has_Name() const {
290 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Name" , "", NULL));
291 }
292
293 std::string Name() const {
294 std::string ret;
295 if (NameFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Name", "", &ret)) return ret;
296 // TODO(edisonn): warn about missing required field, assert for known good p dfs
297 return "";
298 }
299
300 /** (Required if the image is a structural content item; PDF 1.3) The integer ke y
301 * of the image's entry in the structural parent tree (see "Finding Structure
302 * Elements from Content Items" on page 600).
303 **/
304 bool has_StructParent() const {
305 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Struc tParent", "", NULL));
306 }
307
308 long StructParent() const {
309 long ret;
310 if (LongFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "StructParen t", "", &ret)) return ret;
311 // TODO(edisonn): warn about missing required field, assert for known good p dfs
312 return 0;
313 }
314
315 /** (Optional; PDF 1.3; indirect reference preferred) The digital identifier of the
316 * image's parent Web Capture content set (see Section 9.9.5, "Object At-
317 * tributes Related to Web Capture").
318 **/
319 bool has_ID() const {
320 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "ID", "", NULL));
321 }
322
323 std::string ID() const {
324 std::string ret;
325 if (StringFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "ID", "", &ret)) return ret;
326 // TODO(edisonn): warn about missing required field, assert for known good p dfs
327 return "";
328 }
329
330 /** (Optional; PDF 1.2) An OPI version dictionary for the image (see Section
331 * 9.10.6, "Open Prepress Interface (OPI)"). If ImageMask is true, this entry
332 * is ignored.
333 **/
334 bool has_OPI() const {
335 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "OPI", "", NULL));
336 }
337
338 SkPdfDictionary* OPI() const {
339 SkPdfDictionary* ret;
340 if (DictionaryFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "OPI", "", &ret)) return ret;
341 // TODO(edisonn): warn about missing required field, assert for known good p dfs
342 return NULL;
343 }
344
345 /** (Optional; PDF 1.4) A metadata stream containing metadata for the image
346 * (see Section 9.2.2, "Metadata Streams").
347 **/
348 bool has_Metadata() const {
349 return (ObjectFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Metad ata", "", NULL));
350 }
351
352 SkPdfStream* Metadata() const {
353 SkPdfStream* ret;
354 if (StreamFromDictionary(fPodofoDoc, fPodofoObj->GetDictionary(), "Metadata" , "", &ret)) return ret;
355 // TODO(edisonn): warn about missing required field, assert for known good p dfs
356 return NULL;
357 }
358
359 };
360
361 #endif // __DEFINED__SkPdfImageDictionary
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698