• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "SkPdfPageObjectDictionary_autogen.h"
9 #include "SkPdfNativeDoc.h"
10 
Type(SkPdfNativeDoc * doc)11 SkString SkPdfPageObjectDictionary::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 required field, assert for known good pdfs
16   return SkString();
17 }
18 
has_Type() const19 bool SkPdfPageObjectDictionary::has_Type() const {
20   return get("Type", "") != NULL;
21 }
22 
Parent(SkPdfNativeDoc * doc)23 SkPdfDictionary* SkPdfPageObjectDictionary::Parent(SkPdfNativeDoc* doc) {
24   SkPdfNativeObject* ret = get("Parent", "");
25   if (doc) {ret = doc->resolveReference(ret);}
26   if ((ret != NULL && ret->isDictionary()) || (doc == NULL && ret != NULL && ret->isReference())) return (SkPdfDictionary*)ret;
27   // TODO(edisonn): warn about missing default value for optional fields
28   return NULL;
29 }
30 
has_Parent() const31 bool SkPdfPageObjectDictionary::has_Parent() const {
32   return get("Parent", "") != NULL;
33 }
34 
LastModified(SkPdfNativeDoc * doc)35 SkPdfDate SkPdfPageObjectDictionary::LastModified(SkPdfNativeDoc* doc) {
36   SkPdfNativeObject* ret = get("LastModified", "");
37   if (doc) {ret = doc->resolveReference(ret);}
38   if ((ret != NULL && ret->isDate()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->dateValue();
39   // TODO(edisonn): warn about missing default value for optional fields
40   return SkPdfDate();
41 }
42 
has_LastModified() const43 bool SkPdfPageObjectDictionary::has_LastModified() const {
44   return get("LastModified", "") != NULL;
45 }
46 
Resources(SkPdfNativeDoc * doc)47 SkPdfResourceDictionary* SkPdfPageObjectDictionary::Resources(SkPdfNativeDoc* doc) {
48   SkPdfNativeObject* ret = get("Resources", "");
49   if (doc) {ret = doc->resolveReference(ret);}
50   if ((ret != NULL && ret->isDictionary() && ((SkPdfResourceDictionary*)ret)->valid()) || (doc == NULL && ret != NULL && ret->isReference())) return (SkPdfResourceDictionary*)ret;
51   // TODO(edisonn): warn about missing required field, assert for known good pdfs
52   return NULL;
53 }
54 
has_Resources() const55 bool SkPdfPageObjectDictionary::has_Resources() const {
56   return get("Resources", "") != NULL;
57 }
58 
MediaBox(SkPdfNativeDoc * doc)59 SkRect SkPdfPageObjectDictionary::MediaBox(SkPdfNativeDoc* doc) {
60   SkPdfNativeObject* ret = get("MediaBox", "");
61   if (doc) {ret = doc->resolveReference(ret);}
62   if ((ret != NULL && ret->isRectangle()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->rectangleValue();
63   // TODO(edisonn): warn about missing required field, assert for known good pdfs
64   return SkRect::MakeEmpty();
65 }
66 
has_MediaBox() const67 bool SkPdfPageObjectDictionary::has_MediaBox() const {
68   return get("MediaBox", "") != NULL;
69 }
70 
CropBox(SkPdfNativeDoc * doc)71 SkRect SkPdfPageObjectDictionary::CropBox(SkPdfNativeDoc* doc) {
72   SkPdfNativeObject* ret = get("CropBox", "");
73   if (doc) {ret = doc->resolveReference(ret);}
74   if ((ret != NULL && ret->isRectangle()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->rectangleValue();
75   // TODO(edisonn): warn about missing default value for optional fields
76   return SkRect::MakeEmpty();
77 }
78 
has_CropBox() const79 bool SkPdfPageObjectDictionary::has_CropBox() const {
80   return get("CropBox", "") != NULL;
81 }
82 
BleedBox(SkPdfNativeDoc * doc)83 SkRect SkPdfPageObjectDictionary::BleedBox(SkPdfNativeDoc* doc) {
84   SkPdfNativeObject* ret = get("BleedBox", "");
85   if (doc) {ret = doc->resolveReference(ret);}
86   if ((ret != NULL && ret->isRectangle()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->rectangleValue();
87   // TODO(edisonn): warn about missing default value for optional fields
88   return SkRect::MakeEmpty();
89 }
90 
has_BleedBox() const91 bool SkPdfPageObjectDictionary::has_BleedBox() const {
92   return get("BleedBox", "") != NULL;
93 }
94 
TrimBox(SkPdfNativeDoc * doc)95 SkRect SkPdfPageObjectDictionary::TrimBox(SkPdfNativeDoc* doc) {
96   SkPdfNativeObject* ret = get("TrimBox", "");
97   if (doc) {ret = doc->resolveReference(ret);}
98   if ((ret != NULL && ret->isRectangle()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->rectangleValue();
99   // TODO(edisonn): warn about missing default value for optional fields
100   return SkRect::MakeEmpty();
101 }
102 
has_TrimBox() const103 bool SkPdfPageObjectDictionary::has_TrimBox() const {
104   return get("TrimBox", "") != NULL;
105 }
106 
ArtBox(SkPdfNativeDoc * doc)107 SkRect SkPdfPageObjectDictionary::ArtBox(SkPdfNativeDoc* doc) {
108   SkPdfNativeObject* ret = get("ArtBox", "");
109   if (doc) {ret = doc->resolveReference(ret);}
110   if ((ret != NULL && ret->isRectangle()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->rectangleValue();
111   // TODO(edisonn): warn about missing default value for optional fields
112   return SkRect::MakeEmpty();
113 }
114 
has_ArtBox() const115 bool SkPdfPageObjectDictionary::has_ArtBox() const {
116   return get("ArtBox", "") != NULL;
117 }
118 
BoxColorInfo(SkPdfNativeDoc * doc)119 SkPdfDictionary* SkPdfPageObjectDictionary::BoxColorInfo(SkPdfNativeDoc* doc) {
120   SkPdfNativeObject* ret = get("BoxColorInfo", "");
121   if (doc) {ret = doc->resolveReference(ret);}
122   if ((ret != NULL && ret->isDictionary()) || (doc == NULL && ret != NULL && ret->isReference())) return (SkPdfDictionary*)ret;
123   // TODO(edisonn): warn about missing default value for optional fields
124   return NULL;
125 }
126 
has_BoxColorInfo() const127 bool SkPdfPageObjectDictionary::has_BoxColorInfo() const {
128   return get("BoxColorInfo", "") != NULL;
129 }
130 
isContentsAStream(SkPdfNativeDoc * doc)131 bool SkPdfPageObjectDictionary::isContentsAStream(SkPdfNativeDoc* doc) {
132   SkPdfNativeObject* ret = get("Contents", "");
133   if (doc) {ret = doc->resolveReference(ret);}
134   return ret != NULL && ret->hasStream();
135 }
136 
getContentsAsStream(SkPdfNativeDoc * doc)137 SkPdfStream* SkPdfPageObjectDictionary::getContentsAsStream(SkPdfNativeDoc* doc) {
138   SkPdfNativeObject* ret = get("Contents", "");
139   if (doc) {ret = doc->resolveReference(ret);}
140   if ((ret != NULL && ret->hasStream()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->getStream();
141   // TODO(edisonn): warn about missing default value for optional fields
142   return NULL;
143 }
144 
isContentsAArray(SkPdfNativeDoc * doc)145 bool SkPdfPageObjectDictionary::isContentsAArray(SkPdfNativeDoc* doc) {
146   SkPdfNativeObject* ret = get("Contents", "");
147   if (doc) {ret = doc->resolveReference(ret);}
148   return ret != NULL && ret->isArray();
149 }
150 
getContentsAsArray(SkPdfNativeDoc * doc)151 SkPdfArray* SkPdfPageObjectDictionary::getContentsAsArray(SkPdfNativeDoc* doc) {
152   SkPdfNativeObject* ret = get("Contents", "");
153   if (doc) {ret = doc->resolveReference(ret);}
154   if ((ret != NULL && ret->isArray()) || (doc == NULL && ret != NULL && ret->isReference())) return (SkPdfArray*)ret;
155   // TODO(edisonn): warn about missing default value for optional fields
156   return NULL;
157 }
158 
has_Contents() const159 bool SkPdfPageObjectDictionary::has_Contents() const {
160   return get("Contents", "") != NULL;
161 }
162 
Rotate(SkPdfNativeDoc * doc)163 int64_t SkPdfPageObjectDictionary::Rotate(SkPdfNativeDoc* doc) {
164   SkPdfNativeObject* ret = get("Rotate", "");
165   if (doc) {ret = doc->resolveReference(ret);}
166   if ((ret != NULL && ret->isInteger()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->intValue();
167   // TODO(edisonn): warn about missing default value for optional fields
168   return 0;
169 }
170 
has_Rotate() const171 bool SkPdfPageObjectDictionary::has_Rotate() const {
172   return get("Rotate", "") != NULL;
173 }
174 
Group(SkPdfNativeDoc * doc)175 SkPdfTransparencyGroupDictionary* SkPdfPageObjectDictionary::Group(SkPdfNativeDoc* doc) {
176   SkPdfNativeObject* ret = get("Group", "");
177   if (doc) {ret = doc->resolveReference(ret);}
178   if ((ret != NULL && ret->isDictionary() && ((SkPdfTransparencyGroupDictionary*)ret)->valid()) || (doc == NULL && ret != NULL && ret->isReference())) return (SkPdfTransparencyGroupDictionary*)ret;
179   // TODO(edisonn): warn about missing default value for optional fields
180   return NULL;
181 }
182 
has_Group() const183 bool SkPdfPageObjectDictionary::has_Group() const {
184   return get("Group", "") != NULL;
185 }
186 
Thumb(SkPdfNativeDoc * doc)187 SkPdfStream* SkPdfPageObjectDictionary::Thumb(SkPdfNativeDoc* doc) {
188   SkPdfNativeObject* ret = get("Thumb", "");
189   if (doc) {ret = doc->resolveReference(ret);}
190   if ((ret != NULL && ret->hasStream()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->getStream();
191   // TODO(edisonn): warn about missing default value for optional fields
192   return NULL;
193 }
194 
has_Thumb() const195 bool SkPdfPageObjectDictionary::has_Thumb() const {
196   return get("Thumb", "") != NULL;
197 }
198 
B(SkPdfNativeDoc * doc)199 SkPdfArray* SkPdfPageObjectDictionary::B(SkPdfNativeDoc* doc) {
200   SkPdfNativeObject* ret = get("B", "");
201   if (doc) {ret = doc->resolveReference(ret);}
202   if ((ret != NULL && ret->isArray()) || (doc == NULL && ret != NULL && ret->isReference())) return (SkPdfArray*)ret;
203   // TODO(edisonn): warn about missing default value for optional fields
204   return NULL;
205 }
206 
has_B() const207 bool SkPdfPageObjectDictionary::has_B() const {
208   return get("B", "") != NULL;
209 }
210 
Dur(SkPdfNativeDoc * doc)211 double SkPdfPageObjectDictionary::Dur(SkPdfNativeDoc* doc) {
212   SkPdfNativeObject* ret = get("Dur", "");
213   if (doc) {ret = doc->resolveReference(ret);}
214   if ((ret != NULL && ret->isNumber()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->numberValue();
215   // TODO(edisonn): warn about missing default value for optional fields
216   return 0;
217 }
218 
has_Dur() const219 bool SkPdfPageObjectDictionary::has_Dur() const {
220   return get("Dur", "") != NULL;
221 }
222 
Trans(SkPdfNativeDoc * doc)223 SkPdfDictionary* SkPdfPageObjectDictionary::Trans(SkPdfNativeDoc* doc) {
224   SkPdfNativeObject* ret = get("Trans", "");
225   if (doc) {ret = doc->resolveReference(ret);}
226   if ((ret != NULL && ret->isDictionary()) || (doc == NULL && ret != NULL && ret->isReference())) return (SkPdfDictionary*)ret;
227   // TODO(edisonn): warn about missing default value for optional fields
228   return NULL;
229 }
230 
has_Trans() const231 bool SkPdfPageObjectDictionary::has_Trans() const {
232   return get("Trans", "") != NULL;
233 }
234 
Annots(SkPdfNativeDoc * doc)235 SkPdfArray* SkPdfPageObjectDictionary::Annots(SkPdfNativeDoc* doc) {
236   SkPdfNativeObject* ret = get("Annots", "");
237   if (doc) {ret = doc->resolveReference(ret);}
238   if ((ret != NULL && ret->isArray()) || (doc == NULL && ret != NULL && ret->isReference())) return (SkPdfArray*)ret;
239   // TODO(edisonn): warn about missing default value for optional fields
240   return NULL;
241 }
242 
has_Annots() const243 bool SkPdfPageObjectDictionary::has_Annots() const {
244   return get("Annots", "") != NULL;
245 }
246 
AA(SkPdfNativeDoc * doc)247 SkPdfDictionary* SkPdfPageObjectDictionary::AA(SkPdfNativeDoc* doc) {
248   SkPdfNativeObject* ret = get("AA", "");
249   if (doc) {ret = doc->resolveReference(ret);}
250   if ((ret != NULL && ret->isDictionary()) || (doc == NULL && ret != NULL && ret->isReference())) return (SkPdfDictionary*)ret;
251   // TODO(edisonn): warn about missing default value for optional fields
252   return NULL;
253 }
254 
has_AA() const255 bool SkPdfPageObjectDictionary::has_AA() const {
256   return get("AA", "") != NULL;
257 }
258 
Metadata(SkPdfNativeDoc * doc)259 SkPdfStream* SkPdfPageObjectDictionary::Metadata(SkPdfNativeDoc* doc) {
260   SkPdfNativeObject* ret = get("Metadata", "");
261   if (doc) {ret = doc->resolveReference(ret);}
262   if ((ret != NULL && ret->hasStream()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->getStream();
263   // TODO(edisonn): warn about missing default value for optional fields
264   return NULL;
265 }
266 
has_Metadata() const267 bool SkPdfPageObjectDictionary::has_Metadata() const {
268   return get("Metadata", "") != NULL;
269 }
270 
PieceInfo(SkPdfNativeDoc * doc)271 SkPdfDictionary* SkPdfPageObjectDictionary::PieceInfo(SkPdfNativeDoc* doc) {
272   SkPdfNativeObject* ret = get("PieceInfo", "");
273   if (doc) {ret = doc->resolveReference(ret);}
274   if ((ret != NULL && ret->isDictionary()) || (doc == NULL && ret != NULL && ret->isReference())) return (SkPdfDictionary*)ret;
275   // TODO(edisonn): warn about missing default value for optional fields
276   return NULL;
277 }
278 
has_PieceInfo() const279 bool SkPdfPageObjectDictionary::has_PieceInfo() const {
280   return get("PieceInfo", "") != NULL;
281 }
282 
StructParents(SkPdfNativeDoc * doc)283 int64_t SkPdfPageObjectDictionary::StructParents(SkPdfNativeDoc* doc) {
284   SkPdfNativeObject* ret = get("StructParents", "");
285   if (doc) {ret = doc->resolveReference(ret);}
286   if ((ret != NULL && ret->isInteger()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->intValue();
287   // TODO(edisonn): warn about missing default value for optional fields
288   return 0;
289 }
290 
has_StructParents() const291 bool SkPdfPageObjectDictionary::has_StructParents() const {
292   return get("StructParents", "") != NULL;
293 }
294 
ID(SkPdfNativeDoc * doc)295 SkString SkPdfPageObjectDictionary::ID(SkPdfNativeDoc* doc) {
296   SkPdfNativeObject* ret = get("ID", "");
297   if (doc) {ret = doc->resolveReference(ret);}
298   if ((ret != NULL && ret->isAnyString()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->stringValue2();
299   // TODO(edisonn): warn about missing default value for optional fields
300   return SkString();
301 }
302 
has_ID() const303 bool SkPdfPageObjectDictionary::has_ID() const {
304   return get("ID", "") != NULL;
305 }
306 
PZ(SkPdfNativeDoc * doc)307 double SkPdfPageObjectDictionary::PZ(SkPdfNativeDoc* doc) {
308   SkPdfNativeObject* ret = get("PZ", "");
309   if (doc) {ret = doc->resolveReference(ret);}
310   if ((ret != NULL && ret->isNumber()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->numberValue();
311   // TODO(edisonn): warn about missing default value for optional fields
312   return 0;
313 }
314 
has_PZ() const315 bool SkPdfPageObjectDictionary::has_PZ() const {
316   return get("PZ", "") != NULL;
317 }
318 
SeparationInfo(SkPdfNativeDoc * doc)319 SkPdfDictionary* SkPdfPageObjectDictionary::SeparationInfo(SkPdfNativeDoc* doc) {
320   SkPdfNativeObject* ret = get("SeparationInfo", "");
321   if (doc) {ret = doc->resolveReference(ret);}
322   if ((ret != NULL && ret->isDictionary()) || (doc == NULL && ret != NULL && ret->isReference())) return (SkPdfDictionary*)ret;
323   // TODO(edisonn): warn about missing default value for optional fields
324   return NULL;
325 }
326 
has_SeparationInfo() const327 bool SkPdfPageObjectDictionary::has_SeparationInfo() const {
328   return get("SeparationInfo", "") != NULL;
329 }
330