Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(275)

Side by Side Diff: fpdfsdk/src/fpdf_flatten.cpp

Issue 1144973004: Merge to XFA: Tidy public fpdfview.h and fpdf_flatten.h. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | public/fpdf_flatten.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "../include/fpdfxfa/fpdfxfa_doc.h" 9 #include "../include/fpdfxfa/fpdfxfa_doc.h"
10 #include "../include/fpdfxfa/fpdfxfa_page.h" 10 #include "../include/fpdfxfa/fpdfxfa_page.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 81
82 if (IsValiableRect(rect, pPageDic->GetRect("MediaBox"))) 82 if (IsValiableRect(rect, pPageDic->GetRect("MediaBox")))
83 pRectArray->Add(rect); 83 pRectArray->Add(rect);
84 84
85 pObjectArray->Add(pStream); 85 pObjectArray->Add(pStream);
86 } 86 }
87 87
88 88
89 int ParserAnnots( CPDF_Document* pSourceDoc, CPDF_Dictionary * pPageDic, CPDF_Re ctArray * pRectArray, CPDF_ObjectArray * pObjectArray, int nUsage) 89 int ParserAnnots( CPDF_Document* pSourceDoc, CPDF_Dictionary * pPageDic, CPDF_Re ctArray * pRectArray, CPDF_ObjectArray * pObjectArray, int nUsage)
90 { 90 {
91 » if (!pSourceDoc || !pPageDic) return FLATTEN_FAIL; 91 if (!pSourceDoc || !pPageDic)
92 » 92 return FLATTEN_FAIL;
93 » GetContentsRect( pSourceDoc, pPageDic, pRectArray );
94 » CPDF_Array* pAnnots = pPageDic->GetArray("Annots");
95 » if (pAnnots)
96 » {
97 » » FX_DWORD dwSize = pAnnots->GetCount();
98 » »
99 » » for (int i = 0; i < (int)dwSize; i++)
100 » » {
101 » » » CPDF_Object* pObj = pAnnots->GetElementValue(i);
102 » » »
103 » » » if (!pObj)continue;
104 » » »
105 » » » if (pObj->GetType() == PDFOBJ_DICTIONARY)
106 » » » {
107 » » » » CPDF_Dictionary* pAnnotDic = (CPDF_Dictionary*)p Obj;
108 » » » » CFX_ByteString sSubtype = pAnnotDic->GetString(" Subtype");
109 » » » » if (sSubtype == "Popup")continue;
110 93
111 » » » » int nAnnotFlag = pAnnotDic->GetInteger("F"); 94 GetContentsRect( pSourceDoc, pPageDic, pRectArray );
95 CPDF_Array* pAnnots = pPageDic->GetArray("Annots");
96 if (!pAnnots)
97 return FLATTEN_NOTHINGTODO;
112 98
113 » » » » if(nAnnotFlag & ANNOTFLAG_HIDDEN) 99 FX_DWORD dwSize = pAnnots->GetCount();
114 » » » » » continue; 100 for (int i = 0; i < (int)dwSize; i++)
115 » » » » if(nUsage == FLAT_NORMALDISPLAY) 101 {
116 » » » » { 102 CPDF_Object* pObj = pAnnots->GetElementValue(i);
117 » » » » » if(nAnnotFlag & ANNOTFLAG_INVISIBLE) 103 if (!pObj || pObj->GetType() != PDFOBJ_DICTIONARY)
118 » » » » » » continue; 104 continue;
119 » » » » » ParserStream( pPageDic, pAnnotDic, pRect Array, pObjectArray );» » 105
120 » » » » } 106 CPDF_Dictionary* pAnnotDic = (CPDF_Dictionary*)pObj;
121 » » » » else 107 CFX_ByteString sSubtype = pAnnotDic->GetString("Subtype");
122 » » » » { 108 if (sSubtype == "Popup")
123 » » » » » if(nAnnotFlag & ANNOTFLAG_PRINT) 109 continue;
124 » » » » » » ParserStream( pPageDic, pAnnotDi c, pRectArray, pObjectArray ); 110
125 » » » » }» » » 111 int nAnnotFlag = pAnnotDic->GetInteger("F");
126 » » » } 112 if (nAnnotFlag & ANNOTFLAG_HIDDEN)
127 » » } 113 continue;
128 » » return FLATTEN_SUCCESS; 114
129 » }else{ 115 if(nUsage == FLAT_NORMALDISPLAY)
130 » » return FLATTEN_NOTINGTODO; 116 {
131 » } 117 if (nAnnotFlag & ANNOTFLAG_INVISIBLE)
118 continue;
119
120 ParserStream( pPageDic, pAnnotDic, pRectArray, pObjectArray );
121 }
122 else
123 {
124 if (nAnnotFlag & ANNOTFLAG_PRINT)
125 ParserStream( pPageDic, pAnnotDic, pRectArray, pObjectArray );
126 }
127 }
128 return FLATTEN_SUCCESS;
132 } 129 }
133 130
134 131
135 FX_FLOAT GetMinMaxValue( CPDF_RectArray& array, FPDF_TYPE type, FPDF_VALUE value ) 132 FX_FLOAT GetMinMaxValue( CPDF_RectArray& array, FPDF_TYPE type, FPDF_VALUE value )
136 { 133 {
137 int nRects = array.GetSize(); 134 int nRects = array.GetSize();
138 FX_FLOAT fRet = 0.0f; 135 FX_FLOAT fRet = 0.0f;
139 136
140 if (nRects <= 0)return 0.0f; 137 if (nRects <= 0)return 0.0f;
141 138
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 if ( !pDocument || !pPageDict ) 341 if ( !pDocument || !pPageDict )
345 { 342 {
346 return FLATTEN_FAIL; 343 return FLATTEN_FAIL;
347 } 344 }
348 345
349 CPDF_ObjectArray ObjectArray; 346 CPDF_ObjectArray ObjectArray;
350 CPDF_RectArray RectArray; 347 CPDF_RectArray RectArray;
351 348
352 int iRet = FLATTEN_FAIL; 349 int iRet = FLATTEN_FAIL;
353 iRet = ParserAnnots( pDocument, pPageDict, &RectArray, &ObjectArray, nFl ag); 350 iRet = ParserAnnots( pDocument, pPageDict, &RectArray, &ObjectArray, nFl ag);
354 » if (iRet == FLATTEN_NOTINGTODO) 351 » if (iRet == FLATTEN_NOTHINGTODO || iRet == FLATTEN_FAIL)
355 » { 352 » » return iRet;
356 » » return FLATTEN_NOTINGTODO; 353
357 » }else if (iRet == FLATTEN_FAIL)
358 » {
359 » » return FLATTEN_FAIL;
360 » }
361 »
362 CPDF_Rect rcOriginalCB; 354 CPDF_Rect rcOriginalCB;
363 CPDF_Rect rcMerger = CalculateRect( &RectArray ); 355 CPDF_Rect rcMerger = CalculateRect( &RectArray );
364 CPDF_Rect rcOriginalMB = pPageDict->GetRect("MediaBox"); 356 CPDF_Rect rcOriginalMB = pPageDict->GetRect("MediaBox");
365 357
366 if (pPageDict->KeyExist("CropBox")) 358 if (pPageDict->KeyExist("CropBox"))
367 rcOriginalMB = pPageDict->GetRect("CropBox"); 359 rcOriginalMB = pPageDict->GetRect("CropBox");
368 360
369 if (rcOriginalMB.IsEmpty()) 361 if (rcOriginalMB.IsEmpty())
370 { 362 {
371 rcOriginalMB = CPDF_Rect(0.0f, 0.0f, 612.0f, 792.0f); 363 rcOriginalMB = CPDF_Rect(0.0f, 0.0f, 612.0f, 792.0f);
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 549
558 pNewXObject->SetData((FX_LPCBYTE)sStream, sStream.GetLength(), F ALSE, FALSE); 550 pNewXObject->SetData((FX_LPCBYTE)sStream, sStream.GetLength(), F ALSE, FALSE);
559 } 551 }
560 pPageDict->RemoveAt( "Annots" ); 552 pPageDict->RemoveAt( "Annots" );
561 553
562 ObjectArray.RemoveAll(); 554 ObjectArray.RemoveAll();
563 RectArray.RemoveAll(); 555 RectArray.RemoveAll();
564 556
565 return FLATTEN_SUCCESS; 557 return FLATTEN_SUCCESS;
566 } 558 }
OLDNEW
« no previous file with comments | « no previous file | public/fpdf_flatten.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698