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

Side by Side Diff: fpdfsdk/src/fsdk_annothandler.cpp

Issue 1473503002: Introduce "underlying types" to abstract XFA differences. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: rebase past Jun's CL. 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 <algorithm> 7 #include <algorithm>
8 8
9 #include "../include/fpdfxfa/fpdfxfa_doc.h" 9 #include "../include/fpdfxfa/fpdfxfa_doc.h"
10 #include "../include/fpdfxfa/fpdfxfa_util.h" 10 #include "../include/fpdfxfa/fpdfxfa_util.h"
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 CFX_ByteString sSubType = pAnnot->GetSubType(); 639 CFX_ByteString sSubType = pAnnot->GetSubType();
640 640
641 if (sSubType == BFFT_SIGNATURE) { 641 if (sSubType == BFFT_SIGNATURE) {
642 } else { 642 } else {
643 if (m_pFormFiller) 643 if (m_pFormFiller)
644 m_pFormFiller->OnCreate(pAnnot); 644 m_pFormFiller->OnCreate(pAnnot);
645 } 645 }
646 } 646 }
647 647
648 void CPDFSDK_BFAnnotHandler::OnLoad(CPDFSDK_Annot* pAnnot) { 648 void CPDFSDK_BFAnnotHandler::OnLoad(CPDFSDK_Annot* pAnnot) {
649 ASSERT(pAnnot != NULL); 649 if (pAnnot->GetSubType() == BFFT_SIGNATURE)
650 return;
651
652 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
653 if (!pWidget->IsAppearanceValid())
654 pWidget->ResetAppearance(NULL, FALSE);
655
656 int nFieldType = pWidget->GetFieldType();
657 if (nFieldType == FIELDTYPE_TEXTFIELD || nFieldType == FIELDTYPE_COMBOBOX) {
658 FX_BOOL bFormated = FALSE;
659 CFX_WideString sValue = pWidget->OnFormat(bFormated);
660 if (bFormated && nFieldType == FIELDTYPE_COMBOBOX) {
661 pWidget->ResetAppearance(sValue.c_str(), FALSE);
662 }
663 }
650 664
651 CPDFSDK_PageView* pPageView = pAnnot->GetPageView(); 665 CPDFSDK_PageView* pPageView = pAnnot->GetPageView();
652 ASSERT(pPageView != NULL); 666 CPDFSDK_Document* pSDKDoc = pPageView->GetSDKDocument();
667 CPDFXFA_Document* pDoc = pSDKDoc->GetXFADocument();
668 if (pDoc->GetDocType() == DOCTYPE_STATIC_XFA) {
669 if (!pWidget->IsAppearanceValid() && !pWidget->GetValue().IsEmpty())
670 pWidget->ResetAppearance(FALSE);
671 }
653 672
654 CPDFSDK_Document* pSDKDoc = pPageView->GetSDKDocument(); 673 if (m_pFormFiller)
655 ASSERT(pSDKDoc != NULL); 674 m_pFormFiller->OnLoad(pAnnot);
656
657 CPDFXFA_Document* pDoc = pSDKDoc->GetDocument();
658 ASSERT(pDoc != NULL);
659
660 CFX_ByteString sSubType = pAnnot->GetSubType();
661
662 if (sSubType == BFFT_SIGNATURE) {
663 } else {
664 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot;
665 if (!pWidget->IsAppearanceValid())
666 pWidget->ResetAppearance(NULL, FALSE);
667
668 int nFieldType = pWidget->GetFieldType();
669 if (nFieldType == FIELDTYPE_TEXTFIELD || nFieldType == FIELDTYPE_COMBOBOX) {
670 FX_BOOL bFormated = FALSE;
671 CFX_WideString sValue = pWidget->OnFormat(bFormated);
672 if (bFormated && nFieldType == FIELDTYPE_COMBOBOX) {
673 pWidget->ResetAppearance(sValue.c_str(), FALSE);
674 }
675 }
676
677 if (pDoc->GetDocType() == DOCTYPE_STATIC_XFA) {
678 if (!pWidget->IsAppearanceValid() && !pWidget->GetValue().IsEmpty())
679 pWidget->ResetAppearance(FALSE);
680 }
681
682 if (m_pFormFiller)
683 m_pFormFiller->OnLoad(pAnnot);
684 }
685 } 675 }
686 676
687 FX_BOOL CPDFSDK_BFAnnotHandler::OnSetFocus(CPDFSDK_Annot* pAnnot, 677 FX_BOOL CPDFSDK_BFAnnotHandler::OnSetFocus(CPDFSDK_Annot* pAnnot,
688 FX_DWORD nFlag) { 678 FX_DWORD nFlag) {
689 ASSERT(pAnnot != NULL); 679 ASSERT(pAnnot != NULL);
690 CFX_ByteString sSubType = pAnnot->GetSubType(); 680 CFX_ByteString sSubType = pAnnot->GetSubType();
691 681
692 if (sSubType == BFFT_SIGNATURE) { 682 if (sSubType == BFFT_SIGNATURE) {
693 } else { 683 } else {
694 if (m_pFormFiller) 684 if (m_pFormFiller)
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
835 FX_BOOL CPDFSDK_XFAAnnotHandler::HitTest(CPDFSDK_PageView* pPageView, 825 FX_BOOL CPDFSDK_XFAAnnotHandler::HitTest(CPDFSDK_PageView* pPageView,
836 CPDFSDK_Annot* pAnnot, 826 CPDFSDK_Annot* pAnnot,
837 const CPDF_Point& point) { 827 const CPDF_Point& point) {
838 if (!pPageView || !pAnnot) 828 if (!pPageView || !pAnnot)
839 return FALSE; 829 return FALSE;
840 830
841 CPDFSDK_Document* pSDKDoc = pPageView->GetSDKDocument(); 831 CPDFSDK_Document* pSDKDoc = pPageView->GetSDKDocument();
842 if (!pSDKDoc) 832 if (!pSDKDoc)
843 return FALSE; 833 return FALSE;
844 834
845 CPDFXFA_Document* pDoc = pSDKDoc->GetDocument(); 835 CPDFXFA_Document* pDoc = pSDKDoc->GetXFADocument();
846 if (!pDoc) 836 if (!pDoc)
847 return FALSE; 837 return FALSE;
848 838
849 IXFA_DocView* pDocView = pDoc->GetXFADocView(); 839 IXFA_DocView* pDocView = pDoc->GetXFADocView();
850 if (!pDocView) 840 if (!pDocView)
851 return FALSE; 841 return FALSE;
852 842
853 IXFA_WidgetHandler* pWidgetHandler = pDocView->GetWidgetHandler(); 843 IXFA_WidgetHandler* pWidgetHandler = pDocView->GetWidgetHandler();
854 if (!pWidgetHandler) 844 if (!pWidgetHandler)
855 return FALSE; 845 return FALSE;
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
1109 return NULL; 1099 return NULL;
1110 1100
1111 CPDFSDK_PageView* pPageView = pAnnot->GetPageView(); 1101 CPDFSDK_PageView* pPageView = pAnnot->GetPageView();
1112 if (!pPageView) 1102 if (!pPageView)
1113 return NULL; 1103 return NULL;
1114 1104
1115 CPDFSDK_Document* pSDKDoc = pPageView->GetSDKDocument(); 1105 CPDFSDK_Document* pSDKDoc = pPageView->GetSDKDocument();
1116 if (!pSDKDoc) 1106 if (!pSDKDoc)
1117 return NULL; 1107 return NULL;
1118 1108
1119 CPDFXFA_Document* pDoc = pSDKDoc->GetDocument(); 1109 CPDFXFA_Document* pDoc = pSDKDoc->GetXFADocument();
1120 if (!pDoc) 1110 if (!pDoc)
1121 return NULL; 1111 return NULL;
1122 1112
1123 IXFA_DocView* pDocView = pDoc->GetXFADocView(); 1113 IXFA_DocView* pDocView = pDoc->GetXFADocView();
1124 if (!pDocView) 1114 if (!pDocView)
1125 return NULL; 1115 return NULL;
1126 1116
1127 return pDocView->GetWidgetHandler(); 1117 return pDocView->GetWidgetHandler();
1128 } 1118 }
1129 1119
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1188 1178
1189 CPDFSDK_Annot* CPDFSDK_AnnotIterator::PrevAnnot() { 1179 CPDFSDK_Annot* CPDFSDK_AnnotIterator::PrevAnnot() {
1190 if (m_pos < m_iteratorAnnotList.size()) 1180 if (m_pos < m_iteratorAnnotList.size())
1191 return m_iteratorAnnotList[m_iteratorAnnotList.size() - ++m_pos]; 1181 return m_iteratorAnnotList[m_iteratorAnnotList.size() - ++m_pos];
1192 return nullptr; 1182 return nullptr;
1193 } 1183 }
1194 1184
1195 CPDFSDK_Annot* CPDFSDK_AnnotIterator::Next() { 1185 CPDFSDK_Annot* CPDFSDK_AnnotIterator::Next() {
1196 return m_bReverse ? PrevAnnot() : NextAnnot(); 1186 return m_bReverse ? PrevAnnot() : NextAnnot();
1197 } 1187 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698