Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
cpdfsdk_pageview.h
Go to the documentation of this file.
1// Copyright 2016 The PDFium Authors
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_CPDFSDK_PAGEVIEW_H_
8#define FPDFSDK_CPDFSDK_PAGEVIEW_H_
9
10#include <stdint.h>
11
12#include <memory>
13#include <vector>
14
15#include "core/fpdfapi/page/cpdf_page.h"
16#include "core/fxcrt/mask.h"
17#include "core/fxcrt/unowned_ptr.h"
18#include "fpdfsdk/cpdfsdk_annot.h"
19
21class CPDF_AnnotList;
23class CPDFSDK_FormFillEnvironment;
24class CPDFSDK_InteractiveForm;
25
26#ifdef PDF_ENABLE_XFA
27class CPDFXFA_Page;
28class CXFA_FFWidget;
29#endif // PDF_ENABLE_XFA
30
31class CPDFSDK_PageView final : public CPDF_Page::View {
32 public:
33 CPDFSDK_PageView(CPDFSDK_FormFillEnvironment* pFormFillEnv, IPDF_Page* page);
35
36 // CPDF_Page::View:
37 void ClearPage(CPDF_Page* pPage) override;
38
40 const CFX_Matrix& mtUser2Device,
41 CPDF_RenderOptions* pOptions,
42 const FX_RECT& pClip);
43
44 void LoadFXAnnots();
50 bool IsValidAnnot(const CPDF_Annot* p) const;
51 bool IsValidSDKAnnot(const CPDFSDK_Annot* p) const;
52
54 CPDFSDK_Annot* GetAnnotByDict(const CPDF_Dictionary* pDict);
55
56#ifdef PDF_ENABLE_XFA
57 CPDFSDK_Annot* AddAnnotForFFWidget(CXFA_FFWidget* pWidget);
58 void DeleteAnnotForFFWidget(CXFA_FFWidget* pWidget);
59 CPDFSDK_Annot* GetAnnotForFFWidget(CXFA_FFWidget* pWidget);
60 IPDF_Page* GetXFAPage();
61#endif // PDF_ENABLE_XFA
62
63 CPDF_Page* GetPDFPage() const;
65 CPDFSDK_FormFillEnvironment* GetFormFillEnv() const { return m_pFormFillEnv; }
66
67 WideString GetFocusedFormText();
68 WideString GetSelectedText();
69 void ReplaceAndKeepSelection(const WideString& text);
70 void ReplaceSelection(const WideString& text);
71 bool SelectAllText();
72
73 bool CanUndo();
74 bool CanRedo();
75 bool Undo();
76 bool Redo();
77
78 bool OnFocus(Mask<FWL_EVENTFLAG> nFlags, const CFX_PointF& point);
79 bool OnLButtonDown(Mask<FWL_EVENTFLAG> nFlags, const CFX_PointF& point);
80 bool OnLButtonUp(Mask<FWL_EVENTFLAG> nFlags, const CFX_PointF& point);
81 bool OnLButtonDblClk(Mask<FWL_EVENTFLAG> nFlags, const CFX_PointF& point);
82 bool OnRButtonDown(Mask<FWL_EVENTFLAG> nFlags, const CFX_PointF& point);
83 bool OnRButtonUp(Mask<FWL_EVENTFLAG> nFlags, const CFX_PointF& point);
84 bool OnChar(uint32_t nChar, Mask<FWL_EVENTFLAG> nFlags);
85 bool OnKeyDown(FWL_VKEYCODE nKeyCode, Mask<FWL_EVENTFLAG> nFlags);
86 bool OnMouseMove(Mask<FWL_EVENTFLAG> nFlags, const CFX_PointF& point);
87 bool OnMouseWheel(Mask<FWL_EVENTFLAG> nFlags,
88 const CFX_PointF& point,
89 const CFX_Vector& delta);
90
91 bool SetIndexSelected(int index, bool selected);
92 bool IsIndexSelected(int index);
93
94 const CFX_Matrix& GetCurrentMatrix() const { return m_curMatrix; }
95 void UpdateRects(const std::vector<CFX_FloatRect>& rects);
96 void UpdateView(CPDFSDK_Annot* pAnnot);
97
98 int GetPageIndex() const;
99
100 void SetValid(bool bValid) { m_bValid = bValid; }
101 bool IsValid() const { return m_bValid; }
102 bool IsLocked() const { return m_bLocked; }
103 void SetBeingDestroyed() { m_bBeingDestroyed = true; }
104 bool IsBeingDestroyed() const { return m_bBeingDestroyed; }
105
106 private:
107#ifdef PDF_ENABLE_XFA
108 CPDFXFA_Page* XFAPageIfNotBackedByPDFPage();
109#endif
110
111 std::unique_ptr<CPDFSDK_Annot> NewAnnot(CPDF_Annot* annot);
112
113 CPDFSDK_InteractiveForm* GetInteractiveForm() const;
114 CPDFSDK_Annot* GetFXAnnotAtPoint(const CFX_PointF& point);
115 CPDFSDK_Annot* GetFXWidgetAtPoint(const CFX_PointF& point);
116
117 int GetPageIndexForStaticPDF() const;
118
119 void EnterWidget(ObservedPtr<CPDFSDK_Annot>& pAnnot,
120 Mask<FWL_EVENTFLAG> nFlags);
121 void ExitWidget(bool callExitCallback, Mask<FWL_EVENTFLAG> nFlags);
122
123 CFX_Matrix m_curMatrix;
124 UnownedPtr<IPDF_Page> const m_page;
125 std::unique_ptr<CPDF_AnnotList> m_pAnnotList;
126 std::vector<std::unique_ptr<CPDFSDK_Annot>> m_SDKAnnotArray;
127 UnownedPtr<CPDFSDK_FormFillEnvironment> const m_pFormFillEnv;
128 ObservedPtr<CPDFSDK_Annot> m_pCaptureWidget;
129 bool m_bOnWidget = false;
130 bool m_bValid = false;
131 bool m_bLocked = false;
132 bool m_bBeingDestroyed = false;
133};
134
135#endif // FPDFSDK_CPDFSDK_PAGEVIEW_H_
virtual bool OnChar(uint32_t nChar, Mask< FWL_EVENTFLAG > nFlags)=0
virtual bool OnLButtonDblClk(Mask< FWL_EVENTFLAG > nFlags, const CFX_PointF &point)=0
virtual bool OnKillFocus(Mask< FWL_EVENTFLAG > nFlags)=0
virtual bool OnSetFocus(Mask< FWL_EVENTFLAG > nFlags)=0
virtual bool OnLButtonUp(Mask< FWL_EVENTFLAG > nFlags, const CFX_PointF &point)=0
virtual void OnMouseEnter(Mask< FWL_EVENTFLAG > nFlags)=0
virtual bool OnRButtonDown(Mask< FWL_EVENTFLAG > nFlags, const CFX_PointF &point)=0
virtual bool OnKeyDown(FWL_VKEYCODE nKeyCode, Mask< FWL_EVENTFLAG > nFlags)=0
virtual void OnMouseExit(Mask< FWL_EVENTFLAG > nFlags)=0
virtual bool OnLButtonDown(Mask< FWL_EVENTFLAG > nFlags, const CFX_PointF &point)=0
virtual bool OnRButtonUp(Mask< FWL_EVENTFLAG > nFlags, const CFX_PointF &point)=0
virtual bool OnMouseMove(Mask< FWL_EVENTFLAG > nFlags, const CFX_PointF &point)=0
virtual bool OnMouseWheel(Mask< FWL_EVENTFLAG > nFlags, const CFX_PointF &point, const CFX_Vector &delta)=0
virtual bool SetIndexSelected(int index, bool selected)=0
virtual bool IsIndexSelected(int index)=0
virtual bool Redo()=0
IPDF_Page * GetPage()
IPDF_Page * GetXFAPage()
static bool OnRButtonUp(ObservedPtr< CPDFSDK_Annot > &pAnnot, Mask< FWL_EVENTFLAG > nFlags, const CFX_PointF &point)
static bool OnKeyDown(ObservedPtr< CPDFSDK_Annot > &pAnnot, FWL_VKEYCODE nKeyCode, Mask< FWL_EVENTFLAG > nFlags)
virtual void ReplaceSelection(const WideString &text)=0
virtual void OnLoad()
static bool OnRButtonDown(ObservedPtr< CPDFSDK_Annot > &pAnnot, Mask< FWL_EVENTFLAG > nFlags, const CFX_PointF &point)
virtual bool CanUndo()=0
virtual WideString GetText()=0
virtual int GetLayoutOrder() const
static bool OnMouseMove(ObservedPtr< CPDFSDK_Annot > &pAnnot, Mask< FWL_EVENTFLAG > nFlags, const CFX_PointF &point)
virtual CFX_FloatRect GetViewBBox()=0
static bool OnKillFocus(ObservedPtr< CPDFSDK_Annot > &pAnnot, Mask< FWL_EVENTFLAG > nFlags)
CPDF_Page * GetPDFPage()
virtual CPDF_Annot::Subtype GetAnnotSubtype() const =0
virtual bool CanRedo()=0
virtual CFX_FloatRect GetRect() const =0
static bool OnLButtonUp(ObservedPtr< CPDFSDK_Annot > &pAnnot, Mask< FWL_EVENTFLAG > nFlags, const CFX_PointF &point)
CPDFSDK_Annot(CPDFSDK_PageView *pPageView)
static bool OnMouseWheel(ObservedPtr< CPDFSDK_Annot > &pAnnot, Mask< FWL_EVENTFLAG > nFlags, const CFX_PointF &point, const CFX_Vector &delta)
virtual WideString GetSelectedText()=0
virtual CPDFSDK_BAAnnot * AsBAAnnot()
virtual ~CPDFSDK_Annot()
static void OnMouseEnter(ObservedPtr< CPDFSDK_Annot > &pAnnot, Mask< FWL_EVENTFLAG > nFlags)
virtual bool DoHitTest(const CFX_PointF &point)=0
CPDFSDK_PageView * GetPageView() const
virtual bool SelectAllText()=0
static bool OnChar(ObservedPtr< CPDFSDK_Annot > &pAnnot, uint32_t nChar, Mask< FWL_EVENTFLAG > nFlags)
static bool OnSetFocus(ObservedPtr< CPDFSDK_Annot > &pAnnot, Mask< FWL_EVENTFLAG > nFlags)
virtual void OnDraw(CFX_RenderDevice *pDevice, const CFX_Matrix &mtUser2Device, bool bDrawAnnots)=0
virtual void ReplaceAndKeepSelection(const WideString &text)=0
static bool OnLButtonDblClk(ObservedPtr< CPDFSDK_Annot > &pAnnot, Mask< FWL_EVENTFLAG > nFlags, const CFX_PointF &point)
virtual CPDF_Annot * GetPDFAnnot() const
virtual CPDFXFA_Widget * AsXFAWidget()
virtual UnsafeInputHandlers * GetUnsafeInputHandlers()=0
static void OnMouseExit(ObservedPtr< CPDFSDK_Annot > &pAnnot, Mask< FWL_EVENTFLAG > nFlags)
static bool OnLButtonDown(ObservedPtr< CPDFSDK_Annot > &pAnnot, Mask< FWL_EVENTFLAG > nFlags, const CFX_PointF &point)
virtual bool Undo()=0
CPDFSDK_Annot * GetFocusAnnot()
bool OnKeyDown(FWL_VKEYCODE nKeyCode, Mask< FWL_EVENTFLAG > nFlags)
CPDF_Document * GetPDFDocument()
std::vector< CPDFSDK_Annot * > GetAnnotList() const
bool OnMouseMove(Mask< FWL_EVENTFLAG > nFlags, const CFX_PointF &point)
CPDFSDK_Annot * GetNextAnnot(CPDFSDK_Annot *pAnnot)
CPDFSDK_Annot * GetPrevAnnot(CPDFSDK_Annot *pAnnot)
void SetValid(bool bValid)
void ReplaceSelection(const WideString &text)
bool OnFocus(Mask< FWL_EVENTFLAG > nFlags, const CFX_PointF &point)
CPDFSDK_Annot * GetLastFocusableAnnot()
bool IsValidSDKAnnot(const CPDFSDK_Annot *p) const
bool IsBeingDestroyed() const
CPDFSDK_PageView(CPDFSDK_FormFillEnvironment *pFormFillEnv, IPDF_Page *page)
void PageView_OnDraw(CFX_RenderDevice *pDevice, const CFX_Matrix &mtUser2Device, CPDF_RenderOptions *pOptions, const FX_RECT &pClip)
bool IsLocked() const
bool OnRButtonUp(Mask< FWL_EVENTFLAG > nFlags, const CFX_PointF &point)
void ClearPage(CPDF_Page *pPage) override
bool OnLButtonDblClk(Mask< FWL_EVENTFLAG > nFlags, const CFX_PointF &point)
CPDFSDK_FormFillEnvironment * GetFormFillEnv() const
void UpdateRects(const std::vector< CFX_FloatRect > &rects)
CPDF_Page * GetPDFPage() const
const CFX_Matrix & GetCurrentMatrix() const
void UpdateView(CPDFSDK_Annot *pAnnot)
bool OnRButtonDown(Mask< FWL_EVENTFLAG > nFlags, const CFX_PointF &point)
bool OnLButtonUp(Mask< FWL_EVENTFLAG > nFlags, const CFX_PointF &point)
WideString GetFocusedFormText()
CPDFSDK_Annot * GetAnnotByDict(const CPDF_Dictionary *pDict)
WideString GetSelectedText()
void ReplaceAndKeepSelection(const WideString &text)
bool OnLButtonDown(Mask< FWL_EVENTFLAG > nFlags, const CFX_PointF &point)
bool IsIndexSelected(int index)
bool OnMouseWheel(Mask< FWL_EVENTFLAG > nFlags, const CFX_PointF &point, const CFX_Vector &delta)
bool IsValidAnnot(const CPDF_Annot *p) const
bool SetIndexSelected(int index, bool selected)
CPDFSDK_Annot * GetFirstFocusableAnnot()
bool OnChar(uint32_t nChar, Mask< FWL_EVENTFLAG > nFlags)
CPDFXFA_Widget * ToXFAWidget(CPDFSDK_Annot *pAnnot)
@ FWL_EVENTFLAG_ShiftKey
@ FWL_EVENTFLAG_RightButtonDown
@ FWL_EVENTFLAG_LeftButtonDown
@ FWL_EVENTFLAG_AutoRepeat
@ FWL_EVENTFLAG_KeyPad
@ FWL_EVENTFLAG_MiddleButtonDown
@ FWL_EVENTFLAG_MetaKey
@ FWL_EVENTFLAG_AltKey
@ FWL_EVENTF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
@ FWL_VKEY_MEDIA_PLAY_Pause
@ FWL_VKEY_Junja
@ FWL_VKEY_F17
@ FWL_VKEY_MEDIA_NEXT_Track
@ FWL_VKEY_Accept
@ FWL_VKEY_NumPad7
@ FWL_VKEY_OEM_7
@ FWL_VKEY_D
@ FWL_VKEY_MEDIA_LAUNCH_APP2
@ FWL_VKEY_Ereof
@ FWL_VKEY_F2
@ FWL_VKEY_F24
@ FWL_VKEY_3
@ FWL_VKEY_VOLUME_Up
@ FWL_VKEY_Scroll
@ FWL_VKEY_F13
@ FWL_VKEY_LShift
@ FWL_VKEY_MEDIA_Stop
@ FWL_VKEY_OEM_Minus
@ FWL_VKEY_VOLUME_Mute
@ FWL_VKEY_2
@ FWL_VKEY_RWin
@ FWL_VKEY_Subtract
@ FWL_VKEY_Space
@ FWL_VKEY_O
@ FWL_VKEY_Execute
@ FWL_VKEY_BROWSER_Back
@ FWL_VKEY_NumPad0
@ FWL_VKEY_F5
@ FWL_VKEY_9
@ FWL_VKEY_R
@ FWL_VKEY_F10
@ FWL_VKEY_K
@ FWL_VKEY_X
@ FWL_VKEY_J
@ FWL_VKEY_Pause
@ FWL_VKEY_OEM_5
@ FWL_VKEY_ProcessKey
@ FWL_VKEY_OEM_2
@ FWL_VKEY_T
@ FWL_VKEY_BROWSER_Favorites
@ FWL_VKEY_L
@ FWL_VKEY_F16
@ FWL_VKEY_Separator
@ FWL_VKEY_Insert
@ FWL_VKEY_N
@ FWL_VKEY_NoName
@ FWL_VKEY_NumPad2
@ FWL_VKEY_LControl
@ FWL_VKEY_Hanja
@ FWL_VKEY_OEM_3
@ FWL_VKEY_F15
@ FWL_VKEY_NunLock
@ FWL_VKEY_OEM_1
@ FWL_VKEY_C
@ FWL_VKEY_Convert
@ FWL_VKEY_OEM_Period
@ FWL_VKEY_NumPad5
@ FWL_VKEY_Apps
@ FWL_VKEY_LMenu
@ FWL_VKEY_BROWSER_Home
@ FWL_VKEY_Back
@ FWL_VKEY_8
@ FWL_VKEY_NumPad6
@ FWL_VKEY_OEM_Clear
@ FWL_VKEY_BROWSER_Stop
@ FWL_VKEY_U
@ FWL_VKEY_Prior
@ FWL_VKEY_Divide
@ FWL_VKEY_OEM_8
@ FWL_VKEY_F3
@ FWL_VKEY_V
@ FWL_VKEY_F8
@ FWL_VKEY_Exsel
@ FWL_VKEY_Kana
@ FWL_VKEY_OEM_102
@ FWL_VKEY_Left
@ FWL_VKEY_Escape
@ FWL_VKEY_BROWSER_Search
@ FWL_VKEY_F4
@ FWL_VKEY_Clear
@ FWL_VKEY_F7
@ FWL_VKEY_F18
@ FWL_VKEY_OEM_Comma
@ FWL_VKEY_Return
@ FWL_VKEY_OEM_Plus
@ FWL_VKEY_5
@ FWL_VKEY_OEM_4
@ FWL_VKEY_Select
@ FWL_VKEY_F22
@ FWL_VKEY_NonConvert
@ FWL_VKEY_BROWSER_Refresh
@ FWL_VKEY_NumPad4
@ FWL_VKEY_Y
@ FWL_VKEY_B
@ FWL_VKEY_VOLUME_Down
@ FWL_VKEY_PA1
@ FWL_VKEY_MEDIA_LAUNCH_MEDIA_Select
@ FWL_VKEY_RControl
@ FWL_VKEY_F20
@ FWL_VKEY_Delete
@ FWL_VKEY_RShift