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 | |
10 #include "../include/fpdfxfa/fpdfxfa_doc.h" | |
11 #include "../include/fpdfxfa/fpdfxfa_util.h" | |
12 #endif | |
13 #include "fpdfsdk/include/formfiller/FFL_FormFiller.h" | 9 #include "fpdfsdk/include/formfiller/FFL_FormFiller.h" |
14 #include "fpdfsdk/include/fsdk_annothandler.h" | 10 #include "fpdfsdk/include/fsdk_annothandler.h" |
15 #include "fpdfsdk/include/fsdk_define.h" | 11 #include "fpdfsdk/include/fsdk_define.h" |
16 #include "fpdfsdk/include/fsdk_mgr.h" | 12 #include "fpdfsdk/include/fsdk_mgr.h" |
17 | 13 |
| 14 #ifdef PDF_ENABLE_XFA |
| 15 #include "../include/fpdfxfa/fpdfxfa_doc.h" |
| 16 #include "../include/fpdfxfa/fpdfxfa_util.h" |
| 17 #endif // PDF_ENABLE_XFA |
| 18 |
18 CPDFSDK_AnnotHandlerMgr::CPDFSDK_AnnotHandlerMgr(CPDFDoc_Environment* pApp) { | 19 CPDFSDK_AnnotHandlerMgr::CPDFSDK_AnnotHandlerMgr(CPDFDoc_Environment* pApp) { |
19 m_pApp = pApp; | 20 m_pApp = pApp; |
20 | 21 |
21 CPDFSDK_BFAnnotHandler* pHandler = new CPDFSDK_BFAnnotHandler(m_pApp); | 22 CPDFSDK_BFAnnotHandler* pHandler = new CPDFSDK_BFAnnotHandler(m_pApp); |
22 pHandler->SetFormFiller(m_pApp->GetIFormFiller()); | 23 pHandler->SetFormFiller(m_pApp->GetIFormFiller()); |
23 RegisterAnnotHandler(pHandler); | 24 RegisterAnnotHandler(pHandler); |
24 #ifdef PDF_ENABLE_XFA | 25 #ifdef PDF_ENABLE_XFA |
25 | |
26 CPDFSDK_XFAAnnotHandler* pXFAAnnotHandler = | 26 CPDFSDK_XFAAnnotHandler* pXFAAnnotHandler = |
27 new CPDFSDK_XFAAnnotHandler(m_pApp); | 27 new CPDFSDK_XFAAnnotHandler(m_pApp); |
28 RegisterAnnotHandler(pXFAAnnotHandler); | 28 RegisterAnnotHandler(pXFAAnnotHandler); |
29 #endif | 29 #endif // PDF_ENABLE_XFA |
30 } | 30 } |
31 | 31 |
32 CPDFSDK_AnnotHandlerMgr::~CPDFSDK_AnnotHandlerMgr() { | 32 CPDFSDK_AnnotHandlerMgr::~CPDFSDK_AnnotHandlerMgr() { |
33 for (int i = 0; i < m_Handlers.GetSize(); i++) { | 33 for (int i = 0; i < m_Handlers.GetSize(); i++) { |
34 IPDFSDK_AnnotHandler* pHandler = m_Handlers.GetAt(i); | 34 IPDFSDK_AnnotHandler* pHandler = m_Handlers.GetAt(i); |
35 delete pHandler; | 35 delete pHandler; |
36 } | 36 } |
37 m_Handlers.RemoveAll(); | 37 m_Handlers.RemoveAll(); |
38 m_mapType2Handler.clear(); | 38 m_mapType2Handler.clear(); |
39 } | 39 } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 ASSERT(pAnnot != NULL); | 76 ASSERT(pAnnot != NULL); |
77 ASSERT(pPageView != NULL); | 77 ASSERT(pPageView != NULL); |
78 | 78 |
79 if (IPDFSDK_AnnotHandler* pAnnotHandler = | 79 if (IPDFSDK_AnnotHandler* pAnnotHandler = |
80 GetAnnotHandler(FSDK_XFAWIDGET_TYPENAME)) { | 80 GetAnnotHandler(FSDK_XFAWIDGET_TYPENAME)) { |
81 return pAnnotHandler->NewAnnot(pAnnot, pPageView); | 81 return pAnnotHandler->NewAnnot(pAnnot, pPageView); |
82 } | 82 } |
83 | 83 |
84 return NULL; | 84 return NULL; |
85 } | 85 } |
| 86 #endif // PDF_ENABLE_XFA |
86 | 87 |
87 #endif | |
88 void CPDFSDK_AnnotHandlerMgr::ReleaseAnnot(CPDFSDK_Annot* pAnnot) { | 88 void CPDFSDK_AnnotHandlerMgr::ReleaseAnnot(CPDFSDK_Annot* pAnnot) { |
89 ASSERT(pAnnot != NULL); | 89 ASSERT(pAnnot != NULL); |
90 | 90 |
91 pAnnot->GetPDFPage(); | 91 pAnnot->GetPDFPage(); |
92 | 92 |
93 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) { | 93 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) { |
94 pAnnotHandler->OnRelease(pAnnot); | 94 pAnnotHandler->OnRelease(pAnnot); |
95 pAnnotHandler->ReleaseAnnot(pAnnot); | 95 pAnnotHandler->ReleaseAnnot(pAnnot); |
96 } else { | 96 } else { |
97 delete (CPDFSDK_Annot*)pAnnot; | 97 delete (CPDFSDK_Annot*)pAnnot; |
(...skipping 25 matching lines...) Expand all Loading... |
123 IPDFSDK_AnnotHandler* CPDFSDK_AnnotHandlerMgr::GetAnnotHandler( | 123 IPDFSDK_AnnotHandler* CPDFSDK_AnnotHandlerMgr::GetAnnotHandler( |
124 CPDFSDK_Annot* pAnnot) const { | 124 CPDFSDK_Annot* pAnnot) const { |
125 ASSERT(pAnnot != NULL); | 125 ASSERT(pAnnot != NULL); |
126 | 126 |
127 CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot(); | 127 CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot(); |
128 if (pPDFAnnot) | 128 if (pPDFAnnot) |
129 return GetAnnotHandler(pPDFAnnot->GetSubType()); | 129 return GetAnnotHandler(pPDFAnnot->GetSubType()); |
130 #ifdef PDF_ENABLE_XFA | 130 #ifdef PDF_ENABLE_XFA |
131 if (pAnnot->GetXFAWidget()) | 131 if (pAnnot->GetXFAWidget()) |
132 return GetAnnotHandler(FSDK_XFAWIDGET_TYPENAME); | 132 return GetAnnotHandler(FSDK_XFAWIDGET_TYPENAME); |
133 #endif | 133 #endif // PDF_ENABLE_XFA |
134 return nullptr; | 134 return nullptr; |
135 } | 135 } |
136 | 136 |
137 IPDFSDK_AnnotHandler* CPDFSDK_AnnotHandlerMgr::GetAnnotHandler( | 137 IPDFSDK_AnnotHandler* CPDFSDK_AnnotHandlerMgr::GetAnnotHandler( |
138 const CFX_ByteString& sType) const { | 138 const CFX_ByteString& sType) const { |
139 auto it = m_mapType2Handler.find(sType); | 139 auto it = m_mapType2Handler.find(sType); |
140 return it != m_mapType2Handler.end() ? it->second : nullptr; | 140 return it != m_mapType2Handler.end() ? it->second : nullptr; |
141 } | 141 } |
142 | 142 |
143 void CPDFSDK_AnnotHandlerMgr::Annot_OnDraw(CPDFSDK_PageView* pPageView, | 143 void CPDFSDK_AnnotHandlerMgr::Annot_OnDraw(CPDFSDK_PageView* pPageView, |
144 CPDFSDK_Annot* pAnnot, | 144 CPDFSDK_Annot* pAnnot, |
145 CFX_RenderDevice* pDevice, | 145 CFX_RenderDevice* pDevice, |
146 CPDF_Matrix* pUser2Device, | 146 CPDF_Matrix* pUser2Device, |
147 FX_DWORD dwFlags) { | 147 FX_DWORD dwFlags) { |
148 ASSERT(pAnnot); | 148 ASSERT(pAnnot); |
149 | 149 |
150 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) { | 150 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) { |
151 pAnnotHandler->OnDraw(pPageView, pAnnot, pDevice, pUser2Device, dwFlags); | 151 pAnnotHandler->OnDraw(pPageView, pAnnot, pDevice, pUser2Device, dwFlags); |
152 } else { | 152 } else { |
153 #ifdef PDF_ENABLE_XFA | 153 #ifdef PDF_ENABLE_XFA |
154 if (pAnnot->IsXFAField()) | 154 if (pAnnot->IsXFAField()) |
155 return; | 155 return; |
156 #endif | 156 #endif // PDF_ENABLE_XFA |
157 static_cast<CPDFSDK_BAAnnot*>(pAnnot) | 157 static_cast<CPDFSDK_BAAnnot*>(pAnnot) |
158 ->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, nullptr); | 158 ->DrawAppearance(pDevice, pUser2Device, CPDF_Annot::Normal, nullptr); |
159 } | 159 } |
160 } | 160 } |
161 | 161 |
162 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnLButtonDown( | 162 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnLButtonDown( |
163 CPDFSDK_PageView* pPageView, | 163 CPDFSDK_PageView* pPageView, |
164 CPDFSDK_Annot* pAnnot, | 164 CPDFSDK_Annot* pAnnot, |
165 FX_DWORD nFlags, | 165 FX_DWORD nFlags, |
166 const CPDF_Point& point) { | 166 const CPDF_Point& point) { |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 (pKillAnnot && pKillAnnot->GetXFAWidget()); | 333 (pKillAnnot && pKillAnnot->GetXFAWidget()); |
334 | 334 |
335 if (bXFA) { | 335 if (bXFA) { |
336 if (IPDFSDK_AnnotHandler* pXFAAnnotHandler = | 336 if (IPDFSDK_AnnotHandler* pXFAAnnotHandler = |
337 GetAnnotHandler(FSDK_XFAWIDGET_TYPENAME)) | 337 GetAnnotHandler(FSDK_XFAWIDGET_TYPENAME)) |
338 return pXFAAnnotHandler->OnXFAChangedFocus(pKillAnnot, pSetAnnot); | 338 return pXFAAnnotHandler->OnXFAChangedFocus(pKillAnnot, pSetAnnot); |
339 } | 339 } |
340 | 340 |
341 return TRUE; | 341 return TRUE; |
342 } | 342 } |
| 343 #endif // PDF_ENABLE_XFA |
343 | 344 |
344 #endif | |
345 CPDF_Rect CPDFSDK_AnnotHandlerMgr::Annot_OnGetViewBBox( | 345 CPDF_Rect CPDFSDK_AnnotHandlerMgr::Annot_OnGetViewBBox( |
346 CPDFSDK_PageView* pPageView, | 346 CPDFSDK_PageView* pPageView, |
347 CPDFSDK_Annot* pAnnot) { | 347 CPDFSDK_Annot* pAnnot) { |
348 ASSERT(pAnnot); | 348 ASSERT(pAnnot); |
349 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) | 349 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) |
350 return pAnnotHandler->GetViewBBox(pPageView, pAnnot); | 350 return pAnnotHandler->GetViewBBox(pPageView, pAnnot); |
351 | 351 |
352 return pAnnot->GetRect(); | 352 return pAnnot->GetRect(); |
353 } | 353 } |
354 | 354 |
355 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnHitTest(CPDFSDK_PageView* pPageView, | 355 FX_BOOL CPDFSDK_AnnotHandlerMgr::Annot_OnHitTest(CPDFSDK_PageView* pPageView, |
356 CPDFSDK_Annot* pAnnot, | 356 CPDFSDK_Annot* pAnnot, |
357 const CPDF_Point& point) { | 357 const CPDF_Point& point) { |
358 ASSERT(pAnnot); | 358 ASSERT(pAnnot); |
359 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) { | 359 if (IPDFSDK_AnnotHandler* pAnnotHandler = GetAnnotHandler(pAnnot)) { |
360 if (pAnnotHandler->CanAnswer(pAnnot)) | 360 if (pAnnotHandler->CanAnswer(pAnnot)) |
361 return pAnnotHandler->HitTest(pPageView, pAnnot, point); | 361 return pAnnotHandler->HitTest(pPageView, pAnnot, point); |
362 } | 362 } |
363 return FALSE; | 363 return FALSE; |
364 } | 364 } |
365 | 365 |
366 CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::GetNextAnnot(CPDFSDK_Annot* pSDKAnnot, | 366 CPDFSDK_Annot* CPDFSDK_AnnotHandlerMgr::GetNextAnnot(CPDFSDK_Annot* pSDKAnnot, |
367 FX_BOOL bNext) { | 367 FX_BOOL bNext) { |
368 #ifndef PDF_ENABLE_XFA | 368 #ifdef PDF_ENABLE_XFA |
369 CBA_AnnotIterator ai(pSDKAnnot->GetPageView(), "Widget", ""); | |
370 return bNext ? ai.GetNextAnnot(pSDKAnnot) : ai.GetPrevAnnot(pSDKAnnot); | |
371 #else | |
372 CPDFSDK_PageView* pPageView = pSDKAnnot->GetPageView(); | 369 CPDFSDK_PageView* pPageView = pSDKAnnot->GetPageView(); |
373 CPDFXFA_Page* pPage = pPageView->GetPDFXFAPage(); | 370 CPDFXFA_Page* pPage = pPageView->GetPDFXFAPage(); |
374 if (pPage == NULL) | 371 if (pPage == NULL) |
375 return NULL; | 372 return NULL; |
376 if (pPage->GetPDFPage()) { // for pdf annots. | 373 if (pPage->GetPDFPage()) { // for pdf annots. |
377 CBA_AnnotIterator ai(pSDKAnnot->GetPageView(), pSDKAnnot->GetType(), ""); | 374 CBA_AnnotIterator ai(pSDKAnnot->GetPageView(), pSDKAnnot->GetType(), ""); |
378 CPDFSDK_Annot* pNext = | 375 CPDFSDK_Annot* pNext = |
379 bNext ? ai.GetNextAnnot(pSDKAnnot) : ai.GetPrevAnnot(pSDKAnnot); | 376 bNext ? ai.GetNextAnnot(pSDKAnnot) : ai.GetPrevAnnot(pSDKAnnot); |
380 return pNext; | 377 return pNext; |
381 } | 378 } |
382 // for xfa annots | 379 // for xfa annots |
383 IXFA_WidgetIterator* pWidgetIterator = | 380 IXFA_WidgetIterator* pWidgetIterator = |
384 pPage->GetXFAPageView()->CreateWidgetIterator( | 381 pPage->GetXFAPageView()->CreateWidgetIterator( |
385 XFA_TRAVERSEWAY_Tranvalse, XFA_WIDGETFILTER_Visible | | 382 XFA_TRAVERSEWAY_Tranvalse, XFA_WIDGETFILTER_Visible | |
386 XFA_WIDGETFILTER_Viewable | | 383 XFA_WIDGETFILTER_Viewable | |
387 XFA_WIDGETFILTER_Field); | 384 XFA_WIDGETFILTER_Field); |
388 if (pWidgetIterator == NULL) | 385 if (pWidgetIterator == NULL) |
389 return NULL; | 386 return NULL; |
390 if (pWidgetIterator->GetCurrentWidget() != pSDKAnnot->GetXFAWidget()) | 387 if (pWidgetIterator->GetCurrentWidget() != pSDKAnnot->GetXFAWidget()) |
391 pWidgetIterator->SetCurrentWidget(pSDKAnnot->GetXFAWidget()); | 388 pWidgetIterator->SetCurrentWidget(pSDKAnnot->GetXFAWidget()); |
392 IXFA_Widget* hNextFocus = NULL; | 389 IXFA_Widget* hNextFocus = NULL; |
393 hNextFocus = | 390 hNextFocus = |
394 bNext ? pWidgetIterator->MoveToNext() : pWidgetIterator->MoveToPrevious(); | 391 bNext ? pWidgetIterator->MoveToNext() : pWidgetIterator->MoveToPrevious(); |
395 if (hNextFocus == NULL && pSDKAnnot != NULL) | 392 if (hNextFocus == NULL && pSDKAnnot != NULL) |
396 hNextFocus = pWidgetIterator->MoveToFirst(); | 393 hNextFocus = pWidgetIterator->MoveToFirst(); |
397 | 394 |
398 pWidgetIterator->Release(); | 395 pWidgetIterator->Release(); |
399 return pPageView->GetAnnotByXFAWidget(hNextFocus); | 396 return pPageView->GetAnnotByXFAWidget(hNextFocus); |
400 #endif | 397 #else // PDF_ENABLE_XFA |
| 398 CBA_AnnotIterator ai(pSDKAnnot->GetPageView(), "Widget", ""); |
| 399 return bNext ? ai.GetNextAnnot(pSDKAnnot) : ai.GetPrevAnnot(pSDKAnnot); |
| 400 #endif // PDF_ENABLE_XFA |
401 } | 401 } |
402 | 402 |
403 FX_BOOL CPDFSDK_BFAnnotHandler::CanAnswer(CPDFSDK_Annot* pAnnot) { | 403 FX_BOOL CPDFSDK_BFAnnotHandler::CanAnswer(CPDFSDK_Annot* pAnnot) { |
404 ASSERT(pAnnot->GetType() == "Widget"); | 404 ASSERT(pAnnot->GetType() == "Widget"); |
405 if (pAnnot->GetSubType() == BFFT_SIGNATURE) | 405 if (pAnnot->GetSubType() == BFFT_SIGNATURE) |
406 return FALSE; | 406 return FALSE; |
407 | 407 |
408 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; | 408 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; |
409 if (!pWidget->IsVisible()) | 409 if (!pWidget->IsVisible()) |
410 return FALSE; | 410 return FALSE; |
(...skipping 28 matching lines...) Expand all Loading... |
439 pWidget->ResetAppearance(nullptr, FALSE); | 439 pWidget->ResetAppearance(nullptr, FALSE); |
440 | 440 |
441 return pWidget; | 441 return pWidget; |
442 } | 442 } |
443 | 443 |
444 #ifdef PDF_ENABLE_XFA | 444 #ifdef PDF_ENABLE_XFA |
445 CPDFSDK_Annot* CPDFSDK_BFAnnotHandler::NewAnnot(IXFA_Widget* hWidget, | 445 CPDFSDK_Annot* CPDFSDK_BFAnnotHandler::NewAnnot(IXFA_Widget* hWidget, |
446 CPDFSDK_PageView* pPage) { | 446 CPDFSDK_PageView* pPage) { |
447 return NULL; | 447 return NULL; |
448 } | 448 } |
| 449 #endif // PDF_ENABLE_XFA |
449 | 450 |
450 #endif | |
451 void CPDFSDK_BFAnnotHandler::ReleaseAnnot(CPDFSDK_Annot* pAnnot) { | 451 void CPDFSDK_BFAnnotHandler::ReleaseAnnot(CPDFSDK_Annot* pAnnot) { |
452 ASSERT(pAnnot != NULL); | 452 ASSERT(pAnnot != NULL); |
453 | 453 |
454 if (m_pFormFiller) | 454 if (m_pFormFiller) |
455 m_pFormFiller->OnDelete(pAnnot); | 455 m_pFormFiller->OnDelete(pAnnot); |
456 | 456 |
457 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; | 457 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)pAnnot; |
458 CPDFSDK_InterForm* pInterForm = pWidget->GetInterForm(); | 458 CPDFSDK_InterForm* pInterForm = pWidget->GetInterForm(); |
459 ASSERT(pInterForm != NULL); | 459 ASSERT(pInterForm != NULL); |
460 | 460 |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
682 } | 682 } |
683 | 683 |
684 #ifdef PDF_ENABLE_XFA | 684 #ifdef PDF_ENABLE_XFA |
685 CPDFSDK_PageView* pPageView = pAnnot->GetPageView(); | 685 CPDFSDK_PageView* pPageView = pAnnot->GetPageView(); |
686 CPDFSDK_Document* pSDKDoc = pPageView->GetSDKDocument(); | 686 CPDFSDK_Document* pSDKDoc = pPageView->GetSDKDocument(); |
687 CPDFXFA_Document* pDoc = pSDKDoc->GetXFADocument(); | 687 CPDFXFA_Document* pDoc = pSDKDoc->GetXFADocument(); |
688 if (pDoc->GetDocType() == DOCTYPE_STATIC_XFA) { | 688 if (pDoc->GetDocType() == DOCTYPE_STATIC_XFA) { |
689 if (!pWidget->IsAppearanceValid() && !pWidget->GetValue().IsEmpty()) | 689 if (!pWidget->IsAppearanceValid() && !pWidget->GetValue().IsEmpty()) |
690 pWidget->ResetAppearance(FALSE); | 690 pWidget->ResetAppearance(FALSE); |
691 } | 691 } |
692 | 692 #endif // PDF_ENABLE_XFA |
693 #endif | |
694 if (m_pFormFiller) | 693 if (m_pFormFiller) |
695 m_pFormFiller->OnLoad(pAnnot); | 694 m_pFormFiller->OnLoad(pAnnot); |
696 } | 695 } |
697 | 696 |
698 FX_BOOL CPDFSDK_BFAnnotHandler::OnSetFocus(CPDFSDK_Annot* pAnnot, | 697 FX_BOOL CPDFSDK_BFAnnotHandler::OnSetFocus(CPDFSDK_Annot* pAnnot, |
699 FX_DWORD nFlag) { | 698 FX_DWORD nFlag) { |
700 ASSERT(pAnnot != NULL); | 699 ASSERT(pAnnot != NULL); |
701 CFX_ByteString sSubType = pAnnot->GetSubType(); | 700 CFX_ByteString sSubType = pAnnot->GetSubType(); |
702 | 701 |
703 if (sSubType == BFFT_SIGNATURE) { | 702 if (sSubType == BFFT_SIGNATURE) { |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
770 | 769 |
771 FX_BOOL CPDFSDK_XFAAnnotHandler::CanAnswer(CPDFSDK_Annot* pAnnot) { | 770 FX_BOOL CPDFSDK_XFAAnnotHandler::CanAnswer(CPDFSDK_Annot* pAnnot) { |
772 return pAnnot->GetXFAWidget() != NULL; | 771 return pAnnot->GetXFAWidget() != NULL; |
773 } | 772 } |
774 | 773 |
775 void CPDFSDK_XFAAnnotHandler::OnDraw(CPDFSDK_PageView* pPageView, | 774 void CPDFSDK_XFAAnnotHandler::OnDraw(CPDFSDK_PageView* pPageView, |
776 CPDFSDK_Annot* pAnnot, | 775 CPDFSDK_Annot* pAnnot, |
777 CFX_RenderDevice* pDevice, | 776 CFX_RenderDevice* pDevice, |
778 CPDF_Matrix* pUser2Device, | 777 CPDF_Matrix* pUser2Device, |
779 FX_DWORD dwFlags) { | 778 FX_DWORD dwFlags) { |
780 #ifdef PDF_ENABLE_XFA | |
781 | |
782 ASSERT(pPageView != NULL); | 779 ASSERT(pPageView != NULL); |
783 ASSERT(pAnnot != NULL); | 780 ASSERT(pAnnot != NULL); |
784 | 781 |
785 CPDFSDK_Document* pSDKDoc = pPageView->GetSDKDocument(); | 782 CPDFSDK_Document* pSDKDoc = pPageView->GetSDKDocument(); |
786 ASSERT(pSDKDoc != NULL); | 783 ASSERT(pSDKDoc != NULL); |
787 | 784 |
788 IXFA_WidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); | 785 IXFA_WidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); |
789 ASSERT(pWidgetHandler != NULL); | 786 ASSERT(pWidgetHandler != NULL); |
790 | 787 |
791 CFX_Graphics gs; | 788 CFX_Graphics gs; |
792 gs.Create(pDevice); | 789 gs.Create(pDevice); |
793 | 790 |
794 CFX_Matrix mt; | 791 CFX_Matrix mt; |
795 mt = *(CFX_Matrix*)pUser2Device; | 792 mt = *(CFX_Matrix*)pUser2Device; |
796 | 793 |
797 FX_BOOL bIsHighlight = FALSE; | 794 FX_BOOL bIsHighlight = FALSE; |
798 if (pSDKDoc->GetFocusAnnot() != pAnnot) | 795 if (pSDKDoc->GetFocusAnnot() != pAnnot) |
799 bIsHighlight = TRUE; | 796 bIsHighlight = TRUE; |
800 | 797 |
801 pWidgetHandler->RenderWidget(pAnnot->GetXFAWidget(), &gs, &mt, bIsHighlight); | 798 pWidgetHandler->RenderWidget(pAnnot->GetXFAWidget(), &gs, &mt, bIsHighlight); |
802 | 799 |
803 // to do highlight and shadow | 800 // to do highlight and shadow |
804 #endif // PDF_ENABLE_XFA | |
805 } | 801 } |
806 | 802 |
807 void CPDFSDK_XFAAnnotHandler::ReleaseAnnot(CPDFSDK_Annot* pAnnot) { | 803 void CPDFSDK_XFAAnnotHandler::ReleaseAnnot(CPDFSDK_Annot* pAnnot) { |
808 ASSERT(pAnnot != NULL); | 804 ASSERT(pAnnot != NULL); |
809 | 805 |
810 CPDFSDK_XFAWidget* pWidget = (CPDFSDK_XFAWidget*)pAnnot; | 806 CPDFSDK_XFAWidget* pWidget = (CPDFSDK_XFAWidget*)pAnnot; |
811 CPDFSDK_InterForm* pInterForm = pWidget->GetInterForm(); | 807 CPDFSDK_InterForm* pInterForm = pWidget->GetInterForm(); |
812 ASSERT(pInterForm != NULL); | 808 ASSERT(pInterForm != NULL); |
813 | 809 |
814 pInterForm->RemoveXFAMap(pWidget->GetXFAWidget()); | 810 pInterForm->RemoveXFAMap(pWidget->GetXFAWidget()); |
815 | 811 |
816 delete pWidget; | 812 delete pWidget; |
817 } | 813 } |
818 | 814 |
819 CPDF_Rect CPDFSDK_XFAAnnotHandler::GetViewBBox(CPDFSDK_PageView* pPageView, | 815 CPDF_Rect CPDFSDK_XFAAnnotHandler::GetViewBBox(CPDFSDK_PageView* pPageView, |
820 CPDFSDK_Annot* pAnnot) { | 816 CPDFSDK_Annot* pAnnot) { |
821 ASSERT(pAnnot != NULL); | 817 ASSERT(pAnnot != NULL); |
822 | 818 |
823 IXFA_WidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); | 819 IXFA_WidgetHandler* pWidgetHandler = GetXFAWidgetHandler(pAnnot); |
824 ASSERT(pWidgetHandler != NULL); | 820 ASSERT(pWidgetHandler != NULL); |
825 | 821 |
826 CFX_RectF rcBBox; | 822 CFX_RectF rcBBox; |
827 #ifdef PDF_ENABLE_XFA | |
828 XFA_ELEMENT eType = | 823 XFA_ELEMENT eType = |
829 pWidgetHandler->GetDataAcc(pAnnot->GetXFAWidget())->GetUIType(); | 824 pWidgetHandler->GetDataAcc(pAnnot->GetXFAWidget())->GetUIType(); |
830 if (eType == XFA_ELEMENT_Signature) | 825 if (eType == XFA_ELEMENT_Signature) |
831 pWidgetHandler->GetBBox(pAnnot->GetXFAWidget(), rcBBox, | 826 pWidgetHandler->GetBBox(pAnnot->GetXFAWidget(), rcBBox, |
832 XFA_WIDGETSTATUS_Visible, TRUE); | 827 XFA_WIDGETSTATUS_Visible, TRUE); |
833 else | 828 else |
834 #endif | |
835 pWidgetHandler->GetBBox(pAnnot->GetXFAWidget(), rcBBox, 0); | 829 pWidgetHandler->GetBBox(pAnnot->GetXFAWidget(), rcBBox, 0); |
836 | 830 |
837 CFX_FloatRect rcWidget(rcBBox.left, rcBBox.top, rcBBox.left + rcBBox.width, | 831 CFX_FloatRect rcWidget(rcBBox.left, rcBBox.top, rcBBox.left + rcBBox.width, |
838 rcBBox.top + rcBBox.height); | 832 rcBBox.top + rcBBox.height); |
839 rcWidget.left -= 1.0f; | 833 rcWidget.left -= 1.0f; |
840 rcWidget.right += 1.0f; | 834 rcWidget.right += 1.0f; |
841 rcWidget.bottom -= 1.0f; | 835 rcWidget.bottom -= 1.0f; |
842 rcWidget.top += 1.0f; | 836 rcWidget.top += 1.0f; |
843 | 837 |
844 return rcWidget; | 838 return rcWidget; |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1157 dwFWLFlag |= FWL_KEYFLAG_MButton; | 1151 dwFWLFlag |= FWL_KEYFLAG_MButton; |
1158 if (dwFlag & FWL_EVENTFLAG_RightButtonDown) | 1152 if (dwFlag & FWL_EVENTFLAG_RightButtonDown) |
1159 dwFWLFlag |= FWL_KEYFLAG_RButton; | 1153 dwFWLFlag |= FWL_KEYFLAG_RButton; |
1160 if (dwFlag & FWL_EVENTFLAG_ShiftKey) | 1154 if (dwFlag & FWL_EVENTFLAG_ShiftKey) |
1161 dwFWLFlag |= FWL_KEYFLAG_Shift; | 1155 dwFWLFlag |= FWL_KEYFLAG_Shift; |
1162 if (dwFlag & FWL_EVENTFLAG_AltKey) | 1156 if (dwFlag & FWL_EVENTFLAG_AltKey) |
1163 dwFWLFlag |= FWL_KEYFLAG_Alt; | 1157 dwFWLFlag |= FWL_KEYFLAG_Alt; |
1164 | 1158 |
1165 return dwFWLFlag; | 1159 return dwFWLFlag; |
1166 } | 1160 } |
| 1161 #endif // PDF_ENABLE_XFA |
1167 | 1162 |
1168 #endif | |
1169 CPDFSDK_AnnotIterator::CPDFSDK_AnnotIterator(CPDFSDK_PageView* pPageView, | 1163 CPDFSDK_AnnotIterator::CPDFSDK_AnnotIterator(CPDFSDK_PageView* pPageView, |
1170 bool bReverse) | 1164 bool bReverse) |
1171 : m_bReverse(bReverse), m_pos(0) { | 1165 : m_bReverse(bReverse), m_pos(0) { |
1172 const std::vector<CPDFSDK_Annot*>& annots = pPageView->GetAnnotList(); | 1166 const std::vector<CPDFSDK_Annot*>& annots = pPageView->GetAnnotList(); |
1173 m_iteratorAnnotList.insert(m_iteratorAnnotList.begin(), annots.rbegin(), | 1167 m_iteratorAnnotList.insert(m_iteratorAnnotList.begin(), annots.rbegin(), |
1174 annots.rend()); | 1168 annots.rend()); |
1175 std::stable_sort(m_iteratorAnnotList.begin(), m_iteratorAnnotList.end(), | 1169 std::stable_sort(m_iteratorAnnotList.begin(), m_iteratorAnnotList.end(), |
1176 [](CPDFSDK_Annot* p1, CPDFSDK_Annot* p2) { | 1170 [](CPDFSDK_Annot* p1, CPDFSDK_Annot* p2) { |
1177 return p1->GetLayoutOrder() < p2->GetLayoutOrder(); | 1171 return p1->GetLayoutOrder() < p2->GetLayoutOrder(); |
1178 }); | 1172 }); |
(...skipping 22 matching lines...) Expand all Loading... |
1201 | 1195 |
1202 CPDFSDK_Annot* CPDFSDK_AnnotIterator::PrevAnnot() { | 1196 CPDFSDK_Annot* CPDFSDK_AnnotIterator::PrevAnnot() { |
1203 if (m_pos < m_iteratorAnnotList.size()) | 1197 if (m_pos < m_iteratorAnnotList.size()) |
1204 return m_iteratorAnnotList[m_iteratorAnnotList.size() - ++m_pos]; | 1198 return m_iteratorAnnotList[m_iteratorAnnotList.size() - ++m_pos]; |
1205 return nullptr; | 1199 return nullptr; |
1206 } | 1200 } |
1207 | 1201 |
1208 CPDFSDK_Annot* CPDFSDK_AnnotIterator::Next() { | 1202 CPDFSDK_Annot* CPDFSDK_AnnotIterator::Next() { |
1209 return m_bReverse ? PrevAnnot() : NextAnnot(); | 1203 return m_bReverse ? PrevAnnot() : NextAnnot(); |
1210 } | 1204 } |
OLD | NEW |