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 "SkPdfShadingDictionary_autogen.h"
9 #include "SkPdfNativeDoc.h"
10 
ShadingType(SkPdfNativeDoc * doc)11 int64_t SkPdfShadingDictionary::ShadingType(SkPdfNativeDoc* doc) {
12   SkPdfNativeObject* ret = get("ShadingType", "");
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_ShadingType() const19 bool SkPdfShadingDictionary::has_ShadingType() const {
20   return get("ShadingType", "") != NULL;
21 }
22 
isColorSpaceAName(SkPdfNativeDoc * doc)23 bool SkPdfShadingDictionary::isColorSpaceAName(SkPdfNativeDoc* doc) {
24   SkPdfNativeObject* ret = get("ColorSpace", "");
25   if (doc) {ret = doc->resolveReference(ret);}
26   return ret != NULL && ret->isName();
27 }
28 
getColorSpaceAsName(SkPdfNativeDoc * doc)29 SkString SkPdfShadingDictionary::getColorSpaceAsName(SkPdfNativeDoc* doc) {
30   SkPdfNativeObject* ret = get("ColorSpace", "");
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 required field, assert for known good pdfs
34   return SkString();
35 }
36 
isColorSpaceAArray(SkPdfNativeDoc * doc)37 bool SkPdfShadingDictionary::isColorSpaceAArray(SkPdfNativeDoc* doc) {
38   SkPdfNativeObject* ret = get("ColorSpace", "");
39   if (doc) {ret = doc->resolveReference(ret);}
40   return ret != NULL && ret->isArray();
41 }
42 
getColorSpaceAsArray(SkPdfNativeDoc * doc)43 SkPdfArray* SkPdfShadingDictionary::getColorSpaceAsArray(SkPdfNativeDoc* doc) {
44   SkPdfNativeObject* ret = get("ColorSpace", "");
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 required field, assert for known good pdfs
48   return NULL;
49 }
50 
has_ColorSpace() const51 bool SkPdfShadingDictionary::has_ColorSpace() const {
52   return get("ColorSpace", "") != NULL;
53 }
54 
Background(SkPdfNativeDoc * doc)55 SkPdfArray* SkPdfShadingDictionary::Background(SkPdfNativeDoc* doc) {
56   SkPdfNativeObject* ret = get("Background", "");
57   if (doc) {ret = doc->resolveReference(ret);}
58   if ((ret != NULL && ret->isArray()) || (doc == NULL && ret != NULL && ret->isReference())) return (SkPdfArray*)ret;
59   // TODO(edisonn): warn about missing default value for optional fields
60   return NULL;
61 }
62 
has_Background() const63 bool SkPdfShadingDictionary::has_Background() const {
64   return get("Background", "") != NULL;
65 }
66 
BBox(SkPdfNativeDoc * doc)67 SkRect SkPdfShadingDictionary::BBox(SkPdfNativeDoc* doc) {
68   SkPdfNativeObject* ret = get("BBox", "");
69   if (doc) {ret = doc->resolveReference(ret);}
70   if ((ret != NULL && ret->isRectangle()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->rectangleValue();
71   // TODO(edisonn): warn about missing default value for optional fields
72   return SkRect::MakeEmpty();
73 }
74 
has_BBox() const75 bool SkPdfShadingDictionary::has_BBox() const {
76   return get("BBox", "") != NULL;
77 }
78 
AntiAlias(SkPdfNativeDoc * doc)79 bool SkPdfShadingDictionary::AntiAlias(SkPdfNativeDoc* doc) {
80   SkPdfNativeObject* ret = get("AntiAlias", "");
81   if (doc) {ret = doc->resolveReference(ret);}
82   if ((ret != NULL && ret->isBoolean()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->boolValue();
83   // TODO(edisonn): warn about missing default value for optional fields
84   return false;
85 }
86 
has_AntiAlias() const87 bool SkPdfShadingDictionary::has_AntiAlias() const {
88   return get("AntiAlias", "") != NULL;
89 }
90