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 "SkPdfAnnotationDictionary_autogen.h" 9 #include "SkPdfNativeDoc.h" 10 11 SkString SkPdfAnnotationDictionary::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 19 bool SkPdfAnnotationDictionary::has_Type() const { 20 return get("Type", "") != NULL; 21 } 22 23 SkString SkPdfAnnotationDictionary::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 31 bool SkPdfAnnotationDictionary::has_Subtype() const { 32 return get("Subtype", "") != NULL; 33 } 34 35 SkString SkPdfAnnotationDictionary::Contents(SkPdfNativeDoc* doc) { 36 SkPdfNativeObject* ret = get("Contents", ""); 37 if (doc) {ret = doc->resolveReference(ret);} 38 if ((ret != NULL && ret->isAnyString()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->stringValue2(); 39 // TODO(edisonn): warn about missing default value for optional fields 40 return SkString(); 41 } 42 43 bool SkPdfAnnotationDictionary::has_Contents() const { 44 return get("Contents", "") != NULL; 45 } 46 47 SkPdfDictionary* SkPdfAnnotationDictionary::P(SkPdfNativeDoc* doc) { 48 SkPdfNativeObject* ret = get("P", ""); 49 if (doc) {ret = doc->resolveReference(ret);} 50 if ((ret != NULL && ret->isDictionary()) || (doc == NULL && ret != NULL && ret->isReference())) return (SkPdfDictionary*)ret; 51 // TODO(edisonn): warn about missing default value for optional fields 52 return NULL; 53 } 54 55 bool SkPdfAnnotationDictionary::has_P() const { 56 return get("P", "") != NULL; 57 } 58 59 SkRect SkPdfAnnotationDictionary::Rect(SkPdfNativeDoc* doc) { 60 SkPdfNativeObject* ret = get("Rect", ""); 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 67 bool SkPdfAnnotationDictionary::has_Rect() const { 68 return get("Rect", "") != NULL; 69 } 70 71 bool SkPdfAnnotationDictionary::has_NM() const { 72 return get("NM", "") != NULL; 73 } 74 75 bool SkPdfAnnotationDictionary::isMADate(SkPdfNativeDoc* doc) { 76 SkPdfNativeObject* ret = get("M", ""); 77 if (doc) {ret = doc->resolveReference(ret);} 78 return ret != NULL && ret->isDate(); 79 } 80 81 SkPdfDate SkPdfAnnotationDictionary::getMAsDate(SkPdfNativeDoc* doc) { 82 SkPdfNativeObject* ret = get("M", ""); 83 if (doc) {ret = doc->resolveReference(ret);} 84 if ((ret != NULL && ret->isDate()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->dateValue(); 85 // TODO(edisonn): warn about missing default value for optional fields 86 return SkPdfDate(); 87 } 88 89 bool SkPdfAnnotationDictionary::isMAString(SkPdfNativeDoc* doc) { 90 SkPdfNativeObject* ret = get("M", ""); 91 if (doc) {ret = doc->resolveReference(ret);} 92 return ret != NULL && ret->isAnyString(); 93 } 94 95 SkString SkPdfAnnotationDictionary::getMAsString(SkPdfNativeDoc* doc) { 96 SkPdfNativeObject* ret = get("M", ""); 97 if (doc) {ret = doc->resolveReference(ret);} 98 if ((ret != NULL && ret->isAnyString()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->stringValue2(); 99 // TODO(edisonn): warn about missing default value for optional fields 100 return SkString(); 101 } 102 103 bool SkPdfAnnotationDictionary::has_M() const { 104 return get("M", "") != NULL; 105 } 106 107 int64_t SkPdfAnnotationDictionary::F(SkPdfNativeDoc* doc) { 108 SkPdfNativeObject* ret = get("F", ""); 109 if (doc) {ret = doc->resolveReference(ret);} 110 if ((ret != NULL && ret->isInteger()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->intValue(); 111 // TODO(edisonn): warn about missing default value for optional fields 112 return 0; 113 } 114 115 bool SkPdfAnnotationDictionary::has_F() const { 116 return get("F", "") != NULL; 117 } 118 119 SkPdfDictionary* SkPdfAnnotationDictionary::BS(SkPdfNativeDoc* doc) { 120 SkPdfNativeObject* ret = get("BS", ""); 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 127 bool SkPdfAnnotationDictionary::has_BS() const { 128 return get("BS", "") != NULL; 129 } 130 131 SkPdfArray* SkPdfAnnotationDictionary::Border(SkPdfNativeDoc* doc) { 132 SkPdfNativeObject* ret = get("Border", ""); 133 if (doc) {ret = doc->resolveReference(ret);} 134 if ((ret != NULL && ret->isArray()) || (doc == NULL && ret != NULL && ret->isReference())) return (SkPdfArray*)ret; 135 // TODO(edisonn): warn about missing default value for optional fields 136 return NULL; 137 } 138 139 bool SkPdfAnnotationDictionary::has_Border() const { 140 return get("Border", "") != NULL; 141 } 142 143 SkPdfDictionary* SkPdfAnnotationDictionary::AP(SkPdfNativeDoc* doc) { 144 SkPdfNativeObject* ret = get("AP", ""); 145 if (doc) {ret = doc->resolveReference(ret);} 146 if ((ret != NULL && ret->isDictionary()) || (doc == NULL && ret != NULL && ret->isReference())) return (SkPdfDictionary*)ret; 147 // TODO(edisonn): warn about missing default value for optional fields 148 return NULL; 149 } 150 151 bool SkPdfAnnotationDictionary::has_AP() const { 152 return get("AP", "") != NULL; 153 } 154 155 SkString SkPdfAnnotationDictionary::AS(SkPdfNativeDoc* doc) { 156 SkPdfNativeObject* ret = get("AS", ""); 157 if (doc) {ret = doc->resolveReference(ret);} 158 if ((ret != NULL && ret->isName()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->nameValue2(); 159 // TODO(edisonn): warn about missing default value for optional fields 160 return SkString(); 161 } 162 163 bool SkPdfAnnotationDictionary::has_AS() const { 164 return get("AS", "") != NULL; 165 } 166 167 SkPdfArray* SkPdfAnnotationDictionary::C(SkPdfNativeDoc* doc) { 168 SkPdfNativeObject* ret = get("C", ""); 169 if (doc) {ret = doc->resolveReference(ret);} 170 if ((ret != NULL && ret->isArray()) || (doc == NULL && ret != NULL && ret->isReference())) return (SkPdfArray*)ret; 171 // TODO(edisonn): warn about missing default value for optional fields 172 return NULL; 173 } 174 175 bool SkPdfAnnotationDictionary::has_C() const { 176 return get("C", "") != NULL; 177 } 178 179 double SkPdfAnnotationDictionary::CA(SkPdfNativeDoc* doc) { 180 SkPdfNativeObject* ret = get("CA", ""); 181 if (doc) {ret = doc->resolveReference(ret);} 182 if ((ret != NULL && ret->isNumber()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->numberValue(); 183 // TODO(edisonn): warn about missing default value for optional fields 184 return 0; 185 } 186 187 bool SkPdfAnnotationDictionary::has_CA() const { 188 return get("CA", "") != NULL; 189 } 190 191 SkString SkPdfAnnotationDictionary::T(SkPdfNativeDoc* doc) { 192 SkPdfNativeObject* ret = get("T", ""); 193 if (doc) {ret = doc->resolveReference(ret);} 194 if ((ret != NULL && ret->isAnyString()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->stringValue2(); 195 // TODO(edisonn): warn about missing default value for optional fields 196 return SkString(); 197 } 198 199 bool SkPdfAnnotationDictionary::has_T() const { 200 return get("T", "") != NULL; 201 } 202 203 SkPdfDictionary* SkPdfAnnotationDictionary::Popup(SkPdfNativeDoc* doc) { 204 SkPdfNativeObject* ret = get("Popup", ""); 205 if (doc) {ret = doc->resolveReference(ret);} 206 if ((ret != NULL && ret->isDictionary()) || (doc == NULL && ret != NULL && ret->isReference())) return (SkPdfDictionary*)ret; 207 // TODO(edisonn): warn about missing default value for optional fields 208 return NULL; 209 } 210 211 bool SkPdfAnnotationDictionary::has_Popup() const { 212 return get("Popup", "") != NULL; 213 } 214 215 SkPdfDictionary* SkPdfAnnotationDictionary::A(SkPdfNativeDoc* doc) { 216 SkPdfNativeObject* ret = get("A", ""); 217 if (doc) {ret = doc->resolveReference(ret);} 218 if ((ret != NULL && ret->isDictionary()) || (doc == NULL && ret != NULL && ret->isReference())) return (SkPdfDictionary*)ret; 219 // TODO(edisonn): warn about missing default value for optional fields 220 return NULL; 221 } 222 223 bool SkPdfAnnotationDictionary::has_A() const { 224 return get("A", "") != NULL; 225 } 226 227 SkPdfDictionary* SkPdfAnnotationDictionary::AA(SkPdfNativeDoc* doc) { 228 SkPdfNativeObject* ret = get("AA", ""); 229 if (doc) {ret = doc->resolveReference(ret);} 230 if ((ret != NULL && ret->isDictionary()) || (doc == NULL && ret != NULL && ret->isReference())) return (SkPdfDictionary*)ret; 231 // TODO(edisonn): warn about missing default value for optional fields 232 return NULL; 233 } 234 235 bool SkPdfAnnotationDictionary::has_AA() const { 236 return get("AA", "") != NULL; 237 } 238 239 int64_t SkPdfAnnotationDictionary::StructParent(SkPdfNativeDoc* doc) { 240 SkPdfNativeObject* ret = get("StructParent", ""); 241 if (doc) {ret = doc->resolveReference(ret);} 242 if ((ret != NULL && ret->isInteger()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->intValue(); 243 // TODO(edisonn): warn about missing default value for optional fields 244 return 0; 245 } 246 247 bool SkPdfAnnotationDictionary::has_StructParent() const { 248 return get("StructParent", "") != NULL; 249 } 250