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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 | 79 |
80 if (IsValiableRect(rect, pPageDic->GetRect("MediaBox"))) | 80 if (IsValiableRect(rect, pPageDic->GetRect("MediaBox"))) |
81 pRectArray->Add(rect); | 81 pRectArray->Add(rect); |
82 | 82 |
83 pObjectArray->Add(pStream); | 83 pObjectArray->Add(pStream); |
84 } | 84 } |
85 | 85 |
86 | 86 |
87 int ParserAnnots( CPDF_Document* pSourceDoc, CPDF_Dictionary * pPageDic, CPDF_Re
ctArray * pRectArray, CPDF_ObjectArray * pObjectArray, int nUsage) | 87 int ParserAnnots( CPDF_Document* pSourceDoc, CPDF_Dictionary * pPageDic, CPDF_Re
ctArray * pRectArray, CPDF_ObjectArray * pObjectArray, int nUsage) |
88 { | 88 { |
89 » if (!pSourceDoc || !pPageDic) return FLATTEN_FAIL; | 89 if (!pSourceDoc || !pPageDic) |
90 » | 90 return FLATTEN_FAIL; |
91 » GetContentsRect( pSourceDoc, pPageDic, pRectArray ); | |
92 » CPDF_Array* pAnnots = pPageDic->GetArray("Annots"); | |
93 » if (pAnnots) | |
94 » { | |
95 » » FX_DWORD dwSize = pAnnots->GetCount(); | |
96 » » | |
97 » » for (int i = 0; i < (int)dwSize; i++) | |
98 » » { | |
99 » » » CPDF_Object* pObj = pAnnots->GetElementValue(i); | |
100 » » » | |
101 » » » if (!pObj)continue; | |
102 » » » | |
103 » » » if (pObj->GetType() == PDFOBJ_DICTIONARY) | |
104 » » » { | |
105 » » » » CPDF_Dictionary* pAnnotDic = (CPDF_Dictionary*)p
Obj; | |
106 » » » » CFX_ByteString sSubtype = pAnnotDic->GetString("
Subtype"); | |
107 » » » » if (sSubtype == "Popup")continue; | |
108 | 91 |
109 » » » » int nAnnotFlag = pAnnotDic->GetInteger("F"); | 92 GetContentsRect( pSourceDoc, pPageDic, pRectArray ); |
| 93 CPDF_Array* pAnnots = pPageDic->GetArray("Annots"); |
| 94 if (!pAnnots) |
| 95 return FLATTEN_NOTHINGTODO; |
110 | 96 |
111 » » » » if(nAnnotFlag & ANNOTFLAG_HIDDEN) | 97 FX_DWORD dwSize = pAnnots->GetCount(); |
112 » » » » » continue; | 98 for (int i = 0; i < (int)dwSize; i++) |
113 » » » » if(nUsage == FLAT_NORMALDISPLAY) | 99 { |
114 » » » » { | 100 CPDF_Object* pObj = pAnnots->GetElementValue(i); |
115 » » » » » if(nAnnotFlag & ANNOTFLAG_INVISIBLE) | 101 if (!pObj || pObj->GetType() != PDFOBJ_DICTIONARY) |
116 » » » » » » continue; | 102 continue; |
117 » » » » » ParserStream( pPageDic, pAnnotDic, pRect
Array, pObjectArray );» » | 103 |
118 » » » » } | 104 CPDF_Dictionary* pAnnotDic = (CPDF_Dictionary*)pObj; |
119 » » » » else | 105 CFX_ByteString sSubtype = pAnnotDic->GetString("Subtype"); |
120 » » » » { | 106 if (sSubtype == "Popup") |
121 » » » » » if(nAnnotFlag & ANNOTFLAG_PRINT) | 107 continue; |
122 » » » » » » ParserStream( pPageDic, pAnnotDi
c, pRectArray, pObjectArray ); | 108 |
123 » » » » }» » » | 109 int nAnnotFlag = pAnnotDic->GetInteger("F"); |
124 » » » } | 110 if (nAnnotFlag & ANNOTFLAG_HIDDEN) |
125 » » } | 111 continue; |
126 » » return FLATTEN_SUCCESS; | 112 |
127 » }else{ | 113 if(nUsage == FLAT_NORMALDISPLAY) |
128 » » return FLATTEN_NOTINGTODO; | 114 { |
129 » } | 115 if (nAnnotFlag & ANNOTFLAG_INVISIBLE) |
| 116 continue; |
| 117 |
| 118 ParserStream( pPageDic, pAnnotDic, pRectArray, pObjectArray ); |
| 119 } |
| 120 else |
| 121 { |
| 122 if (nAnnotFlag & ANNOTFLAG_PRINT) |
| 123 ParserStream( pPageDic, pAnnotDic, pRectArray, pObjectArray ); |
| 124 } |
| 125 } |
| 126 return FLATTEN_SUCCESS; |
130 } | 127 } |
131 | 128 |
132 | 129 |
133 FX_FLOAT GetMinMaxValue( CPDF_RectArray& array, FPDF_TYPE type, FPDF_VALUE value
) | 130 FX_FLOAT GetMinMaxValue( CPDF_RectArray& array, FPDF_TYPE type, FPDF_VALUE value
) |
134 { | 131 { |
135 int nRects = array.GetSize(); | 132 int nRects = array.GetSize(); |
136 FX_FLOAT fRet = 0.0f; | 133 FX_FLOAT fRet = 0.0f; |
137 | 134 |
138 if (nRects <= 0)return 0.0f; | 135 if (nRects <= 0)return 0.0f; |
139 | 136 |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 if ( !pDocument || !pPageDict ) | 335 if ( !pDocument || !pPageDict ) |
339 { | 336 { |
340 return FLATTEN_FAIL; | 337 return FLATTEN_FAIL; |
341 } | 338 } |
342 | 339 |
343 CPDF_ObjectArray ObjectArray; | 340 CPDF_ObjectArray ObjectArray; |
344 CPDF_RectArray RectArray; | 341 CPDF_RectArray RectArray; |
345 | 342 |
346 int iRet = FLATTEN_FAIL; | 343 int iRet = FLATTEN_FAIL; |
347 iRet = ParserAnnots( pDocument, pPageDict, &RectArray, &ObjectArray, nFl
ag); | 344 iRet = ParserAnnots( pDocument, pPageDict, &RectArray, &ObjectArray, nFl
ag); |
348 » if (iRet == FLATTEN_NOTINGTODO) | 345 » if (iRet == FLATTEN_NOTHINGTODO || iRet == FLATTEN_FAIL) |
349 » { | 346 » » return iRet; |
350 » » return FLATTEN_NOTINGTODO; | 347 |
351 » }else if (iRet == FLATTEN_FAIL) | |
352 » { | |
353 » » return FLATTEN_FAIL; | |
354 » } | |
355 » | |
356 CPDF_Rect rcOriginalCB; | 348 CPDF_Rect rcOriginalCB; |
357 CPDF_Rect rcMerger = CalculateRect( &RectArray ); | 349 CPDF_Rect rcMerger = CalculateRect( &RectArray ); |
358 CPDF_Rect rcOriginalMB = pPageDict->GetRect("MediaBox"); | 350 CPDF_Rect rcOriginalMB = pPageDict->GetRect("MediaBox"); |
359 | 351 |
360 if (pPageDict->KeyExist("CropBox")) | 352 if (pPageDict->KeyExist("CropBox")) |
361 rcOriginalMB = pPageDict->GetRect("CropBox"); | 353 rcOriginalMB = pPageDict->GetRect("CropBox"); |
362 | 354 |
363 if (rcOriginalMB.IsEmpty()) | 355 if (rcOriginalMB.IsEmpty()) |
364 { | 356 { |
365 rcOriginalMB = CPDF_Rect(0.0f, 0.0f, 612.0f, 792.0f); | 357 rcOriginalMB = CPDF_Rect(0.0f, 0.0f, 612.0f, 792.0f); |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 | 540 |
549 pNewXObject->SetData((FX_LPCBYTE)sStream, sStream.GetLength(), F
ALSE, FALSE); | 541 pNewXObject->SetData((FX_LPCBYTE)sStream, sStream.GetLength(), F
ALSE, FALSE); |
550 } | 542 } |
551 pPageDict->RemoveAt( "Annots" ); | 543 pPageDict->RemoveAt( "Annots" ); |
552 | 544 |
553 ObjectArray.RemoveAll(); | 545 ObjectArray.RemoveAll(); |
554 RectArray.RemoveAll(); | 546 RectArray.RemoveAll(); |
555 | 547 |
556 return FLATTEN_SUCCESS; | 548 return FLATTEN_SUCCESS; |
557 } | 549 } |
OLD | NEW |