xref: /aosp_15_r20/external/pdfium/xfa/fgas/layout/cfgas_breakpiece.h (revision 3ac0a46f773bac49fa9476ec2b1cf3f8da5ec3a4)
1 // Copyright 2017 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_BREAKPIECE_H_
8 #define XFA_FGAS_LAYOUT_CFGAS_BREAKPIECE_H_
9 
10 #include <vector>
11 
12 #include "core/fxcrt/retain_ptr.h"
13 #include "core/fxcrt/unowned_ptr.h"
14 #include "core/fxcrt/widestring.h"
15 #include "xfa/fgas/layout/cfgas_char.h"
16 
17 class CFGAS_TextUserData;
18 
19 class CFGAS_BreakPiece {
20  public:
21   CFGAS_BreakPiece();
22   CFGAS_BreakPiece(const CFGAS_BreakPiece& other);
23   ~CFGAS_BreakPiece();
24 
25   int32_t GetEndPos() const;
26 
27   // TODO(thestig): When GetCharCount() returns size_t, remove this.
28   size_t GetLength() const;
29 
30   CFGAS_Char* GetChar(int32_t index) const;
31   CFGAS_Char* GetChar(size_t index) const;
32   WideString GetString() const;
33   std::vector<int32_t> GetWidths() const;
34 
GetStatus()35   CFGAS_Char::BreakType GetStatus() const { return m_dwStatus; }
SetStatus(CFGAS_Char::BreakType status)36   void SetStatus(CFGAS_Char::BreakType status) { m_dwStatus = status; }
37 
GetStartPos()38   int32_t GetStartPos() const { return m_iStartPos; }
SetStartPos(int32_t pos)39   void SetStartPos(int32_t pos) { m_iStartPos = pos; }
IncrementStartPos(int32_t count)40   void IncrementStartPos(int32_t count) { m_iStartPos += count; }
41 
GetWidth()42   int32_t GetWidth() const { return m_iWidth; }
SetWidth(int32_t width)43   void SetWidth(int32_t width) { m_iWidth = width; }
IncrementWidth(int32_t width)44   void IncrementWidth(int32_t width) { m_iWidth += width; }
45 
GetStartChar()46   int32_t GetStartChar() const { return m_iStartChar; }
SetStartChar(int32_t pos)47   void SetStartChar(int32_t pos) { m_iStartChar = pos; }
48 
GetCharCount()49   int32_t GetCharCount() const { return m_iCharCount; }
SetCharCount(int32_t count)50   void SetCharCount(int32_t count) { m_iCharCount = count; }
51 
GetBidiLevel()52   int32_t GetBidiLevel() const { return m_iBidiLevel; }
SetBidiLevel(int32_t level)53   void SetBidiLevel(int32_t level) { m_iBidiLevel = level; }
54 
GetBidiPos()55   int32_t GetBidiPos() const { return m_iBidiPos; }
SetBidiPos(int32_t pos)56   void SetBidiPos(int32_t pos) { m_iBidiPos = pos; }
57 
GetFontSize()58   int32_t GetFontSize() const { return m_iFontSize; }
SetFontSize(int32_t font_size)59   void SetFontSize(int32_t font_size) { m_iFontSize = font_size; }
60 
GetHorizontalScale()61   int32_t GetHorizontalScale() const { return m_iHorizontalScale; }
SetHorizontalScale(int32_t scale)62   void SetHorizontalScale(int32_t scale) { m_iHorizontalScale = scale; }
63 
GetVerticalScale()64   int32_t GetVerticalScale() const { return m_iVerticalScale; }
SetVerticalScale(int32_t scale)65   void SetVerticalScale(int32_t scale) { m_iVerticalScale = scale; }
66 
GetCharStyles()67   uint32_t GetCharStyles() const { return m_dwCharStyles; }
SetCharStyles(uint32_t styles)68   void SetCharStyles(uint32_t styles) { m_dwCharStyles = styles; }
69 
SetChars(std::vector<CFGAS_Char> * chars)70   void SetChars(std::vector<CFGAS_Char>* chars) { m_pChars = chars; }
71 
GetUserData()72   const CFGAS_TextUserData* GetUserData() const { return m_pUserData.Get(); }
SetUserData(const RetainPtr<CFGAS_TextUserData> & user_data)73   void SetUserData(const RetainPtr<CFGAS_TextUserData>& user_data) {
74     m_pUserData = user_data;
75   }
76 
77  private:
78   CFGAS_Char::BreakType m_dwStatus = CFGAS_Char::BreakType::kPiece;
79   int32_t m_iStartPos = 0;
80   int32_t m_iWidth = -1;
81   int32_t m_iStartChar = 0;
82   int32_t m_iCharCount = 0;
83   int32_t m_iBidiLevel = 0;
84   int32_t m_iBidiPos = 0;
85   int32_t m_iFontSize = 0;
86   int32_t m_iHorizontalScale = 100;
87   int32_t m_iVerticalScale = 100;
88   uint32_t m_dwCharStyles = 0;
89   UnownedPtr<std::vector<CFGAS_Char>> m_pChars;
90   RetainPtr<CFGAS_TextUserData> m_pUserData;
91 };
92 
93 #endif  // XFA_FGAS_LAYOUT_CFGAS_BREAKPIECE_H_
94