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

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

Issue 883393007: Kill off some dodgy JS callbacks (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: remove more now-unreachable code. Created 5 years, 10 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/include/javascript/app.h ('k') | fpdfsdk/src/javascript/Document.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 "../include/fsdk_define.h" 7 #include "../include/fsdk_define.h"
8 #include "../include/fpdfxfa/fpdfxfa_doc.h" 8 #include "../include/fpdfxfa/fpdfxfa_doc.h"
9 #include "../include/fpdfxfa/fpdfxfa_util.h" 9 #include "../include/fpdfxfa/fpdfxfa_util.h"
10 #include "../include/fsdk_mgr.h" 10 #include "../include/fsdk_mgr.h"
(...skipping 3123 matching lines...) Expand 10 before | Expand all | Expand 10 after
3134 nBufSize = fdfEncodedData.GetLength(); 3134 nBufSize = fdfEncodedData.GetLength();
3135 pBuf = FX_Alloc(FX_BYTE, nBufSize); 3135 pBuf = FX_Alloc(FX_BYTE, nBufSize);
3136 if(!pBuf) 3136 if(!pBuf)
3137 return FALSE; 3137 return FALSE;
3138 FXSYS_memcpy(pBuf, fdfEncodedData.GetBuffer(), nBufSize); 3138 FXSYS_memcpy(pBuf, fdfEncodedData.GetBuffer(), nBufSize);
3139 3139
3140 } 3140 }
3141 return TRUE; 3141 return TRUE;
3142 } 3142 }
3143 3143
3144 FX_BOOL CPDFSDK_InterForm::ExportFieldsToFDFFile(const CFX_WideString& sFDFFileN ame,
3145 const CFX_PtrArray& fields, FX_BOOL bIncludeOrExclude)
3146 {
3147 if (sFDFFileName.IsEmpty()) return FALSE;
3148 ASSERT(m_pDocument != NULL);
3149 ASSERT(m_pInterForm != NULL);
3150
3151 CFDF_Document* pFDF = m_pInterForm->ExportToFDF(m_pDocument->GetPath(),( CFX_PtrArray&)fields, bIncludeOrExclude);
3152 if (!pFDF) return FALSE;
3153 FX_BOOL bRet = pFDF->WriteFile(sFDFFileName.UTF8Encode()); // = FALSE;//
3154 delete pFDF;
3155
3156 return bRet;
3157 }
3158 FX_BOOL CPDFSDK_InterForm::ExportFieldsToFDFTextBuf(const CFX_PtrArray& fields,F X_BOOL bIncludeOrExclude, CFX_ByteTextBuf& textBuf) 3144 FX_BOOL CPDFSDK_InterForm::ExportFieldsToFDFTextBuf(const CFX_PtrArray& fields,F X_BOOL bIncludeOrExclude, CFX_ByteTextBuf& textBuf)
3159 { 3145 {
3160 ASSERT(m_pDocument != NULL); 3146 ASSERT(m_pDocument != NULL);
3161 ASSERT(m_pInterForm != NULL); 3147 ASSERT(m_pInterForm != NULL);
3162 3148
3163 CFDF_Document* pFDF = m_pInterForm->ExportToFDF(m_pDocument->GetPath(),( CFX_PtrArray&)fields, bIncludeOrExclude); 3149 CFDF_Document* pFDF = m_pInterForm->ExportToFDF(m_pDocument->GetPath(),( CFX_PtrArray&)fields, bIncludeOrExclude);
3164 if (!pFDF) return FALSE; 3150 if (!pFDF) return FALSE;
3165 FX_BOOL bRet = pFDF->WriteBuf(textBuf); // = FALSE;// 3151 FX_BOOL bRet = pFDF->WriteBuf(textBuf); // = FALSE;//
3166 delete pFDF; 3152 delete pFDF;
3167 3153
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
3227 3213
3228 if (bUrlEncoded && pBuffer) 3214 if (bUrlEncoded && pBuffer)
3229 { 3215 {
3230 FX_Free(pBuffer); 3216 FX_Free(pBuffer);
3231 pBuffer = NULL; 3217 pBuffer = NULL;
3232 } 3218 }
3233 3219
3234 return TRUE; 3220 return TRUE;
3235 } 3221 }
3236 3222
3237 FX_BOOL CPDFSDK_InterForm::ExportFormToFDFFile(const CFX_WideString& sFDFFileNam e)
3238 {
3239 if (sFDFFileName.IsEmpty()) return FALSE;
3240
3241 ASSERT(m_pInterForm != NULL);
3242 ASSERT(m_pDocument != NULL);
3243
3244 CFDF_Document* pFDF = m_pInterForm->ExportToFDF(m_pDocument->GetPath());
3245 if (!pFDF) return FALSE;
3246
3247 FX_BOOL bRet = pFDF->WriteFile(sFDFFileName.UTF8Encode());
3248 delete pFDF;
3249
3250 return bRet;
3251 }
3252
3253 FX_BOOL CPDFSDK_InterForm::ExportFormToFDFTextBuf(CFX_ByteTextBuf& textBuf) 3223 FX_BOOL CPDFSDK_InterForm::ExportFormToFDFTextBuf(CFX_ByteTextBuf& textBuf)
3254 { 3224 {
3255 3225
3256 ASSERT(m_pInterForm != NULL); 3226 ASSERT(m_pInterForm != NULL);
3257 ASSERT(m_pDocument != NULL); 3227 ASSERT(m_pDocument != NULL);
3258 3228
3259 CFDF_Document* pFDF = m_pInterForm->ExportToFDF(m_pDocument->GetPath()); 3229 CFDF_Document* pFDF = m_pInterForm->ExportToFDF(m_pDocument->GetPath());
3260 if (!pFDF) return FALSE; 3230 if (!pFDF) return FALSE;
3261 3231
3262 FX_BOOL bRet = pFDF->WriteBuf(textBuf); 3232 FX_BOOL bRet = pFDF->WriteBuf(textBuf);
3263 delete pFDF; 3233 delete pFDF;
3264 3234
3265 return bRet; 3235 return bRet;
3266 } 3236 }
3267 3237
3268 FX_BOOL CPDFSDK_InterForm::ExportFormToTxtFile(const CFX_WideString& sTxtFileNam e)
3269 {
3270 ASSERT(m_pInterForm != NULL);
3271
3272 CFX_WideString sFieldNames;
3273 CFX_WideString sFieldValues;
3274
3275 int nSize = m_pInterForm->CountFields();
3276
3277 if (nSize > 0)
3278 {
3279 for (int i=0; i<nSize; i++)
3280 {
3281 CPDF_FormField* pField = m_pInterForm->GetField(i);
3282 ASSERT(pField != NULL);
3283
3284 if (i != 0)
3285 {
3286 sFieldNames += L"\t";
3287 sFieldValues += L"\t";
3288 }
3289 sFieldNames += pField->GetFullName();
3290 sFieldValues += pField->GetValue();
3291 }
3292
3293 return TRUE;
3294 }
3295
3296 return FALSE;
3297 }
3298
3299 FX_BOOL CPDFSDK_InterForm::ImportFormFromTxtFile(const CFX_WideString& sTxtFileN ame)
3300 {
3301 ASSERT(m_pInterForm != NULL);
3302
3303 return TRUE;
3304 }
3305 3238
3306 FX_BOOL CPDFSDK_InterForm::DoAction_ResetForm(const CPDF_Action& action) 3239 FX_BOOL CPDFSDK_InterForm::DoAction_ResetForm(const CPDF_Action& action)
3307 { 3240 {
3308 ASSERT(action != NULL); 3241 ASSERT(action != NULL);
3309 3242
3310 CPDF_Dictionary* pActionDict = action; 3243 CPDF_Dictionary* pActionDict = action;
3311 3244
3312 if (pActionDict->KeyExist("Fields")) 3245 if (pActionDict->KeyExist("Fields"))
3313 { 3246 {
3314 CPDF_ActionFields af = action.GetWidgets(); 3247 CPDF_ActionFields af = action.GetWidgets();
(...skipping 10 matching lines...) Expand all
3325 } 3258 }
3326 else 3259 else
3327 { 3260 {
3328 ASSERT(m_pInterForm != NULL); 3261 ASSERT(m_pInterForm != NULL);
3329 return m_pInterForm->ResetForm(TRUE); 3262 return m_pInterForm->ResetForm(TRUE);
3330 } 3263 }
3331 } 3264 }
3332 3265
3333 FX_BOOL CPDFSDK_InterForm::DoAction_ImportData(const CPDF_Action& action) 3266 FX_BOOL CPDFSDK_InterForm::DoAction_ImportData(const CPDF_Action& action)
3334 { 3267 {
3335 ASSERT(action != NULL);
3336
3337 CFX_WideString sFilePath = action.GetFilePath();
3338 if (sFilePath.IsEmpty())
3339 return FALSE;
3340
3341 if (!ImportFormFromFDFFile(sFilePath, TRUE))
3342 {
3343 return FALSE;
3344 }
3345
3346 return TRUE;
3347 }
3348
3349 FX_BOOL CPDFSDK_InterForm::ImportFormFromFDFFile(const CFX_WideString& csFDFFile Name,
3350 FX_BOOL bNotify)
3351 {
3352 return FALSE; 3268 return FALSE;
3353 } 3269 }
3354 3270
3355 void CPDFSDK_InterForm::GetFieldFromObjects(const CFX_PtrArray& objects, CFX_Ptr Array& fields) 3271 void CPDFSDK_InterForm::GetFieldFromObjects(const CFX_PtrArray& objects, CFX_Ptr Array& fields)
3356 { 3272 {
3357 ASSERT(m_pInterForm != NULL); 3273 ASSERT(m_pInterForm != NULL);
3358 3274
3359 int iCount = objects.GetSize(); 3275 int iCount = objects.GetSize();
3360 for (int i = 0; i < iCount; i ++) 3276 for (int i = 0; i < iCount; i ++)
3361 { 3277 {
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after
3889 3805
3890 CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot(); 3806 CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot();
3891 ASSERT(pPDFAnnot != NULL); 3807 ASSERT(pPDFAnnot != NULL);
3892 3808
3893 CPDF_Rect rcAnnot; 3809 CPDF_Rect rcAnnot;
3894 pPDFAnnot->GetRect(rcAnnot); 3810 pPDFAnnot->GetRect(rcAnnot);
3895 3811
3896 return rcAnnot; 3812 return rcAnnot;
3897 } 3813 }
3898 3814
OLDNEW
« no previous file with comments | « fpdfsdk/include/javascript/app.h ('k') | fpdfsdk/src/javascript/Document.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698