1 /*
2  * Copyright 2013 Google Inc.
3 
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #include "SkPdfImageDictionary_autogen.h"
9 #include "SkPdfNativeDoc.h"
10 
Type(SkPdfNativeDoc * doc)11 SkString SkPdfImageDictionary::Type(SkPdfNativeDoc* doc) {
12   SkPdfNativeObject* ret = get("Type", "");
13   if (doc) {ret = doc->resolveReference(ret);}
14   if ((ret != NULL && ret->isName()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->nameValue2();
15   // TODO(edisonn): warn about missing default value for optional fields
16   return SkString();
17 }
18 
has_Type() const19 bool SkPdfImageDictionary::has_Type() const {
20   return get("Type", "") != NULL;
21 }
22 
Subtype(SkPdfNativeDoc * doc)23 SkString SkPdfImageDictionary::Subtype(SkPdfNativeDoc* doc) {
24   SkPdfNativeObject* ret = get("Subtype", "");
25   if (doc) {ret = doc->resolveReference(ret);}
26   if ((ret != NULL && ret->isName()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->nameValue2();
27   // TODO(edisonn): warn about missing required field, assert for known good pdfs
28   return SkString();
29 }
30 
has_Subtype() const31 bool SkPdfImageDictionary::has_Subtype() const {
32   return get("Subtype", "") != NULL;
33 }
34 
Width(SkPdfNativeDoc * doc)35 int64_t SkPdfImageDictionary::Width(SkPdfNativeDoc* doc) {
36   SkPdfNativeObject* ret = get("Width", "");
37   if (doc) {ret = doc->resolveReference(ret);}
38   if ((ret != NULL && ret->isInteger()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->intValue();
39   // TODO(edisonn): warn about missing required field, assert for known good pdfs
40   return 0;
41 }
42 
has_Width() const43 bool SkPdfImageDictionary::has_Width() const {
44   return get("Width", "") != NULL;
45 }
46 
Height(SkPdfNativeDoc * doc)47 int64_t SkPdfImageDictionary::Height(SkPdfNativeDoc* doc) {
48   SkPdfNativeObject* ret = get("Height", "");
49   if (doc) {ret = doc->resolveReference(ret);}
50   if ((ret != NULL && ret->isInteger()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->intValue();
51   // TODO(edisonn): warn about missing required field, assert for known good pdfs
52   return 0;
53 }
54 
has_Height() const55 bool SkPdfImageDictionary::has_Height() const {
56   return get("Height", "") != NULL;
57 }
58 
isColorSpaceAName(SkPdfNativeDoc * doc)59 bool SkPdfImageDictionary::isColorSpaceAName(SkPdfNativeDoc* doc) {
60   SkPdfNativeObject* ret = get("ColorSpace", "");
61   if (doc) {ret = doc->resolveReference(ret);}
62   return ret != NULL && ret->isName();
63 }
64 
getColorSpaceAsName(SkPdfNativeDoc * doc)65 SkString SkPdfImageDictionary::getColorSpaceAsName(SkPdfNativeDoc* doc) {
66   SkPdfNativeObject* ret = get("ColorSpace", "");
67   if (doc) {ret = doc->resolveReference(ret);}
68   if ((ret != NULL && ret->isName()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->nameValue2();
69   // TODO(edisonn): warn about missing default value for optional fields
70   return SkString();
71 }
72 
isColorSpaceAArray(SkPdfNativeDoc * doc)73 bool SkPdfImageDictionary::isColorSpaceAArray(SkPdfNativeDoc* doc) {
74   SkPdfNativeObject* ret = get("ColorSpace", "");
75   if (doc) {ret = doc->resolveReference(ret);}
76   return ret != NULL && ret->isArray();
77 }
78 
getColorSpaceAsArray(SkPdfNativeDoc * doc)79 SkPdfArray* SkPdfImageDictionary::getColorSpaceAsArray(SkPdfNativeDoc* doc) {
80   SkPdfNativeObject* ret = get("ColorSpace", "");
81   if (doc) {ret = doc->resolveReference(ret);}
82   if ((ret != NULL && ret->isArray()) || (doc == NULL && ret != NULL && ret->isReference())) return (SkPdfArray*)ret;
83   // TODO(edisonn): warn about missing default value for optional fields
84   return NULL;
85 }
86 
has_ColorSpace() const87 bool SkPdfImageDictionary::has_ColorSpace() const {
88   return get("ColorSpace", "") != NULL;
89 }
90 
BitsPerComponent(SkPdfNativeDoc * doc)91 int64_t SkPdfImageDictionary::BitsPerComponent(SkPdfNativeDoc* doc) {
92   SkPdfNativeObject* ret = get("BitsPerComponent", "");
93   if (doc) {ret = doc->resolveReference(ret);}
94   if ((ret != NULL && ret->isInteger()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->intValue();
95   // TODO(edisonn): warn about missing default value for optional fields
96   return 0;
97 }
98 
has_BitsPerComponent() const99 bool SkPdfImageDictionary::has_BitsPerComponent() const {
100   return get("BitsPerComponent", "") != NULL;
101 }
102 
Intent(SkPdfNativeDoc * doc)103 SkString SkPdfImageDictionary::Intent(SkPdfNativeDoc* doc) {
104   SkPdfNativeObject* ret = get("Intent", "");
105   if (doc) {ret = doc->resolveReference(ret);}
106   if ((ret != NULL && ret->isName()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->nameValue2();
107   // TODO(edisonn): warn about missing default value for optional fields
108   return SkString();
109 }
110 
has_Intent() const111 bool SkPdfImageDictionary::has_Intent() const {
112   return get("Intent", "") != NULL;
113 }
114 
ImageMask(SkPdfNativeDoc * doc)115 bool SkPdfImageDictionary::ImageMask(SkPdfNativeDoc* doc) {
116   SkPdfNativeObject* ret = get("ImageMask", "");
117   if (doc) {ret = doc->resolveReference(ret);}
118   if ((ret != NULL && ret->isBoolean()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->boolValue();
119   // TODO(edisonn): warn about missing default value for optional fields
120   return false;
121 }
122 
has_ImageMask() const123 bool SkPdfImageDictionary::has_ImageMask() const {
124   return get("ImageMask", "") != NULL;
125 }
126 
isMaskAStream(SkPdfNativeDoc * doc)127 bool SkPdfImageDictionary::isMaskAStream(SkPdfNativeDoc* doc) {
128   SkPdfNativeObject* ret = get("Mask", "");
129   if (doc) {ret = doc->resolveReference(ret);}
130   return ret != NULL && ret->hasStream();
131 }
132 
getMaskAsStream(SkPdfNativeDoc * doc)133 SkPdfStream* SkPdfImageDictionary::getMaskAsStream(SkPdfNativeDoc* doc) {
134   SkPdfNativeObject* ret = get("Mask", "");
135   if (doc) {ret = doc->resolveReference(ret);}
136   if ((ret != NULL && ret->hasStream()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->getStream();
137   // TODO(edisonn): warn about missing default value for optional fields
138   return NULL;
139 }
140 
isMaskAArray(SkPdfNativeDoc * doc)141 bool SkPdfImageDictionary::isMaskAArray(SkPdfNativeDoc* doc) {
142   SkPdfNativeObject* ret = get("Mask", "");
143   if (doc) {ret = doc->resolveReference(ret);}
144   return ret != NULL && ret->isArray();
145 }
146 
getMaskAsArray(SkPdfNativeDoc * doc)147 SkPdfArray* SkPdfImageDictionary::getMaskAsArray(SkPdfNativeDoc* doc) {
148   SkPdfNativeObject* ret = get("Mask", "");
149   if (doc) {ret = doc->resolveReference(ret);}
150   if ((ret != NULL && ret->isArray()) || (doc == NULL && ret != NULL && ret->isReference())) return (SkPdfArray*)ret;
151   // TODO(edisonn): warn about missing default value for optional fields
152   return NULL;
153 }
154 
has_Mask() const155 bool SkPdfImageDictionary::has_Mask() const {
156   return get("Mask", "") != NULL;
157 }
158 
SMask(SkPdfNativeDoc * doc)159 SkPdfImageDictionary* SkPdfImageDictionary::SMask(SkPdfNativeDoc* doc) {
160   SkPdfNativeObject* ret = get("SMask", "");
161   if (doc) {ret = doc->resolveReference(ret);}
162   if ((ret != NULL && ret->isDictionary() && ((SkPdfImageDictionary*)ret)->valid()) || (doc == NULL && ret != NULL && ret->isReference())) return (SkPdfImageDictionary*)ret;
163   // TODO(edisonn): warn about missing default value for optional fields
164   return NULL;
165 }
166 
has_SMask() const167 bool SkPdfImageDictionary::has_SMask() const {
168   return get("SMask", "") != NULL;
169 }
170 
Decode(SkPdfNativeDoc * doc)171 SkPdfArray* SkPdfImageDictionary::Decode(SkPdfNativeDoc* doc) {
172   SkPdfNativeObject* ret = get("Decode", "");
173   if (doc) {ret = doc->resolveReference(ret);}
174   if ((ret != NULL && ret->isArray()) || (doc == NULL && ret != NULL && ret->isReference())) return (SkPdfArray*)ret;
175   // TODO(edisonn): warn about missing default value for optional fields
176   return NULL;
177 }
178 
has_Decode() const179 bool SkPdfImageDictionary::has_Decode() const {
180   return get("Decode", "") != NULL;
181 }
182 
Interpolate(SkPdfNativeDoc * doc)183 bool SkPdfImageDictionary::Interpolate(SkPdfNativeDoc* doc) {
184   SkPdfNativeObject* ret = get("Interpolate", "");
185   if (doc) {ret = doc->resolveReference(ret);}
186   if ((ret != NULL && ret->isBoolean()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->boolValue();
187   // TODO(edisonn): warn about missing default value for optional fields
188   return false;
189 }
190 
has_Interpolate() const191 bool SkPdfImageDictionary::has_Interpolate() const {
192   return get("Interpolate", "") != NULL;
193 }
194 
Alternates(SkPdfNativeDoc * doc)195 SkPdfArray* SkPdfImageDictionary::Alternates(SkPdfNativeDoc* doc) {
196   SkPdfNativeObject* ret = get("Alternates", "");
197   if (doc) {ret = doc->resolveReference(ret);}
198   if ((ret != NULL && ret->isArray()) || (doc == NULL && ret != NULL && ret->isReference())) return (SkPdfArray*)ret;
199   // TODO(edisonn): warn about missing default value for optional fields
200   return NULL;
201 }
202 
has_Alternates() const203 bool SkPdfImageDictionary::has_Alternates() const {
204   return get("Alternates", "") != NULL;
205 }
206 
Name(SkPdfNativeDoc * doc)207 SkString SkPdfImageDictionary::Name(SkPdfNativeDoc* doc) {
208   SkPdfNativeObject* ret = get("Name", "");
209   if (doc) {ret = doc->resolveReference(ret);}
210   if ((ret != NULL && ret->isName()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->nameValue2();
211   // TODO(edisonn): warn about missing default value for optional fields
212   return SkString();
213 }
214 
has_Name() const215 bool SkPdfImageDictionary::has_Name() const {
216   return get("Name", "") != NULL;
217 }
218 
StructParent(SkPdfNativeDoc * doc)219 int64_t SkPdfImageDictionary::StructParent(SkPdfNativeDoc* doc) {
220   SkPdfNativeObject* ret = get("StructParent", "");
221   if (doc) {ret = doc->resolveReference(ret);}
222   if ((ret != NULL && ret->isInteger()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->intValue();
223   // TODO(edisonn): warn about missing default value for optional fields
224   return 0;
225 }
226 
has_StructParent() const227 bool SkPdfImageDictionary::has_StructParent() const {
228   return get("StructParent", "") != NULL;
229 }
230 
ID(SkPdfNativeDoc * doc)231 SkString SkPdfImageDictionary::ID(SkPdfNativeDoc* doc) {
232   SkPdfNativeObject* ret = get("ID", "");
233   if (doc) {ret = doc->resolveReference(ret);}
234   if ((ret != NULL && ret->isAnyString()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->stringValue2();
235   // TODO(edisonn): warn about missing default value for optional fields
236   return SkString();
237 }
238 
has_ID() const239 bool SkPdfImageDictionary::has_ID() const {
240   return get("ID", "") != NULL;
241 }
242 
OPI(SkPdfNativeDoc * doc)243 SkPdfDictionary* SkPdfImageDictionary::OPI(SkPdfNativeDoc* doc) {
244   SkPdfNativeObject* ret = get("OPI", "");
245   if (doc) {ret = doc->resolveReference(ret);}
246   if ((ret != NULL && ret->isDictionary()) || (doc == NULL && ret != NULL && ret->isReference())) return (SkPdfDictionary*)ret;
247   // TODO(edisonn): warn about missing default value for optional fields
248   return NULL;
249 }
250 
has_OPI() const251 bool SkPdfImageDictionary::has_OPI() const {
252   return get("OPI", "") != NULL;
253 }
254 
Metadata(SkPdfNativeDoc * doc)255 SkPdfStream* SkPdfImageDictionary::Metadata(SkPdfNativeDoc* doc) {
256   SkPdfNativeObject* ret = get("Metadata", "");
257   if (doc) {ret = doc->resolveReference(ret);}
258   if ((ret != NULL && ret->hasStream()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->getStream();
259   // TODO(edisonn): warn about missing default value for optional fields
260   return NULL;
261 }
262 
has_Metadata() const263 bool SkPdfImageDictionary::has_Metadata() const {
264   return get("Metadata", "") != NULL;
265 }
266