Philip P. Moltmann | 4d3acf4 | 2017-03-20 11:05:52 -0700 | [diff] [blame] | 1 | // Copyright 2016 PDFium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | |
| 7 | #include "core/fpdfdoc/cline.h" |
| 8 | |
Philip P. Moltmann | d904c1e | 2018-03-19 09:26:45 -0700 | [diff] [blame] | 9 | CLine::CLine(const CPVT_LineInfo& lineinfo) : m_LineInfo(lineinfo) {} |
| 10 | |
Haibo Huang | 49cc930 | 2020-04-27 16:14:24 -0700 | [diff] [blame] | 11 | CLine::~CLine() = default; |
Philip P. Moltmann | 4d3acf4 | 2017-03-20 11:05:52 -0700 | [diff] [blame] | 12 | |
| 13 | CPVT_WordPlace CLine::GetBeginWordPlace() const { |
| 14 | return CPVT_WordPlace(LinePlace.nSecIndex, LinePlace.nLineIndex, -1); |
| 15 | } |
| 16 | |
| 17 | CPVT_WordPlace CLine::GetEndWordPlace() const { |
| 18 | return CPVT_WordPlace(LinePlace.nSecIndex, LinePlace.nLineIndex, |
| 19 | m_LineInfo.nEndWordIndex); |
| 20 | } |
| 21 | |
| 22 | CPVT_WordPlace CLine::GetPrevWordPlace(const CPVT_WordPlace& place) const { |
| 23 | if (place.nWordIndex > m_LineInfo.nEndWordIndex) { |
| 24 | return CPVT_WordPlace(place.nSecIndex, place.nLineIndex, |
| 25 | m_LineInfo.nEndWordIndex); |
| 26 | } |
| 27 | return CPVT_WordPlace(place.nSecIndex, place.nLineIndex, |
| 28 | place.nWordIndex - 1); |
| 29 | } |
| 30 | |
| 31 | CPVT_WordPlace CLine::GetNextWordPlace(const CPVT_WordPlace& place) const { |
| 32 | if (place.nWordIndex < m_LineInfo.nBeginWordIndex) { |
| 33 | return CPVT_WordPlace(place.nSecIndex, place.nLineIndex, |
| 34 | m_LineInfo.nBeginWordIndex); |
| 35 | } |
| 36 | return CPVT_WordPlace(place.nSecIndex, place.nLineIndex, |
| 37 | place.nWordIndex + 1); |
| 38 | } |