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

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

Issue 2412523002: Cleanup env variable names (Closed)
Patch Set: Fix spelling 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
« no previous file with comments | « fpdfsdk/formfiller/cffl_formfiller.h ('k') | fpdfsdk/formfiller/cffl_interactiveformfiller.h » ('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 "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 = m_pEnv->GetPageView(pPage, true); 253 CPDFSDK_PageView* pPageView = m_pFormFillEnv->GetPageView(pPage, true);
254 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, TRUE)) 254 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, TRUE))
255 pWnd->SetFocus(); 255 pWnd->SetFocus();
256 256
257 m_bValid = TRUE; 257 m_bValid = TRUE;
258 FX_RECT rcRect = GetViewBBox(pPageView, pAnnot); 258 FX_RECT rcRect = GetViewBBox(pPageView, pAnnot);
259 InvalidateRect(rcRect.left, rcRect.top, rcRect.right, rcRect.bottom); 259 InvalidateRect(rcRect.left, rcRect.top, rcRect.right, rcRect.bottom);
260 } 260 }
261 261
262 void CFFL_FormFiller::KillFocusForAnnot(CPDFSDK_Annot* pAnnot, uint32_t nFlag) { 262 void CFFL_FormFiller::KillFocusForAnnot(CPDFSDK_Annot* pAnnot, uint32_t nFlag) {
263 if (!IsValid()) 263 if (!IsValid())
(...skipping 20 matching lines...) Expand all
284 break; 284 break;
285 } 285 }
286 EscapeFiller(pPageView, bDestroyPDFWindow); 286 EscapeFiller(pPageView, bDestroyPDFWindow);
287 } 287 }
288 288
289 FX_BOOL CFFL_FormFiller::IsValid() const { 289 FX_BOOL CFFL_FormFiller::IsValid() const {
290 return m_bValid; 290 return m_bValid;
291 } 291 }
292 292
293 PWL_CREATEPARAM CFFL_FormFiller::GetCreateParam() { 293 PWL_CREATEPARAM CFFL_FormFiller::GetCreateParam() {
294 ASSERT(m_pEnv); 294 ASSERT(m_pFormFillEnv);
295 295
296 PWL_CREATEPARAM cp; 296 PWL_CREATEPARAM cp;
297 cp.pParentWnd = nullptr; 297 cp.pParentWnd = nullptr;
298 cp.pProvider = this; 298 cp.pProvider = this;
299 cp.rcRectWnd = GetPDFWindowRect(); 299 cp.rcRectWnd = GetPDFWindowRect();
300 300
301 uint32_t dwCreateFlags = PWS_BORDER | PWS_BACKGROUND | PWS_VISIBLE; 301 uint32_t dwCreateFlags = PWS_BORDER | PWS_BACKGROUND | PWS_VISIBLE;
302 uint32_t dwFieldFlag = m_pWidget->GetFieldFlags(); 302 uint32_t dwFieldFlag = m_pWidget->GetFieldFlags();
303 if (dwFieldFlag & FIELDFLAG_READONLY) { 303 if (dwFieldFlag & FIELDFLAG_READONLY) {
304 dwCreateFlags |= PWS_READONLY; 304 dwCreateFlags |= PWS_READONLY;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 cp.dwBorderWidth *= 2; 336 cp.dwBorderWidth *= 2;
337 break; 337 break;
338 default: 338 default:
339 break; 339 break;
340 } 340 }
341 341
342 if (cp.fFontSize <= 0) 342 if (cp.fFontSize <= 0)
343 dwCreateFlags |= PWS_AUTOFONTSIZE; 343 dwCreateFlags |= PWS_AUTOFONTSIZE;
344 344
345 cp.dwFlags = dwCreateFlags; 345 cp.dwFlags = dwCreateFlags;
346 cp.pSystemHandler = m_pEnv->GetSysHandler(); 346 cp.pSystemHandler = m_pFormFillEnv->GetSysHandler();
347 return cp; 347 return cp;
348 } 348 }
349 349
350 CPWL_Wnd* CFFL_FormFiller::GetPDFWindow(CPDFSDK_PageView* pPageView, 350 CPWL_Wnd* CFFL_FormFiller::GetPDFWindow(CPDFSDK_PageView* pPageView,
351 FX_BOOL bNew) { 351 FX_BOOL bNew) {
352 ASSERT(pPageView); 352 ASSERT(pPageView);
353 353
354 auto it = m_Maps.find(pPageView); 354 auto it = m_Maps.find(pPageView);
355 const bool found = it != m_Maps.end(); 355 const bool found = it != m_Maps.end();
356 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
431 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);
432 break; 432 break;
433 } 433 }
434 mt.e += rcDA.left; 434 mt.e += rcDA.left;
435 mt.f += rcDA.bottom; 435 mt.f += rcDA.bottom;
436 436
437 return mt; 437 return mt;
438 } 438 }
439 439
440 CFX_WideString CFFL_FormFiller::LoadPopupMenuString(int nIndex) { 440 CFX_WideString CFFL_FormFiller::LoadPopupMenuString(int nIndex) {
441 ASSERT(m_pEnv); 441 ASSERT(m_pFormFillEnv);
442 442
443 return L""; 443 return L"";
444 } 444 }
445 445
446 CFX_FloatRect CFFL_FormFiller::GetPDFWindowRect() const { 446 CFX_FloatRect CFFL_FormFiller::GetPDFWindowRect() const {
447 CFX_FloatRect rectAnnot = m_pWidget->GetPDFAnnot()->GetRect(); 447 CFX_FloatRect rectAnnot = m_pWidget->GetPDFAnnot()->GetRect();
448 448
449 FX_FLOAT fWidth = rectAnnot.right - rectAnnot.left; 449 FX_FLOAT fWidth = rectAnnot.right - rectAnnot.left;
450 FX_FLOAT fHeight = rectAnnot.top - rectAnnot.bottom; 450 FX_FLOAT fHeight = rectAnnot.top - rectAnnot.bottom;
451 if ((m_pWidget->GetRotate() / 90) & 0x01) 451 if ((m_pWidget->GetRotate() / 90) & 0x01)
452 return CFX_FloatRect(0, 0, fHeight, fWidth); 452 return CFX_FloatRect(0, 0, fHeight, fWidth);
453 453
454 return CFX_FloatRect(0, 0, fWidth, fHeight); 454 return CFX_FloatRect(0, 0, fWidth, fHeight);
455 } 455 }
456 456
457 CPDFSDK_PageView* CFFL_FormFiller::GetCurPageView(bool renew) { 457 CPDFSDK_PageView* CFFL_FormFiller::GetCurPageView(bool renew) {
458 UnderlyingPageType* pPage = m_pAnnot->GetUnderlyingPage(); 458 UnderlyingPageType* pPage = m_pAnnot->GetUnderlyingPage();
459 return m_pEnv ? m_pEnv->GetPageView(pPage, renew) : nullptr; 459 return m_pFormFillEnv ? m_pFormFillEnv->GetPageView(pPage, renew) : nullptr;
460 } 460 }
461 461
462 CFX_FloatRect CFFL_FormFiller::GetFocusBox(CPDFSDK_PageView* pPageView) { 462 CFX_FloatRect CFFL_FormFiller::GetFocusBox(CPDFSDK_PageView* pPageView) {
463 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) { 463 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) {
464 CFX_FloatRect rcFocus = FFLtoWnd(pPageView, PWLtoFFL(pWnd->GetFocusRect())); 464 CFX_FloatRect rcFocus = FFLtoWnd(pPageView, PWLtoFFL(pWnd->GetFocusRect()));
465 CFX_FloatRect rcPage = pPageView->GetPDFPage()->GetPageBBox(); 465 CFX_FloatRect rcPage = pPageView->GetPDFPage()->GetPageBBox();
466 if (rcPage.Contains(rcFocus)) 466 if (rcPage.Contains(rcFocus))
467 return rcFocus; 467 return rcFocus;
468 } 468 }
469 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
516 const CFX_FloatRect& rect) { 516 const CFX_FloatRect& rect) {
517 return rect; 517 return rect;
518 } 518 }
519 519
520 FX_BOOL CFFL_FormFiller::CommitData(CPDFSDK_PageView* pPageView, 520 FX_BOOL CFFL_FormFiller::CommitData(CPDFSDK_PageView* pPageView,
521 uint32_t nFlag) { 521 uint32_t nFlag) {
522 if (IsDataChanged(pPageView)) { 522 if (IsDataChanged(pPageView)) {
523 FX_BOOL bRC = TRUE; 523 FX_BOOL bRC = TRUE;
524 FX_BOOL bExit = FALSE; 524 FX_BOOL bExit = FALSE;
525 CFFL_InteractiveFormFiller* pFormFiller = 525 CFFL_InteractiveFormFiller* pFormFiller =
526 m_pEnv->GetInteractiveFormFiller(); 526 m_pFormFillEnv->GetInteractiveFormFiller();
527 CPDFSDK_Annot::ObservedPtr pObserved(m_pWidget); 527 CPDFSDK_Annot::ObservedPtr pObserved(m_pWidget);
528 pFormFiller->OnKeyStrokeCommit(&pObserved, pPageView, bRC, bExit, nFlag); 528 pFormFiller->OnKeyStrokeCommit(&pObserved, pPageView, bRC, bExit, nFlag);
529 if (!pObserved || bExit) 529 if (!pObserved || bExit)
530 return TRUE; 530 return TRUE;
531 if (!bRC) { 531 if (!bRC) {
532 ResetPDFWindow(pPageView, FALSE); 532 ResetPDFWindow(pPageView, FALSE);
533 return TRUE; 533 return TRUE;
534 } 534 }
535 pFormFiller->OnValidate(&pObserved, pPageView, bRC, bExit, nFlag); 535 pFormFiller->OnValidate(&pObserved, pPageView, bRC, bExit, nFlag);
536 if (!pObserved || bExit) 536 if (!pObserved || bExit)
(...skipping 18 matching lines...) Expand all
555 555
556 void CFFL_FormFiller::SaveData(CPDFSDK_PageView* pPageView) {} 556 void CFFL_FormFiller::SaveData(CPDFSDK_PageView* pPageView) {}
557 557
558 #ifdef PDF_ENABLE_XFA 558 #ifdef PDF_ENABLE_XFA
559 FX_BOOL CFFL_FormFiller::IsFieldFull(CPDFSDK_PageView* pPageView) { 559 FX_BOOL CFFL_FormFiller::IsFieldFull(CPDFSDK_PageView* pPageView) {
560 return FALSE; 560 return FALSE;
561 } 561 }
562 #endif // PDF_ENABLE_XFA 562 #endif // PDF_ENABLE_XFA
563 563
564 void CFFL_FormFiller::SetChangeMark() { 564 void CFFL_FormFiller::SetChangeMark() {
565 m_pEnv->OnChange(); 565 m_pFormFillEnv->OnChange();
566 } 566 }
567 567
568 void CFFL_FormFiller::GetActionData(CPDFSDK_PageView* pPageView, 568 void CFFL_FormFiller::GetActionData(CPDFSDK_PageView* pPageView,
569 CPDF_AAction::AActionType type, 569 CPDF_AAction::AActionType type,
570 PDFSDK_FieldAction& fa) { 570 PDFSDK_FieldAction& fa) {
571 fa.sValue = m_pWidget->GetValue(); 571 fa.sValue = m_pWidget->GetValue();
572 } 572 }
573 573
574 void CFFL_FormFiller::SetActionData(CPDFSDK_PageView* pPageView, 574 void CFFL_FormFiller::SetActionData(CPDFSDK_PageView* pPageView,
575 CPDF_AAction::AActionType type, 575 CPDF_AAction::AActionType type,
(...skipping 10 matching lines...) Expand all
586 void CFFL_FormFiller::RestoreState(CPDFSDK_PageView* pPageView) {} 586 void CFFL_FormFiller::RestoreState(CPDFSDK_PageView* pPageView) {}
587 587
588 CPWL_Wnd* CFFL_FormFiller::ResetPDFWindow(CPDFSDK_PageView* pPageView, 588 CPWL_Wnd* CFFL_FormFiller::ResetPDFWindow(CPDFSDK_PageView* pPageView,
589 FX_BOOL bRestoreValue) { 589 FX_BOOL bRestoreValue) {
590 return GetPDFWindow(pPageView, FALSE); 590 return GetPDFWindow(pPageView, FALSE);
591 } 591 }
592 592
593 void CFFL_FormFiller::TimerProc() {} 593 void CFFL_FormFiller::TimerProc() {}
594 594
595 CFX_SystemHandler* CFFL_FormFiller::GetSystemHandler() const { 595 CFX_SystemHandler* CFFL_FormFiller::GetSystemHandler() const {
596 return m_pEnv->GetSysHandler(); 596 return m_pFormFillEnv->GetSysHandler();
597 } 597 }
598 598
599 void CFFL_FormFiller::EscapeFiller(CPDFSDK_PageView* pPageView, 599 void CFFL_FormFiller::EscapeFiller(CPDFSDK_PageView* pPageView,
600 FX_BOOL bDestroyPDFWindow) { 600 FX_BOOL bDestroyPDFWindow) {
601 m_bValid = FALSE; 601 m_bValid = FALSE;
602 602
603 FX_RECT rcRect = GetViewBBox(pPageView, m_pWidget); 603 FX_RECT rcRect = GetViewBBox(pPageView, m_pWidget);
604 InvalidateRect(rcRect.left, rcRect.top, rcRect.right, rcRect.bottom); 604 InvalidateRect(rcRect.left, rcRect.top, rcRect.right, rcRect.bottom);
605 605
606 if (bDestroyPDFWindow) 606 if (bDestroyPDFWindow)
607 DestroyPDFWindow(pPageView); 607 DestroyPDFWindow(pPageView);
608 } 608 }
609 609
610 void CFFL_FormFiller::InvalidateRect(double left, 610 void CFFL_FormFiller::InvalidateRect(double left,
611 double top, 611 double top,
612 double right, 612 double right,
613 double bottom) { 613 double bottom) {
614 UnderlyingPageType* pPage = m_pWidget->GetUnderlyingPage(); 614 UnderlyingPageType* pPage = m_pWidget->GetUnderlyingPage();
615 m_pEnv->Invalidate(pPage, left, top, right, bottom); 615 m_pFormFillEnv->Invalidate(pPage, left, top, right, bottom);
616 } 616 }
617 617
618 CFFL_Button::CFFL_Button(CPDFSDK_FormFillEnvironment* pApp, 618 CFFL_Button::CFFL_Button(CPDFSDK_FormFillEnvironment* pApp,
619 CPDFSDK_Annot* pWidget) 619 CPDFSDK_Annot* pWidget)
620 : CFFL_FormFiller(pApp, pWidget), m_bMouseIn(FALSE), m_bMouseDown(FALSE) {} 620 : CFFL_FormFiller(pApp, pWidget), m_bMouseIn(FALSE), m_bMouseDown(FALSE) {}
621 621
622 CFFL_Button::~CFFL_Button() {} 622 CFFL_Button::~CFFL_Button() {}
623 623
624 void CFFL_Button::OnMouseEnter(CPDFSDK_PageView* pPageView, 624 void CFFL_Button::OnMouseEnter(CPDFSDK_PageView* pPageView,
625 CPDFSDK_Annot* pAnnot) { 625 CPDFSDK_Annot* pAnnot) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 666
667 FX_RECT rect = GetViewBBox(pPageView, pAnnot); 667 FX_RECT rect = GetViewBBox(pPageView, pAnnot);
668 InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); 668 InvalidateRect(rect.left, rect.top, rect.right, rect.bottom);
669 return TRUE; 669 return TRUE;
670 } 670 }
671 671
672 FX_BOOL CFFL_Button::OnMouseMove(CPDFSDK_PageView* pPageView, 672 FX_BOOL CFFL_Button::OnMouseMove(CPDFSDK_PageView* pPageView,
673 CPDFSDK_Annot* pAnnot, 673 CPDFSDK_Annot* pAnnot,
674 uint32_t nFlags, 674 uint32_t nFlags,
675 const CFX_FloatPoint& point) { 675 const CFX_FloatPoint& point) {
676 ASSERT(m_pEnv); 676 ASSERT(m_pFormFillEnv);
677 677
678 return TRUE; 678 return TRUE;
679 } 679 }
680 680
681 void CFFL_Button::OnDraw(CPDFSDK_PageView* pPageView, 681 void CFFL_Button::OnDraw(CPDFSDK_PageView* pPageView,
682 CPDFSDK_Annot* pAnnot, 682 CPDFSDK_Annot* pAnnot,
683 CFX_RenderDevice* pDevice, 683 CFX_RenderDevice* pDevice,
684 CFX_Matrix* pUser2Device) { 684 CFX_Matrix* pUser2Device) {
685 ASSERT(pPageView); 685 ASSERT(pPageView);
686 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; 686 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
(...skipping 22 matching lines...) Expand all
709 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, nullptr); 709 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, nullptr);
710 } 710 }
711 } 711 }
712 712
713 void CFFL_Button::OnDrawDeactive(CPDFSDK_PageView* pPageView, 713 void CFFL_Button::OnDrawDeactive(CPDFSDK_PageView* pPageView,
714 CPDFSDK_Annot* pAnnot, 714 CPDFSDK_Annot* pAnnot,
715 CFX_RenderDevice* pDevice, 715 CFX_RenderDevice* pDevice,
716 CFX_Matrix* pUser2Device) { 716 CFX_Matrix* pUser2Device) {
717 OnDraw(pPageView, pAnnot, pDevice, pUser2Device); 717 OnDraw(pPageView, pAnnot, pDevice, pUser2Device);
718 } 718 }
OLDNEW
« no previous file with comments | « fpdfsdk/formfiller/cffl_formfiller.h ('k') | fpdfsdk/formfiller/cffl_interactiveformfiller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698