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