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 "SkPdfCIDFontDictionary_autogen.h"
9#include "SkPdfNativeDoc.h"
10
11SkString SkPdfCIDFontDictionary::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 required field, assert for known good pdfs
16  return SkString();
17}
18
19bool SkPdfCIDFontDictionary::has_Type() const {
20  return get("Type", "") != NULL;
21}
22
23SkString SkPdfCIDFontDictionary::Subtype(SkPdfNativeDoc* doc) {
24  SkPdfNativeObject* ret = get("Subtype", "");
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 SkPdfCIDFontDictionary::has_Subtype() const {
32  return get("Subtype", "") != NULL;
33}
34
35SkString SkPdfCIDFontDictionary::BaseFont(SkPdfNativeDoc* doc) {
36  SkPdfNativeObject* ret = get("BaseFont", "");
37  if (doc) {ret = doc->resolveReference(ret);}
38  if ((ret != NULL && ret->isName()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->nameValue2();
39  // TODO(edisonn): warn about missing required field, assert for known good pdfs
40  return SkString();
41}
42
43bool SkPdfCIDFontDictionary::has_BaseFont() const {
44  return get("BaseFont", "") != NULL;
45}
46
47SkPdfDictionary* SkPdfCIDFontDictionary::CIDSystemInfo(SkPdfNativeDoc* doc) {
48  SkPdfNativeObject* ret = get("CIDSystemInfo", "");
49  if (doc) {ret = doc->resolveReference(ret);}
50  if ((ret != NULL && ret->isDictionary()) || (doc == NULL && ret != NULL && ret->isReference())) return (SkPdfDictionary*)ret;
51  // TODO(edisonn): warn about missing required field, assert for known good pdfs
52  return NULL;
53}
54
55bool SkPdfCIDFontDictionary::has_CIDSystemInfo() const {
56  return get("CIDSystemInfo", "") != NULL;
57}
58
59SkPdfFontDescriptorDictionary* SkPdfCIDFontDictionary::FontDescriptor(SkPdfNativeDoc* doc) {
60  SkPdfNativeObject* ret = get("FontDescriptor", "");
61  if (doc) {ret = doc->resolveReference(ret);}
62  if ((ret != NULL && ret->isDictionary() && ((SkPdfFontDescriptorDictionary*)ret)->valid()) || (doc == NULL && ret != NULL && ret->isReference())) return (SkPdfFontDescriptorDictionary*)ret;
63  // TODO(edisonn): warn about missing default value for optional fields
64  return NULL;
65}
66
67bool SkPdfCIDFontDictionary::has_FontDescriptor() const {
68  return get("FontDescriptor", "") != NULL;
69}
70
71int64_t SkPdfCIDFontDictionary::DW(SkPdfNativeDoc* doc) {
72  SkPdfNativeObject* ret = get("DW", "");
73  if (doc) {ret = doc->resolveReference(ret);}
74  if ((ret != NULL && ret->isInteger()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->intValue();
75  // TODO(edisonn): warn about missing default value for optional fields
76  return 0;
77}
78
79bool SkPdfCIDFontDictionary::has_DW() const {
80  return get("DW", "") != NULL;
81}
82
83SkPdfArray* SkPdfCIDFontDictionary::W(SkPdfNativeDoc* doc) {
84  SkPdfNativeObject* ret = get("W", "");
85  if (doc) {ret = doc->resolveReference(ret);}
86  if ((ret != NULL && ret->isArray()) || (doc == NULL && ret != NULL && ret->isReference())) return (SkPdfArray*)ret;
87  // TODO(edisonn): warn about missing default value for optional fields
88  return NULL;
89}
90
91bool SkPdfCIDFontDictionary::has_W() const {
92  return get("W", "") != NULL;
93}
94
95SkPdfArray* SkPdfCIDFontDictionary::DW2(SkPdfNativeDoc* doc) {
96  SkPdfNativeObject* ret = get("DW2", "");
97  if (doc) {ret = doc->resolveReference(ret);}
98  if ((ret != NULL && ret->isArray()) || (doc == NULL && ret != NULL && ret->isReference())) return (SkPdfArray*)ret;
99  // TODO(edisonn): warn about missing default value for optional fields
100  return NULL;
101}
102
103bool SkPdfCIDFontDictionary::has_DW2() const {
104  return get("DW2", "") != NULL;
105}
106
107SkPdfArray* SkPdfCIDFontDictionary::W2(SkPdfNativeDoc* doc) {
108  SkPdfNativeObject* ret = get("W2", "");
109  if (doc) {ret = doc->resolveReference(ret);}
110  if ((ret != NULL && ret->isArray()) || (doc == NULL && ret != NULL && ret->isReference())) return (SkPdfArray*)ret;
111  // TODO(edisonn): warn about missing default value for optional fields
112  return NULL;
113}
114
115bool SkPdfCIDFontDictionary::has_W2() const {
116  return get("W2", "") != NULL;
117}
118
119bool SkPdfCIDFontDictionary::isCIDToGIDMapAStream(SkPdfNativeDoc* doc) {
120  SkPdfNativeObject* ret = get("CIDToGIDMap", "");
121  if (doc) {ret = doc->resolveReference(ret);}
122  return ret != NULL && ret->hasStream();
123}
124
125SkPdfStream* SkPdfCIDFontDictionary::getCIDToGIDMapAsStream(SkPdfNativeDoc* doc) {
126  SkPdfNativeObject* ret = get("CIDToGIDMap", "");
127  if (doc) {ret = doc->resolveReference(ret);}
128  if ((ret != NULL && ret->hasStream()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->getStream();
129  // TODO(edisonn): warn about missing default value for optional fields
130  return NULL;
131}
132
133bool SkPdfCIDFontDictionary::isCIDToGIDMapAName(SkPdfNativeDoc* doc) {
134  SkPdfNativeObject* ret = get("CIDToGIDMap", "");
135  if (doc) {ret = doc->resolveReference(ret);}
136  return ret != NULL && ret->isName();
137}
138
139SkString SkPdfCIDFontDictionary::getCIDToGIDMapAsName(SkPdfNativeDoc* doc) {
140  SkPdfNativeObject* ret = get("CIDToGIDMap", "");
141  if (doc) {ret = doc->resolveReference(ret);}
142  if ((ret != NULL && ret->isName()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->nameValue2();
143  // TODO(edisonn): warn about missing default value for optional fields
144  return SkString();
145}
146
147bool SkPdfCIDFontDictionary::has_CIDToGIDMap() const {
148  return get("CIDToGIDMap", "") != NULL;
149}
150