OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "../include/fsdk_define.h" | 7 #include "../include/fsdk_define.h" |
8 #include "../include/fsdk_mgr.h" | 8 #include "../include/fsdk_mgr.h" |
9 #include "../include/formfiller/FFL_FormFiller.h" | 9 #include "../include/formfiller/FFL_FormFiller.h" |
10 #include "../include/fsdk_annothandler.h" | 10 #include "../include/fsdk_annothandler.h" |
11 | 11 |
12 CPDFSDK_AnnotHandlerMgr::CPDFSDK_AnnotHandlerMgr(CPDFDoc_Environment* pApp) { | 12 CPDFSDK_AnnotHandlerMgr::CPDFSDK_AnnotHandlerMgr(CPDFDoc_Environment* pApp) { |
13 m_pApp = pApp; | 13 m_pApp = pApp; |
14 | 14 |
15 CPDFSDK_AnnotHandler* pHandler = new CPDFSDK_AnnotHandler(m_pApp); | 15 CPDFSDK_BFAnnotHandler* pHandler = new CPDFSDK_BFAnnotHandler(m_pApp); |
16 pHandler->SetFormFiller(m_pApp->GetIFormFiller()); | 16 pHandler->SetFormFiller(m_pApp->GetIFormFiller()); |
17 RegisterAnnotHandler(pHandler); | 17 RegisterAnnotHandler(pHandler); |
18 } | 18 } |
19 | 19 |
20 CPDFSDK_AnnotHandlerMgr::~CPDFSDK_AnnotHandlerMgr() { | 20 CPDFSDK_AnnotHandlerMgr::~CPDFSDK_AnnotHandlerMgr() { |
21 for (int i = 0; i < m_Handlers.GetSize(); i++) { | 21 for (int i = 0; i < m_Handlers.GetSize(); i++) { |
22 CPDFSDK_AnnotHandler* pHandler = m_Handlers.GetAt(i); | 22 IPDFSDK_AnnotHandler* pHandler = m_Handlers.GetAt(i); |
23 delete pHandler; | 23 delete pHandler; |
24 } | 24 } |
25 m_Handlers.RemoveAll(); | 25 m_Handlers.RemoveAll(); |
26 m_mapType2Handler.clear(); | 26 m_mapType2Handler.clear(); |
27 } | 27 } |
28 | 28 |
29 void CPDFSDK_AnnotHandlerMgr::RegisterAnnotHandler( | 29 void CPDFSDK_AnnotHandlerMgr::RegisterAnnotHandler( |
30 CPDFSDK_AnnotHandler* pAnnotHandler) { | 30 IPDFSDK_AnnotHandler* pAnnotHandler) { |
31 ASSERT(!GetAnnotHandler(pAnnotHandler->GetType())); | 31 ASSERT(!GetAnnotHandler(pAnnotHandler->GetType())); |
32 | 32 |
33 m_Handlers.Add(pAnnotHandler); | 33 m_Handlers.Add(pAnnotHandler); |
34 m_mapType2Handler[pAnnotHandler->GetType()] = pAnnotHandler; | 34 m_mapType2Handler[pAnnotHandler->GetType()] = pAnnotHandler; |
35 } | 35 } |
36 | 36 |
37 void CPDFSDK_AnnotHandlerMgr::UnRegisterAnnotHandler( | 37 void CPDFSDK_AnnotHandlerMgr::UnRegisterAnnotHandler( |
38 CPDFSDK_AnnotHandler* pAnnotHandler) { | 38 IPDFSDK_AnnotHandler* pAnnotHandler) { |
39 m_mapType2Handler.erase(pAnnotHandler->GetType()); | 39 m_mapType2Handler.erase(pAnnotHandler->GetType()); |
40 for (int i = 0, sz = m_Handlers.GetSize(); i < sz; i++) { | 40 for (int i = 0, sz = m_Handlers.GetSize(); i < sz; i++) { |
41 if (m_Handlers.GetAt(i) == pAnnotHandler) { | 41 if (m_Handlers.GetAt(i) == pAnnotHandler) { |
42 m_Handlers.RemoveAt(i); | 42 m_Handlers.RemoveAt(i); |
43 break; | 43 break; |
44 } | 44 } |
45 } | 45 } |
46 } | 46 } |
47 | 47 |
48 CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::NewAnnot(CPDF_Annot* pAnnot, | 48 CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::NewAnnot(CPDF_Annot* pAnnot, |
49 CPDFSDK_PageView* pPageView) { | 49 CPDFSDK_PageView* pPageView) { |
50 ASSERT(pAnnot != NULL); | 50 ASSERT(pAnnot != NULL); |
51 ASSERT(pPageView != NULL); | 51 ASSERT(pPageView != NULL); |
52 | 52 |
53 if (CPDFSDK_AnnotHandler* pAnnotHandler = | 53 if (IPDFSDK_AnnotHandler* pAnnotHandler = |
54 GetAnnotHandler(pAnnot->GetSubType())) { | 54 GetAnnotHandler(pAnnot->GetSubType())) { |
55 return pAnnotHandler->NewAnnot(pAnnot, pPageView); | 55 return pAnnotHandler->NewAnnot(pAnnot, pPageView); |
56 } | 56 } |
57 | 57 |
58 return new CPDFSDK_Annot(pAnnot, pPageView); | 58 return new CPDFSDK_Annot(pAnnot, pPageView); |
59 } | 59 } |
60 | 60 |
61 void CPDFSDK_AnnotHandlerMgr::ReleaseAnnot(CPDFSDK_Annot* pAnnot) { | 61 void CPDFSDK_AnnotHandlerMgr::ReleaseAnnot(CPDFSDK_Annot* pAnnot) { |
62 ASSERT(pAnnot != NULL); | 62 ASSERT(pAnnot != NULL); |
63 | 63 |
64 pAnnot->GetPDFPage(); | 64 pAnnot->GetPDFPage(); |
65 | 65 |
66 if (CPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) { | 66 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) { |
67 pAnnotHandler->OnRelease(pAnnot); | 67 pAnnotHandler->OnRelease(pAnnot); |
68 pAnnotHandler->ReleaseAnnot(pAnnot); | 68 pAnnotHandler->ReleaseAnnot(pAnnot); |
69 } else { | 69 } else { |
70 delete (CPDFSDK_Annot*)pAnnot; | 70 delete (CPDFSDK_Annot*)pAnnot; |
71 } | 71 } |
72 } | 72 } |
73 | 73 |
74 void CPDFSDK_AnnotHandlerMgr::Annot_OnCreate(CPDFSDK_Annot* pAnnot) { | 74 void CPDFSDK_AnnotHandlerMgr::Annot_OnCreate(CPDFSDK_Annot* pAnnot) { |
75 ASSERT(pAnnot != NULL); | 75 ASSERT(pAnnot != NULL); |
76 | 76 |
77 CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot(); | 77 CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot(); |
78 | 78 |
79 CPDFSDK_DateTime curTime; | 79 CPDFSDK_DateTime curTime; |
80 pPDFAnnot->GetAnnotDict()->SetAtString("M", curTime.ToPDFDateTimeString()); | 80 pPDFAnnot->GetAnnotDict()->SetAtString("M", curTime.ToPDFDateTimeString()); |
81 pPDFAnnot->GetAnnotDict()->SetAtNumber("F", 0); | 81 pPDFAnnot->GetAnnotDict()->SetAtNumber("F", 0); |
82 | 82 |
83 if (CPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) { | 83 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) { |
84 pAnnotHandler->OnCreate(pAnnot); | 84 pAnnotHandler->OnCreate(pAnnot); |
85 } | 85 } |
86 } | 86 } |
87 | 87 |
88 void CPDFSDK_AnnotHandlerMgr::Annot_OnLoad(CPDFSDK_Annot* pAnnot) { | 88 void CPDFSDK_AnnotHandlerMgr::Annot_OnLoad(CPDFSDK_Annot* pAnnot) { |
89 ASSERT(pAnnot != NULL); | 89 ASSERT(pAnnot != NULL); |
90 | 90 |
91 if (CPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) { | 91 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) { |
92 pAnnotHandler->OnLoad(pAnnot); | 92 pAnnotHandler->OnLoad(pAnnot); |
93 } | 93 } |
94 } | 94 } |
95 | 95 |
96 CPDFSDK_AnnotHandler* CPDFSDK_AnnotHandlerMgr::GetAnnotHandler( | 96 IPDFSDK_AnnotHandler* CPDFSDK_AnnotHandlerMgr::GetAnnotHandler( |
97 CPDFSDK_Annot* pAnnot) const { | 97 CPDFSDK_Annot* pAnnot) const { |
98 ASSERT(pAnnot != NULL); | 98 ASSERT(pAnnot != NULL); |
99 | 99 |
100 CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot(); | 100 CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot(); |
101 ASSERT(pPDFAnnot != NULL); | 101 ASSERT(pPDFAnnot != NULL); |
102 | 102 |
103 return GetAnnotHandler(pPDFAnnot->GetSubType()); | 103 return GetAnnotHandler(pPDFAnnot->GetSubType()); |
104 } | 104 } |
105 | 105 |
106 CPDFSDK_AnnotHandler* CPDFSDK_AnnotHandlerMgr::GetAnnotHandler( | 106 IPDFSDK_AnnotHandler* CPDFSDK_AnnotHandlerMgr::GetAnnotHandler( |
107 const CFX_ByteString& sType) const { | 107 const CFX_ByteString& sType) const { |
108 auto it = m_mapType2Handler.find(sType); | 108 auto it = m_mapType2Handler.find(sType); |
109 return it != m_mapType2Handler.end() ? it->second : nullptr; | 109 return it != m_mapType2Handler.end() ? it->second : nullptr; |
110 } | 110 } |
111 | 111 |
112 void CPDFSDK_AnnotHandlerMgr::Annot_OnDraw(CPDFSDK_PageView* pPageView, | 112 void CPDFSDK_AnnotHandlerMgr::Annot_OnDraw(CPDFSDK_PageView* pPageView, |
113 CPDFSDK_Annot* pAnnot, | 113 CPDFSDK_Annot* pAnnot, |
114 CFX_RenderDevice* pDevice, | 114 CFX_RenderDevice* pDevice, |
115 CPDF_Matrix* pUser2Device, | 115 CPDF_Matrix* pUser2Device, |
116 FX_DWORD dwFlags) { | 116 FX_DWORD dwFlags) { |
117 ASSERT(pAnnot != NULL); | 117 ASSERT(pAnnot != NULL); |
118 | 118 |
119 if (CPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) { | 119 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) { |
120 pAnnotHandler->OnDraw(pPageView, pAnnot, pDevice, pUser2Device, dwFlags); | 120 pAnnotHandler->OnDraw(pPageView, pAnnot, pDevice, pUser2Device, dwFlags); |
121 } else { | 121 } else { |
122 pAnnot->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL); | 122 pAnnot->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL); |
123 } | 123 } |
124 } | 124 } |
125 | 125 |
126 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnLButtonDown( | 126 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnLButtonDown( |
127 CPDFSDK_PageView* pPageView, | 127 CPDFSDK_PageView* pPageView, |
128 CPDFSDK_Annot* pAnnot, | 128 CPDFSDK_Annot* pAnnot, |
129 FX_DWORD nFlags, | 129 FX_DWORD nFlags, |
130 const CPDF_Point& point) { | 130 const CPDF_Point& point) { |
131 ASSERT(pAnnot != NULL); | 131 ASSERT(pAnnot != NULL); |
132 | 132 |
133 if (CPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) { | 133 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) { |
134 return pAnnotHandler->OnLButtonDown(pPageView, pAnnot, nFlags, point); | 134 return pAnnotHandler->OnLButtonDown(pPageView, pAnnot, nFlags, point); |
135 } | 135 } |
136 return FALSE; | 136 return FALSE; |
137 } | 137 } |
138 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnLButtonUp(CPDFSDK_PageView* pPageView, | 138 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnLButtonUp(CPDFSDK_PageView* pPageView, |
139 CPDFSDK_Annot* pAnnot, | 139 CPDFSDK_Annot* pAnnot, |
140 FX_DWORD nFlags, | 140 FX_DWORD nFlags, |
141 const CPDF_Point& point) { | 141 const CPDF_Point& point) { |
142 ASSERT(pAnnot != NULL); | 142 ASSERT(pAnnot != NULL); |
143 | 143 |
144 if (CPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) { | 144 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) { |
145 return pAnnotHandler->OnLButtonUp(pPageView, pAnnot, nFlags, point); | 145 return pAnnotHandler->OnLButtonUp(pPageView, pAnnot, nFlags, point); |
146 } | 146 } |
147 return FALSE; | 147 return FALSE; |
148 } | 148 } |
149 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnLButtonDblClk( | 149 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnLButtonDblClk( |
150 CPDFSDK_PageView* pPageView, | 150 CPDFSDK_PageView* pPageView, |
151 CPDFSDK_Annot* pAnnot, | 151 CPDFSDK_Annot* pAnnot, |
152 FX_DWORD nFlags, | 152 FX_DWORD nFlags, |
153 const CPDF_Point& point) { | 153 const CPDF_Point& point) { |
154 ASSERT(pAnnot != NULL); | 154 ASSERT(pAnnot != NULL); |
155 | 155 |
156 if (CPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) { | 156 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) { |
157 return pAnnotHandler->OnLButtonDblClk(pPageView, pAnnot, nFlags, point); | 157 return pAnnotHandler->OnLButtonDblClk(pPageView, pAnnot, nFlags, point); |
158 } | 158 } |
159 return FALSE; | 159 return FALSE; |
160 } | 160 } |
161 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnMouseMove(CPDFSDK_PageView* pPageView, | 161 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnMouseMove(CPDFSDK_PageView* pPageView, |
162 CPDFSDK_Annot* pAnnot, | 162 CPDFSDK_Annot* pAnnot, |
163 FX_DWORD nFlags, | 163 FX_DWORD nFlags, |
164 const CPDF_Point& point) { | 164 const CPDF_Point& point) { |
165 ASSERT(pAnnot != NULL); | 165 ASSERT(pAnnot != NULL); |
166 | 166 |
167 if (CPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) { | 167 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) { |
168 return pAnnotHandler->OnMouseMove(pPageView, pAnnot, nFlags, point); | 168 return pAnnotHandler->OnMouseMove(pPageView, pAnnot, nFlags, point); |
169 } | 169 } |
170 return FALSE; | 170 return FALSE; |
171 } | 171 } |
172 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnMouseWheel(CPDFSDK_PageView* pPageView, | 172 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnMouseWheel(CPDFSDK_PageView* pPageView, |
173 CPDFSDK_Annot* pAnnot, | 173 CPDFSDK_Annot* pAnnot, |
174 FX_DWORD nFlags, | 174 FX_DWORD nFlags, |
175 short zDelta, | 175 short zDelta, |
176 const CPDF_Point& point) { | 176 const CPDF_Point& point) { |
177 ASSERT(pAnnot != NULL); | 177 ASSERT(pAnnot != NULL); |
178 | 178 |
179 if (CPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) { | 179 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) { |
180 return pAnnotHandler->OnMouseWheel(pPageView, pAnnot, nFlags, zDelta, | 180 return pAnnotHandler->OnMouseWheel(pPageView, pAnnot, nFlags, zDelta, |
181 point); | 181 point); |
182 } | 182 } |
183 return FALSE; | 183 return FALSE; |
184 } | 184 } |
185 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnRButtonDown( | 185 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnRButtonDown( |
186 CPDFSDK_PageView* pPageView, | 186 CPDFSDK_PageView* pPageView, |
187 CPDFSDK_Annot* pAnnot, | 187 CPDFSDK_Annot* pAnnot, |
188 FX_DWORD nFlags, | 188 FX_DWORD nFlags, |
189 const CPDF_Point& point) { | 189 const CPDF_Point& point) { |
190 ASSERT(pAnnot != NULL); | 190 ASSERT(pAnnot != NULL); |
191 | 191 |
192 if (CPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) { | 192 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) { |
193 return pAnnotHandler->OnRButtonDown(pPageView, pAnnot, nFlags, point); | 193 return pAnnotHandler->OnRButtonDown(pPageView, pAnnot, nFlags, point); |
194 } | 194 } |
195 return FALSE; | 195 return FALSE; |
196 } | 196 } |
197 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnRButtonUp(CPDFSDK_PageView* pPageView, | 197 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnRButtonUp(CPDFSDK_PageView* pPageView, |
198 CPDFSDK_Annot* pAnnot, | 198 CPDFSDK_Annot* pAnnot, |
199 FX_DWORD nFlags, | 199 FX_DWORD nFlags, |
200 const CPDF_Point& point) { | 200 const CPDF_Point& point) { |
201 ASSERT(pAnnot != NULL); | 201 ASSERT(pAnnot != NULL); |
202 | 202 |
203 if (CPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) { | 203 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) { |
204 return pAnnotHandler->OnRButtonUp(pPageView, pAnnot, nFlags, point); | 204 return pAnnotHandler->OnRButtonUp(pPageView, pAnnot, nFlags, point); |
205 } | 205 } |
206 return FALSE; | 206 return FALSE; |
207 } | 207 } |
208 | 208 |
209 void CPDFSDK_AnnotHandlerMgr::Annot_OnMouseEnter(CPDFSDK_PageView* pPageView, | 209 void CPDFSDK_AnnotHandlerMgr::Annot_OnMouseEnter(CPDFSDK_PageView* pPageView, |
210 CPDFSDK_Annot* pAnnot, | 210 CPDFSDK_Annot* pAnnot, |
211 FX_DWORD nFlag) { | 211 FX_DWORD nFlag) { |
212 ASSERT(pAnnot != NULL); | 212 ASSERT(pAnnot != NULL); |
213 | 213 |
214 if (CPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) { | 214 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) { |
215 pAnnotHandler->OnMouseEnter(pPageView, pAnnot, nFlag); | 215 pAnnotHandler->OnMouseEnter(pPageView, pAnnot, nFlag); |
216 } | 216 } |
217 return; | 217 return; |
218 } | 218 } |
219 | 219 |
220 void CPDFSDK_AnnotHandlerMgr::Annot_OnMouseExit(CPDFSDK_PageView* pPageView, | 220 void CPDFSDK_AnnotHandlerMgr::Annot_OnMouseExit(CPDFSDK_PageView* pPageView, |
221 CPDFSDK_Annot* pAnnot, | 221 CPDFSDK_Annot* pAnnot, |
222 FX_DWORD nFlag) { | 222 FX_DWORD nFlag) { |
223 ASSERT(pAnnot != NULL); | 223 ASSERT(pAnnot != NULL); |
224 | 224 |
225 if (CPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) { | 225 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) { |
226 pAnnotHandler->OnMouseExit(pPageView, pAnnot, nFlag); | 226 pAnnotHandler->OnMouseExit(pPageView, pAnnot, nFlag); |
227 } | 227 } |
228 return; | 228 return; |
229 } | 229 } |
230 | 230 |
231 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnChar(CPDFSDK_Annot* pAnnot, | 231 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnChar(CPDFSDK_Annot* pAnnot, |
232 FX_DWORD nChar, | 232 FX_DWORD nChar, |
233 FX_DWORD nFlags) { | 233 FX_DWORD nFlags) { |
234 if (CPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) { | 234 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) { |
235 return pAnnotHandler->OnChar(pAnnot, nChar, nFlags); | 235 return pAnnotHandler->OnChar(pAnnot, nChar, nFlags); |
236 } | 236 } |
237 return FALSE; | 237 return FALSE; |
238 } | 238 } |
239 | 239 |
240 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnKeyDown(CPDFSDK_Annot* pAnnot, | 240 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnKeyDown(CPDFSDK_Annot* pAnnot, |
241 int nKeyCode, | 241 int nKeyCode, |
242 int nFlag) { | 242 int nFlag) { |
243 if (!m_pApp->FFI_IsCTRLKeyDown(nFlag) && !m_pApp->FFI_IsALTKeyDown(nFlag)) { | 243 if (!m_pApp->FFI_IsCTRLKeyDown(nFlag) && !m_pApp->FFI_IsALTKeyDown(nFlag)) { |
244 CPDFSDK_PageView* pPage = pAnnot->GetPageView(); | 244 CPDFSDK_PageView* pPage = pAnnot->GetPageView(); |
245 CPDFSDK_Annot* pFocusAnnot = pPage->GetFocusAnnot(); | 245 CPDFSDK_Annot* pFocusAnnot = pPage->GetFocusAnnot(); |
246 if (pFocusAnnot && (nKeyCode == FWL_VKEY_Tab)) { | 246 if (pFocusAnnot && (nKeyCode == FWL_VKEY_Tab)) { |
247 CPDFSDK_Annot* pNext = | 247 CPDFSDK_Annot* pNext = |
248 GetNextAnnot(pFocusAnnot, !m_pApp->FFI_IsSHIFTKeyDown(nFlag)); | 248 GetNextAnnot(pFocusAnnot, !m_pApp->FFI_IsSHIFTKeyDown(nFlag)); |
249 | 249 |
250 if (pNext && pNext != pFocusAnnot) { | 250 if (pNext && pNext != pFocusAnnot) { |
251 CPDFSDK_Document* pDocument = pPage->GetSDKDocument(); | 251 CPDFSDK_Document* pDocument = pPage->GetSDKDocument(); |
252 pDocument->SetFocusAnnot(pNext); | 252 pDocument->SetFocusAnnot(pNext); |
253 return TRUE; | 253 return TRUE; |
254 } | 254 } |
255 } | 255 } |
256 } | 256 } |
257 | 257 |
258 if (CPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) { | 258 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) { |
259 return pAnnotHandler->OnKeyDown(pAnnot, nKeyCode, nFlag); | 259 return pAnnotHandler->OnKeyDown(pAnnot, nKeyCode, nFlag); |
260 } | 260 } |
261 return FALSE; | 261 return FALSE; |
262 } | 262 } |
263 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnKeyUp(CPDFSDK_Annot* pAnnot, | 263 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnKeyUp(CPDFSDK_Annot* pAnnot, |
264 int nKeyCode, | 264 int nKeyCode, |
265 int nFlag) { | 265 int nFlag) { |
266 return FALSE; | 266 return FALSE; |
267 } | 267 } |
268 | 268 |
269 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnSetFocus(CPDFSDK_Annot* pAnnot, | 269 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnSetFocus(CPDFSDK_Annot* pAnnot, |
270 FX_DWORD nFlag) { | 270 FX_DWORD nFlag) { |
271 ASSERT(pAnnot != NULL); | 271 ASSERT(pAnnot != NULL); |
272 | 272 |
273 if (CPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) { | 273 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) { |
274 if (pAnnotHandler->OnSetFocus(pAnnot, nFlag)) { | 274 if (pAnnotHandler->OnSetFocus(pAnnot, nFlag)) { |
275 CPDFSDK_PageView* pPage = pAnnot->GetPageView(); | 275 CPDFSDK_PageView* pPage = pAnnot->GetPageView(); |
276 pPage->GetSDKDocument(); | 276 pPage->GetSDKDocument(); |
277 return TRUE; | 277 return TRUE; |
278 } | 278 } |
279 } | 279 } |
280 return FALSE; | 280 return FALSE; |
281 } | 281 } |
282 | 282 |
283 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnKillFocus(CPDFSDK_Annot* pAnnot, | 283 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnKillFocus(CPDFSDK_Annot* pAnnot, |
284 FX_DWORD nFlag) { | 284 FX_DWORD nFlag) { |
285 ASSERT(pAnnot); | 285 ASSERT(pAnnot); |
286 if (CPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) | 286 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) |
287 return pAnnotHandler->OnKillFocus(pAnnot, nFlag); | 287 return pAnnotHandler->OnKillFocus(pAnnot, nFlag); |
288 | 288 |
289 return FALSE; | 289 return FALSE; |
290 } | 290 } |
291 | 291 |
292 CPDF_Rect CPDFSDK_AnnotHandlerMgr::Annot_OnGetViewBBox( | 292 CPDF_Rect CPDFSDK_AnnotHandlerMgr::Annot_OnGetViewBBox( |
293 CPDFSDK_PageView* pPageView, | 293 CPDFSDK_PageView* pPageView, |
294 CPDFSDK_Annot* pAnnot) { | 294 CPDFSDK_Annot* pAnnot) { |
295 ASSERT(pAnnot); | 295 ASSERT(pAnnot); |
296 if (CPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) | 296 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) |
297 return pAnnotHandler->GetViewBBox(pPageView, pAnnot); | 297 return pAnnotHandler->GetViewBBox(pPageView, pAnnot); |
298 | 298 |
299 return pAnnot->GetRect(); | 299 return pAnnot->GetRect(); |
300 } | 300 } |
301 | 301 |
302 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnHitTest(CPDFSDK_PageView* pPageView, | 302 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnHitTest(CPDFSDK_PageView* pPageView, |
303 CPDFSDK_Annot* pAnnot, | 303 CPDFSDK_Annot* pAnnot, |
304 const CPDF_Point& point) { | 304 const CPDF_Point& point) { |
305 ASSERT(pAnnot); | 305 ASSERT(pAnnot); |
306 if (CPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) { | 306 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) { |
307 if (pAnnotHandler->CanAnswer(pAnnot)) | 307 if (pAnnotHandler->CanAnswer(pAnnot)) |
308 return pAnnotHandler->HitTest(pPageView, pAnnot, point); | 308 return pAnnotHandler->HitTest(pPageView, pAnnot, point); |
309 } | 309 } |
310 return FALSE; | 310 return FALSE; |
311 } | 311 } |
312 | 312 |
313 CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::GetNextAnnot(CPDFSDK_Annot* pSDKAnnot, | 313 CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::GetNextAnnot(CPDFSDK_Annot* pSDKAnnot, |
314 FX_BOOL bNext) { | 314 FX_BOOL bNext) { |
315 CBA_AnnotIterator ai(pSDKAnnot->GetPageView(), "Widget", ""); | 315 CBA_AnnotIterator ai(pSDKAnnot->GetPageView(), "Widget", ""); |
316 return bNext ? ai.GetNextAnnot(pSDKAnnot) : ai.GetPrevAnnot(pSDKAnnot); | 316 return bNext ? ai.GetNextAnnot(pSDKAnnot) : ai.GetPrevAnnot(pSDKAnnot); |
317 } | 317 } |
318 | 318 |
319 FX_BOOL CPDFSDK_AnnotHandler::CanAnswer(CPDFSDK_Annot* pAnnot) { | 319 FX_BOOL CPDFSDK_BFAnnotHandler::CanAnswer(CPDFSDK_Annot* pAnnot) { |
320 ASSERT(pAnnot->GetType() == "Widget"); | 320 ASSERT(pAnnot->GetType() == "Widget"); |
321 if (pAnnot->GetSubType() == BFFT_SIGNATURE) | 321 if (pAnnot->GetSubType() == BFFT_SIGNATURE) |
322 return FALSE; | 322 return FALSE; |
323 | 323 |
324 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; | 324 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; |
325 if (!pWidget->IsVisible()) | 325 if (!pWidget->IsVisible()) |
326 return FALSE; | 326 return FALSE; |
327 | 327 |
328 int nFieldFlags = pWidget->GetFieldFlags(); | 328 int nFieldFlags = pWidget->GetFieldFlags(); |
329 if ((nFieldFlags & FIELDFLAG_READONLY) == FIELDFLAG_READONLY) | 329 if ((nFieldFlags & FIELDFLAG_READONLY) == FIELDFLAG_READONLY) |
330 return FALSE; | 330 return FALSE; |
331 | 331 |
332 if (pWidget->GetFieldType() == FIELDTYPE_PUSHBUTTON) | 332 if (pWidget->GetFieldType() == FIELDTYPE_PUSHBUTTON) |
333 return TRUE; | 333 return TRUE; |
334 | 334 |
335 CPDF_Page* pPage = pWidget->GetPDFPage(); | 335 CPDF_Page* pPage = pWidget->GetPDFPage(); |
336 CPDF_Document* pDocument = pPage->m_pDocument; | 336 CPDF_Document* pDocument = pPage->m_pDocument; |
337 FX_DWORD dwPermissions = pDocument->GetUserPermissions(); | 337 FX_DWORD dwPermissions = pDocument->GetUserPermissions(); |
338 return (dwPermissions & FPDFPERM_FILL_FORM) || | 338 return (dwPermissions & FPDFPERM_FILL_FORM) || |
339 (dwPermissions & FPDFPERM_ANNOT_FORM); | 339 (dwPermissions & FPDFPERM_ANNOT_FORM); |
340 } | 340 } |
341 | 341 |
342 CPDFSDK_Annot* CPDFSDK_AnnotHandler::NewAnnot(CPDF_Annot* pAnnot, | 342 CPDFSDK_Annot* CPDFSDK_BFAnnotHandler::NewAnnot(CPDF_Annot* pAnnot, |
343 CPDFSDK_PageView* pPage) { | 343 CPDFSDK_PageView* pPage) { |
344 CPDFSDK_Document* pSDKDoc = m_pApp->GetSDKDocument(); | 344 CPDFSDK_Document* pSDKDoc = m_pApp->GetSDKDocument(); |
345 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pSDKDoc->GetInterForm(); | 345 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pSDKDoc->GetInterForm(); |
346 CPDF_FormControl* pCtrl = CPDFSDK_Widget::GetFormControl( | 346 CPDF_FormControl* pCtrl = CPDFSDK_Widget::GetFormControl( |
347 pInterForm->GetInterForm(), pAnnot->GetAnnotDict()); | 347 pInterForm->GetInterForm(), pAnnot->GetAnnotDict()); |
348 if (!pCtrl) | 348 if (!pCtrl) |
349 return nullptr; | 349 return nullptr; |
350 | 350 |
351 CPDFSDK_Widget* pWidget = new CPDFSDK_Widget(pAnnot, pPage, pInterForm); | 351 CPDFSDK_Widget* pWidget = new CPDFSDK_Widget(pAnnot, pPage, pInterForm); |
352 pInterForm->AddMap(pCtrl, pWidget); | 352 pInterForm->AddMap(pCtrl, pWidget); |
353 CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm(); | 353 CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm(); |
354 if (pPDFInterForm && pPDFInterForm->NeedConstructAP()) | 354 if (pPDFInterForm && pPDFInterForm->NeedConstructAP()) |
355 pWidget->ResetAppearance(nullptr, FALSE); | 355 pWidget->ResetAppearance(nullptr, FALSE); |
356 | 356 |
357 return pWidget; | 357 return pWidget; |
358 } | 358 } |
359 | 359 |
360 void CPDFSDK_AnnotHandler::ReleaseAnnot(CPDFSDK_Annot* pAnnot) { | 360 void CPDFSDK_BFAnnotHandler::ReleaseAnnot(CPDFSDK_Annot* pAnnot) { |
361 ASSERT(pAnnot != NULL); | 361 ASSERT(pAnnot != NULL); |
362 | 362 |
363 if (m_pFormFiller) | 363 if (m_pFormFiller) |
364 m_pFormFiller->OnDelete(pAnnot); | 364 m_pFormFiller->OnDelete(pAnnot); |
365 | 365 |
366 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; | 366 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; |
367 CPDFSDK_InterForm* pInterForm = pWidget->GetInterForm(); | 367 CPDFSDK_InterForm* pInterForm = pWidget->GetInterForm(); |
368 ASSERT(pInterForm != NULL); | 368 ASSERT(pInterForm != NULL); |
369 | 369 |
370 CPDF_FormControl* pCtrol = pWidget->GetFormControl(); | 370 CPDF_FormControl* pCtrol = pWidget->GetFormControl(); |
371 pInterForm->RemoveMap(pCtrol); | 371 pInterForm->RemoveMap(pCtrol); |
372 | 372 |
373 delete pWidget; | 373 delete pWidget; |
374 } | 374 } |
375 | 375 |
376 void CPDFSDK_AnnotHandler::OnDraw(CPDFSDK_PageView* pPageView, | 376 void CPDFSDK_BFAnnotHandler::OnDraw(CPDFSDK_PageView* pPageView, |
377 CPDFSDK_Annot* pAnnot, | 377 CPDFSDK_Annot* pAnnot, |
378 CFX_RenderDevice* pDevice, | 378 CFX_RenderDevice* pDevice, |
379 CPDF_Matrix* pUser2Device, | 379 CPDF_Matrix* pUser2Device, |
380 FX_DWORD dwFlags) { | 380 FX_DWORD dwFlags) { |
381 ASSERT(pAnnot != NULL); | 381 ASSERT(pAnnot != NULL); |
382 CFX_ByteString sSubType = pAnnot->GetSubType(); | 382 CFX_ByteString sSubType = pAnnot->GetSubType(); |
383 | 383 |
384 if (sSubType == BFFT_SIGNATURE) { | 384 if (sSubType == BFFT_SIGNATURE) { |
385 pAnnot->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL); | 385 pAnnot->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL); |
386 } else { | 386 } else { |
387 if (m_pFormFiller) { | 387 if (m_pFormFiller) { |
388 m_pFormFiller->OnDraw(pPageView, pAnnot, pDevice, pUser2Device, dwFlags); | 388 m_pFormFiller->OnDraw(pPageView, pAnnot, pDevice, pUser2Device, dwFlags); |
389 } | 389 } |
390 } | 390 } |
391 } | 391 } |
392 | 392 |
393 void CPDFSDK_AnnotHandler::OnMouseEnter(CPDFSDK_PageView* pPageView, | 393 void CPDFSDK_BFAnnotHandler::OnMouseEnter(CPDFSDK_PageView* pPageView, |
394 CPDFSDK_Annot* pAnnot, | 394 CPDFSDK_Annot* pAnnot, |
395 FX_DWORD nFlag) { | 395 FX_DWORD nFlag) { |
396 ASSERT(pAnnot != NULL); | 396 ASSERT(pAnnot != NULL); |
397 CFX_ByteString sSubType = pAnnot->GetSubType(); | 397 CFX_ByteString sSubType = pAnnot->GetSubType(); |
398 | 398 |
399 if (sSubType == BFFT_SIGNATURE) { | 399 if (sSubType == BFFT_SIGNATURE) { |
400 } else { | 400 } else { |
401 if (m_pFormFiller) | 401 if (m_pFormFiller) |
402 m_pFormFiller->OnMouseEnter(pPageView, pAnnot, nFlag); | 402 m_pFormFiller->OnMouseEnter(pPageView, pAnnot, nFlag); |
403 } | 403 } |
404 } | 404 } |
405 void CPDFSDK_AnnotHandler::OnMouseExit(CPDFSDK_PageView* pPageView, | 405 void CPDFSDK_BFAnnotHandler::OnMouseExit(CPDFSDK_PageView* pPageView, |
406 CPDFSDK_Annot* pAnnot, | 406 CPDFSDK_Annot* pAnnot, |
407 FX_DWORD nFlag) { | 407 FX_DWORD nFlag) { |
408 ASSERT(pAnnot != NULL); | 408 ASSERT(pAnnot != NULL); |
409 CFX_ByteString sSubType = pAnnot->GetSubType(); | 409 CFX_ByteString sSubType = pAnnot->GetSubType(); |
410 | 410 |
411 if (sSubType == BFFT_SIGNATURE) { | 411 if (sSubType == BFFT_SIGNATURE) { |
412 } else { | 412 } else { |
413 if (m_pFormFiller) | 413 if (m_pFormFiller) |
414 m_pFormFiller->OnMouseExit(pPageView, pAnnot, nFlag); | 414 m_pFormFiller->OnMouseExit(pPageView, pAnnot, nFlag); |
415 } | 415 } |
416 } | 416 } |
417 FX_BOOL CPDFSDK_AnnotHandler::OnLButtonDown(CPDFSDK_PageView* pPageView, | 417 FX_BOOL CPDFSDK_BFAnnotHandler::OnLButtonDown(CPDFSDK_PageView* pPageView, |
418 CPDFSDK_Annot* pAnnot, | 418 CPDFSDK_Annot* pAnnot, |
419 FX_DWORD nFlags, | 419 FX_DWORD nFlags, |
420 const CPDF_Point& point) { | 420 const CPDF_Point& point) { |
421 ASSERT(pAnnot != NULL); | 421 ASSERT(pAnnot != NULL); |
422 CFX_ByteString sSubType = pAnnot->GetSubType(); | 422 CFX_ByteString sSubType = pAnnot->GetSubType(); |
423 | 423 |
424 if (sSubType == BFFT_SIGNATURE) { | 424 if (sSubType == BFFT_SIGNATURE) { |
425 } else { | 425 } else { |
426 if (m_pFormFiller) | 426 if (m_pFormFiller) |
427 return m_pFormFiller->OnLButtonDown(pPageView, pAnnot, nFlags, point); | 427 return m_pFormFiller->OnLButtonDown(pPageView, pAnnot, nFlags, point); |
428 } | 428 } |
429 | 429 |
430 return FALSE; | 430 return FALSE; |
431 } | 431 } |
432 | 432 |
433 FX_BOOL CPDFSDK_AnnotHandler::OnLButtonUp(CPDFSDK_PageView* pPageView, | 433 FX_BOOL CPDFSDK_BFAnnotHandler::OnLButtonUp(CPDFSDK_PageView* pPageView, |
434 CPDFSDK_Annot* pAnnot, | 434 CPDFSDK_Annot* pAnnot, |
435 FX_DWORD nFlags, | 435 FX_DWORD nFlags, |
436 const CPDF_Point& point) { | 436 const CPDF_Point& point) { |
437 ASSERT(pAnnot != NULL); | 437 ASSERT(pAnnot != NULL); |
438 CFX_ByteString sSubType = pAnnot->GetSubType(); | 438 CFX_ByteString sSubType = pAnnot->GetSubType(); |
439 | 439 |
440 if (sSubType == BFFT_SIGNATURE) { | 440 if (sSubType == BFFT_SIGNATURE) { |
441 } else { | 441 } else { |
442 if (m_pFormFiller) | 442 if (m_pFormFiller) |
443 return m_pFormFiller->OnLButtonUp(pPageView, pAnnot, nFlags, point); | 443 return m_pFormFiller->OnLButtonUp(pPageView, pAnnot, nFlags, point); |
444 } | 444 } |
445 | 445 |
446 return FALSE; | 446 return FALSE; |
447 } | 447 } |
448 | 448 |
449 FX_BOOL CPDFSDK_AnnotHandler::OnLButtonDblClk(CPDFSDK_PageView* pPageView, | 449 FX_BOOL CPDFSDK_BFAnnotHandler::OnLButtonDblClk(CPDFSDK_PageView* pPageView, |
450 CPDFSDK_Annot* pAnnot, | 450 CPDFSDK_Annot* pAnnot, |
451 FX_DWORD nFlags, | 451 FX_DWORD nFlags, |
452 const CPDF_Point& point) { | 452 const CPDF_Point& point) { |
453 ASSERT(pAnnot != NULL); | 453 ASSERT(pAnnot != NULL); |
454 CFX_ByteString sSubType = pAnnot->GetSubType(); | 454 CFX_ByteString sSubType = pAnnot->GetSubType(); |
455 | 455 |
456 if (sSubType == BFFT_SIGNATURE) { | 456 if (sSubType == BFFT_SIGNATURE) { |
457 } else { | 457 } else { |
458 if (m_pFormFiller) | 458 if (m_pFormFiller) |
459 return m_pFormFiller->OnLButtonDblClk(pPageView, pAnnot, nFlags, point); | 459 return m_pFormFiller->OnLButtonDblClk(pPageView, pAnnot, nFlags, point); |
460 } | 460 } |
461 | 461 |
462 return FALSE; | 462 return FALSE; |
463 } | 463 } |
464 | 464 |
465 FX_BOOL CPDFSDK_AnnotHandler::OnMouseMove(CPDFSDK_PageView* pPageView, | 465 FX_BOOL CPDFSDK_BFAnnotHandler::OnMouseMove(CPDFSDK_PageView* pPageView, |
466 CPDFSDK_Annot* pAnnot, | 466 CPDFSDK_Annot* pAnnot, |
467 FX_DWORD nFlags, | 467 FX_DWORD nFlags, |
468 const CPDF_Point& point) { | 468 const CPDF_Point& point) { |
469 ASSERT(pAnnot != NULL); | 469 ASSERT(pAnnot != NULL); |
470 CFX_ByteString sSubType = pAnnot->GetSubType(); | 470 CFX_ByteString sSubType = pAnnot->GetSubType(); |
471 | 471 |
472 if (sSubType == BFFT_SIGNATURE) { | 472 if (sSubType == BFFT_SIGNATURE) { |
473 } else { | 473 } else { |
474 if (m_pFormFiller) | 474 if (m_pFormFiller) |
475 return m_pFormFiller->OnMouseMove(pPageView, pAnnot, nFlags, point); | 475 return m_pFormFiller->OnMouseMove(pPageView, pAnnot, nFlags, point); |
476 } | 476 } |
477 | 477 |
478 return FALSE; | 478 return FALSE; |
479 } | 479 } |
480 | 480 |
481 FX_BOOL CPDFSDK_AnnotHandler::OnMouseWheel(CPDFSDK_PageView* pPageView, | 481 FX_BOOL CPDFSDK_BFAnnotHandler::OnMouseWheel(CPDFSDK_PageView* pPageView, |
482 CPDFSDK_Annot* pAnnot, | 482 CPDFSDK_Annot* pAnnot, |
483 FX_DWORD nFlags, | 483 FX_DWORD nFlags, |
484 short zDelta, | 484 short zDelta, |
485 const CPDF_Point& point) { | 485 const CPDF_Point& point) { |
486 ASSERT(pAnnot != NULL); | 486 ASSERT(pAnnot != NULL); |
487 CFX_ByteString sSubType = pAnnot->GetSubType(); | 487 CFX_ByteString sSubType = pAnnot->GetSubType(); |
488 | 488 |
489 if (sSubType == BFFT_SIGNATURE) { | 489 if (sSubType == BFFT_SIGNATURE) { |
490 } else { | 490 } else { |
491 if (m_pFormFiller) | 491 if (m_pFormFiller) |
492 return m_pFormFiller->OnMouseWheel(pPageView, pAnnot, nFlags, zDelta, | 492 return m_pFormFiller->OnMouseWheel(pPageView, pAnnot, nFlags, zDelta, |
493 point); | 493 point); |
494 } | 494 } |
495 | 495 |
496 return FALSE; | 496 return FALSE; |
497 } | 497 } |
498 | 498 |
499 FX_BOOL CPDFSDK_AnnotHandler::OnRButtonDown(CPDFSDK_PageView* pPageView, | 499 FX_BOOL CPDFSDK_BFAnnotHandler::OnRButtonDown(CPDFSDK_PageView* pPageView, |
500 CPDFSDK_Annot* pAnnot, | 500 CPDFSDK_Annot* pAnnot, |
501 FX_DWORD nFlags, | 501 FX_DWORD nFlags, |
502 const CPDF_Point& point) { | 502 const CPDF_Point& point) { |
503 ASSERT(pAnnot != NULL); | 503 ASSERT(pAnnot != NULL); |
504 CFX_ByteString sSubType = pAnnot->GetSubType(); | 504 CFX_ByteString sSubType = pAnnot->GetSubType(); |
505 | 505 |
506 if (sSubType == BFFT_SIGNATURE) { | 506 if (sSubType == BFFT_SIGNATURE) { |
507 } else { | 507 } else { |
508 if (m_pFormFiller) | 508 if (m_pFormFiller) |
509 return m_pFormFiller->OnRButtonDown(pPageView, pAnnot, nFlags, point); | 509 return m_pFormFiller->OnRButtonDown(pPageView, pAnnot, nFlags, point); |
510 } | 510 } |
511 | 511 |
512 return FALSE; | 512 return FALSE; |
513 } | 513 } |
514 FX_BOOL CPDFSDK_AnnotHandler::OnRButtonUp(CPDFSDK_PageView* pPageView, | 514 FX_BOOL CPDFSDK_BFAnnotHandler::OnRButtonUp(CPDFSDK_PageView* pPageView, |
515 CPDFSDK_Annot* pAnnot, | 515 CPDFSDK_Annot* pAnnot, |
516 FX_DWORD nFlags, | 516 FX_DWORD nFlags, |
517 const CPDF_Point& point) { | 517 const CPDF_Point& point) { |
518 ASSERT(pAnnot != NULL); | 518 ASSERT(pAnnot != NULL); |
519 CFX_ByteString sSubType = pAnnot->GetSubType(); | 519 CFX_ByteString sSubType = pAnnot->GetSubType(); |
520 | 520 |
521 if (sSubType == BFFT_SIGNATURE) { | 521 if (sSubType == BFFT_SIGNATURE) { |
522 } else { | 522 } else { |
523 if (m_pFormFiller) | 523 if (m_pFormFiller) |
524 return m_pFormFiller->OnRButtonUp(pPageView, pAnnot, nFlags, point); | 524 return m_pFormFiller->OnRButtonUp(pPageView, pAnnot, nFlags, point); |
525 } | 525 } |
526 | 526 |
527 return FALSE; | 527 return FALSE; |
528 } | 528 } |
529 | 529 |
530 FX_BOOL CPDFSDK_AnnotHandler::OnChar(CPDFSDK_Annot* pAnnot, | 530 FX_BOOL CPDFSDK_BFAnnotHandler::OnChar(CPDFSDK_Annot* pAnnot, |
531 FX_DWORD nChar, | 531 FX_DWORD nChar, |
532 FX_DWORD nFlags) { | 532 FX_DWORD nFlags) { |
533 ASSERT(pAnnot != NULL); | 533 ASSERT(pAnnot != NULL); |
534 CFX_ByteString sSubType = pAnnot->GetSubType(); | 534 CFX_ByteString sSubType = pAnnot->GetSubType(); |
535 | 535 |
536 if (sSubType == BFFT_SIGNATURE) { | 536 if (sSubType == BFFT_SIGNATURE) { |
537 } else { | 537 } else { |
538 if (m_pFormFiller) | 538 if (m_pFormFiller) |
539 return m_pFormFiller->OnChar(pAnnot, nChar, nFlags); | 539 return m_pFormFiller->OnChar(pAnnot, nChar, nFlags); |
540 } | 540 } |
541 | 541 |
542 return FALSE; | 542 return FALSE; |
543 } | 543 } |
544 | 544 |
545 FX_BOOL CPDFSDK_AnnotHandler::OnKeyDown(CPDFSDK_Annot* pAnnot, | 545 FX_BOOL CPDFSDK_BFAnnotHandler::OnKeyDown(CPDFSDK_Annot* pAnnot, |
546 int nKeyCode, | 546 int nKeyCode, |
547 int nFlag) { | 547 int nFlag) { |
548 ASSERT(pAnnot != NULL); | 548 ASSERT(pAnnot != NULL); |
549 CFX_ByteString sSubType = pAnnot->GetSubType(); | 549 CFX_ByteString sSubType = pAnnot->GetSubType(); |
550 | 550 |
551 if (sSubType == BFFT_SIGNATURE) { | 551 if (sSubType == BFFT_SIGNATURE) { |
552 } else { | 552 } else { |
553 if (m_pFormFiller) | 553 if (m_pFormFiller) |
554 return m_pFormFiller->OnKeyDown(pAnnot, nKeyCode, nFlag); | 554 return m_pFormFiller->OnKeyDown(pAnnot, nKeyCode, nFlag); |
555 } | 555 } |
556 | 556 |
557 return FALSE; | 557 return FALSE; |
558 } | 558 } |
559 | 559 |
560 FX_BOOL CPDFSDK_AnnotHandler::OnKeyUp(CPDFSDK_Annot* pAnnot, | 560 FX_BOOL CPDFSDK_BFAnnotHandler::OnKeyUp(CPDFSDK_Annot* pAnnot, |
561 int nKeyCode, | 561 int nKeyCode, |
562 int nFlag) { | 562 int nFlag) { |
563 return FALSE; | 563 return FALSE; |
564 } | 564 } |
565 void CPDFSDK_AnnotHandler::OnCreate(CPDFSDK_Annot* pAnnot) { | 565 void CPDFSDK_BFAnnotHandler::OnCreate(CPDFSDK_Annot* pAnnot) { |
566 ASSERT(pAnnot != NULL); | 566 ASSERT(pAnnot != NULL); |
567 CFX_ByteString sSubType = pAnnot->GetSubType(); | 567 CFX_ByteString sSubType = pAnnot->GetSubType(); |
568 | 568 |
569 if (sSubType == BFFT_SIGNATURE) { | 569 if (sSubType == BFFT_SIGNATURE) { |
570 } else { | 570 } else { |
571 if (m_pFormFiller) | 571 if (m_pFormFiller) |
572 m_pFormFiller->OnCreate(pAnnot); | 572 m_pFormFiller->OnCreate(pAnnot); |
573 } | 573 } |
574 } | 574 } |
575 | 575 |
576 void CPDFSDK_AnnotHandler::OnLoad(CPDFSDK_Annot* pAnnot) { | 576 void CPDFSDK_BFAnnotHandler::OnLoad(CPDFSDK_Annot* pAnnot) { |
577 ASSERT(pAnnot != NULL); | 577 ASSERT(pAnnot != NULL); |
578 | 578 |
579 CFX_ByteString sSubType = pAnnot->GetSubType(); | 579 CFX_ByteString sSubType = pAnnot->GetSubType(); |
580 | 580 |
581 if (sSubType == BFFT_SIGNATURE) { | 581 if (sSubType == BFFT_SIGNATURE) { |
582 } else { | 582 } else { |
583 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; | 583 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; |
584 if (!pWidget->IsAppearanceValid()) | 584 if (!pWidget->IsAppearanceValid()) |
585 pWidget->ResetAppearance(NULL, FALSE); | 585 pWidget->ResetAppearance(NULL, FALSE); |
586 | 586 |
587 int nFieldType = pWidget->GetFieldType(); | 587 int nFieldType = pWidget->GetFieldType(); |
588 if (nFieldType == FIELDTYPE_TEXTFIELD || nFieldType == FIELDTYPE_COMBOBOX) { | 588 if (nFieldType == FIELDTYPE_TEXTFIELD || nFieldType == FIELDTYPE_COMBOBOX) { |
589 FX_BOOL bFormated = FALSE; | 589 FX_BOOL bFormated = FALSE; |
590 CFX_WideString sValue = pWidget->OnFormat(bFormated); | 590 CFX_WideString sValue = pWidget->OnFormat(bFormated); |
591 if (bFormated && nFieldType == FIELDTYPE_COMBOBOX) { | 591 if (bFormated && nFieldType == FIELDTYPE_COMBOBOX) { |
592 pWidget->ResetAppearance(sValue.c_str(), FALSE); | 592 pWidget->ResetAppearance(sValue.c_str(), FALSE); |
593 } | 593 } |
594 } | 594 } |
595 | 595 |
596 if (m_pFormFiller) | 596 if (m_pFormFiller) |
597 m_pFormFiller->OnLoad(pAnnot); | 597 m_pFormFiller->OnLoad(pAnnot); |
598 } | 598 } |
599 } | 599 } |
600 | 600 |
601 FX_BOOL CPDFSDK_AnnotHandler::OnSetFocus(CPDFSDK_Annot* pAnnot, | 601 FX_BOOL CPDFSDK_BFAnnotHandler::OnSetFocus(CPDFSDK_Annot* pAnnot, |
602 FX_DWORD nFlag) { | 602 FX_DWORD nFlag) { |
603 ASSERT(pAnnot != NULL); | 603 ASSERT(pAnnot != NULL); |
604 CFX_ByteString sSubType = pAnnot->GetSubType(); | 604 CFX_ByteString sSubType = pAnnot->GetSubType(); |
605 | 605 |
606 if (sSubType == BFFT_SIGNATURE) { | 606 if (sSubType == BFFT_SIGNATURE) { |
607 } else { | 607 } else { |
608 if (m_pFormFiller) | 608 if (m_pFormFiller) |
609 return m_pFormFiller->OnSetFocus(pAnnot, nFlag); | 609 return m_pFormFiller->OnSetFocus(pAnnot, nFlag); |
610 } | 610 } |
611 | 611 |
612 return TRUE; | 612 return TRUE; |
613 } | 613 } |
614 FX_BOOL CPDFSDK_AnnotHandler::OnKillFocus(CPDFSDK_Annot* pAnnot, | 614 FX_BOOL CPDFSDK_BFAnnotHandler::OnKillFocus(CPDFSDK_Annot* pAnnot, |
615 FX_DWORD nFlag) { | 615 FX_DWORD nFlag) { |
616 ASSERT(pAnnot != NULL); | 616 ASSERT(pAnnot != NULL); |
617 CFX_ByteString sSubType = pAnnot->GetSubType(); | 617 CFX_ByteString sSubType = pAnnot->GetSubType(); |
618 | 618 |
619 if (sSubType == BFFT_SIGNATURE) { | 619 if (sSubType == BFFT_SIGNATURE) { |
620 } else { | 620 } else { |
621 if (m_pFormFiller) | 621 if (m_pFormFiller) |
622 return m_pFormFiller->OnKillFocus(pAnnot, nFlag); | 622 return m_pFormFiller->OnKillFocus(pAnnot, nFlag); |
623 } | 623 } |
624 | 624 |
625 return TRUE; | 625 return TRUE; |
626 } | 626 } |
627 | 627 |
628 CPDF_Rect CPDFSDK_AnnotHandler::GetViewBBox(CPDFSDK_PageView* pPageView, | 628 CPDF_Rect CPDFSDK_BFAnnotHandler::GetViewBBox(CPDFSDK_PageView* pPageView, |
629 CPDFSDK_Annot* pAnnot) { | 629 CPDFSDK_Annot* pAnnot) { |
630 ASSERT(pAnnot != NULL); | 630 ASSERT(pAnnot != NULL); |
631 CFX_ByteString sSubType = pAnnot->GetSubType(); | 631 CFX_ByteString sSubType = pAnnot->GetSubType(); |
632 | 632 |
633 if (sSubType == BFFT_SIGNATURE) { | 633 if (sSubType == BFFT_SIGNATURE) { |
634 } else { | 634 } else { |
635 if (m_pFormFiller) | 635 if (m_pFormFiller) |
636 return m_pFormFiller->GetViewBBox(pPageView, pAnnot); | 636 return m_pFormFiller->GetViewBBox(pPageView, pAnnot); |
637 } | 637 } |
638 | 638 |
639 return CPDF_Rect(0, 0, 0, 0); | 639 return CPDF_Rect(0, 0, 0, 0); |
640 } | 640 } |
641 | 641 |
642 FX_BOOL CPDFSDK_AnnotHandler::HitTest(CPDFSDK_PageView* pPageView, | 642 FX_BOOL CPDFSDK_BFAnnotHandler::HitTest(CPDFSDK_PageView* pPageView, |
643 CPDFSDK_Annot* pAnnot, | 643 CPDFSDK_Annot* pAnnot, |
644 const CPDF_Point& point) { | 644 const CPDF_Point& point) { |
645 ASSERT(pPageView); | 645 ASSERT(pPageView); |
646 ASSERT(pAnnot); | 646 ASSERT(pAnnot); |
647 | 647 |
648 CPDF_Rect rect = GetViewBBox(pPageView, pAnnot); | 648 CPDF_Rect rect = GetViewBBox(pPageView, pAnnot); |
649 return rect.Contains(point.x, point.y); | 649 return rect.Contains(point.x, point.y); |
650 } | 650 } |
651 | 651 |
652 // CReader_AnnotIteratorEx | 652 // CReader_AnnotIteratorEx |
653 | 653 |
654 CPDFSDK_AnnotIterator::CPDFSDK_AnnotIterator(CPDFSDK_PageView* pPageView, | 654 CPDFSDK_AnnotIterator::CPDFSDK_AnnotIterator(CPDFSDK_PageView* pPageView, |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
803 if (pReaderAnnot == pTopMostAnnot) { | 803 if (pReaderAnnot == pTopMostAnnot) { |
804 m_pIteratorAnnotList.RemoveAt(i); | 804 m_pIteratorAnnotList.RemoveAt(i); |
805 m_pIteratorAnnotList.InsertAt(0, pReaderAnnot); | 805 m_pIteratorAnnotList.InsertAt(0, pReaderAnnot); |
806 break; | 806 break; |
807 } | 807 } |
808 } | 808 } |
809 } | 809 } |
810 | 810 |
811 return TRUE; | 811 return TRUE; |
812 } | 812 } |
OLD | NEW |