diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2017-03-13 15:32:07 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-03-14 14:13:24 +0000 |
commit | 893822aa5b6254591f8e80fbffcbb4fa6ad849aa (patch) | |
tree | 74e20ab6378d515c12a1ec9b9fc70d8e309b361b /xfa/fgas/layout/fgas_textbreak.h | |
parent | 80e370c7d8b6541f59d98b6cbfbaae51f7e139da (diff) | |
download | pdfium-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/fgas_textbreak.h')
-rw-r--r-- | xfa/fgas/layout/fgas_textbreak.h | 121 |
1 files changed, 16 insertions, 105 deletions
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; |