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 "SkPdfStreamCommonDictionary_autogen.h"
9 #include "SkPdfNativeDoc.h"
10 
Length(SkPdfNativeDoc * doc)11 int64_t SkPdfStreamCommonDictionary::Length(SkPdfNativeDoc* doc) {
12   SkPdfNativeObject* ret = get("Length", "");
13   if (doc) {ret = doc->resolveReference(ret);}
14   if ((ret != NULL && ret->isInteger()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->intValue();
15   // TODO(edisonn): warn about missing required field, assert for known good pdfs
16   return 0;
17 }
18 
has_Length() const19 bool SkPdfStreamCommonDictionary::has_Length() const {
20   return get("Length", "") != NULL;
21 }
22 
isFilterAName(SkPdfNativeDoc * doc)23 bool SkPdfStreamCommonDictionary::isFilterAName(SkPdfNativeDoc* doc) {
24   SkPdfNativeObject* ret = get("Filter", "");
25   if (doc) {ret = doc->resolveReference(ret);}
26   return ret != NULL && ret->isName();
27 }
28 
getFilterAsName(SkPdfNativeDoc * doc)29 SkString SkPdfStreamCommonDictionary::getFilterAsName(SkPdfNativeDoc* doc) {
30   SkPdfNativeObject* ret = get("Filter", "");
31   if (doc) {ret = doc->resolveReference(ret);}
32   if ((ret != NULL && ret->isName()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->nameValue2();
33   // TODO(edisonn): warn about missing default value for optional fields
34   return SkString();
35 }
36 
isFilterAArray(SkPdfNativeDoc * doc)37 bool SkPdfStreamCommonDictionary::isFilterAArray(SkPdfNativeDoc* doc) {
38   SkPdfNativeObject* ret = get("Filter", "");
39   if (doc) {ret = doc->resolveReference(ret);}
40   return ret != NULL && ret->isArray();
41 }
42 
getFilterAsArray(SkPdfNativeDoc * doc)43 SkPdfArray* SkPdfStreamCommonDictionary::getFilterAsArray(SkPdfNativeDoc* doc) {
44   SkPdfNativeObject* ret = get("Filter", "");
45   if (doc) {ret = doc->resolveReference(ret);}
46   if ((ret != NULL && ret->isArray()) || (doc == NULL && ret != NULL && ret->isReference())) return (SkPdfArray*)ret;
47   // TODO(edisonn): warn about missing default value for optional fields
48   return NULL;
49 }
50 
has_Filter() const51 bool SkPdfStreamCommonDictionary::has_Filter() const {
52   return get("Filter", "") != NULL;
53 }
54 
isDecodeParmsADictionary(SkPdfNativeDoc * doc)55 bool SkPdfStreamCommonDictionary::isDecodeParmsADictionary(SkPdfNativeDoc* doc) {
56   SkPdfNativeObject* ret = get("DecodeParms", "");
57   if (doc) {ret = doc->resolveReference(ret);}
58   return ret != NULL && ret->isDictionary();
59 }
60 
getDecodeParmsAsDictionary(SkPdfNativeDoc * doc)61 SkPdfDictionary* SkPdfStreamCommonDictionary::getDecodeParmsAsDictionary(SkPdfNativeDoc* doc) {
62   SkPdfNativeObject* ret = get("DecodeParms", "");
63   if (doc) {ret = doc->resolveReference(ret);}
64   if ((ret != NULL && ret->isDictionary()) || (doc == NULL && ret != NULL && ret->isReference())) return (SkPdfDictionary*)ret;
65   // TODO(edisonn): warn about missing default value for optional fields
66   return NULL;
67 }
68 
isDecodeParmsAArray(SkPdfNativeDoc * doc)69 bool SkPdfStreamCommonDictionary::isDecodeParmsAArray(SkPdfNativeDoc* doc) {
70   SkPdfNativeObject* ret = get("DecodeParms", "");
71   if (doc) {ret = doc->resolveReference(ret);}
72   return ret != NULL && ret->isArray();
73 }
74 
getDecodeParmsAsArray(SkPdfNativeDoc * doc)75 SkPdfArray* SkPdfStreamCommonDictionary::getDecodeParmsAsArray(SkPdfNativeDoc* doc) {
76   SkPdfNativeObject* ret = get("DecodeParms", "");
77   if (doc) {ret = doc->resolveReference(ret);}
78   if ((ret != NULL && ret->isArray()) || (doc == NULL && ret != NULL && ret->isReference())) return (SkPdfArray*)ret;
79   // TODO(edisonn): warn about missing default value for optional fields
80   return NULL;
81 }
82 
has_DecodeParms() const83 bool SkPdfStreamCommonDictionary::has_DecodeParms() const {
84   return get("DecodeParms", "") != NULL;
85 }
86 
F(SkPdfNativeDoc * doc)87 SkPdfFileSpec SkPdfStreamCommonDictionary::F(SkPdfNativeDoc* doc) {
88   SkPdfNativeObject* ret = get("F", "");
89   if (doc) {ret = doc->resolveReference(ret);}
90   if ((ret != NULL && false) || (doc == NULL && ret != NULL && ret->isReference())) return ret->fileSpecValue();
91   // TODO(edisonn): warn about missing default value for optional fields
92   return SkPdfFileSpec();
93 }
94 
has_F() const95 bool SkPdfStreamCommonDictionary::has_F() const {
96   return get("F", "") != NULL;
97 }
98 
isFFilterAName(SkPdfNativeDoc * doc)99 bool SkPdfStreamCommonDictionary::isFFilterAName(SkPdfNativeDoc* doc) {
100   SkPdfNativeObject* ret = get("FFilter", "");
101   if (doc) {ret = doc->resolveReference(ret);}
102   return ret != NULL && ret->isName();
103 }
104 
getFFilterAsName(SkPdfNativeDoc * doc)105 SkString SkPdfStreamCommonDictionary::getFFilterAsName(SkPdfNativeDoc* doc) {
106   SkPdfNativeObject* ret = get("FFilter", "");
107   if (doc) {ret = doc->resolveReference(ret);}
108   if ((ret != NULL && ret->isName()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->nameValue2();
109   // TODO(edisonn): warn about missing default value for optional fields
110   return SkString();
111 }
112 
isFFilterAArray(SkPdfNativeDoc * doc)113 bool SkPdfStreamCommonDictionary::isFFilterAArray(SkPdfNativeDoc* doc) {
114   SkPdfNativeObject* ret = get("FFilter", "");
115   if (doc) {ret = doc->resolveReference(ret);}
116   return ret != NULL && ret->isArray();
117 }
118 
getFFilterAsArray(SkPdfNativeDoc * doc)119 SkPdfArray* SkPdfStreamCommonDictionary::getFFilterAsArray(SkPdfNativeDoc* doc) {
120   SkPdfNativeObject* ret = get("FFilter", "");
121   if (doc) {ret = doc->resolveReference(ret);}
122   if ((ret != NULL && ret->isArray()) || (doc == NULL && ret != NULL && ret->isReference())) return (SkPdfArray*)ret;
123   // TODO(edisonn): warn about missing default value for optional fields
124   return NULL;
125 }
126 
has_FFilter() const127 bool SkPdfStreamCommonDictionary::has_FFilter() const {
128   return get("FFilter", "") != NULL;
129 }
130 
isFDecodeParmsADictionary(SkPdfNativeDoc * doc)131 bool SkPdfStreamCommonDictionary::isFDecodeParmsADictionary(SkPdfNativeDoc* doc) {
132   SkPdfNativeObject* ret = get("FDecodeParms", "");
133   if (doc) {ret = doc->resolveReference(ret);}
134   return ret != NULL && ret->isDictionary();
135 }
136 
getFDecodeParmsAsDictionary(SkPdfNativeDoc * doc)137 SkPdfDictionary* SkPdfStreamCommonDictionary::getFDecodeParmsAsDictionary(SkPdfNativeDoc* doc) {
138   SkPdfNativeObject* ret = get("FDecodeParms", "");
139   if (doc) {ret = doc->resolveReference(ret);}
140   if ((ret != NULL && ret->isDictionary()) || (doc == NULL && ret != NULL && ret->isReference())) return (SkPdfDictionary*)ret;
141   // TODO(edisonn): warn about missing default value for optional fields
142   return NULL;
143 }
144 
isFDecodeParmsAArray(SkPdfNativeDoc * doc)145 bool SkPdfStreamCommonDictionary::isFDecodeParmsAArray(SkPdfNativeDoc* doc) {
146   SkPdfNativeObject* ret = get("FDecodeParms", "");
147   if (doc) {ret = doc->resolveReference(ret);}
148   return ret != NULL && ret->isArray();
149 }
150 
getFDecodeParmsAsArray(SkPdfNativeDoc * doc)151 SkPdfArray* SkPdfStreamCommonDictionary::getFDecodeParmsAsArray(SkPdfNativeDoc* doc) {
152   SkPdfNativeObject* ret = get("FDecodeParms", "");
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_FDecodeParms() const159 bool SkPdfStreamCommonDictionary::has_FDecodeParms() const {
160   return get("FDecodeParms", "") != NULL;
161 }
162