• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2017 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 "xfa/fgas/layout/cfx_breakpiece.h"
8 
9 #include "xfa/fgas/layout/cfx_textuserdata.h"
10 
CFX_BreakPiece()11 CFX_BreakPiece::CFX_BreakPiece()
12     : m_dwStatus(CFX_BreakType::Piece),
13       m_iStartPos(0),
14       m_iWidth(-1),
15       m_iStartChar(0),
16       m_iChars(0),
17       m_iBidiLevel(0),
18       m_iBidiPos(0),
19       m_iFontSize(0),
20       m_iHorizontalScale(100),
21       m_iVerticalScale(100),
22       m_dwIdentity(0),
23       m_dwCharStyles(0),
24       m_pChars(nullptr) {}
25 
26 CFX_BreakPiece::CFX_BreakPiece(const CFX_BreakPiece& other) = default;
27 
28 CFX_BreakPiece::~CFX_BreakPiece() = default;
29 
GetEndPos() const30 int32_t CFX_BreakPiece::GetEndPos() const {
31   return m_iWidth < 0 ? m_iStartPos : m_iStartPos + m_iWidth;
32 }
33 
GetChar(int32_t index) const34 CFX_Char* CFX_BreakPiece::GetChar(int32_t index) const {
35   ASSERT(index >= 0);
36   ASSERT(index < m_iChars);
37   ASSERT(m_pChars);
38   return &(*m_pChars)[m_iStartChar + index];
39 }
40 
GetString() const41 WideString CFX_BreakPiece::GetString() const {
42   WideString ret;
43   ret.Reserve(m_iChars);
44   for (int32_t i = m_iStartChar; i < m_iStartChar + m_iChars; i++)
45     ret += static_cast<wchar_t>((*m_pChars)[i].char_code());
46   return ret;
47 }
48 
GetWidths() const49 std::vector<int32_t> CFX_BreakPiece::GetWidths() const {
50   std::vector<int32_t> ret;
51   ret.reserve(m_iChars);
52   for (int32_t i = m_iStartChar; i < m_iStartChar + m_iChars; i++)
53     ret.push_back((*m_pChars)[i].m_iCharWidth);
54   return ret;
55 }
56