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 "../../public/fpdf_formfill.h" | 7 #include "../../public/fpdf_formfill.h" |
8 #include "../../public/fpdfview.h" | 8 #include "../../public/fpdfview.h" |
9 #include "../include/fsdk_define.h" | 9 #include "../include/fsdk_define.h" |
10 #include "../include/fpdfxfa/fpdfxfa_doc.h" | 10 #include "../include/fpdfxfa/fpdfxfa_doc.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 { | 50 { |
51 IXFA_WidgetHandler* pWidgetHandler = NULL; | 51 IXFA_WidgetHandler* pWidgetHandler = NULL; |
52 IXFA_DocView* pDocView = pPageView->GetDocView(); | 52 IXFA_DocView* pDocView = pPageView->GetDocView(); |
53 if (!pDocView) | 53 if (!pDocView) |
54 return -1; | 54 return -1; |
55 | 55 |
56 pWidgetHandler = pDocView->GetWidgetHandler(); | 56 pWidgetHandler = pDocView->GetWidgetHandler(); |
57 if (!pWidgetHandler) | 57 if (!pWidgetHandler) |
58 return -1; | 58 return -1; |
59 | 59 |
60 » » XFA_HWIDGET pXFAAnnot = NULL; | 60 » » IXFA_Widget* pXFAAnnot = NULL; |
61 IXFA_WidgetIterator* pWidgetIterator = pPageView->CreateWidgetIt
erator(XFA_TRAVERSEWAY_Form, XFA_WIDGETFILTER_Viewable|XFA_WIDGETFILTER_AllType)
; | 61 IXFA_WidgetIterator* pWidgetIterator = pPageView->CreateWidgetIt
erator(XFA_TRAVERSEWAY_Form, XFA_WIDGETFILTER_Viewable|XFA_WIDGETFILTER_AllType)
; |
62 if (!pWidgetIterator) | 62 if (!pWidgetIterator) |
63 return -1; | 63 return -1; |
64 pXFAAnnot = pWidgetIterator->MoveToNext(); | 64 pXFAAnnot = pWidgetIterator->MoveToNext(); |
65 while (pXFAAnnot) { | 65 while (pXFAAnnot) { |
66 CFX_RectF rcBBox; | 66 CFX_RectF rcBBox; |
67 pWidgetHandler->GetBBox (pXFAAnnot, rcBBox, 0); | 67 pWidgetHandler->GetBBox (pXFAAnnot, rcBBox, 0); |
68 CFX_FloatRect rcWidget(rcBBox.left, rcBBox.top, rcBBox.l
eft + rcBBox.width, rcBBox.top+rcBBox.height); | 68 CFX_FloatRect rcWidget(rcBBox.left, rcBBox.top, rcBBox.l
eft + rcBBox.width, rcBBox.top+rcBBox.height); |
69 rcWidget.left -= 1.0f; | 69 rcWidget.left -= 1.0f; |
70 rcWidget.right += 1.0f; | 70 rcWidget.right += 1.0f; |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 return; | 345 return; |
346 | 346 |
347 CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document; | 347 CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document; |
348 if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && pDocument->GetDocT
ype() != XFA_DOCTYPE_Static) | 348 if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && pDocument->GetDocT
ype() != XFA_DOCTYPE_Static) |
349 return; | 349 return; |
350 | 350 |
351 IXFA_MenuHandler* pXFAMenuHander = CPDFXFA_App::GetInstance()->GetXFAApp
()->GetMenuHandler(); | 351 IXFA_MenuHandler* pXFAMenuHander = CPDFXFA_App::GetInstance()->GetXFAApp
()->GetMenuHandler(); |
352 if (pXFAMenuHander == NULL) | 352 if (pXFAMenuHander == NULL) |
353 return; | 353 return; |
354 | 354 |
355 » pXFAMenuHander->Undo((XFA_HWIDGET)hWidget); | 355 » pXFAMenuHander->Undo((IXFA_Widget*)hWidget); |
356 | 356 |
357 } | 357 } |
358 DLLEXPORT void STDCALL FPDF_Widget_Redo(FPDF_DOCUMENT document, FPDF_WIDGET hWid
get) | 358 DLLEXPORT void STDCALL FPDF_Widget_Redo(FPDF_DOCUMENT document, FPDF_WIDGET hWid
get) |
359 { | 359 { |
360 if (NULL == hWidget || NULL == document) | 360 if (NULL == hWidget || NULL == document) |
361 return; | 361 return; |
362 | 362 |
363 CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document; | 363 CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document; |
364 if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && pDocument->GetDocT
ype() != XFA_DOCTYPE_Static) | 364 if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && pDocument->GetDocT
ype() != XFA_DOCTYPE_Static) |
365 return; | 365 return; |
366 | 366 |
367 IXFA_MenuHandler* pXFAMenuHander = CPDFXFA_App::GetInstance()->GetXFAApp
()->GetMenuHandler(); | 367 IXFA_MenuHandler* pXFAMenuHander = CPDFXFA_App::GetInstance()->GetXFAApp
()->GetMenuHandler(); |
368 if (pXFAMenuHander == NULL) | 368 if (pXFAMenuHander == NULL) |
369 return; | 369 return; |
370 | 370 |
371 » pXFAMenuHander->Redo((XFA_HWIDGET)hWidget); | 371 » pXFAMenuHander->Redo((IXFA_Widget*)hWidget); |
372 } | 372 } |
373 | 373 |
374 DLLEXPORT void STDCALL FPDF_Widget_SelectAll(FPDF_DOCUMENT document, FPDF_WIDGET
hWidget) | 374 DLLEXPORT void STDCALL FPDF_Widget_SelectAll(FPDF_DOCUMENT document, FPDF_WIDGET
hWidget) |
375 { | 375 { |
376 if (NULL == hWidget || NULL == document) | 376 if (NULL == hWidget || NULL == document) |
377 return; | 377 return; |
378 | 378 |
379 CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document; | 379 CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document; |
380 if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && pDocument->GetDocT
ype() != XFA_DOCTYPE_Static) | 380 if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && pDocument->GetDocT
ype() != XFA_DOCTYPE_Static) |
381 return; | 381 return; |
382 | 382 |
383 IXFA_MenuHandler* pXFAMenuHander = CPDFXFA_App::GetInstance()->GetXFAApp
()->GetMenuHandler(); | 383 IXFA_MenuHandler* pXFAMenuHander = CPDFXFA_App::GetInstance()->GetXFAApp
()->GetMenuHandler(); |
384 if (pXFAMenuHander == NULL) | 384 if (pXFAMenuHander == NULL) |
385 return; | 385 return; |
386 | 386 |
387 » pXFAMenuHander->SelectAll((XFA_HWIDGET)hWidget); | 387 » pXFAMenuHander->SelectAll((IXFA_Widget*)hWidget); |
388 } | 388 } |
389 DLLEXPORT void STDCALL FPDF_Widget_Copy(FPDF_DOCUMENT document, FPDF_WIDGET hWid
get, FPDF_WIDESTRING wsText, FPDF_DWORD* size) | 389 DLLEXPORT void STDCALL FPDF_Widget_Copy(FPDF_DOCUMENT document, FPDF_WIDGET hWid
get, FPDF_WIDESTRING wsText, FPDF_DWORD* size) |
390 { | 390 { |
391 if (NULL == hWidget || NULL == document) | 391 if (NULL == hWidget || NULL == document) |
392 return; | 392 return; |
393 | 393 |
394 CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document; | 394 CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document; |
395 if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && pDocument->GetDocT
ype() != XFA_DOCTYPE_Static) | 395 if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && pDocument->GetDocT
ype() != XFA_DOCTYPE_Static) |
396 return; | 396 return; |
397 | 397 |
398 IXFA_MenuHandler* pXFAMenuHander = CPDFXFA_App::GetInstance()->GetXFAApp
()->GetMenuHandler(); | 398 IXFA_MenuHandler* pXFAMenuHander = CPDFXFA_App::GetInstance()->GetXFAApp
()->GetMenuHandler(); |
399 if (pXFAMenuHander == NULL) | 399 if (pXFAMenuHander == NULL) |
400 return; | 400 return; |
401 | 401 |
402 CFX_WideString wsCpText; | 402 CFX_WideString wsCpText; |
403 » pXFAMenuHander->Copy((XFA_HWIDGET)hWidget, wsCpText); | 403 » pXFAMenuHander->Copy((IXFA_Widget*)hWidget, wsCpText); |
404 | 404 |
405 CFX_ByteString bsCpText = wsCpText.UTF16LE_Encode(); | 405 CFX_ByteString bsCpText = wsCpText.UTF16LE_Encode(); |
406 int len = bsCpText.GetLength()/sizeof(unsigned short); | 406 int len = bsCpText.GetLength()/sizeof(unsigned short); |
407 if (wsText == NULL) { | 407 if (wsText == NULL) { |
408 *size = len; | 408 *size = len; |
409 return; | 409 return; |
410 } | 410 } |
411 | 411 |
412 int real_size = len < *size ? len : *size; | 412 int real_size = len < *size ? len : *size; |
413 if (real_size > 0) | 413 if (real_size > 0) |
414 { | 414 { |
415 FXSYS_memcpy((void*)wsText,bsCpText.GetBuffer(real_size*sizeof(u
nsigned short)),real_size*sizeof(unsigned short)); | 415 FXSYS_memcpy((void*)wsText,bsCpText.GetBuffer(real_size*sizeof(u
nsigned short)),real_size*sizeof(unsigned short)); |
416 bsCpText.ReleaseBuffer(real_size*sizeof(unsigned short)); | 416 bsCpText.ReleaseBuffer(real_size*sizeof(unsigned short)); |
417 } | 417 } |
418 *size = real_size; | 418 *size = real_size; |
419 } | 419 } |
420 DLLEXPORT void STDCALL FPDF_Widget_Cut(FPDF_DOCUMENT document, FPDF_WIDGET hWidg
et, FPDF_WIDESTRING wsText, FPDF_DWORD* size) | 420 DLLEXPORT void STDCALL FPDF_Widget_Cut(FPDF_DOCUMENT document, FPDF_WIDGET hWidg
et, FPDF_WIDESTRING wsText, FPDF_DWORD* size) |
421 { | 421 { |
422 if (NULL == hWidget || NULL == document) | 422 if (NULL == hWidget || NULL == document) |
423 return; | 423 return; |
424 CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document; | 424 CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document; |
425 if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && pDocument->GetDocT
ype() != XFA_DOCTYPE_Static) | 425 if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && pDocument->GetDocT
ype() != XFA_DOCTYPE_Static) |
426 return; | 426 return; |
427 | 427 |
428 IXFA_MenuHandler* pXFAMenuHander = CPDFXFA_App::GetInstance()->GetXFAApp
()->GetMenuHandler(); | 428 IXFA_MenuHandler* pXFAMenuHander = CPDFXFA_App::GetInstance()->GetXFAApp
()->GetMenuHandler(); |
429 if (pXFAMenuHander == NULL) | 429 if (pXFAMenuHander == NULL) |
430 return; | 430 return; |
431 | 431 |
432 CFX_WideString wsCpText; | 432 CFX_WideString wsCpText; |
433 » pXFAMenuHander->Cut((XFA_HWIDGET)hWidget, wsCpText); | 433 » pXFAMenuHander->Cut((IXFA_Widget*)hWidget, wsCpText); |
434 | 434 |
435 CFX_ByteString bsCpText = wsCpText.UTF16LE_Encode(); | 435 CFX_ByteString bsCpText = wsCpText.UTF16LE_Encode(); |
436 int len = bsCpText.GetLength()/sizeof(unsigned short); | 436 int len = bsCpText.GetLength()/sizeof(unsigned short); |
437 if (wsText == NULL) { | 437 if (wsText == NULL) { |
438 *size = len; | 438 *size = len; |
439 return; | 439 return; |
440 } | 440 } |
441 | 441 |
442 int real_size = len < *size ? len : *size; | 442 int real_size = len < *size ? len : *size; |
443 if (real_size > 0) | 443 if (real_size > 0) |
(...skipping 10 matching lines...) Expand all Loading... |
454 | 454 |
455 CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document; | 455 CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document; |
456 if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && pDocument->GetDocT
ype() != XFA_DOCTYPE_Static) | 456 if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && pDocument->GetDocT
ype() != XFA_DOCTYPE_Static) |
457 return; | 457 return; |
458 | 458 |
459 IXFA_MenuHandler* pXFAMenuHander = CPDFXFA_App::GetInstance()->GetXFAApp
()->GetMenuHandler(); | 459 IXFA_MenuHandler* pXFAMenuHander = CPDFXFA_App::GetInstance()->GetXFAApp
()->GetMenuHandler(); |
460 if (pXFAMenuHander == NULL) | 460 if (pXFAMenuHander == NULL) |
461 return; | 461 return; |
462 | 462 |
463 CFX_WideString wstr = CFX_WideString::FromUTF16LE(wsText, size); | 463 CFX_WideString wstr = CFX_WideString::FromUTF16LE(wsText, size); |
464 » pXFAMenuHander->Paste((XFA_HWIDGET)hWidget, wstr); | 464 » pXFAMenuHander->Paste((IXFA_Widget*)hWidget, wstr); |
465 | 465 |
466 } | 466 } |
467 DLLEXPORT void STDCALL FPDF_Widget_ReplaceSpellCheckWord(FPDF_DOCUMENT document,
FPDF_WIDGET hWidget, float x, float y, FPDF_BYTESTRING bsText) | 467 DLLEXPORT void STDCALL FPDF_Widget_ReplaceSpellCheckWord(FPDF_DOCUMENT document,
FPDF_WIDGET hWidget, float x, float y, FPDF_BYTESTRING bsText) |
468 { | 468 { |
469 if (NULL == hWidget || NULL == document) | 469 if (NULL == hWidget || NULL == document) |
470 return; | 470 return; |
471 | 471 |
472 CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document; | 472 CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document; |
473 if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && pDocument->GetDocT
ype() != XFA_DOCTYPE_Static) | 473 if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && pDocument->GetDocT
ype() != XFA_DOCTYPE_Static) |
474 return; | 474 return; |
475 | 475 |
476 IXFA_MenuHandler* pXFAMenuHander = CPDFXFA_App::GetInstance()->GetXFAApp
()->GetMenuHandler(); | 476 IXFA_MenuHandler* pXFAMenuHander = CPDFXFA_App::GetInstance()->GetXFAApp
()->GetMenuHandler(); |
477 if (pXFAMenuHander == NULL) | 477 if (pXFAMenuHander == NULL) |
478 return; | 478 return; |
479 | 479 |
480 CFX_PointF ptPopup; | 480 CFX_PointF ptPopup; |
481 ptPopup.x = x; | 481 ptPopup.x = x; |
482 ptPopup.y = y; | 482 ptPopup.y = y; |
483 CFX_ByteStringC bs(bsText); | 483 CFX_ByteStringC bs(bsText); |
484 » pXFAMenuHander->ReplaceSpellCheckWord((XFA_HWIDGET)hWidget,ptPopup,bs); | 484 » pXFAMenuHander->ReplaceSpellCheckWord((IXFA_Widget*)hWidget,ptPopup,bs); |
485 | 485 |
486 } | 486 } |
487 DLLEXPORT void STDCALL FPDF_Widget_GetSpellCheckWords(FPDF_DOCUMENT document, FP
DF_WIDGET hWidget, float x, float y, FPDF_STRINGHANDLE* stringHandle) | 487 DLLEXPORT void STDCALL FPDF_Widget_GetSpellCheckWords(FPDF_DOCUMENT document, FP
DF_WIDGET hWidget, float x, float y, FPDF_STRINGHANDLE* stringHandle) |
488 { | 488 { |
489 if (NULL == hWidget || NULL == document) | 489 if (NULL == hWidget || NULL == document) |
490 return; | 490 return; |
491 | 491 |
492 CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document; | 492 CPDFXFA_Document* pDocument = (CPDFXFA_Document*)document; |
493 if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && pDocument->GetDocT
ype() != XFA_DOCTYPE_Static) | 493 if (pDocument->GetDocType() != XFA_DOCTYPE_Dynamic && pDocument->GetDocT
ype() != XFA_DOCTYPE_Static) |
494 return; | 494 return; |
495 | 495 |
496 IXFA_MenuHandler* pXFAMenuHander = CPDFXFA_App::GetInstance()->GetXFAApp
()->GetMenuHandler(); | 496 IXFA_MenuHandler* pXFAMenuHander = CPDFXFA_App::GetInstance()->GetXFAApp
()->GetMenuHandler(); |
497 if (pXFAMenuHander == NULL) | 497 if (pXFAMenuHander == NULL) |
498 return; | 498 return; |
499 | 499 |
500 CFX_ByteStringArray* sSuggestWords = FX_NEW CFX_ByteStringArray; | 500 CFX_ByteStringArray* sSuggestWords = FX_NEW CFX_ByteStringArray; |
501 CFX_PointF ptPopup; | 501 CFX_PointF ptPopup; |
502 ptPopup.x = x; | 502 ptPopup.x = x; |
503 ptPopup.y = y; | 503 ptPopup.y = y; |
504 » pXFAMenuHander->GetSuggestWords((XFA_HWIDGET)hWidget, ptPopup, *sSuggest
Words); | 504 » pXFAMenuHander->GetSuggestWords((IXFA_Widget*)hWidget, ptPopup, *sSugges
tWords); |
505 *stringHandle = (FPDF_STRINGHANDLE)sSuggestWords; | 505 *stringHandle = (FPDF_STRINGHANDLE)sSuggestWords; |
506 } | 506 } |
507 DLLEXPORT int STDCALL FPDF_StringHandleCounts(FPDF_STRINGHANDLE stringHandle) | 507 DLLEXPORT int STDCALL FPDF_StringHandleCounts(FPDF_STRINGHANDLE stringHandle) |
508 { | 508 { |
509 if (stringHandle == NULL) | 509 if (stringHandle == NULL) |
510 return -1; | 510 return -1; |
511 CFX_ByteStringArray* sSuggestWords = (CFX_ByteStringArray*)stringHandle; | 511 CFX_ByteStringArray* sSuggestWords = (CFX_ByteStringArray*)stringHandle; |
512 return sSuggestWords->GetSize(); | 512 return sSuggestWords->GetSize(); |
513 } | 513 } |
514 DLLEXPORT FPDF_BOOL STDCALL FPDF_StringHandleGetStringByIndex(FPDF_STRINGHANDLE
stringHandle, int index, FPDF_BYTESTRING bsText, FPDF_DWORD* size) | 514 DLLEXPORT FPDF_BOOL STDCALL FPDF_StringHandleGetStringByIndex(FPDF_STRINGHANDLE
stringHandle, int index, FPDF_BYTESTRING bsText, FPDF_DWORD* size) |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
707 if (bExistCAAction) | 707 if (bExistCAAction) |
708 { | 708 { |
709 CPDF_Action action = aa.GetAction(CPDF_AAction::
ClosePage); | 709 CPDF_Action action = aa.GetAction(CPDF_AAction::
ClosePage); |
710 pActionHandler->DoAction_Page(action, CPDF_AActi
on::ClosePage, pSDKDoc); | 710 pActionHandler->DoAction_Page(action, CPDF_AActi
on::ClosePage, pSDKDoc); |
711 } | 711 } |
712 } | 712 } |
713 } | 713 } |
714 } | 714 } |
715 | 715 |
716 | 716 |
OLD | NEW |