summaryrefslogtreecommitdiff
path: root/xfa/fgas/layout/cfx_breakline.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-03-13 15:32:07 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-03-14 14:13:24 +0000
commit893822aa5b6254591f8e80fbffcbb4fa6ad849aa (patch)
tree74e20ab6378d515c12a1ec9b9fc70d8e309b361b /xfa/fgas/layout/cfx_breakline.cpp
parent80e370c7d8b6541f59d98b6cbfbaae51f7e139da (diff)
downloadpdfium-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_breakline.cpp')
-rw-r--r--xfa/fgas/layout/cfx_breakline.cpp55
1 files changed, 55 insertions, 0 deletions
diff --git a/xfa/fgas/layout/cfx_breakline.cpp b/xfa/fgas/layout/cfx_breakline.cpp
new file mode 100644
index 0000000000..4e9d8ad5ae
--- /dev/null
+++ b/xfa/fgas/layout/cfx_breakline.cpp
@@ -0,0 +1,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(index >= 0 && index < pdfium::CollectionSize<int32_t>(m_LineChars));
+ return &m_LineChars[index];
+}
+
+const CFX_Char* CFX_BreakLine::GetChar(int32_t index) const {
+ ASSERT(index >= 0 && index < pdfium::CollectionSize<int32_t>(m_LineChars));
+ 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(CFX_WideString& wsStr) const {
+ int32_t iCount = pdfium::CollectionSize<int32_t>(m_LineChars);
+ FX_WCHAR* pBuf = wsStr.GetBuffer(iCount);
+ for (int32_t i = 0; i < iCount; i++)
+ *pBuf++ = static_cast<FX_WCHAR>(m_LineChars[i].m_wCharCode);
+ 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;
+}