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 "../../public/fpdf_flatten.h" | 7 #include "../../public/fpdf_flatten.h" |
8 #include "../include/fsdk_define.h" | 8 #include "../include/fsdk_define.h" |
9 | 9 |
10 typedef CFX_ArrayTemplate<CPDF_Dictionary*> CPDF_ObjectArray; | 10 typedef CFX_ArrayTemplate<CPDF_Dictionary*> CPDF_ObjectArray; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 if (!pSourceDoc || !pPageDic) | 87 if (!pSourceDoc || !pPageDic) |
88 return FLATTEN_FAIL; | 88 return FLATTEN_FAIL; |
89 | 89 |
90 GetContentsRect(pSourceDoc, pPageDic, pRectArray); | 90 GetContentsRect(pSourceDoc, pPageDic, pRectArray); |
91 CPDF_Array* pAnnots = pPageDic->GetArray("Annots"); | 91 CPDF_Array* pAnnots = pPageDic->GetArray("Annots"); |
92 if (!pAnnots) | 92 if (!pAnnots) |
93 return FLATTEN_NOTHINGTODO; | 93 return FLATTEN_NOTHINGTODO; |
94 | 94 |
95 FX_DWORD dwSize = pAnnots->GetCount(); | 95 FX_DWORD dwSize = pAnnots->GetCount(); |
96 for (int i = 0; i < (int)dwSize; i++) { | 96 for (int i = 0; i < (int)dwSize; i++) { |
97 CPDF_Object* pObj = pAnnots->GetElementValue(i); | 97 CPDF_Dictionary* pAnnotDic = ToDictionary(pAnnots->GetElementValue(i)); |
98 if (!pObj || pObj->GetType() != PDFOBJ_DICTIONARY) | 98 if (!pAnnotDic) |
99 continue; | 99 continue; |
100 | 100 |
101 CPDF_Dictionary* pAnnotDic = (CPDF_Dictionary*)pObj; | |
102 CFX_ByteString sSubtype = pAnnotDic->GetString("Subtype"); | 101 CFX_ByteString sSubtype = pAnnotDic->GetString("Subtype"); |
103 if (sSubtype == "Popup") | 102 if (sSubtype == "Popup") |
104 continue; | 103 continue; |
105 | 104 |
106 int nAnnotFlag = pAnnotDic->GetInteger("F"); | 105 int nAnnotFlag = pAnnotDic->GetInteger("F"); |
107 if (nAnnotFlag & ANNOTFLAG_HIDDEN) | 106 if (nAnnotFlag & ANNOTFLAG_HIDDEN) |
108 continue; | 107 continue; |
109 | 108 |
110 if (nUsage == FLAT_NORMALDISPLAY) { | 109 if (nUsage == FLAT_NORMALDISPLAY) { |
111 if (nAnnotFlag & ANNOTFLAG_INVISIBLE) | 110 if (nAnnotFlag & ANNOTFLAG_INVISIBLE) |
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
517 pNewXObject->SetData((const uint8_t*)sStream, sStream.GetLength(), FALSE, | 516 pNewXObject->SetData((const uint8_t*)sStream, sStream.GetLength(), FALSE, |
518 FALSE); | 517 FALSE); |
519 } | 518 } |
520 pPageDict->RemoveAt("Annots"); | 519 pPageDict->RemoveAt("Annots"); |
521 | 520 |
522 ObjectArray.RemoveAll(); | 521 ObjectArray.RemoveAll(); |
523 RectArray.RemoveAll(); | 522 RectArray.RemoveAll(); |
524 | 523 |
525 return FLATTEN_SUCCESS; | 524 return FLATTEN_SUCCESS; |
526 } | 525 } |
OLD | NEW |