| OLD | NEW |
| 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 "../../public/fpdf_ext.h" | 7 #include "../../public/fpdf_ext.h" |
| 8 #include "../../third_party/base/nonstd_unique_ptr.h" |
| 8 #include "../include/formfiller/FFL_FormFiller.h" | 9 #include "../include/formfiller/FFL_FormFiller.h" |
| 10 #include "../include/fsdk_define.h" |
| 11 #include "../include/fsdk_mgr.h" |
| 12 #include "../include/javascript/IJavaScript.h" |
| 13 |
| 9 #include "../include/fpdfxfa/fpdfxfa_app.h" | 14 #include "../include/fpdfxfa/fpdfxfa_app.h" |
| 10 #include "../include/fpdfxfa/fpdfxfa_doc.h" | 15 #include "../include/fpdfxfa/fpdfxfa_doc.h" |
| 11 #include "../include/fpdfxfa/fpdfxfa_page.h" | 16 #include "../include/fpdfxfa/fpdfxfa_page.h" |
| 12 #include "../include/fpdfxfa/fpdfxfa_util.h" | 17 #include "../include/fpdfxfa/fpdfxfa_util.h" |
| 13 #include "../include/fsdk_define.h" | |
| 14 #include "../include/fsdk_mgr.h" | |
| 15 #include "../include/javascript/IJavaScript.h" | |
| 16 | 18 |
| 17 #if _FX_OS_ == _FX_ANDROID_ | 19 #if _FX_OS_ == _FX_ANDROID_ |
| 18 #include "time.h" | 20 #include "time.h" |
| 19 #else | 21 #else |
| 20 #include <ctime> | 22 #include <ctime> |
| 21 #endif | 23 #endif |
| 22 | 24 |
| 23 class CFX_SystemHandler : public IFX_SystemHandler { | 25 class CFX_SystemHandler : public IFX_SystemHandler { |
| 24 public: | 26 public: |
| 25 CFX_SystemHandler(CPDFDoc_Environment* pEnv) : m_pEnv(pEnv), m_nCharSet(-1) {} | 27 CFX_SystemHandler(CPDFDoc_Environment* pEnv) : m_pEnv(pEnv), m_nCharSet(-1) {} |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 if (!pPage || !pPageView) | 100 if (!pPage || !pPageView) |
| 99 return; | 101 return; |
| 100 CPDF_Matrix page2device; | 102 CPDF_Matrix page2device; |
| 101 pPageView->GetCurrentMatrix(page2device); | 103 pPageView->GetCurrentMatrix(page2device); |
| 102 CPDF_Matrix device2page; | 104 CPDF_Matrix device2page; |
| 103 device2page.SetReverse(page2device); | 105 device2page.SetReverse(page2device); |
| 104 FX_FLOAT left, top, right, bottom; | 106 FX_FLOAT left, top, right, bottom; |
| 105 device2page.Transform((FX_FLOAT)rect.left, (FX_FLOAT)rect.top, left, top); | 107 device2page.Transform((FX_FLOAT)rect.left, (FX_FLOAT)rect.top, left, top); |
| 106 device2page.Transform((FX_FLOAT)rect.right, (FX_FLOAT)rect.bottom, right, | 108 device2page.Transform((FX_FLOAT)rect.right, (FX_FLOAT)rect.bottom, right, |
| 107 bottom); | 109 bottom); |
| 108 // m_pEnv->FFI_DeviceToPage(pPage, rect.left, rect.top, (double*)&left, | |
| 109 // (double*)&top); | |
| 110 // m_pEnv->FFI_DeviceToPage(pPage, rect.right, rect.bottom, (double*)&right, | |
| 111 // (double*)&bottom); | |
| 112 CPDF_Rect rcPDF(left, bottom, right, top); | 110 CPDF_Rect rcPDF(left, bottom, right, top); |
| 113 rcPDF.Normalize(); | 111 rcPDF.Normalize(); |
| 114 | 112 |
| 115 m_pEnv->FFI_Invalidate(pPage, rcPDF.left, rcPDF.top, rcPDF.right, | 113 m_pEnv->FFI_Invalidate(pPage, rcPDF.left, rcPDF.top, rcPDF.right, |
| 116 rcPDF.bottom); | 114 rcPDF.bottom); |
| 117 } | 115 } |
| 118 void CFX_SystemHandler::OutputSelectedRect(void* pFormFiller, CPDF_Rect& rect) { | 116 void CFX_SystemHandler::OutputSelectedRect(void* pFormFiller, CPDF_Rect& rect) { |
| 119 CFFL_FormFiller* pFFL = (CFFL_FormFiller*)pFormFiller; | 117 CFFL_FormFiller* pFFL = (CFFL_FormFiller*)pFormFiller; |
| 120 if (pFFL) { | 118 if (pFFL) { |
| 121 CPDF_Point leftbottom = CPDF_Point(rect.left, rect.bottom); | 119 CPDF_Point leftbottom = CPDF_Point(rect.left, rect.bottom); |
| (...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 680 | 678 |
| 681 delete m_pAnnotList; | 679 delete m_pAnnotList; |
| 682 m_pAnnotList = NULL; | 680 m_pAnnotList = NULL; |
| 683 } | 681 } |
| 684 | 682 |
| 685 void CPDFSDK_PageView::PageView_OnDraw(CFX_RenderDevice* pDevice, | 683 void CPDFSDK_PageView::PageView_OnDraw(CFX_RenderDevice* pDevice, |
| 686 CPDF_Matrix* pUser2Device, | 684 CPDF_Matrix* pUser2Device, |
| 687 CPDF_RenderOptions* pOptions, | 685 CPDF_RenderOptions* pOptions, |
| 688 FX_RECT* pClip) { | 686 FX_RECT* pClip) { |
| 689 m_curMatrix = *pUser2Device; | 687 m_curMatrix = *pUser2Device; |
| 690 // m_pAnnotList->DisplayAnnots(m_page, pDevice, pUser2Device, FALSE, | |
| 691 // pOptions); | |
| 692 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 688 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
| 693 CPDFXFA_Page* pPage = GetPDFXFAPage(); | 689 CPDFXFA_Page* pPage = GetPDFXFAPage(); |
| 694 | 690 |
| 695 if (pPage == NULL) | 691 if (pPage == NULL) |
| 696 return; | 692 return; |
| 697 | 693 |
| 698 #ifdef PDF_ENABLE_XFA | 694 #ifdef PDF_ENABLE_XFA |
| 699 if (pPage->GetDocument()->GetDocType() == DOCTYPE_DYNIMIC_XFA) { | 695 if (pPage->GetDocument()->GetDocType() == DOCTYPE_DYNIMIC_XFA) { |
| 700 CFX_Graphics gs; | 696 CFX_Graphics gs; |
| 701 gs.Create(pDevice); | 697 gs.Create(pDevice); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 716 renderOptions); | 712 renderOptions); |
| 717 pRenderContext->DoRender(); | 713 pRenderContext->DoRender(); |
| 718 pRenderContext->StopRender(); | 714 pRenderContext->StopRender(); |
| 719 pRenderContext->Release(); | 715 pRenderContext->Release(); |
| 720 return; | 716 return; |
| 721 } | 717 } |
| 722 #endif // PDF_ENABLE_XFA | 718 #endif // PDF_ENABLE_XFA |
| 723 | 719 |
| 724 // for pdf/static xfa. | 720 // for pdf/static xfa. |
| 725 CPDFSDK_AnnotIterator annotIterator(this, TRUE); | 721 CPDFSDK_AnnotIterator annotIterator(this, TRUE); |
| 726 CPDFSDK_Annot* pSDKAnnot = NULL; | |
| 727 int index = -1; | 722 int index = -1; |
| 728 pSDKAnnot = annotIterator.Next(index); | 723 while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next(index)) { |
| 729 while (pSDKAnnot) { | |
| 730 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 724 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
| 731 ASSERT(pAnnotHandlerMgr); | |
| 732 pAnnotHandlerMgr->Annot_OnDraw(this, pSDKAnnot, pDevice, pUser2Device, 0); | 725 pAnnotHandlerMgr->Annot_OnDraw(this, pSDKAnnot, pDevice, pUser2Device, 0); |
| 733 pSDKAnnot = annotIterator.Next(index); | |
| 734 } | 726 } |
| 735 } | 727 } |
| 728 |
| 736 CPDF_Annot* CPDFSDK_PageView::GetPDFAnnotAtPoint(FX_FLOAT pageX, | 729 CPDF_Annot* CPDFSDK_PageView::GetPDFAnnotAtPoint(FX_FLOAT pageX, |
| 737 FX_FLOAT pageY) { | 730 FX_FLOAT pageY) { |
| 738 int nCount = m_pAnnotList->Count(); | 731 int nCount = m_pAnnotList->Count(); |
| 739 for (int i = 0; i < nCount; i++) { | 732 for (int i = 0; i < nCount; i++) { |
| 740 CPDF_Annot* pAnnot = m_pAnnotList->GetAt(i); | 733 CPDF_Annot* pAnnot = m_pAnnotList->GetAt(i); |
| 741 CFX_FloatRect annotRect; | 734 CFX_FloatRect annotRect; |
| 742 pAnnot->GetRect(annotRect); | 735 pAnnot->GetRect(annotRect); |
| 743 if (annotRect.Contains(pageX, pageY)) | 736 if (annotRect.Contains(pageX, pageY)) |
| 744 return pAnnot; | 737 return pAnnot; |
| 745 } | 738 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 777 } | 770 } |
| 778 | 771 |
| 779 return NULL; | 772 return NULL; |
| 780 } | 773 } |
| 781 | 774 |
| 782 CPDFSDK_Annot* CPDFSDK_PageView::GetFXWidgetAtPoint(FX_FLOAT pageX, | 775 CPDFSDK_Annot* CPDFSDK_PageView::GetFXWidgetAtPoint(FX_FLOAT pageX, |
| 783 FX_FLOAT pageY) { | 776 FX_FLOAT pageY) { |
| 784 CPDFSDK_AnnotIterator annotIterator(this, FALSE); | 777 CPDFSDK_AnnotIterator annotIterator(this, FALSE); |
| 785 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 778 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
| 786 CPDFSDK_AnnotHandlerMgr* pAnnotMgr = pEnv->GetAnnotHandlerMgr(); | 779 CPDFSDK_AnnotHandlerMgr* pAnnotMgr = pEnv->GetAnnotHandlerMgr(); |
| 787 CPDFSDK_Annot* pSDKAnnot = NULL; | |
| 788 int index = -1; | 780 int index = -1; |
| 789 pSDKAnnot = annotIterator.Next(index); | 781 while (CPDFSDK_Annot* pSDKAnnot = annotIterator.Next(index)) { |
| 790 while (pSDKAnnot) { | |
| 791 if (pSDKAnnot->GetType() == "Widget" || | 782 if (pSDKAnnot->GetType() == "Widget" || |
| 792 pSDKAnnot->GetType() == FSDK_XFAWIDGET_TYPENAME) { | 783 pSDKAnnot->GetType() == FSDK_XFAWIDGET_TYPENAME) { |
| 793 pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot); | 784 pAnnotMgr->Annot_OnGetViewBBox(this, pSDKAnnot); |
| 794 CPDF_Point point(pageX, pageY); | 785 CPDF_Point point(pageX, pageY); |
| 795 if (pAnnotMgr->Annot_OnHitTest(this, pSDKAnnot, point)) | 786 if (pAnnotMgr->Annot_OnHitTest(this, pSDKAnnot, point)) |
| 796 return pSDKAnnot; | 787 return pSDKAnnot; |
| 797 } | 788 } |
| 798 pSDKAnnot = annotIterator.Next(index); | |
| 799 } | 789 } |
| 800 | 790 |
| 801 return NULL; | 791 return NULL; |
| 802 } | 792 } |
| 803 | 793 |
| 804 FX_BOOL CPDFSDK_PageView::Annot_HasAppearance(CPDF_Annot* pAnnot) { | 794 FX_BOOL CPDFSDK_PageView::Annot_HasAppearance(CPDF_Annot* pAnnot) { |
| 805 CPDF_Dictionary* pAnnotDic = pAnnot->GetAnnotDict(); | 795 CPDF_Dictionary* pAnnotDic = pAnnot->GetAnnotDict(); |
| 806 if (pAnnotDic) | 796 if (pAnnotDic) |
| 807 return pAnnotDic->KeyExist("AS"); | 797 return pAnnotDic->KeyExist("AS"); |
| 808 return FALSE; | 798 return FALSE; |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1074 return pAnnotHandlerMgr->Annot_OnKeyDown(pAnnot, nKeyCode, nFlag); | 1064 return pAnnotHandlerMgr->Annot_OnKeyDown(pAnnot, nKeyCode, nFlag); |
| 1075 } | 1065 } |
| 1076 return FALSE; | 1066 return FALSE; |
| 1077 } | 1067 } |
| 1078 | 1068 |
| 1079 FX_BOOL CPDFSDK_PageView::OnKeyUp(int nKeyCode, int nFlag) { | 1069 FX_BOOL CPDFSDK_PageView::OnKeyUp(int nKeyCode, int nFlag) { |
| 1080 return FALSE; | 1070 return FALSE; |
| 1081 } | 1071 } |
| 1082 | 1072 |
| 1083 void CPDFSDK_PageView::LoadFXAnnots() { | 1073 void CPDFSDK_PageView::LoadFXAnnots() { |
| 1084 ASSERT(m_page != NULL); | |
| 1085 | |
| 1086 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); | 1074 CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); |
| 1087 ASSERT(pEnv != NULL); | |
| 1088 | |
| 1089 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); | 1075 CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
| 1090 ASSERT(pAnnotHandlerMgr != NULL); | |
| 1091 | 1076 |
| 1092 SetLock(TRUE); | 1077 SetLock(TRUE); |
| 1093 m_page->AddRef(); | 1078 m_page->AddRef(); |
| 1094 if (m_pSDKDoc->GetDocument()->GetDocType() == DOCTYPE_DYNIMIC_XFA) { | 1079 if (m_pSDKDoc->GetDocument()->GetDocType() == DOCTYPE_DYNIMIC_XFA) { |
| 1095 IXFA_PageView* pageView = NULL; | 1080 IXFA_PageView* pageView = NULL; |
| 1096 pageView = m_page->GetXFAPageView(); | 1081 pageView = m_page->GetXFAPageView(); |
| 1097 ASSERT(pageView != NULL); | 1082 ASSERT(pageView != NULL); |
| 1098 | 1083 |
| 1099 IXFA_WidgetIterator* pWidgetHander = pageView->CreateWidgetIterator( | 1084 IXFA_WidgetIterator* pWidgetHander = pageView->CreateWidgetIterator( |
| 1100 XFA_TRAVERSEWAY_Form, XFA_WIDGETFILTER_Visible | | 1085 XFA_TRAVERSEWAY_Form, XFA_WIDGETFILTER_Visible | |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1192 if (!pFocusAnnot) | 1177 if (!pFocusAnnot) |
| 1193 return NULL; | 1178 return NULL; |
| 1194 | 1179 |
| 1195 for (int i = 0; i < m_fxAnnotArray.GetSize(); i++) { | 1180 for (int i = 0; i < m_fxAnnotArray.GetSize(); i++) { |
| 1196 CPDFSDK_Annot* pAnnot = (CPDFSDK_Annot*)m_fxAnnotArray.GetAt(i); | 1181 CPDFSDK_Annot* pAnnot = (CPDFSDK_Annot*)m_fxAnnotArray.GetAt(i); |
| 1197 if (pAnnot == pFocusAnnot) | 1182 if (pAnnot == pFocusAnnot) |
| 1198 return pAnnot; | 1183 return pAnnot; |
| 1199 } | 1184 } |
| 1200 return NULL; | 1185 return NULL; |
| 1201 } | 1186 } |
| OLD | NEW |