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 "SkPdfType3FontDictionary_autogen.h" 9 #include "SkPdfNativeDoc.h" 10 11 SkString SkPdfType3FontDictionary::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 19 bool SkPdfType3FontDictionary::has_Type() const { 20 return get("Type", "") != NULL; 21 } 22 23 SkString SkPdfType3FontDictionary::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 SkPdfType3FontDictionary::has_Subtype() const { 32 return get("Subtype", "") != NULL; 33 } 34 35 SkString SkPdfType3FontDictionary::Name(SkPdfNativeDoc* doc) { 36 SkPdfNativeObject* ret = get("Name", ""); 37 if (doc) {ret = doc->resolveReference(ret);} 38 if ((ret != NULL && ret->isName()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->nameValue2(); 39 // TODO(edisonn): warn about missing default value for optional fields 40 return SkString(); 41 } 42 43 bool SkPdfType3FontDictionary::has_Name() const { 44 return get("Name", "") != NULL; 45 } 46 47 SkRect SkPdfType3FontDictionary::FontBBox(SkPdfNativeDoc* doc) { 48 SkPdfNativeObject* ret = get("FontBBox", ""); 49 if (doc) {ret = doc->resolveReference(ret);} 50 if ((ret != NULL && ret->isRectangle()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->rectangleValue(); 51 // TODO(edisonn): warn about missing required field, assert for known good pdfs 52 return SkRect::MakeEmpty(); 53 } 54 55 bool SkPdfType3FontDictionary::has_FontBBox() const { 56 return get("FontBBox", "") != NULL; 57 } 58 59 SkMatrix SkPdfType3FontDictionary::FontMatrix(SkPdfNativeDoc* doc) { 60 SkPdfNativeObject* ret = get("FontMatrix", ""); 61 if (doc) {ret = doc->resolveReference(ret);} 62 if ((ret != NULL && ret->isMatrix()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->matrixValue(); 63 // TODO(edisonn): warn about missing required field, assert for known good pdfs 64 return SkMatrix::I(); 65 } 66 67 bool SkPdfType3FontDictionary::has_FontMatrix() const { 68 return get("FontMatrix", "") != NULL; 69 } 70 71 SkPdfDictionary* SkPdfType3FontDictionary::CharProcs(SkPdfNativeDoc* doc) { 72 SkPdfNativeObject* ret = get("CharProcs", ""); 73 if (doc) {ret = doc->resolveReference(ret);} 74 if ((ret != NULL && ret->isDictionary()) || (doc == NULL && ret != NULL && ret->isReference())) return (SkPdfDictionary*)ret; 75 // TODO(edisonn): warn about missing required field, assert for known good pdfs 76 return NULL; 77 } 78 79 bool SkPdfType3FontDictionary::has_CharProcs() const { 80 return get("CharProcs", "") != NULL; 81 } 82 83 bool SkPdfType3FontDictionary::isEncodingAName(SkPdfNativeDoc* doc) { 84 SkPdfNativeObject* ret = get("Encoding", ""); 85 if (doc) {ret = doc->resolveReference(ret);} 86 return ret != NULL && ret->isName(); 87 } 88 89 SkString SkPdfType3FontDictionary::getEncodingAsName(SkPdfNativeDoc* doc) { 90 SkPdfNativeObject* ret = get("Encoding", ""); 91 if (doc) {ret = doc->resolveReference(ret);} 92 if ((ret != NULL && ret->isName()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->nameValue2(); 93 // TODO(edisonn): warn about missing required field, assert for known good pdfs 94 return SkString(); 95 } 96 97 bool SkPdfType3FontDictionary::isEncodingAEncodingdictionary(SkPdfNativeDoc* doc) { 98 SkPdfNativeObject* ret = get("Encoding", ""); 99 if (doc) {ret = doc->resolveReference(ret);} 100 return ret != NULL && ret->isDictionary() && ((SkPdfEncodingDictionary*)ret)->valid(); 101 } 102 103 SkPdfEncodingDictionary* SkPdfType3FontDictionary::getEncodingAsEncodingdictionary(SkPdfNativeDoc* doc) { 104 SkPdfNativeObject* ret = get("Encoding", ""); 105 if (doc) {ret = doc->resolveReference(ret);} 106 if ((ret != NULL && ret->isDictionary() && ((SkPdfEncodingDictionary*)ret)->valid()) || (doc == NULL && ret != NULL && ret->isReference())) return (SkPdfEncodingDictionary*)ret; 107 // TODO(edisonn): warn about missing required field, assert for known good pdfs 108 return NULL; 109 } 110 111 bool SkPdfType3FontDictionary::has_Encoding() const { 112 return get("Encoding", "") != NULL; 113 } 114 115 int64_t SkPdfType3FontDictionary::FirstChar(SkPdfNativeDoc* doc) { 116 SkPdfNativeObject* ret = get("FirstChar", ""); 117 if (doc) {ret = doc->resolveReference(ret);} 118 if ((ret != NULL && ret->isInteger()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->intValue(); 119 // TODO(edisonn): warn about missing required field, assert for known good pdfs 120 return 0; 121 } 122 123 bool SkPdfType3FontDictionary::has_FirstChar() const { 124 return get("FirstChar", "") != NULL; 125 } 126 127 int64_t SkPdfType3FontDictionary::LastChar(SkPdfNativeDoc* doc) { 128 SkPdfNativeObject* ret = get("LastChar", ""); 129 if (doc) {ret = doc->resolveReference(ret);} 130 if ((ret != NULL && ret->isInteger()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->intValue(); 131 // TODO(edisonn): warn about missing required field, assert for known good pdfs 132 return 0; 133 } 134 135 bool SkPdfType3FontDictionary::has_LastChar() const { 136 return get("LastChar", "") != NULL; 137 } 138 139 SkPdfArray* SkPdfType3FontDictionary::Widths(SkPdfNativeDoc* doc) { 140 SkPdfNativeObject* ret = get("Widths", ""); 141 if (doc) {ret = doc->resolveReference(ret);} 142 if ((ret != NULL && ret->isArray()) || (doc == NULL && ret != NULL && ret->isReference())) return (SkPdfArray*)ret; 143 // TODO(edisonn): warn about missing default value for optional fields 144 return NULL; 145 } 146 147 bool SkPdfType3FontDictionary::has_Widths() const { 148 return get("Widths", "") != NULL; 149 } 150 151 SkPdfResourceDictionary* SkPdfType3FontDictionary::Resources(SkPdfNativeDoc* doc) { 152 SkPdfNativeObject* ret = get("Resources", ""); 153 if (doc) {ret = doc->resolveReference(ret);} 154 if ((ret != NULL && ret->isDictionary() && ((SkPdfResourceDictionary*)ret)->valid()) || (doc == NULL && ret != NULL && ret->isReference())) return (SkPdfResourceDictionary*)ret; 155 // TODO(edisonn): warn about missing default value for optional fields 156 return NULL; 157 } 158 159 bool SkPdfType3FontDictionary::has_Resources() const { 160 return get("Resources", "") != NULL; 161 } 162 163 SkPdfStream* SkPdfType3FontDictionary::ToUnicode(SkPdfNativeDoc* doc) { 164 SkPdfNativeObject* ret = get("ToUnicode", ""); 165 if (doc) {ret = doc->resolveReference(ret);} 166 if ((ret != NULL && ret->hasStream()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->getStream(); 167 // TODO(edisonn): warn about missing default value for optional fields 168 return NULL; 169 } 170 171 bool SkPdfType3FontDictionary::has_ToUnicode() const { 172 return get("ToUnicode", "") != NULL; 173 } 174