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 "SkPdfWebCaptureDictionary_autogen.h"
9#include "SkPdfNativeDoc.h"
10
11SkString SkPdfWebCaptureDictionary::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
19bool SkPdfWebCaptureDictionary::has_Type() const {
20  return get("Type", "") != NULL;
21}
22
23SkString SkPdfWebCaptureDictionary::S(SkPdfNativeDoc* doc) {
24  SkPdfNativeObject* ret = get("S", "");
25  if (doc) {ret = doc->resolveReference(ret);}
26  if ((ret != NULL && ret->isName()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->nameValue2();
27  // TODO(edisonn): warn about missing required field, assert for known good pdfs
28  return SkString();
29}
30
31bool SkPdfWebCaptureDictionary::has_S() const {
32  return get("S", "") != NULL;
33}
34
35SkString SkPdfWebCaptureDictionary::ID(SkPdfNativeDoc* doc) {
36  SkPdfNativeObject* ret = get("ID", "");
37  if (doc) {ret = doc->resolveReference(ret);}
38  if ((ret != NULL && ret->isAnyString()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->stringValue2();
39  // TODO(edisonn): warn about missing required field, assert for known good pdfs
40  return SkString();
41}
42
43bool SkPdfWebCaptureDictionary::has_ID() const {
44  return get("ID", "") != NULL;
45}
46
47SkPdfArray* SkPdfWebCaptureDictionary::O(SkPdfNativeDoc* doc) {
48  SkPdfNativeObject* ret = get("O", "");
49  if (doc) {ret = doc->resolveReference(ret);}
50  if ((ret != NULL && ret->isArray()) || (doc == NULL && ret != NULL && ret->isReference())) return (SkPdfArray*)ret;
51  // TODO(edisonn): warn about missing required field, assert for known good pdfs
52  return NULL;
53}
54
55bool SkPdfWebCaptureDictionary::has_O() const {
56  return get("O", "") != NULL;
57}
58
59bool SkPdfWebCaptureDictionary::isSIADictionary(SkPdfNativeDoc* doc) {
60  SkPdfNativeObject* ret = get("SI", "");
61  if (doc) {ret = doc->resolveReference(ret);}
62  return ret != NULL && ret->isDictionary();
63}
64
65SkPdfDictionary* SkPdfWebCaptureDictionary::getSIAsDictionary(SkPdfNativeDoc* doc) {
66  SkPdfNativeObject* ret = get("SI", "");
67  if (doc) {ret = doc->resolveReference(ret);}
68  if ((ret != NULL && ret->isDictionary()) || (doc == NULL && ret != NULL && ret->isReference())) return (SkPdfDictionary*)ret;
69  // TODO(edisonn): warn about missing required field, assert for known good pdfs
70  return NULL;
71}
72
73bool SkPdfWebCaptureDictionary::isSIAArray(SkPdfNativeDoc* doc) {
74  SkPdfNativeObject* ret = get("SI", "");
75  if (doc) {ret = doc->resolveReference(ret);}
76  return ret != NULL && ret->isArray();
77}
78
79SkPdfArray* SkPdfWebCaptureDictionary::getSIAsArray(SkPdfNativeDoc* doc) {
80  SkPdfNativeObject* ret = get("SI", "");
81  if (doc) {ret = doc->resolveReference(ret);}
82  if ((ret != NULL && ret->isArray()) || (doc == NULL && ret != NULL && ret->isReference())) return (SkPdfArray*)ret;
83  // TODO(edisonn): warn about missing required field, assert for known good pdfs
84  return NULL;
85}
86
87bool SkPdfWebCaptureDictionary::has_SI() const {
88  return get("SI", "") != NULL;
89}
90
91SkString SkPdfWebCaptureDictionary::CT(SkPdfNativeDoc* doc) {
92  SkPdfNativeObject* ret = get("CT", "");
93  if (doc) {ret = doc->resolveReference(ret);}
94  if ((ret != NULL && ret->isAnyString()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->stringValue2();
95  // TODO(edisonn): warn about missing default value for optional fields
96  return SkString();
97}
98
99bool SkPdfWebCaptureDictionary::has_CT() const {
100  return get("CT", "") != NULL;
101}
102
103SkPdfDate SkPdfWebCaptureDictionary::TS(SkPdfNativeDoc* doc) {
104  SkPdfNativeObject* ret = get("TS", "");
105  if (doc) {ret = doc->resolveReference(ret);}
106  if ((ret != NULL && ret->isDate()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->dateValue();
107  // TODO(edisonn): warn about missing default value for optional fields
108  return SkPdfDate();
109}
110
111bool SkPdfWebCaptureDictionary::has_TS() const {
112  return get("TS", "") != NULL;
113}
114