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

Side by Side Diff: fpdfsdk/fsdk_mgr.cpp

Issue 2295953002: Use enum class for subtypes of CPDF_Annot. (Closed)
Patch Set: Use enum class for subtypes of CPDF_Annot. 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/fsdk_baseform_embeddertest.cpp ('k') | fpdfsdk/include/cba_annotiterator.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/include/fsdk_mgr.h" 7 #include "fpdfsdk/include/fsdk_mgr.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 CPDFSDK_AnnotHandlerMgr* pAnnotHandler = m_pEnv->GetAnnotHandlerMgr(); 435 CPDFSDK_AnnotHandlerMgr* pAnnotHandler = m_pEnv->GetAnnotHandlerMgr();
436 CPDFSDK_Annot* pFocusAnnot = m_pFocusAnnot; 436 CPDFSDK_Annot* pFocusAnnot = m_pFocusAnnot;
437 m_pFocusAnnot = nullptr; 437 m_pFocusAnnot = nullptr;
438 438
439 #ifdef PDF_ENABLE_XFA 439 #ifdef PDF_ENABLE_XFA
440 if (!pAnnotHandler->Annot_OnChangeFocus(nullptr, pFocusAnnot)) 440 if (!pAnnotHandler->Annot_OnChangeFocus(nullptr, pFocusAnnot))
441 return FALSE; 441 return FALSE;
442 #endif // PDF_ENABLE_XFA 442 #endif // PDF_ENABLE_XFA
443 443
444 if (pAnnotHandler->Annot_OnKillFocus(pFocusAnnot, nFlag)) { 444 if (pAnnotHandler->Annot_OnKillFocus(pFocusAnnot, nFlag)) {
445 if (pFocusAnnot->GetAnnotSubtype() == "Widget") { 445 if (pFocusAnnot->GetAnnotSubtype() == CPDF_Annot::Subtype::WIDGET) {
446 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pFocusAnnot; 446 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pFocusAnnot;
447 int nFieldType = pWidget->GetFieldType(); 447 int nFieldType = pWidget->GetFieldType();
448 if (FIELDTYPE_TEXTFIELD == nFieldType || 448 if (FIELDTYPE_TEXTFIELD == nFieldType ||
449 FIELDTYPE_COMBOBOX == nFieldType) { 449 FIELDTYPE_COMBOBOX == nFieldType) {
450 m_pEnv->FFI_OnSetFieldInputFocus(nullptr, nullptr, 0, FALSE); 450 m_pEnv->FFI_OnSetFieldInputFocus(nullptr, nullptr, 0, FALSE);
451 } 451 }
452 } 452 }
453 453
454 if (!m_pFocusAnnot) 454 if (!m_pFocusAnnot)
455 return TRUE; 455 return TRUE;
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 CFX_FloatRect annotRect = pAnnot->GetRect(); 579 CFX_FloatRect annotRect = pAnnot->GetRect();
580 if (annotRect.Contains(pageX, pageY)) 580 if (annotRect.Contains(pageX, pageY))
581 return pAnnot.get(); 581 return pAnnot.get();
582 } 582 }
583 return nullptr; 583 return nullptr;
584 } 584 }
585 585
586 const CPDF_Annot* CPDFSDK_PageView::GetPDFWidgetAtPoint(FX_FLOAT pageX, 586 const CPDF_Annot* CPDFSDK_PageView::GetPDFWidgetAtPoint(FX_FLOAT pageX,
587 FX_FLOAT pageY) { 587 FX_FLOAT pageY) {
588 for (const auto& pAnnot : m_pAnnotList->All()) { 588 for (const auto& pAnnot : m_pAnnotList->All()) {
589 if (pAnnot->GetSubtype() == "Widget") { 589 if (pAnnot->GetSubtype() == CPDF_Annot::Subtype::WIDGET) {
590 CFX_FloatRect annotRect = pAnnot->GetRect(); 590 CFX_FloatRect annotRect = pAnnot->GetRect();
591 if (annotRect.Contains(pageX, pageY)) 591 if (annotRect.Contains(pageX, pageY))
592 return pAnnot.get(); 592 return pAnnot.get();
593 } 593 }
594 } 594 }
595 return nullptr; 595 return nullptr;
596 } 596 }
597 597
598 CPDFSDK_Annot* CPDFSDK_PageView::GetFXAnnotAtPoint(FX_FLOAT pageX, 598 CPDFSDK_Annot* CPDFSDK_PageView::GetFXAnnotAtPoint(FX_FLOAT pageX,
599 FX_FLOAT pageY) { 599 FX_FLOAT pageY) {
600 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); 600 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
601 CPDFSDK_AnnotHandlerMgr* pAnnotMgr = pEnv->GetAnnotHandlerMgr(); 601 CPDFSDK_AnnotHandlerMgr* pAnnotMgr = pEnv->GetAnnotHandlerMgr();
602 CPDFSDK_AnnotIterator annotIterator(this, false); 602 CPDFSDK_AnnotIterator annotIterator(this, false);
603 while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next()) { 603 while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next()) {
604 CFX_FloatRect rc = pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot); 604 CFX_FloatRect rc = pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot);
605 if (pSDKAnnot->GetAnnotSubtype() == "Popup") 605 if (pSDKAnnot->GetAnnotSubtype() == CPDF_Annot::Subtype::POPUP)
606 continue; 606 continue;
607 if (rc.Contains(pageX, pageY)) 607 if (rc.Contains(pageX, pageY))
608 return pSDKAnnot; 608 return pSDKAnnot;
609 } 609 }
610 610
611 return nullptr; 611 return nullptr;
612 } 612 }
613 613
614 CPDFSDK_Annot* CPDFSDK_PageView::GetFXWidgetAtPoint(FX_FLOAT pageX, 614 CPDFSDK_Annot* CPDFSDK_PageView::GetFXWidgetAtPoint(FX_FLOAT pageX,
615 FX_FLOAT pageY) { 615 FX_FLOAT pageY) {
616 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); 616 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv();
617 CPDFSDK_AnnotHandlerMgr* pAnnotMgr = pEnv->GetAnnotHandlerMgr(); 617 CPDFSDK_AnnotHandlerMgr* pAnnotMgr = pEnv->GetAnnotHandlerMgr();
618 CPDFSDK_AnnotIterator annotIterator(this, false); 618 CPDFSDK_AnnotIterator annotIterator(this, false);
619 while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next()) { 619 while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next()) {
620 bool bHitTest = pSDKAnnot->GetAnnotSubtype() == "Widget"; 620 bool bHitTest = pSDKAnnot->GetAnnotSubtype() == CPDF_Annot::Subtype::WIDGET;
621 #ifdef PDF_ENABLE_XFA 621 #ifdef PDF_ENABLE_XFA
622 bHitTest = 622 bHitTest = bHitTest ||
623 bHitTest || pSDKAnnot->GetAnnotSubtype() == FSDK_XFAWIDGET_TYPENAME; 623 pSDKAnnot->GetAnnotSubtype() == CPDF_Annot::Subtype::XFAWIDGET;
624 #endif // PDF_ENABLE_XFA 624 #endif // PDF_ENABLE_XFA
625 if (bHitTest) { 625 if (bHitTest) {
626 pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot); 626 pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot);
627 CFX_FloatPoint point(pageX, pageY); 627 CFX_FloatPoint point(pageX, pageY);
628 if (pAnnotMgr->Annot_OnHitTest(this, pSDKAnnot, point)) 628 if (pAnnotMgr->Annot_OnHitTest(this, pSDKAnnot, point))
629 return pSDKAnnot; 629 return pSDKAnnot;
630 } 630 }
631 } 631 }
632 632
633 return nullptr; 633 return nullptr;
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
1022 return pAnnot; 1022 return pAnnot;
1023 } 1023 }
1024 return nullptr; 1024 return nullptr;
1025 } 1025 }
1026 1026
1027 int CPDFSDK_PageView::GetPageIndexForStaticPDF() const { 1027 int CPDFSDK_PageView::GetPageIndexForStaticPDF() const {
1028 CPDF_Dictionary* pDict = GetPDFPage()->m_pFormDict; 1028 CPDF_Dictionary* pDict = GetPDFPage()->m_pFormDict;
1029 CPDF_Document* pDoc = m_pSDKDoc->GetPDFDocument(); 1029 CPDF_Document* pDoc = m_pSDKDoc->GetPDFDocument();
1030 return (pDoc && pDict) ? pDoc->GetPageIndex(pDict->GetObjNum()) : -1; 1030 return (pDoc && pDict) ? pDoc->GetPageIndex(pDict->GetObjNum()) : -1;
1031 } 1031 }
OLDNEW
« no previous file with comments | « fpdfsdk/fsdk_baseform_embeddertest.cpp ('k') | fpdfsdk/include/cba_annotiterator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698