OLD | NEW |
---|---|
1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "fpdfsdk/include/cpdfsdk_annothandlermgr.h" | 7 #include "fpdfsdk/include/cpdfsdk_annothandlermgr.h" |
8 | 8 |
9 #include "core/fpdfdoc/include/cpdf_annot.h" | 9 #include "core/fpdfdoc/include/cpdf_annot.h" |
10 #include "fpdfsdk/include/cba_annotiterator.h" | 10 #include "fpdfsdk/include/cba_annotiterator.h" |
11 #include "fpdfsdk/include/cpdfsdk_annot.h" | 11 #include "fpdfsdk/include/cpdfsdk_annot.h" |
12 #include "fpdfsdk/include/cpdfsdk_baannot.h" | 12 #include "fpdfsdk/include/cpdfsdk_baannot.h" |
13 #include "fpdfsdk/include/cpdfsdk_baannothandler.h" | |
13 #include "fpdfsdk/include/cpdfsdk_bfannothandler.h" | 14 #include "fpdfsdk/include/cpdfsdk_bfannothandler.h" |
14 #include "fpdfsdk/include/cpdfsdk_datetime.h" | 15 #include "fpdfsdk/include/cpdfsdk_datetime.h" |
15 #include "fpdfsdk/include/fsdk_mgr.h" | 16 #include "fpdfsdk/include/fsdk_mgr.h" |
16 | 17 |
17 #ifdef PDF_ENABLE_XFA | 18 #ifdef PDF_ENABLE_XFA |
18 #include "fpdfsdk/include/cpdfsdk_xfaannothandler.h" | 19 #include "fpdfsdk/include/cpdfsdk_xfaannothandler.h" |
19 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_page.h" | 20 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_page.h" |
20 #include "xfa/fxfa/include/xfa_ffpageview.h" | 21 #include "xfa/fxfa/include/xfa_ffpageview.h" |
21 #include "xfa/fxfa/include/xfa_ffwidget.h" | 22 #include "xfa/fxfa/include/xfa_ffwidget.h" |
22 #endif // PDF_ENABLE_XFA | 23 #endif // PDF_ENABLE_XFA |
23 | 24 |
24 CPDFSDK_AnnotHandlerMgr::CPDFSDK_AnnotHandlerMgr(CPDFDoc_Environment* pApp) { | 25 CPDFSDK_AnnotHandlerMgr::CPDFSDK_AnnotHandlerMgr(CPDFDoc_Environment* pApp) |
25 m_pApp = pApp; | 26 : m_pApp(pApp), |
26 | 27 m_pBFAnnotHandler(new CPDFSDK_BFAnnotHandler(pApp)), |
27 CPDFSDK_BFAnnotHandler* pHandler = new CPDFSDK_BFAnnotHandler(m_pApp); | |
28 pHandler->SetFormFiller(m_pApp->GetIFormFiller()); | |
29 RegisterAnnotHandler(pHandler); | |
30 #ifdef PDF_ENABLE_XFA | 28 #ifdef PDF_ENABLE_XFA |
31 CPDFSDK_XFAAnnotHandler* pXFAAnnotHandler = | 29 m_pXFAAnnotHandler(new CPDFSDK_XFAAnnotHandler(pApp)), |
32 new CPDFSDK_XFAAnnotHandler(m_pApp); | |
33 RegisterAnnotHandler(pXFAAnnotHandler); | |
34 #endif // PDF_ENABLE_XFA | 30 #endif // PDF_ENABLE_XFA |
31 m_pBAAnnotHandler(new CPDFSDK_BAAnnotHandler()) { | |
32 m_pBFAnnotHandler->SetFormFiller(m_pApp->GetIFormFiller()); | |
35 } | 33 } |
36 | 34 |
37 CPDFSDK_AnnotHandlerMgr::~CPDFSDK_AnnotHandlerMgr() {} | 35 CPDFSDK_AnnotHandlerMgr::~CPDFSDK_AnnotHandlerMgr() {} |
38 | 36 |
39 void CPDFSDK_AnnotHandlerMgr::RegisterAnnotHandler( | |
40 IPDFSDK_AnnotHandler* pAnnotHandler) { | |
41 ASSERT(!GetAnnotHandler(pAnnotHandler->GetType())); | |
42 | |
43 m_mapType2Handler[pAnnotHandler->GetType()].reset(pAnnotHandler); | |
44 } | |
45 | |
46 void CPDFSDK_AnnotHandlerMgr::UnRegisterAnnotHandler( | |
47 IPDFSDK_AnnotHandler* pAnnotHandler) { | |
48 m_mapType2Handler.erase(pAnnotHandler->GetType()); | |
49 } | |
50 | |
51 CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::NewAnnot(CPDF_Annot* pAnnot, | 37 CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::NewAnnot(CPDF_Annot* pAnnot, |
52 CPDFSDK_PageView* pPageView) { | 38 CPDFSDK_PageView* pPageView) { |
53 ASSERT(pPageView); | 39 ASSERT(pPageView); |
54 | 40 return GetAnnotHandler(pAnnot->GetSubType())->NewAnnot(pAnnot, pPageView); |
55 if (IPDFSDK_AnnotHandler* pAnnotHandler = | |
56 GetAnnotHandler(pAnnot->GetSubType())) { | |
57 return pAnnotHandler->NewAnnot(pAnnot, pPageView); | |
58 } | |
59 | |
60 return new CPDFSDK_BAAnnot(pAnnot, pPageView); | |
61 } | 41 } |
62 | 42 |
63 #ifdef PDF_ENABLE_XFA | 43 #ifdef PDF_ENABLE_XFA |
64 CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::NewAnnot(CXFA_FFWidget* pAnnot, | 44 CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::NewAnnot(CXFA_FFWidget* pAnnot, |
65 CPDFSDK_PageView* pPageView) { | 45 CPDFSDK_PageView* pPageView) { |
66 ASSERT(pAnnot); | 46 ASSERT(pAnnot); |
67 ASSERT(pPageView); | 47 ASSERT(pPageView); |
68 | 48 |
69 if (IPDFSDK_AnnotHandler* pAnnotHandler = | 49 return GetAnnotHandler(FSDK_XFAWIDGET_TYPENAME)->NewAnnot(pAnnot, pPageView); |
70 GetAnnotHandler(FSDK_XFAWIDGET_TYPENAME)) { | |
71 return pAnnotHandler->NewAnnot(pAnnot, pPageView); | |
72 } | |
73 | |
74 return nullptr; | |
75 } | 50 } |
76 #endif // PDF_ENABLE_XFA | 51 #endif // PDF_ENABLE_XFA |
77 | 52 |
78 void CPDFSDK_AnnotHandlerMgr::ReleaseAnnot(CPDFSDK_Annot* pAnnot) { | 53 void CPDFSDK_AnnotHandlerMgr::ReleaseAnnot(CPDFSDK_Annot* pAnnot) { |
79 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) { | 54 IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot); |
dsinclair
2016/08/24 14:00:20
So, previously if we didnt' find the annotation ha
jaepark
2016/08/24 18:37:49
In BAAnnotHandler, it does the same thing as befor
| |
80 pAnnotHandler->OnRelease(pAnnot); | 55 pAnnotHandler->OnRelease(pAnnot); |
81 pAnnotHandler->ReleaseAnnot(pAnnot); | 56 pAnnotHandler->ReleaseAnnot(pAnnot); |
82 } else { | |
83 delete pAnnot; | |
84 } | |
85 } | 57 } |
86 | 58 |
87 void CPDFSDK_AnnotHandlerMgr::Annot_OnCreate(CPDFSDK_Annot* pAnnot) { | 59 void CPDFSDK_AnnotHandlerMgr::Annot_OnCreate(CPDFSDK_Annot* pAnnot) { |
88 CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot(); | 60 CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot(); |
89 | 61 |
90 CPDFSDK_DateTime curTime; | 62 CPDFSDK_DateTime curTime; |
91 pPDFAnnot->GetAnnotDict()->SetAtString("M", curTime.ToPDFDateTimeString()); | 63 pPDFAnnot->GetAnnotDict()->SetAtString("M", curTime.ToPDFDateTimeString()); |
92 pPDFAnnot->GetAnnotDict()->SetAtNumber("F", 0); | 64 pPDFAnnot->GetAnnotDict()->SetAtNumber("F", 0); |
93 | 65 |
94 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) | 66 GetAnnotHandler(pAnnot)->OnCreate(pAnnot); |
95 pAnnotHandler->OnCreate(pAnnot); | |
96 } | 67 } |
97 | 68 |
98 void CPDFSDK_AnnotHandlerMgr::Annot_OnLoad(CPDFSDK_Annot* pAnnot) { | 69 void CPDFSDK_AnnotHandlerMgr::Annot_OnLoad(CPDFSDK_Annot* pAnnot) { |
99 ASSERT(pAnnot); | 70 ASSERT(pAnnot); |
100 | 71 GetAnnotHandler(pAnnot)->OnLoad(pAnnot); |
101 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) | |
102 pAnnotHandler->OnLoad(pAnnot); | |
103 } | 72 } |
104 | 73 |
105 IPDFSDK_AnnotHandler* CPDFSDK_AnnotHandlerMgr::GetAnnotHandler( | 74 IPDFSDK_AnnotHandler* CPDFSDK_AnnotHandlerMgr::GetAnnotHandler( |
106 CPDFSDK_Annot* pAnnot) const { | 75 CPDFSDK_Annot* pAnnot) const { |
107 CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot(); | 76 return GetAnnotHandler(pAnnot->GetType()); |
108 if (pPDFAnnot) | |
109 return GetAnnotHandler(pPDFAnnot->GetSubType()); | |
dsinclair
2016/08/24 14:00:20
This used to operate on the internal annotation an
jaepark
2016/08/24 18:37:49
The logic of GetAnnotHandler is the same.
CPDFSDK_
| |
110 #ifdef PDF_ENABLE_XFA | |
111 if (pAnnot->GetXFAWidget()) | |
112 return GetAnnotHandler(FSDK_XFAWIDGET_TYPENAME); | |
113 #endif // PDF_ENABLE_XFA | |
114 return nullptr; | |
115 } | 77 } |
116 | 78 |
117 IPDFSDK_AnnotHandler* CPDFSDK_AnnotHandlerMgr::GetAnnotHandler( | 79 IPDFSDK_AnnotHandler* CPDFSDK_AnnotHandlerMgr::GetAnnotHandler( |
118 const CFX_ByteString& sType) const { | 80 const CFX_ByteString& sType) const { |
119 auto it = m_mapType2Handler.find(sType); | 81 if (sType == "Widget") |
120 return it != m_mapType2Handler.end() ? it->second.get() : nullptr; | 82 return m_pBFAnnotHandler.get(); |
83 | |
84 #ifdef PDF_ENABLE_XFA | |
85 if (sType == FSDK_XFAWIDGET_TYPENAME) | |
86 return m_pXFAAnnotHandler.get(); | |
87 #endif // PDF_ENABLE_XFA | |
88 | |
89 return m_pBAAnnotHandler.get(); | |
121 } | 90 } |
122 | 91 |
123 void CPDFSDK_AnnotHandlerMgr::Annot_OnDraw(CPDFSDK_PageView* pPageView, | 92 void CPDFSDK_AnnotHandlerMgr::Annot_OnDraw(CPDFSDK_PageView* pPageView, |
124 CPDFSDK_Annot* pAnnot, | 93 CPDFSDK_Annot* pAnnot, |
125 CFX_RenderDevice* pDevice, | 94 CFX_RenderDevice* pDevice, |
126 CFX_Matrix* pUser2Device, | 95 CFX_Matrix* pUser2Device, |
127 uint32_t dwFlags) { | 96 uint32_t dwFlags) { |
128 ASSERT(pAnnot); | 97 ASSERT(pAnnot); |
129 | 98 GetAnnotHandler(pAnnot)->OnDraw(pPageView, pAnnot, pDevice, pUser2Device, |
130 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) { | 99 dwFlags); |
131 pAnnotHandler->OnDraw(pPageView, pAnnot, pDevice, pUser2Device, dwFlags); | |
132 } else { | |
133 #ifdef PDF_ENABLE_XFA | |
134 if (pAnnot->IsXFAField()) | |
dsinclair
2016/08/24 14:00:20
We no longer need to bail early on XFA fields?
jaepark
2016/08/24 18:37:49
We handle this in BAAnnotHandler.
| |
135 return; | |
136 #endif // PDF_ENABLE_XFA | |
137 static_cast<CPDFSDK_BAAnnot*>(pAnnot)->DrawAppearance( | |
138 pDevice, pUser2Device, CPDF_Annot::Normal, nullptr); | |
139 } | |
140 } | 100 } |
141 | 101 |
142 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnLButtonDown( | 102 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnLButtonDown( |
143 CPDFSDK_PageView* pPageView, | 103 CPDFSDK_PageView* pPageView, |
144 CPDFSDK_Annot* pAnnot, | 104 CPDFSDK_Annot* pAnnot, |
145 uint32_t nFlags, | 105 uint32_t nFlags, |
146 const CFX_FloatPoint& point) { | 106 const CFX_FloatPoint& point) { |
147 ASSERT(pAnnot); | 107 ASSERT(pAnnot); |
148 | 108 return GetAnnotHandler(pAnnot)->OnLButtonDown(pPageView, pAnnot, nFlags, |
149 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) | 109 point); |
150 return pAnnotHandler->OnLButtonDown(pPageView, pAnnot, nFlags, point); | |
151 | |
152 return FALSE; | |
153 } | 110 } |
154 | 111 |
155 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnLButtonUp( | 112 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnLButtonUp( |
156 CPDFSDK_PageView* pPageView, | 113 CPDFSDK_PageView* pPageView, |
157 CPDFSDK_Annot* pAnnot, | 114 CPDFSDK_Annot* pAnnot, |
158 uint32_t nFlags, | 115 uint32_t nFlags, |
159 const CFX_FloatPoint& point) { | 116 const CFX_FloatPoint& point) { |
160 ASSERT(pAnnot); | 117 ASSERT(pAnnot); |
161 | 118 return GetAnnotHandler(pAnnot)->OnLButtonUp(pPageView, pAnnot, nFlags, point); |
162 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) | |
163 return pAnnotHandler->OnLButtonUp(pPageView, pAnnot, nFlags, point); | |
164 | |
165 return FALSE; | |
166 } | 119 } |
167 | 120 |
168 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnLButtonDblClk( | 121 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnLButtonDblClk( |
169 CPDFSDK_PageView* pPageView, | 122 CPDFSDK_PageView* pPageView, |
170 CPDFSDK_Annot* pAnnot, | 123 CPDFSDK_Annot* pAnnot, |
171 uint32_t nFlags, | 124 uint32_t nFlags, |
172 const CFX_FloatPoint& point) { | 125 const CFX_FloatPoint& point) { |
173 ASSERT(pAnnot); | 126 ASSERT(pAnnot); |
174 | 127 return GetAnnotHandler(pAnnot)->OnLButtonDblClk(pPageView, pAnnot, nFlags, |
175 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) | 128 point); |
176 return pAnnotHandler->OnLButtonDblClk(pPageView, pAnnot, nFlags, point); | |
177 | |
178 return FALSE; | |
179 } | 129 } |
180 | 130 |
181 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnMouseMove( | 131 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnMouseMove( |
182 CPDFSDK_PageView* pPageView, | 132 CPDFSDK_PageView* pPageView, |
183 CPDFSDK_Annot* pAnnot, | 133 CPDFSDK_Annot* pAnnot, |
184 uint32_t nFlags, | 134 uint32_t nFlags, |
185 const CFX_FloatPoint& point) { | 135 const CFX_FloatPoint& point) { |
186 ASSERT(pAnnot); | 136 ASSERT(pAnnot); |
187 | 137 return GetAnnotHandler(pAnnot)->OnMouseMove(pPageView, pAnnot, nFlags, point); |
188 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) | |
189 return pAnnotHandler->OnMouseMove(pPageView, pAnnot, nFlags, point); | |
190 | |
191 return FALSE; | |
192 } | 138 } |
193 | 139 |
194 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnMouseWheel( | 140 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnMouseWheel( |
195 CPDFSDK_PageView* pPageView, | 141 CPDFSDK_PageView* pPageView, |
196 CPDFSDK_Annot* pAnnot, | 142 CPDFSDK_Annot* pAnnot, |
197 uint32_t nFlags, | 143 uint32_t nFlags, |
198 short zDelta, | 144 short zDelta, |
199 const CFX_FloatPoint& point) { | 145 const CFX_FloatPoint& point) { |
200 ASSERT(pAnnot); | 146 ASSERT(pAnnot); |
201 | 147 return GetAnnotHandler(pAnnot)->OnMouseWheel(pPageView, pAnnot, nFlags, |
202 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) { | 148 zDelta, point); |
203 return pAnnotHandler->OnMouseWheel(pPageView, pAnnot, nFlags, zDelta, | |
204 point); | |
205 } | |
206 return FALSE; | |
207 } | 149 } |
208 | 150 |
209 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnRButtonDown( | 151 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnRButtonDown( |
210 CPDFSDK_PageView* pPageView, | 152 CPDFSDK_PageView* pPageView, |
211 CPDFSDK_Annot* pAnnot, | 153 CPDFSDK_Annot* pAnnot, |
212 uint32_t nFlags, | 154 uint32_t nFlags, |
213 const CFX_FloatPoint& point) { | 155 const CFX_FloatPoint& point) { |
214 ASSERT(pAnnot); | 156 ASSERT(pAnnot); |
215 | 157 return GetAnnotHandler(pAnnot)->OnRButtonDown(pPageView, pAnnot, nFlags, |
216 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) | 158 point); |
217 return pAnnotHandler->OnRButtonDown(pPageView, pAnnot, nFlags, point); | |
218 | |
219 return FALSE; | |
220 } | 159 } |
221 | 160 |
222 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnRButtonUp( | 161 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnRButtonUp( |
223 CPDFSDK_PageView* pPageView, | 162 CPDFSDK_PageView* pPageView, |
224 CPDFSDK_Annot* pAnnot, | 163 CPDFSDK_Annot* pAnnot, |
225 uint32_t nFlags, | 164 uint32_t nFlags, |
226 const CFX_FloatPoint& point) { | 165 const CFX_FloatPoint& point) { |
227 ASSERT(pAnnot); | 166 ASSERT(pAnnot); |
228 | 167 return GetAnnotHandler(pAnnot)->OnRButtonUp(pPageView, pAnnot, nFlags, point); |
229 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) | |
230 return pAnnotHandler->OnRButtonUp(pPageView, pAnnot, nFlags, point); | |
231 | |
232 return FALSE; | |
233 } | 168 } |
234 | 169 |
235 void CPDFSDK_AnnotHandlerMgr::Annot_OnMouseEnter(CPDFSDK_PageView* pPageView, | 170 void CPDFSDK_AnnotHandlerMgr::Annot_OnMouseEnter(CPDFSDK_PageView* pPageView, |
236 CPDFSDK_Annot* pAnnot, | 171 CPDFSDK_Annot* pAnnot, |
237 uint32_t nFlag) { | 172 uint32_t nFlag) { |
238 ASSERT(pAnnot); | 173 ASSERT(pAnnot); |
239 | 174 GetAnnotHandler(pAnnot)->OnMouseEnter(pPageView, pAnnot, nFlag); |
240 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) | |
241 pAnnotHandler->OnMouseEnter(pPageView, pAnnot, nFlag); | |
242 } | 175 } |
243 | 176 |
244 void CPDFSDK_AnnotHandlerMgr::Annot_OnMouseExit(CPDFSDK_PageView* pPageView, | 177 void CPDFSDK_AnnotHandlerMgr::Annot_OnMouseExit(CPDFSDK_PageView* pPageView, |
245 CPDFSDK_Annot* pAnnot, | 178 CPDFSDK_Annot* pAnnot, |
246 uint32_t nFlag) { | 179 uint32_t nFlag) { |
247 ASSERT(pAnnot); | 180 ASSERT(pAnnot); |
248 | 181 GetAnnotHandler(pAnnot)->OnMouseExit(pPageView, pAnnot, nFlag); |
249 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) | |
250 pAnnotHandler->OnMouseExit(pPageView, pAnnot, nFlag); | |
251 } | 182 } |
252 | 183 |
253 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnChar(CPDFSDK_Annot* pAnnot, | 184 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnChar(CPDFSDK_Annot* pAnnot, |
254 uint32_t nChar, | 185 uint32_t nChar, |
255 uint32_t nFlags) { | 186 uint32_t nFlags) { |
256 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) | 187 return GetAnnotHandler(pAnnot)->OnChar(pAnnot, nChar, nFlags); |
257 return pAnnotHandler->OnChar(pAnnot, nChar, nFlags); | |
258 | |
259 return FALSE; | |
260 } | 188 } |
261 | 189 |
262 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnKeyDown(CPDFSDK_Annot* pAnnot, | 190 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnKeyDown(CPDFSDK_Annot* pAnnot, |
263 int nKeyCode, | 191 int nKeyCode, |
264 int nFlag) { | 192 int nFlag) { |
265 if (!m_pApp->FFI_IsCTRLKeyDown(nFlag) && !m_pApp->FFI_IsALTKeyDown(nFlag)) { | 193 if (m_pApp->FFI_IsCTRLKeyDown(nFlag) || m_pApp->FFI_IsALTKeyDown(nFlag)) |
266 CPDFSDK_PageView* pPage = pAnnot->GetPageView(); | 194 return GetAnnotHandler(pAnnot)->OnKeyDown(pAnnot, nKeyCode, nFlag); |
267 CPDFSDK_Annot* pFocusAnnot = pPage->GetFocusAnnot(); | |
268 if (pFocusAnnot && (nKeyCode == FWL_VKEY_Tab)) { | |
269 CPDFSDK_Annot* pNext = | |
270 GetNextAnnot(pFocusAnnot, !m_pApp->FFI_IsSHIFTKeyDown(nFlag)); | |
271 | 195 |
272 if (pNext && pNext != pFocusAnnot) { | 196 CPDFSDK_PageView* pPage = pAnnot->GetPageView(); |
273 CPDFSDK_Document* pDocument = pPage->GetSDKDocument(); | 197 CPDFSDK_Annot* pFocusAnnot = pPage->GetFocusAnnot(); |
274 pDocument->SetFocusAnnot(pNext); | 198 if (pFocusAnnot && (nKeyCode == FWL_VKEY_Tab)) { |
275 return TRUE; | 199 CPDFSDK_Annot* pNext = |
276 } | 200 GetNextAnnot(pFocusAnnot, !m_pApp->FFI_IsSHIFTKeyDown(nFlag)); |
201 | |
202 if (pNext && pNext != pFocusAnnot) { | |
203 CPDFSDK_Document* pDocument = pPage->GetSDKDocument(); | |
204 pDocument->SetFocusAnnot(pNext); | |
205 return TRUE; | |
277 } | 206 } |
278 } | 207 } |
279 | 208 |
280 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) | |
281 return pAnnotHandler->OnKeyDown(pAnnot, nKeyCode, nFlag); | |
282 | |
283 return FALSE; | 209 return FALSE; |
284 } | 210 } |
285 | 211 |
286 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnKeyUp(CPDFSDK_Annot* pAnnot, | 212 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnKeyUp(CPDFSDK_Annot* pAnnot, |
287 int nKeyCode, | 213 int nKeyCode, |
288 int nFlag) { | 214 int nFlag) { |
289 return FALSE; | 215 return FALSE; |
290 } | 216 } |
291 | 217 |
292 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnSetFocus(CPDFSDK_Annot* pAnnot, | 218 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnSetFocus(CPDFSDK_Annot* pAnnot, |
293 uint32_t nFlag) { | 219 uint32_t nFlag) { |
294 ASSERT(pAnnot); | 220 ASSERT(pAnnot); |
295 | 221 |
296 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) { | 222 if (!GetAnnotHandler(pAnnot)->OnSetFocus(pAnnot, nFlag)) |
297 if (pAnnotHandler->OnSetFocus(pAnnot, nFlag)) { | 223 return FALSE; |
298 CPDFSDK_PageView* pPage = pAnnot->GetPageView(); | 224 |
299 pPage->GetSDKDocument(); | 225 CPDFSDK_PageView* pPage = pAnnot->GetPageView(); |
300 return TRUE; | 226 pPage->GetSDKDocument(); |
301 } | 227 return TRUE; |
302 } | |
303 return FALSE; | |
304 } | 228 } |
305 | 229 |
306 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnKillFocus(CPDFSDK_Annot* pAnnot, | 230 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnKillFocus(CPDFSDK_Annot* pAnnot, |
307 uint32_t nFlag) { | 231 uint32_t nFlag) { |
308 ASSERT(pAnnot); | 232 ASSERT(pAnnot); |
309 | 233 return GetAnnotHandler(pAnnot)->OnKillFocus(pAnnot, nFlag); |
310 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) | |
311 return pAnnotHandler->OnKillFocus(pAnnot, nFlag); | |
312 | |
313 return FALSE; | |
314 } | 234 } |
315 | 235 |
316 #ifdef PDF_ENABLE_XFA | 236 #ifdef PDF_ENABLE_XFA |
317 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnChangeFocus( | 237 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnChangeFocus( |
318 CPDFSDK_Annot* pSetAnnot, | 238 CPDFSDK_Annot* pSetAnnot, |
319 CPDFSDK_Annot* pKillAnnot) { | 239 CPDFSDK_Annot* pKillAnnot) { |
320 FX_BOOL bXFA = (pSetAnnot && pSetAnnot->GetXFAWidget()) || | 240 FX_BOOL bXFA = (pSetAnnot && pSetAnnot->GetXFAWidget()) || |
321 (pKillAnnot && pKillAnnot->GetXFAWidget()); | 241 (pKillAnnot && pKillAnnot->GetXFAWidget()); |
322 | 242 |
323 if (bXFA) { | 243 if (bXFA) { |
324 if (IPDFSDK_AnnotHandler* pXFAAnnotHandler = | 244 if (IPDFSDK_AnnotHandler* pXFAAnnotHandler = |
325 GetAnnotHandler(FSDK_XFAWIDGET_TYPENAME)) | 245 GetAnnotHandler(FSDK_XFAWIDGET_TYPENAME)) |
326 return pXFAAnnotHandler->OnXFAChangedFocus(pKillAnnot, pSetAnnot); | 246 return pXFAAnnotHandler->OnXFAChangedFocus(pKillAnnot, pSetAnnot); |
327 } | 247 } |
328 | 248 |
329 return TRUE; | 249 return TRUE; |
330 } | 250 } |
331 #endif // PDF_ENABLE_XFA | 251 #endif // PDF_ENABLE_XFA |
332 | 252 |
333 CFX_FloatRect CPDFSDK_AnnotHandlerMgr::Annot_OnGetViewBBox( | 253 CFX_FloatRect CPDFSDK_AnnotHandlerMgr::Annot_OnGetViewBBox( |
334 CPDFSDK_PageView* pPageView, | 254 CPDFSDK_PageView* pPageView, |
335 CPDFSDK_Annot* pAnnot) { | 255 CPDFSDK_Annot* pAnnot) { |
336 ASSERT(pAnnot); | 256 ASSERT(pAnnot); |
337 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) | 257 return GetAnnotHandler(pAnnot)->GetViewBBox(pPageView, pAnnot); |
338 return pAnnotHandler->GetViewBBox(pPageView, pAnnot); | |
339 | |
340 return pAnnot->GetRect(); | |
341 } | 258 } |
342 | 259 |
343 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnHitTest(CPDFSDK_PageView* pPageView, | 260 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnHitTest(CPDFSDK_PageView* pPageView, |
344 CPDFSDK_Annot* pAnnot, | 261 CPDFSDK_Annot* pAnnot, |
345 const CFX_FloatPoint& point) { | 262 const CFX_FloatPoint& point) { |
346 ASSERT(pAnnot); | 263 ASSERT(pAnnot); |
347 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) { | 264 IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot); |
348 if (pAnnotHandler->CanAnswer(pAnnot)) | 265 if (pAnnotHandler->CanAnswer(pAnnot)) |
349 return pAnnotHandler->HitTest(pPageView, pAnnot, point); | 266 return pAnnotHandler->HitTest(pPageView, pAnnot, point); |
350 } | 267 |
351 return FALSE; | 268 return FALSE; |
352 } | 269 } |
353 | 270 |
354 CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::GetNextAnnot(CPDFSDK_Annot* pSDKAnnot, | 271 CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::GetNextAnnot(CPDFSDK_Annot* pSDKAnnot, |
355 FX_BOOL bNext) { | 272 FX_BOOL bNext) { |
356 #ifdef PDF_ENABLE_XFA | 273 #ifdef PDF_ENABLE_XFA |
357 CPDFSDK_PageView* pPageView = pSDKAnnot->GetPageView(); | 274 CPDFSDK_PageView* pPageView = pSDKAnnot->GetPageView(); |
358 CPDFXFA_Page* pPage = pPageView->GetPDFXFAPage(); | 275 CPDFXFA_Page* pPage = pPageView->GetPDFXFAPage(); |
359 if (!pPage) | 276 if (!pPage) |
360 return nullptr; | 277 return nullptr; |
(...skipping 17 matching lines...) Expand all Loading... | |
378 bNext ? pWidgetIterator->MoveToNext() : pWidgetIterator->MoveToPrevious(); | 295 bNext ? pWidgetIterator->MoveToNext() : pWidgetIterator->MoveToPrevious(); |
379 if (!hNextFocus && pSDKAnnot) | 296 if (!hNextFocus && pSDKAnnot) |
380 hNextFocus = pWidgetIterator->MoveToFirst(); | 297 hNextFocus = pWidgetIterator->MoveToFirst(); |
381 | 298 |
382 return pPageView->GetAnnotByXFAWidget(hNextFocus); | 299 return pPageView->GetAnnotByXFAWidget(hNextFocus); |
383 #else // PDF_ENABLE_XFA | 300 #else // PDF_ENABLE_XFA |
384 CBA_AnnotIterator ai(pSDKAnnot->GetPageView(), "Widget", ""); | 301 CBA_AnnotIterator ai(pSDKAnnot->GetPageView(), "Widget", ""); |
385 return bNext ? ai.GetNextAnnot(pSDKAnnot) : ai.GetPrevAnnot(pSDKAnnot); | 302 return bNext ? ai.GetNextAnnot(pSDKAnnot) : ai.GetPrevAnnot(pSDKAnnot); |
386 #endif // PDF_ENABLE_XFA | 303 #endif // PDF_ENABLE_XFA |
387 } | 304 } |
OLD | NEW |