diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2017-03-13 15:32:07 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-03-14 14:13:24 +0000 |
commit | 893822aa5b6254591f8e80fbffcbb4fa6ad849aa (patch) | |
tree | 74e20ab6378d515c12a1ec9b9fc70d8e309b361b /xfa/fgas/layout/cfx_breakpiece.cpp | |
parent | 80e370c7d8b6541f59d98b6cbfbaae51f7e139da (diff) | |
download | pdfium-893822aa5b6254591f8e80fbffcbb4fa6ad849aa.tar.xz |
Merge text breaking helper classes.
This Cl merges the CFX_TxtPiece and CFX_RTFPiece classes into
CFX_BreakPiece. CFX_TxtLine and CFX_RTFLine into CFX_BreakLine and
CFX_TxtChar and CFX_RTFChar into CFX_Char.
Change-Id: I95421bdf4cafd5e394db9238dea3603ccb8349c3
Reviewed-on: https://pdfium-review.googlesource.com/2966
Reviewed-by: Nicolás Peña <npm@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fgas/layout/cfx_breakpiece.cpp')
-rw-r--r-- | xfa/fgas/layout/cfx_breakpiece.cpp | 53 |
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; +} |