summaryrefslogtreecommitdiff
path: root/xfa/fgas/layout/cfx_breakpiece.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fgas/layout/cfx_breakpiece.cpp')
-rw-r--r--xfa/fgas/layout/cfx_breakpiece.cpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/xfa/fgas/layout/cfx_breakpiece.cpp b/xfa/fgas/layout/cfx_breakpiece.cpp
new file mode 100644
index 0000000000..d31c53f964
--- /dev/null
+++ b/xfa/fgas/layout/cfx_breakpiece.cpp
@@ -0,0 +1,53 @@
+// 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_breakpiece.h"
+
+CFX_BreakPiece::CFX_BreakPiece()
+ : m_dwStatus(CFX_BreakType::Piece),
+ m_iStartPos(0),
+ m_iWidth(-1),
+ m_iStartChar(0),
+ m_iChars(0),
+ m_iBidiLevel(0),
+ m_iBidiPos(0),
+ m_iFontSize(0),
+ m_iFontHeight(0),
+ m_iHorizontalScale(100),
+ m_iVerticalScale(100),
+ m_dwIdentity(0),
+ m_dwCharStyles(0),
+ m_pChars(nullptr),
+ m_pUserData(nullptr) {}
+
+CFX_BreakPiece::CFX_BreakPiece(const CFX_BreakPiece& other) = default;
+
+CFX_BreakPiece::~CFX_BreakPiece() = default;
+
+int32_t CFX_BreakPiece::GetEndPos() const {
+ return m_iWidth < 0 ? m_iStartPos : m_iStartPos + m_iWidth;
+}
+
+CFX_Char* CFX_BreakPiece::GetChar(int32_t index) const {
+ ASSERT(index >= 0 && index < m_iChars && m_pChars);
+ return &(*m_pChars)[m_iStartChar + index];
+}
+
+CFX_WideString CFX_BreakPiece::GetString() const {
+ CFX_WideString ret;
+ ret.Reserve(m_iChars);
+ for (int32_t i = m_iStartChar; i < m_iStartChar + m_iChars; i++)
+ ret += static_cast<FX_WCHAR>((*m_pChars)[i].m_wCharCode);
+ return ret;
+}
+
+std::vector<int32_t> CFX_BreakPiece::GetWidths() const {
+ std::vector<int32_t> ret;
+ ret.reserve(m_iChars);
+ for (int32_t i = m_iStartChar; i < m_iStartChar + m_iChars; i++)
+ ret.push_back((*m_pChars)[i].m_iCharWidth);
+ return ret;
+}