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 #include "xfa/fgas/layout/fgas_rtfbreak.h" | 7 #include "xfa/fgas/layout/fgas_rtfbreak.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 CFX_RTFCharArray m_LineChars; | 61 CFX_RTFCharArray m_LineChars; |
62 CFX_RTFPieceArray m_LinePieces; | 62 CFX_RTFPieceArray m_LinePieces; |
63 int32_t m_iStart; | 63 int32_t m_iStart; |
64 int32_t m_iWidth; | 64 int32_t m_iWidth; |
65 int32_t m_iArabicChars; | 65 int32_t m_iArabicChars; |
66 int32_t m_iMBCSChars; | 66 int32_t m_iMBCSChars; |
67 }; | 67 }; |
68 | 68 |
69 class CFX_RTFBreak : public IFX_RTFBreak { | 69 class CFX_RTFBreak : public IFX_RTFBreak { |
70 public: | 70 public: |
71 CFX_RTFBreak(FX_DWORD dwPolicies); | 71 CFX_RTFBreak(uint32_t dwPolicies); |
72 ~CFX_RTFBreak(); | 72 ~CFX_RTFBreak(); |
73 void Release() override { delete this; } | 73 void Release() override { delete this; } |
74 void SetLineBoundary(FX_FLOAT fLineStart, FX_FLOAT fLineEnd) override; | 74 void SetLineBoundary(FX_FLOAT fLineStart, FX_FLOAT fLineEnd) override; |
75 void SetLineStartPos(FX_FLOAT fLinePos) override; | 75 void SetLineStartPos(FX_FLOAT fLinePos) override; |
76 FX_DWORD GetLayoutStyles() const override { return m_dwLayoutStyles; } | 76 uint32_t GetLayoutStyles() const override { return m_dwLayoutStyles; } |
77 void SetLayoutStyles(FX_DWORD dwLayoutStyles) override; | 77 void SetLayoutStyles(uint32_t dwLayoutStyles) override; |
78 void SetFont(IFX_Font* pFont) override; | 78 void SetFont(IFX_Font* pFont) override; |
79 void SetFontSize(FX_FLOAT fFontSize) override; | 79 void SetFontSize(FX_FLOAT fFontSize) override; |
80 void SetTabWidth(FX_FLOAT fTabWidth) override; | 80 void SetTabWidth(FX_FLOAT fTabWidth) override; |
81 void AddPositionedTab(FX_FLOAT fTabPos) override; | 81 void AddPositionedTab(FX_FLOAT fTabPos) override; |
82 void SetPositionedTabs(const CFX_FloatArray& tabs) override; | 82 void SetPositionedTabs(const CFX_FloatArray& tabs) override; |
83 void ClearPositionedTabs() override; | 83 void ClearPositionedTabs() override; |
84 void SetDefaultChar(FX_WCHAR wch) override; | 84 void SetDefaultChar(FX_WCHAR wch) override; |
85 void SetLineBreakChar(FX_WCHAR wch) override; | 85 void SetLineBreakChar(FX_WCHAR wch) override; |
86 void SetLineBreakTolerance(FX_FLOAT fTolerance) override; | 86 void SetLineBreakTolerance(FX_FLOAT fTolerance) override; |
87 void SetHorizontalScale(int32_t iScale) override; | 87 void SetHorizontalScale(int32_t iScale) override; |
88 void SetVerticalScale(int32_t iScale) override; | 88 void SetVerticalScale(int32_t iScale) override; |
89 void SetCharRotation(int32_t iCharRotation) override; | 89 void SetCharRotation(int32_t iCharRotation) override; |
90 void SetCharSpace(FX_FLOAT fCharSpace) override; | 90 void SetCharSpace(FX_FLOAT fCharSpace) override; |
91 void SetWordSpace(FX_BOOL bDefault, FX_FLOAT fWordSpace) override; | 91 void SetWordSpace(FX_BOOL bDefault, FX_FLOAT fWordSpace) override; |
92 void SetReadingOrder(FX_BOOL bRTL = FALSE) override; | 92 void SetReadingOrder(FX_BOOL bRTL = FALSE) override; |
93 void SetAlignment(int32_t iAlignment = FX_RTFLINEALIGNMENT_Left) override; | 93 void SetAlignment(int32_t iAlignment = FX_RTFLINEALIGNMENT_Left) override; |
94 void SetUserData(IFX_Unknown* pUserData) override; | 94 void SetUserData(IFX_Unknown* pUserData) override; |
95 FX_DWORD AppendChar(FX_WCHAR wch) override; | 95 uint32_t AppendChar(FX_WCHAR wch) override; |
96 FX_DWORD EndBreak(FX_DWORD dwStatus = FX_RTFBREAK_PieceBreak) override; | 96 uint32_t EndBreak(uint32_t dwStatus = FX_RTFBREAK_PieceBreak) override; |
97 int32_t CountBreakPieces() const override; | 97 int32_t CountBreakPieces() const override; |
98 const CFX_RTFPiece* GetBreakPiece(int32_t index) const override; | 98 const CFX_RTFPiece* GetBreakPiece(int32_t index) const override; |
99 void GetLineRect(CFX_RectF& rect) const override; | 99 void GetLineRect(CFX_RectF& rect) const override; |
100 void ClearBreakPieces() override; | 100 void ClearBreakPieces() override; |
101 void Reset() override; | 101 void Reset() override; |
102 int32_t GetDisplayPos( | 102 int32_t GetDisplayPos( |
103 const FX_RTFTEXTOBJ* pText, | 103 const FX_RTFTEXTOBJ* pText, |
104 FXTEXT_CHARPOS* pCharPos, | 104 FXTEXT_CHARPOS* pCharPos, |
105 FX_BOOL bCharCode = FALSE, | 105 FX_BOOL bCharCode = FALSE, |
106 CFX_WideString* pWSForms = NULL, | 106 CFX_WideString* pWSForms = NULL, |
107 FX_AdjustCharDisplayPos pAdjustPos = NULL) const override; | 107 FX_AdjustCharDisplayPos pAdjustPos = NULL) const override; |
108 int32_t GetCharRects(const FX_RTFTEXTOBJ* pText, | 108 int32_t GetCharRects(const FX_RTFTEXTOBJ* pText, |
109 CFX_RectFArray& rtArray, | 109 CFX_RectFArray& rtArray, |
110 FX_BOOL bCharBBox = FALSE) const override; | 110 FX_BOOL bCharBBox = FALSE) const override; |
111 FX_DWORD AppendChar_CharCode(FX_WCHAR wch); | 111 uint32_t AppendChar_CharCode(FX_WCHAR wch); |
112 FX_DWORD AppendChar_Combination(CFX_RTFChar* pCurChar, int32_t iRotation); | 112 uint32_t AppendChar_Combination(CFX_RTFChar* pCurChar, int32_t iRotation); |
113 FX_DWORD AppendChar_Tab(CFX_RTFChar* pCurChar, int32_t iRotation); | 113 uint32_t AppendChar_Tab(CFX_RTFChar* pCurChar, int32_t iRotation); |
114 FX_DWORD AppendChar_Control(CFX_RTFChar* pCurChar, int32_t iRotation); | 114 uint32_t AppendChar_Control(CFX_RTFChar* pCurChar, int32_t iRotation); |
115 FX_DWORD AppendChar_Arabic(CFX_RTFChar* pCurChar, int32_t iRotation); | 115 uint32_t AppendChar_Arabic(CFX_RTFChar* pCurChar, int32_t iRotation); |
116 FX_DWORD AppendChar_Others(CFX_RTFChar* pCurChar, int32_t iRotation); | 116 uint32_t AppendChar_Others(CFX_RTFChar* pCurChar, int32_t iRotation); |
117 | 117 |
118 protected: | 118 protected: |
119 FX_DWORD m_dwPolicies; | 119 uint32_t m_dwPolicies; |
120 IFX_ArabicChar* m_pArabicChar; | 120 IFX_ArabicChar* m_pArabicChar; |
121 int32_t m_iBoundaryStart; | 121 int32_t m_iBoundaryStart; |
122 int32_t m_iBoundaryEnd; | 122 int32_t m_iBoundaryEnd; |
123 FX_DWORD m_dwLayoutStyles; | 123 uint32_t m_dwLayoutStyles; |
124 FX_BOOL m_bPagination; | 124 FX_BOOL m_bPagination; |
125 FX_BOOL m_bVertical; | 125 FX_BOOL m_bVertical; |
126 FX_BOOL m_bSingleLine; | 126 FX_BOOL m_bSingleLine; |
127 FX_BOOL m_bCharCode; | 127 FX_BOOL m_bCharCode; |
128 IFX_Font* m_pFont; | 128 IFX_Font* m_pFont; |
129 int32_t m_iFontHeight; | 129 int32_t m_iFontHeight; |
130 int32_t m_iFontSize; | 130 int32_t m_iFontSize; |
131 int32_t m_iTabWidth; | 131 int32_t m_iTabWidth; |
132 CFX_Int32Array m_PositionedTabs; | 132 CFX_Int32Array m_PositionedTabs; |
133 FX_BOOL m_bOrphanLine; | 133 FX_BOOL m_bOrphanLine; |
134 FX_WCHAR m_wDefChar; | 134 FX_WCHAR m_wDefChar; |
135 int32_t m_iDefChar; | 135 int32_t m_iDefChar; |
136 FX_WCHAR m_wLineBreakChar; | 136 FX_WCHAR m_wLineBreakChar; |
137 int32_t m_iHorizontalScale; | 137 int32_t m_iHorizontalScale; |
138 int32_t m_iVerticalScale; | 138 int32_t m_iVerticalScale; |
139 int32_t m_iLineRotation; | 139 int32_t m_iLineRotation; |
140 int32_t m_iCharRotation; | 140 int32_t m_iCharRotation; |
141 int32_t m_iRotation; | 141 int32_t m_iRotation; |
142 int32_t m_iCharSpace; | 142 int32_t m_iCharSpace; |
143 FX_BOOL m_bWordSpace; | 143 FX_BOOL m_bWordSpace; |
144 int32_t m_iWordSpace; | 144 int32_t m_iWordSpace; |
145 FX_BOOL m_bRTL; | 145 FX_BOOL m_bRTL; |
146 int32_t m_iAlignment; | 146 int32_t m_iAlignment; |
147 IFX_Unknown* m_pUserData; | 147 IFX_Unknown* m_pUserData; |
148 FX_DWORD m_dwCharType; | 148 uint32_t m_dwCharType; |
149 FX_DWORD m_dwIdentity; | 149 uint32_t m_dwIdentity; |
150 CFX_RTFLine m_RTFLine1; | 150 CFX_RTFLine m_RTFLine1; |
151 CFX_RTFLine m_RTFLine2; | 151 CFX_RTFLine m_RTFLine2; |
152 CFX_RTFLine* m_pCurLine; | 152 CFX_RTFLine* m_pCurLine; |
153 int32_t m_iReady; | 153 int32_t m_iReady; |
154 int32_t m_iTolerance; | 154 int32_t m_iTolerance; |
155 int32_t GetLineRotation(FX_DWORD dwStyles) const; | 155 int32_t GetLineRotation(uint32_t dwStyles) const; |
156 void SetBreakStatus(); | 156 void SetBreakStatus(); |
157 CFX_RTFChar* GetLastChar(int32_t index) const; | 157 CFX_RTFChar* GetLastChar(int32_t index) const; |
158 CFX_RTFLine* GetRTFLine(FX_BOOL bReady) const; | 158 CFX_RTFLine* GetRTFLine(FX_BOOL bReady) const; |
159 CFX_RTFPieceArray* GetRTFPieces(FX_BOOL bReady) const; | 159 CFX_RTFPieceArray* GetRTFPieces(FX_BOOL bReady) const; |
160 FX_DWORD GetUnifiedCharType(FX_DWORD dwType) const; | 160 uint32_t GetUnifiedCharType(uint32_t dwType) const; |
161 int32_t GetLastPositionedTab() const; | 161 int32_t GetLastPositionedTab() const; |
162 FX_BOOL GetPositionedTab(int32_t& iTabPos) const; | 162 FX_BOOL GetPositionedTab(int32_t& iTabPos) const; |
163 int32_t GetBreakPos(CFX_RTFCharArray& tca, | 163 int32_t GetBreakPos(CFX_RTFCharArray& tca, |
164 int32_t& iEndPos, | 164 int32_t& iEndPos, |
165 FX_BOOL bAllChars = FALSE, | 165 FX_BOOL bAllChars = FALSE, |
166 FX_BOOL bOnlyBrk = FALSE); | 166 FX_BOOL bOnlyBrk = FALSE); |
167 void SplitTextLine(CFX_RTFLine* pCurLine, | 167 void SplitTextLine(CFX_RTFLine* pCurLine, |
168 CFX_RTFLine* pNextLine, | 168 CFX_RTFLine* pNextLine, |
169 FX_BOOL bAllChars = FALSE); | 169 FX_BOOL bAllChars = FALSE); |
170 FX_BOOL EndBreak_SplitLine(CFX_RTFLine* pNextLine, | 170 FX_BOOL EndBreak_SplitLine(CFX_RTFLine* pNextLine, |
171 FX_BOOL bAllChars, | 171 FX_BOOL bAllChars, |
172 FX_DWORD dwStatus); | 172 uint32_t dwStatus); |
173 void EndBreak_BidiLine(CFX_TPOArray& tpos, FX_DWORD dwStatus); | 173 void EndBreak_BidiLine(CFX_TPOArray& tpos, uint32_t dwStatus); |
174 void EndBreak_Alignment(CFX_TPOArray& tpos, | 174 void EndBreak_Alignment(CFX_TPOArray& tpos, |
175 FX_BOOL bAllChars, | 175 FX_BOOL bAllChars, |
176 FX_DWORD dwStatus); | 176 uint32_t dwStatus); |
177 }; | 177 }; |
178 | 178 |
179 } // namespace | 179 } // namespace |
180 | 180 |
181 IFX_RTFBreak* IFX_RTFBreak::Create(FX_DWORD dwPolicies) { | 181 IFX_RTFBreak* IFX_RTFBreak::Create(uint32_t dwPolicies) { |
182 return new CFX_RTFBreak(dwPolicies); | 182 return new CFX_RTFBreak(dwPolicies); |
183 } | 183 } |
184 CFX_RTFBreak::CFX_RTFBreak(FX_DWORD dwPolicies) | 184 CFX_RTFBreak::CFX_RTFBreak(uint32_t dwPolicies) |
185 : m_dwPolicies(dwPolicies), | 185 : m_dwPolicies(dwPolicies), |
186 m_pArabicChar(NULL), | 186 m_pArabicChar(NULL), |
187 m_iBoundaryStart(0), | 187 m_iBoundaryStart(0), |
188 m_iBoundaryEnd(2000000), | 188 m_iBoundaryEnd(2000000), |
189 m_dwLayoutStyles(0), | 189 m_dwLayoutStyles(0), |
190 m_bPagination(FALSE), | 190 m_bPagination(FALSE), |
191 m_bVertical(FALSE), | 191 m_bVertical(FALSE), |
192 m_bSingleLine(FALSE), | 192 m_bSingleLine(FALSE), |
193 m_bCharCode(FALSE), | 193 m_bCharCode(FALSE), |
194 m_pFont(NULL), | 194 m_pFont(NULL), |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 m_iBoundaryEnd = FXSYS_round(fLineEnd * 20000.0f); | 236 m_iBoundaryEnd = FXSYS_round(fLineEnd * 20000.0f); |
237 m_pCurLine->m_iStart = std::min(m_pCurLine->m_iStart, m_iBoundaryEnd); | 237 m_pCurLine->m_iStart = std::min(m_pCurLine->m_iStart, m_iBoundaryEnd); |
238 m_pCurLine->m_iStart = std::max(m_pCurLine->m_iStart, m_iBoundaryStart); | 238 m_pCurLine->m_iStart = std::max(m_pCurLine->m_iStart, m_iBoundaryStart); |
239 } | 239 } |
240 void CFX_RTFBreak::SetLineStartPos(FX_FLOAT fLinePos) { | 240 void CFX_RTFBreak::SetLineStartPos(FX_FLOAT fLinePos) { |
241 int32_t iLinePos = FXSYS_round(fLinePos * 20000.0f); | 241 int32_t iLinePos = FXSYS_round(fLinePos * 20000.0f); |
242 iLinePos = std::min(iLinePos, m_iBoundaryEnd); | 242 iLinePos = std::min(iLinePos, m_iBoundaryEnd); |
243 iLinePos = std::max(iLinePos, m_iBoundaryStart); | 243 iLinePos = std::max(iLinePos, m_iBoundaryStart); |
244 m_pCurLine->m_iStart = iLinePos; | 244 m_pCurLine->m_iStart = iLinePos; |
245 } | 245 } |
246 void CFX_RTFBreak::SetLayoutStyles(FX_DWORD dwLayoutStyles) { | 246 void CFX_RTFBreak::SetLayoutStyles(uint32_t dwLayoutStyles) { |
247 if (m_dwLayoutStyles == dwLayoutStyles) { | 247 if (m_dwLayoutStyles == dwLayoutStyles) { |
248 return; | 248 return; |
249 } | 249 } |
250 SetBreakStatus(); | 250 SetBreakStatus(); |
251 m_dwLayoutStyles = dwLayoutStyles; | 251 m_dwLayoutStyles = dwLayoutStyles; |
252 m_bPagination = (m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_Pagination) != 0; | 252 m_bPagination = (m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_Pagination) != 0; |
253 m_bVertical = (m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_VerticalChars) != 0; | 253 m_bVertical = (m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_VerticalChars) != 0; |
254 m_bSingleLine = (m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_SingleLine) != 0; | 254 m_bSingleLine = (m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_SingleLine) != 0; |
255 m_bCharCode = (m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_MBCSCode) != 0; | 255 m_bCharCode = (m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_MBCSCode) != 0; |
256 m_iLineRotation = GetLineRotation(m_dwLayoutStyles); | 256 m_iLineRotation = GetLineRotation(m_dwLayoutStyles); |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 SetBreakStatus(); | 417 SetBreakStatus(); |
418 if (m_pUserData != NULL) { | 418 if (m_pUserData != NULL) { |
419 m_pUserData->Release(); | 419 m_pUserData->Release(); |
420 } | 420 } |
421 m_pUserData = pUserData; | 421 m_pUserData = pUserData; |
422 if (m_pUserData != NULL) { | 422 if (m_pUserData != NULL) { |
423 m_pUserData->AddRef(); | 423 m_pUserData->AddRef(); |
424 } | 424 } |
425 } | 425 } |
426 static const int32_t gs_FX_RTFLineRotations[8] = {0, 3, 1, 0, 2, 1, 3, 2}; | 426 static const int32_t gs_FX_RTFLineRotations[8] = {0, 3, 1, 0, 2, 1, 3, 2}; |
427 int32_t CFX_RTFBreak::GetLineRotation(FX_DWORD dwStyles) const { | 427 int32_t CFX_RTFBreak::GetLineRotation(uint32_t dwStyles) const { |
428 return gs_FX_RTFLineRotations[(dwStyles & 0x0E) >> 1]; | 428 return gs_FX_RTFLineRotations[(dwStyles & 0x0E) >> 1]; |
429 } | 429 } |
430 void CFX_RTFBreak::SetBreakStatus() { | 430 void CFX_RTFBreak::SetBreakStatus() { |
431 m_dwIdentity++; | 431 m_dwIdentity++; |
432 int32_t iCount = m_pCurLine->CountChars(); | 432 int32_t iCount = m_pCurLine->CountChars(); |
433 if (iCount < 1) { | 433 if (iCount < 1) { |
434 return; | 434 return; |
435 } | 435 } |
436 CFX_RTFChar& tc = m_pCurLine->GetChar(iCount - 1); | 436 CFX_RTFChar& tc = m_pCurLine->GetChar(iCount - 1); |
437 if (tc.m_dwStatus == 0) { | 437 if (tc.m_dwStatus == 0) { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 FXSYS_assert(m_pCurLine != NULL); | 470 FXSYS_assert(m_pCurLine != NULL); |
471 return m_pCurLine; | 471 return m_pCurLine; |
472 } | 472 } |
473 CFX_RTFPieceArray* CFX_RTFBreak::GetRTFPieces(FX_BOOL bReady) const { | 473 CFX_RTFPieceArray* CFX_RTFBreak::GetRTFPieces(FX_BOOL bReady) const { |
474 CFX_RTFLine* pRTFLine = GetRTFLine(bReady); | 474 CFX_RTFLine* pRTFLine = GetRTFLine(bReady); |
475 if (pRTFLine == NULL) { | 475 if (pRTFLine == NULL) { |
476 return NULL; | 476 return NULL; |
477 } | 477 } |
478 return &pRTFLine->m_LinePieces; | 478 return &pRTFLine->m_LinePieces; |
479 } | 479 } |
480 inline FX_DWORD CFX_RTFBreak::GetUnifiedCharType(FX_DWORD dwType) const { | 480 inline uint32_t CFX_RTFBreak::GetUnifiedCharType(uint32_t dwType) const { |
481 return dwType >= FX_CHARTYPE_ArabicAlef ? FX_CHARTYPE_Arabic : dwType; | 481 return dwType >= FX_CHARTYPE_ArabicAlef ? FX_CHARTYPE_Arabic : dwType; |
482 } | 482 } |
483 int32_t CFX_RTFBreak::GetLastPositionedTab() const { | 483 int32_t CFX_RTFBreak::GetLastPositionedTab() const { |
484 int32_t iCount = m_PositionedTabs.GetSize(); | 484 int32_t iCount = m_PositionedTabs.GetSize(); |
485 if (iCount < 1) { | 485 if (iCount < 1) { |
486 return m_iBoundaryStart; | 486 return m_iBoundaryStart; |
487 } | 487 } |
488 return m_PositionedTabs[iCount - 1]; | 488 return m_PositionedTabs[iCount - 1]; |
489 } | 489 } |
490 FX_BOOL CFX_RTFBreak::GetPositionedTab(int32_t& iTabPos) const { | 490 FX_BOOL CFX_RTFBreak::GetPositionedTab(int32_t& iTabPos) const { |
491 int32_t iCount = m_PositionedTabs.GetSize(); | 491 int32_t iCount = m_PositionedTabs.GetSize(); |
492 for (int32_t i = 0; i < iCount; i++) { | 492 for (int32_t i = 0; i < iCount; i++) { |
493 if (m_PositionedTabs[i] > iTabPos) { | 493 if (m_PositionedTabs[i] > iTabPos) { |
494 iTabPos = m_PositionedTabs[i]; | 494 iTabPos = m_PositionedTabs[i]; |
495 return TRUE; | 495 return TRUE; |
496 } | 496 } |
497 } | 497 } |
498 return FALSE; | 498 return FALSE; |
499 } | 499 } |
500 typedef FX_DWORD (CFX_RTFBreak::*FX_RTFBreak_LPFAppendChar)( | 500 typedef uint32_t (CFX_RTFBreak::*FX_RTFBreak_LPFAppendChar)( |
501 CFX_RTFChar* pCurChar, | 501 CFX_RTFChar* pCurChar, |
502 int32_t iRotation); | 502 int32_t iRotation); |
503 static const FX_RTFBreak_LPFAppendChar g_FX_RTFBreak_lpfAppendChar[16] = { | 503 static const FX_RTFBreak_LPFAppendChar g_FX_RTFBreak_lpfAppendChar[16] = { |
504 &CFX_RTFBreak::AppendChar_Others, &CFX_RTFBreak::AppendChar_Tab, | 504 &CFX_RTFBreak::AppendChar_Others, &CFX_RTFBreak::AppendChar_Tab, |
505 &CFX_RTFBreak::AppendChar_Others, &CFX_RTFBreak::AppendChar_Control, | 505 &CFX_RTFBreak::AppendChar_Others, &CFX_RTFBreak::AppendChar_Control, |
506 &CFX_RTFBreak::AppendChar_Combination, &CFX_RTFBreak::AppendChar_Others, | 506 &CFX_RTFBreak::AppendChar_Combination, &CFX_RTFBreak::AppendChar_Others, |
507 &CFX_RTFBreak::AppendChar_Others, &CFX_RTFBreak::AppendChar_Arabic, | 507 &CFX_RTFBreak::AppendChar_Others, &CFX_RTFBreak::AppendChar_Arabic, |
508 &CFX_RTFBreak::AppendChar_Arabic, &CFX_RTFBreak::AppendChar_Arabic, | 508 &CFX_RTFBreak::AppendChar_Arabic, &CFX_RTFBreak::AppendChar_Arabic, |
509 &CFX_RTFBreak::AppendChar_Arabic, &CFX_RTFBreak::AppendChar_Arabic, | 509 &CFX_RTFBreak::AppendChar_Arabic, &CFX_RTFBreak::AppendChar_Arabic, |
510 &CFX_RTFBreak::AppendChar_Arabic, &CFX_RTFBreak::AppendChar_Others, | 510 &CFX_RTFBreak::AppendChar_Arabic, &CFX_RTFBreak::AppendChar_Others, |
511 &CFX_RTFBreak::AppendChar_Others, &CFX_RTFBreak::AppendChar_Others, | 511 &CFX_RTFBreak::AppendChar_Others, &CFX_RTFBreak::AppendChar_Others, |
512 }; | 512 }; |
513 FX_DWORD CFX_RTFBreak::AppendChar(FX_WCHAR wch) { | 513 uint32_t CFX_RTFBreak::AppendChar(FX_WCHAR wch) { |
514 FXSYS_assert(m_pFont != NULL && m_pCurLine != NULL && m_pArabicChar != NULL); | 514 FXSYS_assert(m_pFont != NULL && m_pCurLine != NULL && m_pArabicChar != NULL); |
515 if (m_bCharCode) { | 515 if (m_bCharCode) { |
516 return AppendChar_CharCode(wch); | 516 return AppendChar_CharCode(wch); |
517 } | 517 } |
518 FX_DWORD dwProps = kTextLayoutCodeProperties[(uint16_t)wch]; | 518 uint32_t dwProps = kTextLayoutCodeProperties[(uint16_t)wch]; |
519 FX_DWORD dwType = (dwProps & FX_CHARTYPEBITSMASK); | 519 uint32_t dwType = (dwProps & FX_CHARTYPEBITSMASK); |
520 CFX_RTFCharArray& tca = m_pCurLine->m_LineChars; | 520 CFX_RTFCharArray& tca = m_pCurLine->m_LineChars; |
521 CFX_RTFChar* pCurChar = tca.AddSpace(); | 521 CFX_RTFChar* pCurChar = tca.AddSpace(); |
522 pCurChar->m_dwStatus = 0; | 522 pCurChar->m_dwStatus = 0; |
523 pCurChar->m_wCharCode = wch; | 523 pCurChar->m_wCharCode = wch; |
524 pCurChar->m_dwCharProps = dwProps; | 524 pCurChar->m_dwCharProps = dwProps; |
525 pCurChar->m_dwCharStyles = 0; | 525 pCurChar->m_dwCharStyles = 0; |
526 pCurChar->m_dwLayoutStyles = 0; | 526 pCurChar->m_dwLayoutStyles = 0; |
527 pCurChar->m_iFontSize = m_iFontSize; | 527 pCurChar->m_iFontSize = m_iFontSize; |
528 pCurChar->m_iFontHeight = m_iFontHeight; | 528 pCurChar->m_iFontHeight = m_iFontHeight; |
529 pCurChar->m_iHorizontalScale = m_iHorizontalScale; | 529 pCurChar->m_iHorizontalScale = m_iHorizontalScale; |
530 pCurChar->m_iVertialScale = m_iVerticalScale; | 530 pCurChar->m_iVertialScale = m_iVerticalScale; |
531 pCurChar->m_nRotation = m_iCharRotation; | 531 pCurChar->m_nRotation = m_iCharRotation; |
532 pCurChar->m_iCharWidth = 0; | 532 pCurChar->m_iCharWidth = 0; |
533 pCurChar->m_dwIdentity = m_dwIdentity; | 533 pCurChar->m_dwIdentity = m_dwIdentity; |
534 if (m_pUserData != NULL) { | 534 if (m_pUserData != NULL) { |
535 m_pUserData->AddRef(); | 535 m_pUserData->AddRef(); |
536 } | 536 } |
537 pCurChar->m_pUserData = m_pUserData; | 537 pCurChar->m_pUserData = m_pUserData; |
538 FX_DWORD dwRet1 = FX_RTFBREAK_None; | 538 uint32_t dwRet1 = FX_RTFBREAK_None; |
539 if (dwType != FX_CHARTYPE_Combination && | 539 if (dwType != FX_CHARTYPE_Combination && |
540 GetUnifiedCharType(m_dwCharType) != GetUnifiedCharType(dwType)) { | 540 GetUnifiedCharType(m_dwCharType) != GetUnifiedCharType(dwType)) { |
541 if (!m_bSingleLine && !m_bOrphanLine && m_dwCharType > 0 && | 541 if (!m_bSingleLine && !m_bOrphanLine && m_dwCharType > 0 && |
542 m_pCurLine->GetLineEnd() > m_iBoundaryEnd + m_iTolerance) { | 542 m_pCurLine->GetLineEnd() > m_iBoundaryEnd + m_iTolerance) { |
543 if (m_dwCharType != FX_CHARTYPE_Space || dwType != FX_CHARTYPE_Control) { | 543 if (m_dwCharType != FX_CHARTYPE_Space || dwType != FX_CHARTYPE_Control) { |
544 dwRet1 = EndBreak(FX_RTFBREAK_LineBreak); | 544 dwRet1 = EndBreak(FX_RTFBREAK_LineBreak); |
545 int32_t iCount = m_pCurLine->CountChars(); | 545 int32_t iCount = m_pCurLine->CountChars(); |
546 if (iCount > 0) { | 546 if (iCount > 0) { |
547 pCurChar = m_pCurLine->m_LineChars.GetDataPtr(iCount - 1); | 547 pCurChar = m_pCurLine->m_LineChars.GetDataPtr(iCount - 1); |
548 } | 548 } |
549 } | 549 } |
550 } | 550 } |
551 } | 551 } |
552 int32_t iRotation = m_iRotation; | 552 int32_t iRotation = m_iRotation; |
553 if (m_bVertical && (dwProps & 0x8000) != 0) { | 553 if (m_bVertical && (dwProps & 0x8000) != 0) { |
554 iRotation = (iRotation + 1) % 4; | 554 iRotation = (iRotation + 1) % 4; |
555 } | 555 } |
556 FX_DWORD dwRet2 = | 556 uint32_t dwRet2 = |
557 (this->*g_FX_RTFBreak_lpfAppendChar[dwType >> FX_CHARTYPEBITS])( | 557 (this->*g_FX_RTFBreak_lpfAppendChar[dwType >> FX_CHARTYPEBITS])( |
558 pCurChar, iRotation); | 558 pCurChar, iRotation); |
559 m_dwCharType = dwType; | 559 m_dwCharType = dwType; |
560 return std::max(dwRet1, dwRet2); | 560 return std::max(dwRet1, dwRet2); |
561 } | 561 } |
562 FX_DWORD CFX_RTFBreak::AppendChar_CharCode(FX_WCHAR wch) { | 562 uint32_t CFX_RTFBreak::AppendChar_CharCode(FX_WCHAR wch) { |
563 FXSYS_assert(m_pFont != NULL && m_pCurLine != NULL); | 563 FXSYS_assert(m_pFont != NULL && m_pCurLine != NULL); |
564 FXSYS_assert(m_bCharCode); | 564 FXSYS_assert(m_bCharCode); |
565 m_pCurLine->m_iMBCSChars++; | 565 m_pCurLine->m_iMBCSChars++; |
566 CFX_RTFCharArray& tca = m_pCurLine->m_LineChars; | 566 CFX_RTFCharArray& tca = m_pCurLine->m_LineChars; |
567 CFX_RTFChar* pCurChar = tca.AddSpace(); | 567 CFX_RTFChar* pCurChar = tca.AddSpace(); |
568 pCurChar->m_dwStatus = 0; | 568 pCurChar->m_dwStatus = 0; |
569 pCurChar->m_wCharCode = wch; | 569 pCurChar->m_wCharCode = wch; |
570 pCurChar->m_dwCharProps = 0; | 570 pCurChar->m_dwCharProps = 0; |
571 pCurChar->m_dwCharStyles = 0; | 571 pCurChar->m_dwCharStyles = 0; |
572 pCurChar->m_dwLayoutStyles = m_dwLayoutStyles; | 572 pCurChar->m_dwLayoutStyles = m_dwLayoutStyles; |
(...skipping 21 matching lines...) Expand all Loading... |
594 iCharWidth += m_iCharSpace; | 594 iCharWidth += m_iCharSpace; |
595 pCurChar->m_iCharWidth = iCharWidth; | 595 pCurChar->m_iCharWidth = iCharWidth; |
596 m_pCurLine->m_iWidth += iCharWidth; | 596 m_pCurLine->m_iWidth += iCharWidth; |
597 m_dwCharType = 0; | 597 m_dwCharType = 0; |
598 if (!m_bSingleLine && | 598 if (!m_bSingleLine && |
599 m_pCurLine->GetLineEnd() > m_iBoundaryEnd + m_iTolerance) { | 599 m_pCurLine->GetLineEnd() > m_iBoundaryEnd + m_iTolerance) { |
600 return EndBreak(FX_RTFBREAK_LineBreak); | 600 return EndBreak(FX_RTFBREAK_LineBreak); |
601 } | 601 } |
602 return FX_RTFBREAK_None; | 602 return FX_RTFBREAK_None; |
603 } | 603 } |
604 FX_DWORD CFX_RTFBreak::AppendChar_Combination(CFX_RTFChar* pCurChar, | 604 uint32_t CFX_RTFBreak::AppendChar_Combination(CFX_RTFChar* pCurChar, |
605 int32_t iRotation) { | 605 int32_t iRotation) { |
606 int32_t iCharWidth = 0; | 606 int32_t iCharWidth = 0; |
607 if (m_bVertical != FX_IsOdd(iRotation)) { | 607 if (m_bVertical != FX_IsOdd(iRotation)) { |
608 iCharWidth = 1000; | 608 iCharWidth = 1000; |
609 } else { | 609 } else { |
610 if (!m_pFont->GetCharWidth(pCurChar->m_wCharCode, iCharWidth, | 610 if (!m_pFont->GetCharWidth(pCurChar->m_wCharCode, iCharWidth, |
611 m_bCharCode)) { | 611 m_bCharCode)) { |
612 iCharWidth = 0; | 612 iCharWidth = 0; |
613 } | 613 } |
614 } | 614 } |
615 iCharWidth *= m_iFontSize; | 615 iCharWidth *= m_iFontSize; |
616 iCharWidth = iCharWidth * m_iHorizontalScale / 100; | 616 iCharWidth = iCharWidth * m_iHorizontalScale / 100; |
617 CFX_RTFChar* pLastChar = GetLastChar(0); | 617 CFX_RTFChar* pLastChar = GetLastChar(0); |
618 if (pLastChar != NULL && pLastChar->GetCharType() > FX_CHARTYPE_Combination) { | 618 if (pLastChar != NULL && pLastChar->GetCharType() > FX_CHARTYPE_Combination) { |
619 iCharWidth = -iCharWidth; | 619 iCharWidth = -iCharWidth; |
620 } else { | 620 } else { |
621 m_dwCharType = FX_CHARTYPE_Combination; | 621 m_dwCharType = FX_CHARTYPE_Combination; |
622 } | 622 } |
623 pCurChar->m_iCharWidth = iCharWidth; | 623 pCurChar->m_iCharWidth = iCharWidth; |
624 if (iCharWidth > 0) { | 624 if (iCharWidth > 0) { |
625 m_pCurLine->m_iWidth += iCharWidth; | 625 m_pCurLine->m_iWidth += iCharWidth; |
626 } | 626 } |
627 return FX_RTFBREAK_None; | 627 return FX_RTFBREAK_None; |
628 } | 628 } |
629 FX_DWORD CFX_RTFBreak::AppendChar_Tab(CFX_RTFChar* pCurChar, | 629 uint32_t CFX_RTFBreak::AppendChar_Tab(CFX_RTFChar* pCurChar, |
630 int32_t iRotation) { | 630 int32_t iRotation) { |
631 if (m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_ExpandTab) { | 631 if (m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_ExpandTab) { |
632 FX_BOOL bBreak = FALSE; | 632 FX_BOOL bBreak = FALSE; |
633 if ((m_dwPolicies & FX_RTFBREAKPOLICY_TabBreak) != 0) { | 633 if ((m_dwPolicies & FX_RTFBREAKPOLICY_TabBreak) != 0) { |
634 bBreak = (m_pCurLine->GetLineEnd() > m_iBoundaryEnd + m_iTolerance); | 634 bBreak = (m_pCurLine->GetLineEnd() > m_iBoundaryEnd + m_iTolerance); |
635 } | 635 } |
636 int32_t& iLineWidth = m_pCurLine->m_iWidth; | 636 int32_t& iLineWidth = m_pCurLine->m_iWidth; |
637 int32_t iCharWidth = iLineWidth; | 637 int32_t iCharWidth = iLineWidth; |
638 if (GetPositionedTab(iCharWidth)) { | 638 if (GetPositionedTab(iCharWidth)) { |
639 iCharWidth -= iLineWidth; | 639 iCharWidth -= iLineWidth; |
640 } else { | 640 } else { |
641 iCharWidth = m_iTabWidth * (iLineWidth / m_iTabWidth + 1) - iLineWidth; | 641 iCharWidth = m_iTabWidth * (iLineWidth / m_iTabWidth + 1) - iLineWidth; |
642 } | 642 } |
643 pCurChar->m_iCharWidth = iCharWidth; | 643 pCurChar->m_iCharWidth = iCharWidth; |
644 iLineWidth += iCharWidth; | 644 iLineWidth += iCharWidth; |
645 if (!m_bSingleLine && !m_bOrphanLine && bBreak) { | 645 if (!m_bSingleLine && !m_bOrphanLine && bBreak) { |
646 return EndBreak(FX_RTFBREAK_LineBreak); | 646 return EndBreak(FX_RTFBREAK_LineBreak); |
647 } | 647 } |
648 } | 648 } |
649 return FX_RTFBREAK_None; | 649 return FX_RTFBREAK_None; |
650 } | 650 } |
651 FX_DWORD CFX_RTFBreak::AppendChar_Control(CFX_RTFChar* pCurChar, | 651 uint32_t CFX_RTFBreak::AppendChar_Control(CFX_RTFChar* pCurChar, |
652 int32_t iRotation) { | 652 int32_t iRotation) { |
653 FX_DWORD dwRet2 = FX_RTFBREAK_None; | 653 uint32_t dwRet2 = FX_RTFBREAK_None; |
654 if (!m_bSingleLine) { | 654 if (!m_bSingleLine) { |
655 switch (pCurChar->m_wCharCode) { | 655 switch (pCurChar->m_wCharCode) { |
656 case L'\v': | 656 case L'\v': |
657 case 0x2028: | 657 case 0x2028: |
658 dwRet2 = FX_RTFBREAK_LineBreak; | 658 dwRet2 = FX_RTFBREAK_LineBreak; |
659 break; | 659 break; |
660 case L'\f': | 660 case L'\f': |
661 dwRet2 = FX_RTFBREAK_PageBreak; | 661 dwRet2 = FX_RTFBREAK_PageBreak; |
662 break; | 662 break; |
663 case 0x2029: | 663 case 0x2029: |
664 dwRet2 = FX_RTFBREAK_ParagraphBreak; | 664 dwRet2 = FX_RTFBREAK_ParagraphBreak; |
665 break; | 665 break; |
666 default: | 666 default: |
667 if (pCurChar->m_wCharCode == m_wLineBreakChar) { | 667 if (pCurChar->m_wCharCode == m_wLineBreakChar) { |
668 dwRet2 = FX_RTFBREAK_ParagraphBreak; | 668 dwRet2 = FX_RTFBREAK_ParagraphBreak; |
669 } | 669 } |
670 break; | 670 break; |
671 } | 671 } |
672 if (dwRet2 != FX_RTFBREAK_None) { | 672 if (dwRet2 != FX_RTFBREAK_None) { |
673 dwRet2 = EndBreak(dwRet2); | 673 dwRet2 = EndBreak(dwRet2); |
674 } | 674 } |
675 } | 675 } |
676 return dwRet2; | 676 return dwRet2; |
677 } | 677 } |
678 FX_DWORD CFX_RTFBreak::AppendChar_Arabic(CFX_RTFChar* pCurChar, | 678 uint32_t CFX_RTFBreak::AppendChar_Arabic(CFX_RTFChar* pCurChar, |
679 int32_t iRotation) { | 679 int32_t iRotation) { |
680 CFX_RTFChar* pLastChar = NULL; | 680 CFX_RTFChar* pLastChar = NULL; |
681 int32_t& iLineWidth = m_pCurLine->m_iWidth; | 681 int32_t& iLineWidth = m_pCurLine->m_iWidth; |
682 int32_t iCharWidth = 0; | 682 int32_t iCharWidth = 0; |
683 FX_WCHAR wForm; | 683 FX_WCHAR wForm; |
684 FX_BOOL bAlef = FALSE; | 684 FX_BOOL bAlef = FALSE; |
685 if (m_dwCharType >= FX_CHARTYPE_ArabicAlef && | 685 if (m_dwCharType >= FX_CHARTYPE_ArabicAlef && |
686 m_dwCharType <= FX_CHARTYPE_ArabicDistortion) { | 686 m_dwCharType <= FX_CHARTYPE_ArabicDistortion) { |
687 pLastChar = GetLastChar(1); | 687 pLastChar = GetLastChar(1); |
688 if (pLastChar != NULL) { | 688 if (pLastChar != NULL) { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
726 iCharWidth = iCharWidth * m_iHorizontalScale / 100; | 726 iCharWidth = iCharWidth * m_iHorizontalScale / 100; |
727 pCurChar->m_iCharWidth = iCharWidth; | 727 pCurChar->m_iCharWidth = iCharWidth; |
728 iLineWidth += iCharWidth; | 728 iLineWidth += iCharWidth; |
729 m_pCurLine->m_iArabicChars++; | 729 m_pCurLine->m_iArabicChars++; |
730 if (!m_bSingleLine && !m_bOrphanLine && | 730 if (!m_bSingleLine && !m_bOrphanLine && |
731 m_pCurLine->GetLineEnd() > m_iBoundaryEnd + m_iTolerance) { | 731 m_pCurLine->GetLineEnd() > m_iBoundaryEnd + m_iTolerance) { |
732 return EndBreak(FX_RTFBREAK_LineBreak); | 732 return EndBreak(FX_RTFBREAK_LineBreak); |
733 } | 733 } |
734 return FX_RTFBREAK_None; | 734 return FX_RTFBREAK_None; |
735 } | 735 } |
736 FX_DWORD CFX_RTFBreak::AppendChar_Others(CFX_RTFChar* pCurChar, | 736 uint32_t CFX_RTFBreak::AppendChar_Others(CFX_RTFChar* pCurChar, |
737 int32_t iRotation) { | 737 int32_t iRotation) { |
738 FX_DWORD dwType = (pCurChar->m_dwCharProps & FX_CHARTYPEBITSMASK); | 738 uint32_t dwType = (pCurChar->m_dwCharProps & FX_CHARTYPEBITSMASK); |
739 FX_WCHAR wForm; | 739 FX_WCHAR wForm; |
740 if (dwType == FX_CHARTYPE_Numeric) { | 740 if (dwType == FX_CHARTYPE_Numeric) { |
741 if (m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_ArabicNumber) { | 741 if (m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_ArabicNumber) { |
742 wForm = pCurChar->m_wCharCode + 0x0630; | 742 wForm = pCurChar->m_wCharCode + 0x0630; |
743 } else { | 743 } else { |
744 wForm = pCurChar->m_wCharCode; | 744 wForm = pCurChar->m_wCharCode; |
745 } | 745 } |
746 } else if (m_bRTL || m_bVertical) { | 746 } else if (m_bRTL || m_bVertical) { |
747 wForm = FX_GetMirrorChar(pCurChar->m_wCharCode, pCurChar->m_dwCharProps, | 747 wForm = FX_GetMirrorChar(pCurChar->m_wCharCode, pCurChar->m_dwCharProps, |
748 m_bRTL, m_bVertical); | 748 m_bRTL, m_bVertical); |
(...skipping 17 matching lines...) Expand all Loading... |
766 pCurChar->m_iCharWidth = iCharWidth; | 766 pCurChar->m_iCharWidth = iCharWidth; |
767 m_pCurLine->m_iWidth += iCharWidth; | 767 m_pCurLine->m_iWidth += iCharWidth; |
768 FX_BOOL bBreak = (dwType != FX_CHARTYPE_Space || | 768 FX_BOOL bBreak = (dwType != FX_CHARTYPE_Space || |
769 (m_dwPolicies & FX_RTFBREAKPOLICY_SpaceBreak) != 0); | 769 (m_dwPolicies & FX_RTFBREAKPOLICY_SpaceBreak) != 0); |
770 if (!m_bSingleLine && !m_bOrphanLine && bBreak && | 770 if (!m_bSingleLine && !m_bOrphanLine && bBreak && |
771 m_pCurLine->GetLineEnd() > m_iBoundaryEnd + m_iTolerance) { | 771 m_pCurLine->GetLineEnd() > m_iBoundaryEnd + m_iTolerance) { |
772 return EndBreak(FX_RTFBREAK_LineBreak); | 772 return EndBreak(FX_RTFBREAK_LineBreak); |
773 } | 773 } |
774 return FX_RTFBREAK_None; | 774 return FX_RTFBREAK_None; |
775 } | 775 } |
776 FX_DWORD CFX_RTFBreak::EndBreak(FX_DWORD dwStatus) { | 776 uint32_t CFX_RTFBreak::EndBreak(uint32_t dwStatus) { |
777 FXSYS_assert(dwStatus >= FX_RTFBREAK_PieceBreak && | 777 FXSYS_assert(dwStatus >= FX_RTFBREAK_PieceBreak && |
778 dwStatus <= FX_RTFBREAK_PageBreak); | 778 dwStatus <= FX_RTFBREAK_PageBreak); |
779 m_dwIdentity++; | 779 m_dwIdentity++; |
780 CFX_RTFPieceArray* pCurPieces = &m_pCurLine->m_LinePieces; | 780 CFX_RTFPieceArray* pCurPieces = &m_pCurLine->m_LinePieces; |
781 int32_t iCount = pCurPieces->GetSize(); | 781 int32_t iCount = pCurPieces->GetSize(); |
782 if (iCount > 0) { | 782 if (iCount > 0) { |
783 CFX_RTFPiece* pLastPiece = pCurPieces->GetPtrAt(--iCount); | 783 CFX_RTFPiece* pLastPiece = pCurPieces->GetPtrAt(--iCount); |
784 if (dwStatus > FX_RTFBREAK_PieceBreak) { | 784 if (dwStatus > FX_RTFBREAK_PieceBreak) { |
785 pLastPiece->m_dwStatus = dwStatus; | 785 pLastPiece->m_dwStatus = dwStatus; |
786 } else { | 786 } else { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
829 } | 829 } |
830 EndBreak_Ret: | 830 EndBreak_Ret: |
831 m_pCurLine = pNextLine; | 831 m_pCurLine = pNextLine; |
832 m_pCurLine->m_iStart = m_iBoundaryStart; | 832 m_pCurLine->m_iStart = m_iBoundaryStart; |
833 CFX_RTFChar* pTC = GetLastChar(0); | 833 CFX_RTFChar* pTC = GetLastChar(0); |
834 m_dwCharType = pTC == NULL ? 0 : pTC->GetCharType(); | 834 m_dwCharType = pTC == NULL ? 0 : pTC->GetCharType(); |
835 return dwStatus; | 835 return dwStatus; |
836 } | 836 } |
837 FX_BOOL CFX_RTFBreak::EndBreak_SplitLine(CFX_RTFLine* pNextLine, | 837 FX_BOOL CFX_RTFBreak::EndBreak_SplitLine(CFX_RTFLine* pNextLine, |
838 FX_BOOL bAllChars, | 838 FX_BOOL bAllChars, |
839 FX_DWORD dwStatus) { | 839 uint32_t dwStatus) { |
840 FX_BOOL bDone = FALSE; | 840 FX_BOOL bDone = FALSE; |
841 if (!m_bSingleLine && !m_bOrphanLine && | 841 if (!m_bSingleLine && !m_bOrphanLine && |
842 m_pCurLine->GetLineEnd() > m_iBoundaryEnd + m_iTolerance) { | 842 m_pCurLine->GetLineEnd() > m_iBoundaryEnd + m_iTolerance) { |
843 CFX_RTFChar& tc = m_pCurLine->GetChar(m_pCurLine->CountChars() - 1); | 843 CFX_RTFChar& tc = m_pCurLine->GetChar(m_pCurLine->CountChars() - 1); |
844 switch (tc.GetCharType()) { | 844 switch (tc.GetCharType()) { |
845 case FX_CHARTYPE_Tab: | 845 case FX_CHARTYPE_Tab: |
846 if ((m_dwPolicies & FX_RTFBREAKPOLICY_TabBreak) != 0) { | 846 if ((m_dwPolicies & FX_RTFBREAKPOLICY_TabBreak) != 0) { |
847 SplitTextLine(m_pCurLine, pNextLine, !m_bPagination && bAllChars); | 847 SplitTextLine(m_pCurLine, pNextLine, !m_bPagination && bAllChars); |
848 bDone = TRUE; | 848 bDone = TRUE; |
849 } | 849 } |
(...skipping 12 matching lines...) Expand all Loading... |
862 break; | 862 break; |
863 } | 863 } |
864 } | 864 } |
865 if (m_bPagination || m_pCurLine->m_iMBCSChars > 0) { | 865 if (m_bPagination || m_pCurLine->m_iMBCSChars > 0) { |
866 const CFX_RTFChar* pCurChars = m_pCurLine->m_LineChars.GetData(); | 866 const CFX_RTFChar* pCurChars = m_pCurLine->m_LineChars.GetData(); |
867 const CFX_RTFChar* pTC; | 867 const CFX_RTFChar* pTC; |
868 CFX_RTFPieceArray* pCurPieces = &m_pCurLine->m_LinePieces; | 868 CFX_RTFPieceArray* pCurPieces = &m_pCurLine->m_LinePieces; |
869 CFX_RTFPiece tp; | 869 CFX_RTFPiece tp; |
870 tp.m_pChars = &m_pCurLine->m_LineChars; | 870 tp.m_pChars = &m_pCurLine->m_LineChars; |
871 FX_BOOL bNew = TRUE; | 871 FX_BOOL bNew = TRUE; |
872 FX_DWORD dwIdentity = (FX_DWORD)-1; | 872 uint32_t dwIdentity = (uint32_t)-1; |
873 int32_t iLast = m_pCurLine->CountChars() - 1, j = 0; | 873 int32_t iLast = m_pCurLine->CountChars() - 1, j = 0; |
874 for (int32_t i = 0; i <= iLast;) { | 874 for (int32_t i = 0; i <= iLast;) { |
875 pTC = pCurChars + i; | 875 pTC = pCurChars + i; |
876 if (bNew) { | 876 if (bNew) { |
877 tp.m_iStartChar = i; | 877 tp.m_iStartChar = i; |
878 tp.m_iStartPos += tp.m_iWidth; | 878 tp.m_iStartPos += tp.m_iWidth; |
879 tp.m_iWidth = 0; | 879 tp.m_iWidth = 0; |
880 tp.m_dwStatus = pTC->m_dwStatus; | 880 tp.m_dwStatus = pTC->m_dwStatus; |
881 tp.m_iFontSize = pTC->m_iFontSize; | 881 tp.m_iFontSize = pTC->m_iFontSize; |
882 tp.m_iFontHeight = pTC->m_iFontHeight; | 882 tp.m_iFontHeight = pTC->m_iFontHeight; |
(...skipping 23 matching lines...) Expand all Loading... |
906 } | 906 } |
907 } | 907 } |
908 return TRUE; | 908 return TRUE; |
909 } | 909 } |
910 if (bAllChars && !bDone) { | 910 if (bAllChars && !bDone) { |
911 int32_t iEndPos = m_pCurLine->GetLineEnd(); | 911 int32_t iEndPos = m_pCurLine->GetLineEnd(); |
912 GetBreakPos(m_pCurLine->m_LineChars, iEndPos, bAllChars, TRUE); | 912 GetBreakPos(m_pCurLine->m_LineChars, iEndPos, bAllChars, TRUE); |
913 } | 913 } |
914 return FALSE; | 914 return FALSE; |
915 } | 915 } |
916 void CFX_RTFBreak::EndBreak_BidiLine(CFX_TPOArray& tpos, FX_DWORD dwStatus) { | 916 void CFX_RTFBreak::EndBreak_BidiLine(CFX_TPOArray& tpos, uint32_t dwStatus) { |
917 FX_TPO tpo; | 917 FX_TPO tpo; |
918 CFX_RTFPiece tp; | 918 CFX_RTFPiece tp; |
919 CFX_RTFChar* pTC; | 919 CFX_RTFChar* pTC; |
920 int32_t i, j; | 920 int32_t i, j; |
921 CFX_RTFCharArray& chars = m_pCurLine->m_LineChars; | 921 CFX_RTFCharArray& chars = m_pCurLine->m_LineChars; |
922 int32_t iCount = m_pCurLine->CountChars(); | 922 int32_t iCount = m_pCurLine->CountChars(); |
923 FX_BOOL bDone = (!m_bPagination && !m_bCharCode && | 923 FX_BOOL bDone = (!m_bPagination && !m_bCharCode && |
924 (m_pCurLine->m_iArabicChars > 0 || m_bRTL)); | 924 (m_pCurLine->m_iArabicChars > 0 || m_bRTL)); |
925 if (bDone) { | 925 if (bDone) { |
926 int32_t iBidiNum = 0; | 926 int32_t iBidiNum = 0; |
(...skipping 14 matching lines...) Expand all Loading... |
941 pTC->m_iBidiLevel = 0; | 941 pTC->m_iBidiLevel = 0; |
942 pTC->m_iBidiPos = 0; | 942 pTC->m_iBidiPos = 0; |
943 pTC->m_iBidiOrder = 0; | 943 pTC->m_iBidiOrder = 0; |
944 } | 944 } |
945 } | 945 } |
946 tp.m_dwStatus = FX_RTFBREAK_PieceBreak; | 946 tp.m_dwStatus = FX_RTFBREAK_PieceBreak; |
947 tp.m_iStartPos = m_pCurLine->m_iStart; | 947 tp.m_iStartPos = m_pCurLine->m_iStart; |
948 tp.m_pChars = &chars; | 948 tp.m_pChars = &chars; |
949 CFX_RTFPieceArray* pCurPieces = &m_pCurLine->m_LinePieces; | 949 CFX_RTFPieceArray* pCurPieces = &m_pCurLine->m_LinePieces; |
950 int32_t iBidiLevel = -1, iCharWidth; | 950 int32_t iBidiLevel = -1, iCharWidth; |
951 FX_DWORD dwIdentity = (FX_DWORD)-1; | 951 uint32_t dwIdentity = (uint32_t)-1; |
952 i = j = 0; | 952 i = j = 0; |
953 while (i < iCount) { | 953 while (i < iCount) { |
954 pTC = chars.GetDataPtr(i); | 954 pTC = chars.GetDataPtr(i); |
955 if (iBidiLevel < 0) { | 955 if (iBidiLevel < 0) { |
956 iBidiLevel = pTC->m_iBidiLevel; | 956 iBidiLevel = pTC->m_iBidiLevel; |
957 iCharWidth = pTC->m_iCharWidth; | 957 iCharWidth = pTC->m_iCharWidth; |
958 if (iCharWidth < 1) { | 958 if (iCharWidth < 1) { |
959 tp.m_iWidth = 0; | 959 tp.m_iWidth = 0; |
960 } else { | 960 } else { |
961 tp.m_iWidth = iCharWidth; | 961 tp.m_iWidth = iCharWidth; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1004 for (i = 0; i <= j; i++) { | 1004 for (i = 0; i <= j; i++) { |
1005 tpo = tpos.GetAt(i); | 1005 tpo = tpos.GetAt(i); |
1006 CFX_RTFPiece& ttp = pCurPieces->GetAt(tpo.index); | 1006 CFX_RTFPiece& ttp = pCurPieces->GetAt(tpo.index); |
1007 ttp.m_iStartPos = iStartPos; | 1007 ttp.m_iStartPos = iStartPos; |
1008 iStartPos += ttp.m_iWidth; | 1008 iStartPos += ttp.m_iWidth; |
1009 } | 1009 } |
1010 } | 1010 } |
1011 } | 1011 } |
1012 void CFX_RTFBreak::EndBreak_Alignment(CFX_TPOArray& tpos, | 1012 void CFX_RTFBreak::EndBreak_Alignment(CFX_TPOArray& tpos, |
1013 FX_BOOL bAllChars, | 1013 FX_BOOL bAllChars, |
1014 FX_DWORD dwStatus) { | 1014 uint32_t dwStatus) { |
1015 CFX_RTFPieceArray* pCurPieces = &m_pCurLine->m_LinePieces; | 1015 CFX_RTFPieceArray* pCurPieces = &m_pCurLine->m_LinePieces; |
1016 int32_t iNetWidth = m_pCurLine->m_iWidth, iGapChars = 0, iCharWidth; | 1016 int32_t iNetWidth = m_pCurLine->m_iWidth, iGapChars = 0, iCharWidth; |
1017 int32_t iCount = pCurPieces->GetSize(); | 1017 int32_t iCount = pCurPieces->GetSize(); |
1018 FX_BOOL bFind = FALSE; | 1018 FX_BOOL bFind = FALSE; |
1019 FX_DWORD dwCharType; | 1019 uint32_t dwCharType; |
1020 int32_t i, j; | 1020 int32_t i, j; |
1021 FX_TPO tpo; | 1021 FX_TPO tpo; |
1022 for (i = iCount - 1; i > -1; i--) { | 1022 for (i = iCount - 1; i > -1; i--) { |
1023 tpo = tpos.GetAt(i); | 1023 tpo = tpos.GetAt(i); |
1024 CFX_RTFPiece& ttp = pCurPieces->GetAt(tpo.index); | 1024 CFX_RTFPiece& ttp = pCurPieces->GetAt(tpo.index); |
1025 if (!bFind) { | 1025 if (!bFind) { |
1026 iNetWidth = ttp.GetEndPos(); | 1026 iNetWidth = ttp.GetEndPos(); |
1027 } | 1027 } |
1028 FX_BOOL bArabic = FX_IsOdd(ttp.m_iBidiLevel); | 1028 FX_BOOL bArabic = FX_IsOdd(ttp.m_iBidiLevel); |
1029 j = bArabic ? 0 : ttp.m_iChars - 1; | 1029 j = bArabic ? 0 : ttp.m_iChars - 1; |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1130 iEndPos -= iCharWidth; | 1130 iEndPos -= iCharWidth; |
1131 } | 1131 } |
1132 } | 1132 } |
1133 return iLength; | 1133 return iLength; |
1134 } | 1134 } |
1135 FX_BOOL bSpaceBreak = (m_dwPolicies & FX_RTFBREAKPOLICY_SpaceBreak) != 0; | 1135 FX_BOOL bSpaceBreak = (m_dwPolicies & FX_RTFBREAKPOLICY_SpaceBreak) != 0; |
1136 FX_BOOL bTabBreak = (m_dwPolicies & FX_RTFBREAKPOLICY_TabBreak) != 0; | 1136 FX_BOOL bTabBreak = (m_dwPolicies & FX_RTFBREAKPOLICY_TabBreak) != 0; |
1137 FX_BOOL bNumberBreak = (m_dwPolicies & FX_RTFBREAKPOLICY_NumberBreak) != 0; | 1137 FX_BOOL bNumberBreak = (m_dwPolicies & FX_RTFBREAKPOLICY_NumberBreak) != 0; |
1138 FX_BOOL bInfixBreak = (m_dwPolicies & FX_RTFBREAKPOLICY_InfixBreak) != 0; | 1138 FX_BOOL bInfixBreak = (m_dwPolicies & FX_RTFBREAKPOLICY_InfixBreak) != 0; |
1139 FX_LINEBREAKTYPE eType; | 1139 FX_LINEBREAKTYPE eType; |
1140 FX_DWORD nCodeProp, nCur, nNext; | 1140 uint32_t nCodeProp, nCur, nNext; |
1141 CFX_RTFChar* pCur = pCharArray + iLength--; | 1141 CFX_RTFChar* pCur = pCharArray + iLength--; |
1142 if (bAllChars) { | 1142 if (bAllChars) { |
1143 pCur->m_nBreakType = FX_LBT_UNKNOWN; | 1143 pCur->m_nBreakType = FX_LBT_UNKNOWN; |
1144 } | 1144 } |
1145 nCodeProp = pCur->m_dwCharProps; | 1145 nCodeProp = pCur->m_dwCharProps; |
1146 nNext = nCodeProp & 0x003F; | 1146 nNext = nCodeProp & 0x003F; |
1147 int32_t iCharWidth = pCur->m_iCharWidth; | 1147 int32_t iCharWidth = pCur->m_iCharWidth; |
1148 if (iCharWidth > 0) { | 1148 if (iCharWidth > 0) { |
1149 iEndPos -= iCharWidth; | 1149 iEndPos -= iCharWidth; |
1150 } | 1150 } |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1348 FX_AdjustCharDisplayPos pAdjustPos) const { | 1348 FX_AdjustCharDisplayPos pAdjustPos) const { |
1349 if (pText == NULL || pText->iLength < 1) { | 1349 if (pText == NULL || pText->iLength < 1) { |
1350 return 0; | 1350 return 0; |
1351 } | 1351 } |
1352 FXSYS_assert(pText->pStr != NULL && pText->pWidths != NULL && | 1352 FXSYS_assert(pText->pStr != NULL && pText->pWidths != NULL && |
1353 pText->pFont != NULL && pText->pRect != NULL); | 1353 pText->pFont != NULL && pText->pRect != NULL); |
1354 const FX_WCHAR* pStr = pText->pStr; | 1354 const FX_WCHAR* pStr = pText->pStr; |
1355 int32_t* pWidths = pText->pWidths; | 1355 int32_t* pWidths = pText->pWidths; |
1356 int32_t iLength = pText->iLength - 1; | 1356 int32_t iLength = pText->iLength - 1; |
1357 IFX_Font* pFont = pText->pFont; | 1357 IFX_Font* pFont = pText->pFont; |
1358 FX_DWORD dwStyles = pText->dwLayoutStyles; | 1358 uint32_t dwStyles = pText->dwLayoutStyles; |
1359 CFX_RectF rtText(*pText->pRect); | 1359 CFX_RectF rtText(*pText->pRect); |
1360 FX_BOOL bRTLPiece = FX_IsOdd(pText->iBidiLevel); | 1360 FX_BOOL bRTLPiece = FX_IsOdd(pText->iBidiLevel); |
1361 FX_FLOAT fFontSize = pText->fFontSize; | 1361 FX_FLOAT fFontSize = pText->fFontSize; |
1362 int32_t iFontSize = FXSYS_round(fFontSize * 20.0f); | 1362 int32_t iFontSize = FXSYS_round(fFontSize * 20.0f); |
1363 int32_t iAscent = pFont->GetAscent(); | 1363 int32_t iAscent = pFont->GetAscent(); |
1364 int32_t iDescent = pFont->GetDescent(); | 1364 int32_t iDescent = pFont->GetDescent(); |
1365 int32_t iMaxHeight = iAscent - iDescent; | 1365 int32_t iMaxHeight = iAscent - iDescent; |
1366 FX_FLOAT fFontHeight = fFontSize; | 1366 FX_FLOAT fFontHeight = fFontSize; |
1367 FX_FLOAT fAscent = fFontHeight * (FX_FLOAT)iAscent / (FX_FLOAT)iMaxHeight; | 1367 FX_FLOAT fAscent = fFontHeight * (FX_FLOAT)iAscent / (FX_FLOAT)iMaxHeight; |
1368 FX_FLOAT fDescent = fFontHeight * (FX_FLOAT)iDescent / (FX_FLOAT)iMaxHeight; | 1368 FX_FLOAT fDescent = fFontHeight * (FX_FLOAT)iDescent / (FX_FLOAT)iMaxHeight; |
1369 FX_BOOL bVerticalDoc = (dwStyles & FX_RTFLAYOUTSTYLE_VerticalLayout) != 0; | 1369 FX_BOOL bVerticalDoc = (dwStyles & FX_RTFLAYOUTSTYLE_VerticalLayout) != 0; |
1370 FX_BOOL bVerticalChar = (dwStyles & FX_RTFLAYOUTSTYLE_VerticalChars) != 0; | 1370 FX_BOOL bVerticalChar = (dwStyles & FX_RTFLAYOUTSTYLE_VerticalChars) != 0; |
1371 FX_BOOL bArabicNumber = (dwStyles & FX_RTFLAYOUTSTYLE_ArabicNumber) != 0; | 1371 FX_BOOL bArabicNumber = (dwStyles & FX_RTFLAYOUTSTYLE_ArabicNumber) != 0; |
1372 FX_BOOL bMBCSCode = (dwStyles & FX_RTFLAYOUTSTYLE_MBCSCode) != 0; | 1372 FX_BOOL bMBCSCode = (dwStyles & FX_RTFLAYOUTSTYLE_MBCSCode) != 0; |
1373 int32_t iRotation = GetLineRotation(dwStyles) + pText->iCharRotation; | 1373 int32_t iRotation = GetLineRotation(dwStyles) + pText->iCharRotation; |
1374 int32_t iCharRotation; | 1374 int32_t iCharRotation; |
1375 FX_WCHAR wch, wPrev = 0xFEFF, wNext, wForm; | 1375 FX_WCHAR wch, wPrev = 0xFEFF, wNext, wForm; |
1376 int32_t iWidth, iCharWidth, iCharHeight; | 1376 int32_t iWidth, iCharWidth, iCharHeight; |
1377 FX_FLOAT fX, fY, fCharWidth, fCharHeight; | 1377 FX_FLOAT fX, fY, fCharWidth, fCharHeight; |
1378 int32_t iHorScale = pText->iHorizontalScale; | 1378 int32_t iHorScale = pText->iHorizontalScale; |
1379 int32_t iVerScale = pText->iVerticalScale; | 1379 int32_t iVerScale = pText->iVerticalScale; |
1380 FX_BOOL bEmptyChar; | 1380 FX_BOOL bEmptyChar; |
1381 FX_DWORD dwProps, dwCharType; | 1381 uint32_t dwProps, dwCharType; |
1382 fX = rtText.left; | 1382 fX = rtText.left; |
1383 fY = rtText.top; | 1383 fY = rtText.top; |
1384 if (bVerticalDoc) { | 1384 if (bVerticalDoc) { |
1385 fX += (rtText.width - fFontSize) / 2.0f; | 1385 fX += (rtText.width - fFontSize) / 2.0f; |
1386 if (bRTLPiece) { | 1386 if (bRTLPiece) { |
1387 fY = rtText.bottom(); | 1387 fY = rtText.bottom(); |
1388 } | 1388 } |
1389 } else { | 1389 } else { |
1390 if (bRTLPiece) { | 1390 if (bRTLPiece) { |
1391 fX = rtText.right(); | 1391 fX = rtText.right(); |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1606 } | 1606 } |
1607 CFX_Rect bbox; | 1607 CFX_Rect bbox; |
1608 bbox.Set(0, 0, 0, 0); | 1608 bbox.Set(0, 0, 0, 0); |
1609 if (bCharBBox) { | 1609 if (bCharBBox) { |
1610 bCharBBox = pFont->GetBBox(bbox); | 1610 bCharBBox = pFont->GetBBox(bbox); |
1611 } | 1611 } |
1612 FX_FLOAT fLeft = std::max(0.0f, bbox.left * fScale); | 1612 FX_FLOAT fLeft = std::max(0.0f, bbox.left * fScale); |
1613 FX_FLOAT fHeight = FXSYS_fabs(bbox.height * fScale); | 1613 FX_FLOAT fHeight = FXSYS_fabs(bbox.height * fScale); |
1614 rtArray.RemoveAll(); | 1614 rtArray.RemoveAll(); |
1615 rtArray.SetSize(iLength); | 1615 rtArray.SetSize(iLength); |
1616 FX_DWORD dwStyles = pText->dwLayoutStyles; | 1616 uint32_t dwStyles = pText->dwLayoutStyles; |
1617 FX_BOOL bVertical = (dwStyles & FX_RTFLAYOUTSTYLE_VerticalLayout) != 0; | 1617 FX_BOOL bVertical = (dwStyles & FX_RTFLAYOUTSTYLE_VerticalLayout) != 0; |
1618 FX_BOOL bSingleLine = (dwStyles & FX_RTFLAYOUTSTYLE_SingleLine) != 0; | 1618 FX_BOOL bSingleLine = (dwStyles & FX_RTFLAYOUTSTYLE_SingleLine) != 0; |
1619 FX_BOOL bCombText = (dwStyles & FX_TXTLAYOUTSTYLE_CombText) != 0; | 1619 FX_BOOL bCombText = (dwStyles & FX_TXTLAYOUTSTYLE_CombText) != 0; |
1620 FX_WCHAR wch, wLineBreakChar = pText->wLineBreakChar; | 1620 FX_WCHAR wch, wLineBreakChar = pText->wLineBreakChar; |
1621 int32_t iCharSize; | 1621 int32_t iCharSize; |
1622 FX_FLOAT fCharSize, fStart; | 1622 FX_FLOAT fCharSize, fStart; |
1623 if (bVertical) { | 1623 if (bVertical) { |
1624 fStart = bRTLPiece ? rect.bottom() : rect.top; | 1624 fStart = bRTLPiece ? rect.bottom() : rect.top; |
1625 } else { | 1625 } else { |
1626 fStart = bRTLPiece ? rect.right() : rect.left; | 1626 fStart = bRTLPiece ? rect.right() : rect.left; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1682 rtBBoxF.height = fHeight; | 1682 rtBBoxF.height = fHeight; |
1683 rtBBoxF.top = std::max(rtBBoxF.top, 0.0f); | 1683 rtBBoxF.top = std::max(rtBBoxF.top, 0.0f); |
1684 } | 1684 } |
1685 rtArray.SetAt(i, rtBBoxF); | 1685 rtArray.SetAt(i, rtBBoxF); |
1686 continue; | 1686 continue; |
1687 } | 1687 } |
1688 rtArray.SetAt(i, rect); | 1688 rtArray.SetAt(i, rect); |
1689 } | 1689 } |
1690 return iLength; | 1690 return iLength; |
1691 } | 1691 } |
OLD | NEW |