blob: d3fce06d6f5948c451af4c4fd9777a56304383ee (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
// Copyright 2017 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
#include "xfa/fgas/layout/cfx_breakline.h"
#include "third_party/base/stl_util.h"
CFX_BreakLine::CFX_BreakLine() : m_iStart(0), m_iWidth(0), m_iArabicChars(0) {}
CFX_BreakLine::~CFX_BreakLine() {}
int32_t CFX_BreakLine::CountChars() const {
return pdfium::CollectionSize<int32_t>(m_LineChars);
}
CFX_Char* CFX_BreakLine::GetChar(int32_t index) {
ASSERT(pdfium::IndexInBounds(m_LineChars, index));
return &m_LineChars[index];
}
const CFX_Char* CFX_BreakLine::GetChar(int32_t index) const {
ASSERT(pdfium::IndexInBounds(m_LineChars, index));
return &m_LineChars[index];
}
int32_t CFX_BreakLine::CountPieces() const {
return pdfium::CollectionSize<int32_t>(m_LinePieces);
}
const CFX_BreakPiece* CFX_BreakLine::GetPiece(int32_t index) const {
ASSERT(index >= 0 && index < CountPieces());
return &m_LinePieces[index];
}
void CFX_BreakLine::GetString(WideString& wsStr) const {
int32_t iCount = pdfium::CollectionSize<int32_t>(m_LineChars);
wchar_t* pBuf = wsStr.GetBuffer(iCount);
for (int32_t i = 0; i < iCount; i++)
*pBuf++ = static_cast<wchar_t>(m_LineChars[i].char_code());
wsStr.ReleaseBuffer(iCount);
}
int32_t CFX_BreakLine::GetLineEnd() const {
return m_iStart + m_iWidth;
}
void CFX_BreakLine::Clear() {
m_LineChars.clear();
m_LinePieces.clear();
m_iWidth = 0;
m_iArabicChars = 0;
}
|