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 CORE_FPDFDOC_PDF_VT_H_ | |
8 #define CORE_FPDFDOC_PDF_VT_H_ | |
9 | |
10 #include "core/fpdfdoc/cpvt_floatrect.h" | |
11 #include "core/fpdfdoc/cpvt_lineinfo.h" | |
12 #include "core/fpdfdoc/include/cpvt_wordrange.h" | |
13 | |
14 class CPDF_VariableText; | |
15 | |
16 struct CPVT_WordInfo; | |
17 | |
18 #define IsFloatZero(f) ((f) < 0.0001 && (f) > -0.0001) | |
19 #define IsFloatBigger(fa, fb) ((fa) > (fb) && !IsFloatZero((fa) - (fb))) | |
20 #define IsFloatSmaller(fa, fb) ((fa) < (fb) && !IsFloatZero((fa) - (fb))) | |
21 #define IsFloatEqual(fa, fb) IsFloatZero((fa) - (fb)) | |
22 | |
23 template <class TYPE> | |
24 class CPVT_ArrayTemplate : public CFX_ArrayTemplate<TYPE> { | |
25 public: | |
26 FX_BOOL IsEmpty() { return CFX_ArrayTemplate<TYPE>::GetSize() <= 0; } | |
27 TYPE GetAt(int nIndex) const { | |
28 if (nIndex >= 0 && nIndex < CFX_ArrayTemplate<TYPE>::GetSize()) { | |
29 return CFX_ArrayTemplate<TYPE>::GetAt(nIndex); | |
30 } | |
31 return nullptr; | |
32 } | |
33 void RemoveAt(int nIndex) { | |
34 if (nIndex >= 0 && nIndex < CFX_ArrayTemplate<TYPE>::GetSize()) { | |
35 CFX_ArrayTemplate<TYPE>::RemoveAt(nIndex); | |
36 } | |
37 } | |
38 }; | |
39 class CLine final { | |
40 public: | |
41 CLine(); | |
42 ~CLine(); | |
43 | |
44 CPVT_WordPlace GetBeginWordPlace() const; | |
45 CPVT_WordPlace GetEndWordPlace() const; | |
46 CPVT_WordPlace GetPrevWordPlace(const CPVT_WordPlace& place) const; | |
47 CPVT_WordPlace GetNextWordPlace(const CPVT_WordPlace& place) const; | |
48 CPVT_WordPlace LinePlace; | |
49 CPVT_LineInfo m_LineInfo; | |
50 }; | |
51 | |
52 class CPDF_EditContainer { | |
53 public: | |
54 CPDF_EditContainer(); | |
55 virtual ~CPDF_EditContainer(); | |
56 | |
57 virtual void SetPlateRect(const CFX_FloatRect& rect); | |
58 virtual const CFX_FloatRect& GetPlateRect() const; | |
59 virtual void SetContentRect(const CPVT_FloatRect& rect); | |
60 virtual CFX_FloatRect GetContentRect() const; | |
61 | |
62 FX_FLOAT GetPlateWidth() const { return m_rcPlate.right - m_rcPlate.left; } | |
63 FX_FLOAT GetPlateHeight() const { return m_rcPlate.top - m_rcPlate.bottom; } | |
64 CFX_SizeF GetPlateSize() const { | |
65 return CFX_SizeF(GetPlateWidth(), GetPlateHeight()); | |
66 } | |
67 CFX_FloatPoint GetBTPoint() const { | |
68 return CFX_FloatPoint(m_rcPlate.left, m_rcPlate.top); | |
69 } | |
70 CFX_FloatPoint GetETPoint() const { | |
71 return CFX_FloatPoint(m_rcPlate.right, m_rcPlate.bottom); | |
72 } | |
73 CFX_FloatPoint InToOut(const CFX_FloatPoint& point) const { | |
74 return CFX_FloatPoint(point.x + GetBTPoint().x, GetBTPoint().y - point.y); | |
75 } | |
76 CFX_FloatPoint OutToIn(const CFX_FloatPoint& point) const { | |
77 return CFX_FloatPoint(point.x - GetBTPoint().x, GetBTPoint().y - point.y); | |
78 } | |
79 CFX_FloatRect InToOut(const CPVT_FloatRect& rect) const { | |
80 CFX_FloatPoint ptLeftTop = InToOut(CFX_FloatPoint(rect.left, rect.top)); | |
81 CFX_FloatPoint ptRightBottom = | |
82 InToOut(CFX_FloatPoint(rect.right, rect.bottom)); | |
83 return CFX_FloatRect(ptLeftTop.x, ptRightBottom.y, ptRightBottom.x, | |
84 ptLeftTop.y); | |
85 } | |
86 CPVT_FloatRect OutToIn(const CFX_FloatRect& rect) const { | |
87 CFX_FloatPoint ptLeftTop = OutToIn(CFX_FloatPoint(rect.left, rect.top)); | |
88 CFX_FloatPoint ptRightBottom = | |
89 OutToIn(CFX_FloatPoint(rect.right, rect.bottom)); | |
90 return CPVT_FloatRect(ptLeftTop.x, ptLeftTop.y, ptRightBottom.x, | |
91 ptRightBottom.y); | |
92 } | |
93 | |
94 private: | |
95 CFX_FloatRect m_rcPlate; | |
96 CPVT_FloatRect m_rcContent; | |
97 }; | |
98 | |
99 #endif // CORE_FPDFDOC_PDF_VT_H_ | |
OLD | NEW |