| 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_PARSER_H_ | 7 #ifndef CORE_INCLUDE_FPDFAPI_FPDF_PARSER_H_ |
| 8 #define CORE_INCLUDE_FPDFAPI_FPDF_PARSER_H_ | 8 #define CORE_INCLUDE_FPDFAPI_FPDF_PARSER_H_ |
| 9 | 9 |
| 10 #include "../fxcrt/fx_system.h" | 10 #include "../fxcrt/fx_system.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 id1 = m_ID1; | 79 id1 = m_ID1; |
| 80 id2 = m_ID2; | 80 id2 = m_ID2; |
| 81 } | 81 } |
| 82 | 82 |
| 83 int GetPageCount() const; | 83 int GetPageCount() const; |
| 84 | 84 |
| 85 CPDF_Dictionary* GetPage(int iPage); | 85 CPDF_Dictionary* GetPage(int iPage); |
| 86 | 86 |
| 87 int GetPageIndex(FX_DWORD objnum); | 87 int GetPageIndex(FX_DWORD objnum); |
| 88 | 88 |
| 89 FX_DWORD» » » » GetUserPermissions(FX_BOOL bCheckRevisio
n = FALSE) const; | 89 FX_DWORD» » » » GetUserPermissions(bool bCheckRevision =
false) const; |
| 90 | 90 |
| 91 FX_BOOL» » » » » IsOwner() const; | 91 bool» » » » » IsOwner() const; |
| 92 | 92 |
| 93 | 93 |
| 94 | 94 |
| 95 CPDF_DocPageData* GetPageData() | 95 CPDF_DocPageData* GetPageData() |
| 96 { | 96 { |
| 97 return GetValidatePageData(); | 97 return GetValidatePageData(); |
| 98 } | 98 } |
| 99 | 99 |
| 100 void ClearPageData(); | 100 void ClearPageData(); |
| 101 | 101 |
| 102 void RemoveColorSpaceFromPageData(CPD
F_Object* pObject); | 102 void RemoveColorSpaceFromPageData(CPD
F_Object* pObject); |
| 103 | 103 |
| 104 | 104 |
| 105 CPDF_DocRenderData* GetRenderData() | 105 CPDF_DocRenderData* GetRenderData() |
| 106 { | 106 { |
| 107 return GetValidateRenderData(); | 107 return GetValidateRenderData(); |
| 108 } | 108 } |
| 109 | 109 |
| 110 void ClearRenderData(); | 110 void ClearRenderData(); |
| 111 | 111 |
| 112 void ClearRenderFont(); | 112 void ClearRenderFont(); |
| 113 | 113 |
| 114 | 114 |
| 115 FX_BOOL» » » » » IsFormStream(FX_DWORD objnum, FX
_BOOL& bForm) const; | 115 bool» » » » » IsFormStream(FX_DWORD objnum, bo
ol& bForm) const; |
| 116 | 116 |
| 117 // |pFontDict| must not be null. | 117 // |pFontDict| must not be null. |
| 118 CPDF_Font* LoadFont(CPDF_Dictionary* pFontDict); | 118 CPDF_Font* LoadFont(CPDF_Dictionary* pFontDict); |
| 119 | 119 |
| 120 CPDF_ColorSpace* LoadColorSpace(CPDF_Object* pCSObj, CPDF_Diction
ary* pResources = NULL); | 120 CPDF_ColorSpace* LoadColorSpace(CPDF_Object* pCSObj, CPDF_Diction
ary* pResources = NULL); |
| 121 | 121 |
| 122 CPDF_Pattern*» » » LoadPattern(CPDF_Object* pObj, FX_BOOL b
Shading, const CFX_AffineMatrix* matrix = NULL); | 122 CPDF_Pattern*» » » LoadPattern(CPDF_Object* pObj, bool bSha
ding, const CFX_AffineMatrix* matrix = NULL); |
| 123 | 123 |
| 124 CPDF_Image* LoadImageF(CPDF_Object* pObj); | 124 CPDF_Image* LoadImageF(CPDF_Object* pObj); |
| 125 | 125 |
| 126 CPDF_StreamAcc* LoadFontFile(CPDF_Stream* pStream); | 126 CPDF_StreamAcc* LoadFontFile(CPDF_Stream* pStream); |
| 127 | 127 |
| 128 CPDF_IccProfile* LoadIccProfile(CPDF_Stream* pStream); | 128 CPDF_IccProfile* LoadIccProfile(CPDF_Stream* pStream); |
| 129 | 129 |
| 130 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 130 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
| 131 | 131 |
| 132 CPDF_Font*» » » » AddWindowsFont(LOGFONTA* pLogFont, FX_BO
OL bVert, FX_BOOL bTranslateName = FALSE); | 132 CPDF_Font*» » » » AddWindowsFont(LOGFONTA* pLogFont, bool
bVert, bool bTranslateName = false); |
| 133 CPDF_Font*» » » » AddWindowsFont(LOGFONTW* pLogFont, FX_BO
OL bVert, FX_BOOL bTranslateName = FALSE); | 133 CPDF_Font*» » » » AddWindowsFont(LOGFONTW* pLogFont, bool
bVert, bool bTranslateName = false); |
| 134 #endif | 134 #endif |
| 135 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 135 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
| 136 CPDF_Font* AddMacFont(CTFontRef pFont, FX_BOOL bVert, FX_BOOL b
TranslateName = FALSE); | 136 CPDF_Font* AddMacFont(CTFontRef pFont, bool bVert, bool bTransl
ateName = false); |
| 137 #endif | 137 #endif |
| 138 | 138 |
| 139 CPDF_Font* AddStandardFont(const FX_CHAR* font, CPD
F_FontEncoding* pEncoding); | 139 CPDF_Font* AddStandardFont(const FX_CHAR* font, CPD
F_FontEncoding* pEncoding); |
| 140 | 140 |
| 141 | 141 |
| 142 CPDF_Font*» » » » AddFont(CFX_Font* pFont, int charset, FX
_BOOL bVert); | 142 CPDF_Font*» » » » AddFont(CFX_Font* pFont, int charset, bo
ol bVert); |
| 143 | 143 |
| 144 void CreateNewDoc(); | 144 void CreateNewDoc(); |
| 145 | 145 |
| 146 CPDF_Dictionary* CreateNewPage(int iPage); | 146 CPDF_Dictionary* CreateNewPage(int iPage); |
| 147 | 147 |
| 148 void DeletePage(int iPage); | 148 void DeletePage(int iPage); |
| 149 | 149 |
| 150 void LoadDoc(); | 150 void LoadDoc(); |
| 151 void LoadAsynDoc(CPDF_Dictionary *pLi
nearized); | 151 void LoadAsynDoc(CPDF_Dictionary *pLi
nearized); |
| 152 void LoadPages(); | 152 void LoadPages(); |
| 153 protected: | 153 protected: |
| 154 | 154 |
| 155 CPDF_Dictionary* m_pRootDict; | 155 CPDF_Dictionary* m_pRootDict; |
| 156 | 156 |
| 157 CPDF_Dictionary* m_pInfoDict; | 157 CPDF_Dictionary* m_pInfoDict; |
| 158 | 158 |
| 159 CFX_ByteString m_ID1; | 159 CFX_ByteString m_ID1; |
| 160 | 160 |
| 161 CFX_ByteString m_ID2; | 161 CFX_ByteString m_ID2; |
| 162 | 162 |
| 163 | 163 |
| 164 FX_BOOL» » » » » m_bLinearized; | 164 bool» » » » » m_bLinearized; |
| 165 | 165 |
| 166 FX_DWORD m_dwFirstPageNo; | 166 FX_DWORD m_dwFirstPageNo; |
| 167 | 167 |
| 168 FX_DWORD m_dwFirstPageObjNum; | 168 FX_DWORD m_dwFirstPageObjNum; |
| 169 | 169 |
| 170 CFX_DWordArray m_PageList; | 170 CFX_DWordArray m_PageList; |
| 171 | 171 |
| 172 int _GetPageCount() const; | 172 int _GetPageCount() const; |
| 173 CPDF_Dictionary* _FindPDFPage(CPDF_Dictionary* pPages, int iPage,
int nPagesToGo, int level); | 173 CPDF_Dictionary* _FindPDFPage(CPDF_Dictionary* pPages, int iPage,
int nPagesToGo, int level); |
| 174 int _FindPageIndex(CPDF_Dictionary*
pNode, FX_DWORD& skip_count, FX_DWORD objnum, int& index, int level = 0); | 174 int _FindPageIndex(CPDF_Dictionary*
pNode, FX_DWORD& skip_count, FX_DWORD objnum, int& index, int level = 0); |
| 175 FX_BOOL» » » » » IsContentUsedElsewhere(FX_DWORD
objnum, CPDF_Dictionary* pPageDict); | 175 bool» » » » » IsContentUsedElsewhere(FX_DWORD
objnum, CPDF_Dictionary* pPageDict); |
| 176 FX_BOOL» » » » » CheckOCGVisible(CPDF_Dictionary*
pOCG, FX_BOOL bPrinting); | 176 bool» » » » » CheckOCGVisible(CPDF_Dictionary*
pOCG, bool bPrinting); |
| 177 CPDF_DocPageData* GetValidatePageData(); | 177 CPDF_DocPageData* GetValidatePageData(); |
| 178 CPDF_DocRenderData* GetValidateRenderData(); | 178 CPDF_DocRenderData* GetValidateRenderData(); |
| 179 friend class CPDF_Creator; | 179 friend class CPDF_Creator; |
| 180 friend class CPDF_Parser; | 180 friend class CPDF_Parser; |
| 181 friend class CPDF_DataAvail; | 181 friend class CPDF_DataAvail; |
| 182 friend class CPDF_OCContext; | 182 friend class CPDF_OCContext; |
| 183 | 183 |
| 184 | 184 |
| 185 | 185 |
| 186 CPDF_DocPageData* m_pDocPage; | 186 CPDF_DocPageData* m_pDocPage; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 197 class CPDF_SimpleParser | 197 class CPDF_SimpleParser |
| 198 { | 198 { |
| 199 public: | 199 public: |
| 200 | 200 |
| 201 CPDF_SimpleParser(const uint8_t* pData, FX_DWORD dwSize); | 201 CPDF_SimpleParser(const uint8_t* pData, FX_DWORD dwSize); |
| 202 | 202 |
| 203 CPDF_SimpleParser(const CFX_ByteStringC& str); | 203 CPDF_SimpleParser(const CFX_ByteStringC& str); |
| 204 | 204 |
| 205 CFX_ByteStringC GetWord(); | 205 CFX_ByteStringC GetWord(); |
| 206 | 206 |
| 207 FX_BOOL» » » » SearchToken(const CFX_ByteStringC& token
); | 207 bool» » » » SearchToken(const CFX_ByteStringC& token
); |
| 208 | 208 |
| 209 FX_BOOL» » » » SkipWord(const CFX_ByteStringC& token); | 209 bool» » » » SkipWord(const CFX_ByteStringC& token); |
| 210 | 210 |
| 211 FX_BOOL» » » » FindTagPair(const CFX_ByteStringC& start
_token, const CFX_ByteStringC& end_token, | 211 bool» » » » FindTagPair(const CFX_ByteStringC& start
_token, const CFX_ByteStringC& end_token, |
| 212 FX_DWORD& start_pos, FX_DWORD& end_pos); | 212 FX_DWORD& start_pos, FX_DWORD& end_pos); |
| 213 | 213 |
| 214 FX_BOOL» » » » FindTagParam(const CFX_ByteStringC& toke
n, int nParams); | 214 bool» » » » FindTagParam(const CFX_ByteStringC& toke
n, int nParams); |
| 215 | 215 |
| 216 FX_DWORD GetPos() | 216 FX_DWORD GetPos() |
| 217 { | 217 { |
| 218 return m_dwCurPos; | 218 return m_dwCurPos; |
| 219 } | 219 } |
| 220 | 220 |
| 221 void SetPos(FX_DWORD pos) | 221 void SetPos(FX_DWORD pos) |
| 222 { | 222 { |
| 223 ASSERT(pos <= m_dwSize); | 223 ASSERT(pos <= m_dwSize); |
| 224 m_dwCurPos = pos; | 224 m_dwCurPos = pos; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 245 FX_FILESIZE SavePos() | 245 FX_FILESIZE SavePos() |
| 246 { | 246 { |
| 247 return m_Pos; | 247 return m_Pos; |
| 248 } | 248 } |
| 249 | 249 |
| 250 void RestorePos(FX_FILESIZE pos) | 250 void RestorePos(FX_FILESIZE pos) |
| 251 { | 251 { |
| 252 m_Pos = pos; | 252 m_Pos = pos; |
| 253 } | 253 } |
| 254 | 254 |
| 255 CPDF_Object*» » GetObject(CPDF_IndirectObjects* pObjList, FX_DWO
RD objnum, FX_DWORD gennum, struct PARSE_CONTEXT* pContext = NULL, FX_BOOL bDecr
ypt = TRUE); | 255 CPDF_Object*» » GetObject(CPDF_IndirectObjects* pObjList, FX_DWO
RD objnum, FX_DWORD gennum, struct PARSE_CONTEXT* pContext = NULL, bool bDecrypt
= true); |
| 256 | 256 |
| 257 | 257 |
| 258 CPDF_Object* GetObjectByStrict(CPDF_IndirectObjects* pObjList
, FX_DWORD objnum, FX_DWORD gennum, struct PARSE_CONTEXT* pContext = NULL); | 258 CPDF_Object* GetObjectByStrict(CPDF_IndirectObjects* pObjList
, FX_DWORD objnum, FX_DWORD gennum, struct PARSE_CONTEXT* pContext = NULL); |
| 259 | 259 |
| 260 int GetDirectNum(); | 260 int GetDirectNum(); |
| 261 | 261 |
| 262 CFX_ByteString GetString(FX_DWORD objnum, FX_DWORD gennum); | 262 CFX_ByteString GetString(FX_DWORD objnum, FX_DWORD gennum); |
| 263 | 263 |
| 264 CFX_ByteString GetName(); | 264 CFX_ByteString GetName(); |
| 265 | 265 |
| 266 CFX_ByteString GetKeyword(); | 266 CFX_ByteString GetKeyword(); |
| 267 | 267 |
| 268 void GetBinary(uint8_t* buffer, FX_DWORD size
); | 268 void GetBinary(uint8_t* buffer, FX_DWORD size
); |
| 269 | 269 |
| 270 void ToNextLine(); | 270 void ToNextLine(); |
| 271 | 271 |
| 272 void ToNextWord(); | 272 void ToNextWord(); |
| 273 | 273 |
| 274 FX_BOOL» » » » SearchWord(const CFX_ByteStringC& word,
FX_BOOL bWholeWord, FX_BOOL bForward, FX_FILESIZE limit); | 274 bool» » » » SearchWord(const CFX_ByteStringC& word,
bool bWholeWord, bool bForward, FX_FILESIZE limit); |
| 275 | 275 |
| 276 int»» » » » SearchMultiWord(const CFX_ByteStringC& w
ords, FX_BOOL bWholeWord, FX_FILESIZE limit); | 276 int»» » » » SearchMultiWord(const CFX_ByteStringC& w
ords, bool bWholeWord, FX_FILESIZE limit); |
| 277 | 277 |
| 278 FX_FILESIZE FindTag(const CFX_ByteStringC& tag, FX_FILESIZE
limit); | 278 FX_FILESIZE FindTag(const CFX_ByteStringC& tag, FX_FILESIZE
limit); |
| 279 | 279 |
| 280 void SetEncrypt(CPDF_CryptoHandler* pCryptoHa
ndler) | 280 void SetEncrypt(CPDF_CryptoHandler* pCryptoHa
ndler) |
| 281 { | 281 { |
| 282 m_pCryptoHandler = pCryptoHandler; | 282 m_pCryptoHandler = pCryptoHandler; |
| 283 } | 283 } |
| 284 | 284 |
| 285 FX_BOOL» » » » IsEncrypted() | 285 bool» » » » IsEncrypted() |
| 286 { | 286 { |
| 287 return m_pCryptoHandler != NULL; | 287 return m_pCryptoHandler != NULL; |
| 288 } | 288 } |
| 289 | 289 |
| 290 FX_BOOL» » » » GetCharAt(FX_FILESIZE pos, uint8_t& ch); | 290 bool» » » » GetCharAt(FX_FILESIZE pos, uint8_t& ch); |
| 291 | 291 |
| 292 FX_BOOL» » » » ReadBlock(uint8_t* pBuf, FX_DWORD size); | 292 bool» » » » ReadBlock(uint8_t* pBuf, FX_DWORD size); |
| 293 | 293 |
| 294 CFX_ByteString» » GetNextWord(FX_BOOL& bIsNumber); | 294 CFX_ByteString» » GetNextWord(bool& bIsNumber); |
| 295 protected: | 295 protected: |
| 296 static const int kParserMaxRecursionDepth = 64; | 296 static const int kParserMaxRecursionDepth = 64; |
| 297 static int s_CurrentRecursionDepth; | 297 static int s_CurrentRecursionDepth; |
| 298 | 298 |
| 299 virtual FX_BOOL» » » » GetNextChar(uint8_t& ch); | 299 virtual bool» » » » GetNextChar(uint8_t& ch); |
| 300 | 300 |
| 301 FX_BOOL» » » » GetCharAtBackward(FX_FILESIZE pos, uint8
_t& ch); | 301 bool» » » » GetCharAtBackward(FX_FILESIZE pos, uint8
_t& ch); |
| 302 | 302 |
| 303 void GetNextWord(); | 303 void GetNextWord(); |
| 304 | 304 |
| 305 FX_BOOL» » » » IsWholeWord(FX_FILESIZE startpos, FX_FIL
ESIZE limit, const uint8_t* tag, FX_DWORD taglen); | 305 bool» » » » IsWholeWord(FX_FILESIZE startpos, FX_FIL
ESIZE limit, const uint8_t* tag, FX_DWORD taglen); |
| 306 | 306 |
| 307 CFX_ByteString ReadString(); | 307 CFX_ByteString ReadString(); |
| 308 | 308 |
| 309 CFX_ByteString ReadHexString(); | 309 CFX_ByteString ReadHexString(); |
| 310 | 310 |
| 311 CPDF_Stream* ReadStream(CPDF_Dictionary* pDict, PARSE_CONTEXT
* pContext, FX_DWORD objnum, FX_DWORD gennum); | 311 CPDF_Stream* ReadStream(CPDF_Dictionary* pDict, PARSE_CONTEXT
* pContext, FX_DWORD objnum, FX_DWORD gennum); |
| 312 | 312 |
| 313 FX_FILESIZE m_Pos; | 313 FX_FILESIZE m_Pos; |
| 314 | 314 |
| 315 FX_BOOL» » » » m_bFileStream; | 315 bool» » » » m_bFileStream; |
| 316 | 316 |
| 317 int m_MetadataObjnum; | 317 int m_MetadataObjnum; |
| 318 | 318 |
| 319 IFX_FileRead* m_pFileAccess; | 319 IFX_FileRead* m_pFileAccess; |
| 320 | 320 |
| 321 FX_DWORD m_HeaderOffset; | 321 FX_DWORD m_HeaderOffset; |
| 322 | 322 |
| 323 FX_FILESIZE m_FileLen; | 323 FX_FILESIZE m_FileLen; |
| 324 | 324 |
| 325 uint8_t* m_pFileBuf; | 325 uint8_t* m_pFileBuf; |
| 326 | 326 |
| 327 FX_DWORD m_BufSize; | 327 FX_DWORD m_BufSize; |
| 328 | 328 |
| 329 FX_FILESIZE m_BufOffset; | 329 FX_FILESIZE m_BufOffset; |
| 330 | 330 |
| 331 CPDF_CryptoHandler* m_pCryptoHandler; | 331 CPDF_CryptoHandler* m_pCryptoHandler; |
| 332 | 332 |
| 333 uint8_t m_WordBuffer[257]; | 333 uint8_t m_WordBuffer[257]; |
| 334 | 334 |
| 335 FX_DWORD m_WordSize; | 335 FX_DWORD m_WordSize; |
| 336 | 336 |
| 337 FX_BOOL» » » » m_bIsNumber; | 337 bool» » » » m_bIsNumber; |
| 338 | 338 |
| 339 FX_FILESIZE m_dwWordPos; | 339 FX_FILESIZE m_dwWordPos; |
| 340 friend class CPDF_Parser; | 340 friend class CPDF_Parser; |
| 341 friend class CPDF_DataAvail; | 341 friend class CPDF_DataAvail; |
| 342 }; | 342 }; |
| 343 | 343 |
| 344 #define PDFPARSE_TYPEONLY 1 | 344 #define PDFPARSE_TYPEONLY 1 |
| 345 #define PDFPARSE_NOSTREAM 2 | 345 #define PDFPARSE_NOSTREAM 2 |
| 346 struct PARSE_CONTEXT { | 346 struct PARSE_CONTEXT { |
| 347 | 347 |
| 348 FX_BOOL» » m_Flags; | 348 bool» » m_Flags; |
| 349 | 349 |
| 350 FX_FILESIZE m_DictStart; | 350 FX_FILESIZE m_DictStart; |
| 351 | 351 |
| 352 FX_FILESIZE m_DictEnd; | 352 FX_FILESIZE m_DictEnd; |
| 353 | 353 |
| 354 FX_FILESIZE m_DataStart; | 354 FX_FILESIZE m_DataStart; |
| 355 | 355 |
| 356 FX_FILESIZE m_DataEnd; | 356 FX_FILESIZE m_DataEnd; |
| 357 }; | 357 }; |
| 358 | 358 |
| 359 #define PDFPARSE_ERROR_SUCCESS 0 | 359 #define PDFPARSE_ERROR_SUCCESS 0 |
| 360 #define PDFPARSE_ERROR_FILE 1 | 360 #define PDFPARSE_ERROR_FILE 1 |
| 361 #define PDFPARSE_ERROR_FORMAT 2 | 361 #define PDFPARSE_ERROR_FORMAT 2 |
| 362 #define PDFPARSE_ERROR_PASSWORD 3 | 362 #define PDFPARSE_ERROR_PASSWORD 3 |
| 363 #define PDFPARSE_ERROR_HANDLER 4 | 363 #define PDFPARSE_ERROR_HANDLER 4 |
| 364 #define PDFPARSE_ERROR_CERT 5 | 364 #define PDFPARSE_ERROR_CERT 5 |
| 365 | 365 |
| 366 class CPDF_Parser | 366 class CPDF_Parser |
| 367 { | 367 { |
| 368 public: | 368 public: |
| 369 CPDF_Parser(); | 369 CPDF_Parser(); |
| 370 ~CPDF_Parser(); | 370 ~CPDF_Parser(); |
| 371 | 371 |
| 372 FX_DWORD» » » StartParse(const FX_CHAR* filename, FX_BOOL bReP
arse = FALSE); | 372 FX_DWORD» » » StartParse(const FX_CHAR* filename, bool bRePars
e = false); |
| 373 FX_DWORD» » » StartParse(const FX_WCHAR* filename, FX_BOOL bRe
Parse = FALSE); | 373 FX_DWORD» » » StartParse(const FX_WCHAR* filename, bool bRePar
se = false); |
| 374 FX_DWORD» » » StartParse(IFX_FileRead* pFile, FX_BOOL bReParse
= FALSE, FX_BOOL bOwnFileRead = TRUE); | 374 FX_DWORD» » » StartParse(IFX_FileRead* pFile, bool bReParse =
false, bool bOwnFileRead = true); |
| 375 | 375 |
| 376 void» » » » CloseParser(FX_BOOL bReParse = FALSE); | 376 void» » » » CloseParser(bool bReParse = false); |
| 377 | 377 |
| 378 FX_DWORD» GetPermissions(FX_BOOL bCheckRevision = FALSE); | 378 FX_DWORD» GetPermissions(bool bCheckRevision = false); |
| 379 | 379 |
| 380 FX_BOOL» » IsOwner(); | 380 bool» » IsOwner(); |
| 381 | 381 |
| 382 void SetPassword(const FX_CHAR* password) | 382 void SetPassword(const FX_CHAR* password) |
| 383 { | 383 { |
| 384 m_Password = password; | 384 m_Password = password; |
| 385 } | 385 } |
| 386 | 386 |
| 387 CFX_ByteString GetPassword() | 387 CFX_ByteString GetPassword() |
| 388 { | 388 { |
| 389 return m_Password; | 389 return m_Password; |
| 390 } | 390 } |
| 391 | 391 |
| 392 CPDF_SecurityHandler* GetSecurityHandler() | 392 CPDF_SecurityHandler* GetSecurityHandler() |
| 393 { | 393 { |
| 394 return m_pSecurityHandler; | 394 return m_pSecurityHandler; |
| 395 } | 395 } |
| 396 | 396 |
| 397 CPDF_CryptoHandler* GetCryptoHandler() | 397 CPDF_CryptoHandler* GetCryptoHandler() |
| 398 { | 398 { |
| 399 return m_Syntax.m_pCryptoHandler; | 399 return m_Syntax.m_pCryptoHandler; |
| 400 } | 400 } |
| 401 | 401 |
| 402 void» » » » SetSecurityHandler(CPDF_SecurityHandler*
pSecurityHandler, FX_BOOL bForced = FALSE); | 402 void» » » » SetSecurityHandler(CPDF_SecurityHandler*
pSecurityHandler, bool bForced = false); |
| 403 | 403 |
| 404 CFX_ByteString GetRecipient() | 404 CFX_ByteString GetRecipient() |
| 405 { | 405 { |
| 406 return m_bsRecipient; | 406 return m_bsRecipient; |
| 407 } | 407 } |
| 408 | 408 |
| 409 CPDF_Dictionary* GetTrailer() | 409 CPDF_Dictionary* GetTrailer() |
| 410 { | 410 { |
| 411 return m_pTrailer; | 411 return m_pTrailer; |
| 412 } | 412 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 428 | 428 |
| 429 FX_DWORD GetRootObjNum(); | 429 FX_DWORD GetRootObjNum(); |
| 430 FX_DWORD GetInfoObjNum() ; | 430 FX_DWORD GetInfoObjNum() ; |
| 431 CPDF_Array* GetIDArray() ; | 431 CPDF_Array* GetIDArray() ; |
| 432 | 432 |
| 433 CPDF_Dictionary* GetEncryptDict() | 433 CPDF_Dictionary* GetEncryptDict() |
| 434 { | 434 { |
| 435 return m_pEncryptDict; | 435 return m_pEncryptDict; |
| 436 } | 436 } |
| 437 | 437 |
| 438 FX_BOOL» » » » IsEncrypted() | 438 bool» » » » IsEncrypted() |
| 439 { | 439 { |
| 440 return GetEncryptDict() != NULL; | 440 return GetEncryptDict() != NULL; |
| 441 } | 441 } |
| 442 | 442 |
| 443 | 443 |
| 444 CPDF_Object* ParseIndirectObject(CPDF_IndirectObjects* pObjLi
st, FX_DWORD objnum, PARSE_CONTEXT* pContext = NULL) ; | 444 CPDF_Object* ParseIndirectObject(CPDF_IndirectObjects* pObjLi
st, FX_DWORD objnum, PARSE_CONTEXT* pContext = NULL) ; |
| 445 FX_DWORD GetLastObjNum(); | 445 FX_DWORD GetLastObjNum(); |
| 446 FX_BOOL» » » » IsFormStream(FX_DWORD objnum, FX_BOOL& b
Form); | 446 bool» » » » IsFormStream(FX_DWORD objnum, bool& bFor
m); |
| 447 | 447 |
| 448 FX_FILESIZE GetObjectOffset(FX_DWORD objnum); | 448 FX_FILESIZE GetObjectOffset(FX_DWORD objnum); |
| 449 | 449 |
| 450 FX_FILESIZE GetObjectSize(FX_DWORD objnum); | 450 FX_FILESIZE GetObjectSize(FX_DWORD objnum); |
| 451 | 451 |
| 452 int GetObjectVersion(FX_DWORD objnum) | 452 int GetObjectVersion(FX_DWORD objnum) |
| 453 { | 453 { |
| 454 return m_ObjVersion[objnum]; | 454 return m_ObjVersion[objnum]; |
| 455 } | 455 } |
| 456 | 456 |
| 457 void GetIndirectBinary(FX_DWORD objnum, uint8
_t*& pBuffer, FX_DWORD& size); | 457 void GetIndirectBinary(FX_DWORD objnum, uint8
_t*& pBuffer, FX_DWORD& size); |
| 458 | 458 |
| 459 FX_BOOL» » » » GetFileStreamOption() | 459 bool» » » » GetFileStreamOption() |
| 460 { | 460 { |
| 461 return m_Syntax.m_bFileStream; | 461 return m_Syntax.m_bFileStream; |
| 462 } | 462 } |
| 463 | 463 |
| 464 void» » » » SetFileStreamOption(FX_BOOL b) | 464 void» » » » SetFileStreamOption(bool b) |
| 465 { | 465 { |
| 466 m_Syntax.m_bFileStream = b; | 466 m_Syntax.m_bFileStream = b; |
| 467 } | 467 } |
| 468 | 468 |
| 469 IFX_FileRead* GetFileAccess() const | 469 IFX_FileRead* GetFileAccess() const |
| 470 { | 470 { |
| 471 return m_Syntax.m_pFileAccess; | 471 return m_Syntax.m_pFileAccess; |
| 472 } | 472 } |
| 473 | 473 |
| 474 int GetFileVersion() const | 474 int GetFileVersion() const |
| 475 { | 475 { |
| 476 return m_FileVersion; | 476 return m_FileVersion; |
| 477 } | 477 } |
| 478 | 478 |
| 479 FX_BOOL» » » » IsXRefStream() const | 479 bool» » » » IsXRefStream() const |
| 480 { | 480 { |
| 481 return m_bXRefStream; | 481 return m_bXRefStream; |
| 482 } | 482 } |
| 483 CPDF_Object* ParseIndirectObjectAt(CPDF_IndirectObjects* pObj
List, FX_FILESIZE pos, FX_DWORD objnum, | 483 CPDF_Object* ParseIndirectObjectAt(CPDF_IndirectObjects* pObj
List, FX_FILESIZE pos, FX_DWORD objnum, |
| 484 struct PARSE_CONTEXT* pContext); | 484 struct PARSE_CONTEXT* pContext); |
| 485 | 485 |
| 486 CPDF_Object* ParseIndirectObjectAtByStrict(CPDF_IndirectObjec
ts* pObjList, FX_FILESIZE pos, FX_DWORD objnum, | 486 CPDF_Object* ParseIndirectObjectAtByStrict(CPDF_IndirectObjec
ts* pObjList, FX_FILESIZE pos, FX_DWORD objnum, |
| 487 struct PARSE_CONTEXT* pContext, FX_FILESIZE *pResultPos); | 487 struct PARSE_CONTEXT* pContext, FX_FILESIZE *pResultPos); |
| 488 | 488 |
| 489 FX_DWORD» » » StartAsynParse(IFX_FileRead* pFile, FX_BOOL bReP
arse = FALSE, FX_BOOL bOwnFileRead = TRUE); | 489 FX_DWORD» » » StartAsynParse(IFX_FileRead* pFile, bool bRePars
e = false, bool bOwnFileRead = true); |
| 490 | 490 |
| 491 FX_DWORD GetFirstPageNo() | 491 FX_DWORD GetFirstPageNo() |
| 492 { | 492 { |
| 493 return m_dwFirstPageNo; | 493 return m_dwFirstPageNo; |
| 494 } | 494 } |
| 495 protected: | 495 protected: |
| 496 CPDF_Document* m_pDocument; | 496 CPDF_Document* m_pDocument; |
| 497 | 497 |
| 498 CPDF_SyntaxParser m_Syntax; | 498 CPDF_SyntaxParser m_Syntax; |
| 499 FX_BOOL» » » » m_bOwnFileRead; | 499 bool» » » » m_bOwnFileRead; |
| 500 CPDF_Object* ParseDirect(CPDF_Object* pObj); | 500 CPDF_Object* ParseDirect(CPDF_Object* pObj); |
| 501 | 501 |
| 502 FX_BOOL» » » » LoadAllCrossRefV4(FX_FILESIZE pos); | 502 bool» » » » LoadAllCrossRefV4(FX_FILESIZE pos); |
| 503 | 503 |
| 504 FX_BOOL» » » » LoadAllCrossRefV5(FX_FILESIZE pos); | 504 bool» » » » LoadAllCrossRefV5(FX_FILESIZE pos); |
| 505 | 505 |
| 506 FX_BOOL» » » » LoadCrossRefV4(FX_FILESIZE pos, FX_FILES
IZE streampos, FX_BOOL bSkip, FX_BOOL bFirst); | 506 bool» » » » LoadCrossRefV4(FX_FILESIZE pos, FX_FILES
IZE streampos, bool bSkip, bool bFirst); |
| 507 | 507 |
| 508 FX_BOOL» » » » LoadCrossRefV5(FX_FILESIZE pos, FX_FILES
IZE& prev, FX_BOOL bMainXRef); | 508 bool» » » » LoadCrossRefV5(FX_FILESIZE pos, FX_FILES
IZE& prev, bool bMainXRef); |
| 509 | 509 |
| 510 CPDF_Dictionary* LoadTrailerV4(); | 510 CPDF_Dictionary* LoadTrailerV4(); |
| 511 | 511 |
| 512 FX_BOOL» » » » RebuildCrossRef(); | 512 bool» » » » RebuildCrossRef(); |
| 513 | 513 |
| 514 FX_DWORD SetEncryptHandler(); | 514 FX_DWORD SetEncryptHandler(); |
| 515 | 515 |
| 516 void ReleaseEncryptHandler(); | 516 void ReleaseEncryptHandler(); |
| 517 | 517 |
| 518 FX_BOOL» » » » LoadLinearizedAllCrossRefV4(FX_FILESIZE
pos, FX_DWORD dwObjCount); | 518 bool» » » » LoadLinearizedAllCrossRefV4(FX_FILESIZE
pos, FX_DWORD dwObjCount); |
| 519 | 519 |
| 520 FX_BOOL» » » » LoadLinearizedCrossRefV4(FX_FILESIZE pos
, FX_DWORD dwObjCount); | 520 bool» » » » LoadLinearizedCrossRefV4(FX_FILESIZE pos
, FX_DWORD dwObjCount); |
| 521 | 521 |
| 522 FX_BOOL» » » » LoadLinearizedAllCrossRefV5(FX_FILESIZE
pos); | 522 bool» » » » LoadLinearizedAllCrossRefV5(FX_FILESIZE
pos); |
| 523 | 523 |
| 524 FX_DWORD LoadLinearizedMainXRefTable(); | 524 FX_DWORD LoadLinearizedMainXRefTable(); |
| 525 | 525 |
| 526 CFX_MapPtrToPtr m_ObjectStreamMap; | 526 CFX_MapPtrToPtr m_ObjectStreamMap; |
| 527 | 527 |
| 528 CPDF_StreamAcc* GetObjectStream(FX_DWORD number); | 528 CPDF_StreamAcc* GetObjectStream(FX_DWORD number); |
| 529 | 529 |
| 530 FX_BOOL» » » » IsLinearizedFile(IFX_FileRead* pFileAcce
ss, FX_DWORD offset); | 530 bool» » » » IsLinearizedFile(IFX_FileRead* pFileAcce
ss, FX_DWORD offset); |
| 531 | 531 |
| 532 | 532 |
| 533 | 533 |
| 534 int m_FileVersion; | 534 int m_FileVersion; |
| 535 | 535 |
| 536 CPDF_Dictionary* m_pTrailer; | 536 CPDF_Dictionary* m_pTrailer; |
| 537 | 537 |
| 538 CPDF_Dictionary* m_pEncryptDict; | 538 CPDF_Dictionary* m_pEncryptDict; |
| 539 void SetEncryptDictionary(CPDF_Dictionary* pDict); | 539 void SetEncryptDictionary(CPDF_Dictionary* pDict); |
| 540 | 540 |
| 541 FX_FILESIZE m_LastXRefOffset; | 541 FX_FILESIZE m_LastXRefOffset; |
| 542 | 542 |
| 543 FX_BOOL» » » » m_bXRefStream; | 543 bool» » » » m_bXRefStream; |
| 544 | 544 |
| 545 | 545 |
| 546 CPDF_SecurityHandler* m_pSecurityHandler; | 546 CPDF_SecurityHandler* m_pSecurityHandler; |
| 547 | 547 |
| 548 FX_BOOL» » » » » m_bForceUseSecurityHandler; | 548 bool» » » » » m_bForceUseSecurityHandler; |
| 549 | 549 |
| 550 CFX_ByteString m_bsRecipient; | 550 CFX_ByteString m_bsRecipient; |
| 551 | 551 |
| 552 CFX_ByteString m_FilePath; | 552 CFX_ByteString m_FilePath; |
| 553 | 553 |
| 554 CFX_ByteString m_Password; | 554 CFX_ByteString m_Password; |
| 555 | 555 |
| 556 CFX_FileSizeArray m_CrossRef; | 556 CFX_FileSizeArray m_CrossRef; |
| 557 | 557 |
| 558 CFX_ByteArray m_V5Type; | 558 CFX_ByteArray m_V5Type; |
| 559 | 559 |
| 560 CFX_FileSizeArray m_SortedOffset; | 560 CFX_FileSizeArray m_SortedOffset; |
| 561 | 561 |
| 562 CFX_WordArray m_ObjVersion; | 562 CFX_WordArray m_ObjVersion; |
| 563 CFX_ArrayTemplate<CPDF_Dictionary *> m_Trailers; | 563 CFX_ArrayTemplate<CPDF_Dictionary *> m_Trailers; |
| 564 | 564 |
| 565 FX_BOOL» » » » m_bVersionUpdated; | 565 bool» » » » m_bVersionUpdated; |
| 566 | 566 |
| 567 CPDF_Object* m_pLinearized; | 567 CPDF_Object* m_pLinearized; |
| 568 | 568 |
| 569 FX_DWORD m_dwFirstPageNo; | 569 FX_DWORD m_dwFirstPageNo; |
| 570 | 570 |
| 571 FX_DWORD m_dwXrefStartObjNum; | 571 FX_DWORD m_dwXrefStartObjNum; |
| 572 friend class CPDF_Creator; | 572 friend class CPDF_Creator; |
| 573 friend class CPDF_DataAvail; | 573 friend class CPDF_DataAvail; |
| 574 }; | 574 }; |
| 575 #define FXCIPHER_NONE 0 | 575 #define FXCIPHER_NONE 0 |
| 576 #define FXCIPHER_RC4 1 | 576 #define FXCIPHER_RC4 1 |
| 577 #define FXCIPHER_AES 2 | 577 #define FXCIPHER_AES 2 |
| 578 #define FXCIPHER_AES2 3 | 578 #define FXCIPHER_AES2 3 |
| 579 class CPDF_SecurityHandler | 579 class CPDF_SecurityHandler |
| 580 { | 580 { |
| 581 public: | 581 public: |
| 582 | 582 |
| 583 virtual ~CPDF_SecurityHandler() {} | 583 virtual ~CPDF_SecurityHandler() {} |
| 584 | 584 |
| 585 virtual FX_BOOL» » OnInit(CPDF_Parser* pParser, CPDF_Dictionary* pE
ncryptDict) = 0; | 585 virtual bool» » OnInit(CPDF_Parser* pParser, CPDF_Dictionary* pE
ncryptDict) = 0; |
| 586 | 586 |
| 587 virtual FX_DWORD GetPermissions() = 0; | 587 virtual FX_DWORD GetPermissions() = 0; |
| 588 | 588 |
| 589 virtual FX_BOOL» » IsOwner() = 0; | 589 virtual bool» » IsOwner() = 0; |
| 590 | 590 |
| 591 virtual FX_BOOL» » GetCryptInfo(int& cipher, const uint8_t*& buffer
, int& keylen) = 0; | 591 virtual bool» » GetCryptInfo(int& cipher, const uint8_t*& buffer
, int& keylen) = 0; |
| 592 | 592 |
| 593 virtual FX_BOOL» » IsMetadataEncrypted() | 593 virtual bool» » IsMetadataEncrypted() |
| 594 { | 594 { |
| 595 return TRUE; | 595 return true; |
| 596 } | 596 } |
| 597 | 597 |
| 598 virtual CPDF_CryptoHandler* CreateCryptoHandler() = 0; | 598 virtual CPDF_CryptoHandler* CreateCryptoHandler() = 0; |
| 599 | 599 |
| 600 virtual CPDF_StandardSecurityHandler* GetStandardHandler() | 600 virtual CPDF_StandardSecurityHandler* GetStandardHandler() |
| 601 { | 601 { |
| 602 return NULL; | 602 return NULL; |
| 603 } | 603 } |
| 604 }; | 604 }; |
| 605 #define PDF_ENCRYPT_CONTENT 0 | 605 #define PDF_ENCRYPT_CONTENT 0 |
| 606 class CPDF_StandardSecurityHandler : public CPDF_SecurityHandler | 606 class CPDF_StandardSecurityHandler : public CPDF_SecurityHandler |
| 607 { | 607 { |
| 608 public: | 608 public: |
| 609 CPDF_StandardSecurityHandler(); | 609 CPDF_StandardSecurityHandler(); |
| 610 | 610 |
| 611 virtual ~CPDF_StandardSecurityHandler(); | 611 virtual ~CPDF_StandardSecurityHandler(); |
| 612 virtual FX_BOOL» » OnInit(CPDF_Parser* pParser, CPDF_Dictionary* pE
ncryptDict); | 612 virtual bool» » OnInit(CPDF_Parser* pParser, CPDF_Dictionary* pE
ncryptDict); |
| 613 virtual FX_DWORD GetPermissions(); | 613 virtual FX_DWORD GetPermissions(); |
| 614 virtual FX_BOOL» » IsOwner() | 614 virtual bool» » IsOwner() |
| 615 { | 615 { |
| 616 return m_bOwner; | 616 return m_bOwner; |
| 617 } | 617 } |
| 618 virtual FX_BOOL» » GetCryptInfo(int& cipher, const uint8_t*& buffer
, int& keylen); | 618 virtual bool» » GetCryptInfo(int& cipher, const uint8_t*& buffer
, int& keylen); |
| 619 virtual FX_BOOL» » IsMetadataEncrypted(); | 619 virtual bool» » IsMetadataEncrypted(); |
| 620 virtual CPDF_CryptoHandler* CreateCryptoHandler(); | 620 virtual CPDF_CryptoHandler* CreateCryptoHandler(); |
| 621 virtual CPDF_StandardSecurityHandler* GetStandardHandler() | 621 virtual CPDF_StandardSecurityHandler* GetStandardHandler() |
| 622 { | 622 { |
| 623 return this; | 623 return this; |
| 624 } | 624 } |
| 625 | 625 |
| 626 void OnCreate(CPDF_Dictionary* pEncryptDict,
CPDF_Array* pIdArray, | 626 void OnCreate(CPDF_Dictionary* pEncryptDict,
CPDF_Array* pIdArray, |
| 627 const uint8_t* user_pass, FX_DWORD user_size, | 627 const uint8_t* user_pass, FX_DWORD user_size, |
| 628 const uint8_t* owner_pass, FX_DWORD owner_size,
FX_DWORD type = PDF_ENCRYPT_CONTENT); | 628 const uint8_t* owner_pass, FX_DWORD owner_size,
FX_DWORD type = PDF_ENCRYPT_CONTENT); |
| 629 | 629 |
| 630 void OnCreate(CPDF_Dictionary* pEncryptDict,
CPDF_Array* pIdArray, | 630 void OnCreate(CPDF_Dictionary* pEncryptDict,
CPDF_Array* pIdArray, |
| 631 const uint8_t* user_pass, FX_DWORD user_size, F
X_DWORD type = PDF_ENCRYPT_CONTENT); | 631 const uint8_t* user_pass, FX_DWORD user_size, F
X_DWORD type = PDF_ENCRYPT_CONTENT); |
| 632 | 632 |
| 633 CFX_ByteString GetUserPassword(const uint8_t* owner_pass, FX_DW
ORD pass_size); | 633 CFX_ByteString GetUserPassword(const uint8_t* owner_pass, FX_DW
ORD pass_size); |
| 634 CFX_ByteString GetUserPassword(const uint8_t* owner_pass, FX_DW
ORD pass_size, int32_t key_len); | 634 CFX_ByteString GetUserPassword(const uint8_t* owner_pass, FX_DW
ORD pass_size, int32_t key_len); |
| 635 int GetVersion() | 635 int GetVersion() |
| 636 { | 636 { |
| 637 return m_Version; | 637 return m_Version; |
| 638 } | 638 } |
| 639 int GetRevision() | 639 int GetRevision() |
| 640 { | 640 { |
| 641 return m_Revision; | 641 return m_Revision; |
| 642 } | 642 } |
| 643 | 643 |
| 644 int»» » » » CheckPassword(const uint8_t* password, F
X_DWORD pass_size, FX_BOOL bOwner, uint8_t* key); | 644 int»» » » » CheckPassword(const uint8_t* password, F
X_DWORD pass_size, bool bOwner, uint8_t* key); |
| 645 int»» » » » CheckPassword(const uint8_t* password, F
X_DWORD pass_size, FX_BOOL bOwner, uint8_t* key, int key_len); | 645 int»» » » » CheckPassword(const uint8_t* password, F
X_DWORD pass_size, bool bOwner, uint8_t* key, int key_len); |
| 646 private: | 646 private: |
| 647 | 647 |
| 648 int m_Version; | 648 int m_Version; |
| 649 | 649 |
| 650 int m_Revision; | 650 int m_Revision; |
| 651 | 651 |
| 652 CPDF_Parser* m_pParser; | 652 CPDF_Parser* m_pParser; |
| 653 | 653 |
| 654 CPDF_Dictionary* m_pEncryptDict; | 654 CPDF_Dictionary* m_pEncryptDict; |
| 655 | 655 |
| 656 FX_BOOL» » » » LoadDict(CPDF_Dictionary* pEncryptDict); | 656 bool» » » » LoadDict(CPDF_Dictionary* pEncryptDict); |
| 657 FX_BOOL» » » » LoadDict(CPDF_Dictionary* pEncryptDict,
FX_DWORD type, int& cipher, int& key_len); | 657 bool» » » » LoadDict(CPDF_Dictionary* pEncryptDict,
FX_DWORD type, int& cipher, int& key_len); |
| 658 | 658 |
| 659 FX_BOOL» » » » CheckUserPassword(const uint8_t* passwor
d, FX_DWORD pass_size, | 659 bool» » » » CheckUserPassword(const uint8_t* passwor
d, FX_DWORD pass_size, |
| 660 FX_BOOL bIgnoreEncryptMeta, uint8_t* k
ey, int32_t key_len); | 660 bool bIgnoreEncryptMeta, uint8_t* key,
int32_t key_len); |
| 661 | 661 |
| 662 FX_BOOL» » » » CheckOwnerPassword(const uint8_t* passwo
rd, FX_DWORD pass_size, uint8_t* key, int32_t key_len); | 662 bool» » » » CheckOwnerPassword(const uint8_t* passwo
rd, FX_DWORD pass_size, uint8_t* key, int32_t key_len); |
| 663 FX_BOOL» » » » AES256_CheckPassword(const uint8_t* pass
word, FX_DWORD size, FX_BOOL bOwner, uint8_t* key); | 663 bool» » » » AES256_CheckPassword(const uint8_t* pass
word, FX_DWORD size, bool bOwner, uint8_t* key); |
| 664 void» » » » AES256_SetPassword(CPDF_Dictionary* pEnc
ryptDict, const uint8_t* password, FX_DWORD size, FX_BOOL bOwner, const uint8_t*
key); | 664 void» » » » AES256_SetPassword(CPDF_Dictionary* pEnc
ryptDict, const uint8_t* password, FX_DWORD size, bool bOwner, const uint8_t* ke
y); |
| 665 void» » » » AES256_SetPerms(CPDF_Dictionary* pEncryp
tDict, FX_DWORD permission, FX_BOOL bEncryptMetadata, const uint8_t* key); | 665 void» » » » AES256_SetPerms(CPDF_Dictionary* pEncryp
tDict, FX_DWORD permission, bool bEncryptMetadata, const uint8_t* key); |
| 666 void OnCreate(CPDF_Dictionary* pEncryptDict,
CPDF_Array* pIdArray, | 666 void OnCreate(CPDF_Dictionary* pEncryptDict,
CPDF_Array* pIdArray, |
| 667 const uint8_t* user_pass, FX_DWORD user_size, | 667 const uint8_t* user_pass, FX_DWORD user_size, |
| 668 const uint8_t* owner_pass, FX_DWORD owner_size,
FX_BOOL bDefault, FX_DWORD type); | 668 const uint8_t* owner_pass, FX_DWORD owner_size,
bool bDefault, FX_DWORD type); |
| 669 FX_BOOL» » » » CheckSecurity(int32_t key_len); | 669 bool» » » » CheckSecurity(int32_t key_len); |
| 670 | 670 |
| 671 FX_BOOL» » » » m_bOwner; | 671 bool» » » » m_bOwner; |
| 672 | 672 |
| 673 FX_DWORD m_Permissions; | 673 FX_DWORD m_Permissions; |
| 674 | 674 |
| 675 int m_Cipher; | 675 int m_Cipher; |
| 676 | 676 |
| 677 uint8_t m_EncryptKey[32]; | 677 uint8_t m_EncryptKey[32]; |
| 678 | 678 |
| 679 int m_KeyLen; | 679 int m_KeyLen; |
| 680 }; | 680 }; |
| 681 class CPDF_CryptoHandler | 681 class CPDF_CryptoHandler |
| 682 { | 682 { |
| 683 public: | 683 public: |
| 684 | 684 |
| 685 virtual ~CPDF_CryptoHandler() {} | 685 virtual ~CPDF_CryptoHandler() {} |
| 686 | 686 |
| 687 virtual FX_BOOL» » Init(CPDF_Dictionary* pEncryptDict, CPDF_Securit
yHandler* pSecurityHandler) = 0; | 687 virtual bool» » Init(CPDF_Dictionary* pEncryptDict, CPDF_Securit
yHandler* pSecurityHandler) = 0; |
| 688 | 688 |
| 689 virtual FX_DWORD DecryptGetSize(FX_DWORD src_size) = 0; | 689 virtual FX_DWORD DecryptGetSize(FX_DWORD src_size) = 0; |
| 690 | 690 |
| 691 virtual void* DecryptStart(FX_DWORD objnum, FX_DWORD gennum) = 0; | 691 virtual void* DecryptStart(FX_DWORD objnum, FX_DWORD gennum) = 0; |
| 692 | 692 |
| 693 virtual FX_BOOL» » DecryptStream(void* context, const uint8_t* src_
buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf) = 0; | 693 virtual bool» » DecryptStream(void* context, const uint8_t* src_
buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf) = 0; |
| 694 | 694 |
| 695 virtual FX_BOOL» » DecryptFinish(void* context, CFX_BinaryBuf& dest
_buf) = 0; | 695 virtual bool» » DecryptFinish(void* context, CFX_BinaryBuf& dest
_buf) = 0; |
| 696 | 696 |
| 697 | 697 |
| 698 virtual FX_DWORD EncryptGetSize(FX_DWORD objnum, FX_DWORD version, const
uint8_t* src_buf, FX_DWORD src_size) = 0; | 698 virtual FX_DWORD EncryptGetSize(FX_DWORD objnum, FX_DWORD version, const
uint8_t* src_buf, FX_DWORD src_size) = 0; |
| 699 | 699 |
| 700 virtual FX_BOOL» » EncryptContent(FX_DWORD objnum, FX_DWORD version
, const uint8_t* src_buf, FX_DWORD src_size, | 700 virtual bool» » EncryptContent(FX_DWORD objnum, FX_DWORD version
, const uint8_t* src_buf, FX_DWORD src_size, |
| 701 uint8_t* dest_buf, FX_DWORD& dest_size) =
0; | 701 uint8_t* dest_buf, FX_DWORD& dest_size) =
0; |
| 702 | 702 |
| 703 void Decrypt(FX_DWORD objnum, FX_DWORD versio
n, CFX_ByteString& str); | 703 void Decrypt(FX_DWORD objnum, FX_DWORD versio
n, CFX_ByteString& str); |
| 704 }; | 704 }; |
| 705 class CPDF_StandardCryptoHandler : public CPDF_CryptoHandler | 705 class CPDF_StandardCryptoHandler : public CPDF_CryptoHandler |
| 706 { | 706 { |
| 707 public: | 707 public: |
| 708 | 708 |
| 709 CPDF_StandardCryptoHandler(); | 709 CPDF_StandardCryptoHandler(); |
| 710 | 710 |
| 711 virtual ~CPDF_StandardCryptoHandler(); | 711 virtual ~CPDF_StandardCryptoHandler(); |
| 712 | 712 |
| 713 FX_BOOL» » » » Init(int cipher, const uint8_t* key, int
keylen); | 713 bool» » » » Init(int cipher, const uint8_t* key, int
keylen); |
| 714 virtual FX_BOOL» » Init(CPDF_Dictionary* pEncryptDict, CPDF_Securit
yHandler* pSecurityHandler); | 714 virtual bool» » Init(CPDF_Dictionary* pEncryptDict, CPDF_Securit
yHandler* pSecurityHandler); |
| 715 virtual FX_DWORD DecryptGetSize(FX_DWORD src_size); | 715 virtual FX_DWORD DecryptGetSize(FX_DWORD src_size); |
| 716 virtual void* DecryptStart(FX_DWORD objnum, FX_DWORD gennum); | 716 virtual void* DecryptStart(FX_DWORD objnum, FX_DWORD gennum); |
| 717 virtual FX_BOOL» » DecryptStream(void* context, const uint8_t* src_
buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf); | 717 virtual bool» » DecryptStream(void* context, const uint8_t* src_
buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf); |
| 718 virtual FX_BOOL» » DecryptFinish(void* context, CFX_BinaryBuf& dest
_buf); | 718 virtual bool» » DecryptFinish(void* context, CFX_BinaryBuf& dest
_buf); |
| 719 virtual FX_DWORD EncryptGetSize(FX_DWORD objnum, FX_DWORD version, const
uint8_t* src_buf, FX_DWORD src_size); | 719 virtual FX_DWORD EncryptGetSize(FX_DWORD objnum, FX_DWORD version, const
uint8_t* src_buf, FX_DWORD src_size); |
| 720 virtual FX_BOOL» » EncryptContent(FX_DWORD objnum, FX_DWORD version
, const uint8_t* src_buf, FX_DWORD src_size, | 720 virtual bool» » EncryptContent(FX_DWORD objnum, FX_DWORD version
, const uint8_t* src_buf, FX_DWORD src_size, |
| 721 uint8_t* dest_buf, FX_DWORD& dest_size); | 721 uint8_t* dest_buf, FX_DWORD& dest_size); |
| 722 protected: | 722 protected: |
| 723 | 723 |
| 724 virtual void» » CryptBlock(FX_BOOL bEncrypt, FX_DWORD objnum, FX
_DWORD gennum, const uint8_t* src_buf, FX_DWORD src_size, | 724 virtual void» » CryptBlock(bool bEncrypt, FX_DWORD objnum, FX_DW
ORD gennum, const uint8_t* src_buf, FX_DWORD src_size, |
| 725 uint8_t* dest_buf, FX_DWORD& dest_size); | 725 uint8_t* dest_buf, FX_DWORD& dest_size); |
| 726 virtual void*» CryptStart(FX_DWORD objnum, FX_DWORD gennum, FX_BOOL bEn
crypt); | 726 virtual void*» CryptStart(FX_DWORD objnum, FX_DWORD gennum, bool bEncry
pt); |
| 727 virtual FX_BOOL» » CryptStream(void* context, const uint8_t* src_bu
f, FX_DWORD src_size, CFX_BinaryBuf& dest_buf, FX_BOOL bEncrypt); | 727 virtual bool» » CryptStream(void* context, const uint8_t* src_bu
f, FX_DWORD src_size, CFX_BinaryBuf& dest_buf, bool bEncrypt); |
| 728 virtual FX_BOOL» » CryptFinish(void* context, CFX_BinaryBuf& dest_b
uf, FX_BOOL bEncrypt); | 728 virtual bool» » CryptFinish(void* context, CFX_BinaryBuf& dest_b
uf, bool bEncrypt); |
| 729 | 729 |
| 730 uint8_t m_EncryptKey[32]; | 730 uint8_t m_EncryptKey[32]; |
| 731 | 731 |
| 732 int m_KeyLen; | 732 int m_KeyLen; |
| 733 | 733 |
| 734 int m_Cipher; | 734 int m_Cipher; |
| 735 | 735 |
| 736 uint8_t* m_pAESContext; | 736 uint8_t* m_pAESContext; |
| 737 }; | 737 }; |
| 738 class CPDF_Point | 738 class CPDF_Point |
| 739 { | 739 { |
| 740 public: | 740 public: |
| 741 | 741 |
| 742 CPDF_Point(FX_FLOAT xx, FX_FLOAT yy) | 742 CPDF_Point(FX_FLOAT xx, FX_FLOAT yy) |
| 743 { | 743 { |
| 744 x = xx; | 744 x = xx; |
| 745 y = yy; | 745 y = yy; |
| 746 } | 746 } |
| 747 | 747 |
| 748 FX_FLOAT x; | 748 FX_FLOAT x; |
| 749 | 749 |
| 750 FX_FLOAT y; | 750 FX_FLOAT y; |
| 751 }; | 751 }; |
| 752 | 752 |
| 753 #define CPDF_Rect CFX_FloatRect | 753 #define CPDF_Rect CFX_FloatRect |
| 754 #define CPDF_Matrix CFX_AffineMatrix | 754 #define CPDF_Matrix CFX_AffineMatrix |
| 755 CFX_ByteString PDF_NameDecode(const CFX_ByteStringC& orig); | 755 CFX_ByteString PDF_NameDecode(const CFX_ByteStringC& orig); |
| 756 CFX_ByteString PDF_NameDecode(const CFX_ByteString& orig); | 756 CFX_ByteString PDF_NameDecode(const CFX_ByteString& orig); |
| 757 CFX_ByteString PDF_NameEncode(const CFX_ByteString& orig); | 757 CFX_ByteString PDF_NameEncode(const CFX_ByteString& orig); |
| 758 CFX_ByteString PDF_EncodeString(const CFX_ByteString& src, FX_BOOL bHex = FALSE)
; | 758 CFX_ByteString PDF_EncodeString(const CFX_ByteString& src, bool bHex = false); |
| 759 CFX_WideString PDF_DecodeText(const uint8_t* pData, FX_DWORD size, CFX_CharMap*
pCharMap = NULL); | 759 CFX_WideString PDF_DecodeText(const uint8_t* pData, FX_DWORD size, CFX_CharMap*
pCharMap = NULL); |
| 760 inline CFX_WideString PDF_DecodeText(const CFX_ByteString& bstr, CFX_CharMap* pC
harMap = NULL) { | 760 inline CFX_WideString PDF_DecodeText(const CFX_ByteString& bstr, CFX_CharMap* pC
harMap = NULL) { |
| 761 return PDF_DecodeText((const uint8_t*)bstr.c_str(), bstr.GetLength(), pCharM
ap); | 761 return PDF_DecodeText((const uint8_t*)bstr.c_str(), bstr.GetLength(), pCharM
ap); |
| 762 } | 762 } |
| 763 CFX_ByteString PDF_EncodeText(const FX_WCHAR* pString, int len = -1, CFX_CharMap
* pCharMap = NULL); | 763 CFX_ByteString PDF_EncodeText(const FX_WCHAR* pString, int len = -1, CFX_CharMap
* pCharMap = NULL); |
| 764 inline CFX_ByteString PDF_EncodeText(const CFX_WideString& str, CFX_CharMap* pCh
arMap = NULL) { | 764 inline CFX_ByteString PDF_EncodeText(const CFX_WideString& str, CFX_CharMap* pCh
arMap = NULL) { |
| 765 return PDF_EncodeText(str.c_str(), str.GetLength(), pCharMap); | 765 return PDF_EncodeText(str.c_str(), str.GetLength(), pCharMap); |
| 766 } | 766 } |
| 767 FX_FLOAT PDF_ClipFloat(FX_FLOAT f); | 767 FX_FLOAT PDF_ClipFloat(FX_FLOAT f); |
| 768 class CFDF_Document : public CPDF_IndirectObjects | 768 class CFDF_Document : public CPDF_IndirectObjects |
| 769 { | 769 { |
| 770 public: | 770 public: |
| 771 static CFDF_Document* CreateNewDoc(); | 771 static CFDF_Document* CreateNewDoc(); |
| 772 static CFDF_Document* ParseFile(IFX_FileRead *pFile, FX_BOOL bOwnFile = FALS
E); | 772 static CFDF_Document* ParseFile(IFX_FileRead *pFile, bool bOwnFile = false); |
| 773 static CFDF_Document* ParseMemory(const uint8_t* pData, FX_DWORD size); | 773 static CFDF_Document* ParseMemory(const uint8_t* pData, FX_DWORD size); |
| 774 | 774 |
| 775 ~CFDF_Document(); | 775 ~CFDF_Document(); |
| 776 | 776 |
| 777 FX_BOOL» » » » » WriteBuf(CFX_ByteTextBuf& buf) c
onst; | 777 bool» » » » » WriteBuf(CFX_ByteTextBuf& buf) c
onst; |
| 778 | 778 |
| 779 CPDF_Dictionary* GetRoot() const | 779 CPDF_Dictionary* GetRoot() const |
| 780 { | 780 { |
| 781 return m_pRootDict; | 781 return m_pRootDict; |
| 782 } | 782 } |
| 783 | 783 |
| 784 CFX_WideString GetWin32Path() const; | 784 CFX_WideString GetWin32Path() const; |
| 785 protected: | 785 protected: |
| 786 | 786 |
| 787 CFDF_Document(); | 787 CFDF_Document(); |
| 788 void» ParseStream(IFX_FileRead *pFile, FX_BOOL bOwnFile); | 788 void» ParseStream(IFX_FileRead *pFile, bool bOwnFile); |
| 789 CPDF_Dictionary* m_pRootDict; | 789 CPDF_Dictionary* m_pRootDict; |
| 790 IFX_FileRead* m_pFile; | 790 IFX_FileRead* m_pFile; |
| 791 FX_BOOL» » » » » m_bOwnFile; | 791 bool» » » » » m_bOwnFile; |
| 792 }; | 792 }; |
| 793 | 793 |
| 794 CFX_WideString FPDF_FileSpec_GetWin32Path(const CPDF_Object* pFileSpec); | 794 CFX_WideString FPDF_FileSpec_GetWin32Path(const CPDF_Object* pFileSpec); |
| 795 void FPDF_FileSpec_SetWin32Path(CPDF_Object* pFileSpec, const
CFX_WideString& fullpath); | 795 void FPDF_FileSpec_SetWin32Path(CPDF_Object* pFileSpec, const
CFX_WideString& fullpath); |
| 796 | 796 |
| 797 void FlateEncode(const uint8_t* src_buf, FX_DWORD src_size, uint8_t*& dest_buf,
FX_DWORD& dest_size); | 797 void FlateEncode(const uint8_t* src_buf, FX_DWORD src_size, uint8_t*& dest_buf,
FX_DWORD& dest_size); |
| 798 FX_DWORD FlateDecode(const uint8_t* src_buf, FX_DWORD src_size, uint8_t*& dest_b
uf, FX_DWORD& dest_size); | 798 FX_DWORD FlateDecode(const uint8_t* src_buf, FX_DWORD src_size, uint8_t*& dest_b
uf, FX_DWORD& dest_size); |
| 799 FX_DWORD RunLengthDecode(const uint8_t* src_buf, FX_DWORD src_size, uint8_t*& de
st_buf, FX_DWORD& dest_size); | 799 FX_DWORD RunLengthDecode(const uint8_t* src_buf, FX_DWORD src_size, uint8_t*& de
st_buf, FX_DWORD& dest_size); |
| 800 class CPDF_NumberTree | 800 class CPDF_NumberTree |
| 801 { | 801 { |
| 802 public: | 802 public: |
| 803 | 803 |
| 804 CPDF_NumberTree(CPDF_Dictionary* pRoot) | 804 CPDF_NumberTree(CPDF_Dictionary* pRoot) |
| 805 { | 805 { |
| 806 m_pRoot = pRoot; | 806 m_pRoot = pRoot; |
| 807 } | 807 } |
| 808 | 808 |
| 809 CPDF_Object* LookupValue(int num); | 809 CPDF_Object* LookupValue(int num); |
| 810 protected: | 810 protected: |
| 811 | 811 |
| 812 CPDF_Dictionary* m_pRoot; | 812 CPDF_Dictionary* m_pRoot; |
| 813 }; | 813 }; |
| 814 | 814 |
| 815 class IFX_FileAvail | 815 class IFX_FileAvail |
| 816 { | 816 { |
| 817 public: | 817 public: |
| 818 virtual ~IFX_FileAvail() { } | 818 virtual ~IFX_FileAvail() { } |
| 819 virtual FX_BOOL» » » IsDataAvail( FX_FILESIZE offset, FX_DWOR
D size) = 0; | 819 virtual bool» » » IsDataAvail( FX_FILESIZE offset, FX_DWOR
D size) = 0; |
| 820 }; | 820 }; |
| 821 class IFX_DownloadHints | 821 class IFX_DownloadHints |
| 822 { | 822 { |
| 823 public: | 823 public: |
| 824 virtual ~IFX_DownloadHints() { } | 824 virtual ~IFX_DownloadHints() { } |
| 825 virtual void AddSegment(FX_FILESIZE offset, FX_DWORD
size) = 0; | 825 virtual void AddSegment(FX_FILESIZE offset, FX_DWORD
size) = 0; |
| 826 }; | 826 }; |
| 827 #define PDF_IS_LINEARIZED 1 | 827 #define PDF_IS_LINEARIZED 1 |
| 828 #define PDF_NOT_LINEARIZED 0 | 828 #define PDF_NOT_LINEARIZED 0 |
| 829 #define PDF_UNKNOW_LINEARIZED -1 | 829 #define PDF_UNKNOW_LINEARIZED -1 |
| 830 #define PDFFORM_NOTAVAIL 0 | 830 #define PDFFORM_NOTAVAIL 0 |
| 831 #define PDFFORM_AVAIL 1 | 831 #define PDFFORM_AVAIL 1 |
| 832 #define PDFFORM_NOTEXIST 2 | 832 #define PDFFORM_NOTEXIST 2 |
| 833 class IPDF_DataAvail | 833 class IPDF_DataAvail |
| 834 { | 834 { |
| 835 public: | 835 public: |
| 836 static IPDF_DataAvail* Create(IFX_FileAvail* pFileAvail, IFX_FileRead* pFile
Read); | 836 static IPDF_DataAvail* Create(IFX_FileAvail* pFileAvail, IFX_FileRead* pFile
Read); |
| 837 virtual ~IPDF_DataAvail() { } | 837 virtual ~IPDF_DataAvail() { } |
| 838 | 838 |
| 839 IFX_FileAvail* GetFileAvail() const { return m_pFileAvail; } | 839 IFX_FileAvail* GetFileAvail() const { return m_pFileAvail; } |
| 840 IFX_FileRead* GetFileRead() const { return m_pFileRead; } | 840 IFX_FileRead* GetFileRead() const { return m_pFileRead; } |
| 841 | 841 |
| 842 virtual FX_BOOL» » » IsDocAvail(IFX_DownloadHints* pHints) =
0; | 842 virtual bool» » » IsDocAvail(IFX_DownloadHints* pHints) =
0; |
| 843 virtual void SetDocument(CPDF_Document* pDoc) = 0; | 843 virtual void SetDocument(CPDF_Document* pDoc) = 0; |
| 844 virtual FX_BOOL» » » IsPageAvail(int iPage, IFX_DownloadHints
* pHints) = 0; | 844 virtual bool» » » IsPageAvail(int iPage, IFX_DownloadHints
* pHints) = 0; |
| 845 virtual FX_BOOL» » » IsLinearized() = 0; | 845 virtual bool» » » IsLinearized() = 0; |
| 846 virtual int32_t IsFormAvail(IFX_DownloadHints *pHints) = 0; | 846 virtual int32_t IsFormAvail(IFX_DownloadHints *pHints) = 0; |
| 847 virtual int32_t IsLinearizedPDF() = 0; | 847 virtual int32_t IsLinearizedPDF() = 0; |
| 848 virtual void GetLinearizedMainXRefInfo(FX_FIL
ESIZE *pPos, FX_DWORD *pSize) = 0; | 848 virtual void GetLinearizedMainXRefInfo(FX_FIL
ESIZE *pPos, FX_DWORD *pSize) = 0; |
| 849 | 849 |
| 850 protected: | 850 protected: |
| 851 IPDF_DataAvail(IFX_FileAvail* pFileAvail, IFX_FileRead* pFileRead); | 851 IPDF_DataAvail(IFX_FileAvail* pFileAvail, IFX_FileRead* pFileRead); |
| 852 | 852 |
| 853 IFX_FileAvail* m_pFileAvail; | 853 IFX_FileAvail* m_pFileAvail; |
| 854 IFX_FileRead* m_pFileRead; | 854 IFX_FileRead* m_pFileRead; |
| 855 }; | 855 }; |
| 856 class CPDF_SortObjNumArray | 856 class CPDF_SortObjNumArray |
| 857 { | 857 { |
| 858 public: | 858 public: |
| 859 | 859 |
| 860 void AddObjNum(FX_DWORD dwObjNum); | 860 void AddObjNum(FX_DWORD dwObjNum); |
| 861 | 861 |
| 862 FX_BOOL Find(FX_DWORD dwObjNum); | 862 bool Find(FX_DWORD dwObjNum); |
| 863 | 863 |
| 864 void RemoveAll() | 864 void RemoveAll() |
| 865 { | 865 { |
| 866 m_number_array.RemoveAll(); | 866 m_number_array.RemoveAll(); |
| 867 } | 867 } |
| 868 protected: | 868 protected: |
| 869 | 869 |
| 870 FX_BOOL BinarySearch(FX_DWORD value, int &iNext); | 870 bool BinarySearch(FX_DWORD value, int &iNext); |
| 871 protected: | 871 protected: |
| 872 | 872 |
| 873 CFX_DWordArray m_number_array; | 873 CFX_DWordArray m_number_array; |
| 874 }; | 874 }; |
| 875 enum PDF_PAGENODE_TYPE { | 875 enum PDF_PAGENODE_TYPE { |
| 876 PDF_PAGENODE_UNKOWN = 0, | 876 PDF_PAGENODE_UNKOWN = 0, |
| 877 PDF_PAGENODE_PAGE, | 877 PDF_PAGENODE_PAGE, |
| 878 PDF_PAGENODE_PAGES, | 878 PDF_PAGENODE_PAGES, |
| 879 PDF_PAGENODE_ARRAY, | 879 PDF_PAGENODE_ARRAY, |
| 880 }; | 880 }; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 905 PDF_DATAAVAIL_PAGE, | 905 PDF_DATAAVAIL_PAGE, |
| 906 PDF_DATAAVAIL_PAGE_LATERLOAD, | 906 PDF_DATAAVAIL_PAGE_LATERLOAD, |
| 907 PDF_DATAAVAIL_RESOURCES, | 907 PDF_DATAAVAIL_RESOURCES, |
| 908 PDF_DATAAVAIL_DONE, | 908 PDF_DATAAVAIL_DONE, |
| 909 PDF_DATAAVAIL_ERROR, | 909 PDF_DATAAVAIL_ERROR, |
| 910 PDF_DATAAVAIL_LOADALLFILE, | 910 PDF_DATAAVAIL_LOADALLFILE, |
| 911 PDF_DATAAVAIL_TRAILER_APPEND | 911 PDF_DATAAVAIL_TRAILER_APPEND |
| 912 }; | 912 }; |
| 913 | 913 |
| 914 #endif // CORE_INCLUDE_FPDFAPI_FPDF_PARSER_H_ | 914 #endif // CORE_INCLUDE_FPDFAPI_FPDF_PARSER_H_ |
| OLD | NEW |