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 #include <utility> | 7 #include <utility> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "../../../include/fpdfapi/fpdf_module.h" | 10 #include "../../../include/fpdfapi/fpdf_module.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 FX_DWORD dwSize = m_CrossRef.GetSize(); | 61 FX_DWORD dwSize = m_CrossRef.GetSize(); |
62 return dwSize ? dwSize - 1 : 0; | 62 return dwSize ? dwSize - 1 : 0; |
63 } | 63 } |
64 void CPDF_Parser::SetEncryptDictionary(CPDF_Dictionary* pDict) | 64 void CPDF_Parser::SetEncryptDictionary(CPDF_Dictionary* pDict) |
65 { | 65 { |
66 m_pEncryptDict = pDict; | 66 m_pEncryptDict = pDict; |
67 } | 67 } |
68 void CPDF_Parser::CloseParser(FX_BOOL bReParse) | 68 void CPDF_Parser::CloseParser(FX_BOOL bReParse) |
69 { | 69 { |
70 m_bVersionUpdated = FALSE; | 70 m_bVersionUpdated = FALSE; |
71 if (m_pDocument && !bReParse) { | 71 if (!bReParse) { |
72 delete m_pDocument; | 72 delete m_pDocument; |
73 m_pDocument = NULL; | 73 m_pDocument = NULL; |
74 } | 74 } |
75 if (m_pTrailer) { | 75 if (m_pTrailer) { |
76 m_pTrailer->Release(); | 76 m_pTrailer->Release(); |
77 m_pTrailer = NULL; | 77 m_pTrailer = NULL; |
78 } | 78 } |
79 ReleaseEncryptHandler(); | 79 ReleaseEncryptHandler(); |
80 SetEncryptDictionary(NULL); | 80 SetEncryptDictionary(NULL); |
81 if (m_bOwnFileRead && m_Syntax.m_pFileAccess) { | 81 if (m_bOwnFileRead && m_Syntax.m_pFileAccess) { |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 delete pCryptoHandler; | 302 delete pCryptoHandler; |
303 pCryptoHandler = NULL; | 303 pCryptoHandler = NULL; |
304 return PDFPARSE_ERROR_HANDLER; | 304 return PDFPARSE_ERROR_HANDLER; |
305 } | 305 } |
306 m_Syntax.SetEncrypt(pCryptoHandler); | 306 m_Syntax.SetEncrypt(pCryptoHandler); |
307 } | 307 } |
308 return PDFPARSE_ERROR_SUCCESS; | 308 return PDFPARSE_ERROR_SUCCESS; |
309 } | 309 } |
310 void CPDF_Parser::ReleaseEncryptHandler() | 310 void CPDF_Parser::ReleaseEncryptHandler() |
311 { | 311 { |
312 if (m_Syntax.m_pCryptoHandler) { | 312 delete m_Syntax.m_pCryptoHandler; |
313 delete m_Syntax.m_pCryptoHandler; | 313 m_Syntax.m_pCryptoHandler = NULL; |
314 m_Syntax.m_pCryptoHandler = NULL; | 314 if (!m_bForceUseSecurityHandler) { |
315 } | |
316 if (m_pSecurityHandler && !m_bForceUseSecurityHandler) { | |
317 delete m_pSecurityHandler; | 315 delete m_pSecurityHandler; |
318 m_pSecurityHandler = NULL; | 316 m_pSecurityHandler = NULL; |
319 } | 317 } |
320 } | 318 } |
321 FX_FILESIZE CPDF_Parser::GetObjectOffset(FX_DWORD objnum) | 319 FX_FILESIZE CPDF_Parser::GetObjectOffset(FX_DWORD objnum) |
322 { | 320 { |
323 if (objnum >= (FX_DWORD)m_CrossRef.GetSize()) { | 321 if (objnum >= (FX_DWORD)m_CrossRef.GetSize()) { |
324 return 0; | 322 return 0; |
325 } | 323 } |
326 if (m_V5Type[objnum] == 1) { | 324 if (m_V5Type[objnum] == 1) { |
(...skipping 1148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1475 } | 1473 } |
1476 return dwPermission; | 1474 return dwPermission; |
1477 } | 1475 } |
1478 FX_BOOL CPDF_Parser::IsOwner() | 1476 FX_BOOL CPDF_Parser::IsOwner() |
1479 { | 1477 { |
1480 return m_pSecurityHandler == NULL ? TRUE : m_pSecurityHandler->IsOwner(); | 1478 return m_pSecurityHandler == NULL ? TRUE : m_pSecurityHandler->IsOwner(); |
1481 } | 1479 } |
1482 void CPDF_Parser::SetSecurityHandler(CPDF_SecurityHandler* pSecurityHandler, FX_
BOOL bForced) | 1480 void CPDF_Parser::SetSecurityHandler(CPDF_SecurityHandler* pSecurityHandler, FX_
BOOL bForced) |
1483 { | 1481 { |
1484 ASSERT(m_pSecurityHandler == NULL); | 1482 ASSERT(m_pSecurityHandler == NULL); |
1485 if (m_pSecurityHandler && !m_bForceUseSecurityHandler) { | 1483 if (!m_bForceUseSecurityHandler) { |
1486 delete m_pSecurityHandler; | 1484 delete m_pSecurityHandler; |
1487 m_pSecurityHandler = NULL; | 1485 m_pSecurityHandler = NULL; |
1488 } | 1486 } |
1489 m_bForceUseSecurityHandler = bForced; | 1487 m_bForceUseSecurityHandler = bForced; |
1490 m_pSecurityHandler = pSecurityHandler; | 1488 m_pSecurityHandler = pSecurityHandler; |
1491 if (m_bForceUseSecurityHandler) { | 1489 if (m_bForceUseSecurityHandler) { |
1492 return; | 1490 return; |
1493 } | 1491 } |
1494 m_Syntax.m_pCryptoHandler = pSecurityHandler->CreateCryptoHandler(); | 1492 m_Syntax.m_pCryptoHandler = pSecurityHandler->CreateCryptoHandler(); |
1495 m_Syntax.m_pCryptoHandler->Init(NULL, pSecurityHandler); | 1493 m_Syntax.m_pCryptoHandler->Init(NULL, pSecurityHandler); |
(...skipping 1481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2977 { | 2975 { |
2978 if (m_pLinearized) { | 2976 if (m_pLinearized) { |
2979 m_pLinearized->Release(); | 2977 m_pLinearized->Release(); |
2980 } | 2978 } |
2981 if (m_pRoot) { | 2979 if (m_pRoot) { |
2982 m_pRoot->Release(); | 2980 m_pRoot->Release(); |
2983 } | 2981 } |
2984 if (m_pTrailer) { | 2982 if (m_pTrailer) { |
2985 m_pTrailer->Release(); | 2983 m_pTrailer->Release(); |
2986 } | 2984 } |
2987 if (m_pageMapCheckState) { | 2985 delete m_pageMapCheckState; |
2988 delete m_pageMapCheckState; | 2986 delete m_pagesLoadState; |
2989 } | |
2990 if (m_pagesLoadState) { | |
2991 delete m_pagesLoadState; | |
2992 } | |
2993 int32_t i = 0; | 2987 int32_t i = 0; |
2994 int32_t iSize = m_arrayAcroforms.GetSize(); | 2988 int32_t iSize = m_arrayAcroforms.GetSize(); |
2995 for (i = 0; i < iSize; ++i) { | 2989 for (i = 0; i < iSize; ++i) { |
2996 ((CPDF_Object *)m_arrayAcroforms.GetAt(i))->Release(); | 2990 ((CPDF_Object *)m_arrayAcroforms.GetAt(i))->Release(); |
2997 } | 2991 } |
2998 } | 2992 } |
2999 void CPDF_DataAvail::SetDocument(CPDF_Document* pDoc) | 2993 void CPDF_DataAvail::SetDocument(CPDF_Document* pDoc) |
3000 { | 2994 { |
3001 m_pDocument = pDoc; | 2995 m_pDocument = pDoc; |
3002 } | 2996 } |
(...skipping 1630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4633 iLow = iMid + 1; | 4627 iLow = iMid + 1; |
4634 } | 4628 } |
4635 } | 4629 } |
4636 iNext = iLow; | 4630 iNext = iLow; |
4637 return FALSE; | 4631 return FALSE; |
4638 } | 4632 } |
4639 CPDF_PageNode::~CPDF_PageNode() | 4633 CPDF_PageNode::~CPDF_PageNode() |
4640 { | 4634 { |
4641 int32_t iSize = m_childNode.GetSize(); | 4635 int32_t iSize = m_childNode.GetSize(); |
4642 for (int32_t i = 0; i < iSize; ++i) { | 4636 for (int32_t i = 0; i < iSize; ++i) { |
4643 CPDF_PageNode *pNode = (CPDF_PageNode*)m_childNode[i]; | 4637 CPDF_PageNode* pNode = (CPDF_PageNode*)m_childNode[i]; |
4644 if (pNode) { | 4638 delete pNode; |
4645 delete pNode; | |
4646 } | |
4647 } | 4639 } |
4648 m_childNode.RemoveAll(); | 4640 m_childNode.RemoveAll(); |
4649 } | 4641 } |
OLD | NEW |