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
11bool SkPdfSourceInformationDictionary::isAUAString(SkPdfNativeDoc* doc) {
12  SkPdfNativeObject* ret = get("AU", "");
13  if (doc) {ret = doc->resolveReference(ret);}
14  return ret != NULL && ret->isAnyString();
15}
16
17SkString 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
25bool SkPdfSourceInformationDictionary::isAUADictionary(SkPdfNativeDoc* doc) {
26  SkPdfNativeObject* ret = get("AU", "");
27  if (doc) {ret = doc->resolveReference(ret);}
28  return ret != NULL && ret->isDictionary();
29}
30
31SkPdfDictionary* 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
39bool SkPdfSourceInformationDictionary::has_AU() const {
40  return get("AU", "") != NULL;
41}
42
43SkPdfDate 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
51bool SkPdfSourceInformationDictionary::has_TS() const {
52  return get("TS", "") != NULL;
53}
54
55SkPdfDate 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
63bool SkPdfSourceInformationDictionary::has_E() const {
64  return get("E", "") != NULL;
65}
66
67int64_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
75bool SkPdfSourceInformationDictionary::has_S() const {
76  return get("S", "") != NULL;
77}
78
79SkPdfDictionary* 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
87bool SkPdfSourceInformationDictionary::has_C() const {
88  return get("C", "") != NULL;
89}
90