| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #ifndef CORE_INCLUDE_FPDFAPI_FPDF_OBJECTS_H_ | 7 #ifndef CORE_INCLUDE_FPDFAPI_FPDF_OBJECTS_H_ |
| 8 #define CORE_INCLUDE_FPDFAPI_FPDF_OBJECTS_H_ | 8 #define CORE_INCLUDE_FPDFAPI_FPDF_OBJECTS_H_ |
| 9 | 9 |
| 10 #include "../fxcrt/fx_coordinates.h" | 10 #include "../fxcrt/fx_coordinates.h" |
| 11 #include "../fxcrt/fx_system.h" | 11 #include "../fxcrt/fx_system.h" |
| 12 | 12 |
| 13 class CPDF_Array; | 13 class CPDF_Array; |
| 14 class CPDF_Boolean; | 14 class CPDF_Boolean; |
| 15 class CPDF_CryptoHandler; | 15 class CPDF_CryptoHandler; |
| 16 class CPDF_Dictionary; | 16 class CPDF_Dictionary; |
| 17 class CPDF_Document; | 17 class CPDF_Document; |
| 18 class CPDF_IndirectObjects; | 18 class CPDF_IndirectObjects; |
| 19 class CPDF_Null; | 19 class CPDF_Null; |
| 20 class CPDF_Number; | 20 class CPDF_Number; |
| 21 class CPDF_Parser; | 21 class CPDF_Parser; |
| 22 class CPDF_Reference; | 22 class CPDF_Reference; |
| 23 class CPDF_Stream; | 23 class CPDF_Stream; |
| 24 class CPDF_StreamAcc; | 24 class CPDF_StreamAcc; |
| 25 class CPDF_StreamFilter; | 25 class CPDF_StreamFilter; |
| 26 class CPDF_String; | 26 class CPDF_String; |
| 27 class IFX_FileRead; | 27 class IFX_FileRead; |
| 28 | 28 |
| 29 #define PDFOBJ_INVALID 0 | 29 #define PDFOBJ_INVALID 0 |
| 30 #define PDFOBJ_BOOLEAN 1 | 30 #define PDFOBJ_BOOLEAN 1 |
| 31 #define PDFOBJ_NUMBER 2 | 31 #define PDFOBJ_NUMBER 2 |
| 32 #define PDFOBJ_STRING 3 | 32 #define PDFOBJ_STRING 3 |
| 33 #define PDFOBJ_NAME 4 | 33 #define PDFOBJ_NAME 4 |
| 34 #define PDFOBJ_ARRAY 5 | 34 #define PDFOBJ_ARRAY 5 |
| 35 #define PDFOBJ_DICTIONARY 6 | 35 #define PDFOBJ_DICTIONARY 6 |
| 36 #define PDFOBJ_STREAM 7 | 36 #define PDFOBJ_STREAM 7 |
| 37 #define PDFOBJ_NULL 8 | 37 #define PDFOBJ_NULL 8 |
| 38 #define PDFOBJ_REFERENCE 9 | 38 #define PDFOBJ_REFERENCE 9 |
| 39 | 39 |
| 40 typedef IFX_FileStream* (*FPDF_LPFCloneStreamCallback)(CPDF_Stream *pStream, voi
d* pUserData); | 40 typedef IFX_FileStream* (*FPDF_LPFCloneStreamCallback)(CPDF_Stream* pStream, |
| 41 class CPDF_Object | 41 void* pUserData); |
| 42 { | 42 class CPDF_Object { |
| 43 public: | 43 public: |
| 44 | 44 int GetType() const { return m_Type; } |
| 45 int GetType() const | 45 |
| 46 { | 46 FX_DWORD GetObjNum() const { return m_ObjNum; } |
| 47 return m_Type; | 47 |
| 48 } | 48 FX_DWORD GetGenNum() const { return m_GenNum; } |
| 49 | 49 |
| 50 FX_DWORD GetObjNum() const | 50 FX_BOOL IsIdentical(CPDF_Object* pObj) const; |
| 51 { | 51 |
| 52 return m_ObjNum; | 52 CPDF_Object* Clone(FX_BOOL bDirect = FALSE) const; |
| 53 } | 53 |
| 54 | 54 CPDF_Object* CloneRef(CPDF_IndirectObjects* pObjs) const; |
| 55 FX_DWORD GetGenNum() const | 55 |
| 56 { | 56 CPDF_Object* GetDirect() const; |
| 57 return m_GenNum; | 57 |
| 58 } | 58 void Release(); |
| 59 | 59 |
| 60 FX_BOOL IsIdentical(CPDF_Object* pObj) const; | 60 CFX_ByteString GetString() const; |
| 61 | 61 |
| 62 CPDF_Object* Clone(FX_BOOL bDirect = FALSE) const; | 62 CFX_ByteStringC GetConstString() const; |
| 63 | 63 |
| 64 CPDF_Object* CloneRef(CPDF_IndirectObjects* pObjs) co
nst; | 64 CFX_WideString GetUnicodeText(CFX_CharMap* pCharMap = NULL) const; |
| 65 | 65 FX_FLOAT GetNumber() const; |
| 66 CPDF_Object* GetDirect() const; | 66 |
| 67 | 67 FX_FLOAT GetNumber16() const; |
| 68 void Release(); | 68 |
| 69 | 69 int GetInteger() const; |
| 70 CFX_ByteString GetString() const; | 70 |
| 71 | 71 CPDF_Dictionary* GetDict() const; |
| 72 CFX_ByteStringC GetConstString() const; | 72 |
| 73 | 73 CPDF_Array* GetArray() const; |
| 74 CFX_WideString GetUnicodeText(CFX_CharMap* pCharMap = N
ULL) const; | 74 |
| 75 FX_FLOAT GetNumber() const; | 75 void SetString(const CFX_ByteString& str); |
| 76 | 76 |
| 77 FX_FLOAT GetNumber16() const; | 77 void SetUnicodeText(const FX_WCHAR* pUnicodes, int len = -1); |
| 78 | 78 |
| 79 int GetInteger() const; | 79 int GetDirectType() const; |
| 80 | 80 |
| 81 CPDF_Dictionary* GetDict() const; | 81 FX_BOOL IsModified() const { return FALSE; } |
| 82 | 82 |
| 83 CPDF_Array* GetArray() const; | 83 protected: |
| 84 | 84 CPDF_Object(FX_DWORD type) : m_Type(type), m_ObjNum(0), m_GenNum(0) {} |
| 85 void SetString(const CFX_ByteString& str); | 85 ~CPDF_Object() {} |
| 86 | 86 void Destroy(); |
| 87 void SetUnicodeText(const FX_WCHAR* pUnicodes
, int len = -1); | 87 |
| 88 | 88 static const int OBJECT_REF_MAX_DEPTH = 128; |
| 89 int GetDirectType() const; | 89 static int s_nCurRefDepth; |
| 90 | 90 FX_DWORD m_Type; |
| 91 FX_BOOL IsModified() const | 91 FX_DWORD m_ObjNum; |
| 92 { | 92 FX_DWORD m_GenNum; |
| 93 return FALSE; | 93 |
| 94 } | 94 friend class CPDF_IndirectObjects; |
| 95 protected: | 95 friend class CPDF_Parser; |
| 96 CPDF_Object(FX_DWORD type) : m_Type(type), m_ObjNum(0), m_GenNum(0) { } | 96 friend class CPDF_SyntaxParser; |
| 97 ~CPDF_Object() { } | 97 |
| 98 void Destroy(); | 98 private: |
| 99 | 99 CPDF_Object(const CPDF_Object& src) {} |
| 100 static const int OBJECT_REF_MAX_DEPTH = 128; | 100 CPDF_Object* CloneInternal(FX_BOOL bDirect, CFX_MapPtrToPtr* visited) const; |
| 101 static int s_nCurRefDepth; | 101 }; |
| 102 FX_DWORD m_Type; | 102 class CPDF_Boolean : public CPDF_Object { |
| 103 FX_DWORD m_ObjNum; | 103 public: |
| 104 FX_DWORD m_GenNum; | 104 static CPDF_Boolean* Create(FX_BOOL value) { return new CPDF_Boolean(value); } |
| 105 | 105 |
| 106 friend class CPDF_IndirectObjects; | 106 CPDF_Boolean() : CPDF_Object(PDFOBJ_BOOLEAN), m_bValue(false) {} |
| 107 friend class CPDF_Parser; | 107 CPDF_Boolean(FX_BOOL value) : CPDF_Object(PDFOBJ_BOOLEAN), m_bValue(value) {} |
| 108 friend class CPDF_SyntaxParser; | 108 |
| 109 private: | 109 FX_BOOL Identical(CPDF_Boolean* pOther) const { |
| 110 CPDF_Object(const CPDF_Object& src) {} | 110 return m_bValue == pOther->m_bValue; |
| 111 CPDF_Object* CloneInternal(FX_BOOL bDirect, CFX_MapPtrToPtr* visited) const; | 111 } |
| 112 }; | 112 |
| 113 class CPDF_Boolean : public CPDF_Object | 113 protected: |
| 114 { | 114 FX_BOOL m_bValue; |
| 115 public: | 115 friend class CPDF_Object; |
| 116 | 116 }; |
| 117 static CPDF_Boolean* Create(FX_BOOL value) | 117 class CPDF_Number : public CPDF_Object { |
| 118 { | 118 public: |
| 119 return new CPDF_Boolean(value); | 119 static CPDF_Number* Create(int value) { return new CPDF_Number(value); } |
| 120 } | 120 |
| 121 | 121 static CPDF_Number* Create(FX_FLOAT value) { return new CPDF_Number(value); } |
| 122 CPDF_Boolean() : CPDF_Object(PDFOBJ_BOOLEAN), m_bValue(false) { } | 122 |
| 123 CPDF_Boolean(FX_BOOL value) : CPDF_Object(PDFOBJ_BOOLEAN), m_bValue(value) {
} | 123 static CPDF_Number* Create(const CFX_ByteStringC& str) { |
| 124 | 124 return new CPDF_Number(str); |
| 125 FX_BOOL Identical(CPDF_Boolean* pOther)
const | 125 } |
| 126 { | 126 |
| 127 return m_bValue == pOther->m_bValue; | 127 static CPDF_Number* Create(FX_BOOL bInteger, void* pData) { |
| 128 } | 128 return new CPDF_Number(bInteger, pData); |
| 129 protected: | 129 } |
| 130 | 130 |
| 131 FX_BOOL m_bValue; | 131 CPDF_Number() : CPDF_Object(PDFOBJ_NUMBER), m_bInteger(false), m_Integer(0) {} |
| 132 friend class CPDF_Object; | 132 |
| 133 }; | 133 CPDF_Number(FX_BOOL bInteger, void* pData); |
| 134 class CPDF_Number : public CPDF_Object | 134 |
| 135 { | 135 CPDF_Number(int value); |
| 136 public: | 136 |
| 137 | 137 CPDF_Number(FX_FLOAT value); |
| 138 static CPDF_Number* Create(int value) | 138 |
| 139 { | 139 CPDF_Number(const CFX_ByteStringC& str); |
| 140 return new CPDF_Number(value); | 140 |
| 141 } | 141 FX_BOOL Identical(CPDF_Number* pOther) const; |
| 142 | 142 |
| 143 static CPDF_Number* Create(FX_FLOAT value) | 143 CFX_ByteString GetString() const; |
| 144 { | 144 |
| 145 return new CPDF_Number(value); | 145 void SetString(const CFX_ByteStringC& str); |
| 146 } | 146 |
| 147 | 147 FX_BOOL IsInteger() const { return m_bInteger; } |
| 148 static CPDF_Number* Create(const CFX_ByteStringC& str) | 148 |
| 149 { | 149 int GetInteger() const { return m_bInteger ? m_Integer : (int)m_Float; } |
| 150 return new CPDF_Number(str); | 150 |
| 151 } | 151 FX_FLOAT GetNumber() const { |
| 152 | 152 return m_bInteger ? (FX_FLOAT)m_Integer : m_Float; |
| 153 static CPDF_Number* Create(FX_BOOL bInteger, void* pData) | 153 } |
| 154 { | 154 |
| 155 return new CPDF_Number(bInteger, pData); | 155 void SetNumber(FX_FLOAT value); |
| 156 } | 156 |
| 157 | 157 FX_FLOAT GetNumber16() const { return GetNumber(); } |
| 158 CPDF_Number() : CPDF_Object(PDFOBJ_NUMBER), m_bInteger(false), m_Integer(0)
{ } | 158 |
| 159 | 159 FX_FLOAT GetFloat() const { |
| 160 CPDF_Number(FX_BOOL bInteger, void* pData); | 160 return m_bInteger ? (FX_FLOAT)m_Integer : m_Float; |
| 161 | 161 } |
| 162 CPDF_Number(int value); | 162 |
| 163 | 163 protected: |
| 164 CPDF_Number(FX_FLOAT value); | 164 FX_BOOL m_bInteger; |
| 165 | 165 |
| 166 CPDF_Number(const CFX_ByteStringC& str); | 166 union { |
| 167 | 167 int m_Integer; |
| 168 FX_BOOL Identical(CPDF_Number* pOther) c
onst; | 168 |
| 169 | 169 FX_FLOAT m_Float; |
| 170 CFX_ByteString GetString() const; | 170 }; |
| 171 | 171 friend class CPDF_Object; |
| 172 void SetString(const CFX_ByteStringC&
str); | 172 }; |
| 173 | 173 class CPDF_String : public CPDF_Object { |
| 174 FX_BOOL IsInteger() const | 174 public: |
| 175 { | 175 static CPDF_String* Create(const CFX_ByteString& str, FX_BOOL bHex = FALSE) { |
| 176 return m_bInteger; | 176 return new CPDF_String(str, bHex); |
| 177 } | 177 } |
| 178 | 178 |
| 179 int GetInteger() const | 179 static CPDF_String* Create(const CFX_WideString& str) { |
| 180 { | 180 return new CPDF_String(str); |
| 181 return m_bInteger ? m_Integer : (int)m_Float; | 181 } |
| 182 } | 182 |
| 183 | 183 CPDF_String() : CPDF_Object(PDFOBJ_STRING), m_bHex(FALSE) {} |
| 184 FX_FLOAT GetNumber() const | 184 |
| 185 { | 185 CPDF_String(const CFX_ByteString& str, FX_BOOL bHex = FALSE) |
| 186 return m_bInteger ? (FX_FLOAT)m_Integer : m_Float; | 186 : CPDF_Object(PDFOBJ_STRING), m_String(str), m_bHex(bHex) {} |
| 187 } | 187 |
| 188 | 188 CPDF_String(const CFX_WideString& str); |
| 189 void SetNumber(FX_FLOAT value); | 189 |
| 190 | 190 CFX_ByteString& GetString() { return m_String; } |
| 191 FX_FLOAT GetNumber16() const | 191 |
| 192 { | 192 FX_BOOL Identical(CPDF_String* pOther) const { |
| 193 return GetNumber(); | 193 return m_String == pOther->m_String; |
| 194 } | 194 } |
| 195 | 195 |
| 196 FX_FLOAT GetFloat() const | 196 FX_BOOL IsHex() const { return m_bHex; } |
| 197 { | 197 |
| 198 return m_bInteger ? (FX_FLOAT)m_Integer : m_Float; | 198 protected: |
| 199 } | 199 CFX_ByteString m_String; |
| 200 protected: | 200 |
| 201 | 201 FX_BOOL m_bHex; |
| 202 FX_BOOL m_bInteger; | 202 friend class CPDF_Object; |
| 203 | 203 }; |
| 204 union { | 204 class CPDF_Name : public CPDF_Object { |
| 205 | 205 public: |
| 206 int m_Integer; | 206 static CPDF_Name* Create(const CFX_ByteString& str) { |
| 207 | 207 return new CPDF_Name(str); |
| 208 FX_FLOAT m_Float; | 208 } |
| 209 }; | 209 |
| 210 friend class CPDF_Object; | 210 static CPDF_Name* Create(const CFX_ByteStringC& str) { |
| 211 }; | 211 return new CPDF_Name(str); |
| 212 class CPDF_String : public CPDF_Object | 212 } |
| 213 { | 213 |
| 214 public: | 214 static CPDF_Name* Create(const FX_CHAR* str) { return new CPDF_Name(str); } |
| 215 | 215 |
| 216 static CPDF_String* Create(const CFX_ByteString& str, FX_BOOL bHex =
FALSE) | 216 CPDF_Name(const CFX_ByteString& str) |
| 217 { | 217 : CPDF_Object(PDFOBJ_NAME), m_Name(str) {} |
| 218 return new CPDF_String(str, bHex); | 218 CPDF_Name(const CFX_ByteStringC& str) |
| 219 } | 219 : CPDF_Object(PDFOBJ_NAME), m_Name(str) {} |
| 220 | 220 CPDF_Name(const FX_CHAR* str) : CPDF_Object(PDFOBJ_NAME), m_Name(str) {} |
| 221 static CPDF_String* Create(const CFX_WideString& str) | 221 |
| 222 { | 222 CFX_ByteString& GetString() { return m_Name; } |
| 223 return new CPDF_String(str); | 223 |
| 224 } | 224 FX_BOOL Identical(CPDF_Name* pOther) const { |
| 225 | 225 return m_Name == pOther->m_Name; |
| 226 CPDF_String() : CPDF_Object(PDFOBJ_STRING), m_bHex(FALSE) { } | 226 } |
| 227 | 227 |
| 228 CPDF_String(const CFX_ByteString& str, FX_BOOL bHex = FALSE) | 228 protected: |
| 229 : CPDF_Object(PDFOBJ_STRING), m_String(str), m_bHex(bHex) { | 229 CFX_ByteString m_Name; |
| 230 } | 230 friend class CPDF_Object; |
| 231 | 231 }; |
| 232 CPDF_String(const CFX_WideString& str); | 232 class CPDF_Array : public CPDF_Object { |
| 233 | 233 public: |
| 234 CFX_ByteString& GetString() | 234 static CPDF_Array* Create() { return new CPDF_Array(); } |
| 235 { | 235 |
| 236 return m_String; | 236 CPDF_Array() : CPDF_Object(PDFOBJ_ARRAY) {} |
| 237 } | 237 |
| 238 | 238 FX_DWORD GetCount() const { return m_Objects.GetSize(); } |
| 239 FX_BOOL Identical(CPDF_String* pOther) c
onst | 239 |
| 240 { | 240 CPDF_Object* GetElement(FX_DWORD index) const; |
| 241 return m_String == pOther->m_String; | 241 |
| 242 } | 242 CPDF_Object* GetElementValue(FX_DWORD index) const; |
| 243 | 243 |
| 244 FX_BOOL IsHex() const | 244 CFX_AffineMatrix GetMatrix(); |
| 245 { | 245 |
| 246 return m_bHex; | 246 CFX_FloatRect GetRect(); |
| 247 } | 247 |
| 248 protected: | 248 CFX_ByteString GetString(FX_DWORD index) const; |
| 249 | 249 |
| 250 CFX_ByteString m_String; | 250 CFX_ByteStringC GetConstString(FX_DWORD index) const; |
| 251 | 251 |
| 252 FX_BOOL m_bHex; | 252 int GetInteger(FX_DWORD index) const; |
| 253 friend class CPDF_Object; | 253 |
| 254 }; | 254 FX_FLOAT GetNumber(FX_DWORD index) const; |
| 255 class CPDF_Name : public CPDF_Object | 255 |
| 256 { | 256 CPDF_Dictionary* GetDict(FX_DWORD index) const; |
| 257 public: | 257 |
| 258 | 258 CPDF_Stream* GetStream(FX_DWORD index) const; |
| 259 static CPDF_Name* Create(const CFX_ByteString& str) | 259 |
| 260 { | 260 CPDF_Array* GetArray(FX_DWORD index) const; |
| 261 return new CPDF_Name(str); | 261 |
| 262 } | 262 FX_FLOAT GetFloat(FX_DWORD index) const { return GetNumber(index); } |
| 263 | 263 |
| 264 static CPDF_Name* Create(const CFX_ByteStringC& str) | 264 void SetAt(FX_DWORD index, |
| 265 { | 265 CPDF_Object* pObj, |
| 266 return new CPDF_Name(str); | 266 CPDF_IndirectObjects* pObjs = NULL); |
| 267 } | 267 |
| 268 | 268 void InsertAt(FX_DWORD index, |
| 269 static CPDF_Name* Create(const FX_CHAR* str) | 269 CPDF_Object* pObj, |
| 270 { | 270 CPDF_IndirectObjects* pObjs = NULL); |
| 271 return new CPDF_Name(str); | 271 |
| 272 } | 272 void RemoveAt(FX_DWORD index); |
| 273 | 273 |
| 274 CPDF_Name(const CFX_ByteString& str) : CPDF_Object(PDFOBJ_NAME), m_Name(str)
{ } | 274 void Add(CPDF_Object* pObj, CPDF_IndirectObjects* pObjs = NULL); |
| 275 CPDF_Name(const CFX_ByteStringC& str) : CPDF_Object(PDFOBJ_NAME), m_Name(str
) { } | 275 |
| 276 CPDF_Name(const FX_CHAR* str) : CPDF_Object(PDFOBJ_NAME), m_Name(str) { } | 276 void AddNumber(FX_FLOAT f); |
| 277 | 277 |
| 278 CFX_ByteString& GetString() | 278 void AddInteger(int i); |
| 279 { | 279 |
| 280 return m_Name; | 280 void AddString(const CFX_ByteString& str); |
| 281 } | 281 |
| 282 | 282 void AddName(const CFX_ByteString& str); |
| 283 FX_BOOL Identical(CPDF_Name* pOther) con
st | 283 |
| 284 { | 284 void AddReference(CPDF_IndirectObjects* pDoc, FX_DWORD objnum); |
| 285 return m_Name == pOther->m_Name; | 285 |
| 286 } | 286 void AddReference(CPDF_IndirectObjects* pDoc, CPDF_Object* obj) { |
| 287 protected: | 287 AddReference(pDoc, obj->GetObjNum()); |
| 288 | 288 } |
| 289 CFX_ByteString m_Name; | 289 |
| 290 friend class CPDF_Object; | 290 FX_FLOAT GetNumber16(FX_DWORD index) const { return GetNumber(index); } |
| 291 }; | 291 |
| 292 class CPDF_Array : public CPDF_Object | 292 void AddNumber16(FX_FLOAT value) { AddNumber(value); } |
| 293 { | 293 |
| 294 public: | 294 FX_BOOL Identical(CPDF_Array* pOther) const; |
| 295 | 295 |
| 296 static CPDF_Array* Create() | 296 protected: |
| 297 { | 297 ~CPDF_Array(); |
| 298 return new CPDF_Array(); | 298 |
| 299 } | 299 CFX_PtrArray m_Objects; |
| 300 | 300 friend class CPDF_Object; |
| 301 CPDF_Array() : CPDF_Object(PDFOBJ_ARRAY) { } | 301 }; |
| 302 | 302 class CPDF_Dictionary : public CPDF_Object { |
| 303 FX_DWORD GetCount() const | 303 public: |
| 304 { | 304 static CPDF_Dictionary* Create() { return new CPDF_Dictionary(); } |
| 305 return m_Objects.GetSize(); | 305 |
| 306 } | 306 CPDF_Dictionary() : CPDF_Object(PDFOBJ_DICTIONARY) {} |
| 307 | 307 |
| 308 CPDF_Object* GetElement(FX_DWORD index) const; | 308 CPDF_Object* GetElement(const CFX_ByteStringC& key) const; |
| 309 | 309 |
| 310 CPDF_Object* GetElementValue(FX_DWORD index) const; | 310 CPDF_Object* GetElementValue(const CFX_ByteStringC& key) const; |
| 311 | 311 |
| 312 | 312 CFX_ByteString GetString(const CFX_ByteStringC& key) const; |
| 313 | 313 |
| 314 CFX_AffineMatrix GetMatrix(); | 314 CFX_ByteStringC GetConstString(const CFX_ByteStringC& key) const; |
| 315 | 315 |
| 316 CFX_FloatRect GetRect(); | 316 CFX_ByteString GetString(const CFX_ByteStringC& key, |
| 317 | 317 const CFX_ByteStringC& default_str) const; |
| 318 | 318 |
| 319 | 319 CFX_ByteStringC GetConstString(const CFX_ByteStringC& key, |
| 320 | 320 const CFX_ByteStringC& default_str) const; |
| 321 CFX_ByteString GetString(FX_DWORD index) const; | 321 |
| 322 | 322 CFX_WideString GetUnicodeText(const CFX_ByteStringC& key, |
| 323 CFX_ByteStringC GetConstString(FX_DWORD index) const; | 323 CFX_CharMap* pCharMap = NULL) const; |
| 324 | 324 |
| 325 int GetInteger(FX_DWORD index) const
; | 325 int GetInteger(const CFX_ByteStringC& key) const; |
| 326 | 326 |
| 327 FX_FLOAT GetNumber(FX_DWORD index) const; | 327 int GetInteger(const CFX_ByteStringC& key, int default_int) const; |
| 328 | 328 |
| 329 CPDF_Dictionary* GetDict(FX_DWORD index) const; | 329 FX_BOOL GetBoolean(const CFX_ByteStringC& key, |
| 330 | 330 FX_BOOL bDefault = FALSE) const; |
| 331 CPDF_Stream* GetStream(FX_DWORD index) const; | 331 |
| 332 | 332 FX_FLOAT GetNumber(const CFX_ByteStringC& key) const; |
| 333 CPDF_Array* GetArray(FX_DWORD index) const; | 333 |
| 334 | 334 CPDF_Dictionary* GetDict(const CFX_ByteStringC& key) const; |
| 335 FX_FLOAT GetFloat(FX_DWORD index) const | 335 |
| 336 { | 336 CPDF_Stream* GetStream(const CFX_ByteStringC& key) const; |
| 337 return GetNumber(index); | 337 |
| 338 } | 338 CPDF_Array* GetArray(const CFX_ByteStringC& key) const; |
| 339 | 339 |
| 340 | 340 CFX_FloatRect GetRect(const CFX_ByteStringC& key) const; |
| 341 | 341 |
| 342 | 342 CFX_AffineMatrix GetMatrix(const CFX_ByteStringC& key) const; |
| 343 void SetAt(FX_DWORD index, CPDF_Objec
t* pObj, CPDF_IndirectObjects* pObjs = NULL); | 343 |
| 344 | 344 FX_FLOAT GetFloat(const CFX_ByteStringC& key) const { return GetNumber(key); } |
| 345 | 345 |
| 346 void InsertAt(FX_DWORD index, CPDF_Ob
ject* pObj, CPDF_IndirectObjects* pObjs = NULL); | 346 FX_BOOL KeyExist(const CFX_ByteStringC& key) const; |
| 347 | 347 |
| 348 void RemoveAt(FX_DWORD index); | 348 FX_POSITION GetStartPos() const; |
| 349 | 349 |
| 350 | 350 CPDF_Object* GetNextElement(FX_POSITION& pos, CFX_ByteString& key) const; |
| 351 void Add(CPDF_Object* pObj, CPDF_Indi
rectObjects* pObjs = NULL); | 351 |
| 352 | 352 void SetAt(const CFX_ByteStringC& key, |
| 353 | 353 CPDF_Object* pObj, |
| 354 | 354 CPDF_IndirectObjects* pObjs = NULL); |
| 355 void AddNumber(FX_FLOAT f); | 355 |
| 356 | 356 void SetAtName(const CFX_ByteStringC& key, const CFX_ByteString& name); |
| 357 void AddInteger(int i); | 357 |
| 358 | 358 void SetAtString(const CFX_ByteStringC& key, const CFX_ByteString& string); |
| 359 void AddString(const CFX_ByteString&
str); | 359 |
| 360 | 360 void SetAtInteger(const CFX_ByteStringC& key, int i); |
| 361 void AddName(const CFX_ByteString& st
r); | 361 |
| 362 | 362 void SetAtNumber(const CFX_ByteStringC& key, FX_FLOAT f); |
| 363 void AddReference(CPDF_IndirectObject
s* pDoc, FX_DWORD objnum); | 363 |
| 364 | 364 void SetAtReference(const CFX_ByteStringC& key, |
| 365 void AddReference(CPDF_IndirectObject
s* pDoc, CPDF_Object* obj) | 365 CPDF_IndirectObjects* pDoc, |
| 366 { | 366 FX_DWORD objnum); |
| 367 AddReference(pDoc, obj->GetObjNum()); | 367 |
| 368 } | 368 void SetAtReference(const CFX_ByteStringC& key, |
| 369 | 369 CPDF_IndirectObjects* pDoc, |
| 370 | 370 CPDF_Object* obj) { |
| 371 FX_FLOAT GetNumber16(FX_DWORD index) const | 371 SetAtReference(key, pDoc, obj->GetObjNum()); |
| 372 { | 372 } |
| 373 return GetNumber(index); | 373 |
| 374 } | 374 void AddReference(const CFX_ByteStringC& key, |
| 375 | 375 CPDF_IndirectObjects* pDoc, |
| 376 void AddNumber16(FX_FLOAT value) | 376 FX_DWORD objnum); |
| 377 { | 377 |
| 378 AddNumber(value); | 378 void AddReference(const CFX_ByteStringC& key, |
| 379 } | 379 CPDF_IndirectObjects* pDoc, |
| 380 | 380 CPDF_Object* obj) { |
| 381 FX_BOOL Identical(CPDF_Array* pOther) co
nst; | 381 AddReference(key, pDoc, obj->GetObjNum()); |
| 382 protected: | 382 } |
| 383 | 383 |
| 384 ~CPDF_Array(); | 384 void SetAtRect(const CFX_ByteStringC& key, const CFX_FloatRect& rect); |
| 385 | 385 |
| 386 CFX_PtrArray m_Objects; | 386 void SetAtMatrix(const CFX_ByteStringC& key, const CFX_AffineMatrix& matrix); |
| 387 friend class CPDF_Object; | 387 |
| 388 }; | 388 void SetAtBoolean(const CFX_ByteStringC& key, FX_BOOL bValue); |
| 389 class CPDF_Dictionary : public CPDF_Object | 389 |
| 390 { | 390 void RemoveAt(const CFX_ByteStringC& key); |
| 391 public: | 391 |
| 392 | 392 void ReplaceKey(const CFX_ByteStringC& oldkey, const CFX_ByteStringC& newkey); |
| 393 static CPDF_Dictionary* Create() | 393 |
| 394 { | 394 FX_BOOL Identical(CPDF_Dictionary* pDict) const; |
| 395 return new CPDF_Dictionary(); | 395 |
| 396 } | 396 int GetCount() const { return m_Map.GetCount(); } |
| 397 | 397 |
| 398 CPDF_Dictionary() : CPDF_Object(PDFOBJ_DICTIONARY) { } | 398 void AddValue(const CFX_ByteStringC& key, CPDF_Object* pObj); |
| 399 | 399 |
| 400 CPDF_Object* GetElement(const CFX_ByteStringC& key) c
onst; | 400 protected: |
| 401 | 401 ~CPDF_Dictionary(); |
| 402 CPDF_Object* GetElementValue(const CFX_ByteStringC& k
ey) const; | 402 |
| 403 | 403 CFX_CMapByteStringToPtr m_Map; |
| 404 | 404 |
| 405 | 405 friend class CPDF_Object; |
| 406 | 406 }; |
| 407 | 407 class CPDF_Stream : public CPDF_Object { |
| 408 CFX_ByteString GetString(const CFX_ByteStringC& key) co
nst; | 408 public: |
| 409 | 409 static CPDF_Stream* Create(uint8_t* pData, |
| 410 CFX_ByteStringC GetConstString(const CFX_ByteStringC& ke
y) const; | 410 FX_DWORD size, |
| 411 | 411 CPDF_Dictionary* pDict) { |
| 412 CFX_ByteString GetString(const CFX_ByteStringC& key, co
nst CFX_ByteStringC& default_str) const; | 412 return new CPDF_Stream(pData, size, pDict); |
| 413 | 413 } |
| 414 CFX_ByteStringC GetConstString(const CFX_ByteStringC& ke
y, const CFX_ByteStringC& default_str) const; | 414 |
| 415 | 415 CPDF_Stream(uint8_t* pData, FX_DWORD size, CPDF_Dictionary* pDict); |
| 416 CFX_WideString GetUnicodeText(const CFX_ByteStringC& ke
y, CFX_CharMap* pCharMap = NULL) const; | 416 |
| 417 | 417 CPDF_Dictionary* GetDict() const { return m_pDict; } |
| 418 int GetInteger(const CFX_ByteStringC
& key) const; | 418 |
| 419 | 419 void SetData(const uint8_t* pData, |
| 420 int GetInteger(const CFX_ByteStringC
& key, int default_int) const; | 420 FX_DWORD size, |
| 421 | 421 FX_BOOL bCompressed, |
| 422 FX_BOOL GetBoolean(const CFX_ByteStringC
& key, FX_BOOL bDefault = FALSE) const; | 422 FX_BOOL bKeepBuf); |
| 423 | 423 |
| 424 FX_FLOAT GetNumber(const CFX_ByteStringC& key) co
nst; | 424 void InitStream(uint8_t* pData, FX_DWORD size, CPDF_Dictionary* pDict); |
| 425 | 425 |
| 426 CPDF_Dictionary* GetDict(const CFX_ByteStringC& key) const; | 426 void InitStream(IFX_FileRead* pFile, CPDF_Dictionary* pDict); |
| 427 | 427 |
| 428 CPDF_Stream* GetStream(const CFX_ByteStringC& key) co
nst; | 428 FX_BOOL Identical(CPDF_Stream* pOther) const; |
| 429 | 429 |
| 430 CPDF_Array* GetArray(const CFX_ByteStringC& key) con
st; | 430 CPDF_StreamFilter* GetStreamFilter(FX_BOOL bRaw = FALSE) const; |
| 431 | 431 |
| 432 CFX_FloatRect GetRect(const CFX_ByteStringC& key) cons
t; | 432 FX_DWORD GetRawSize() const { return m_dwSize; } |
| 433 | 433 |
| 434 CFX_AffineMatrix GetMatrix(const CFX_ByteStringC& key) const; | 434 FX_BOOL ReadRawData(FX_FILESIZE start_pos, |
| 435 | 435 uint8_t* pBuf, |
| 436 FX_FLOAT GetFloat(const CFX_ByteStringC& key) con
st | 436 FX_DWORD buf_size) const; |
| 437 { | 437 |
| 438 return GetNumber(key); | 438 FX_BOOL IsMemoryBased() const { return m_GenNum == (FX_DWORD)-1; } |
| 439 } | 439 |
| 440 | 440 CPDF_Stream* Clone(FX_BOOL bDirect, |
| 441 | 441 FPDF_LPFCloneStreamCallback lpfCallback, |
| 442 FX_BOOL KeyExist(const CFX_ByteStringC&
key) const; | 442 void* pUserData) const; |
| 443 | 443 |
| 444 FX_POSITION GetStartPos() const; | 444 protected: |
| 445 | 445 ~CPDF_Stream(); |
| 446 CPDF_Object* GetNextElement(FX_POSITION& pos, CFX_Byt
eString& key) const; | 446 |
| 447 | 447 CPDF_Dictionary* m_pDict; |
| 448 void SetAt(const CFX_ByteStringC& key
, CPDF_Object* pObj, CPDF_IndirectObjects* pObjs = NULL); | 448 |
| 449 | 449 FX_DWORD m_dwSize; |
| 450 | 450 |
| 451 | 451 FX_DWORD m_GenNum; |
| 452 void SetAtName(const CFX_ByteStringC&
key, const CFX_ByteString& name); | 452 |
| 453 | 453 union { |
| 454 | 454 uint8_t* m_pDataBuf; |
| 455 void SetAtString(const CFX_ByteString
C& key, const CFX_ByteString& string); | 455 |
| 456 | 456 IFX_FileRead* m_pFile; |
| 457 | 457 }; |
| 458 void SetAtInteger(const CFX_ByteStrin
gC& key, int i); | 458 |
| 459 | 459 FX_FILESIZE m_FileOffset; |
| 460 | 460 |
| 461 void SetAtNumber(const CFX_ByteString
C& key, FX_FLOAT f); | 461 CPDF_CryptoHandler* m_pCryptoHandler; |
| 462 | 462 |
| 463 void SetAtReference(const CFX_ByteStr
ingC& key, CPDF_IndirectObjects* pDoc, FX_DWORD objnum); | 463 void InitStream(CPDF_Dictionary* pDict); |
| 464 | 464 friend class CPDF_Object; |
| 465 void SetAtReference(const CFX_ByteStr
ingC& key, CPDF_IndirectObjects* pDoc, CPDF_Object* obj) | 465 friend class CPDF_StreamAcc; |
| 466 { | 466 friend class CPDF_AttachmentAcc; |
| 467 SetAtReference(key, pDoc, obj->GetObjNum()); | 467 }; |
| 468 } | 468 class CPDF_StreamAcc { |
| 469 | 469 public: |
| 470 void AddReference(const CFX_ByteStrin
gC& key, CPDF_IndirectObjects* pDoc, FX_DWORD objnum); | 470 CPDF_StreamAcc(); |
| 471 | 471 |
| 472 void AddReference(const CFX_ByteStrin
gC& key, CPDF_IndirectObjects* pDoc, CPDF_Object* obj) | 472 ~CPDF_StreamAcc(); |
| 473 { | 473 |
| 474 AddReference(key, pDoc, obj->GetObjNum()); | 474 void LoadAllData(const CPDF_Stream* pStream, |
| 475 } | 475 FX_BOOL bRawAccess = FALSE, |
| 476 | 476 FX_DWORD estimated_size = 0, |
| 477 void SetAtRect(const CFX_ByteStringC&
key, const CFX_FloatRect& rect); | 477 FX_BOOL bImageAcc = FALSE); |
| 478 | 478 |
| 479 void SetAtMatrix(const CFX_ByteString
C& key, const CFX_AffineMatrix& matrix); | 479 const CPDF_Stream* GetStream() const { return m_pStream; } |
| 480 | 480 |
| 481 void SetAtBoolean(const CFX_ByteStrin
gC& key, FX_BOOL bValue); | 481 CPDF_Dictionary* GetDict() const { |
| 482 | 482 return m_pStream ? m_pStream->GetDict() : NULL; |
| 483 | 483 } |
| 484 | 484 |
| 485 void RemoveAt(const CFX_ByteStringC&
key); | 485 const uint8_t* GetData() const; |
| 486 | 486 |
| 487 | 487 FX_DWORD GetSize() const; |
| 488 void ReplaceKey(const CFX_ByteStringC
& oldkey, const CFX_ByteStringC& newkey); | 488 |
| 489 | 489 uint8_t* DetachData(); |
| 490 FX_BOOL Identical(CPDF_Dictionary* pDict
) const; | 490 |
| 491 | 491 const CFX_ByteString& GetImageDecoder() { return m_ImageDecoder; } |
| 492 int GetCount() const | 492 |
| 493 { | 493 const CPDF_Dictionary* GetImageParam() { return m_pImageParam; } |
| 494 return m_Map.GetCount(); | 494 |
| 495 } | 495 protected: |
| 496 | 496 uint8_t* m_pData; |
| 497 void AddValue(const CFX_ByteStringC&
key, CPDF_Object* pObj); | 497 |
| 498 protected: | 498 FX_DWORD m_dwSize; |
| 499 | 499 |
| 500 ~CPDF_Dictionary(); | 500 FX_BOOL m_bNewBuf; |
| 501 | 501 |
| 502 CFX_CMapByteStringToPtr m_Map; | 502 CFX_ByteString m_ImageDecoder; |
| 503 | 503 |
| 504 friend class CPDF_Object; | 504 CPDF_Dictionary* m_pImageParam; |
| 505 }; | 505 |
| 506 class CPDF_Stream : public CPDF_Object | 506 const CPDF_Stream* m_pStream; |
| 507 { | 507 |
| 508 public: | 508 uint8_t* m_pSrcData; |
| 509 | 509 }; |
| 510 static CPDF_Stream* Create(uint8_t* pData, FX_DWORD size, CPDF_Dicti
onary* pDict) | 510 CFX_DataFilter* FPDF_CreateFilter(const CFX_ByteStringC& name, |
| 511 { | 511 const CPDF_Dictionary* pParam, |
| 512 return new CPDF_Stream(pData, size, pDict); | 512 int width = 0, |
| 513 } | 513 int height = 0); |
| 514 | 514 #define FPDF_FILTER_BUFFER_SIZE 20480 |
| 515 CPDF_Stream(uint8_t* pData, FX_DWORD size, CPDF_Dictionary* pDict); | 515 class CPDF_StreamFilter { |
| 516 | 516 public: |
| 517 CPDF_Dictionary* GetDict() const | 517 ~CPDF_StreamFilter(); |
| 518 { | 518 |
| 519 return m_pDict; | 519 FX_DWORD ReadBlock(uint8_t* buffer, FX_DWORD size); |
| 520 } | 520 |
| 521 | 521 FX_DWORD GetSrcPos() { return m_SrcOffset; } |
| 522 void SetData(const uint8_t* pData, FX
_DWORD size, FX_BOOL bCompressed, FX_BOOL bKeepBuf); | 522 |
| 523 | 523 const CPDF_Stream* GetStream() { return m_pStream; } |
| 524 void InitStream(uint8_t* pData, FX_DW
ORD size, CPDF_Dictionary* pDict); | 524 |
| 525 | 525 protected: |
| 526 void InitStream(IFX_FileRead *pFile,
CPDF_Dictionary* pDict); | 526 CPDF_StreamFilter() {} |
| 527 | 527 |
| 528 FX_BOOL Identical(CPDF_Stream* pOther) c
onst; | 528 FX_DWORD ReadLeftOver(uint8_t* buffer, FX_DWORD buf_size); |
| 529 | 529 |
| 530 CPDF_StreamFilter* GetStreamFilter(FX_BOOL bRaw = FALSE) const; | 530 const CPDF_Stream* m_pStream; |
| 531 | 531 |
| 532 | 532 CFX_DataFilter* m_pFilter; |
| 533 | 533 |
| 534 FX_DWORD GetRawSize() const | 534 CFX_BinaryBuf* m_pBuffer; |
| 535 { | 535 |
| 536 return m_dwSize; | 536 FX_DWORD m_BufOffset; |
| 537 } | 537 |
| 538 | 538 FX_DWORD m_SrcOffset; |
| 539 FX_BOOL ReadRawData(FX_FILESIZE start_po
s, uint8_t* pBuf, FX_DWORD buf_size) const; | 539 |
| 540 | 540 uint8_t m_SrcBuffer[FPDF_FILTER_BUFFER_SIZE]; |
| 541 | 541 friend class CPDF_Stream; |
| 542 FX_BOOL IsMemoryBased() const | 542 }; |
| 543 { | 543 class CPDF_Null : public CPDF_Object { |
| 544 return m_GenNum == (FX_DWORD) - 1; | 544 public: |
| 545 } | 545 static CPDF_Null* Create() { return new CPDF_Null(); } |
| 546 | 546 |
| 547 CPDF_Stream* Clone(FX_BOOL bDirect, FPDF_LPFCloneStre
amCallback lpfCallback, void* pUserData) const; | 547 CPDF_Null() : CPDF_Object(PDFOBJ_NULL) {} |
| 548 protected: | 548 }; |
| 549 | 549 class CPDF_Reference : public CPDF_Object { |
| 550 ~CPDF_Stream(); | 550 public: |
| 551 | 551 CPDF_Reference(CPDF_IndirectObjects* pDoc, int objnum) |
| 552 CPDF_Dictionary* m_pDict; | 552 : CPDF_Object(PDFOBJ_REFERENCE), m_pObjList(pDoc), m_RefObjNum(objnum) {} |
| 553 | 553 |
| 554 FX_DWORD m_dwSize; | 554 CPDF_IndirectObjects* GetObjList() const { return m_pObjList; } |
| 555 | 555 |
| 556 FX_DWORD m_GenNum; | 556 FX_DWORD GetRefObjNum() const { return m_RefObjNum; } |
| 557 | 557 |
| 558 union { | 558 void SetRef(CPDF_IndirectObjects* pDoc, FX_DWORD objnum); |
| 559 | 559 |
| 560 uint8_t* m_pDataBuf; | 560 FX_BOOL Identical(CPDF_Reference* pOther) const { |
| 561 | 561 return m_RefObjNum == pOther->m_RefObjNum; |
| 562 IFX_FileRead* m_pFile; | 562 } |
| 563 }; | 563 |
| 564 | 564 protected: |
| 565 FX_FILESIZE m_FileOffset; | 565 CPDF_IndirectObjects* m_pObjList; |
| 566 | 566 |
| 567 CPDF_CryptoHandler* m_pCryptoHandler; | 567 FX_DWORD m_RefObjNum; |
| 568 | 568 friend class CPDF_Object; |
| 569 void InitStream(CPDF_Dictionary* pDic
t); | 569 }; |
| 570 friend class CPDF_Object; | 570 class CPDF_IndirectObjects { |
| 571 friend class CPDF_StreamAcc; | 571 public: |
| 572 friend class CPDF_AttachmentAcc; | 572 CPDF_IndirectObjects(CPDF_Parser* pParser); |
| 573 }; | 573 |
| 574 class CPDF_StreamAcc | 574 ~CPDF_IndirectObjects(); |
| 575 { | 575 |
| 576 public: | 576 CPDF_Object* GetIndirectObject(FX_DWORD objnum, |
| 577 | 577 struct PARSE_CONTEXT* pContext = NULL); |
| 578 CPDF_StreamAcc(); | 578 |
| 579 | 579 int GetIndirectType(FX_DWORD objnum); |
| 580 ~CPDF_StreamAcc(); | 580 |
| 581 | 581 FX_DWORD AddIndirectObject(CPDF_Object* pObj); |
| 582 void LoadAllData(const CPDF_Stream* p
Stream, FX_BOOL bRawAccess = FALSE, | 582 |
| 583 FX_DWORD estimated_size = 0, FX_BOOL bIm
ageAcc = FALSE); | 583 void ReleaseIndirectObject(FX_DWORD objnum); |
| 584 | 584 |
| 585 const CPDF_Stream* GetStream() const | 585 void InsertIndirectObject(FX_DWORD objnum, CPDF_Object* pObj); |
| 586 { | 586 |
| 587 return m_pStream; | 587 FX_DWORD GetLastObjNum() const; |
| 588 } | 588 |
| 589 | 589 FX_POSITION GetStartPosition() const { |
| 590 CPDF_Dictionary* GetDict() const | 590 return m_IndirectObjs.GetStartPosition(); |
| 591 { | 591 } |
| 592 return m_pStream? m_pStream->GetDict() : NULL; | 592 |
| 593 } | 593 void GetNextAssoc(FX_POSITION& rPos, |
| 594 | 594 FX_DWORD& objnum, |
| 595 const uint8_t* GetData() const; | 595 CPDF_Object*& pObject) const { |
| 596 | 596 m_IndirectObjs.GetNextAssoc(rPos, (void*&)objnum, (void*&)pObject); |
| 597 FX_DWORD GetSize() const; | 597 } |
| 598 | 598 |
| 599 uint8_t* DetachData(); | 599 protected: |
| 600 | 600 CFX_MapPtrToPtr m_IndirectObjs; |
| 601 const CFX_ByteString& GetImageDecoder() | 601 |
| 602 { | 602 CPDF_Parser* m_pParser; |
| 603 return m_ImageDecoder; | 603 |
| 604 } | 604 FX_DWORD m_LastObjNum; |
| 605 | |
| 606 const CPDF_Dictionary* GetImageParam() | |
| 607 { | |
| 608 return m_pImageParam; | |
| 609 } | |
| 610 protected: | |
| 611 | |
| 612 uint8_t* m_pData; | |
| 613 | |
| 614 FX_DWORD m_dwSize; | |
| 615 | |
| 616 FX_BOOL m_bNewBuf; | |
| 617 | |
| 618 CFX_ByteString m_ImageDecoder; | |
| 619 | |
| 620 CPDF_Dictionary* m_pImageParam; | |
| 621 | |
| 622 const CPDF_Stream* m_pStream; | |
| 623 | |
| 624 uint8_t* m_pSrcData; | |
| 625 }; | |
| 626 CFX_DataFilter* FPDF_CreateFilter(const CFX_ByteStringC& name, const CPDF_Dictio
nary* pParam, int width = 0, int height = 0); | |
| 627 #define FPDF_FILTER_BUFFER_SIZE 20480 | |
| 628 class CPDF_StreamFilter | |
| 629 { | |
| 630 public: | |
| 631 | |
| 632 ~CPDF_StreamFilter(); | |
| 633 | |
| 634 FX_DWORD ReadBlock(uint8_t* buffer, FX_DWORD size); | |
| 635 | |
| 636 FX_DWORD GetSrcPos() | |
| 637 { | |
| 638 return m_SrcOffset; | |
| 639 } | |
| 640 | |
| 641 const CPDF_Stream* GetStream() | |
| 642 { | |
| 643 return m_pStream; | |
| 644 } | |
| 645 protected: | |
| 646 | |
| 647 CPDF_StreamFilter() {} | |
| 648 | |
| 649 FX_DWORD ReadLeftOver(uint8_t* buffer, FX_DWORD buf_size)
; | |
| 650 | |
| 651 const CPDF_Stream* m_pStream; | |
| 652 | |
| 653 CFX_DataFilter* m_pFilter; | |
| 654 | |
| 655 CFX_BinaryBuf* m_pBuffer; | |
| 656 | |
| 657 FX_DWORD m_BufOffset; | |
| 658 | |
| 659 FX_DWORD m_SrcOffset; | |
| 660 | |
| 661 uint8_t m_SrcBuffer[FPDF_FILTER_BUFFER_SIZE]; | |
| 662 friend class CPDF_Stream; | |
| 663 }; | |
| 664 class CPDF_Null : public CPDF_Object | |
| 665 { | |
| 666 public: | |
| 667 | |
| 668 static CPDF_Null* Create() | |
| 669 { | |
| 670 return new CPDF_Null(); | |
| 671 } | |
| 672 | |
| 673 CPDF_Null() : CPDF_Object(PDFOBJ_NULL) { } | |
| 674 }; | |
| 675 class CPDF_Reference : public CPDF_Object | |
| 676 { | |
| 677 public: | |
| 678 CPDF_Reference(CPDF_IndirectObjects* pDoc, int objnum) | |
| 679 : CPDF_Object(PDFOBJ_REFERENCE), m_pObjList(pDoc), m_RefObjNum(objnum) { | |
| 680 } | |
| 681 | |
| 682 CPDF_IndirectObjects* GetObjList() const | |
| 683 { | |
| 684 return m_pObjList; | |
| 685 } | |
| 686 | |
| 687 FX_DWORD GetRefObjNum() const | |
| 688 { | |
| 689 return m_RefObjNum; | |
| 690 } | |
| 691 | |
| 692 void SetRef(CPDF_IndirectObjects* pDo
c, FX_DWORD objnum); | |
| 693 | |
| 694 FX_BOOL Identical(CPDF_Reference* pOther
) const | |
| 695 { | |
| 696 return m_RefObjNum == pOther->m_RefObjNum; | |
| 697 } | |
| 698 protected: | |
| 699 | |
| 700 CPDF_IndirectObjects* m_pObjList; | |
| 701 | |
| 702 FX_DWORD m_RefObjNum; | |
| 703 friend class CPDF_Object; | |
| 704 }; | |
| 705 class CPDF_IndirectObjects | |
| 706 { | |
| 707 public: | |
| 708 | |
| 709 CPDF_IndirectObjects(CPDF_Parser* pParser); | |
| 710 | |
| 711 ~CPDF_IndirectObjects(); | |
| 712 | |
| 713 CPDF_Object* GetIndirectObject(FX_DWORD objnum, struc
t PARSE_CONTEXT* pContext = NULL); | |
| 714 | |
| 715 int GetIndirectType(FX_DWORD objnum)
; | |
| 716 | |
| 717 FX_DWORD AddIndirectObject(CPDF_Object* pObj); | |
| 718 | |
| 719 void ReleaseIndirectObject(FX_DWORD o
bjnum); | |
| 720 | |
| 721 void InsertIndirectObject(FX_DWORD ob
jnum, CPDF_Object* pObj); | |
| 722 | |
| 723 FX_DWORD GetLastObjNum() const; | |
| 724 | |
| 725 FX_POSITION GetStartPosition() const | |
| 726 { | |
| 727 return m_IndirectObjs.GetStartPosition(); | |
| 728 } | |
| 729 | |
| 730 void GetNextAssoc(FX_POSITION& rPos,
FX_DWORD& objnum, CPDF_Object*& pObject) const | |
| 731 { | |
| 732 m_IndirectObjs.GetNextAssoc(rPos, (void*&)objnum, (void*&)pObject); | |
| 733 } | |
| 734 protected: | |
| 735 | |
| 736 CFX_MapPtrToPtr m_IndirectObjs; | |
| 737 | |
| 738 CPDF_Parser* m_pParser; | |
| 739 | |
| 740 FX_DWORD m_LastObjNum; | |
| 741 }; | 605 }; |
| 742 | 606 |
| 743 #endif // CORE_INCLUDE_FPDFAPI_FPDF_OBJECTS_H_ | 607 #endif // CORE_INCLUDE_FPDFAPI_FPDF_OBJECTS_H_ |
| OLD | NEW |