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