John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1 | // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
Lei Zhang | 60f507b | 2015-06-13 00:41:00 -0700 | [diff] [blame] | 4 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 5 | // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | |
Dan Sinclair | 3ebd121 | 2016-03-09 09:59:23 -0500 | [diff] [blame] | 7 | #include "fpdfsdk/include/fsdk_annothandler.h" |
| 8 | |
Lei Zhang | bf60b29 | 2015-10-26 12:14:35 -0700 | [diff] [blame] | 9 | #include <algorithm> |
Dan Sinclair | 3ebd121 | 2016-03-09 09:59:23 -0500 | [diff] [blame] | 10 | #include <vector> |
Lei Zhang | bf60b29 | 2015-10-26 12:14:35 -0700 | [diff] [blame] | 11 | |
Dan Sinclair | 455a419 | 2016-03-16 09:48:56 -0400 | [diff] [blame] | 12 | #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" |
Dan Sinclair | aa403d3 | 2016-03-15 14:57:22 -0400 | [diff] [blame] | 13 | #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" |
dsinclair | cac704d | 2016-07-28 12:59:09 -0700 | [diff] [blame] | 14 | #include "core/fpdfdoc/include/cpdf_interform.h" |
npm | 9ada2d8 | 2016-08-10 07:51:38 -0700 | [diff] [blame] | 15 | #include "core/fxge/include/cfx_renderdevice.h" |
Dan Sinclair | edbb319 | 2016-03-21 09:08:24 -0400 | [diff] [blame] | 16 | #include "fpdfsdk/formfiller/cffl_formfiller.h" |
jaepark | 2736276 | 2016-08-11 13:10:39 -0700 | [diff] [blame] | 17 | #include "fpdfsdk/include/cpdfsdk_datetime.h" |
Lei Zhang | bde53d2 | 2015-11-12 22:21:30 -0800 | [diff] [blame] | 18 | #include "fpdfsdk/include/fsdk_define.h" |
| 19 | #include "fpdfsdk/include/fsdk_mgr.h" |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 20 | |
Tom Sepez | 40e9ff3 | 2015-11-30 12:39:54 -0800 | [diff] [blame] | 21 | #ifdef PDF_ENABLE_XFA |
dsinclair | 89bdd08 | 2016-04-06 10:47:54 -0700 | [diff] [blame] | 22 | #include "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h" |
| 23 | #include "fpdfsdk/fpdfxfa/include/fpdfxfa_page.h" |
| 24 | #include "fpdfsdk/fpdfxfa/include/fpdfxfa_util.h" |
dsinclair | 89fcde8 | 2016-05-03 13:00:25 -0700 | [diff] [blame] | 25 | #include "xfa/fwl/core/include/fwl_widgethit.h" |
dsinclair | 7222ea6 | 2016-04-06 14:33:07 -0700 | [diff] [blame] | 26 | #include "xfa/fxfa/include/xfa_ffwidget.h" |
weili | 625ad66 | 2016-06-15 11:21:33 -0700 | [diff] [blame] | 27 | #include "xfa/fxfa/include/xfa_ffdocview.h" |
| 28 | #include "xfa/fxfa/include/xfa_ffpageview.h" |
| 29 | #include "xfa/fxfa/include/xfa_ffwidgethandler.h" |
Dan Sinclair | 811b8a4 | 2016-03-17 08:59:42 -0400 | [diff] [blame] | 30 | #include "xfa/fxgraphics/include/cfx_graphics.h" |
Tom Sepez | 40e9ff3 | 2015-11-30 12:39:54 -0800 | [diff] [blame] | 31 | #endif // PDF_ENABLE_XFA |
| 32 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 33 | CPDFSDK_AnnotHandlerMgr::CPDFSDK_AnnotHandlerMgr(CPDFDoc_Environment* pApp) { |
| 34 | m_pApp = pApp; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 35 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 36 | CPDFSDK_BFAnnotHandler* pHandler = new CPDFSDK_BFAnnotHandler(m_pApp); |
| 37 | pHandler->SetFormFiller(m_pApp->GetIFormFiller()); |
| 38 | RegisterAnnotHandler(pHandler); |
Tom Sepez | 51da093 | 2015-11-25 16:05:49 -0800 | [diff] [blame] | 39 | #ifdef PDF_ENABLE_XFA |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 40 | CPDFSDK_XFAAnnotHandler* pXFAAnnotHandler = |
| 41 | new CPDFSDK_XFAAnnotHandler(m_pApp); |
| 42 | RegisterAnnotHandler(pXFAAnnotHandler); |
Tom Sepez | 40e9ff3 | 2015-11-30 12:39:54 -0800 | [diff] [blame] | 43 | #endif // PDF_ENABLE_XFA |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 44 | } |
| 45 | |
weili | 9ca2b09 | 2016-07-21 12:26:18 -0700 | [diff] [blame] | 46 | CPDFSDK_AnnotHandlerMgr::~CPDFSDK_AnnotHandlerMgr() {} |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 47 | |
| 48 | void CPDFSDK_AnnotHandlerMgr::RegisterAnnotHandler( |
| 49 | IPDFSDK_AnnotHandler* pAnnotHandler) { |
Tom Sepez | 09d33bc | 2015-08-19 09:49:24 -0700 | [diff] [blame] | 50 | ASSERT(!GetAnnotHandler(pAnnotHandler->GetType())); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 51 | |
weili | 9ca2b09 | 2016-07-21 12:26:18 -0700 | [diff] [blame] | 52 | m_mapType2Handler[pAnnotHandler->GetType()].reset(pAnnotHandler); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | void CPDFSDK_AnnotHandlerMgr::UnRegisterAnnotHandler( |
| 56 | IPDFSDK_AnnotHandler* pAnnotHandler) { |
Tom Sepez | 09d33bc | 2015-08-19 09:49:24 -0700 | [diff] [blame] | 57 | m_mapType2Handler.erase(pAnnotHandler->GetType()); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 58 | } |
| 59 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 60 | CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::NewAnnot(CPDF_Annot* pAnnot, |
| 61 | CPDFSDK_PageView* pPageView) { |
Lei Zhang | 96660d6 | 2015-12-14 18:27:25 -0800 | [diff] [blame] | 62 | ASSERT(pPageView); |
Lei Zhang | 60f507b | 2015-06-13 00:41:00 -0700 | [diff] [blame] | 63 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 64 | if (IPDFSDK_AnnotHandler* pAnnotHandler = |
| 65 | GetAnnotHandler(pAnnot->GetSubType())) { |
| 66 | return pAnnotHandler->NewAnnot(pAnnot, pPageView); |
| 67 | } |
Lei Zhang | 60f507b | 2015-06-13 00:41:00 -0700 | [diff] [blame] | 68 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 69 | return new CPDFSDK_BAAnnot(pAnnot, pPageView); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 70 | } |
| 71 | |
Tom Sepez | 51da093 | 2015-11-25 16:05:49 -0800 | [diff] [blame] | 72 | #ifdef PDF_ENABLE_XFA |
dsinclair | df4bc59 | 2016-03-31 20:34:43 -0700 | [diff] [blame] | 73 | CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::NewAnnot(CXFA_FFWidget* pAnnot, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 74 | CPDFSDK_PageView* pPageView) { |
Lei Zhang | 5eca305 | 2016-02-22 20:32:21 -0800 | [diff] [blame] | 75 | ASSERT(pAnnot); |
| 76 | ASSERT(pPageView); |
Lei Zhang | 60f507b | 2015-06-13 00:41:00 -0700 | [diff] [blame] | 77 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 78 | if (IPDFSDK_AnnotHandler* pAnnotHandler = |
| 79 | GetAnnotHandler(FSDK_XFAWIDGET_TYPENAME)) { |
| 80 | return pAnnotHandler->NewAnnot(pAnnot, pPageView); |
| 81 | } |
Lei Zhang | 60f507b | 2015-06-13 00:41:00 -0700 | [diff] [blame] | 82 | |
thestig | 1cd352e | 2016-06-07 17:53:06 -0700 | [diff] [blame] | 83 | return nullptr; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 84 | } |
Tom Sepez | 40e9ff3 | 2015-11-30 12:39:54 -0800 | [diff] [blame] | 85 | #endif // PDF_ENABLE_XFA |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 86 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 87 | void CPDFSDK_AnnotHandlerMgr::ReleaseAnnot(CPDFSDK_Annot* pAnnot) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 88 | if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) { |
| 89 | pAnnotHandler->OnRelease(pAnnot); |
| 90 | pAnnotHandler->ReleaseAnnot(pAnnot); |
| 91 | } else { |
tsepez | 77b909e | 2016-06-09 14:08:11 -0700 | [diff] [blame] | 92 | delete pAnnot; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 93 | } |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 94 | } |
| 95 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 96 | void CPDFSDK_AnnotHandlerMgr::Annot_OnCreate(CPDFSDK_Annot* pAnnot) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 97 | CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot(); |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 98 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 99 | CPDFSDK_DateTime curTime; |
| 100 | pPDFAnnot->GetAnnotDict()->SetAtString("M", curTime.ToPDFDateTimeString()); |
| 101 | pPDFAnnot->GetAnnotDict()->SetAtNumber("F", 0); |
| 102 | |
| 103 | if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) { |
| 104 | pAnnotHandler->OnCreate(pAnnot); |
| 105 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 106 | } |
| 107 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 108 | void CPDFSDK_AnnotHandlerMgr::Annot_OnLoad(CPDFSDK_Annot* pAnnot) { |
Lei Zhang | 96660d6 | 2015-12-14 18:27:25 -0800 | [diff] [blame] | 109 | ASSERT(pAnnot); |
Lei Zhang | 60f507b | 2015-06-13 00:41:00 -0700 | [diff] [blame] | 110 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 111 | if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) { |
| 112 | pAnnotHandler->OnLoad(pAnnot); |
| 113 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 114 | } |
| 115 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 116 | IPDFSDK_AnnotHandler* CPDFSDK_AnnotHandlerMgr::GetAnnotHandler( |
| 117 | CPDFSDK_Annot* pAnnot) const { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 118 | CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot(); |
| 119 | if (pPDFAnnot) |
| 120 | return GetAnnotHandler(pPDFAnnot->GetSubType()); |
Tom Sepez | 51da093 | 2015-11-25 16:05:49 -0800 | [diff] [blame] | 121 | #ifdef PDF_ENABLE_XFA |
Tom Sepez | c7e4c4f | 2015-11-20 09:45:24 -0800 | [diff] [blame] | 122 | if (pAnnot->GetXFAWidget()) |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 123 | return GetAnnotHandler(FSDK_XFAWIDGET_TYPENAME); |
Tom Sepez | 40e9ff3 | 2015-11-30 12:39:54 -0800 | [diff] [blame] | 124 | #endif // PDF_ENABLE_XFA |
Tom Sepez | c7e4c4f | 2015-11-20 09:45:24 -0800 | [diff] [blame] | 125 | return nullptr; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 126 | } |
| 127 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 128 | IPDFSDK_AnnotHandler* CPDFSDK_AnnotHandlerMgr::GetAnnotHandler( |
| 129 | const CFX_ByteString& sType) const { |
Tom Sepez | 09d33bc | 2015-08-19 09:49:24 -0700 | [diff] [blame] | 130 | auto it = m_mapType2Handler.find(sType); |
weili | 9ca2b09 | 2016-07-21 12:26:18 -0700 | [diff] [blame] | 131 | return it != m_mapType2Handler.end() ? it->second.get() : nullptr; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 132 | } |
| 133 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 134 | void CPDFSDK_AnnotHandlerMgr::Annot_OnDraw(CPDFSDK_PageView* pPageView, |
| 135 | CPDFSDK_Annot* pAnnot, |
| 136 | CFX_RenderDevice* pDevice, |
Tom Sepez | 60d909e | 2015-12-10 15:34:55 -0800 | [diff] [blame] | 137 | CFX_Matrix* pUser2Device, |
tsepez | c3255f5 | 2016-03-25 14:52:27 -0700 | [diff] [blame] | 138 | uint32_t dwFlags) { |
Dan Sinclair | bfe042a | 2015-11-04 14:04:13 -0500 | [diff] [blame] | 139 | ASSERT(pAnnot); |
Lei Zhang | 60f507b | 2015-06-13 00:41:00 -0700 | [diff] [blame] | 140 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 141 | if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) { |
| 142 | pAnnotHandler->OnDraw(pPageView, pAnnot, pDevice, pUser2Device, dwFlags); |
| 143 | } else { |
Tom Sepez | 51da093 | 2015-11-25 16:05:49 -0800 | [diff] [blame] | 144 | #ifdef PDF_ENABLE_XFA |
Tom Sepez | 540c436 | 2015-11-24 13:33:57 -0800 | [diff] [blame] | 145 | if (pAnnot->IsXFAField()) |
| 146 | return; |
Tom Sepez | 40e9ff3 | 2015-11-30 12:39:54 -0800 | [diff] [blame] | 147 | #endif // PDF_ENABLE_XFA |
Tom Sepez | 540c436 | 2015-11-24 13:33:57 -0800 | [diff] [blame] | 148 | static_cast<CPDFSDK_BAAnnot*>(pAnnot) |
| 149 | ->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, nullptr); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 150 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 151 | } |
| 152 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 153 | FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnLButtonDown( |
| 154 | CPDFSDK_PageView* pPageView, |
| 155 | CPDFSDK_Annot* pAnnot, |
tsepez | c3255f5 | 2016-03-25 14:52:27 -0700 | [diff] [blame] | 156 | uint32_t nFlags, |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 157 | const CFX_FloatPoint& point) { |
Lei Zhang | 96660d6 | 2015-12-14 18:27:25 -0800 | [diff] [blame] | 158 | ASSERT(pAnnot); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 159 | |
| 160 | if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) { |
| 161 | return pAnnotHandler->OnLButtonDown(pPageView, pAnnot, nFlags, point); |
| 162 | } |
| 163 | return FALSE; |
| 164 | } |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 165 | FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnLButtonUp( |
| 166 | CPDFSDK_PageView* pPageView, |
| 167 | CPDFSDK_Annot* pAnnot, |
tsepez | c3255f5 | 2016-03-25 14:52:27 -0700 | [diff] [blame] | 168 | uint32_t nFlags, |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 169 | const CFX_FloatPoint& point) { |
Lei Zhang | 96660d6 | 2015-12-14 18:27:25 -0800 | [diff] [blame] | 170 | ASSERT(pAnnot); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 171 | |
| 172 | if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) { |
| 173 | return pAnnotHandler->OnLButtonUp(pPageView, pAnnot, nFlags, point); |
| 174 | } |
| 175 | return FALSE; |
| 176 | } |
| 177 | FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnLButtonDblClk( |
| 178 | CPDFSDK_PageView* pPageView, |
| 179 | CPDFSDK_Annot* pAnnot, |
tsepez | c3255f5 | 2016-03-25 14:52:27 -0700 | [diff] [blame] | 180 | uint32_t nFlags, |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 181 | const CFX_FloatPoint& point) { |
Lei Zhang | 96660d6 | 2015-12-14 18:27:25 -0800 | [diff] [blame] | 182 | ASSERT(pAnnot); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 183 | |
| 184 | if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) { |
| 185 | return pAnnotHandler->OnLButtonDblClk(pPageView, pAnnot, nFlags, point); |
| 186 | } |
| 187 | return FALSE; |
| 188 | } |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 189 | FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnMouseMove( |
| 190 | CPDFSDK_PageView* pPageView, |
| 191 | CPDFSDK_Annot* pAnnot, |
tsepez | c3255f5 | 2016-03-25 14:52:27 -0700 | [diff] [blame] | 192 | uint32_t nFlags, |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 193 | const CFX_FloatPoint& point) { |
Lei Zhang | 96660d6 | 2015-12-14 18:27:25 -0800 | [diff] [blame] | 194 | ASSERT(pAnnot); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 195 | |
| 196 | if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) { |
| 197 | return pAnnotHandler->OnMouseMove(pPageView, pAnnot, nFlags, point); |
| 198 | } |
| 199 | return FALSE; |
| 200 | } |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 201 | FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnMouseWheel( |
| 202 | CPDFSDK_PageView* pPageView, |
| 203 | CPDFSDK_Annot* pAnnot, |
tsepez | c3255f5 | 2016-03-25 14:52:27 -0700 | [diff] [blame] | 204 | uint32_t nFlags, |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 205 | short zDelta, |
| 206 | const CFX_FloatPoint& point) { |
Lei Zhang | 96660d6 | 2015-12-14 18:27:25 -0800 | [diff] [blame] | 207 | ASSERT(pAnnot); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 208 | |
| 209 | if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) { |
| 210 | return pAnnotHandler->OnMouseWheel(pPageView, pAnnot, nFlags, zDelta, |
| 211 | point); |
| 212 | } |
| 213 | return FALSE; |
| 214 | } |
| 215 | FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnRButtonDown( |
| 216 | CPDFSDK_PageView* pPageView, |
| 217 | CPDFSDK_Annot* pAnnot, |
tsepez | c3255f5 | 2016-03-25 14:52:27 -0700 | [diff] [blame] | 218 | uint32_t nFlags, |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 219 | const CFX_FloatPoint& point) { |
Lei Zhang | 96660d6 | 2015-12-14 18:27:25 -0800 | [diff] [blame] | 220 | ASSERT(pAnnot); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 221 | |
| 222 | if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) { |
| 223 | return pAnnotHandler->OnRButtonDown(pPageView, pAnnot, nFlags, point); |
| 224 | } |
| 225 | return FALSE; |
| 226 | } |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 227 | FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnRButtonUp( |
| 228 | CPDFSDK_PageView* pPageView, |
| 229 | CPDFSDK_Annot* pAnnot, |
tsepez | c3255f5 | 2016-03-25 14:52:27 -0700 | [diff] [blame] | 230 | uint32_t nFlags, |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 231 | const CFX_FloatPoint& point) { |
Lei Zhang | 96660d6 | 2015-12-14 18:27:25 -0800 | [diff] [blame] | 232 | ASSERT(pAnnot); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 233 | |
| 234 | if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) { |
| 235 | return pAnnotHandler->OnRButtonUp(pPageView, pAnnot, nFlags, point); |
| 236 | } |
| 237 | return FALSE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 238 | } |
| 239 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 240 | void CPDFSDK_AnnotHandlerMgr::Annot_OnMouseEnter(CPDFSDK_PageView* pPageView, |
| 241 | CPDFSDK_Annot* pAnnot, |
tsepez | c3255f5 | 2016-03-25 14:52:27 -0700 | [diff] [blame] | 242 | uint32_t nFlag) { |
Lei Zhang | 96660d6 | 2015-12-14 18:27:25 -0800 | [diff] [blame] | 243 | ASSERT(pAnnot); |
Lei Zhang | 60f507b | 2015-06-13 00:41:00 -0700 | [diff] [blame] | 244 | |
Lei Zhang | 05e6741 | 2016-01-25 16:35:42 -0800 | [diff] [blame] | 245 | if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 246 | pAnnotHandler->OnMouseEnter(pPageView, pAnnot, nFlag); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 247 | } |
| 248 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 249 | void CPDFSDK_AnnotHandlerMgr::Annot_OnMouseExit(CPDFSDK_PageView* pPageView, |
| 250 | CPDFSDK_Annot* pAnnot, |
tsepez | c3255f5 | 2016-03-25 14:52:27 -0700 | [diff] [blame] | 251 | uint32_t nFlag) { |
Lei Zhang | 96660d6 | 2015-12-14 18:27:25 -0800 | [diff] [blame] | 252 | ASSERT(pAnnot); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 253 | |
Lei Zhang | 05e6741 | 2016-01-25 16:35:42 -0800 | [diff] [blame] | 254 | if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 255 | pAnnotHandler->OnMouseExit(pPageView, pAnnot, nFlag); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 256 | } |
| 257 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 258 | FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnChar(CPDFSDK_Annot* pAnnot, |
tsepez | c3255f5 | 2016-03-25 14:52:27 -0700 | [diff] [blame] | 259 | uint32_t nChar, |
| 260 | uint32_t nFlags) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 261 | if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) { |
| 262 | return pAnnotHandler->OnChar(pAnnot, nChar, nFlags); |
| 263 | } |
| 264 | return FALSE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 265 | } |
| 266 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 267 | FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnKeyDown(CPDFSDK_Annot* pAnnot, |
| 268 | int nKeyCode, |
| 269 | int nFlag) { |
| 270 | if (!m_pApp->FFI_IsCTRLKeyDown(nFlag) && !m_pApp->FFI_IsALTKeyDown(nFlag)) { |
| 271 | CPDFSDK_PageView* pPage = pAnnot->GetPageView(); |
| 272 | CPDFSDK_Annot* pFocusAnnot = pPage->GetFocusAnnot(); |
| 273 | if (pFocusAnnot && (nKeyCode == FWL_VKEY_Tab)) { |
| 274 | CPDFSDK_Annot* pNext = |
| 275 | GetNextAnnot(pFocusAnnot, !m_pApp->FFI_IsSHIFTKeyDown(nFlag)); |
Lei Zhang | 60f507b | 2015-06-13 00:41:00 -0700 | [diff] [blame] | 276 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 277 | if (pNext && pNext != pFocusAnnot) { |
| 278 | CPDFSDK_Document* pDocument = pPage->GetSDKDocument(); |
| 279 | pDocument->SetFocusAnnot(pNext); |
Tom Sepez | 2f2ffec | 2015-07-23 14:42:09 -0700 | [diff] [blame] | 280 | return TRUE; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 281 | } |
| 282 | } |
| 283 | } |
Lei Zhang | 60f507b | 2015-06-13 00:41:00 -0700 | [diff] [blame] | 284 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 285 | if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) { |
| 286 | return pAnnotHandler->OnKeyDown(pAnnot, nKeyCode, nFlag); |
| 287 | } |
| 288 | return FALSE; |
| 289 | } |
| 290 | FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnKeyUp(CPDFSDK_Annot* pAnnot, |
| 291 | int nKeyCode, |
| 292 | int nFlag) { |
| 293 | return FALSE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 294 | } |
| 295 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 296 | FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnSetFocus(CPDFSDK_Annot* pAnnot, |
tsepez | c3255f5 | 2016-03-25 14:52:27 -0700 | [diff] [blame] | 297 | uint32_t nFlag) { |
Lei Zhang | 96660d6 | 2015-12-14 18:27:25 -0800 | [diff] [blame] | 298 | ASSERT(pAnnot); |
Lei Zhang | 60f507b | 2015-06-13 00:41:00 -0700 | [diff] [blame] | 299 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 300 | if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) { |
| 301 | if (pAnnotHandler->OnSetFocus(pAnnot, nFlag)) { |
| 302 | CPDFSDK_PageView* pPage = pAnnot->GetPageView(); |
| 303 | pPage->GetSDKDocument(); |
| 304 | return TRUE; |
| 305 | } |
| 306 | } |
| 307 | return FALSE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 308 | } |
| 309 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 310 | FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnKillFocus(CPDFSDK_Annot* pAnnot, |
tsepez | c3255f5 | 2016-03-25 14:52:27 -0700 | [diff] [blame] | 311 | uint32_t nFlag) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 312 | ASSERT(pAnnot); |
| 313 | if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) |
| 314 | return pAnnotHandler->OnKillFocus(pAnnot, nFlag); |
| 315 | |
| 316 | return FALSE; |
| 317 | } |
| 318 | |
Tom Sepez | 51da093 | 2015-11-25 16:05:49 -0800 | [diff] [blame] | 319 | #ifdef PDF_ENABLE_XFA |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 320 | FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnChangeFocus( |
| 321 | CPDFSDK_Annot* pSetAnnot, |
| 322 | CPDFSDK_Annot* pKillAnnot) { |
| 323 | FX_BOOL bXFA = (pSetAnnot && pSetAnnot->GetXFAWidget()) || |
| 324 | (pKillAnnot && pKillAnnot->GetXFAWidget()); |
| 325 | |
| 326 | if (bXFA) { |
| 327 | if (IPDFSDK_AnnotHandler* pXFAAnnotHandler = |
| 328 | GetAnnotHandler(FSDK_XFAWIDGET_TYPENAME)) |
| 329 | return pXFAAnnotHandler->OnXFAChangedFocus(pKillAnnot, pSetAnnot); |
| 330 | } |
| 331 | |
| 332 | return TRUE; |
| 333 | } |
Tom Sepez | 40e9ff3 | 2015-11-30 12:39:54 -0800 | [diff] [blame] | 334 | #endif // PDF_ENABLE_XFA |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 335 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 336 | CFX_FloatRect CPDFSDK_AnnotHandlerMgr::Annot_OnGetViewBBox( |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 337 | CPDFSDK_PageView* pPageView, |
| 338 | CPDFSDK_Annot* pAnnot) { |
| 339 | ASSERT(pAnnot); |
| 340 | if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) |
| 341 | return pAnnotHandler->GetViewBBox(pPageView, pAnnot); |
| 342 | |
| 343 | return pAnnot->GetRect(); |
| 344 | } |
| 345 | |
| 346 | FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnHitTest(CPDFSDK_PageView* pPageView, |
| 347 | CPDFSDK_Annot* pAnnot, |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 348 | const CFX_FloatPoint& point) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 349 | ASSERT(pAnnot); |
| 350 | if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) { |
| 351 | if (pAnnotHandler->CanAnswer(pAnnot)) |
| 352 | return pAnnotHandler->HitTest(pPageView, pAnnot, point); |
| 353 | } |
| 354 | return FALSE; |
| 355 | } |
| 356 | |
| 357 | CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::GetNextAnnot(CPDFSDK_Annot* pSDKAnnot, |
| 358 | FX_BOOL bNext) { |
Tom Sepez | 40e9ff3 | 2015-11-30 12:39:54 -0800 | [diff] [blame] | 359 | #ifdef PDF_ENABLE_XFA |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 360 | CPDFSDK_PageView* pPageView = pSDKAnnot->GetPageView(); |
| 361 | CPDFXFA_Page* pPage = pPageView->GetPDFXFAPage(); |
thestig | 1cd352e | 2016-06-07 17:53:06 -0700 | [diff] [blame] | 362 | if (!pPage) |
| 363 | return nullptr; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 364 | if (pPage->GetPDFPage()) { // for pdf annots. |
| 365 | CBA_AnnotIterator ai(pSDKAnnot->GetPageView(), pSDKAnnot->GetType(), ""); |
| 366 | CPDFSDK_Annot* pNext = |
| 367 | bNext ? ai.GetNextAnnot(pSDKAnnot) : ai.GetPrevAnnot(pSDKAnnot); |
| 368 | return pNext; |
| 369 | } |
| 370 | // for xfa annots |
tsepez | cc4d6d8 | 2016-05-16 13:21:03 -0700 | [diff] [blame] | 371 | std::unique_ptr<IXFA_WidgetIterator> pWidgetIterator( |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 372 | pPage->GetXFAPageView()->CreateWidgetIterator( |
dsinclair | 935d8d5 | 2016-05-17 10:32:18 -0700 | [diff] [blame] | 373 | XFA_TRAVERSEWAY_Tranvalse, XFA_WidgetStatus_Visible | |
| 374 | XFA_WidgetStatus_Viewable | |
| 375 | XFA_WidgetStatus_Focused)); |
tsepez | cc4d6d8 | 2016-05-16 13:21:03 -0700 | [diff] [blame] | 376 | if (!pWidgetIterator) |
| 377 | return nullptr; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 378 | if (pWidgetIterator->GetCurrentWidget() != pSDKAnnot->GetXFAWidget()) |
| 379 | pWidgetIterator->SetCurrentWidget(pSDKAnnot->GetXFAWidget()); |
tsepez | cc4d6d8 | 2016-05-16 13:21:03 -0700 | [diff] [blame] | 380 | CXFA_FFWidget* hNextFocus = |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 381 | bNext ? pWidgetIterator->MoveToNext() : pWidgetIterator->MoveToPrevious(); |
Lei Zhang | 5eca305 | 2016-02-22 20:32:21 -0800 | [diff] [blame] | 382 | if (!hNextFocus && pSDKAnnot) |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 383 | hNextFocus = pWidgetIterator->MoveToFirst(); |
| 384 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 385 | return pPageView->GetAnnotByXFAWidget(hNextFocus); |
Tom Sepez | 40e9ff3 | 2015-11-30 12:39:54 -0800 | [diff] [blame] | 386 | #else // PDF_ENABLE_XFA |
| 387 | CBA_AnnotIterator ai(pSDKAnnot->GetPageView(), "Widget", ""); |
| 388 | return bNext ? ai.GetNextAnnot(pSDKAnnot) : ai.GetPrevAnnot(pSDKAnnot); |
| 389 | #endif // PDF_ENABLE_XFA |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 390 | } |
| 391 | |
weili | 625ad66 | 2016-06-15 11:21:33 -0700 | [diff] [blame] | 392 | CPDFSDK_BFAnnotHandler::CPDFSDK_BFAnnotHandler(CPDFDoc_Environment* pApp) |
| 393 | : m_pApp(pApp), m_pFormFiller(nullptr) {} |
| 394 | |
| 395 | CPDFSDK_BFAnnotHandler::~CPDFSDK_BFAnnotHandler() {} |
| 396 | |
| 397 | CFX_ByteString CPDFSDK_BFAnnotHandler::GetType() { |
| 398 | return CFX_ByteString("Widget"); |
| 399 | } |
| 400 | |
| 401 | CFX_ByteString CPDFSDK_BFAnnotHandler::GetName() { |
| 402 | return CFX_ByteString("WidgetHandler"); |
| 403 | } |
| 404 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 405 | FX_BOOL CPDFSDK_BFAnnotHandler::CanAnswer(CPDFSDK_Annot* pAnnot) { |
| 406 | ASSERT(pAnnot->GetType() == "Widget"); |
| 407 | if (pAnnot->GetSubType() == BFFT_SIGNATURE) |
| 408 | return FALSE; |
| 409 | |
tsepez | 77b909e | 2016-06-09 14:08:11 -0700 | [diff] [blame] | 410 | CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 411 | if (!pWidget->IsVisible()) |
| 412 | return FALSE; |
| 413 | |
| 414 | int nFieldFlags = pWidget->GetFieldFlags(); |
| 415 | if ((nFieldFlags & FIELDFLAG_READONLY) == FIELDFLAG_READONLY) |
| 416 | return FALSE; |
| 417 | |
| 418 | if (pWidget->GetFieldType() == FIELDTYPE_PUSHBUTTON) |
| 419 | return TRUE; |
| 420 | |
| 421 | CPDF_Page* pPage = pWidget->GetPDFPage(); |
| 422 | CPDF_Document* pDocument = pPage->m_pDocument; |
tsepez | c3255f5 | 2016-03-25 14:52:27 -0700 | [diff] [blame] | 423 | uint32_t dwPermissions = pDocument->GetUserPermissions(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 424 | return (dwPermissions & FPDFPERM_FILL_FORM) || |
| 425 | (dwPermissions & FPDFPERM_ANNOT_FORM); |
| 426 | } |
| 427 | |
| 428 | CPDFSDK_Annot* CPDFSDK_BFAnnotHandler::NewAnnot(CPDF_Annot* pAnnot, |
| 429 | CPDFSDK_PageView* pPage) { |
| 430 | CPDFSDK_Document* pSDKDoc = m_pApp->GetSDKDocument(); |
tsepez | 23ae4a5 | 2016-06-08 20:44:54 -0700 | [diff] [blame] | 431 | CPDFSDK_InterForm* pInterForm = pSDKDoc->GetInterForm(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 432 | CPDF_FormControl* pCtrl = CPDFSDK_Widget::GetFormControl( |
| 433 | pInterForm->GetInterForm(), pAnnot->GetAnnotDict()); |
| 434 | if (!pCtrl) |
| 435 | return nullptr; |
| 436 | |
| 437 | CPDFSDK_Widget* pWidget = new CPDFSDK_Widget(pAnnot, pPage, pInterForm); |
| 438 | pInterForm->AddMap(pCtrl, pWidget); |
| 439 | CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm(); |
| 440 | if (pPDFInterForm && pPDFInterForm->NeedConstructAP()) |
| 441 | pWidget->ResetAppearance(nullptr, FALSE); |
| 442 | |
| 443 | return pWidget; |
| 444 | } |
| 445 | |
Tom Sepez | 51da093 | 2015-11-25 16:05:49 -0800 | [diff] [blame] | 446 | #ifdef PDF_ENABLE_XFA |
dsinclair | df4bc59 | 2016-03-31 20:34:43 -0700 | [diff] [blame] | 447 | CPDFSDK_Annot* CPDFSDK_BFAnnotHandler::NewAnnot(CXFA_FFWidget* hWidget, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 448 | CPDFSDK_PageView* pPage) { |
thestig | 1cd352e | 2016-06-07 17:53:06 -0700 | [diff] [blame] | 449 | return nullptr; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 450 | } |
Tom Sepez | 40e9ff3 | 2015-11-30 12:39:54 -0800 | [diff] [blame] | 451 | #endif // PDF_ENABLE_XFA |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 452 | |
| 453 | void CPDFSDK_BFAnnotHandler::ReleaseAnnot(CPDFSDK_Annot* pAnnot) { |
Lei Zhang | 96660d6 | 2015-12-14 18:27:25 -0800 | [diff] [blame] | 454 | ASSERT(pAnnot); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 455 | |
| 456 | if (m_pFormFiller) |
| 457 | m_pFormFiller->OnDelete(pAnnot); |
| 458 | |
tsepez | 77b909e | 2016-06-09 14:08:11 -0700 | [diff] [blame] | 459 | std::unique_ptr<CPDFSDK_Widget> pWidget(static_cast<CPDFSDK_Widget*>(pAnnot)); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 460 | CPDFSDK_InterForm* pInterForm = pWidget->GetInterForm(); |
tsepez | 77b909e | 2016-06-09 14:08:11 -0700 | [diff] [blame] | 461 | CPDF_FormControl* pControl = pWidget->GetFormControl(); |
| 462 | pInterForm->RemoveMap(pControl); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 463 | } |
| 464 | |
weili | 625ad66 | 2016-06-15 11:21:33 -0700 | [diff] [blame] | 465 | void CPDFSDK_BFAnnotHandler::DeleteAnnot(CPDFSDK_Annot* pAnnot) {} |
| 466 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 467 | void CPDFSDK_BFAnnotHandler::OnDraw(CPDFSDK_PageView* pPageView, |
| 468 | CPDFSDK_Annot* pAnnot, |
| 469 | CFX_RenderDevice* pDevice, |
Tom Sepez | 60d909e | 2015-12-10 15:34:55 -0800 | [diff] [blame] | 470 | CFX_Matrix* pUser2Device, |
tsepez | c3255f5 | 2016-03-25 14:52:27 -0700 | [diff] [blame] | 471 | uint32_t dwFlags) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 472 | CFX_ByteString sSubType = pAnnot->GetSubType(); |
| 473 | |
| 474 | if (sSubType == BFFT_SIGNATURE) { |
Dan Sinclair | bfe042a | 2015-11-04 14:04:13 -0500 | [diff] [blame] | 475 | static_cast<CPDFSDK_BAAnnot*>(pAnnot) |
| 476 | ->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, nullptr); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 477 | } else { |
| 478 | if (m_pFormFiller) { |
| 479 | m_pFormFiller->OnDraw(pPageView, pAnnot, pDevice, pUser2Device, dwFlags); |
| 480 | } |
| 481 | } |
| 482 | } |
| 483 | |
weili | 625ad66 | 2016-06-15 11:21:33 -0700 | [diff] [blame] | 484 | void CPDFSDK_BFAnnotHandler::OnDrawSleep(CPDFSDK_PageView* pPageView, |
| 485 | CPDFSDK_Annot* pAnnot, |
| 486 | CFX_RenderDevice* pDevice, |
| 487 | CFX_Matrix* pUser2Device, |
| 488 | const CFX_FloatRect& rcWindow, |
| 489 | uint32_t dwFlags) {} |
| 490 | |
| 491 | void CPDFSDK_BFAnnotHandler::OnDelete(CPDFSDK_Annot* pAnnot) {} |
| 492 | |
| 493 | void CPDFSDK_BFAnnotHandler::OnRelease(CPDFSDK_Annot* pAnnot) {} |
| 494 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 495 | void CPDFSDK_BFAnnotHandler::OnMouseEnter(CPDFSDK_PageView* pPageView, |
| 496 | CPDFSDK_Annot* pAnnot, |
tsepez | c3255f5 | 2016-03-25 14:52:27 -0700 | [diff] [blame] | 497 | uint32_t nFlag) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 498 | CFX_ByteString sSubType = pAnnot->GetSubType(); |
| 499 | |
| 500 | if (sSubType == BFFT_SIGNATURE) { |
| 501 | } else { |
| 502 | if (m_pFormFiller) |
| 503 | m_pFormFiller->OnMouseEnter(pPageView, pAnnot, nFlag); |
| 504 | } |
| 505 | } |
| 506 | void CPDFSDK_BFAnnotHandler::OnMouseExit(CPDFSDK_PageView* pPageView, |
| 507 | CPDFSDK_Annot* pAnnot, |
tsepez | c3255f5 | 2016-03-25 14:52:27 -0700 | [diff] [blame] | 508 | uint32_t nFlag) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 509 | CFX_ByteString sSubType = pAnnot->GetSubType(); |
| 510 | |
| 511 | if (sSubType == BFFT_SIGNATURE) { |
| 512 | } else { |
| 513 | if (m_pFormFiller) |
| 514 | m_pFormFiller->OnMouseExit(pPageView, pAnnot, nFlag); |
| 515 | } |
| 516 | } |
| 517 | FX_BOOL CPDFSDK_BFAnnotHandler::OnLButtonDown(CPDFSDK_PageView* pPageView, |
| 518 | CPDFSDK_Annot* pAnnot, |
tsepez | c3255f5 | 2016-03-25 14:52:27 -0700 | [diff] [blame] | 519 | uint32_t nFlags, |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 520 | const CFX_FloatPoint& point) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 521 | CFX_ByteString sSubType = pAnnot->GetSubType(); |
| 522 | |
| 523 | if (sSubType == BFFT_SIGNATURE) { |
| 524 | } else { |
| 525 | if (m_pFormFiller) |
| 526 | return m_pFormFiller->OnLButtonDown(pPageView, pAnnot, nFlags, point); |
| 527 | } |
| 528 | |
| 529 | return FALSE; |
| 530 | } |
| 531 | |
| 532 | FX_BOOL CPDFSDK_BFAnnotHandler::OnLButtonUp(CPDFSDK_PageView* pPageView, |
| 533 | CPDFSDK_Annot* pAnnot, |
tsepez | c3255f5 | 2016-03-25 14:52:27 -0700 | [diff] [blame] | 534 | uint32_t nFlags, |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 535 | const CFX_FloatPoint& point) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 536 | CFX_ByteString sSubType = pAnnot->GetSubType(); |
| 537 | |
| 538 | if (sSubType == BFFT_SIGNATURE) { |
| 539 | } else { |
| 540 | if (m_pFormFiller) |
| 541 | return m_pFormFiller->OnLButtonUp(pPageView, pAnnot, nFlags, point); |
| 542 | } |
| 543 | |
| 544 | return FALSE; |
| 545 | } |
| 546 | |
| 547 | FX_BOOL CPDFSDK_BFAnnotHandler::OnLButtonDblClk(CPDFSDK_PageView* pPageView, |
| 548 | CPDFSDK_Annot* pAnnot, |
tsepez | c3255f5 | 2016-03-25 14:52:27 -0700 | [diff] [blame] | 549 | uint32_t nFlags, |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 550 | const CFX_FloatPoint& point) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 551 | CFX_ByteString sSubType = pAnnot->GetSubType(); |
| 552 | |
| 553 | if (sSubType == BFFT_SIGNATURE) { |
| 554 | } else { |
| 555 | if (m_pFormFiller) |
| 556 | return m_pFormFiller->OnLButtonDblClk(pPageView, pAnnot, nFlags, point); |
| 557 | } |
| 558 | |
| 559 | return FALSE; |
| 560 | } |
| 561 | |
| 562 | FX_BOOL CPDFSDK_BFAnnotHandler::OnMouseMove(CPDFSDK_PageView* pPageView, |
| 563 | CPDFSDK_Annot* pAnnot, |
tsepez | c3255f5 | 2016-03-25 14:52:27 -0700 | [diff] [blame] | 564 | uint32_t nFlags, |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 565 | const CFX_FloatPoint& point) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 566 | CFX_ByteString sSubType = pAnnot->GetSubType(); |
| 567 | |
| 568 | if (sSubType == BFFT_SIGNATURE) { |
| 569 | } else { |
| 570 | if (m_pFormFiller) |
| 571 | return m_pFormFiller->OnMouseMove(pPageView, pAnnot, nFlags, point); |
| 572 | } |
| 573 | |
| 574 | return FALSE; |
| 575 | } |
| 576 | |
| 577 | FX_BOOL CPDFSDK_BFAnnotHandler::OnMouseWheel(CPDFSDK_PageView* pPageView, |
| 578 | CPDFSDK_Annot* pAnnot, |
tsepez | c3255f5 | 2016-03-25 14:52:27 -0700 | [diff] [blame] | 579 | uint32_t nFlags, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 580 | short zDelta, |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 581 | const CFX_FloatPoint& point) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 582 | CFX_ByteString sSubType = pAnnot->GetSubType(); |
| 583 | |
| 584 | if (sSubType == BFFT_SIGNATURE) { |
| 585 | } else { |
| 586 | if (m_pFormFiller) |
| 587 | return m_pFormFiller->OnMouseWheel(pPageView, pAnnot, nFlags, zDelta, |
| 588 | point); |
| 589 | } |
| 590 | |
| 591 | return FALSE; |
| 592 | } |
| 593 | |
| 594 | FX_BOOL CPDFSDK_BFAnnotHandler::OnRButtonDown(CPDFSDK_PageView* pPageView, |
| 595 | CPDFSDK_Annot* pAnnot, |
tsepez | c3255f5 | 2016-03-25 14:52:27 -0700 | [diff] [blame] | 596 | uint32_t nFlags, |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 597 | const CFX_FloatPoint& point) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 598 | CFX_ByteString sSubType = pAnnot->GetSubType(); |
| 599 | |
| 600 | if (sSubType == BFFT_SIGNATURE) { |
| 601 | } else { |
| 602 | if (m_pFormFiller) |
| 603 | return m_pFormFiller->OnRButtonDown(pPageView, pAnnot, nFlags, point); |
| 604 | } |
| 605 | |
| 606 | return FALSE; |
| 607 | } |
| 608 | FX_BOOL CPDFSDK_BFAnnotHandler::OnRButtonUp(CPDFSDK_PageView* pPageView, |
| 609 | CPDFSDK_Annot* pAnnot, |
tsepez | c3255f5 | 2016-03-25 14:52:27 -0700 | [diff] [blame] | 610 | uint32_t nFlags, |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 611 | const CFX_FloatPoint& point) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 612 | CFX_ByteString sSubType = pAnnot->GetSubType(); |
| 613 | |
| 614 | if (sSubType == BFFT_SIGNATURE) { |
| 615 | } else { |
| 616 | if (m_pFormFiller) |
| 617 | return m_pFormFiller->OnRButtonUp(pPageView, pAnnot, nFlags, point); |
| 618 | } |
| 619 | |
| 620 | return FALSE; |
| 621 | } |
| 622 | |
weili | 625ad66 | 2016-06-15 11:21:33 -0700 | [diff] [blame] | 623 | FX_BOOL CPDFSDK_BFAnnotHandler::OnRButtonDblClk(CPDFSDK_PageView* pPageView, |
| 624 | CPDFSDK_Annot* pAnnot, |
| 625 | uint32_t nFlags, |
| 626 | const CFX_FloatPoint& point) { |
| 627 | return FALSE; |
| 628 | } |
| 629 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 630 | FX_BOOL CPDFSDK_BFAnnotHandler::OnChar(CPDFSDK_Annot* pAnnot, |
tsepez | c3255f5 | 2016-03-25 14:52:27 -0700 | [diff] [blame] | 631 | uint32_t nChar, |
| 632 | uint32_t nFlags) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 633 | CFX_ByteString sSubType = pAnnot->GetSubType(); |
| 634 | |
| 635 | if (sSubType == BFFT_SIGNATURE) { |
| 636 | } else { |
| 637 | if (m_pFormFiller) |
| 638 | return m_pFormFiller->OnChar(pAnnot, nChar, nFlags); |
| 639 | } |
| 640 | |
| 641 | return FALSE; |
| 642 | } |
| 643 | |
| 644 | FX_BOOL CPDFSDK_BFAnnotHandler::OnKeyDown(CPDFSDK_Annot* pAnnot, |
| 645 | int nKeyCode, |
| 646 | int nFlag) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 647 | CFX_ByteString sSubType = pAnnot->GetSubType(); |
| 648 | |
| 649 | if (sSubType == BFFT_SIGNATURE) { |
| 650 | } else { |
| 651 | if (m_pFormFiller) |
| 652 | return m_pFormFiller->OnKeyDown(pAnnot, nKeyCode, nFlag); |
| 653 | } |
| 654 | |
| 655 | return FALSE; |
| 656 | } |
| 657 | |
| 658 | FX_BOOL CPDFSDK_BFAnnotHandler::OnKeyUp(CPDFSDK_Annot* pAnnot, |
| 659 | int nKeyCode, |
| 660 | int nFlag) { |
| 661 | return FALSE; |
| 662 | } |
| 663 | void CPDFSDK_BFAnnotHandler::OnCreate(CPDFSDK_Annot* pAnnot) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 664 | CFX_ByteString sSubType = pAnnot->GetSubType(); |
| 665 | |
| 666 | if (sSubType == BFFT_SIGNATURE) { |
| 667 | } else { |
| 668 | if (m_pFormFiller) |
| 669 | m_pFormFiller->OnCreate(pAnnot); |
| 670 | } |
| 671 | } |
| 672 | |
| 673 | void CPDFSDK_BFAnnotHandler::OnLoad(CPDFSDK_Annot* pAnnot) { |
Tom Sepez | 50d12ad | 2015-11-24 09:50:51 -0800 | [diff] [blame] | 674 | if (pAnnot->GetSubType() == BFFT_SIGNATURE) |
| 675 | return; |
| 676 | |
tsepez | 77b909e | 2016-06-09 14:08:11 -0700 | [diff] [blame] | 677 | CPDFSDK_Widget* pWidget = static_cast<CPDFSDK_Widget*>(pAnnot); |
Tom Sepez | 50d12ad | 2015-11-24 09:50:51 -0800 | [diff] [blame] | 678 | if (!pWidget->IsAppearanceValid()) |
thestig | 1cd352e | 2016-06-07 17:53:06 -0700 | [diff] [blame] | 679 | pWidget->ResetAppearance(nullptr, FALSE); |
Tom Sepez | 50d12ad | 2015-11-24 09:50:51 -0800 | [diff] [blame] | 680 | |
| 681 | int nFieldType = pWidget->GetFieldType(); |
| 682 | if (nFieldType == FIELDTYPE_TEXTFIELD || nFieldType == FIELDTYPE_COMBOBOX) { |
| 683 | FX_BOOL bFormated = FALSE; |
| 684 | CFX_WideString sValue = pWidget->OnFormat(bFormated); |
| 685 | if (bFormated && nFieldType == FIELDTYPE_COMBOBOX) { |
| 686 | pWidget->ResetAppearance(sValue.c_str(), FALSE); |
| 687 | } |
| 688 | } |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 689 | |
Tom Sepez | 51da093 | 2015-11-25 16:05:49 -0800 | [diff] [blame] | 690 | #ifdef PDF_ENABLE_XFA |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 691 | CPDFSDK_PageView* pPageView = pAnnot->GetPageView(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 692 | CPDFSDK_Document* pSDKDoc = pPageView->GetSDKDocument(); |
Tom Sepez | 50d12ad | 2015-11-24 09:50:51 -0800 | [diff] [blame] | 693 | CPDFXFA_Document* pDoc = pSDKDoc->GetXFADocument(); |
| 694 | if (pDoc->GetDocType() == DOCTYPE_STATIC_XFA) { |
| 695 | if (!pWidget->IsAppearanceValid() && !pWidget->GetValue().IsEmpty()) |
| 696 | pWidget->ResetAppearance(FALSE); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 697 | } |
Tom Sepez | 40e9ff3 | 2015-11-30 12:39:54 -0800 | [diff] [blame] | 698 | #endif // PDF_ENABLE_XFA |
Tom Sepez | 50d12ad | 2015-11-24 09:50:51 -0800 | [diff] [blame] | 699 | if (m_pFormFiller) |
| 700 | m_pFormFiller->OnLoad(pAnnot); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 701 | } |
| 702 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 703 | FX_BOOL CPDFSDK_BFAnnotHandler::OnSetFocus(CPDFSDK_Annot* pAnnot, |
tsepez | c3255f5 | 2016-03-25 14:52:27 -0700 | [diff] [blame] | 704 | uint32_t nFlag) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 705 | CFX_ByteString sSubType = pAnnot->GetSubType(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 706 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 707 | if (sSubType == BFFT_SIGNATURE) { |
| 708 | } else { |
| 709 | if (m_pFormFiller) |
| 710 | return m_pFormFiller->OnSetFocus(pAnnot, nFlag); |
| 711 | } |
Lei Zhang | 60f507b | 2015-06-13 00:41:00 -0700 | [diff] [blame] | 712 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 713 | return TRUE; |
| 714 | } |
| 715 | FX_BOOL CPDFSDK_BFAnnotHandler::OnKillFocus(CPDFSDK_Annot* pAnnot, |
tsepez | c3255f5 | 2016-03-25 14:52:27 -0700 | [diff] [blame] | 716 | uint32_t nFlag) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 717 | CFX_ByteString sSubType = pAnnot->GetSubType(); |
| 718 | |
| 719 | if (sSubType == BFFT_SIGNATURE) { |
| 720 | } else { |
| 721 | if (m_pFormFiller) |
| 722 | return m_pFormFiller->OnKillFocus(pAnnot, nFlag); |
| 723 | } |
| 724 | |
| 725 | return TRUE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 726 | } |
| 727 | |
weili | 625ad66 | 2016-06-15 11:21:33 -0700 | [diff] [blame] | 728 | #ifdef PDF_ENABLE_XFA |
| 729 | |
| 730 | FX_BOOL CPDFSDK_BFAnnotHandler::OnXFAChangedFocus(CPDFSDK_Annot* pOldAnnot, |
| 731 | CPDFSDK_Annot* pNewAnnot) { |
| 732 | return TRUE; |
| 733 | } |
| 734 | |
| 735 | #endif // PDF_ENABLE_XFA |
| 736 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 737 | CFX_FloatRect CPDFSDK_BFAnnotHandler::GetViewBBox(CPDFSDK_PageView* pPageView, |
| 738 | CPDFSDK_Annot* pAnnot) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 739 | CFX_ByteString sSubType = pAnnot->GetSubType(); |
Tom Sepez | d5e7b35 | 2016-02-29 11:24:29 -0800 | [diff] [blame] | 740 | if (sSubType != BFFT_SIGNATURE && m_pFormFiller) |
| 741 | return CFX_FloatRect(m_pFormFiller->GetViewBBox(pPageView, pAnnot)); |
Lei Zhang | 60f507b | 2015-06-13 00:41:00 -0700 | [diff] [blame] | 742 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 743 | return CFX_FloatRect(0, 0, 0, 0); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 744 | } |
| 745 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 746 | FX_BOOL CPDFSDK_BFAnnotHandler::HitTest(CPDFSDK_PageView* pPageView, |
| 747 | CPDFSDK_Annot* pAnnot, |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 748 | const CFX_FloatPoint& point) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 749 | ASSERT(pPageView); |
| 750 | ASSERT(pAnnot); |
Lei Zhang | 60f507b | 2015-06-13 00:41:00 -0700 | [diff] [blame] | 751 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 752 | CFX_FloatRect rect = GetViewBBox(pPageView, pAnnot); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 753 | return rect.Contains(point.x, point.y); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 754 | } |
| 755 | |
Tom Sepez | 51da093 | 2015-11-25 16:05:49 -0800 | [diff] [blame] | 756 | #ifdef PDF_ENABLE_XFA |
Lei Zhang | 60f507b | 2015-06-13 00:41:00 -0700 | [diff] [blame] | 757 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 758 | CPDFSDK_XFAAnnotHandler::CPDFSDK_XFAAnnotHandler(CPDFDoc_Environment* pApp) |
| 759 | : m_pApp(pApp) {} |
| 760 | |
weili | 625ad66 | 2016-06-15 11:21:33 -0700 | [diff] [blame] | 761 | CPDFSDK_XFAAnnotHandler::~CPDFSDK_XFAAnnotHandler() {} |
| 762 | |
| 763 | CFX_ByteString CPDFSDK_XFAAnnotHandler::GetType() { |
| 764 | return FSDK_XFAWIDGET_TYPENAME; |
| 765 | } |
| 766 | |
| 767 | CFX_ByteString CPDFSDK_XFAAnnotHandler::GetName() { |
| 768 | return "XFAWidgetHandler"; |
| 769 | } |
| 770 | |
| 771 | FX_BOOL CPDFSDK_XFAAnnotHandler::CanAnswer(CPDFSDK_Annot* pAnnot) { |
| 772 | return !!pAnnot->GetXFAWidget(); |
| 773 | } |
| 774 | |
| 775 | CPDFSDK_Annot* CPDFSDK_XFAAnnotHandler::NewAnnot(CPDF_Annot* pAnnot, |
| 776 | CPDFSDK_PageView* pPage) { |
| 777 | return nullptr; |
| 778 | } |
| 779 | |
dsinclair | df4bc59 | 2016-03-31 20:34:43 -0700 | [diff] [blame] | 780 | CPDFSDK_Annot* CPDFSDK_XFAAnnotHandler::NewAnnot(CXFA_FFWidget* pAnnot, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 781 | CPDFSDK_PageView* pPage) { |
| 782 | CPDFSDK_Document* pSDKDoc = m_pApp->GetSDKDocument(); |
tsepez | 23ae4a5 | 2016-06-08 20:44:54 -0700 | [diff] [blame] | 783 | CPDFSDK_InterForm* pInterForm = pSDKDoc->GetInterForm(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 784 | CPDFSDK_XFAWidget* pWidget = new CPDFSDK_XFAWidget(pAnnot, pPage, pInterForm); |
| 785 | pInterForm->AddXFAMap(pAnnot, pWidget); |
| 786 | return pWidget; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 787 | } |
| 788 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 789 | void CPDFSDK_XFAAnnotHandler::OnDraw(CPDFSDK_PageView* pPageView, |
| 790 | CPDFSDK_Annot* pAnnot, |
| 791 | CFX_RenderDevice* pDevice, |
Tom Sepez | 60d909e | 2015-12-10 15:34:55 -0800 | [diff] [blame] | 792 | CFX_Matrix* pUser2Device, |
tsepez | c3255f5 | 2016-03-25 14:52:27 -0700 | [diff] [blame] | 793 | uint32_t dwFlags) { |
thestig | 1cd352e | 2016-06-07 17:53:06 -0700 | [diff] [blame] | 794 | ASSERT(pPageView); |
| 795 | ASSERT(pAnnot); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 796 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 797 | CPDFSDK_Document* pSDKDoc = pPageView->GetSDKDocument(); |
dsinclair | df4bc59 | 2016-03-31 20:34:43 -0700 | [diff] [blame] | 798 | CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 799 | |
| 800 | CFX_Graphics gs; |
| 801 | gs.Create(pDevice); |
| 802 | |
| 803 | CFX_Matrix mt; |
| 804 | mt = *(CFX_Matrix*)pUser2Device; |
| 805 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 806 | FX_BOOL bIsHighlight = FALSE; |
| 807 | if (pSDKDoc->GetFocusAnnot() != pAnnot) |
| 808 | bIsHighlight = TRUE; |
| 809 | |
| 810 | pWidgetHandler->RenderWidget(pAnnot->GetXFAWidget(), &gs, &mt, bIsHighlight); |
| 811 | |
| 812 | // to do highlight and shadow |
| 813 | } |
| 814 | |
weili | 625ad66 | 2016-06-15 11:21:33 -0700 | [diff] [blame] | 815 | void CPDFSDK_XFAAnnotHandler::OnDrawSleep(CPDFSDK_PageView* pPageView, |
| 816 | CPDFSDK_Annot* pAnnot, |
| 817 | CFX_RenderDevice* pDevice, |
| 818 | CFX_Matrix* pUser2Device, |
| 819 | const CFX_FloatRect& rcWindow, |
| 820 | uint32_t dwFlags) {} |
| 821 | |
| 822 | void CPDFSDK_XFAAnnotHandler::OnCreate(CPDFSDK_Annot* pAnnot) {} |
| 823 | |
| 824 | void CPDFSDK_XFAAnnotHandler::OnLoad(CPDFSDK_Annot* pAnnot) {} |
| 825 | |
| 826 | void CPDFSDK_XFAAnnotHandler::OnDelete(CPDFSDK_Annot* pAnnot) {} |
| 827 | |
| 828 | void CPDFSDK_XFAAnnotHandler::OnRelease(CPDFSDK_Annot* pAnnot) {} |
| 829 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 830 | void CPDFSDK_XFAAnnotHandler::ReleaseAnnot(CPDFSDK_Annot* pAnnot) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 831 | CPDFSDK_XFAWidget* pWidget = (CPDFSDK_XFAWidget*)pAnnot; |
| 832 | CPDFSDK_InterForm* pInterForm = pWidget->GetInterForm(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 833 | pInterForm->RemoveXFAMap(pWidget->GetXFAWidget()); |
| 834 | |
| 835 | delete pWidget; |
| 836 | } |
| 837 | |
weili | 625ad66 | 2016-06-15 11:21:33 -0700 | [diff] [blame] | 838 | void CPDFSDK_XFAAnnotHandler::DeleteAnnot(CPDFSDK_Annot* pAnnot) {} |
| 839 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 840 | CFX_FloatRect CPDFSDK_XFAAnnotHandler::GetViewBBox(CPDFSDK_PageView* pPageView, |
| 841 | CPDFSDK_Annot* pAnnot) { |
Lei Zhang | 5eca305 | 2016-02-22 20:32:21 -0800 | [diff] [blame] | 842 | ASSERT(pAnnot); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 843 | |
Tom Sepez | a8a39e2 | 2015-10-12 15:47:07 -0700 | [diff] [blame] | 844 | CFX_RectF rcBBox; |
dsinclair | 56a8b19 | 2016-06-21 14:15:25 -0700 | [diff] [blame] | 845 | XFA_Element eType = pAnnot->GetXFAWidget()->GetDataAcc()->GetUIType(); |
| 846 | if (eType == XFA_Element::Signature) |
dsinclair | 935d8d5 | 2016-05-17 10:32:18 -0700 | [diff] [blame] | 847 | pAnnot->GetXFAWidget()->GetBBox(rcBBox, XFA_WidgetStatus_Visible, TRUE); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 848 | else |
dsinclair | 935d8d5 | 2016-05-17 10:32:18 -0700 | [diff] [blame] | 849 | pAnnot->GetXFAWidget()->GetBBox(rcBBox, XFA_WidgetStatus_None); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 850 | |
| 851 | CFX_FloatRect rcWidget(rcBBox.left, rcBBox.top, rcBBox.left + rcBBox.width, |
| 852 | rcBBox.top + rcBBox.height); |
| 853 | rcWidget.left -= 1.0f; |
| 854 | rcWidget.right += 1.0f; |
| 855 | rcWidget.bottom -= 1.0f; |
| 856 | rcWidget.top += 1.0f; |
| 857 | |
| 858 | return rcWidget; |
| 859 | } |
| 860 | |
| 861 | FX_BOOL CPDFSDK_XFAAnnotHandler::HitTest(CPDFSDK_PageView* pPageView, |
| 862 | CPDFSDK_Annot* pAnnot, |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 863 | const CFX_FloatPoint& point) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 864 | if (!pPageView || !pAnnot) |
Tom Sepez | dcbc02f | 2015-07-17 09:16:17 -0700 | [diff] [blame] | 865 | return FALSE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 866 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 867 | CPDFSDK_Document* pSDKDoc = pPageView->GetSDKDocument(); |
| 868 | if (!pSDKDoc) |
Tom Sepez | dcbc02f | 2015-07-17 09:16:17 -0700 | [diff] [blame] | 869 | return FALSE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 870 | |
Tom Sepez | 50d12ad | 2015-11-24 09:50:51 -0800 | [diff] [blame] | 871 | CPDFXFA_Document* pDoc = pSDKDoc->GetXFADocument(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 872 | if (!pDoc) |
Tom Sepez | dcbc02f | 2015-07-17 09:16:17 -0700 | [diff] [blame] | 873 | return FALSE; |
Lei Zhang | 60f507b | 2015-06-13 00:41:00 -0700 | [diff] [blame] | 874 | |
dsinclair | df4bc59 | 2016-03-31 20:34:43 -0700 | [diff] [blame] | 875 | CXFA_FFDocView* pDocView = pDoc->GetXFADocView(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 876 | if (!pDocView) |
Tom Sepez | dcbc02f | 2015-07-17 09:16:17 -0700 | [diff] [blame] | 877 | return FALSE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 878 | |
dsinclair | df4bc59 | 2016-03-31 20:34:43 -0700 | [diff] [blame] | 879 | CXFA_FFWidgetHandler* pWidgetHandler = pDocView->GetWidgetHandler(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 880 | if (!pWidgetHandler) |
Tom Sepez | dcbc02f | 2015-07-17 09:16:17 -0700 | [diff] [blame] | 881 | return FALSE; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 882 | |
dsinclair | 89fcde8 | 2016-05-03 13:00:25 -0700 | [diff] [blame] | 883 | FWL_WidgetHit dwHitTest = |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 884 | pWidgetHandler->OnHitTest(pAnnot->GetXFAWidget(), point.x, point.y); |
dsinclair | 89fcde8 | 2016-05-03 13:00:25 -0700 | [diff] [blame] | 885 | return dwHitTest != FWL_WidgetHit::Unknown; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 886 | } |
| 887 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 888 | void CPDFSDK_XFAAnnotHandler::OnMouseEnter(CPDFSDK_PageView* pPageView, |
| 889 | CPDFSDK_Annot* pAnnot, |
tsepez | c3255f5 | 2016-03-25 14:52:27 -0700 | [diff] [blame] | 890 | uint32_t nFlag) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 891 | if (!pPageView || !pAnnot) |
| 892 | return; |
dsinclair | df4bc59 | 2016-03-31 20:34:43 -0700 | [diff] [blame] | 893 | CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 894 | pWidgetHandler->OnMouseEnter(pAnnot->GetXFAWidget()); |
| 895 | } |
Lei Zhang | 60f507b | 2015-06-13 00:41:00 -0700 | [diff] [blame] | 896 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 897 | void CPDFSDK_XFAAnnotHandler::OnMouseExit(CPDFSDK_PageView* pPageView, |
| 898 | CPDFSDK_Annot* pAnnot, |
tsepez | c3255f5 | 2016-03-25 14:52:27 -0700 | [diff] [blame] | 899 | uint32_t nFlag) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 900 | if (!pPageView || !pAnnot) |
| 901 | return; |
| 902 | |
dsinclair | df4bc59 | 2016-03-31 20:34:43 -0700 | [diff] [blame] | 903 | CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 904 | pWidgetHandler->OnMouseExit(pAnnot->GetXFAWidget()); |
| 905 | } |
| 906 | |
| 907 | FX_BOOL CPDFSDK_XFAAnnotHandler::OnLButtonDown(CPDFSDK_PageView* pPageView, |
| 908 | CPDFSDK_Annot* pAnnot, |
tsepez | c3255f5 | 2016-03-25 14:52:27 -0700 | [diff] [blame] | 909 | uint32_t nFlags, |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 910 | const CFX_FloatPoint& point) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 911 | if (!pPageView || !pAnnot) |
Tom Sepez | dcbc02f | 2015-07-17 09:16:17 -0700 | [diff] [blame] | 912 | return FALSE; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 913 | |
dsinclair | df4bc59 | 2016-03-31 20:34:43 -0700 | [diff] [blame] | 914 | CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); |
Lei Zhang | 5eca305 | 2016-02-22 20:32:21 -0800 | [diff] [blame] | 915 | return pWidgetHandler->OnLButtonDown(pAnnot->GetXFAWidget(), |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 916 | GetFWLFlags(nFlags), point.x, point.y); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 917 | } |
| 918 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 919 | FX_BOOL CPDFSDK_XFAAnnotHandler::OnLButtonUp(CPDFSDK_PageView* pPageView, |
| 920 | CPDFSDK_Annot* pAnnot, |
tsepez | c3255f5 | 2016-03-25 14:52:27 -0700 | [diff] [blame] | 921 | uint32_t nFlags, |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 922 | const CFX_FloatPoint& point) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 923 | if (!pPageView || !pAnnot) |
Tom Sepez | dcbc02f | 2015-07-17 09:16:17 -0700 | [diff] [blame] | 924 | return FALSE; |
Lei Zhang | 60f507b | 2015-06-13 00:41:00 -0700 | [diff] [blame] | 925 | |
dsinclair | df4bc59 | 2016-03-31 20:34:43 -0700 | [diff] [blame] | 926 | CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); |
Lei Zhang | 5eca305 | 2016-02-22 20:32:21 -0800 | [diff] [blame] | 927 | return pWidgetHandler->OnLButtonUp(pAnnot->GetXFAWidget(), |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 928 | GetFWLFlags(nFlags), point.x, point.y); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 929 | } |
| 930 | |
| 931 | FX_BOOL CPDFSDK_XFAAnnotHandler::OnLButtonDblClk(CPDFSDK_PageView* pPageView, |
| 932 | CPDFSDK_Annot* pAnnot, |
tsepez | c3255f5 | 2016-03-25 14:52:27 -0700 | [diff] [blame] | 933 | uint32_t nFlags, |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 934 | const CFX_FloatPoint& point) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 935 | if (!pPageView || !pAnnot) |
| 936 | return FALSE; |
| 937 | |
dsinclair | df4bc59 | 2016-03-31 20:34:43 -0700 | [diff] [blame] | 938 | CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); |
Lei Zhang | 5eca305 | 2016-02-22 20:32:21 -0800 | [diff] [blame] | 939 | return pWidgetHandler->OnLButtonDblClk(pAnnot->GetXFAWidget(), |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 940 | GetFWLFlags(nFlags), point.x, point.y); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 941 | } |
| 942 | |
| 943 | FX_BOOL CPDFSDK_XFAAnnotHandler::OnMouseMove(CPDFSDK_PageView* pPageView, |
| 944 | CPDFSDK_Annot* pAnnot, |
tsepez | c3255f5 | 2016-03-25 14:52:27 -0700 | [diff] [blame] | 945 | uint32_t nFlags, |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 946 | const CFX_FloatPoint& point) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 947 | if (!pPageView || !pAnnot) |
| 948 | return FALSE; |
| 949 | |
dsinclair | df4bc59 | 2016-03-31 20:34:43 -0700 | [diff] [blame] | 950 | CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); |
Lei Zhang | 5eca305 | 2016-02-22 20:32:21 -0800 | [diff] [blame] | 951 | return pWidgetHandler->OnMouseMove(pAnnot->GetXFAWidget(), |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 952 | GetFWLFlags(nFlags), point.x, point.y); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 953 | } |
| 954 | |
| 955 | FX_BOOL CPDFSDK_XFAAnnotHandler::OnMouseWheel(CPDFSDK_PageView* pPageView, |
| 956 | CPDFSDK_Annot* pAnnot, |
tsepez | c3255f5 | 2016-03-25 14:52:27 -0700 | [diff] [blame] | 957 | uint32_t nFlags, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 958 | short zDelta, |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 959 | const CFX_FloatPoint& point) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 960 | if (!pPageView || !pAnnot) |
| 961 | return FALSE; |
| 962 | |
dsinclair | df4bc59 | 2016-03-31 20:34:43 -0700 | [diff] [blame] | 963 | CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); |
Lei Zhang | 5eca305 | 2016-02-22 20:32:21 -0800 | [diff] [blame] | 964 | return pWidgetHandler->OnMouseWheel( |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 965 | pAnnot->GetXFAWidget(), GetFWLFlags(nFlags), zDelta, point.x, point.y); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 966 | } |
| 967 | |
| 968 | FX_BOOL CPDFSDK_XFAAnnotHandler::OnRButtonDown(CPDFSDK_PageView* pPageView, |
| 969 | CPDFSDK_Annot* pAnnot, |
tsepez | c3255f5 | 2016-03-25 14:52:27 -0700 | [diff] [blame] | 970 | uint32_t nFlags, |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 971 | const CFX_FloatPoint& point) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 972 | if (!pPageView || !pAnnot) |
| 973 | return FALSE; |
| 974 | |
dsinclair | df4bc59 | 2016-03-31 20:34:43 -0700 | [diff] [blame] | 975 | CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); |
Lei Zhang | 5eca305 | 2016-02-22 20:32:21 -0800 | [diff] [blame] | 976 | return pWidgetHandler->OnRButtonDown(pAnnot->GetXFAWidget(), |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 977 | GetFWLFlags(nFlags), point.x, point.y); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 978 | } |
| 979 | |
| 980 | FX_BOOL CPDFSDK_XFAAnnotHandler::OnRButtonUp(CPDFSDK_PageView* pPageView, |
| 981 | CPDFSDK_Annot* pAnnot, |
tsepez | c3255f5 | 2016-03-25 14:52:27 -0700 | [diff] [blame] | 982 | uint32_t nFlags, |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 983 | const CFX_FloatPoint& point) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 984 | if (!pPageView || !pAnnot) |
| 985 | return FALSE; |
| 986 | |
dsinclair | df4bc59 | 2016-03-31 20:34:43 -0700 | [diff] [blame] | 987 | CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); |
Lei Zhang | 5eca305 | 2016-02-22 20:32:21 -0800 | [diff] [blame] | 988 | return pWidgetHandler->OnRButtonUp(pAnnot->GetXFAWidget(), |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 989 | GetFWLFlags(nFlags), point.x, point.y); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 990 | } |
| 991 | |
| 992 | FX_BOOL CPDFSDK_XFAAnnotHandler::OnRButtonDblClk(CPDFSDK_PageView* pPageView, |
| 993 | CPDFSDK_Annot* pAnnot, |
tsepez | c3255f5 | 2016-03-25 14:52:27 -0700 | [diff] [blame] | 994 | uint32_t nFlags, |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 995 | const CFX_FloatPoint& point) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 996 | if (!pPageView || !pAnnot) |
| 997 | return FALSE; |
| 998 | |
dsinclair | df4bc59 | 2016-03-31 20:34:43 -0700 | [diff] [blame] | 999 | CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); |
Lei Zhang | 5eca305 | 2016-02-22 20:32:21 -0800 | [diff] [blame] | 1000 | return pWidgetHandler->OnRButtonDblClk(pAnnot->GetXFAWidget(), |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1001 | GetFWLFlags(nFlags), point.x, point.y); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1002 | } |
| 1003 | |
| 1004 | FX_BOOL CPDFSDK_XFAAnnotHandler::OnChar(CPDFSDK_Annot* pAnnot, |
tsepez | c3255f5 | 2016-03-25 14:52:27 -0700 | [diff] [blame] | 1005 | uint32_t nChar, |
| 1006 | uint32_t nFlags) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1007 | if (!pAnnot) |
| 1008 | return FALSE; |
| 1009 | |
dsinclair | df4bc59 | 2016-03-31 20:34:43 -0700 | [diff] [blame] | 1010 | CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); |
Lei Zhang | 5eca305 | 2016-02-22 20:32:21 -0800 | [diff] [blame] | 1011 | return pWidgetHandler->OnChar(pAnnot->GetXFAWidget(), nChar, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1012 | GetFWLFlags(nFlags)); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1013 | } |
| 1014 | |
| 1015 | FX_BOOL CPDFSDK_XFAAnnotHandler::OnKeyDown(CPDFSDK_Annot* pAnnot, |
| 1016 | int nKeyCode, |
| 1017 | int nFlag) { |
| 1018 | if (!pAnnot) |
| 1019 | return FALSE; |
| 1020 | |
dsinclair | df4bc59 | 2016-03-31 20:34:43 -0700 | [diff] [blame] | 1021 | CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); |
Lei Zhang | 5eca305 | 2016-02-22 20:32:21 -0800 | [diff] [blame] | 1022 | return pWidgetHandler->OnKeyDown(pAnnot->GetXFAWidget(), nKeyCode, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1023 | GetFWLFlags(nFlag)); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1024 | } |
| 1025 | |
| 1026 | FX_BOOL CPDFSDK_XFAAnnotHandler::OnKeyUp(CPDFSDK_Annot* pAnnot, |
| 1027 | int nKeyCode, |
| 1028 | int nFlag) { |
| 1029 | if (!pAnnot) |
| 1030 | return FALSE; |
| 1031 | |
dsinclair | df4bc59 | 2016-03-31 20:34:43 -0700 | [diff] [blame] | 1032 | CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); |
Lei Zhang | 5eca305 | 2016-02-22 20:32:21 -0800 | [diff] [blame] | 1033 | return pWidgetHandler->OnKeyUp(pAnnot->GetXFAWidget(), nKeyCode, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1034 | GetFWLFlags(nFlag)); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1035 | } |
| 1036 | |
weili | 625ad66 | 2016-06-15 11:21:33 -0700 | [diff] [blame] | 1037 | void CPDFSDK_XFAAnnotHandler::OnDeSelected(CPDFSDK_Annot* pAnnot) {} |
| 1038 | |
| 1039 | void CPDFSDK_XFAAnnotHandler::OnSelected(CPDFSDK_Annot* pAnnot) {} |
| 1040 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1041 | FX_BOOL CPDFSDK_XFAAnnotHandler::OnSetFocus(CPDFSDK_Annot* pAnnot, |
tsepez | c3255f5 | 2016-03-25 14:52:27 -0700 | [diff] [blame] | 1042 | uint32_t nFlag) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1043 | return TRUE; |
| 1044 | } |
| 1045 | |
| 1046 | FX_BOOL CPDFSDK_XFAAnnotHandler::OnKillFocus(CPDFSDK_Annot* pAnnot, |
tsepez | c3255f5 | 2016-03-25 14:52:27 -0700 | [diff] [blame] | 1047 | uint32_t nFlag) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1048 | return TRUE; |
| 1049 | } |
| 1050 | |
| 1051 | FX_BOOL CPDFSDK_XFAAnnotHandler::OnXFAChangedFocus(CPDFSDK_Annot* pOldAnnot, |
| 1052 | CPDFSDK_Annot* pNewAnnot) { |
thestig | 1cd352e | 2016-06-07 17:53:06 -0700 | [diff] [blame] | 1053 | CXFA_FFWidgetHandler* pWidgetHandler = nullptr; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1054 | |
| 1055 | if (pOldAnnot) |
| 1056 | pWidgetHandler = GetXFAWidgetHandler(pOldAnnot); |
| 1057 | else if (pNewAnnot) |
| 1058 | pWidgetHandler = GetXFAWidgetHandler(pNewAnnot); |
| 1059 | |
| 1060 | if (pWidgetHandler) { |
| 1061 | FX_BOOL bRet = TRUE; |
thestig | 1cd352e | 2016-06-07 17:53:06 -0700 | [diff] [blame] | 1062 | CXFA_FFWidget* hWidget = pNewAnnot ? pNewAnnot->GetXFAWidget() : nullptr; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1063 | if (hWidget) { |
dsinclair | 221caf6 | 2016-04-04 12:08:40 -0700 | [diff] [blame] | 1064 | CXFA_FFPageView* pXFAPageView = hWidget->GetPageView(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1065 | if (pXFAPageView) { |
| 1066 | bRet = pXFAPageView->GetDocView()->SetFocus(hWidget); |
| 1067 | if (pXFAPageView->GetDocView()->GetFocusWidget() == hWidget) |
| 1068 | bRet = TRUE; |
| 1069 | } |
Tom Sepez | dcbc02f | 2015-07-17 09:16:17 -0700 | [diff] [blame] | 1070 | } |
Tom Sepez | dcbc02f | 2015-07-17 09:16:17 -0700 | [diff] [blame] | 1071 | return bRet; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1072 | } |
| 1073 | |
| 1074 | return TRUE; |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 1075 | } |
| 1076 | |
dsinclair | df4bc59 | 2016-03-31 20:34:43 -0700 | [diff] [blame] | 1077 | CXFA_FFWidgetHandler* CPDFSDK_XFAAnnotHandler::GetXFAWidgetHandler( |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1078 | CPDFSDK_Annot* pAnnot) { |
| 1079 | if (!pAnnot) |
thestig | 1cd352e | 2016-06-07 17:53:06 -0700 | [diff] [blame] | 1080 | return nullptr; |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 1081 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1082 | CPDFSDK_PageView* pPageView = pAnnot->GetPageView(); |
| 1083 | if (!pPageView) |
thestig | 1cd352e | 2016-06-07 17:53:06 -0700 | [diff] [blame] | 1084 | return nullptr; |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 1085 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1086 | CPDFSDK_Document* pSDKDoc = pPageView->GetSDKDocument(); |
| 1087 | if (!pSDKDoc) |
thestig | 1cd352e | 2016-06-07 17:53:06 -0700 | [diff] [blame] | 1088 | return nullptr; |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 1089 | |
Tom Sepez | 50d12ad | 2015-11-24 09:50:51 -0800 | [diff] [blame] | 1090 | CPDFXFA_Document* pDoc = pSDKDoc->GetXFADocument(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1091 | if (!pDoc) |
thestig | 1cd352e | 2016-06-07 17:53:06 -0700 | [diff] [blame] | 1092 | return nullptr; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1093 | |
dsinclair | df4bc59 | 2016-03-31 20:34:43 -0700 | [diff] [blame] | 1094 | CXFA_FFDocView* pDocView = pDoc->GetXFADocView(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1095 | if (!pDocView) |
thestig | 1cd352e | 2016-06-07 17:53:06 -0700 | [diff] [blame] | 1096 | return nullptr; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1097 | |
| 1098 | return pDocView->GetWidgetHandler(); |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 1099 | } |
| 1100 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1101 | #define FWL_KEYFLAG_Ctrl (1 << 0) |
| 1102 | #define FWL_KEYFLAG_Alt (1 << 1) |
| 1103 | #define FWL_KEYFLAG_Shift (1 << 2) |
| 1104 | #define FWL_KEYFLAG_LButton (1 << 3) |
| 1105 | #define FWL_KEYFLAG_RButton (1 << 4) |
| 1106 | #define FWL_KEYFLAG_MButton (1 << 5) |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 1107 | |
tsepez | c3255f5 | 2016-03-25 14:52:27 -0700 | [diff] [blame] | 1108 | uint32_t CPDFSDK_XFAAnnotHandler::GetFWLFlags(uint32_t dwFlag) { |
| 1109 | uint32_t dwFWLFlag = 0; |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 1110 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1111 | if (dwFlag & FWL_EVENTFLAG_ControlKey) |
| 1112 | dwFWLFlag |= FWL_KEYFLAG_Ctrl; |
| 1113 | if (dwFlag & FWL_EVENTFLAG_LeftButtonDown) |
| 1114 | dwFWLFlag |= FWL_KEYFLAG_LButton; |
| 1115 | if (dwFlag & FWL_EVENTFLAG_MiddleButtonDown) |
| 1116 | dwFWLFlag |= FWL_KEYFLAG_MButton; |
| 1117 | if (dwFlag & FWL_EVENTFLAG_RightButtonDown) |
| 1118 | dwFWLFlag |= FWL_KEYFLAG_RButton; |
| 1119 | if (dwFlag & FWL_EVENTFLAG_ShiftKey) |
| 1120 | dwFWLFlag |= FWL_KEYFLAG_Shift; |
| 1121 | if (dwFlag & FWL_EVENTFLAG_AltKey) |
| 1122 | dwFWLFlag |= FWL_KEYFLAG_Alt; |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 1123 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1124 | return dwFWLFlag; |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 1125 | } |
Tom Sepez | 40e9ff3 | 2015-11-30 12:39:54 -0800 | [diff] [blame] | 1126 | #endif // PDF_ENABLE_XFA |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 1127 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1128 | CPDFSDK_AnnotIterator::CPDFSDK_AnnotIterator(CPDFSDK_PageView* pPageView, |
Lei Zhang | bf60b29 | 2015-10-26 12:14:35 -0700 | [diff] [blame] | 1129 | bool bReverse) |
| 1130 | : m_bReverse(bReverse), m_pos(0) { |
| 1131 | const std::vector<CPDFSDK_Annot*>& annots = pPageView->GetAnnotList(); |
| 1132 | m_iteratorAnnotList.insert(m_iteratorAnnotList.begin(), annots.rbegin(), |
| 1133 | annots.rend()); |
| 1134 | std::stable_sort(m_iteratorAnnotList.begin(), m_iteratorAnnotList.end(), |
| 1135 | [](CPDFSDK_Annot* p1, CPDFSDK_Annot* p2) { |
| 1136 | return p1->GetLayoutOrder() < p2->GetLayoutOrder(); |
| 1137 | }); |
Bo Xu | fdc00a7 | 2014-10-28 23:03:33 -0700 | [diff] [blame] | 1138 | |
Lei Zhang | bf60b29 | 2015-10-26 12:14:35 -0700 | [diff] [blame] | 1139 | CPDFSDK_Annot* pTopMostAnnot = pPageView->GetFocusAnnot(); |
| 1140 | if (!pTopMostAnnot) |
| 1141 | return; |
Lei Zhang | 60f507b | 2015-06-13 00:41:00 -0700 | [diff] [blame] | 1142 | |
Lei Zhang | bf60b29 | 2015-10-26 12:14:35 -0700 | [diff] [blame] | 1143 | auto it = std::find(m_iteratorAnnotList.begin(), m_iteratorAnnotList.end(), |
| 1144 | pTopMostAnnot); |
| 1145 | if (it != m_iteratorAnnotList.end()) { |
| 1146 | CPDFSDK_Annot* pReaderAnnot = *it; |
| 1147 | m_iteratorAnnotList.erase(it); |
| 1148 | m_iteratorAnnotList.insert(m_iteratorAnnotList.begin(), pReaderAnnot); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1149 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1150 | } |
| 1151 | |
Dan Sinclair | f766ad2 | 2016-03-14 13:51:24 -0400 | [diff] [blame] | 1152 | CPDFSDK_AnnotIterator::~CPDFSDK_AnnotIterator() {} |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1153 | |
Lei Zhang | bf60b29 | 2015-10-26 12:14:35 -0700 | [diff] [blame] | 1154 | CPDFSDK_Annot* CPDFSDK_AnnotIterator::NextAnnot() { |
| 1155 | if (m_pos < m_iteratorAnnotList.size()) |
| 1156 | return m_iteratorAnnotList[m_pos++]; |
| 1157 | return nullptr; |
| 1158 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1159 | |
Lei Zhang | bf60b29 | 2015-10-26 12:14:35 -0700 | [diff] [blame] | 1160 | CPDFSDK_Annot* CPDFSDK_AnnotIterator::PrevAnnot() { |
| 1161 | if (m_pos < m_iteratorAnnotList.size()) |
| 1162 | return m_iteratorAnnotList[m_iteratorAnnotList.size() - ++m_pos]; |
| 1163 | return nullptr; |
| 1164 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1165 | |
Lei Zhang | bf60b29 | 2015-10-26 12:14:35 -0700 | [diff] [blame] | 1166 | CPDFSDK_Annot* CPDFSDK_AnnotIterator::Next() { |
| 1167 | return m_bReverse ? PrevAnnot() : NextAnnot(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1168 | } |