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 | 7 |
8 #include "../../include/formfiller/FFL_FormFiller.h" | 8 #include "../../include/formfiller/FFL_FormFiller.h" |
9 #include "../../include/formfiller/FFL_Notify.h" | 9 #include "../../include/formfiller/FFL_Notify.h" |
10 #include "../../include/formfiller/FFL_CBA_Fontmap.h" | 10 #include "../../include/formfiller/FFL_CBA_Fontmap.h" |
11 | 11 |
12 #define GetRed(rgb) ((uint8_t)(rgb)) | 12 #define GetRed(rgb) ((uint8_t)(rgb)) |
13 #define GetGreen(rgb) ((uint8_t)(((FX_WORD)(rgb)) >> 8)) | 13 #define GetGreen(rgb) ((uint8_t)(((FX_WORD)(rgb)) >> 8)) |
14 #define GetBlue(rgb) ((uint8_t)((rgb)>>16)) | 14 #define GetBlue(rgb) ((uint8_t)((rgb)>>16)) |
15 | 15 |
16 #define FFL_HINT_ELAPSE 800 | 16 #define FFL_HINT_ELAPSE 800 |
17 | 17 |
18 /* ------------------------- CFFL_FormFiller ------------------------- */ | 18 /* ------------------------- CFFL_FormFiller ------------------------- */ |
19 | 19 |
20 CFFL_FormFiller::CFFL_FormFiller(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pAnno
t) | 20 CFFL_FormFiller::CFFL_FormFiller(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pAnno
t) |
21 : m_pApp(pApp), | 21 : m_pApp(pApp), |
22 m_pAnnot(pAnnot), | 22 m_pAnnot(pAnnot), |
23 m_bValid(FALSE), | 23 m_bValid(false), |
24 m_ptOldPos(0,0) | 24 m_ptOldPos(0,0) |
25 { | 25 { |
26 m_pWidget = (CPDFSDK_Widget*) pAnnot; | 26 m_pWidget = (CPDFSDK_Widget*) pAnnot; |
27 } | 27 } |
28 | 28 |
29 CFFL_FormFiller::~CFFL_FormFiller() | 29 CFFL_FormFiller::~CFFL_FormFiller() |
30 { | 30 { |
31 for (auto& it : m_Maps) { | 31 for (auto& it : m_Maps) { |
32 CPWL_Wnd* pWnd = it.second; | 32 CPWL_Wnd* pWnd = it.second; |
33 CFFL_PrivateData* pData = (CFFL_PrivateData*)pWnd->GetAttachedData(); | 33 CFFL_PrivateData* pData = (CFFL_PrivateData*)pWnd->GetAttachedData(); |
34 pWnd->Destroy(); | 34 pWnd->Destroy(); |
35 delete pWnd; | 35 delete pWnd; |
36 delete pData; | 36 delete pData; |
37 } | 37 } |
38 m_Maps.clear(); | 38 m_Maps.clear(); |
39 } | 39 } |
40 | 40 |
41 void CFFL_FormFiller::SetWindowRect(CPDFSDK_PageView* pPageView, const CPDF_Rect
& rcWindow) | 41 void CFFL_FormFiller::SetWindowRect(CPDFSDK_PageView* pPageView, const CPDF_Rect
& rcWindow) |
42 { | 42 { |
43 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) | 43 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, false)) |
44 { | 44 { |
45 pWnd->Move(CPDF_Rect(rcWindow), TRUE, FALSE); | 45 pWnd->Move(CPDF_Rect(rcWindow), true, false); |
46 } | 46 } |
47 } | 47 } |
48 | 48 |
49 CPDF_Rect CFFL_FormFiller::GetWindowRect(CPDFSDK_PageView* pPageView) | 49 CPDF_Rect CFFL_FormFiller::GetWindowRect(CPDFSDK_PageView* pPageView) |
50 { | 50 { |
51 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) | 51 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, false)) |
52 { | 52 { |
53 return pWnd->GetWindowRect(); | 53 return pWnd->GetWindowRect(); |
54 } | 54 } |
55 | 55 |
56 return CPDF_Rect(0,0,0,0); | 56 return CPDF_Rect(0,0,0,0); |
57 } | 57 } |
58 | 58 |
59 FX_RECT CFFL_FormFiller::GetViewBBox(CPDFSDK_PageView *pPageView, CPDFSDK_Annot*
pAnnot) | 59 FX_RECT CFFL_FormFiller::GetViewBBox(CPDFSDK_PageView *pPageView, CPDFSDK_Annot*
pAnnot) |
60 { | 60 { |
61 ASSERT(pPageView != NULL); | 61 ASSERT(pPageView != NULL); |
62 ASSERT(pAnnot != NULL); | 62 ASSERT(pAnnot != NULL); |
63 | 63 |
64 CPDF_Rect rcAnnot = m_pWidget->GetRect(); | 64 CPDF_Rect rcAnnot = m_pWidget->GetRect(); |
65 | 65 |
66 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) | 66 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, false)) |
67 { | 67 { |
68 CPDF_Rect rcWindow = pWnd->GetWindowRect(); | 68 CPDF_Rect rcWindow = pWnd->GetWindowRect(); |
69 rcAnnot = PWLtoFFL(rcWindow); | 69 rcAnnot = PWLtoFFL(rcWindow); |
70 } | 70 } |
71 | 71 |
72 CPDF_Rect rcWin = rcAnnot; | 72 CPDF_Rect rcWin = rcAnnot; |
73 | 73 |
74 CPDF_Rect rcFocus = GetFocusBox(pPageView); | 74 CPDF_Rect rcFocus = GetFocusBox(pPageView); |
75 if (!rcFocus.IsEmpty()) | 75 if (!rcFocus.IsEmpty()) |
76 rcWin.Union(rcFocus); | 76 rcWin.Union(rcFocus); |
77 | 77 |
78 CPDF_Rect rect = CPWL_Utils::InflateRect(rcWin,1); | 78 CPDF_Rect rect = CPWL_Utils::InflateRect(rcWin,1); |
79 | 79 |
80 return rect.GetOutterRect(); | 80 return rect.GetOutterRect(); |
81 } | 81 } |
82 | 82 |
83 void CFFL_FormFiller::OnDraw(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, | 83 void CFFL_FormFiller::OnDraw(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, |
84 CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Devic
e, | 84 CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Devic
e, |
85 FX_DWORD dwFlags) | 85 FX_DWORD dwFlags) |
86 { | 86 { |
87 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); | 87 ASSERT(pAnnot->GetPDFAnnot()->GetSubType() == "Widget"); |
88 | 88 |
89 if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, FALSE)) | 89 if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, false)) |
90 { | 90 { |
91 CPDF_Matrix mt = GetCurMatrix(); | 91 CPDF_Matrix mt = GetCurMatrix(); |
92 mt.Concat(*pUser2Device); | 92 mt.Concat(*pUser2Device); |
93 pWnd->DrawAppearance(pDevice,&mt); | 93 pWnd->DrawAppearance(pDevice,&mt); |
94 } | 94 } |
95 else | 95 else |
96 { | 96 { |
97 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; | 97 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; |
98 if (CFFL_IFormFiller::IsVisible(pWidget)) | 98 if (CFFL_IFormFiller::IsVisible(pWidget)) |
99 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, N
ULL); | 99 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, N
ULL); |
(...skipping 24 matching lines...) Expand all Loading... |
124 void CFFL_FormFiller::OnMouseEnter(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* p
Annot) | 124 void CFFL_FormFiller::OnMouseEnter(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* p
Annot) |
125 { | 125 { |
126 } | 126 } |
127 | 127 |
128 void CFFL_FormFiller::OnMouseExit(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pA
nnot) | 128 void CFFL_FormFiller::OnMouseExit(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pA
nnot) |
129 { | 129 { |
130 EndTimer(); | 130 EndTimer(); |
131 ASSERT(m_pWidget != NULL); | 131 ASSERT(m_pWidget != NULL); |
132 } | 132 } |
133 | 133 |
134 FX_BOOL CFFL_FormFiller::OnLButtonDown(CPDFSDK_PageView *pPageView, CPDFSDK_Anno
t* pAnnot, FX_UINT nFlags, const CPDF_Point& point) | 134 bool CFFL_FormFiller::OnLButtonDown(CPDFSDK_PageView *pPageView, CPDFSDK_Annot*
pAnnot, FX_UINT nFlags, const CPDF_Point& point) |
135 { | 135 { |
136 if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, TRUE)) | 136 if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, true)) |
137 { | 137 { |
138 m_bValid = TRUE; | 138 m_bValid = true; |
139 FX_RECT rect = GetViewBBox(pPageView,pAnnot); | 139 FX_RECT rect = GetViewBBox(pPageView,pAnnot); |
140 InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); | 140 InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); |
141 | 141 |
142 if(!rect.Contains((int)point.x, (int)point.y)) | 142 if(!rect.Contains((int)point.x, (int)point.y)) |
143 return FALSE; | 143 return false; |
144 | 144 |
145 return pWnd->OnLButtonDown(WndtoPWL(pPageView, point),nFlags); | 145 return pWnd->OnLButtonDown(WndtoPWL(pPageView, point),nFlags); |
146 } | 146 } |
147 | 147 |
148 return FALSE; | 148 return false; |
149 } | 149 } |
150 | 150 |
151 FX_BOOL CFFL_FormFiller::OnLButtonUp(CPDFSDK_PageView *pPageView, CPDFSDK_Annot*
pAnnot, FX_UINT nFlags, const CPDF_Point& point) | 151 bool CFFL_FormFiller::OnLButtonUp(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pA
nnot, FX_UINT nFlags, const CPDF_Point& point) |
152 { | 152 { |
153 if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, FALSE)) | 153 if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, false)) |
154 { | 154 { |
155 FX_RECT rcFFL = GetViewBBox(pPageView, pAnnot); | 155 FX_RECT rcFFL = GetViewBBox(pPageView, pAnnot); |
156 InvalidateRect(rcFFL.left, rcFFL.top, rcFFL.right, rcFFL.bottom); | 156 InvalidateRect(rcFFL.left, rcFFL.top, rcFFL.right, rcFFL.bottom); |
157 pWnd->OnLButtonUp(WndtoPWL(pPageView, point),nFlags); | 157 pWnd->OnLButtonUp(WndtoPWL(pPageView, point),nFlags); |
158 return TRUE; | 158 return true; |
159 } | 159 } |
160 | 160 |
161 return FALSE; | 161 return false; |
162 } | 162 } |
163 | 163 |
164 FX_BOOL CFFL_FormFiller::OnLButtonDblClk(CPDFSDK_PageView *pPageView, CPDFSDK_An
not* pAnnot, FX_UINT nFlags, const CPDF_Point& point) | 164 bool CFFL_FormFiller::OnLButtonDblClk(CPDFSDK_PageView *pPageView, CPDFSDK_Annot
* pAnnot, FX_UINT nFlags, const CPDF_Point& point) |
165 { | 165 { |
166 if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, FALSE)) | 166 if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, false)) |
167 { | 167 { |
168 pWnd->OnLButtonDblClk(WndtoPWL(pPageView, point),nFlags); | 168 pWnd->OnLButtonDblClk(WndtoPWL(pPageView, point),nFlags); |
169 return TRUE; | 169 return true; |
170 } | 170 } |
171 | 171 |
172 return FALSE; | 172 return false; |
173 } | 173 } |
174 | 174 |
175 FX_BOOL CFFL_FormFiller::OnMouseMove(CPDFSDK_PageView *pPageView, CPDFSDK_Annot*
pAnnot, FX_UINT nFlags, const CPDF_Point& point) | 175 bool CFFL_FormFiller::OnMouseMove(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pA
nnot, FX_UINT nFlags, const CPDF_Point& point) |
176 { | 176 { |
177 if ((m_ptOldPos.x != point.x) || (m_ptOldPos.y != point.y)) | 177 if ((m_ptOldPos.x != point.x) || (m_ptOldPos.y != point.y)) |
178 { | 178 { |
179 m_ptOldPos = point; | 179 m_ptOldPos = point; |
180 } | 180 } |
181 | 181 |
182 if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, FALSE)) | 182 if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, false)) |
183 { | 183 { |
184 pWnd->OnMouseMove(WndtoPWL(pPageView, point),nFlags); | 184 pWnd->OnMouseMove(WndtoPWL(pPageView, point),nFlags); |
185 return TRUE; | 185 return true; |
186 } | 186 } |
187 | 187 |
188 return FALSE; | 188 return false; |
189 } | 189 } |
190 | 190 |
191 FX_BOOL CFFL_FormFiller::OnMouseWheel(CPDFSDK_PageView *pPageView, CPDFSDK_Annot
* pAnnot, FX_UINT nFlags, short zDelta, const CPDF_Point& point) | 191 bool CFFL_FormFiller::OnMouseWheel(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* p
Annot, FX_UINT nFlags, short zDelta, const CPDF_Point& point) |
192 { | 192 { |
193 if (!IsValid()) return FALSE; | 193 if (!IsValid()) return false; |
194 | 194 |
195 if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, TRUE)) | 195 if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, true)) |
196 { | 196 { |
197 return pWnd->OnMouseWheel(zDelta, WndtoPWL(pPageView, point),nFlags); | 197 return pWnd->OnMouseWheel(zDelta, WndtoPWL(pPageView, point),nFlags); |
198 } | 198 } |
199 | 199 |
200 return FALSE; | 200 return false; |
201 } | 201 } |
202 | 202 |
203 FX_BOOL CFFL_FormFiller::OnRButtonDown(CPDFSDK_PageView *pPageView, CPDFSDK_Anno
t* pAnnot, FX_UINT nFlags, const CPDF_Point& point) | 203 bool CFFL_FormFiller::OnRButtonDown(CPDFSDK_PageView *pPageView, CPDFSDK_Annot*
pAnnot, FX_UINT nFlags, const CPDF_Point& point) |
204 { | 204 { |
205 if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, TRUE)) | 205 if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, true)) |
206 { | 206 { |
207 pWnd->OnRButtonDown(WndtoPWL(pPageView, point),nFlags); | 207 pWnd->OnRButtonDown(WndtoPWL(pPageView, point),nFlags); |
208 return TRUE; | 208 return true; |
209 } | 209 } |
210 | 210 |
211 return FALSE; | 211 return false; |
212 } | 212 } |
213 | 213 |
214 FX_BOOL CFFL_FormFiller::OnRButtonUp(CPDFSDK_PageView *pPageView, CPDFSDK_Annot*
pAnnot, FX_UINT nFlags, const CPDF_Point& point) | 214 bool CFFL_FormFiller::OnRButtonUp(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pA
nnot, FX_UINT nFlags, const CPDF_Point& point) |
215 { | 215 { |
216 if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, FALSE)) | 216 if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, false)) |
217 { | 217 { |
218 pWnd->OnRButtonUp(WndtoPWL(pPageView, point),nFlags); | 218 pWnd->OnRButtonUp(WndtoPWL(pPageView, point),nFlags); |
219 return TRUE; | 219 return true; |
220 } | 220 } |
221 | 221 |
222 return FALSE; | 222 return false; |
223 } | 223 } |
224 | 224 |
225 FX_BOOL CFFL_FormFiller::OnKeyDown(CPDFSDK_Annot* pAnnot, FX_UINT nKeyCode, FX_U
INT nFlags) | 225 bool CFFL_FormFiller::OnKeyDown(CPDFSDK_Annot* pAnnot, FX_UINT nKeyCode, FX_UINT
nFlags) |
226 { | 226 { |
227 if (IsValid()) | 227 if (IsValid()) |
228 { | 228 { |
229 CPDFSDK_PageView* pPageView = GetCurPageView(); | 229 CPDFSDK_PageView* pPageView = GetCurPageView(); |
230 ASSERT(pPageView != NULL); | 230 ASSERT(pPageView != NULL); |
231 | 231 |
232 if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, FALSE)) | 232 if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, false)) |
233 { | 233 { |
234 return pWnd->OnKeyDown(nKeyCode,nFlags); | 234 return pWnd->OnKeyDown(nKeyCode,nFlags); |
235 } | 235 } |
236 } | 236 } |
237 | 237 |
238 return FALSE; | 238 return false; |
239 } | 239 } |
240 | 240 |
241 FX_BOOL CFFL_FormFiller::OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT nF
lags) | 241 bool CFFL_FormFiller::OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT nFlag
s) |
242 { | 242 { |
243 if (IsValid()) | 243 if (IsValid()) |
244 { | 244 { |
245 CPDFSDK_PageView* pPageView = GetCurPageView(); | 245 CPDFSDK_PageView* pPageView = GetCurPageView(); |
246 ASSERT(pPageView != NULL); | 246 ASSERT(pPageView != NULL); |
247 | 247 |
248 if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, FALSE)) | 248 if (CPWL_Wnd * pWnd = GetPDFWindow(pPageView, false)) |
249 { | 249 { |
250 return pWnd->OnChar(nChar,nFlags); | 250 return pWnd->OnChar(nChar,nFlags); |
251 } | 251 } |
252 } | 252 } |
253 | 253 |
254 return FALSE; | 254 return false; |
255 } | 255 } |
256 | 256 |
257 FX_BOOL CFFL_FormFiller::OnSetFocus(CPDFSDK_Annot* pAnnot, FX_UINT nFlag) | 257 bool CFFL_FormFiller::OnSetFocus(CPDFSDK_Annot* pAnnot, FX_UINT nFlag) |
258 { | 258 { |
259 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; | 259 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; |
260 CPDF_Page* pPage = pWidget->GetPDFPage(); | 260 CPDF_Page* pPage = pWidget->GetPDFPage(); |
261 CPDFSDK_Document* pDoc = m_pApp->GetSDKDocument(); | 261 CPDFSDK_Document* pDoc = m_pApp->GetSDKDocument(); |
262 CPDFSDK_PageView* pPageView = pDoc->GetPageView(pPage); | 262 CPDFSDK_PageView* pPageView = pDoc->GetPageView(pPage); |
263 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, TRUE)) | 263 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, true)) |
264 pWnd->SetFocus(); | 264 pWnd->SetFocus(); |
265 | 265 |
266 m_bValid = TRUE; | 266 m_bValid = true; |
267 FX_RECT rcRect = GetViewBBox(pPageView,pAnnot); | 267 FX_RECT rcRect = GetViewBBox(pPageView,pAnnot); |
268 InvalidateRect(rcRect.left, rcRect.top, rcRect.right, rcRect.bottom); | 268 InvalidateRect(rcRect.left, rcRect.top, rcRect.right, rcRect.bottom); |
269 return TRUE; | 269 return true; |
270 } | 270 } |
271 | 271 |
272 FX_BOOL CFFL_FormFiller::OnKillFocus(CPDFSDK_Annot* pAnnot, FX_UINT nFlag) | 272 bool CFFL_FormFiller::OnKillFocus(CPDFSDK_Annot* pAnnot, FX_UINT nFlag) |
273 { | 273 { |
274 if (!IsValid()) | 274 if (!IsValid()) |
275 return TRUE; | 275 return true; |
276 | 276 |
277 CPDFSDK_PageView* pPageView = GetCurPageView(); | 277 CPDFSDK_PageView* pPageView = GetCurPageView(); |
278 CommitData(pPageView, nFlag); | 278 CommitData(pPageView, nFlag); |
279 | 279 |
280 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) | 280 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, false)) |
281 pWnd->KillFocus(); | 281 pWnd->KillFocus(); |
282 | 282 |
283 switch (m_pWidget->GetFieldType()) | 283 switch (m_pWidget->GetFieldType()) |
284 { | 284 { |
285 case FIELDTYPE_PUSHBUTTON: | 285 case FIELDTYPE_PUSHBUTTON: |
286 case FIELDTYPE_CHECKBOX: | 286 case FIELDTYPE_CHECKBOX: |
287 case FIELDTYPE_RADIOBUTTON: | 287 case FIELDTYPE_RADIOBUTTON: |
288 EscapeFiller(pPageView, TRUE); | 288 EscapeFiller(pPageView, true); |
289 break; | 289 break; |
290 default: | 290 default: |
291 EscapeFiller(pPageView, FALSE); | 291 EscapeFiller(pPageView, false); |
292 break; | 292 break; |
293 } | 293 } |
294 return TRUE; | 294 return true; |
295 } | 295 } |
296 | 296 |
297 FX_BOOL CFFL_FormFiller::IsValid() const | 297 bool CFFL_FormFiller::IsValid() const |
298 { | 298 { |
299 return m_bValid; | 299 return m_bValid; |
300 } | 300 } |
301 | 301 |
302 PWL_CREATEPARAM CFFL_FormFiller::GetCreateParam() | 302 PWL_CREATEPARAM CFFL_FormFiller::GetCreateParam() |
303 { | 303 { |
304 ASSERT(m_pApp != NULL); | 304 ASSERT(m_pApp != NULL); |
305 | 305 |
306 PWL_CREATEPARAM cp; | 306 PWL_CREATEPARAM cp; |
307 cp.pParentWnd = NULL; | 307 cp.pParentWnd = NULL; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 if (cp.fFontSize <= 0) | 363 if (cp.fFontSize <= 0) |
364 { | 364 { |
365 dwCreateFlags |= PWS_AUTOFONTSIZE; | 365 dwCreateFlags |= PWS_AUTOFONTSIZE; |
366 } | 366 } |
367 | 367 |
368 cp.dwFlags = dwCreateFlags; | 368 cp.dwFlags = dwCreateFlags; |
369 cp.pSystemHandler = m_pApp->GetSysHandler(); | 369 cp.pSystemHandler = m_pApp->GetSysHandler(); |
370 return cp; | 370 return cp; |
371 } | 371 } |
372 | 372 |
373 CPWL_Wnd* CFFL_FormFiller::GetPDFWindow(CPDFSDK_PageView* pPageView, FX_BOOL bNe
w) | 373 CPWL_Wnd* CFFL_FormFiller::GetPDFWindow(CPDFSDK_PageView* pPageView, bool bNew) |
374 { | 374 { |
375 ASSERT(pPageView); | 375 ASSERT(pPageView); |
376 | 376 |
377 auto it = m_Maps.find(pPageView); | 377 auto it = m_Maps.find(pPageView); |
378 const bool found = it != m_Maps.end(); | 378 const bool found = it != m_Maps.end(); |
379 CPWL_Wnd* pWnd = found ? it->second : nullptr; | 379 CPWL_Wnd* pWnd = found ? it->second : nullptr; |
380 if (!bNew) | 380 if (!bNew) |
381 return pWnd; | 381 return pWnd; |
382 | 382 |
383 if (found) { | 383 if (found) { |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 | 492 |
493 CPDFSDK_PageView* CFFL_FormFiller::GetCurPageView() | 493 CPDFSDK_PageView* CFFL_FormFiller::GetCurPageView() |
494 { | 494 { |
495 CPDF_Page* pPage = m_pAnnot->GetPDFPage(); | 495 CPDF_Page* pPage = m_pAnnot->GetPDFPage(); |
496 CPDFSDK_Document* pSDKDoc = m_pApp->GetSDKDocument(); | 496 CPDFSDK_Document* pSDKDoc = m_pApp->GetSDKDocument(); |
497 return pSDKDoc ? pSDKDoc->GetPageView(pPage) : nullptr; | 497 return pSDKDoc ? pSDKDoc->GetPageView(pPage) : nullptr; |
498 } | 498 } |
499 | 499 |
500 CPDF_Rect CFFL_FormFiller::GetFocusBox(CPDFSDK_PageView* pPageView) | 500 CPDF_Rect CFFL_FormFiller::GetFocusBox(CPDFSDK_PageView* pPageView) |
501 { | 501 { |
502 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, FALSE)) | 502 if (CPWL_Wnd* pWnd = GetPDFWindow(pPageView, false)) |
503 { | 503 { |
504 CPDF_Rect rcFocus = FFLtoWnd(pPageView, PWLtoFFL(pWnd->GetFocusRect())); | 504 CPDF_Rect rcFocus = FFLtoWnd(pPageView, PWLtoFFL(pWnd->GetFocusRect())); |
505 CPDF_Rect rcPage = pPageView->GetPDFPage()->GetPageBBox(); | 505 CPDF_Rect rcPage = pPageView->GetPDFPage()->GetPageBBox(); |
506 if (rcPage.Contains(rcFocus)) | 506 if (rcPage.Contains(rcFocus)) |
507 return rcFocus; | 507 return rcFocus; |
508 } | 508 } |
509 return CPDF_Rect(0,0,0,0); | 509 return CPDF_Rect(0,0,0,0); |
510 } | 510 } |
511 | 511 |
512 CPDF_Rect CFFL_FormFiller::FFLtoPWL(const CPDF_Rect& rect) | 512 CPDF_Rect CFFL_FormFiller::FFLtoPWL(const CPDF_Rect& rect) |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 CPDF_Point CFFL_FormFiller::WndtoPWL(CPDFSDK_PageView* pPageView, const CPDF_Poi
nt& pt) | 554 CPDF_Point CFFL_FormFiller::WndtoPWL(CPDFSDK_PageView* pPageView, const CPDF_Poi
nt& pt) |
555 { | 555 { |
556 return FFLtoPWL(pt); | 556 return FFLtoPWL(pt); |
557 } | 557 } |
558 | 558 |
559 CPDF_Rect CFFL_FormFiller::FFLtoWnd(CPDFSDK_PageView* pPageView, const CPDF_Rect
& rect) | 559 CPDF_Rect CFFL_FormFiller::FFLtoWnd(CPDFSDK_PageView* pPageView, const CPDF_Rect
& rect) |
560 { | 560 { |
561 return rect; | 561 return rect; |
562 } | 562 } |
563 | 563 |
564 FX_BOOL CFFL_FormFiller::CommitData(CPDFSDK_PageView* pPageView, FX_UINT nFlag) | 564 bool CFFL_FormFiller::CommitData(CPDFSDK_PageView* pPageView, FX_UINT nFlag) |
565 { | 565 { |
566 if (IsDataChanged(pPageView)) | 566 if (IsDataChanged(pPageView)) |
567 { | 567 { |
568 FX_BOOL bRC = TRUE; | 568 bool bRC = true; |
569 FX_BOOL bExit = FALSE; | 569 bool bExit = false; |
570 CFFL_IFormFiller* pIFormFiller = m_pApp->GetIFormFiller(); | 570 CFFL_IFormFiller* pIFormFiller = m_pApp->GetIFormFiller(); |
571 pIFormFiller->OnKeyStrokeCommit(m_pWidget, pPageView, bRC, bExit, nFlag)
; | 571 pIFormFiller->OnKeyStrokeCommit(m_pWidget, pPageView, bRC, bExit, nFlag)
; |
572 if (bExit) | 572 if (bExit) |
573 return TRUE; | 573 return true; |
574 if (!bRC) | 574 if (!bRC) |
575 { | 575 { |
576 ResetPDFWindow(pPageView, FALSE); | 576 ResetPDFWindow(pPageView, false); |
577 return TRUE; | 577 return true; |
578 } | 578 } |
579 | 579 |
580 pIFormFiller->OnValidate(m_pWidget, pPageView, bRC, bExit, nFlag); | 580 pIFormFiller->OnValidate(m_pWidget, pPageView, bRC, bExit, nFlag); |
581 if (bExit) | 581 if (bExit) |
582 return TRUE; | 582 return true; |
583 if (!bRC) | 583 if (!bRC) |
584 { | 584 { |
585 ResetPDFWindow(pPageView, FALSE); | 585 ResetPDFWindow(pPageView, false); |
586 return TRUE; | 586 return true; |
587 } | 587 } |
588 | 588 |
589 SaveData(pPageView); | 589 SaveData(pPageView); |
590 pIFormFiller->OnCalculate(m_pWidget, pPageView, bExit,nFlag); | 590 pIFormFiller->OnCalculate(m_pWidget, pPageView, bExit,nFlag); |
591 if (bExit) | 591 if (bExit) |
592 return TRUE; | 592 return true; |
593 | 593 |
594 pIFormFiller->OnFormat(m_pWidget, pPageView, bExit,nFlag); | 594 pIFormFiller->OnFormat(m_pWidget, pPageView, bExit,nFlag); |
595 } | 595 } |
596 return TRUE; | 596 return true; |
597 } | 597 } |
598 | 598 |
599 FX_BOOL CFFL_FormFiller::IsDataChanged(CPDFSDK_PageView* pPageView) | 599 bool CFFL_FormFiller::IsDataChanged(CPDFSDK_PageView* pPageView) |
600 { | 600 { |
601 return FALSE; | 601 return false; |
602 } | 602 } |
603 | 603 |
604 void CFFL_FormFiller::SaveData(CPDFSDK_PageView* pPageView) | 604 void CFFL_FormFiller::SaveData(CPDFSDK_PageView* pPageView) |
605 { | 605 { |
606 } | 606 } |
607 | 607 |
608 void CFFL_FormFiller::SetChangeMark() | 608 void CFFL_FormFiller::SetChangeMark() |
609 { | 609 { |
610 m_pApp->FFI_OnChange(); | 610 m_pApp->FFI_OnChange(); |
611 } | 611 } |
612 | 612 |
613 void CFFL_FormFiller::GetActionData(CPDFSDK_PageView* pPageView, CPDF_AAction::A
ActionType type, | 613 void CFFL_FormFiller::GetActionData(CPDFSDK_PageView* pPageView, CPDF_AAction::A
ActionType type, |
614 PDFSDK_FieldAction& fa) | 614 PDFSDK_FieldAction& fa) |
615 { | 615 { |
616 fa.sValue = m_pWidget->GetValue(); | 616 fa.sValue = m_pWidget->GetValue(); |
617 } | 617 } |
618 | 618 |
619 void CFFL_FormFiller::SetActionData(CPDFSDK_PageView* pPageView, CPDF_AAction::A
ActionType type, | 619 void CFFL_FormFiller::SetActionData(CPDFSDK_PageView* pPageView, CPDF_AAction::A
ActionType type, |
620 const PDFSDK_FieldAction& fa) | 620 const PDFSDK_FieldAction& fa) |
621 { | 621 { |
622 } | 622 } |
623 | 623 |
624 FX_BOOL CFFL_FormFiller::IsActionDataChanged(CPDF_AAction::AActionType type, con
st PDFSDK_FieldAction& faOld, | 624 bool CFFL_FormFiller::IsActionDataChanged(CPDF_AAction::AActionType type, const
PDFSDK_FieldAction& faOld, |
625 const PDFSDK_FieldAction& faNew) | 625 const PDFSDK_FieldAction& faNew) |
626 { | 626 { |
627 return FALSE; | 627 return false; |
628 } | 628 } |
629 | 629 |
630 void CFFL_FormFiller::SaveState(CPDFSDK_PageView* pPageView) | 630 void CFFL_FormFiller::SaveState(CPDFSDK_PageView* pPageView) |
631 { | 631 { |
632 } | 632 } |
633 | 633 |
634 void CFFL_FormFiller::RestoreState(CPDFSDK_PageView* pPageView) | 634 void CFFL_FormFiller::RestoreState(CPDFSDK_PageView* pPageView) |
635 { | 635 { |
636 } | 636 } |
637 | 637 |
638 CPWL_Wnd* CFFL_FormFiller::ResetPDFWindow(CPDFSDK_PageView* pPageView, FX_BOOL
bRestoreValue) | 638 CPWL_Wnd* CFFL_FormFiller::ResetPDFWindow(CPDFSDK_PageView* pPageView, bool bRe
storeValue) |
639 { | 639 { |
640 return GetPDFWindow(pPageView, FALSE); | 640 return GetPDFWindow(pPageView, false); |
641 } | 641 } |
642 | 642 |
643 void CFFL_FormFiller::TimerProc() | 643 void CFFL_FormFiller::TimerProc() |
644 { | 644 { |
645 | 645 |
646 } | 646 } |
647 | 647 |
648 IFX_SystemHandler* CFFL_FormFiller::GetSystemHandler() const | 648 IFX_SystemHandler* CFFL_FormFiller::GetSystemHandler() const |
649 { | 649 { |
650 return m_pApp->GetSysHandler(); | 650 return m_pApp->GetSysHandler(); |
651 } | 651 } |
652 | 652 |
653 void CFFL_FormFiller::OnKeyStroke(FX_BOOL bKeyDown) | 653 void CFFL_FormFiller::OnKeyStroke(bool bKeyDown) |
654 { | 654 { |
655 } | 655 } |
656 | 656 |
657 void CFFL_FormFiller::EscapeFiller(CPDFSDK_PageView* pPageView, FX_BOOL bDestroy
PDFWindow) | 657 void CFFL_FormFiller::EscapeFiller(CPDFSDK_PageView* pPageView, bool bDestroyPDF
Window) |
658 { | 658 { |
659 m_bValid = FALSE; | 659 m_bValid = false; |
660 | 660 |
661 FX_RECT rcRect = GetViewBBox(pPageView, m_pWidget); | 661 FX_RECT rcRect = GetViewBBox(pPageView, m_pWidget); |
662 InvalidateRect(rcRect.left, rcRect.top, rcRect.right, rcRect.bottom); | 662 InvalidateRect(rcRect.left, rcRect.top, rcRect.right, rcRect.bottom); |
663 | 663 |
664 if(bDestroyPDFWindow) | 664 if(bDestroyPDFWindow) |
665 DestroyPDFWindow(pPageView); | 665 DestroyPDFWindow(pPageView); |
666 } | 666 } |
667 | 667 |
668 FX_BOOL CFFL_FormFiller::CanCopy(CPDFSDK_Document* pDocument) | 668 bool CFFL_FormFiller::CanCopy(CPDFSDK_Document* pDocument) |
669 { | 669 { |
670 return FALSE; | 670 return false; |
671 } | 671 } |
672 | 672 |
673 FX_BOOL CFFL_FormFiller::CanCut(CPDFSDK_Document* pDocument) | 673 bool CFFL_FormFiller::CanCut(CPDFSDK_Document* pDocument) |
674 { | 674 { |
675 return FALSE; | 675 return false; |
676 } | 676 } |
677 | 677 |
678 FX_BOOL CFFL_FormFiller::CanPaste(CPDFSDK_Document* pDocument) | 678 bool CFFL_FormFiller::CanPaste(CPDFSDK_Document* pDocument) |
679 { | 679 { |
680 return FALSE; | 680 return false; |
681 } | 681 } |
682 | 682 |
683 void CFFL_FormFiller::DoCopy(CPDFSDK_Document* pDocument) | 683 void CFFL_FormFiller::DoCopy(CPDFSDK_Document* pDocument) |
684 { | 684 { |
685 } | 685 } |
686 | 686 |
687 void CFFL_FormFiller::DoCut(CPDFSDK_Document* pDocument) | 687 void CFFL_FormFiller::DoCut(CPDFSDK_Document* pDocument) |
688 { | 688 { |
689 } | 689 } |
690 | 690 |
691 void CFFL_FormFiller::DoPaste(CPDFSDK_Document* pDocument) | 691 void CFFL_FormFiller::DoPaste(CPDFSDK_Document* pDocument) |
692 { | 692 { |
693 } | 693 } |
694 | 694 |
695 void CFFL_FormFiller::InvalidateRect(double left, double top, double right, doub
le bottom) | 695 void CFFL_FormFiller::InvalidateRect(double left, double top, double right, doub
le bottom) |
696 { | 696 { |
697 CPDF_Page * pPage = m_pWidget->GetPDFPage(); | 697 CPDF_Page * pPage = m_pWidget->GetPDFPage(); |
698 m_pApp->FFI_Invalidate(pPage, left, top, right, bottom); | 698 m_pApp->FFI_Invalidate(pPage, left, top, right, bottom); |
699 } | 699 } |
700 | 700 |
701 /* ------------------------- CFFL_Button ------------------------- */ | 701 /* ------------------------- CFFL_Button ------------------------- */ |
702 | 702 |
703 CFFL_Button::CFFL_Button(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pWidget) : | 703 CFFL_Button::CFFL_Button(CPDFDoc_Environment* pApp, CPDFSDK_Annot* pWidget) : |
704 CFFL_FormFiller(pApp, pWidget), | 704 CFFL_FormFiller(pApp, pWidget), |
705 m_bMouseIn(FALSE), | 705 m_bMouseIn(false), |
706 m_bMouseDown(FALSE) | 706 m_bMouseDown(false) |
707 { | 707 { |
708 } | 708 } |
709 | 709 |
710 CFFL_Button::~CFFL_Button() | 710 CFFL_Button::~CFFL_Button() |
711 { | 711 { |
712 } | 712 } |
713 | 713 |
714 void CFFL_Button::OnMouseEnter(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnno
t) | 714 void CFFL_Button::OnMouseEnter(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnno
t) |
715 { | 715 { |
716 m_bMouseIn = TRUE; | 716 m_bMouseIn = true; |
717 FX_RECT rect = GetViewBBox(pPageView,pAnnot); | 717 FX_RECT rect = GetViewBBox(pPageView,pAnnot); |
718 InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); | 718 InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); |
719 } | 719 } |
720 | 720 |
721 void CFFL_Button::OnMouseExit(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot
) | 721 void CFFL_Button::OnMouseExit(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot
) |
722 { | 722 { |
723 m_bMouseIn = FALSE; | 723 m_bMouseIn = false; |
724 | 724 |
725 FX_RECT rect = GetViewBBox(pPageView,pAnnot); | 725 FX_RECT rect = GetViewBBox(pPageView,pAnnot); |
726 InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); | 726 InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); |
727 EndTimer(); | 727 EndTimer(); |
728 ASSERT(m_pWidget != NULL); | 728 ASSERT(m_pWidget != NULL); |
729 } | 729 } |
730 | 730 |
731 FX_BOOL CFFL_Button::OnLButtonDown(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* p
Annot, FX_UINT nFlags, const CPDF_Point& point) | 731 bool CFFL_Button::OnLButtonDown(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnn
ot, FX_UINT nFlags, const CPDF_Point& point) |
732 { | 732 { |
733 CPDF_Rect rcAnnot = pAnnot->GetRect(); | 733 CPDF_Rect rcAnnot = pAnnot->GetRect(); |
734 if(!rcAnnot.Contains(point.x, point.y)) | 734 if(!rcAnnot.Contains(point.x, point.y)) |
735 return FALSE; | 735 return false; |
736 | 736 |
737 m_bMouseDown = TRUE; | 737 m_bMouseDown = true; |
738 m_bValid = TRUE; | 738 m_bValid = true; |
739 FX_RECT rect = GetViewBBox(pPageView, pAnnot); | 739 FX_RECT rect = GetViewBBox(pPageView, pAnnot); |
740 InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); | 740 InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); |
741 return TRUE; | 741 return true; |
742 } | 742 } |
743 | 743 |
744 FX_BOOL CFFL_Button::OnLButtonUp(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAn
not, FX_UINT nFlags, const CPDF_Point& point) | 744 bool CFFL_Button::OnLButtonUp(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot
, FX_UINT nFlags, const CPDF_Point& point) |
745 { | 745 { |
746 CPDF_Rect rcAnnot = pAnnot->GetRect(); | 746 CPDF_Rect rcAnnot = pAnnot->GetRect(); |
747 if(!rcAnnot.Contains(point.x, point.y)) | 747 if(!rcAnnot.Contains(point.x, point.y)) |
748 return FALSE; | 748 return false; |
749 | 749 |
750 m_bMouseDown = FALSE; | 750 m_bMouseDown = false; |
751 m_pWidget->GetPDFPage(); | 751 m_pWidget->GetPDFPage(); |
752 | 752 |
753 | 753 |
754 FX_RECT rect = GetViewBBox(pPageView, pAnnot); | 754 FX_RECT rect = GetViewBBox(pPageView, pAnnot); |
755 InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); | 755 InvalidateRect(rect.left, rect.top, rect.right, rect.bottom); |
756 return TRUE; | 756 return true; |
757 } | 757 } |
758 | 758 |
759 FX_BOOL CFFL_Button::OnMouseMove(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAn
not, FX_UINT nFlags, const CPDF_Point& point) | 759 bool CFFL_Button::OnMouseMove(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot
, FX_UINT nFlags, const CPDF_Point& point) |
760 { | 760 { |
761 ASSERT(m_pApp != NULL); | 761 ASSERT(m_pApp != NULL); |
762 | 762 |
763 return TRUE; | 763 return true; |
764 } | 764 } |
765 | 765 |
766 void CFFL_Button::OnDraw(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, | 766 void CFFL_Button::OnDraw(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAnnot, |
767 CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, | 767 CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, |
768 FX_DWORD dwFlags) | 768 FX_DWORD dwFlags) |
769 { | 769 { |
770 ASSERT(pPageView != NULL); | 770 ASSERT(pPageView != NULL); |
771 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; | 771 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; |
772 CPDF_FormControl* pCtrl = pWidget->GetFormControl(); | 772 CPDF_FormControl* pCtrl = pWidget->GetFormControl(); |
773 CPDF_FormControl::HighlightingMode eHM = pCtrl->GetHighlightingMode(); | 773 CPDF_FormControl::HighlightingMode eHM = pCtrl->GetHighlightingMode(); |
(...skipping 23 matching lines...) Expand all Loading... |
797 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL)
; | 797 pWidget->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, NULL)
; |
798 } | 798 } |
799 | 799 |
800 | 800 |
801 void CFFL_Button::OnDrawDeactive(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAn
not, | 801 void CFFL_Button::OnDrawDeactive(CPDFSDK_PageView *pPageView, CPDFSDK_Annot* pAn
not, |
802 CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2D
evice, | 802 CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2D
evice, |
803 FX_DWORD dwFlags) | 803 FX_DWORD dwFlags) |
804 { | 804 { |
805 OnDraw(pPageView, pAnnot, pDevice, pUser2Device, dwFlags); | 805 OnDraw(pPageView, pAnnot, pDevice, pUser2Device, dwFlags); |
806 } | 806 } |
OLD | NEW |