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

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

Issue 1239313005: Merge to XFA - else after returns. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Fix issues. Created 5 years, 5 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 | « fpdfsdk/src/fpdfppo.cpp ('k') | fpdfsdk/src/fsdk_annothandler.cpp » ('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_edit.h" 7 #include "../../public/fpdf_edit.h"
8 #include "../../public/fpdf_formfill.h" 8 #include "../../public/fpdf_formfill.h"
9 #include "../../public/fpdf_save.h" 9 #include "../../public/fpdf_save.h"
10 #include "../include/fsdk_define.h" 10 #include "../include/fsdk_define.h"
11 #include "../include/fpdfxfa/fpdfxfa_doc.h" 11 #include "../include/fpdfxfa/fpdfxfa_doc.h"
12 #include "../include/fpdfxfa/fpdfxfa_app.h" 12 #include "../include/fpdfxfa/fpdfxfa_app.h"
13 #include "../include/fpdfxfa/fpdfxfa_util.h" 13 #include "../include/fpdfxfa/fpdfxfa_util.h"
14 14
15 #if _FX_OS_ == _FX_ANDROID_ 15 #if _FX_OS_ == _FX_ANDROID_
16 #include "time.h" 16 #include "time.h"
17 #else 17 #else
18 #include <ctime> 18 #include <ctime>
19 #endif 19 #endif
20 20
21 class CFX_IFileWrite final : public IFX_StreamWrite 21 class CFX_IFileWrite final : public IFX_StreamWrite
22 { 22 {
23 23
24 public: 24 public:
25 » CFX_IFileWrite(); 25 CFX_IFileWrite();
26 » FX_BOOL»» » » Init( FPDF_FILEWRITE * pFileWriteStruct ); 26 FX_BOOL Init( FPDF_FILEWRITE * pFileWriteStruct );
27 » virtual»FX_BOOL»» WriteBlock(const void* pData, size_t size) overr ide; 27 virtual FX_BOOL WriteBlock(const void* pData, size_t size) override;
28 » virtual void» » Release() override {} 28 virtual void Release() override {}
29 29
30 protected: 30 protected:
31 » FPDF_FILEWRITE*»» m_pFileWriteStruct; 31 FPDF_FILEWRITE* m_pFileWriteStruct;
32 }; 32 };
33 33
34 CFX_IFileWrite::CFX_IFileWrite() 34 CFX_IFileWrite::CFX_IFileWrite()
35 { 35 {
36 » m_pFileWriteStruct = NULL; 36 m_pFileWriteStruct = NULL;
37 } 37 }
38 38
39 FX_BOOL CFX_IFileWrite::Init( FPDF_FILEWRITE * pFileWriteStruct ) 39 FX_BOOL CFX_IFileWrite::Init( FPDF_FILEWRITE * pFileWriteStruct )
40 { 40 {
41 » if (!pFileWriteStruct) 41 if (!pFileWriteStruct)
42 » » return FALSE; 42 return FALSE;
43 » else 43
44 » { 44 m_pFileWriteStruct = pFileWriteStruct;
45 » » m_pFileWriteStruct = pFileWriteStruct; 45 return TRUE;
46 » }
47 » return TRUE;
48 } 46 }
49 47
50 FX_BOOL CFX_IFileWrite::WriteBlock(const void* pData, size_t size) 48 FX_BOOL CFX_IFileWrite::WriteBlock(const void* pData, size_t size)
51 { 49 {
52 » if (m_pFileWriteStruct) 50 if (!m_pFileWriteStruct)
53 » { 51 return FALSE;
54 » » m_pFileWriteStruct->WriteBlock( m_pFileWriteStruct, pData, size ); 52
55 » » return TRUE; 53 m_pFileWriteStruct->WriteBlock( m_pFileWriteStruct, pData, size );
56 » } 54 return TRUE;
57 » else
58 » » return FALSE;
59 } 55 }
60 56
61 #define XFA_DATASETS 0 57 #define XFA_DATASETS 0
62 #define XFA_FORMS 1 58 #define XFA_FORMS 1
63 59
64 FX_BOOL _SaveXFADocumentData(CPDFXFA_Document* pDocument, CFX_PtrArray& fileList ) 60 FX_BOOL _SaveXFADocumentData(CPDFXFA_Document* pDocument, CFX_PtrArray& fileList )
65 { 61 {
66 » if (!pDocument) 62 if (!pDocument)
67 » » return FALSE; 63 return FALSE;
68 » if (pDocument->GetDocType() != DOCTYPE_DYNIMIC_XFA && pDocument->GetDocT ype() != DOCTYPE_STATIC_XFA) 64 if (pDocument->GetDocType() != DOCTYPE_DYNIMIC_XFA && pDocument->GetDocType( ) != DOCTYPE_STATIC_XFA)
69 » » return TRUE; 65 return TRUE;
70 » if (!CPDFXFA_App::GetInstance()->GetXFAApp()) 66 if (!CPDFXFA_App::GetInstance()->GetXFAApp())
71 » » return TRUE; 67 return TRUE;
72 68
73 » IXFA_DocView* pXFADocView = pDocument->GetXFADocView(); 69 IXFA_DocView* pXFADocView = pDocument->GetXFADocView();
74 » if (NULL == pXFADocView) 70 if (NULL == pXFADocView)
75 » » return TRUE; 71 return TRUE;
76 72
77 » IXFA_DocHandler *pXFADocHandler = CPDFXFA_App::GetInstance()->GetXFAApp( )->GetDocHandler(); 73 IXFA_DocHandler *pXFADocHandler = CPDFXFA_App::GetInstance()->GetXFAApp()->G etDocHandler();
78 » CPDF_Document * pPDFDocument = pDocument->GetPDFDoc(); 74 CPDF_Document * pPDFDocument = pDocument->GetPDFDoc();
79 » if (pDocument == NULL) 75 if (pDocument == NULL)
80 » » return FALSE; 76 return FALSE;
81 77
82 » CPDF_Dictionary* pRoot = pPDFDocument->GetRoot(); 78 CPDF_Dictionary* pRoot = pPDFDocument->GetRoot();
83 » if (pRoot == NULL) 79 if (pRoot == NULL)
84 » » return FALSE; 80 return FALSE;
85 » CPDF_Dictionary* pAcroForm = pRoot->GetDict("AcroForm"); 81 CPDF_Dictionary* pAcroForm = pRoot->GetDict("AcroForm");
86 » if (NULL == pAcroForm) 82 if (NULL == pAcroForm)
87 » » return FALSE; 83 return FALSE;
88 » CPDF_Object* pXFA = pAcroForm->GetElement("XFA"); 84 CPDF_Object* pXFA = pAcroForm->GetElement("XFA");
89 » if (pXFA == NULL) 85 if (pXFA == NULL)
90 » » return TRUE; 86 return TRUE;
91 » if(pXFA->GetType() != PDFOBJ_ARRAY) 87 if(pXFA->GetType() != PDFOBJ_ARRAY)
92 » » return FALSE; 88 return FALSE;
93 » CPDF_Array* pArray = pXFA->GetArray(); 89 CPDF_Array* pArray = pXFA->GetArray();
94 » if (NULL == pArray) 90 if (NULL == pArray)
95 » » return FALSE; 91 return FALSE;
96 » int size = pArray->GetCount(); 92 int size = pArray->GetCount();
97 » int iFormIndex = -1; 93 int iFormIndex = -1;
98 » int iDataSetsIndex = -1; 94 int iDataSetsIndex = -1;
99 » int iTemplate = -1; 95 int iTemplate = -1;
100 » int iLast = size - 2; 96 int iLast = size - 2;
101 » for (int i = 0; i < size - 1; i++) 97 for (int i = 0; i < size - 1; i++)
102 » { 98 {
103 » » CPDF_Object* pPDFObj = pArray->GetElement(i); 99 CPDF_Object* pPDFObj = pArray->GetElement(i);
104 » » if (pPDFObj->GetType() != PDFOBJ_STRING) 100 if (pPDFObj->GetType() != PDFOBJ_STRING)
105 » » » continue; 101 continue;
106 » » if (pPDFObj->GetString() == "form") 102 if (pPDFObj->GetString() == "form")
107 » » » iFormIndex = i+1; 103 iFormIndex = i+1;
108 » » else if (pPDFObj->GetString() == "datasets") 104 else if (pPDFObj->GetString() == "datasets")
109 » » » iDataSetsIndex = i+1; 105 iDataSetsIndex = i+1;
110 » » else if (pPDFObj->GetString() == FX_BSTRC("template")) 106 else if (pPDFObj->GetString() == FX_BSTRC("template"))
111 » » » iTemplate = i + 1; 107 iTemplate = i + 1;
112 » } 108 }
113 » IXFA_ChecksumContext* pContext = NULL; 109 IXFA_ChecksumContext* pContext = NULL;
114 #define XFA_USECKSUM 110 #define XFA_USECKSUM
115 #ifdef XFA_USECKSUM 111 #ifdef XFA_USECKSUM
116 » //Checksum 112 //Checksum
117 » pContext = XFA_Checksum_Create(); 113 pContext = XFA_Checksum_Create();
118 » FXSYS_assert(pContext); 114 FXSYS_assert(pContext);
119 » pContext->StartChecksum(); 115 pContext->StartChecksum();
120 116
121 » //template 117 //template
122 » if (iTemplate > -1) 118 if (iTemplate > -1)
123 » { 119 {
124 » » CPDF_Stream *pTemplateStream = pArray->GetStream(iTemplate); 120 CPDF_Stream *pTemplateStream = pArray->GetStream(iTemplate);
125 » » CPDF_StreamAcc streamAcc; 121 CPDF_StreamAcc streamAcc;
126 » » streamAcc.LoadAllData(pTemplateStream); 122 streamAcc.LoadAllData(pTemplateStream);
127 » » uint8_t* pData = (uint8_t*)streamAcc.GetData(); 123 uint8_t* pData = (uint8_t*)streamAcc.GetData();
128 » » FX_DWORD dwSize2 = streamAcc.GetSize(); 124 FX_DWORD dwSize2 = streamAcc.GetSize();
129 » » IFX_FileStream *pTemplate = FX_CreateMemoryStream(pData, dwSize2 ); 125 IFX_FileStream *pTemplate = FX_CreateMemoryStream(pData, dwSize2);
130 » » pContext->UpdateChecksum((IFX_FileRead*)pTemplate); 126 pContext->UpdateChecksum((IFX_FileRead*)pTemplate);
131 » » pTemplate->Release(); 127 pTemplate->Release();
132 » } 128 }
133 #endif 129 #endif
134 » CPDF_Stream* pFormStream = NULL; 130 CPDF_Stream* pFormStream = NULL;
135 » CPDF_Stream* pDataSetsStream = NULL; 131 CPDF_Stream* pDataSetsStream = NULL;
136 » if (iFormIndex != -1) 132 if (iFormIndex != -1)
137 » { 133 {
138 » » //Get form CPDF_Stream 134 //Get form CPDF_Stream
139 » » CPDF_Object* pFormPDFObj = pArray->GetElement(iFormIndex); 135 CPDF_Object* pFormPDFObj = pArray->GetElement(iFormIndex);
140 » » if (pFormPDFObj->GetType() == PDFOBJ_REFERENCE) 136 if (pFormPDFObj->GetType() == PDFOBJ_REFERENCE)
141 » » { 137 {
142 » » » CPDF_Reference* pFormRefObj = (CPDF_Reference*)pFormPDFO bj; 138 CPDF_Reference* pFormRefObj = (CPDF_Reference*)pFormPDFObj;
143 » » » CPDF_Object* pFormDircetObj = pFormPDFObj->GetDirect(); 139 CPDF_Object* pFormDircetObj = pFormPDFObj->GetDirect();
144 » » » if (NULL != pFormDircetObj && pFormDircetObj->GetType() == PDFOBJ_STREAM) 140 if (NULL != pFormDircetObj && pFormDircetObj->GetType() == PDFOBJ_ST REAM)
145 » » » { 141 {
146 » » » » pFormStream = (CPDF_Stream*)pFormDircetObj; 142 pFormStream = (CPDF_Stream*)pFormDircetObj;
147 » » » } 143 }
148 » » } 144 }
149 » » else if (pFormPDFObj->GetType() == PDFOBJ_STREAM) 145 else if (pFormPDFObj->GetType() == PDFOBJ_STREAM)
150 » » { 146 {
151 » » » pFormStream = (CPDF_Stream*)pFormPDFObj; 147 pFormStream = (CPDF_Stream*)pFormPDFObj;
152 » » } 148 }
153 » } 149 }
154 150
155 » if (iDataSetsIndex != -1) 151 if (iDataSetsIndex != -1)
156 » { 152 {
157 » » //Get datasets CPDF_Stream 153 //Get datasets CPDF_Stream
158 » » CPDF_Object* pDataSetsPDFObj = pArray->GetElement(iDataSetsIndex ); 154 CPDF_Object* pDataSetsPDFObj = pArray->GetElement(iDataSetsIndex);
159 » » if (pDataSetsPDFObj->GetType() == PDFOBJ_REFERENCE) 155 if (pDataSetsPDFObj->GetType() == PDFOBJ_REFERENCE)
160 » » { 156 {
161 » » » CPDF_Reference* pDataSetsRefObj = (CPDF_Reference*)pData SetsPDFObj; 157 CPDF_Reference* pDataSetsRefObj = (CPDF_Reference*)pDataSetsPDFObj;
162 » » » CPDF_Object* pDataSetsDircetObj = pDataSetsRefObj->GetDi rect(); 158 CPDF_Object* pDataSetsDircetObj = pDataSetsRefObj->GetDirect();
163 » » » if (NULL != pDataSetsDircetObj && pDataSetsDircetObj->Ge tType() == PDFOBJ_STREAM) 159 if (NULL != pDataSetsDircetObj && pDataSetsDircetObj->GetType() == P DFOBJ_STREAM)
164 » » » { 160 {
165 » » » » pDataSetsStream = (CPDF_Stream*)pDataSetsDircetO bj; 161 pDataSetsStream = (CPDF_Stream*)pDataSetsDircetObj;
166 » » » } 162 }
167 » » } 163 }
168 » » else if (pDataSetsPDFObj->GetType() == PDFOBJ_STREAM) 164 else if (pDataSetsPDFObj->GetType() == PDFOBJ_STREAM)
169 » » { 165 {
170 » » » pDataSetsStream = (CPDF_Stream*)pDataSetsPDFObj; 166 pDataSetsStream = (CPDF_Stream*)pDataSetsPDFObj;
171 » » } 167 }
172 » } 168 }
173 » //end 169 //end
174 » //L"datasets" 170 //L"datasets"
175 » { 171 {
176 » » IFX_FileStream* pDsfileWrite = FX_CreateMemoryStream(); 172 IFX_FileStream* pDsfileWrite = FX_CreateMemoryStream();
177 » » if ( NULL == pDsfileWrite ) 173 if ( NULL == pDsfileWrite )
178 » » { 174 {
179 » » » pContext->Release(); 175 pContext->Release();
180 » » » pDsfileWrite->Release(); 176 pDsfileWrite->Release();
181 » » » return FALSE; 177 return FALSE;
182 » » } 178 }
183 » » if (pXFADocHandler->SavePackage(pXFADocView->GetDoc(), CFX_WideS tringC(L"datasets"), pDsfileWrite) && pDsfileWrite->GetSize()>0) 179 if (pXFADocHandler->SavePackage(pXFADocView->GetDoc(), CFX_WideStringC(L "datasets"), pDsfileWrite) && pDsfileWrite->GetSize()>0)
184 » » { 180 {
185 #ifdef XFA_USECKSUM 181 #ifdef XFA_USECKSUM
186 » » //Datasets 182 //Datasets
187 » » pContext->UpdateChecksum((IFX_FileRead*)pDsfileWrite); 183 pContext->UpdateChecksum((IFX_FileRead*)pDsfileWrite);
188 » » pContext->FinishChecksum(); 184 pContext->FinishChecksum();
189 #endif 185 #endif
190 » » » CPDF_Dictionary* pDataDict = FX_NEW CPDF_Dictionary; 186 CPDF_Dictionary* pDataDict = FX_NEW CPDF_Dictionary;
191 » » » if (iDataSetsIndex != -1) 187 if (iDataSetsIndex != -1)
192 » » » { 188 {
193 » » » » if (pDataSetsStream) 189 if (pDataSetsStream)
194 » » » » » pDataSetsStream->InitStream(pDsfileWrite , pDataDict); 190 pDataSetsStream->InitStream(pDsfileWrite, pDataDict);
195 » » » } 191 }
196 » » » else 192 else
197 » » » { 193 {
198 » » » » CPDF_Stream* pData = FX_NEW CPDF_Stream(NULL, 0, NULL); 194 CPDF_Stream* pData = FX_NEW CPDF_Stream(NULL, 0, NULL);
199 » » » » pData->InitStream(pDsfileWrite, pDataDict); 195 pData->InitStream(pDsfileWrite, pDataDict);
200 » » » » FX_DWORD AppStreamobjnum = pPDFDocument->AddIndi rectObject(pData); 196 FX_DWORD AppStreamobjnum = pPDFDocument->AddIndirectObject(pData );
201 » » » » CPDF_Reference* pRef = (CPDF_Reference*)pPDFDocu ment->GetIndirectObject(AppStreamobjnum); 197 CPDF_Reference* pRef = (CPDF_Reference*)pPDFDocument->GetIndirec tObject(AppStreamobjnum);
202 » » » » { 198 {
203 » » » » » iLast = pArray->GetCount() -2; 199 iLast = pArray->GetCount() -2;
204 » » » » » pArray->InsertAt(iLast,CPDF_String::Crea te("datasets")); 200 pArray->InsertAt(iLast,CPDF_String::Create("datasets"));
205 » » » » » pArray->InsertAt(iLast+1, pData, pPDFDoc ument); 201 pArray->InsertAt(iLast+1, pData, pPDFDocument);
206 » » » » } 202 }
207 » » » } 203 }
208 » » » fileList.Add(pDsfileWrite); 204 fileList.Add(pDsfileWrite);
209 » » } 205 }
210 » } 206 }
211 207
212 208
213 » //L"form" 209 //L"form"
214 » { 210 {
215 211
216 » » IFX_FileStream* pfileWrite = FX_CreateMemoryStream(); 212 IFX_FileStream* pfileWrite = FX_CreateMemoryStream();
217 » » if (NULL == pfileWrite) 213 if (NULL == pfileWrite)
218 » » { 214 {
219 » » » pContext->Release(); 215 pContext->Release();
220 » » » return FALSE; 216 return FALSE;
221 » » } 217 }
222 » » if(pXFADocHandler->SavePackage(pXFADocView->GetDoc(), CFX_WideSt ringC(L"form"), pfileWrite, pContext) && pfileWrite > 0) 218 if(pXFADocHandler->SavePackage(pXFADocView->GetDoc(), CFX_WideStringC(L" form"), pfileWrite, pContext) && pfileWrite > 0)
223 » » { 219 {
224 » » » CPDF_Dictionary* pDataDict = FX_NEW CPDF_Dictionary; 220 CPDF_Dictionary* pDataDict = FX_NEW CPDF_Dictionary;
225 » » » if (iFormIndex != -1) 221 if (iFormIndex != -1)
226 » » » { 222 {
227 » » » » if (pFormStream) 223 if (pFormStream)
228 » » » » » pFormStream->InitStream(pfileWrite, pDat aDict); 224 pFormStream->InitStream(pfileWrite, pDataDict);
229 » » » } 225 }
230 » » » else 226 else
231 » » » { 227 {
232 » » » » CPDF_Stream* pData = FX_NEW CPDF_Stream(NULL, 0, NULL); 228 CPDF_Stream* pData = FX_NEW CPDF_Stream(NULL, 0, NULL);
233 » » » » pData->InitStream(pfileWrite, pDataDict); 229 pData->InitStream(pfileWrite, pDataDict);
234 » » » » FX_DWORD AppStreamobjnum = pPDFDocument->AddIndi rectObject(pData); 230 FX_DWORD AppStreamobjnum = pPDFDocument->AddIndirectObject(pData );
235 » » » » CPDF_Reference* pRef = (CPDF_Reference*)pPDFDocu ment->GetIndirectObject(AppStreamobjnum); 231 CPDF_Reference* pRef = (CPDF_Reference*)pPDFDocument->GetIndirec tObject(AppStreamobjnum);
236 » » » » { 232 {
237 » » » » » iLast = pArray->GetCount() -2; 233 iLast = pArray->GetCount() -2;
238 » » » » » pArray->InsertAt(iLast, CPDF_String::Cre ate("form")); 234 pArray->InsertAt(iLast, CPDF_String::Create("form"));
239 » » » » » pArray->InsertAt(iLast+1, pData, pPDFDoc ument); 235 pArray->InsertAt(iLast+1, pData, pPDFDocument);
240 » » » » } 236 }
241 » » » } 237 }
242 » » » fileList.Add(pfileWrite); 238 fileList.Add(pfileWrite);
243 » » } 239 }
244 » } 240 }
245 » pContext->Release(); 241 pContext->Release();
246 » return TRUE; 242 return TRUE;
247 } 243 }
248 244
249 245
250 FX_BOOL _SendPostSaveToXFADoc(CPDFXFA_Document* pDocument) 246 FX_BOOL _SendPostSaveToXFADoc(CPDFXFA_Document* pDocument)
251 { 247 {
252 » if (!pDocument) 248 if (!pDocument)
253 » » return FALSE; 249 return FALSE;
254 250
255 » if (pDocument->GetDocType() != DOCTYPE_DYNIMIC_XFA && pDocument->GetDocT ype() != DOCTYPE_STATIC_XFA) 251 if (pDocument->GetDocType() != DOCTYPE_DYNIMIC_XFA && pDocument->GetDocType( ) != DOCTYPE_STATIC_XFA)
256 » » return TRUE; 252 return TRUE;
257 253
258 » IXFA_DocView* pXFADocView = pDocument->GetXFADocView(); 254 IXFA_DocView* pXFADocView = pDocument->GetXFADocView();
259 » if (NULL == pXFADocView) 255 if (NULL == pXFADocView)
260 » » return FALSE; 256 return FALSE;
261 » IXFA_WidgetHandler* pWidgetHander = pXFADocView->GetWidgetHandler(); 257 IXFA_WidgetHandler* pWidgetHander = pXFADocView->GetWidgetHandler();
262 258
263 » CXFA_WidgetAcc* pWidgetAcc = NULL; 259 CXFA_WidgetAcc* pWidgetAcc = NULL;
264 » IXFA_WidgetAccIterator* pWidgetAccIterator = pXFADocView->CreateWidgetAc cIterator(); 260 IXFA_WidgetAccIterator* pWidgetAccIterator = pXFADocView->CreateWidgetAccIte rator();
265 » pWidgetAcc = pWidgetAccIterator->MoveToNext(); 261 pWidgetAcc = pWidgetAccIterator->MoveToNext();
266 » while(pWidgetAcc) 262 while(pWidgetAcc)
267 » { 263 {
268 » » CXFA_EventParam preParam; 264 CXFA_EventParam preParam;
269 » » preParam.m_eType = XFA_EVENT_PostSave; 265 preParam.m_eType = XFA_EVENT_PostSave;
270 » » pWidgetHander->ProcessEvent(pWidgetAcc,&preParam); 266 pWidgetHander->ProcessEvent(pWidgetAcc,&preParam);
271 » » pWidgetAcc = pWidgetAccIterator->MoveToNext(); 267 pWidgetAcc = pWidgetAccIterator->MoveToNext();
272 » } 268 }
273 » pWidgetAccIterator->Release(); 269 pWidgetAccIterator->Release();
274 » pXFADocView->UpdateDocView(); 270 pXFADocView->UpdateDocView();
275 » pDocument->_ClearChangeMark(); 271 pDocument->_ClearChangeMark();
276 » return TRUE; 272 return TRUE;
277 } 273 }
278 274
279 275
280 FX_BOOL _SendPreSaveToXFADoc(CPDFXFA_Document* pDocument, CFX_PtrArray& fileList ) 276 FX_BOOL _SendPreSaveToXFADoc(CPDFXFA_Document* pDocument, CFX_PtrArray& fileList )
281 { 277 {
282 » if (pDocument->GetDocType() != DOCTYPE_DYNIMIC_XFA && pDocument->GetDocT ype() != DOCTYPE_STATIC_XFA) 278 if (pDocument->GetDocType() != DOCTYPE_DYNIMIC_XFA && pDocument->GetDocType( ) != DOCTYPE_STATIC_XFA)
283 » » return TRUE; 279 return TRUE;
284 » IXFA_DocView* pXFADocView = pDocument->GetXFADocView(); 280 IXFA_DocView* pXFADocView = pDocument->GetXFADocView();
285 » if (NULL == pXFADocView) 281 if (NULL == pXFADocView)
286 » » return TRUE; 282 return TRUE;
287 » IXFA_WidgetHandler* pWidgetHander = pXFADocView->GetWidgetHandler(); 283 IXFA_WidgetHandler* pWidgetHander = pXFADocView->GetWidgetHandler();
288 » CXFA_WidgetAcc* pWidgetAcc = NULL; 284 CXFA_WidgetAcc* pWidgetAcc = NULL;
289 » IXFA_WidgetAccIterator* pWidgetAccIterator = pXFADocView->CreateWidgetAc cIterator(); 285 IXFA_WidgetAccIterator* pWidgetAccIterator = pXFADocView->CreateWidgetAccIte rator();
290 » pWidgetAcc = pWidgetAccIterator->MoveToNext(); 286 pWidgetAcc = pWidgetAccIterator->MoveToNext();
291 » while(pWidgetAcc) 287 while(pWidgetAcc)
292 » { 288 {
293 » » CXFA_EventParam preParam; 289 CXFA_EventParam preParam;
294 » » preParam.m_eType = XFA_EVENT_PreSave; 290 preParam.m_eType = XFA_EVENT_PreSave;
295 » » pWidgetHander->ProcessEvent(pWidgetAcc, &preParam); 291 pWidgetHander->ProcessEvent(pWidgetAcc, &preParam);
296 » » pWidgetAcc = pWidgetAccIterator->MoveToNext(); 292 pWidgetAcc = pWidgetAccIterator->MoveToNext();
297 » } 293 }
298 » pWidgetAccIterator->Release(); 294 pWidgetAccIterator->Release();
299 » pXFADocView->UpdateDocView(); 295 pXFADocView->UpdateDocView();
300 » return _SaveXFADocumentData(pDocument, fileList); 296 return _SaveXFADocumentData(pDocument, fileList);
301 } 297 }
302 298
303 FPDF_BOOL _FPDF_Doc_Save(FPDF_DOCUMENT document, FPDF_FILEWRITE * pFileWrite,FPD F_DWORD flags, FPDF_BOOL bSetVersion, 299 FPDF_BOOL _FPDF_Doc_Save(FPDF_DOCUMENT document, FPDF_FILEWRITE * pFileWrite,FPD F_DWORD flags, FPDF_BOOL bSetVersion,
304 » » » » » » int fileVerion) 300 int fileVerion)
305 { 301 {
306 » CPDFXFA_Document* pDoc = (CPDFXFA_Document*)document; 302 CPDFXFA_Document* pDoc = (CPDFXFA_Document*)document;
307 303
308 » CFX_PtrArray fileList; 304 CFX_PtrArray fileList;
309 305
310 » _SendPreSaveToXFADoc(pDoc, fileList); 306 _SendPreSaveToXFADoc(pDoc, fileList);
311 307
312 » CPDF_Document* pPDFDoc = pDoc->GetPDFDoc(); 308 CPDF_Document* pPDFDoc = pDoc->GetPDFDoc();
313 » if (!pPDFDoc) 309 if (!pPDFDoc)
314 » » return 0; 310 return 0;
315 311
316 » if ( flags < FPDF_INCREMENTAL || flags > FPDF_REMOVE_SECURITY ) 312 if ( flags < FPDF_INCREMENTAL || flags > FPDF_REMOVE_SECURITY )
317 » { 313 {
318 » » flags = 0; 314 flags = 0;
319 » } 315 }
320 316
321 » CPDF_Creator FileMaker(pPDFDoc); 317 CPDF_Creator FileMaker(pPDFDoc);
322 » if (bSetVersion) 318 if (bSetVersion)
323 » » FileMaker.SetFileVersion(fileVerion); 319 FileMaker.SetFileVersion(fileVerion);
324 » if (flags == FPDF_REMOVE_SECURITY) 320 if (flags == FPDF_REMOVE_SECURITY)
325 » { 321 {
326 » » flags = 0; 322 flags = 0;
327 » » FileMaker.RemoveSecurity(); 323 FileMaker.RemoveSecurity();
328 » } 324 }
329 » CFX_IFileWrite* pStreamWrite = NULL; 325 CFX_IFileWrite* pStreamWrite = NULL;
330 » FX_BOOL bRet; 326 FX_BOOL bRet;
331 » pStreamWrite = new CFX_IFileWrite; 327 pStreamWrite = new CFX_IFileWrite;
332 » pStreamWrite->Init( pFileWrite ); 328 pStreamWrite->Init( pFileWrite );
333 » bRet = FileMaker.Create(pStreamWrite, flags); 329 bRet = FileMaker.Create(pStreamWrite, flags);
334 330
335 » _SendPostSaveToXFADoc(pDoc); 331 _SendPostSaveToXFADoc(pDoc);
336 » //pDoc->_ClearChangeMark(); 332 //pDoc->_ClearChangeMark();
337 333
338 » for (int i = 0; i < fileList.GetSize(); i++) 334 for (int i = 0; i < fileList.GetSize(); i++)
339 » { 335 {
340 » » IFX_FileStream* pFile = (IFX_FileStream*)fileList.GetAt(i); 336 IFX_FileStream* pFile = (IFX_FileStream*)fileList.GetAt(i);
341 » » pFile->Release(); 337 pFile->Release();
342 » } 338 }
343 » fileList.RemoveAll(); 339 fileList.RemoveAll();
344 340
345 » delete pStreamWrite; 341 delete pStreamWrite;
346 » return bRet; 342 return bRet;
347 } 343 }
348 344
349 DLLEXPORT FPDF_BOOL STDCALL FPDF_SaveAsCopy(» FPDF_DOCUMENT document,FPDF_FILE WRITE * pFileWrite, 345 DLLEXPORT FPDF_BOOL STDCALL FPDF_SaveAsCopy( FPDF_DOCUMENT document,FPDF_FILE WRITE * pFileWrite,
350 » » » » » » » » » » » » FPDF_DWORD flags ) 346 FPDF_DWORD flags )
351 { 347 {
352 » return _FPDF_Doc_Save(document, pFileWrite, flags, FALSE , 0); 348 return _FPDF_Doc_Save(document, pFileWrite, flags, FALSE , 0);
353 } 349 }
354 350
355 DLLEXPORT FPDF_BOOL STDCALL FPDF_SaveWithVersion(» FPDF_DOCUMENT document,F PDF_FILEWRITE * pFileWrite, 351 DLLEXPORT FPDF_BOOL STDCALL FPDF_SaveWithVersion( FPDF_DOCUMENT document,FPDF_ FILEWRITE * pFileWrite,
356 » FPDF_DWORD flags, int fileVersion) 352 FPDF_DWORD flags, int fileVersion)
357 { 353 {
358 » return _FPDF_Doc_Save(document, pFileWrite, flags, TRUE , fileVersion); 354 return _FPDF_Doc_Save(document, pFileWrite, flags, TRUE , fileVersion);
359 } 355 }
360 356
OLDNEW
« no previous file with comments | « fpdfsdk/src/fpdfppo.cpp ('k') | fpdfsdk/src/fsdk_annothandler.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698