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

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

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

Powered by Google App Engine
This is Rietveld 408576698