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 "SkPdfSourceInformationDictionary_autogen.h"
9 #include "SkPdfNativeDoc.h"
10 
isAUAString(SkPdfNativeDoc * doc)11 bool SkPdfSourceInformationDictionary::isAUAString(SkPdfNativeDoc* doc) {
12   SkPdfNativeObject* ret = get("AU", "");
13   if (doc) {ret = doc->resolveReference(ret);}
14   return ret != NULL && ret->isAnyString();
15 }
16 
getAUAsString(SkPdfNativeDoc * doc)17 SkString SkPdfSourceInformationDictionary::getAUAsString(SkPdfNativeDoc* doc) {
18   SkPdfNativeObject* ret = get("AU", "");
19   if (doc) {ret = doc->resolveReference(ret);}
20   if ((ret != NULL && ret->isAnyString()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->stringValue2();
21   // TODO(edisonn): warn about missing required field, assert for known good pdfs
22   return SkString();
23 }
24 
isAUADictionary(SkPdfNativeDoc * doc)25 bool SkPdfSourceInformationDictionary::isAUADictionary(SkPdfNativeDoc* doc) {
26   SkPdfNativeObject* ret = get("AU", "");
27   if (doc) {ret = doc->resolveReference(ret);}
28   return ret != NULL && ret->isDictionary();
29 }
30 
getAUAsDictionary(SkPdfNativeDoc * doc)31 SkPdfDictionary* SkPdfSourceInformationDictionary::getAUAsDictionary(SkPdfNativeDoc* doc) {
32   SkPdfNativeObject* ret = get("AU", "");
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_AU() const39 bool SkPdfSourceInformationDictionary::has_AU() const {
40   return get("AU", "") != NULL;
41 }
42 
TS(SkPdfNativeDoc * doc)43 SkPdfDate SkPdfSourceInformationDictionary::TS(SkPdfNativeDoc* doc) {
44   SkPdfNativeObject* ret = get("TS", "");
45   if (doc) {ret = doc->resolveReference(ret);}
46   if ((ret != NULL && ret->isDate()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->dateValue();
47   // TODO(edisonn): warn about missing default value for optional fields
48   return SkPdfDate();
49 }
50 
has_TS() const51 bool SkPdfSourceInformationDictionary::has_TS() const {
52   return get("TS", "") != NULL;
53 }
54 
E(SkPdfNativeDoc * doc)55 SkPdfDate SkPdfSourceInformationDictionary::E(SkPdfNativeDoc* doc) {
56   SkPdfNativeObject* ret = get("E", "");
57   if (doc) {ret = doc->resolveReference(ret);}
58   if ((ret != NULL && ret->isDate()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->dateValue();
59   // TODO(edisonn): warn about missing default value for optional fields
60   return SkPdfDate();
61 }
62 
has_E() const63 bool SkPdfSourceInformationDictionary::has_E() const {
64   return get("E", "") != NULL;
65 }
66 
S(SkPdfNativeDoc * doc)67 int64_t SkPdfSourceInformationDictionary::S(SkPdfNativeDoc* doc) {
68   SkPdfNativeObject* ret = get("S", "");
69   if (doc) {ret = doc->resolveReference(ret);}
70   if ((ret != NULL && ret->isInteger()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->intValue();
71   // TODO(edisonn): warn about missing default value for optional fields
72   return 0;
73 }
74 
has_S() const75 bool SkPdfSourceInformationDictionary::has_S() const {
76   return get("S", "") != NULL;
77 }
78 
C(SkPdfNativeDoc * doc)79 SkPdfDictionary* SkPdfSourceInformationDictionary::C(SkPdfNativeDoc* doc) {
80   SkPdfNativeObject* ret = get("C", "");
81   if (doc) {ret = doc->resolveReference(ret);}
82   if ((ret != NULL && ret->isDictionary()) || (doc == NULL && ret != NULL && ret->isReference())) return (SkPdfDictionary*)ret;
83   // TODO(edisonn): warn about missing default value for optional fields
84   return NULL;
85 }
86 
has_C() const87 bool SkPdfSourceInformationDictionary::has_C() const {
88   return get("C", "") != NULL;
89 }
90