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 "SkPdfEncryptionCommonDictionary_autogen.h"
9#include "SkPdfNativeDoc.h"
10
11SkString SkPdfEncryptionCommonDictionary::Filter(SkPdfNativeDoc* doc) {
12  SkPdfNativeObject* ret = get("Filter", "");
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 SkPdfEncryptionCommonDictionary::has_Filter() const {
20  return get("Filter", "") != NULL;
21}
22
23double SkPdfEncryptionCommonDictionary::V(SkPdfNativeDoc* doc) {
24  SkPdfNativeObject* ret = get("V", "");
25  if (doc) {ret = doc->resolveReference(ret);}
26  if ((ret != NULL && ret->isNumber()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->numberValue();
27  // TODO(edisonn): warn about missing default value for optional fields
28  return 0;
29}
30
31bool SkPdfEncryptionCommonDictionary::has_V() const {
32  return get("V", "") != NULL;
33}
34
35int64_t SkPdfEncryptionCommonDictionary::Length(SkPdfNativeDoc* doc) {
36  SkPdfNativeObject* ret = get("Length", "");
37  if (doc) {ret = doc->resolveReference(ret);}
38  if ((ret != NULL && ret->isInteger()) || (doc == NULL && ret != NULL && ret->isReference())) return ret->intValue();
39  // TODO(edisonn): warn about missing default value for optional fields
40  return 0;
41}
42
43bool SkPdfEncryptionCommonDictionary::has_Length() const {
44  return get("Length", "") != NULL;
45}
46