summaryrefslogtreecommitdiff
path: root/xfa/fgas
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fgas')
-rw-r--r--xfa/fgas/layout/cfx_breakline.cpp55
-rw-r--r--xfa/fgas/layout/cfx_breakline.h39
-rw-r--r--xfa/fgas/layout/cfx_breakpiece.cpp53
-rw-r--r--xfa/fgas/layout/cfx_breakpiece.h46
-rw-r--r--xfa/fgas/layout/fgas_rtfbreak.cpp118
-rw-r--r--xfa/fgas/layout/fgas_rtfbreak.h104
-rw-r--r--xfa/fgas/layout/fgas_textbreak.cpp105
-rw-r--r--xfa/fgas/layout/fgas_textbreak.h121
8 files changed, 312 insertions, 329 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;
+}
diff --git a/xfa/fgas/layout/cfx_breakline.h b/xfa/fgas/layout/cfx_breakline.h
new file mode 100644
index 0000000000..138ee3104e
--- /dev/null
+++ b/xfa/fgas/layout/cfx_breakline.h
@@ -0,0 +1,39 @@
+// 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
+
+#ifndef XFA_FGAS_LAYOUT_CFX_BREAKLINE_H_
+#define XFA_FGAS_LAYOUT_CFX_BREAKLINE_H_
+
+#include <vector>
+
+#include "core/fxcrt/cfx_char.h"
+#include "xfa/fgas/layout/cfx_breakpiece.h"
+
+class CFX_BreakLine {
+ public:
+ CFX_BreakLine();
+ ~CFX_BreakLine();
+
+ int32_t CountChars() const;
+ CFX_Char* GetChar(int32_t index);
+ const CFX_Char* GetChar(int32_t index) const;
+
+ int32_t CountPieces() const;
+ const CFX_BreakPiece* GetPiece(int32_t index) const;
+
+ void GetString(CFX_WideString& wsStr) const;
+ int32_t GetLineEnd() const;
+
+ void Clear();
+
+ std::vector<CFX_Char> m_LineChars;
+ std::vector<CFX_BreakPiece> m_LinePieces;
+ int32_t m_iStart;
+ int32_t m_iWidth;
+ int32_t m_iArabicChars;
+};
+
+#endif // XFA_FGAS_LAYOUT_CFX_BREAKLINE_H_
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;
+}
diff --git a/xfa/fgas/layout/cfx_breakpiece.h b/xfa/fgas/layout/cfx_breakpiece.h
new file mode 100644
index 0000000000..64622b25c1
--- /dev/null
+++ b/xfa/fgas/layout/cfx_breakpiece.h
@@ -0,0 +1,46 @@
+// 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
+
+#ifndef XFA_FGAS_LAYOUT_CFX_BREAKPIECE_H_
+#define XFA_FGAS_LAYOUT_CFX_BREAKPIECE_H_
+
+#include <vector>
+
+#include "core/fxcrt/cfx_char.h"
+#include "core/fxcrt/cfx_retain_ptr.h"
+#include "core/fxcrt/fx_string.h"
+
+class CFX_BreakPiece {
+ public:
+ CFX_BreakPiece();
+ CFX_BreakPiece(const CFX_BreakPiece& other);
+ ~CFX_BreakPiece();
+
+ int32_t GetEndPos() const;
+ int32_t GetLength() const { return m_iChars; }
+
+ CFX_Char* GetChar(int32_t index) const;
+ CFX_WideString GetString() const;
+ std::vector<int32_t> GetWidths() const;
+
+ CFX_BreakType m_dwStatus;
+ int32_t m_iStartPos;
+ int32_t m_iWidth;
+ int32_t m_iStartChar;
+ int32_t m_iChars;
+ int32_t m_iBidiLevel;
+ int32_t m_iBidiPos;
+ int32_t m_iFontSize;
+ int32_t m_iFontHeight;
+ int32_t m_iHorizontalScale;
+ int32_t m_iVerticalScale;
+ uint32_t m_dwIdentity;
+ uint32_t m_dwCharStyles;
+ std::vector<CFX_Char>* m_pChars; // not owned.
+ CFX_RetainPtr<CFX_Retainable> m_pUserData;
+};
+
+#endif // XFA_FGAS_LAYOUT_CFX_BREAKPIECE_H_
diff --git a/xfa/fgas/layout/fgas_rtfbreak.cpp b/xfa/fgas/layout/fgas_rtfbreak.cpp
index c725dfb268..85edaf7f99 100644
--- a/xfa/fgas/layout/fgas_rtfbreak.cpp
+++ b/xfa/fgas/layout/fgas_rtfbreak.cpp
@@ -148,20 +148,20 @@ void CFX_RTFBreak::SetBreakStatus() {
if (iCount < 1)
return;
- CFX_RTFChar& tc = m_pCurLine->GetChar(iCount - 1);
- if (tc.m_dwStatus == CFX_BreakType::None)
- tc.m_dwStatus = CFX_BreakType::Piece;
+ CFX_Char* tc = m_pCurLine->GetChar(iCount - 1);
+ if (tc->m_dwStatus == CFX_BreakType::None)
+ tc->m_dwStatus = CFX_BreakType::Piece;
}
-CFX_RTFChar* CFX_RTFBreak::GetLastChar(int32_t index) const {
- std::vector<CFX_RTFChar>& tca = m_pCurLine->m_LineChars;
+CFX_Char* CFX_RTFBreak::GetLastChar(int32_t index) const {
+ std::vector<CFX_Char>& tca = m_pCurLine->m_LineChars;
int32_t iCount = pdfium::CollectionSize<int32_t>(tca);
if (index < 0 || index >= iCount)
return nullptr;
int32_t iStart = iCount - 1;
while (iStart > -1) {
- CFX_RTFChar* pTC = &tca[iStart--];
+ CFX_Char* pTC = &tca[iStart--];
if (pTC->m_iCharWidth >= 0 ||
pTC->GetCharType() != FX_CHARTYPE_Combination) {
if (--index < 0)
@@ -197,7 +197,7 @@ CFX_BreakType CFX_RTFBreak::AppendChar(FX_WCHAR wch) {
FX_CHARTYPE chartype = GetCharTypeFromProp(dwProps);
m_pCurLine->m_LineChars.emplace_back();
- CFX_RTFChar* pCurChar = &m_pCurLine->m_LineChars.back();
+ CFX_Char* pCurChar = &m_pCurLine->m_LineChars.back();
pCurChar->m_dwStatus = CFX_BreakType::None;
pCurChar->m_wCharCode = wch;
pCurChar->m_dwCharProps = dwProps;
@@ -253,14 +253,14 @@ CFX_BreakType CFX_RTFBreak::AppendChar(FX_WCHAR wch) {
return std::max(dwRet1, dwRet2);
}
-void CFX_RTFBreak::AppendChar_Combination(CFX_RTFChar* pCurChar) {
+void CFX_RTFBreak::AppendChar_Combination(CFX_Char* pCurChar) {
int32_t iCharWidth = 0;
if (!m_pFont->GetCharWidth(pCurChar->m_wCharCode, iCharWidth, false))
iCharWidth = 0;
iCharWidth *= m_iFontSize;
iCharWidth = iCharWidth * m_iHorizontalScale / 100;
- CFX_RTFChar* pLastChar = GetLastChar(0);
+ CFX_Char* pLastChar = GetLastChar(0);
if (pLastChar && pLastChar->GetCharType() > FX_CHARTYPE_Combination)
iCharWidth = -iCharWidth;
else
@@ -271,7 +271,7 @@ void CFX_RTFBreak::AppendChar_Combination(CFX_RTFChar* pCurChar) {
m_pCurLine->m_iWidth += iCharWidth;
}
-void CFX_RTFBreak::AppendChar_Tab(CFX_RTFChar* pCurChar) {
+void CFX_RTFBreak::AppendChar_Tab(CFX_Char* pCurChar) {
if (!(m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_ExpandTab))
return;
@@ -286,7 +286,7 @@ void CFX_RTFBreak::AppendChar_Tab(CFX_RTFChar* pCurChar) {
iLineWidth += iCharWidth;
}
-CFX_BreakType CFX_RTFBreak::AppendChar_Control(CFX_RTFChar* pCurChar) {
+CFX_BreakType CFX_RTFBreak::AppendChar_Control(CFX_Char* pCurChar) {
CFX_BreakType dwRet2 = CFX_BreakType::None;
switch (pCurChar->m_wCharCode) {
case L'\v':
@@ -310,8 +310,8 @@ CFX_BreakType CFX_RTFBreak::AppendChar_Control(CFX_RTFChar* pCurChar) {
return dwRet2;
}
-CFX_BreakType CFX_RTFBreak::AppendChar_Arabic(CFX_RTFChar* pCurChar) {
- CFX_RTFChar* pLastChar = nullptr;
+CFX_BreakType CFX_RTFBreak::AppendChar_Arabic(CFX_Char* pCurChar) {
+ CFX_Char* pLastChar = nullptr;
int32_t iCharWidth = 0;
FX_WCHAR wForm;
bool bAlef = false;
@@ -320,7 +320,7 @@ CFX_BreakType CFX_RTFBreak::AppendChar_Arabic(CFX_RTFChar* pCurChar) {
pLastChar = GetLastChar(1);
if (pLastChar) {
m_pCurLine->m_iWidth -= pLastChar->m_iCharWidth;
- CFX_RTFChar* pPrevChar = GetLastChar(2);
+ CFX_Char* pPrevChar = GetLastChar(2);
wForm = pdfium::arabic::GetFormChar(pLastChar, pPrevChar, pCurChar);
bAlef = (wForm == 0xFEFF &&
pLastChar->GetCharType() == FX_CHARTYPE_ArabicAlef);
@@ -355,7 +355,7 @@ CFX_BreakType CFX_RTFBreak::AppendChar_Arabic(CFX_RTFChar* pCurChar) {
return CFX_BreakType::None;
}
-CFX_BreakType CFX_RTFBreak::AppendChar_Others(CFX_RTFChar* pCurChar) {
+CFX_BreakType CFX_RTFBreak::AppendChar_Others(CFX_Char* pCurChar) {
FX_CHARTYPE chartype = pCurChar->GetCharType();
FX_WCHAR wForm = pCurChar->m_wCharCode;
int32_t iCharWidth = 0;
@@ -398,13 +398,13 @@ CFX_BreakType CFX_RTFBreak::EndBreak(CFX_BreakType dwStatus) {
if (iCount < 1)
return CFX_BreakType::None;
- CFX_RTFChar& tc = m_pCurLine->GetChar(iCount - 1);
- tc.m_dwStatus = dwStatus;
+ CFX_Char* tc = m_pCurLine->GetChar(iCount - 1);
+ tc->m_dwStatus = dwStatus;
if (dwStatus == CFX_BreakType::Piece)
return dwStatus;
m_iReadyLineIndex = m_pCurLine == &m_RTFLine[0] ? 0 : 1;
- CFX_RTFLine* pNextLine = &m_RTFLine[1 - m_iReadyLineIndex];
+ CFX_BreakLine* pNextLine = &m_RTFLine[1 - m_iReadyLineIndex];
bool bAllChars = m_iAlignment == CFX_RTFLineAlignment::Justified ||
m_iAlignment == CFX_RTFLineAlignment::Distributed;
@@ -417,18 +417,18 @@ CFX_BreakType CFX_RTFBreak::EndBreak(CFX_BreakType dwStatus) {
m_pCurLine = pNextLine;
m_pCurLine->m_iStart = m_iBoundaryStart;
- CFX_RTFChar* pTC = GetLastChar(0);
+ CFX_Char* pTC = GetLastChar(0);
m_eCharType = pTC ? pTC->GetCharType() : FX_CHARTYPE_Unknown;
return dwStatus;
}
-bool CFX_RTFBreak::EndBreak_SplitLine(CFX_RTFLine* pNextLine,
+bool CFX_RTFBreak::EndBreak_SplitLine(CFX_BreakLine* pNextLine,
bool bAllChars,
CFX_BreakType dwStatus) {
bool bDone = false;
if (m_pCurLine->GetLineEnd() > m_iBoundaryEnd + m_iTolerance) {
- const CFX_RTFChar& tc = m_pCurLine->GetChar(m_pCurLine->CountChars() - 1);
- switch (tc.GetCharType()) {
+ const CFX_Char* tc = m_pCurLine->GetChar(m_pCurLine->CountChars() - 1);
+ switch (tc->GetCharType()) {
case FX_CHARTYPE_Tab:
case FX_CHARTYPE_Control:
case FX_CHARTYPE_Space:
@@ -448,15 +448,15 @@ bool CFX_RTFBreak::EndBreak_SplitLine(CFX_RTFLine* pNextLine,
return false;
}
- const CFX_RTFChar* pCurChars = m_pCurLine->m_LineChars.data();
- CFX_RTFPiece tp;
+ const CFX_Char* pCurChars = m_pCurLine->m_LineChars.data();
+ CFX_BreakPiece tp;
tp.m_pChars = &m_pCurLine->m_LineChars;
bool bNew = true;
uint32_t dwIdentity = static_cast<uint32_t>(-1);
int32_t iLast = m_pCurLine->CountChars() - 1;
int32_t j = 0;
for (int32_t i = 0; i <= iLast;) {
- const CFX_RTFChar* pTC = pCurChars + i;
+ const CFX_Char* pTC = pCurChars + i;
if (bNew) {
tp.m_iStartChar = i;
tp.m_iStartPos += tp.m_iWidth;
@@ -494,8 +494,8 @@ bool CFX_RTFBreak::EndBreak_SplitLine(CFX_RTFLine* pNextLine,
void CFX_RTFBreak::EndBreak_BidiLine(std::deque<FX_TPO>* tpos,
CFX_BreakType dwStatus) {
- CFX_RTFChar* pTC;
- std::vector<CFX_RTFChar>& chars = m_pCurLine->m_LineChars;
+ CFX_Char* pTC;
+ std::vector<CFX_Char>& chars = m_pCurLine->m_LineChars;
int32_t iCount = m_pCurLine->CountChars();
if (!m_bPagination && m_pCurLine->m_iArabicChars > 0) {
int32_t iBidiNum = 0;
@@ -517,7 +517,7 @@ void CFX_RTFBreak::EndBreak_BidiLine(std::deque<FX_TPO>* tpos,
}
}
- CFX_RTFPiece tp;
+ CFX_BreakPiece tp;
tp.m_dwStatus = CFX_BreakType::Piece;
tp.m_iStartPos = m_pCurLine->m_iStart;
tp.m_pChars = &chars;
@@ -577,7 +577,7 @@ void CFX_RTFBreak::EndBreak_BidiLine(std::deque<FX_TPO>* tpos,
std::sort(tpos->begin(), tpos->end());
int32_t iStartPos = m_pCurLine->m_iStart;
for (const auto& it : *tpos) {
- CFX_RTFPiece& ttp = m_pCurLine->m_LinePieces[it.index];
+ CFX_BreakPiece& ttp = m_pCurLine->m_LinePieces[it.index];
ttp.m_iStartPos = iStartPos;
iStartPos += ttp.m_iWidth;
}
@@ -590,23 +590,23 @@ void CFX_RTFBreak::EndBreak_Alignment(const std::deque<FX_TPO>& tpos,
int32_t iGapChars = 0;
bool bFind = false;
for (auto it = tpos.rbegin(); it != tpos.rend(); it++) {
- CFX_RTFPiece& ttp = m_pCurLine->m_LinePieces[it->index];
+ CFX_BreakPiece& ttp = m_pCurLine->m_LinePieces[it->index];
if (!bFind)
iNetWidth = ttp.GetEndPos();
bool bArabic = FX_IsOdd(ttp.m_iBidiLevel);
int32_t j = bArabic ? 0 : ttp.m_iChars - 1;
while (j > -1 && j < ttp.m_iChars) {
- const CFX_RTFChar& tc = ttp.GetChar(j);
- if (tc.m_nBreakType == FX_LBT_DIRECT_BRK)
+ const CFX_Char* tc = ttp.GetChar(j);
+ if (tc->m_nBreakType == FX_LBT_DIRECT_BRK)
++iGapChars;
if (!bFind || !bAllChars) {
- uint32_t dwCharType = tc.GetCharType();
+ uint32_t dwCharType = tc->GetCharType();
if (dwCharType == FX_CHARTYPE_Space ||
dwCharType == FX_CHARTYPE_Control) {
if (!bFind) {
- int32_t iCharWidth = tc.m_iCharWidth;
+ int32_t iCharWidth = tc->m_iCharWidth;
if (bAllChars && iCharWidth > 0)
iNetWidth -= iCharWidth;
}
@@ -628,19 +628,19 @@ void CFX_RTFBreak::EndBreak_Alignment(const std::deque<FX_TPO>& tpos,
dwStatus != CFX_BreakType::Paragraph))) {
int32_t iStart = -1;
for (const auto& tpo : tpos) {
- CFX_RTFPiece& ttp = m_pCurLine->m_LinePieces[tpo.index];
+ CFX_BreakPiece& ttp = m_pCurLine->m_LinePieces[tpo.index];
if (iStart < 0)
iStart = ttp.m_iStartPos;
else
ttp.m_iStartPos = iStart;
for (int32_t j = 0; j < ttp.m_iChars; ++j) {
- CFX_RTFChar& tc = ttp.GetChar(j);
- if (tc.m_nBreakType != FX_LBT_DIRECT_BRK || tc.m_iCharWidth < 0)
+ CFX_Char* tc = ttp.GetChar(j);
+ if (tc->m_nBreakType != FX_LBT_DIRECT_BRK || tc->m_iCharWidth < 0)
continue;
int32_t k = iOffset / iGapChars;
- tc.m_iCharWidth += k;
+ tc->m_iCharWidth += k;
ttp.m_iWidth += k;
iOffset -= k;
--iGapChars;
@@ -660,7 +660,7 @@ void CFX_RTFBreak::EndBreak_Alignment(const std::deque<FX_TPO>& tpos,
}
}
-int32_t CFX_RTFBreak::GetBreakPos(std::vector<CFX_RTFChar>& tca,
+int32_t CFX_RTFBreak::GetBreakPos(std::vector<CFX_Char>& tca,
int32_t& iEndPos,
bool bAllChars,
bool bOnlyBrk) {
@@ -682,8 +682,8 @@ int32_t CFX_RTFBreak::GetBreakPos(std::vector<CFX_RTFChar>& tca,
iBreakPos = iEndPos;
}
- CFX_RTFChar* pCharArray = tca.data();
- CFX_RTFChar* pCur = pCharArray + iLength;
+ CFX_Char* pCharArray = tca.data();
+ CFX_Char* pCur = pCharArray + iLength;
--iLength;
if (bAllChars)
pCur->m_nBreakType = FX_LBT_UNKNOWN;
@@ -755,8 +755,8 @@ int32_t CFX_RTFBreak::GetBreakPos(std::vector<CFX_RTFChar>& tca,
return 0;
}
-void CFX_RTFBreak::SplitTextLine(CFX_RTFLine* pCurLine,
- CFX_RTFLine* pNextLine,
+void CFX_RTFBreak::SplitTextLine(CFX_BreakLine* pCurLine,
+ CFX_BreakLine* pNextLine,
bool bAllChars) {
ASSERT(pCurLine && pNextLine);
int32_t iCount = pCurLine->CountChars();
@@ -764,7 +764,7 @@ void CFX_RTFBreak::SplitTextLine(CFX_RTFLine* pCurLine,
return;
int32_t iEndPos = pCurLine->GetLineEnd();
- std::vector<CFX_RTFChar>& curChars = pCurLine->m_LineChars;
+ std::vector<CFX_Char>& curChars = pCurLine->m_LineChars;
int32_t iCharPos = GetBreakPos(curChars, iEndPos, bAllChars, false);
if (iCharPos < 0)
iCharPos = 0;
@@ -777,7 +777,7 @@ void CFX_RTFBreak::SplitTextLine(CFX_RTFLine* pCurLine,
}
pNextLine->m_LineChars =
- std::vector<CFX_RTFChar>(curChars.begin() + iCharPos, curChars.end());
+ std::vector<CFX_Char>(curChars.begin() + iCharPos, curChars.end());
curChars.erase(curChars.begin() + iCharPos, curChars.end());
pNextLine->m_iStart = pCurLine->m_iStart;
pNextLine->m_iWidth = pCurLine->GetLineEnd() - iEndPos;
@@ -799,11 +799,11 @@ int32_t CFX_RTFBreak::CountBreakPieces() const {
: 0;
}
-const CFX_RTFPiece* CFX_RTFBreak::GetBreakPieceUnstable(int32_t index) const {
+const CFX_BreakPiece* CFX_RTFBreak::GetBreakPieceUnstable(int32_t index) const {
if (!HasRTFLine())
return nullptr;
- const std::vector<CFX_RTFPiece>& pRTFPieces =
+ const std::vector<CFX_BreakPiece>& pRTFPieces =
m_RTFLine[m_iReadyLineIndex].m_LinePieces;
if (index < 0 || index >= pdfium::CollectionSize<int32_t>(pRTFPieces))
return nullptr;
@@ -937,30 +937,6 @@ int32_t CFX_RTFBreak::GetDisplayPos(const FX_RTFTEXTOBJ* pText,
return iCount;
}
-CFX_RTFPiece::CFX_RTFPiece()
- : 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_pChars(nullptr),
- m_pUserData(nullptr) {}
-
-CFX_RTFPiece::CFX_RTFPiece(const CFX_RTFPiece& other) = default;
-
-CFX_RTFPiece::~CFX_RTFPiece() {}
-
-CFX_RTFLine::CFX_RTFLine() : m_iStart(0), m_iWidth(0), m_iArabicChars(0) {}
-
-CFX_RTFLine::~CFX_RTFLine() {}
-
FX_RTFTEXTOBJ::FX_RTFTEXTOBJ()
: pFont(nullptr),
pRect(nullptr),
diff --git a/xfa/fgas/layout/fgas_rtfbreak.h b/xfa/fgas/layout/fgas_rtfbreak.h
index d71eeeef17..b3def63251 100644
--- a/xfa/fgas/layout/fgas_rtfbreak.h
+++ b/xfa/fgas/layout/fgas_rtfbreak.h
@@ -44,82 +44,6 @@ struct FX_RTFTEXTOBJ {
int32_t iVerticalScale;
};
-class CFX_RTFPiece {
- public:
- CFX_RTFPiece();
- CFX_RTFPiece(const CFX_RTFPiece& other);
- ~CFX_RTFPiece();
-
- int32_t GetEndPos() const {
- return m_iWidth < 0 ? m_iStartPos : m_iStartPos + m_iWidth;
- }
-
- CFX_RTFChar& GetChar(int32_t index) {
- ASSERT(index > -1 && index < m_iChars && m_pChars);
- return (*m_pChars)[m_iStartChar + index];
- }
-
- CFX_WideString 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> 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;
- }
-
- CFX_BreakType m_dwStatus;
- int32_t m_iStartPos;
- int32_t m_iWidth;
- int32_t m_iStartChar;
- int32_t m_iChars;
- int32_t m_iBidiLevel;
- int32_t m_iBidiPos;
- int32_t m_iFontSize;
- int32_t m_iFontHeight;
- int32_t m_iHorizontalScale;
- int32_t m_iVerticalScale;
- uint32_t m_dwIdentity;
- std::vector<CFX_RTFChar>* m_pChars; // not owned.
- CFX_RetainPtr<CFX_Retainable> m_pUserData;
-};
-
-class CFX_RTFLine {
- public:
- CFX_RTFLine();
- ~CFX_RTFLine();
-
- int32_t CountChars() const {
- return pdfium::CollectionSize<int32_t>(m_LineChars);
- }
-
- CFX_RTFChar& GetChar(int32_t index) {
- ASSERT(index >= 0 && index < pdfium::CollectionSize<int32_t>(m_LineChars));
- return m_LineChars[index];
- }
-
- int32_t GetLineEnd() const { return m_iStart + m_iWidth; }
- void Clear() {
- m_LineChars.clear();
- m_LinePieces.clear();
- m_iWidth = 0;
- m_iArabicChars = 0;
- }
-
- std::vector<CFX_RTFChar> m_LineChars;
- std::vector<CFX_RTFPiece> m_LinePieces;
- int32_t m_iStart;
- int32_t m_iWidth;
- int32_t m_iArabicChars;
-};
-
class CFX_RTFBreak {
public:
explicit CFX_RTFBreak(uint32_t dwLayoutStyles);
@@ -141,7 +65,7 @@ class CFX_RTFBreak {
CFX_BreakType EndBreak(CFX_BreakType dwStatus);
int32_t CountBreakPieces() const;
- const CFX_RTFPiece* GetBreakPieceUnstable(int32_t index) const;
+ const CFX_BreakPiece* GetBreakPieceUnstable(int32_t index) const;
void ClearBreakPieces();
void Reset();
@@ -152,30 +76,30 @@ class CFX_RTFBreak {
CFX_BreakType AppendChar(FX_WCHAR wch);
- CFX_RTFLine* GetCurrentLineForTesting() const { return m_pCurLine; }
+ CFX_BreakLine* GetCurrentLineForTesting() const { return m_pCurLine; }
private:
- void AppendChar_Combination(CFX_RTFChar* pCurChar);
- void AppendChar_Tab(CFX_RTFChar* pCurChar);
- CFX_BreakType AppendChar_Control(CFX_RTFChar* pCurChar);
- CFX_BreakType AppendChar_Arabic(CFX_RTFChar* pCurChar);
- CFX_BreakType AppendChar_Others(CFX_RTFChar* pCurChar);
+ void AppendChar_Combination(CFX_Char* pCurChar);
+ void AppendChar_Tab(CFX_Char* pCurChar);
+ CFX_BreakType AppendChar_Control(CFX_Char* pCurChar);
+ CFX_BreakType AppendChar_Arabic(CFX_Char* pCurChar);
+ CFX_BreakType AppendChar_Others(CFX_Char* pCurChar);
void FontChanged();
void SetBreakStatus();
- CFX_RTFChar* GetLastChar(int32_t index) const;
+ CFX_Char* GetLastChar(int32_t index) const;
bool HasRTFLine() const { return m_iReadyLineIndex >= 0; }
FX_CHARTYPE GetUnifiedCharType(FX_CHARTYPE chartype) const;
int32_t GetLastPositionedTab() const;
bool GetPositionedTab(int32_t* iTabPos) const;
- int32_t GetBreakPos(std::vector<CFX_RTFChar>& tca,
+ int32_t GetBreakPos(std::vector<CFX_Char>& tca,
int32_t& iEndPos,
bool bAllChars,
bool bOnlyBrk);
- void SplitTextLine(CFX_RTFLine* pCurLine,
- CFX_RTFLine* pNextLine,
+ void SplitTextLine(CFX_BreakLine* pCurLine,
+ CFX_BreakLine* pNextLine,
bool bAllChars);
- bool EndBreak_SplitLine(CFX_RTFLine* pNextLine,
+ bool EndBreak_SplitLine(CFX_BreakLine* pNextLine,
bool bAllChars,
CFX_BreakType dwStatus);
void EndBreak_BidiLine(std::deque<FX_TPO>* tpos, CFX_BreakType dwStatus);
@@ -202,8 +126,8 @@ class CFX_RTFBreak {
CFX_RetainPtr<CFX_Retainable> m_pUserData;
FX_CHARTYPE m_eCharType;
uint32_t m_dwIdentity;
- CFX_RTFLine m_RTFLine[2];
- CFX_RTFLine* m_pCurLine;
+ CFX_BreakLine m_RTFLine[2];
+ CFX_BreakLine* m_pCurLine;
int32_t m_iTolerance;
int8_t m_iReadyLineIndex;
};
diff --git a/xfa/fgas/layout/fgas_textbreak.cpp b/xfa/fgas/layout/fgas_textbreak.cpp
index e168613882..9343f94cc6 100644
--- a/xfa/fgas/layout/fgas_textbreak.cpp
+++ b/xfa/fgas/layout/fgas_textbreak.cpp
@@ -17,7 +17,7 @@
namespace {
typedef CFX_BreakType (CFX_TxtBreak::*FX_TxtBreak_LPFAppendChar)(
- CFX_TxtChar* pCurChar);
+ CFX_Char* pCurChar);
const FX_TxtBreak_LPFAppendChar g_FX_TxtBreak_lpfAppendChar[16] = {
&CFX_TxtBreak::AppendChar_Others, &CFX_TxtBreak::AppendChar_Tab,
&CFX_TxtBreak::AppendChar_Others, &CFX_TxtBreak::AppendChar_Control,
@@ -156,7 +156,7 @@ void CFX_TxtBreak::SetBreakStatus() {
if (iCount < 1)
return;
- CFX_TxtChar* pTC = m_pCurLine->GetCharPtr(iCount - 1);
+ CFX_Char* pTC = m_pCurLine->GetChar(iCount - 1);
if (pTC->m_dwStatus == CFX_BreakType::None)
pTC->m_dwStatus = CFX_BreakType::Piece;
}
@@ -175,15 +175,15 @@ void CFX_TxtBreak::SetCharSpace(FX_FLOAT fCharSpace) {
m_iCharSpace = FXSYS_round(fCharSpace * 20000.0f);
}
-CFX_TxtChar* CFX_TxtBreak::GetLastChar(int32_t index, bool bOmitChar) const {
- std::vector<CFX_TxtChar>& ca = m_pCurLine->m_LineChars;
+CFX_Char* CFX_TxtBreak::GetLastChar(int32_t index, bool bOmitChar) const {
+ std::vector<CFX_Char>& ca = m_pCurLine->m_LineChars;
int32_t iCount = pdfium::CollectionSize<int32_t>(ca);
if (index < 0 || index >= iCount)
return nullptr;
int32_t iStart = iCount - 1;
while (iStart > -1) {
- CFX_TxtChar* pTC = &ca[iStart--];
+ CFX_Char* pTC = &ca[iStart--];
if (bOmitChar && pTC->GetCharType() == FX_CHARTYPE_Combination)
continue;
if (--index < 0)
@@ -202,13 +202,12 @@ void CFX_TxtBreak::ResetArabicContext() {
ResetContextCharStyles();
}
-void CFX_TxtBreak::AppendChar_PageLoad(CFX_TxtChar* pCurChar,
- uint32_t dwProps) {
+void CFX_TxtBreak::AppendChar_PageLoad(CFX_Char* pCurChar, uint32_t dwProps) {
pCurChar->m_dwStatus = CFX_BreakType::None;
pCurChar->m_dwCharStyles = m_dwContextCharStyles;
}
-CFX_BreakType CFX_TxtBreak::AppendChar_Combination(CFX_TxtChar* pCurChar) {
+CFX_BreakType CFX_TxtBreak::AppendChar_Combination(CFX_Char* pCurChar) {
FX_WCHAR wch = pCurChar->m_wCharCode;
FX_WCHAR wForm;
int32_t iCharWidth = 0;
@@ -217,7 +216,7 @@ CFX_BreakType CFX_TxtBreak::AppendChar_Combination(CFX_TxtChar* pCurChar) {
iCharWidth = m_iCombWidth;
} else {
wForm = wch;
- CFX_TxtChar* pLastChar = GetLastChar(0, false);
+ CFX_Char* pLastChar = GetLastChar(0, false);
if (pLastChar &&
(pLastChar->m_dwCharStyles & FX_TXTCHARSTYLE_ArabicShadda) == 0) {
bool bShadda = false;
@@ -249,12 +248,12 @@ CFX_BreakType CFX_TxtBreak::AppendChar_Combination(CFX_TxtChar* pCurChar) {
return CFX_BreakType::None;
}
-CFX_BreakType CFX_TxtBreak::AppendChar_Tab(CFX_TxtChar* pCurChar) {
+CFX_BreakType CFX_TxtBreak::AppendChar_Tab(CFX_Char* pCurChar) {
m_eCharType = FX_CHARTYPE_Tab;
return CFX_BreakType::None;
}
-CFX_BreakType CFX_TxtBreak::AppendChar_Control(CFX_TxtChar* pCurChar) {
+CFX_BreakType CFX_TxtBreak::AppendChar_Control(CFX_Char* pCurChar) {
m_eCharType = FX_CHARTYPE_Control;
CFX_BreakType dwRet = CFX_BreakType::None;
if (!m_bSingleLine) {
@@ -281,12 +280,12 @@ CFX_BreakType CFX_TxtBreak::AppendChar_Control(CFX_TxtChar* pCurChar) {
return dwRet;
}
-CFX_BreakType CFX_TxtBreak::AppendChar_Arabic(CFX_TxtChar* pCurChar) {
+CFX_BreakType CFX_TxtBreak::AppendChar_Arabic(CFX_Char* pCurChar) {
FX_CHARTYPE chartype = pCurChar->GetCharType();
int32_t& iLineWidth = m_pCurLine->m_iWidth;
FX_WCHAR wForm;
int32_t iCharWidth = 0;
- CFX_TxtChar* pLastChar = nullptr;
+ CFX_Char* pLastChar = nullptr;
bool bAlef = false;
if (!m_bCombText && m_eCharType >= FX_CHARTYPE_ArabicAlef &&
m_eCharType <= FX_CHARTYPE_ArabicDistortion) {
@@ -335,7 +334,7 @@ CFX_BreakType CFX_TxtBreak::AppendChar_Arabic(CFX_TxtChar* pCurChar) {
return CFX_BreakType::None;
}
-CFX_BreakType CFX_TxtBreak::AppendChar_Others(CFX_TxtChar* pCurChar) {
+CFX_BreakType CFX_TxtBreak::AppendChar_Others(CFX_Char* pCurChar) {
FX_CHARTYPE chartype = pCurChar->GetCharType();
int32_t& iLineWidth = m_pCurLine->m_iWidth;
int32_t iCharWidth = 0;
@@ -369,7 +368,7 @@ CFX_BreakType CFX_TxtBreak::AppendChar(FX_WCHAR wch) {
FX_CHARTYPE chartype = GetCharTypeFromProp(dwProps);
m_pCurLine->m_LineChars.emplace_back();
- CFX_TxtChar* pCurChar = &m_pCurLine->m_LineChars.back();
+ CFX_Char* pCurChar = &m_pCurLine->m_LineChars.back();
pCurChar->m_wCharCode = static_cast<uint16_t>(wch);
pCurChar->m_dwCharProps = dwProps;
pCurChar->m_dwCharStyles = 0;
@@ -401,12 +400,13 @@ CFX_BreakType CFX_TxtBreak::AppendChar(FX_WCHAR wch) {
return std::max(dwRet1, dwRet2);
}
-bool CFX_TxtBreak::EndBreak_SplitLine(CFX_TxtLine* pNextLine, bool bAllChars) {
+bool CFX_TxtBreak::EndBreak_SplitLine(CFX_BreakLine* pNextLine,
+ bool bAllChars) {
int32_t iCount = m_pCurLine->CountChars();
bool bDone = false;
- CFX_TxtChar* pTC;
+ CFX_Char* pTC;
if (!m_bSingleLine && m_pCurLine->m_iWidth > m_iLineWidth + m_iTolerance) {
- pTC = m_pCurLine->GetCharPtr(iCount - 1);
+ pTC = m_pCurLine->GetChar(iCount - 1);
switch (pTC->GetCharType()) {
case FX_CHARTYPE_Tab:
case FX_CHARTYPE_Control:
@@ -420,7 +420,7 @@ bool CFX_TxtBreak::EndBreak_SplitLine(CFX_TxtLine* pNextLine, bool bAllChars) {
}
iCount = m_pCurLine->CountChars();
- CFX_TxtPiece tp;
+ CFX_BreakPiece tp;
if (bAllChars && !bDone) {
int32_t iEndPos = m_pCurLine->m_iWidth;
GetBreakPos(m_pCurLine->m_LineChars, iEndPos, bAllChars, true);
@@ -430,12 +430,12 @@ bool CFX_TxtBreak::EndBreak_SplitLine(CFX_TxtLine* pNextLine, bool bAllChars) {
void CFX_TxtBreak::EndBreak_BidiLine(std::deque<FX_TPO>* tpos,
CFX_BreakType dwStatus) {
- CFX_TxtPiece tp;
+ CFX_BreakPiece tp;
FX_TPO tpo;
- CFX_TxtChar* pTC;
+ CFX_Char* pTC;
int32_t i;
int32_t j;
- std::vector<CFX_TxtChar>& chars = m_pCurLine->m_LineChars;
+ std::vector<CFX_Char>& chars = m_pCurLine->m_LineChars;
int32_t iCount = m_pCurLine->CountChars();
bool bDone = m_pCurLine->m_iArabicChars > 0;
if (bDone) {
@@ -511,7 +511,7 @@ void CFX_TxtBreak::EndBreak_BidiLine(std::deque<FX_TPO>* tpos,
int32_t iStartPos = 0;
for (i = 0; i <= j; i++) {
tpo = (*tpos)[i];
- CFX_TxtPiece& ttp = m_pCurLine->m_LinePieces[tpo.index];
+ CFX_BreakPiece& ttp = m_pCurLine->m_LinePieces[tpo.index];
ttp.m_iStartPos = iStartPos;
iStartPos += ttp.m_iWidth;
}
@@ -541,21 +541,21 @@ void CFX_TxtBreak::EndBreak_Alignment(const std::deque<FX_TPO>& tpos,
int32_t iGapChars = 0;
bool bFind = false;
for (auto it = tpos.rbegin(); it != tpos.rend(); ++it) {
- CFX_TxtPiece& ttp = m_pCurLine->m_LinePieces[it->index];
+ CFX_BreakPiece& ttp = m_pCurLine->m_LinePieces[it->index];
if (!bFind)
iNetWidth = ttp.GetEndPos();
bool bArabic = FX_IsOdd(ttp.m_iBidiLevel);
int32_t j = bArabic ? 0 : ttp.m_iChars - 1;
while (j > -1 && j < ttp.m_iChars) {
- const CFX_TxtChar& pTC = ttp.GetChar(j);
- if (pTC.m_nBreakType == FX_LBT_DIRECT_BRK)
+ const CFX_Char* pTC = ttp.GetChar(j);
+ if (pTC->m_nBreakType == FX_LBT_DIRECT_BRK)
iGapChars++;
if (!bFind || !bAllChars) {
- FX_CHARTYPE chartype = pTC.GetCharType();
+ FX_CHARTYPE chartype = pTC->GetCharType();
if (chartype == FX_CHARTYPE_Space || chartype == FX_CHARTYPE_Control) {
- if (!bFind && bAllChars && pTC.m_iCharWidth > 0)
- iNetWidth -= pTC.m_iCharWidth;
+ if (!bFind && bAllChars && pTC->m_iCharWidth > 0)
+ iNetWidth -= pTC->m_iCharWidth;
} else {
bFind = true;
if (!bAllChars)
@@ -573,19 +573,19 @@ void CFX_TxtBreak::EndBreak_Alignment(const std::deque<FX_TPO>& tpos,
dwStatus != CFX_BreakType::Paragraph) {
int32_t iStart = -1;
for (auto& tpo : tpos) {
- CFX_TxtPiece& ttp = m_pCurLine->m_LinePieces[tpo.index];
+ CFX_BreakPiece& ttp = m_pCurLine->m_LinePieces[tpo.index];
if (iStart < -1)
iStart = ttp.m_iStartPos;
else
ttp.m_iStartPos = iStart;
for (int32_t j = 0; j < ttp.m_iChars; j++) {
- CFX_TxtChar& pTC = ttp.GetChar(j);
- if (pTC.m_nBreakType != FX_LBT_DIRECT_BRK || pTC.m_iCharWidth < 0)
+ CFX_Char* pTC = ttp.GetChar(j);
+ if (pTC->m_nBreakType != FX_LBT_DIRECT_BRK || pTC->m_iCharWidth < 0)
continue;
int32_t k = iOffset / iGapChars;
- pTC.m_iCharWidth += k;
+ pTC->m_iCharWidth += k;
ttp.m_iWidth += k;
iOffset -= k;
iGapChars--;
@@ -629,12 +629,12 @@ CFX_BreakType CFX_TxtBreak::EndBreak(CFX_BreakType dwStatus) {
if (iCount < 1)
return CFX_BreakType::None;
- m_pCurLine->GetCharPtr(iCount - 1)->m_dwStatus = dwStatus;
+ m_pCurLine->GetChar(iCount - 1)->m_dwStatus = dwStatus;
if (dwStatus == CFX_BreakType::Piece)
return dwStatus;
m_iReadyLineIndex = m_pCurLine == &m_TxtLine[0] ? 0 : 1;
- CFX_TxtLine* pNextLine = &m_TxtLine[1 - m_iReadyLineIndex];
+ CFX_BreakLine* pNextLine = &m_TxtLine[1 - m_iReadyLineIndex];
bool bAllChars = m_iCurAlignment > CFX_TxtLineAlignment_Right;
if (!EndBreak_SplitLine(pNextLine, bAllChars)) {
std::deque<FX_TPO> tpos;
@@ -653,7 +653,7 @@ CFX_BreakType CFX_TxtBreak::EndBreak(CFX_BreakType dwStatus) {
return dwStatus;
}
-int32_t CFX_TxtBreak::GetBreakPos(std::vector<CFX_TxtChar>& ca,
+int32_t CFX_TxtBreak::GetBreakPos(std::vector<CFX_Char>& ca,
int32_t& iEndPos,
bool bAllChars,
bool bOnlyBrk) {
@@ -746,8 +746,8 @@ int32_t CFX_TxtBreak::GetBreakPos(std::vector<CFX_TxtChar>& ca,
return 0;
}
-void CFX_TxtBreak::SplitTextLine(CFX_TxtLine* pCurLine,
- CFX_TxtLine* pNextLine,
+void CFX_TxtBreak::SplitTextLine(CFX_BreakLine* pCurLine,
+ CFX_BreakLine* pNextLine,
bool bAllChars) {
ASSERT(pCurLine && pNextLine);
int32_t iCount = pCurLine->CountChars();
@@ -755,7 +755,7 @@ void CFX_TxtBreak::SplitTextLine(CFX_TxtLine* pCurLine,
return;
int32_t iEndPos = pCurLine->m_iWidth;
- std::vector<CFX_TxtChar>& curChars = pCurLine->m_LineChars;
+ std::vector<CFX_Char>& curChars = pCurLine->m_LineChars;
int32_t iCharPos = GetBreakPos(curChars, iEndPos, bAllChars, false);
if (iCharPos < 0)
iCharPos = 0;
@@ -769,10 +769,10 @@ void CFX_TxtBreak::SplitTextLine(CFX_TxtLine* pCurLine,
}
pNextLine->m_LineChars =
- std::vector<CFX_TxtChar>(curChars.begin() + iCharPos, curChars.end());
+ std::vector<CFX_Char>(curChars.begin() + iCharPos, curChars.end());
curChars.erase(curChars.begin() + iCharPos, curChars.end());
pCurLine->m_iWidth = iEndPos;
- CFX_TxtChar* pTC = &curChars[iCharPos - 1];
+ CFX_Char* pTC = &curChars[iCharPos - 1];
pTC->m_nBreakType = FX_LBT_UNKNOWN;
iCount = pdfium::CollectionSize<int>(pNextLine->m_LineChars);
int32_t iWidth = 0;
@@ -793,7 +793,7 @@ int32_t CFX_TxtBreak::CountBreakPieces() const {
: 0;
}
-const CFX_TxtPiece* CFX_TxtBreak::GetBreakPiece(int32_t index) const {
+const CFX_BreakPiece* CFX_TxtBreak::GetBreakPiece(int32_t index) const {
if (!HasTxtLine())
return nullptr;
if (index < 0 ||
@@ -1194,24 +1194,3 @@ FX_TXTRUN::FX_TXTRUN()
FX_TXTRUN::~FX_TXTRUN() {}
FX_TXTRUN::FX_TXTRUN(const FX_TXTRUN& other) = default;
-
-CFX_TxtPiece::CFX_TxtPiece()
- : m_dwStatus(CFX_BreakType::Piece),
- m_iStartPos(0),
- m_iWidth(-1),
- m_iStartChar(0),
- m_iChars(0),
- m_iBidiLevel(0),
- m_iBidiPos(0),
- m_iHorizontalScale(100),
- m_iVerticalScale(100),
- m_dwCharStyles(0),
- m_pChars(nullptr) {}
-
-CFX_TxtPiece::CFX_TxtPiece(const CFX_TxtPiece& other) = default;
-
-CFX_TxtPiece::~CFX_TxtPiece() = default;
-
-CFX_TxtLine::CFX_TxtLine() : m_iStart(0), m_iWidth(0), m_iArabicChars(0) {}
-
-CFX_TxtLine::~CFX_TxtLine() {}
diff --git a/xfa/fgas/layout/fgas_textbreak.h b/xfa/fgas/layout/fgas_textbreak.h
index c023955aab..9aa576f380 100644
--- a/xfa/fgas/layout/fgas_textbreak.h
+++ b/xfa/fgas/layout/fgas_textbreak.h
@@ -11,15 +11,13 @@
#include <memory>
#include <vector>
-#include "core/fxcrt/fx_ucd.h"
+#include "core/fxcrt/cfx_char.h"
#include "core/fxge/cfx_renderdevice.h"
#include "third_party/base/stl_util.h"
#include "xfa/fde/cfde_txtedtpage.h"
+#include "xfa/fgas/layout/cfx_breakline.h"
-class CFX_Char;
class CFGAS_GEFont;
-class CFX_TxtChar;
-class CFX_TxtPiece;
struct FDE_TEXTEDITPIECE;
#define FX_TXTLAYOUTSTYLE_SingleLine 0x0200
@@ -67,93 +65,6 @@ struct FX_TXTRUN {
bool bSkipSpace;
};
-class CFX_TxtPiece {
- public:
- CFX_TxtPiece();
- CFX_TxtPiece(const CFX_TxtPiece& other);
- ~CFX_TxtPiece();
-
- int32_t GetEndPos() const {
- return m_iWidth < 0 ? m_iStartPos : m_iStartPos + m_iWidth;
- }
- int32_t GetLength() const { return m_iChars; }
-
- CFX_TxtChar& GetChar(int32_t index) const {
- ASSERT(index > -1 && index < m_iChars && m_pChars);
- return (*m_pChars)[m_iStartChar + index];
- }
-
- CFX_WideString 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;
- }
-
- CFX_BreakType m_dwStatus;
- int32_t m_iStartPos;
- int32_t m_iWidth;
- int32_t m_iStartChar;
- int32_t m_iChars;
- int32_t m_iBidiLevel;
- int32_t m_iBidiPos;
- int32_t m_iHorizontalScale;
- int32_t m_iVerticalScale;
- uint32_t m_dwCharStyles;
- std::vector<CFX_TxtChar>* m_pChars;
-};
-
-class CFX_TxtLine {
- public:
- CFX_TxtLine();
- ~CFX_TxtLine();
-
- int32_t CountChars() const {
- return pdfium::CollectionSize<int32_t>(m_LineChars);
- }
-
- CFX_TxtChar* GetCharPtr(int32_t index) {
- ASSERT(index >= 0 && index < pdfium::CollectionSize<int32_t>(m_LineChars));
- return &m_LineChars[index];
- }
-
- const CFX_TxtChar* GetCharPtr(int32_t index) const {
- ASSERT(index >= 0 && index < pdfium::CollectionSize<int32_t>(m_LineChars));
- return &m_LineChars[index];
- }
-
- int32_t CountPieces() const {
- return pdfium::CollectionSize<int32_t>(m_LinePieces);
- }
-
- const CFX_TxtPiece* GetPiecePtr(int32_t index) const {
- ASSERT(index >= 0 && index < CountPieces());
- return &m_LinePieces[index];
- }
-
- void 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);
- }
-
- void Clear() {
- m_LineChars.clear();
- m_LinePieces.clear();
- m_iWidth = 0;
- m_iArabicChars = 0;
- }
-
- std::vector<CFX_TxtChar> m_LineChars;
- std::vector<CFX_TxtPiece> m_LinePieces;
- int32_t m_iStart;
- int32_t m_iWidth;
- int32_t m_iArabicChars;
-};
-
class CFX_TxtBreak {
public:
CFX_TxtBreak();
@@ -174,7 +85,7 @@ class CFX_TxtBreak {
void SetCombWidth(FX_FLOAT fCombWidth);
CFX_BreakType EndBreak(CFX_BreakType dwStatus);
int32_t CountBreakPieces() const;
- const CFX_TxtPiece* GetBreakPiece(int32_t index) const;
+ const CFX_BreakPiece* GetBreakPiece(int32_t index) const;
void ClearBreakPieces();
void Reset();
int32_t GetDisplayPos(const FX_TXTRUN* pTxtRun,
@@ -183,33 +94,33 @@ class CFX_TxtBreak {
CFX_WideString* pWSForms = nullptr) const;
std::vector<CFX_RectF> GetCharRects(const FX_TXTRUN* pTxtRun,
bool bCharBBox = false) const;
- void AppendChar_PageLoad(CFX_TxtChar* pCurChar, uint32_t dwProps);
+ void AppendChar_PageLoad(CFX_Char* pCurChar, uint32_t dwProps);
CFX_BreakType AppendChar(FX_WCHAR wch);
- CFX_BreakType AppendChar_Combination(CFX_TxtChar* pCurChar);
- CFX_BreakType AppendChar_Tab(CFX_TxtChar* pCurChar);
- CFX_BreakType AppendChar_Control(CFX_TxtChar* pCurChar);
- CFX_BreakType AppendChar_Arabic(CFX_TxtChar* pCurChar);
- CFX_BreakType AppendChar_Others(CFX_TxtChar* pCurChar);
+ CFX_BreakType AppendChar_Combination(CFX_Char* pCurChar);
+ CFX_BreakType AppendChar_Tab(CFX_Char* pCurChar);
+ CFX_BreakType AppendChar_Control(CFX_Char* pCurChar);
+ CFX_BreakType AppendChar_Arabic(CFX_Char* pCurChar);
+ CFX_BreakType AppendChar_Others(CFX_Char* pCurChar);
private:
void FontChanged();
void SetBreakStatus();
- CFX_TxtChar* GetLastChar(int32_t index, bool bOmitChar = true) const;
+ CFX_Char* GetLastChar(int32_t index, bool bOmitChar = true) const;
bool HasTxtLine() const { return m_iReadyLineIndex >= 0; }
FX_CHARTYPE GetUnifiedCharType(FX_CHARTYPE dwType) const;
void ResetArabicContext();
void ResetContextCharStyles();
- bool EndBreak_SplitLine(CFX_TxtLine* pNextLine, bool bAllChars);
+ bool EndBreak_SplitLine(CFX_BreakLine* pNextLine, bool bAllChars);
void EndBreak_BidiLine(std::deque<FX_TPO>* tpos, CFX_BreakType dwStatus);
void EndBreak_Alignment(const std::deque<FX_TPO>& tpos,
bool bAllChars,
CFX_BreakType dwStatus);
- int32_t GetBreakPos(std::vector<CFX_TxtChar>& ca,
+ int32_t GetBreakPos(std::vector<CFX_Char>& ca,
int32_t& iEndPos,
bool bAllChars = false,
bool bOnlyBrk = false);
- void SplitTextLine(CFX_TxtLine* pCurLine,
- CFX_TxtLine* pNextLine,
+ void SplitTextLine(CFX_BreakLine* pCurLine,
+ CFX_BreakLine* pNextLine,
bool bAllChars = false);
int32_t m_iLineWidth;
@@ -230,8 +141,8 @@ class CFX_TxtBreak {
int32_t m_iCombWidth;
FX_CHARTYPE m_eCharType;
int32_t m_iCurAlignment;
- CFX_TxtLine m_TxtLine[2];
- CFX_TxtLine* m_pCurLine;
+ CFX_BreakLine m_TxtLine[2];
+ CFX_BreakLine* m_pCurLine;
int32_t m_iTolerance;
int32_t m_iHorScale;
int32_t m_iCharSpace;