OLD | NEW |
| (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 XFA_SRC_FEE_FDE_TXTEDTBUF_H_ | |
8 #define XFA_SRC_FEE_FDE_TXTEDTBUF_H_ | |
9 | |
10 #include "xfa/src/fee/ifde_txtedtbuf.h" | |
11 #include "xfa/src/fee/ifde_txtedtengine.h" | |
12 #include "xfa/src/fgas/crt/fgas_memory.h" | |
13 | |
14 class IFX_CharIter; | |
15 class CFDE_TxtEdtBuf; | |
16 | |
17 class CFDE_TxtEdtBufIter : public IFX_CharIter { | |
18 public: | |
19 CFDE_TxtEdtBufIter(CFDE_TxtEdtBuf* pBuf, FX_WCHAR wcAlias = 0); | |
20 | |
21 virtual void Release(); | |
22 virtual FX_BOOL Next(FX_BOOL bPrev = FALSE); | |
23 virtual FX_WCHAR GetChar(); | |
24 virtual void SetAt(int32_t nIndex); | |
25 virtual int32_t GetAt() const; | |
26 virtual FX_BOOL IsEOF(FX_BOOL bTail = TRUE) const; | |
27 virtual IFX_CharIter* Clone(); | |
28 | |
29 protected: | |
30 ~CFDE_TxtEdtBufIter(); | |
31 | |
32 private: | |
33 CFDE_TxtEdtBuf* m_pBuf; | |
34 int32_t m_nCurChunk; | |
35 int32_t m_nCurIndex; | |
36 int32_t m_nIndex; | |
37 FX_WCHAR m_Alias; | |
38 }; | |
39 class CFDE_TxtEdtBuf : public IFDE_TxtEdtBuf { | |
40 friend class CFDE_TxtEdtBufIter; | |
41 struct _FDE_CHUNKHEADER { | |
42 int32_t nUsed; | |
43 FX_WCHAR wChars[1]; | |
44 }; | |
45 typedef _FDE_CHUNKHEADER FDE_CHUNKHEADER; | |
46 typedef _FDE_CHUNKHEADER* FDE_LPCHUNKHEADER; | |
47 struct _FDE_CHUNKPLACE { | |
48 int32_t nChunkIndex; | |
49 int32_t nCharIndex; | |
50 }; | |
51 typedef _FDE_CHUNKPLACE FDE_CHUNKPLACE; | |
52 typedef _FDE_CHUNKPLACE* FDE_LPCHUNKPLACE; | |
53 | |
54 public: | |
55 CFDE_TxtEdtBuf(int32_t nDefChunkSize = FDE_DEFCHUNKLENGTH); | |
56 | |
57 virtual void Release(); | |
58 virtual FX_BOOL SetChunkSize(int32_t nChunkSize); | |
59 virtual int32_t GetChunkSize() const; | |
60 virtual int32_t GetTextLength() const; | |
61 virtual void SetText(const CFX_WideString& wsText); | |
62 virtual void GetText(CFX_WideString& wsText) const; | |
63 virtual FX_WCHAR GetCharByIndex(int32_t nIndex) const; | |
64 virtual void GetRange(CFX_WideString& wsText, | |
65 int32_t nBegine, | |
66 int32_t nCount = -1) const; | |
67 | |
68 virtual void Insert(int32_t nPos, | |
69 const FX_WCHAR* lpText, | |
70 int32_t nLength = 1); | |
71 virtual void Delete(int32_t nIndex, int32_t nLength = 1); | |
72 virtual void Clear(FX_BOOL bRelease = TRUE); | |
73 | |
74 virtual FX_BOOL Optimize(IFX_Pause* pPause = NULL); | |
75 | |
76 protected: | |
77 virtual ~CFDE_TxtEdtBuf(); | |
78 | |
79 private: | |
80 void ResetChunkBuffer(int32_t nDefChunkCount, int32_t nChunkSize); | |
81 int32_t CP2Index(const FDE_CHUNKPLACE& cp) const; | |
82 void Index2CP(int32_t nIndex, FDE_CHUNKPLACE& cp) const; | |
83 | |
84 int32_t m_nChunkSize; | |
85 | |
86 int32_t m_nTotal; | |
87 FX_BOOL m_bChanged; | |
88 CFX_PtrArray m_Chunks; | |
89 IFX_MEMAllocator* m_pAllocator; | |
90 }; | |
91 | |
92 #endif // XFA_SRC_FEE_FDE_TXTEDTBUF_H_ | |
OLD | NEW |