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

Side by Side Diff: fpdfsdk/formfiller/cffl_formfiller.cpp

Issue 2412523002: Cleanup env variable names (Closed)
Patch Set: Cleanup Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
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 "fpdfsdk/formfiller/cffl_formfiller.h" 7 #include "fpdfsdk/formfiller/cffl_formfiller.h"
8 8
9 #include "core/fpdfapi/page/cpdf_page.h" 9 #include "core/fpdfapi/page/cpdf_page.h"
10 #include "core/fxge/cfx_renderdevice.h" 10 #include "core/fxge/cfx_renderdevice.h"
11 #include "fpdfsdk/cpdfsdk_formfillenvironment.h" 11 #include "fpdfsdk/cpdfsdk_formfillenvironment.h"
12 #include "fpdfsdk/cpdfsdk_pageview.h" 12 #include "fpdfsdk/cpdfsdk_pageview.h"
13 #include "fpdfsdk/cpdfsdk_widget.h" 13 #include "fpdfsdk/cpdfsdk_widget.h"
14 #include "fpdfsdk/formfiller/cba_fontmap.h" 14 #include "fpdfsdk/formfiller/cba_fontmap.h"
15 #include "fpdfsdk/fsdk_common.h" 15 #include "fpdfsdk/fsdk_common.h"
16 #include "fpdfsdk/pdfwindow/PWL_Utils.h" 16 #include "fpdfsdk/pdfwindow/PWL_Utils.h"
17 17
18 #define GetRed(rgb) ((uint8_t)(rgb)) 18 #define GetRed(rgb) ((uint8_t)(rgb))
19 #define GetGreen(rgb) ((uint8_t)(((uint16_t)(rgb)) >> 8)) 19 #define GetGreen(rgb) ((uint8_t)(((uint16_t)(rgb)) >> 8))
20 #define GetBlue(rgb) ((uint8_t)((rgb) >> 16)) 20 #define GetBlue(rgb) ((uint8_t)((rgb) >> 16))
21 21
22 #define FFL_HINT_ELAPSE 800 22 #define FFL_HINT_ELAPSE 800
23 23
24 CFFL_FormFiller::CFFL_FormFiller(CPDFSDK_FormFillEnvironment* pEnv, 24 CFFL_FormFiller::CFFL_FormFiller(CPDFSDK_FormFillEnvironment* pFormFillEnv,
25 CPDFSDK_Annot* pAnnot) 25 CPDFSDK_Annot* pAnnot)
26 : m_pEnv(pEnv), m_pAnnot(pAnnot), m_bValid(FALSE) { 26 : m_pFormFillEnv(pFormFillEnv), m_pAnnot(pAnnot), m_bValid(FALSE) {
27 m_pWidget = static_cast<CPDFSDK_Widget*>(pAnnot); 27 m_pWidget = static_cast<CPDFSDK_Widget*>(pAnnot);
28 } 28 }
29 29
30 CFFL_FormFiller::~CFFL_FormFiller() { 30 CFFL_FormFiller::~CFFL_FormFiller() {
31 DestroyWindows(); 31 DestroyWindows();
32 } 32 }
33 33
34 void CFFL_FormFiller::DestroyWindows() { 34 void CFFL_FormFiller::DestroyWindows() {
35 for (const auto& it : m_Maps) { 35 for (const auto& it : m_Maps) {
36 CPWL_Wnd* pWnd = it.second; 36 CPWL_Wnd* pWnd = it.second;
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 return pWnd->OnChar(nChar, nFlags); 243 return pWnd->OnChar(nChar, nFlags);
244 } 244 }
245 } 245 }
246 246
247 return FALSE; 247 return FALSE;
248 } 248 }
249 249
250 void CFFL_FormFiller::SetFocusForAnnot(CPDFSDK_Annot* pAnnot, uint32_t nFlag) { 250 void CFFL_FormFiller::SetFocusForAnnot(CPDFSDK_Annot* pAnnot, uint32_t nFlag) {
251 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; 251 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
252 UnderlyingPageType* pPage = pWidget->GetUnderlyingPage(); 252 UnderlyingPageType* pPage = pWidget->GetUnderlyingPage();
253 CPDFSDK_PageView* pPageView = 253 CPDFSDK_PageView* pPageView = m_pFormFillEnv->GetPageView(pPage, true);
254 m_pEnv->GetSDKDocument()->GetPageView(pPage, true);
255 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, TRUE)) 254 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, TRUE))
256 pWnd->SetFocus(); 255 pWnd->SetFocus();
257 256
258 m_bValid = TRUE; 257 m_bValid = TRUE;
259 FX_RECT rcRect = GetViewBBox(pPageView, pAnnot); 258 FX_RECT rcRect = GetViewBBox(pPageView, pAnnot);
260 InvalidateRect(rcRect.left, rcRect.top, rcRect.right, rcRect.bottom); 259 InvalidateRect(rcRect.left, rcRect.top, rcRect.right, rcRect.bottom);
261 } 260 }
262 261
263 void CFFL_FormFiller::KillFocusForAnnot(CPDFSDK_Annot* pAnnot, uint32_t nFlag) { 262 void CFFL_FormFiller::KillFocusForAnnot(CPDFSDK_Annot* pAnnot, uint32_t nFlag) {
264 if (!IsValid()) 263 if (!IsValid())
(...skipping 20 matching lines...) Expand all
285 break; 284 break;
286 } 285 }
287 EscapeFiller(pPageView, bDestroyPDFWindow); 286 EscapeFiller(pPageView, bDestroyPDFWindow);
288 } 287 }
289 288
290 FX_BOOL CFFL_FormFiller::IsValid() const { 289 FX_BOOL CFFL_FormFiller::IsValid() const {
291 return m_bValid; 290 return m_bValid;
292 } 291 }
293 292
294 PWL_CREATEPARAM CFFL_FormFiller::GetCreateParam() { 293 PWL_CREATEPARAM CFFL_FormFiller::GetCreateParam() {
295 ASSERT(m_pEnv); 294 ASSERT(m_pFormFillEnv);
296 295
297 PWL_CREATEPARAM cp; 296 PWL_CREATEPARAM cp;
298 cp.pParentWnd = nullptr; 297 cp.pParentWnd = nullptr;
299 cp.pProvider = this; 298 cp.pProvider = this;
300 cp.rcRectWnd = GetPDFWindowRect(); 299 cp.rcRectWnd = GetPDFWindowRect();
301 300
302 uint32_t dwCreateFlags = PWS_BORDER | PWS_BACKGROUND | PWS_VISIBLE; 301 uint32_t dwCreateFlags = PWS_BORDER | PWS_BACKGROUND | PWS_VISIBLE;
303 uint32_t dwFieldFlag = m_pWidget->GetFieldFlags(); 302 uint32_t dwFieldFlag = m_pWidget->GetFieldFlags();
304 if (dwFieldFlag & FIELDFLAG_READONLY) { 303 if (dwFieldFlag & FIELDFLAG_READONLY) {
305 dwCreateFlags |= PWS_READONLY; 304 dwCreateFlags |= PWS_READONLY;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 cp.dwBorderWidth *= 2; 336 cp.dwBorderWidth *= 2;
338 break; 337 break;
339 default: 338 default:
340 break; 339 break;
341 } 340 }
342 341
343 if (cp.fFontSize <= 0) 342 if (cp.fFontSize <= 0)
344 dwCreateFlags |= PWS_AUTOFONTSIZE; 343 dwCreateFlags |= PWS_AUTOFONTSIZE;
345 344
346 cp.dwFlags = dwCreateFlags; 345 cp.dwFlags = dwCreateFlags;
347 cp.pSystemHandler = m_pEnv->GetSysHandler(); 346 cp.pSystemHandler = m_pFormFillEnv->GetSysHandler();
348 return cp; 347 return cp;
349 } 348 }
350 349
351 CPWL_Wnd* CFFL_FormFiller::GetPDFWindow(CPDFSDK_PageView* pPageView, 350 CPWL_Wnd* CFFL_FormFiller::GetPDFWindow(CPDFSDK_PageView* pPageView,
352 FX_BOOL bNew) { 351 FX_BOOL bNew) {
353 ASSERT(pPageView); 352 ASSERT(pPageView);
354 353
355 auto it = m_Maps.find(pPageView); 354 auto it = m_Maps.find(pPageView);
356 const bool found = it != m_Maps.end(); 355 const bool found = it != m_Maps.end();
357 CPWL_Wnd* pWnd = found ? it->second : nullptr; 356 CPWL_Wnd* pWnd = found ? it->second : nullptr;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 mt = CFX_Matrix(0, -1, 1, 0, 0, rcDA.top - rcDA.bottom); 431 mt = CFX_Matrix(0, -1, 1, 0, 0, rcDA.top - rcDA.bottom);
433 break; 432 break;
434 } 433 }
435 mt.e += rcDA.left; 434 mt.e += rcDA.left;
436 mt.f += rcDA.bottom; 435 mt.f += rcDA.bottom;
437 436
438 return mt; 437 return mt;
439 } 438 }
440 439
441 CFX_WideString CFFL_FormFiller::LoadPopupMenuString(int nIndex) { 440 CFX_WideString CFFL_FormFiller::LoadPopupMenuString(int nIndex) {
442 ASSERT(m_pEnv); 441 ASSERT(m_pFormFillEnv);
443 442
444 return L""; 443 return L"";
445 } 444 }
446 445
447 CFX_FloatRect CFFL_FormFiller::GetPDFWindowRect() const { 446 CFX_FloatRect CFFL_FormFiller::GetPDFWindowRect() const {
448 CFX_FloatRect rectAnnot = m_pWidget->GetPDFAnnot()->GetRect(); 447 CFX_FloatRect rectAnnot = m_pWidget->GetPDFAnnot()->GetRect();
449 448
450 FX_FLOAT fWidth = rectAnnot.right - rectAnnot.left; 449 FX_FLOAT fWidth = rectAnnot.right - rectAnnot.left;
451 FX_FLOAT fHeight = rectAnnot.top - rectAnnot.bottom; 450 FX_FLOAT fHeight = rectAnnot.top - rectAnnot.bottom;
452 if ((m_pWidget->GetRotate() / 90) & 0x01) 451 if ((m_pWidget->GetRotate() / 90) & 0x01)
453 return CFX_FloatRect(0, 0, fHeight, fWidth); 452 return CFX_FloatRect(0, 0, fHeight, fWidth);
454 453
455 return CFX_FloatRect(0, 0, fWidth, fHeight); 454 return CFX_FloatRect(0, 0, fWidth, fHeight);
456 } 455 }
457 456
458 CPDFSDK_PageView* CFFL_FormFiller::GetCurPageView(bool renew) { 457 CPDFSDK_PageView* CFFL_FormFiller::GetCurPageView(bool renew) {
459 UnderlyingPageType* pPage = m_pAnnot->GetUnderlyingPage(); 458 UnderlyingPageType* pPage = m_pAnnot->GetUnderlyingPage();
460 return m_pEnv ? m_pEnv->GetSDKDocument()->GetPageView(pPage, renew) : nullptr; 459 return m_pFormFillEnv ? m_pFormFillEnv->GetPageView(pPage, renew) : nullptr;
461 } 460 }
462 461
463 CFX_FloatRect CFFL_FormFiller::GetFocusBox(CPDFSDK_PageView* pPageView) { 462 CFX_FloatRect CFFL_FormFiller::GetFocusBox(CPDFSDK_PageView* pPageView) {
464 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) { 463 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) {
465 CFX_FloatRect rcFocus = FFLtoWnd(pPageView, PWLtoFFL(pWnd->GetFocusRect())); 464 CFX_FloatRect rcFocus = FFLtoWnd(pPageView, PWLtoFFL(pWnd->GetFocusRect()));
466 CFX_FloatRect rcPage = pPageView->GetPDFPage()->GetPageBBox(); 465 CFX_FloatRect rcPage = pPageView->GetPDFPage()->GetPageBBox();
467 if (rcPage.Contains(rcFocus)) 466 if (rcPage.Contains(rcFocus))
468 return rcFocus; 467 return rcFocus;
469 } 468 }
470 return CFX_FloatRect(0, 0, 0, 0); 469 return CFX_FloatRect(0, 0, 0, 0);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 const CFX_FloatRect& rect) { 516 const CFX_FloatRect& rect) {
518 return rect; 517 return rect;
519 } 518 }
520 519
521 FX_BOOL CFFL_FormFiller::CommitData(CPDFSDK_PageView* pPageView, 520 FX_BOOL CFFL_FormFiller::CommitData(CPDFSDK_PageView* pPageView,
522 uint32_t nFlag) { 521 uint32_t nFlag) {
523 if (IsDataChanged(pPageView)) { 522 if (IsDataChanged(pPageView)) {
524 FX_BOOL bRC = TRUE; 523 FX_BOOL bRC = TRUE;
525 FX_BOOL bExit = FALSE; 524 FX_BOOL bExit = FALSE;
526 CFFL_InteractiveFormFiller* pFormFiller = 525 CFFL_InteractiveFormFiller* pFormFiller =
527 m_pEnv->GetInteractiveFormFiller(); 526 m_pFormFillEnv->GetInteractiveFormFiller();
528 CPDFSDK_Annot::ObservedPtr pObserved(m_pWidget); 527 CPDFSDK_Annot::ObservedPtr pObserved(m_pWidget);
529 pFormFiller->OnKeyStrokeCommit(&pObserved, pPageView, bRC, bExit, nFlag); 528 pFormFiller->OnKeyStrokeCommit(&pObserved, pPageView, bRC, bExit, nFlag);
530 if (!pObserved || bExit) 529 if (!pObserved || bExit)
531 return TRUE; 530 return TRUE;
532 if (!bRC) { 531 if (!bRC) {
533 ResetPDFWindow(pPageView, FALSE); 532 ResetPDFWindow(pPageView, FALSE);
534 return TRUE; 533 return TRUE;
535 } 534 }
536 pFormFiller->OnValidate(&pObserved, pPageView, bRC, bExit, nFlag); 535 pFormFiller->OnValidate(&pObserved, pPageView, bRC, bExit, nFlag);
537 if (!pObserved || bExit) 536 if (!pObserved || bExit)
(...skipping 18 matching lines...) Expand all
556 555
557 void CFFL_FormFiller::SaveData(CPDFSDK_PageView* pPageView) {} 556 void CFFL_FormFiller::SaveData(CPDFSDK_PageView* pPageView) {}
558 557
559 #ifdef PDF_ENABLE_XFA 558 #ifdef PDF_ENABLE_XFA
560 FX_BOOL CFFL_FormFiller::IsFieldFull(CPDFSDK_PageView* pPageView) { 559 FX_BOOL CFFL_FormFiller::IsFieldFull(CPDFSDK_PageView* pPageView) {
561 return FALSE; 560 return FALSE;
562 } 561 }
563 #endif // PDF_ENABLE_XFA 562 #endif // PDF_ENABLE_XFA
564 563
565 void CFFL_FormFiller::SetChangeMark() { 564 void CFFL_FormFiller::SetChangeMark() {
566 m_pEnv->OnChange(); 565 m_pFormFillEnv->OnChange();
567 } 566 }
568 567
569 void CFFL_FormFiller::GetActionData(CPDFSDK_PageView* pPageView, 568 void CFFL_FormFiller::GetActionData(CPDFSDK_PageView* pPageView,
570 CPDF_AAction::AActionType type, 569 CPDF_AAction::AActionType type,
571 PDFSDK_FieldAction& fa) { 570 PDFSDK_FieldAction& fa) {
572 fa.sValue = m_pWidget->GetValue(); 571 fa.sValue = m_pWidget->GetValue();
573 } 572 }
574 573
575 void CFFL_FormFiller::SetActionData(CPDFSDK_PageView* pPageView, 574 void CFFL_FormFiller::SetActionData(CPDFSDK_PageView* pPageView,
576 CPDF_AAction::AActionType type, 575 CPDF_AAction::AActionType type,
(...skipping 10 matching lines...) Expand all
587 void CFFL_FormFiller::RestoreState(CPDFSDK_PageView* pPageView) {} 586 void CFFL_FormFiller::RestoreState(CPDFSDK_PageView* pPageView) {}
588 587
589 CPWL_Wnd* CFFL_FormFiller::ResetPDFWindow(CPDFSDK_PageView* pPageView, 588 CPWL_Wnd* CFFL_FormFiller::ResetPDFWindow(CPDFSDK_PageView* pPageView,
590 FX_BOOL bRestoreValue) { 589 FX_BOOL bRestoreValue) {
591 return GetPDFWindow(pPageView, FALSE); 590 return GetPDFWindow(pPageView, FALSE);
592 } 591 }
593 592
594 void CFFL_FormFiller::TimerProc() {} 593 void CFFL_FormFiller::TimerProc() {}
595 594
596 CFX_SystemHandler* CFFL_FormFiller::GetSystemHandler() const { 595 CFX_SystemHandler* CFFL_FormFiller::GetSystemHandler() const {
597 return m_pEnv->GetSysHandler(); 596 return m_pFormFillEnv->GetSysHandler();
598 } 597 }
599 598
600 void CFFL_FormFiller::EscapeFiller(CPDFSDK_PageView* pPageView, 599 void CFFL_FormFiller::EscapeFiller(CPDFSDK_PageView* pPageView,
601 FX_BOOL bDestroyPDFWindow) { 600 FX_BOOL bDestroyPDFWindow) {
602 m_bValid = FALSE; 601 m_bValid = FALSE;
603 602
604 FX_RECT rcRect = GetViewBBox(pPageView, m_pWidget); 603 FX_RECT rcRect = GetViewBBox(pPageView, m_pWidget);
605 InvalidateRect(rcRect.left, rcRect.top, rcRect.right, rcRect.bottom); 604 InvalidateRect(rcRect.left, rcRect.top, rcRect.right, rcRect.bottom);
606 605
607 if (bDestroyPDFWindow) 606 if (bDestroyPDFWindow)
608 DestroyPDFWindow(pPageView); 607 DestroyPDFWindow(pPageView);
609 } 608 }
610 609
611 void CFFL_FormFiller::InvalidateRect(double left, 610 void CFFL_FormFiller::InvalidateRect(double left,
612 double top, 611 double top,
613 double right, 612 double right,
614 double bottom) { 613 double bottom) {
615 UnderlyingPageType* pPage = m_pWidget->GetUnderlyingPage(); 614 UnderlyingPageType* pPage = m_pWidget->GetUnderlyingPage();
616 m_pEnv->Invalidate(pPage, left, top, right, bottom); 615 m_pFormFillEnv->Invalidate(pPage, left, top, right, bottom);
617 } 616 }
618 617
619 CFFL_Button::CFFL_Button(CPDFSDK_FormFillEnvironment* pApp, 618 CFFL_Button::CFFL_Button(CPDFSDK_FormFillEnvironment* pApp,
620 CPDFSDK_Annot* pWidget) 619 CPDFSDK_Annot* pWidget)
621 : CFFL_FormFiller(pApp, pWidget), m_bMouseIn(FALSE), m_bMouseDown(FALSE) {} 620 : CFFL_FormFiller(pApp, pWidget), m_bMouseIn(FALSE), m_bMouseDown(FALSE) {}
622 621
623 CFFL_Button::~CFFL_Button() {} 622 CFFL_Button::~CFFL_Button() {}
624 623
625 void CFFL_Button::OnMouseEnter(CPDFSDK_PageView* pPageView, 624 void CFFL_Button::OnMouseEnter(CPDFSDK_PageView* pPageView,
626 CPDFSDK_Annot* pAnnot) { 625 CPDFSDK_Annot* pAnnot) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
667 666
668 FX_RECT rect = GetViewBBox(pPageView, pAnnot); 667 FX_RECT rect = GetViewBBox(pPageView, pAnnot);
669 InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); 668 InvalidateRect(rect.left, rect.top, rect.right, rect.bottom);
670 return TRUE; 669 return TRUE;
671 } 670 }
672 671
673 FX_BOOL CFFL_Button::OnMouseMove(CPDFSDK_PageView* pPageView, 672 FX_BOOL CFFL_Button::OnMouseMove(CPDFSDK_PageView* pPageView,
674 CPDFSDK_Annot* pAnnot, 673 CPDFSDK_Annot* pAnnot,
675 uint32_t nFlags, 674 uint32_t nFlags,
676 const CFX_FloatPoint& point) { 675 const CFX_FloatPoint& point) {
677 ASSERT(m_pEnv); 676 ASSERT(m_pFormFillEnv);
678 677
679 return TRUE; 678 return TRUE;
680 } 679 }
681 680
682 void CFFL_Button::OnDraw(CPDFSDK_PageView* pPageView, 681 void CFFL_Button::OnDraw(CPDFSDK_PageView* pPageView,
683 CPDFSDK_Annot* pAnnot, 682 CPDFSDK_Annot* pAnnot,
684 CFX_RenderDevice* pDevice, 683 CFX_RenderDevice* pDevice,
685 CFX_Matrix* pUser2Device) { 684 CFX_Matrix* pUser2Device) {
686 ASSERT(pPageView); 685 ASSERT(pPageView);
687 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; 686 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
(...skipping 22 matching lines...) Expand all
710 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, nullptr); 709 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, nullptr);
711 } 710 }
712 } 711 }
713 712
714 void CFFL_Button::OnDrawDeactive(CPDFSDK_PageView* pPageView, 713 void CFFL_Button::OnDrawDeactive(CPDFSDK_PageView* pPageView,
715 CPDFSDK_Annot* pAnnot, 714 CPDFSDK_Annot* pAnnot,
716 CFX_RenderDevice* pDevice, 715 CFX_RenderDevice* pDevice,
717 CFX_Matrix* pUser2Device) { 716 CFX_Matrix* pUser2Device) {
718 OnDraw(pPageView, pAnnot, pDevice, pUser2Device); 717 OnDraw(pPageView, pAnnot, pDevice, pUser2Device);
719 } 718 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698