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

Side by Side Diff: fpdfsdk/fpdfformfill.cpp

Issue 2453683011: Remove FX_BOOL from fpdfsdk. (Closed)
Patch Set: Regenerate patch after rebase. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fpdfsdk/fpdfeditpage.cpp ('k') | fpdfsdk/fpdfppo.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "public/fpdf_formfill.h" 7 #include "public/fpdf_formfill.h"
8 8
9 #include <memory> 9 #include <memory>
10 #include <vector> 10 #include <vector>
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 delete pFormFillEnv; 283 delete pFormFillEnv;
284 } 284 }
285 285
286 DLLEXPORT FPDF_BOOL STDCALL FORM_OnMouseMove(FPDF_FORMHANDLE hHandle, 286 DLLEXPORT FPDF_BOOL STDCALL FORM_OnMouseMove(FPDF_FORMHANDLE hHandle,
287 FPDF_PAGE page, 287 FPDF_PAGE page,
288 int modifier, 288 int modifier,
289 double page_x, 289 double page_x,
290 double page_y) { 290 double page_y) {
291 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page); 291 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
292 if (!pPageView) 292 if (!pPageView)
293 return FALSE; 293 return false;
294 294
295 CFX_FloatPoint pt((FX_FLOAT)page_x, (FX_FLOAT)page_y); 295 CFX_FloatPoint pt((FX_FLOAT)page_x, (FX_FLOAT)page_y);
296 return pPageView->OnMouseMove(pt, modifier); 296 return pPageView->OnMouseMove(pt, modifier);
297 } 297 }
298 298
299 DLLEXPORT FPDF_BOOL STDCALL FORM_OnLButtonDown(FPDF_FORMHANDLE hHandle, 299 DLLEXPORT FPDF_BOOL STDCALL FORM_OnLButtonDown(FPDF_FORMHANDLE hHandle,
300 FPDF_PAGE page, 300 FPDF_PAGE page,
301 int modifier, 301 int modifier,
302 double page_x, 302 double page_x,
303 double page_y) { 303 double page_y) {
304 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page); 304 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
305 if (!pPageView) 305 if (!pPageView)
306 return FALSE; 306 return false;
307 307
308 CFX_FloatPoint pt((FX_FLOAT)page_x, (FX_FLOAT)page_y); 308 CFX_FloatPoint pt((FX_FLOAT)page_x, (FX_FLOAT)page_y);
309 return pPageView->OnLButtonDown(pt, modifier); 309 return pPageView->OnLButtonDown(pt, modifier);
310 } 310 }
311 311
312 DLLEXPORT FPDF_BOOL STDCALL FORM_OnLButtonUp(FPDF_FORMHANDLE hHandle, 312 DLLEXPORT FPDF_BOOL STDCALL FORM_OnLButtonUp(FPDF_FORMHANDLE hHandle,
313 FPDF_PAGE page, 313 FPDF_PAGE page,
314 int modifier, 314 int modifier,
315 double page_x, 315 double page_x,
316 double page_y) { 316 double page_y) {
317 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page); 317 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
318 if (!pPageView) 318 if (!pPageView)
319 return FALSE; 319 return false;
320 320
321 CFX_FloatPoint pt((FX_FLOAT)page_x, (FX_FLOAT)page_y); 321 CFX_FloatPoint pt((FX_FLOAT)page_x, (FX_FLOAT)page_y);
322 return pPageView->OnLButtonUp(pt, modifier); 322 return pPageView->OnLButtonUp(pt, modifier);
323 } 323 }
324 324
325 #ifdef PDF_ENABLE_XFA 325 #ifdef PDF_ENABLE_XFA
326 DLLEXPORT FPDF_BOOL STDCALL FORM_OnRButtonDown(FPDF_FORMHANDLE hHandle, 326 DLLEXPORT FPDF_BOOL STDCALL FORM_OnRButtonDown(FPDF_FORMHANDLE hHandle,
327 FPDF_PAGE page, 327 FPDF_PAGE page,
328 int modifier, 328 int modifier,
329 double page_x, 329 double page_x,
330 double page_y) { 330 double page_y) {
331 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page); 331 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
332 if (!pPageView) 332 if (!pPageView)
333 return FALSE; 333 return false;
334 334
335 CFX_FloatPoint pt((FX_FLOAT)page_x, (FX_FLOAT)page_y); 335 CFX_FloatPoint pt((FX_FLOAT)page_x, (FX_FLOAT)page_y);
336 return pPageView->OnRButtonDown(pt, modifier); 336 return pPageView->OnRButtonDown(pt, modifier);
337 } 337 }
338 338
339 DLLEXPORT FPDF_BOOL STDCALL FORM_OnRButtonUp(FPDF_FORMHANDLE hHandle, 339 DLLEXPORT FPDF_BOOL STDCALL FORM_OnRButtonUp(FPDF_FORMHANDLE hHandle,
340 FPDF_PAGE page, 340 FPDF_PAGE page,
341 int modifier, 341 int modifier,
342 double page_x, 342 double page_x,
343 double page_y) { 343 double page_y) {
344 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page); 344 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
345 if (!pPageView) 345 if (!pPageView)
346 return FALSE; 346 return false;
347 347
348 CFX_FloatPoint pt((FX_FLOAT)page_x, (FX_FLOAT)page_y); 348 CFX_FloatPoint pt((FX_FLOAT)page_x, (FX_FLOAT)page_y);
349 return pPageView->OnRButtonUp(pt, modifier); 349 return pPageView->OnRButtonUp(pt, modifier);
350 } 350 }
351 #endif // PDF_ENABLE_XFA 351 #endif // PDF_ENABLE_XFA
352 352
353 DLLEXPORT FPDF_BOOL STDCALL FORM_OnKeyDown(FPDF_FORMHANDLE hHandle, 353 DLLEXPORT FPDF_BOOL STDCALL FORM_OnKeyDown(FPDF_FORMHANDLE hHandle,
354 FPDF_PAGE page, 354 FPDF_PAGE page,
355 int nKeyCode, 355 int nKeyCode,
356 int modifier) { 356 int modifier) {
357 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page); 357 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
358 if (!pPageView) 358 if (!pPageView)
359 return FALSE; 359 return false;
360 360
361 return pPageView->OnKeyDown(nKeyCode, modifier); 361 return pPageView->OnKeyDown(nKeyCode, modifier);
362 } 362 }
363 363
364 DLLEXPORT FPDF_BOOL STDCALL FORM_OnKeyUp(FPDF_FORMHANDLE hHandle, 364 DLLEXPORT FPDF_BOOL STDCALL FORM_OnKeyUp(FPDF_FORMHANDLE hHandle,
365 FPDF_PAGE page, 365 FPDF_PAGE page,
366 int nKeyCode, 366 int nKeyCode,
367 int modifier) { 367 int modifier) {
368 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page); 368 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
369 if (!pPageView) 369 if (!pPageView)
370 return FALSE; 370 return false;
371 371
372 return pPageView->OnKeyUp(nKeyCode, modifier); 372 return pPageView->OnKeyUp(nKeyCode, modifier);
373 } 373 }
374 374
375 DLLEXPORT FPDF_BOOL STDCALL FORM_OnChar(FPDF_FORMHANDLE hHandle, 375 DLLEXPORT FPDF_BOOL STDCALL FORM_OnChar(FPDF_FORMHANDLE hHandle,
376 FPDF_PAGE page, 376 FPDF_PAGE page,
377 int nChar, 377 int nChar,
378 int modifier) { 378 int modifier) {
379 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page); 379 CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page);
380 if (!pPageView) 380 if (!pPageView)
381 return FALSE; 381 return false;
382 382
383 return pPageView->OnChar(nChar, modifier); 383 return pPageView->OnChar(nChar, modifier);
384 } 384 }
385 385
386 DLLEXPORT FPDF_BOOL STDCALL FORM_ForceToKillFocus(FPDF_FORMHANDLE hHandle) { 386 DLLEXPORT FPDF_BOOL STDCALL FORM_ForceToKillFocus(FPDF_FORMHANDLE hHandle) {
387 CPDFSDK_FormFillEnvironment* pFormFillEnv = 387 CPDFSDK_FormFillEnvironment* pFormFillEnv =
388 HandleToCPDFSDKEnvironment(hHandle); 388 HandleToCPDFSDKEnvironment(hHandle);
389 if (!pFormFillEnv) 389 if (!pFormFillEnv)
390 return FALSE; 390 return false;
391 return pFormFillEnv->KillFocusAnnot(0); 391 return pFormFillEnv->KillFocusAnnot(0);
392 } 392 }
393 393
394 DLLEXPORT void STDCALL FPDF_FFLDraw(FPDF_FORMHANDLE hHandle, 394 DLLEXPORT void STDCALL FPDF_FFLDraw(FPDF_FORMHANDLE hHandle,
395 FPDF_BITMAP bitmap, 395 FPDF_BITMAP bitmap,
396 FPDF_PAGE page, 396 FPDF_PAGE page,
397 int start_x, 397 int start_x,
398 int start_y, 398 int start_y,
399 int size_x, 399 int size_x,
400 int size_y, 400 int size_y,
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 std::vector<CFX_ByteString>* sSuggestWords = FromFPDFStringHandle(sHandle); 587 std::vector<CFX_ByteString>* sSuggestWords = FromFPDFStringHandle(sHandle);
588 return sSuggestWords ? pdfium::CollectionSize<int>(*sSuggestWords) : -1; 588 return sSuggestWords ? pdfium::CollectionSize<int>(*sSuggestWords) : -1;
589 } 589 }
590 590
591 DLLEXPORT FPDF_BOOL STDCALL 591 DLLEXPORT FPDF_BOOL STDCALL
592 FPDF_StringHandleGetStringByIndex(FPDF_STRINGHANDLE sHandle, 592 FPDF_StringHandleGetStringByIndex(FPDF_STRINGHANDLE sHandle,
593 int index, 593 int index,
594 FPDF_BYTESTRING bsText, 594 FPDF_BYTESTRING bsText,
595 FPDF_DWORD* size) { 595 FPDF_DWORD* size) {
596 if (!sHandle || !size) 596 if (!sHandle || !size)
597 return FALSE; 597 return false;
598 598
599 int count = FPDF_StringHandleCounts(sHandle); 599 int count = FPDF_StringHandleCounts(sHandle);
600 if (index < 0 || index >= count) 600 if (index < 0 || index >= count)
601 return FALSE; 601 return false;
602 602
603 std::vector<CFX_ByteString>* sSuggestWords = FromFPDFStringHandle(sHandle); 603 std::vector<CFX_ByteString>* sSuggestWords = FromFPDFStringHandle(sHandle);
604 uint32_t len = (*sSuggestWords)[index].GetLength(); 604 uint32_t len = (*sSuggestWords)[index].GetLength();
605 if (!bsText) { 605 if (!bsText) {
606 *size = len; 606 *size = len;
607 return TRUE; 607 return true;
608 } 608 }
609 609
610 uint32_t real_size = len < *size ? len : *size; 610 uint32_t real_size = len < *size ? len : *size;
611 if (real_size > 0) 611 if (real_size > 0)
612 FXSYS_memcpy((void*)bsText, (*sSuggestWords)[index].c_str(), real_size); 612 FXSYS_memcpy((void*)bsText, (*sSuggestWords)[index].c_str(), real_size);
613 *size = real_size; 613 *size = real_size;
614 return TRUE; 614 return true;
615 } 615 }
616 616
617 DLLEXPORT void STDCALL 617 DLLEXPORT void STDCALL
618 FPDF_StringHandleRelease(FPDF_STRINGHANDLE stringHandle) { 618 FPDF_StringHandleRelease(FPDF_STRINGHANDLE stringHandle) {
619 delete FromFPDFStringHandle(stringHandle); 619 delete FromFPDFStringHandle(stringHandle);
620 } 620 }
621 621
622 DLLEXPORT FPDF_BOOL STDCALL 622 DLLEXPORT FPDF_BOOL STDCALL
623 FPDF_StringHandleAddString(FPDF_STRINGHANDLE stringHandle, 623 FPDF_StringHandleAddString(FPDF_STRINGHANDLE stringHandle,
624 FPDF_BYTESTRING bsText, 624 FPDF_BYTESTRING bsText,
625 FPDF_DWORD size) { 625 FPDF_DWORD size) {
626 if (!stringHandle || !bsText || size == 0) 626 if (!stringHandle || !bsText || size == 0)
627 return FALSE; 627 return false;
628 628
629 FromFPDFStringHandle(stringHandle)->push_back(CFX_ByteString(bsText, size)); 629 FromFPDFStringHandle(stringHandle)->push_back(CFX_ByteString(bsText, size));
630 return TRUE; 630 return true;
631 } 631 }
632 #endif // PDF_ENABLE_XFA 632 #endif // PDF_ENABLE_XFA
633 633
634 DLLEXPORT void STDCALL FPDF_SetFormFieldHighlightColor(FPDF_FORMHANDLE hHandle, 634 DLLEXPORT void STDCALL FPDF_SetFormFieldHighlightColor(FPDF_FORMHANDLE hHandle,
635 int fieldType, 635 int fieldType,
636 unsigned long color) { 636 unsigned long color) {
637 if (CPDFSDK_InterForm* pInterForm = FormHandleToInterForm(hHandle)) 637 if (CPDFSDK_InterForm* pInterForm = FormHandleToInterForm(hHandle))
638 pInterForm->SetHighlightColor(color, fieldType); 638 pInterForm->SetHighlightColor(color, fieldType);
639 } 639 }
640 640
641 DLLEXPORT void STDCALL FPDF_SetFormFieldHighlightAlpha(FPDF_FORMHANDLE hHandle, 641 DLLEXPORT void STDCALL FPDF_SetFormFieldHighlightAlpha(FPDF_FORMHANDLE hHandle,
642 unsigned char alpha) { 642 unsigned char alpha) {
643 if (CPDFSDK_InterForm* pInterForm = FormHandleToInterForm(hHandle)) 643 if (CPDFSDK_InterForm* pInterForm = FormHandleToInterForm(hHandle))
644 pInterForm->SetHighlightAlpha(alpha); 644 pInterForm->SetHighlightAlpha(alpha);
645 } 645 }
646 646
647 DLLEXPORT void STDCALL FPDF_RemoveFormFieldHighlight(FPDF_FORMHANDLE hHandle) { 647 DLLEXPORT void STDCALL FPDF_RemoveFormFieldHighlight(FPDF_FORMHANDLE hHandle) {
648 if (CPDFSDK_InterForm* pInterForm = FormHandleToInterForm(hHandle)) 648 if (CPDFSDK_InterForm* pInterForm = FormHandleToInterForm(hHandle))
649 pInterForm->RemoveAllHighLight(); 649 pInterForm->RemoveAllHighLight();
650 } 650 }
651 651
652 DLLEXPORT void STDCALL FORM_OnAfterLoadPage(FPDF_PAGE page, 652 DLLEXPORT void STDCALL FORM_OnAfterLoadPage(FPDF_PAGE page,
653 FPDF_FORMHANDLE hHandle) { 653 FPDF_FORMHANDLE hHandle) {
654 if (CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page)) 654 if (CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, page))
655 pPageView->SetValid(TRUE); 655 pPageView->SetValid(true);
656 } 656 }
657 657
658 DLLEXPORT void STDCALL FORM_OnBeforeClosePage(FPDF_PAGE page, 658 DLLEXPORT void STDCALL FORM_OnBeforeClosePage(FPDF_PAGE page,
659 FPDF_FORMHANDLE hHandle) { 659 FPDF_FORMHANDLE hHandle) {
660 if (!hHandle) 660 if (!hHandle)
661 return; 661 return;
662 662
663 CPDFSDK_FormFillEnvironment* pFormFillEnv = 663 CPDFSDK_FormFillEnvironment* pFormFillEnv =
664 HandleToCPDFSDKEnvironment(hHandle); 664 HandleToCPDFSDKEnvironment(hHandle);
665 if (!pFormFillEnv) 665 if (!pFormFillEnv)
666 return; 666 return;
667 667
668 UnderlyingPageType* pPage = UnderlyingFromFPDFPage(page); 668 UnderlyingPageType* pPage = UnderlyingFromFPDFPage(page);
669 if (!pPage) 669 if (!pPage)
670 return; 670 return;
671 671
672 CPDFSDK_PageView* pPageView = pFormFillEnv->GetPageView(pPage, false); 672 CPDFSDK_PageView* pPageView = pFormFillEnv->GetPageView(pPage, false);
673 if (pPageView) { 673 if (pPageView) {
674 pPageView->SetValid(FALSE); 674 pPageView->SetValid(false);
675 // RemovePageView() takes care of the delete for us. 675 // RemovePageView() takes care of the delete for us.
676 pFormFillEnv->RemovePageView(pPage); 676 pFormFillEnv->RemovePageView(pPage);
677 } 677 }
678 } 678 }
679 679
680 DLLEXPORT void STDCALL FORM_DoDocumentJSAction(FPDF_FORMHANDLE hHandle) { 680 DLLEXPORT void STDCALL FORM_DoDocumentJSAction(FPDF_FORMHANDLE hHandle) {
681 CPDFSDK_FormFillEnvironment* pFormFillEnv = 681 CPDFSDK_FormFillEnvironment* pFormFillEnv =
682 HandleToCPDFSDKEnvironment(hHandle); 682 HandleToCPDFSDKEnvironment(hHandle);
683 if (pFormFillEnv && pFormFillEnv->IsJSInitiated()) 683 if (pFormFillEnv && pFormFillEnv->IsJSInitiated())
684 pFormFillEnv->ProcJavascriptFun(); 684 pFormFillEnv->ProcJavascriptFun();
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 pFormFillEnv); 742 pFormFillEnv);
743 } 743 }
744 } else { 744 } else {
745 if (aa.ActionExist(CPDF_AAction::ClosePage)) { 745 if (aa.ActionExist(CPDF_AAction::ClosePage)) {
746 CPDF_Action action = aa.GetAction(CPDF_AAction::ClosePage); 746 CPDF_Action action = aa.GetAction(CPDF_AAction::ClosePage);
747 pActionHandler->DoAction_Page(action, CPDF_AAction::ClosePage, 747 pActionHandler->DoAction_Page(action, CPDF_AAction::ClosePage,
748 pFormFillEnv); 748 pFormFillEnv);
749 } 749 }
750 } 750 }
751 } 751 }
OLDNEW
« no previous file with comments | « fpdfsdk/fpdfeditpage.cpp ('k') | fpdfsdk/fpdfppo.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698