| OLD | NEW |
| 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 FPDFSDK_INCLUDE_FXEDIT_FXET_EDIT_H_ | 7 #ifndef FPDFSDK_INCLUDE_FXEDIT_FXET_EDIT_H_ |
| 8 #define FPDFSDK_INCLUDE_FXEDIT_FXET_EDIT_H_ | 8 #define FPDFSDK_INCLUDE_FXEDIT_FXET_EDIT_H_ |
| 9 | 9 |
| 10 #include "../../../core/include/fpdfdoc/fpdf_vt.h" | 10 #include "../../../core/include/fpdfdoc/fpdf_vt.h" |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 | 108 |
| 109 void operator=(CFX_Edit_LineRectArray& rects) { | 109 void operator=(CFX_Edit_LineRectArray& rects) { |
| 110 Empty(); | 110 Empty(); |
| 111 for (int32_t i = 0, sz = rects.GetSize(); i < sz; i++) | 111 for (int32_t i = 0, sz = rects.GetSize(); i < sz; i++) |
| 112 m_LineRects.Add(rects.GetAt(i)); | 112 m_LineRects.Add(rects.GetAt(i)); |
| 113 | 113 |
| 114 rects.RemoveAll(); | 114 rects.RemoveAll(); |
| 115 } | 115 } |
| 116 | 116 |
| 117 void Add(const CPVT_WordRange& wrLine, const CPDF_Rect& rcLine) { | 117 void Add(const CPVT_WordRange& wrLine, const CPDF_Rect& rcLine) { |
| 118 if (CFX_Edit_LineRect* pRect = new CFX_Edit_LineRect(wrLine, rcLine)) | 118 m_LineRects.Add(new CFX_Edit_LineRect(wrLine, rcLine)); |
| 119 m_LineRects.Add(pRect); | |
| 120 } | 119 } |
| 121 | 120 |
| 122 int32_t GetSize() const { return m_LineRects.GetSize(); } | 121 int32_t GetSize() const { return m_LineRects.GetSize(); } |
| 123 | 122 |
| 124 CFX_Edit_LineRect* GetAt(int32_t nIndex) const { | 123 CFX_Edit_LineRect* GetAt(int32_t nIndex) const { |
| 125 if (nIndex < 0 || nIndex >= m_LineRects.GetSize()) | 124 if (nIndex < 0 || nIndex >= m_LineRects.GetSize()) |
| 126 return NULL; | 125 return NULL; |
| 127 | 126 |
| 128 return m_LineRects.GetAt(nIndex); | 127 return m_LineRects.GetAt(nIndex); |
| 129 } | 128 } |
| 130 | 129 |
| 131 CFX_ArrayTemplate<CFX_Edit_LineRect*> m_LineRects; | 130 CFX_ArrayTemplate<CFX_Edit_LineRect*> m_LineRects; |
| 132 }; | 131 }; |
| 133 | 132 |
| 134 class CFX_Edit_RectArray { | 133 class CFX_Edit_RectArray { |
| 135 public: | 134 public: |
| 136 CFX_Edit_RectArray() {} | 135 CFX_Edit_RectArray() {} |
| 137 | 136 |
| 138 virtual ~CFX_Edit_RectArray() { Empty(); } | 137 virtual ~CFX_Edit_RectArray() { Empty(); } |
| 139 | 138 |
| 140 void Empty() { | 139 void Empty() { |
| 141 for (int32_t i = 0, sz = m_Rects.GetSize(); i < sz; i++) | 140 for (int32_t i = 0, sz = m_Rects.GetSize(); i < sz; i++) |
| 142 delete m_Rects.GetAt(i); | 141 delete m_Rects.GetAt(i); |
| 143 | 142 |
| 144 m_Rects.RemoveAll(); | 143 m_Rects.RemoveAll(); |
| 145 } | 144 } |
| 146 | 145 |
| 147 void Add(const CPDF_Rect& rect) { | 146 void Add(const CPDF_Rect& rect) { |
| 148 // check for overlaped area | 147 // check for overlapped area |
| 149 for (int32_t i = 0, sz = m_Rects.GetSize(); i < sz; i++) | 148 for (int32_t i = 0, sz = m_Rects.GetSize(); i < sz; i++) { |
| 150 if (CPDF_Rect* pRect = m_Rects.GetAt(i)) | 149 CPDF_Rect* pRect = m_Rects.GetAt(i); |
| 151 if (pRect->Contains(rect)) | 150 if (pRect && pRect->Contains(rect)) |
| 152 return; | 151 return; |
| 152 } |
| 153 | 153 |
| 154 if (CPDF_Rect* pNewRect = new CPDF_Rect(rect)) | 154 m_Rects.Add(new CPDF_Rect(rect)); |
| 155 m_Rects.Add(pNewRect); | |
| 156 } | 155 } |
| 157 | 156 |
| 158 int32_t GetSize() const { return m_Rects.GetSize(); } | 157 int32_t GetSize() const { return m_Rects.GetSize(); } |
| 159 | 158 |
| 160 CPDF_Rect* GetAt(int32_t nIndex) const { | 159 CPDF_Rect* GetAt(int32_t nIndex) const { |
| 161 if (nIndex < 0 || nIndex >= m_Rects.GetSize()) | 160 if (nIndex < 0 || nIndex >= m_Rects.GetSize()) |
| 162 return NULL; | 161 return NULL; |
| 163 | 162 |
| 164 return m_Rects.GetAt(nIndex); | 163 return m_Rects.GetAt(nIndex); |
| 165 } | 164 } |
| (...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 814 int32_t GetTypeDescent(int32_t nFontIndex); | 813 int32_t GetTypeDescent(int32_t nFontIndex); |
| 815 int32_t GetWordFontIndex(FX_WORD word, int32_t charset, int32_t nFontIndex); | 814 int32_t GetWordFontIndex(FX_WORD word, int32_t charset, int32_t nFontIndex); |
| 816 int32_t GetDefaultFontIndex(); | 815 int32_t GetDefaultFontIndex(); |
| 817 FX_BOOL IsLatinWord(FX_WORD word); | 816 FX_BOOL IsLatinWord(FX_WORD word); |
| 818 | 817 |
| 819 private: | 818 private: |
| 820 IFX_Edit_FontMap* m_pFontMap; | 819 IFX_Edit_FontMap* m_pFontMap; |
| 821 }; | 820 }; |
| 822 | 821 |
| 823 #endif // FPDFSDK_INCLUDE_FXEDIT_FXET_EDIT_H_ | 822 #endif // FPDFSDK_INCLUDE_FXEDIT_FXET_EDIT_H_ |
| OLD | NEW |