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

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

Issue 1919283008: Remove unneeded CPVT classes. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: rebase 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/ctypeset.h ('k') | core/fpdfdoc/doc_vt.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 CORE_FPDFDOC_PDF_VT_H_ 7 #ifndef CORE_FPDFDOC_DOC_VT_H_
8 #define CORE_FPDFDOC_PDF_VT_H_ 8 #define CORE_FPDFDOC_DOC_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>
40 class CPVT_ArrayTemplate : public CFX_ArrayTemplate<TYPE> {
41 public:
42 FX_BOOL IsEmpty() { return CFX_ArrayTemplate<TYPE>::GetSize() <= 0; }
43 TYPE GetAt(int nIndex) const {
44 if (nIndex >= 0 && nIndex < CFX_ArrayTemplate<TYPE>::GetSize()) {
45 return CFX_ArrayTemplate<TYPE>::GetAt(nIndex);
46 }
47 return NULL;
48 }
49 void RemoveAt(int nIndex) {
50 if (nIndex >= 0 && nIndex < CFX_ArrayTemplate<TYPE>::GetSize()) {
51 CFX_ArrayTemplate<TYPE>::RemoveAt(nIndex);
52 }
53 }
54 };
55 class CLine { 23 class CLine {
56 public: 24 public:
57 CLine(); 25 CLine();
58 virtual ~CLine(); 26 ~CLine();
27
59 CPVT_WordPlace GetBeginWordPlace() const; 28 CPVT_WordPlace GetBeginWordPlace() const;
60 CPVT_WordPlace GetEndWordPlace() const; 29 CPVT_WordPlace GetEndWordPlace() const;
61 CPVT_WordPlace GetPrevWordPlace(const CPVT_WordPlace& place) const; 30 CPVT_WordPlace GetPrevWordPlace(const CPVT_WordPlace& place) const;
62 CPVT_WordPlace GetNextWordPlace(const CPVT_WordPlace& place) const; 31 CPVT_WordPlace GetNextWordPlace(const CPVT_WordPlace& place) const;
63 CPVT_WordPlace LinePlace; 32 CPVT_WordPlace LinePlace;
64 CPVT_LineInfo m_LineInfo; 33 CPVT_LineInfo m_LineInfo;
65 }; 34 };
35
66 class CLines { 36 class CLines {
67 public: 37 public:
68 CLines() : m_nTotal(0) {} 38 CLines() : m_nTotal(0) {}
69 virtual ~CLines() { RemoveAll(); } 39 ~CLines() { RemoveAll(); }
40
70 int32_t GetSize() const { return m_Lines.GetSize(); } 41 int32_t GetSize() const { return m_Lines.GetSize(); }
71 CLine* GetAt(int32_t nIndex) const { return m_Lines.GetAt(nIndex); } 42 CLine* GetAt(int32_t nIndex) const { return m_Lines.GetAt(nIndex); }
72 void Empty() { m_nTotal = 0; } 43 void Empty() { m_nTotal = 0; }
73 void RemoveAll() { 44 void RemoveAll() {
74 for (int32_t i = 0, sz = GetSize(); i < sz; i++) { 45 for (int32_t i = 0, sz = GetSize(); i < sz; i++) {
75 delete GetAt(i); 46 delete GetAt(i);
76 } 47 }
77 m_Lines.RemoveAll(); 48 m_Lines.RemoveAll();
78 m_nTotal = 0; 49 m_nTotal = 0;
79 } 50 }
80 int32_t Add(const CPVT_LineInfo& lineinfo) { 51 int32_t Add(const CPVT_LineInfo& lineinfo) {
81 if (m_nTotal >= GetSize()) { 52 if (m_nTotal >= GetSize()) {
82 CLine* pLine = new CLine; 53 CLine* pLine = new CLine;
83 pLine->m_LineInfo = lineinfo; 54 pLine->m_LineInfo = lineinfo;
84 m_Lines.Add(pLine); 55 m_Lines.Add(pLine);
85 } else if (CLine* pLine = GetAt(m_nTotal)) { 56 } else if (CLine* pLine = GetAt(m_nTotal)) {
86 pLine->m_LineInfo = lineinfo; 57 pLine->m_LineInfo = lineinfo;
87 } 58 }
88 return m_nTotal++; 59 return m_nTotal++;
89 } 60 }
90 void Clear() { 61 void Clear() {
91 for (int32_t i = GetSize() - 1; i >= m_nTotal; i--) { 62 for (int32_t i = GetSize() - 1; i >= m_nTotal; i--) {
92 delete GetAt(i); 63 delete GetAt(i);
93 m_Lines.RemoveAt(i); 64 m_Lines.RemoveAt(i);
94 } 65 }
95 } 66 }
96 67
97 private: 68 private:
98 CPVT_ArrayTemplate<CLine*> m_Lines; 69 CFX_ArrayTemplate<CLine*> m_Lines;
99 int32_t m_nTotal; 70 int32_t m_nTotal;
100 }; 71 };
101 72
102 class CPDF_EditContainer { 73 class CPDF_EditContainer {
103 public: 74 public:
104 CPDF_EditContainer() : m_rcPlate(0, 0, 0, 0), m_rcContent(0, 0, 0, 0) {} 75 CPDF_EditContainer();
105 virtual ~CPDF_EditContainer() {} 76 virtual ~CPDF_EditContainer();
77
78 virtual const CFX_FloatRect& GetPlateRect() const { return m_rcPlate; }
106 virtual void SetPlateRect(const CFX_FloatRect& rect) { m_rcPlate = rect; } 79 virtual void SetPlateRect(const CFX_FloatRect& rect) { m_rcPlate = rect; }
107 virtual const CFX_FloatRect& GetPlateRect() const { return m_rcPlate; } 80 virtual CFX_FloatRect GetContentRect() const { return m_rcContent; }
108 virtual void SetContentRect(const CPVT_FloatRect& rect) { 81 virtual void SetContentRect(const CPVT_FloatRect& rect) {
109 m_rcContent = rect; 82 m_rcContent = rect;
110 } 83 }
111 virtual CFX_FloatRect GetContentRect() const { return m_rcContent; } 84
112 FX_FLOAT GetPlateWidth() const { return m_rcPlate.right - m_rcPlate.left; } 85 FX_FLOAT GetPlateWidth() const { return m_rcPlate.right - m_rcPlate.left; }
113 FX_FLOAT GetPlateHeight() const { return m_rcPlate.top - m_rcPlate.bottom; } 86 FX_FLOAT GetPlateHeight() const { return m_rcPlate.top - m_rcPlate.bottom; }
114 CPVT_Size GetPlateSize() const {
115 return CPVT_Size(GetPlateWidth(), GetPlateHeight());
116 }
117 CFX_FloatPoint GetBTPoint() const { 87 CFX_FloatPoint GetBTPoint() const {
118 return CFX_FloatPoint(m_rcPlate.left, m_rcPlate.top); 88 return CFX_FloatPoint(m_rcPlate.left, m_rcPlate.top);
119 } 89 }
120 CFX_FloatPoint GetETPoint() const { 90 CFX_FloatPoint InToOut(const CFX_FloatPoint& point) const {
121 return CFX_FloatPoint(m_rcPlate.right, m_rcPlate.bottom);
122 }
123 inline CFX_FloatPoint InToOut(const CFX_FloatPoint& point) const {
124 return CFX_FloatPoint(point.x + GetBTPoint().x, GetBTPoint().y - point.y); 91 return CFX_FloatPoint(point.x + GetBTPoint().x, GetBTPoint().y - point.y);
125 } 92 }
126 inline CFX_FloatPoint OutToIn(const CFX_FloatPoint& point) const { 93 CFX_FloatPoint OutToIn(const CFX_FloatPoint& point) const {
127 return CFX_FloatPoint(point.x - GetBTPoint().x, GetBTPoint().y - point.y); 94 return CFX_FloatPoint(point.x - GetBTPoint().x, GetBTPoint().y - point.y);
128 } 95 }
129 inline CFX_FloatRect InToOut(const CPVT_FloatRect& rect) const { 96 CFX_FloatRect InToOut(const CPVT_FloatRect& rect) const;
130 CFX_FloatPoint ptLeftTop = InToOut(CFX_FloatPoint(rect.left, rect.top));
131 CFX_FloatPoint ptRightBottom =
132 InToOut(CFX_FloatPoint(rect.right, rect.bottom));
133 return CFX_FloatRect(ptLeftTop.x, ptRightBottom.y, ptRightBottom.x,
134 ptLeftTop.y);
135 }
136 inline CPVT_FloatRect OutToIn(const CFX_FloatRect& rect) const {
137 CFX_FloatPoint ptLeftTop = OutToIn(CFX_FloatPoint(rect.left, rect.top));
138 CFX_FloatPoint ptRightBottom =
139 OutToIn(CFX_FloatPoint(rect.right, rect.bottom));
140 return CPVT_FloatRect(ptLeftTop.x, ptLeftTop.y, ptRightBottom.x,
141 ptRightBottom.y);
142 }
143 97
144 private: 98 private:
145 CFX_FloatRect m_rcPlate; 99 CFX_FloatRect m_rcPlate;
146 CPVT_FloatRect m_rcContent; 100 CPVT_FloatRect m_rcContent;
147 }; 101 };
148 102
149 #endif // CORE_FPDFDOC_PDF_VT_H_ 103 #endif // CORE_FPDFDOC_DOC_VT_H_
OLDNEW
« no previous file with comments | « core/fpdfdoc/ctypeset.h ('k') | core/fpdfdoc/doc_vt.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698