diff options
Diffstat (limited to 'xfa/fgas/layout')
-rw-r--r-- | xfa/fgas/layout/fgas_rtfbreak.cpp | 24 | ||||
-rw-r--r-- | xfa/fgas/layout/fgas_rtfbreak.h | 4 | ||||
-rw-r--r-- | xfa/fgas/layout/fgas_textbreak.cpp | 52 | ||||
-rw-r--r-- | xfa/fgas/layout/fgas_textbreak.h | 10 |
4 files changed, 35 insertions, 55 deletions
diff --git a/xfa/fgas/layout/fgas_rtfbreak.cpp b/xfa/fgas/layout/fgas_rtfbreak.cpp index 8f1761dea8..c725dfb268 100644 --- a/xfa/fgas/layout/fgas_rtfbreak.cpp +++ b/xfa/fgas/layout/fgas_rtfbreak.cpp @@ -34,7 +34,7 @@ CFX_RTFBreak::CFX_RTFBreak(uint32_t dwLayoutStyles) m_dwIdentity(0), m_pCurLine(nullptr), m_iTolerance(0), - m_iReady(-1) { + m_iReadyLineIndex(-1) { m_pCurLine = &m_RTFLine[0]; SetBreakStatus(); @@ -386,10 +386,10 @@ CFX_BreakType CFX_RTFBreak::EndBreak(CFX_BreakType dwStatus) { } if (HasRTFLine()) { - if (!m_RTFLine[m_iReady].m_LinePieces.empty()) { + if (!m_RTFLine[m_iReadyLineIndex].m_LinePieces.empty()) { if (dwStatus != CFX_BreakType::Piece) - m_RTFLine[m_iReady].m_LinePieces.back().m_dwStatus = dwStatus; - return m_RTFLine[m_iReady].m_LinePieces.back().m_dwStatus; + m_RTFLine[m_iReadyLineIndex].m_LinePieces.back().m_dwStatus = dwStatus; + return m_RTFLine[m_iReadyLineIndex].m_LinePieces.back().m_dwStatus; } return CFX_BreakType::None; } @@ -403,8 +403,8 @@ CFX_BreakType CFX_RTFBreak::EndBreak(CFX_BreakType dwStatus) { if (dwStatus == CFX_BreakType::Piece) return dwStatus; - m_iReady = m_pCurLine == &m_RTFLine[0] ? 0 : 1; - CFX_RTFLine* pNextLine = &m_RTFLine[1 - m_iReady]; + m_iReadyLineIndex = m_pCurLine == &m_RTFLine[0] ? 0 : 1; + CFX_RTFLine* pNextLine = &m_RTFLine[1 - m_iReadyLineIndex]; bool bAllChars = m_iAlignment == CFX_RTFLineAlignment::Justified || m_iAlignment == CFX_RTFLineAlignment::Distributed; @@ -794,9 +794,9 @@ void CFX_RTFBreak::SplitTextLine(CFX_RTFLine* pCurLine, } int32_t CFX_RTFBreak::CountBreakPieces() const { - return HasRTFLine() - ? pdfium::CollectionSize<int32_t>(m_RTFLine[m_iReady].m_LinePieces) - : 0; + return HasRTFLine() ? pdfium::CollectionSize<int32_t>( + m_RTFLine[m_iReadyLineIndex].m_LinePieces) + : 0; } const CFX_RTFPiece* CFX_RTFBreak::GetBreakPieceUnstable(int32_t index) const { @@ -804,7 +804,7 @@ const CFX_RTFPiece* CFX_RTFBreak::GetBreakPieceUnstable(int32_t index) const { return nullptr; const std::vector<CFX_RTFPiece>& pRTFPieces = - m_RTFLine[m_iReady].m_LinePieces; + m_RTFLine[m_iReadyLineIndex].m_LinePieces; if (index < 0 || index >= pdfium::CollectionSize<int32_t>(pRTFPieces)) return nullptr; return &pRTFPieces[index]; @@ -812,9 +812,9 @@ const CFX_RTFPiece* CFX_RTFBreak::GetBreakPieceUnstable(int32_t index) const { void CFX_RTFBreak::ClearBreakPieces() { if (HasRTFLine()) - m_RTFLine[m_iReady].Clear(); + m_RTFLine[m_iReadyLineIndex].Clear(); - m_iReady = -1; + m_iReadyLineIndex = -1; } void CFX_RTFBreak::Reset() { diff --git a/xfa/fgas/layout/fgas_rtfbreak.h b/xfa/fgas/layout/fgas_rtfbreak.h index 5d29e0e84f..9d4d29b034 100644 --- a/xfa/fgas/layout/fgas_rtfbreak.h +++ b/xfa/fgas/layout/fgas_rtfbreak.h @@ -164,7 +164,7 @@ class CFX_RTFBreak { void FontChanged(); void SetBreakStatus(); CFX_RTFChar* GetLastChar(int32_t index) const; - bool HasRTFLine() const { return m_iReady >= 0; } + bool HasRTFLine() const { return m_iReadyLineIndex >= 0; } FX_CHARTYPE GetUnifiedCharType(FX_CHARTYPE chartype) const; int32_t GetLastPositionedTab() const; bool GetPositionedTab(int32_t* iTabPos) const; @@ -206,7 +206,7 @@ class CFX_RTFBreak { CFX_RTFLine m_RTFLine[2]; CFX_RTFLine* m_pCurLine; int32_t m_iTolerance; - int8_t m_iReady; + int8_t m_iReadyLineIndex; }; #endif // XFA_FGAS_LAYOUT_FGAS_RTFBREAK_H_ diff --git a/xfa/fgas/layout/fgas_textbreak.cpp b/xfa/fgas/layout/fgas_textbreak.cpp index a6473842f0..2d3b8b9f48 100644 --- a/xfa/fgas/layout/fgas_textbreak.cpp +++ b/xfa/fgas/layout/fgas_textbreak.cpp @@ -43,11 +43,11 @@ CFX_TxtBreak::CFX_TxtBreak() m_dwLayoutStyles(0), m_bSingleLine(false), m_bCombText(false), + m_bEquidistant(true), m_iArabicContext(1), m_iCurArabicContext(1), m_pFont(nullptr), m_iFontSize(240), - m_bEquidistant(true), m_iTabWidth(720000), m_wDefChar(0xFEFF), m_wParagBreakChar(L'\n'), @@ -57,11 +57,11 @@ CFX_TxtBreak::CFX_TxtBreak() m_iCombWidth(360000), m_eCharType(FX_CHARTYPE_Unknown), m_pCurLine(nullptr), - m_iReady(0), m_iTolerance(0), m_iHorScale(100), - m_iCharSpace(0) { - m_pCurLine = &m_TxtLine1; + m_iCharSpace(0), + m_iReadyLineIndex(-1) { + m_pCurLine = &m_TxtLine[0]; ResetArabicContext(); } @@ -194,19 +194,6 @@ CFX_TxtChar* CFX_TxtBreak::GetLastChar(int32_t index, bool bOmitChar) const { return nullptr; } -const CFX_TxtLine* CFX_TxtBreak::GetTxtLine() const { - if (m_iReady == 1) - return &m_TxtLine1; - if (m_iReady == 2) - return &m_TxtLine2; - return nullptr; -} - -const CFX_TxtPieceArray* CFX_TxtBreak::GetTxtPieces() const { - const CFX_TxtLine* pTxtLine = GetTxtLine(); - return pTxtLine ? &pTxtLine->m_LinePieces : nullptr; -} - inline FX_CHARTYPE CFX_TxtBreak::GetUnifiedCharType( FX_CHARTYPE chartype) const { return chartype >= FX_CHARTYPE_ArabicAlef ? FX_CHARTYPE_Arabic : chartype; @@ -650,9 +637,8 @@ CFX_BreakType CFX_TxtBreak::EndBreak(CFX_BreakType dwStatus) { dwStatus = pLastPiece->m_dwStatus; return dwStatus; } else { - const CFX_TxtLine* pLastLine = GetTxtLine(); - if (pLastLine) { - pCurPieces = &pLastLine->m_LinePieces; + if (HasTxtLine()) { + pCurPieces = &m_TxtLine[m_iReadyLineIndex].m_LinePieces; iCount = pCurPieces->GetSize(); if (iCount-- > 0) { CFX_TxtPiece* pLastPiece = pCurPieces->GetPtrAt(iCount); @@ -675,9 +661,8 @@ CFX_BreakType CFX_TxtBreak::EndBreak(CFX_BreakType dwStatus) { return dwStatus; } - m_iReady = m_pCurLine == &m_TxtLine1 ? 1 : 2; - CFX_TxtLine* pNextLine = - m_pCurLine == &m_TxtLine1 ? &m_TxtLine2 : &m_TxtLine1; + m_iReadyLineIndex = m_pCurLine == &m_TxtLine[0] ? 0 : 1; + CFX_TxtLine* pNextLine = &m_TxtLine[1 - m_iReadyLineIndex]; bool bAllChars = m_iCurAlignment > CFX_TxtLineAlignment_Right; if (!EndBreak_SplitLine(pNextLine, bAllChars)) { std::deque<FX_TPO> tpos; @@ -831,24 +816,21 @@ void CFX_TxtBreak::SplitTextLine(CFX_TxtLine* pCurLine, } int32_t CFX_TxtBreak::CountBreakPieces() const { - const CFX_TxtPieceArray* pTxtPieces = GetTxtPieces(); - return pTxtPieces ? pTxtPieces->GetSize() : 0; + return HasTxtLine() ? m_TxtLine[m_iReadyLineIndex].m_LinePieces.GetSize() : 0; } const CFX_TxtPiece* CFX_TxtBreak::GetBreakPiece(int32_t index) const { - const CFX_TxtPieceArray* pTxtPieces = GetTxtPieces(); - if (!pTxtPieces) + if (!HasTxtLine()) return nullptr; - if (index < 0 || index >= pTxtPieces->GetSize()) + if (index < 0 || index >= m_TxtLine[m_iReadyLineIndex].m_LinePieces.GetSize()) return nullptr; - return pTxtPieces->GetPtrAt(index); + return m_TxtLine[m_iReadyLineIndex].m_LinePieces.GetPtrAt(index); } void CFX_TxtBreak::ClearBreakPieces() { - const CFX_TxtLine* pTxtLine = GetTxtLine(); - if (pTxtLine) - const_cast<CFX_TxtLine*>(pTxtLine)->RemoveAll(true); - m_iReady = 0; + if (HasTxtLine()) + m_TxtLine[m_iReadyLineIndex].RemoveAll(true); + m_iReadyLineIndex = -1; } void CFX_TxtBreak::Reset() { @@ -856,8 +838,8 @@ void CFX_TxtBreak::Reset() { m_iArabicContext = 1; m_iCurArabicContext = 1; ResetArabicContext(); - m_TxtLine1.RemoveAll(true); - m_TxtLine2.RemoveAll(true); + m_TxtLine[0].RemoveAll(true); + m_TxtLine[1].RemoveAll(true); } struct FX_FORMCHAR { diff --git a/xfa/fgas/layout/fgas_textbreak.h b/xfa/fgas/layout/fgas_textbreak.h index 513912d409..6d2582f4e1 100644 --- a/xfa/fgas/layout/fgas_textbreak.h +++ b/xfa/fgas/layout/fgas_textbreak.h @@ -193,8 +193,7 @@ class CFX_TxtBreak { void FontChanged(); void SetBreakStatus(); CFX_TxtChar* GetLastChar(int32_t index, bool bOmitChar = true) const; - const CFX_TxtLine* GetTxtLine() const; - const CFX_TxtPieceArray* GetTxtPieces() const; + bool HasTxtLine() const { return m_iReadyLineIndex >= 0; } FX_CHARTYPE GetUnifiedCharType(FX_CHARTYPE dwType) const; void ResetArabicContext(); void ResetContextCharStyles(); @@ -215,11 +214,11 @@ class CFX_TxtBreak { uint32_t m_dwLayoutStyles; bool m_bSingleLine; bool m_bCombText; + bool m_bEquidistant; int32_t m_iArabicContext; int32_t m_iCurArabicContext; CFX_RetainPtr<CFGAS_GEFont> m_pFont; int32_t m_iFontSize; - bool m_bEquidistant; int32_t m_iTabWidth; FX_WCHAR m_wDefChar; FX_WCHAR m_wParagBreakChar; @@ -229,13 +228,12 @@ class CFX_TxtBreak { int32_t m_iCombWidth; FX_CHARTYPE m_eCharType; int32_t m_iCurAlignment; - CFX_TxtLine m_TxtLine1; - CFX_TxtLine m_TxtLine2; + CFX_TxtLine m_TxtLine[2]; CFX_TxtLine* m_pCurLine; - int32_t m_iReady; int32_t m_iTolerance; int32_t m_iHorScale; int32_t m_iCharSpace; + int8_t m_iReadyLineIndex; }; #endif // XFA_FGAS_LAYOUT_FGAS_TEXTBREAK_H_ |