| 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 "../../include/javascript/JavaScript.h" | 7 #include "../../include/javascript/JavaScript.h" |
| 8 #include "../../include/javascript/IJavaScript.h" | 8 #include "../../include/javascript/IJavaScript.h" |
| 9 #include "../../include/javascript/JS_Define.h" | 9 #include "../../include/javascript/JS_Define.h" |
| 10 #include "../../include/javascript/JS_Object.h" | 10 #include "../../include/javascript/JS_Object.h" |
| 11 #include "../../include/javascript/JS_Value.h" | 11 #include "../../include/javascript/JS_Value.h" |
| 12 #include "../../include/javascript/Document.h" | 12 #include "../../include/javascript/Document.h" |
| 13 #include "../../include/javascript/JS_EventHandler.h" | 13 #include "../../include/javascript/JS_EventHandler.h" |
| 14 #include "../../include/javascript/JS_Context.h" | 14 #include "../../include/javascript/JS_Context.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 JS_STATIC_PROP_ENTRY(calculate) | 71 JS_STATIC_PROP_ENTRY(calculate) |
| 72 JS_STATIC_PROP_ENTRY(Collab) | 72 JS_STATIC_PROP_ENTRY(Collab) |
| 73 JS_STATIC_PROP_ENTRY(creationDate) | 73 JS_STATIC_PROP_ENTRY(creationDate) |
| 74 JS_STATIC_PROP_ENTRY(creator) | 74 JS_STATIC_PROP_ENTRY(creator) |
| 75 JS_STATIC_PROP_ENTRY(delay) | 75 JS_STATIC_PROP_ENTRY(delay) |
| 76 JS_STATIC_PROP_ENTRY(dirty) | 76 JS_STATIC_PROP_ENTRY(dirty) |
| 77 JS_STATIC_PROP_ENTRY(documentFileName) | 77 JS_STATIC_PROP_ENTRY(documentFileName) |
| 78 JS_STATIC_PROP_ENTRY(external) | 78 JS_STATIC_PROP_ENTRY(external) |
| 79 JS_STATIC_PROP_ENTRY(filesize) | 79 JS_STATIC_PROP_ENTRY(filesize) |
| 80 JS_STATIC_PROP_ENTRY(icons) | 80 JS_STATIC_PROP_ENTRY(icons) |
| 81 » JS_STATIC_PROP_ENTRY(info) | 81 » JS_STATIC_PROP_ENTRY(info) |
| 82 JS_STATIC_PROP_ENTRY(keywords) | 82 JS_STATIC_PROP_ENTRY(keywords) |
| 83 JS_STATIC_PROP_ENTRY(layout) | 83 JS_STATIC_PROP_ENTRY(layout) |
| 84 JS_STATIC_PROP_ENTRY(media) | 84 JS_STATIC_PROP_ENTRY(media) |
| 85 JS_STATIC_PROP_ENTRY(modDate) | 85 JS_STATIC_PROP_ENTRY(modDate) |
| 86 JS_STATIC_PROP_ENTRY(mouseX) | 86 JS_STATIC_PROP_ENTRY(mouseX) |
| 87 JS_STATIC_PROP_ENTRY(mouseY) | 87 JS_STATIC_PROP_ENTRY(mouseY) |
| 88 JS_STATIC_PROP_ENTRY(numFields) | 88 JS_STATIC_PROP_ENTRY(numFields) |
| 89 JS_STATIC_PROP_ENTRY(numPages) | 89 JS_STATIC_PROP_ENTRY(numPages) |
| 90 » JS_STATIC_PROP_ENTRY(pageNum) | 90 » JS_STATIC_PROP_ENTRY(pageNum) |
| 91 JS_STATIC_PROP_ENTRY(pageWindowRect) | 91 JS_STATIC_PROP_ENTRY(pageWindowRect) |
| 92 JS_STATIC_PROP_ENTRY(path) | 92 JS_STATIC_PROP_ENTRY(path) |
| 93 JS_STATIC_PROP_ENTRY(producer) | 93 JS_STATIC_PROP_ENTRY(producer) |
| 94 JS_STATIC_PROP_ENTRY(subject) | 94 JS_STATIC_PROP_ENTRY(subject) |
| 95 JS_STATIC_PROP_ENTRY(title) | 95 JS_STATIC_PROP_ENTRY(title) |
| 96 JS_STATIC_PROP_ENTRY(zoom) | 96 JS_STATIC_PROP_ENTRY(zoom) |
| 97 JS_STATIC_PROP_ENTRY(zoomType) | 97 JS_STATIC_PROP_ENTRY(zoomType) |
| 98 END_JS_STATIC_PROP() | 98 END_JS_STATIC_PROP() |
| 99 | 99 |
| 100 BEGIN_JS_STATIC_METHOD(CJS_Document) | 100 BEGIN_JS_STATIC_METHOD(CJS_Document) |
| (...skipping 29 matching lines...) Expand all Loading... |
| 130 JS_STATIC_METHOD_ENTRY(importTextData, 2) | 130 JS_STATIC_METHOD_ENTRY(importTextData, 2) |
| 131 JS_STATIC_METHOD_ENTRY(insertPages, 4) | 131 JS_STATIC_METHOD_ENTRY(insertPages, 4) |
| 132 JS_STATIC_METHOD_ENTRY(mailForm, 6) | 132 JS_STATIC_METHOD_ENTRY(mailForm, 6) |
| 133 JS_STATIC_METHOD_ENTRY(print, 9) | 133 JS_STATIC_METHOD_ENTRY(print, 9) |
| 134 JS_STATIC_METHOD_ENTRY(removeField, 1) | 134 JS_STATIC_METHOD_ENTRY(removeField, 1) |
| 135 JS_STATIC_METHOD_ENTRY(replacePages, 4) | 135 JS_STATIC_METHOD_ENTRY(replacePages, 4) |
| 136 JS_STATIC_METHOD_ENTRY(resetForm, 1) | 136 JS_STATIC_METHOD_ENTRY(resetForm, 1) |
| 137 JS_STATIC_METHOD_ENTRY(removeIcon, 0) | 137 JS_STATIC_METHOD_ENTRY(removeIcon, 0) |
| 138 JS_STATIC_METHOD_ENTRY(saveAs, 5) | 138 JS_STATIC_METHOD_ENTRY(saveAs, 5) |
| 139 JS_STATIC_METHOD_ENTRY(submitForm, 23) | 139 JS_STATIC_METHOD_ENTRY(submitForm, 23) |
| 140 » JS_STATIC_METHOD_ENTRY(mailDoc, 0)» » | 140 » JS_STATIC_METHOD_ENTRY(mailDoc, 0) |
| 141 END_JS_STATIC_METHOD() | 141 END_JS_STATIC_METHOD() |
| 142 | 142 |
| 143 IMPLEMENT_JS_CLASS(CJS_Document, Document) | 143 IMPLEMENT_JS_CLASS(CJS_Document, Document) |
| 144 | 144 |
| 145 FX_BOOL CJS_Document::InitInstance(IFXJS_Context* cc) | 145 FX_BOOL CJS_Document::InitInstance(IFXJS_Context* cc) |
| 146 { | 146 { |
| 147 CJS_Context* pContext = (CJS_Context*)cc; | 147 CJS_Context* pContext = (CJS_Context*)cc; |
| 148 ASSERT(pContext != NULL); | 148 ASSERT(pContext != NULL); |
| 149 | 149 |
| 150 Document* pDoc = (Document*)GetEmbedObject(); | 150 Document* pDoc = (Document*)GetEmbedObject(); |
| 151 ASSERT(pDoc != NULL); | 151 ASSERT(pDoc != NULL); |
| 152 » | 152 |
| 153 pDoc->AttachDoc(pContext->GetReaderDocument()); | 153 pDoc->AttachDoc(pContext->GetReaderDocument()); |
| 154 pDoc->SetIsolate(pContext->GetJSRuntime()->GetIsolate()); | 154 pDoc->SetIsolate(pContext->GetJSRuntime()->GetIsolate()); |
| 155 return TRUE; | 155 return TRUE; |
| 156 }; | 156 }; |
| 157 | 157 |
| 158 /* --------------------------------- Document ---------------------------------
*/ | 158 /* --------------------------------- Document ---------------------------------
*/ |
| 159 | 159 |
| 160 Document::Document(CJS_Object* pJSObject) : CJS_EmbedObj(pJSObject), | 160 Document::Document(CJS_Object* pJSObject) : CJS_EmbedObj(pJSObject), |
| 161 m_isolate(NULL), | 161 m_isolate(NULL), |
| 162 m_pIconTree(NULL), | 162 m_pIconTree(NULL), |
| (...skipping 11 matching lines...) Expand all Loading... |
| 174 delete m_pIconTree; | 174 delete m_pIconTree; |
| 175 m_pIconTree = NULL; | 175 m_pIconTree = NULL; |
| 176 } | 176 } |
| 177 for (int i=0; i<m_DelayData.GetSize(); i++) | 177 for (int i=0; i<m_DelayData.GetSize(); i++) |
| 178 { | 178 { |
| 179 if (CJS_DelayData* pData = m_DelayData.GetAt(i)) | 179 if (CJS_DelayData* pData = m_DelayData.GetAt(i)) |
| 180 { | 180 { |
| 181 delete pData; | 181 delete pData; |
| 182 pData = NULL; | 182 pData = NULL; |
| 183 m_DelayData.SetAt(i, NULL); | 183 m_DelayData.SetAt(i, NULL); |
| 184 » » » | 184 |
| 185 } | 185 } |
| 186 } | 186 } |
| 187 | 187 |
| 188 m_DelayData.RemoveAll(); | 188 m_DelayData.RemoveAll(); |
| 189 m_DelayAnnotData.RemoveAll(); | 189 m_DelayAnnotData.RemoveAll(); |
| 190 } | 190 } |
| 191 | 191 |
| 192 //the total number of fileds in document. | 192 //the total number of fileds in document. |
| 193 FX_BOOL Document::numFields(OBJ_PROP_PARAMS) | 193 FX_BOOL Document::numFields(OBJ_PROP_PARAMS) |
| 194 { | 194 { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 } | 246 } |
| 247 | 247 |
| 248 return TRUE; | 248 return TRUE; |
| 249 } | 249 } |
| 250 | 250 |
| 251 FX_BOOL Document::pageNum(OBJ_PROP_PARAMS) | 251 FX_BOOL Document::pageNum(OBJ_PROP_PARAMS) |
| 252 { | 252 { |
| 253 ASSERT(m_pDocument != NULL); | 253 ASSERT(m_pDocument != NULL); |
| 254 | 254 |
| 255 if (vp.IsGetting()) | 255 if (vp.IsGetting()) |
| 256 » {» » » | 256 » { |
| 257 if (CPDFSDK_PageView* pPageView = m_pDocument->GetCurrentView()) | 257 if (CPDFSDK_PageView* pPageView = m_pDocument->GetCurrentView()) |
| 258 { | 258 { |
| 259 vp << pPageView->GetPageIndex(); | 259 vp << pPageView->GetPageIndex(); |
| 260 } | 260 } |
| 261 } | 261 } |
| 262 else | 262 else |
| 263 » {» » | 263 » { |
| 264 int iPageCount = m_pDocument->GetPageCount(); | 264 int iPageCount = m_pDocument->GetPageCount(); |
| 265 | 265 |
| 266 int iPageNum = 0; | 266 int iPageNum = 0; |
| 267 vp >> iPageNum; | 267 vp >> iPageNum; |
| 268 | 268 |
| 269 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); | 269 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); |
| 270 if(!pEnv) | 270 if(!pEnv) |
| 271 return FALSE; | 271 return FALSE; |
| 272 | 272 |
| 273 if (iPageNum >= 0 && iPageNum < iPageCount) | 273 if (iPageNum >= 0 && iPageNum < iPageCount) |
| 274 { | 274 { |
| 275 pEnv->JS_docgotoPage(iPageNum); | 275 pEnv->JS_docgotoPage(iPageNum); |
| 276 } | 276 } |
| 277 else if (iPageNum >= iPageCount) | 277 else if (iPageNum >= iPageCount) |
| 278 { | 278 { |
| 279 pEnv->JS_docgotoPage(iPageCount-1); | 279 pEnv->JS_docgotoPage(iPageCount-1); |
| 280 } | 280 } |
| 281 else if (iPageNum < 0) | 281 else if (iPageNum < 0) |
| 282 { | 282 { |
| 283 pEnv->JS_docgotoPage(0); | 283 pEnv->JS_docgotoPage(0); |
| 284 } | 284 } |
| 285 } | 285 } |
| 286 | 286 |
| 287 return TRUE; | 287 return TRUE; |
| 288 } | 288 } |
| 289 | 289 |
| 290 FX_BOOL Document::ParserParams(JSObject* pObj,CJS_AnnotObj& annotobj) | 290 FX_BOOL Document::ParserParams(JSObject* pObj,CJS_AnnotObj& annotobj) |
| 291 { | 291 { |
| 292 // Not supported. |
| 292 return TRUE; | 293 return TRUE; |
| 293 } | 294 } |
| 294 | 295 |
| 295 FX_BOOL Document::addAnnot(OBJ_METHOD_PARAMS) | 296 FX_BOOL Document::addAnnot(OBJ_METHOD_PARAMS) |
| 296 { | 297 { |
| 298 // Not supported. |
| 297 return TRUE; | 299 return TRUE; |
| 298 } | 300 } |
| 299 | 301 |
| 300 FX_BOOL Document::addField(OBJ_METHOD_PARAMS) | 302 FX_BOOL Document::addField(OBJ_METHOD_PARAMS) |
| 301 { | 303 { |
| 302 » //Doesn't support. | 304 » // Not supported. |
| 303 return TRUE; | 305 return TRUE; |
| 304 } | 306 } |
| 305 | 307 |
| 306 //exports form fields as a tab-delimited text file to a local hard disk. | |
| 307 //comment: need reader support | |
| 308 //note : watch the third parameter:cPath, for what case it can be safely saved? | |
| 309 //int CPDFSDK_InterForm::ExportAsText(FX_BOOL bNoPassword,StringArray aFields,St
ring cPath); | |
| 310 //return value, int the index of the parameters illegal, the index is based on 1
. | |
| 311 | |
| 312 FX_BOOL Document::exportAsText(OBJ_METHOD_PARAMS) | 308 FX_BOOL Document::exportAsText(OBJ_METHOD_PARAMS) |
| 313 { | 309 { |
| 314 » if (IsSafeMode(cc)) return TRUE; | 310 » // Unsafe, not supported. |
| 315 return TRUE; | 311 return TRUE; |
| 316 } | 312 } |
| 317 | 313 |
| 318 //exports form fields as a fdf file to the local hard drive | |
| 319 //comment: need reader supports | |
| 320 //note:the last parameter hasn't been confirmed.because the previous one blocks
the way. | |
| 321 //int CPDFSDK_Document::ExportAsFDF(FX_BOOL bAllFields,BOOL bNoPassword,StringAr
ray aFields,FX_BOOL bFlags,String cPath,FX_BOOL bAnnotations); | |
| 322 | |
| 323 FX_BOOL Document::exportAsFDF(OBJ_METHOD_PARAMS) | 314 FX_BOOL Document::exportAsFDF(OBJ_METHOD_PARAMS) |
| 324 { | 315 { |
| 325 » v8::Isolate* isolate = GetIsolate(cc); | 316 » // Unsafe, not supported. |
| 326 » if (IsSafeMode(cc)) return TRUE; | 317 » return TRUE; |
| 327 | |
| 328 » ASSERT(m_pDocument != NULL); | |
| 329 | |
| 330 » if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) return FALSE; | |
| 331 | |
| 332 » FX_BOOL bAllFields = params.size() > 0 ? (FX_BOOL)params[0] : FALSE; | |
| 333 » FX_BOOL bNoPassWord = params.size() > 1 ? (FX_BOOL)params[1] : TRUE; | |
| 334 » FX_BOOL bWhole = params.size() > 2 ? (params[2].GetType() == VT_null) :
TRUE; | |
| 335 » CJS_Array arrayFileds(isolate); | |
| 336 » if (!bWhole) | |
| 337 » » arrayFileds.Attach(params[2]); | |
| 338 » //FX_BOOL bFlags = params.size() > 3 ? (FX_BOOL)params[3] : FALSE; | |
| 339 » CFX_WideString swFilePath = params.size() > 4 ? (FX_LPCWSTR)params[4].op
erator CFX_WideString() : L""; | |
| 340 | |
| 341 » if (swFilePath.IsEmpty()) | |
| 342 » { | |
| 343 » » CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); | |
| 344 » » swFilePath = pEnv->JS_fieldBrowse(); | |
| 345 » » if(swFilePath.IsEmpty()) | |
| 346 » » » return TRUE; | |
| 347 » } | |
| 348 » else | |
| 349 » { | |
| 350 » » swFilePath = app::PDFPathToSysPath(swFilePath); | |
| 351 » } | |
| 352 » | |
| 353 » m_pDocument->SetFocusAnnot(NULL); | |
| 354 | |
| 355 » CPDFSDK_InterForm* pInterForm= (CPDFSDK_InterForm*)m_pDocument->GetInter
Form(); | |
| 356 » ASSERT(pInterForm != NULL); | |
| 357 | |
| 358 » CPDF_InterForm* pPDFForm = pInterForm->GetInterForm(); | |
| 359 » ASSERT(pPDFForm != NULL); | |
| 360 | |
| 361 » CFX_PtrArray aFields; | |
| 362 | |
| 363 » if (bWhole) | |
| 364 » { | |
| 365 » » for (int j=0,jsz=pPDFForm->CountFields(); j<jsz; j++) | |
| 366 » » { | |
| 367 » » » aFields.Add(pPDFForm->GetField(j)); | |
| 368 » » } | |
| 369 » } | |
| 370 » else | |
| 371 » { | |
| 372 » » for (int i=0,isz=arrayFileds.GetLength(); i<isz; i++) | |
| 373 » » { | |
| 374 » » » CJS_Value valName(isolate); | |
| 375 » » » arrayFileds.GetElement(i,valName); | |
| 376 » » » CFX_WideString swName = valName.operator CFX_WideString(
); | |
| 377 | |
| 378 » » » for (int j=0, jsz=pPDFForm->CountFields(swName); j<jsz;
j++) | |
| 379 » » » { | |
| 380 » » » » aFields.Add(pPDFForm->GetField(j, swName)); | |
| 381 » » » } | |
| 382 » » } | |
| 383 » } | |
| 384 | |
| 385 » CFX_PtrArray fields; | |
| 386 | |
| 387 » for (int i=0,sz=aFields.GetSize(); i<sz; i++) | |
| 388 » { | |
| 389 » » CPDF_FormField* pField = (CPDF_FormField*)aFields[i]; | |
| 390 » » | |
| 391 » » if (!bAllFields) | |
| 392 » » » if (pField->GetValue() == L"") | |
| 393 » » » » continue; | |
| 394 | |
| 395 » » if (bNoPassWord) | |
| 396 » » » if (pField->GetFieldFlags() & 0x2000) | |
| 397 » » » » continue; | |
| 398 | |
| 399 » » fields.Add((void*)pField); | |
| 400 » } | |
| 401 | |
| 402 » return pInterForm->ExportFieldsToFDFFile(swFilePath, fields, TRUE); | |
| 403 } | 318 } |
| 404 | 319 |
| 405 //exports form fields an XFDF file to the local hard drive | |
| 406 //comment: need reder supports | |
| 407 //note:the last parameter can't be test | |
| 408 //int CPDFSDK_Document::ExportAsXFDF(FX_BOOL bAllFields,FX_BOOL bNoPassWord,Str
ingArray aFields,String cPath,FX_BOOL bAnnoatations); | |
| 409 | |
| 410 FX_BOOL Document::exportAsXFDF(OBJ_METHOD_PARAMS) | 320 FX_BOOL Document::exportAsXFDF(OBJ_METHOD_PARAMS) |
| 411 { | 321 { |
| 412 » if (IsSafeMode(cc)) return TRUE; | 322 » // Unsafe, not supported. |
| 413 » ASSERT(m_pDocument != NULL); | |
| 414 | |
| 415 » if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) return FALSE; | |
| 416 | |
| 417 return TRUE; | 323 return TRUE; |
| 418 } | 324 } |
| 419 | 325 |
| 420 //Maps a field object in PDF document to a JavaScript variable | 326 //Maps a field object in PDF document to a JavaScript variable |
| 421 //comment: | 327 //comment: |
| 422 //note: the paremter cName, this is clue how to treat if the cName is not a vali
able filed name in this document | 328 //note: the paremter cName, this is clue how to treat if the cName is not a vali
able filed name in this document |
| 423 | 329 |
| 424 FX_BOOL Document::getField(OBJ_METHOD_PARAMS) | 330 FX_BOOL Document::getField(OBJ_METHOD_PARAMS) |
| 425 { | 331 { |
| 426 v8::Isolate* isolate = GetIsolate(cc); | 332 v8::Isolate* isolate = GetIsolate(cc); |
| 427 ASSERT(m_pDocument != NULL); | 333 ASSERT(m_pDocument != NULL); |
| 428 | 334 |
| 429 if (params.size() < 1) return FALSE; | 335 if (params.size() < 1) return FALSE; |
| 430 | 336 |
| 431 CFX_WideString wideName = params[0].operator CFX_WideString(); | 337 CFX_WideString wideName = params[0].operator CFX_WideString(); |
| 432 | 338 |
| 433 CPDFSDK_InterForm* pInterForm = m_pDocument->GetInterForm(); | 339 CPDFSDK_InterForm* pInterForm = m_pDocument->GetInterForm(); |
| 434 ASSERT(pInterForm != NULL); | 340 ASSERT(pInterForm != NULL); |
| 435 | 341 |
| 436 CPDF_InterForm* pPDFForm = pInterForm->GetInterForm(); | 342 CPDF_InterForm* pPDFForm = pInterForm->GetInterForm(); |
| 437 ASSERT(pPDFForm != NULL); | 343 ASSERT(pPDFForm != NULL); |
| 438 | 344 |
| 439 » if (pPDFForm->CountFields(wideName) <= 0) | 345 » if (pPDFForm->CountFields(wideName) <= 0) |
| 440 { | 346 { |
| 441 vRet.SetNull(); | 347 vRet.SetNull(); |
| 442 return TRUE; | 348 return TRUE; |
| 443 } | 349 } |
| 444 | 350 |
| 445 CJS_Context* pContext = (CJS_Context*)cc; | 351 CJS_Context* pContext = (CJS_Context*)cc; |
| 446 ASSERT(pContext != NULL); | 352 ASSERT(pContext != NULL); |
| 447 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 353 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
| 448 ASSERT(pRuntime != NULL); | 354 ASSERT(pRuntime != NULL); |
| 449 | 355 |
| 450 JSFXObject pFieldObj = JS_NewFxDynamicObj(*pRuntime, pContext, JS_GetOb
jDefnID(*pRuntime, L"Field")); | 356 JSFXObject pFieldObj = JS_NewFxDynamicObj(*pRuntime, pContext, JS_GetOb
jDefnID(*pRuntime, L"Field")); |
| 451 | 357 |
| 452 CJS_Field * pJSField = (CJS_Field*)JS_GetPrivate(isolate,pFieldObj); | 358 CJS_Field * pJSField = (CJS_Field*)JS_GetPrivate(isolate,pFieldObj); |
| 453 ASSERT(pJSField != NULL); | 359 ASSERT(pJSField != NULL); |
| 454 | 360 |
| 455 » Field * pField = (Field *)pJSField->GetEmbedObject(); | 361 » Field * pField = (Field *)pJSField->GetEmbedObject(); |
| 456 ASSERT(pField != NULL); | 362 ASSERT(pField != NULL); |
| 457 | 363 |
| 458 pField->AttachField(this, wideName); | 364 pField->AttachField(this, wideName); |
| 459 vRet = pJSField; | 365 vRet = pJSField; |
| 460 | 366 |
| 461 return TRUE; | 367 return TRUE; |
| 462 } | 368 } |
| 463 | 369 |
| 464 //Gets the name of the nth field in the document | 370 //Gets the name of the nth field in the document |
| 465 //comment: | |
| 466 //note: the parameter nIndex, if it is not available | |
| 467 | |
| 468 FX_BOOL Document::getNthFieldName(OBJ_METHOD_PARAMS) | 371 FX_BOOL Document::getNthFieldName(OBJ_METHOD_PARAMS) |
| 469 { | 372 { |
| 470 ASSERT(m_pDocument != NULL); | 373 ASSERT(m_pDocument != NULL); |
| 471 | 374 |
| 472 int nIndex = params.size() > 0 ? (int)params[0] : -1; | 375 int nIndex = params.size() > 0 ? (int)params[0] : -1; |
| 473 if (nIndex == -1) return FALSE; | 376 if (nIndex == -1) return FALSE; |
| 474 | 377 |
| 475 CPDFSDK_InterForm* pInterForm = m_pDocument->GetInterForm(); | 378 CPDFSDK_InterForm* pInterForm = m_pDocument->GetInterForm(); |
| 476 ASSERT(pInterForm != NULL); | 379 ASSERT(pInterForm != NULL); |
| 477 | 380 |
| 478 CPDF_InterForm* pPDFForm = pInterForm->GetInterForm(); | 381 CPDF_InterForm* pPDFForm = pInterForm->GetInterForm(); |
| 479 ASSERT(pPDFForm != NULL); | 382 ASSERT(pPDFForm != NULL); |
| 480 | 383 |
| 481 CPDF_FormField* pField = pPDFForm->GetField(nIndex); | 384 CPDF_FormField* pField = pPDFForm->GetField(nIndex); |
| 482 if (!pField) | 385 if (!pField) |
| 483 return FALSE; | 386 return FALSE; |
| 484 | 387 |
| 485 vRet = pField->GetFullName(); | 388 vRet = pField->GetFullName(); |
| 486 » return TRUE;» | 389 » return TRUE; |
| 487 } | 390 } |
| 488 | 391 |
| 489 //imports the specified fdf file. | |
| 490 //comments: need reader suppport | |
| 491 //note:once the cpath is illigl then a file dialog box pops up in order to ask
user to chooose the file | |
| 492 //int CPDFSDK_Document::importAnFDF(String cPath); | |
| 493 | |
| 494 FX_BOOL Document::importAnFDF(OBJ_METHOD_PARAMS) | 392 FX_BOOL Document::importAnFDF(OBJ_METHOD_PARAMS) |
| 495 { | 393 { |
| 496 » if (IsSafeMode(cc)) return TRUE; | 394 » // Unsafe, not supported. |
| 497 » ASSERT(m_pDocument != NULL); | |
| 498 | |
| 499 » if (!(m_pDocument->GetPermissions(FPDFPERM_MODIFY) || | |
| 500 » » m_pDocument->GetPermissions(FPDFPERM_ANNOT_FORM) || | |
| 501 » » m_pDocument->GetPermissions(FPDFPERM_FILL_FORM))) return FALSE; | |
| 502 | |
| 503 | |
| 504 » CFX_WideString swPath; | |
| 505 » | |
| 506 » if (params.size() > 0) | |
| 507 » » swPath = params[0]; | |
| 508 » | |
| 509 » if (swPath.IsEmpty()) | |
| 510 » { | |
| 511 » » CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); | |
| 512 » » swPath = pEnv->JS_fieldBrowse(); | |
| 513 » » if(swPath.IsEmpty()) | |
| 514 » » » return TRUE; | |
| 515 » } | |
| 516 » else | |
| 517 » { | |
| 518 » » swPath = app::PDFPathToSysPath(swPath); | |
| 519 » } | |
| 520 | |
| 521 » m_pDocument->SetFocusAnnot(NULL); | |
| 522 | |
| 523 » CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInte
rForm(); | |
| 524 » ASSERT(pInterForm != NULL); | |
| 525 | |
| 526 » if (!pInterForm->ImportFormFromFDFFile(swPath, TRUE)) | |
| 527 » » return FALSE; | |
| 528 | |
| 529 » m_pDocument->SetChangeMark(); | |
| 530 // » CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); | |
| 531 // » ASSERT(pEnv != NULL); | |
| 532 // » IUndo* pUndo = IUndo::GetUndo(pEnv); | |
| 533 // » ASSERT(pUndo != NULL); | |
| 534 // » pUndo->Reset(m_pDocument); | |
| 535 | |
| 536 return TRUE; | 395 return TRUE; |
| 537 } | 396 } |
| 538 | 397 |
| 539 //imports and specified XFDF file containing XML form data | |
| 540 //comment: need reader supports | |
| 541 //note: same as up | |
| 542 //int CPDFSDK_Document::importAnFDF(String cPath) | |
| 543 | |
| 544 FX_BOOL Document::importAnXFDF(OBJ_METHOD_PARAMS) | 398 FX_BOOL Document::importAnXFDF(OBJ_METHOD_PARAMS) |
| 545 { | 399 { |
| 546 » if (IsSafeMode(cc)) return TRUE; | 400 » // Unsafe, not supported. |
| 547 » ASSERT(m_pDocument != NULL); | |
| 548 | |
| 549 » if (!(m_pDocument->GetPermissions(FPDFPERM_MODIFY) || | |
| 550 » » m_pDocument->GetPermissions(FPDFPERM_ANNOT_FORM) || | |
| 551 » » m_pDocument->GetPermissions(FPDFPERM_FILL_FORM))) return FALSE; | |
| 552 | |
| 553 return TRUE; | 401 return TRUE; |
| 554 } | 402 } |
| 555 | 403 |
| 556 //imports and specified text file | |
| 557 //commnet: need reader supports | |
| 558 //note: same as up,when nRow is not rational,adobe is dumb for it. | |
| 559 //int CPDFSDK_Document::importTextData(String cPath,int nRow); | |
| 560 | |
| 561 FX_BOOL Document::importTextData(OBJ_METHOD_PARAMS) | 404 FX_BOOL Document::importTextData(OBJ_METHOD_PARAMS) |
| 562 { | 405 { |
| 563 » if (IsSafeMode(cc)) return TRUE; | 406 » // Unsafe, not supported. |
| 564 » ASSERT(m_pDocument != NULL); | |
| 565 | |
| 566 » if (!(m_pDocument->GetPermissions(FPDFPERM_MODIFY) || | |
| 567 » » m_pDocument->GetPermissions(FPDFPERM_ANNOT_FORM) || | |
| 568 » » m_pDocument->GetPermissions(FPDFPERM_FILL_FORM))) return FALSE; | |
| 569 | |
| 570 return TRUE; | 407 return TRUE; |
| 571 } | 408 } |
| 572 | 409 |
| 573 //exports the form data and mails the resulting fdf file as an attachment to all
recipients. | 410 //exports the form data and mails the resulting fdf file as an attachment to all
recipients. |
| 574 //comment: need reader supports | 411 //comment: need reader supports |
| 575 //note: | 412 //note: |
| 576 //int CPDFSDK_Document::mailForm(FX_BOOL bUI,String cto,string ccc,string cbcc,s
tring cSubject,string cms); | 413 //int CPDFSDK_Document::mailForm(FX_BOOL bUI,String cto,string ccc,string cbcc,s
tring cSubject,string cms); |
| 577 | 414 |
| 578 FX_BOOL Document::mailForm(OBJ_METHOD_PARAMS) | 415 FX_BOOL Document::mailForm(OBJ_METHOD_PARAMS) |
| 579 { | 416 { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 643 nStart = pprintp
aramsObj->nStart; | 480 nStart = pprintp
aramsObj->nStart; |
| 644 nEnd = pprintpar
amsObj->nEnd; | 481 nEnd = pprintpar
amsObj->nEnd; |
| 645 bSilent = pprint
paramsObj->bSilent; | 482 bSilent = pprint
paramsObj->bSilent; |
| 646 bShrinkToFit = p
printparamsObj->bShrinkToFit; | 483 bShrinkToFit = p
printparamsObj->bShrinkToFit; |
| 647 bPrintAsImage =
pprintparamsObj->bPrintAsImage; | 484 bPrintAsImage =
pprintparamsObj->bPrintAsImage; |
| 648 bReverse = pprin
tparamsObj->bReverse; | 485 bReverse = pprin
tparamsObj->bReverse; |
| 649 bAnnotations = p
printparamsObj->bAnnotations; | 486 bAnnotations = p
printparamsObj->bAnnotations; |
| 650 } | 487 } |
| 651 } | 488 } |
| 652 } | 489 } |
| 653 » » » }» | 490 » » » } |
| 654 } | 491 } |
| 655 } | 492 } |
| 656 else | 493 else |
| 657 { | 494 { |
| 658 if(nlength >= 1) | 495 if(nlength >= 1) |
| 659 bUI = params[0]; | 496 bUI = params[0]; |
| 660 if(nlength >= 2) | 497 if(nlength >= 2) |
| 661 nStart = (int)params[1]; | 498 nStart = (int)params[1]; |
| 662 if(nlength >= 3) | 499 if(nlength >= 3) |
| 663 nEnd = (int)params[2]; | 500 nEnd = (int)params[2]; |
| 664 if(nlength >= 4) | 501 if(nlength >= 4) |
| 665 bSilent = params[3]; | 502 bSilent = params[3]; |
| 666 if(nlength >= 5) | 503 if(nlength >= 5) |
| 667 bShrinkToFit = params[4]; | 504 bShrinkToFit = params[4]; |
| 668 if(nlength >= 6) | 505 if(nlength >= 6) |
| 669 bPrintAsImage = params[5]; | 506 bPrintAsImage = params[5]; |
| 670 if(nlength >= 7) | 507 if(nlength >= 7) |
| 671 bReverse = params[6]; | 508 bReverse = params[6]; |
| 672 if(nlength >= 8) | 509 if(nlength >= 8) |
| 673 bAnnotations = params[7]; | 510 bAnnotations = params[7]; |
| 674 } | 511 } |
| 675 | 512 |
| 676 ASSERT(m_pDocument != NULL); | 513 ASSERT(m_pDocument != NULL); |
| 677 | 514 |
| 678 if (CPDFDoc_Environment* pEnv = m_pDocument->GetEnv()) | 515 if (CPDFDoc_Environment* pEnv = m_pDocument->GetEnv()) |
| 679 { | 516 { |
| 680 pEnv->JS_docprint(bUI, nStart, nEnd, bSilent, bShrinkToFit, bPri
ntAsImage, bReverse, bAnnotations); | 517 pEnv->JS_docprint(bUI, nStart, nEnd, bSilent, bShrinkToFit, bPri
ntAsImage, bReverse, bAnnotations); |
| 681 return TRUE; | 518 return TRUE; |
| 682 } | 519 } |
| 683 return FALSE; | 520 return FALSE; |
| 684 } | 521 } |
| 685 | 522 |
| 686 //removes the specified field from the document. | 523 //removes the specified field from the document. |
| 687 //comment: | 524 //comment: |
| 688 //note: if the filed name is not retional, adobe is dumb for it. | 525 //note: if the filed name is not retional, adobe is dumb for it. |
| 689 | 526 |
| 690 FX_BOOL Document::removeField(OBJ_METHOD_PARAMS) | 527 FX_BOOL Document::removeField(OBJ_METHOD_PARAMS) |
| 691 { | 528 { |
| 692 ASSERT(m_pDocument != NULL); | 529 ASSERT(m_pDocument != NULL); |
| 693 | 530 |
| 694 » if (!(m_pDocument->GetPermissions(FPDFPERM_MODIFY) || | 531 » if (!(m_pDocument->GetPermissions(FPDFPERM_MODIFY) || |
| 695 m_pDocument->GetPermissions(FPDFPERM_ANNOT_FORM))) return FALSE; | 532 m_pDocument->GetPermissions(FPDFPERM_ANNOT_FORM))) return FALSE; |
| 696 | 533 |
| 697 if (params.size() < 1) | 534 if (params.size() < 1) |
| 698 return TRUE; | 535 return TRUE; |
| 699 | 536 |
| 700 CFX_WideString sFieldName = params[0].operator CFX_WideString(); | 537 CFX_WideString sFieldName = params[0].operator CFX_WideString(); |
| 701 | 538 |
| 702 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInte
rForm(); | 539 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInte
rForm(); |
| 703 ASSERT(pInterForm != NULL); | 540 ASSERT(pInterForm != NULL); |
| 704 | 541 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 718 rcAnnot.left -= 1; | 555 rcAnnot.left -= 1; |
| 719 rcAnnot.bottom -= 1; | 556 rcAnnot.bottom -= 1; |
| 720 rcAnnot.right += 1; | 557 rcAnnot.right += 1; |
| 721 rcAnnot.top += 1; | 558 rcAnnot.top += 1; |
| 722 | 559 |
| 723 CFX_RectArray aRefresh; | 560 CFX_RectArray aRefresh; |
| 724 aRefresh.Add(rcAnnot); | 561 aRefresh.Add(rcAnnot); |
| 725 | 562 |
| 726 CPDFXFA_Page* pPage = pWidget->GetPDFXFAPage(); | 563 CPDFXFA_Page* pPage = pWidget->GetPDFXFAPage(); |
| 727 ASSERT(pPage != NULL); | 564 ASSERT(pPage != NULL); |
| 728 » » » | 565 |
| 729 CPDFSDK_PageView* pPageView = m_pDocument->GetPageView(p
Page); | 566 CPDFSDK_PageView* pPageView = m_pDocument->GetPageView(p
Page); |
| 730 pPageView->DeleteAnnot(pWidget); | 567 pPageView->DeleteAnnot(pWidget); |
| 731 | 568 |
| 732 pPageView->UpdateRects(aRefresh); | 569 pPageView->UpdateRects(aRefresh); |
| 733 } | 570 } |
| 734 m_pDocument->SetChangeMark(); | 571 m_pDocument->SetChangeMark(); |
| 735 } | 572 } |
| 736 | 573 |
| 737 return TRUE; | 574 return TRUE; |
| 738 } | 575 } |
| 739 | 576 |
| 740 //reset filed values within a document. | 577 //reset filed values within a document. |
| 741 //comment: | 578 //comment: |
| 742 //note: if the fields names r not rational, aodbe is dumb for it. | 579 //note: if the fields names r not rational, aodbe is dumb for it. |
| 743 | 580 |
| 744 FX_BOOL Document::resetForm(OBJ_METHOD_PARAMS) | 581 FX_BOOL Document::resetForm(OBJ_METHOD_PARAMS) |
| 745 { | 582 { |
| 746 ASSERT(m_pDocument != NULL); | 583 ASSERT(m_pDocument != NULL); |
| 747 | 584 |
| 748 » if (!(m_pDocument->GetPermissions(FPDFPERM_MODIFY) || | 585 » if (!(m_pDocument->GetPermissions(FPDFPERM_MODIFY) || |
| 749 m_pDocument->GetPermissions(FPDFPERM_ANNOT_FORM) || | 586 m_pDocument->GetPermissions(FPDFPERM_ANNOT_FORM) || |
| 750 m_pDocument->GetPermissions(FPDFPERM_FILL_FORM))) return FALSE; | 587 m_pDocument->GetPermissions(FPDFPERM_FILL_FORM))) return FALSE; |
| 751 | 588 |
| 752 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInte
rForm(); | 589 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInte
rForm(); |
| 753 ASSERT(pInterForm != NULL); | 590 ASSERT(pInterForm != NULL); |
| 754 | 591 |
| 755 CPDF_InterForm* pPDFForm = pInterForm->GetInterForm(); | 592 CPDF_InterForm* pPDFForm = pInterForm->GetInterForm(); |
| 756 ASSERT(pPDFForm != NULL); | 593 ASSERT(pPDFForm != NULL); |
| 757 | 594 |
| 758 v8::Isolate* isolate = GetIsolate(cc); | 595 v8::Isolate* isolate = GetIsolate(cc); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 769 aName.SetElement(0,params[0]); | 606 aName.SetElement(0,params[0]); |
| 770 break; | 607 break; |
| 771 } | 608 } |
| 772 | 609 |
| 773 CFX_PtrArray aFields; | 610 CFX_PtrArray aFields; |
| 774 | 611 |
| 775 for (int i=0,isz=aName.GetLength(); i<isz; i++) | 612 for (int i=0,isz=aName.GetLength(); i<isz; i++) |
| 776 { | 613 { |
| 777 CJS_Value valElement(isolate); | 614 CJS_Value valElement(isolate); |
| 778 aName.GetElement(i,valElement); | 615 aName.GetElement(i,valElement); |
| 779 » » » CFX_WideString swVal = valElement.operator CFX_WideStrin
g();» | 616 » » » CFX_WideString swVal = valElement.operator CFX_WideStrin
g(); |
| 780 » » » | 617 |
| 781 for (int j=0,jsz=pPDFForm->CountFields(swVal); j<jsz; j+
+) | 618 for (int j=0,jsz=pPDFForm->CountFields(swVal); j<jsz; j+
+) |
| 782 { | 619 { |
| 783 aFields.Add((void*)pPDFForm->GetField(j,swVal)); | 620 aFields.Add((void*)pPDFForm->GetField(j,swVal)); |
| 784 » » » }» » | 621 » » » } |
| 785 } | 622 } |
| 786 | 623 |
| 787 if (aFields.GetSize() > 0) | 624 if (aFields.GetSize() > 0) |
| 788 { | 625 { |
| 789 pPDFForm->ResetForm(aFields, TRUE, TRUE); | 626 pPDFForm->ResetForm(aFields, TRUE, TRUE); |
| 790 m_pDocument->SetChangeMark(); | 627 m_pDocument->SetChangeMark(); |
| 791 | 628 |
| 792 } | 629 } |
| 793 } | 630 } |
| 794 else | 631 else |
| 795 { | 632 { |
| 796 pPDFForm->ResetForm(TRUE); | 633 pPDFForm->ResetForm(TRUE); |
| 797 m_pDocument->SetChangeMark(); | 634 m_pDocument->SetChangeMark(); |
| 798 | 635 |
| 799 } | 636 } |
| 800 | 637 |
| 801 return TRUE; | 638 return TRUE; |
| 802 } | 639 } |
| 803 | 640 |
| 804 | 641 |
| 805 FX_BOOL Document::saveAs(OBJ_METHOD_PARAMS) | 642 FX_BOOL Document::saveAs(OBJ_METHOD_PARAMS) |
| 806 { | 643 { |
| 807 | 644 // Unsafe, not supported. |
| 808 » if (IsSafeMode(cc)) return TRUE; | 645 return TRUE; |
| 809 | |
| 810 » ASSERT(m_pDocument != NULL); | |
| 811 | |
| 812 //» m_pDocument->DoSaveAs(); | |
| 813 | |
| 814 » return TRUE; | |
| 815 } | 646 } |
| 816 | 647 |
| 817 | 648 |
| 818 FX_BOOL Document::submitForm(OBJ_METHOD_PARAMS) | 649 FX_BOOL Document::submitForm(OBJ_METHOD_PARAMS) |
| 819 { | 650 { |
| 820 ASSERT(m_pDocument != NULL); | 651 ASSERT(m_pDocument != NULL); |
| 821 | 652 |
| 822 // if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) return FALSE; | 653 // if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) return FALSE; |
| 823 | 654 |
| 824 int nSize = params.size(); | 655 int nSize = params.size(); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 846 JSObject pObj = (JSObject)params[0]; | 677 JSObject pObj = (JSObject)params[0]; |
| 847 v8::Handle<v8::Value> pValue = JS_GetObjectElement(isolate,pObj,
L"cURL"); | 678 v8::Handle<v8::Value> pValue = JS_GetObjectElement(isolate,pObj,
L"cURL"); |
| 848 if (!pValue.IsEmpty()) | 679 if (!pValue.IsEmpty()) |
| 849 strURL = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)
); | 680 strURL = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)
); |
| 850 pValue = JS_GetObjectElement(isolate,pObj, L"bFDF"); | 681 pValue = JS_GetObjectElement(isolate,pObj, L"bFDF"); |
| 851 bFDF = CJS_Value(isolate,pValue, GET_VALUE_TYPE(pValue))
; | 682 bFDF = CJS_Value(isolate,pValue, GET_VALUE_TYPE(pValue))
; |
| 852 pValue = JS_GetObjectElement(isolate,pObj, L"bEmpty"); | 683 pValue = JS_GetObjectElement(isolate,pObj, L"bEmpty"); |
| 853 bEmpty = CJS_Value(isolate,pValue, GET_VALUE_TYPE(pValue
)); | 684 bEmpty = CJS_Value(isolate,pValue, GET_VALUE_TYPE(pValue
)); |
| 854 pValue = JS_GetObjectElement(isolate,pObj,L"aFields"); | 685 pValue = JS_GetObjectElement(isolate,pObj,L"aFields"); |
| 855 aFields.Attach(CJS_Value(isolate,pValue, GET_VALUE_TYPE(
pValue))); | 686 aFields.Attach(CJS_Value(isolate,pValue, GET_VALUE_TYPE(
pValue))); |
| 856 » }» » | 687 » } |
| 857 | 688 |
| 858 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInte
rForm(); | 689 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInte
rForm(); |
| 859 ASSERT(pInterForm != NULL); | 690 ASSERT(pInterForm != NULL); |
| 860 CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm(); | 691 CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm(); |
| 861 ASSERT(pPDFInterForm != NULL); | 692 ASSERT(pPDFInterForm != NULL); |
| 862 | 693 |
| 863 FX_BOOL bAll = (aFields.GetLength() == 0); | 694 FX_BOOL bAll = (aFields.GetLength() == 0); |
| 864 | 695 |
| 865 if (bAll && bEmpty) | 696 if (bAll && bEmpty) |
| 866 { | 697 { |
| 867 CJS_Context* pContext = (CJS_Context*)cc; | 698 CJS_Context* pContext = (CJS_Context*)cc; |
| 868 ASSERT(pContext != NULL); | 699 ASSERT(pContext != NULL); |
| 869 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 700 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
| 870 ASSERT(pRuntime != NULL); | 701 ASSERT(pRuntime != NULL); |
| 871 | 702 |
| 872 » » | 703 |
| 873 if (pPDFInterForm->CheckRequiredFields()) | 704 if (pPDFInterForm->CheckRequiredFields()) |
| 874 { | 705 { |
| 875 pRuntime->BeginBlock(); | 706 pRuntime->BeginBlock(); |
| 876 pInterForm->SubmitForm(strURL, FALSE); | 707 pInterForm->SubmitForm(strURL, FALSE); |
| 877 pRuntime->EndBlock(); | 708 pRuntime->EndBlock(); |
| 878 } | 709 } |
| 879 | 710 |
| 880 return TRUE; | 711 return TRUE; |
| 881 } | 712 } |
| 882 else | 713 else |
| 883 » {» | 714 » { |
| 884 CFX_PtrArray fieldObjects; | 715 CFX_PtrArray fieldObjects; |
| 885 | 716 |
| 886 for (int i=0,sz=aFields.GetLength(); i<sz; i++) | 717 for (int i=0,sz=aFields.GetLength(); i<sz; i++) |
| 887 { | 718 { |
| 888 CJS_Value valName(isolate); | 719 CJS_Value valName(isolate); |
| 889 aFields.GetElement(i, valName); | 720 aFields.GetElement(i, valName); |
| 890 CFX_WideString sName = valName.operator CFX_WideString()
; | 721 CFX_WideString sName = valName.operator CFX_WideString()
; |
| 891 | 722 |
| 892 CPDF_InterForm* pPDFForm = pInterForm->GetInterForm(); | 723 CPDF_InterForm* pPDFForm = pInterForm->GetInterForm(); |
| 893 ASSERT(pPDFForm != NULL); | 724 ASSERT(pPDFForm != NULL); |
| 894 | 725 |
| 895 for (int j=0, jsz=pPDFForm->CountFields(sName); j<jsz; j
++) | 726 for (int j=0, jsz=pPDFForm->CountFields(sName); j<jsz; j
++) |
| 896 { | 727 { |
| 897 CPDF_FormField* pField = pPDFForm->GetField(j, s
Name); | 728 CPDF_FormField* pField = pPDFForm->GetField(j, s
Name); |
| 898 if (!bEmpty && pField->GetValue().IsEmpty()) | 729 if (!bEmpty && pField->GetValue().IsEmpty()) |
| 899 continue; | 730 continue; |
| 900 | 731 |
| 901 fieldObjects.Add(pField); | 732 fieldObjects.Add(pField); |
| 902 } | 733 } |
| 903 } | 734 } |
| 904 | 735 |
| 905 CJS_Context* pContext = (CJS_Context*)cc; | 736 CJS_Context* pContext = (CJS_Context*)cc; |
| 906 ASSERT(pContext != NULL); | 737 ASSERT(pContext != NULL); |
| 907 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 738 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
| 908 ASSERT(pRuntime != NULL); | 739 ASSERT(pRuntime != NULL); |
| 909 | 740 |
| 910 » » | 741 |
| 911 if (pPDFInterForm->CheckRequiredFields(&fieldObjects, TRUE)) | 742 if (pPDFInterForm->CheckRequiredFields(&fieldObjects, TRUE)) |
| 912 { | 743 { |
| 913 pRuntime->BeginBlock(); | 744 pRuntime->BeginBlock(); |
| 914 pInterForm->SubmitFields(strURL, fieldObjects, TRUE, !bF
DF); | 745 pInterForm->SubmitFields(strURL, fieldObjects, TRUE, !bF
DF); |
| 915 pRuntime->EndBlock(); | 746 pRuntime->EndBlock(); |
| 916 } | 747 } |
| 917 | 748 |
| 918 return TRUE; | 749 return TRUE; |
| 919 } | 750 } |
| 920 | 751 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 936 { | 767 { |
| 937 return FALSE; | 768 return FALSE; |
| 938 } | 769 } |
| 939 | 770 |
| 940 FX_BOOL Document::ExtractFolderName(CPDFSDK_Document *pDoc,CFX_ByteString &strFo
lderName) | 771 FX_BOOL Document::ExtractFolderName(CPDFSDK_Document *pDoc,CFX_ByteString &strFo
lderName) |
| 941 { | 772 { |
| 942 return FALSE; | 773 return FALSE; |
| 943 } | 774 } |
| 944 | 775 |
| 945 FX_BOOL Document::bookmarkRoot(OBJ_PROP_PARAMS) | 776 FX_BOOL Document::bookmarkRoot(OBJ_PROP_PARAMS) |
| 946 {» | 777 { |
| 947 return TRUE; | 778 return TRUE; |
| 948 } | 779 } |
| 949 | 780 |
| 950 FX_BOOL Document::mailDoc(OBJ_METHOD_PARAMS) | 781 FX_BOOL Document::mailDoc(OBJ_METHOD_PARAMS) |
| 951 { | 782 { |
| 952 ASSERT(m_pDocument != NULL); | 783 ASSERT(m_pDocument != NULL); |
| 953 | 784 |
| 954 FX_BOOL bUI = TRUE; | 785 FX_BOOL bUI = TRUE; |
| 955 CFX_WideString cTo = L""; | 786 CFX_WideString cTo = L""; |
| 956 CFX_WideString cCc = L""; | 787 CFX_WideString cCc = L""; |
| 957 CFX_WideString cBcc = L""; | 788 CFX_WideString cBcc = L""; |
| 958 CFX_WideString cSubject = L""; | 789 CFX_WideString cSubject = L""; |
| 959 CFX_WideString cMsg = L""; | 790 CFX_WideString cMsg = L""; |
| 960 » | 791 |
| 961 | 792 |
| 962 bUI = params.size()>=1?static_cast<FX_BOOL>(params[0]):TRUE; | 793 bUI = params.size()>=1?static_cast<FX_BOOL>(params[0]):TRUE; |
| 963 cTo = params.size()>=2?(const wchar_t*)params[1].operator CFX_WideString
():L""; | 794 cTo = params.size()>=2?(const wchar_t*)params[1].operator CFX_WideString
():L""; |
| 964 cCc = params.size()>=3?(const wchar_t*)params[2].operator CFX_WideString
():L""; | 795 cCc = params.size()>=3?(const wchar_t*)params[2].operator CFX_WideString
():L""; |
| 965 cBcc = params.size()>=4?(const wchar_t*)params[3].operator CFX_WideStrin
g():L""; | 796 cBcc = params.size()>=4?(const wchar_t*)params[3].operator CFX_WideStrin
g():L""; |
| 966 cSubject = params.size()>=5?(const wchar_t*)params[4].operator CFX_WideS
tring():L""; | 797 cSubject = params.size()>=5?(const wchar_t*)params[4].operator CFX_WideS
tring():L""; |
| 967 cMsg = params.size()>=6?(const wchar_t*)params[5].operator CFX_WideStrin
g():L""; | 798 cMsg = params.size()>=6?(const wchar_t*)params[5].operator CFX_WideStrin
g():L""; |
| 968 » | 799 |
| 969 v8::Isolate* isolate = GetIsolate(cc); | 800 v8::Isolate* isolate = GetIsolate(cc); |
| 970 | 801 |
| 971 if(params.size()>=1 && params[0].GetType() == VT_object) | 802 if(params.size()>=1 && params[0].GetType() == VT_object) |
| 972 { | 803 { |
| 973 JSObject pObj = (JSObject )params[0]; | 804 JSObject pObj = (JSObject )params[0]; |
| 974 | 805 |
| 975 v8::Handle<v8::Value> pValue = JS_GetObjectElement(isolate,pObj,
L"bUI"); | 806 v8::Handle<v8::Value> pValue = JS_GetObjectElement(isolate,pObj,
L"bUI"); |
| 976 bUI = (int)CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValu
e)); | 807 bUI = (int)CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValu
e)); |
| 977 | 808 |
| 978 pValue = JS_GetObjectElement(isolate,pObj, L"cTo"); | 809 pValue = JS_GetObjectElement(isolate,pObj, L"cTo"); |
| 979 cTo = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).o
perator CFX_WideString(); | 810 cTo = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).o
perator CFX_WideString(); |
| 980 | 811 |
| 981 pValue = JS_GetObjectElement(isolate,pObj, L"cCc"); | 812 pValue = JS_GetObjectElement(isolate,pObj, L"cCc"); |
| 982 cCc = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).o
perator CFX_WideString(); | 813 cCc = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).o
perator CFX_WideString(); |
| 983 | 814 |
| 984 pValue = JS_GetObjectElement(isolate,pObj, L"cBcc"); | 815 pValue = JS_GetObjectElement(isolate,pObj, L"cBcc"); |
| 985 cBcc = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).
operator CFX_WideString(); | 816 cBcc = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).
operator CFX_WideString(); |
| 986 | 817 |
| 987 pValue = JS_GetObjectElement(isolate,pObj, L"cSubject"); | 818 pValue = JS_GetObjectElement(isolate,pObj, L"cSubject"); |
| 988 cSubject = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValu
e)).operator CFX_WideString(); | 819 cSubject = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValu
e)).operator CFX_WideString(); |
| 989 | 820 |
| 990 pValue = JS_GetObjectElement(isolate,pObj, L"cMsg"); | 821 pValue = JS_GetObjectElement(isolate,pObj, L"cMsg"); |
| 991 cMsg = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).
operator CFX_WideString(); | 822 cMsg = CJS_Value(isolate,pValue,GET_VALUE_TYPE(pValue)).
operator CFX_WideString(); |
| 992 » | 823 |
| 993 } | 824 } |
| 994 | 825 |
| 995 CJS_Context* pContext = (CJS_Context*)cc; | 826 CJS_Context* pContext = (CJS_Context*)cc; |
| 996 ASSERT(pContext != NULL); | 827 ASSERT(pContext != NULL); |
| 997 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 828 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
| 998 ASSERT(pRuntime != NULL); | 829 ASSERT(pRuntime != NULL); |
| 999 | 830 |
| 1000 pRuntime->BeginBlock(); | 831 pRuntime->BeginBlock(); |
| 1001 CPDFDoc_Environment* pEnv = pRuntime->GetReaderApp(); | 832 CPDFDoc_Environment* pEnv = pRuntime->GetReaderApp(); |
| 1002 pEnv->JS_docmailForm(NULL, 0, bUI, cTo.c_str(), cSubject.c_str(), cCc.c_
str(), cBcc.c_str(), cMsg.c_str()); | 833 pEnv->JS_docmailForm(NULL, 0, bUI, cTo.c_str(), cSubject.c_str(), cCc.c_
str(), cBcc.c_str(), cMsg.c_str()); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1057 JS_PutObjectString(isolate,pObj, L"Author", cwAuthor); | 888 JS_PutObjectString(isolate,pObj, L"Author", cwAuthor); |
| 1058 JS_PutObjectString(isolate,pObj, L"Title", cwTitle); | 889 JS_PutObjectString(isolate,pObj, L"Title", cwTitle); |
| 1059 JS_PutObjectString(isolate,pObj, L"Subject", cwSubject); | 890 JS_PutObjectString(isolate,pObj, L"Subject", cwSubject); |
| 1060 JS_PutObjectString(isolate,pObj, L"Keywords", cwKeywords); | 891 JS_PutObjectString(isolate,pObj, L"Keywords", cwKeywords); |
| 1061 JS_PutObjectString(isolate,pObj, L"Creator", cwCreator); | 892 JS_PutObjectString(isolate,pObj, L"Creator", cwCreator); |
| 1062 JS_PutObjectString(isolate,pObj, L"Producer", cwProducer); | 893 JS_PutObjectString(isolate,pObj, L"Producer", cwProducer); |
| 1063 JS_PutObjectString(isolate,pObj, L"CreationDate", cwCreationDate
); | 894 JS_PutObjectString(isolate,pObj, L"CreationDate", cwCreationDate
); |
| 1064 JS_PutObjectString(isolate,pObj, L"ModDate", cwModDate); | 895 JS_PutObjectString(isolate,pObj, L"ModDate", cwModDate); |
| 1065 JS_PutObjectString(isolate,pObj, L"Trapped", cwTrapped); | 896 JS_PutObjectString(isolate,pObj, L"Trapped", cwTrapped); |
| 1066 | 897 |
| 1067 // It's to be compatible to non-standard info dictionary.» | 898 // It's to be compatible to non-standard info dictionary. |
| 1068 FX_POSITION pos = pDictionary->GetStartPos(); | 899 FX_POSITION pos = pDictionary->GetStartPos(); |
| 1069 while(pos) | 900 while(pos) |
| 1070 { | 901 { |
| 1071 CFX_ByteString bsKey; | 902 CFX_ByteString bsKey; |
| 1072 CPDF_Object* pValueObj = pDictionary->GetNextElement(pos
, bsKey); | 903 CPDF_Object* pValueObj = pDictionary->GetNextElement(pos
, bsKey); |
| 1073 CFX_WideString wsKey = CFX_WideString::FromUTF8(bsKey,
bsKey.GetLength()); | 904 CFX_WideString wsKey = CFX_WideString::FromUTF8(bsKey,
bsKey.GetLength()); |
| 1074 if((pValueObj->GetType()==PDFOBJ_STRING) || (pValueObj->
GetType()==PDFOBJ_NAME) ) | 905 if((pValueObj->GetType()==PDFOBJ_STRING) || (pValueObj->
GetType()==PDFOBJ_NAME) ) |
| 1075 JS_PutObjectString(isolate,pObj, wsKey,
pValueObj->GetUnicodeText()); | 906 JS_PutObjectString(isolate,pObj, wsKey,
pValueObj->GetUnicodeText()); |
| 1076 if(pValueObj->GetType()==PDFOBJ_NUMBER) | 907 if(pValueObj->GetType()==PDFOBJ_NUMBER) |
| 1077 JS_PutObjectNumber(isolate,pObj, wsKey, (float)p
ValueObj->GetNumber()); | 908 JS_PutObjectNumber(isolate,pObj, wsKey, (float)p
ValueObj->GetNumber()); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1148 { | 979 { |
| 1149 ASSERT(m_pDocument != NULL); | 980 ASSERT(m_pDocument != NULL); |
| 1150 | 981 |
| 1151 if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) return FALSE; | 982 if (!m_pDocument->GetPermissions(FPDFPERM_MODIFY)) return FALSE; |
| 1152 | 983 |
| 1153 bool b; | 984 bool b; |
| 1154 vp >> b; | 985 vp >> b; |
| 1155 | 986 |
| 1156 m_bDelay = b; | 987 m_bDelay = b; |
| 1157 | 988 |
| 1158 » » if (m_bDelay) | 989 » » if (m_bDelay) |
| 1159 { | 990 { |
| 1160 for (int i=0,sz=m_DelayData.GetSize(); i<sz; i++) | 991 for (int i=0,sz=m_DelayData.GetSize(); i<sz; i++) |
| 1161 delete m_DelayData.GetAt(i); | 992 delete m_DelayData.GetAt(i); |
| 1162 | 993 |
| 1163 m_DelayData.RemoveAll(); | 994 m_DelayData.RemoveAll(); |
| 1164 } | 995 } |
| 1165 else | 996 else |
| 1166 { | 997 { |
| 1167 for (int i=0,sz=m_DelayData.GetSize(); i<sz; i++) | 998 for (int i=0,sz=m_DelayData.GetSize(); i<sz; i++) |
| 1168 { | 999 { |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1349 return TRUE; | 1180 return TRUE; |
| 1350 } | 1181 } |
| 1351 } | 1182 } |
| 1352 | 1183 |
| 1353 vp << 0; | 1184 vp << 0; |
| 1354 return TRUE; | 1185 return TRUE; |
| 1355 } | 1186 } |
| 1356 | 1187 |
| 1357 FX_BOOL Document::mouseX(OBJ_PROP_PARAMS) | 1188 FX_BOOL Document::mouseX(OBJ_PROP_PARAMS) |
| 1358 { | 1189 { |
| 1359 » return TRUE;» | 1190 » return TRUE; |
| 1360 } | 1191 } |
| 1361 | 1192 |
| 1362 FX_BOOL Document::mouseY(OBJ_PROP_PARAMS) | 1193 FX_BOOL Document::mouseY(OBJ_PROP_PARAMS) |
| 1363 { | 1194 { |
| 1364 return TRUE; | 1195 return TRUE; |
| 1365 } | 1196 } |
| 1366 | 1197 |
| 1367 FX_BOOL Document::baseURL(OBJ_PROP_PARAMS) | 1198 FX_BOOL Document::baseURL(OBJ_PROP_PARAMS) |
| 1368 { | 1199 { |
| 1369 if (vp.IsGetting()) | 1200 if (vp.IsGetting()) |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1480 | 1311 |
| 1481 return TRUE; | 1312 return TRUE; |
| 1482 } | 1313 } |
| 1483 | 1314 |
| 1484 FX_BOOL Document::pageWindowRect(OBJ_PROP_PARAMS) | 1315 FX_BOOL Document::pageWindowRect(OBJ_PROP_PARAMS) |
| 1485 { | 1316 { |
| 1486 return TRUE; | 1317 return TRUE; |
| 1487 } | 1318 } |
| 1488 | 1319 |
| 1489 FX_BOOL Document::layout(OBJ_PROP_PARAMS) | 1320 FX_BOOL Document::layout(OBJ_PROP_PARAMS) |
| 1490 {» | 1321 { |
| 1491 return TRUE; | 1322 return TRUE; |
| 1492 } | 1323 } |
| 1493 | 1324 |
| 1494 FX_BOOL Document::addLink(OBJ_METHOD_PARAMS) | 1325 FX_BOOL Document::addLink(OBJ_METHOD_PARAMS) |
| 1495 { | 1326 { |
| 1496 return TRUE; | 1327 return TRUE; |
| 1497 } | 1328 } |
| 1498 | 1329 |
| 1499 FX_BOOL Document::closeDoc(OBJ_METHOD_PARAMS) | 1330 FX_BOOL Document::closeDoc(OBJ_METHOD_PARAMS) |
| 1500 { | 1331 { |
| 1501 ASSERT(m_pDocument != NULL); | 1332 ASSERT(m_pDocument != NULL); |
| 1502 | 1333 |
| 1503 | 1334 |
| 1504 » | 1335 |
| 1505 » | 1336 |
| 1506 | 1337 |
| 1507 return TRUE; | 1338 return TRUE; |
| 1508 } | 1339 } |
| 1509 | 1340 |
| 1510 FX_BOOL Document::getPageBox(OBJ_METHOD_PARAMS) | 1341 FX_BOOL Document::getPageBox(OBJ_METHOD_PARAMS) |
| 1511 { | 1342 { |
| 1512 return TRUE; | 1343 return TRUE; |
| 1513 } | 1344 } |
| 1514 | 1345 |
| 1515 | 1346 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1530 return TRUE; | 1361 return TRUE; |
| 1531 } | 1362 } |
| 1532 | 1363 |
| 1533 FX_BOOL Document::getAnnots3D(OBJ_METHOD_PARAMS) | 1364 FX_BOOL Document::getAnnots3D(OBJ_METHOD_PARAMS) |
| 1534 { | 1365 { |
| 1535 vRet = VT_undefined; | 1366 vRet = VT_undefined; |
| 1536 return TRUE; | 1367 return TRUE; |
| 1537 } | 1368 } |
| 1538 | 1369 |
| 1539 FX_BOOL Document::getOCGs(OBJ_METHOD_PARAMS) | 1370 FX_BOOL Document::getOCGs(OBJ_METHOD_PARAMS) |
| 1540 {» | 1371 { |
| 1541 return TRUE; | 1372 return TRUE; |
| 1542 } | 1373 } |
| 1543 | 1374 |
| 1544 FX_BOOL Document::getLinks(OBJ_METHOD_PARAMS) | 1375 FX_BOOL Document::getLinks(OBJ_METHOD_PARAMS) |
| 1545 { | 1376 { |
| 1546 return TRUE; | 1377 return TRUE; |
| 1547 } | 1378 } |
| 1548 | 1379 |
| 1549 bool Document::IsEnclosedInRect(CFX_FloatRect rect, CFX_FloatRect LinkRect) | 1380 bool Document::IsEnclosedInRect(CFX_FloatRect rect, CFX_FloatRect LinkRect) |
| 1550 { | 1381 { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1570 { | 1401 { |
| 1571 m_pEnd->NextIcon = pNewIcon; | 1402 m_pEnd->NextIcon = pNewIcon; |
| 1572 m_pEnd = pNewIcon; | 1403 m_pEnd = pNewIcon; |
| 1573 m_iLength++; | 1404 m_iLength++; |
| 1574 } | 1405 } |
| 1575 } | 1406 } |
| 1576 | 1407 |
| 1577 void IconTree::DeleteIconTree() | 1408 void IconTree::DeleteIconTree() |
| 1578 { | 1409 { |
| 1579 if (!m_pHead || !m_pEnd)return; | 1410 if (!m_pHead || !m_pEnd)return; |
| 1580 » | 1411 |
| 1581 IconElement* pTemp = NULL; | 1412 IconElement* pTemp = NULL; |
| 1582 while(m_pEnd != m_pHead) | 1413 while(m_pEnd != m_pHead) |
| 1583 { | 1414 { |
| 1584 pTemp = m_pHead; | 1415 pTemp = m_pHead; |
| 1585 m_pHead = m_pHead->NextIcon; | 1416 m_pHead = m_pHead->NextIcon; |
| 1586 delete pTemp; | 1417 delete pTemp; |
| 1587 } | 1418 } |
| 1588 | 1419 |
| 1589 delete m_pEnd; | 1420 delete m_pEnd; |
| 1590 m_pHead = NULL; | 1421 m_pHead = NULL; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1607 } | 1438 } |
| 1608 return pTemp; | 1439 return pTemp; |
| 1609 } | 1440 } |
| 1610 else | 1441 else |
| 1611 return NULL; | 1442 return NULL; |
| 1612 } | 1443 } |
| 1613 | 1444 |
| 1614 void IconTree::DeleteIconElement(CFX_WideString swIconName) | 1445 void IconTree::DeleteIconElement(CFX_WideString swIconName) |
| 1615 { | 1446 { |
| 1616 IconElement* pTemp = m_pHead; | 1447 IconElement* pTemp = m_pHead; |
| 1617 » int iLoopCount = m_iLength; | 1448 » int iLoopCount = m_iLength; |
| 1618 for (int i = 0; i < iLoopCount - 1; i++) | 1449 for (int i = 0; i < iLoopCount - 1; i++) |
| 1619 { | 1450 { |
| 1620 if (pTemp == m_pEnd) | 1451 if (pTemp == m_pEnd) |
| 1621 break; | 1452 break; |
| 1622 » | 1453 |
| 1623 if (m_pHead->IconName == swIconName) | 1454 if (m_pHead->IconName == swIconName) |
| 1624 { | 1455 { |
| 1625 m_pHead = m_pHead->NextIcon; | 1456 m_pHead = m_pHead->NextIcon; |
| 1626 delete pTemp; | 1457 delete pTemp; |
| 1627 m_iLength--; | 1458 m_iLength--; |
| 1628 pTemp = m_pHead; | 1459 pTemp = m_pHead; |
| 1629 } | 1460 } |
| 1630 if (pTemp->NextIcon->IconName == swIconName) | 1461 if (pTemp->NextIcon->IconName == swIconName) |
| 1631 { | 1462 { |
| 1632 if (pTemp->NextIcon == m_pEnd) | 1463 if (pTemp->NextIcon == m_pEnd) |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1655 FX_BOOL Document::addIcon(OBJ_METHOD_PARAMS) | 1486 FX_BOOL Document::addIcon(OBJ_METHOD_PARAMS) |
| 1656 { | 1487 { |
| 1657 if (params.size() != 2)return FALSE; | 1488 if (params.size() != 2)return FALSE; |
| 1658 | 1489 |
| 1659 CJS_Context* pContext = (CJS_Context*)cc; | 1490 CJS_Context* pContext = (CJS_Context*)cc; |
| 1660 ASSERT(pContext != NULL); | 1491 ASSERT(pContext != NULL); |
| 1661 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 1492 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
| 1662 ASSERT(pRuntime != NULL); | 1493 ASSERT(pRuntime != NULL); |
| 1663 | 1494 |
| 1664 CFX_WideString swIconName = params[0].operator CFX_WideString(); | 1495 CFX_WideString swIconName = params[0].operator CFX_WideString(); |
| 1665 » | 1496 |
| 1666 JSFXObject pJSIcon = (JSFXObject)params[1]; | 1497 JSFXObject pJSIcon = (JSFXObject)params[1]; |
| 1667 if (JS_GetObjDefnID(pJSIcon) != JS_GetObjDefnID(*pRuntime, L"Icon")) ret
urn FALSE; | 1498 if (JS_GetObjDefnID(pJSIcon) != JS_GetObjDefnID(*pRuntime, L"Icon")) ret
urn FALSE; |
| 1668 | 1499 |
| 1669 CJS_EmbedObj* pEmbedObj = ((CJS_Object*)params[1])->GetEmbedObject(); | 1500 CJS_EmbedObj* pEmbedObj = ((CJS_Object*)params[1])->GetEmbedObject(); |
| 1670 if (!pEmbedObj)return FALSE; | 1501 if (!pEmbedObj)return FALSE; |
| 1671 Icon* pIcon = (Icon*)pEmbedObj; | 1502 Icon* pIcon = (Icon*)pEmbedObj; |
| 1672 | 1503 |
| 1673 if (!m_pIconTree) | 1504 if (!m_pIconTree) |
| 1674 m_pIconTree = new IconTree(); | 1505 m_pIconTree = new IconTree(); |
| 1675 | 1506 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1695 CJS_Array Icons(m_isolate); | 1526 CJS_Array Icons(m_isolate); |
| 1696 IconElement* pIconElement = NULL; | 1527 IconElement* pIconElement = NULL; |
| 1697 int iIconTreeLength = m_pIconTree->GetLength(); | 1528 int iIconTreeLength = m_pIconTree->GetLength(); |
| 1698 | 1529 |
| 1699 CJS_Context* pContext = (CJS_Context *)cc; | 1530 CJS_Context* pContext = (CJS_Context *)cc; |
| 1700 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 1531 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
| 1701 | 1532 |
| 1702 for (int i = 0; i < iIconTreeLength; i++) | 1533 for (int i = 0; i < iIconTreeLength; i++) |
| 1703 { | 1534 { |
| 1704 pIconElement = (*m_pIconTree)[i]; | 1535 pIconElement = (*m_pIconTree)[i]; |
| 1705 » » | 1536 |
| 1706 JSFXObject pObj = JS_NewFxDynamicObj(*pRuntime, pContext, JS_Ge
tObjDefnID(*pRuntime, L"Icon")); | 1537 JSFXObject pObj = JS_NewFxDynamicObj(*pRuntime, pContext, JS_Ge
tObjDefnID(*pRuntime, L"Icon")); |
| 1707 if (pObj.IsEmpty()) return FALSE; | 1538 if (pObj.IsEmpty()) return FALSE; |
| 1708 » » » » | 1539 |
| 1709 CJS_Icon * pJS_Icon = (CJS_Icon *)JS_GetPrivate(pObj); | 1540 CJS_Icon * pJS_Icon = (CJS_Icon *)JS_GetPrivate(pObj); |
| 1710 if (!pJS_Icon) return FALSE; | 1541 if (!pJS_Icon) return FALSE; |
| 1711 | 1542 |
| 1712 Icon* pIcon = (Icon*)pJS_Icon->GetEmbedObject(); | 1543 Icon* pIcon = (Icon*)pJS_Icon->GetEmbedObject(); |
| 1713 if (!pIcon)return FALSE; | 1544 if (!pIcon)return FALSE; |
| 1714 | 1545 |
| 1715 pIcon->SetStream(pIconElement->IconStream->GetStream()); | 1546 pIcon->SetStream(pIconElement->IconStream->GetStream()); |
| 1716 pIcon->SetIconName(pIconElement->IconName); | 1547 pIcon->SetIconName(pIconElement->IconName); |
| 1717 Icons.SetElement(i, CJS_Value(m_isolate,pJS_Icon)); | 1548 Icons.SetElement(i, CJS_Value(m_isolate,pJS_Icon)); |
| 1718 } | 1549 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1730 int iIconCounts = m_pIconTree->GetLength(); | 1561 int iIconCounts = m_pIconTree->GetLength(); |
| 1731 | 1562 |
| 1732 CJS_Context* pContext = (CJS_Context *)cc; | 1563 CJS_Context* pContext = (CJS_Context *)cc; |
| 1733 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); | 1564 CJS_Runtime* pRuntime = pContext->GetJSRuntime(); |
| 1734 | 1565 |
| 1735 for (int i = 0; i < iIconCounts; i++) | 1566 for (int i = 0; i < iIconCounts; i++) |
| 1736 { | 1567 { |
| 1737 if ((*m_pIconTree)[i]->IconName == swIconName) | 1568 if ((*m_pIconTree)[i]->IconName == swIconName) |
| 1738 { | 1569 { |
| 1739 Icon* pRetIcon = (*m_pIconTree)[i]->IconStream; | 1570 Icon* pRetIcon = (*m_pIconTree)[i]->IconStream; |
| 1740 » » » » | 1571 |
| 1741 JSFXObject pObj = JS_NewFxDynamicObj(*pRuntime, pContex
t, JS_GetObjDefnID(*pRuntime, L"Icon")); | 1572 JSFXObject pObj = JS_NewFxDynamicObj(*pRuntime, pContex
t, JS_GetObjDefnID(*pRuntime, L"Icon")); |
| 1742 if (pObj.IsEmpty()) return FALSE; | 1573 if (pObj.IsEmpty()) return FALSE; |
| 1743 » » » » » | 1574 |
| 1744 CJS_Icon * pJS_Icon = (CJS_Icon *)JS_GetPrivate(pObj); | 1575 CJS_Icon * pJS_Icon = (CJS_Icon *)JS_GetPrivate(pObj); |
| 1745 if (!pJS_Icon) return FALSE; | 1576 if (!pJS_Icon) return FALSE; |
| 1746 | 1577 |
| 1747 Icon* pIcon = (Icon*)pJS_Icon->GetEmbedObject(); | 1578 Icon* pIcon = (Icon*)pJS_Icon->GetEmbedObject(); |
| 1748 if (!pIcon)return FALSE; | 1579 if (!pIcon)return FALSE; |
| 1749 | 1580 |
| 1750 pIcon->SetIconName(swIconName); | 1581 pIcon->SetIconName(swIconName); |
| 1751 pIcon->SetStream(pRetIcon->GetStream()); | 1582 pIcon->SetStream(pRetIcon->GetStream()); |
| 1752 vRet = pJS_Icon; | 1583 vRet = pJS_Icon; |
| 1753 return TRUE; | 1584 return TRUE; |
| 1754 } | 1585 } |
| 1755 } | 1586 } |
| 1756 | 1587 |
| 1757 return FALSE; | 1588 return FALSE; |
| 1758 } | 1589 } |
| 1759 | 1590 |
| 1760 FX_BOOL Document::removeIcon(OBJ_METHOD_PARAMS) | 1591 FX_BOOL Document::removeIcon(OBJ_METHOD_PARAMS) |
| 1761 { | 1592 { |
| 1762 if (params.size() != 1)return FALSE; | 1593 if (params.size() != 1)return FALSE; |
| 1763 if(!m_pIconTree) | 1594 if(!m_pIconTree) |
| 1764 return FALSE; | 1595 return FALSE; |
| 1765 CFX_WideString swIconName = params[0].operator CFX_WideString(); | 1596 CFX_WideString swIconName = params[0].operator CFX_WideString(); |
| 1766 return TRUE; | 1597 return TRUE; |
| 1767 } | 1598 } |
| 1768 | 1599 |
| 1769 FX_BOOL Document::createDataObject(OBJ_METHOD_PARAMS) | 1600 FX_BOOL Document::createDataObject(OBJ_METHOD_PARAMS) |
| 1770 { | 1601 { |
| 1771 » if (IsSafeMode(cc)) return TRUE; | 1602 // Unsafe, not implemented. |
| 1772 » ASSERT(m_pDocument != NULL); | 1603 return TRUE; |
| 1773 | |
| 1774 » CFX_WideString swName = L""; | |
| 1775 » CFX_ByteString sbName = ""; | |
| 1776 » CFX_WideString swValue = L""; | |
| 1777 » CFX_WideString swMIMEType = L""; | |
| 1778 » CFX_WideString swCryptFilter = L""; | |
| 1779 » CFX_ByteString sbFileValue = ""; | |
| 1780 » | |
| 1781 » int iParamSize = params.size(); | |
| 1782 » for (int i = 0; i < iParamSize; i++) | |
| 1783 » { | |
| 1784 » » if (i == 0) | |
| 1785 » » » swName = params[0]; | |
| 1786 » » if (i == 1) | |
| 1787 » » » swValue = params[1]; | |
| 1788 » » if (i == 2) | |
| 1789 » » » swMIMEType = params[2]; | |
| 1790 » » if (i == 3) | |
| 1791 » » » swCryptFilter = params[4]; | |
| 1792 » } | |
| 1793 | |
| 1794 » FILE* pFile = NULL; | |
| 1795 | |
| 1796 » //CFileStatus fileStatus; | |
| 1797 » const int BUFSIZE = 17; | |
| 1798 » FX_BYTE buf[BUFSIZE]; | |
| 1799 » FX_BYTE *pBuffer = NULL; | |
| 1800 » char* pBuf = NULL; | |
| 1801 » int nFileSize = 0; | |
| 1802 » sbFileValue = CFX_ByteString::FromUnicode(swValue); | |
| 1803 » sbName = CFX_ByteString::FromUnicode(swName); | |
| 1804 » int iBufLength = sbFileValue.GetLength(); | |
| 1805 » pBuf = (char*)malloc(sizeof(char) * iBufLength); | |
| 1806 » pBuf = sbFileValue.GetBuffer(iBufLength); | |
| 1807 | |
| 1808 » if ( NULL == (pFile = FXSYS_fopen( sbName.GetBuffer(sbName.GetLength()),
"wb+" )) ) | |
| 1809 » { | |
| 1810 » » return FALSE; | |
| 1811 » } | |
| 1812 | |
| 1813 » fwrite( pBuf, sizeof(char), iBufLength, pFile ); | |
| 1814 » fclose( pFile ); | |
| 1815 » pFile = NULL; | |
| 1816 | |
| 1817 » pFile = FXSYS_fopen( sbName.GetBuffer(sbName.GetLength()), "rb+" ); | |
| 1818 » fseek( pFile, 0, SEEK_END ); | |
| 1819 » nFileSize = ftell( pFile ); | |
| 1820 | |
| 1821 » pBuffer = new FX_BYTE[nFileSize]; | |
| 1822 » fseek( pFile, 0, SEEK_SET ); | |
| 1823 » size_t s = fread( pBuffer, sizeof(char), nFileSize, pFile ); | |
| 1824 » if(s == 0) | |
| 1825 » { | |
| 1826 » » delete[] pBuffer; | |
| 1827 » » return FALSE; | |
| 1828 » } | |
| 1829 | |
| 1830 » CRYPT_MD5Generate(pBuffer, nFileSize, buf); | |
| 1831 » buf[BUFSIZE - 1] = 0; | |
| 1832 » CFX_WideString csCheckSum((FX_LPCWSTR)buf, 16); | |
| 1833 » delete[] pBuffer; | |
| 1834 | |
| 1835 » return TRUE; | |
| 1836 } | 1604 } |
| 1837 | 1605 |
| 1838 FX_BOOL Document::media(OBJ_PROP_PARAMS) | 1606 FX_BOOL Document::media(OBJ_PROP_PARAMS) |
| 1839 { | 1607 { |
| 1840 return TRUE; | 1608 return TRUE; |
| 1841 } | 1609 } |
| 1842 | 1610 |
| 1843 FX_BOOL Document::calculateNow(OBJ_METHOD_PARAMS) | 1611 FX_BOOL Document::calculateNow(OBJ_METHOD_PARAMS) |
| 1844 { | 1612 { |
| 1845 ASSERT(m_pDocument != NULL); | 1613 ASSERT(m_pDocument != NULL); |
| 1846 | 1614 |
| 1847 » if (!(m_pDocument->GetPermissions(FPDFPERM_MODIFY) || | 1615 » if (!(m_pDocument->GetPermissions(FPDFPERM_MODIFY) || |
| 1848 m_pDocument->GetPermissions(FPDFPERM_ANNOT_FORM) || | 1616 m_pDocument->GetPermissions(FPDFPERM_ANNOT_FORM) || |
| 1849 m_pDocument->GetPermissions(FPDFPERM_FILL_FORM))) return FALSE; | 1617 m_pDocument->GetPermissions(FPDFPERM_FILL_FORM))) return FALSE; |
| 1850 | 1618 |
| 1851 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInte
rForm(); | 1619 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)m_pDocument->GetInte
rForm(); |
| 1852 ASSERT(pInterForm != NULL); | 1620 ASSERT(pInterForm != NULL); |
| 1853 pInterForm->OnCalculate(); | 1621 pInterForm->OnCalculate(); |
| 1854 return TRUE; | 1622 return TRUE; |
| 1855 } | 1623 } |
| 1856 | 1624 |
| 1857 FX_BOOL Document::Collab(OBJ_PROP_PARAMS) | 1625 FX_BOOL Document::Collab(OBJ_PROP_PARAMS) |
| 1858 { | 1626 { |
| 1859 return TRUE; | 1627 return TRUE; |
| 1860 } | 1628 } |
| 1861 | 1629 |
| 1862 FX_BOOL Document::getPageNthWord(OBJ_METHOD_PARAMS) | 1630 FX_BOOL Document::getPageNthWord(OBJ_METHOD_PARAMS) |
| 1863 { | 1631 { |
| 1864 //if (IsSafeMode(cc)) return TRUE; | |
| 1865 | |
| 1866 ASSERT(m_pDocument != NULL); | 1632 ASSERT(m_pDocument != NULL); |
| 1867 | 1633 |
| 1868 if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) return FALSE; | 1634 if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) return FALSE; |
| 1869 | 1635 |
| 1870 int nPageNo = params.GetSize() > 0 ? (int)params[0] : 0; | 1636 int nPageNo = params.GetSize() > 0 ? (int)params[0] : 0; |
| 1871 int nWordNo = params.GetSize() > 1 ? (int)params[1] : 0; | 1637 int nWordNo = params.GetSize() > 1 ? (int)params[1] : 0; |
| 1872 bool bStrip = params.GetSize() > 2 ? (bool)params[2] : true; | 1638 bool bStrip = params.GetSize() > 2 ? (bool)params[2] : true; |
| 1873 | 1639 |
| 1874 CPDF_Document* pDocument = m_pDocument->GetDocument()->GetPDFDoc(); | 1640 CPDF_Document* pDocument = m_pDocument->GetDocument()->GetPDFDoc(); |
| 1875 if (!pDocument) return FALSE; | 1641 if (!pDocument) return FALSE; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1918 swRet.TrimLeft(); | 1684 swRet.TrimLeft(); |
| 1919 swRet.TrimRight(); | 1685 swRet.TrimRight(); |
| 1920 } | 1686 } |
| 1921 | 1687 |
| 1922 vRet = swRet; | 1688 vRet = swRet; |
| 1923 return TRUE; | 1689 return TRUE; |
| 1924 } | 1690 } |
| 1925 | 1691 |
| 1926 FX_BOOL Document::getPageNthWordQuads(OBJ_METHOD_PARAMS) | 1692 FX_BOOL Document::getPageNthWordQuads(OBJ_METHOD_PARAMS) |
| 1927 { | 1693 { |
| 1928 //if (IsSafeMode(cc)) return TRUE; | |
| 1929 | |
| 1930 ASSERT(m_pDocument != NULL); | 1694 ASSERT(m_pDocument != NULL); |
| 1931 | 1695 |
| 1932 if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) return FALSE; | 1696 if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT_ACCESS)) return FALSE; |
| 1933 | 1697 |
| 1934 return FALSE; | 1698 return FALSE; |
| 1935 } | 1699 } |
| 1936 | 1700 |
| 1937 FX_BOOL Document::getPageNumWords(OBJ_METHOD_PARAMS) | 1701 FX_BOOL Document::getPageNumWords(OBJ_METHOD_PARAMS) |
| 1938 { | 1702 { |
| 1939 ASSERT(m_pDocument != NULL); | 1703 ASSERT(m_pDocument != NULL); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2013 | 1777 |
| 2014 pTextObj->GetCharInfo(i, charcode, kerning); | 1778 pTextObj->GetCharInfo(i, charcode, kerning); |
| 2015 CFX_WideString swUnicode = pFont->UnicodeFromCharCode(charcode); | 1779 CFX_WideString swUnicode = pFont->UnicodeFromCharCode(charcode); |
| 2016 | 1780 |
| 2017 FX_WORD unicode = 0; | 1781 FX_WORD unicode = 0; |
| 2018 if (swUnicode.GetLength() > 0) | 1782 if (swUnicode.GetLength() > 0) |
| 2019 unicode = swUnicode[0]; | 1783 unicode = swUnicode[0]; |
| 2020 | 1784 |
| 2021 if (ISLATINWORD(unicode) && bIsLatin) | 1785 if (ISLATINWORD(unicode) && bIsLatin) |
| 2022 continue; | 1786 continue; |
| 2023 » » | 1787 |
| 2024 bIsLatin = ISLATINWORD(unicode); | 1788 bIsLatin = ISLATINWORD(unicode); |
| 2025 if (unicode != 0x20) | 1789 if (unicode != 0x20) |
| 2026 nWords++; | 1790 nWords++; |
| 2027 } | 1791 } |
| 2028 | 1792 |
| 2029 return nWords; | 1793 return nWords; |
| 2030 } | 1794 } |
| 2031 | 1795 |
| 2032 CFX_WideString Document::GetObjWordStr(CPDF_TextObject* pTextObj, int nWordIndex
) | 1796 CFX_WideString Document::GetObjWordStr(CPDF_TextObject* pTextObj, int nWordIndex
) |
| 2033 { | 1797 { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2050 CFX_WideString swUnicode = pFont->UnicodeFromCharCode(charcode); | 1814 CFX_WideString swUnicode = pFont->UnicodeFromCharCode(charcode); |
| 2051 | 1815 |
| 2052 FX_WORD unicode = 0; | 1816 FX_WORD unicode = 0; |
| 2053 if (swUnicode.GetLength() > 0) | 1817 if (swUnicode.GetLength() > 0) |
| 2054 unicode = swUnicode[0]; | 1818 unicode = swUnicode[0]; |
| 2055 | 1819 |
| 2056 if (ISLATINWORD(unicode) && bIsLatin) | 1820 if (ISLATINWORD(unicode) && bIsLatin) |
| 2057 { | 1821 { |
| 2058 } | 1822 } |
| 2059 else | 1823 else |
| 2060 » » {» » | 1824 » » { |
| 2061 bIsLatin = ISLATINWORD(unicode); | 1825 bIsLatin = ISLATINWORD(unicode); |
| 2062 if (unicode != 0x20) | 1826 if (unicode != 0x20) |
| 2063 » » » » nWords++;» | 1827 » » » » nWords++; |
| 2064 } | 1828 } |
| 2065 | 1829 |
| 2066 if (nWords-1 == nWordIndex) | 1830 if (nWords-1 == nWordIndex) |
| 2067 swRet += unicode; | 1831 swRet += unicode; |
| 2068 } | 1832 } |
| 2069 | 1833 |
| 2070 return swRet; | 1834 return swRet; |
| 2071 } | 1835 } |
| 2072 | 1836 |
| 2073 FX_BOOL Document::zoom(OBJ_PROP_PARAMS) | 1837 FX_BOOL Document::zoom(OBJ_PROP_PARAMS) |
| (...skipping 12 matching lines...) Expand all Loading... |
| 2086 (refW, ReflowWidth) | 1850 (refW, ReflowWidth) |
| 2087 */ | 1851 */ |
| 2088 | 1852 |
| 2089 FX_BOOL Document::zoomType(OBJ_PROP_PARAMS) | 1853 FX_BOOL Document::zoomType(OBJ_PROP_PARAMS) |
| 2090 { | 1854 { |
| 2091 return TRUE; | 1855 return TRUE; |
| 2092 } | 1856 } |
| 2093 | 1857 |
| 2094 FX_BOOL Document::deletePages(OBJ_METHOD_PARAMS) | 1858 FX_BOOL Document::deletePages(OBJ_METHOD_PARAMS) |
| 2095 { | 1859 { |
| 2096 | |
| 2097 | |
| 2098 | |
| 2099 | |
| 2100 | |
| 2101 | |
| 2102 v8::Isolate* isolate = GetIsolate(cc); | 1860 v8::Isolate* isolate = GetIsolate(cc); |
| 2103 // if (pEnv->GetAppName().Compare(PHANTOM) != 0) | |
| 2104 // return TRUE; | |
| 2105 | |
| 2106 //if (IsSafeMode(cc)) return TRUE; | |
| 2107 | |
| 2108 ASSERT(m_pDocument != NULL); | 1861 ASSERT(m_pDocument != NULL); |
| 2109 | 1862 |
| 2110 » if (!(m_pDocument->GetPermissions(FPDFPERM_MODIFY) || | 1863 » if (!(m_pDocument->GetPermissions(FPDFPERM_MODIFY) || |
| 2111 m_pDocument->GetPermissions(FPDFPERM_ASSEMBLE))) return FALSE; | 1864 m_pDocument->GetPermissions(FPDFPERM_ASSEMBLE))) return FALSE; |
| 2112 | 1865 |
| 2113 int iSize = params.size(); | 1866 int iSize = params.size(); |
| 2114 » | 1867 |
| 2115 int nStart = 0; | 1868 int nStart = 0; |
| 2116 int nEnd = 0; | 1869 int nEnd = 0; |
| 2117 » | 1870 |
| 2118 if (iSize < 1) | 1871 if (iSize < 1) |
| 2119 { | 1872 { |
| 2120 } | 1873 } |
| 2121 else if (iSize == 1) | 1874 else if (iSize == 1) |
| 2122 { | 1875 { |
| 2123 if (params[0].GetType() == VT_object) | 1876 if (params[0].GetType() == VT_object) |
| 2124 { | 1877 { |
| 2125 JSObject pObj = (JSObject )params[0]; | 1878 JSObject pObj = (JSObject )params[0]; |
| 2126 v8::Handle<v8::Value> pValue = JS_GetObjectElement(isola
te,pObj, L"nStart"); | 1879 v8::Handle<v8::Value> pValue = JS_GetObjectElement(isola
te,pObj, L"nStart"); |
| 2127 nStart = (int)CJS_Value(m_isolate,pValue,GET_VAL
UE_TYPE(pValue)); | 1880 nStart = (int)CJS_Value(m_isolate,pValue,GET_VAL
UE_TYPE(pValue)); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2143 int nTotal = m_pDocument->GetPageCount(); | 1896 int nTotal = m_pDocument->GetPageCount(); |
| 2144 | 1897 |
| 2145 if (nStart < 0) nStart = 0; | 1898 if (nStart < 0) nStart = 0; |
| 2146 if (nStart >= nTotal) nStart = nTotal - 1; | 1899 if (nStart >= nTotal) nStart = nTotal - 1; |
| 2147 | 1900 |
| 2148 if (nEnd < 0) nEnd = 0; | 1901 if (nEnd < 0) nEnd = 0; |
| 2149 if (nEnd >= nTotal) nEnd = nTotal - 1; | 1902 if (nEnd >= nTotal) nEnd = nTotal - 1; |
| 2150 | 1903 |
| 2151 if (nEnd < nStart) nEnd = nStart; | 1904 if (nEnd < nStart) nEnd = nStart; |
| 2152 | 1905 |
| 2153 » | 1906 |
| 2154 | 1907 |
| 2155 return TRUE; | 1908 return TRUE; |
| 2156 } | 1909 } |
| 2157 | 1910 |
| 2158 FX_BOOL Document::extractPages(OBJ_METHOD_PARAMS) | 1911 FX_BOOL Document::extractPages(OBJ_METHOD_PARAMS) |
| 2159 { | 1912 { |
| 2160 » | 1913 // Unsafe, not supported. |
| 2161 | 1914 return TRUE; |
| 2162 » | |
| 2163 » | |
| 2164 » | |
| 2165 | |
| 2166 » v8::Isolate* isolate = GetIsolate(cc); | |
| 2167 | |
| 2168 » if (IsSafeMode(cc)) return TRUE; | |
| 2169 | |
| 2170 » ASSERT(m_pDocument != NULL); | |
| 2171 | |
| 2172 » if (!m_pDocument->GetPermissions(FPDFPERM_EXTRACT)) return FALSE; | |
| 2173 | |
| 2174 » int iSize = params.size(); | |
| 2175 » | |
| 2176 » int nTotal = m_pDocument->GetPageCount(); | |
| 2177 » int nStart = 0; | |
| 2178 » int nEnd = nTotal - 1; | |
| 2179 | |
| 2180 » CFX_WideString swFilePath; | |
| 2181 » | |
| 2182 » if (iSize < 1) | |
| 2183 » { | |
| 2184 » } | |
| 2185 » else if (iSize == 1) | |
| 2186 » { | |
| 2187 » » if (params[0].GetType() == VT_object) | |
| 2188 » » { | |
| 2189 » » » JSObject pObj = (JSObject )params[0]; | |
| 2190 » » » v8::Handle<v8::Value> pValue = JS_GetObjectElement(isola
te,pObj, L"nStart"); | |
| 2191 » » » » nStart = (int)CJS_Value(m_isolate,pValue,GET_VAL
UE_TYPE(pValue)); | |
| 2192 | |
| 2193 » » » pValue = JS_GetObjectElement(isolate,pObj, L"nEnd"); | |
| 2194 » » » » nEnd = (int)CJS_Value(m_isolate,pValue,GET_VALUE
_TYPE(pValue)); | |
| 2195 | |
| 2196 » » » pValue = JS_GetObjectElement(isolate,pObj, L"cPath"); | |
| 2197 » » » » swFilePath = CJS_Value(m_isolate,pValue,GET_VALU
E_TYPE(pValue)).operator CFX_WideString(); | |
| 2198 » » } | |
| 2199 » » else | |
| 2200 » » { | |
| 2201 » » » nStart = (int)params[0]; | |
| 2202 » » } | |
| 2203 » } | |
| 2204 » else if (iSize == 2) | |
| 2205 » { | |
| 2206 » » nStart = (int)params[0]; | |
| 2207 » » nEnd = (int)params[1]; | |
| 2208 » } | |
| 2209 » else | |
| 2210 » { | |
| 2211 » » nStart = (int)params[0]; | |
| 2212 » » nEnd = (int)params[1]; | |
| 2213 » » swFilePath = params[2].operator CFX_WideString(); | |
| 2214 » } | |
| 2215 | |
| 2216 » if (nEnd < nStart) | |
| 2217 » » nEnd = nStart; | |
| 2218 | |
| 2219 » CPDF_Document *pNewDoc = new CPDF_Document; | |
| 2220 » pNewDoc->CreateNewDoc();» | |
| 2221 | |
| 2222 » CFX_WordArray array; | |
| 2223 » for (int i=nStart; i<=nEnd; i++) | |
| 2224 » » array.Add(i); | |
| 2225 | |
| 2226 //» m_pDocument->ExtractPages(array, pNewDoc); | |
| 2227 | |
| 2228 » if (swFilePath.IsEmpty()) | |
| 2229 » { | |
| 2230 | |
| 2231 » } | |
| 2232 » else | |
| 2233 » { | |
| 2234 » » swFilePath = app::PDFPathToSysPath(swFilePath); | |
| 2235 » » CPDF_Creator PDFCreater(pNewDoc); | |
| 2236 » » PDFCreater.Create(swFilePath); | |
| 2237 » » delete pNewDoc; | |
| 2238 //» » pEnv->OpenDocument(swFilePath); | |
| 2239 » » vRet.SetNull(); | |
| 2240 » } | |
| 2241 | |
| 2242 » return TRUE; | |
| 2243 } | 1915 } |
| 2244 | 1916 |
| 2245 FX_BOOL Document::insertPages(OBJ_METHOD_PARAMS) | 1917 FX_BOOL Document::insertPages(OBJ_METHOD_PARAMS) |
| 2246 { | 1918 { |
| 2247 | 1919 // Unsafe, not supported. |
| 2248 | 1920 return TRUE; |
| 2249 » | |
| 2250 | |
| 2251 | |
| 2252 | |
| 2253 » v8::Isolate* isolate = GetIsolate(cc); | |
| 2254 | |
| 2255 » if (IsSafeMode(cc)) return TRUE; | |
| 2256 | |
| 2257 » ASSERT(m_pDocument != NULL); | |
| 2258 | |
| 2259 » if (!(m_pDocument->GetPermissions(FPDFPERM_MODIFY) || | |
| 2260 » » m_pDocument->GetPermissions(FPDFPERM_ASSEMBLE))) return FALSE; | |
| 2261 | |
| 2262 » int iSize = params.size(); | |
| 2263 » | |
| 2264 » int nStart = 0; | |
| 2265 » int nEnd = 0; | |
| 2266 » int nPage = 0; | |
| 2267 | |
| 2268 » CFX_WideString swFilePath; | |
| 2269 » | |
| 2270 » if (iSize < 1) | |
| 2271 » { | |
| 2272 » } | |
| 2273 » else if (iSize == 1) | |
| 2274 » { | |
| 2275 » » if (params[0].GetType() == VT_object) | |
| 2276 » » { | |
| 2277 » » » JSObject pObj = (JSObject )params[0]; | |
| 2278 | |
| 2279 » » » v8::Handle<v8::Value> pValue = JS_GetObjectElement(isola
te,pObj, L"nPage"); | |
| 2280 » » » » nPage = (int)CJS_Value(m_isolate,pValue,GET_VALU
E_TYPE(pValue)); | |
| 2281 | |
| 2282 » » » pValue = JS_GetObjectElement(isolate,pObj, L"cPath"); | |
| 2283 » » » » swFilePath = CJS_Value(m_isolate,pValue,GET_VALU
E_TYPE(pValue)).operator CFX_WideString(); | |
| 2284 | |
| 2285 » » » pValue = JS_GetObjectElement(isolate,pObj, L"nStart"); | |
| 2286 » » » » nStart = (int)CJS_Value(m_isolate,pValue,GET_VAL
UE_TYPE(pValue)); | |
| 2287 | |
| 2288 » » » pValue = JS_GetObjectElement(isolate,pObj, L"nEnd"); | |
| 2289 » » » » nEnd = (int)CJS_Value(m_isolate,pValue,GET_VALUE
_TYPE(pValue)); | |
| 2290 » » } | |
| 2291 » » else | |
| 2292 » » { | |
| 2293 » » » nPage = (int)params[0]; | |
| 2294 » » } | |
| 2295 » } | |
| 2296 » else | |
| 2297 » { | |
| 2298 » » nPage = (int)params[0]; | |
| 2299 | |
| 2300 » » if (iSize >= 2) | |
| 2301 » » » swFilePath = params[1].operator CFX_WideString(); | |
| 2302 | |
| 2303 » » if (iSize >= 3) | |
| 2304 » » » nStart = (int)params[2]; | |
| 2305 | |
| 2306 » » if (iSize >= 4) | |
| 2307 » » » nEnd = (int)params[3]; | |
| 2308 » } | |
| 2309 | |
| 2310 » nPage++; | |
| 2311 | |
| 2312 » if (nPage < 0) | |
| 2313 » » nPage = 0; | |
| 2314 | |
| 2315 » if (nPage > m_pDocument->GetPageCount()) | |
| 2316 » » nPage = m_pDocument->GetPageCount(); | |
| 2317 | |
| 2318 » if (swFilePath.IsEmpty()) return FALSE; | |
| 2319 | |
| 2320 » swFilePath = app::PDFPathToSysPath(swFilePath); | |
| 2321 | |
| 2322 » CPDF_Parser pdfParser; | |
| 2323 » pdfParser.StartParse(swFilePath, FALSE); | |
| 2324 » CPDF_Document* pSrcDoc = pdfParser.GetDocument(); | |
| 2325 | |
| 2326 » if (!pSrcDoc) | |
| 2327 » { | |
| 2328 » » pdfParser.CloseParser(); | |
| 2329 » » return FALSE; | |
| 2330 » } | |
| 2331 | |
| 2332 » int nTotal = pSrcDoc->GetPageCount(); | |
| 2333 | |
| 2334 » if (nStart < 0)»nStart = 0; | |
| 2335 » if (nStart >= nTotal) nStart = nTotal - 1; | |
| 2336 | |
| 2337 » if (nEnd < 0) nEnd = 0; | |
| 2338 » if (nEnd >= nTotal) nEnd = nTotal - 1; | |
| 2339 | |
| 2340 » if (nEnd < nStart) nEnd = nStart; | |
| 2341 | |
| 2342 » CFX_WordArray array; | |
| 2343 » for (int i=nStart; i<=nEnd; i++) | |
| 2344 » » array.Add(i); | |
| 2345 | |
| 2346 //» m_pDocument->InsertPages(nPage, pSrcDoc, array); | |
| 2347 | |
| 2348 » pdfParser.CloseParser(); | |
| 2349 | |
| 2350 » return TRUE; | |
| 2351 } | 1921 } |
| 2352 | 1922 |
| 2353 FX_BOOL Document::replacePages(OBJ_METHOD_PARAMS) | 1923 FX_BOOL Document::replacePages(OBJ_METHOD_PARAMS) |
| 2354 { | 1924 { |
| 2355 | 1925 // Unsafe, not supported. |
| 2356 | 1926 return TRUE; |
| 2357 » | |
| 2358 | |
| 2359 | |
| 2360 | |
| 2361 » v8::Isolate* isolate = GetIsolate(cc); | |
| 2362 | |
| 2363 » if (IsSafeMode(cc)) return TRUE; | |
| 2364 | |
| 2365 » ASSERT(m_pDocument != NULL); | |
| 2366 | |
| 2367 » if (!(m_pDocument->GetPermissions(FPDFPERM_MODIFY) || | |
| 2368 » » m_pDocument->GetPermissions(FPDFPERM_ASSEMBLE))) return FALSE; | |
| 2369 | |
| 2370 » int iSize = params.size(); | |
| 2371 » | |
| 2372 » int nStart = -1; | |
| 2373 » int nEnd = -1; | |
| 2374 » int nPage = 0; | |
| 2375 | |
| 2376 » CFX_WideString swFilePath; | |
| 2377 » | |
| 2378 » if (iSize < 1) | |
| 2379 » { | |
| 2380 » } | |
| 2381 » else if (iSize == 1) | |
| 2382 » { | |
| 2383 » » if (params[0].GetType() == VT_object) | |
| 2384 » » { | |
| 2385 » » » JSObject pObj = (JSObject )params[0]; | |
| 2386 | |
| 2387 » » » v8::Handle<v8::Value> pValue = JS_GetObjectElement(isola
te,pObj, L"nPage"); | |
| 2388 » » » » nPage = (int)CJS_Value(m_isolate,pValue,GET_VALU
E_TYPE(pValue)); | |
| 2389 | |
| 2390 » » » pValue = JS_GetObjectElement(isolate,pObj, L"cPath"); | |
| 2391 » » » » swFilePath = CJS_Value(m_isolate,pValue,GET_VALU
E_TYPE(pValue)).operator CFX_WideString(); | |
| 2392 | |
| 2393 » » » pValue = JS_GetObjectElement(isolate,pObj, L"nStart"); | |
| 2394 » » » » nStart = (int)CJS_Value(m_isolate,pValue,GET_VAL
UE_TYPE(pValue)); | |
| 2395 | |
| 2396 » » » pValue = JS_GetObjectElement(isolate,pObj, L"nEnd"); | |
| 2397 » » » » nEnd = (int)CJS_Value(m_isolate,pValue,GET_VALUE
_TYPE(pValue)); | |
| 2398 » » } | |
| 2399 » » else | |
| 2400 » » { | |
| 2401 » » » nPage = (int)params[0]; | |
| 2402 » » } | |
| 2403 » } | |
| 2404 » else | |
| 2405 » { | |
| 2406 » » nPage = (int)params[0]; | |
| 2407 | |
| 2408 » » if (iSize >= 2) | |
| 2409 » » » swFilePath = params[1].operator CFX_WideString(); | |
| 2410 | |
| 2411 » » if (iSize >= 3) | |
| 2412 » » » nStart = (int)params[2]; | |
| 2413 | |
| 2414 » » if (iSize >= 4) | |
| 2415 » » » nEnd = (int)params[3]; | |
| 2416 » } | |
| 2417 | |
| 2418 » if (nPage < 0) | |
| 2419 » » nPage = 0; | |
| 2420 | |
| 2421 » if (nPage >= m_pDocument->GetPageCount()) | |
| 2422 » » nPage = m_pDocument->GetPageCount() - 1; | |
| 2423 | |
| 2424 » if (swFilePath.IsEmpty()) return FALSE; | |
| 2425 | |
| 2426 » swFilePath = app::PDFPathToSysPath(swFilePath); | |
| 2427 | |
| 2428 » CPDF_Parser pdfParser; | |
| 2429 » pdfParser.StartParse(swFilePath, FALSE); | |
| 2430 » CPDF_Document* pSrcDoc = pdfParser.GetDocument(); | |
| 2431 | |
| 2432 » if (!pSrcDoc) | |
| 2433 » { | |
| 2434 » » pdfParser.CloseParser(); | |
| 2435 » » return FALSE; | |
| 2436 » } | |
| 2437 | |
| 2438 » int nTotal = pSrcDoc->GetPageCount(); | |
| 2439 | |
| 2440 » if (nStart < 0) | |
| 2441 » { | |
| 2442 » » if (nEnd < 0) | |
| 2443 » » { | |
| 2444 » » » nStart = 0; | |
| 2445 » » » nEnd = nTotal - 1; | |
| 2446 » » } | |
| 2447 » » else | |
| 2448 » » { | |
| 2449 » » » nStart = 0; | |
| 2450 » » } | |
| 2451 » } | |
| 2452 » else | |
| 2453 » { | |
| 2454 » » if (nEnd < 0) | |
| 2455 » » { | |
| 2456 » » » nEnd = nStart; | |
| 2457 » » } | |
| 2458 » » else | |
| 2459 » » { | |
| 2460 » » » if (nStart >= nTotal) nStart = nTotal - 1; | |
| 2461 » » » if (nEnd >= nTotal) nEnd = nTotal - 1; | |
| 2462 | |
| 2463 » » » if (nEnd < nStart) nEnd = nStart; | |
| 2464 » » } | |
| 2465 » } | |
| 2466 | |
| 2467 » CFX_WordArray array; | |
| 2468 » for (int i=nStart; i<=nEnd; i++) | |
| 2469 » » array.Add(i); | |
| 2470 | |
| 2471 //» m_pDocument->ReplacePages(nPage, pSrcDoc, array); | |
| 2472 | |
| 2473 » pdfParser.CloseParser(); | |
| 2474 | |
| 2475 » return TRUE; | |
| 2476 } | 1927 } |
| 2477 | 1928 |
| 2478 FX_BOOL Document::getURL(OBJ_METHOD_PARAMS) | 1929 FX_BOOL Document::getURL(OBJ_METHOD_PARAMS) |
| 2479 { | 1930 { |
| 2480 » if (IsSafeMode(cc)) return TRUE; | 1931 // Unsafe, not supported. |
| 2481 | 1932 return TRUE; |
| 2482 » return TRUE; | |
| 2483 } | 1933 } |
| 2484 | 1934 |
| 2485 void Document::AddDelayData(CJS_DelayData* pData) | 1935 void Document::AddDelayData(CJS_DelayData* pData) |
| 2486 { | 1936 { |
| 2487 m_DelayData.Add(pData); | 1937 m_DelayData.Add(pData); |
| 2488 } | 1938 } |
| 2489 | 1939 |
| 2490 void Document::DoFieldDelay(const CFX_WideString& sFieldName, int nControlIndex) | 1940 void Document::DoFieldDelay(const CFX_WideString& sFieldName, int nControlIndex) |
| 2491 { | 1941 { |
| 2492 CFX_DWordArray DelArray; | 1942 CFX_DWordArray DelArray; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 2512 } | 1962 } |
| 2513 | 1963 |
| 2514 void Document::AddDelayAnnotData(CJS_AnnotObj *pData) | 1964 void Document::AddDelayAnnotData(CJS_AnnotObj *pData) |
| 2515 { | 1965 { |
| 2516 m_DelayAnnotData.Add(pData); | 1966 m_DelayAnnotData.Add(pData); |
| 2517 } | 1967 } |
| 2518 | 1968 |
| 2519 void Document::DoAnnotDelay() | 1969 void Document::DoAnnotDelay() |
| 2520 { | 1970 { |
| 2521 CFX_DWordArray DelArray; | 1971 CFX_DWordArray DelArray; |
| 2522 » | 1972 |
| 2523 for (int j=DelArray.GetSize()-1; j>=0; j--) | 1973 for (int j=DelArray.GetSize()-1; j>=0; j--) |
| 2524 { | 1974 { |
| 2525 m_DelayData.RemoveAt(DelArray[j]); | 1975 m_DelayData.RemoveAt(DelArray[j]); |
| 2526 } | 1976 } |
| 2527 } | 1977 } |
| OLD | NEW |