1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
|
// Copyright 2014 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#ifndef XFA_FXFA_CXFA_FFWIDGET_H_
#define XFA_FXFA_CXFA_FFWIDGET_H_
#include <vector>
#include "core/fpdfdoc/cpdf_formfield.h"
#include "core/fxcodec/fx_codec_def.h"
#include "core/fxge/cfx_graphstatedata.h"
#include "xfa/fwl/cfwl_app.h"
#include "xfa/fxfa/fxfa.h"
#include "xfa/fxfa/parser/cxfa_contentlayoutitem.h"
class CXFA_Box;
class CXFA_FFPageView;
class CXFA_FFDocView;
class CXFA_FFDoc;
class CXFA_FFApp;
class CXFA_Graphics;
class CXFA_Image;
enum class FWL_WidgetHit;
inline float XFA_UnitPx2Pt(float fPx, float fDpi) {
return fPx * 72.0f / fDpi;
}
#define XFA_FLOAT_PERCISION 0.001f
void XFA_DrawImage(CXFA_Graphics* pGS,
const CFX_RectF& rtImage,
const CFX_Matrix& matrix,
const RetainPtr<CFX_DIBitmap>& pDIBitmap,
XFA_AttributeEnum iAspect,
int32_t iImageXDpi,
int32_t iImageYDpi,
XFA_AttributeEnum iHorzAlign = XFA_AttributeEnum::Left,
XFA_AttributeEnum iVertAlign = XFA_AttributeEnum::Top);
RetainPtr<CFX_DIBitmap> XFA_LoadImageFromBuffer(
const RetainPtr<IFX_SeekableReadStream>& pImageFileRead,
FXCODEC_IMAGE_TYPE type,
int32_t& iImageXDpi,
int32_t& iImageYDpi);
void XFA_RectWithoutMargin(CFX_RectF& rt,
const CXFA_Margin* margin,
bool bUI = false);
CXFA_FFWidget* XFA_GetWidgetFromLayoutItem(CXFA_LayoutItem* pLayoutItem);
class CXFA_CalcData {
public:
CXFA_CalcData();
~CXFA_CalcData();
std::vector<CXFA_Node*> m_Globals;
int32_t m_iRefCount;
};
class CXFA_FFWidget : public CXFA_ContentLayoutItem {
public:
explicit CXFA_FFWidget(CXFA_Node* pNode);
~CXFA_FFWidget() override;
virtual CFX_RectF GetBBox(uint32_t dwStatus, bool bDrawFocus = false);
virtual void RenderWidget(CXFA_Graphics* pGS,
const CFX_Matrix& matrix,
uint32_t dwStatus);
virtual bool IsLoaded();
virtual bool LoadWidget();
virtual void UnloadWidget();
virtual bool PerformLayout();
virtual bool UpdateFWLData();
virtual void UpdateWidgetProperty();
virtual bool OnMouseEnter();
virtual bool OnMouseExit();
virtual bool OnLButtonDown(uint32_t dwFlags, const CFX_PointF& point);
virtual bool OnLButtonUp(uint32_t dwFlags, const CFX_PointF& point);
virtual bool OnLButtonDblClk(uint32_t dwFlags, const CFX_PointF& point);
virtual bool OnMouseMove(uint32_t dwFlags, const CFX_PointF& point);
virtual bool OnMouseWheel(uint32_t dwFlags,
int16_t zDelta,
const CFX_PointF& point);
virtual bool OnRButtonDown(uint32_t dwFlags, const CFX_PointF& point);
virtual bool OnRButtonUp(uint32_t dwFlags, const CFX_PointF& point);
virtual bool OnRButtonDblClk(uint32_t dwFlags, const CFX_PointF& point);
virtual bool OnSetFocus(CXFA_FFWidget* pOldWidget);
virtual bool OnKillFocus(CXFA_FFWidget* pNewWidget);
virtual bool OnKeyDown(uint32_t dwKeyCode, uint32_t dwFlags);
virtual bool OnKeyUp(uint32_t dwKeyCode, uint32_t dwFlags);
virtual bool OnChar(uint32_t dwChar, uint32_t dwFlags);
virtual FWL_WidgetHit OnHitTest(const CFX_PointF& point);
virtual bool OnSetCursor(const CFX_PointF& point);
virtual bool CanUndo();
virtual bool CanRedo();
virtual bool Undo();
virtual bool Redo();
virtual bool CanCopy();
virtual bool CanCut();
virtual bool CanPaste();
virtual bool CanSelectAll();
virtual bool CanDelete();
virtual bool CanDeSelect();
virtual Optional<WideString> Copy();
virtual Optional<WideString> Cut();
virtual bool Paste(const WideString& wsPaste);
virtual void SelectAll();
virtual void Delete();
virtual void DeSelect();
virtual FormFieldType GetFormFieldType();
// TODO(tsepez): Implement or remove.
void GetSuggestWords(CFX_PointF pointf, std::vector<ByteString>* pWords);
bool ReplaceSpellCheckWord(CFX_PointF pointf,
const ByteStringView& bsReplace);
CXFA_FFPageView* GetPageView() const { return m_pPageView; }
void SetPageView(CXFA_FFPageView* pPageView) { m_pPageView = pPageView; }
const CFX_RectF& GetWidgetRect() const;
const CFX_RectF& RecacheWidgetRect() const;
uint32_t GetStatus();
void ModifyStatus(uint32_t dwAdded, uint32_t dwRemoved);
CXFA_Node* GetNode() { return m_pNode.Get(); }
CXFA_FFDocView* GetDocView();
void SetDocView(CXFA_FFDocView* pDocView);
CXFA_FFDoc* GetDoc();
CXFA_FFApp* GetApp();
IXFA_AppProvider* GetAppProvider();
void AddInvalidateRect();
bool IsFocused() const { return !!(m_dwStatus & XFA_WidgetStatus_Focused); }
CFX_PointF Rotate2Normal(const CFX_PointF& point);
CFX_Matrix GetRotateMatrix();
bool IsLayoutRectEmpty();
CXFA_FFWidget* GetParent();
bool IsAncestorOf(CXFA_FFWidget* pWidget);
const CFWL_App* GetFWLApp();
protected:
virtual bool PtInActiveRect(const CFX_PointF& point);
void DrawBorder(CXFA_Graphics* pGS,
CXFA_Box* box,
const CFX_RectF& rtBorder,
const CFX_Matrix& matrix);
void DrawBorderWithFlag(CXFA_Graphics* pGS,
CXFA_Box* box,
const CFX_RectF& rtBorder,
const CFX_Matrix& matrix,
bool forceRound);
CFX_RectF GetRectWithoutRotate();
bool IsMatchVisibleStatus(uint32_t dwStatus);
void EventKillFocus();
bool IsButtonDown();
void SetButtonDown(bool bSet);
CXFA_FFDocView* m_pDocView = nullptr;
CXFA_FFPageView* m_pPageView = nullptr;
UnownedPtr<CXFA_Node> const m_pNode;
mutable CFX_RectF m_rtWidget;
};
#endif // XFA_FXFA_CXFA_FFWIDGET_H_
|