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 "SkPdfRemoteGoToActionDictionary_autogen.h"
9 #include "SkPdfNativeDoc.h"
10 
S(SkPdfNativeDoc * doc)11 SkString SkPdfRemoteGoToActionDictionary::S(SkPdfNativeDoc* doc) {
12   SkPdfNativeObject* ret = get("S", "");
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 
has_S() const19 bool SkPdfRemoteGoToActionDictionary::has_S() const {
20   return get("S", "") != NULL;
21 }
22 
F(SkPdfNativeDoc * doc)23 SkPdfFileSpec SkPdfRemoteGoToActionDictionary::F(SkPdfNativeDoc* doc) {
24   SkPdfNativeObject* ret = get("F", "");
25   if (doc) {ret = doc->resolveReference(ret);}
26   if ((ret != NULL && false) || (doc == NULL && ret != NULL && ret->isReference())) return ret->fileSpecValue();
27   // TODO(edisonn): warn about missing required field, assert for known good pdfs
28   return SkPdfFileSpec();
29 }
30 
has_F() const31 bool SkPdfRemoteGoToActionDictionary::has_F() const {
32   return get("F", "") != NULL;
33 }
34 
isDAName(SkPdfNativeDoc * doc)35 bool SkPdfRemoteGoToActionDictionary::isDAName(SkPdfNativeDoc* doc) {
36   SkPdfNativeObject* ret = get("D", "");
37   if (doc) {ret = doc->resolveReference(ret);}
38   return ret != NULL && ret->isName();
39 }
40 
getDAsName(SkPdfNativeDoc * doc)41 SkString SkPdfRemoteGoToActionDictionary::getDAsName(SkPdfNativeDoc* doc) {
42   SkPdfNativeObject* ret = get("D", "");
43   if (doc) {ret = doc->resolveReference(ret);}
44   if ((ret != NULL && ret->isName()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->nameValue2();
45   // TODO(edisonn): warn about missing required field, assert for known good pdfs
46   return SkString();
47 }
48 
isDAString(SkPdfNativeDoc * doc)49 bool SkPdfRemoteGoToActionDictionary::isDAString(SkPdfNativeDoc* doc) {
50   SkPdfNativeObject* ret = get("D", "");
51   if (doc) {ret = doc->resolveReference(ret);}
52   return ret != NULL && ret->isAnyString();
53 }
54 
getDAsString(SkPdfNativeDoc * doc)55 SkString SkPdfRemoteGoToActionDictionary::getDAsString(SkPdfNativeDoc* doc) {
56   SkPdfNativeObject* ret = get("D", "");
57   if (doc) {ret = doc->resolveReference(ret);}
58   if ((ret != NULL && ret->isAnyString()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->stringValue2();
59   // TODO(edisonn): warn about missing required field, assert for known good pdfs
60   return SkString();
61 }
62 
isDAArray(SkPdfNativeDoc * doc)63 bool SkPdfRemoteGoToActionDictionary::isDAArray(SkPdfNativeDoc* doc) {
64   SkPdfNativeObject* ret = get("D", "");
65   if (doc) {ret = doc->resolveReference(ret);}
66   return ret != NULL && ret->isArray();
67 }
68 
getDAsArray(SkPdfNativeDoc * doc)69 SkPdfArray* SkPdfRemoteGoToActionDictionary::getDAsArray(SkPdfNativeDoc* doc) {
70   SkPdfNativeObject* ret = get("D", "");
71   if (doc) {ret = doc->resolveReference(ret);}
72   if ((ret != NULL && ret->isArray()) || (doc == NULL && ret != NULL && ret->isReference())) return (SkPdfArray*)ret;
73   // TODO(edisonn): warn about missing required field, assert for known good pdfs
74   return NULL;
75 }
76 
has_D() const77 bool SkPdfRemoteGoToActionDictionary::has_D() const {
78   return get("D", "") != NULL;
79 }
80 
NewWindow(SkPdfNativeDoc * doc)81 bool SkPdfRemoteGoToActionDictionary::NewWindow(SkPdfNativeDoc* doc) {
82   SkPdfNativeObject* ret = get("NewWindow", "");
83   if (doc) {ret = doc->resolveReference(ret);}
84   if ((ret != NULL && ret->isBoolean()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->boolValue();
85   // TODO(edisonn): warn about missing default value for optional fields
86   return false;
87 }
88 
has_NewWindow() const89 bool SkPdfRemoteGoToActionDictionary::has_NewWindow() const {
90   return get("NewWindow", "") != NULL;
91 }
92