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

Side by Side Diff: core/fpdfdoc/pdf_vt.h

Issue 1961333002: Remove CPVT_Size and CPVT_FloatRange. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: More point to size Created 4 years, 7 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 | « core/fpdfdoc/include/cpdf_variabletext.h ('k') | no next file » | 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 CORE_FPDFDOC_PDF_VT_H_ 7 #ifndef CORE_FPDFDOC_PDF_VT_H_
8 #define CORE_FPDFDOC_PDF_VT_H_ 8 #define CORE_FPDFDOC_PDF_VT_H_
9 9
10 #include "core/fpdfdoc/cpvt_floatrect.h" 10 #include "core/fpdfdoc/cpvt_floatrect.h"
11 #include "core/fpdfdoc/cpvt_lineinfo.h" 11 #include "core/fpdfdoc/cpvt_lineinfo.h"
12 #include "core/fpdfdoc/include/cpvt_wordrange.h" 12 #include "core/fpdfdoc/include/cpvt_wordrange.h"
13 13
14 class CPDF_VariableText; 14 class CPDF_VariableText;
15 15
16 struct CPVT_WordInfo; 16 struct CPVT_WordInfo;
17 17
18 #define IsFloatZero(f) ((f) < 0.0001 && (f) > -0.0001) 18 #define IsFloatZero(f) ((f) < 0.0001 && (f) > -0.0001)
19 #define IsFloatBigger(fa, fb) ((fa) > (fb) && !IsFloatZero((fa) - (fb))) 19 #define IsFloatBigger(fa, fb) ((fa) > (fb) && !IsFloatZero((fa) - (fb)))
20 #define IsFloatSmaller(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)) 21 #define IsFloatEqual(fa, fb) IsFloatZero((fa) - (fb))
22 22
23 class CPVT_Size {
24 public:
25 CPVT_Size() : x(0.0f), y(0.0f) {}
26 CPVT_Size(FX_FLOAT other_x, FX_FLOAT other_y) {
27 x = other_x;
28 y = other_y;
29 }
30 FX_FLOAT x, y;
31 };
32
33 struct CPVT_FloatRange {
34 CPVT_FloatRange() : fMin(0.0f), fMax(0.0f) {}
35 CPVT_FloatRange(FX_FLOAT min, FX_FLOAT max) : fMin(min), fMax(max) {}
36 FX_FLOAT Range() const { return fMax - fMin; }
37 FX_FLOAT fMin, fMax;
38 };
39 template <class TYPE> 23 template <class TYPE>
40 class CPVT_ArrayTemplate : public CFX_ArrayTemplate<TYPE> { 24 class CPVT_ArrayTemplate : public CFX_ArrayTemplate<TYPE> {
41 public: 25 public:
42 FX_BOOL IsEmpty() { return CFX_ArrayTemplate<TYPE>::GetSize() <= 0; } 26 FX_BOOL IsEmpty() { return CFX_ArrayTemplate<TYPE>::GetSize() <= 0; }
43 TYPE GetAt(int nIndex) const { 27 TYPE GetAt(int nIndex) const {
44 if (nIndex >= 0 && nIndex < CFX_ArrayTemplate<TYPE>::GetSize()) { 28 if (nIndex >= 0 && nIndex < CFX_ArrayTemplate<TYPE>::GetSize()) {
45 return CFX_ArrayTemplate<TYPE>::GetAt(nIndex); 29 return CFX_ArrayTemplate<TYPE>::GetAt(nIndex);
46 } 30 }
47 return NULL; 31 return NULL;
48 } 32 }
49 void RemoveAt(int nIndex) { 33 void RemoveAt(int nIndex) {
50 if (nIndex >= 0 && nIndex < CFX_ArrayTemplate<TYPE>::GetSize()) { 34 if (nIndex >= 0 && nIndex < CFX_ArrayTemplate<TYPE>::GetSize()) {
51 CFX_ArrayTemplate<TYPE>::RemoveAt(nIndex); 35 CFX_ArrayTemplate<TYPE>::RemoveAt(nIndex);
52 } 36 }
53 } 37 }
54 }; 38 };
55 class CLine { 39 class CLine final {
56 public: 40 public:
57 CLine(); 41 CLine();
58 virtual ~CLine(); 42 ~CLine();
43
59 CPVT_WordPlace GetBeginWordPlace() const; 44 CPVT_WordPlace GetBeginWordPlace() const;
60 CPVT_WordPlace GetEndWordPlace() const; 45 CPVT_WordPlace GetEndWordPlace() const;
61 CPVT_WordPlace GetPrevWordPlace(const CPVT_WordPlace& place) const; 46 CPVT_WordPlace GetPrevWordPlace(const CPVT_WordPlace& place) const;
62 CPVT_WordPlace GetNextWordPlace(const CPVT_WordPlace& place) const; 47 CPVT_WordPlace GetNextWordPlace(const CPVT_WordPlace& place) const;
63 CPVT_WordPlace LinePlace; 48 CPVT_WordPlace LinePlace;
64 CPVT_LineInfo m_LineInfo; 49 CPVT_LineInfo m_LineInfo;
65 }; 50 };
66 class CLines { 51
52 class CLines final {
67 public: 53 public:
68 CLines() : m_nTotal(0) {} 54 CLines() : m_nTotal(0) {}
69 virtual ~CLines() { RemoveAll(); } 55 ~CLines() { RemoveAll(); }
56
70 int32_t GetSize() const { return m_Lines.GetSize(); } 57 int32_t GetSize() const { return m_Lines.GetSize(); }
71 CLine* GetAt(int32_t nIndex) const { return m_Lines.GetAt(nIndex); } 58 CLine* GetAt(int32_t nIndex) const { return m_Lines.GetAt(nIndex); }
72 void Empty() { m_nTotal = 0; } 59 void Empty() { m_nTotal = 0; }
73 void RemoveAll() { 60 void RemoveAll() {
74 for (int32_t i = 0, sz = GetSize(); i < sz; i++) { 61 for (int32_t i = 0, sz = GetSize(); i < sz; i++) {
75 delete GetAt(i); 62 delete GetAt(i);
76 } 63 }
77 m_Lines.RemoveAll(); 64 m_Lines.RemoveAll();
78 m_nTotal = 0; 65 m_nTotal = 0;
79 } 66 }
(...skipping 16 matching lines...) Expand all
96 83
97 private: 84 private:
98 CPVT_ArrayTemplate<CLine*> m_Lines; 85 CPVT_ArrayTemplate<CLine*> m_Lines;
99 int32_t m_nTotal; 86 int32_t m_nTotal;
100 }; 87 };
101 88
102 class CPDF_EditContainer { 89 class CPDF_EditContainer {
103 public: 90 public:
104 CPDF_EditContainer() : m_rcPlate(0, 0, 0, 0), m_rcContent(0, 0, 0, 0) {} 91 CPDF_EditContainer() : m_rcPlate(0, 0, 0, 0), m_rcContent(0, 0, 0, 0) {}
105 virtual ~CPDF_EditContainer() {} 92 virtual ~CPDF_EditContainer() {}
93
106 virtual void SetPlateRect(const CFX_FloatRect& rect) { m_rcPlate = rect; } 94 virtual void SetPlateRect(const CFX_FloatRect& rect) { m_rcPlate = rect; }
107 virtual const CFX_FloatRect& GetPlateRect() const { return m_rcPlate; } 95 virtual const CFX_FloatRect& GetPlateRect() const { return m_rcPlate; }
108 virtual void SetContentRect(const CPVT_FloatRect& rect) { 96 virtual void SetContentRect(const CPVT_FloatRect& rect) {
109 m_rcContent = rect; 97 m_rcContent = rect;
110 } 98 }
111 virtual CFX_FloatRect GetContentRect() const { return m_rcContent; } 99 virtual CFX_FloatRect GetContentRect() const { return m_rcContent; }
112 FX_FLOAT GetPlateWidth() const { return m_rcPlate.right - m_rcPlate.left; } 100 FX_FLOAT GetPlateWidth() const { return m_rcPlate.right - m_rcPlate.left; }
113 FX_FLOAT GetPlateHeight() const { return m_rcPlate.top - m_rcPlate.bottom; } 101 FX_FLOAT GetPlateHeight() const { return m_rcPlate.top - m_rcPlate.bottom; }
114 CPVT_Size GetPlateSize() const { 102 CFX_SizeF GetPlateSize() const {
115 return CPVT_Size(GetPlateWidth(), GetPlateHeight()); 103 return CFX_SizeF(GetPlateWidth(), GetPlateHeight());
116 } 104 }
117 CFX_FloatPoint GetBTPoint() const { 105 CFX_FloatPoint GetBTPoint() const {
118 return CFX_FloatPoint(m_rcPlate.left, m_rcPlate.top); 106 return CFX_FloatPoint(m_rcPlate.left, m_rcPlate.top);
119 } 107 }
120 CFX_FloatPoint GetETPoint() const { 108 CFX_FloatPoint GetETPoint() const {
121 return CFX_FloatPoint(m_rcPlate.right, m_rcPlate.bottom); 109 return CFX_FloatPoint(m_rcPlate.right, m_rcPlate.bottom);
122 } 110 }
123 inline CFX_FloatPoint InToOut(const CFX_FloatPoint& point) const { 111 inline CFX_FloatPoint InToOut(const CFX_FloatPoint& point) const {
124 return CFX_FloatPoint(point.x + GetBTPoint().x, GetBTPoint().y - point.y); 112 return CFX_FloatPoint(point.x + GetBTPoint().x, GetBTPoint().y - point.y);
125 } 113 }
(...skipping 14 matching lines...) Expand all
140 return CPVT_FloatRect(ptLeftTop.x, ptLeftTop.y, ptRightBottom.x, 128 return CPVT_FloatRect(ptLeftTop.x, ptLeftTop.y, ptRightBottom.x,
141 ptRightBottom.y); 129 ptRightBottom.y);
142 } 130 }
143 131
144 private: 132 private:
145 CFX_FloatRect m_rcPlate; 133 CFX_FloatRect m_rcPlate;
146 CPVT_FloatRect m_rcContent; 134 CPVT_FloatRect m_rcContent;
147 }; 135 };
148 136
149 #endif // CORE_FPDFDOC_PDF_VT_H_ 137 #endif // CORE_FPDFDOC_PDF_VT_H_
OLDNEW
« no previous file with comments | « core/fpdfdoc/include/cpdf_variabletext.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698