| OLD | NEW |
| (Empty) |
| 1 // Copyright 2016 PDFium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | |
| 6 | |
| 7 #ifndef FPDFSDK_INCLUDE_CPDFSDK_PAGEVIEW_H_ | |
| 8 #define FPDFSDK_INCLUDE_CPDFSDK_PAGEVIEW_H_ | |
| 9 | |
| 10 #include <memory> | |
| 11 #include <vector> | |
| 12 | |
| 13 #include "core/fpdfapi/fpdf_page/cpdf_page.h" | |
| 14 #include "core/fxcrt/fx_system.h" | |
| 15 #include "fpdfsdk/include/cpdfsdk_annot.h" | |
| 16 #include "fpdfsdk/include/cpdfsdk_document.h" | |
| 17 | |
| 18 class CFX_RenderDevice; | |
| 19 class CPDF_AnnotList; | |
| 20 class CPDF_RenderOptions; | |
| 21 | |
| 22 class CPDFSDK_PageView final : public CPDF_Page::View { | |
| 23 public: | |
| 24 CPDFSDK_PageView(CPDFSDK_Document* pSDKDoc, UnderlyingPageType* page); | |
| 25 ~CPDFSDK_PageView(); | |
| 26 | |
| 27 #ifdef PDF_ENABLE_XFA | |
| 28 void PageView_OnDraw(CFX_RenderDevice* pDevice, | |
| 29 CFX_Matrix* pUser2Device, | |
| 30 CPDF_RenderOptions* pOptions, | |
| 31 const FX_RECT& pClip); | |
| 32 #else // PDF_ENABLE_XFA | |
| 33 void PageView_OnDraw(CFX_RenderDevice* pDevice, | |
| 34 CFX_Matrix* pUser2Device, | |
| 35 CPDF_RenderOptions* pOptions); | |
| 36 #endif // PDF_ENABLE_XFA | |
| 37 | |
| 38 const CPDF_Annot* GetPDFAnnotAtPoint(FX_FLOAT pageX, FX_FLOAT pageY); | |
| 39 CPDFSDK_Annot* GetFXAnnotAtPoint(FX_FLOAT pageX, FX_FLOAT pageY); | |
| 40 const CPDF_Annot* GetPDFWidgetAtPoint(FX_FLOAT pageX, FX_FLOAT pageY); | |
| 41 CPDFSDK_Annot* GetFXWidgetAtPoint(FX_FLOAT pageX, FX_FLOAT pageY); | |
| 42 CPDFSDK_Annot* GetFocusAnnot(); | |
| 43 void SetFocusAnnot(CPDFSDK_Annot::ObservedPtr* pSDKAnnot, | |
| 44 uint32_t nFlag = 0) { | |
| 45 m_pSDKDoc->SetFocusAnnot(pSDKAnnot, nFlag); | |
| 46 } | |
| 47 FX_BOOL KillFocusAnnot(uint32_t nFlag = 0) { | |
| 48 return m_pSDKDoc->KillFocusAnnot(nFlag); | |
| 49 } | |
| 50 void KillFocusAnnotIfNeeded(); | |
| 51 | |
| 52 CPDFSDK_Annot* AddAnnot(CPDF_Dictionary* pDict); | |
| 53 CPDFSDK_Annot* AddAnnot(const FX_CHAR* lpSubType, CPDF_Dictionary* pDict); | |
| 54 CPDFSDK_Annot* AddAnnot(CPDF_Annot* pPDFAnnot); | |
| 55 | |
| 56 FX_BOOL DeleteAnnot(CPDFSDK_Annot* pAnnot); | |
| 57 size_t CountAnnots() const; | |
| 58 CPDFSDK_Annot* GetAnnot(size_t nIndex); | |
| 59 CPDFSDK_Annot* GetAnnotByDict(CPDF_Dictionary* pDict); | |
| 60 | |
| 61 #ifdef PDF_ENABLE_XFA | |
| 62 CPDFSDK_Annot* AddAnnot(CXFA_FFWidget* pPDFAnnot); | |
| 63 CPDFSDK_Annot* GetAnnotByXFAWidget(CXFA_FFWidget* hWidget); | |
| 64 CPDFXFA_Page* GetPDFXFAPage() { return m_page; } | |
| 65 #endif // PDF_ENABLE_XFA | |
| 66 | |
| 67 CPDF_Page* GetPDFPage() const; | |
| 68 CPDF_Document* GetPDFDocument(); | |
| 69 CPDFSDK_Document* GetSDKDocument() { return m_pSDKDoc; } | |
| 70 FX_BOOL OnLButtonDown(const CFX_FloatPoint& point, uint32_t nFlag); | |
| 71 FX_BOOL OnLButtonUp(const CFX_FloatPoint& point, uint32_t nFlag); | |
| 72 #ifdef PDF_ENABLE_XFA | |
| 73 FX_BOOL OnRButtonDown(const CFX_FloatPoint& point, uint32_t nFlag); | |
| 74 FX_BOOL OnRButtonUp(const CFX_FloatPoint& point, uint32_t nFlag); | |
| 75 #endif // PDF_ENABLE_XFA | |
| 76 FX_BOOL OnChar(int nChar, uint32_t nFlag); | |
| 77 FX_BOOL OnKeyDown(int nKeyCode, int nFlag); | |
| 78 FX_BOOL OnKeyUp(int nKeyCode, int nFlag); | |
| 79 | |
| 80 FX_BOOL OnMouseMove(const CFX_FloatPoint& point, int nFlag); | |
| 81 FX_BOOL OnMouseWheel(double deltaX, | |
| 82 double deltaY, | |
| 83 const CFX_FloatPoint& point, | |
| 84 int nFlag); | |
| 85 bool IsValidAnnot(const CPDF_Annot* p) const; | |
| 86 void GetCurrentMatrix(CFX_Matrix& matrix) { matrix = m_curMatrix; } | |
| 87 void UpdateRects(const std::vector<CFX_FloatRect>& rects); | |
| 88 void UpdateView(CPDFSDK_Annot* pAnnot); | |
| 89 const std::vector<CPDFSDK_Annot*>& GetAnnotList() const { | |
| 90 return m_fxAnnotArray; | |
| 91 } | |
| 92 | |
| 93 int GetPageIndex() const; | |
| 94 void LoadFXAnnots(); | |
| 95 void ClearFXAnnots(); | |
| 96 void SetValid(FX_BOOL bValid) { m_bValid = bValid; } | |
| 97 FX_BOOL IsValid() { return m_bValid; } | |
| 98 void SetLock(FX_BOOL bLocked) { m_bLocked = bLocked; } | |
| 99 FX_BOOL IsLocked() { return m_bLocked; } | |
| 100 #ifndef PDF_ENABLE_XFA | |
| 101 bool OwnsPage() const { return m_bOwnsPage; } | |
| 102 void TakePageOwnership() { m_bOwnsPage = true; } | |
| 103 #endif // PDF_ENABLE_XFA | |
| 104 | |
| 105 private: | |
| 106 int GetPageIndexForStaticPDF() const; | |
| 107 | |
| 108 CFX_Matrix m_curMatrix; | |
| 109 UnderlyingPageType* const m_page; | |
| 110 std::unique_ptr<CPDF_AnnotList> m_pAnnotList; | |
| 111 std::vector<CPDFSDK_Annot*> m_fxAnnotArray; | |
| 112 CPDFSDK_Document* const m_pSDKDoc; | |
| 113 CPDFSDK_Annot::ObservedPtr m_pCaptureWidget; | |
| 114 #ifndef PDF_ENABLE_XFA | |
| 115 bool m_bOwnsPage; | |
| 116 #endif // PDF_ENABLE_XFA | |
| 117 FX_BOOL m_bEnterWidget; | |
| 118 FX_BOOL m_bExitWidget; | |
| 119 FX_BOOL m_bOnWidget; | |
| 120 FX_BOOL m_bValid; | |
| 121 FX_BOOL m_bLocked; | |
| 122 }; | |
| 123 | |
| 124 #endif // FPDFSDK_INCLUDE_CPDFSDK_PAGEVIEW_H_ | |
| OLD | NEW |