Chromium Code Reviews| 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 CFX_Edit_LineRect* pRect = new CFX_Edit_LineRect(wrLine, rcLine); |
|
Tom Sepez
2015/08/12 22:20:37
nit: just m_LineRects.Add(new CFX_Edit_LineRect(wr
Lei Zhang
2015/08/13 22:23:57
Done.
| |
| 119 m_LineRects.Add(pRect); | 119 m_LineRects.Add(pRect); |
| 120 } | 120 } |
| 121 | 121 |
| 122 int32_t GetSize() const { return m_LineRects.GetSize(); } | 122 int32_t GetSize() const { return m_LineRects.GetSize(); } |
| 123 | 123 |
| 124 CFX_Edit_LineRect* GetAt(int32_t nIndex) const { | 124 CFX_Edit_LineRect* GetAt(int32_t nIndex) const { |
| 125 if (nIndex < 0 || nIndex >= m_LineRects.GetSize()) | 125 if (nIndex < 0 || nIndex >= m_LineRects.GetSize()) |
| 126 return NULL; | 126 return NULL; |
| 127 | 127 |
| 128 return m_LineRects.GetAt(nIndex); | 128 return m_LineRects.GetAt(nIndex); |
| 129 } | 129 } |
| 130 | 130 |
| 131 CFX_ArrayTemplate<CFX_Edit_LineRect*> m_LineRects; | 131 CFX_ArrayTemplate<CFX_Edit_LineRect*> m_LineRects; |
| 132 }; | 132 }; |
| 133 | 133 |
| 134 class CFX_Edit_RectArray { | 134 class CFX_Edit_RectArray { |
| 135 public: | 135 public: |
| 136 CFX_Edit_RectArray() {} | 136 CFX_Edit_RectArray() {} |
| 137 | 137 |
| 138 virtual ~CFX_Edit_RectArray() { Empty(); } | 138 virtual ~CFX_Edit_RectArray() { Empty(); } |
| 139 | 139 |
| 140 void Empty() { | 140 void Empty() { |
| 141 for (int32_t i = 0, sz = m_Rects.GetSize(); i < sz; i++) | 141 for (int32_t i = 0, sz = m_Rects.GetSize(); i < sz; i++) |
| 142 delete m_Rects.GetAt(i); | 142 delete m_Rects.GetAt(i); |
| 143 | 143 |
| 144 m_Rects.RemoveAll(); | 144 m_Rects.RemoveAll(); |
| 145 } | 145 } |
| 146 | 146 |
| 147 void Add(const CPDF_Rect& rect) { | 147 void Add(const CPDF_Rect& rect) { |
| 148 // check for overlaped area | 148 // check for overlapped area |
| 149 for (int32_t i = 0, sz = m_Rects.GetSize(); i < sz; i++) | 149 for (int32_t i = 0, sz = m_Rects.GetSize(); i < sz; i++) { |
| 150 if (CPDF_Rect* pRect = m_Rects.GetAt(i)) | 150 CPDF_Rect* pRect = m_Rects.GetAt(i); |
| 151 if (pRect->Contains(rect)) | 151 if (pRect && pRect->Contains(rect)) |
| 152 return; | 152 return; |
| 153 } | |
| 153 | 154 |
| 154 if (CPDF_Rect* pNewRect = new CPDF_Rect(rect)) | 155 CPDF_Rect* pNewRect = new CPDF_Rect(rect); |
| 155 m_Rects.Add(pNewRect); | 156 m_Rects.Add(pNewRect); |
|
Tom Sepez
2015/08/12 22:20:37
nit: just m_Rects.Add(new CPDF_Rect(rect));
Lei Zhang
2015/08/13 22:23:57
Done.
| |
| 156 } | 157 } |
| 157 | 158 |
| 158 int32_t GetSize() const { return m_Rects.GetSize(); } | 159 int32_t GetSize() const { return m_Rects.GetSize(); } |
| 159 | 160 |
| 160 CPDF_Rect* GetAt(int32_t nIndex) const { | 161 CPDF_Rect* GetAt(int32_t nIndex) const { |
| 161 if (nIndex < 0 || nIndex >= m_Rects.GetSize()) | 162 if (nIndex < 0 || nIndex >= m_Rects.GetSize()) |
| 162 return NULL; | 163 return NULL; |
| 163 | 164 |
| 164 return m_Rects.GetAt(nIndex); | 165 return m_Rects.GetAt(nIndex); |
| 165 } | 166 } |
| (...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 814 int32_t GetTypeDescent(int32_t nFontIndex); | 815 int32_t GetTypeDescent(int32_t nFontIndex); |
| 815 int32_t GetWordFontIndex(FX_WORD word, int32_t charset, int32_t nFontIndex); | 816 int32_t GetWordFontIndex(FX_WORD word, int32_t charset, int32_t nFontIndex); |
| 816 int32_t GetDefaultFontIndex(); | 817 int32_t GetDefaultFontIndex(); |
| 817 FX_BOOL IsLatinWord(FX_WORD word); | 818 FX_BOOL IsLatinWord(FX_WORD word); |
| 818 | 819 |
| 819 private: | 820 private: |
| 820 IFX_Edit_FontMap* m_pFontMap; | 821 IFX_Edit_FontMap* m_pFontMap; |
| 821 }; | 822 }; |
| 822 | 823 |
| 823 #endif // FPDFSDK_INCLUDE_FXEDIT_FXET_EDIT_H_ | 824 #endif // FPDFSDK_INCLUDE_FXEDIT_FXET_EDIT_H_ |
| OLD | NEW |