Nest CFX_BreakType enum in CFX_Char.
One less prefix to rename down the road.
Bug: pdfium:1567
Change-Id: Ib946cd77690c59b95853f6fadfd03ccd05c1446c
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/78670
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/xfa/fde/cfde_texteditengine.cpp b/xfa/fde/cfde_texteditengine.cpp
index 0ff4e41..24192b7 100644
--- a/xfa/fde/cfde_texteditengine.cpp
+++ b/xfa/fde/cfde_texteditengine.cpp
@@ -1072,7 +1072,7 @@
}
void CFDE_TextEditEngine::RebuildPieces() {
- text_break_.EndBreak(CFX_BreakType::kParagraph);
+ text_break_.EndBreak(CFX_Char::BreakType::kParagraph);
text_break_.ClearBreakPieces();
char_widths_.clear();
@@ -1091,10 +1091,10 @@
while (!iter.IsEOF(false)) {
iter.Next(false);
- CFX_BreakType break_status = text_break_.AppendChar(
+ CFX_Char::BreakType break_status = text_break_.AppendChar(
password_mode_ ? password_alias_ : iter.GetChar());
if (iter.IsEOF(false) && CFX_BreakTypeNoneOrPiece(break_status))
- break_status = text_break_.EndBreak(CFX_BreakType::kParagraph);
+ break_status = text_break_.EndBreak(CFX_Char::BreakType::kParagraph);
if (CFX_BreakTypeNoneOrPiece(break_status))
continue;
diff --git a/xfa/fde/cfde_textout.cpp b/xfa/fde/cfde_textout.cpp
index ce7a1d2..9c24ea3 100644
--- a/xfa/fde/cfde_textout.cpp
+++ b/xfa/fde/cfde_textout.cpp
@@ -213,7 +213,7 @@
float fWidth = 0.0f;
float fHeight = 0.0f;
float fStartPos = pRect->right();
- CFX_BreakType dwBreakStatus = CFX_BreakType::kNone;
+ CFX_Char::BreakType dwBreakStatus = CFX_Char::BreakType::kNone;
bool break_char_is_set = false;
for (const wchar_t& wch : str) {
if (!break_char_is_set && (wch == L'\n' || wch == L'\r')) {
@@ -225,7 +225,7 @@
RetrieveLineWidth(dwBreakStatus, &fStartPos, &fWidth, &fHeight);
}
- dwBreakStatus = m_pTxtBreak->EndBreak(CFX_BreakType::kParagraph);
+ dwBreakStatus = m_pTxtBreak->EndBreak(CFX_Char::BreakType::kParagraph);
if (!CFX_BreakTypeNoneOrPiece(dwBreakStatus))
RetrieveLineWidth(dwBreakStatus, &fStartPos, &fWidth, &fHeight);
@@ -244,7 +244,7 @@
pRect->height -= m_fLineSpace - m_fFontSize;
}
-bool CFDE_TextOut::RetrieveLineWidth(CFX_BreakType dwBreakStatus,
+bool CFDE_TextOut::RetrieveLineWidth(CFX_Char::BreakType dwBreakStatus,
float* pStartPos,
float* pWidth,
float* pHeight) {
@@ -261,9 +261,9 @@
}
m_pTxtBreak->ClearBreakPieces();
- if (dwBreakStatus == CFX_BreakType::kParagraph)
+ if (dwBreakStatus == CFX_Char::BreakType::kParagraph)
m_pTxtBreak->Reset();
- if (!m_Styles.line_wrap_ && dwBreakStatus == CFX_BreakType::kLine) {
+ if (!m_Styles.line_wrap_ && dwBreakStatus == CFX_Char::BreakType::kLine) {
*pWidth += fLineWidth;
} else {
*pWidth = std::max(*pWidth, fLineWidth);
@@ -329,7 +329,7 @@
m_fLinePos = rect.top;
size_t start_char = 0;
int32_t iPieceWidths = 0;
- CFX_BreakType dwBreakStatus;
+ CFX_Char::BreakType dwBreakStatus;
bool bRet = false;
for (const auto& wch : str) {
dwBreakStatus = m_pTxtBreak->AppendChar(wch);
@@ -338,9 +338,9 @@
bool bEndofLine =
RetrievePieces(dwBreakStatus, false, rect, &start_char, &iPieceWidths);
- if (bEndofLine &&
- (m_Styles.line_wrap_ || dwBreakStatus == CFX_BreakType::kParagraph ||
- dwBreakStatus == CFX_BreakType::kPage)) {
+ if (bEndofLine && (m_Styles.line_wrap_ ||
+ dwBreakStatus == CFX_Char::BreakType::kParagraph ||
+ dwBreakStatus == CFX_Char::BreakType::kPage)) {
iPieceWidths = 0;
++m_iCurLine;
m_fLinePos += fLineStep;
@@ -353,7 +353,7 @@
}
}
- dwBreakStatus = m_pTxtBreak->EndBreak(CFX_BreakType::kParagraph);
+ dwBreakStatus = m_pTxtBreak->EndBreak(CFX_Char::BreakType::kParagraph);
if (!CFX_BreakTypeNoneOrPiece(dwBreakStatus) && !bRet)
RetrievePieces(dwBreakStatus, false, rect, &start_char, &iPieceWidths);
@@ -361,7 +361,7 @@
m_pTxtBreak->Reset();
}
-bool CFDE_TextOut::RetrievePieces(CFX_BreakType dwBreakStatus,
+bool CFDE_TextOut::RetrievePieces(CFX_Char::BreakType dwBreakStatus,
bool bReload,
const CFX_RectF& rect,
size_t* pStartChar,
@@ -411,7 +411,7 @@
m_pTxtBreak->ClearBreakPieces();
return m_Styles.single_line_ || m_Styles.line_wrap_ || bNeedReload ||
- dwBreakStatus == CFX_BreakType::kParagraph;
+ dwBreakStatus == CFX_Char::BreakType::kParagraph;
}
void CFDE_TextOut::AppendPiece(const Piece& piece,
@@ -456,7 +456,7 @@
size_t start_char = 0;
size_t piece_count = line->GetSize();
int32_t piece_widths = 0;
- CFX_BreakType break_status = CFX_BreakType::kNone;
+ CFX_Char::BreakType break_status = CFX_Char::BreakType::kNone;
for (size_t piece_index = 0; piece_index < piece_count; ++piece_index) {
const Piece* piece = line->GetPieceAtIndex(piece_index);
if (piece_index == 0) {
@@ -471,7 +471,7 @@
}
}
- break_status = m_pTxtBreak->EndBreak(CFX_BreakType::kParagraph);
+ break_status = m_pTxtBreak->EndBreak(CFX_Char::BreakType::kParagraph);
if (!CFX_BreakTypeNoneOrPiece(break_status))
RetrievePieces(break_status, true, rect, &start_char, &piece_widths);
diff --git a/xfa/fde/cfde_textout.h b/xfa/fde/cfde_textout.h
index 70cb176..97f0d19 100644
--- a/xfa/fde/cfde_textout.h
+++ b/xfa/fde/cfde_textout.h
@@ -81,7 +81,7 @@
std::deque<Piece> pieces_;
};
- bool RetrieveLineWidth(CFX_BreakType dwBreakStatus,
+ bool RetrieveLineWidth(CFX_Char::BreakType dwBreakStatus,
float* pStartPos,
float* pWidth,
float* pHeight);
@@ -89,7 +89,7 @@
void Reload(const CFX_RectF& rect);
void ReloadLinePiece(Line* pLine, const CFX_RectF& rect);
- bool RetrievePieces(CFX_BreakType dwBreakStatus,
+ bool RetrievePieces(CFX_Char::BreakType dwBreakStatus,
bool bReload,
const CFX_RectF& rect,
size_t* pStartChar,
diff --git a/xfa/fgas/layout/cfx_break.cpp b/xfa/fgas/layout/cfx_break.cpp
index 2532725..39ed44c 100644
--- a/xfa/fgas/layout/cfx_break.cpp
+++ b/xfa/fgas/layout/cfx_break.cpp
@@ -75,8 +75,8 @@
return;
CFX_Char* tc = m_pCurLine->GetChar(m_pCurLine->m_LineChars.size() - 1);
- if (tc->m_dwStatus == CFX_BreakType::kNone)
- tc->m_dwStatus = CFX_BreakType::kPiece;
+ if (tc->m_dwStatus == CFX_Char::BreakType::kNone)
+ tc->m_dwStatus = CFX_Char::BreakType::kPiece;
}
bool CFX_Break::IsGreaterThanLineWidth(int32_t width) const {
diff --git a/xfa/fgas/layout/cfx_breakpiece.h b/xfa/fgas/layout/cfx_breakpiece.h
index a708bf1..a61b764 100644
--- a/xfa/fgas/layout/cfx_breakpiece.h
+++ b/xfa/fgas/layout/cfx_breakpiece.h
@@ -29,7 +29,7 @@
WideString GetString() const;
std::vector<int32_t> GetWidths() const;
- CFX_BreakType m_dwStatus = CFX_BreakType::kPiece;
+ CFX_Char::BreakType m_dwStatus = CFX_Char::BreakType::kPiece;
int32_t m_iStartPos = 0;
int32_t m_iWidth = -1;
int32_t m_iStartChar = 0;
diff --git a/xfa/fgas/layout/cfx_char.h b/xfa/fgas/layout/cfx_char.h
index deca8e9..3e26a62 100644
--- a/xfa/fgas/layout/cfx_char.h
+++ b/xfa/fgas/layout/cfx_char.h
@@ -16,16 +16,16 @@
#include "xfa/fgas/layout/cfx_textuserdata.h"
#include "xfa/fgas/layout/fx_linebreak.h"
-enum class CFX_BreakType : uint8_t {
- kNone = 0,
- kPiece,
- kLine,
- kParagraph,
- kPage
-};
-
class CFX_Char {
public:
+ enum class BreakType : uint8_t {
+ kNone = 0,
+ kPiece,
+ kLine,
+ kParagraph,
+ kPage
+ };
+
static void BidiLine(std::vector<CFX_Char>* chars, size_t iCount);
explicit CFX_Char(uint16_t wCharCode);
@@ -36,12 +36,11 @@
~CFX_Char();
FX_CHARTYPE GetCharType() const;
-
uint16_t char_code() const { return m_wCharCode; }
int16_t horizonal_scale() const { return m_iHorizontalScale; }
int16_t vertical_scale() const { return m_iVerticalScale; }
- CFX_BreakType m_dwStatus = CFX_BreakType::kNone;
+ BreakType m_dwStatus = BreakType::kNone;
FX_BIDICLASS m_iBidiClass = FX_BIDICLASS::kON;
FX_LINEBREAKTYPE m_eLineBreakType = FX_LINEBREAKTYPE::kUNKNOWN;
uint32_t m_dwCharStyles = 0;
diff --git a/xfa/fgas/layout/cfx_rtfbreak.cpp b/xfa/fgas/layout/cfx_rtfbreak.cpp
index 2f94768..fdc14d8 100644
--- a/xfa/fgas/layout/cfx_rtfbreak.cpp
+++ b/xfa/fgas/layout/cfx_rtfbreak.cpp
@@ -68,7 +68,7 @@
return true;
}
-CFX_BreakType CFX_RTFBreak::AppendChar(wchar_t wch) {
+CFX_Char::BreakType CFX_RTFBreak::AppendChar(wchar_t wch) {
DCHECK(m_pCurLine);
FX_CHARTYPE chartype = FX_GetCharType(wch);
@@ -79,19 +79,19 @@
pCurChar->m_dwIdentity = m_dwIdentity;
pCurChar->m_pUserData = m_pUserData;
- CFX_BreakType dwRet1 = CFX_BreakType::kNone;
+ CFX_Char::BreakType dwRet1 = CFX_Char::BreakType::kNone;
if (chartype != FX_CHARTYPE::kCombination &&
GetUnifiedCharType(m_eCharType) != GetUnifiedCharType(chartype) &&
m_eCharType != FX_CHARTYPE::kUnknown &&
IsGreaterThanLineWidth(m_pCurLine->GetLineEnd()) &&
(m_eCharType != FX_CHARTYPE::kSpace ||
chartype != FX_CHARTYPE::kControl)) {
- dwRet1 = EndBreak(CFX_BreakType::kLine);
+ dwRet1 = EndBreak(CFX_Char::BreakType::kLine);
if (!m_pCurLine->m_LineChars.empty())
pCurChar = &m_pCurLine->m_LineChars.back();
}
- CFX_BreakType dwRet2 = CFX_BreakType::kNone;
+ CFX_Char::BreakType dwRet2 = CFX_Char::BreakType::kNone;
switch (chartype) {
case FX_CHARTYPE::kTab:
AppendChar_Tab(pCurChar);
@@ -173,31 +173,31 @@
iLineWidth += iCharWidth;
}
-CFX_BreakType CFX_RTFBreak::AppendChar_Control(CFX_Char* pCurChar) {
- CFX_BreakType dwRet2 = CFX_BreakType::kNone;
+CFX_Char::BreakType CFX_RTFBreak::AppendChar_Control(CFX_Char* pCurChar) {
+ CFX_Char::BreakType dwRet2 = CFX_Char::BreakType::kNone;
switch (pCurChar->char_code()) {
case L'\v':
case 0x2028:
- dwRet2 = CFX_BreakType::kLine;
+ dwRet2 = CFX_Char::BreakType::kLine;
break;
case L'\f':
- dwRet2 = CFX_BreakType::kPage;
+ dwRet2 = CFX_Char::BreakType::kPage;
break;
case 0x2029:
- dwRet2 = CFX_BreakType::kParagraph;
+ dwRet2 = CFX_Char::BreakType::kParagraph;
break;
default:
if (pCurChar->char_code() == m_wParagraphBreakChar)
- dwRet2 = CFX_BreakType::kParagraph;
+ dwRet2 = CFX_Char::BreakType::kParagraph;
break;
}
- if (dwRet2 != CFX_BreakType::kNone)
+ if (dwRet2 != CFX_Char::BreakType::kNone)
dwRet2 = EndBreak(dwRet2);
return dwRet2;
}
-CFX_BreakType CFX_RTFBreak::AppendChar_Arabic(CFX_Char* pCurChar) {
+CFX_Char::BreakType CFX_RTFBreak::AppendChar_Arabic(CFX_Char* pCurChar) {
m_pCurLine->IncrementArabicCharCount();
CFX_Char* pLastChar = nullptr;
@@ -232,7 +232,7 @@
FX_SAFE_INT32 checked_width = m_pCurLine->m_iWidth;
checked_width += iCharWidthValid;
if (!checked_width.IsValid())
- return CFX_BreakType::kNone;
+ return CFX_Char::BreakType::kNone;
m_pCurLine->m_iWidth = checked_width.ValueOrDie();
iCharWidth = 0;
@@ -261,16 +261,16 @@
FX_SAFE_INT32 checked_width = m_pCurLine->m_iWidth;
checked_width += iCharWidthValid;
if (!checked_width.IsValid())
- return CFX_BreakType::kNone;
+ return CFX_Char::BreakType::kNone;
m_pCurLine->m_iWidth = checked_width.ValueOrDie();
if (IsGreaterThanLineWidth(m_pCurLine->GetLineEnd()))
- return EndBreak(CFX_BreakType::kLine);
- return CFX_BreakType::kNone;
+ return EndBreak(CFX_Char::BreakType::kLine);
+ return CFX_Char::BreakType::kNone;
}
-CFX_BreakType CFX_RTFBreak::AppendChar_Others(CFX_Char* pCurChar) {
+CFX_Char::BreakType CFX_RTFBreak::AppendChar_Others(CFX_Char* pCurChar) {
FX_CHARTYPE chartype = pCurChar->GetCharType();
wchar_t wForm = pCurChar->char_code();
FX_SAFE_INT32 iCharWidth;
@@ -291,41 +291,41 @@
FX_SAFE_INT32 checked_width = m_pCurLine->m_iWidth;
checked_width += iCharWidthValid;
if (!checked_width.IsValid())
- return CFX_BreakType::kNone;
+ return CFX_Char::BreakType::kNone;
m_pCurLine->m_iWidth = checked_width.ValueOrDie();
if (chartype != FX_CHARTYPE::kSpace &&
IsGreaterThanLineWidth(m_pCurLine->GetLineEnd())) {
- return EndBreak(CFX_BreakType::kLine);
+ return EndBreak(CFX_Char::BreakType::kLine);
}
- return CFX_BreakType::kNone;
+ return CFX_Char::BreakType::kNone;
}
-CFX_BreakType CFX_RTFBreak::EndBreak(CFX_BreakType dwStatus) {
- DCHECK(dwStatus != CFX_BreakType::kNone);
+CFX_Char::BreakType CFX_RTFBreak::EndBreak(CFX_Char::BreakType dwStatus) {
+ DCHECK(dwStatus != CFX_Char::BreakType::kNone);
++m_dwIdentity;
if (!m_pCurLine->m_LinePieces.empty()) {
- if (dwStatus != CFX_BreakType::kPiece)
+ if (dwStatus != CFX_Char::BreakType::kPiece)
m_pCurLine->m_LinePieces.back().m_dwStatus = dwStatus;
return m_pCurLine->m_LinePieces.back().m_dwStatus;
}
if (HasLine()) {
if (m_Lines[m_iReadyLineIndex].m_LinePieces.empty())
- return CFX_BreakType::kNone;
+ return CFX_Char::BreakType::kNone;
- if (dwStatus != CFX_BreakType::kPiece)
+ if (dwStatus != CFX_Char::BreakType::kPiece)
m_Lines[m_iReadyLineIndex].m_LinePieces.back().m_dwStatus = dwStatus;
return m_Lines[m_iReadyLineIndex].m_LinePieces.back().m_dwStatus;
}
if (m_pCurLine->m_LineChars.empty())
- return CFX_BreakType::kNone;
+ return CFX_Char::BreakType::kNone;
CFX_Char* tc = m_pCurLine->GetChar(m_pCurLine->m_LineChars.size() - 1);
tc->m_dwStatus = dwStatus;
- if (dwStatus == CFX_BreakType::kPiece)
+ if (dwStatus == CFX_Char::BreakType::kPiece)
return dwStatus;
m_iReadyLineIndex = m_pCurLine == &m_Lines[0] ? 0 : 1;
@@ -349,7 +349,7 @@
bool CFX_RTFBreak::EndBreak_SplitLine(CFX_BreakLine* pNextLine,
bool bAllChars,
- CFX_BreakType dwStatus) {
+ CFX_Char::BreakType dwStatus) {
bool bDone = false;
if (IsGreaterThanLineWidth(m_pCurLine->GetLineEnd())) {
const CFX_Char* tc =
@@ -398,7 +398,7 @@
bNew = false;
}
- if (i == iLast || pTC->m_dwStatus != CFX_BreakType::kNone ||
+ if (i == iLast || pTC->m_dwStatus != CFX_Char::BreakType::kNone ||
pTC->m_dwIdentity != dwIdentity) {
tp.m_iCharCount = i - j;
if (pTC->m_dwIdentity == dwIdentity) {
@@ -418,7 +418,7 @@
}
void CFX_RTFBreak::EndBreak_BidiLine(std::deque<FX_TPO>* tpos,
- CFX_BreakType dwStatus) {
+ CFX_Char::BreakType dwStatus) {
CFX_Char* pTC;
std::vector<CFX_Char>& chars = m_pCurLine->m_LineChars;
if (!m_bPagination && m_pCurLine->HasArabicChar()) {
@@ -442,7 +442,7 @@
}
CFX_BreakPiece tp;
- tp.m_dwStatus = CFX_BreakType::kPiece;
+ tp.m_dwStatus = CFX_Char::BreakType::kPiece;
tp.m_iStartPos = m_pCurLine->m_iStart;
tp.m_pChars = &chars;
@@ -467,7 +467,7 @@
dwIdentity = pTC->m_dwIdentity;
tp.m_dwIdentity = dwIdentity;
tp.m_pUserData = pTC->m_pUserData;
- tp.m_dwStatus = CFX_BreakType::kPiece;
+ tp.m_dwStatus = CFX_Char::BreakType::kPiece;
++i;
} else if (iBidiLevel != pTC->m_iBidiLevel ||
pTC->m_dwIdentity != dwIdentity) {
@@ -509,7 +509,7 @@
void CFX_RTFBreak::EndBreak_Alignment(const std::deque<FX_TPO>& tpos,
bool bAllChars,
- CFX_BreakType dwStatus) {
+ CFX_Char::BreakType dwStatus) {
int32_t iNetWidth = m_pCurLine->m_iWidth;
int32_t iGapChars = 0;
bool bFind = false;
@@ -549,7 +549,7 @@
int32_t iOffset = m_iLineWidth - iNetWidth;
if (iGapChars > 0 && (m_iAlignment == CFX_RTFLineAlignment::Distributed ||
(m_iAlignment == CFX_RTFLineAlignment::Justified &&
- dwStatus != CFX_BreakType::kParagraph))) {
+ dwStatus != CFX_Char::BreakType::kParagraph))) {
int32_t iStart = -1;
for (const auto& tpo : tpos) {
CFX_BreakPiece& ttp = m_pCurLine->m_LinePieces[tpo.index];
@@ -715,7 +715,7 @@
pCurLine->DecrementArabicCharCount();
pNextLine->IncrementArabicCharCount();
}
- pNextLine->m_LineChars[i].m_dwStatus = CFX_BreakType::kNone;
+ pNextLine->m_LineChars[i].m_dwStatus = CFX_Char::BreakType::kNone;
}
}
diff --git a/xfa/fgas/layout/cfx_rtfbreak.h b/xfa/fgas/layout/cfx_rtfbreak.h
index e056b61..6d2475c 100644
--- a/xfa/fgas/layout/cfx_rtfbreak.h
+++ b/xfa/fgas/layout/cfx_rtfbreak.h
@@ -39,19 +39,19 @@
void AddPositionedTab(float fTabPos);
- CFX_BreakType EndBreak(CFX_BreakType dwStatus);
+ CFX_Char::BreakType EndBreak(CFX_Char::BreakType dwStatus);
size_t GetDisplayPos(const CFX_TextPiece* pPiece,
std::vector<TextCharPos>* pCharPos) const;
- CFX_BreakType AppendChar(wchar_t wch);
+ CFX_Char::BreakType AppendChar(wchar_t wch);
private:
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);
+ CFX_Char::BreakType AppendChar_Control(CFX_Char* pCurChar);
+ CFX_Char::BreakType AppendChar_Arabic(CFX_Char* pCurChar);
+ CFX_Char::BreakType AppendChar_Others(CFX_Char* pCurChar);
bool GetPositionedTab(int32_t* iTabPos) const;
int32_t GetBreakPos(std::vector<CFX_Char>& tca,
@@ -63,11 +63,12 @@
bool bAllChars);
bool EndBreak_SplitLine(CFX_BreakLine* pNextLine,
bool bAllChars,
- CFX_BreakType dwStatus);
- void EndBreak_BidiLine(std::deque<FX_TPO>* tpos, CFX_BreakType dwStatus);
+ CFX_Char::BreakType dwStatus);
+ void EndBreak_BidiLine(std::deque<FX_TPO>* tpos,
+ CFX_Char::BreakType dwStatus);
void EndBreak_Alignment(const std::deque<FX_TPO>& tpos,
bool bAllChars,
- CFX_BreakType dwStatus);
+ CFX_Char::BreakType dwStatus);
bool m_bPagination;
std::vector<int32_t> m_PositionedTabs;
diff --git a/xfa/fgas/layout/cfx_rtfbreak_unittest.cpp b/xfa/fgas/layout/cfx_rtfbreak_unittest.cpp
index 4261a43..b300cd8 100644
--- a/xfa/fgas/layout/cfx_rtfbreak_unittest.cpp
+++ b/xfa/fgas/layout/cfx_rtfbreak_unittest.cpp
@@ -41,9 +41,9 @@
WideString str(L"Input String.");
for (wchar_t ch : str)
- EXPECT_EQ(CFX_BreakType::kNone, rtf_break->AppendChar(ch));
+ EXPECT_EQ(CFX_Char::BreakType::kNone, rtf_break->AppendChar(ch));
- EXPECT_EQ(CFX_BreakType::kParagraph, rtf_break->AppendChar(L'\n'));
+ EXPECT_EQ(CFX_Char::BreakType::kParagraph, rtf_break->AppendChar(L'\n'));
ASSERT_EQ(1, rtf_break->CountBreakPieces());
EXPECT_EQ(str + L"\n", rtf_break->GetBreakPieceUnstable(0)->GetString());
@@ -53,22 +53,22 @@
str = L"Second str.";
for (wchar_t ch : str)
- EXPECT_EQ(CFX_BreakType::kNone, rtf_break->AppendChar(ch));
+ EXPECT_EQ(CFX_Char::BreakType::kNone, rtf_break->AppendChar(ch));
// Force the end of the break at the end of the string.
- rtf_break->EndBreak(CFX_BreakType::kParagraph);
+ rtf_break->EndBreak(CFX_Char::BreakType::kParagraph);
ASSERT_EQ(1, rtf_break->CountBreakPieces());
EXPECT_EQ(str, rtf_break->GetBreakPieceUnstable(0)->GetString());
}
TEST_F(CFX_RTFBreakTest, ControlCharacters) {
auto rtf_break = CreateBreak(FX_LAYOUTSTYLE_ExpandTab);
- EXPECT_EQ(CFX_BreakType::kLine, rtf_break->AppendChar(L'\v'));
- EXPECT_EQ(CFX_BreakType::kPage, rtf_break->AppendChar(L'\f'));
+ EXPECT_EQ(CFX_Char::BreakType::kLine, rtf_break->AppendChar(L'\v'));
+ EXPECT_EQ(CFX_Char::BreakType::kPage, rtf_break->AppendChar(L'\f'));
const wchar_t kUnicodeParagraphSeparator = 0x2029;
- EXPECT_EQ(CFX_BreakType::kParagraph,
+ EXPECT_EQ(CFX_Char::BreakType::kParagraph,
rtf_break->AppendChar(kUnicodeParagraphSeparator));
- EXPECT_EQ(CFX_BreakType::kParagraph, rtf_break->AppendChar(L'\n'));
+ EXPECT_EQ(CFX_Char::BreakType::kParagraph, rtf_break->AppendChar(L'\n'));
ASSERT_EQ(1, rtf_break->CountBreakPieces());
EXPECT_EQ(L"\v", rtf_break->GetBreakPieceUnstable(0)->GetString());
diff --git a/xfa/fgas/layout/cfx_txtbreak.cpp b/xfa/fgas/layout/cfx_txtbreak.cpp
index 5565518..3de42fc 100644
--- a/xfa/fgas/layout/cfx_txtbreak.cpp
+++ b/xfa/fgas/layout/cfx_txtbreak.cpp
@@ -101,34 +101,34 @@
m_eCharType = FX_CHARTYPE::kTab;
}
-CFX_BreakType CFX_TxtBreak::AppendChar_Control(CFX_Char* pCurChar) {
+CFX_Char::BreakType CFX_TxtBreak::AppendChar_Control(CFX_Char* pCurChar) {
m_eCharType = FX_CHARTYPE::kControl;
- CFX_BreakType dwRet = CFX_BreakType::kNone;
+ CFX_Char::BreakType dwRet = CFX_Char::BreakType::kNone;
if (!m_bSingleLine) {
wchar_t wch = pCurChar->char_code();
switch (wch) {
case L'\v':
case 0x2028:
- dwRet = CFX_BreakType::kLine;
+ dwRet = CFX_Char::BreakType::kLine;
break;
case L'\f':
- dwRet = CFX_BreakType::kPage;
+ dwRet = CFX_Char::BreakType::kPage;
break;
case 0x2029:
- dwRet = CFX_BreakType::kParagraph;
+ dwRet = CFX_Char::BreakType::kParagraph;
break;
default:
if (wch == m_wParagraphBreakChar)
- dwRet = CFX_BreakType::kParagraph;
+ dwRet = CFX_Char::BreakType::kParagraph;
break;
}
- if (dwRet != CFX_BreakType::kNone)
+ if (dwRet != CFX_Char::BreakType::kNone)
dwRet = EndBreak(dwRet);
}
return dwRet;
}
-CFX_BreakType CFX_TxtBreak::AppendChar_Arabic(CFX_Char* pCurChar) {
+CFX_Char::BreakType CFX_TxtBreak::AppendChar_Arabic(CFX_Char* pCurChar) {
FX_CHARTYPE chartype = pCurChar->GetCharType();
int32_t& iLineWidth = m_pCurLine->m_iWidth;
wchar_t wForm;
@@ -191,11 +191,11 @@
m_pCurLine->IncrementArabicCharCount();
if (!m_bSingleLine && IsGreaterThanLineWidth(iLineWidth))
- return EndBreak(CFX_BreakType::kLine);
- return CFX_BreakType::kNone;
+ return EndBreak(CFX_Char::BreakType::kLine);
+ return CFX_Char::BreakType::kNone;
}
-CFX_BreakType CFX_TxtBreak::AppendChar_Others(CFX_Char* pCurChar) {
+CFX_Char::BreakType CFX_TxtBreak::AppendChar_Others(CFX_Char* pCurChar) {
FX_CHARTYPE chartype = pCurChar->GetCharType();
int32_t& iLineWidth = m_pCurLine->m_iWidth;
FX_SAFE_INT32 iCharWidth = 0;
@@ -224,37 +224,37 @@
iLineWidth += iCharWidthValid;
if (!m_bSingleLine && chartype != FX_CHARTYPE::kSpace &&
IsGreaterThanLineWidth(iLineWidth)) {
- return EndBreak(CFX_BreakType::kLine);
+ return EndBreak(CFX_Char::BreakType::kLine);
}
- return CFX_BreakType::kNone;
+ return CFX_Char::BreakType::kNone;
}
-CFX_BreakType CFX_TxtBreak::AppendChar(wchar_t wch) {
+CFX_Char::BreakType CFX_TxtBreak::AppendChar(wchar_t wch) {
FX_CHARTYPE chartype = FX_GetCharType(wch);
m_pCurLine->m_LineChars.emplace_back(wch, m_iHorizontalScale,
m_iVerticalScale);
CFX_Char* pCurChar = &m_pCurLine->m_LineChars.back();
pCurChar->m_dwCharStyles = m_iAlignment | (1 << 8);
- CFX_BreakType dwRet1 = CFX_BreakType::kNone;
+ CFX_Char::BreakType dwRet1 = CFX_Char::BreakType::kNone;
if (chartype != FX_CHARTYPE::kCombination &&
GetUnifiedCharType(m_eCharType) != GetUnifiedCharType(chartype) &&
m_eCharType != FX_CHARTYPE::kUnknown && !m_bSingleLine &&
IsGreaterThanLineWidth(m_pCurLine->m_iWidth) &&
(m_eCharType != FX_CHARTYPE::kSpace ||
chartype != FX_CHARTYPE::kControl)) {
- dwRet1 = EndBreak(CFX_BreakType::kLine);
+ dwRet1 = EndBreak(CFX_Char::BreakType::kLine);
if (!m_pCurLine->m_LineChars.empty())
pCurChar = &m_pCurLine->m_LineChars.back();
}
- CFX_BreakType dwRet2 = CFX_BreakType::kNone;
+ CFX_Char::BreakType dwRet2 = CFX_Char::BreakType::kNone;
if (wch == m_wParagraphBreakChar) {
// This is handled in AppendChar_Control, but it seems like \n and \r
// don't get matched as control characters so we go into AppendChar_other
// and never detect the new paragraph ...
- dwRet2 = CFX_BreakType::kParagraph;
+ dwRet2 = CFX_Char::BreakType::kParagraph;
EndBreak(dwRet2);
} else {
switch (chartype) {
@@ -311,7 +311,7 @@
}
void CFX_TxtBreak::EndBreak_BidiLine(std::deque<FX_TPO>* tpos,
- CFX_BreakType dwStatus) {
+ CFX_Char::BreakType dwStatus) {
CFX_BreakPiece tp;
FX_TPO tpo;
CFX_Char* pTC;
@@ -343,7 +343,7 @@
}
CFX_Char::BidiLine(&chars, iBidiNum + 1);
- tp.m_dwStatus = CFX_BreakType::kPiece;
+ tp.m_dwStatus = CFX_Char::BreakType::kPiece;
tp.m_iStartPos = m_pCurLine->m_iStart;
tp.m_pChars = &m_pCurLine->m_LineChars;
int32_t iBidiLevel = -1;
@@ -361,10 +361,10 @@
tp.m_dwCharStyles = pTC->m_dwCharStyles;
tp.m_iHorizontalScale = pTC->horizonal_scale();
tp.m_iVerticalScale = pTC->vertical_scale();
- tp.m_dwStatus = CFX_BreakType::kPiece;
+ tp.m_dwStatus = CFX_Char::BreakType::kPiece;
}
if (iBidiLevel != pTC->m_iBidiLevel ||
- pTC->m_dwStatus != CFX_BreakType::kNone) {
+ pTC->m_dwStatus != CFX_Char::BreakType::kNone) {
if (iBidiLevel == pTC->m_iBidiLevel) {
tp.m_dwStatus = pTC->m_dwStatus;
iCharWidth = pTC->m_iCharWidth;
@@ -414,7 +414,7 @@
void CFX_TxtBreak::EndBreak_Alignment(const std::deque<FX_TPO>& tpos,
bool bAllChars,
- CFX_BreakType dwStatus) {
+ CFX_Char::BreakType dwStatus) {
int32_t iNetWidth = m_pCurLine->m_iWidth;
int32_t iGapChars = 0;
bool bFind = false;
@@ -449,7 +449,7 @@
int32_t iOffset = m_iLineWidth - iNetWidth;
if (iGapChars > 0 && m_iAlignment & CFX_TxtLineAlignment_Justified &&
- dwStatus != CFX_BreakType::kParagraph) {
+ dwStatus != CFX_Char::BreakType::kParagraph) {
int32_t iStart = -1;
for (auto& tpo : tpos) {
CFX_BreakPiece& ttp = m_pCurLine->m_LinePieces[tpo.index];
@@ -485,29 +485,29 @@
}
}
-CFX_BreakType CFX_TxtBreak::EndBreak(CFX_BreakType dwStatus) {
- DCHECK(dwStatus != CFX_BreakType::kNone);
+CFX_Char::BreakType CFX_TxtBreak::EndBreak(CFX_Char::BreakType dwStatus) {
+ DCHECK(dwStatus != CFX_Char::BreakType::kNone);
if (!m_pCurLine->m_LinePieces.empty()) {
- if (dwStatus != CFX_BreakType::kPiece)
+ if (dwStatus != CFX_Char::BreakType::kPiece)
m_pCurLine->m_LinePieces.back().m_dwStatus = dwStatus;
return m_pCurLine->m_LinePieces.back().m_dwStatus;
}
if (HasLine()) {
if (m_Lines[m_iReadyLineIndex].m_LinePieces.empty())
- return CFX_BreakType::kNone;
+ return CFX_Char::BreakType::kNone;
- if (dwStatus != CFX_BreakType::kPiece)
+ if (dwStatus != CFX_Char::BreakType::kPiece)
m_Lines[m_iReadyLineIndex].m_LinePieces.back().m_dwStatus = dwStatus;
return m_Lines[m_iReadyLineIndex].m_LinePieces.back().m_dwStatus;
}
if (m_pCurLine->m_LineChars.empty())
- return CFX_BreakType::kNone;
+ return CFX_Char::BreakType::kNone;
m_pCurLine->m_LineChars.back().m_dwStatus = dwStatus;
- if (dwStatus == CFX_BreakType::kPiece)
+ if (dwStatus == CFX_Char::BreakType::kPiece)
return dwStatus;
m_iReadyLineIndex = m_pCurLine == &m_Lines[0] ? 0 : 1;
@@ -648,7 +648,7 @@
pNextLine->IncrementArabicCharCount();
}
iWidth += std::max(0, pNextLine->m_LineChars[i].m_iCharWidth);
- pNextLine->m_LineChars[i].m_dwStatus = CFX_BreakType::kNone;
+ pNextLine->m_LineChars[i].m_dwStatus = CFX_Char::BreakType::kNone;
}
pNextLine->m_iWidth = iWidth;
}
diff --git a/xfa/fgas/layout/cfx_txtbreak.h b/xfa/fgas/layout/cfx_txtbreak.h
index ba9e6e9..81e157d 100644
--- a/xfa/fgas/layout/cfx_txtbreak.h
+++ b/xfa/fgas/layout/cfx_txtbreak.h
@@ -27,8 +27,9 @@
CFX_TxtLineAlignment_Justified = 1 << 2
};
-inline bool CFX_BreakTypeNoneOrPiece(CFX_BreakType type) {
- return type == CFX_BreakType::kNone || type == CFX_BreakType::kPiece;
+inline bool CFX_BreakTypeNoneOrPiece(CFX_Char::BreakType type) {
+ return type == CFX_Char::BreakType::kNone ||
+ type == CFX_Char::BreakType::kPiece;
}
class CFX_TxtBreak final : public CFX_Break {
@@ -68,25 +69,26 @@
void SetLineWidth(float fLineWidth);
void SetAlignment(int32_t iAlignment);
void SetCombWidth(float fCombWidth);
- CFX_BreakType EndBreak(CFX_BreakType dwStatus);
+ CFX_Char::BreakType EndBreak(CFX_Char::BreakType dwStatus);
size_t GetDisplayPos(const Run* pTxtRun, TextCharPos* pCharPos) const;
std::vector<CFX_RectF> GetCharRects(const Run* pTxtRun, bool bCharBBox) const;
- CFX_BreakType AppendChar(wchar_t wch);
+ CFX_Char::BreakType AppendChar(wchar_t wch);
private:
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);
+ CFX_Char::BreakType AppendChar_Control(CFX_Char* pCurChar);
+ CFX_Char::BreakType AppendChar_Arabic(CFX_Char* pCurChar);
+ CFX_Char::BreakType AppendChar_Others(CFX_Char* pCurChar);
void ResetContextCharStyles();
void EndBreak_SplitLine(CFX_BreakLine* pNextLine, bool bAllChars);
- void EndBreak_BidiLine(std::deque<FX_TPO>* tpos, CFX_BreakType dwStatus);
+ void EndBreak_BidiLine(std::deque<FX_TPO>* tpos,
+ CFX_Char::BreakType dwStatus);
void EndBreak_Alignment(const std::deque<FX_TPO>& tpos,
bool bAllChars,
- CFX_BreakType dwStatus);
+ CFX_Char::BreakType dwStatus);
int32_t GetBreakPos(std::vector<CFX_Char>* pChars,
bool bAllChars,
bool bOnlyBrk,
diff --git a/xfa/fxfa/cxfa_textlayout.cpp b/xfa/fxfa/cxfa_textlayout.cpp
index e6a1135..3904e34 100644
--- a/xfa/fxfa/cxfa_textlayout.cpp
+++ b/xfa/fxfa/cxfa_textlayout.cpp
@@ -722,7 +722,7 @@
if (bRet && m_pLoader)
m_pLoader->pNode = pNode;
else
- EndBreak(CFX_BreakType::kParagraph, pLinePos, bSavePieces);
+ EndBreak(CFX_Char::BreakType::kParagraph, pLinePos, bSavePieces);
}
bool CXFA_TextLayout::LoadRichText(
@@ -874,7 +874,7 @@
m_pLoader->bFilterSpace = true;
}
if (bCurLi)
- EndBreak(CFX_BreakType::kLine, pLinePos, bSavePieces);
+ EndBreak(CFX_Char::BreakType::kLine, pLinePos, bSavePieces);
} else {
if (pContext)
eDisplay = pContext->GetDisplay();
@@ -883,9 +883,9 @@
if (!pContext || bContentNode)
return true;
- CFX_BreakType dwStatus = (eDisplay == CFX_CSSDisplay::Block)
- ? CFX_BreakType::kParagraph
- : CFX_BreakType::kPiece;
+ CFX_Char::BreakType dwStatus = (eDisplay == CFX_CSSDisplay::Block)
+ ? CFX_Char::BreakType::kParagraph
+ : CFX_Char::BreakType::kPiece;
EndBreak(dwStatus, pLinePos, bSavePieces);
if (eDisplay == CFX_CSSDisplay::Block) {
*pLinePos += fSpaceBelow;
@@ -906,7 +906,7 @@
float* pLinePos,
float fSpaceAbove,
bool bSavePieces) {
- CFX_BreakType dwStatus = CFX_BreakType::kNone;
+ CFX_Char::BreakType dwStatus = CFX_Char::BreakType::kNone;
int32_t iChar = 0;
if (m_pLoader)
iChar = m_pLoader->iChar;
@@ -918,14 +918,15 @@
wch = 0x20;
dwStatus = m_pBreak->AppendChar(wch);
- if (dwStatus != CFX_BreakType::kNone && dwStatus != CFX_BreakType::kPiece) {
+ if (dwStatus != CFX_Char::BreakType::kNone &&
+ dwStatus != CFX_Char::BreakType::kPiece) {
AppendTextLine(dwStatus, pLinePos, bSavePieces, false);
if (IsEnd(bSavePieces)) {
if (m_pLoader)
m_pLoader->iChar = i;
return true;
}
- if (dwStatus == CFX_BreakType::kParagraph && m_bRichText)
+ if (dwStatus == CFX_Char::BreakType::kParagraph && m_bRichText)
*pLinePos += fSpaceAbove;
}
}
@@ -943,11 +944,12 @@
return false;
}
-void CXFA_TextLayout::EndBreak(CFX_BreakType dwStatus,
+void CXFA_TextLayout::EndBreak(CFX_Char::BreakType dwStatus,
float* pLinePos,
bool bSavePieces) {
dwStatus = m_pBreak->EndBreak(dwStatus);
- if (dwStatus != CFX_BreakType::kNone && dwStatus != CFX_BreakType::kPiece)
+ if (dwStatus != CFX_Char::BreakType::kNone &&
+ dwStatus != CFX_Char::BreakType::kPiece)
AppendTextLine(dwStatus, pLinePos, bSavePieces, true);
}
@@ -1006,7 +1008,7 @@
}
}
-void CXFA_TextLayout::AppendTextLine(CFX_BreakType dwStatus,
+void CXFA_TextLayout::AppendTextLine(CFX_Char::BreakType dwStatus,
float* pLinePos,
bool bSavePieces,
bool bEndBreak) {
@@ -1110,7 +1112,7 @@
}
m_pBreak->ClearBreakPieces();
- if (dwStatus == CFX_BreakType::kParagraph) {
+ if (dwStatus == CFX_Char::BreakType::kParagraph) {
m_pBreak->Reset();
if (!pStyle && bEndBreak) {
CXFA_Para* para = m_pTextProvider->GetParaIfExists();
diff --git a/xfa/fxfa/cxfa_textlayout.h b/xfa/fxfa/cxfa_textlayout.h
index 7264ebd..398bb0b 100644
--- a/xfa/fxfa/cxfa_textlayout.h
+++ b/xfa/fxfa/cxfa_textlayout.h
@@ -147,11 +147,11 @@
float* pLinePos,
float fSpaceAbove,
bool bSavePieces);
- void AppendTextLine(CFX_BreakType dwStatus,
+ void AppendTextLine(CFX_Char::BreakType dwStatus,
float* pLinePos,
bool bSavePieces,
bool bEndBreak);
- void EndBreak(CFX_BreakType dwStatus, float* pLinePos, bool bDefault);
+ void EndBreak(CFX_Char::BreakType dwStatus, float* pLinePos, bool bDefault);
bool IsEnd(bool bSavePieces);
void UpdateAlign(float fHeight, float fBottom);
void RenderString(CFX_RenderDevice* pDevice,