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 "SkPdfAppearanceDictionary_autogen.h"
9 #include "SkPdfNativeDoc.h"
10 
isNAStream(SkPdfNativeDoc * doc)11 bool SkPdfAppearanceDictionary::isNAStream(SkPdfNativeDoc* doc) {
12   SkPdfNativeObject* ret = get("N", "");
13   if (doc) {ret = doc->resolveReference(ret);}
14   return ret != NULL && ret->hasStream();
15 }
16 
getNAsStream(SkPdfNativeDoc * doc)17 SkPdfStream* SkPdfAppearanceDictionary::getNAsStream(SkPdfNativeDoc* doc) {
18   SkPdfNativeObject* ret = get("N", "");
19   if (doc) {ret = doc->resolveReference(ret);}
20   if ((ret != NULL && ret->hasStream()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->getStream();
21   // TODO(edisonn): warn about missing required field, assert for known good pdfs
22   return NULL;
23 }
24 
isNADictionary(SkPdfNativeDoc * doc)25 bool SkPdfAppearanceDictionary::isNADictionary(SkPdfNativeDoc* doc) {
26   SkPdfNativeObject* ret = get("N", "");
27   if (doc) {ret = doc->resolveReference(ret);}
28   return ret != NULL && ret->isDictionary();
29 }
30 
getNAsDictionary(SkPdfNativeDoc * doc)31 SkPdfDictionary* SkPdfAppearanceDictionary::getNAsDictionary(SkPdfNativeDoc* doc) {
32   SkPdfNativeObject* ret = get("N", "");
33   if (doc) {ret = doc->resolveReference(ret);}
34   if ((ret != NULL && ret->isDictionary()) || (doc == NULL && ret != NULL && ret->isReference())) return (SkPdfDictionary*)ret;
35   // TODO(edisonn): warn about missing required field, assert for known good pdfs
36   return NULL;
37 }
38 
has_N() const39 bool SkPdfAppearanceDictionary::has_N() const {
40   return get("N", "") != NULL;
41 }
42 
isRAStream(SkPdfNativeDoc * doc)43 bool SkPdfAppearanceDictionary::isRAStream(SkPdfNativeDoc* doc) {
44   SkPdfNativeObject* ret = get("R", "");
45   if (doc) {ret = doc->resolveReference(ret);}
46   return ret != NULL && ret->hasStream();
47 }
48 
getRAsStream(SkPdfNativeDoc * doc)49 SkPdfStream* SkPdfAppearanceDictionary::getRAsStream(SkPdfNativeDoc* doc) {
50   SkPdfNativeObject* ret = get("R", "");
51   if (doc) {ret = doc->resolveReference(ret);}
52   if ((ret != NULL && ret->hasStream()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->getStream();
53   // TODO(edisonn): warn about missing default value for optional fields
54   return NULL;
55 }
56 
isRADictionary(SkPdfNativeDoc * doc)57 bool SkPdfAppearanceDictionary::isRADictionary(SkPdfNativeDoc* doc) {
58   SkPdfNativeObject* ret = get("R", "");
59   if (doc) {ret = doc->resolveReference(ret);}
60   return ret != NULL && ret->isDictionary();
61 }
62 
getRAsDictionary(SkPdfNativeDoc * doc)63 SkPdfDictionary* SkPdfAppearanceDictionary::getRAsDictionary(SkPdfNativeDoc* doc) {
64   SkPdfNativeObject* ret = get("R", "");
65   if (doc) {ret = doc->resolveReference(ret);}
66   if ((ret != NULL && ret->isDictionary()) || (doc == NULL && ret != NULL && ret->isReference())) return (SkPdfDictionary*)ret;
67   // TODO(edisonn): warn about missing default value for optional fields
68   return NULL;
69 }
70 
has_R() const71 bool SkPdfAppearanceDictionary::has_R() const {
72   return get("R", "") != NULL;
73 }
74 
isDAStream(SkPdfNativeDoc * doc)75 bool SkPdfAppearanceDictionary::isDAStream(SkPdfNativeDoc* doc) {
76   SkPdfNativeObject* ret = get("D", "");
77   if (doc) {ret = doc->resolveReference(ret);}
78   return ret != NULL && ret->hasStream();
79 }
80 
getDAsStream(SkPdfNativeDoc * doc)81 SkPdfStream* SkPdfAppearanceDictionary::getDAsStream(SkPdfNativeDoc* doc) {
82   SkPdfNativeObject* ret = get("D", "");
83   if (doc) {ret = doc->resolveReference(ret);}
84   if ((ret != NULL && ret->hasStream()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->getStream();
85   // TODO(edisonn): warn about missing default value for optional fields
86   return NULL;
87 }
88 
isDADictionary(SkPdfNativeDoc * doc)89 bool SkPdfAppearanceDictionary::isDADictionary(SkPdfNativeDoc* doc) {
90   SkPdfNativeObject* ret = get("D", "");
91   if (doc) {ret = doc->resolveReference(ret);}
92   return ret != NULL && ret->isDictionary();
93 }
94 
getDAsDictionary(SkPdfNativeDoc * doc)95 SkPdfDictionary* SkPdfAppearanceDictionary::getDAsDictionary(SkPdfNativeDoc* doc) {
96   SkPdfNativeObject* ret = get("D", "");
97   if (doc) {ret = doc->resolveReference(ret);}
98   if ((ret != NULL && ret->isDictionary()) || (doc == NULL && ret != NULL && ret->isReference())) return (SkPdfDictionary*)ret;
99   // TODO(edisonn): warn about missing default value for optional fields
100   return NULL;
101 }
102 
has_D() const103 bool SkPdfAppearanceDictionary::has_D() const {
104   return get("D", "") != NULL;
105 }
106