1 // Copyright 2014 The PDFium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 6 7 #ifndef XFA_FGAS_LAYOUT_CFGAS_RTFBREAK_H_ 8 #define XFA_FGAS_LAYOUT_CFGAS_RTFBREAK_H_ 9 10 #include <deque> 11 #include <vector> 12 13 #include "core/fxcrt/fx_coordinates.h" 14 #include "core/fxcrt/fx_unicode.h" 15 #include "core/fxcrt/retain_ptr.h" 16 #include "xfa/fgas/layout/cfgas_break.h" 17 18 class CFGAS_TextPiece; 19 class CFGAS_TextUserData; 20 class TextCharPos; 21 22 class CFGAS_RTFBreak final : public CFGAS_Break { 23 public: 24 enum class LineAlignment : uint8_t { 25 Left = 0, 26 Center, 27 Right, 28 Justified, 29 Distributed 30 }; 31 32 explicit CFGAS_RTFBreak(Mask<LayoutStyle> dwLayoutStyles); 33 ~CFGAS_RTFBreak() override; 34 35 void SetLineStartPos(float fLinePos); 36 SetAlignment(LineAlignment align)37 void SetAlignment(LineAlignment align) { m_iAlignment = align; } 38 void SetUserData(const RetainPtr<CFGAS_TextUserData>& pUserData); 39 40 void AddPositionedTab(float fTabPos); 41 42 CFGAS_Char::BreakType EndBreak(CFGAS_Char::BreakType dwStatus); 43 44 size_t GetDisplayPos(const CFGAS_TextPiece* pPiece, 45 std::vector<TextCharPos>* pCharPos) const; 46 47 CFGAS_Char::BreakType AppendChar(wchar_t wch); 48 49 private: 50 void AppendChar_Combination(CFGAS_Char* pCurChar); 51 void AppendChar_Tab(CFGAS_Char* pCurChar); 52 CFGAS_Char::BreakType AppendChar_Control(CFGAS_Char* pCurChar); 53 CFGAS_Char::BreakType AppendChar_Arabic(CFGAS_Char* pCurChar); 54 CFGAS_Char::BreakType AppendChar_Others(CFGAS_Char* pCurChar); 55 bool GetPositionedTab(int32_t* iTabPos) const; 56 57 int32_t GetBreakPos(std::vector<CFGAS_Char>& tca, 58 bool bAllChars, 59 bool bOnlyBrk, 60 int32_t* pEndPos); 61 void SplitTextLine(CFGAS_BreakLine* pCurLine, 62 CFGAS_BreakLine* pNextLine, 63 bool bAllChars); 64 bool EndBreakSplitLine(CFGAS_BreakLine* pNextLine, 65 bool bAllChars, 66 CFGAS_Char::BreakType dwStatus); 67 std::deque<TPO> EndBreakBidiLine(CFGAS_Char::BreakType dwStatus); 68 void EndBreakAlignment(const std::deque<TPO>& tpos, 69 bool bAllChars, 70 CFGAS_Char::BreakType dwStatus); 71 72 bool m_bPagination = false; 73 LineAlignment m_iAlignment = LineAlignment::Left; 74 std::vector<int32_t> m_PositionedTabs; 75 RetainPtr<CFGAS_TextUserData> m_pUserData; 76 }; 77 78 #endif // XFA_FGAS_LAYOUT_CFGAS_RTFBREAK_H_ 79