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/fpdfxfa/fpdfxfa_doc.h" | 8 #include "../include/fpdfxfa/fpdfxfa_doc.h" |
9 #include "../include/fpdfxfa/fpdfxfa_util.h" | 9 #include "../include/fpdfxfa/fpdfxfa_util.h" |
10 #include "../include/fsdk_mgr.h" | 10 #include "../include/fsdk_mgr.h" |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 | 302 |
303 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnSetFocus(CPDFSDK_Annot* pAnnot,
FX_DWORD nFlag) | 303 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnSetFocus(CPDFSDK_Annot* pAnnot,
FX_DWORD nFlag) |
304 { | 304 { |
305 ASSERT(pAnnot != NULL); | 305 ASSERT(pAnnot != NULL); |
306 | 306 |
307 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) | 307 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) |
308 { | 308 { |
309 if (pAnnotHandler->OnSetFocus(pAnnot, nFlag)) | 309 if (pAnnotHandler->OnSetFocus(pAnnot, nFlag)) |
310 { | 310 { |
311 CPDFSDK_PageView* pPage = pAnnot->GetPageView(); | 311 CPDFSDK_PageView* pPage = pAnnot->GetPageView(); |
312 ASSERT(pPage != NULL); | |
313 | |
314 pPage->GetSDKDocument(); | 312 pPage->GetSDKDocument(); |
315 // pDocument->SetTopmostAnnot(pAnnot); | |
316 | |
317 return TRUE; | 313 return TRUE; |
318 } | 314 } |
319 else | |
320 { | |
321 return FALSE; | |
322 } | |
323 } | 315 } |
324 | |
325 return FALSE; | 316 return FALSE; |
326 } | 317 } |
327 | 318 |
328 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnKillFocus(CPDFSDK_Annot* pAnnot
, FX_DWORD nFlag) | 319 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnKillFocus(CPDFSDK_Annot* pAnnot
, FX_DWORD nFlag) |
329 { | 320 { |
330 ASSERT(pAnnot != NULL); | 321 ASSERT(pAnnot); |
331 | |
332 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) | 322 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) |
333 { | 323 return pAnnotHandler->OnKillFocus(pAnnot, nFlag); |
334 if (pAnnotHandler->OnKillFocus(pAnnot, nFlag)) | |
335 { | |
336 return TRUE; | |
337 } | |
338 else | |
339 return FALSE; | |
340 } | |
341 | 324 |
342 return FALSE; | 325 return FALSE; |
343 } | 326 } |
344 | 327 |
345 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnChangeFocus(CPDFSDK_Annot* pSetAnnot,CP
DFSDK_Annot* pKillAnnot) | 328 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnChangeFocus(CPDFSDK_Annot* pSetAnnot,CP
DFSDK_Annot* pKillAnnot) |
346 { | 329 { |
347 FX_BOOL bXFA = (pSetAnnot && pSetAnnot->GetXFAWidget()) || | 330 FX_BOOL bXFA = (pSetAnnot && pSetAnnot->GetXFAWidget()) || |
348 (pKillAnnot && pKillAnnot->GetXFAWidget()); | 331 (pKillAnnot && pKillAnnot->GetXFAWidget()); |
349 | 332 |
350 if (bXFA) | 333 if (bXFA) |
351 { | 334 { |
352 if (IPDFSDK_AnnotHandler* pXFAAnnotHandler = GetAnnotHandler(FSDK_XFAWID
GET_TYPENAME)) | 335 if (IPDFSDK_AnnotHandler* pXFAAnnotHandler = GetAnnotHandler(FSDK_XFAWID
GET_TYPENAME)) |
353 return pXFAAnnotHandler->OnXFAChangedFocus(pKillAnnot, pSetAnnot); | 336 return pXFAAnnotHandler->OnXFAChangedFocus(pKillAnnot, pSetAnnot); |
354 } | 337 } |
355 | 338 |
356 return TRUE; | 339 return TRUE; |
357 } | 340 } |
358 | 341 |
359 CPDF_Rect CPDFSDK_AnnotHandlerMgr::Annot_OnGetViewBBox(CPDFSDK_PageView *pPage
View, CPDFSDK_Annot* pAnnot) | 342 CPDF_Rect CPDFSDK_AnnotHandlerMgr::Annot_OnGetViewBBox(CPDFSDK_PageView *pPage
View, CPDFSDK_Annot* pAnnot) |
360 { | 343 { |
361 ASSERT(pAnnot); | 344 ASSERT(pAnnot); |
362 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) | 345 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) |
363 { | |
364 return pAnnotHandler->GetViewBBox(pPageView, pAnnot); | 346 return pAnnotHandler->GetViewBBox(pPageView, pAnnot); |
365 } | 347 |
366 return pAnnot->GetRect(); | 348 return pAnnot->GetRect(); |
367 } | 349 } |
368 | 350 |
369 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnHitTest(CPDFSDK_PageView *pPageView, CP
DFSDK_Annot* pAnnot, const CPDF_Point& point) | 351 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnHitTest(CPDFSDK_PageView *pPageView, CP
DFSDK_Annot* pAnnot, const CPDF_Point& point) |
370 { | 352 { |
371 ASSERT(pAnnot); | 353 ASSERT(pAnnot); |
372 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) | 354 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) |
373 { | 355 { |
374 if(pAnnotHandler->CanAnswer(pAnnot)) | 356 if (pAnnotHandler->CanAnswer(pAnnot)) |
375 return pAnnotHandler->HitTest(pPageView, pAnnot, point); | 357 return pAnnotHandler->HitTest(pPageView, pAnnot, point); |
376 } | 358 } |
377 return FALSE; | 359 return FALSE; |
378 } | 360 } |
379 | 361 |
380 CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::GetNextAnnot(CPDFSDK_Annot* pSDKAnnot,F
X_BOOL bNext) | 362 CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::GetNextAnnot(CPDFSDK_Annot* pSDKAnnot,F
X_BOOL bNext) |
381 { | 363 { |
382 CPDFSDK_PageView* pPageView = pSDKAnnot->GetPageView(); | 364 CPDFSDK_PageView* pPageView = pSDKAnnot->GetPageView(); |
383 CPDFXFA_Page* pPage = pPageView->GetPDFXFAPage(); | 365 CPDFXFA_Page* pPage = pPageView->GetPDFXFAPage(); |
384 if (pPage == NULL) | 366 if (pPage == NULL) |
(...skipping 15 matching lines...) Expand all Loading... |
400 hNextFocus = bNext?pWidgetIterator->MoveToNext():pWidgetIterator->MoveToPrev
ious(); | 382 hNextFocus = bNext?pWidgetIterator->MoveToNext():pWidgetIterator->MoveToPrev
ious(); |
401 if (hNextFocus == NULL && pSDKAnnot != NULL) | 383 if (hNextFocus == NULL && pSDKAnnot != NULL) |
402 hNextFocus = pWidgetIterator->MoveToFirst(); | 384 hNextFocus = pWidgetIterator->MoveToFirst(); |
403 | 385 |
404 pWidgetIterator->Release(); | 386 pWidgetIterator->Release(); |
405 return pPageView->GetAnnotByXFAWidget(hNextFocus); | 387 return pPageView->GetAnnotByXFAWidget(hNextFocus); |
406 } | 388 } |
407 | 389 |
408 FX_BOOL CPDFSDK_BFAnnotHandler::CanAnswer(CPDFSDK_Annot* pAnnot) | 390 FX_BOOL CPDFSDK_BFAnnotHandler::CanAnswer(CPDFSDK_Annot* pAnnot) |
409 { | 391 { |
410 ASSERT(pAnnot); | |
411 ASSERT(pAnnot->GetType() == "Widget"); | 392 ASSERT(pAnnot->GetType() == "Widget"); |
412 CFX_ByteString sSubType = pAnnot->GetSubType(); | 393 if (pAnnot->GetSubType() == BFFT_SIGNATURE) |
| 394 return FALSE; |
413 | 395 |
414 if (sSubType == BFFT_SIGNATURE) | 396 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; |
415 { | 397 if (!pWidget->IsVisible()) |
416 } | 398 return FALSE; |
417 else | |
418 { | |
419 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; | |
420 if (!pWidget->IsVisible()) return FALSE; | |
421 | 399 |
422 int nFieldFlags = pWidget->GetFieldFlags(); | 400 int nFieldFlags = pWidget->GetFieldFlags(); |
423 if ((nFieldFlags & FIELDFLAG_READONLY) == FIELDFLAG_READONLY) return FAL
SE; | 401 if ((nFieldFlags & FIELDFLAG_READONLY) == FIELDFLAG_READONLY) |
424 if (pWidget->GetFieldType() == FIELDTYPE_PUSHBUTTON) | 402 return FALSE; |
425 return TRUE; | |
426 else | |
427 { | |
428 CPDF_Page* pPage = pWidget->GetPDFPage(); | |
429 ASSERT(pPage != NULL); | |
430 | 403 |
431 CPDF_Document* pDocument = pPage->m_pDocument; | 404 if (pWidget->GetFieldType() == FIELDTYPE_PUSHBUTTON) |
432 ASSERT(pDocument != NULL); | 405 return TRUE; |
433 | 406 |
434 FX_DWORD dwPermissions = pDocument->GetUserPermissions(); | 407 CPDF_Page* pPage = pWidget->GetPDFPage(); |
435 return (dwPermissions&FPDFPERM_FILL_FORM) || | 408 CPDF_Document* pDocument = pPage->m_pDocument; |
436 (dwPermissions&FPDFPERM_ANNOT_FORM) || | 409 FX_DWORD dwPermissions = pDocument->GetUserPermissions(); |
437 (dwPermissions&FPDFPERM_ANNOT_FORM); | 410 return (dwPermissions & FPDFPERM_FILL_FORM) || |
438 } | 411 (dwPermissions & FPDFPERM_ANNOT_FORM); |
439 } | |
440 | |
441 return FALSE; | |
442 } | 412 } |
443 | 413 |
444 CPDFSDK_Annot* CPDFSDK_BFAnnotHandler::NewAnnot(CPDF_Annot* pAnnot, CPDFSDK_Page
View* pPage) | 414 CPDFSDK_Annot* CPDFSDK_BFAnnotHandler::NewAnnot(CPDF_Annot* pAnnot, CPDFSDK_Page
View* pPage) |
445 { | 415 { |
446 CPDFSDK_Document* pSDKDoc = m_pApp->GetSDKDocument(); | 416 CPDFSDK_Document* pSDKDoc = m_pApp->GetSDKDocument(); |
447 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pSDKDoc->GetInterForm(); | 417 CPDFSDK_InterForm* pInterForm = (CPDFSDK_InterForm*)pSDKDoc->GetInterForm(); |
448 CPDF_FormControl* pCtrl = CPDFSDK_Widget::GetFormControl(pInterForm->GetInte
rForm(), pAnnot->GetAnnotDict()); | 418 CPDF_FormControl* pCtrl = CPDFSDK_Widget::GetFormControl(pInterForm->GetInte
rForm(), pAnnot->GetAnnotDict()); |
449 if (!pCtrl) | 419 if (!pCtrl) |
450 return nullptr; | 420 return nullptr; |
451 | 421 |
(...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1331 arrayList[j + 1] = arrayList[j]; | 1301 arrayList[j + 1] = arrayList[j]; |
1332 } while (--j >= 0 && pCompare(pTemp, (CPDFSDK_Annot*)arrayList[j]) <
0); | 1302 } while (--j >= 0 && pCompare(pTemp, (CPDFSDK_Annot*)arrayList[j]) <
0); |
1333 | 1303 |
1334 arrayList[j+1] = pTemp; | 1304 arrayList[j+1] = pTemp; |
1335 } | 1305 } |
1336 } | 1306 } |
1337 } | 1307 } |
1338 | 1308 |
1339 int LyOrderCompare(CPDFSDK_Annot* p1, CPDFSDK_Annot* p2) | 1309 int LyOrderCompare(CPDFSDK_Annot* p1, CPDFSDK_Annot* p2) |
1340 { | 1310 { |
1341 if(p1->GetLayoutOrder() < p2->GetLayoutOrder()) | 1311 if (p1->GetLayoutOrder() < p2->GetLayoutOrder()) |
1342 return -1; | 1312 return -1; |
1343 else if (p1->GetLayoutOrder() == p2->GetLayoutOrder()) | 1313 if (p1->GetLayoutOrder() > p2->GetLayoutOrder()) |
1344 return 0; | |
1345 else | |
1346 return 1; | 1314 return 1; |
| 1315 return 0; |
1347 } | 1316 } |
1348 | 1317 |
1349 FX_BOOL CPDFSDK_AnnotIterator::InitIteratorAnnotList(CPDFSDK_PageView* pPageView
,CFX_PtrArray * pAnnotList) | 1318 FX_BOOL CPDFSDK_AnnotIterator::InitIteratorAnnotList(CPDFSDK_PageView* pPageView
,CFX_PtrArray * pAnnotList) |
1350 { | 1319 { |
1351 ASSERT(pPageView); | 1320 ASSERT(pPageView); |
1352 | 1321 |
1353 if(pAnnotList==NULL){ | 1322 if(pAnnotList==NULL){ |
1354 pAnnotList=pPageView->GetAnnotList(); | 1323 pAnnotList=pPageView->GetAnnotList(); |
1355 } | 1324 } |
1356 | 1325 |
(...skipping 22 matching lines...) Expand all Loading... |
1379 { | 1348 { |
1380 m_pIteratorAnnotList.RemoveAt(i); | 1349 m_pIteratorAnnotList.RemoveAt(i); |
1381 m_pIteratorAnnotList.InsertAt(0, pReaderAnnot); | 1350 m_pIteratorAnnotList.InsertAt(0, pReaderAnnot); |
1382 break; | 1351 break; |
1383 } | 1352 } |
1384 } | 1353 } |
1385 } | 1354 } |
1386 | 1355 |
1387 return TRUE; | 1356 return TRUE; |
1388 } | 1357 } |
OLD | NEW |