summaryrefslogtreecommitdiff
path: root/core/fpdfdoc/doc_vt.h
diff options
context:
space:
mode:
authorthestig <thestig@chromium.org>2016-05-02 12:40:36 -0700
committerCommit bot <commit-bot@chromium.org>2016-05-02 12:40:36 -0700
commita354eb517429e10d84abff65e455f0c183fe58e0 (patch)
tree69dd116ad19e98f94239d43f03d7e685492ee413 /core/fpdfdoc/doc_vt.h
parent8f0d0da1b12e29133fb48a778603c03bf0056124 (diff)
downloadpdfium-a354eb517429e10d84abff65e455f0c183fe58e0.tar.xz
Remove unneeded CPVT classes.
- CPVT_Size is the same as CFX_PointF - CPVT_FloatRange is unused. - CPVT_ArrayTemplate is just a wrapper for CFX_ArrayTemplate. Review-Url: https://codereview.chromium.org/1919283008
Diffstat (limited to 'core/fpdfdoc/doc_vt.h')
-rw-r--r--core/fpdfdoc/doc_vt.h103
1 files changed, 103 insertions, 0 deletions
diff --git a/core/fpdfdoc/doc_vt.h b/core/fpdfdoc/doc_vt.h
new file mode 100644
index 0000000000..09be92b8e7
--- /dev/null
+++ b/core/fpdfdoc/doc_vt.h
@@ -0,0 +1,103 @@
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef CORE_FPDFDOC_DOC_VT_H_
+#define CORE_FPDFDOC_DOC_VT_H_
+
+#include "core/fpdfdoc/cpvt_floatrect.h"
+#include "core/fpdfdoc/cpvt_lineinfo.h"
+#include "core/fpdfdoc/include/cpvt_wordrange.h"
+
+class CPDF_VariableText;
+
+struct CPVT_WordInfo;
+
+#define IsFloatZero(f) ((f) < 0.0001 && (f) > -0.0001)
+#define IsFloatBigger(fa, fb) ((fa) > (fb) && !IsFloatZero((fa) - (fb)))
+#define IsFloatSmaller(fa, fb) ((fa) < (fb) && !IsFloatZero((fa) - (fb)))
+#define IsFloatEqual(fa, fb) IsFloatZero((fa) - (fb))
+
+class CLine {
+ public:
+ CLine();
+ ~CLine();
+
+ CPVT_WordPlace GetBeginWordPlace() const;
+ CPVT_WordPlace GetEndWordPlace() const;
+ CPVT_WordPlace GetPrevWordPlace(const CPVT_WordPlace& place) const;
+ CPVT_WordPlace GetNextWordPlace(const CPVT_WordPlace& place) const;
+ CPVT_WordPlace LinePlace;
+ CPVT_LineInfo m_LineInfo;
+};
+
+class CLines {
+ public:
+ CLines() : m_nTotal(0) {}
+ ~CLines() { RemoveAll(); }
+
+ int32_t GetSize() const { return m_Lines.GetSize(); }
+ CLine* GetAt(int32_t nIndex) const { return m_Lines.GetAt(nIndex); }
+ void Empty() { m_nTotal = 0; }
+ void RemoveAll() {
+ for (int32_t i = 0, sz = GetSize(); i < sz; i++) {
+ delete GetAt(i);
+ }
+ m_Lines.RemoveAll();
+ m_nTotal = 0;
+ }
+ int32_t Add(const CPVT_LineInfo& lineinfo) {
+ if (m_nTotal >= GetSize()) {
+ CLine* pLine = new CLine;
+ pLine->m_LineInfo = lineinfo;
+ m_Lines.Add(pLine);
+ } else if (CLine* pLine = GetAt(m_nTotal)) {
+ pLine->m_LineInfo = lineinfo;
+ }
+ return m_nTotal++;
+ }
+ void Clear() {
+ for (int32_t i = GetSize() - 1; i >= m_nTotal; i--) {
+ delete GetAt(i);
+ m_Lines.RemoveAt(i);
+ }
+ }
+
+ private:
+ CFX_ArrayTemplate<CLine*> m_Lines;
+ int32_t m_nTotal;
+};
+
+class CPDF_EditContainer {
+ public:
+ CPDF_EditContainer();
+ virtual ~CPDF_EditContainer();
+
+ virtual const CFX_FloatRect& GetPlateRect() const { return m_rcPlate; }
+ virtual void SetPlateRect(const CFX_FloatRect& rect) { m_rcPlate = rect; }
+ virtual CFX_FloatRect GetContentRect() const { return m_rcContent; }
+ virtual void SetContentRect(const CPVT_FloatRect& rect) {
+ m_rcContent = rect;
+ }
+
+ FX_FLOAT GetPlateWidth() const { return m_rcPlate.right - m_rcPlate.left; }
+ FX_FLOAT GetPlateHeight() const { return m_rcPlate.top - m_rcPlate.bottom; }
+ CFX_FloatPoint GetBTPoint() const {
+ return CFX_FloatPoint(m_rcPlate.left, m_rcPlate.top);
+ }
+ CFX_FloatPoint InToOut(const CFX_FloatPoint& point) const {
+ return CFX_FloatPoint(point.x + GetBTPoint().x, GetBTPoint().y - point.y);
+ }
+ CFX_FloatPoint OutToIn(const CFX_FloatPoint& point) const {
+ return CFX_FloatPoint(point.x - GetBTPoint().x, GetBTPoint().y - point.y);
+ }
+ CFX_FloatRect InToOut(const CPVT_FloatRect& rect) const;
+
+ private:
+ CFX_FloatRect m_rcPlate;
+ CPVT_FloatRect m_rcContent;
+};
+
+#endif // CORE_FPDFDOC_DOC_VT_H_