Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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/clines.h" | |
| 8 | |
| 9 CLines::CLines() : m_nTotal(0) {} | |
| 10 | |
| 11 CLines::~CLines() { | |
| 12 RemoveAll(); | |
| 13 } | |
| 14 | |
| 15 int32_t CLines::GetSize() const { | |
| 16 return m_Lines.GetSize(); | |
| 17 } | |
| 18 | |
| 19 CLine* CLines::GetAt(int32_t nIndex) const { | |
| 20 return m_Lines.GetAt(nIndex); | |
| 21 } | |
| 22 | |
| 23 void CLines::Empty() { | |
| 24 m_nTotal = 0; | |
| 25 } | |
| 26 | |
| 27 void CLines::RemoveAll() { | |
| 28 for (int32_t i = 0, sz = GetSize(); i < sz; i++) { | |
| 29 delete GetAt(i); | |
| 30 } | |
|
dsinclair
2016/06/14 20:12:48
nit: no {}'s
Wei Li
2016/06/14 22:00:54
Done.
| |
| 31 m_Lines.RemoveAll(); | |
| 32 m_nTotal = 0; | |
| 33 } | |
| 34 | |
| 35 int32_t CLines::Add(const CPVT_LineInfo& lineinfo) { | |
| 36 if (m_nTotal >= GetSize()) { | |
| 37 CLine* pLine = new CLine; | |
| 38 pLine->m_LineInfo = lineinfo; | |
| 39 m_Lines.Add(pLine); | |
| 40 } else if (CLine* pLine = GetAt(m_nTotal)) { | |
| 41 pLine->m_LineInfo = lineinfo; | |
| 42 } | |
| 43 return m_nTotal++; | |
| 44 } | |
| 45 | |
| 46 void CLines::Clear() { | |
| 47 for (int32_t i = GetSize() - 1; i >= m_nTotal; i--) { | |
| 48 delete GetAt(i); | |
| 49 m_Lines.RemoveAt(i); | |
| 50 } | |
| 51 } | |
| OLD | NEW |