blob: d3e354d0e825a1687861aa4c1abfc4f0182e5452 [file] [log] [blame]
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001// Copyright 2014 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.
Lei Zhanga6d9f0e2015-06-13 00:48:38 -07004
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07005// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
Tom Sepez19922bb2015-05-28 13:23:12 -07007#ifndef FPDFSDK_INCLUDE_FXEDIT_FXET_EDIT_H_
8#define FPDFSDK_INCLUDE_FXEDIT_FXET_EDIT_H_
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07009
Lei Zhanga688a042015-11-09 13:57:49 -080010#include "core/include/fpdfdoc/fpdf_vt.h"
Lei Zhang375a8642016-01-11 11:59:17 -080011#include "fpdfsdk/include/fxedit/fx_edit.h"
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070012
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070013class CFX_Edit;
14class CFX_Edit_Iterator;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070015class CFX_Edit_Provider;
16
Nico Weber9d8ec5a2015-08-04 13:00:21 -070017#define FX_EDIT_IsFloatZero(f) (f < 0.0001 && f > -0.0001)
18#define FX_EDIT_IsFloatEqual(fa, fb) FX_EDIT_IsFloatZero(fa - fb)
19#define FX_EDIT_IsFloatBigger(fa, fb) (fa > fb && !FX_EDIT_IsFloatEqual(fa, fb))
20#define FX_EDIT_IsFloatSmaller(fa, fb) \
21 (fa < fb && !FX_EDIT_IsFloatEqual(fa, fb))
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070022
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070023/* ------------------------- CFX_Edit_Refresh ---------------------------- */
24
Nico Weber9d8ec5a2015-08-04 13:00:21 -070025enum REFRESH_PLAN_E { RP_ANALYSE, RP_NOANALYSE, RP_OPTIONAL };
26
27enum EDIT_PROPS_E {
28 EP_LINELEADING,
29 EP_LINEINDENT,
30 EP_ALIGNMENT,
31 EP_FONTINDEX,
32 EP_FONTSIZE,
33 EP_WORDCOLOR,
34 EP_SCRIPTTYPE,
35 EP_UNDERLINE,
36 EP_CROSSOUT,
37 EP_CHARSPACE,
38 EP_HORZSCALE,
39 EP_BOLD,
40 EP_ITALIC
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070041};
42
Nico Weber9d8ec5a2015-08-04 13:00:21 -070043struct CFX_Edit_LineRect {
Tom Sepez281a9ea2016-02-26 14:24:28 -080044 CFX_Edit_LineRect(const CPVT_WordRange& wrLine, const CFX_FloatRect& rcLine)
Nico Weber9d8ec5a2015-08-04 13:00:21 -070045 : m_wrLine(wrLine), m_rcLine(rcLine) {}
46
47 FX_BOOL operator!=(const CFX_Edit_LineRect& linerect) const {
48 return FXSYS_memcmp(this, &linerect, sizeof(CFX_Edit_LineRect)) != 0;
49 }
50
51 FX_BOOL IsSameHeight(const CFX_Edit_LineRect& linerect) const {
52 return FX_EDIT_IsFloatZero(
53 (m_rcLine.top - m_rcLine.bottom) -
54 (linerect.m_rcLine.top - linerect.m_rcLine.bottom));
55 }
56
57 FX_BOOL IsSameTop(const CFX_Edit_LineRect& linerect) const {
58 return FX_EDIT_IsFloatZero(m_rcLine.top - linerect.m_rcLine.top);
59 }
60
61 FX_BOOL IsSameLeft(const CFX_Edit_LineRect& linerect) const {
62 return FX_EDIT_IsFloatZero(m_rcLine.left - linerect.m_rcLine.left);
63 }
64
65 FX_BOOL IsSameRight(const CFX_Edit_LineRect& linerect) const {
66 return FX_EDIT_IsFloatZero(m_rcLine.right - linerect.m_rcLine.right);
67 }
68
69 CPVT_WordRange m_wrLine;
Tom Sepez281a9ea2016-02-26 14:24:28 -080070 CFX_FloatRect m_rcLine;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070071};
72
Nico Weber9d8ec5a2015-08-04 13:00:21 -070073class CFX_Edit_LineRectArray {
74 public:
75 CFX_Edit_LineRectArray() {}
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070076
Nico Weber9d8ec5a2015-08-04 13:00:21 -070077 virtual ~CFX_Edit_LineRectArray() { Empty(); }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070078
Nico Weber9d8ec5a2015-08-04 13:00:21 -070079 void Empty() {
80 for (int32_t i = 0, sz = m_LineRects.GetSize(); i < sz; i++)
81 delete m_LineRects.GetAt(i);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070082
Nico Weber9d8ec5a2015-08-04 13:00:21 -070083 m_LineRects.RemoveAll();
84 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070085
Nico Weber9d8ec5a2015-08-04 13:00:21 -070086 void RemoveAll() { m_LineRects.RemoveAll(); }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070087
Nico Weber9d8ec5a2015-08-04 13:00:21 -070088 void operator=(CFX_Edit_LineRectArray& rects) {
89 Empty();
90 for (int32_t i = 0, sz = rects.GetSize(); i < sz; i++)
91 m_LineRects.Add(rects.GetAt(i));
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070092
Nico Weber9d8ec5a2015-08-04 13:00:21 -070093 rects.RemoveAll();
94 }
95
Tom Sepez281a9ea2016-02-26 14:24:28 -080096 void Add(const CPVT_WordRange& wrLine, const CFX_FloatRect& rcLine) {
Lei Zhange00660b2015-08-13 15:40:18 -070097 m_LineRects.Add(new CFX_Edit_LineRect(wrLine, rcLine));
Nico Weber9d8ec5a2015-08-04 13:00:21 -070098 }
99
100 int32_t GetSize() const { return m_LineRects.GetSize(); }
101
102 CFX_Edit_LineRect* GetAt(int32_t nIndex) const {
103 if (nIndex < 0 || nIndex >= m_LineRects.GetSize())
104 return NULL;
105
106 return m_LineRects.GetAt(nIndex);
107 }
108
109 CFX_ArrayTemplate<CFX_Edit_LineRect*> m_LineRects;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700110};
111
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700112class CFX_Edit_RectArray {
113 public:
114 CFX_Edit_RectArray() {}
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700115
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700116 virtual ~CFX_Edit_RectArray() { Empty(); }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700117
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700118 void Empty() {
119 for (int32_t i = 0, sz = m_Rects.GetSize(); i < sz; i++)
120 delete m_Rects.GetAt(i);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700121
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700122 m_Rects.RemoveAll();
123 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700124
Tom Sepez281a9ea2016-02-26 14:24:28 -0800125 void Add(const CFX_FloatRect& rect) {
Lei Zhange00660b2015-08-13 15:40:18 -0700126 // check for overlapped area
127 for (int32_t i = 0, sz = m_Rects.GetSize(); i < sz; i++) {
Tom Sepez281a9ea2016-02-26 14:24:28 -0800128 CFX_FloatRect* pRect = m_Rects.GetAt(i);
Lei Zhange00660b2015-08-13 15:40:18 -0700129 if (pRect && pRect->Contains(rect))
130 return;
131 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700132
Tom Sepez281a9ea2016-02-26 14:24:28 -0800133 m_Rects.Add(new CFX_FloatRect(rect));
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700134 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700135
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700136 int32_t GetSize() const { return m_Rects.GetSize(); }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700137
Tom Sepez281a9ea2016-02-26 14:24:28 -0800138 CFX_FloatRect* GetAt(int32_t nIndex) const {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700139 if (nIndex < 0 || nIndex >= m_Rects.GetSize())
140 return NULL;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700141
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700142 return m_Rects.GetAt(nIndex);
143 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700144
Tom Sepez281a9ea2016-02-26 14:24:28 -0800145 CFX_ArrayTemplate<CFX_FloatRect*> m_Rects;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700146};
147
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700148class CFX_Edit_Refresh {
149 public:
150 CFX_Edit_Refresh();
151 virtual ~CFX_Edit_Refresh();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700152
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700153 void BeginRefresh();
Tom Sepez281a9ea2016-02-26 14:24:28 -0800154 void Push(const CPVT_WordRange& linerange, const CFX_FloatRect& rect);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700155 void NoAnalyse();
156 void Analyse(int32_t nAlignment);
Tom Sepez281a9ea2016-02-26 14:24:28 -0800157 void AddRefresh(const CFX_FloatRect& rect);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700158 const CFX_Edit_RectArray* GetRefreshRects() const;
159 void EndRefresh();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700160
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700161 private:
162 CFX_Edit_LineRectArray m_NewLineRects;
163 CFX_Edit_LineRectArray m_OldLineRects;
164 CFX_Edit_RectArray m_RefreshRects;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700165};
166
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700167/* ------------------------- CFX_Edit_Select ---------------------------- */
168
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700169class CFX_Edit_Select {
170 public:
171 CFX_Edit_Select() {}
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700172
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700173 CFX_Edit_Select(const CPVT_WordPlace& begin, const CPVT_WordPlace& end) {
174 Set(begin, end);
175 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700176
Lei Zhang375a8642016-01-11 11:59:17 -0800177 explicit CFX_Edit_Select(const CPVT_WordRange& range) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700178 Set(range.BeginPos, range.EndPos);
179 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700180
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700181 CPVT_WordRange ConvertToWordRange() const {
182 return CPVT_WordRange(BeginPos, EndPos);
183 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700184
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700185 void Default() {
186 BeginPos.Default();
187 EndPos.Default();
188 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700189
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700190 void Set(const CPVT_WordPlace& begin, const CPVT_WordPlace& end) {
191 BeginPos = begin;
192 EndPos = end;
193 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700194
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700195 void SetBeginPos(const CPVT_WordPlace& begin) { BeginPos = begin; }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700196
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700197 void SetEndPos(const CPVT_WordPlace& end) { EndPos = end; }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700198
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700199 FX_BOOL IsExist() const { return BeginPos != EndPos; }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700200
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700201 FX_BOOL operator!=(const CPVT_WordRange& wr) const {
202 return wr.BeginPos != BeginPos || wr.EndPos != EndPos;
203 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700204
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700205 CPVT_WordPlace BeginPos, EndPos;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700206};
207
208/* ------------------------- CFX_Edit_Undo ---------------------------- */
209
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700210class CFX_Edit_Undo {
211 public:
Lei Zhang375a8642016-01-11 11:59:17 -0800212 explicit CFX_Edit_Undo(int32_t nBufsize);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700213 virtual ~CFX_Edit_Undo();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700214
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700215 void Undo();
216 void Redo();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700217
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700218 void AddItem(IFX_Edit_UndoItem* pItem);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700219
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700220 FX_BOOL CanUndo() const;
221 FX_BOOL CanRedo() const;
222 FX_BOOL IsModified() const;
223 FX_BOOL IsWorking() const;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700224
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700225 void Reset();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700226
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700227 IFX_Edit_UndoItem* GetItem(int32_t nIndex);
228 int32_t GetItemCount() { return m_UndoItemStack.GetSize(); }
229 int32_t GetCurUndoPos() { return m_nCurUndoPos; }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700230
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700231 private:
232 void SetBufSize(int32_t nSize) { m_nBufSize = nSize; }
233 int32_t GetBufSize() { return m_nBufSize; }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700234
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700235 void RemoveHeads();
236 void RemoveTails();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700237
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700238 private:
239 CFX_ArrayTemplate<IFX_Edit_UndoItem*> m_UndoItemStack;
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700240
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700241 int32_t m_nCurUndoPos;
242 int32_t m_nBufSize;
243 FX_BOOL m_bModified;
244 FX_BOOL m_bVirgin;
245 FX_BOOL m_bWorking;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700246};
247
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700248class CFX_Edit_UndoItem : public IFX_Edit_UndoItem {
249 public:
250 CFX_Edit_UndoItem() : m_bFirst(TRUE), m_bLast(TRUE) {}
Lei Zhang2b1a2d52015-08-14 22:16:22 -0700251 ~CFX_Edit_UndoItem() override {}
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700252
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700253 CFX_WideString GetUndoTitle() override { return L""; }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700254
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700255 void SetFirst(FX_BOOL bFirst) { m_bFirst = bFirst; }
256 FX_BOOL IsFirst() { return m_bFirst; }
257 void SetLast(FX_BOOL bLast) { m_bLast = bLast; }
258 FX_BOOL IsLast() { return m_bLast; }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700259
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700260 private:
261 FX_BOOL m_bFirst;
262 FX_BOOL m_bLast;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700263};
264
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700265class CFX_Edit_GroupUndoItem : public IFX_Edit_UndoItem {
266 public:
Lei Zhang375a8642016-01-11 11:59:17 -0800267 explicit CFX_Edit_GroupUndoItem(const CFX_WideString& sTitle);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700268 ~CFX_Edit_GroupUndoItem() override;
Tom Sepezced4c2b2015-04-20 16:33:30 -0700269
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700270 void Undo() override;
271 void Redo() override;
272 CFX_WideString GetUndoTitle() override;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700273
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700274 void AddUndoItem(CFX_Edit_UndoItem* pUndoItem);
275 void UpdateItems();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700276
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700277 private:
278 CFX_WideString m_sTitle;
279 CFX_ArrayTemplate<CFX_Edit_UndoItem*> m_Items;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700280};
281
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700282/* ------------------------- CFX_Edit_UndoItem derived classes
283 * ---------------------------- */
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700284
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700285class CFXEU_InsertWord : public CFX_Edit_UndoItem {
286 public:
287 CFXEU_InsertWord(CFX_Edit* pEdit,
288 const CPVT_WordPlace& wpOldPlace,
289 const CPVT_WordPlace& wpNewPlace,
Tom Sepez62a70f92016-03-21 15:00:20 -0700290 uint16_t word,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700291 int32_t charset,
292 const CPVT_WordProps* pWordProps);
Lei Zhang2b1a2d52015-08-14 22:16:22 -0700293 ~CFXEU_InsertWord() override;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700294
Lei Zhang2b1a2d52015-08-14 22:16:22 -0700295 // CFX_Edit_UndoItem
296 void Redo() override;
297 void Undo() override;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700298
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700299 private:
300 CFX_Edit* m_pEdit;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700301
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700302 CPVT_WordPlace m_wpOld;
303 CPVT_WordPlace m_wpNew;
Tom Sepez62a70f92016-03-21 15:00:20 -0700304 uint16_t m_Word;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700305 int32_t m_nCharset;
306 CPVT_WordProps m_WordProps;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700307};
308
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700309class CFXEU_InsertReturn : public CFX_Edit_UndoItem {
310 public:
311 CFXEU_InsertReturn(CFX_Edit* pEdit,
312 const CPVT_WordPlace& wpOldPlace,
313 const CPVT_WordPlace& wpNewPlace,
314 const CPVT_SecProps* pSecProps,
315 const CPVT_WordProps* pWordProps);
Lei Zhang2b1a2d52015-08-14 22:16:22 -0700316 ~CFXEU_InsertReturn() override;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700317
Lei Zhang2b1a2d52015-08-14 22:16:22 -0700318 // CFX_Edit_UndoItem
319 void Redo() override;
320 void Undo() override;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700321
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700322 private:
323 CFX_Edit* m_pEdit;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700324
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700325 CPVT_WordPlace m_wpOld;
326 CPVT_WordPlace m_wpNew;
327 CPVT_SecProps m_SecProps;
328 CPVT_WordProps m_WordProps;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700329};
330
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700331class CFXEU_Backspace : public CFX_Edit_UndoItem {
332 public:
333 CFXEU_Backspace(CFX_Edit* pEdit,
334 const CPVT_WordPlace& wpOldPlace,
335 const CPVT_WordPlace& wpNewPlace,
Tom Sepez62a70f92016-03-21 15:00:20 -0700336 uint16_t word,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700337 int32_t charset,
338 const CPVT_SecProps& SecProps,
339 const CPVT_WordProps& WordProps);
Lei Zhang2b1a2d52015-08-14 22:16:22 -0700340 ~CFXEU_Backspace() override;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700341
Lei Zhang2b1a2d52015-08-14 22:16:22 -0700342 // CFX_Edit_UndoItem
343 void Redo() override;
344 void Undo() override;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700345
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700346 private:
347 CFX_Edit* m_pEdit;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700348
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700349 CPVT_WordPlace m_wpOld;
350 CPVT_WordPlace m_wpNew;
Tom Sepez62a70f92016-03-21 15:00:20 -0700351 uint16_t m_Word;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700352 int32_t m_nCharset;
353 CPVT_SecProps m_SecProps;
354 CPVT_WordProps m_WordProps;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700355};
356
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700357class CFXEU_Delete : public CFX_Edit_UndoItem {
358 public:
359 CFXEU_Delete(CFX_Edit* pEdit,
360 const CPVT_WordPlace& wpOldPlace,
361 const CPVT_WordPlace& wpNewPlace,
Tom Sepez62a70f92016-03-21 15:00:20 -0700362 uint16_t word,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700363 int32_t charset,
364 const CPVT_SecProps& SecProps,
365 const CPVT_WordProps& WordProps,
366 FX_BOOL bSecEnd);
Lei Zhang2b1a2d52015-08-14 22:16:22 -0700367 ~CFXEU_Delete() override;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700368
Lei Zhang2b1a2d52015-08-14 22:16:22 -0700369 // CFX_Edit_UndoItem
370 void Redo() override;
371 void Undo() override;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700372
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700373 private:
374 CFX_Edit* m_pEdit;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700375
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700376 CPVT_WordPlace m_wpOld;
377 CPVT_WordPlace m_wpNew;
Tom Sepez62a70f92016-03-21 15:00:20 -0700378 uint16_t m_Word;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700379 int32_t m_nCharset;
380 CPVT_SecProps m_SecProps;
381 CPVT_WordProps m_WordProps;
382 FX_BOOL m_bSecEnd;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700383};
384
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700385class CFXEU_Clear : public CFX_Edit_UndoItem {
386 public:
387 CFXEU_Clear(CFX_Edit* pEdit,
388 const CPVT_WordRange& wrSel,
389 const CFX_WideString& swText);
Lei Zhang2b1a2d52015-08-14 22:16:22 -0700390 ~CFXEU_Clear() override;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700391
Lei Zhang2b1a2d52015-08-14 22:16:22 -0700392 // CFX_Edit_UndoItem
393 void Redo() override;
394 void Undo() override;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700395
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700396 private:
397 CFX_Edit* m_pEdit;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700398
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700399 CPVT_WordRange m_wrSel;
400 CFX_WideString m_swText;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700401};
402
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700403class CFXEU_ClearRich : public CFX_Edit_UndoItem {
404 public:
405 CFXEU_ClearRich(CFX_Edit* pEdit,
406 const CPVT_WordPlace& wpOldPlace,
407 const CPVT_WordPlace& wpNewPlace,
408 const CPVT_WordRange& wrSel,
Tom Sepez62a70f92016-03-21 15:00:20 -0700409 uint16_t word,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700410 int32_t charset,
411 const CPVT_SecProps& SecProps,
412 const CPVT_WordProps& WordProps);
Lei Zhang2b1a2d52015-08-14 22:16:22 -0700413 ~CFXEU_ClearRich() override;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700414
Lei Zhang2b1a2d52015-08-14 22:16:22 -0700415 // CFX_Edit_UndoItem
416 void Redo() override;
417 void Undo() override;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700418
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700419 private:
420 CFX_Edit* m_pEdit;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700421
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700422 CPVT_WordPlace m_wpOld;
423 CPVT_WordPlace m_wpNew;
424 CPVT_WordRange m_wrSel;
Tom Sepez62a70f92016-03-21 15:00:20 -0700425 uint16_t m_Word;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700426 int32_t m_nCharset;
427 CPVT_SecProps m_SecProps;
428 CPVT_WordProps m_WordProps;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700429};
430
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700431class CFXEU_InsertText : public CFX_Edit_UndoItem {
432 public:
433 CFXEU_InsertText(CFX_Edit* pEdit,
434 const CPVT_WordPlace& wpOldPlace,
435 const CPVT_WordPlace& wpNewPlace,
436 const CFX_WideString& swText,
437 int32_t charset,
438 const CPVT_SecProps* pSecProps,
439 const CPVT_WordProps* pWordProps);
Lei Zhang2b1a2d52015-08-14 22:16:22 -0700440 ~CFXEU_InsertText() override;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700441
Lei Zhang2b1a2d52015-08-14 22:16:22 -0700442 // CFX_Edit_UndoItem
443 void Redo() override;
444 void Undo() override;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700445
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700446 private:
447 CFX_Edit* m_pEdit;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700448
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700449 CPVT_WordPlace m_wpOld;
450 CPVT_WordPlace m_wpNew;
451 CFX_WideString m_swText;
452 int32_t m_nCharset;
453 CPVT_SecProps m_SecProps;
454 CPVT_WordProps m_WordProps;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700455};
456
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700457class CFXEU_SetSecProps : public CFX_Edit_UndoItem {
458 public:
459 CFXEU_SetSecProps(CFX_Edit* pEdit,
460 const CPVT_WordPlace& place,
461 EDIT_PROPS_E ep,
462 const CPVT_SecProps& oldsecprops,
463 const CPVT_WordProps& oldwordprops,
464 const CPVT_SecProps& newsecprops,
465 const CPVT_WordProps& newwordprops,
466 const CPVT_WordRange& range);
Lei Zhang2b1a2d52015-08-14 22:16:22 -0700467 ~CFXEU_SetSecProps() override;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700468
Lei Zhang2b1a2d52015-08-14 22:16:22 -0700469 // CFX_Edit_UndoItem
470 void Redo() override;
471 void Undo() override;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700472
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700473 private:
474 CFX_Edit* m_pEdit;
475 CPVT_WordPlace m_wpPlace;
476 CPVT_WordRange m_wrPlace;
477 EDIT_PROPS_E m_eProps;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700478
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700479 CPVT_SecProps m_OldSecProps;
480 CPVT_SecProps m_NewSecProps;
481 CPVT_WordProps m_OldWordProps;
482 CPVT_WordProps m_NewWordProps;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700483};
484
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700485class CFXEU_SetWordProps : public CFX_Edit_UndoItem {
486 public:
487 CFXEU_SetWordProps(CFX_Edit* pEdit,
488 const CPVT_WordPlace& place,
489 EDIT_PROPS_E ep,
490 const CPVT_WordProps& oldprops,
491 const CPVT_WordProps& newprops,
492 const CPVT_WordRange& range);
Lei Zhang2b1a2d52015-08-14 22:16:22 -0700493 ~CFXEU_SetWordProps() override;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700494
Lei Zhang2b1a2d52015-08-14 22:16:22 -0700495 // CFX_Edit_UndoItem
496 void Redo() override;
497 void Undo() override;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700498
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700499 private:
500 CFX_Edit* m_pEdit;
501 CPVT_WordPlace m_wpPlace;
502 CPVT_WordRange m_wrPlace;
503 EDIT_PROPS_E m_eProps;
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700504
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700505 CPVT_WordProps m_OldWordProps;
506 CPVT_WordProps m_NewWordProps;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700507};
508
509/* ------------------------- CFX_Edit ---------------------------- */
510
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700511class CFX_Edit : public IFX_Edit {
512 friend class CFX_Edit_Iterator;
513 friend class CFXEU_InsertWord;
514 friend class CFXEU_InsertReturn;
515 friend class CFXEU_Backspace;
516 friend class CFXEU_Delete;
517 friend class CFXEU_Clear;
518 friend class CFXEU_ClearRich;
519 friend class CFXEU_SetSecProps;
520 friend class CFXEU_SetWordProps;
521 friend class CFXEU_InsertText;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700522
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700523 public:
Lei Zhang375a8642016-01-11 11:59:17 -0800524 explicit CFX_Edit(IPDF_VariableText* pVT);
Lei Zhang2b1a2d52015-08-14 22:16:22 -0700525 ~CFX_Edit() override;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700526
Lei Zhang2b1a2d52015-08-14 22:16:22 -0700527 // IFX_Edit
528 void SetFontMap(IFX_Edit_FontMap* pFontMap) override;
529 void SetVTProvider(IPDF_VariableText_Provider* pProvider) override;
530 void SetNotify(IFX_Edit_Notify* pNotify) override;
531 void SetOprNotify(IFX_Edit_OprNotify* pOprNotify) override;
532 IFX_Edit_Iterator* GetIterator() override;
533 IPDF_VariableText* GetVariableText() override;
534 IFX_Edit_FontMap* GetFontMap() override;
535 void Initialize() override;
Tom Sepez281a9ea2016-02-26 14:24:28 -0800536 void SetPlateRect(const CFX_FloatRect& rect, FX_BOOL bPaint = TRUE) override;
537 void SetScrollPos(const CFX_FloatPoint& point) override;
Lei Zhang2b1a2d52015-08-14 22:16:22 -0700538 void SetAlignmentH(int32_t nFormat = 0, FX_BOOL bPaint = TRUE) override;
539 void SetAlignmentV(int32_t nFormat = 0, FX_BOOL bPaint = TRUE) override;
Tom Sepez62a70f92016-03-21 15:00:20 -0700540 void SetPasswordChar(uint16_t wSubWord = '*', FX_BOOL bPaint = TRUE) override;
Lei Zhang2b1a2d52015-08-14 22:16:22 -0700541 void SetLimitChar(int32_t nLimitChar = 0, FX_BOOL bPaint = TRUE) override;
542 void SetCharArray(int32_t nCharArray = 0, FX_BOOL bPaint = TRUE) override;
543 void SetCharSpace(FX_FLOAT fCharSpace = 0.0f, FX_BOOL bPaint = TRUE) override;
544 void SetHorzScale(int32_t nHorzScale = 100, FX_BOOL bPaint = TRUE) override;
545 void SetLineLeading(FX_FLOAT fLineLeading, FX_BOOL bPaint = TRUE) override;
546 void SetMultiLine(FX_BOOL bMultiLine = TRUE, FX_BOOL bPaint = TRUE) override;
547 void SetAutoReturn(FX_BOOL bAuto = TRUE, FX_BOOL bPaint = TRUE) override;
548 void SetAutoFontSize(FX_BOOL bAuto = TRUE, FX_BOOL bPaint = TRUE) override;
549 void SetAutoScroll(FX_BOOL bAuto = TRUE, FX_BOOL bPaint = TRUE) override;
550 void SetFontSize(FX_FLOAT fFontSize, FX_BOOL bPaint = TRUE) override;
551 void SetTextOverflow(FX_BOOL bAllowed = FALSE,
552 FX_BOOL bPaint = TRUE) override;
553 FX_BOOL IsRichText() const override;
554 void SetRichText(FX_BOOL bRichText = TRUE, FX_BOOL bPaint = TRUE) override;
555 FX_BOOL SetRichFontSize(FX_FLOAT fFontSize) override;
556 FX_BOOL SetRichFontIndex(int32_t nFontIndex) override;
557 FX_BOOL SetRichTextColor(FX_COLORREF dwColor) override;
558 FX_BOOL SetRichTextScript(int32_t nScriptType) override;
559 FX_BOOL SetRichTextBold(FX_BOOL bBold = TRUE) override;
560 FX_BOOL SetRichTextItalic(FX_BOOL bItalic = TRUE) override;
561 FX_BOOL SetRichTextUnderline(FX_BOOL bUnderline = TRUE) override;
562 FX_BOOL SetRichTextCrossout(FX_BOOL bCrossout = TRUE) override;
563 FX_BOOL SetRichTextCharSpace(FX_FLOAT fCharSpace) override;
564 FX_BOOL SetRichTextHorzScale(int32_t nHorzScale = 100) override;
565 FX_BOOL SetRichTextLineLeading(FX_FLOAT fLineLeading) override;
566 FX_BOOL SetRichTextLineIndent(FX_FLOAT fLineIndent) override;
567 FX_BOOL SetRichTextAlignment(int32_t nAlignment) override;
Tom Sepez281a9ea2016-02-26 14:24:28 -0800568 void OnMouseDown(const CFX_FloatPoint& point,
Lei Zhang2b1a2d52015-08-14 22:16:22 -0700569 FX_BOOL bShift,
570 FX_BOOL bCtrl) override;
Tom Sepez281a9ea2016-02-26 14:24:28 -0800571 void OnMouseMove(const CFX_FloatPoint& point,
Lei Zhang2b1a2d52015-08-14 22:16:22 -0700572 FX_BOOL bShift,
573 FX_BOOL bCtrl) override;
574 void OnVK_UP(FX_BOOL bShift, FX_BOOL bCtrl) override;
575 void OnVK_DOWN(FX_BOOL bShift, FX_BOOL bCtrl) override;
576 void OnVK_LEFT(FX_BOOL bShift, FX_BOOL bCtrl) override;
577 void OnVK_RIGHT(FX_BOOL bShift, FX_BOOL bCtrl) override;
578 void OnVK_HOME(FX_BOOL bShift, FX_BOOL bCtrl) override;
579 void OnVK_END(FX_BOOL bShift, FX_BOOL bCtrl) override;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700580 void SetText(const FX_WCHAR* text,
581 int32_t charset = DEFAULT_CHARSET,
582 const CPVT_SecProps* pSecProps = NULL,
Lei Zhang2b1a2d52015-08-14 22:16:22 -0700583 const CPVT_WordProps* pWordProps = NULL) override;
Tom Sepez62a70f92016-03-21 15:00:20 -0700584 FX_BOOL InsertWord(uint16_t word,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700585 int32_t charset = DEFAULT_CHARSET,
Lei Zhang2b1a2d52015-08-14 22:16:22 -0700586 const CPVT_WordProps* pWordProps = NULL) override;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700587 FX_BOOL InsertReturn(const CPVT_SecProps* pSecProps = NULL,
Lei Zhang2b1a2d52015-08-14 22:16:22 -0700588 const CPVT_WordProps* pWordProps = NULL) override;
589 FX_BOOL Backspace() override;
590 FX_BOOL Delete() override;
591 FX_BOOL Clear() override;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700592 FX_BOOL InsertText(const FX_WCHAR* text,
593 int32_t charset = DEFAULT_CHARSET,
594 const CPVT_SecProps* pSecProps = NULL,
Lei Zhang2b1a2d52015-08-14 22:16:22 -0700595 const CPVT_WordProps* pWordProps = NULL) override;
596 FX_BOOL Redo() override;
597 FX_BOOL Undo() override;
598 int32_t WordPlaceToWordIndex(const CPVT_WordPlace& place) const override;
599 CPVT_WordPlace WordIndexToWordPlace(int32_t index) const override;
600 CPVT_WordPlace GetLineBeginPlace(const CPVT_WordPlace& place) const override;
601 CPVT_WordPlace GetLineEndPlace(const CPVT_WordPlace& place) const override;
602 CPVT_WordPlace GetSectionBeginPlace(
603 const CPVT_WordPlace& place) const override;
604 CPVT_WordPlace GetSectionEndPlace(const CPVT_WordPlace& place) const override;
Tom Sepez281a9ea2016-02-26 14:24:28 -0800605 CPVT_WordPlace SearchWordPlace(const CFX_FloatPoint& point) const override;
Lei Zhang2b1a2d52015-08-14 22:16:22 -0700606 int32_t GetCaret() const override;
607 CPVT_WordPlace GetCaretWordPlace() const override;
608 CFX_WideString GetSelText() const override;
609 CFX_WideString GetText() const override;
610 FX_FLOAT GetFontSize() const override;
Tom Sepez62a70f92016-03-21 15:00:20 -0700611 uint16_t GetPasswordChar() const override;
Tom Sepez281a9ea2016-02-26 14:24:28 -0800612 CFX_FloatPoint GetScrollPos() const override;
Lei Zhang2b1a2d52015-08-14 22:16:22 -0700613 int32_t GetCharArray() const override;
Tom Sepez281a9ea2016-02-26 14:24:28 -0800614 CFX_FloatRect GetPlateRect() const override;
615 CFX_FloatRect GetContentRect() const override;
Lei Zhang2b1a2d52015-08-14 22:16:22 -0700616 CFX_WideString GetRangeText(const CPVT_WordRange& range) const override;
617 int32_t GetHorzScale() const override;
618 FX_FLOAT GetCharSpace() const override;
619 int32_t GetTotalWords() const override;
620 void SetSel(int32_t nStartChar, int32_t nEndChar) override;
621 void GetSel(int32_t& nStartChar, int32_t& nEndChar) const override;
622 void SelectAll() override;
623 void SelectNone() override;
624 FX_BOOL IsSelected() const override;
625 void Paint() override;
626 void EnableNotify(FX_BOOL bNotify) override;
627 void EnableRefresh(FX_BOOL bRefresh) override;
628 void RefreshWordRange(const CPVT_WordRange& wr) override;
629 void SetCaret(int32_t nPos) override;
630 CPVT_WordRange GetWholeWordRange() const override;
631 CPVT_WordRange GetSelectWordRange() const override;
632 void EnableUndo(FX_BOOL bUndo) override;
633 void EnableOprNotify(FX_BOOL bNotify) override;
634 FX_BOOL IsTextFull() const override;
635 FX_BOOL IsTextOverflow() const;
636 FX_BOOL CanUndo() const override;
637 FX_BOOL CanRedo() const override;
638 FX_BOOL IsModified() const override;
639 CPVT_WordRange GetVisibleWordRange() const override;
640 void AddUndoItem(IFX_Edit_UndoItem* pUndoItem) override;
641
642 FX_BOOL Empty();
643
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700644 CPVT_WordPlace DoInsertText(const CPVT_WordPlace& place,
645 const FX_WCHAR* text,
646 int32_t charset,
647 const CPVT_SecProps* pSecProps,
648 const CPVT_WordProps* pWordProps);
Tom Sepez62a70f92016-03-21 15:00:20 -0700649 int32_t GetCharSetFromUnicode(uint16_t word, int32_t nOldCharset);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700650
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700651 int32_t GetTotalLines() const;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700652
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700653 private:
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700654 void SetSel(const CPVT_WordPlace& begin, const CPVT_WordPlace& end);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700655
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700656 void RearrangeAll();
657 void RearrangePart(const CPVT_WordRange& range);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700658 void ScrollToCaret();
659 void SetScrollInfo();
660 void SetScrollPosX(FX_FLOAT fx);
661 void SetScrollPosY(FX_FLOAT fy);
662 void SetScrollLimit();
663 void SetContentChanged();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700664
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700665 void SetText(const FX_WCHAR* text,
666 int32_t charset,
667 const CPVT_SecProps* pSecProps,
668 const CPVT_WordProps* pWordProps,
669 FX_BOOL bAddUndo,
670 FX_BOOL bPaint);
Tom Sepez62a70f92016-03-21 15:00:20 -0700671 FX_BOOL InsertWord(uint16_t word,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700672 int32_t charset,
673 const CPVT_WordProps* pWordProps,
674 FX_BOOL bAddUndo,
675 FX_BOOL bPaint);
676 FX_BOOL InsertReturn(const CPVT_SecProps* pSecProps,
677 const CPVT_WordProps* pWordProps,
678 FX_BOOL bAddUndo,
679 FX_BOOL bPaint);
680 FX_BOOL Backspace(FX_BOOL bAddUndo, FX_BOOL bPaint);
681 FX_BOOL Delete(FX_BOOL bAddUndo, FX_BOOL bPaint);
682 FX_BOOL Clear(FX_BOOL bAddUndo, FX_BOOL bPaint);
683 FX_BOOL InsertText(const FX_WCHAR* text,
684 int32_t charset,
685 const CPVT_SecProps* pSecProps,
686 const CPVT_WordProps* pWordProps,
687 FX_BOOL bAddUndo,
688 FX_BOOL bPaint);
689 FX_BOOL SetRichTextProps(EDIT_PROPS_E eProps,
690 const CPVT_SecProps* pSecProps,
691 const CPVT_WordProps* pWordProps);
692 FX_BOOL SetSecProps(EDIT_PROPS_E eProps,
693 const CPVT_WordPlace& place,
694 const CPVT_SecProps* pSecProps,
695 const CPVT_WordProps* pWordProps,
696 const CPVT_WordRange& wr,
697 FX_BOOL bAddUndo);
698 FX_BOOL SetWordProps(EDIT_PROPS_E eProps,
699 const CPVT_WordPlace& place,
700 const CPVT_WordProps* pWordProps,
701 const CPVT_WordRange& wr,
702 FX_BOOL bAddUndo);
703 void PaintSetProps(EDIT_PROPS_E eProps, const CPVT_WordRange& wr);
704 void PaintInsertText(const CPVT_WordPlace& wpOld,
705 const CPVT_WordPlace& wpNew);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700706
Tom Sepez281a9ea2016-02-26 14:24:28 -0800707 inline CFX_FloatPoint VTToEdit(const CFX_FloatPoint& point) const;
708 inline CFX_FloatPoint EditToVT(const CFX_FloatPoint& point) const;
709 inline CFX_FloatRect VTToEdit(const CFX_FloatRect& rect) const;
710 inline CFX_FloatRect EditToVT(const CFX_FloatRect& rect) const;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700711
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700712 void Refresh(REFRESH_PLAN_E ePlan,
713 const CPVT_WordRange* pRange1 = NULL,
714 const CPVT_WordRange* pRange2 = NULL);
715 void RefreshPushLineRects(const CPVT_WordRange& wr);
716 void RefreshPushRandomRects(const CPVT_WordRange& wr);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700717
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700718 void SetCaret(const CPVT_WordPlace& place);
719 void SetCaretInfo();
720 void SetCaretOrigin();
721 void SetCaretChange();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700722
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700723 CPVT_WordRange GetLatinWordsRange(const CPVT_WordPlace& place) const;
724 CPVT_WordRange CombineWordRange(const CPVT_WordRange& wr1,
725 const CPVT_WordRange& wr2);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700726
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700727
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700728 void BeginGroupUndo(const CFX_WideString& sTitle);
729 void EndGroupUndo();
730 void AddEditUndoItem(CFX_Edit_UndoItem* pEditUndoItem);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700731
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700732 void SetPageInfo(const CPVT_WordPlace& place);
733 CPVT_WordPlace SearchPageEndPlace(const CPVT_WordPlace& wpPageBegin,
Tom Sepez281a9ea2016-02-26 14:24:28 -0800734 const CFX_FloatPoint& point) const;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700735 FX_FLOAT GetLineTop(const CPVT_WordPlace& place) const;
736 FX_FLOAT GetLineBottom(const CPVT_WordPlace& place) const;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700737
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700738 private:
739 IPDF_VariableText* m_pVT;
740 IFX_Edit_Notify* m_pNotify;
741 IFX_Edit_OprNotify* m_pOprNotify;
742 CFX_Edit_Provider* m_pVTProvide;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700743
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700744 CPVT_WordPlace m_wpCaret;
745 CPVT_WordPlace m_wpOldCaret;
746 CFX_Edit_Select m_SelState;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700747
Tom Sepez281a9ea2016-02-26 14:24:28 -0800748 CFX_FloatPoint m_ptScrollPos;
749 CFX_FloatPoint m_ptRefreshScrollPos;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700750 FX_BOOL m_bEnableScroll;
751 IFX_Edit_Iterator* m_pIterator;
752 CFX_Edit_Refresh m_Refresh;
Tom Sepez281a9ea2016-02-26 14:24:28 -0800753 CFX_FloatPoint m_ptCaret;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700754 CFX_Edit_Undo m_Undo;
755 int32_t m_nAlignment;
756 FX_BOOL m_bNotifyFlag;
757 FX_BOOL m_bEnableOverflow;
758 FX_BOOL m_bEnableRefresh;
Tom Sepez281a9ea2016-02-26 14:24:28 -0800759 CFX_FloatRect m_rcOldContent;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700760 FX_BOOL m_bEnableUndo;
761 FX_BOOL m_bNotify;
762 FX_BOOL m_bOprNotify;
763 CFX_Edit_GroupUndoItem* m_pGroupUndoItem;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700764};
765
766/* ------------------------- CFX_Edit_Iterator ---------------------------- */
767
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700768class CFX_Edit_Iterator : public IFX_Edit_Iterator {
769 public:
770 CFX_Edit_Iterator(CFX_Edit* pEdit, IPDF_VariableText_Iterator* pVTIterator);
Lei Zhang2b1a2d52015-08-14 22:16:22 -0700771 ~CFX_Edit_Iterator() override;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700772
Lei Zhang2b1a2d52015-08-14 22:16:22 -0700773 // IFX_Edit_Iterator
774 FX_BOOL NextWord() override;
775 FX_BOOL NextLine() override;
776 FX_BOOL NextSection() override;
777 FX_BOOL PrevWord() override;
778 FX_BOOL PrevLine() override;
779 FX_BOOL PrevSection() override;
780 FX_BOOL GetWord(CPVT_Word& word) const override;
781 FX_BOOL GetLine(CPVT_Line& line) const override;
782 FX_BOOL GetSection(CPVT_Section& section) const override;
783 void SetAt(int32_t nWordIndex) override;
784 void SetAt(const CPVT_WordPlace& place) override;
785 const CPVT_WordPlace& GetAt() const override;
786 IFX_Edit* GetEdit() const override;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700787
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700788 private:
789 CFX_Edit* m_pEdit;
790 IPDF_VariableText_Iterator* m_pVTIterator;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700791};
792
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700793class CFX_Edit_Provider : public IPDF_VariableText_Provider {
794 public:
Lei Zhang375a8642016-01-11 11:59:17 -0800795 explicit CFX_Edit_Provider(IFX_Edit_FontMap* pFontMap);
Lei Zhang5fd907b2015-11-19 22:20:59 -0800796 ~CFX_Edit_Provider() override;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700797
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700798 IFX_Edit_FontMap* GetFontMap();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700799
Lei Zhang5fd907b2015-11-19 22:20:59 -0800800 // IPDF_VariableText_Provider:
801 int32_t GetCharWidth(int32_t nFontIndex,
Tom Sepez62a70f92016-03-21 15:00:20 -0700802 uint16_t word,
Lei Zhang5fd907b2015-11-19 22:20:59 -0800803 int32_t nWordStyle) override;
804 int32_t GetTypeAscent(int32_t nFontIndex) override;
805 int32_t GetTypeDescent(int32_t nFontIndex) override;
Tom Sepez62a70f92016-03-21 15:00:20 -0700806 int32_t GetWordFontIndex(uint16_t word,
Lei Zhang5fd907b2015-11-19 22:20:59 -0800807 int32_t charset,
808 int32_t nFontIndex) override;
809 int32_t GetDefaultFontIndex() override;
Tom Sepez62a70f92016-03-21 15:00:20 -0700810 FX_BOOL IsLatinWord(uint16_t word) override;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700811
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700812 private:
813 IFX_Edit_FontMap* m_pFontMap;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700814};
815
Tom Sepez19922bb2015-05-28 13:23:12 -0700816#endif // FPDFSDK_INCLUDE_FXEDIT_FXET_EDIT_H_