From 893822aa5b6254591f8e80fbffcbb4fa6ad849aa Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Mon, 13 Mar 2017 15:32:07 -0400 Subject: Merge text breaking helper classes. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Commit-Queue: dsinclair --- xfa/fgas/layout/fgas_rtfbreak.h | 104 ++++++---------------------------------- 1 file changed, 14 insertions(+), 90 deletions(-) (limited to 'xfa/fgas/layout/fgas_rtfbreak.h') 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((*m_pChars)[i].m_wCharCode); - return ret; - } - - std::vector GetWidths() const { - std::vector 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* m_pChars; // not owned. - CFX_RetainPtr m_pUserData; -}; - -class CFX_RTFLine { - public: - CFX_RTFLine(); - ~CFX_RTFLine(); - - int32_t CountChars() const { - return pdfium::CollectionSize(m_LineChars); - } - - CFX_RTFChar& GetChar(int32_t index) { - ASSERT(index >= 0 && index < pdfium::CollectionSize(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 m_LineChars; - std::vector 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& tca, + int32_t GetBreakPos(std::vector& 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* tpos, CFX_BreakType dwStatus); @@ -202,8 +126,8 @@ class CFX_RTFBreak { CFX_RetainPtr 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; }; -- cgit v1.2.3