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

Side by Side Diff: fpdfsdk/src/formfiller/FFL_FormFiller.cpp

Issue 1519693002: Merge to XFA: Remove CFX_AffineMatrix/CPDF_Matrix (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: XFA-specific changes Created 5 years 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/include/formfiller/FFL_CBA_Fontmap.h" 7 #include "fpdfsdk/include/formfiller/FFL_CBA_Fontmap.h"
8 #include "fpdfsdk/include/formfiller/FFL_FormFiller.h" 8 #include "fpdfsdk/include/formfiller/FFL_FormFiller.h"
9 9
10 #define GetRed(rgb) ((uint8_t)(rgb)) 10 #define GetRed(rgb) ((uint8_t)(rgb))
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 rcWin.Union(rcFocus); 66 rcWin.Union(rcFocus);
67 67
68 CPDF_Rect rect = CPWL_Utils::InflateRect(rcWin, 1); 68 CPDF_Rect rect = CPWL_Utils::InflateRect(rcWin, 1);
69 69
70 return rect.GetOutterRect(); 70 return rect.GetOutterRect();
71 } 71 }
72 72
73 void CFFL_FormFiller::OnDraw(CPDFSDK_PageView* pPageView, 73 void CFFL_FormFiller::OnDraw(CPDFSDK_PageView* pPageView,
74 CPDFSDK_Annot* pAnnot, 74 CPDFSDK_Annot* pAnnot,
75 CFX_RenderDevice* pDevice, 75 CFX_RenderDevice* pDevice,
76 CPDF_Matrix* pUser2Device, 76 CFX_Matrix* pUser2Device,
77 FX_DWORD dwFlags) { 77 FX_DWORD dwFlags) {
78 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); 78 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget");
79 79
80 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) { 80 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) {
81 CPDF_Matrix mt = GetCurMatrix(); 81 CFX_Matrix mt = GetCurMatrix();
82 mt.Concat(*pUser2Device); 82 mt.Concat(*pUser2Device);
83 pWnd->DrawAppearance(pDevice, &mt); 83 pWnd->DrawAppearance(pDevice, &mt);
84 } else { 84 } else {
85 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; 85 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
86 if (CFFL_IFormFiller::IsVisible(pWidget)) 86 if (CFFL_IFormFiller::IsVisible(pWidget))
87 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL); 87 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL);
88 } 88 }
89 } 89 }
90 90
91 void CFFL_FormFiller::OnDrawDeactive(CPDFSDK_PageView* pPageView, 91 void CFFL_FormFiller::OnDrawDeactive(CPDFSDK_PageView* pPageView,
92 CPDFSDK_Annot* pAnnot, 92 CPDFSDK_Annot* pAnnot,
93 CFX_RenderDevice* pDevice, 93 CFX_RenderDevice* pDevice,
94 CPDF_Matrix* pUser2Device, 94 CFX_Matrix* pUser2Device,
95 FX_DWORD dwFlags) { 95 FX_DWORD dwFlags) {
96 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; 96 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
97 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL); 97 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL);
98 } 98 }
99 99
100 void CFFL_FormFiller::OnCreate(CPDFSDK_Annot* pAnnot) {} 100 void CFFL_FormFiller::OnCreate(CPDFSDK_Annot* pAnnot) {}
101 101
102 void CFFL_FormFiller::OnLoad(CPDFSDK_Annot* pAnnot) {} 102 void CFFL_FormFiller::OnLoad(CPDFSDK_Annot* pAnnot) {}
103 103
104 void CFFL_FormFiller::OnDelete(CPDFSDK_Annot* pAnnot) {} 104 void CFFL_FormFiller::OnDelete(CPDFSDK_Annot* pAnnot) {}
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 391
392 CPWL_Wnd* pWnd = it->second; 392 CPWL_Wnd* pWnd = it->second;
393 CFFL_PrivateData* pData = (CFFL_PrivateData*)pWnd->GetAttachedData(); 393 CFFL_PrivateData* pData = (CFFL_PrivateData*)pWnd->GetAttachedData();
394 pWnd->Destroy(); 394 pWnd->Destroy();
395 delete pWnd; 395 delete pWnd;
396 delete pData; 396 delete pData;
397 397
398 m_Maps.erase(it); 398 m_Maps.erase(it);
399 } 399 }
400 400
401 CPDF_Matrix CFFL_FormFiller::GetWindowMatrix(void* pAttachedData) { 401 CFX_Matrix CFFL_FormFiller::GetWindowMatrix(void* pAttachedData) {
402 if (CFFL_PrivateData* pPrivateData = (CFFL_PrivateData*)pAttachedData) { 402 if (CFFL_PrivateData* pPrivateData = (CFFL_PrivateData*)pAttachedData) {
403 if (pPrivateData->pPageView) { 403 if (pPrivateData->pPageView) {
404 CPDF_Matrix mtPageView; 404 CFX_Matrix mtPageView;
405 pPrivateData->pPageView->GetCurrentMatrix(mtPageView); 405 pPrivateData->pPageView->GetCurrentMatrix(mtPageView);
406 CPDF_Matrix mt = GetCurMatrix(); 406 CFX_Matrix mt = GetCurMatrix();
407 mt.Concat(mtPageView); 407 mt.Concat(mtPageView);
408 408
409 return mt; 409 return mt;
410 } 410 }
411 } 411 }
412 return CPDF_Matrix(1, 0, 0, 1, 0, 0); 412 return CFX_Matrix(1, 0, 0, 1, 0, 0);
413 } 413 }
414 414
415 CPDF_Matrix CFFL_FormFiller::GetCurMatrix() { 415 CFX_Matrix CFFL_FormFiller::GetCurMatrix() {
416 CPDF_Matrix mt; 416 CFX_Matrix mt;
417 417
418 ASSERT(m_pWidget != NULL); 418 ASSERT(m_pWidget != NULL);
419 419
420 CPDF_Rect rcDA; 420 CPDF_Rect rcDA;
421 m_pWidget->GetPDFAnnot()->GetRect(rcDA); 421 m_pWidget->GetPDFAnnot()->GetRect(rcDA);
422 422
423 switch (m_pWidget->GetRotate()) { 423 switch (m_pWidget->GetRotate()) {
424 default: 424 default:
425 case 0: 425 case 0:
426 mt = CPDF_Matrix(1, 0, 0, 1, 0, 0); 426 mt = CFX_Matrix(1, 0, 0, 1, 0, 0);
427 break; 427 break;
428 case 90: 428 case 90:
429 mt = CPDF_Matrix(0, 1, -1, 0, rcDA.right - rcDA.left, 0); 429 mt = CFX_Matrix(0, 1, -1, 0, rcDA.right - rcDA.left, 0);
430 break; 430 break;
431 case 180: 431 case 180:
432 mt = CPDF_Matrix(-1, 0, 0, -1, rcDA.right - rcDA.left, 432 mt = CFX_Matrix(-1, 0, 0, -1, rcDA.right - rcDA.left,
433 rcDA.top - rcDA.bottom); 433 rcDA.top - rcDA.bottom);
434 break; 434 break;
435 case 270: 435 case 270:
436 mt = CPDF_Matrix(0, -1, 1, 0, 0, rcDA.top - rcDA.bottom); 436 mt = CFX_Matrix(0, -1, 1, 0, 0, rcDA.top - rcDA.bottom);
437 break; 437 break;
438 } 438 }
439 mt.e += rcDA.left; 439 mt.e += rcDA.left;
440 mt.f += rcDA.bottom; 440 mt.f += rcDA.bottom;
441 441
442 return mt; 442 return mt;
443 } 443 }
444 444
445 CFX_WideString CFFL_FormFiller::LoadPopupMenuString(int nIndex) { 445 CFX_WideString CFFL_FormFiller::LoadPopupMenuString(int nIndex) {
446 ASSERT(m_pApp != NULL); 446 ASSERT(m_pApp != NULL);
(...skipping 23 matching lines...) Expand all
470 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) { 470 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) {
471 CPDF_Rect rcFocus = FFLtoWnd(pPageView, PWLtoFFL(pWnd->GetFocusRect())); 471 CPDF_Rect rcFocus = FFLtoWnd(pPageView, PWLtoFFL(pWnd->GetFocusRect()));
472 CPDF_Rect rcPage = pPageView->GetPDFPage()->GetPageBBox(); 472 CPDF_Rect rcPage = pPageView->GetPDFPage()->GetPageBBox();
473 if (rcPage.Contains(rcFocus)) 473 if (rcPage.Contains(rcFocus))
474 return rcFocus; 474 return rcFocus;
475 } 475 }
476 return CPDF_Rect(0, 0, 0, 0); 476 return CPDF_Rect(0, 0, 0, 0);
477 } 477 }
478 478
479 CPDF_Rect CFFL_FormFiller::FFLtoPWL(const CPDF_Rect& rect) { 479 CPDF_Rect CFFL_FormFiller::FFLtoPWL(const CPDF_Rect& rect) {
480 CPDF_Matrix mt; 480 CFX_Matrix mt;
481 mt.SetReverse(GetCurMatrix()); 481 mt.SetReverse(GetCurMatrix());
482 482
483 CPDF_Rect temp = rect; 483 CPDF_Rect temp = rect;
484 mt.TransformRect(temp); 484 mt.TransformRect(temp);
485 485
486 return temp; 486 return temp;
487 } 487 }
488 488
489 CPDF_Rect CFFL_FormFiller::PWLtoFFL(const CPDF_Rect& rect) { 489 CPDF_Rect CFFL_FormFiller::PWLtoFFL(const CPDF_Rect& rect) {
490 CPDF_Matrix mt = GetCurMatrix(); 490 CFX_Matrix mt = GetCurMatrix();
491 491
492 CPDF_Rect temp = rect; 492 CPDF_Rect temp = rect;
493 mt.TransformRect(temp); 493 mt.TransformRect(temp);
494 494
495 return temp; 495 return temp;
496 } 496 }
497 497
498 CPDF_Point CFFL_FormFiller::FFLtoPWL(const CPDF_Point& point) { 498 CPDF_Point CFFL_FormFiller::FFLtoPWL(const CPDF_Point& point) {
499 CPDF_Matrix mt; 499 CFX_Matrix mt;
500 mt.SetReverse(GetCurMatrix()); 500 mt.SetReverse(GetCurMatrix());
501 501
502 CPDF_Point pt = point; 502 CPDF_Point pt = point;
503 mt.Transform(pt.x, pt.y); 503 mt.Transform(pt.x, pt.y);
504 504
505 return pt; 505 return pt;
506 } 506 }
507 507
508 CPDF_Point CFFL_FormFiller::PWLtoFFL(const CPDF_Point& point) { 508 CPDF_Point CFFL_FormFiller::PWLtoFFL(const CPDF_Point& point) {
509 CPDF_Matrix mt = GetCurMatrix(); 509 CFX_Matrix mt = GetCurMatrix();
510 510
511 CPDF_Point pt = point; 511 CPDF_Point pt = point;
512 mt.Transform(pt.x, pt.y); 512 mt.Transform(pt.x, pt.y);
513 513
514 return pt; 514 return pt;
515 } 515 }
516 516
517 CPDF_Point CFFL_FormFiller::WndtoPWL(CPDFSDK_PageView* pPageView, 517 CPDF_Point CFFL_FormFiller::WndtoPWL(CPDFSDK_PageView* pPageView,
518 const CPDF_Point& pt) { 518 const CPDF_Point& pt) {
519 return FFLtoPWL(pt); 519 return FFLtoPWL(pt);
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 FX_UINT nFlags, 682 FX_UINT nFlags,
683 const CPDF_Point& point) { 683 const CPDF_Point& point) {
684 ASSERT(m_pApp != NULL); 684 ASSERT(m_pApp != NULL);
685 685
686 return TRUE; 686 return TRUE;
687 } 687 }
688 688
689 void CFFL_Button::OnDraw(CPDFSDK_PageView* pPageView, 689 void CFFL_Button::OnDraw(CPDFSDK_PageView* pPageView,
690 CPDFSDK_Annot* pAnnot, 690 CPDFSDK_Annot* pAnnot,
691 CFX_RenderDevice* pDevice, 691 CFX_RenderDevice* pDevice,
692 CPDF_Matrix* pUser2Device, 692 CFX_Matrix* pUser2Device,
693 FX_DWORD dwFlags) { 693 FX_DWORD dwFlags) {
694 ASSERT(pPageView != NULL); 694 ASSERT(pPageView != NULL);
695 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; 695 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
696 CPDF_FormControl* pCtrl = pWidget->GetFormControl(); 696 CPDF_FormControl* pCtrl = pWidget->GetFormControl();
697 CPDF_FormControl::HighlightingMode eHM = pCtrl->GetHighlightingMode(); 697 CPDF_FormControl::HighlightingMode eHM = pCtrl->GetHighlightingMode();
698 698
699 if (eHM == CPDF_FormControl::Push) { 699 if (eHM == CPDF_FormControl::Push) {
700 if (m_bMouseDown) { 700 if (m_bMouseDown) {
701 if (pWidget->IsWidgetAppearanceValid(CPDF_Annot::Down)) 701 if (pWidget->IsWidgetAppearanceValid(CPDF_Annot::Down))
702 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Down, NULL); 702 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Down, NULL);
(...skipping 10 matching lines...) Expand all
713 } else { 713 } else {
714 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL); 714 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL);
715 } 715 }
716 } else 716 } else
717 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL); 717 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL);
718 } 718 }
719 719
720 void CFFL_Button::OnDrawDeactive(CPDFSDK_PageView* pPageView, 720 void CFFL_Button::OnDrawDeactive(CPDFSDK_PageView* pPageView,
721 CPDFSDK_Annot* pAnnot, 721 CPDFSDK_Annot* pAnnot,
722 CFX_RenderDevice* pDevice, 722 CFX_RenderDevice* pDevice,
723 CPDF_Matrix* pUser2Device, 723 CFX_Matrix* pUser2Device,
724 FX_DWORD dwFlags) { 724 FX_DWORD dwFlags) {
725 OnDraw(pPageView, pAnnot, pDevice, pUser2Device, dwFlags); 725 OnDraw(pPageView, pAnnot, pDevice, pUser2Device, dwFlags);
726 } 726 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698