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
CLine()9 CLine::CLine() {}
10
CLine(const CPVT_LineInfo & lineinfo)11 CLine::CLine(const CPVT_LineInfo& lineinfo) : m_LineInfo(lineinfo) {}
12
~CLine()13 CLine::~CLine() {}
14
GetBeginWordPlace() const15 CPVT_WordPlace CLine::GetBeginWordPlace() const {
16 return CPVT_WordPlace(LinePlace.nSecIndex, LinePlace.nLineIndex, -1);
17 }
18
GetEndWordPlace() const19 CPVT_WordPlace CLine::GetEndWordPlace() const {
20 return CPVT_WordPlace(LinePlace.nSecIndex, LinePlace.nLineIndex,
21 m_LineInfo.nEndWordIndex);
22 }
23
GetPrevWordPlace(const CPVT_WordPlace & place) const24 CPVT_WordPlace CLine::GetPrevWordPlace(const CPVT_WordPlace& place) const {
25 if (place.nWordIndex > m_LineInfo.nEndWordIndex) {
26 return CPVT_WordPlace(place.nSecIndex, place.nLineIndex,
27 m_LineInfo.nEndWordIndex);
28 }
29 return CPVT_WordPlace(place.nSecIndex, place.nLineIndex,
30 place.nWordIndex - 1);
31 }
32
GetNextWordPlace(const CPVT_WordPlace & place) const33 CPVT_WordPlace CLine::GetNextWordPlace(const CPVT_WordPlace& place) const {
34 if (place.nWordIndex < m_LineInfo.nBeginWordIndex) {
35 return CPVT_WordPlace(place.nSecIndex, place.nLineIndex,
36 m_LineInfo.nBeginWordIndex);
37 }
38 return CPVT_WordPlace(place.nSecIndex, place.nLineIndex,
39 place.nWordIndex + 1);
40 }
41