OLD | NEW |
1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 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 #include "core/fpdfdoc/csection.h" | 7 #include "core/fpdfdoc/csection.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 } | 142 } |
143 } else { | 143 } else { |
144 break; | 144 break; |
145 } | 145 } |
146 } | 146 } |
147 } | 147 } |
148 | 148 |
149 CPVT_WordPlace CSection::SearchWordPlace(const CFX_FloatPoint& point) const { | 149 CPVT_WordPlace CSection::SearchWordPlace(const CFX_FloatPoint& point) const { |
150 ASSERT(m_pVT); | 150 ASSERT(m_pVT); |
151 CPVT_WordPlace place = GetBeginWordPlace(); | 151 CPVT_WordPlace place = GetBeginWordPlace(); |
152 FX_BOOL bUp = TRUE; | 152 bool bUp = true; |
153 FX_BOOL bDown = TRUE; | 153 bool bDown = true; |
154 int32_t nLeft = 0; | 154 int32_t nLeft = 0; |
155 int32_t nRight = m_LineArray.GetSize() - 1; | 155 int32_t nRight = m_LineArray.GetSize() - 1; |
156 int32_t nMid = m_LineArray.GetSize() / 2; | 156 int32_t nMid = m_LineArray.GetSize() / 2; |
157 FX_FLOAT fTop = 0; | 157 FX_FLOAT fTop = 0; |
158 FX_FLOAT fBottom = 0; | 158 FX_FLOAT fBottom = 0; |
159 while (nLeft <= nRight) { | 159 while (nLeft <= nRight) { |
160 if (CLine* pLine = m_LineArray.GetAt(nMid)) { | 160 if (CLine* pLine = m_LineArray.GetAt(nMid)) { |
161 fTop = pLine->m_LineInfo.fLineY - pLine->m_LineInfo.fLineAscent - | 161 fTop = pLine->m_LineInfo.fLineY - pLine->m_LineInfo.fLineAscent - |
162 m_pVT->GetLineLeading(m_SecInfo); | 162 m_pVT->GetLineLeading(m_SecInfo); |
163 fBottom = pLine->m_LineInfo.fLineY - pLine->m_LineInfo.fLineDescent; | 163 fBottom = pLine->m_LineInfo.fLineY - pLine->m_LineInfo.fLineDescent; |
164 if (IsFloatBigger(point.y, fTop)) { | 164 if (IsFloatBigger(point.y, fTop)) { |
165 bUp = FALSE; | 165 bUp = false; |
166 } | 166 } |
167 if (IsFloatSmaller(point.y, fBottom)) { | 167 if (IsFloatSmaller(point.y, fBottom)) { |
168 bDown = FALSE; | 168 bDown = false; |
169 } | 169 } |
170 if (IsFloatSmaller(point.y, fTop)) { | 170 if (IsFloatSmaller(point.y, fTop)) { |
171 nRight = nMid - 1; | 171 nRight = nMid - 1; |
172 nMid = (nLeft + nRight) / 2; | 172 nMid = (nLeft + nRight) / 2; |
173 continue; | 173 continue; |
174 } else if (IsFloatBigger(point.y, fBottom)) { | 174 } else if (IsFloatBigger(point.y, fBottom)) { |
175 nLeft = nMid + 1; | 175 nLeft = nMid + 1; |
176 nMid = (nLeft + nRight) / 2; | 176 nMid = (nLeft + nRight) / 2; |
177 continue; | 177 continue; |
178 } else { | 178 } else { |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 ClearLeftWords(PlaceRange.EndPos.nWordIndex); | 282 ClearLeftWords(PlaceRange.EndPos.nWordIndex); |
283 } else { | 283 } else { |
284 ResetWordArray(); | 284 ResetWordArray(); |
285 } | 285 } |
286 } | 286 } |
287 | 287 |
288 void CSection::ClearWord(const CPVT_WordPlace& place) { | 288 void CSection::ClearWord(const CPVT_WordPlace& place) { |
289 delete m_WordArray.GetAt(place.nWordIndex); | 289 delete m_WordArray.GetAt(place.nWordIndex); |
290 m_WordArray.RemoveAt(place.nWordIndex); | 290 m_WordArray.RemoveAt(place.nWordIndex); |
291 } | 291 } |
OLD | NEW |