OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #ifndef XFA_FDE_TTO_FDE_TEXTOUT_H_ | 7 #ifndef XFA_FDE_TTO_FDE_TEXTOUT_H_ |
8 #define XFA_FDE_TTO_FDE_TEXTOUT_H_ | 8 #define XFA_FDE_TTO_FDE_TEXTOUT_H_ |
9 | 9 |
10 #include "core/fxge/include/fx_dib.h" | 10 #include "core/fxge/include/fx_dib.h" |
11 #include "core/fxge/include/fx_ge.h" | 11 #include "core/fxge/include/fx_ge.h" |
| 12 #include "xfa/fde/fde_object.h" |
| 13 #include "xfa/fgas/crt/fgas_utils.h" |
12 #include "xfa/fgas/font/fgas_font.h" | 14 #include "xfa/fgas/font/fgas_font.h" |
| 15 #include "xfa/fgas/layout/fgas_textbreak.h" |
13 | 16 |
14 #define FDE_TTOSTYLE_Underline 0x0001 | 17 #define FDE_TTOSTYLE_Underline 0x0001 |
15 #define FDE_TTOSTYLE_Strikeout 0x0002 | 18 #define FDE_TTOSTYLE_Strikeout 0x0002 |
16 #define FDE_TTOSTYLE_VerticalLayout 0x0004 | 19 #define FDE_TTOSTYLE_VerticalLayout 0x0004 |
17 #define FDE_TTOSTYLE_SingleLine 0x0010 | 20 #define FDE_TTOSTYLE_SingleLine 0x0010 |
18 #define FDE_TTOSTYLE_ExpandTab 0x0020 | 21 #define FDE_TTOSTYLE_ExpandTab 0x0020 |
19 #define FDE_TTOSTYLE_HotKey 0x0040 | 22 #define FDE_TTOSTYLE_HotKey 0x0040 |
20 #define FDE_TTOSTYLE_Ellipsis 0x0080 | 23 #define FDE_TTOSTYLE_Ellipsis 0x0080 |
21 #define FDE_TTOSTYLE_LineWrap 0x0100 | 24 #define FDE_TTOSTYLE_LineWrap 0x0100 |
22 #define FDE_TTOSTYLE_ArabicShapes 0x0200 | 25 #define FDE_TTOSTYLE_ArabicShapes 0x0200 |
23 #define FDE_TTOSTYLE_RTL 0x0400 | 26 #define FDE_TTOSTYLE_RTL 0x0400 |
24 #define FDE_TTOSTYLE_ArabicContext 0x0800 | 27 #define FDE_TTOSTYLE_ArabicContext 0x0800 |
25 #define FDE_TTOSTYLE_LastLineHeight 0x1000 | 28 #define FDE_TTOSTYLE_LastLineHeight 0x1000 |
26 #define FDE_TTOALIGNMENT_TopLeft 0 | 29 #define FDE_TTOALIGNMENT_TopLeft 0 |
27 #define FDE_TTOALIGNMENT_TopCenter 1 | 30 #define FDE_TTOALIGNMENT_TopCenter 1 |
28 #define FDE_TTOALIGNMENT_TopRight 2 | 31 #define FDE_TTOALIGNMENT_TopRight 2 |
29 #define FDE_TTOALIGNMENT_TopAuto 3 | 32 #define FDE_TTOALIGNMENT_TopAuto 3 |
30 #define FDE_TTOALIGNMENT_CenterLeft 4 | 33 #define FDE_TTOALIGNMENT_CenterLeft 4 |
31 #define FDE_TTOALIGNMENT_Center 5 | 34 #define FDE_TTOALIGNMENT_Center 5 |
32 #define FDE_TTOALIGNMENT_CenterRight 6 | 35 #define FDE_TTOALIGNMENT_CenterRight 6 |
33 #define FDE_TTOALIGNMENT_CenterAuto 7 | 36 #define FDE_TTOALIGNMENT_CenterAuto 7 |
34 #define FDE_TTOALIGNMENT_BottomLeft 8 | 37 #define FDE_TTOALIGNMENT_BottomLeft 8 |
35 #define FDE_TTOALIGNMENT_BottomCenter 9 | 38 #define FDE_TTOALIGNMENT_BottomCenter 9 |
36 #define FDE_TTOALIGNMENT_BottomRight 10 | 39 #define FDE_TTOALIGNMENT_BottomRight 10 |
37 #define FDE_TTOALIGNMENT_BottomAuto 11 | 40 #define FDE_TTOALIGNMENT_BottomAuto 11 |
38 | 41 |
39 class IFDE_TextOut { | 42 class CFDE_RenderDevice; |
| 43 class CFX_TxtBreak; |
| 44 |
| 45 struct FDE_TTOPIECE { |
| 46 int32_t iStartChar; |
| 47 int32_t iChars; |
| 48 uint32_t dwCharStyles; |
| 49 CFX_RectF rtPiece; |
| 50 }; |
| 51 typedef CFX_MassArrayTemplate<FDE_TTOPIECE> CFDE_TTOPieceArray; |
| 52 |
| 53 class CFDE_TTOLine : public CFX_Target { |
40 public: | 54 public: |
41 static IFDE_TextOut* Create(); | 55 CFDE_TTOLine(); |
42 virtual ~IFDE_TextOut() {} | 56 CFDE_TTOLine(const CFDE_TTOLine& ttoLine); |
43 virtual void Release() = 0; | 57 ~CFDE_TTOLine(); |
44 virtual void SetFont(IFX_Font* pFont) = 0; | 58 int32_t AddPiece(int32_t index, const FDE_TTOPIECE& ttoPiece); |
45 virtual void SetFontSize(FX_FLOAT fFontSize) = 0; | 59 int32_t GetSize() const; |
46 virtual void SetTextColor(FX_ARGB color) = 0; | 60 FDE_TTOPIECE* GetPtrAt(int32_t index); |
47 virtual void SetStyles(uint32_t dwStyles) = 0; | 61 void RemoveLast(int32_t iCount); |
48 virtual void SetTabWidth(FX_FLOAT fTabWidth) = 0; | 62 void RemoveAll(FX_BOOL bLeaveMemory); |
49 virtual void SetEllipsisString(const CFX_WideString& wsEllipsis) = 0; | 63 |
50 virtual void SetParagraphBreakChar(FX_WCHAR wch) = 0; | 64 FX_BOOL m_bNewReload; |
51 virtual void SetAlignment(int32_t iAlignment) = 0; | 65 CFDE_TTOPieceArray m_pieces; |
52 virtual void SetLineSpace(FX_FLOAT fLineSpace) = 0; | 66 |
53 virtual void SetDIBitmap(CFX_DIBitmap* pDIB) = 0; | 67 protected: |
54 virtual void SetRenderDevice(CFX_RenderDevice* pDevice) = 0; | 68 int32_t m_iPieceCount; |
55 virtual void SetClipRect(const CFX_Rect& rtClip) = 0; | 69 }; |
56 virtual void SetClipRect(const CFX_RectF& rtClip) = 0; | 70 typedef CFX_ObjectMassArrayTemplate<CFDE_TTOLine> CFDE_TTOLineArray; |
57 virtual void SetMatrix(const CFX_Matrix& matrix) = 0; | 71 |
58 virtual void SetLineBreakTolerance(FX_FLOAT fTolerance) = 0; | 72 class CFDE_TextOut : public CFX_Target { |
59 virtual void CalcSize(const FX_WCHAR* pwsStr, | 73 public: |
60 int32_t iLength, | 74 CFDE_TextOut(); |
61 CFX_Size& size) = 0; | 75 ~CFDE_TextOut(); |
62 virtual void CalcSize(const FX_WCHAR* pwsStr, | 76 |
63 int32_t iLength, | 77 void Release() { delete this; } |
64 CFX_SizeF& size) = 0; | 78 void SetFont(IFX_Font* pFont); |
65 virtual void CalcSize(const FX_WCHAR* pwsStr, | 79 void SetFontSize(FX_FLOAT fFontSize); |
66 int32_t iLength, | 80 void SetTextColor(FX_ARGB color); |
67 CFX_Rect& rect) = 0; | 81 void SetStyles(uint32_t dwStyles); |
68 virtual void CalcSize(const FX_WCHAR* pwsStr, | 82 void SetTabWidth(FX_FLOAT fTabWidth); |
69 int32_t iLength, | 83 void SetEllipsisString(const CFX_WideString& wsEllipsis); |
70 CFX_RectF& rect) = 0; | 84 void SetParagraphBreakChar(FX_WCHAR wch); |
71 virtual void DrawText(const FX_WCHAR* pwsStr, | 85 void SetAlignment(int32_t iAlignment); |
72 int32_t iLength, | 86 void SetLineSpace(FX_FLOAT fLineSpace); |
73 int32_t x, | 87 void SetDIBitmap(CFX_DIBitmap* pDIB); |
74 int32_t y) = 0; | 88 void SetRenderDevice(CFX_RenderDevice* pDevice); |
75 virtual void DrawText(const FX_WCHAR* pwsStr, | 89 void SetClipRect(const CFX_Rect& rtClip); |
76 int32_t iLength, | 90 void SetClipRect(const CFX_RectF& rtClip); |
77 FX_FLOAT x, | 91 void SetMatrix(const CFX_Matrix& matrix); |
78 FX_FLOAT y) = 0; | 92 void SetLineBreakTolerance(FX_FLOAT fTolerance); |
79 virtual void DrawText(const FX_WCHAR* pwsStr, | 93 void CalcSize(const FX_WCHAR* pwsStr, int32_t iLength, CFX_Size& size); |
80 int32_t iLength, | 94 void CalcSize(const FX_WCHAR* pwsStr, int32_t iLength, CFX_SizeF& size); |
81 const CFX_Rect& rect) = 0; | 95 void CalcSize(const FX_WCHAR* pwsStr, int32_t iLength, CFX_Rect& rect); |
82 virtual void DrawText(const FX_WCHAR* pwsStr, | 96 void CalcSize(const FX_WCHAR* pwsStr, int32_t iLength, CFX_RectF& rect); |
83 int32_t iLength, | 97 |
84 const CFX_RectF& rect) = 0; | 98 void DrawText(const FX_WCHAR* pwsStr, int32_t iLength, int32_t x, int32_t y); |
85 virtual void SetLogicClipRect(const CFX_RectF& rtClip) = 0; | 99 void DrawText(const FX_WCHAR* pwsStr, |
86 virtual void CalcLogicSize(const FX_WCHAR* pwsStr, | 100 int32_t iLength, |
87 int32_t iLength, | 101 FX_FLOAT x, |
88 CFX_SizeF& size) = 0; | 102 FX_FLOAT y); |
89 virtual void CalcLogicSize(const FX_WCHAR* pwsStr, | 103 void DrawText(const FX_WCHAR* pwsStr, int32_t iLength, const CFX_Rect& rect); |
90 int32_t iLength, | 104 void DrawText(const FX_WCHAR* pwsStr, int32_t iLength, const CFX_RectF& rect); |
91 CFX_RectF& rect) = 0; | 105 |
92 virtual void DrawLogicText(const FX_WCHAR* pwsStr, | 106 void SetLogicClipRect(const CFX_RectF& rtClip); |
93 int32_t iLength, | 107 void CalcLogicSize(const FX_WCHAR* pwsStr, int32_t iLength, CFX_SizeF& size); |
94 FX_FLOAT x, | 108 void CalcLogicSize(const FX_WCHAR* pwsStr, int32_t iLength, CFX_RectF& rect); |
95 FX_FLOAT y) = 0; | 109 void DrawLogicText(const FX_WCHAR* pwsStr, |
96 virtual void DrawLogicText(const FX_WCHAR* pwsStr, | 110 int32_t iLength, |
97 int32_t iLength, | 111 FX_FLOAT x, |
98 const CFX_RectF& rect) = 0; | 112 FX_FLOAT y); |
99 virtual int32_t GetTotalLines() = 0; | 113 void DrawLogicText(const FX_WCHAR* pwsStr, |
| 114 int32_t iLength, |
| 115 const CFX_RectF& rect); |
| 116 int32_t GetTotalLines(); |
| 117 |
| 118 protected: |
| 119 void CalcTextSize(const FX_WCHAR* pwsStr, int32_t iLength, CFX_RectF& rect); |
| 120 FX_BOOL RetrieveLineWidth(uint32_t dwBreakStatus, |
| 121 FX_FLOAT& fStartPos, |
| 122 FX_FLOAT& fWidth, |
| 123 FX_FLOAT& fHeight); |
| 124 void SetLineWidth(CFX_RectF& rect); |
| 125 void DrawText(const FX_WCHAR* pwsStr, |
| 126 int32_t iLength, |
| 127 const CFX_RectF& rect, |
| 128 const CFX_RectF& rtClip); |
| 129 void LoadText(const FX_WCHAR* pwsStr, int32_t iLength, const CFX_RectF& rect); |
| 130 void LoadEllipsis(); |
| 131 void ExpandBuffer(int32_t iSize, int32_t iType); |
| 132 void RetrieveEllPieces(int32_t*& pCharWidths); |
| 133 |
| 134 void Reload(const CFX_RectF& rect); |
| 135 void ReloadLinePiece(CFDE_TTOLine* pLine, const CFX_RectF& rect); |
| 136 FX_BOOL RetriecePieces(uint32_t dwBreakStatus, |
| 137 int32_t& iStartChar, |
| 138 int32_t& iPieceWidths, |
| 139 FX_BOOL bReload, |
| 140 const CFX_RectF& rect); |
| 141 void AppendPiece(const FDE_TTOPIECE& ttoPiece, |
| 142 FX_BOOL bNeedReload, |
| 143 FX_BOOL bEnd); |
| 144 void ReplaceWidthEllipsis(); |
| 145 void DoAlignment(const CFX_RectF& rect); |
| 146 void OnDraw(const CFX_RectF& rtClip); |
| 147 int32_t GetDisplayPos(FDE_TTOPIECE* pPiece); |
| 148 int32_t GetCharRects(const FDE_TTOPIECE* pPiece); |
| 149 |
| 150 FX_TXTRUN ToTextRun(const FDE_TTOPIECE* pPiece); |
| 151 void DrawLine(const FDE_TTOPIECE* pPiece, CFDE_Pen*& pPen); |
| 152 |
| 153 CFX_TxtBreak* m_pTxtBreak; |
| 154 IFX_Font* m_pFont; |
| 155 FX_FLOAT m_fFontSize; |
| 156 FX_FLOAT m_fLineSpace; |
| 157 FX_FLOAT m_fLinePos; |
| 158 FX_FLOAT m_fTolerance; |
| 159 int32_t m_iAlignment; |
| 160 int32_t m_iTxtBkAlignment; |
| 161 int32_t* m_pCharWidths; |
| 162 int32_t m_iChars; |
| 163 int32_t* m_pEllCharWidths; |
| 164 int32_t m_iEllChars; |
| 165 FX_WCHAR m_wParagraphBkChar; |
| 166 FX_ARGB m_TxtColor; |
| 167 uint32_t m_dwStyles; |
| 168 uint32_t m_dwTxtBkStyles; |
| 169 CFX_WideString m_wsEllipsis; |
| 170 FX_BOOL m_bElliChanged; |
| 171 int32_t m_iEllipsisWidth; |
| 172 CFX_WideString m_wsText; |
| 173 CFX_RectF m_rtClip; |
| 174 CFX_RectF m_rtLogicClip; |
| 175 CFX_Matrix m_Matrix; |
| 176 CFDE_TTOLineArray m_ttoLines; |
| 177 int32_t m_iCurLine; |
| 178 int32_t m_iCurPiece; |
| 179 int32_t m_iTotalLines; |
| 180 FXTEXT_CHARPOS* m_pCharPos; |
| 181 int32_t m_iCharPosSize; |
| 182 CFDE_RenderDevice* m_pRenderDevice; |
| 183 CFX_Int32Array m_hotKeys; |
| 184 CFX_RectFArray m_rectArray; |
100 }; | 185 }; |
101 | 186 |
102 #endif // XFA_FDE_TTO_FDE_TEXTOUT_H_ | 187 #endif // XFA_FDE_TTO_FDE_TEXTOUT_H_ |
OLD | NEW |