Home | History | Annotate | Download | only in pdfapi
      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 
     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 
     19 bool SkPdfImageDictionary::has_Type() const {
     20   return get("Type", "") != NULL;
     21 }
     22 
     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 
     31 bool SkPdfImageDictionary::has_Subtype() const {
     32   return get("Subtype", "") != NULL;
     33 }
     34 
     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 
     43 bool SkPdfImageDictionary::has_Width() const {
     44   return get("Width", "") != NULL;
     45 }
     46 
     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 
     55 bool SkPdfImageDictionary::has_Height() const {
     56   return get("Height", "") != NULL;
     57 }
     58 
     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 
     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 
     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 
     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 
     87 bool SkPdfImageDictionary::has_ColorSpace() const {
     88   return get("ColorSpace", "") != NULL;
     89 }
     90 
     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 
     99 bool SkPdfImageDictionary::has_BitsPerComponent() const {
    100   return get("BitsPerComponent", "") != NULL;
    101 }
    102 
    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 
    111 bool SkPdfImageDictionary::has_Intent() const {
    112   return get("Intent", "") != NULL;
    113 }
    114 
    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 
    123 bool SkPdfImageDictionary::has_ImageMask() const {
    124   return get("ImageMask", "") != NULL;
    125 }
    126 
    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 
    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 
    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 
    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 
    155 bool SkPdfImageDictionary::has_Mask() const {
    156   return get("Mask", "") != NULL;
    157 }
    158 
    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 
    167 bool SkPdfImageDictionary::has_SMask() const {
    168   return get("SMask", "") != NULL;
    169 }
    170 
    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 
    179 bool SkPdfImageDictionary::has_Decode() const {
    180   return get("Decode", "") != NULL;
    181 }
    182 
    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 
    191 bool SkPdfImageDictionary::has_Interpolate() const {
    192   return get("Interpolate", "") != NULL;
    193 }
    194 
    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 
    203 bool SkPdfImageDictionary::has_Alternates() const {
    204   return get("Alternates", "") != NULL;
    205 }
    206 
    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 
    215 bool SkPdfImageDictionary::has_Name() const {
    216   return get("Name", "") != NULL;
    217 }
    218 
    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 
    227 bool SkPdfImageDictionary::has_StructParent() const {
    228   return get("StructParent", "") != NULL;
    229 }
    230 
    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 
    239 bool SkPdfImageDictionary::has_ID() const {
    240   return get("ID", "") != NULL;
    241 }
    242 
    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 
    251 bool SkPdfImageDictionary::has_OPI() const {
    252   return get("OPI", "") != NULL;
    253 }
    254 
    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 
    263 bool SkPdfImageDictionary::has_Metadata() const {
    264   return get("Metadata", "") != NULL;
    265 }
    266