Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
cpdf_object.cpp
Go to the documentation of this file.
1// Copyright 2016 The PDFium Authors
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7#include "core/fpdfapi/parser/cpdf_object.h"
8
9#include <algorithm>
10
11#include "core/fpdfapi/parser/cpdf_array.h"
12#include "core/fpdfapi/parser/cpdf_dictionary.h"
13#include "core/fpdfapi/parser/cpdf_indirect_object_holder.h"
14#include "core/fpdfapi/parser/cpdf_parser.h"
15#include "core/fpdfapi/parser/cpdf_reference.h"
16#include "core/fxcrt/fx_string.h"
17#include "third_party/base/check.h"
18#include "third_party/base/notreached.h"
19
20CPDF_Object::~CPDF_Object() = default;
21
22static_assert(sizeof(uint64_t) >= sizeof(CPDF_Object*),
23 "Need a bigger type for cache keys");
24
25static_assert(CPDF_Parser::kMaxObjectNumber < static_cast<uint32_t>(1) << 31,
26 "Need a smaller kMaxObjNumber for cache keys");
27
28uint64_t CPDF_Object::KeyForCache() const {
29 if (IsInline())
30 return (static_cast<uint64_t>(1) << 63) | reinterpret_cast<uint64_t>(this);
31
32 return (static_cast<uint64_t>(m_ObjNum) << 32) |
33 static_cast<uint64_t>(m_GenNum);
34}
35
37 return pdfium::WrapRetain(const_cast<CPDF_Object*>(GetDirectInternal()));
38}
39
41 return pdfium::WrapRetain(GetDirectInternal());
42}
43
45 return this;
46}
47
49 std::set<const CPDF_Object*> visited_objs;
50 return CloneNonCyclic(bDirect, &visited_objs);
51}
52
54 return CloneObjectNonCyclic(true);
55}
56
58 bool bDirect,
59 std::set<const CPDF_Object*>* pVisited) const {
60 return Clone();
61}
62
63ByteString CPDF_Object::GetString() const {
64 return ByteString();
65}
66
67WideString CPDF_Object::GetUnicodeText() const {
68 return WideString();
69}
70
71float CPDF_Object::GetNumber() const {
72 return 0;
73}
74
75int CPDF_Object::GetInteger() const {
76 return 0;
77}
78
79RetainPtr<const CPDF_Dictionary> CPDF_Object::GetDict() const {
80 return pdfium::WrapRetain(GetDictInternal());
81}
82
84 return pdfium::WrapRetain(const_cast<CPDF_Dictionary*>(GetDictInternal()));
85}
86
87const CPDF_Dictionary* CPDF_Object::GetDictInternal() const {
88 return nullptr;
89}
90
91void CPDF_Object::SetString(const ByteString& str) {
92 NOTREACHED_NORETURN();
93}
94
96 return nullptr;
97}
98
99const CPDF_Array* CPDF_Object::AsArray() const {
100 return const_cast<CPDF_Object*>(this)->AsMutableArray();
101}
102
104 return nullptr;
105}
106
107const CPDF_Boolean* CPDF_Object::AsBoolean() const {
108 return const_cast<CPDF_Object*>(this)->AsMutableBoolean();
109}
110
111CPDF_Dictionary* CPDF_Object::AsMutableDictionary() {
112 return nullptr;
113}
114
115const CPDF_Dictionary* CPDF_Object::AsDictionary() const {
116 return const_cast<CPDF_Object*>(this)->AsMutableDictionary();
117}
118
120 return nullptr;
121}
122
123const CPDF_Name* CPDF_Object::AsName() const {
124 return const_cast<CPDF_Object*>(this)->AsMutableName();
125}
126
128 return nullptr;
129}
130
131const CPDF_Null* CPDF_Object::AsNull() const {
132 return const_cast<CPDF_Object*>(this)->AsMutableNull();
133}
134
136 return nullptr;
137}
138
139const CPDF_Number* CPDF_Object::AsNumber() const {
140 return const_cast<CPDF_Object*>(this)->AsMutableNumber();
141}
142
143CPDF_Reference* CPDF_Object::AsMutableReference() {
144 return nullptr;
145}
146
147const CPDF_Reference* CPDF_Object::AsReference() const {
148 return const_cast<CPDF_Object*>(this)->AsMutableReference();
149}
150
152 return nullptr;
153}
154
155const CPDF_Stream* CPDF_Object::AsStream() const {
156 return const_cast<CPDF_Object*>(this)->AsMutableStream();
157}
158
160 return nullptr;
161}
162
163const CPDF_String* CPDF_Object::AsString() const {
164 return const_cast<CPDF_Object*>(this)->AsMutableString();
165}
166
168 CPDF_IndirectObjectHolder* holder) const {
170 return pdfium::MakeRetain<CPDF_Reference>(holder, GetObjNum());
171}
RetainPtr< const CPDF_Dictionary > GetDict() const
bool IsInline() const
Definition cpdf_object.h:69
virtual WideString GetUnicodeText() const
virtual ByteString GetString() const
RetainPtr< const CPDF_Object > GetDirect() const
uint32_t m_GenNum
virtual CPDF_Null * AsMutableNull()
const CPDF_Name * AsName() const
const CPDF_Boolean * AsBoolean() const
virtual void SetString(const ByteString &str)
const CPDF_Null * AsNull() const
virtual RetainPtr< CPDF_Reference > MakeReference(CPDF_IndirectObjectHolder *holder) const
RetainPtr< CPDF_Object > GetMutableDirect()
const CPDF_Array * AsArray() const
virtual int GetInteger() const
virtual float GetNumber() const
uint32_t GetObjNum() const
Definition cpdf_object.h:65
const CPDF_Dictionary * AsDictionary() const
RetainPtr< CPDF_Object > CloneDirectObject() const
virtual CPDF_Stream * AsMutableStream()
virtual CPDF_Number * AsMutableNumber()
virtual CPDF_Dictionary * AsMutableDictionary()
virtual RetainPtr< CPDF_Object > Clone() const =0
virtual CPDF_Reference * AsMutableReference()
uint32_t m_ObjNum
const CPDF_Stream * AsStream() const
virtual const CPDF_Object * GetDirectInternal() const
virtual CPDF_Name * AsMutableName()
const CPDF_String * AsString() const
uint64_t KeyForCache() const
virtual CPDF_Array * AsMutableArray()
const CPDF_Reference * AsReference() const
virtual RetainPtr< CPDF_Object > CloneNonCyclic(bool bDirect, std::set< const CPDF_Object * > *pVisited) const
virtual CPDF_String * AsMutableString()
const CPDF_Number * AsNumber() const
RetainPtr< CPDF_Dictionary > GetMutableDict()
RetainPtr< CPDF_Object > CloneObjectNonCyclic(bool bDirect) const
virtual const CPDF_Dictionary * GetDictInternal() const
~CPDF_Object() override
virtual CPDF_Boolean * AsMutableBoolean()
static constexpr uint32_t kMaxObjectNumber
Definition cpdf_parser.h:57
#define CHECK(cvref)