| 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 <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #ifdef PDF_ENABLE_XFA |
| 9 #include "../include/fpdfxfa/fpdfxfa_doc.h" | 10 #include "../include/fpdfxfa/fpdfxfa_doc.h" |
| 10 #include "../include/fpdfxfa/fpdfxfa_util.h" | 11 #include "../include/fpdfxfa/fpdfxfa_util.h" |
| 12 #endif |
| 11 #include "fpdfsdk/include/formfiller/FFL_FormFiller.h" | 13 #include "fpdfsdk/include/formfiller/FFL_FormFiller.h" |
| 12 #include "fpdfsdk/include/fsdk_annothandler.h" | 14 #include "fpdfsdk/include/fsdk_annothandler.h" |
| 13 #include "fpdfsdk/include/fsdk_define.h" | 15 #include "fpdfsdk/include/fsdk_define.h" |
| 14 #include "fpdfsdk/include/fsdk_mgr.h" | 16 #include "fpdfsdk/include/fsdk_mgr.h" |
| 15 | 17 |
| 16 CPDFSDK_AnnotHandlerMgr::CPDFSDK_AnnotHandlerMgr(CPDFDoc_Environment* pApp) { | 18 CPDFSDK_AnnotHandlerMgr::CPDFSDK_AnnotHandlerMgr(CPDFDoc_Environment* pApp) { |
| 17 m_pApp = pApp; | 19 m_pApp = pApp; |
| 18 | 20 |
| 19 CPDFSDK_BFAnnotHandler* pHandler = new CPDFSDK_BFAnnotHandler(m_pApp); | 21 CPDFSDK_BFAnnotHandler* pHandler = new CPDFSDK_BFAnnotHandler(m_pApp); |
| 20 pHandler->SetFormFiller(m_pApp->GetIFormFiller()); | 22 pHandler->SetFormFiller(m_pApp->GetIFormFiller()); |
| 21 RegisterAnnotHandler(pHandler); | 23 RegisterAnnotHandler(pHandler); |
| 24 #ifdef PDF_ENABLE_XFA |
| 22 | 25 |
| 23 CPDFSDK_XFAAnnotHandler* pXFAAnnotHandler = | 26 CPDFSDK_XFAAnnotHandler* pXFAAnnotHandler = |
| 24 new CPDFSDK_XFAAnnotHandler(m_pApp); | 27 new CPDFSDK_XFAAnnotHandler(m_pApp); |
| 25 RegisterAnnotHandler(pXFAAnnotHandler); | 28 RegisterAnnotHandler(pXFAAnnotHandler); |
| 29 #endif |
| 26 } | 30 } |
| 27 | 31 |
| 28 CPDFSDK_AnnotHandlerMgr::~CPDFSDK_AnnotHandlerMgr() { | 32 CPDFSDK_AnnotHandlerMgr::~CPDFSDK_AnnotHandlerMgr() { |
| 29 for (int i = 0; i < m_Handlers.GetSize(); i++) { | 33 for (int i = 0; i < m_Handlers.GetSize(); i++) { |
| 30 IPDFSDK_AnnotHandler* pHandler = m_Handlers.GetAt(i); | 34 IPDFSDK_AnnotHandler* pHandler = m_Handlers.GetAt(i); |
| 31 delete pHandler; | 35 delete pHandler; |
| 32 } | 36 } |
| 33 m_Handlers.RemoveAll(); | 37 m_Handlers.RemoveAll(); |
| 34 m_mapType2Handler.clear(); | 38 m_mapType2Handler.clear(); |
| 35 } | 39 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 59 ASSERT(pPageView != NULL); | 63 ASSERT(pPageView != NULL); |
| 60 | 64 |
| 61 if (IPDFSDK_AnnotHandler* pAnnotHandler = | 65 if (IPDFSDK_AnnotHandler* pAnnotHandler = |
| 62 GetAnnotHandler(pAnnot->GetSubType())) { | 66 GetAnnotHandler(pAnnot->GetSubType())) { |
| 63 return pAnnotHandler->NewAnnot(pAnnot, pPageView); | 67 return pAnnotHandler->NewAnnot(pAnnot, pPageView); |
| 64 } | 68 } |
| 65 | 69 |
| 66 return new CPDFSDK_BAAnnot(pAnnot, pPageView); | 70 return new CPDFSDK_BAAnnot(pAnnot, pPageView); |
| 67 } | 71 } |
| 68 | 72 |
| 73 #ifdef PDF_ENABLE_XFA |
| 69 CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::NewAnnot(IXFA_Widget* pAnnot, | 74 CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::NewAnnot(IXFA_Widget* pAnnot, |
| 70 CPDFSDK_PageView* pPageView) { | 75 CPDFSDK_PageView* pPageView) { |
| 71 ASSERT(pAnnot != NULL); | 76 ASSERT(pAnnot != NULL); |
| 72 ASSERT(pPageView != NULL); | 77 ASSERT(pPageView != NULL); |
| 73 | 78 |
| 74 if (IPDFSDK_AnnotHandler* pAnnotHandler = | 79 if (IPDFSDK_AnnotHandler* pAnnotHandler = |
| 75 GetAnnotHandler(FSDK_XFAWIDGET_TYPENAME)) { | 80 GetAnnotHandler(FSDK_XFAWIDGET_TYPENAME)) { |
| 76 return pAnnotHandler->NewAnnot(pAnnot, pPageView); | 81 return pAnnotHandler->NewAnnot(pAnnot, pPageView); |
| 77 } | 82 } |
| 78 | 83 |
| 79 return NULL; | 84 return NULL; |
| 80 } | 85 } |
| 81 | 86 |
| 87 #endif |
| 82 void CPDFSDK_AnnotHandlerMgr::ReleaseAnnot(CPDFSDK_Annot* pAnnot) { | 88 void CPDFSDK_AnnotHandlerMgr::ReleaseAnnot(CPDFSDK_Annot* pAnnot) { |
| 83 ASSERT(pAnnot != NULL); | 89 ASSERT(pAnnot != NULL); |
| 84 | 90 |
| 85 pAnnot->GetPDFPage(); | 91 pAnnot->GetPDFPage(); |
| 86 | 92 |
| 87 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) { | 93 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) { |
| 88 pAnnotHandler->OnRelease(pAnnot); | 94 pAnnotHandler->OnRelease(pAnnot); |
| 89 pAnnotHandler->ReleaseAnnot(pAnnot); | 95 pAnnotHandler->ReleaseAnnot(pAnnot); |
| 90 } else { | 96 } else { |
| 91 delete (CPDFSDK_Annot*)pAnnot; | 97 delete (CPDFSDK_Annot*)pAnnot; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 114 } | 120 } |
| 115 } | 121 } |
| 116 | 122 |
| 117 IPDFSDK_AnnotHandler* CPDFSDK_AnnotHandlerMgr::GetAnnotHandler( | 123 IPDFSDK_AnnotHandler* CPDFSDK_AnnotHandlerMgr::GetAnnotHandler( |
| 118 CPDFSDK_Annot* pAnnot) const { | 124 CPDFSDK_Annot* pAnnot) const { |
| 119 ASSERT(pAnnot != NULL); | 125 ASSERT(pAnnot != NULL); |
| 120 | 126 |
| 121 CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot(); | 127 CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot(); |
| 122 if (pPDFAnnot) | 128 if (pPDFAnnot) |
| 123 return GetAnnotHandler(pPDFAnnot->GetSubType()); | 129 return GetAnnotHandler(pPDFAnnot->GetSubType()); |
| 130 #ifdef PDF_ENABLE_XFA |
| 124 if (pAnnot->GetXFAWidget()) | 131 if (pAnnot->GetXFAWidget()) |
| 125 return GetAnnotHandler(FSDK_XFAWIDGET_TYPENAME); | 132 return GetAnnotHandler(FSDK_XFAWIDGET_TYPENAME); |
| 133 #endif |
| 126 return nullptr; | 134 return nullptr; |
| 127 } | 135 } |
| 128 | 136 |
| 129 IPDFSDK_AnnotHandler* CPDFSDK_AnnotHandlerMgr::GetAnnotHandler( | 137 IPDFSDK_AnnotHandler* CPDFSDK_AnnotHandlerMgr::GetAnnotHandler( |
| 130 const CFX_ByteString& sType) const { | 138 const CFX_ByteString& sType) const { |
| 131 auto it = m_mapType2Handler.find(sType); | 139 auto it = m_mapType2Handler.find(sType); |
| 132 return it != m_mapType2Handler.end() ? it->second : nullptr; | 140 return it != m_mapType2Handler.end() ? it->second : nullptr; |
| 133 } | 141 } |
| 134 | 142 |
| 135 void CPDFSDK_AnnotHandlerMgr::Annot_OnDraw(CPDFSDK_PageView* pPageView, | 143 void CPDFSDK_AnnotHandlerMgr::Annot_OnDraw(CPDFSDK_PageView* pPageView, |
| 136 CPDFSDK_Annot* pAnnot, | 144 CPDFSDK_Annot* pAnnot, |
| 137 CFX_RenderDevice* pDevice, | 145 CFX_RenderDevice* pDevice, |
| 138 CPDF_Matrix* pUser2Device, | 146 CPDF_Matrix* pUser2Device, |
| 139 FX_DWORD dwFlags) { | 147 FX_DWORD dwFlags) { |
| 140 ASSERT(pAnnot); | 148 ASSERT(pAnnot); |
| 141 | 149 |
| 142 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) { | 150 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) { |
| 143 pAnnotHandler->OnDraw(pPageView, pAnnot, pDevice, pUser2Device, dwFlags); | 151 pAnnotHandler->OnDraw(pPageView, pAnnot, pDevice, pUser2Device, dwFlags); |
| 144 } else { | 152 } else { |
| 153 #ifdef PDF_ENABLE_XFA |
| 145 if (pAnnot->IsXFAField()) | 154 if (pAnnot->IsXFAField()) |
| 146 return; | 155 return; |
| 156 #endif |
| 147 static_cast<CPDFSDK_BAAnnot*>(pAnnot) | 157 static_cast<CPDFSDK_BAAnnot*>(pAnnot) |
| 148 ->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, nullptr); | 158 ->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, nullptr); |
| 149 } | 159 } |
| 150 } | 160 } |
| 151 | 161 |
| 152 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnLButtonDown( | 162 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnLButtonDown( |
| 153 CPDFSDK_PageView* pPageView, | 163 CPDFSDK_PageView* pPageView, |
| 154 CPDFSDK_Annot* pAnnot, | 164 CPDFSDK_Annot* pAnnot, |
| 155 FX_DWORD nFlags, | 165 FX_DWORD nFlags, |
| 156 const CPDF_Point& point) { | 166 const CPDF_Point& point) { |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 | 318 |
| 309 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnKillFocus(CPDFSDK_Annot* pAnnot, | 319 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnKillFocus(CPDFSDK_Annot* pAnnot, |
| 310 FX_DWORD nFlag) { | 320 FX_DWORD nFlag) { |
| 311 ASSERT(pAnnot); | 321 ASSERT(pAnnot); |
| 312 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) | 322 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) |
| 313 return pAnnotHandler->OnKillFocus(pAnnot, nFlag); | 323 return pAnnotHandler->OnKillFocus(pAnnot, nFlag); |
| 314 | 324 |
| 315 return FALSE; | 325 return FALSE; |
| 316 } | 326 } |
| 317 | 327 |
| 328 #ifdef PDF_ENABLE_XFA |
| 318 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnChangeFocus( | 329 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnChangeFocus( |
| 319 CPDFSDK_Annot* pSetAnnot, | 330 CPDFSDK_Annot* pSetAnnot, |
| 320 CPDFSDK_Annot* pKillAnnot) { | 331 CPDFSDK_Annot* pKillAnnot) { |
| 321 FX_BOOL bXFA = (pSetAnnot && pSetAnnot->GetXFAWidget()) || | 332 FX_BOOL bXFA = (pSetAnnot && pSetAnnot->GetXFAWidget()) || |
| 322 (pKillAnnot && pKillAnnot->GetXFAWidget()); | 333 (pKillAnnot && pKillAnnot->GetXFAWidget()); |
| 323 | 334 |
| 324 if (bXFA) { | 335 if (bXFA) { |
| 325 if (IPDFSDK_AnnotHandler* pXFAAnnotHandler = | 336 if (IPDFSDK_AnnotHandler* pXFAAnnotHandler = |
| 326 GetAnnotHandler(FSDK_XFAWIDGET_TYPENAME)) | 337 GetAnnotHandler(FSDK_XFAWIDGET_TYPENAME)) |
| 327 return pXFAAnnotHandler->OnXFAChangedFocus(pKillAnnot, pSetAnnot); | 338 return pXFAAnnotHandler->OnXFAChangedFocus(pKillAnnot, pSetAnnot); |
| 328 } | 339 } |
| 329 | 340 |
| 330 return TRUE; | 341 return TRUE; |
| 331 } | 342 } |
| 332 | 343 |
| 344 #endif |
| 333 CPDF_Rect CPDFSDK_AnnotHandlerMgr::Annot_OnGetViewBBox( | 345 CPDF_Rect CPDFSDK_AnnotHandlerMgr::Annot_OnGetViewBBox( |
| 334 CPDFSDK_PageView* pPageView, | 346 CPDFSDK_PageView* pPageView, |
| 335 CPDFSDK_Annot* pAnnot) { | 347 CPDFSDK_Annot* pAnnot) { |
| 336 ASSERT(pAnnot); | 348 ASSERT(pAnnot); |
| 337 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) | 349 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) |
| 338 return pAnnotHandler->GetViewBBox(pPageView, pAnnot); | 350 return pAnnotHandler->GetViewBBox(pPageView, pAnnot); |
| 339 | 351 |
| 340 return pAnnot->GetRect(); | 352 return pAnnot->GetRect(); |
| 341 } | 353 } |
| 342 | 354 |
| 343 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnHitTest(CPDFSDK_PageView* pPageView, | 355 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnHitTest(CPDFSDK_PageView* pPageView, |
| 344 CPDFSDK_Annot* pAnnot, | 356 CPDFSDK_Annot* pAnnot, |
| 345 const CPDF_Point& point) { | 357 const CPDF_Point& point) { |
| 346 ASSERT(pAnnot); | 358 ASSERT(pAnnot); |
| 347 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) { | 359 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) { |
| 348 if (pAnnotHandler->CanAnswer(pAnnot)) | 360 if (pAnnotHandler->CanAnswer(pAnnot)) |
| 349 return pAnnotHandler->HitTest(pPageView, pAnnot, point); | 361 return pAnnotHandler->HitTest(pPageView, pAnnot, point); |
| 350 } | 362 } |
| 351 return FALSE; | 363 return FALSE; |
| 352 } | 364 } |
| 353 | 365 |
| 354 CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::GetNextAnnot(CPDFSDK_Annot* pSDKAnnot, | 366 CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::GetNextAnnot(CPDFSDK_Annot* pSDKAnnot, |
| 355 FX_BOOL bNext) { | 367 FX_BOOL bNext) { |
| 368 #ifndef PDF_ENABLE_XFA |
| 369 CBA_AnnotIterator ai(pSDKAnnot->GetPageView(), "Widget", ""); |
| 370 return bNext ? ai.GetNextAnnot(pSDKAnnot) : ai.GetPrevAnnot(pSDKAnnot); |
| 371 #else |
| 356 CPDFSDK_PageView* pPageView = pSDKAnnot->GetPageView(); | 372 CPDFSDK_PageView* pPageView = pSDKAnnot->GetPageView(); |
| 357 CPDFXFA_Page* pPage = pPageView->GetPDFXFAPage(); | 373 CPDFXFA_Page* pPage = pPageView->GetPDFXFAPage(); |
| 358 if (pPage == NULL) | 374 if (pPage == NULL) |
| 359 return NULL; | 375 return NULL; |
| 360 if (pPage->GetPDFPage()) { // for pdf annots. | 376 if (pPage->GetPDFPage()) { // for pdf annots. |
| 361 CBA_AnnotIterator ai(pSDKAnnot->GetPageView(), pSDKAnnot->GetType(), ""); | 377 CBA_AnnotIterator ai(pSDKAnnot->GetPageView(), pSDKAnnot->GetType(), ""); |
| 362 CPDFSDK_Annot* pNext = | 378 CPDFSDK_Annot* pNext = |
| 363 bNext ? ai.GetNextAnnot(pSDKAnnot) : ai.GetPrevAnnot(pSDKAnnot); | 379 bNext ? ai.GetNextAnnot(pSDKAnnot) : ai.GetPrevAnnot(pSDKAnnot); |
| 364 return pNext; | 380 return pNext; |
| 365 } | 381 } |
| 366 // for xfa annots | 382 // for xfa annots |
| 367 IXFA_WidgetIterator* pWidgetIterator = | 383 IXFA_WidgetIterator* pWidgetIterator = |
| 368 pPage->GetXFAPageView()->CreateWidgetIterator( | 384 pPage->GetXFAPageView()->CreateWidgetIterator( |
| 369 XFA_TRAVERSEWAY_Tranvalse, XFA_WIDGETFILTER_Visible | | 385 XFA_TRAVERSEWAY_Tranvalse, XFA_WIDGETFILTER_Visible | |
| 370 XFA_WIDGETFILTER_Viewable | | 386 XFA_WIDGETFILTER_Viewable | |
| 371 XFA_WIDGETFILTER_Field); | 387 XFA_WIDGETFILTER_Field); |
| 372 if (pWidgetIterator == NULL) | 388 if (pWidgetIterator == NULL) |
| 373 return NULL; | 389 return NULL; |
| 374 if (pWidgetIterator->GetCurrentWidget() != pSDKAnnot->GetXFAWidget()) | 390 if (pWidgetIterator->GetCurrentWidget() != pSDKAnnot->GetXFAWidget()) |
| 375 pWidgetIterator->SetCurrentWidget(pSDKAnnot->GetXFAWidget()); | 391 pWidgetIterator->SetCurrentWidget(pSDKAnnot->GetXFAWidget()); |
| 376 IXFA_Widget* hNextFocus = NULL; | 392 IXFA_Widget* hNextFocus = NULL; |
| 377 hNextFocus = | 393 hNextFocus = |
| 378 bNext ? pWidgetIterator->MoveToNext() : pWidgetIterator->MoveToPrevious(); | 394 bNext ? pWidgetIterator->MoveToNext() : pWidgetIterator->MoveToPrevious(); |
| 379 if (hNextFocus == NULL && pSDKAnnot != NULL) | 395 if (hNextFocus == NULL && pSDKAnnot != NULL) |
| 380 hNextFocus = pWidgetIterator->MoveToFirst(); | 396 hNextFocus = pWidgetIterator->MoveToFirst(); |
| 381 | 397 |
| 382 pWidgetIterator->Release(); | 398 pWidgetIterator->Release(); |
| 383 return pPageView->GetAnnotByXFAWidget(hNextFocus); | 399 return pPageView->GetAnnotByXFAWidget(hNextFocus); |
| 400 #endif |
| 384 } | 401 } |
| 385 | 402 |
| 386 FX_BOOL CPDFSDK_BFAnnotHandler::CanAnswer(CPDFSDK_Annot* pAnnot) { | 403 FX_BOOL CPDFSDK_BFAnnotHandler::CanAnswer(CPDFSDK_Annot* pAnnot) { |
| 387 ASSERT(pAnnot->GetType() == "Widget"); | 404 ASSERT(pAnnot->GetType() == "Widget"); |
| 388 if (pAnnot->GetSubType() == BFFT_SIGNATURE) | 405 if (pAnnot->GetSubType() == BFFT_SIGNATURE) |
| 389 return FALSE; | 406 return FALSE; |
| 390 | 407 |
| 391 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; | 408 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; |
| 392 if (!pWidget->IsVisible()) | 409 if (!pWidget->IsVisible()) |
| 393 return FALSE; | 410 return FALSE; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 417 | 434 |
| 418 CPDFSDK_Widget* pWidget = new CPDFSDK_Widget(pAnnot, pPage, pInterForm); | 435 CPDFSDK_Widget* pWidget = new CPDFSDK_Widget(pAnnot, pPage, pInterForm); |
| 419 pInterForm->AddMap(pCtrl, pWidget); | 436 pInterForm->AddMap(pCtrl, pWidget); |
| 420 CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm(); | 437 CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm(); |
| 421 if (pPDFInterForm && pPDFInterForm->NeedConstructAP()) | 438 if (pPDFInterForm && pPDFInterForm->NeedConstructAP()) |
| 422 pWidget->ResetAppearance(nullptr, FALSE); | 439 pWidget->ResetAppearance(nullptr, FALSE); |
| 423 | 440 |
| 424 return pWidget; | 441 return pWidget; |
| 425 } | 442 } |
| 426 | 443 |
| 444 #ifdef PDF_ENABLE_XFA |
| 427 CPDFSDK_Annot* CPDFSDK_BFAnnotHandler::NewAnnot(IXFA_Widget* hWidget, | 445 CPDFSDK_Annot* CPDFSDK_BFAnnotHandler::NewAnnot(IXFA_Widget* hWidget, |
| 428 CPDFSDK_PageView* pPage) { | 446 CPDFSDK_PageView* pPage) { |
| 429 return NULL; | 447 return NULL; |
| 430 } | 448 } |
| 431 | 449 |
| 450 #endif |
| 432 void CPDFSDK_BFAnnotHandler::ReleaseAnnot(CPDFSDK_Annot* pAnnot) { | 451 void CPDFSDK_BFAnnotHandler::ReleaseAnnot(CPDFSDK_Annot* pAnnot) { |
| 433 ASSERT(pAnnot != NULL); | 452 ASSERT(pAnnot != NULL); |
| 434 | 453 |
| 435 if (m_pFormFiller) | 454 if (m_pFormFiller) |
| 436 m_pFormFiller->OnDelete(pAnnot); | 455 m_pFormFiller->OnDelete(pAnnot); |
| 437 | 456 |
| 438 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; | 457 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; |
| 439 CPDFSDK_InterForm* pInterForm = pWidget->GetInterForm(); | 458 CPDFSDK_InterForm* pInterForm = pWidget->GetInterForm(); |
| 440 ASSERT(pInterForm != NULL); | 459 ASSERT(pInterForm != NULL); |
| 441 | 460 |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 655 | 674 |
| 656 int nFieldType = pWidget->GetFieldType(); | 675 int nFieldType = pWidget->GetFieldType(); |
| 657 if (nFieldType == FIELDTYPE_TEXTFIELD || nFieldType == FIELDTYPE_COMBOBOX) { | 676 if (nFieldType == FIELDTYPE_TEXTFIELD || nFieldType == FIELDTYPE_COMBOBOX) { |
| 658 FX_BOOL bFormated = FALSE; | 677 FX_BOOL bFormated = FALSE; |
| 659 CFX_WideString sValue = pWidget->OnFormat(bFormated); | 678 CFX_WideString sValue = pWidget->OnFormat(bFormated); |
| 660 if (bFormated && nFieldType == FIELDTYPE_COMBOBOX) { | 679 if (bFormated && nFieldType == FIELDTYPE_COMBOBOX) { |
| 661 pWidget->ResetAppearance(sValue.c_str(), FALSE); | 680 pWidget->ResetAppearance(sValue.c_str(), FALSE); |
| 662 } | 681 } |
| 663 } | 682 } |
| 664 | 683 |
| 684 #ifdef PDF_ENABLE_XFA |
| 665 CPDFSDK_PageView* pPageView = pAnnot->GetPageView(); | 685 CPDFSDK_PageView* pPageView = pAnnot->GetPageView(); |
| 666 CPDFSDK_Document* pSDKDoc = pPageView->GetSDKDocument(); | 686 CPDFSDK_Document* pSDKDoc = pPageView->GetSDKDocument(); |
| 667 CPDFXFA_Document* pDoc = pSDKDoc->GetXFADocument(); | 687 CPDFXFA_Document* pDoc = pSDKDoc->GetXFADocument(); |
| 668 if (pDoc->GetDocType() == DOCTYPE_STATIC_XFA) { | 688 if (pDoc->GetDocType() == DOCTYPE_STATIC_XFA) { |
| 669 if (!pWidget->IsAppearanceValid() && !pWidget->GetValue().IsEmpty()) | 689 if (!pWidget->IsAppearanceValid() && !pWidget->GetValue().IsEmpty()) |
| 670 pWidget->ResetAppearance(FALSE); | 690 pWidget->ResetAppearance(FALSE); |
| 671 } | 691 } |
| 672 | 692 |
| 693 #endif |
| 673 if (m_pFormFiller) | 694 if (m_pFormFiller) |
| 674 m_pFormFiller->OnLoad(pAnnot); | 695 m_pFormFiller->OnLoad(pAnnot); |
| 675 } | 696 } |
| 676 | 697 |
| 677 FX_BOOL CPDFSDK_BFAnnotHandler::OnSetFocus(CPDFSDK_Annot* pAnnot, | 698 FX_BOOL CPDFSDK_BFAnnotHandler::OnSetFocus(CPDFSDK_Annot* pAnnot, |
| 678 FX_DWORD nFlag) { | 699 FX_DWORD nFlag) { |
| 679 ASSERT(pAnnot != NULL); | 700 ASSERT(pAnnot != NULL); |
| 680 CFX_ByteString sSubType = pAnnot->GetSubType(); | 701 CFX_ByteString sSubType = pAnnot->GetSubType(); |
| 681 | 702 |
| 682 if (sSubType == BFFT_SIGNATURE) { | 703 if (sSubType == BFFT_SIGNATURE) { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 718 FX_BOOL CPDFSDK_BFAnnotHandler::HitTest(CPDFSDK_PageView* pPageView, | 739 FX_BOOL CPDFSDK_BFAnnotHandler::HitTest(CPDFSDK_PageView* pPageView, |
| 719 CPDFSDK_Annot* pAnnot, | 740 CPDFSDK_Annot* pAnnot, |
| 720 const CPDF_Point& point) { | 741 const CPDF_Point& point) { |
| 721 ASSERT(pPageView); | 742 ASSERT(pPageView); |
| 722 ASSERT(pAnnot); | 743 ASSERT(pAnnot); |
| 723 | 744 |
| 724 CPDF_Rect rect = GetViewBBox(pPageView, pAnnot); | 745 CPDF_Rect rect = GetViewBBox(pPageView, pAnnot); |
| 725 return rect.Contains(point.x, point.y); | 746 return rect.Contains(point.x, point.y); |
| 726 } | 747 } |
| 727 | 748 |
| 749 #ifdef PDF_ENABLE_XFA |
| 728 #define FWL_WGTHITTEST_Unknown 0 | 750 #define FWL_WGTHITTEST_Unknown 0 |
| 729 #define FWL_WGTHITTEST_Client 1 // arrow | 751 #define FWL_WGTHITTEST_Client 1 // arrow |
| 730 #define FWL_WGTHITTEST_Titlebar 11 // caption | 752 #define FWL_WGTHITTEST_Titlebar 11 // caption |
| 731 #define FWL_WGTHITTEST_HScrollBar 15 | 753 #define FWL_WGTHITTEST_HScrollBar 15 |
| 732 #define FWL_WGTHITTEST_VScrollBar 16 | 754 #define FWL_WGTHITTEST_VScrollBar 16 |
| 733 #define FWL_WGTHITTEST_Border 17 | 755 #define FWL_WGTHITTEST_Border 17 |
| 734 #define FWL_WGTHITTEST_Edit 19 | 756 #define FWL_WGTHITTEST_Edit 19 |
| 735 #define FWL_WGTHITTEST_HyperLink 20 | 757 #define FWL_WGTHITTEST_HyperLink 20 |
| 736 | 758 |
| 737 CPDFSDK_XFAAnnotHandler::CPDFSDK_XFAAnnotHandler(CPDFDoc_Environment* pApp) | 759 CPDFSDK_XFAAnnotHandler::CPDFSDK_XFAAnnotHandler(CPDFDoc_Environment* pApp) |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1136 if (dwFlag & FWL_EVENTFLAG_RightButtonDown) | 1158 if (dwFlag & FWL_EVENTFLAG_RightButtonDown) |
| 1137 dwFWLFlag |= FWL_KEYFLAG_RButton; | 1159 dwFWLFlag |= FWL_KEYFLAG_RButton; |
| 1138 if (dwFlag & FWL_EVENTFLAG_ShiftKey) | 1160 if (dwFlag & FWL_EVENTFLAG_ShiftKey) |
| 1139 dwFWLFlag |= FWL_KEYFLAG_Shift; | 1161 dwFWLFlag |= FWL_KEYFLAG_Shift; |
| 1140 if (dwFlag & FWL_EVENTFLAG_AltKey) | 1162 if (dwFlag & FWL_EVENTFLAG_AltKey) |
| 1141 dwFWLFlag |= FWL_KEYFLAG_Alt; | 1163 dwFWLFlag |= FWL_KEYFLAG_Alt; |
| 1142 | 1164 |
| 1143 return dwFWLFlag; | 1165 return dwFWLFlag; |
| 1144 } | 1166 } |
| 1145 | 1167 |
| 1168 #endif |
| 1146 CPDFSDK_AnnotIterator::CPDFSDK_AnnotIterator(CPDFSDK_PageView* pPageView, | 1169 CPDFSDK_AnnotIterator::CPDFSDK_AnnotIterator(CPDFSDK_PageView* pPageView, |
| 1147 bool bReverse) | 1170 bool bReverse) |
| 1148 : m_bReverse(bReverse), m_pos(0) { | 1171 : m_bReverse(bReverse), m_pos(0) { |
| 1149 const std::vector<CPDFSDK_Annot*>& annots = pPageView->GetAnnotList(); | 1172 const std::vector<CPDFSDK_Annot*>& annots = pPageView->GetAnnotList(); |
| 1150 m_iteratorAnnotList.insert(m_iteratorAnnotList.begin(), annots.rbegin(), | 1173 m_iteratorAnnotList.insert(m_iteratorAnnotList.begin(), annots.rbegin(), |
| 1151 annots.rend()); | 1174 annots.rend()); |
| 1152 std::stable_sort(m_iteratorAnnotList.begin(), m_iteratorAnnotList.end(), | 1175 std::stable_sort(m_iteratorAnnotList.begin(), m_iteratorAnnotList.end(), |
| 1153 [](CPDFSDK_Annot* p1, CPDFSDK_Annot* p2) { | 1176 [](CPDFSDK_Annot* p1, CPDFSDK_Annot* p2) { |
| 1154 return p1->GetLayoutOrder() < p2->GetLayoutOrder(); | 1177 return p1->GetLayoutOrder() < p2->GetLayoutOrder(); |
| 1155 }); | 1178 }); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1178 | 1201 |
| 1179 CPDFSDK_Annot* CPDFSDK_AnnotIterator::PrevAnnot() { | 1202 CPDFSDK_Annot* CPDFSDK_AnnotIterator::PrevAnnot() { |
| 1180 if (m_pos < m_iteratorAnnotList.size()) | 1203 if (m_pos < m_iteratorAnnotList.size()) |
| 1181 return m_iteratorAnnotList[m_iteratorAnnotList.size() - ++m_pos]; | 1204 return m_iteratorAnnotList[m_iteratorAnnotList.size() - ++m_pos]; |
| 1182 return nullptr; | 1205 return nullptr; |
| 1183 } | 1206 } |
| 1184 | 1207 |
| 1185 CPDFSDK_Annot* CPDFSDK_AnnotIterator::Next() { | 1208 CPDFSDK_Annot* CPDFSDK_AnnotIterator::Next() { |
| 1186 return m_bReverse ? PrevAnnot() : NextAnnot(); | 1209 return m_bReverse ? PrevAnnot() : NextAnnot(); |
| 1187 } | 1210 } |
| OLD | NEW |