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 "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h" | 7 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h" |
8 | 8 |
9 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" | 9 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" |
10 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" | 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 m_nLoadStatus(FXFA_LOADSTATUS_PRELOAD), | 58 m_nLoadStatus(FXFA_LOADSTATUS_PRELOAD), |
59 m_nPageCount(0) {} | 59 m_nPageCount(0) {} |
60 | 60 |
61 CPDFXFA_Document::~CPDFXFA_Document() { | 61 CPDFXFA_Document::~CPDFXFA_Document() { |
62 m_nLoadStatus = FXFA_LOADSTATUS_CLOSING; | 62 m_nLoadStatus = FXFA_LOADSTATUS_CLOSING; |
63 | 63 |
64 if (m_pXFADoc) { | 64 if (m_pXFADoc) { |
65 CXFA_FFApp* pApp = m_pApp->GetXFAApp(); | 65 CXFA_FFApp* pApp = m_pApp->GetXFAApp(); |
66 if (pApp) { | 66 if (pApp) { |
67 CXFA_FFDocHandler* pDocHandler = pApp->GetDocHandler(); | 67 CXFA_FFDocHandler* pDocHandler = pApp->GetDocHandler(); |
68 if (pDocHandler) { | 68 if (pDocHandler) |
69 CloseXFADoc(pDocHandler); | 69 CloseXFADoc(pDocHandler); |
70 } | |
71 } | 70 } |
72 m_pXFADoc.reset(); | 71 m_pXFADoc.reset(); |
73 } | 72 } |
74 if (m_pJSContext && m_pSDKDoc && m_pSDKDoc->GetEnv()) | 73 if (m_pJSContext && m_pSDKDoc && m_pSDKDoc->GetEnv()) |
75 m_pSDKDoc->GetEnv()->GetJSRuntime()->ReleaseContext(m_pJSContext); | 74 m_pSDKDoc->GetEnv()->GetJSRuntime()->ReleaseContext(m_pJSContext); |
76 | 75 |
77 m_nLoadStatus = FXFA_LOADSTATUS_CLOSED; | 76 m_nLoadStatus = FXFA_LOADSTATUS_CLOSED; |
78 } | 77 } |
79 | 78 |
80 FX_BOOL CPDFXFA_Document::LoadXFADoc() { | 79 FX_BOOL CPDFXFA_Document::LoadXFADoc() { |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 m_XFAPageList.SetAt(page->GetPageIndex(), nullptr); | 212 m_XFAPageList.SetAt(page->GetPageIndex(), nullptr); |
214 } | 213 } |
215 | 214 |
216 CPDFSDK_Document* CPDFXFA_Document::GetSDKDocument( | 215 CPDFSDK_Document* CPDFXFA_Document::GetSDKDocument( |
217 CPDFDoc_Environment* pFormFillEnv) { | 216 CPDFDoc_Environment* pFormFillEnv) { |
218 if (!m_pSDKDoc && pFormFillEnv) | 217 if (!m_pSDKDoc && pFormFillEnv) |
219 m_pSDKDoc.reset(new CPDFSDK_Document(this, pFormFillEnv)); | 218 m_pSDKDoc.reset(new CPDFSDK_Document(this, pFormFillEnv)); |
220 return m_pSDKDoc.get(); | 219 return m_pSDKDoc.get(); |
221 } | 220 } |
222 | 221 |
223 void CPDFXFA_Document::FXRect2PDFRect(const CFX_RectF& fxRectF, | |
224 CFX_FloatRect& pdfRect) { | |
225 pdfRect.left = fxRectF.left; | |
226 pdfRect.top = fxRectF.bottom(); | |
227 pdfRect.right = fxRectF.right(); | |
228 pdfRect.bottom = fxRectF.top; | |
229 } | |
230 | |
231 void CPDFXFA_Document::SetChangeMark(CXFA_FFDoc* hDoc) { | 222 void CPDFXFA_Document::SetChangeMark(CXFA_FFDoc* hDoc) { |
232 if (hDoc == m_pXFADoc.get() && m_pSDKDoc) { | 223 if (hDoc == m_pXFADoc.get() && m_pSDKDoc) |
233 m_pSDKDoc->SetChangeMark(); | 224 m_pSDKDoc->SetChangeMark(); |
234 } | |
235 } | 225 } |
236 | 226 |
237 void CPDFXFA_Document::InvalidateRect(CXFA_FFPageView* pPageView, | 227 void CPDFXFA_Document::InvalidateRect(CXFA_FFPageView* pPageView, |
238 const CFX_RectF& rt, | 228 const CFX_RectF& rt, |
239 uint32_t dwFlags /* = 0 */) { | 229 uint32_t dwFlags /* = 0 */) { |
240 if (!m_pXFADoc || !m_pSDKDoc) | 230 if (!m_pXFADoc || !m_pSDKDoc) |
241 return; | 231 return; |
242 | 232 |
243 if (m_iDocType != DOCTYPE_DYNAMIC_XFA) | 233 if (m_iDocType != DOCTYPE_DYNAMIC_XFA) |
244 return; | 234 return; |
245 | 235 |
246 CFX_FloatRect rcPage; | |
247 FXRect2PDFRect(rt, rcPage); | |
248 | |
249 CPDFXFA_Page* pPage = GetPage(pPageView); | 236 CPDFXFA_Page* pPage = GetPage(pPageView); |
250 if (!pPage) | 237 if (!pPage) |
251 return; | 238 return; |
252 | 239 |
253 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 240 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
254 if (!pEnv) | 241 if (!pEnv) |
255 return; | 242 return; |
256 | 243 |
| 244 CFX_FloatRect rcPage = CFX_FloatRect::FromCFXRectF(rt); |
257 pEnv->FFI_Invalidate((FPDF_PAGE)pPage, rcPage.left, rcPage.bottom, | 245 pEnv->FFI_Invalidate((FPDF_PAGE)pPage, rcPage.left, rcPage.bottom, |
258 rcPage.right, rcPage.top); | 246 rcPage.right, rcPage.top); |
259 } | 247 } |
260 | 248 |
261 void CPDFXFA_Document::DisplayCaret(CXFA_FFWidget* hWidget, | 249 void CPDFXFA_Document::DisplayCaret(CXFA_FFWidget* hWidget, |
262 FX_BOOL bVisible, | 250 FX_BOOL bVisible, |
263 const CFX_RectF* pRtAnchor) { | 251 const CFX_RectF* pRtAnchor) { |
264 if (!hWidget || !pRtAnchor || !m_pXFADoc || !m_pSDKDoc || !m_pXFADocView) | 252 if (!hWidget || !pRtAnchor || !m_pXFADoc || !m_pSDKDoc || !m_pXFADocView) |
265 return; | 253 return; |
266 | 254 |
267 if (m_iDocType != DOCTYPE_DYNAMIC_XFA) | 255 if (m_iDocType != DOCTYPE_DYNAMIC_XFA) |
268 return; | 256 return; |
269 | 257 |
270 CXFA_FFWidgetHandler* pWidgetHandler = m_pXFADocView->GetWidgetHandler(); | 258 CXFA_FFWidgetHandler* pWidgetHandler = m_pXFADocView->GetWidgetHandler(); |
271 if (!pWidgetHandler) | 259 if (!pWidgetHandler) |
272 return; | 260 return; |
273 | 261 |
274 CXFA_FFPageView* pPageView = hWidget->GetPageView(); | 262 CXFA_FFPageView* pPageView = hWidget->GetPageView(); |
275 if (!pPageView) | 263 if (!pPageView) |
276 return; | 264 return; |
277 | 265 |
278 CPDFXFA_Page* pPage = GetPage(pPageView); | 266 CPDFXFA_Page* pPage = GetPage(pPageView); |
279 if (!pPage) | 267 if (!pPage) |
280 return; | 268 return; |
281 | 269 |
282 CFX_FloatRect rcCaret; | |
283 FXRect2PDFRect(*pRtAnchor, rcCaret); | |
284 | |
285 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 270 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
286 if (!pEnv) | 271 if (!pEnv) |
287 return; | 272 return; |
288 | 273 |
| 274 CFX_FloatRect rcCaret = CFX_FloatRect::FromCFXRectF(*pRtAnchor); |
289 pEnv->FFI_DisplayCaret((FPDF_PAGE)pPage, bVisible, rcCaret.left, rcCaret.top, | 275 pEnv->FFI_DisplayCaret((FPDF_PAGE)pPage, bVisible, rcCaret.left, rcCaret.top, |
290 rcCaret.right, rcCaret.bottom); | 276 rcCaret.right, rcCaret.bottom); |
291 } | 277 } |
292 | 278 |
293 FX_BOOL CPDFXFA_Document::GetPopupPos(CXFA_FFWidget* hWidget, | 279 FX_BOOL CPDFXFA_Document::GetPopupPos(CXFA_FFWidget* hWidget, |
294 FX_FLOAT fMinPopup, | 280 FX_FLOAT fMinPopup, |
295 FX_FLOAT fMaxPopup, | 281 FX_FLOAT fMaxPopup, |
296 const CFX_RectF& rtAnchor, | 282 const CFX_RectF& rtAnchor, |
297 CFX_RectF& rtPopup) { | 283 CFX_RectF& rtPopup) { |
298 if (!hWidget) | 284 if (!hWidget) |
299 return FALSE; | 285 return FALSE; |
300 | 286 |
301 CXFA_FFPageView* pXFAPageView = hWidget->GetPageView(); | 287 CXFA_FFPageView* pXFAPageView = hWidget->GetPageView(); |
302 if (!pXFAPageView) | 288 if (!pXFAPageView) |
303 return FALSE; | 289 return FALSE; |
304 | 290 |
305 CPDFXFA_Page* pPage = GetPage(pXFAPageView); | 291 CPDFXFA_Page* pPage = GetPage(pXFAPageView); |
306 if (!pPage) | 292 if (!pPage) |
307 return FALSE; | 293 return FALSE; |
308 | 294 |
309 CXFA_WidgetAcc* pWidgetAcc = hWidget->GetDataAcc(); | 295 CXFA_WidgetAcc* pWidgetAcc = hWidget->GetDataAcc(); |
310 int nRotate = pWidgetAcc->GetRotate(); | 296 int nRotate = pWidgetAcc->GetRotate(); |
311 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 297 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
312 if (!pEnv) | 298 if (!pEnv) |
313 return FALSE; | 299 return FALSE; |
| 300 |
314 FS_RECTF pageViewRect = {0.0f, 0.0f, 0.0f, 0.0f}; | 301 FS_RECTF pageViewRect = {0.0f, 0.0f, 0.0f, 0.0f}; |
315 pEnv->FFI_GetPageViewRect(pPage, pageViewRect); | 302 pEnv->FFI_GetPageViewRect(pPage, pageViewRect); |
316 | 303 |
317 CFX_FloatRect rcAnchor; | 304 int t1; |
318 rcAnchor.left = rtAnchor.left; | 305 int t2; |
319 rcAnchor.top = rtAnchor.bottom(); | 306 CFX_FloatRect rcAnchor = CFX_FloatRect::FromCFXRectF(rtAnchor); |
320 rcAnchor.right = rtAnchor.right(); | |
321 rcAnchor.bottom = rtAnchor.top; | |
322 | |
323 int t1, t2, t; | |
324 uint32_t dwPos; | |
325 FX_FLOAT fPoupHeight; | |
326 switch (nRotate) { | 307 switch (nRotate) { |
327 case 90: { | 308 case 90: { |
328 t1 = (int)(pageViewRect.right - rcAnchor.right); | 309 t1 = (int)(pageViewRect.right - rcAnchor.right); |
329 t2 = (int)(rcAnchor.left - pageViewRect.left); | 310 t2 = (int)(rcAnchor.left - pageViewRect.left); |
330 if (rcAnchor.bottom < pageViewRect.bottom) { | 311 if (rcAnchor.bottom < pageViewRect.bottom) |
331 rtPopup.left += rcAnchor.bottom - pageViewRect.bottom; | 312 rtPopup.left += rcAnchor.bottom - pageViewRect.bottom; |
332 } | |
333 | |
334 break; | 313 break; |
335 } | 314 } |
336 | |
337 case 180: { | 315 case 180: { |
338 t2 = (int)(pageViewRect.top - rcAnchor.top); | 316 t2 = (int)(pageViewRect.top - rcAnchor.top); |
339 t1 = (int)(rcAnchor.bottom - pageViewRect.bottom); | 317 t1 = (int)(rcAnchor.bottom - pageViewRect.bottom); |
340 if (rcAnchor.left < pageViewRect.left) { | 318 if (rcAnchor.left < pageViewRect.left) |
341 rtPopup.left += rcAnchor.left - pageViewRect.left; | 319 rtPopup.left += rcAnchor.left - pageViewRect.left; |
342 } | |
343 break; | 320 break; |
344 } | 321 } |
345 case 270: { | 322 case 270: { |
346 t1 = (int)(rcAnchor.left - pageViewRect.left); | 323 t1 = (int)(rcAnchor.left - pageViewRect.left); |
347 t2 = (int)(pageViewRect.right - rcAnchor.right); | 324 t2 = (int)(pageViewRect.right - rcAnchor.right); |
348 | 325 if (rcAnchor.top > pageViewRect.top) |
349 if (rcAnchor.top > pageViewRect.top) { | |
350 rtPopup.left -= rcAnchor.top - pageViewRect.top; | 326 rtPopup.left -= rcAnchor.top - pageViewRect.top; |
351 } | |
352 break; | 327 break; |
353 } | 328 } |
354 case 0: | 329 case 0: |
355 default: { | 330 default: { |
356 t1 = (int)(pageViewRect.top - rcAnchor.top); | 331 t1 = (int)(pageViewRect.top - rcAnchor.top); |
357 t2 = (int)(rcAnchor.bottom - pageViewRect.bottom); | 332 t2 = (int)(rcAnchor.bottom - pageViewRect.bottom); |
358 if (rcAnchor.right > pageViewRect.right) { | 333 if (rcAnchor.right > pageViewRect.right) |
359 rtPopup.left -= rcAnchor.right - pageViewRect.right; | 334 rtPopup.left -= rcAnchor.right - pageViewRect.right; |
360 } | |
361 break; | 335 break; |
362 } | 336 } |
363 } | 337 } |
364 | 338 |
365 if (t1 <= 0 && t2 <= 0) { | 339 int t; |
| 340 uint32_t dwPos; |
| 341 if (t1 <= 0 && t2 <= 0) |
366 return FALSE; | 342 return FALSE; |
367 } | |
368 if (t1 <= 0) { | 343 if (t1 <= 0) { |
369 t = t2; | 344 t = t2; |
370 dwPos = 1; | 345 dwPos = 1; |
371 } else if (t2 <= 0) { | 346 } else if (t2 <= 0) { |
372 t = t1; | 347 t = t1; |
373 dwPos = 0; | 348 dwPos = 0; |
374 } else if (t1 > t2) { | 349 } else if (t1 > t2) { |
375 t = t1; | 350 t = t1; |
376 dwPos = 0; | 351 dwPos = 0; |
377 } else { | 352 } else { |
378 t = t2; | 353 t = t2; |
379 dwPos = 1; | 354 dwPos = 1; |
380 } | 355 } |
381 if (t < fMinPopup) { | 356 |
382 fPoupHeight = fMinPopup; | 357 FX_FLOAT fPopupHeight; |
383 } else if (t > fMaxPopup) { | 358 if (t < fMinPopup) |
384 fPoupHeight = fMaxPopup; | 359 fPopupHeight = fMinPopup; |
385 } else { | 360 else if (t > fMaxPopup) |
386 fPoupHeight = (FX_FLOAT)t; | 361 fPopupHeight = fMaxPopup; |
387 } | 362 else |
| 363 fPopupHeight = static_cast<FX_FLOAT>(t); |
388 | 364 |
389 switch (nRotate) { | 365 switch (nRotate) { |
390 case 0: | 366 case 0: |
391 case 180: { | 367 case 180: { |
392 if (dwPos == 0) { | 368 if (dwPos == 0) { |
393 rtPopup.top = rtAnchor.height; | 369 rtPopup.top = rtAnchor.height; |
394 rtPopup.height = fPoupHeight; | 370 rtPopup.height = fPopupHeight; |
395 } else { | 371 } else { |
396 rtPopup.top = -fPoupHeight; | 372 rtPopup.top = -fPopupHeight; |
397 rtPopup.height = fPoupHeight; | 373 rtPopup.height = fPopupHeight; |
398 } | 374 } |
399 break; | 375 break; |
400 } | 376 } |
401 case 90: | 377 case 90: |
402 case 270: { | 378 case 270: { |
403 if (dwPos == 0) { | 379 if (dwPos == 0) { |
404 rtPopup.top = rtAnchor.width; | 380 rtPopup.top = rtAnchor.width; |
405 rtPopup.height = fPoupHeight; | 381 rtPopup.height = fPopupHeight; |
406 } else { | 382 } else { |
407 rtPopup.top = -fPoupHeight; | 383 rtPopup.top = -fPopupHeight; |
408 rtPopup.height = fPoupHeight; | 384 rtPopup.height = fPopupHeight; |
409 } | 385 } |
410 break; | 386 break; |
411 } | 387 } |
412 default: | 388 default: |
413 break; | 389 break; |
414 } | 390 } |
415 | 391 |
416 return TRUE; | 392 return TRUE; |
417 } | 393 } |
418 | 394 |
419 FX_BOOL CPDFXFA_Document::PopupMenu(CXFA_FFWidget* hWidget, | 395 FX_BOOL CPDFXFA_Document::PopupMenu(CXFA_FFWidget* hWidget, |
420 CFX_PointF ptPopup, | 396 CFX_PointF ptPopup) { |
421 const CFX_RectF* pRectExclude) { | |
422 if (!hWidget) | 397 if (!hWidget) |
423 return FALSE; | 398 return FALSE; |
424 | 399 |
425 CXFA_FFPageView* pXFAPageView = hWidget->GetPageView(); | 400 CXFA_FFPageView* pXFAPageView = hWidget->GetPageView(); |
426 if (!pXFAPageView) | 401 if (!pXFAPageView) |
427 return FALSE; | 402 return FALSE; |
428 | 403 |
429 CPDFXFA_Page* pPage = GetPage(pXFAPageView); | 404 CPDFXFA_Page* pPage = GetPage(pXFAPageView); |
430 if (!pPage) | 405 if (!pPage) |
431 return FALSE; | 406 return FALSE; |
432 | 407 |
| 408 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
| 409 if (!pEnv) |
| 410 return FALSE; |
| 411 |
433 int menuFlag = 0; | 412 int menuFlag = 0; |
| 413 if (hWidget->CanUndo()) |
| 414 menuFlag |= FXFA_MENU_UNDO; |
| 415 if (hWidget->CanRedo()) |
| 416 menuFlag |= FXFA_MENU_REDO; |
| 417 if (hWidget->CanPaste()) |
| 418 menuFlag |= FXFA_MENU_PASTE; |
| 419 if (hWidget->CanCopy()) |
| 420 menuFlag |= FXFA_MENU_COPY; |
| 421 if (hWidget->CanCut()) |
| 422 menuFlag |= FXFA_MENU_CUT; |
| 423 if (hWidget->CanSelectAll()) |
| 424 menuFlag |= FXFA_MENU_SELECTALL; |
434 | 425 |
435 if (hWidget->CanUndo()) | 426 return pEnv->FFI_PopupMenu(pPage, hWidget, menuFlag, ptPopup, nullptr); |
436 menuFlag |= FXFA_MEMU_UNDO; | |
437 if (hWidget->CanRedo()) | |
438 menuFlag |= FXFA_MEMU_REDO; | |
439 if (hWidget->CanPaste()) | |
440 menuFlag |= FXFA_MEMU_PASTE; | |
441 if (hWidget->CanCopy()) | |
442 menuFlag |= FXFA_MEMU_COPY; | |
443 if (hWidget->CanCut()) | |
444 menuFlag |= FXFA_MEMU_CUT; | |
445 if (hWidget->CanSelectAll()) | |
446 menuFlag |= FXFA_MEMU_SELECTALL; | |
447 | |
448 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | |
449 return pEnv && | |
450 pEnv->FFI_PopupMenu(pPage, hWidget, menuFlag, ptPopup, nullptr); | |
451 } | 427 } |
452 | 428 |
453 void CPDFXFA_Document::PageViewEvent(CXFA_FFPageView* pPageView, | 429 void CPDFXFA_Document::PageViewEvent(CXFA_FFPageView* pPageView, |
454 uint32_t dwFlags) { | 430 uint32_t dwFlags) { |
455 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 431 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
456 if (!pEnv) | 432 if (!pEnv) |
457 return; | 433 return; |
458 | 434 |
459 if (m_nLoadStatus != FXFA_LOADSTATUS_LOADING && | 435 if (m_nLoadStatus == FXFA_LOADSTATUS_LOADING || |
460 m_nLoadStatus != FXFA_LOADSTATUS_CLOSING && | 436 m_nLoadStatus == FXFA_LOADSTATUS_CLOSING || |
461 XFA_PAGEVIEWEVENT_StopLayout == dwFlags) { | 437 XFA_PAGEVIEWEVENT_StopLayout != dwFlags) |
462 int nNewCount = GetPageCount(); | 438 return; |
463 if (nNewCount == m_nPageCount) | |
464 return; | |
465 | 439 |
466 CXFA_FFDocView* pXFADocView = GetXFADocView(); | 440 int nNewCount = GetPageCount(); |
467 if (!pXFADocView) | 441 if (nNewCount == m_nPageCount) |
468 return; | 442 return; |
469 for (int iPageIter = 0; iPageIter < m_nPageCount; iPageIter++) { | |
470 CPDFXFA_Page* pPage = m_XFAPageList.GetAt(iPageIter); | |
471 if (!pPage) | |
472 continue; | |
473 m_pSDKDoc->RemovePageView(pPage); | |
474 CXFA_FFPageView* pXFAPageView = pXFADocView->GetPageView(iPageIter); | |
475 pPage->SetXFAPageView(pXFAPageView); | |
476 } | |
477 | 443 |
478 int flag = (nNewCount < m_nPageCount) ? FXFA_PAGEVIEWEVENT_POSTREMOVED | 444 CXFA_FFDocView* pXFADocView = GetXFADocView(); |
479 : FXFA_PAGEVIEWEVENT_POSTADDED; | 445 if (!pXFADocView) |
480 int count = FXSYS_abs(nNewCount - m_nPageCount); | 446 return; |
481 m_nPageCount = nNewCount; | 447 |
482 m_XFAPageList.SetSize(nNewCount); | 448 for (int iPageIter = 0; iPageIter < m_nPageCount; iPageIter++) { |
483 pEnv->FFI_PageEvent(count, flag); | 449 CPDFXFA_Page* pPage = m_XFAPageList.GetAt(iPageIter); |
| 450 if (!pPage) |
| 451 continue; |
| 452 |
| 453 m_pSDKDoc->RemovePageView(pPage); |
| 454 pPage->SetXFAPageView(pXFADocView->GetPageView(iPageIter)); |
484 } | 455 } |
| 456 |
| 457 int flag = (nNewCount < m_nPageCount) ? FXFA_PAGEVIEWEVENT_POSTREMOVED |
| 458 : FXFA_PAGEVIEWEVENT_POSTADDED; |
| 459 int count = FXSYS_abs(nNewCount - m_nPageCount); |
| 460 m_nPageCount = nNewCount; |
| 461 m_XFAPageList.SetSize(nNewCount); |
| 462 pEnv->FFI_PageEvent(count, flag); |
485 } | 463 } |
486 | 464 |
487 void CPDFXFA_Document::WidgetPostAdd(CXFA_FFWidget* hWidget, | 465 void CPDFXFA_Document::WidgetPostAdd(CXFA_FFWidget* hWidget, |
488 CXFA_WidgetAcc* pWidgetData) { | 466 CXFA_WidgetAcc* pWidgetData) { |
489 if (m_iDocType != DOCTYPE_DYNAMIC_XFA || !hWidget) | 467 if (m_iDocType != DOCTYPE_DYNAMIC_XFA || !hWidget) |
490 return; | 468 return; |
491 | 469 |
492 CXFA_FFPageView* pPageView = hWidget->GetPageView(); | 470 CXFA_FFPageView* pPageView = hWidget->GetPageView(); |
493 if (!pPageView) | 471 if (!pPageView) |
494 return; | 472 return; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 | 514 |
537 return pEnv->FFI_GetCurrentPageIndex(this); | 515 return pEnv->FFI_GetCurrentPageIndex(this); |
538 } | 516 } |
539 | 517 |
540 void CPDFXFA_Document::SetCurrentPage(CXFA_FFDoc* hDoc, int32_t iCurPage) { | 518 void CPDFXFA_Document::SetCurrentPage(CXFA_FFDoc* hDoc, int32_t iCurPage) { |
541 if (hDoc != m_pXFADoc.get() || !m_pSDKDoc || | 519 if (hDoc != m_pXFADoc.get() || !m_pSDKDoc || |
542 m_iDocType != DOCTYPE_DYNAMIC_XFA || iCurPage < 0 || | 520 m_iDocType != DOCTYPE_DYNAMIC_XFA || iCurPage < 0 || |
543 iCurPage >= m_pSDKDoc->GetPageCount()) { | 521 iCurPage >= m_pSDKDoc->GetPageCount()) { |
544 return; | 522 return; |
545 } | 523 } |
| 524 |
546 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 525 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
547 if (!pEnv) | 526 if (!pEnv) |
548 return; | 527 return; |
549 pEnv->FFI_SetCurrentPage(this, iCurPage); | 528 pEnv->FFI_SetCurrentPage(this, iCurPage); |
550 } | 529 } |
551 | 530 |
552 FX_BOOL CPDFXFA_Document::IsCalculationsEnabled(CXFA_FFDoc* hDoc) { | 531 FX_BOOL CPDFXFA_Document::IsCalculationsEnabled(CXFA_FFDoc* hDoc) { |
553 if (hDoc != m_pXFADoc.get() || !m_pSDKDoc) | 532 if (hDoc != m_pXFADoc.get() || !m_pSDKDoc) |
554 return FALSE; | 533 return FALSE; |
555 if (m_pSDKDoc->GetInterForm()) | 534 if (m_pSDKDoc->GetInterForm()) |
556 return m_pSDKDoc->GetInterForm()->IsXfaCalculateEnabled(); | 535 return m_pSDKDoc->GetInterForm()->IsXfaCalculateEnabled(); |
557 | |
558 return FALSE; | 536 return FALSE; |
559 } | 537 } |
560 | 538 |
561 void CPDFXFA_Document::SetCalculationsEnabled(CXFA_FFDoc* hDoc, | 539 void CPDFXFA_Document::SetCalculationsEnabled(CXFA_FFDoc* hDoc, |
562 FX_BOOL bEnabled) { | 540 FX_BOOL bEnabled) { |
563 if (hDoc != m_pXFADoc.get() || !m_pSDKDoc) | 541 if (hDoc != m_pXFADoc.get() || !m_pSDKDoc) |
564 return; | 542 return; |
565 if (m_pSDKDoc->GetInterForm()) | 543 if (m_pSDKDoc->GetInterForm()) |
566 m_pSDKDoc->GetInterForm()->XfaEnableCalculate(bEnabled); | 544 m_pSDKDoc->GetInterForm()->XfaEnableCalculate(bEnabled); |
567 } | 545 } |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
599 | 577 |
600 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 578 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
601 if (!pEnv) | 579 if (!pEnv) |
602 return; | 580 return; |
603 | 581 |
604 int fileType = bXDP ? FXFA_SAVEAS_XDP : FXFA_SAVEAS_XML; | 582 int fileType = bXDP ? FXFA_SAVEAS_XDP : FXFA_SAVEAS_XML; |
605 CFX_ByteString bs = wsFilePath.UTF16LE_Encode(); | 583 CFX_ByteString bs = wsFilePath.UTF16LE_Encode(); |
606 if (wsFilePath.IsEmpty()) { | 584 if (wsFilePath.IsEmpty()) { |
607 if (!pEnv->GetFormFillInfo() || !pEnv->GetFormFillInfo()->m_pJsPlatform) | 585 if (!pEnv->GetFormFillInfo() || !pEnv->GetFormFillInfo()->m_pJsPlatform) |
608 return; | 586 return; |
| 587 |
609 CFX_WideString filepath = pEnv->JS_fieldBrowse(); | 588 CFX_WideString filepath = pEnv->JS_fieldBrowse(); |
610 bs = filepath.UTF16LE_Encode(); | 589 bs = filepath.UTF16LE_Encode(); |
611 } | 590 } |
612 int len = bs.GetLength() / sizeof(unsigned short); | 591 int len = bs.GetLength(); |
613 FPDF_FILEHANDLER* pFileHandler = pEnv->FFI_OpenFile( | 592 FPDF_FILEHANDLER* pFileHandler = |
614 bXDP ? FXFA_SAVEAS_XDP : FXFA_SAVEAS_XML, | 593 pEnv->FFI_OpenFile(bXDP ? FXFA_SAVEAS_XDP : FXFA_SAVEAS_XML, |
615 (FPDF_WIDESTRING)bs.GetBuffer(len * sizeof(unsigned short)), "wb"); | 594 (FPDF_WIDESTRING)bs.GetBuffer(len), "wb"); |
616 bs.ReleaseBuffer(len * sizeof(unsigned short)); | 595 bs.ReleaseBuffer(len); |
617 if (!pFileHandler) | 596 if (!pFileHandler) |
618 return; | 597 return; |
619 | 598 |
620 CFPDF_FileStream fileWrite(pFileHandler); | 599 CFPDF_FileStream fileWrite(pFileHandler); |
621 CFX_ByteString content; | 600 CFX_ByteString content; |
622 if (fileType == FXFA_SAVEAS_XML) { | 601 if (fileType == FXFA_SAVEAS_XML) { |
623 content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"; | 602 content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"; |
624 fileWrite.WriteBlock(content.c_str(), fileWrite.GetSize(), | 603 fileWrite.WriteBlock(content.c_str(), fileWrite.GetSize(), |
625 content.GetLength()); | 604 content.GetLength()); |
626 m_pXFADocView->GetDoc()->SavePackage(XFA_HASHCODE_Data, &fileWrite, | 605 m_pXFADocView->GetDoc()->SavePackage(XFA_HASHCODE_Data, &fileWrite, |
627 nullptr); | 606 nullptr); |
628 } else if (fileType == FXFA_SAVEAS_XDP) { | 607 } else if (fileType == FXFA_SAVEAS_XDP) { |
629 if (!m_pPDFDoc) | 608 if (!m_pPDFDoc) |
630 return; | 609 return; |
| 610 |
631 CPDF_Dictionary* pRoot = m_pPDFDoc->GetRoot(); | 611 CPDF_Dictionary* pRoot = m_pPDFDoc->GetRoot(); |
632 if (!pRoot) | 612 if (!pRoot) |
633 return; | 613 return; |
| 614 |
634 CPDF_Dictionary* pAcroForm = pRoot->GetDictBy("AcroForm"); | 615 CPDF_Dictionary* pAcroForm = pRoot->GetDictBy("AcroForm"); |
635 if (!pAcroForm) | 616 if (!pAcroForm) |
636 return; | 617 return; |
| 618 |
637 CPDF_Array* pArray = ToArray(pAcroForm->GetObjectBy("XFA")); | 619 CPDF_Array* pArray = ToArray(pAcroForm->GetObjectBy("XFA")); |
638 if (!pArray) | 620 if (!pArray) |
639 return; | 621 return; |
640 | 622 |
641 int size = pArray->GetCount(); | 623 int size = pArray->GetCount(); |
642 for (int i = 1; i < size; i += 2) { | 624 for (int i = 1; i < size; i += 2) { |
643 CPDF_Object* pPDFObj = pArray->GetObjectAt(i); | 625 CPDF_Object* pPDFObj = pArray->GetObjectAt(i); |
644 CPDF_Object* pPrePDFObj = pArray->GetObjectAt(i - 1); | 626 CPDF_Object* pPrePDFObj = pArray->GetObjectAt(i - 1); |
645 if (!pPrePDFObj->IsString()) | 627 if (!pPrePDFObj->IsString()) |
646 continue; | 628 continue; |
647 if (!pPDFObj->IsReference()) | 629 if (!pPDFObj->IsReference()) |
648 continue; | 630 continue; |
| 631 |
649 CPDF_Stream* pStream = ToStream(pPDFObj->GetDirect()); | 632 CPDF_Stream* pStream = ToStream(pPDFObj->GetDirect()); |
650 if (!pStream) | 633 if (!pStream) |
651 continue; | 634 continue; |
652 if (pPrePDFObj->GetString() == "form") { | 635 if (pPrePDFObj->GetString() == "form") { |
653 m_pXFADocView->GetDoc()->SavePackage(XFA_HASHCODE_Form, &fileWrite, | 636 m_pXFADocView->GetDoc()->SavePackage(XFA_HASHCODE_Form, &fileWrite, |
654 nullptr); | 637 nullptr); |
655 } else if (pPrePDFObj->GetString() == "datasets") { | 638 continue; |
| 639 } |
| 640 if (pPrePDFObj->GetString() == "datasets") { |
656 m_pXFADocView->GetDoc()->SavePackage(XFA_HASHCODE_Datasets, &fileWrite, | 641 m_pXFADocView->GetDoc()->SavePackage(XFA_HASHCODE_Datasets, &fileWrite, |
657 nullptr); | 642 nullptr); |
658 } else { | 643 continue; |
659 if (i == size - 1) { | |
660 CFX_WideString wPath = CFX_WideString::FromUTF16LE( | |
661 reinterpret_cast<const unsigned short*>(bs.c_str()), | |
662 bs.GetLength() / sizeof(unsigned short)); | |
663 CFX_ByteString bPath = wPath.UTF8Encode(); | |
664 const char* szFormat = | |
665 "\n<pdf href=\"%s\" xmlns=\"http://ns.adobe.com/xdp/pdf/\"/>"; | |
666 content.Format(szFormat, bPath.c_str()); | |
667 fileWrite.WriteBlock(content.c_str(), fileWrite.GetSize(), | |
668 content.GetLength()); | |
669 } | |
670 std::unique_ptr<CPDF_StreamAcc> pAcc(new CPDF_StreamAcc); | |
671 pAcc->LoadAllData(pStream); | |
672 fileWrite.WriteBlock(pAcc->GetData(), fileWrite.GetSize(), | |
673 pAcc->GetSize()); | |
674 } | 644 } |
| 645 if (i == size - 1) { |
| 646 CFX_WideString wPath = CFX_WideString::FromUTF16LE( |
| 647 reinterpret_cast<const unsigned short*>(bs.c_str()), |
| 648 bs.GetLength() / sizeof(unsigned short)); |
| 649 CFX_ByteString bPath = wPath.UTF8Encode(); |
| 650 const char* szFormat = |
| 651 "\n<pdf href=\"%s\" xmlns=\"http://ns.adobe.com/xdp/pdf/\"/>"; |
| 652 content.Format(szFormat, bPath.c_str()); |
| 653 fileWrite.WriteBlock(content.c_str(), fileWrite.GetSize(), |
| 654 content.GetLength()); |
| 655 } |
| 656 std::unique_ptr<CPDF_StreamAcc> pAcc(new CPDF_StreamAcc); |
| 657 pAcc->LoadAllData(pStream); |
| 658 fileWrite.WriteBlock(pAcc->GetData(), fileWrite.GetSize(), |
| 659 pAcc->GetSize()); |
675 } | 660 } |
676 } | 661 } |
677 if (!fileWrite.Flush()) { | 662 if (!fileWrite.Flush()) { |
678 // Ignoring flush error. | 663 // Ignoring flush error. |
679 } | 664 } |
680 } | 665 } |
681 | 666 |
682 void CPDFXFA_Document::GotoURL(CXFA_FFDoc* hDoc, | 667 void CPDFXFA_Document::GotoURL(CXFA_FFDoc* hDoc, |
683 const CFX_WideString& bsURL, | 668 const CFX_WideString& bsURL, |
684 FX_BOOL bAppend) { | 669 FX_BOOL bAppend) { |
(...skipping 10 matching lines...) Expand all Loading... |
695 CFX_WideStringC str(bsURL.c_str()); | 680 CFX_WideStringC str(bsURL.c_str()); |
696 | 681 |
697 pEnv->FFI_GotoURL(this, str, bAppend); | 682 pEnv->FFI_GotoURL(this, str, bAppend); |
698 } | 683 } |
699 | 684 |
700 FX_BOOL CPDFXFA_Document::IsValidationsEnabled(CXFA_FFDoc* hDoc) { | 685 FX_BOOL CPDFXFA_Document::IsValidationsEnabled(CXFA_FFDoc* hDoc) { |
701 if (hDoc != m_pXFADoc.get() || !m_pSDKDoc) | 686 if (hDoc != m_pXFADoc.get() || !m_pSDKDoc) |
702 return FALSE; | 687 return FALSE; |
703 if (m_pSDKDoc->GetInterForm()) | 688 if (m_pSDKDoc->GetInterForm()) |
704 return m_pSDKDoc->GetInterForm()->IsXfaValidationsEnabled(); | 689 return m_pSDKDoc->GetInterForm()->IsXfaValidationsEnabled(); |
705 | |
706 return TRUE; | 690 return TRUE; |
707 } | 691 } |
708 | 692 |
709 void CPDFXFA_Document::SetValidationsEnabled(CXFA_FFDoc* hDoc, | 693 void CPDFXFA_Document::SetValidationsEnabled(CXFA_FFDoc* hDoc, |
710 FX_BOOL bEnabled) { | 694 FX_BOOL bEnabled) { |
711 if (hDoc != m_pXFADoc.get() || !m_pSDKDoc) | 695 if (hDoc != m_pXFADoc.get() || !m_pSDKDoc) |
712 return; | 696 return; |
713 if (m_pSDKDoc->GetInterForm()) | 697 if (m_pSDKDoc->GetInterForm()) |
714 m_pSDKDoc->GetInterForm()->XfaSetValidationsEnabled(bEnabled); | 698 m_pSDKDoc->GetInterForm()->XfaSetValidationsEnabled(bEnabled); |
715 } | 699 } |
716 | 700 |
717 void CPDFXFA_Document::SetFocusWidget(CXFA_FFDoc* hDoc, | 701 void CPDFXFA_Document::SetFocusWidget(CXFA_FFDoc* hDoc, |
718 CXFA_FFWidget* hWidget) { | 702 CXFA_FFWidget* hWidget) { |
719 if (hDoc != m_pXFADoc.get()) | 703 if (hDoc != m_pXFADoc.get()) |
720 return; | 704 return; |
721 | 705 |
722 if (!hWidget) { | 706 if (!hWidget) { |
723 m_pSDKDoc->SetFocusAnnot(nullptr); | 707 m_pSDKDoc->SetFocusAnnot(nullptr); |
724 return; | 708 return; |
725 } | 709 } |
726 | 710 |
727 int pageViewCount = m_pSDKDoc->GetPageViewCount(); | 711 int pageViewCount = m_pSDKDoc->GetPageViewCount(); |
728 for (int i = 0; i < pageViewCount; i++) { | 712 for (int i = 0; i < pageViewCount; i++) { |
729 CPDFSDK_PageView* pPageView = m_pSDKDoc->GetPageView(i); | 713 CPDFSDK_PageView* pPageView = m_pSDKDoc->GetPageView(i); |
730 if (!pPageView) | 714 if (!pPageView) |
731 continue; | 715 continue; |
| 716 |
732 CPDFSDK_Annot* pAnnot = pPageView->GetAnnotByXFAWidget(hWidget); | 717 CPDFSDK_Annot* pAnnot = pPageView->GetAnnotByXFAWidget(hWidget); |
733 if (pAnnot) { | 718 if (pAnnot) { |
734 m_pSDKDoc->SetFocusAnnot(pAnnot); | 719 m_pSDKDoc->SetFocusAnnot(pAnnot); |
735 break; | 720 break; |
736 } | 721 } |
737 } | 722 } |
738 } | 723 } |
739 | 724 |
740 void CPDFXFA_Document::Print(CXFA_FFDoc* hDoc, | 725 void CPDFXFA_Document::Print(CXFA_FFDoc* hDoc, |
741 int32_t nStartPage, | 726 int32_t nStartPage, |
(...skipping 10 matching lines...) Expand all Loading... |
752 } | 737 } |
753 | 738 |
754 pEnv->GetFormFillInfo()->m_pJsPlatform->Doc_print( | 739 pEnv->GetFormFillInfo()->m_pJsPlatform->Doc_print( |
755 pEnv->GetFormFillInfo()->m_pJsPlatform, | 740 pEnv->GetFormFillInfo()->m_pJsPlatform, |
756 dwOptions & XFA_PRINTOPT_ShowDialog, nStartPage, nEndPage, | 741 dwOptions & XFA_PRINTOPT_ShowDialog, nStartPage, nEndPage, |
757 dwOptions & XFA_PRINTOPT_CanCancel, dwOptions & XFA_PRINTOPT_ShrinkPage, | 742 dwOptions & XFA_PRINTOPT_CanCancel, dwOptions & XFA_PRINTOPT_ShrinkPage, |
758 dwOptions & XFA_PRINTOPT_AsImage, dwOptions & XFA_PRINTOPT_ReverseOrder, | 743 dwOptions & XFA_PRINTOPT_AsImage, dwOptions & XFA_PRINTOPT_ReverseOrder, |
759 dwOptions & XFA_PRINTOPT_PrintAnnot); | 744 dwOptions & XFA_PRINTOPT_PrintAnnot); |
760 } | 745 } |
761 | 746 |
762 void CPDFXFA_Document::GetURL(CXFA_FFDoc* hDoc, CFX_WideString& wsDocURL) { | 747 FX_ARGB CPDFXFA_Document::GetHighlightColor(CXFA_FFDoc* hDoc) { |
763 if (hDoc != m_pXFADoc.get()) | 748 if (hDoc != m_pXFADoc.get() || !m_pSDKDoc) |
764 return; | 749 return 0; |
765 | 750 |
766 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 751 CPDFSDK_InterForm* pInterForm = m_pSDKDoc->GetInterForm(); |
767 if (!pEnv) | 752 if (!pInterForm) |
768 return; | 753 return 0; |
769 | 754 |
770 pEnv->FFI_GetURL(this, wsDocURL); | 755 return ArgbEncode(pInterForm->GetHighlightAlpha(), |
771 } | 756 pInterForm->GetHighlightColor(FPDF_FORMFIELD_XFA)); |
772 | |
773 FX_ARGB CPDFXFA_Document::GetHighlightColor(CXFA_FFDoc* hDoc) { | |
774 if (hDoc != m_pXFADoc.get()) | |
775 return 0; | |
776 if (m_pSDKDoc) { | |
777 if (CPDFSDK_InterForm* pInterForm = m_pSDKDoc->GetInterForm()) { | |
778 FX_COLORREF color = pInterForm->GetHighlightColor(FPDF_FORMFIELD_XFA); | |
779 uint8_t alpha = pInterForm->GetHighlightAlpha(); | |
780 FX_ARGB argb = ArgbEncode((int)alpha, color); | |
781 return argb; | |
782 } | |
783 } | |
784 return 0; | |
785 } | 757 } |
786 | 758 |
787 FX_BOOL CPDFXFA_Document::NotifySubmit(FX_BOOL bPrevOrPost) { | 759 FX_BOOL CPDFXFA_Document::NotifySubmit(FX_BOOL bPrevOrPost) { |
788 if (bPrevOrPost) | 760 if (bPrevOrPost) |
789 return OnBeforeNotifySubmit(); | 761 return OnBeforeNotifySubmit(); |
790 | 762 |
791 OnAfterNotifySubmit(); | 763 OnAfterNotifySubmit(); |
792 return TRUE; | 764 return TRUE; |
793 } | 765 } |
794 | 766 |
(...skipping 11 matching lines...) Expand all Loading... |
806 std::unique_ptr<CXFA_WidgetAccIterator> pWidgetAccIterator( | 778 std::unique_ptr<CXFA_WidgetAccIterator> pWidgetAccIterator( |
807 m_pXFADocView->CreateWidgetAccIterator()); | 779 m_pXFADocView->CreateWidgetAccIterator()); |
808 if (pWidgetAccIterator) { | 780 if (pWidgetAccIterator) { |
809 CXFA_EventParam Param; | 781 CXFA_EventParam Param; |
810 Param.m_eType = XFA_EVENT_PreSubmit; | 782 Param.m_eType = XFA_EVENT_PreSubmit; |
811 while (CXFA_WidgetAcc* pWidgetAcc = pWidgetAccIterator->MoveToNext()) | 783 while (CXFA_WidgetAcc* pWidgetAcc = pWidgetAccIterator->MoveToNext()) |
812 pWidgetHandler->ProcessEvent(pWidgetAcc, &Param); | 784 pWidgetHandler->ProcessEvent(pWidgetAcc, &Param); |
813 } | 785 } |
814 | 786 |
815 pWidgetAccIterator.reset(m_pXFADocView->CreateWidgetAccIterator()); | 787 pWidgetAccIterator.reset(m_pXFADocView->CreateWidgetAccIterator()); |
816 if (pWidgetAccIterator) { | 788 if (!pWidgetAccIterator) |
817 CXFA_WidgetAcc* pWidgetAcc = pWidgetAccIterator->MoveToNext(); | 789 return TRUE; |
| 790 |
| 791 CXFA_WidgetAcc* pWidgetAcc = pWidgetAccIterator->MoveToNext(); |
| 792 pWidgetAcc = pWidgetAccIterator->MoveToNext(); |
| 793 while (pWidgetAcc) { |
| 794 int fRet = pWidgetAcc->ProcessValidate(-1); |
| 795 if (fRet == XFA_EVENTERROR_Error) { |
| 796 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
| 797 if (!pEnv) |
| 798 return FALSE; |
| 799 |
| 800 CFX_WideString ws; |
| 801 ws.FromLocal(IDS_XFA_Validate_Input); |
| 802 CFX_ByteString bs = ws.UTF16LE_Encode(); |
| 803 int len = bs.GetLength(); |
| 804 pEnv->FFI_Alert((FPDF_WIDESTRING)bs.GetBuffer(len), (FPDF_WIDESTRING)L"", |
| 805 0, 1); |
| 806 bs.ReleaseBuffer(len); |
| 807 return FALSE; |
| 808 } |
818 pWidgetAcc = pWidgetAccIterator->MoveToNext(); | 809 pWidgetAcc = pWidgetAccIterator->MoveToNext(); |
819 while (pWidgetAcc) { | |
820 int fRet = pWidgetAcc->ProcessValidate(-1); | |
821 if (fRet == XFA_EVENTERROR_Error) { | |
822 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | |
823 if (!pEnv) | |
824 return FALSE; | |
825 CFX_WideString ws; | |
826 ws.FromLocal(IDS_XFA_Validate_Input); | |
827 CFX_ByteString bs = ws.UTF16LE_Encode(); | |
828 int len = bs.GetLength() / sizeof(unsigned short); | |
829 pEnv->FFI_Alert( | |
830 (FPDF_WIDESTRING)bs.GetBuffer(len * sizeof(unsigned short)), | |
831 (FPDF_WIDESTRING)L"", 0, 1); | |
832 bs.ReleaseBuffer(len * sizeof(unsigned short)); | |
833 return FALSE; | |
834 } | |
835 pWidgetAcc = pWidgetAccIterator->MoveToNext(); | |
836 } | |
837 m_pXFADocView->UpdateDocView(); | |
838 } | 810 } |
| 811 m_pXFADocView->UpdateDocView(); |
| 812 |
839 return TRUE; | 813 return TRUE; |
840 } | 814 } |
841 | 815 |
842 void CPDFXFA_Document::OnAfterNotifySubmit() { | 816 void CPDFXFA_Document::OnAfterNotifySubmit() { |
843 if (m_iDocType != DOCTYPE_DYNAMIC_XFA && m_iDocType != DOCTYPE_STATIC_XFA) | 817 if (m_iDocType != DOCTYPE_DYNAMIC_XFA && m_iDocType != DOCTYPE_STATIC_XFA) |
844 return; | 818 return; |
845 | 819 |
846 if (!m_pXFADocView) | 820 if (!m_pXFADocView) |
847 return; | 821 return; |
848 | 822 |
(...skipping 12 matching lines...) Expand all Loading... |
861 while (pWidgetAcc) { | 835 while (pWidgetAcc) { |
862 pWidgetHandler->ProcessEvent(pWidgetAcc, &Param); | 836 pWidgetHandler->ProcessEvent(pWidgetAcc, &Param); |
863 pWidgetAcc = pWidgetAccIterator->MoveToNext(); | 837 pWidgetAcc = pWidgetAccIterator->MoveToNext(); |
864 } | 838 } |
865 m_pXFADocView->UpdateDocView(); | 839 m_pXFADocView->UpdateDocView(); |
866 } | 840 } |
867 | 841 |
868 FX_BOOL CPDFXFA_Document::SubmitData(CXFA_FFDoc* hDoc, CXFA_Submit submit) { | 842 FX_BOOL CPDFXFA_Document::SubmitData(CXFA_FFDoc* hDoc, CXFA_Submit submit) { |
869 if (!NotifySubmit(TRUE) || !m_pXFADocView) | 843 if (!NotifySubmit(TRUE) || !m_pXFADocView) |
870 return FALSE; | 844 return FALSE; |
| 845 |
871 m_pXFADocView->UpdateDocView(); | 846 m_pXFADocView->UpdateDocView(); |
872 | |
873 FX_BOOL ret = SubmitDataInternal(hDoc, submit); | 847 FX_BOOL ret = SubmitDataInternal(hDoc, submit); |
874 NotifySubmit(FALSE); | 848 NotifySubmit(FALSE); |
875 return ret; | 849 return ret; |
876 } | 850 } |
877 | 851 |
878 IFX_FileRead* CPDFXFA_Document::OpenLinkedFile(CXFA_FFDoc* hDoc, | 852 IFX_FileRead* CPDFXFA_Document::OpenLinkedFile(CXFA_FFDoc* hDoc, |
879 const CFX_WideString& wsLink) { | 853 const CFX_WideString& wsLink) { |
880 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 854 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
881 if (!pEnv) | 855 if (!pEnv) |
882 return FALSE; | 856 return FALSE; |
| 857 |
883 CFX_ByteString bs = wsLink.UTF16LE_Encode(); | 858 CFX_ByteString bs = wsLink.UTF16LE_Encode(); |
884 int len = bs.GetLength() / sizeof(unsigned short); | 859 int len = bs.GetLength(); |
885 FPDF_FILEHANDLER* pFileHandler = pEnv->FFI_OpenFile( | 860 FPDF_FILEHANDLER* pFileHandler = |
886 0, (FPDF_WIDESTRING)bs.GetBuffer(len * sizeof(unsigned short)), "rb"); | 861 pEnv->FFI_OpenFile(0, (FPDF_WIDESTRING)bs.GetBuffer(len), "rb"); |
887 bs.ReleaseBuffer(len * sizeof(unsigned short)); | 862 bs.ReleaseBuffer(len); |
888 | 863 |
889 if (!pFileHandler) | 864 if (!pFileHandler) |
890 return nullptr; | 865 return nullptr; |
891 return new CFPDF_FileStream(pFileHandler); | 866 return new CFPDF_FileStream(pFileHandler); |
892 } | 867 } |
893 | 868 |
894 FX_BOOL CPDFXFA_Document::ExportSubmitFile(FPDF_FILEHANDLER* pFileHandler, | 869 FX_BOOL CPDFXFA_Document::ExportSubmitFile(FPDF_FILEHANDLER* pFileHandler, |
895 int fileType, | 870 int fileType, |
896 FPDF_DWORD encodeType, | 871 FPDF_DWORD encodeType, |
897 FPDF_DWORD flag) { | 872 FPDF_DWORD flag) { |
898 if (!m_pXFADocView) | 873 if (!m_pXFADocView) |
899 return FALSE; | 874 return FALSE; |
900 | 875 |
901 CFX_ByteString content; | 876 CFX_ByteString content; |
902 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 877 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
903 if (!pEnv) | 878 if (!pEnv) |
904 return FALSE; | 879 return FALSE; |
905 | 880 |
906 CFPDF_FileStream fileStream(pFileHandler); | 881 CFPDF_FileStream fileStream(pFileHandler); |
907 | |
908 if (fileType == FXFA_SAVEAS_XML) { | 882 if (fileType == FXFA_SAVEAS_XML) { |
909 const char kContent[] = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"; | 883 const char kContent[] = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"; |
910 fileStream.WriteBlock(kContent, 0, strlen(kContent)); | 884 fileStream.WriteBlock(kContent, 0, strlen(kContent)); |
911 m_pXFADoc->SavePackage(XFA_HASHCODE_Data, &fileStream, nullptr); | 885 m_pXFADoc->SavePackage(XFA_HASHCODE_Data, &fileStream, nullptr); |
912 return TRUE; | 886 return TRUE; |
913 } | 887 } |
914 | 888 |
915 if (fileType != FXFA_SAVEAS_XDP) | 889 if (fileType != FXFA_SAVEAS_XDP) |
916 return TRUE; | 890 return TRUE; |
917 | 891 |
918 if (!flag) { | 892 if (!flag) { |
919 flag = FXFA_CONFIG | FXFA_TEMPLATE | FXFA_LOCALESET | FXFA_DATASETS | | 893 flag = FXFA_CONFIG | FXFA_TEMPLATE | FXFA_LOCALESET | FXFA_DATASETS | |
920 FXFA_XMPMETA | FXFA_XFDF | FXFA_FORM; | 894 FXFA_XMPMETA | FXFA_XFDF | FXFA_FORM; |
921 } | 895 } |
922 if (!m_pPDFDoc) { | 896 if (!m_pPDFDoc) { |
923 fileStream.Flush(); | 897 fileStream.Flush(); |
924 return FALSE; | 898 return FALSE; |
925 } | 899 } |
| 900 |
926 CPDF_Dictionary* pRoot = m_pPDFDoc->GetRoot(); | 901 CPDF_Dictionary* pRoot = m_pPDFDoc->GetRoot(); |
927 if (!pRoot) { | 902 if (!pRoot) { |
928 fileStream.Flush(); | 903 fileStream.Flush(); |
929 return FALSE; | 904 return FALSE; |
930 } | 905 } |
| 906 |
931 CPDF_Dictionary* pAcroForm = pRoot->GetDictBy("AcroForm"); | 907 CPDF_Dictionary* pAcroForm = pRoot->GetDictBy("AcroForm"); |
932 if (!pAcroForm) { | 908 if (!pAcroForm) { |
933 fileStream.Flush(); | 909 fileStream.Flush(); |
934 return FALSE; | 910 return FALSE; |
935 } | 911 } |
| 912 |
936 CPDF_Array* pArray = ToArray(pAcroForm->GetObjectBy("XFA")); | 913 CPDF_Array* pArray = ToArray(pAcroForm->GetObjectBy("XFA")); |
937 if (!pArray) { | 914 if (!pArray) { |
938 fileStream.Flush(); | 915 fileStream.Flush(); |
939 return FALSE; | 916 return FALSE; |
940 } | 917 } |
941 | 918 |
942 int size = pArray->GetCount(); | 919 int size = pArray->GetCount(); |
943 for (int i = 1; i < size; i += 2) { | 920 for (int i = 1; i < size; i += 2) { |
944 CPDF_Object* pPDFObj = pArray->GetObjectAt(i); | 921 CPDF_Object* pPDFObj = pArray->GetObjectAt(i); |
945 CPDF_Object* pPrePDFObj = pArray->GetObjectAt(i - 1); | 922 CPDF_Object* pPrePDFObj = pArray->GetObjectAt(i - 1); |
946 if (!pPrePDFObj->IsString()) | 923 if (!pPrePDFObj->IsString()) |
947 continue; | 924 continue; |
948 if (!pPDFObj->IsReference()) | 925 if (!pPDFObj->IsReference()) |
949 continue; | 926 continue; |
| 927 |
950 CPDF_Object* pDirectObj = pPDFObj->GetDirect(); | 928 CPDF_Object* pDirectObj = pPDFObj->GetDirect(); |
951 if (!pDirectObj->IsStream()) | 929 if (!pDirectObj->IsStream()) |
952 continue; | 930 continue; |
953 if (pPrePDFObj->GetString() == "config" && !(flag & FXFA_CONFIG)) | 931 if (pPrePDFObj->GetString() == "config" && !(flag & FXFA_CONFIG)) |
954 continue; | 932 continue; |
955 if (pPrePDFObj->GetString() == "template" && !(flag & FXFA_TEMPLATE)) | 933 if (pPrePDFObj->GetString() == "template" && !(flag & FXFA_TEMPLATE)) |
956 continue; | 934 continue; |
957 if (pPrePDFObj->GetString() == "localeSet" && !(flag & FXFA_LOCALESET)) | 935 if (pPrePDFObj->GetString() == "localeSet" && !(flag & FXFA_LOCALESET)) |
958 continue; | 936 continue; |
959 if (pPrePDFObj->GetString() == "datasets" && !(flag & FXFA_DATASETS)) | 937 if (pPrePDFObj->GetString() == "datasets" && !(flag & FXFA_DATASETS)) |
(...skipping 29 matching lines...) Expand all Loading... |
989 if (csSrcContent.Find(L" localeSet ", 0) != -1) | 967 if (csSrcContent.Find(L" localeSet ", 0) != -1) |
990 flag |= FXFA_LOCALESET; | 968 flag |= FXFA_LOCALESET; |
991 if (csSrcContent.Find(L" datasets ", 0) != -1) | 969 if (csSrcContent.Find(L" datasets ", 0) != -1) |
992 flag |= FXFA_DATASETS; | 970 flag |= FXFA_DATASETS; |
993 if (csSrcContent.Find(L" xmpmeta ", 0) != -1) | 971 if (csSrcContent.Find(L" xmpmeta ", 0) != -1) |
994 flag |= FXFA_XMPMETA; | 972 flag |= FXFA_XMPMETA; |
995 if (csSrcContent.Find(L" xfdf ", 0) != -1) | 973 if (csSrcContent.Find(L" xfdf ", 0) != -1) |
996 flag |= FXFA_XFDF; | 974 flag |= FXFA_XFDF; |
997 if (csSrcContent.Find(L" form ", 0) != -1) | 975 if (csSrcContent.Find(L" form ", 0) != -1) |
998 flag |= FXFA_FORM; | 976 flag |= FXFA_FORM; |
999 if (flag == 0) | 977 if (flag == 0) { |
1000 flag = FXFA_CONFIG | FXFA_TEMPLATE | FXFA_LOCALESET | FXFA_DATASETS | | 978 flag = FXFA_CONFIG | FXFA_TEMPLATE | FXFA_LOCALESET | FXFA_DATASETS | |
1001 FXFA_XMPMETA | FXFA_XFDF | FXFA_FORM; | 979 FXFA_XMPMETA | FXFA_XFDF | FXFA_FORM; |
| 980 } |
1002 } | 981 } |
1003 | 982 |
1004 FX_BOOL CPDFXFA_Document::MailToInfo(CFX_WideString& csURL, | 983 FX_BOOL CPDFXFA_Document::MailToInfo(CFX_WideString& csURL, |
1005 CFX_WideString& csToAddress, | 984 CFX_WideString& csToAddress, |
1006 CFX_WideString& csCCAddress, | 985 CFX_WideString& csCCAddress, |
1007 CFX_WideString& csBCCAddress, | 986 CFX_WideString& csBCCAddress, |
1008 CFX_WideString& csSubject, | 987 CFX_WideString& csSubject, |
1009 CFX_WideString& csMsg) { | 988 CFX_WideString& csMsg) { |
1010 CFX_WideString srcURL = csURL; | 989 CFX_WideString srcURL = csURL; |
1011 srcURL.TrimLeft(); | 990 srcURL.TrimLeft(); |
1012 if (0 != srcURL.Left(7).CompareNoCase(L"mailto:")) | 991 if (srcURL.Left(7).CompareNoCase(L"mailto:") != 0) |
1013 return FALSE; | 992 return FALSE; |
| 993 |
1014 int pos = srcURL.Find(L'?', 0); | 994 int pos = srcURL.Find(L'?', 0); |
1015 CFX_WideString tmp; | 995 CFX_WideString tmp; |
1016 if (pos == -1) { | 996 if (pos == -1) { |
1017 pos = srcURL.Find(L'@', 0); | 997 pos = srcURL.Find(L'@', 0); |
1018 if (pos == -1) | 998 if (pos == -1) |
1019 return FALSE; | 999 return FALSE; |
1020 | 1000 |
1021 tmp = srcURL.Right(csURL.GetLength() - 7); | 1001 tmp = srcURL.Right(csURL.GetLength() - 7); |
1022 tmp.TrimLeft(); | |
1023 tmp.TrimRight(); | |
1024 } else { | 1002 } else { |
1025 tmp = srcURL.Left(pos); | 1003 tmp = srcURL.Left(pos); |
1026 tmp = tmp.Right(tmp.GetLength() - 7); | 1004 tmp = tmp.Right(tmp.GetLength() - 7); |
1027 tmp.TrimLeft(); | |
1028 tmp.TrimRight(); | |
1029 } | 1005 } |
| 1006 tmp.TrimLeft(); |
| 1007 tmp.TrimRight(); |
1030 | 1008 |
1031 csToAddress = tmp; | 1009 csToAddress = tmp; |
1032 | 1010 |
1033 srcURL = srcURL.Right(srcURL.GetLength() - (pos + 1)); | 1011 srcURL = srcURL.Right(srcURL.GetLength() - (pos + 1)); |
1034 while (!srcURL.IsEmpty()) { | 1012 while (!srcURL.IsEmpty()) { |
1035 srcURL.TrimLeft(); | 1013 srcURL.TrimLeft(); |
1036 srcURL.TrimRight(); | 1014 srcURL.TrimRight(); |
1037 pos = srcURL.Find(L'&', 0); | 1015 pos = srcURL.Find(L'&', 0); |
1038 if (pos == -1) | |
1039 tmp = srcURL; | |
1040 else | |
1041 tmp = srcURL.Left(pos); | |
1042 | 1016 |
| 1017 tmp = (pos == -1) ? srcURL : srcURL.Left(pos); |
1043 tmp.TrimLeft(); | 1018 tmp.TrimLeft(); |
1044 tmp.TrimRight(); | 1019 tmp.TrimRight(); |
1045 if (tmp.GetLength() >= 3 && 0 == tmp.Left(3).CompareNoCase(L"cc=")) { | 1020 if (tmp.GetLength() >= 3 && tmp.Left(3).CompareNoCase(L"cc=") == 0) { |
1046 tmp = tmp.Right(tmp.GetLength() - 3); | 1021 tmp = tmp.Right(tmp.GetLength() - 3); |
1047 if (!csCCAddress.IsEmpty()) | 1022 if (!csCCAddress.IsEmpty()) |
1048 csCCAddress += L';'; | 1023 csCCAddress += L';'; |
1049 csCCAddress += tmp; | 1024 csCCAddress += tmp; |
1050 | |
1051 } else if (tmp.GetLength() >= 4 && | 1025 } else if (tmp.GetLength() >= 4 && |
1052 0 == tmp.Left(4).CompareNoCase(L"bcc=")) { | 1026 tmp.Left(4).CompareNoCase(L"bcc=") == 0) { |
1053 tmp = tmp.Right(tmp.GetLength() - 4); | 1027 tmp = tmp.Right(tmp.GetLength() - 4); |
1054 if (!csBCCAddress.IsEmpty()) | 1028 if (!csBCCAddress.IsEmpty()) |
1055 csBCCAddress += L';'; | 1029 csBCCAddress += L';'; |
1056 csBCCAddress += tmp; | 1030 csBCCAddress += tmp; |
1057 } else if (tmp.GetLength() >= 8 && | 1031 } else if (tmp.GetLength() >= 8 && |
1058 0 == tmp.Left(8).CompareNoCase(L"subject=")) { | 1032 tmp.Left(8).CompareNoCase(L"subject=") == 0) { |
1059 tmp = tmp.Right(tmp.GetLength() - 8); | 1033 tmp = tmp.Right(tmp.GetLength() - 8); |
1060 csSubject += tmp; | 1034 csSubject += tmp; |
1061 } else if (tmp.GetLength() >= 5 && | 1035 } else if (tmp.GetLength() >= 5 && |
1062 0 == tmp.Left(5).CompareNoCase(L"body=")) { | 1036 tmp.Left(5).CompareNoCase(L"body=") == 0) { |
1063 tmp = tmp.Right(tmp.GetLength() - 5); | 1037 tmp = tmp.Right(tmp.GetLength() - 5); |
1064 csMsg += tmp; | 1038 csMsg += tmp; |
1065 } | 1039 } |
1066 if (pos == -1) | 1040 srcURL = (pos == -1) ? L"" : srcURL.Right(csURL.GetLength() - (pos + 1)); |
1067 srcURL = L""; | |
1068 else | |
1069 srcURL = srcURL.Right(csURL.GetLength() - (pos + 1)); | |
1070 } | 1041 } |
1071 csToAddress.Replace(L",", L";"); | 1042 csToAddress.Replace(L",", L";"); |
1072 csCCAddress.Replace(L",", L";"); | 1043 csCCAddress.Replace(L",", L";"); |
1073 csBCCAddress.Replace(L",", L";"); | 1044 csBCCAddress.Replace(L",", L";"); |
1074 return TRUE; | 1045 return TRUE; |
1075 } | 1046 } |
1076 | 1047 |
1077 FX_BOOL CPDFXFA_Document::SubmitDataInternal(CXFA_FFDoc* hDoc, | 1048 FX_BOOL CPDFXFA_Document::SubmitDataInternal(CXFA_FFDoc* hDoc, |
1078 CXFA_Submit submit) { | 1049 CXFA_Submit submit) { |
1079 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 1050 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
1080 if (!pEnv) | 1051 if (!pEnv) |
1081 return FALSE; | 1052 return FALSE; |
| 1053 |
1082 CFX_WideStringC csURLC; | 1054 CFX_WideStringC csURLC; |
1083 submit.GetSubmitTarget(csURLC); | 1055 submit.GetSubmitTarget(csURLC); |
1084 CFX_WideString csURL(csURLC); | 1056 CFX_WideString csURL(csURLC); |
1085 if (csURL.IsEmpty()) { | 1057 if (csURL.IsEmpty()) { |
1086 CFX_WideString ws; | 1058 CFX_WideString ws; |
1087 ws.FromLocal("Submit cancelled."); | 1059 ws.FromLocal("Submit cancelled."); |
1088 CFX_ByteString bs = ws.UTF16LE_Encode(); | 1060 CFX_ByteString bs = ws.UTF16LE_Encode(); |
1089 int len = bs.GetLength() / sizeof(unsigned short); | 1061 int len = bs.GetLength(); |
1090 pEnv->FFI_Alert((FPDF_WIDESTRING)bs.GetBuffer(len * sizeof(unsigned short)), | 1062 pEnv->FFI_Alert((FPDF_WIDESTRING)bs.GetBuffer(len), (FPDF_WIDESTRING)L"", 0, |
1091 (FPDF_WIDESTRING)L"", 0, 4); | 1063 4); |
1092 bs.ReleaseBuffer(len * sizeof(unsigned short)); | 1064 bs.ReleaseBuffer(len); |
1093 return FALSE; | 1065 return FALSE; |
1094 } | 1066 } |
| 1067 |
1095 FPDF_BOOL bRet = TRUE; | 1068 FPDF_BOOL bRet = TRUE; |
1096 FPDF_FILEHANDLER* pFileHandler = nullptr; | 1069 FPDF_FILEHANDLER* pFileHandler = nullptr; |
1097 int fileFlag = -1; | 1070 int fileFlag = -1; |
1098 switch (submit.GetSubmitFormat()) { | 1071 switch (submit.GetSubmitFormat()) { |
1099 case XFA_ATTRIBUTEENUM_Xdp: { | 1072 case XFA_ATTRIBUTEENUM_Xdp: { |
1100 CFX_WideStringC csContentC; | 1073 CFX_WideStringC csContentC; |
1101 submit.GetSubmitXDPContent(csContentC); | 1074 submit.GetSubmitXDPContent(csContentC); |
1102 CFX_WideString csContent; | 1075 CFX_WideString csContent; |
1103 csContent = csContentC; | 1076 csContent = csContentC; |
1104 csContent.TrimLeft(); | 1077 csContent.TrimLeft(); |
1105 csContent.TrimRight(); | 1078 csContent.TrimRight(); |
1106 CFX_WideString space; | 1079 CFX_WideString space; |
1107 space.FromLocal(" "); | 1080 space.FromLocal(" "); |
1108 csContent = space + csContent + space; | 1081 csContent = space + csContent + space; |
1109 FPDF_DWORD flag = 0; | 1082 FPDF_DWORD flag = 0; |
1110 if (submit.IsSubmitEmbedPDF()) | 1083 if (submit.IsSubmitEmbedPDF()) |
1111 flag |= FXFA_PDF; | 1084 flag |= FXFA_PDF; |
| 1085 |
1112 ToXFAContentFlags(csContent, flag); | 1086 ToXFAContentFlags(csContent, flag); |
1113 pFileHandler = pEnv->FFI_OpenFile(FXFA_SAVEAS_XDP, nullptr, "wb"); | 1087 pFileHandler = pEnv->FFI_OpenFile(FXFA_SAVEAS_XDP, nullptr, "wb"); |
1114 fileFlag = FXFA_SAVEAS_XDP; | 1088 fileFlag = FXFA_SAVEAS_XDP; |
1115 ExportSubmitFile(pFileHandler, FXFA_SAVEAS_XDP, 0, flag); | 1089 ExportSubmitFile(pFileHandler, FXFA_SAVEAS_XDP, 0, flag); |
1116 break; | 1090 break; |
1117 } | 1091 } |
1118 case XFA_ATTRIBUTEENUM_Xml: | 1092 case XFA_ATTRIBUTEENUM_Xml: |
1119 pFileHandler = pEnv->FFI_OpenFile(FXFA_SAVEAS_XML, nullptr, "wb"); | 1093 pFileHandler = pEnv->FFI_OpenFile(FXFA_SAVEAS_XML, nullptr, "wb"); |
1120 fileFlag = FXFA_SAVEAS_XML; | 1094 fileFlag = FXFA_SAVEAS_XML; |
1121 ExportSubmitFile(pFileHandler, FXFA_SAVEAS_XML, 0, FXFA_XFA_ALL); | 1095 ExportSubmitFile(pFileHandler, FXFA_SAVEAS_XML, 0, FXFA_XFA_ALL); |
1122 break; | 1096 break; |
1123 case XFA_ATTRIBUTEENUM_Pdf: | 1097 case XFA_ATTRIBUTEENUM_Pdf: |
1124 break; | 1098 break; |
1125 case XFA_ATTRIBUTEENUM_Urlencoded: | 1099 case XFA_ATTRIBUTEENUM_Urlencoded: |
1126 pFileHandler = pEnv->FFI_OpenFile(FXFA_SAVEAS_XML, nullptr, "wb"); | 1100 pFileHandler = pEnv->FFI_OpenFile(FXFA_SAVEAS_XML, nullptr, "wb"); |
1127 fileFlag = FXFA_SAVEAS_XML; | 1101 fileFlag = FXFA_SAVEAS_XML; |
1128 ExportSubmitFile(pFileHandler, FXFA_SAVEAS_XML, 0, FXFA_XFA_ALL); | 1102 ExportSubmitFile(pFileHandler, FXFA_SAVEAS_XML, 0, FXFA_XFA_ALL); |
1129 break; | 1103 break; |
1130 default: | 1104 default: |
1131 return false; | 1105 return false; |
1132 } | 1106 } |
1133 if (!pFileHandler) | 1107 if (!pFileHandler) |
1134 return FALSE; | 1108 return FALSE; |
1135 if (0 == csURL.Left(7).CompareNoCase(L"mailto:")) { | 1109 if (csURL.Left(7).CompareNoCase(L"mailto:") == 0) { |
1136 CFX_WideString csToAddress; | 1110 CFX_WideString csToAddress; |
1137 CFX_WideString csCCAddress; | 1111 CFX_WideString csCCAddress; |
1138 CFX_WideString csBCCAddress; | 1112 CFX_WideString csBCCAddress; |
1139 CFX_WideString csSubject; | 1113 CFX_WideString csSubject; |
1140 CFX_WideString csMsg; | 1114 CFX_WideString csMsg; |
1141 bRet = MailToInfo(csURL, csToAddress, csCCAddress, csBCCAddress, csSubject, | 1115 bRet = MailToInfo(csURL, csToAddress, csCCAddress, csBCCAddress, csSubject, |
1142 csMsg); | 1116 csMsg); |
1143 if (!bRet) | 1117 if (!bRet) |
1144 return FALSE; | 1118 return FALSE; |
| 1119 |
1145 CFX_ByteString bsTo = CFX_WideString(csToAddress).UTF16LE_Encode(); | 1120 CFX_ByteString bsTo = CFX_WideString(csToAddress).UTF16LE_Encode(); |
1146 CFX_ByteString bsCC = CFX_WideString(csCCAddress).UTF16LE_Encode(); | 1121 CFX_ByteString bsCC = CFX_WideString(csCCAddress).UTF16LE_Encode(); |
1147 CFX_ByteString bsBcc = CFX_WideString(csBCCAddress).UTF16LE_Encode(); | 1122 CFX_ByteString bsBcc = CFX_WideString(csBCCAddress).UTF16LE_Encode(); |
1148 CFX_ByteString bsSubject = CFX_WideString(csSubject).UTF16LE_Encode(); | 1123 CFX_ByteString bsSubject = CFX_WideString(csSubject).UTF16LE_Encode(); |
1149 CFX_ByteString bsMsg = CFX_WideString(csMsg).UTF16LE_Encode(); | 1124 CFX_ByteString bsMsg = CFX_WideString(csMsg).UTF16LE_Encode(); |
1150 FPDF_WIDESTRING pTo = (FPDF_WIDESTRING)bsTo.GetBuffer(bsTo.GetLength()); | 1125 FPDF_WIDESTRING pTo = (FPDF_WIDESTRING)bsTo.GetBuffer(bsTo.GetLength()); |
1151 FPDF_WIDESTRING pCC = (FPDF_WIDESTRING)bsCC.GetBuffer(bsCC.GetLength()); | 1126 FPDF_WIDESTRING pCC = (FPDF_WIDESTRING)bsCC.GetBuffer(bsCC.GetLength()); |
1152 FPDF_WIDESTRING pBcc = (FPDF_WIDESTRING)bsBcc.GetBuffer(bsBcc.GetLength()); | 1127 FPDF_WIDESTRING pBcc = (FPDF_WIDESTRING)bsBcc.GetBuffer(bsBcc.GetLength()); |
1153 FPDF_WIDESTRING pSubject = | 1128 FPDF_WIDESTRING pSubject = |
1154 (FPDF_WIDESTRING)bsSubject.GetBuffer(bsSubject.GetLength()); | 1129 (FPDF_WIDESTRING)bsSubject.GetBuffer(bsSubject.GetLength()); |
1155 FPDF_WIDESTRING pMsg = (FPDF_WIDESTRING)bsMsg.GetBuffer(bsMsg.GetLength()); | 1130 FPDF_WIDESTRING pMsg = (FPDF_WIDESTRING)bsMsg.GetBuffer(bsMsg.GetLength()); |
1156 pEnv->FFI_EmailTo(pFileHandler, pTo, pSubject, pCC, pBcc, pMsg); | 1131 pEnv->FFI_EmailTo(pFileHandler, pTo, pSubject, pCC, pBcc, pMsg); |
1157 bsTo.ReleaseBuffer(); | 1132 bsTo.ReleaseBuffer(); |
1158 bsCC.ReleaseBuffer(); | 1133 bsCC.ReleaseBuffer(); |
1159 bsBcc.ReleaseBuffer(); | 1134 bsBcc.ReleaseBuffer(); |
1160 bsSubject.ReleaseBuffer(); | 1135 bsSubject.ReleaseBuffer(); |
1161 bsMsg.ReleaseBuffer(); | 1136 bsMsg.ReleaseBuffer(); |
1162 } else { | 1137 } else { |
1163 // HTTP or FTP | 1138 // HTTP or FTP |
1164 CFX_WideString ws; | 1139 CFX_WideString ws; |
1165 CFX_ByteString bs = csURL.UTF16LE_Encode(); | 1140 CFX_ByteString bs = csURL.UTF16LE_Encode(); |
1166 int len = bs.GetLength() / sizeof(unsigned short); | 1141 int len = bs.GetLength(); |
1167 pEnv->FFI_UploadTo( | 1142 pEnv->FFI_UploadTo(pFileHandler, fileFlag, |
1168 pFileHandler, fileFlag, | 1143 (FPDF_WIDESTRING)bs.GetBuffer(len)); |
1169 (FPDF_WIDESTRING)bs.GetBuffer(len * sizeof(unsigned short))); | 1144 bs.ReleaseBuffer(len); |
1170 bs.ReleaseBuffer(len * sizeof(unsigned short)); | |
1171 } | 1145 } |
1172 return bRet; | 1146 return bRet; |
1173 } | 1147 } |
1174 | 1148 |
1175 FX_BOOL CPDFXFA_Document::SetGlobalProperty(CXFA_FFDoc* hDoc, | 1149 FX_BOOL CPDFXFA_Document::SetGlobalProperty(CXFA_FFDoc* hDoc, |
1176 const CFX_ByteStringC& szPropName, | 1150 const CFX_ByteStringC& szPropName, |
1177 CFXJSE_Value* pValue) { | 1151 CFXJSE_Value* pValue) { |
1178 if (hDoc != m_pXFADoc.get()) | 1152 if (hDoc != m_pXFADoc.get()) |
1179 return FALSE; | 1153 return FALSE; |
1180 | 1154 |
1181 if (m_pSDKDoc && m_pSDKDoc->GetEnv()->GetJSRuntime()) | 1155 if (m_pSDKDoc && m_pSDKDoc->GetEnv()->GetJSRuntime()) |
1182 return m_pSDKDoc->GetEnv()->GetJSRuntime()->SetValueByName(szPropName, | 1156 return m_pSDKDoc->GetEnv()->GetJSRuntime()->SetValueByName(szPropName, |
1183 pValue); | 1157 pValue); |
1184 return FALSE; | 1158 return FALSE; |
1185 } | 1159 } |
1186 FX_BOOL CPDFXFA_Document::GetPDFScriptObject(CXFA_FFDoc* hDoc, | |
1187 const CFX_ByteStringC& utf8Name, | |
1188 CFXJSE_Value* pValue) { | |
1189 if (hDoc != m_pXFADoc.get()) | |
1190 return FALSE; | |
1191 | 1160 |
1192 if (!m_pSDKDoc || !m_pSDKDoc->GetEnv()->GetJSRuntime()) | |
1193 return FALSE; | |
1194 | |
1195 if (!m_pJSContext) { | |
1196 m_pSDKDoc->GetEnv()->GetJSRuntime()->SetReaderDocument(m_pSDKDoc.get()); | |
1197 m_pJSContext = m_pSDKDoc->GetEnv()->GetJSRuntime()->NewContext(); | |
1198 } | |
1199 | |
1200 return m_pSDKDoc->GetEnv()->GetJSRuntime()->GetValueByName(utf8Name, pValue); | |
1201 } | |
1202 FX_BOOL CPDFXFA_Document::GetGlobalProperty(CXFA_FFDoc* hDoc, | 1161 FX_BOOL CPDFXFA_Document::GetGlobalProperty(CXFA_FFDoc* hDoc, |
1203 const CFX_ByteStringC& szPropName, | 1162 const CFX_ByteStringC& szPropName, |
1204 CFXJSE_Value* pValue) { | 1163 CFXJSE_Value* pValue) { |
1205 if (hDoc != m_pXFADoc.get()) | 1164 if (hDoc != m_pXFADoc.get()) |
1206 return FALSE; | 1165 return FALSE; |
1207 if (!m_pSDKDoc || !m_pSDKDoc->GetEnv()->GetJSRuntime()) | 1166 if (!m_pSDKDoc || !m_pSDKDoc->GetEnv()->GetJSRuntime()) |
1208 return FALSE; | 1167 return FALSE; |
1209 | 1168 |
1210 if (!m_pJSContext) { | 1169 if (!m_pJSContext) { |
1211 m_pSDKDoc->GetEnv()->GetJSRuntime()->SetReaderDocument(m_pSDKDoc.get()); | 1170 m_pSDKDoc->GetEnv()->GetJSRuntime()->SetReaderDocument(m_pSDKDoc.get()); |
1212 m_pJSContext = m_pSDKDoc->GetEnv()->GetJSRuntime()->NewContext(); | 1171 m_pJSContext = m_pSDKDoc->GetEnv()->GetJSRuntime()->NewContext(); |
1213 } | 1172 } |
1214 | 1173 |
1215 return m_pSDKDoc->GetEnv()->GetJSRuntime()->GetValueByName(szPropName, | 1174 return m_pSDKDoc->GetEnv()->GetJSRuntime()->GetValueByName(szPropName, |
1216 pValue); | 1175 pValue); |
1217 } | 1176 } |
OLD | NEW |