| 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 XFA_FEE_FDE_TXTEDTENGINE_H_ | 7 #ifndef XFA_FEE_FDE_TXTEDTENGINE_H_ |
| 8 #define XFA_FEE_FDE_TXTEDTENGINE_H_ | 8 #define XFA_FEE_FDE_TXTEDTENGINE_H_ |
| 9 | 9 |
| 10 #include "core/fxcrt/include/fx_string.h" | 10 #include "core/fxcrt/include/fx_string.h" |
| 11 #include "xfa/fee/ifde_txtedtbuf.h" | 11 #include "xfa/fee/fde_txtedtbuf.h" |
| 12 #include "xfa/fee/ifde_txtedtengine.h" | 12 #include "xfa/fee/ifde_txtedtengine.h" |
| 13 #include "xfa/fgas/layout/fgas_textbreak.h" | 13 #include "xfa/fgas/layout/fgas_textbreak.h" |
| 14 | 14 |
| 15 class CFX_TxtBreak; | 15 class CFX_TxtBreak; |
| 16 class IFX_CharIter; | 16 class IFX_CharIter; |
| 17 class CFDE_TxtEdtParag; | 17 class CFDE_TxtEdtParag; |
| 18 class CFDE_TxtEdtDoRecord_Insert; | 18 class CFDE_TxtEdtDoRecord_Insert; |
| 19 class CFDE_TxtEdtDoRecord_DeleteRange; | 19 class CFDE_TxtEdtDoRecord_DeleteRange; |
| 20 | 20 |
| 21 class IFDE_TxtEdtDoRecord { | 21 class IFDE_TxtEdtDoRecord { |
| 22 public: | 22 public: |
| 23 static IFDE_TxtEdtDoRecord* Create(const CFX_ByteStringC& bsDoRecord); | 23 static IFDE_TxtEdtDoRecord* Create(const CFX_ByteStringC& bsDoRecord); |
| 24 virtual ~IFDE_TxtEdtDoRecord() {} | 24 virtual ~IFDE_TxtEdtDoRecord() {} |
| 25 virtual void Release() = 0; | 25 virtual void Release() = 0; |
| 26 virtual FX_BOOL Redo() = 0; | 26 virtual FX_BOOL Redo() = 0; |
| 27 virtual FX_BOOL Undo() = 0; | 27 virtual FX_BOOL Undo() = 0; |
| 28 virtual void Serialize(CFX_ByteString& bsDoRecord) const = 0; | 28 virtual void Serialize(CFX_ByteString& bsDoRecord) const = 0; |
| 29 }; | 29 }; |
| 30 | 30 |
| 31 class CFDE_TxtEdtEngine : public IFDE_TxtEdtEngine { | 31 class CFDE_TxtEdtEngine { |
| 32 friend class CFDE_TxtEdtDoRecord_Insert; | |
| 33 friend class CFDE_TxtEdtDoRecord_DeleteRange; | |
| 34 friend class CFDE_TxtEdtPage; | |
| 35 struct _FDE_TXTEDTSELRANGE { | |
| 36 int32_t nStart; | |
| 37 int32_t nCount; | |
| 38 }; | |
| 39 typedef _FDE_TXTEDTSELRANGE FDE_TXTEDTSELRANGE; | |
| 40 typedef _FDE_TXTEDTSELRANGE* FDE_LPTXTEDTSELRANGE; | |
| 41 struct _FDE_TXTEDTPARAGPOS { | |
| 42 int32_t nParagIndex; | |
| 43 int32_t nCharIndex; | |
| 44 }; | |
| 45 typedef _FDE_TXTEDTPARAGPOS FDE_TXTEDTPARAGPOS; | |
| 46 typedef _FDE_TXTEDTPARAGPOS* FDE_LPTXTEDTPARAGPOS; | |
| 47 | |
| 48 public: | 32 public: |
| 49 CFDE_TxtEdtEngine(); | 33 CFDE_TxtEdtEngine(); |
| 50 virtual void Release(); | |
| 51 | 34 |
| 52 virtual void SetEditParams(const FDE_TXTEDTPARAMS& params); | 35 void Release(); |
| 53 virtual const FDE_TXTEDTPARAMS* GetEditParams() const; | |
| 54 | 36 |
| 55 virtual int32_t CountPages() const; | 37 void SetEditParams(const FDE_TXTEDTPARAMS& params); |
| 56 virtual IFDE_TxtEdtPage* GetPage(int32_t nIndex); | 38 FDE_TXTEDTPARAMS* GetEditParams(); |
| 57 | 39 |
| 58 virtual FX_BOOL SetBufChunkSize(int32_t nChunkSize); | 40 int32_t CountPages() const; |
| 59 virtual void SetTextByStream(IFX_Stream* pStream); | 41 IFDE_TxtEdtPage* GetPage(int32_t nIndex); |
| 60 virtual void SetText(const CFX_WideString& wsText); | |
| 61 virtual int32_t GetTextLength() const; | |
| 62 virtual void GetText(CFX_WideString& wsText, | |
| 63 int32_t nStart, | |
| 64 int32_t nCount = -1); | |
| 65 virtual void ClearText(); | |
| 66 | 42 |
| 67 virtual int32_t GetCaretRect(CFX_RectF& rtCaret) const; | 43 FX_BOOL SetBufChunkSize(int32_t nChunkSize); |
| 68 virtual int32_t GetCaretPos() const; | 44 void SetTextByStream(IFX_Stream* pStream); |
| 69 virtual int32_t SetCaretPos(int32_t nIndex, FX_BOOL bBefore); | 45 void SetText(const CFX_WideString& wsText); |
| 70 virtual int32_t MoveCaretPos(FDE_TXTEDTMOVECARET eMoveCaret, | 46 int32_t GetTextLength() const; |
| 71 FX_BOOL bShift = FALSE, | 47 void GetText(CFX_WideString& wsText, int32_t nStart, int32_t nCount = -1); |
| 72 FX_BOOL bCtrl = FALSE); | 48 void ClearText(); |
| 73 virtual void Lock(); | |
| 74 virtual void Unlock(); | |
| 75 virtual FX_BOOL IsLocked() const; | |
| 76 | 49 |
| 77 virtual int32_t Insert(int32_t nStart, | 50 int32_t GetCaretRect(CFX_RectF& rtCaret) const; |
| 78 const FX_WCHAR* lpText, | 51 int32_t GetCaretPos() const; |
| 79 int32_t nLength); | 52 int32_t SetCaretPos(int32_t nIndex, FX_BOOL bBefore); |
| 80 virtual int32_t Delete(int32_t nStart, FX_BOOL bBackspace = FALSE); | 53 int32_t MoveCaretPos(FDE_TXTEDTMOVECARET eMoveCaret, |
| 81 virtual int32_t DeleteRange(int32_t nStart, int32_t nCount = -1); | 54 FX_BOOL bShift = FALSE, |
| 82 virtual int32_t Replace(int32_t nStart, | 55 FX_BOOL bCtrl = FALSE); |
| 83 int32_t nLength, | 56 void Lock(); |
| 84 const CFX_WideString& wsReplace); | 57 void Unlock(); |
| 58 FX_BOOL IsLocked() const; |
| 85 | 59 |
| 86 virtual void SetLimit(int32_t nLimit); | 60 int32_t Insert(int32_t nStart, const FX_WCHAR* lpText, int32_t nLength); |
| 87 virtual void SetAliasChar(FX_WCHAR wcAlias); | 61 int32_t Delete(int32_t nStart, FX_BOOL bBackspace = FALSE); |
| 62 int32_t DeleteRange(int32_t nStart, int32_t nCount = -1); |
| 63 int32_t Replace(int32_t nStart, |
| 64 int32_t nLength, |
| 65 const CFX_WideString& wsReplace); |
| 66 |
| 67 void SetLimit(int32_t nLimit); |
| 68 void SetAliasChar(FX_WCHAR wcAlias); |
| 88 | 69 |
| 89 void RemoveSelRange(int32_t nStart, int32_t nCount = -1); | 70 void RemoveSelRange(int32_t nStart, int32_t nCount = -1); |
| 90 | 71 |
| 91 virtual void AddSelRange(int32_t nStart, int32_t nCount = -1); | 72 void AddSelRange(int32_t nStart, int32_t nCount = -1); |
| 92 virtual int32_t CountSelRanges(); | 73 int32_t CountSelRanges(); |
| 93 virtual int32_t GetSelRange(int32_t nIndex, int32_t& nStart); | 74 int32_t GetSelRange(int32_t nIndex, int32_t& nStart); |
| 94 virtual void ClearSelection(); | 75 void ClearSelection(); |
| 95 | 76 |
| 96 virtual FX_BOOL Redo(const CFX_ByteStringC& bsRedo); | 77 FX_BOOL Redo(const CFX_ByteStringC& bsRedo); |
| 97 virtual FX_BOOL Undo(const CFX_ByteStringC& bsUndo); | 78 FX_BOOL Undo(const CFX_ByteStringC& bsUndo); |
| 98 | 79 |
| 99 virtual int32_t StartLayout(); | 80 int32_t StartLayout(); |
| 100 virtual int32_t DoLayout(IFX_Pause* pPause); | 81 int32_t DoLayout(IFX_Pause* pPause); |
| 101 virtual void EndLayout(); | 82 void EndLayout(); |
| 102 | 83 |
| 103 virtual FX_BOOL Optimize(IFX_Pause* pPause = NULL); | 84 FX_BOOL Optimize(IFX_Pause* pPause = NULL); |
| 104 virtual int32_t CountParags() const; | 85 int32_t CountParags() const; |
| 105 virtual IFDE_TxtEdtParag* GetParag(int32_t nParagIndex) const; | 86 CFDE_TxtEdtParag* GetParag(int32_t nParagIndex) const; |
| 106 virtual IFX_CharIter* CreateCharIter(); | 87 IFX_CharIter* CreateCharIter(); |
| 107 IFDE_TxtEdtBuf* GetTextBuf() const; | 88 CFDE_TxtEdtBuf* GetTextBuf() const; |
| 108 int32_t GetTextBufLength() const; | 89 int32_t GetTextBufLength() const; |
| 109 CFX_TxtBreak* GetTextBreak() const; | 90 CFX_TxtBreak* GetTextBreak() const; |
| 110 int32_t GetLineCount() const; | 91 int32_t GetLineCount() const; |
| 111 int32_t GetPageLineCount() const; | 92 int32_t GetPageLineCount() const; |
| 112 | 93 |
| 113 int32_t Line2Parag(int32_t nStartParag, | 94 int32_t Line2Parag(int32_t nStartParag, |
| 114 int32_t nStartLineofParag, | 95 int32_t nStartLineofParag, |
| 115 int32_t nLineIndex, | 96 int32_t nLineIndex, |
| 116 int32_t& nStartLine) const; | 97 int32_t& nStartLine) const; |
| 117 FX_WCHAR GetAliasChar() const { return m_wcAliasChar; } | 98 FX_WCHAR GetAliasChar() const { return m_wcAliasChar; } |
| 118 | 99 |
| 119 protected: | 100 protected: |
| 120 virtual ~CFDE_TxtEdtEngine(); | 101 ~CFDE_TxtEdtEngine(); |
| 121 | 102 |
| 122 private: | 103 private: |
| 104 friend class CFDE_TxtEdtDoRecord_Insert; |
| 105 friend class CFDE_TxtEdtDoRecord_DeleteRange; |
| 106 friend class CFDE_TxtEdtPage; |
| 107 |
| 108 struct FDE_TXTEDTSELRANGE { |
| 109 int32_t nStart; |
| 110 int32_t nCount; |
| 111 }; |
| 112 |
| 113 struct FDE_TXTEDTPARAGPOS { |
| 114 int32_t nParagIndex; |
| 115 int32_t nCharIndex; |
| 116 }; |
| 117 |
| 123 void Inner_Insert(int32_t nStart, const FX_WCHAR* lpText, int32_t nLength); | 118 void Inner_Insert(int32_t nStart, const FX_WCHAR* lpText, int32_t nLength); |
| 124 void GetPreDeleteText(CFX_WideString& wsText, | 119 void GetPreDeleteText(CFX_WideString& wsText, |
| 125 int32_t nIndex, | 120 int32_t nIndex, |
| 126 int32_t nLength); | 121 int32_t nLength); |
| 127 void GetPreInsertText(CFX_WideString& wsText, | 122 void GetPreInsertText(CFX_WideString& wsText, |
| 128 int32_t nIndex, | 123 int32_t nIndex, |
| 129 const FX_WCHAR* lpText, | 124 const FX_WCHAR* lpText, |
| 130 int32_t nLength); | 125 int32_t nLength); |
| 131 void GetPreReplaceText(CFX_WideString& wsText, | 126 void GetPreReplaceText(CFX_WideString& wsText, |
| 132 int32_t nIndex, | 127 int32_t nIndex, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 void UpdateCaretRect(int32_t nIndex, FX_BOOL bBefore = TRUE); | 161 void UpdateCaretRect(int32_t nIndex, FX_BOOL bBefore = TRUE); |
| 167 void GetCaretRect(CFX_RectF& rtCaret, | 162 void GetCaretRect(CFX_RectF& rtCaret, |
| 168 int32_t nPageIndex, | 163 int32_t nPageIndex, |
| 169 int32_t nCaret, | 164 int32_t nCaret, |
| 170 FX_BOOL bBefore = TRUE); | 165 FX_BOOL bBefore = TRUE); |
| 171 void UpdateCaretIndex(const CFX_PointF& ptCaret); | 166 void UpdateCaretIndex(const CFX_PointF& ptCaret); |
| 172 | 167 |
| 173 FX_BOOL IsSelect(); | 168 FX_BOOL IsSelect(); |
| 174 void DeleteSelect(); | 169 void DeleteSelect(); |
| 175 | 170 |
| 176 IFDE_TxtEdtBuf* m_pTxtBuf; | 171 CFDE_TxtEdtBuf* m_pTxtBuf; |
| 177 CFX_TxtBreak* m_pTextBreak; | 172 CFX_TxtBreak* m_pTextBreak; |
| 178 FDE_TXTEDTPARAMS m_Param; | 173 FDE_TXTEDTPARAMS m_Param; |
| 179 CFX_ArrayTemplate<IFDE_TxtEdtPage*> m_PagePtrArray; | 174 CFX_ArrayTemplate<IFDE_TxtEdtPage*> m_PagePtrArray; |
| 180 CFX_ArrayTemplate<CFDE_TxtEdtParag*> m_ParagPtrArray; | 175 CFX_ArrayTemplate<CFDE_TxtEdtParag*> m_ParagPtrArray; |
| 181 CFX_ArrayTemplate<FDE_LPTXTEDTSELRANGE> m_SelRangePtrArr; | 176 CFX_ArrayTemplate<FDE_TXTEDTSELRANGE*> m_SelRangePtrArr; |
| 182 int32_t m_nPageLineCount; | 177 int32_t m_nPageLineCount; |
| 183 int32_t m_nLineCount; | 178 int32_t m_nLineCount; |
| 184 int32_t m_nAnchorPos; | 179 int32_t m_nAnchorPos; |
| 185 int32_t m_nLayoutPos; | 180 int32_t m_nLayoutPos; |
| 186 FX_FLOAT m_fCaretPosReserve; | 181 FX_FLOAT m_fCaretPosReserve; |
| 187 int32_t m_nCaret; | 182 int32_t m_nCaret; |
| 188 FX_BOOL m_bBefore; | 183 FX_BOOL m_bBefore; |
| 189 int32_t m_nCaretPage; | 184 int32_t m_nCaretPage; |
| 190 CFX_RectF m_rtCaret; | 185 CFX_RectF m_rtCaret; |
| 191 uint32_t m_dwFindFlags; | 186 uint32_t m_dwFindFlags; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 | 234 |
| 240 private: | 235 private: |
| 241 CFDE_TxtEdtEngine* m_pEngine; | 236 CFDE_TxtEdtEngine* m_pEngine; |
| 242 FX_BOOL m_bSel; | 237 FX_BOOL m_bSel; |
| 243 int32_t m_nIndex; | 238 int32_t m_nIndex; |
| 244 int32_t m_nCaret; | 239 int32_t m_nCaret; |
| 245 CFX_WideString m_wsRange; | 240 CFX_WideString m_wsRange; |
| 246 }; | 241 }; |
| 247 | 242 |
| 248 #endif // XFA_FEE_FDE_TXTEDTENGINE_H_ | 243 #endif // XFA_FEE_FDE_TXTEDTENGINE_H_ |
| OLD | NEW |