Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Side by Side Diff: xfa/fde/cfde_txtedtbuf.h

Issue 2614383003: Add CFDE_TxtEdtBuf tests (Closed)
Patch Set: Review feedback Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « BUILD.gn ('k') | xfa/fde/cfde_txtedtbuf.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_FDE_CFDE_TXTEDTBUF_H_ 7 #ifndef XFA_FDE_CFDE_TXTEDTBUF_H_
8 #define XFA_FDE_CFDE_TXTEDTBUF_H_ 8 #define XFA_FDE_CFDE_TXTEDTBUF_H_
9 9
10 #include <memory> 10 #include <memory>
11 11
12 #include "core/fxcrt/fx_basic.h" 12 #include "core/fxcrt/fx_basic.h"
13 #include "core/fxcrt/fx_system.h" 13 #include "core/fxcrt/fx_system.h"
14 14
15 class IFX_MemoryAllocator; 15 class IFX_MemoryAllocator;
16 class IFX_Pause; 16 class IFX_Pause;
17 17
18 class CFDE_TxtEdtBuf { 18 class CFDE_TxtEdtBuf {
19 public: 19 public:
20 CFDE_TxtEdtBuf(); 20 CFDE_TxtEdtBuf();
21 ~CFDE_TxtEdtBuf(); 21 ~CFDE_TxtEdtBuf();
22 22
23 int32_t GetChunkSize() const; 23 int32_t GetChunkSize() const;
24 int32_t GetTextLength() const; 24 int32_t GetTextLength() const;
25 void SetText(const CFX_WideString& wsText); 25 void SetText(const CFX_WideString& wsText);
26 CFX_WideString GetText() const; 26 CFX_WideString GetText() const;
27 FX_WCHAR GetCharByIndex(int32_t nIndex) const; 27 FX_WCHAR GetCharByIndex(int32_t nIndex) const;
28 CFX_WideString GetRange(int32_t nBegin, int32_t nCount = -1) const; 28 CFX_WideString GetRange(int32_t nBegin, int32_t nCount) const;
29 29
30 void Insert(int32_t nPos, const FX_WCHAR* lpText, int32_t nLength = 1); 30 void Insert(int32_t nPos, const FX_WCHAR* lpText, int32_t nLength);
31 void Delete(int32_t nIndex, int32_t nLength = 1); 31 void Delete(int32_t nIndex, int32_t nLength);
32 void Clear(bool bRelease = true); 32 void Clear(bool bRelease);
33
34 bool Optimize(IFX_Pause* pPause = nullptr);
35 33
36 private: 34 private:
37 friend class CFDE_TxtEdtBufIter; 35 friend class CFDE_TxtEdtBufIter;
36 friend class CFDE_TxtEdtBufTest;
38 37
39 struct FDE_CHUNKHEADER { 38 struct FDE_CHUNKHEADER {
40 int32_t nUsed; 39 int32_t nUsed;
41 FX_WCHAR wChars[1]; 40 FX_WCHAR wChars[1];
42 }; 41 };
43 42
44 struct FDE_CHUNKPLACE { 43 struct FDE_CHUNKPLACE {
45 int32_t nChunkIndex; 44 int32_t nChunkIndex;
46 int32_t nCharIndex; 45 int32_t nCharIndex;
47 }; 46 };
48 47
49 void ResetChunkBuffer(int32_t nDefChunkCount, int32_t nChunkSize); 48 void ResetChunkBuffer(int32_t nDefChunkCount, int32_t nChunkSize);
50 int32_t CP2Index(const FDE_CHUNKPLACE& cp) const; 49 int32_t CP2Index(const FDE_CHUNKPLACE& cp) const;
51 void Index2CP(int32_t nIndex, FDE_CHUNKPLACE& cp) const; 50 void Index2CP(int32_t nIndex, FDE_CHUNKPLACE& cp) const;
52 51
52 void SetChunkSizeForTesting(size_t size);
53
53 int32_t m_nChunkSize; 54 int32_t m_nChunkSize;
54 55
55 int32_t m_nTotal; 56 int32_t m_nTotal;
56 bool m_bChanged; 57 bool m_bChanged;
57 CFX_ArrayTemplate<FDE_CHUNKHEADER*> m_Chunks; 58 CFX_ArrayTemplate<FDE_CHUNKHEADER*> m_Chunks;
58 std::unique_ptr<IFX_MemoryAllocator> m_pAllocator; 59 std::unique_ptr<IFX_MemoryAllocator> m_pAllocator;
59 }; 60 };
60 61
61 #endif // XFA_FDE_CFDE_TXTEDTBUF_H_ 62 #endif // XFA_FDE_CFDE_TXTEDTBUF_H_
OLDNEW
« no previous file with comments | « BUILD.gn ('k') | xfa/fde/cfde_txtedtbuf.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698