| 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_INCLUDE_FXEDIT_FXET_EDIT_H_ | 7 #ifndef FPDFSDK_INCLUDE_FXEDIT_FXET_EDIT_H_ |
| 8 #define FPDFSDK_INCLUDE_FXEDIT_FXET_EDIT_H_ | 8 #define FPDFSDK_INCLUDE_FXEDIT_FXET_EDIT_H_ |
| 9 | 9 |
| 10 #include "core/include/fpdfdoc/fpdf_vt.h" | 10 #include "core/include/fpdfdoc/fpdf_vt.h" |
| 11 #include "fx_edit.h" | 11 #include "fpdfsdk/include/fxedit/fx_edit.h" |
| 12 | 12 |
| 13 class CFX_Edit_Page; | |
| 14 struct CFX_Edit_LineRect; | |
| 15 class CFX_Edit_LineRectArray; | |
| 16 class CFX_Edit_RectArray; | |
| 17 class CFX_Edit_Refresh; | |
| 18 class CFX_Edit_Select; | |
| 19 class CFX_Edit; | 13 class CFX_Edit; |
| 20 class CFX_Edit_Iterator; | 14 class CFX_Edit_Iterator; |
| 21 class CFX_Edit_Refresh; | |
| 22 class CFX_Edit_UndoItem; | |
| 23 class CFX_Edit_Undo; | |
| 24 class CFX_Edit_Provider; | 15 class CFX_Edit_Provider; |
| 25 | 16 |
| 26 #define FX_EDIT_IsFloatZero(f) (f < 0.0001 && f > -0.0001) | 17 #define FX_EDIT_IsFloatZero(f) (f < 0.0001 && f > -0.0001) |
| 27 #define FX_EDIT_IsFloatEqual(fa, fb) FX_EDIT_IsFloatZero(fa - fb) | 18 #define FX_EDIT_IsFloatEqual(fa, fb) FX_EDIT_IsFloatZero(fa - fb) |
| 28 #define FX_EDIT_IsFloatBigger(fa, fb) (fa > fb && !FX_EDIT_IsFloatEqual(fa, fb)) | 19 #define FX_EDIT_IsFloatBigger(fa, fb) (fa > fb && !FX_EDIT_IsFloatEqual(fa, fb)) |
| 29 #define FX_EDIT_IsFloatSmaller(fa, fb) \ | 20 #define FX_EDIT_IsFloatSmaller(fa, fb) \ |
| 30 (fa < fb && !FX_EDIT_IsFloatEqual(fa, fb)) | 21 (fa < fb && !FX_EDIT_IsFloatEqual(fa, fb)) |
| 31 | 22 |
| 32 template <class T> | |
| 33 T FX_EDIT_MIN(const T& i, const T& j) { | |
| 34 return ((i < j) ? i : j); | |
| 35 } | |
| 36 template <class T> | |
| 37 T FX_EDIT_MAX(const T& i, const T& j) { | |
| 38 return ((i > j) ? i : j); | |
| 39 } | |
| 40 | |
| 41 #define FX_EDIT_PI 3.14159265358979f | |
| 42 #define FX_EDIT_ITALIC_ANGEL 10 * FX_EDIT_PI / 180.0f | |
| 43 | |
| 44 /* ------------------------- CFX_Edit_Refresh ---------------------------- */ | 23 /* ------------------------- CFX_Edit_Refresh ---------------------------- */ |
| 45 | 24 |
| 46 enum REFRESH_PLAN_E { RP_ANALYSE, RP_NOANALYSE, RP_OPTIONAL }; | 25 enum REFRESH_PLAN_E { RP_ANALYSE, RP_NOANALYSE, RP_OPTIONAL }; |
| 47 | 26 |
| 48 enum EDIT_PROPS_E { | 27 enum EDIT_PROPS_E { |
| 49 EP_LINELEADING, | 28 EP_LINELEADING, |
| 50 EP_LINEINDENT, | 29 EP_LINEINDENT, |
| 51 EP_ALIGNMENT, | 30 EP_ALIGNMENT, |
| 52 EP_FONTINDEX, | 31 EP_FONTINDEX, |
| 53 EP_FONTSIZE, | 32 EP_FONTSIZE, |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 /* ------------------------- CFX_Edit_Select ---------------------------- */ | 167 /* ------------------------- CFX_Edit_Select ---------------------------- */ |
| 189 | 168 |
| 190 class CFX_Edit_Select { | 169 class CFX_Edit_Select { |
| 191 public: | 170 public: |
| 192 CFX_Edit_Select() {} | 171 CFX_Edit_Select() {} |
| 193 | 172 |
| 194 CFX_Edit_Select(const CPVT_WordPlace& begin, const CPVT_WordPlace& end) { | 173 CFX_Edit_Select(const CPVT_WordPlace& begin, const CPVT_WordPlace& end) { |
| 195 Set(begin, end); | 174 Set(begin, end); |
| 196 } | 175 } |
| 197 | 176 |
| 198 CFX_Edit_Select(const CPVT_WordRange& range) { | 177 explicit CFX_Edit_Select(const CPVT_WordRange& range) { |
| 199 Set(range.BeginPos, range.EndPos); | 178 Set(range.BeginPos, range.EndPos); |
| 200 } | 179 } |
| 201 | 180 |
| 202 CPVT_WordRange ConvertToWordRange() const { | 181 CPVT_WordRange ConvertToWordRange() const { |
| 203 return CPVT_WordRange(BeginPos, EndPos); | 182 return CPVT_WordRange(BeginPos, EndPos); |
| 204 } | 183 } |
| 205 | 184 |
| 206 void Default() { | 185 void Default() { |
| 207 BeginPos.Default(); | 186 BeginPos.Default(); |
| 208 EndPos.Default(); | 187 EndPos.Default(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 223 return wr.BeginPos != BeginPos || wr.EndPos != EndPos; | 202 return wr.BeginPos != BeginPos || wr.EndPos != EndPos; |
| 224 } | 203 } |
| 225 | 204 |
| 226 CPVT_WordPlace BeginPos, EndPos; | 205 CPVT_WordPlace BeginPos, EndPos; |
| 227 }; | 206 }; |
| 228 | 207 |
| 229 /* ------------------------- CFX_Edit_Undo ---------------------------- */ | 208 /* ------------------------- CFX_Edit_Undo ---------------------------- */ |
| 230 | 209 |
| 231 class CFX_Edit_Undo { | 210 class CFX_Edit_Undo { |
| 232 public: | 211 public: |
| 233 CFX_Edit_Undo(int32_t nBufsize = 10000); | 212 explicit CFX_Edit_Undo(int32_t nBufsize); |
| 234 virtual ~CFX_Edit_Undo(); | 213 virtual ~CFX_Edit_Undo(); |
| 235 | 214 |
| 236 void Undo(); | 215 void Undo(); |
| 237 void Redo(); | 216 void Redo(); |
| 238 | 217 |
| 239 void AddItem(IFX_Edit_UndoItem* pItem); | 218 void AddItem(IFX_Edit_UndoItem* pItem); |
| 240 | 219 |
| 241 FX_BOOL CanUndo() const; | 220 FX_BOOL CanUndo() const; |
| 242 FX_BOOL CanRedo() const; | 221 FX_BOOL CanRedo() const; |
| 243 FX_BOOL IsModified() const; | 222 FX_BOOL IsModified() const; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 void SetLast(FX_BOOL bLast) { m_bLast = bLast; } | 257 void SetLast(FX_BOOL bLast) { m_bLast = bLast; } |
| 279 FX_BOOL IsLast() { return m_bLast; } | 258 FX_BOOL IsLast() { return m_bLast; } |
| 280 | 259 |
| 281 private: | 260 private: |
| 282 FX_BOOL m_bFirst; | 261 FX_BOOL m_bFirst; |
| 283 FX_BOOL m_bLast; | 262 FX_BOOL m_bLast; |
| 284 }; | 263 }; |
| 285 | 264 |
| 286 class CFX_Edit_GroupUndoItem : public IFX_Edit_UndoItem { | 265 class CFX_Edit_GroupUndoItem : public IFX_Edit_UndoItem { |
| 287 public: | 266 public: |
| 288 CFX_Edit_GroupUndoItem(const CFX_WideString& sTitle); | 267 explicit CFX_Edit_GroupUndoItem(const CFX_WideString& sTitle); |
| 289 ~CFX_Edit_GroupUndoItem() override; | 268 ~CFX_Edit_GroupUndoItem() override; |
| 290 | 269 |
| 291 void Undo() override; | 270 void Undo() override; |
| 292 void Redo() override; | 271 void Redo() override; |
| 293 CFX_WideString GetUndoTitle() override; | 272 CFX_WideString GetUndoTitle() override; |
| 294 | 273 |
| 295 void AddUndoItem(CFX_Edit_UndoItem* pUndoItem); | 274 void AddUndoItem(CFX_Edit_UndoItem* pUndoItem); |
| 296 void UpdateItems(); | 275 void UpdateItems(); |
| 297 | 276 |
| 298 private: | 277 private: |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 friend class CFXEU_InsertReturn; | 514 friend class CFXEU_InsertReturn; |
| 536 friend class CFXEU_Backspace; | 515 friend class CFXEU_Backspace; |
| 537 friend class CFXEU_Delete; | 516 friend class CFXEU_Delete; |
| 538 friend class CFXEU_Clear; | 517 friend class CFXEU_Clear; |
| 539 friend class CFXEU_ClearRich; | 518 friend class CFXEU_ClearRich; |
| 540 friend class CFXEU_SetSecProps; | 519 friend class CFXEU_SetSecProps; |
| 541 friend class CFXEU_SetWordProps; | 520 friend class CFXEU_SetWordProps; |
| 542 friend class CFXEU_InsertText; | 521 friend class CFXEU_InsertText; |
| 543 | 522 |
| 544 public: | 523 public: |
| 545 CFX_Edit(IPDF_VariableText* pVT); | 524 explicit CFX_Edit(IPDF_VariableText* pVT); |
| 546 ~CFX_Edit() override; | 525 ~CFX_Edit() override; |
| 547 | 526 |
| 548 // IFX_Edit | 527 // IFX_Edit |
| 549 void SetFontMap(IFX_Edit_FontMap* pFontMap) override; | 528 void SetFontMap(IFX_Edit_FontMap* pFontMap) override; |
| 550 void SetVTProvider(IPDF_VariableText_Provider* pProvider) override; | 529 void SetVTProvider(IPDF_VariableText_Provider* pProvider) override; |
| 551 void SetNotify(IFX_Edit_Notify* pNotify) override; | 530 void SetNotify(IFX_Edit_Notify* pNotify) override; |
| 552 void SetOprNotify(IFX_Edit_OprNotify* pOprNotify) override; | 531 void SetOprNotify(IFX_Edit_OprNotify* pOprNotify) override; |
| 553 IFX_Edit_Iterator* GetIterator() override; | 532 IFX_Edit_Iterator* GetIterator() override; |
| 554 IPDF_VariableText* GetVariableText() override; | 533 IPDF_VariableText* GetVariableText() override; |
| 555 IFX_Edit_FontMap* GetFontMap() override; | 534 IFX_Edit_FontMap* GetFontMap() override; |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 806 const CPVT_WordPlace& GetAt() const override; | 785 const CPVT_WordPlace& GetAt() const override; |
| 807 IFX_Edit* GetEdit() const override; | 786 IFX_Edit* GetEdit() const override; |
| 808 | 787 |
| 809 private: | 788 private: |
| 810 CFX_Edit* m_pEdit; | 789 CFX_Edit* m_pEdit; |
| 811 IPDF_VariableText_Iterator* m_pVTIterator; | 790 IPDF_VariableText_Iterator* m_pVTIterator; |
| 812 }; | 791 }; |
| 813 | 792 |
| 814 class CFX_Edit_Provider : public IPDF_VariableText_Provider { | 793 class CFX_Edit_Provider : public IPDF_VariableText_Provider { |
| 815 public: | 794 public: |
| 816 CFX_Edit_Provider(IFX_Edit_FontMap* pFontMap); | 795 explicit CFX_Edit_Provider(IFX_Edit_FontMap* pFontMap); |
| 817 ~CFX_Edit_Provider() override; | 796 ~CFX_Edit_Provider() override; |
| 818 | 797 |
| 819 IFX_Edit_FontMap* GetFontMap(); | 798 IFX_Edit_FontMap* GetFontMap(); |
| 820 | 799 |
| 821 // IPDF_VariableText_Provider: | 800 // IPDF_VariableText_Provider: |
| 822 int32_t GetCharWidth(int32_t nFontIndex, | 801 int32_t GetCharWidth(int32_t nFontIndex, |
| 823 FX_WORD word, | 802 FX_WORD word, |
| 824 int32_t nWordStyle) override; | 803 int32_t nWordStyle) override; |
| 825 int32_t GetTypeAscent(int32_t nFontIndex) override; | 804 int32_t GetTypeAscent(int32_t nFontIndex) override; |
| 826 int32_t GetTypeDescent(int32_t nFontIndex) override; | 805 int32_t GetTypeDescent(int32_t nFontIndex) override; |
| 827 int32_t GetWordFontIndex(FX_WORD word, | 806 int32_t GetWordFontIndex(FX_WORD word, |
| 828 int32_t charset, | 807 int32_t charset, |
| 829 int32_t nFontIndex) override; | 808 int32_t nFontIndex) override; |
| 830 int32_t GetDefaultFontIndex() override; | 809 int32_t GetDefaultFontIndex() override; |
| 831 FX_BOOL IsLatinWord(FX_WORD word) override; | 810 FX_BOOL IsLatinWord(FX_WORD word) override; |
| 832 | 811 |
| 833 private: | 812 private: |
| 834 IFX_Edit_FontMap* m_pFontMap; | 813 IFX_Edit_FontMap* m_pFontMap; |
| 835 }; | 814 }; |
| 836 | 815 |
| 837 #endif // FPDFSDK_INCLUDE_FXEDIT_FXET_EDIT_H_ | 816 #endif // FPDFSDK_INCLUDE_FXEDIT_FXET_EDIT_H_ |
| OLD | NEW |