Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(643)

Side by Side Diff: fpdfsdk/include/fxedit/fxet_edit.h

Issue 1863163002: Move code from fpdfsdk/include to the sub directories. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fpdfsdk/include/fxedit/fx_edit.h ('k') | fpdfsdk/include/fxedit/fxet_list.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // 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.
4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7 #ifndef FPDFSDK_INCLUDE_FXEDIT_FXET_EDIT_H_
8 #define FPDFSDK_INCLUDE_FXEDIT_FXET_EDIT_H_
9
10 #include "core/fpdfdoc/include/cpvt_secprops.h"
11 #include "core/fpdfdoc/include/cpvt_wordprops.h"
12 #include "fpdfsdk/include/fxedit/fx_edit.h"
13
14 class CFX_Edit;
15 class CFX_Edit_Iterator;
16 class CFX_Edit_Provider;
17
18 #define FX_EDIT_IsFloatZero(f) (f < 0.0001 && f > -0.0001)
19 #define FX_EDIT_IsFloatEqual(fa, fb) FX_EDIT_IsFloatZero(fa - fb)
20 #define FX_EDIT_IsFloatBigger(fa, fb) (fa > fb && !FX_EDIT_IsFloatEqual(fa, fb))
21 #define FX_EDIT_IsFloatSmaller(fa, fb) \
22 (fa < fb && !FX_EDIT_IsFloatEqual(fa, fb))
23
24 enum REFRESH_PLAN_E { RP_ANALYSE, RP_NOANALYSE, RP_OPTIONAL };
25
26 enum EDIT_PROPS_E {
27 EP_LINELEADING,
28 EP_LINEINDENT,
29 EP_ALIGNMENT,
30 EP_FONTINDEX,
31 EP_FONTSIZE,
32 EP_WORDCOLOR,
33 EP_SCRIPTTYPE,
34 EP_UNDERLINE,
35 EP_CROSSOUT,
36 EP_CHARSPACE,
37 EP_HORZSCALE,
38 EP_BOLD,
39 EP_ITALIC
40 };
41
42 struct CFX_Edit_LineRect {
43 CFX_Edit_LineRect(const CPVT_WordRange& wrLine, const CFX_FloatRect& rcLine)
44 : m_wrLine(wrLine), m_rcLine(rcLine) {}
45
46 FX_BOOL operator!=(const CFX_Edit_LineRect& linerect) const {
47 return FXSYS_memcmp(this, &linerect, sizeof(CFX_Edit_LineRect)) != 0;
48 }
49
50 FX_BOOL IsSameHeight(const CFX_Edit_LineRect& linerect) const {
51 return FX_EDIT_IsFloatZero(
52 (m_rcLine.top - m_rcLine.bottom) -
53 (linerect.m_rcLine.top - linerect.m_rcLine.bottom));
54 }
55
56 FX_BOOL IsSameTop(const CFX_Edit_LineRect& linerect) const {
57 return FX_EDIT_IsFloatZero(m_rcLine.top - linerect.m_rcLine.top);
58 }
59
60 FX_BOOL IsSameLeft(const CFX_Edit_LineRect& linerect) const {
61 return FX_EDIT_IsFloatZero(m_rcLine.left - linerect.m_rcLine.left);
62 }
63
64 FX_BOOL IsSameRight(const CFX_Edit_LineRect& linerect) const {
65 return FX_EDIT_IsFloatZero(m_rcLine.right - linerect.m_rcLine.right);
66 }
67
68 CPVT_WordRange m_wrLine;
69 CFX_FloatRect m_rcLine;
70 };
71
72 class CFX_Edit_LineRectArray {
73 public:
74 CFX_Edit_LineRectArray() {}
75
76 virtual ~CFX_Edit_LineRectArray() { Empty(); }
77
78 void Empty() {
79 for (int32_t i = 0, sz = m_LineRects.GetSize(); i < sz; i++)
80 delete m_LineRects.GetAt(i);
81
82 m_LineRects.RemoveAll();
83 }
84
85 void RemoveAll() { m_LineRects.RemoveAll(); }
86
87 void operator=(CFX_Edit_LineRectArray& rects) {
88 Empty();
89 for (int32_t i = 0, sz = rects.GetSize(); i < sz; i++)
90 m_LineRects.Add(rects.GetAt(i));
91
92 rects.RemoveAll();
93 }
94
95 void Add(const CPVT_WordRange& wrLine, const CFX_FloatRect& rcLine) {
96 m_LineRects.Add(new CFX_Edit_LineRect(wrLine, rcLine));
97 }
98
99 int32_t GetSize() const { return m_LineRects.GetSize(); }
100
101 CFX_Edit_LineRect* GetAt(int32_t nIndex) const {
102 if (nIndex < 0 || nIndex >= m_LineRects.GetSize())
103 return NULL;
104
105 return m_LineRects.GetAt(nIndex);
106 }
107
108 CFX_ArrayTemplate<CFX_Edit_LineRect*> m_LineRects;
109 };
110
111 class CFX_Edit_RectArray {
112 public:
113 CFX_Edit_RectArray() {}
114
115 virtual ~CFX_Edit_RectArray() { Empty(); }
116
117 void Empty() {
118 for (int32_t i = 0, sz = m_Rects.GetSize(); i < sz; i++)
119 delete m_Rects.GetAt(i);
120
121 m_Rects.RemoveAll();
122 }
123
124 void Add(const CFX_FloatRect& rect) {
125 // check for overlapped area
126 for (int32_t i = 0, sz = m_Rects.GetSize(); i < sz; i++) {
127 CFX_FloatRect* pRect = m_Rects.GetAt(i);
128 if (pRect && pRect->Contains(rect))
129 return;
130 }
131
132 m_Rects.Add(new CFX_FloatRect(rect));
133 }
134
135 int32_t GetSize() const { return m_Rects.GetSize(); }
136
137 CFX_FloatRect* GetAt(int32_t nIndex) const {
138 if (nIndex < 0 || nIndex >= m_Rects.GetSize())
139 return NULL;
140
141 return m_Rects.GetAt(nIndex);
142 }
143
144 CFX_ArrayTemplate<CFX_FloatRect*> m_Rects;
145 };
146
147 class CFX_Edit_Refresh {
148 public:
149 CFX_Edit_Refresh();
150 virtual ~CFX_Edit_Refresh();
151
152 void BeginRefresh();
153 void Push(const CPVT_WordRange& linerange, const CFX_FloatRect& rect);
154 void NoAnalyse();
155 void Analyse(int32_t nAlignment);
156 void AddRefresh(const CFX_FloatRect& rect);
157 const CFX_Edit_RectArray* GetRefreshRects() const;
158 void EndRefresh();
159
160 private:
161 CFX_Edit_LineRectArray m_NewLineRects;
162 CFX_Edit_LineRectArray m_OldLineRects;
163 CFX_Edit_RectArray m_RefreshRects;
164 };
165
166 class CFX_Edit_Select {
167 public:
168 CFX_Edit_Select() {}
169
170 CFX_Edit_Select(const CPVT_WordPlace& begin, const CPVT_WordPlace& end) {
171 Set(begin, end);
172 }
173
174 explicit CFX_Edit_Select(const CPVT_WordRange& range) {
175 Set(range.BeginPos, range.EndPos);
176 }
177
178 CPVT_WordRange ConvertToWordRange() const {
179 return CPVT_WordRange(BeginPos, EndPos);
180 }
181
182 void Default() {
183 BeginPos.Default();
184 EndPos.Default();
185 }
186
187 void Set(const CPVT_WordPlace& begin, const CPVT_WordPlace& end) {
188 BeginPos = begin;
189 EndPos = end;
190 }
191
192 void SetBeginPos(const CPVT_WordPlace& begin) { BeginPos = begin; }
193
194 void SetEndPos(const CPVT_WordPlace& end) { EndPos = end; }
195
196 FX_BOOL IsExist() const { return BeginPos != EndPos; }
197
198 FX_BOOL operator!=(const CPVT_WordRange& wr) const {
199 return wr.BeginPos != BeginPos || wr.EndPos != EndPos;
200 }
201
202 CPVT_WordPlace BeginPos, EndPos;
203 };
204
205 class CFX_Edit_Undo {
206 public:
207 explicit CFX_Edit_Undo(int32_t nBufsize);
208 virtual ~CFX_Edit_Undo();
209
210 void Undo();
211 void Redo();
212
213 void AddItem(IFX_Edit_UndoItem* pItem);
214
215 FX_BOOL CanUndo() const;
216 FX_BOOL CanRedo() const;
217 FX_BOOL IsModified() const;
218 FX_BOOL IsWorking() const;
219
220 void Reset();
221
222 IFX_Edit_UndoItem* GetItem(int32_t nIndex);
223 int32_t GetItemCount() { return m_UndoItemStack.GetSize(); }
224 int32_t GetCurUndoPos() { return m_nCurUndoPos; }
225
226 private:
227 void SetBufSize(int32_t nSize) { m_nBufSize = nSize; }
228 int32_t GetBufSize() { return m_nBufSize; }
229
230 void RemoveHeads();
231 void RemoveTails();
232
233 private:
234 CFX_ArrayTemplate<IFX_Edit_UndoItem*> m_UndoItemStack;
235
236 int32_t m_nCurUndoPos;
237 int32_t m_nBufSize;
238 FX_BOOL m_bModified;
239 FX_BOOL m_bVirgin;
240 FX_BOOL m_bWorking;
241 };
242
243 class CFX_Edit_UndoItem : public IFX_Edit_UndoItem {
244 public:
245 CFX_Edit_UndoItem() : m_bFirst(TRUE), m_bLast(TRUE) {}
246 ~CFX_Edit_UndoItem() override {}
247
248 CFX_WideString GetUndoTitle() override { return L""; }
249
250 void SetFirst(FX_BOOL bFirst) { m_bFirst = bFirst; }
251 FX_BOOL IsFirst() { return m_bFirst; }
252 void SetLast(FX_BOOL bLast) { m_bLast = bLast; }
253 FX_BOOL IsLast() { return m_bLast; }
254
255 private:
256 FX_BOOL m_bFirst;
257 FX_BOOL m_bLast;
258 };
259
260 class CFX_Edit_GroupUndoItem : public IFX_Edit_UndoItem {
261 public:
262 explicit CFX_Edit_GroupUndoItem(const CFX_WideString& sTitle);
263 ~CFX_Edit_GroupUndoItem() override;
264
265 void Undo() override;
266 void Redo() override;
267 CFX_WideString GetUndoTitle() override;
268
269 void AddUndoItem(CFX_Edit_UndoItem* pUndoItem);
270 void UpdateItems();
271
272 private:
273 CFX_WideString m_sTitle;
274 CFX_ArrayTemplate<CFX_Edit_UndoItem*> m_Items;
275 };
276
277 class CFXEU_InsertWord : public CFX_Edit_UndoItem {
278 public:
279 CFXEU_InsertWord(CFX_Edit* pEdit,
280 const CPVT_WordPlace& wpOldPlace,
281 const CPVT_WordPlace& wpNewPlace,
282 uint16_t word,
283 int32_t charset,
284 const CPVT_WordProps* pWordProps);
285 ~CFXEU_InsertWord() override;
286
287 // CFX_Edit_UndoItem
288 void Redo() override;
289 void Undo() override;
290
291 private:
292 CFX_Edit* m_pEdit;
293
294 CPVT_WordPlace m_wpOld;
295 CPVT_WordPlace m_wpNew;
296 uint16_t m_Word;
297 int32_t m_nCharset;
298 CPVT_WordProps m_WordProps;
299 };
300
301 class CFXEU_InsertReturn : public CFX_Edit_UndoItem {
302 public:
303 CFXEU_InsertReturn(CFX_Edit* pEdit,
304 const CPVT_WordPlace& wpOldPlace,
305 const CPVT_WordPlace& wpNewPlace,
306 const CPVT_SecProps* pSecProps,
307 const CPVT_WordProps* pWordProps);
308 ~CFXEU_InsertReturn() override;
309
310 // CFX_Edit_UndoItem
311 void Redo() override;
312 void Undo() override;
313
314 private:
315 CFX_Edit* m_pEdit;
316
317 CPVT_WordPlace m_wpOld;
318 CPVT_WordPlace m_wpNew;
319 CPVT_SecProps m_SecProps;
320 CPVT_WordProps m_WordProps;
321 };
322
323 class CFXEU_Backspace : public CFX_Edit_UndoItem {
324 public:
325 CFXEU_Backspace(CFX_Edit* pEdit,
326 const CPVT_WordPlace& wpOldPlace,
327 const CPVT_WordPlace& wpNewPlace,
328 uint16_t word,
329 int32_t charset,
330 const CPVT_SecProps& SecProps,
331 const CPVT_WordProps& WordProps);
332 ~CFXEU_Backspace() override;
333
334 // CFX_Edit_UndoItem
335 void Redo() override;
336 void Undo() override;
337
338 private:
339 CFX_Edit* m_pEdit;
340
341 CPVT_WordPlace m_wpOld;
342 CPVT_WordPlace m_wpNew;
343 uint16_t m_Word;
344 int32_t m_nCharset;
345 CPVT_SecProps m_SecProps;
346 CPVT_WordProps m_WordProps;
347 };
348
349 class CFXEU_Delete : public CFX_Edit_UndoItem {
350 public:
351 CFXEU_Delete(CFX_Edit* pEdit,
352 const CPVT_WordPlace& wpOldPlace,
353 const CPVT_WordPlace& wpNewPlace,
354 uint16_t word,
355 int32_t charset,
356 const CPVT_SecProps& SecProps,
357 const CPVT_WordProps& WordProps,
358 FX_BOOL bSecEnd);
359 ~CFXEU_Delete() override;
360
361 // CFX_Edit_UndoItem
362 void Redo() override;
363 void Undo() override;
364
365 private:
366 CFX_Edit* m_pEdit;
367
368 CPVT_WordPlace m_wpOld;
369 CPVT_WordPlace m_wpNew;
370 uint16_t m_Word;
371 int32_t m_nCharset;
372 CPVT_SecProps m_SecProps;
373 CPVT_WordProps m_WordProps;
374 FX_BOOL m_bSecEnd;
375 };
376
377 class CFXEU_Clear : public CFX_Edit_UndoItem {
378 public:
379 CFXEU_Clear(CFX_Edit* pEdit,
380 const CPVT_WordRange& wrSel,
381 const CFX_WideString& swText);
382 ~CFXEU_Clear() override;
383
384 // CFX_Edit_UndoItem
385 void Redo() override;
386 void Undo() override;
387
388 private:
389 CFX_Edit* m_pEdit;
390
391 CPVT_WordRange m_wrSel;
392 CFX_WideString m_swText;
393 };
394
395 class CFXEU_ClearRich : public CFX_Edit_UndoItem {
396 public:
397 CFXEU_ClearRich(CFX_Edit* pEdit,
398 const CPVT_WordPlace& wpOldPlace,
399 const CPVT_WordPlace& wpNewPlace,
400 const CPVT_WordRange& wrSel,
401 uint16_t word,
402 int32_t charset,
403 const CPVT_SecProps& SecProps,
404 const CPVT_WordProps& WordProps);
405 ~CFXEU_ClearRich() override;
406
407 // CFX_Edit_UndoItem
408 void Redo() override;
409 void Undo() override;
410
411 private:
412 CFX_Edit* m_pEdit;
413
414 CPVT_WordPlace m_wpOld;
415 CPVT_WordPlace m_wpNew;
416 CPVT_WordRange m_wrSel;
417 uint16_t m_Word;
418 int32_t m_nCharset;
419 CPVT_SecProps m_SecProps;
420 CPVT_WordProps m_WordProps;
421 };
422
423 class CFXEU_InsertText : public CFX_Edit_UndoItem {
424 public:
425 CFXEU_InsertText(CFX_Edit* pEdit,
426 const CPVT_WordPlace& wpOldPlace,
427 const CPVT_WordPlace& wpNewPlace,
428 const CFX_WideString& swText,
429 int32_t charset,
430 const CPVT_SecProps* pSecProps,
431 const CPVT_WordProps* pWordProps);
432 ~CFXEU_InsertText() override;
433
434 // CFX_Edit_UndoItem
435 void Redo() override;
436 void Undo() override;
437
438 private:
439 CFX_Edit* m_pEdit;
440
441 CPVT_WordPlace m_wpOld;
442 CPVT_WordPlace m_wpNew;
443 CFX_WideString m_swText;
444 int32_t m_nCharset;
445 CPVT_SecProps m_SecProps;
446 CPVT_WordProps m_WordProps;
447 };
448
449 class CFXEU_SetSecProps : public CFX_Edit_UndoItem {
450 public:
451 CFXEU_SetSecProps(CFX_Edit* pEdit,
452 const CPVT_WordPlace& place,
453 EDIT_PROPS_E ep,
454 const CPVT_SecProps& oldsecprops,
455 const CPVT_WordProps& oldwordprops,
456 const CPVT_SecProps& newsecprops,
457 const CPVT_WordProps& newwordprops,
458 const CPVT_WordRange& range);
459 ~CFXEU_SetSecProps() override;
460
461 // CFX_Edit_UndoItem
462 void Redo() override;
463 void Undo() override;
464
465 private:
466 CFX_Edit* m_pEdit;
467 CPVT_WordPlace m_wpPlace;
468 CPVT_WordRange m_wrPlace;
469 EDIT_PROPS_E m_eProps;
470
471 CPVT_SecProps m_OldSecProps;
472 CPVT_SecProps m_NewSecProps;
473 CPVT_WordProps m_OldWordProps;
474 CPVT_WordProps m_NewWordProps;
475 };
476
477 class CFXEU_SetWordProps : public CFX_Edit_UndoItem {
478 public:
479 CFXEU_SetWordProps(CFX_Edit* pEdit,
480 const CPVT_WordPlace& place,
481 EDIT_PROPS_E ep,
482 const CPVT_WordProps& oldprops,
483 const CPVT_WordProps& newprops,
484 const CPVT_WordRange& range);
485 ~CFXEU_SetWordProps() override;
486
487 // CFX_Edit_UndoItem
488 void Redo() override;
489 void Undo() override;
490
491 private:
492 CFX_Edit* m_pEdit;
493 CPVT_WordPlace m_wpPlace;
494 CPVT_WordRange m_wrPlace;
495 EDIT_PROPS_E m_eProps;
496
497 CPVT_WordProps m_OldWordProps;
498 CPVT_WordProps m_NewWordProps;
499 };
500
501 class CFX_Edit : public IFX_Edit {
502 friend class CFX_Edit_Iterator;
503 friend class CFXEU_InsertWord;
504 friend class CFXEU_InsertReturn;
505 friend class CFXEU_Backspace;
506 friend class CFXEU_Delete;
507 friend class CFXEU_Clear;
508 friend class CFXEU_ClearRich;
509 friend class CFXEU_SetSecProps;
510 friend class CFXEU_SetWordProps;
511 friend class CFXEU_InsertText;
512
513 public:
514 explicit CFX_Edit(CPDF_VariableText* pVT);
515 ~CFX_Edit() override;
516
517 // IFX_Edit
518 void SetFontMap(IPVT_FontMap* pFontMap) override;
519 void SetVTProvider(CPDF_VariableText::Provider* pProvider) override;
520 void SetNotify(IFX_Edit_Notify* pNotify) override;
521 void SetOprNotify(IFX_Edit_OprNotify* pOprNotify) override;
522 IFX_Edit_Iterator* GetIterator() override;
523 CPDF_VariableText* GetVariableText() override;
524 IPVT_FontMap* GetFontMap() override;
525 void Initialize() override;
526 void SetPlateRect(const CFX_FloatRect& rect, FX_BOOL bPaint = TRUE) override;
527 void SetScrollPos(const CFX_FloatPoint& point) override;
528 void SetAlignmentH(int32_t nFormat = 0, FX_BOOL bPaint = TRUE) override;
529 void SetAlignmentV(int32_t nFormat = 0, FX_BOOL bPaint = TRUE) override;
530 void SetPasswordChar(uint16_t wSubWord = '*', FX_BOOL bPaint = TRUE) override;
531 void SetLimitChar(int32_t nLimitChar = 0, FX_BOOL bPaint = TRUE) override;
532 void SetCharArray(int32_t nCharArray = 0, FX_BOOL bPaint = TRUE) override;
533 void SetCharSpace(FX_FLOAT fCharSpace = 0.0f, FX_BOOL bPaint = TRUE) override;
534 void SetHorzScale(int32_t nHorzScale = 100, FX_BOOL bPaint = TRUE) override;
535 void SetLineLeading(FX_FLOAT fLineLeading, FX_BOOL bPaint = TRUE) override;
536 void SetMultiLine(FX_BOOL bMultiLine = TRUE, FX_BOOL bPaint = TRUE) override;
537 void SetAutoReturn(FX_BOOL bAuto = TRUE, FX_BOOL bPaint = TRUE) override;
538 void SetAutoFontSize(FX_BOOL bAuto = TRUE, FX_BOOL bPaint = TRUE) override;
539 void SetAutoScroll(FX_BOOL bAuto = TRUE, FX_BOOL bPaint = TRUE) override;
540 void SetFontSize(FX_FLOAT fFontSize, FX_BOOL bPaint = TRUE) override;
541 void SetTextOverflow(FX_BOOL bAllowed = FALSE,
542 FX_BOOL bPaint = TRUE) override;
543 FX_BOOL IsRichText() const override;
544 void SetRichText(FX_BOOL bRichText = TRUE, FX_BOOL bPaint = TRUE) override;
545 FX_BOOL SetRichFontSize(FX_FLOAT fFontSize) override;
546 FX_BOOL SetRichFontIndex(int32_t nFontIndex) override;
547 FX_BOOL SetRichTextColor(FX_COLORREF dwColor) override;
548 FX_BOOL SetRichTextScript(CPDF_VariableText::ScriptType nScriptType) override;
549 FX_BOOL SetRichTextBold(FX_BOOL bBold = TRUE) override;
550 FX_BOOL SetRichTextItalic(FX_BOOL bItalic = TRUE) override;
551 FX_BOOL SetRichTextUnderline(FX_BOOL bUnderline = TRUE) override;
552 FX_BOOL SetRichTextCrossout(FX_BOOL bCrossout = TRUE) override;
553 FX_BOOL SetRichTextCharSpace(FX_FLOAT fCharSpace) override;
554 FX_BOOL SetRichTextHorzScale(int32_t nHorzScale = 100) override;
555 FX_BOOL SetRichTextLineLeading(FX_FLOAT fLineLeading) override;
556 FX_BOOL SetRichTextLineIndent(FX_FLOAT fLineIndent) override;
557 FX_BOOL SetRichTextAlignment(int32_t nAlignment) override;
558 void OnMouseDown(const CFX_FloatPoint& point,
559 FX_BOOL bShift,
560 FX_BOOL bCtrl) override;
561 void OnMouseMove(const CFX_FloatPoint& point,
562 FX_BOOL bShift,
563 FX_BOOL bCtrl) override;
564 void OnVK_UP(FX_BOOL bShift, FX_BOOL bCtrl) override;
565 void OnVK_DOWN(FX_BOOL bShift, FX_BOOL bCtrl) override;
566 void OnVK_LEFT(FX_BOOL bShift, FX_BOOL bCtrl) override;
567 void OnVK_RIGHT(FX_BOOL bShift, FX_BOOL bCtrl) override;
568 void OnVK_HOME(FX_BOOL bShift, FX_BOOL bCtrl) override;
569 void OnVK_END(FX_BOOL bShift, FX_BOOL bCtrl) override;
570 void SetText(const FX_WCHAR* text,
571 int32_t charset = DEFAULT_CHARSET,
572 const CPVT_SecProps* pSecProps = NULL,
573 const CPVT_WordProps* pWordProps = NULL) override;
574 FX_BOOL InsertWord(uint16_t word,
575 int32_t charset = DEFAULT_CHARSET,
576 const CPVT_WordProps* pWordProps = NULL) override;
577 FX_BOOL InsertReturn(const CPVT_SecProps* pSecProps = NULL,
578 const CPVT_WordProps* pWordProps = NULL) override;
579 FX_BOOL Backspace() override;
580 FX_BOOL Delete() override;
581 FX_BOOL Clear() override;
582 FX_BOOL InsertText(const FX_WCHAR* text,
583 int32_t charset = DEFAULT_CHARSET,
584 const CPVT_SecProps* pSecProps = NULL,
585 const CPVT_WordProps* pWordProps = NULL) override;
586 FX_BOOL Redo() override;
587 FX_BOOL Undo() override;
588 int32_t WordPlaceToWordIndex(const CPVT_WordPlace& place) const override;
589 CPVT_WordPlace WordIndexToWordPlace(int32_t index) const override;
590 CPVT_WordPlace GetLineBeginPlace(const CPVT_WordPlace& place) const override;
591 CPVT_WordPlace GetLineEndPlace(const CPVT_WordPlace& place) const override;
592 CPVT_WordPlace GetSectionBeginPlace(
593 const CPVT_WordPlace& place) const override;
594 CPVT_WordPlace GetSectionEndPlace(const CPVT_WordPlace& place) const override;
595 CPVT_WordPlace SearchWordPlace(const CFX_FloatPoint& point) const override;
596 int32_t GetCaret() const override;
597 CPVT_WordPlace GetCaretWordPlace() const override;
598 CFX_WideString GetSelText() const override;
599 CFX_WideString GetText() const override;
600 FX_FLOAT GetFontSize() const override;
601 uint16_t GetPasswordChar() const override;
602 CFX_FloatPoint GetScrollPos() const override;
603 int32_t GetCharArray() const override;
604 CFX_FloatRect GetPlateRect() const override;
605 CFX_FloatRect GetContentRect() const override;
606 CFX_WideString GetRangeText(const CPVT_WordRange& range) const override;
607 int32_t GetHorzScale() const override;
608 FX_FLOAT GetCharSpace() const override;
609 int32_t GetTotalWords() const override;
610 void SetSel(int32_t nStartChar, int32_t nEndChar) override;
611 void GetSel(int32_t& nStartChar, int32_t& nEndChar) const override;
612 void SelectAll() override;
613 void SelectNone() override;
614 FX_BOOL IsSelected() const override;
615 void Paint() override;
616 void EnableNotify(FX_BOOL bNotify) override;
617 void EnableRefresh(FX_BOOL bRefresh) override;
618 void RefreshWordRange(const CPVT_WordRange& wr) override;
619 void SetCaret(int32_t nPos) override;
620 CPVT_WordRange GetWholeWordRange() const override;
621 CPVT_WordRange GetSelectWordRange() const override;
622 void EnableUndo(FX_BOOL bUndo) override;
623 void EnableOprNotify(FX_BOOL bNotify) override;
624 FX_BOOL IsTextFull() const override;
625 FX_BOOL IsTextOverflow() const;
626 FX_BOOL CanUndo() const override;
627 FX_BOOL CanRedo() const override;
628 FX_BOOL IsModified() const override;
629 CPVT_WordRange GetVisibleWordRange() const override;
630 void AddUndoItem(IFX_Edit_UndoItem* pUndoItem) override;
631
632 FX_BOOL Empty();
633
634 CPVT_WordPlace DoInsertText(const CPVT_WordPlace& place,
635 const FX_WCHAR* text,
636 int32_t charset,
637 const CPVT_SecProps* pSecProps,
638 const CPVT_WordProps* pWordProps);
639 int32_t GetCharSetFromUnicode(uint16_t word, int32_t nOldCharset);
640
641 int32_t GetTotalLines() const;
642
643 private:
644 void SetSel(const CPVT_WordPlace& begin, const CPVT_WordPlace& end);
645
646 void RearrangeAll();
647 void RearrangePart(const CPVT_WordRange& range);
648 void ScrollToCaret();
649 void SetScrollInfo();
650 void SetScrollPosX(FX_FLOAT fx);
651 void SetScrollPosY(FX_FLOAT fy);
652 void SetScrollLimit();
653 void SetContentChanged();
654
655 void SetText(const FX_WCHAR* text,
656 int32_t charset,
657 const CPVT_SecProps* pSecProps,
658 const CPVT_WordProps* pWordProps,
659 FX_BOOL bAddUndo,
660 FX_BOOL bPaint);
661 FX_BOOL InsertWord(uint16_t word,
662 int32_t charset,
663 const CPVT_WordProps* pWordProps,
664 FX_BOOL bAddUndo,
665 FX_BOOL bPaint);
666 FX_BOOL InsertReturn(const CPVT_SecProps* pSecProps,
667 const CPVT_WordProps* pWordProps,
668 FX_BOOL bAddUndo,
669 FX_BOOL bPaint);
670 FX_BOOL Backspace(FX_BOOL bAddUndo, FX_BOOL bPaint);
671 FX_BOOL Delete(FX_BOOL bAddUndo, FX_BOOL bPaint);
672 FX_BOOL Clear(FX_BOOL bAddUndo, FX_BOOL bPaint);
673 FX_BOOL InsertText(const FX_WCHAR* text,
674 int32_t charset,
675 const CPVT_SecProps* pSecProps,
676 const CPVT_WordProps* pWordProps,
677 FX_BOOL bAddUndo,
678 FX_BOOL bPaint);
679 FX_BOOL SetRichTextProps(EDIT_PROPS_E eProps,
680 const CPVT_SecProps* pSecProps,
681 const CPVT_WordProps* pWordProps);
682 FX_BOOL SetSecProps(EDIT_PROPS_E eProps,
683 const CPVT_WordPlace& place,
684 const CPVT_SecProps* pSecProps,
685 const CPVT_WordProps* pWordProps,
686 const CPVT_WordRange& wr,
687 FX_BOOL bAddUndo);
688 FX_BOOL SetWordProps(EDIT_PROPS_E eProps,
689 const CPVT_WordPlace& place,
690 const CPVT_WordProps* pWordProps,
691 const CPVT_WordRange& wr,
692 FX_BOOL bAddUndo);
693 void PaintSetProps(EDIT_PROPS_E eProps, const CPVT_WordRange& wr);
694 void PaintInsertText(const CPVT_WordPlace& wpOld,
695 const CPVT_WordPlace& wpNew);
696
697 inline CFX_FloatPoint VTToEdit(const CFX_FloatPoint& point) const;
698 inline CFX_FloatPoint EditToVT(const CFX_FloatPoint& point) const;
699 inline CFX_FloatRect VTToEdit(const CFX_FloatRect& rect) const;
700 inline CFX_FloatRect EditToVT(const CFX_FloatRect& rect) const;
701
702 void Refresh(REFRESH_PLAN_E ePlan,
703 const CPVT_WordRange* pRange1 = NULL,
704 const CPVT_WordRange* pRange2 = NULL);
705 void RefreshPushLineRects(const CPVT_WordRange& wr);
706 void RefreshPushRandomRects(const CPVT_WordRange& wr);
707
708 void SetCaret(const CPVT_WordPlace& place);
709 void SetCaretInfo();
710 void SetCaretOrigin();
711 void SetCaretChange();
712
713 CPVT_WordRange GetLatinWordsRange(const CPVT_WordPlace& place) const;
714 CPVT_WordRange CombineWordRange(const CPVT_WordRange& wr1,
715 const CPVT_WordRange& wr2);
716
717
718 void BeginGroupUndo(const CFX_WideString& sTitle);
719 void EndGroupUndo();
720 void AddEditUndoItem(CFX_Edit_UndoItem* pEditUndoItem);
721
722 void SetPageInfo(const CPVT_WordPlace& place);
723 CPVT_WordPlace SearchPageEndPlace(const CPVT_WordPlace& wpPageBegin,
724 const CFX_FloatPoint& point) const;
725 FX_FLOAT GetLineTop(const CPVT_WordPlace& place) const;
726 FX_FLOAT GetLineBottom(const CPVT_WordPlace& place) const;
727
728 private:
729 CPDF_VariableText* m_pVT;
730 IFX_Edit_Notify* m_pNotify;
731 IFX_Edit_OprNotify* m_pOprNotify;
732 CFX_Edit_Provider* m_pVTProvide;
733
734 CPVT_WordPlace m_wpCaret;
735 CPVT_WordPlace m_wpOldCaret;
736 CFX_Edit_Select m_SelState;
737
738 CFX_FloatPoint m_ptScrollPos;
739 CFX_FloatPoint m_ptRefreshScrollPos;
740 FX_BOOL m_bEnableScroll;
741 IFX_Edit_Iterator* m_pIterator;
742 CFX_Edit_Refresh m_Refresh;
743 CFX_FloatPoint m_ptCaret;
744 CFX_Edit_Undo m_Undo;
745 int32_t m_nAlignment;
746 FX_BOOL m_bNotifyFlag;
747 FX_BOOL m_bEnableOverflow;
748 FX_BOOL m_bEnableRefresh;
749 CFX_FloatRect m_rcOldContent;
750 FX_BOOL m_bEnableUndo;
751 FX_BOOL m_bNotify;
752 FX_BOOL m_bOprNotify;
753 CFX_Edit_GroupUndoItem* m_pGroupUndoItem;
754 };
755
756 class CFX_Edit_Iterator : public IFX_Edit_Iterator {
757 public:
758 CFX_Edit_Iterator(CFX_Edit* pEdit, CPDF_VariableText::Iterator* pVTIterator);
759 ~CFX_Edit_Iterator() override;
760
761 // IFX_Edit_Iterator
762 FX_BOOL NextWord() override;
763 FX_BOOL NextLine() override;
764 FX_BOOL NextSection() override;
765 FX_BOOL PrevWord() override;
766 FX_BOOL PrevLine() override;
767 FX_BOOL PrevSection() override;
768 FX_BOOL GetWord(CPVT_Word& word) const override;
769 FX_BOOL GetLine(CPVT_Line& line) const override;
770 FX_BOOL GetSection(CPVT_Section& section) const override;
771 void SetAt(int32_t nWordIndex) override;
772 void SetAt(const CPVT_WordPlace& place) override;
773 const CPVT_WordPlace& GetAt() const override;
774 IFX_Edit* GetEdit() const override;
775
776 private:
777 CFX_Edit* m_pEdit;
778 CPDF_VariableText::Iterator* m_pVTIterator;
779 };
780
781 class CFX_Edit_Provider : public CPDF_VariableText::Provider {
782 public:
783 explicit CFX_Edit_Provider(IPVT_FontMap* pFontMap);
784 ~CFX_Edit_Provider() override;
785
786 IPVT_FontMap* GetFontMap();
787
788 // CPDF_VariableText::Provider:
789 int32_t GetCharWidth(int32_t nFontIndex,
790 uint16_t word,
791 int32_t nWordStyle) override;
792 int32_t GetTypeAscent(int32_t nFontIndex) override;
793 int32_t GetTypeDescent(int32_t nFontIndex) override;
794 int32_t GetWordFontIndex(uint16_t word,
795 int32_t charset,
796 int32_t nFontIndex) override;
797 int32_t GetDefaultFontIndex() override;
798 FX_BOOL IsLatinWord(uint16_t word) override;
799
800 private:
801 IPVT_FontMap* m_pFontMap;
802 };
803
804 #endif // FPDFSDK_INCLUDE_FXEDIT_FXET_EDIT_H_
OLDNEW
« no previous file with comments | « fpdfsdk/include/fxedit/fx_edit.h ('k') | fpdfsdk/include/fxedit/fxet_list.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698