OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #ifndef FPDFSDK_FXEDIT_INCLUDE_FXET_EDIT_H_ | 7 #ifndef FPDFSDK_FXEDIT_INCLUDE_FXET_EDIT_H_ |
8 #define FPDFSDK_FXEDIT_INCLUDE_FXET_EDIT_H_ | 8 #define FPDFSDK_FXEDIT_INCLUDE_FXET_EDIT_H_ |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 FX_BOOL IsSameRight(const CFX_Edit_LineRect& linerect) const { | 66 FX_BOOL IsSameRight(const CFX_Edit_LineRect& linerect) const { |
67 return FX_EDIT_IsFloatZero(m_rcLine.right - linerect.m_rcLine.right); | 67 return FX_EDIT_IsFloatZero(m_rcLine.right - linerect.m_rcLine.right); |
68 } | 68 } |
69 | 69 |
70 CPVT_WordRange m_wrLine; | 70 CPVT_WordRange m_wrLine; |
71 CFX_FloatRect m_rcLine; | 71 CFX_FloatRect m_rcLine; |
72 }; | 72 }; |
73 | 73 |
74 class CFX_Edit_LineRectArray { | 74 class CFX_Edit_LineRectArray { |
75 public: | 75 public: |
76 CFX_Edit_LineRectArray() {} | 76 CFX_Edit_LineRectArray(); |
| 77 virtual ~CFX_Edit_LineRectArray(); |
77 | 78 |
78 virtual ~CFX_Edit_LineRectArray() { Empty(); } | 79 void Empty(); |
| 80 void RemoveAll(); |
| 81 void operator=(CFX_Edit_LineRectArray& rects); |
| 82 void Add(const CPVT_WordRange& wrLine, const CFX_FloatRect& rcLine); |
79 | 83 |
80 void Empty() { | 84 int32_t GetSize() const; |
81 for (int32_t i = 0, sz = m_LineRects.GetSize(); i < sz; i++) | 85 CFX_Edit_LineRect* GetAt(int32_t nIndex) const; |
82 delete m_LineRects.GetAt(i); | |
83 | 86 |
84 m_LineRects.RemoveAll(); | 87 private: |
85 } | |
86 | |
87 void RemoveAll() { m_LineRects.RemoveAll(); } | |
88 | |
89 void operator=(CFX_Edit_LineRectArray& rects) { | |
90 Empty(); | |
91 for (int32_t i = 0, sz = rects.GetSize(); i < sz; i++) | |
92 m_LineRects.Add(rects.GetAt(i)); | |
93 | |
94 rects.RemoveAll(); | |
95 } | |
96 | |
97 void Add(const CPVT_WordRange& wrLine, const CFX_FloatRect& rcLine) { | |
98 m_LineRects.Add(new CFX_Edit_LineRect(wrLine, rcLine)); | |
99 } | |
100 | |
101 int32_t GetSize() const { return m_LineRects.GetSize(); } | |
102 | |
103 CFX_Edit_LineRect* GetAt(int32_t nIndex) const { | |
104 if (nIndex < 0 || nIndex >= m_LineRects.GetSize()) | |
105 return nullptr; | |
106 | |
107 return m_LineRects.GetAt(nIndex); | |
108 } | |
109 | |
110 CFX_ArrayTemplate<CFX_Edit_LineRect*> m_LineRects; | 88 CFX_ArrayTemplate<CFX_Edit_LineRect*> m_LineRects; |
111 }; | 89 }; |
112 | 90 |
113 class CFX_Edit_RectArray { | 91 class CFX_Edit_RectArray { |
114 public: | 92 public: |
115 CFX_Edit_RectArray() {} | 93 CFX_Edit_RectArray(); |
| 94 virtual ~CFX_Edit_RectArray(); |
116 | 95 |
117 virtual ~CFX_Edit_RectArray() { Empty(); } | 96 void Empty(); |
| 97 void Add(const CFX_FloatRect& rect); |
118 | 98 |
119 void Empty() { | 99 int32_t GetSize() const; |
120 for (int32_t i = 0, sz = m_Rects.GetSize(); i < sz; i++) | 100 CFX_FloatRect* GetAt(int32_t nIndex) const; |
121 delete m_Rects.GetAt(i); | |
122 | 101 |
123 m_Rects.RemoveAll(); | 102 private: |
124 } | |
125 | |
126 void Add(const CFX_FloatRect& rect) { | |
127 // check for overlapped area | |
128 for (int32_t i = 0, sz = m_Rects.GetSize(); i < sz; i++) { | |
129 CFX_FloatRect* pRect = m_Rects.GetAt(i); | |
130 if (pRect && pRect->Contains(rect)) | |
131 return; | |
132 } | |
133 | |
134 m_Rects.Add(new CFX_FloatRect(rect)); | |
135 } | |
136 | |
137 int32_t GetSize() const { return m_Rects.GetSize(); } | |
138 | |
139 CFX_FloatRect* GetAt(int32_t nIndex) const { | |
140 if (nIndex < 0 || nIndex >= m_Rects.GetSize()) | |
141 return nullptr; | |
142 | |
143 return m_Rects.GetAt(nIndex); | |
144 } | |
145 | |
146 CFX_ArrayTemplate<CFX_FloatRect*> m_Rects; | 103 CFX_ArrayTemplate<CFX_FloatRect*> m_Rects; |
147 }; | 104 }; |
148 | 105 |
149 class CFX_Edit_Refresh { | 106 class CFX_Edit_Refresh { |
150 public: | 107 public: |
151 CFX_Edit_Refresh(); | 108 CFX_Edit_Refresh(); |
152 virtual ~CFX_Edit_Refresh(); | 109 virtual ~CFX_Edit_Refresh(); |
153 | 110 |
154 void BeginRefresh(); | 111 void BeginRefresh(); |
155 void Push(const CPVT_WordRange& linerange, const CFX_FloatRect& rect); | 112 void Push(const CPVT_WordRange& linerange, const CFX_FloatRect& rect); |
156 void NoAnalyse(); | 113 void NoAnalyse(); |
157 void Analyse(int32_t nAlignment); | 114 void Analyse(int32_t nAlignment); |
158 void AddRefresh(const CFX_FloatRect& rect); | 115 void AddRefresh(const CFX_FloatRect& rect); |
159 const CFX_Edit_RectArray* GetRefreshRects() const; | 116 const CFX_Edit_RectArray* GetRefreshRects() const; |
160 void EndRefresh(); | 117 void EndRefresh(); |
161 | 118 |
162 private: | 119 private: |
163 CFX_Edit_LineRectArray m_NewLineRects; | 120 CFX_Edit_LineRectArray m_NewLineRects; |
164 CFX_Edit_LineRectArray m_OldLineRects; | 121 CFX_Edit_LineRectArray m_OldLineRects; |
165 CFX_Edit_RectArray m_RefreshRects; | 122 CFX_Edit_RectArray m_RefreshRects; |
166 }; | 123 }; |
167 | 124 |
168 class CFX_Edit_Select { | 125 class CFX_Edit_Select { |
169 public: | 126 public: |
170 CFX_Edit_Select() {} | 127 CFX_Edit_Select(); |
| 128 CFX_Edit_Select(const CPVT_WordPlace& begin, const CPVT_WordPlace& end); |
| 129 explicit CFX_Edit_Select(const CPVT_WordRange& range); |
171 | 130 |
172 CFX_Edit_Select(const CPVT_WordPlace& begin, const CPVT_WordPlace& end) { | 131 void Default(); |
173 Set(begin, end); | 132 void Set(const CPVT_WordPlace& begin, const CPVT_WordPlace& end); |
174 } | 133 void SetBeginPos(const CPVT_WordPlace& begin); |
| 134 void SetEndPos(const CPVT_WordPlace& end); |
175 | 135 |
176 explicit CFX_Edit_Select(const CPVT_WordRange& range) { | 136 CPVT_WordRange ConvertToWordRange() const; |
177 Set(range.BeginPos, range.EndPos); | 137 FX_BOOL IsExist() const; |
178 } | 138 FX_BOOL operator!=(const CPVT_WordRange& wr) const; |
179 | |
180 CPVT_WordRange ConvertToWordRange() const { | |
181 return CPVT_WordRange(BeginPos, EndPos); | |
182 } | |
183 | |
184 void Default() { | |
185 BeginPos.Default(); | |
186 EndPos.Default(); | |
187 } | |
188 | |
189 void Set(const CPVT_WordPlace& begin, const CPVT_WordPlace& end) { | |
190 BeginPos = begin; | |
191 EndPos = end; | |
192 } | |
193 | |
194 void SetBeginPos(const CPVT_WordPlace& begin) { BeginPos = begin; } | |
195 | |
196 void SetEndPos(const CPVT_WordPlace& end) { EndPos = end; } | |
197 | |
198 FX_BOOL IsExist() const { return BeginPos != EndPos; } | |
199 | |
200 FX_BOOL operator!=(const CPVT_WordRange& wr) const { | |
201 return wr.BeginPos != BeginPos || wr.EndPos != EndPos; | |
202 } | |
203 | 139 |
204 CPVT_WordPlace BeginPos, EndPos; | 140 CPVT_WordPlace BeginPos, EndPos; |
205 }; | 141 }; |
206 | 142 |
207 class CFX_Edit_Undo { | 143 class CFX_Edit_Undo { |
208 public: | 144 public: |
209 explicit CFX_Edit_Undo(int32_t nBufsize); | 145 explicit CFX_Edit_Undo(int32_t nBufsize); |
210 virtual ~CFX_Edit_Undo(); | 146 virtual ~CFX_Edit_Undo(); |
211 | 147 |
212 void Undo(); | 148 void Undo(); |
(...skipping 24 matching lines...) Expand all Loading... |
237 | 173 |
238 int32_t m_nCurUndoPos; | 174 int32_t m_nCurUndoPos; |
239 int32_t m_nBufSize; | 175 int32_t m_nBufSize; |
240 FX_BOOL m_bModified; | 176 FX_BOOL m_bModified; |
241 FX_BOOL m_bVirgin; | 177 FX_BOOL m_bVirgin; |
242 FX_BOOL m_bWorking; | 178 FX_BOOL m_bWorking; |
243 }; | 179 }; |
244 | 180 |
245 class CFX_Edit_UndoItem : public IFX_Edit_UndoItem { | 181 class CFX_Edit_UndoItem : public IFX_Edit_UndoItem { |
246 public: | 182 public: |
247 CFX_Edit_UndoItem() : m_bFirst(TRUE), m_bLast(TRUE) {} | 183 CFX_Edit_UndoItem(); |
248 ~CFX_Edit_UndoItem() override {} | 184 ~CFX_Edit_UndoItem() override; |
249 | 185 |
250 CFX_WideString GetUndoTitle() override { return L""; } | 186 CFX_WideString GetUndoTitle() override; |
251 | 187 |
252 void SetFirst(FX_BOOL bFirst) { m_bFirst = bFirst; } | 188 void SetFirst(FX_BOOL bFirst); |
253 FX_BOOL IsFirst() { return m_bFirst; } | 189 FX_BOOL IsFirst(); |
254 void SetLast(FX_BOOL bLast) { m_bLast = bLast; } | 190 void SetLast(FX_BOOL bLast); |
255 FX_BOOL IsLast() { return m_bLast; } | 191 FX_BOOL IsLast(); |
256 | 192 |
257 private: | 193 private: |
258 FX_BOOL m_bFirst; | 194 FX_BOOL m_bFirst; |
259 FX_BOOL m_bLast; | 195 FX_BOOL m_bLast; |
260 }; | 196 }; |
261 | 197 |
262 class CFX_Edit_GroupUndoItem : public IFX_Edit_UndoItem { | 198 class CFX_Edit_GroupUndoItem : public IFX_Edit_UndoItem { |
263 public: | 199 public: |
264 explicit CFX_Edit_GroupUndoItem(const CFX_WideString& sTitle); | 200 explicit CFX_Edit_GroupUndoItem(const CFX_WideString& sTitle); |
265 ~CFX_Edit_GroupUndoItem() override; | 201 ~CFX_Edit_GroupUndoItem() override; |
266 | 202 |
| 203 // IFX_Edit_UndoItem |
267 void Undo() override; | 204 void Undo() override; |
268 void Redo() override; | 205 void Redo() override; |
269 CFX_WideString GetUndoTitle() override; | 206 CFX_WideString GetUndoTitle() override; |
270 | 207 |
271 void AddUndoItem(CFX_Edit_UndoItem* pUndoItem); | 208 void AddUndoItem(CFX_Edit_UndoItem* pUndoItem); |
272 void UpdateItems(); | 209 void UpdateItems(); |
273 | 210 |
274 private: | 211 private: |
275 CFX_WideString m_sTitle; | 212 CFX_WideString m_sTitle; |
276 CFX_ArrayTemplate<CFX_Edit_UndoItem*> m_Items; | 213 CFX_ArrayTemplate<CFX_Edit_UndoItem*> m_Items; |
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
795 int32_t charset, | 732 int32_t charset, |
796 int32_t nFontIndex) override; | 733 int32_t nFontIndex) override; |
797 int32_t GetDefaultFontIndex() override; | 734 int32_t GetDefaultFontIndex() override; |
798 FX_BOOL IsLatinWord(uint16_t word) override; | 735 FX_BOOL IsLatinWord(uint16_t word) override; |
799 | 736 |
800 private: | 737 private: |
801 IPVT_FontMap* m_pFontMap; | 738 IPVT_FontMap* m_pFontMap; |
802 }; | 739 }; |
803 | 740 |
804 #endif // FPDFSDK_FXEDIT_INCLUDE_FXET_EDIT_H_ | 741 #endif // FPDFSDK_FXEDIT_INCLUDE_FXET_EDIT_H_ |
OLD | NEW |