| 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_xfawidgethandler.h" | 7 #include "fpdfsdk/include/cpdfsdk_xfawidgethandler.h" |
| 8 | 8 |
| 9 #include "core/fpdfdoc/include/cpdf_interform.h" | 9 #include "core/fpdfdoc/include/cpdf_interform.h" |
| 10 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h" | 10 #include "fpdfsdk/fpdfxfa/include/fpdfxfa_doc.h" |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 CXFA_FFWidgetHandler* pWidgetHandler = pDocView->GetWidgetHandler(); | 131 CXFA_FFWidgetHandler* pWidgetHandler = pDocView->GetWidgetHandler(); |
| 132 if (!pWidgetHandler) | 132 if (!pWidgetHandler) |
| 133 return FALSE; | 133 return FALSE; |
| 134 | 134 |
| 135 FWL_WidgetHit dwHitTest = | 135 FWL_WidgetHit dwHitTest = |
| 136 pWidgetHandler->OnHitTest(pAnnot->GetXFAWidget(), point.x, point.y); | 136 pWidgetHandler->OnHitTest(pAnnot->GetXFAWidget(), point.x, point.y); |
| 137 return dwHitTest != FWL_WidgetHit::Unknown; | 137 return dwHitTest != FWL_WidgetHit::Unknown; |
| 138 } | 138 } |
| 139 | 139 |
| 140 void CPDFSDK_XFAWidgetHandler::OnMouseEnter(CPDFSDK_PageView* pPageView, | 140 void CPDFSDK_XFAWidgetHandler::OnMouseEnter(CPDFSDK_PageView* pPageView, |
| 141 CPDFSDK_Annot* pAnnot, | 141 CPDFSDK_Annot::ObservedPtr* pAnnot, |
| 142 uint32_t nFlag) { | 142 uint32_t nFlag) { |
| 143 if (!pPageView || !pAnnot) | 143 if (!pPageView || !(*pAnnot)) |
| 144 return; | 144 return; |
| 145 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); | 145 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot->Get()); |
| 146 pWidgetHandler->OnMouseEnter(pAnnot->GetXFAWidget()); | 146 pWidgetHandler->OnMouseEnter((*pAnnot)->GetXFAWidget()); |
| 147 } | 147 } |
| 148 | 148 |
| 149 void CPDFSDK_XFAWidgetHandler::OnMouseExit(CPDFSDK_PageView* pPageView, | 149 void CPDFSDK_XFAWidgetHandler::OnMouseExit(CPDFSDK_PageView* pPageView, |
| 150 CPDFSDK_Annot* pAnnot, | 150 CPDFSDK_Annot::ObservedPtr* pAnnot, |
| 151 uint32_t nFlag) { | 151 uint32_t nFlag) { |
| 152 if (!pPageView || !pAnnot) | 152 if (!pPageView || !(*pAnnot)) |
| 153 return; | 153 return; |
| 154 | 154 |
| 155 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); | 155 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot->Get()); |
| 156 pWidgetHandler->OnMouseExit(pAnnot->GetXFAWidget()); | 156 pWidgetHandler->OnMouseExit((*pAnnot)->GetXFAWidget()); |
| 157 } | 157 } |
| 158 | 158 |
| 159 FX_BOOL CPDFSDK_XFAWidgetHandler::OnLButtonDown(CPDFSDK_PageView* pPageView, | 159 FX_BOOL CPDFSDK_XFAWidgetHandler::OnLButtonDown( |
| 160 CPDFSDK_Annot* pAnnot, | 160 CPDFSDK_PageView* pPageView, |
| 161 uint32_t nFlags, | 161 CPDFSDK_Annot::ObservedPtr* pAnnot, |
| 162 const CFX_FloatPoint& point) { | 162 uint32_t nFlags, |
| 163 if (!pPageView || !pAnnot) | 163 const CFX_FloatPoint& point) { |
| 164 if (!pPageView || !(*pAnnot)) |
| 164 return FALSE; | 165 return FALSE; |
| 165 | 166 |
| 166 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); | 167 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot->Get()); |
| 167 return pWidgetHandler->OnLButtonDown(pAnnot->GetXFAWidget(), | 168 return pWidgetHandler->OnLButtonDown((*pAnnot)->GetXFAWidget(), |
| 168 GetFWLFlags(nFlags), point.x, point.y); | 169 GetFWLFlags(nFlags), point.x, point.y); |
| 169 } | 170 } |
| 170 | 171 |
| 171 FX_BOOL CPDFSDK_XFAWidgetHandler::OnLButtonUp(CPDFSDK_PageView* pPageView, | 172 FX_BOOL CPDFSDK_XFAWidgetHandler::OnLButtonUp( |
| 172 CPDFSDK_Annot* pAnnot, | 173 CPDFSDK_PageView* pPageView, |
| 173 uint32_t nFlags, | 174 CPDFSDK_Annot::ObservedPtr* pAnnot, |
| 174 const CFX_FloatPoint& point) { | 175 uint32_t nFlags, |
| 175 if (!pPageView || !pAnnot) | 176 const CFX_FloatPoint& point) { |
| 177 if (!pPageView || !(*pAnnot)) |
| 176 return FALSE; | 178 return FALSE; |
| 177 | 179 |
| 178 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); | 180 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot->Get()); |
| 179 return pWidgetHandler->OnLButtonUp(pAnnot->GetXFAWidget(), | 181 return pWidgetHandler->OnLButtonUp((*pAnnot)->GetXFAWidget(), |
| 180 GetFWLFlags(nFlags), point.x, point.y); | 182 GetFWLFlags(nFlags), point.x, point.y); |
| 181 } | 183 } |
| 182 | 184 |
| 183 FX_BOOL CPDFSDK_XFAWidgetHandler::OnLButtonDblClk(CPDFSDK_PageView* pPageView, | 185 FX_BOOL CPDFSDK_XFAWidgetHandler::OnLButtonDblClk( |
| 184 CPDFSDK_Annot* pAnnot, | 186 CPDFSDK_PageView* pPageView, |
| 185 uint32_t nFlags, | 187 CPDFSDK_Annot::ObservedPtr* pAnnot, |
| 186 const CFX_FloatPoint& point) { | 188 uint32_t nFlags, |
| 187 if (!pPageView || !pAnnot) | 189 const CFX_FloatPoint& point) { |
| 190 if (!pPageView || !(*pAnnot)) |
| 188 return FALSE; | 191 return FALSE; |
| 189 | 192 |
| 190 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); | 193 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot->Get()); |
| 191 return pWidgetHandler->OnLButtonDblClk(pAnnot->GetXFAWidget(), | 194 return pWidgetHandler->OnLButtonDblClk((*pAnnot)->GetXFAWidget(), |
| 192 GetFWLFlags(nFlags), point.x, point.y); | 195 GetFWLFlags(nFlags), point.x, point.y); |
| 193 } | 196 } |
| 194 | 197 |
| 195 FX_BOOL CPDFSDK_XFAWidgetHandler::OnMouseMove(CPDFSDK_PageView* pPageView, | 198 FX_BOOL CPDFSDK_XFAWidgetHandler::OnMouseMove( |
| 196 CPDFSDK_Annot* pAnnot, | 199 CPDFSDK_PageView* pPageView, |
| 197 uint32_t nFlags, | 200 CPDFSDK_Annot::ObservedPtr* pAnnot, |
| 198 const CFX_FloatPoint& point) { | 201 uint32_t nFlags, |
| 199 if (!pPageView || !pAnnot) | 202 const CFX_FloatPoint& point) { |
| 203 if (!pPageView || !(*pAnnot)) |
| 200 return FALSE; | 204 return FALSE; |
| 201 | 205 |
| 202 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); | 206 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot->Get()); |
| 203 return pWidgetHandler->OnMouseMove(pAnnot->GetXFAWidget(), | 207 return pWidgetHandler->OnMouseMove((*pAnnot)->GetXFAWidget(), |
| 204 GetFWLFlags(nFlags), point.x, point.y); | 208 GetFWLFlags(nFlags), point.x, point.y); |
| 205 } | 209 } |
| 206 | 210 |
| 207 FX_BOOL CPDFSDK_XFAWidgetHandler::OnMouseWheel(CPDFSDK_PageView* pPageView, | 211 FX_BOOL CPDFSDK_XFAWidgetHandler::OnMouseWheel( |
| 208 CPDFSDK_Annot* pAnnot, | 212 CPDFSDK_PageView* pPageView, |
| 209 uint32_t nFlags, | 213 CPDFSDK_Annot::ObservedPtr* pAnnot, |
| 210 short zDelta, | 214 uint32_t nFlags, |
| 211 const CFX_FloatPoint& point) { | 215 short zDelta, |
| 212 if (!pPageView || !pAnnot) | 216 const CFX_FloatPoint& point) { |
| 217 if (!pPageView || !(*pAnnot)) |
| 213 return FALSE; | 218 return FALSE; |
| 214 | 219 |
| 215 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); | 220 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot->Get()); |
| 216 return pWidgetHandler->OnMouseWheel( | 221 return pWidgetHandler->OnMouseWheel( |
| 217 pAnnot->GetXFAWidget(), GetFWLFlags(nFlags), zDelta, point.x, point.y); | 222 (*pAnnot)->GetXFAWidget(), GetFWLFlags(nFlags), zDelta, point.x, point.y); |
| 218 } | 223 } |
| 219 | 224 |
| 220 FX_BOOL CPDFSDK_XFAWidgetHandler::OnRButtonDown(CPDFSDK_PageView* pPageView, | 225 FX_BOOL CPDFSDK_XFAWidgetHandler::OnRButtonDown( |
| 221 CPDFSDK_Annot* pAnnot, | 226 CPDFSDK_PageView* pPageView, |
| 222 uint32_t nFlags, | 227 CPDFSDK_Annot::ObservedPtr* pAnnot, |
| 223 const CFX_FloatPoint& point) { | 228 uint32_t nFlags, |
| 224 if (!pPageView || !pAnnot) | 229 const CFX_FloatPoint& point) { |
| 230 if (!pPageView || !(*pAnnot)) |
| 225 return FALSE; | 231 return FALSE; |
| 226 | 232 |
| 227 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); | 233 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot->Get()); |
| 228 return pWidgetHandler->OnRButtonDown(pAnnot->GetXFAWidget(), | 234 return pWidgetHandler->OnRButtonDown((*pAnnot)->GetXFAWidget(), |
| 229 GetFWLFlags(nFlags), point.x, point.y); | 235 GetFWLFlags(nFlags), point.x, point.y); |
| 230 } | 236 } |
| 231 | 237 |
| 232 FX_BOOL CPDFSDK_XFAWidgetHandler::OnRButtonUp(CPDFSDK_PageView* pPageView, | 238 FX_BOOL CPDFSDK_XFAWidgetHandler::OnRButtonUp( |
| 233 CPDFSDK_Annot* pAnnot, | 239 CPDFSDK_PageView* pPageView, |
| 234 uint32_t nFlags, | 240 CPDFSDK_Annot::ObservedPtr* pAnnot, |
| 235 const CFX_FloatPoint& point) { | 241 uint32_t nFlags, |
| 236 if (!pPageView || !pAnnot) | 242 const CFX_FloatPoint& point) { |
| 243 if (!pPageView || !(*pAnnot)) |
| 237 return FALSE; | 244 return FALSE; |
| 238 | 245 |
| 239 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); | 246 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot->Get()); |
| 240 return pWidgetHandler->OnRButtonUp(pAnnot->GetXFAWidget(), | 247 return pWidgetHandler->OnRButtonUp((*pAnnot)->GetXFAWidget(), |
| 241 GetFWLFlags(nFlags), point.x, point.y); | 248 GetFWLFlags(nFlags), point.x, point.y); |
| 242 } | 249 } |
| 243 | 250 |
| 244 FX_BOOL CPDFSDK_XFAWidgetHandler::OnRButtonDblClk(CPDFSDK_PageView* pPageView, | 251 FX_BOOL CPDFSDK_XFAWidgetHandler::OnRButtonDblClk( |
| 245 CPDFSDK_Annot* pAnnot, | 252 CPDFSDK_PageView* pPageView, |
| 246 uint32_t nFlags, | 253 CPDFSDK_Annot::ObservedPtr* pAnnot, |
| 247 const CFX_FloatPoint& point) { | 254 uint32_t nFlags, |
| 248 if (!pPageView || !pAnnot) | 255 const CFX_FloatPoint& point) { |
| 256 if (!pPageView || !(*pAnnot)) |
| 249 return FALSE; | 257 return FALSE; |
| 250 | 258 |
| 251 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); | 259 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot->Get()); |
| 252 return pWidgetHandler->OnRButtonDblClk(pAnnot->GetXFAWidget(), | 260 return pWidgetHandler->OnRButtonDblClk((*pAnnot)->GetXFAWidget(), |
| 253 GetFWLFlags(nFlags), point.x, point.y); | 261 GetFWLFlags(nFlags), point.x, point.y); |
| 254 } | 262 } |
| 255 | 263 |
| 256 FX_BOOL CPDFSDK_XFAWidgetHandler::OnChar(CPDFSDK_Annot* pAnnot, | 264 FX_BOOL CPDFSDK_XFAWidgetHandler::OnChar(CPDFSDK_Annot* pAnnot, |
| 257 uint32_t nChar, | 265 uint32_t nChar, |
| 258 uint32_t nFlags) { | 266 uint32_t nFlags) { |
| 259 if (!pAnnot) | 267 if (!pAnnot) |
| 260 return FALSE; | 268 return FALSE; |
| 261 | 269 |
| 262 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); | 270 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 283 | 291 |
| 284 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); | 292 CXFA_FFWidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); |
| 285 return pWidgetHandler->OnKeyUp(pAnnot->GetXFAWidget(), nKeyCode, | 293 return pWidgetHandler->OnKeyUp(pAnnot->GetXFAWidget(), nKeyCode, |
| 286 GetFWLFlags(nFlag)); | 294 GetFWLFlags(nFlag)); |
| 287 } | 295 } |
| 288 | 296 |
| 289 void CPDFSDK_XFAWidgetHandler::OnDeSelected(CPDFSDK_Annot* pAnnot) {} | 297 void CPDFSDK_XFAWidgetHandler::OnDeSelected(CPDFSDK_Annot* pAnnot) {} |
| 290 | 298 |
| 291 void CPDFSDK_XFAWidgetHandler::OnSelected(CPDFSDK_Annot* pAnnot) {} | 299 void CPDFSDK_XFAWidgetHandler::OnSelected(CPDFSDK_Annot* pAnnot) {} |
| 292 | 300 |
| 293 FX_BOOL CPDFSDK_XFAWidgetHandler::OnSetFocus(CPDFSDK_Annot* pAnnot, | 301 FX_BOOL CPDFSDK_XFAWidgetHandler::OnSetFocus(CPDFSDK_Annot::ObservedPtr* pAnnot, |
| 294 uint32_t nFlag) { | 302 uint32_t nFlag) { |
| 295 return TRUE; | 303 return TRUE; |
| 296 } | 304 } |
| 297 | 305 |
| 298 FX_BOOL CPDFSDK_XFAWidgetHandler::OnKillFocus(CPDFSDK_Annot* pAnnot, | 306 FX_BOOL CPDFSDK_XFAWidgetHandler::OnKillFocus( |
| 299 uint32_t nFlag) { | 307 CPDFSDK_Annot::ObservedPtr* pAnnot, |
| 308 uint32_t nFlag) { |
| 300 return TRUE; | 309 return TRUE; |
| 301 } | 310 } |
| 302 | 311 |
| 303 FX_BOOL CPDFSDK_XFAWidgetHandler::OnXFAChangedFocus(CPDFSDK_Annot* pOldAnnot, | 312 FX_BOOL CPDFSDK_XFAWidgetHandler::OnXFAChangedFocus( |
| 304 CPDFSDK_Annot* pNewAnnot) { | 313 CPDFSDK_Annot::ObservedPtr* pOldAnnot, |
| 314 CPDFSDK_Annot::ObservedPtr* pNewAnnot) { |
| 305 CXFA_FFWidgetHandler* pWidgetHandler = nullptr; | 315 CXFA_FFWidgetHandler* pWidgetHandler = nullptr; |
| 316 if (*pOldAnnot) |
| 317 pWidgetHandler = GetXFAWidgetHandler(pOldAnnot->Get()); |
| 318 else if (*pNewAnnot) |
| 319 pWidgetHandler = GetXFAWidgetHandler(pNewAnnot->Get()); |
| 306 | 320 |
| 307 if (pOldAnnot) | 321 if (!pWidgetHandler) |
| 308 pWidgetHandler = GetXFAWidgetHandler(pOldAnnot); | 322 return TRUE; |
| 309 else if (pNewAnnot) | |
| 310 pWidgetHandler = GetXFAWidgetHandler(pNewAnnot); | |
| 311 | 323 |
| 312 if (pWidgetHandler) { | 324 CXFA_FFWidget* hWidget = *pNewAnnot ? (*pNewAnnot)->GetXFAWidget() : nullptr; |
| 313 FX_BOOL bRet = TRUE; | 325 if (!hWidget) |
| 314 CXFA_FFWidget* hWidget = pNewAnnot ? pNewAnnot->GetXFAWidget() : nullptr; | 326 return TRUE; |
| 315 if (hWidget) { | |
| 316 CXFA_FFPageView* pXFAPageView = hWidget->GetPageView(); | |
| 317 if (pXFAPageView) { | |
| 318 bRet = pXFAPageView->GetDocView()->SetFocus(hWidget); | |
| 319 if (pXFAPageView->GetDocView()->GetFocusWidget() == hWidget) | |
| 320 bRet = TRUE; | |
| 321 } | |
| 322 } | |
| 323 return bRet; | |
| 324 } | |
| 325 | 327 |
| 326 return TRUE; | 328 CXFA_FFPageView* pXFAPageView = hWidget->GetPageView(); |
| 329 if (!pXFAPageView) |
| 330 return TRUE; |
| 331 |
| 332 FX_BOOL bRet = pXFAPageView->GetDocView()->SetFocus(hWidget); |
| 333 if (pXFAPageView->GetDocView()->GetFocusWidget() == hWidget) |
| 334 bRet = TRUE; |
| 335 |
| 336 return bRet; |
| 327 } | 337 } |
| 328 | 338 |
| 329 CXFA_FFWidgetHandler* CPDFSDK_XFAWidgetHandler::GetXFAWidgetHandler( | 339 CXFA_FFWidgetHandler* CPDFSDK_XFAWidgetHandler::GetXFAWidgetHandler( |
| 330 CPDFSDK_Annot* pAnnot) { | 340 CPDFSDK_Annot* pAnnot) { |
| 331 if (!pAnnot) | 341 if (!pAnnot) |
| 332 return nullptr; | 342 return nullptr; |
| 333 | 343 |
| 334 CPDFSDK_PageView* pPageView = pAnnot->GetPageView(); | 344 CPDFSDK_PageView* pPageView = pAnnot->GetPageView(); |
| 335 if (!pPageView) | 345 if (!pPageView) |
| 336 return nullptr; | 346 return nullptr; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 dwFWLFlag |= FWL_KEYFLAG_MButton; | 378 dwFWLFlag |= FWL_KEYFLAG_MButton; |
| 369 if (dwFlag & FWL_EVENTFLAG_RightButtonDown) | 379 if (dwFlag & FWL_EVENTFLAG_RightButtonDown) |
| 370 dwFWLFlag |= FWL_KEYFLAG_RButton; | 380 dwFWLFlag |= FWL_KEYFLAG_RButton; |
| 371 if (dwFlag & FWL_EVENTFLAG_ShiftKey) | 381 if (dwFlag & FWL_EVENTFLAG_ShiftKey) |
| 372 dwFWLFlag |= FWL_KEYFLAG_Shift; | 382 dwFWLFlag |= FWL_KEYFLAG_Shift; |
| 373 if (dwFlag & FWL_EVENTFLAG_AltKey) | 383 if (dwFlag & FWL_EVENTFLAG_AltKey) |
| 374 dwFWLFlag |= FWL_KEYFLAG_Alt; | 384 dwFWLFlag |= FWL_KEYFLAG_Alt; |
| 375 | 385 |
| 376 return dwFWLFlag; | 386 return dwFWLFlag; |
| 377 } | 387 } |
| OLD | NEW |