• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "core/fxcrt/span.h"
17 #include "xfa/fgas/layout/cfgas_break.h"
18 
19 class CFGAS_TextPiece;
20 class CFGAS_TextUserData;
21 class TextCharPos;
22 
23 class CFGAS_RTFBreak final : public CFGAS_Break {
24  public:
25   enum class LineAlignment : uint8_t {
26     Left = 0,
27     Center,
28     Right,
29     Justified,
30     Distributed
31   };
32 
33   explicit CFGAS_RTFBreak(Mask<LayoutStyle> dwLayoutStyles);
34   ~CFGAS_RTFBreak() override;
35 
36   void SetLineStartPos(float fLinePos);
37 
SetAlignment(LineAlignment align)38   void SetAlignment(LineAlignment align) { m_iAlignment = align; }
39   void SetUserData(const RetainPtr<CFGAS_TextUserData>& pUserData);
40 
41   void AddPositionedTab(float fTabPos);
42 
43   CFGAS_Char::BreakType EndBreak(CFGAS_Char::BreakType dwStatus);
44 
45   size_t GetDisplayPos(const CFGAS_TextPiece* pPiece,
46                        pdfium::span<TextCharPos> pCharPos) const;
47 
48   CFGAS_Char::BreakType AppendChar(wchar_t wch);
49 
50  private:
51   void AppendChar_Combination(CFGAS_Char* pCurChar);
52   void AppendChar_Tab(CFGAS_Char* pCurChar);
53   CFGAS_Char::BreakType AppendChar_Control(CFGAS_Char* pCurChar);
54   CFGAS_Char::BreakType AppendChar_Arabic(CFGAS_Char* pCurChar);
55   CFGAS_Char::BreakType AppendChar_Others(CFGAS_Char* pCurChar);
56   bool GetPositionedTab(int32_t* iTabPos) const;
57 
58   int32_t GetBreakPos(std::vector<CFGAS_Char>& tca,
59                       bool bAllChars,
60                       bool bOnlyBrk,
61                       int32_t* pEndPos);
62   void SplitTextLine(CFGAS_BreakLine* pCurLine,
63                      CFGAS_BreakLine* pNextLine,
64                      bool bAllChars);
65   bool EndBreakSplitLine(CFGAS_BreakLine* pNextLine,
66                          bool bAllChars,
67                          CFGAS_Char::BreakType dwStatus);
68   std::deque<TPO> EndBreakBidiLine(CFGAS_Char::BreakType dwStatus);
69   void EndBreakAlignment(const std::deque<TPO>& tpos,
70                          bool bAllChars,
71                          CFGAS_Char::BreakType dwStatus);
72 
73   bool m_bPagination = false;
74   LineAlignment m_iAlignment = LineAlignment::Left;
75   std::vector<int32_t> m_PositionedTabs;
76   RetainPtr<CFGAS_TextUserData> m_pUserData;
77 };
78 
79 #endif  // XFA_FGAS_LAYOUT_CFGAS_RTFBREAK_H_
80