OLD | NEW |
| (Empty) |
1 // Copyright 2016 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 CORE_FPDFDOC_INCLUDE_CPVT_WORDRANGE_H_ | |
8 #define CORE_FPDFDOC_INCLUDE_CPVT_WORDRANGE_H_ | |
9 | |
10 #include "core/fpdfdoc/include/cpvt_wordplace.h" | |
11 #include "core/fxcrt/include/fx_system.h" | |
12 | |
13 struct CPVT_WordRange { | |
14 CPVT_WordRange() {} | |
15 | |
16 CPVT_WordRange(const CPVT_WordPlace& begin, const CPVT_WordPlace& end) { | |
17 Set(begin, end); | |
18 } | |
19 | |
20 void Default() { | |
21 BeginPos.Default(); | |
22 EndPos.Default(); | |
23 } | |
24 | |
25 void Set(const CPVT_WordPlace& begin, const CPVT_WordPlace& end) { | |
26 BeginPos = begin; | |
27 EndPos = end; | |
28 SwapWordPlace(); | |
29 } | |
30 | |
31 void SetBeginPos(const CPVT_WordPlace& begin) { | |
32 BeginPos = begin; | |
33 SwapWordPlace(); | |
34 } | |
35 | |
36 void SetEndPos(const CPVT_WordPlace& end) { | |
37 EndPos = end; | |
38 SwapWordPlace(); | |
39 } | |
40 | |
41 FX_BOOL IsExist() const { return BeginPos != EndPos; } | |
42 | |
43 FX_BOOL operator!=(const CPVT_WordRange& wr) const { | |
44 return wr.BeginPos != BeginPos || wr.EndPos != EndPos; | |
45 } | |
46 | |
47 void SwapWordPlace() { | |
48 if (BeginPos.WordCmp(EndPos) > 0) { | |
49 CPVT_WordPlace place = EndPos; | |
50 EndPos = BeginPos; | |
51 BeginPos = place; | |
52 } | |
53 } | |
54 | |
55 CPVT_WordPlace BeginPos; | |
56 CPVT_WordPlace EndPos; | |
57 }; | |
58 | |
59 #endif // CORE_FPDFDOC_INCLUDE_CPVT_WORDRANGE_H_ | |
OLD | NEW |