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