John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 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. |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 4 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 5 | // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | |
Dan Sinclair | c411eb9 | 2017-07-25 09:39:30 -0400 | [diff] [blame] | 7 | #ifndef FPDFSDK_PWL_CPWL_EDIT_IMPL_H_ |
| 8 | #define FPDFSDK_PWL_CPWL_EDIT_IMPL_H_ |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 9 | |
Tom Sepez | 3509d16 | 2017-01-30 13:22:02 -0800 | [diff] [blame] | 10 | #include <deque> |
thestig | 821d59e | 2016-05-11 12:59:22 -0700 | [diff] [blame] | 11 | #include <memory> |
tsepez | 6745f96 | 2017-01-04 10:09:45 -0800 | [diff] [blame] | 12 | #include <vector> |
thestig | 821d59e | 2016-05-11 12:59:22 -0700 | [diff] [blame] | 13 | |
Dan Sinclair | ce813f8 | 2017-10-05 15:12:58 -0400 | [diff] [blame] | 14 | #include "core/fpdfdoc/cpdf_variabletext.h" |
| 15 | #include "core/fpdfdoc/cpvt_wordrange.h" |
Dan Sinclair | aee0db0 | 2017-09-21 16:53:58 -0400 | [diff] [blame] | 16 | #include "core/fxcrt/unowned_ptr.h" |
Dan Sinclair | c08dc39 | 2017-07-24 08:57:35 -0400 | [diff] [blame] | 17 | |
| 18 | #define FX_EDIT_ISLATINWORD(u) \ |
| 19 | (u == 0x2D || (u <= 0x005A && u >= 0x0041) || \ |
| 20 | (u <= 0x007A && u >= 0x0061) || (u <= 0x02AF && u >= 0x00C0)) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 21 | |
dsinclair | 8faac62 | 2016-09-15 12:41:50 -0700 | [diff] [blame] | 22 | class CFFL_FormFiller; |
Dan Sinclair | 6b0158f | 2017-07-24 09:42:55 -0400 | [diff] [blame] | 23 | class CPWL_EditImpl; |
| 24 | class CPWL_EditImpl_Iterator; |
| 25 | class CPWL_EditImpl_Provider; |
dsinclair | e35af1e | 2016-07-13 11:26:20 -0700 | [diff] [blame] | 26 | class CFX_RenderDevice; |
| 27 | class CFX_SystemHandler; |
dsinclair | 8faac62 | 2016-09-15 12:41:50 -0700 | [diff] [blame] | 28 | class CPWL_Edit; |
| 29 | class CPWL_EditCtrl; |
dsinclair | e35af1e | 2016-07-13 11:26:20 -0700 | [diff] [blame] | 30 | class IFX_Edit_UndoItem; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 31 | |
Dan Sinclair | 6b0158f | 2017-07-24 09:42:55 -0400 | [diff] [blame] | 32 | struct CPWL_EditImpl_LineRect { |
| 33 | CPWL_EditImpl_LineRect(const CPVT_WordRange& wrLine, |
| 34 | const CFX_FloatRect& rcLine) |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 35 | : m_wrLine(wrLine), m_rcLine(rcLine) {} |
| 36 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 37 | CPVT_WordRange m_wrLine; |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 38 | CFX_FloatRect m_rcLine; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 39 | }; |
| 40 | |
Dan Sinclair | 6b0158f | 2017-07-24 09:42:55 -0400 | [diff] [blame] | 41 | class CPWL_EditImpl_LineRectArray { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 42 | public: |
Dan Sinclair | 6b0158f | 2017-07-24 09:42:55 -0400 | [diff] [blame] | 43 | CPWL_EditImpl_LineRectArray(); |
| 44 | ~CPWL_EditImpl_LineRectArray(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 45 | |
Dan Sinclair | 6b0158f | 2017-07-24 09:42:55 -0400 | [diff] [blame] | 46 | void operator=(CPWL_EditImpl_LineRectArray&& rects); |
weili | 625ad66 | 2016-06-15 11:21:33 -0700 | [diff] [blame] | 47 | void Add(const CPVT_WordRange& wrLine, const CFX_FloatRect& rcLine); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 48 | |
weili | 625ad66 | 2016-06-15 11:21:33 -0700 | [diff] [blame] | 49 | int32_t GetSize() const; |
Dan Sinclair | 6b0158f | 2017-07-24 09:42:55 -0400 | [diff] [blame] | 50 | CPWL_EditImpl_LineRect* GetAt(int32_t nIndex) const; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 51 | |
weili | 625ad66 | 2016-06-15 11:21:33 -0700 | [diff] [blame] | 52 | private: |
Dan Sinclair | 6b0158f | 2017-07-24 09:42:55 -0400 | [diff] [blame] | 53 | std::vector<std::unique_ptr<CPWL_EditImpl_LineRect>> m_LineRects; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 54 | }; |
| 55 | |
Dan Sinclair | 6b0158f | 2017-07-24 09:42:55 -0400 | [diff] [blame] | 56 | class CPWL_EditImpl_RectArray { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 57 | public: |
Dan Sinclair | 6b0158f | 2017-07-24 09:42:55 -0400 | [diff] [blame] | 58 | CPWL_EditImpl_RectArray(); |
| 59 | ~CPWL_EditImpl_RectArray(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 60 | |
Tom Sepez | 3509d16 | 2017-01-30 13:22:02 -0800 | [diff] [blame] | 61 | void Clear(); |
weili | 625ad66 | 2016-06-15 11:21:33 -0700 | [diff] [blame] | 62 | void Add(const CFX_FloatRect& rect); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 63 | |
weili | 625ad66 | 2016-06-15 11:21:33 -0700 | [diff] [blame] | 64 | int32_t GetSize() const; |
| 65 | CFX_FloatRect* GetAt(int32_t nIndex) const; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 66 | |
weili | 625ad66 | 2016-06-15 11:21:33 -0700 | [diff] [blame] | 67 | private: |
Tom Sepez | 3509d16 | 2017-01-30 13:22:02 -0800 | [diff] [blame] | 68 | std::vector<std::unique_ptr<CFX_FloatRect>> m_Rects; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 69 | }; |
| 70 | |
Dan Sinclair | 6b0158f | 2017-07-24 09:42:55 -0400 | [diff] [blame] | 71 | class CPWL_EditImpl_Refresh { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 72 | public: |
Dan Sinclair | 6b0158f | 2017-07-24 09:42:55 -0400 | [diff] [blame] | 73 | CPWL_EditImpl_Refresh(); |
| 74 | ~CPWL_EditImpl_Refresh(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 75 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 76 | void BeginRefresh(); |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 77 | void Push(const CPVT_WordRange& linerange, const CFX_FloatRect& rect); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 78 | void NoAnalyse(); |
Dan Sinclair | 6b0158f | 2017-07-24 09:42:55 -0400 | [diff] [blame] | 79 | const CPWL_EditImpl_RectArray* GetRefreshRects() const; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 80 | void EndRefresh(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 81 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 82 | private: |
Dan Sinclair | 6b0158f | 2017-07-24 09:42:55 -0400 | [diff] [blame] | 83 | CPWL_EditImpl_LineRectArray m_NewLineRects; |
| 84 | CPWL_EditImpl_LineRectArray m_OldLineRects; |
| 85 | CPWL_EditImpl_RectArray m_RefreshRects; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 86 | }; |
| 87 | |
Dan Sinclair | 6b0158f | 2017-07-24 09:42:55 -0400 | [diff] [blame] | 88 | class CPWL_EditImpl_Select { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 89 | public: |
Dan Sinclair | 6b0158f | 2017-07-24 09:42:55 -0400 | [diff] [blame] | 90 | CPWL_EditImpl_Select(); |
| 91 | explicit CPWL_EditImpl_Select(const CPVT_WordRange& range); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 92 | |
Tom Sepez | 52f69b3 | 2017-03-21 13:42:38 -0700 | [diff] [blame] | 93 | void Reset(); |
weili | 625ad66 | 2016-06-15 11:21:33 -0700 | [diff] [blame] | 94 | void Set(const CPVT_WordPlace& begin, const CPVT_WordPlace& end); |
weili | 625ad66 | 2016-06-15 11:21:33 -0700 | [diff] [blame] | 95 | void SetEndPos(const CPVT_WordPlace& end); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 96 | |
weili | 625ad66 | 2016-06-15 11:21:33 -0700 | [diff] [blame] | 97 | CPVT_WordRange ConvertToWordRange() const; |
Tom Sepez | 52f69b3 | 2017-03-21 13:42:38 -0700 | [diff] [blame] | 98 | bool IsEmpty() const; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 99 | |
Tom Sepez | 3509d16 | 2017-01-30 13:22:02 -0800 | [diff] [blame] | 100 | CPVT_WordPlace BeginPos; |
| 101 | CPVT_WordPlace EndPos; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 102 | }; |
| 103 | |
Dan Sinclair | 6b0158f | 2017-07-24 09:42:55 -0400 | [diff] [blame] | 104 | class CPWL_EditImpl_Undo { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 105 | public: |
Lei Zhang | bff66f1 | 2017-08-15 13:26:44 -0700 | [diff] [blame] | 106 | CPWL_EditImpl_Undo(); |
Dan Sinclair | 6b0158f | 2017-07-24 09:42:55 -0400 | [diff] [blame] | 107 | ~CPWL_EditImpl_Undo(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 108 | |
Tom Sepez | 3509d16 | 2017-01-30 13:22:02 -0800 | [diff] [blame] | 109 | void AddItem(std::unique_ptr<IFX_Edit_UndoItem> pItem); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 110 | void Undo(); |
| 111 | void Redo(); |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 112 | bool CanUndo() const; |
| 113 | bool CanRedo() const; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 114 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 115 | private: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 116 | void RemoveHeads(); |
| 117 | void RemoveTails(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 118 | |
Tom Sepez | 3509d16 | 2017-01-30 13:22:02 -0800 | [diff] [blame] | 119 | std::deque<std::unique_ptr<IFX_Edit_UndoItem>> m_UndoItemStack; |
| 120 | size_t m_nCurUndoPos; |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 121 | bool m_bWorking; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 122 | }; |
| 123 | |
dsinclair | e35af1e | 2016-07-13 11:26:20 -0700 | [diff] [blame] | 124 | class IFX_Edit_UndoItem { |
| 125 | public: |
| 126 | virtual ~IFX_Edit_UndoItem() {} |
| 127 | |
| 128 | virtual void Undo() = 0; |
| 129 | virtual void Redo() = 0; |
dsinclair | e35af1e | 2016-07-13 11:26:20 -0700 | [diff] [blame] | 130 | }; |
| 131 | |
Lei Zhang | ae9c5ca | 2017-08-12 07:15:14 -0700 | [diff] [blame] | 132 | class CFXEU_InsertWord : public IFX_Edit_UndoItem { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 133 | public: |
Dan Sinclair | 6b0158f | 2017-07-24 09:42:55 -0400 | [diff] [blame] | 134 | CFXEU_InsertWord(CPWL_EditImpl* pEdit, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 135 | const CPVT_WordPlace& wpOldPlace, |
| 136 | const CPVT_WordPlace& wpNewPlace, |
Tom Sepez | 62a70f9 | 2016-03-21 15:00:20 -0700 | [diff] [blame] | 137 | uint16_t word, |
Dan Sinclair | 671a799 | 2017-10-05 14:36:33 -0400 | [diff] [blame] | 138 | int32_t charset); |
Lei Zhang | 2b1a2d5 | 2015-08-14 22:16:22 -0700 | [diff] [blame] | 139 | ~CFXEU_InsertWord() override; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 140 | |
Lei Zhang | ae9c5ca | 2017-08-12 07:15:14 -0700 | [diff] [blame] | 141 | // IFX_Edit_UndoItem: |
Lei Zhang | 2b1a2d5 | 2015-08-14 22:16:22 -0700 | [diff] [blame] | 142 | void Redo() override; |
| 143 | void Undo() override; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 144 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 145 | private: |
Dan Sinclair | aee0db0 | 2017-09-21 16:53:58 -0400 | [diff] [blame] | 146 | UnownedPtr<CPWL_EditImpl> m_pEdit; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 147 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 148 | CPVT_WordPlace m_wpOld; |
| 149 | CPVT_WordPlace m_wpNew; |
Tom Sepez | 62a70f9 | 2016-03-21 15:00:20 -0700 | [diff] [blame] | 150 | uint16_t m_Word; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 151 | int32_t m_nCharset; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 152 | }; |
| 153 | |
Lei Zhang | ae9c5ca | 2017-08-12 07:15:14 -0700 | [diff] [blame] | 154 | class CFXEU_InsertReturn : public IFX_Edit_UndoItem { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 155 | public: |
Dan Sinclair | 6b0158f | 2017-07-24 09:42:55 -0400 | [diff] [blame] | 156 | CFXEU_InsertReturn(CPWL_EditImpl* pEdit, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 157 | const CPVT_WordPlace& wpOldPlace, |
Dan Sinclair | 671a799 | 2017-10-05 14:36:33 -0400 | [diff] [blame] | 158 | const CPVT_WordPlace& wpNewPlace); |
Lei Zhang | 2b1a2d5 | 2015-08-14 22:16:22 -0700 | [diff] [blame] | 159 | ~CFXEU_InsertReturn() override; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 160 | |
Lei Zhang | ae9c5ca | 2017-08-12 07:15:14 -0700 | [diff] [blame] | 161 | // IFX_Edit_UndoItem: |
Lei Zhang | 2b1a2d5 | 2015-08-14 22:16:22 -0700 | [diff] [blame] | 162 | void Redo() override; |
| 163 | void Undo() override; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 164 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 165 | private: |
Dan Sinclair | aee0db0 | 2017-09-21 16:53:58 -0400 | [diff] [blame] | 166 | UnownedPtr<CPWL_EditImpl> m_pEdit; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 167 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 168 | CPVT_WordPlace m_wpOld; |
| 169 | CPVT_WordPlace m_wpNew; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 170 | }; |
| 171 | |
Lei Zhang | ae9c5ca | 2017-08-12 07:15:14 -0700 | [diff] [blame] | 172 | class CFXEU_Backspace : public IFX_Edit_UndoItem { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 173 | public: |
Dan Sinclair | 6b0158f | 2017-07-24 09:42:55 -0400 | [diff] [blame] | 174 | CFXEU_Backspace(CPWL_EditImpl* pEdit, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 175 | const CPVT_WordPlace& wpOldPlace, |
| 176 | const CPVT_WordPlace& wpNewPlace, |
Tom Sepez | 62a70f9 | 2016-03-21 15:00:20 -0700 | [diff] [blame] | 177 | uint16_t word, |
Dan Sinclair | 671a799 | 2017-10-05 14:36:33 -0400 | [diff] [blame] | 178 | int32_t charset); |
Lei Zhang | 2b1a2d5 | 2015-08-14 22:16:22 -0700 | [diff] [blame] | 179 | ~CFXEU_Backspace() override; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 180 | |
Lei Zhang | ae9c5ca | 2017-08-12 07:15:14 -0700 | [diff] [blame] | 181 | // IFX_Edit_UndoItem: |
Lei Zhang | 2b1a2d5 | 2015-08-14 22:16:22 -0700 | [diff] [blame] | 182 | void Redo() override; |
| 183 | void Undo() override; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 184 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 185 | private: |
Dan Sinclair | aee0db0 | 2017-09-21 16:53:58 -0400 | [diff] [blame] | 186 | UnownedPtr<CPWL_EditImpl> m_pEdit; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 187 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 188 | CPVT_WordPlace m_wpOld; |
| 189 | CPVT_WordPlace m_wpNew; |
Tom Sepez | 62a70f9 | 2016-03-21 15:00:20 -0700 | [diff] [blame] | 190 | uint16_t m_Word; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 191 | int32_t m_nCharset; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 192 | }; |
| 193 | |
Lei Zhang | ae9c5ca | 2017-08-12 07:15:14 -0700 | [diff] [blame] | 194 | class CFXEU_Delete : public IFX_Edit_UndoItem { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 195 | public: |
Dan Sinclair | 6b0158f | 2017-07-24 09:42:55 -0400 | [diff] [blame] | 196 | CFXEU_Delete(CPWL_EditImpl* pEdit, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 197 | const CPVT_WordPlace& wpOldPlace, |
| 198 | const CPVT_WordPlace& wpNewPlace, |
Tom Sepez | 62a70f9 | 2016-03-21 15:00:20 -0700 | [diff] [blame] | 199 | uint16_t word, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 200 | int32_t charset, |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 201 | bool bSecEnd); |
Lei Zhang | 2b1a2d5 | 2015-08-14 22:16:22 -0700 | [diff] [blame] | 202 | ~CFXEU_Delete() override; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 203 | |
Lei Zhang | ae9c5ca | 2017-08-12 07:15:14 -0700 | [diff] [blame] | 204 | // IFX_Edit_UndoItem: |
Lei Zhang | 2b1a2d5 | 2015-08-14 22:16:22 -0700 | [diff] [blame] | 205 | void Redo() override; |
| 206 | void Undo() override; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 207 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 208 | private: |
Dan Sinclair | aee0db0 | 2017-09-21 16:53:58 -0400 | [diff] [blame] | 209 | UnownedPtr<CPWL_EditImpl> m_pEdit; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 210 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 211 | CPVT_WordPlace m_wpOld; |
| 212 | CPVT_WordPlace m_wpNew; |
Tom Sepez | 62a70f9 | 2016-03-21 15:00:20 -0700 | [diff] [blame] | 213 | uint16_t m_Word; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 214 | int32_t m_nCharset; |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 215 | bool m_bSecEnd; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 216 | }; |
| 217 | |
Lei Zhang | ae9c5ca | 2017-08-12 07:15:14 -0700 | [diff] [blame] | 218 | class CFXEU_Clear : public IFX_Edit_UndoItem { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 219 | public: |
Dan Sinclair | 6b0158f | 2017-07-24 09:42:55 -0400 | [diff] [blame] | 220 | CFXEU_Clear(CPWL_EditImpl* pEdit, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 221 | const CPVT_WordRange& wrSel, |
Ryan Harrison | 275e260 | 2017-09-18 14:23:18 -0400 | [diff] [blame] | 222 | const WideString& swText); |
Lei Zhang | 2b1a2d5 | 2015-08-14 22:16:22 -0700 | [diff] [blame] | 223 | ~CFXEU_Clear() override; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 224 | |
Lei Zhang | ae9c5ca | 2017-08-12 07:15:14 -0700 | [diff] [blame] | 225 | // IFX_Edit_UndoItem: |
Lei Zhang | 2b1a2d5 | 2015-08-14 22:16:22 -0700 | [diff] [blame] | 226 | void Redo() override; |
| 227 | void Undo() override; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 228 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 229 | private: |
Dan Sinclair | aee0db0 | 2017-09-21 16:53:58 -0400 | [diff] [blame] | 230 | UnownedPtr<CPWL_EditImpl> m_pEdit; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 231 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 232 | CPVT_WordRange m_wrSel; |
Ryan Harrison | 275e260 | 2017-09-18 14:23:18 -0400 | [diff] [blame] | 233 | WideString m_swText; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 234 | }; |
| 235 | |
Lei Zhang | ae9c5ca | 2017-08-12 07:15:14 -0700 | [diff] [blame] | 236 | class CFXEU_InsertText : public IFX_Edit_UndoItem { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 237 | public: |
Dan Sinclair | 6b0158f | 2017-07-24 09:42:55 -0400 | [diff] [blame] | 238 | CFXEU_InsertText(CPWL_EditImpl* pEdit, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 239 | const CPVT_WordPlace& wpOldPlace, |
| 240 | const CPVT_WordPlace& wpNewPlace, |
Ryan Harrison | 275e260 | 2017-09-18 14:23:18 -0400 | [diff] [blame] | 241 | const WideString& swText, |
dsinclair | efd5a99 | 2016-07-18 10:04:07 -0700 | [diff] [blame] | 242 | int32_t charset); |
Lei Zhang | 2b1a2d5 | 2015-08-14 22:16:22 -0700 | [diff] [blame] | 243 | ~CFXEU_InsertText() override; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 244 | |
Lei Zhang | ae9c5ca | 2017-08-12 07:15:14 -0700 | [diff] [blame] | 245 | // IFX_Edit_UndoItem: |
Lei Zhang | 2b1a2d5 | 2015-08-14 22:16:22 -0700 | [diff] [blame] | 246 | void Redo() override; |
| 247 | void Undo() override; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 248 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 249 | private: |
Dan Sinclair | aee0db0 | 2017-09-21 16:53:58 -0400 | [diff] [blame] | 250 | UnownedPtr<CPWL_EditImpl> m_pEdit; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 251 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 252 | CPVT_WordPlace m_wpOld; |
| 253 | CPVT_WordPlace m_wpNew; |
Ryan Harrison | 275e260 | 2017-09-18 14:23:18 -0400 | [diff] [blame] | 254 | WideString m_swText; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 255 | int32_t m_nCharset; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 256 | }; |
| 257 | |
Dan Sinclair | 6b0158f | 2017-07-24 09:42:55 -0400 | [diff] [blame] | 258 | class CPWL_EditImpl { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 259 | public: |
dsinclair | e35af1e | 2016-07-13 11:26:20 -0700 | [diff] [blame] | 260 | static void DrawEdit(CFX_RenderDevice* pDevice, |
Lei Zhang | eb14e04 | 2017-08-15 13:56:43 -0700 | [diff] [blame] | 261 | const CFX_Matrix& mtUser2Device, |
Dan Sinclair | 6b0158f | 2017-07-24 09:42:55 -0400 | [diff] [blame] | 262 | CPWL_EditImpl* pEdit, |
dsinclair | e35af1e | 2016-07-13 11:26:20 -0700 | [diff] [blame] | 263 | FX_COLORREF crTextFill, |
dsinclair | e35af1e | 2016-07-13 11:26:20 -0700 | [diff] [blame] | 264 | const CFX_FloatRect& rcClip, |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame] | 265 | const CFX_PointF& ptOffset, |
dsinclair | e35af1e | 2016-07-13 11:26:20 -0700 | [diff] [blame] | 266 | const CPVT_WordRange* pRange, |
| 267 | CFX_SystemHandler* pSystemHandler, |
dsinclair | 8faac62 | 2016-09-15 12:41:50 -0700 | [diff] [blame] | 268 | CFFL_FormFiller* pFFLData); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 269 | |
Dan Sinclair | 6b0158f | 2017-07-24 09:42:55 -0400 | [diff] [blame] | 270 | CPWL_EditImpl(); |
| 271 | ~CPWL_EditImpl(); |
dsinclair | e35af1e | 2016-07-13 11:26:20 -0700 | [diff] [blame] | 272 | |
| 273 | void SetFontMap(IPVT_FontMap* pFontMap); |
| 274 | void SetNotify(CPWL_EditCtrl* pNotify); |
Lei Zhang | 5688d62 | 2017-08-12 07:04:19 -0700 | [diff] [blame] | 275 | void SetOperationNotify(CPWL_Edit* pOperationNotify); |
dsinclair | e35af1e | 2016-07-13 11:26:20 -0700 | [diff] [blame] | 276 | |
| 277 | // Returns an iterator for the contents. Should not be released. |
Dan Sinclair | 6b0158f | 2017-07-24 09:42:55 -0400 | [diff] [blame] | 278 | CPWL_EditImpl_Iterator* GetIterator(); |
dsinclair | e35af1e | 2016-07-13 11:26:20 -0700 | [diff] [blame] | 279 | IPVT_FontMap* GetFontMap(); |
| 280 | void Initialize(); |
| 281 | |
| 282 | // Set the bounding box of the text area. |
dsinclair | efd5a99 | 2016-07-18 10:04:07 -0700 | [diff] [blame] | 283 | void SetPlateRect(const CFX_FloatRect& rect); |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame] | 284 | void SetScrollPos(const CFX_PointF& point); |
dsinclair | e35af1e | 2016-07-13 11:26:20 -0700 | [diff] [blame] | 285 | |
| 286 | // Set the horizontal text alignment. (nFormat [0:left, 1:middle, 2:right]) |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 287 | void SetAlignmentH(int32_t nFormat, bool bPaint); |
dsinclair | e35af1e | 2016-07-13 11:26:20 -0700 | [diff] [blame] | 288 | // Set the vertical text alignment. (nFormat [0:left, 1:middle, 2:right]) |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 289 | void SetAlignmentV(int32_t nFormat, bool bPaint); |
dsinclair | e35af1e | 2016-07-13 11:26:20 -0700 | [diff] [blame] | 290 | |
| 291 | // Set the substitution character for hidden text. |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 292 | void SetPasswordChar(uint16_t wSubWord, bool bPaint); |
dsinclair | e35af1e | 2016-07-13 11:26:20 -0700 | [diff] [blame] | 293 | |
| 294 | // Set the maximum number of words in the text. |
dsinclair | efd5a99 | 2016-07-18 10:04:07 -0700 | [diff] [blame] | 295 | void SetLimitChar(int32_t nLimitChar); |
| 296 | void SetCharArray(int32_t nCharArray); |
Dan Sinclair | 05df075 | 2017-03-14 14:43:42 -0400 | [diff] [blame] | 297 | void SetCharSpace(float fCharSpace); |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 298 | void SetMultiLine(bool bMultiLine, bool bPaint); |
| 299 | void SetAutoReturn(bool bAuto, bool bPaint); |
| 300 | void SetAutoFontSize(bool bAuto, bool bPaint); |
| 301 | void SetAutoScroll(bool bAuto, bool bPaint); |
Dan Sinclair | 05df075 | 2017-03-14 14:43:42 -0400 | [diff] [blame] | 302 | void SetFontSize(float fFontSize); |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 303 | void SetTextOverflow(bool bAllowed, bool bPaint); |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame] | 304 | void OnMouseDown(const CFX_PointF& point, bool bShift, bool bCtrl); |
| 305 | void OnMouseMove(const CFX_PointF& point, bool bShift, bool bCtrl); |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 306 | void OnVK_UP(bool bShift, bool bCtrl); |
| 307 | void OnVK_DOWN(bool bShift, bool bCtrl); |
| 308 | void OnVK_LEFT(bool bShift, bool bCtrl); |
| 309 | void OnVK_RIGHT(bool bShift, bool bCtrl); |
| 310 | void OnVK_HOME(bool bShift, bool bCtrl); |
| 311 | void OnVK_END(bool bShift, bool bCtrl); |
Ryan Harrison | 275e260 | 2017-09-18 14:23:18 -0400 | [diff] [blame] | 312 | void SetText(const WideString& sText); |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 313 | bool InsertWord(uint16_t word, int32_t charset); |
| 314 | bool InsertReturn(); |
| 315 | bool Backspace(); |
| 316 | bool Delete(); |
Diana Gage | 22bf7a5 | 2017-07-21 11:33:18 -0700 | [diff] [blame] | 317 | bool ClearSelection(); |
Ryan Harrison | 275e260 | 2017-09-18 14:23:18 -0400 | [diff] [blame] | 318 | bool InsertText(const WideString& sText, int32_t charset); |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 319 | bool Redo(); |
| 320 | bool Undo(); |
dsinclair | e35af1e | 2016-07-13 11:26:20 -0700 | [diff] [blame] | 321 | CPVT_WordPlace WordIndexToWordPlace(int32_t index) const; |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame] | 322 | CPVT_WordPlace SearchWordPlace(const CFX_PointF& point) const; |
dsinclair | e35af1e | 2016-07-13 11:26:20 -0700 | [diff] [blame] | 323 | int32_t GetCaret() const; |
| 324 | CPVT_WordPlace GetCaretWordPlace() const; |
Ryan Harrison | 275e260 | 2017-09-18 14:23:18 -0400 | [diff] [blame] | 325 | WideString GetSelectedText() const; |
| 326 | WideString GetText() const; |
Dan Sinclair | 05df075 | 2017-03-14 14:43:42 -0400 | [diff] [blame] | 327 | float GetFontSize() const; |
dsinclair | e35af1e | 2016-07-13 11:26:20 -0700 | [diff] [blame] | 328 | uint16_t GetPasswordChar() const; |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame] | 329 | CFX_PointF GetScrollPos() const; |
dsinclair | e35af1e | 2016-07-13 11:26:20 -0700 | [diff] [blame] | 330 | int32_t GetCharArray() const; |
dsinclair | e35af1e | 2016-07-13 11:26:20 -0700 | [diff] [blame] | 331 | CFX_FloatRect GetContentRect() const; |
Ryan Harrison | 275e260 | 2017-09-18 14:23:18 -0400 | [diff] [blame] | 332 | WideString GetRangeText(const CPVT_WordRange& range) const; |
dsinclair | e35af1e | 2016-07-13 11:26:20 -0700 | [diff] [blame] | 333 | int32_t GetHorzScale() const; |
Dan Sinclair | 05df075 | 2017-03-14 14:43:42 -0400 | [diff] [blame] | 334 | float GetCharSpace() const; |
Diana Gage | 4d02e90 | 2017-07-20 17:20:31 -0700 | [diff] [blame] | 335 | void SetSelection(int32_t nStartChar, int32_t nEndChar); |
| 336 | void GetSelection(int32_t& nStartChar, int32_t& nEndChar) const; |
dsinclair | e35af1e | 2016-07-13 11:26:20 -0700 | [diff] [blame] | 337 | void SelectAll(); |
| 338 | void SelectNone(); |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 339 | bool IsSelected() const; |
dsinclair | e35af1e | 2016-07-13 11:26:20 -0700 | [diff] [blame] | 340 | void Paint(); |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 341 | void EnableRefresh(bool bRefresh); |
dsinclair | e35af1e | 2016-07-13 11:26:20 -0700 | [diff] [blame] | 342 | void RefreshWordRange(const CPVT_WordRange& wr); |
dsinclair | e35af1e | 2016-07-13 11:26:20 -0700 | [diff] [blame] | 343 | CPVT_WordRange GetWholeWordRange() const; |
| 344 | CPVT_WordRange GetSelectWordRange() const; |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 345 | void EnableUndo(bool bUndo); |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 346 | bool IsTextFull() const; |
| 347 | bool IsTextOverflow() const; |
| 348 | bool CanUndo() const; |
| 349 | bool CanRedo() const; |
dsinclair | e35af1e | 2016-07-13 11:26:20 -0700 | [diff] [blame] | 350 | CPVT_WordRange GetVisibleWordRange() const; |
Lei Zhang | 2b1a2d5 | 2015-08-14 22:16:22 -0700 | [diff] [blame] | 351 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 352 | bool Empty(); |
Lei Zhang | 2b1a2d5 | 2015-08-14 22:16:22 -0700 | [diff] [blame] | 353 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 354 | CPVT_WordPlace DoInsertText(const CPVT_WordPlace& place, |
Ryan Harrison | 275e260 | 2017-09-18 14:23:18 -0400 | [diff] [blame] | 355 | const WideString& sText, |
dsinclair | efd5a99 | 2016-07-18 10:04:07 -0700 | [diff] [blame] | 356 | int32_t charset); |
Tom Sepez | 62a70f9 | 2016-03-21 15:00:20 -0700 | [diff] [blame] | 357 | int32_t GetCharSetFromUnicode(uint16_t word, int32_t nOldCharset); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 358 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 359 | int32_t GetTotalLines() const; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 360 | |
Ryan Harrison | 275e260 | 2017-09-18 14:23:18 -0400 | [diff] [blame] | 361 | ByteString GetPDFWordString(int32_t nFontIndex, |
| 362 | uint16_t Word, |
| 363 | uint16_t SubWord); |
Dan Sinclair | c08dc39 | 2017-07-24 08:57:35 -0400 | [diff] [blame] | 364 | |
Diana Gage | 4d02e90 | 2017-07-20 17:20:31 -0700 | [diff] [blame] | 365 | void SetSelection(const CPVT_WordPlace& begin, const CPVT_WordPlace& end); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 366 | |
Dan Sinclair | 6dc4fb8 | 2017-10-17 09:08:26 -0400 | [diff] [blame] | 367 | bool Delete(bool bAddUndo, bool bPaint); |
| 368 | bool Clear(bool bAddUndo, bool bPaint); |
| 369 | bool InsertText(const WideString& sText, |
| 370 | int32_t charset, |
| 371 | bool bAddUndo, |
| 372 | bool bPaint); |
| 373 | bool InsertWord(uint16_t word, int32_t charset, bool bAddUndo, bool bPaint); |
| 374 | bool InsertReturn(bool bAddUndo, bool bPaint); |
| 375 | bool Backspace(bool bAddUndo, bool bPaint); |
| 376 | void SetCaret(const CPVT_WordPlace& place); |
| 377 | |
| 378 | CFX_PointF VTToEdit(const CFX_PointF& point) const; |
| 379 | |
| 380 | private: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 381 | void RearrangeAll(); |
| 382 | void RearrangePart(const CPVT_WordRange& range); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 383 | void ScrollToCaret(); |
| 384 | void SetScrollInfo(); |
Dan Sinclair | 05df075 | 2017-03-14 14:43:42 -0400 | [diff] [blame] | 385 | void SetScrollPosX(float fx); |
| 386 | void SetScrollPosY(float fy); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 387 | void SetScrollLimit(); |
| 388 | void SetContentChanged(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 389 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 390 | void PaintInsertText(const CPVT_WordPlace& wpOld, |
| 391 | const CPVT_WordPlace& wpNew); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 392 | |
Dan Sinclair | 6dc4fb8 | 2017-10-17 09:08:26 -0400 | [diff] [blame] | 393 | CFX_PointF EditToVT(const CFX_PointF& point) const; |
| 394 | CFX_FloatRect VTToEdit(const CFX_FloatRect& rect) const; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 395 | |
dsinclair | efd5a99 | 2016-07-18 10:04:07 -0700 | [diff] [blame] | 396 | void Refresh(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 397 | void RefreshPushLineRects(const CPVT_WordRange& wr); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 398 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 399 | void SetCaretInfo(); |
| 400 | void SetCaretOrigin(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 401 | |
Lei Zhang | ae9c5ca | 2017-08-12 07:15:14 -0700 | [diff] [blame] | 402 | void AddEditUndoItem(std::unique_ptr<IFX_Edit_UndoItem> pEditUndoItem); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 403 | |
dsinclair | e35af1e | 2016-07-13 11:26:20 -0700 | [diff] [blame] | 404 | std::unique_ptr<CPDF_VariableText> m_pVT; |
Dan Sinclair | aee0db0 | 2017-09-21 16:53:58 -0400 | [diff] [blame] | 405 | UnownedPtr<CPWL_EditCtrl> m_pNotify; |
| 406 | UnownedPtr<CPWL_Edit> m_pOperationNotify; |
Dan Sinclair | 6b0158f | 2017-07-24 09:42:55 -0400 | [diff] [blame] | 407 | std::unique_ptr<CPWL_EditImpl_Provider> m_pVTProvider; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 408 | CPVT_WordPlace m_wpCaret; |
| 409 | CPVT_WordPlace m_wpOldCaret; |
Dan Sinclair | 6b0158f | 2017-07-24 09:42:55 -0400 | [diff] [blame] | 410 | CPWL_EditImpl_Select m_SelState; |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame] | 411 | CFX_PointF m_ptScrollPos; |
| 412 | CFX_PointF m_ptRefreshScrollPos; |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 413 | bool m_bEnableScroll; |
Dan Sinclair | 6b0158f | 2017-07-24 09:42:55 -0400 | [diff] [blame] | 414 | std::unique_ptr<CPWL_EditImpl_Iterator> m_pIterator; |
| 415 | CPWL_EditImpl_Refresh m_Refresh; |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame] | 416 | CFX_PointF m_ptCaret; |
Dan Sinclair | 6b0158f | 2017-07-24 09:42:55 -0400 | [diff] [blame] | 417 | CPWL_EditImpl_Undo m_Undo; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 418 | int32_t m_nAlignment; |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 419 | bool m_bNotifyFlag; |
| 420 | bool m_bEnableOverflow; |
| 421 | bool m_bEnableRefresh; |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 422 | CFX_FloatRect m_rcOldContent; |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 423 | bool m_bEnableUndo; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 424 | }; |
| 425 | |
Dan Sinclair | 6b0158f | 2017-07-24 09:42:55 -0400 | [diff] [blame] | 426 | class CPWL_EditImpl_Iterator { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 427 | public: |
Dan Sinclair | 6b0158f | 2017-07-24 09:42:55 -0400 | [diff] [blame] | 428 | CPWL_EditImpl_Iterator(CPWL_EditImpl* pEdit, |
| 429 | CPDF_VariableText::Iterator* pVTIterator); |
| 430 | ~CPWL_EditImpl_Iterator(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 431 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 432 | bool NextWord(); |
| 433 | bool PrevWord(); |
| 434 | bool GetWord(CPVT_Word& word) const; |
| 435 | bool GetLine(CPVT_Line& line) const; |
dsinclair | e35af1e | 2016-07-13 11:26:20 -0700 | [diff] [blame] | 436 | void SetAt(int32_t nWordIndex); |
| 437 | void SetAt(const CPVT_WordPlace& place); |
| 438 | const CPVT_WordPlace& GetAt() const; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 439 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 440 | private: |
Dan Sinclair | aee0db0 | 2017-09-21 16:53:58 -0400 | [diff] [blame] | 441 | UnownedPtr<CPWL_EditImpl> m_pEdit; |
dsinclair | c7a7349 | 2016-04-05 12:01:42 -0700 | [diff] [blame] | 442 | CPDF_VariableText::Iterator* m_pVTIterator; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 443 | }; |
| 444 | |
Dan Sinclair | 6b0158f | 2017-07-24 09:42:55 -0400 | [diff] [blame] | 445 | class CPWL_EditImpl_Provider : public CPDF_VariableText::Provider { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 446 | public: |
Dan Sinclair | 6b0158f | 2017-07-24 09:42:55 -0400 | [diff] [blame] | 447 | explicit CPWL_EditImpl_Provider(IPVT_FontMap* pFontMap); |
| 448 | ~CPWL_EditImpl_Provider() override; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 449 | |
Tom Sepez | d0409af | 2017-05-25 15:53:57 -0700 | [diff] [blame] | 450 | IPVT_FontMap* GetFontMap() const; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 451 | |
dsinclair | c7a7349 | 2016-04-05 12:01:42 -0700 | [diff] [blame] | 452 | // CPDF_VariableText::Provider: |
npm | 41d6bbe | 2016-09-14 11:54:44 -0700 | [diff] [blame] | 453 | int32_t GetCharWidth(int32_t nFontIndex, uint16_t word) override; |
Lei Zhang | 5fd907b | 2015-11-19 22:20:59 -0800 | [diff] [blame] | 454 | int32_t GetTypeAscent(int32_t nFontIndex) override; |
| 455 | int32_t GetTypeDescent(int32_t nFontIndex) override; |
Tom Sepez | 62a70f9 | 2016-03-21 15:00:20 -0700 | [diff] [blame] | 456 | int32_t GetWordFontIndex(uint16_t word, |
Lei Zhang | 5fd907b | 2015-11-19 22:20:59 -0800 | [diff] [blame] | 457 | int32_t charset, |
| 458 | int32_t nFontIndex) override; |
| 459 | int32_t GetDefaultFontIndex() override; |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 460 | bool IsLatinWord(uint16_t word) override; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 461 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 462 | private: |
dsinclair | c7a7349 | 2016-04-05 12:01:42 -0700 | [diff] [blame] | 463 | IPVT_FontMap* m_pFontMap; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 464 | }; |
| 465 | |
Dan Sinclair | c411eb9 | 2017-07-25 09:39:30 -0400 | [diff] [blame] | 466 | #endif // FPDFSDK_PWL_CPWL_EDIT_IMPL_H_ |