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 "SkPdfType1PatternDictionary_autogen.h"
9 #include "SkPdfNativeDoc.h"
10 
Type(SkPdfNativeDoc * doc)11 SkString SkPdfType1PatternDictionary::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 
has_Type() const19 bool SkPdfType1PatternDictionary::has_Type() const {
20   return get("Type", "") != NULL;
21 }
22 
PatternType(SkPdfNativeDoc * doc)23 int64_t SkPdfType1PatternDictionary::PatternType(SkPdfNativeDoc* doc) {
24   SkPdfNativeObject* ret = get("PatternType", "");
25   if (doc) {ret = doc->resolveReference(ret);}
26   if ((ret != NULL && ret->isInteger()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->intValue();
27   // TODO(edisonn): warn about missing required field, assert for known good pdfs
28   return 0;
29 }
30 
has_PatternType() const31 bool SkPdfType1PatternDictionary::has_PatternType() const {
32   return get("PatternType", "") != NULL;
33 }
34 
PaintType(SkPdfNativeDoc * doc)35 int64_t SkPdfType1PatternDictionary::PaintType(SkPdfNativeDoc* doc) {
36   SkPdfNativeObject* ret = get("PaintType", "");
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 
has_PaintType() const43 bool SkPdfType1PatternDictionary::has_PaintType() const {
44   return get("PaintType", "") != NULL;
45 }
46 
TilingType(SkPdfNativeDoc * doc)47 int64_t SkPdfType1PatternDictionary::TilingType(SkPdfNativeDoc* doc) {
48   SkPdfNativeObject* ret = get("TilingType", "");
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 
has_TilingType() const55 bool SkPdfType1PatternDictionary::has_TilingType() const {
56   return get("TilingType", "") != NULL;
57 }
58 
BBox(SkPdfNativeDoc * doc)59 SkRect SkPdfType1PatternDictionary::BBox(SkPdfNativeDoc* doc) {
60   SkPdfNativeObject* ret = get("BBox", "");
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 
has_BBox() const67 bool SkPdfType1PatternDictionary::has_BBox() const {
68   return get("BBox", "") != NULL;
69 }
70 
XStep(SkPdfNativeDoc * doc)71 double SkPdfType1PatternDictionary::XStep(SkPdfNativeDoc* doc) {
72   SkPdfNativeObject* ret = get("XStep", "");
73   if (doc) {ret = doc->resolveReference(ret);}
74   if ((ret != NULL && ret->isNumber()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->numberValue();
75   // TODO(edisonn): warn about missing required field, assert for known good pdfs
76   return 0;
77 }
78 
has_XStep() const79 bool SkPdfType1PatternDictionary::has_XStep() const {
80   return get("XStep", "") != NULL;
81 }
82 
YStep(SkPdfNativeDoc * doc)83 double SkPdfType1PatternDictionary::YStep(SkPdfNativeDoc* doc) {
84   SkPdfNativeObject* ret = get("YStep", "");
85   if (doc) {ret = doc->resolveReference(ret);}
86   if ((ret != NULL && ret->isNumber()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->numberValue();
87   // TODO(edisonn): warn about missing required field, assert for known good pdfs
88   return 0;
89 }
90 
has_YStep() const91 bool SkPdfType1PatternDictionary::has_YStep() const {
92   return get("YStep", "") != NULL;
93 }
94 
Resources(SkPdfNativeDoc * doc)95 SkPdfResourceDictionary* SkPdfType1PatternDictionary::Resources(SkPdfNativeDoc* doc) {
96   SkPdfNativeObject* ret = get("Resources", "");
97   if (doc) {ret = doc->resolveReference(ret);}
98   if ((ret != NULL && ret->isDictionary() && ((SkPdfResourceDictionary*)ret)->valid()) || (doc == NULL && ret != NULL && ret->isReference())) return (SkPdfResourceDictionary*)ret;
99   // TODO(edisonn): warn about missing required field, assert for known good pdfs
100   return NULL;
101 }
102 
has_Resources() const103 bool SkPdfType1PatternDictionary::has_Resources() const {
104   return get("Resources", "") != NULL;
105 }
106 
Matrix(SkPdfNativeDoc * doc)107 SkMatrix SkPdfType1PatternDictionary::Matrix(SkPdfNativeDoc* doc) {
108   SkPdfNativeObject* ret = get("Matrix", "");
109   if (doc) {ret = doc->resolveReference(ret);}
110   if ((ret != NULL && ret->isMatrix()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->matrixValue();
111   // TODO(edisonn): warn about missing default value for optional fields
112   return SkMatrix::I();
113 }
114 
has_Matrix() const115 bool SkPdfType1PatternDictionary::has_Matrix() const {
116   return get("Matrix", "") != NULL;
117 }
118