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 9 CLine::CLine() {} 10 11 CLine::CLine(const CPVT_LineInfo& lineinfo) : m_LineInfo(lineinfo) {} 12 13 CLine::~CLine() {} 14 15 CPVT_WordPlace CLine::GetBeginWordPlace() const { 16 return CPVT_WordPlace(LinePlace.nSecIndex, LinePlace.nLineIndex, -1); 17 } 18 19 CPVT_WordPlace CLine::GetEndWordPlace() const { 20 return CPVT_WordPlace(LinePlace.nSecIndex, LinePlace.nLineIndex, 21 m_LineInfo.nEndWordIndex); 22 } 23 24 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 33 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