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 |
11 #include "core/fxcrt/include/fx_arabic.h" | 11 #include "core/fxcrt/include/fx_arabic.h" |
12 #include "core/fxcrt/include/fx_arb.h" | 12 #include "core/fxcrt/include/fx_arb.h" |
13 #include "xfa/fgas/layout/fgas_linebreak.h" | 13 #include "xfa/fgas/layout/fgas_linebreak.h" |
14 #include "xfa/fgas/layout/fgas_unicode.h" | 14 #include "xfa/fgas/layout/fgas_unicode.h" |
15 | 15 |
16 CFX_RTFBreak::CFX_RTFBreak(uint32_t dwPolicies) | 16 CFX_RTFBreak::CFX_RTFBreak(uint32_t dwPolicies) |
17 : m_dwPolicies(dwPolicies), | 17 : m_dwPolicies(dwPolicies), |
18 m_iBoundaryStart(0), | 18 m_iBoundaryStart(0), |
19 m_iBoundaryEnd(2000000), | 19 m_iBoundaryEnd(2000000), |
20 m_dwLayoutStyles(0), | 20 m_dwLayoutStyles(0), |
21 m_bPagination(FALSE), | 21 m_bPagination(FALSE), |
22 m_bVertical(FALSE), | 22 m_bVertical(FALSE), |
23 m_bSingleLine(FALSE), | 23 m_bSingleLine(FALSE), |
24 m_bCharCode(FALSE), | 24 m_bCharCode(FALSE), |
25 m_pFont(NULL), | 25 m_pFont(nullptr), |
26 m_iFontHeight(240), | 26 m_iFontHeight(240), |
27 m_iFontSize(240), | 27 m_iFontSize(240), |
28 m_iTabWidth(720000), | 28 m_iTabWidth(720000), |
29 m_PositionedTabs(), | 29 m_PositionedTabs(), |
30 m_bOrphanLine(FALSE), | 30 m_bOrphanLine(FALSE), |
31 m_wDefChar(0xFEFF), | 31 m_wDefChar(0xFEFF), |
32 m_iDefChar(0), | 32 m_iDefChar(0), |
33 m_wLineBreakChar(L'\n'), | 33 m_wLineBreakChar(L'\n'), |
34 m_iHorizontalScale(100), | 34 m_iHorizontalScale(100), |
35 m_iVerticalScale(100), | 35 m_iVerticalScale(100), |
36 m_iLineRotation(0), | 36 m_iLineRotation(0), |
37 m_iCharRotation(0), | 37 m_iCharRotation(0), |
38 m_iRotation(0), | 38 m_iRotation(0), |
39 m_iCharSpace(0), | 39 m_iCharSpace(0), |
40 m_bWordSpace(FALSE), | 40 m_bWordSpace(FALSE), |
41 m_iWordSpace(0), | 41 m_iWordSpace(0), |
42 m_bRTL(FALSE), | 42 m_bRTL(FALSE), |
43 m_iAlignment(FX_RTFLINEALIGNMENT_Left), | 43 m_iAlignment(FX_RTFLINEALIGNMENT_Left), |
44 m_pUserData(NULL), | 44 m_pUserData(nullptr), |
45 m_eCharType(FX_CHARTYPE_Unknown), | 45 m_eCharType(FX_CHARTYPE_Unknown), |
46 m_dwIdentity(0), | 46 m_dwIdentity(0), |
47 m_RTFLine1(), | 47 m_RTFLine1(), |
48 m_RTFLine2(), | 48 m_RTFLine2(), |
49 m_pCurLine(NULL), | 49 m_pCurLine(nullptr), |
50 m_iReady(0), | 50 m_iReady(0), |
51 m_iTolerance(0) { | 51 m_iTolerance(0) { |
52 m_pCurLine = &m_RTFLine1; | 52 m_pCurLine = &m_RTFLine1; |
53 } | 53 } |
54 CFX_RTFBreak::~CFX_RTFBreak() { | 54 CFX_RTFBreak::~CFX_RTFBreak() { |
55 Reset(); | 55 Reset(); |
56 m_PositionedTabs.RemoveAll(); | 56 m_PositionedTabs.RemoveAll(); |
57 if (m_pUserData != NULL) { | 57 if (m_pUserData) |
58 m_pUserData->Release(); | 58 m_pUserData->Release(); |
59 } | |
60 } | 59 } |
61 void CFX_RTFBreak::SetLineBoundary(FX_FLOAT fLineStart, FX_FLOAT fLineEnd) { | 60 void CFX_RTFBreak::SetLineBoundary(FX_FLOAT fLineStart, FX_FLOAT fLineEnd) { |
62 if (fLineStart > fLineEnd) | 61 if (fLineStart > fLineEnd) |
63 return; | 62 return; |
64 m_iBoundaryStart = FXSYS_round(fLineStart * 20000.0f); | 63 m_iBoundaryStart = FXSYS_round(fLineStart * 20000.0f); |
65 m_iBoundaryEnd = FXSYS_round(fLineEnd * 20000.0f); | 64 m_iBoundaryEnd = FXSYS_round(fLineEnd * 20000.0f); |
66 m_pCurLine->m_iStart = std::min(m_pCurLine->m_iStart, m_iBoundaryEnd); | 65 m_pCurLine->m_iStart = std::min(m_pCurLine->m_iStart, m_iBoundaryEnd); |
67 m_pCurLine->m_iStart = std::max(m_pCurLine->m_iStart, m_iBoundaryStart); | 66 m_pCurLine->m_iStart = std::max(m_pCurLine->m_iStart, m_iBoundaryStart); |
68 } | 67 } |
69 void CFX_RTFBreak::SetLineStartPos(FX_FLOAT fLinePos) { | 68 void CFX_RTFBreak::SetLineStartPos(FX_FLOAT fLinePos) { |
(...skipping 10 matching lines...) Expand all Loading... |
80 m_dwLayoutStyles = dwLayoutStyles; | 79 m_dwLayoutStyles = dwLayoutStyles; |
81 m_bPagination = (m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_Pagination) != 0; | 80 m_bPagination = (m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_Pagination) != 0; |
82 m_bVertical = (m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_VerticalChars) != 0; | 81 m_bVertical = (m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_VerticalChars) != 0; |
83 m_bSingleLine = (m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_SingleLine) != 0; | 82 m_bSingleLine = (m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_SingleLine) != 0; |
84 m_bCharCode = (m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_MBCSCode) != 0; | 83 m_bCharCode = (m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_MBCSCode) != 0; |
85 m_iLineRotation = GetLineRotation(m_dwLayoutStyles); | 84 m_iLineRotation = GetLineRotation(m_dwLayoutStyles); |
86 m_iRotation = m_iLineRotation + m_iCharRotation; | 85 m_iRotation = m_iLineRotation + m_iCharRotation; |
87 m_iRotation %= 4; | 86 m_iRotation %= 4; |
88 } | 87 } |
89 void CFX_RTFBreak::SetFont(IFGAS_Font* pFont) { | 88 void CFX_RTFBreak::SetFont(IFGAS_Font* pFont) { |
90 if (pFont == NULL) { | 89 if (!pFont || m_pFont == pFont) |
91 return; | 90 return; |
92 } | 91 |
93 if (m_pFont == pFont) { | |
94 return; | |
95 } | |
96 SetBreakStatus(); | 92 SetBreakStatus(); |
97 m_pFont = pFont; | 93 m_pFont = pFont; |
98 m_iDefChar = 0; | 94 m_iDefChar = 0; |
99 if (m_pFont != NULL) { | 95 if (m_pFont) { |
100 m_iFontHeight = m_iFontSize; | 96 m_iFontHeight = m_iFontSize; |
101 if (m_wDefChar != 0xFEFF) { | 97 if (m_wDefChar != 0xFEFF) { |
102 m_pFont->GetCharWidth(m_wDefChar, m_iDefChar, FALSE); | 98 m_pFont->GetCharWidth(m_wDefChar, m_iDefChar, FALSE); |
103 m_iDefChar *= m_iFontSize; | 99 m_iDefChar *= m_iFontSize; |
104 } | 100 } |
105 } | 101 } |
106 } | 102 } |
107 void CFX_RTFBreak::SetFontSize(FX_FLOAT fFontSize) { | 103 void CFX_RTFBreak::SetFontSize(FX_FLOAT fFontSize) { |
108 int32_t iFontSize = FXSYS_round(fFontSize * 20.0f); | 104 int32_t iFontSize = FXSYS_round(fFontSize * 20.0f); |
109 if (m_iFontSize == iFontSize) { | 105 if (m_iFontSize == iFontSize) { |
110 return; | 106 return; |
111 } | 107 } |
112 SetBreakStatus(); | 108 SetBreakStatus(); |
113 m_iFontSize = iFontSize; | 109 m_iFontSize = iFontSize; |
114 m_iDefChar = 0; | 110 m_iDefChar = 0; |
115 if (m_pFont != NULL) { | 111 if (m_pFont) { |
116 m_iFontHeight = m_iFontSize; | 112 m_iFontHeight = m_iFontSize; |
117 if (m_wDefChar != 0xFEFF) { | 113 if (m_wDefChar != 0xFEFF) { |
118 m_pFont->GetCharWidth(m_wDefChar, m_iDefChar, FALSE); | 114 m_pFont->GetCharWidth(m_wDefChar, m_iDefChar, FALSE); |
119 m_iDefChar *= m_iFontSize; | 115 m_iDefChar *= m_iFontSize; |
120 } | 116 } |
121 } | 117 } |
122 } | 118 } |
123 void CFX_RTFBreak::SetTabWidth(FX_FLOAT fTabWidth) { | 119 void CFX_RTFBreak::SetTabWidth(FX_FLOAT fTabWidth) { |
124 m_iTabWidth = FXSYS_round(fTabWidth * 20000.0f); | 120 m_iTabWidth = FXSYS_round(fTabWidth * 20000.0f); |
125 } | 121 } |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 m_bOrphanLine = FALSE; | 161 m_bOrphanLine = FALSE; |
166 } | 162 } |
167 } | 163 } |
168 void CFX_RTFBreak::ClearPositionedTabs() { | 164 void CFX_RTFBreak::ClearPositionedTabs() { |
169 m_PositionedTabs.RemoveAll(); | 165 m_PositionedTabs.RemoveAll(); |
170 m_bOrphanLine = FALSE; | 166 m_bOrphanLine = FALSE; |
171 } | 167 } |
172 void CFX_RTFBreak::SetDefaultChar(FX_WCHAR wch) { | 168 void CFX_RTFBreak::SetDefaultChar(FX_WCHAR wch) { |
173 m_wDefChar = wch; | 169 m_wDefChar = wch; |
174 m_iDefChar = 0; | 170 m_iDefChar = 0; |
175 if (m_wDefChar != 0xFEFF && m_pFont != NULL) { | 171 if (m_wDefChar != 0xFEFF && m_pFont) { |
176 m_pFont->GetCharWidth(m_wDefChar, m_iDefChar, FALSE); | 172 m_pFont->GetCharWidth(m_wDefChar, m_iDefChar, FALSE); |
177 if (m_iDefChar < 0) { | 173 if (m_iDefChar < 0) { |
178 m_iDefChar = 0; | 174 m_iDefChar = 0; |
179 } else { | 175 } else { |
180 m_iDefChar *= m_iFontSize; | 176 m_iDefChar *= m_iFontSize; |
181 } | 177 } |
182 } | 178 } |
183 } | 179 } |
184 void CFX_RTFBreak::SetLineBreakChar(FX_WCHAR wch) { | 180 void CFX_RTFBreak::SetLineBreakChar(FX_WCHAR wch) { |
185 if (wch != L'\r' && wch != L'\n') { | 181 if (wch != L'\r' && wch != L'\n') { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 void CFX_RTFBreak::SetAlignment(int32_t iAlignment) { | 233 void CFX_RTFBreak::SetAlignment(int32_t iAlignment) { |
238 ASSERT(iAlignment >= FX_RTFLINEALIGNMENT_Left && | 234 ASSERT(iAlignment >= FX_RTFLINEALIGNMENT_Left && |
239 iAlignment <= FX_RTFLINEALIGNMENT_Distributed); | 235 iAlignment <= FX_RTFLINEALIGNMENT_Distributed); |
240 m_iAlignment = iAlignment; | 236 m_iAlignment = iAlignment; |
241 } | 237 } |
242 void CFX_RTFBreak::SetUserData(IFX_Retainable* pUserData) { | 238 void CFX_RTFBreak::SetUserData(IFX_Retainable* pUserData) { |
243 if (m_pUserData == pUserData) { | 239 if (m_pUserData == pUserData) { |
244 return; | 240 return; |
245 } | 241 } |
246 SetBreakStatus(); | 242 SetBreakStatus(); |
247 if (m_pUserData != NULL) { | 243 if (m_pUserData) |
248 m_pUserData->Release(); | 244 m_pUserData->Release(); |
249 } | |
250 m_pUserData = pUserData; | 245 m_pUserData = pUserData; |
251 if (m_pUserData != NULL) { | 246 if (m_pUserData) |
252 m_pUserData->Retain(); | 247 m_pUserData->Retain(); |
253 } | |
254 } | 248 } |
255 static const int32_t gs_FX_RTFLineRotations[8] = {0, 3, 1, 0, 2, 1, 3, 2}; | 249 static const int32_t gs_FX_RTFLineRotations[8] = {0, 3, 1, 0, 2, 1, 3, 2}; |
256 int32_t CFX_RTFBreak::GetLineRotation(uint32_t dwStyles) const { | 250 int32_t CFX_RTFBreak::GetLineRotation(uint32_t dwStyles) const { |
257 return gs_FX_RTFLineRotations[(dwStyles & 0x0E) >> 1]; | 251 return gs_FX_RTFLineRotations[(dwStyles & 0x0E) >> 1]; |
258 } | 252 } |
259 void CFX_RTFBreak::SetBreakStatus() { | 253 void CFX_RTFBreak::SetBreakStatus() { |
260 m_dwIdentity++; | 254 m_dwIdentity++; |
261 int32_t iCount = m_pCurLine->CountChars(); | 255 int32_t iCount = m_pCurLine->CountChars(); |
262 if (iCount < 1) { | 256 if (iCount < 1) { |
263 return; | 257 return; |
264 } | 258 } |
265 CFX_RTFChar& tc = m_pCurLine->GetChar(iCount - 1); | 259 CFX_RTFChar& tc = m_pCurLine->GetChar(iCount - 1); |
266 if (tc.m_dwStatus == 0) { | 260 if (tc.m_dwStatus == 0) { |
267 tc.m_dwStatus = FX_RTFBREAK_PieceBreak; | 261 tc.m_dwStatus = FX_RTFBREAK_PieceBreak; |
268 } | 262 } |
269 } | 263 } |
270 CFX_RTFChar* CFX_RTFBreak::GetLastChar(int32_t index) const { | 264 CFX_RTFChar* CFX_RTFBreak::GetLastChar(int32_t index) const { |
271 CFX_RTFCharArray& tca = m_pCurLine->m_LineChars; | 265 CFX_RTFCharArray& tca = m_pCurLine->m_LineChars; |
272 int32_t iCount = tca.GetSize(); | 266 int32_t iCount = tca.GetSize(); |
273 if (index < 0 || index >= iCount) { | 267 if (index < 0 || index >= iCount) { |
274 return NULL; | 268 return nullptr; |
275 } | 269 } |
276 CFX_RTFChar* pTC; | 270 CFX_RTFChar* pTC; |
277 int32_t iStart = iCount - 1; | 271 int32_t iStart = iCount - 1; |
278 while (iStart > -1) { | 272 while (iStart > -1) { |
279 pTC = tca.GetDataPtr(iStart--); | 273 pTC = tca.GetDataPtr(iStart--); |
280 if (pTC->m_iCharWidth >= 0 || | 274 if (pTC->m_iCharWidth >= 0 || |
281 pTC->GetCharType() != FX_CHARTYPE_Combination) { | 275 pTC->GetCharType() != FX_CHARTYPE_Combination) { |
282 if (--index < 0) { | 276 if (--index < 0) { |
283 return pTC; | 277 return pTC; |
284 } | 278 } |
285 } | 279 } |
286 } | 280 } |
287 return NULL; | 281 return nullptr; |
288 } | 282 } |
289 CFX_RTFLine* CFX_RTFBreak::GetRTFLine(FX_BOOL bReady) const { | 283 CFX_RTFLine* CFX_RTFBreak::GetRTFLine(FX_BOOL bReady) const { |
290 if (bReady) { | 284 if (bReady) { |
291 if (m_iReady == 1) { | 285 if (m_iReady == 1) |
292 return (CFX_RTFLine*)&m_RTFLine1; | 286 return (CFX_RTFLine*)&m_RTFLine1; |
293 } else if (m_iReady == 2) { | 287 if (m_iReady == 2) |
294 return (CFX_RTFLine*)&m_RTFLine2; | 288 return (CFX_RTFLine*)&m_RTFLine2; |
295 } else { | 289 return nullptr; |
296 return NULL; | |
297 } | |
298 } | 290 } |
299 ASSERT(m_pCurLine != NULL); | 291 ASSERT(m_pCurLine); |
300 return m_pCurLine; | 292 return m_pCurLine; |
301 } | 293 } |
302 CFX_RTFPieceArray* CFX_RTFBreak::GetRTFPieces(FX_BOOL bReady) const { | 294 CFX_RTFPieceArray* CFX_RTFBreak::GetRTFPieces(FX_BOOL bReady) const { |
303 CFX_RTFLine* pRTFLine = GetRTFLine(bReady); | 295 CFX_RTFLine* pRTFLine = GetRTFLine(bReady); |
304 if (pRTFLine == NULL) { | 296 return pRTFLine ? &pRTFLine->m_LinePieces : nullptr; |
305 return NULL; | |
306 } | |
307 return &pRTFLine->m_LinePieces; | |
308 } | 297 } |
309 inline FX_CHARTYPE CFX_RTFBreak::GetUnifiedCharType( | 298 inline FX_CHARTYPE CFX_RTFBreak::GetUnifiedCharType( |
310 FX_CHARTYPE chartype) const { | 299 FX_CHARTYPE chartype) const { |
311 return chartype >= FX_CHARTYPE_ArabicAlef ? FX_CHARTYPE_Arabic : chartype; | 300 return chartype >= FX_CHARTYPE_ArabicAlef ? FX_CHARTYPE_Arabic : chartype; |
312 } | 301 } |
313 int32_t CFX_RTFBreak::GetLastPositionedTab() const { | 302 int32_t CFX_RTFBreak::GetLastPositionedTab() const { |
314 int32_t iCount = m_PositionedTabs.GetSize(); | 303 int32_t iCount = m_PositionedTabs.GetSize(); |
315 if (iCount < 1) { | 304 if (iCount < 1) { |
316 return m_iBoundaryStart; | 305 return m_iBoundaryStart; |
317 } | 306 } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 pCurChar->m_dwCharProps = dwProps; | 343 pCurChar->m_dwCharProps = dwProps; |
355 pCurChar->m_dwCharStyles = 0; | 344 pCurChar->m_dwCharStyles = 0; |
356 pCurChar->m_dwLayoutStyles = 0; | 345 pCurChar->m_dwLayoutStyles = 0; |
357 pCurChar->m_iFontSize = m_iFontSize; | 346 pCurChar->m_iFontSize = m_iFontSize; |
358 pCurChar->m_iFontHeight = m_iFontHeight; | 347 pCurChar->m_iFontHeight = m_iFontHeight; |
359 pCurChar->m_iHorizontalScale = m_iHorizontalScale; | 348 pCurChar->m_iHorizontalScale = m_iHorizontalScale; |
360 pCurChar->m_iVertialScale = m_iVerticalScale; | 349 pCurChar->m_iVertialScale = m_iVerticalScale; |
361 pCurChar->m_nRotation = m_iCharRotation; | 350 pCurChar->m_nRotation = m_iCharRotation; |
362 pCurChar->m_iCharWidth = 0; | 351 pCurChar->m_iCharWidth = 0; |
363 pCurChar->m_dwIdentity = m_dwIdentity; | 352 pCurChar->m_dwIdentity = m_dwIdentity; |
364 if (m_pUserData != NULL) { | 353 if (m_pUserData) |
365 m_pUserData->Retain(); | 354 m_pUserData->Retain(); |
366 } | 355 |
367 pCurChar->m_pUserData = m_pUserData; | 356 pCurChar->m_pUserData = m_pUserData; |
368 uint32_t dwRet1 = FX_RTFBREAK_None; | 357 uint32_t dwRet1 = FX_RTFBREAK_None; |
369 if (chartype != FX_CHARTYPE_Combination && | 358 if (chartype != FX_CHARTYPE_Combination && |
370 GetUnifiedCharType(m_eCharType) != GetUnifiedCharType(chartype)) { | 359 GetUnifiedCharType(m_eCharType) != GetUnifiedCharType(chartype)) { |
371 if (!m_bSingleLine && !m_bOrphanLine && | 360 if (!m_bSingleLine && !m_bOrphanLine && |
372 m_eCharType != FX_CHARTYPE_Unknown && | 361 m_eCharType != FX_CHARTYPE_Unknown && |
373 m_pCurLine->GetLineEnd() > m_iBoundaryEnd + m_iTolerance) { | 362 m_pCurLine->GetLineEnd() > m_iBoundaryEnd + m_iTolerance) { |
374 if (m_eCharType != FX_CHARTYPE_Space || chartype != FX_CHARTYPE_Control) { | 363 if (m_eCharType != FX_CHARTYPE_Space || chartype != FX_CHARTYPE_Control) { |
375 dwRet1 = EndBreak(FX_RTFBREAK_LineBreak); | 364 dwRet1 = EndBreak(FX_RTFBREAK_LineBreak); |
376 int32_t iCount = m_pCurLine->CountChars(); | 365 int32_t iCount = m_pCurLine->CountChars(); |
377 if (iCount > 0) { | 366 if (iCount > 0) { |
378 pCurChar = m_pCurLine->m_LineChars.GetDataPtr(iCount - 1); | 367 pCurChar = m_pCurLine->m_LineChars.GetDataPtr(iCount - 1); |
379 } | 368 } |
380 } | 369 } |
381 } | 370 } |
382 } | 371 } |
383 int32_t iRotation = m_iRotation; | 372 int32_t iRotation = m_iRotation; |
384 if (m_bVertical && (dwProps & 0x8000) != 0) { | 373 if (m_bVertical && (dwProps & 0x8000) != 0) { |
385 iRotation = (iRotation + 1) % 4; | 374 iRotation = (iRotation + 1) % 4; |
386 } | 375 } |
387 uint32_t dwRet2 = | 376 uint32_t dwRet2 = |
388 (this->*g_FX_RTFBreak_lpfAppendChar[chartype >> FX_CHARTYPEBITS])( | 377 (this->*g_FX_RTFBreak_lpfAppendChar[chartype >> FX_CHARTYPEBITS])( |
389 pCurChar, iRotation); | 378 pCurChar, iRotation); |
390 m_eCharType = chartype; | 379 m_eCharType = chartype; |
391 return std::max(dwRet1, dwRet2); | 380 return std::max(dwRet1, dwRet2); |
392 } | 381 } |
393 uint32_t CFX_RTFBreak::AppendChar_CharCode(FX_WCHAR wch) { | 382 uint32_t CFX_RTFBreak::AppendChar_CharCode(FX_WCHAR wch) { |
394 ASSERT(m_pFont != NULL && m_pCurLine != NULL); | 383 ASSERT(m_pFont && m_pCurLine); |
395 ASSERT(m_bCharCode); | 384 ASSERT(m_bCharCode); |
396 m_pCurLine->m_iMBCSChars++; | 385 m_pCurLine->m_iMBCSChars++; |
397 CFX_RTFCharArray& tca = m_pCurLine->m_LineChars; | 386 CFX_RTFCharArray& tca = m_pCurLine->m_LineChars; |
398 CFX_RTFChar* pCurChar = tca.AddSpace(); | 387 CFX_RTFChar* pCurChar = tca.AddSpace(); |
399 pCurChar->m_dwStatus = 0; | 388 pCurChar->m_dwStatus = 0; |
400 pCurChar->m_wCharCode = wch; | 389 pCurChar->m_wCharCode = wch; |
401 pCurChar->m_dwCharProps = 0; | 390 pCurChar->m_dwCharProps = 0; |
402 pCurChar->m_dwCharStyles = 0; | 391 pCurChar->m_dwCharStyles = 0; |
403 pCurChar->m_dwLayoutStyles = m_dwLayoutStyles; | 392 pCurChar->m_dwLayoutStyles = m_dwLayoutStyles; |
404 pCurChar->m_iFontSize = m_iFontSize; | 393 pCurChar->m_iFontSize = m_iFontSize; |
405 pCurChar->m_iFontHeight = m_iFontHeight; | 394 pCurChar->m_iFontHeight = m_iFontHeight; |
406 pCurChar->m_iHorizontalScale = m_iHorizontalScale; | 395 pCurChar->m_iHorizontalScale = m_iHorizontalScale; |
407 pCurChar->m_iVertialScale = m_iVerticalScale; | 396 pCurChar->m_iVertialScale = m_iVerticalScale; |
408 pCurChar->m_nRotation = m_iCharRotation; | 397 pCurChar->m_nRotation = m_iCharRotation; |
409 pCurChar->m_iCharWidth = 0; | 398 pCurChar->m_iCharWidth = 0; |
410 pCurChar->m_dwIdentity = m_dwIdentity; | 399 pCurChar->m_dwIdentity = m_dwIdentity; |
411 if (m_pUserData != NULL) { | 400 if (m_pUserData) |
412 m_pUserData->Retain(); | 401 m_pUserData->Retain(); |
413 } | 402 |
414 pCurChar->m_pUserData = m_pUserData; | 403 pCurChar->m_pUserData = m_pUserData; |
415 int32_t iCharWidth = 0; | 404 int32_t iCharWidth = 0; |
416 if (m_bVertical != FX_IsOdd(m_iRotation)) { | 405 if (m_bVertical != FX_IsOdd(m_iRotation)) { |
417 iCharWidth = 1000; | 406 iCharWidth = 1000; |
418 } else { | 407 } else { |
419 if (!m_pFont->GetCharWidth(wch, iCharWidth, TRUE)) { | 408 if (!m_pFont->GetCharWidth(wch, iCharWidth, TRUE)) { |
420 iCharWidth = m_iDefChar; | 409 iCharWidth = m_iDefChar; |
421 } | 410 } |
422 } | 411 } |
423 iCharWidth *= m_iFontSize; | 412 iCharWidth *= m_iFontSize; |
(...skipping 15 matching lines...) Expand all Loading... |
439 iCharWidth = 1000; | 428 iCharWidth = 1000; |
440 } else { | 429 } else { |
441 if (!m_pFont->GetCharWidth(pCurChar->m_wCharCode, iCharWidth, | 430 if (!m_pFont->GetCharWidth(pCurChar->m_wCharCode, iCharWidth, |
442 m_bCharCode)) { | 431 m_bCharCode)) { |
443 iCharWidth = 0; | 432 iCharWidth = 0; |
444 } | 433 } |
445 } | 434 } |
446 iCharWidth *= m_iFontSize; | 435 iCharWidth *= m_iFontSize; |
447 iCharWidth = iCharWidth * m_iHorizontalScale / 100; | 436 iCharWidth = iCharWidth * m_iHorizontalScale / 100; |
448 CFX_RTFChar* pLastChar = GetLastChar(0); | 437 CFX_RTFChar* pLastChar = GetLastChar(0); |
449 if (pLastChar != NULL && pLastChar->GetCharType() > FX_CHARTYPE_Combination) { | 438 if (pLastChar && pLastChar->GetCharType() > FX_CHARTYPE_Combination) { |
450 iCharWidth = -iCharWidth; | 439 iCharWidth = -iCharWidth; |
451 } else { | 440 } else { |
452 m_eCharType = FX_CHARTYPE_Combination; | 441 m_eCharType = FX_CHARTYPE_Combination; |
453 } | 442 } |
454 pCurChar->m_iCharWidth = iCharWidth; | 443 pCurChar->m_iCharWidth = iCharWidth; |
455 if (iCharWidth > 0) { | 444 if (iCharWidth > 0) { |
456 m_pCurLine->m_iWidth += iCharWidth; | 445 m_pCurLine->m_iWidth += iCharWidth; |
457 } | 446 } |
458 return FX_RTFBREAK_None; | 447 return FX_RTFBREAK_None; |
459 } | 448 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 break; | 490 break; |
502 } | 491 } |
503 if (dwRet2 != FX_RTFBREAK_None) { | 492 if (dwRet2 != FX_RTFBREAK_None) { |
504 dwRet2 = EndBreak(dwRet2); | 493 dwRet2 = EndBreak(dwRet2); |
505 } | 494 } |
506 } | 495 } |
507 return dwRet2; | 496 return dwRet2; |
508 } | 497 } |
509 uint32_t CFX_RTFBreak::AppendChar_Arabic(CFX_RTFChar* pCurChar, | 498 uint32_t CFX_RTFBreak::AppendChar_Arabic(CFX_RTFChar* pCurChar, |
510 int32_t iRotation) { | 499 int32_t iRotation) { |
511 CFX_RTFChar* pLastChar = NULL; | 500 CFX_RTFChar* pLastChar = nullptr; |
512 int32_t& iLineWidth = m_pCurLine->m_iWidth; | 501 int32_t& iLineWidth = m_pCurLine->m_iWidth; |
513 int32_t iCharWidth = 0; | 502 int32_t iCharWidth = 0; |
514 FX_WCHAR wForm; | 503 FX_WCHAR wForm; |
515 FX_BOOL bAlef = FALSE; | 504 FX_BOOL bAlef = FALSE; |
516 if (m_eCharType >= FX_CHARTYPE_ArabicAlef && | 505 if (m_eCharType >= FX_CHARTYPE_ArabicAlef && |
517 m_eCharType <= FX_CHARTYPE_ArabicDistortion) { | 506 m_eCharType <= FX_CHARTYPE_ArabicDistortion) { |
518 pLastChar = GetLastChar(1); | 507 pLastChar = GetLastChar(1); |
519 if (pLastChar != NULL) { | 508 if (pLastChar) { |
520 iLineWidth -= pLastChar->m_iCharWidth; | 509 iLineWidth -= pLastChar->m_iCharWidth; |
521 CFX_RTFChar* pPrevChar = GetLastChar(2); | 510 CFX_RTFChar* pPrevChar = GetLastChar(2); |
522 wForm = pdfium::arabic::GetFormChar(pLastChar, pPrevChar, pCurChar); | 511 wForm = pdfium::arabic::GetFormChar(pLastChar, pPrevChar, pCurChar); |
523 bAlef = (wForm == 0xFEFF && | 512 bAlef = (wForm == 0xFEFF && |
524 pLastChar->GetCharType() == FX_CHARTYPE_ArabicAlef); | 513 pLastChar->GetCharType() == FX_CHARTYPE_ArabicAlef); |
525 int32_t iLastRotation = pLastChar->m_nRotation + m_iLineRotation; | 514 int32_t iLastRotation = pLastChar->m_nRotation + m_iLineRotation; |
526 if (m_bVertical && (pLastChar->m_dwCharProps & 0x8000) != 0) { | 515 if (m_bVertical && (pLastChar->m_dwCharProps & 0x8000) != 0) { |
527 iLastRotation++; | 516 iLastRotation++; |
528 } | 517 } |
529 if (m_bVertical != FX_IsOdd(iLastRotation)) { | 518 if (m_bVertical != FX_IsOdd(iLastRotation)) { |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
613 if (iCount > 0) { | 602 if (iCount > 0) { |
614 CFX_RTFPiece* pLastPiece = pCurPieces->GetPtrAt(--iCount); | 603 CFX_RTFPiece* pLastPiece = pCurPieces->GetPtrAt(--iCount); |
615 if (dwStatus > FX_RTFBREAK_PieceBreak) { | 604 if (dwStatus > FX_RTFBREAK_PieceBreak) { |
616 pLastPiece->m_dwStatus = dwStatus; | 605 pLastPiece->m_dwStatus = dwStatus; |
617 } else { | 606 } else { |
618 dwStatus = pLastPiece->m_dwStatus; | 607 dwStatus = pLastPiece->m_dwStatus; |
619 } | 608 } |
620 return dwStatus; | 609 return dwStatus; |
621 } else { | 610 } else { |
622 CFX_RTFLine* pLastLine = GetRTFLine(TRUE); | 611 CFX_RTFLine* pLastLine = GetRTFLine(TRUE); |
623 if (pLastLine != NULL) { | 612 if (pLastLine) { |
624 pCurPieces = &pLastLine->m_LinePieces; | 613 pCurPieces = &pLastLine->m_LinePieces; |
625 iCount = pCurPieces->GetSize(); | 614 iCount = pCurPieces->GetSize(); |
626 if (iCount-- > 0) { | 615 if (iCount-- > 0) { |
627 CFX_RTFPiece* pLastPiece = pCurPieces->GetPtrAt(iCount); | 616 CFX_RTFPiece* pLastPiece = pCurPieces->GetPtrAt(iCount); |
628 if (dwStatus > FX_RTFBREAK_PieceBreak) { | 617 if (dwStatus > FX_RTFBREAK_PieceBreak) { |
629 pLastPiece->m_dwStatus = dwStatus; | 618 pLastPiece->m_dwStatus = dwStatus; |
630 } else { | 619 } else { |
631 dwStatus = pLastPiece->m_dwStatus; | 620 dwStatus = pLastPiece->m_dwStatus; |
632 } | 621 } |
633 return dwStatus; | 622 return dwStatus; |
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1059 } | 1048 } |
1060 if (iLast > -1) { | 1049 if (iLast > -1) { |
1061 iEndPos = iLastPos; | 1050 iEndPos = iLastPos; |
1062 return iLast; | 1051 return iLast; |
1063 } | 1052 } |
1064 return 0; | 1053 return 0; |
1065 } | 1054 } |
1066 void CFX_RTFBreak::SplitTextLine(CFX_RTFLine* pCurLine, | 1055 void CFX_RTFBreak::SplitTextLine(CFX_RTFLine* pCurLine, |
1067 CFX_RTFLine* pNextLine, | 1056 CFX_RTFLine* pNextLine, |
1068 FX_BOOL bAllChars) { | 1057 FX_BOOL bAllChars) { |
1069 ASSERT(pCurLine != NULL && pNextLine != NULL); | 1058 ASSERT(pCurLine && pNextLine); |
1070 int32_t iCount = pCurLine->CountChars(); | 1059 int32_t iCount = pCurLine->CountChars(); |
1071 if (iCount < 2) { | 1060 if (iCount < 2) { |
1072 return; | 1061 return; |
1073 } | 1062 } |
1074 int32_t iEndPos = pCurLine->GetLineEnd(); | 1063 int32_t iEndPos = pCurLine->GetLineEnd(); |
1075 CFX_RTFCharArray& curChars = pCurLine->m_LineChars; | 1064 CFX_RTFCharArray& curChars = pCurLine->m_LineChars; |
1076 int32_t iCharPos = GetBreakPos(curChars, iEndPos, bAllChars, FALSE); | 1065 int32_t iCharPos = GetBreakPos(curChars, iEndPos, bAllChars, FALSE); |
1077 if (iCharPos < 0) { | 1066 if (iCharPos < 0) { |
1078 iCharPos = 0; | 1067 iCharPos = 0; |
1079 } | 1068 } |
(...skipping 26 matching lines...) Expand all Loading... |
1106 } | 1095 } |
1107 if (tc->m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_MBCSCode) { | 1096 if (tc->m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_MBCSCode) { |
1108 pCurLine->m_iMBCSChars--; | 1097 pCurLine->m_iMBCSChars--; |
1109 pNextLine->m_iMBCSChars++; | 1098 pNextLine->m_iMBCSChars++; |
1110 } | 1099 } |
1111 tc->m_dwStatus = 0; | 1100 tc->m_dwStatus = 0; |
1112 } | 1101 } |
1113 } | 1102 } |
1114 int32_t CFX_RTFBreak::CountBreakPieces() const { | 1103 int32_t CFX_RTFBreak::CountBreakPieces() const { |
1115 CFX_RTFPieceArray* pRTFPieces = GetRTFPieces(TRUE); | 1104 CFX_RTFPieceArray* pRTFPieces = GetRTFPieces(TRUE); |
1116 if (pRTFPieces == NULL) { | 1105 return pRTFPieces ? pRTFPieces->GetSize() : 0; |
1117 return 0; | |
1118 } | |
1119 return pRTFPieces->GetSize(); | |
1120 } | 1106 } |
1121 const CFX_RTFPiece* CFX_RTFBreak::GetBreakPiece(int32_t index) const { | 1107 const CFX_RTFPiece* CFX_RTFBreak::GetBreakPiece(int32_t index) const { |
1122 CFX_RTFPieceArray* pRTFPieces = GetRTFPieces(TRUE); | 1108 CFX_RTFPieceArray* pRTFPieces = GetRTFPieces(TRUE); |
1123 if (pRTFPieces == NULL) { | 1109 if (!pRTFPieces) |
1124 return NULL; | 1110 return nullptr; |
1125 } | 1111 if (index < 0 || index >= pRTFPieces->GetSize()) |
1126 if (index < 0 || index >= pRTFPieces->GetSize()) { | 1112 return nullptr; |
1127 return NULL; | |
1128 } | |
1129 return pRTFPieces->GetPtrAt(index); | 1113 return pRTFPieces->GetPtrAt(index); |
1130 } | 1114 } |
1131 void CFX_RTFBreak::GetLineRect(CFX_RectF& rect) const { | 1115 void CFX_RTFBreak::GetLineRect(CFX_RectF& rect) const { |
1132 rect.top = 0; | 1116 rect.top = 0; |
1133 CFX_RTFLine* pRTFLine = GetRTFLine(TRUE); | 1117 CFX_RTFLine* pRTFLine = GetRTFLine(TRUE); |
1134 if (pRTFLine == NULL) { | 1118 if (!pRTFLine) { |
1135 rect.left = ((FX_FLOAT)m_iBoundaryStart) / 20000.0f; | 1119 rect.left = ((FX_FLOAT)m_iBoundaryStart) / 20000.0f; |
1136 rect.width = rect.height = 0; | 1120 rect.width = rect.height = 0; |
1137 return; | 1121 return; |
1138 } | 1122 } |
1139 rect.left = ((FX_FLOAT)pRTFLine->m_iStart) / 20000.0f; | 1123 rect.left = ((FX_FLOAT)pRTFLine->m_iStart) / 20000.0f; |
1140 rect.width = ((FX_FLOAT)pRTFLine->m_iWidth) / 20000.0f; | 1124 rect.width = ((FX_FLOAT)pRTFLine->m_iWidth) / 20000.0f; |
1141 CFX_RTFPieceArray& rtfPieces = pRTFLine->m_LinePieces; | 1125 CFX_RTFPieceArray& rtfPieces = pRTFLine->m_LinePieces; |
1142 int32_t iCount = rtfPieces.GetSize(); | 1126 int32_t iCount = rtfPieces.GetSize(); |
1143 if (iCount < 1) { | 1127 if (iCount < 1) { |
1144 rect.width = 0; | 1128 rect.width = 0; |
1145 return; | 1129 return; |
1146 } | 1130 } |
1147 CFX_RTFPiece* pBreakPiece; | 1131 CFX_RTFPiece* pBreakPiece; |
1148 int32_t iLineHeight = 0, iMax; | 1132 int32_t iLineHeight = 0, iMax; |
1149 for (int32_t i = 0; i < iCount; i++) { | 1133 for (int32_t i = 0; i < iCount; i++) { |
1150 pBreakPiece = rtfPieces.GetPtrAt(i); | 1134 pBreakPiece = rtfPieces.GetPtrAt(i); |
1151 int32_t iFontHeight = FXSYS_round(pBreakPiece->m_iFontHeight * | 1135 int32_t iFontHeight = FXSYS_round(pBreakPiece->m_iFontHeight * |
1152 pBreakPiece->m_iVerticalScale / 100.0f); | 1136 pBreakPiece->m_iVerticalScale / 100.0f); |
1153 iMax = std::max(pBreakPiece->m_iFontSize, iFontHeight); | 1137 iMax = std::max(pBreakPiece->m_iFontSize, iFontHeight); |
1154 if (i == 0) { | 1138 if (i == 0) { |
1155 iLineHeight = iMax; | 1139 iLineHeight = iMax; |
1156 } else if (iLineHeight < iMax) { | 1140 } else if (iLineHeight < iMax) { |
1157 iLineHeight = iMax; | 1141 iLineHeight = iMax; |
1158 } | 1142 } |
1159 } | 1143 } |
1160 rect.height = ((FX_FLOAT)iLineHeight) / 20.0f; | 1144 rect.height = ((FX_FLOAT)iLineHeight) / 20.0f; |
1161 } | 1145 } |
1162 void CFX_RTFBreak::ClearBreakPieces() { | 1146 void CFX_RTFBreak::ClearBreakPieces() { |
1163 CFX_RTFLine* pRTFLine = GetRTFLine(TRUE); | 1147 CFX_RTFLine* pRTFLine = GetRTFLine(TRUE); |
1164 if (pRTFLine != NULL) { | 1148 if (pRTFLine) |
1165 pRTFLine->RemoveAll(TRUE); | 1149 pRTFLine->RemoveAll(TRUE); |
1166 } | |
1167 m_iReady = 0; | 1150 m_iReady = 0; |
1168 } | 1151 } |
1169 void CFX_RTFBreak::Reset() { | 1152 void CFX_RTFBreak::Reset() { |
1170 m_eCharType = FX_CHARTYPE_Unknown; | 1153 m_eCharType = FX_CHARTYPE_Unknown; |
1171 m_RTFLine1.RemoveAll(TRUE); | 1154 m_RTFLine1.RemoveAll(TRUE); |
1172 m_RTFLine2.RemoveAll(TRUE); | 1155 m_RTFLine2.RemoveAll(TRUE); |
1173 } | 1156 } |
1174 int32_t CFX_RTFBreak::GetDisplayPos(const FX_RTFTEXTOBJ* pText, | 1157 int32_t CFX_RTFBreak::GetDisplayPos(const FX_RTFTEXTOBJ* pText, |
1175 FXTEXT_CHARPOS* pCharPos, | 1158 FXTEXT_CHARPOS* pCharPos, |
1176 FX_BOOL bCharCode, | 1159 FX_BOOL bCharCode, |
1177 CFX_WideString* pWSForms, | 1160 CFX_WideString* pWSForms, |
1178 FX_AdjustCharDisplayPos pAdjustPos) const { | 1161 FX_AdjustCharDisplayPos pAdjustPos) const { |
1179 if (pText == NULL || pText->iLength < 1) { | 1162 if (!pText || pText->iLength < 1) |
1180 return 0; | 1163 return 0; |
1181 } | 1164 |
1182 ASSERT(pText->pStr != NULL && pText->pWidths != NULL && | 1165 ASSERT(pText->pStr && pText->pWidths && pText->pFont && pText->pRect); |
1183 pText->pFont != NULL && pText->pRect != NULL); | |
1184 const FX_WCHAR* pStr = pText->pStr; | 1166 const FX_WCHAR* pStr = pText->pStr; |
1185 int32_t* pWidths = pText->pWidths; | 1167 int32_t* pWidths = pText->pWidths; |
1186 int32_t iLength = pText->iLength - 1; | 1168 int32_t iLength = pText->iLength - 1; |
1187 IFGAS_Font* pFont = pText->pFont; | 1169 IFGAS_Font* pFont = pText->pFont; |
1188 uint32_t dwStyles = pText->dwLayoutStyles; | 1170 uint32_t dwStyles = pText->dwLayoutStyles; |
1189 CFX_RectF rtText(*pText->pRect); | 1171 CFX_RectF rtText(*pText->pRect); |
1190 FX_BOOL bRTLPiece = FX_IsOdd(pText->iBidiLevel); | 1172 FX_BOOL bRTLPiece = FX_IsOdd(pText->iBidiLevel); |
1191 FX_FLOAT fFontSize = pText->fFontSize; | 1173 FX_FLOAT fFontSize = pText->fFontSize; |
1192 int32_t iFontSize = FXSYS_round(fFontSize * 20.0f); | 1174 int32_t iFontSize = FXSYS_round(fFontSize * 20.0f); |
1193 int32_t iAscent = pFont->GetAscent(); | 1175 int32_t iAscent = pFont->GetAscent(); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1244 } | 1226 } |
1245 if (!bMBCSCode) { | 1227 if (!bMBCSCode) { |
1246 bEmptyChar = (dwCharType >= FX_CHARTYPE_Tab && | 1228 bEmptyChar = (dwCharType >= FX_CHARTYPE_Tab && |
1247 dwCharType <= FX_CHARTYPE_Control); | 1229 dwCharType <= FX_CHARTYPE_Control); |
1248 } else { | 1230 } else { |
1249 bEmptyChar = FALSE; | 1231 bEmptyChar = FALSE; |
1250 } | 1232 } |
1251 if (!bEmptyChar) { | 1233 if (!bEmptyChar) { |
1252 iCount++; | 1234 iCount++; |
1253 } | 1235 } |
1254 if (pCharPos != NULL) { | 1236 if (pCharPos) { |
1255 iCharWidth /= iFontSize; | 1237 iCharWidth /= iFontSize; |
1256 wForm = wch; | 1238 wForm = wch; |
1257 if (!bMBCSCode) { | 1239 if (!bMBCSCode) { |
1258 if (dwCharType >= FX_CHARTYPE_ArabicAlef) { | 1240 if (dwCharType >= FX_CHARTYPE_ArabicAlef) { |
1259 if (i < iLength) { | 1241 if (i < iLength) { |
1260 wNext = *pStr; | 1242 wNext = *pStr; |
1261 if (*pWidths < 0) { | 1243 if (*pWidths < 0) { |
1262 if (i + 1 < iLength) { | 1244 if (i + 1 < iLength) { |
1263 wNext = pStr[1]; | 1245 wNext = pStr[1]; |
1264 } | 1246 } |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1410 } | 1392 } |
1411 if (iWidth > 0) { | 1393 if (iWidth > 0) { |
1412 wPrev = wch; | 1394 wPrev = wch; |
1413 } | 1395 } |
1414 } | 1396 } |
1415 return iCount; | 1397 return iCount; |
1416 } | 1398 } |
1417 int32_t CFX_RTFBreak::GetCharRects(const FX_RTFTEXTOBJ* pText, | 1399 int32_t CFX_RTFBreak::GetCharRects(const FX_RTFTEXTOBJ* pText, |
1418 CFX_RectFArray& rtArray, | 1400 CFX_RectFArray& rtArray, |
1419 FX_BOOL bCharBBox) const { | 1401 FX_BOOL bCharBBox) const { |
1420 if (pText == NULL || pText->iLength < 1) { | 1402 if (!pText || pText->iLength < 1) |
1421 return 0; | 1403 return 0; |
1422 } | 1404 |
1423 ASSERT(pText->pStr != NULL && pText->pWidths != NULL && | 1405 ASSERT(pText->pStr && pText->pWidths && pText->pFont && pText->pRect); |
1424 pText->pFont != NULL && pText->pRect != NULL); | |
1425 const FX_WCHAR* pStr = pText->pStr; | 1406 const FX_WCHAR* pStr = pText->pStr; |
1426 int32_t* pWidths = pText->pWidths; | 1407 int32_t* pWidths = pText->pWidths; |
1427 int32_t iLength = pText->iLength; | 1408 int32_t iLength = pText->iLength; |
1428 CFX_RectF rect(*pText->pRect); | 1409 CFX_RectF rect(*pText->pRect); |
1429 FX_BOOL bRTLPiece = FX_IsOdd(pText->iBidiLevel); | 1410 FX_BOOL bRTLPiece = FX_IsOdd(pText->iBidiLevel); |
1430 FX_FLOAT fFontSize = pText->fFontSize; | 1411 FX_FLOAT fFontSize = pText->fFontSize; |
1431 int32_t iFontSize = FXSYS_round(fFontSize * 20.0f); | 1412 int32_t iFontSize = FXSYS_round(fFontSize * 20.0f); |
1432 FX_FLOAT fScale = fFontSize / 1000.0f; | 1413 FX_FLOAT fScale = fFontSize / 1000.0f; |
1433 IFGAS_Font* pFont = pText->pFont; | 1414 IFGAS_Font* pFont = pText->pFont; |
1434 if (pFont == NULL) { | 1415 if (!pFont) |
1435 bCharBBox = FALSE; | 1416 bCharBBox = FALSE; |
1436 } | 1417 |
1437 CFX_Rect bbox; | 1418 CFX_Rect bbox; |
1438 bbox.Set(0, 0, 0, 0); | 1419 bbox.Set(0, 0, 0, 0); |
1439 if (bCharBBox) { | 1420 if (bCharBBox) { |
1440 bCharBBox = pFont->GetBBox(bbox); | 1421 bCharBBox = pFont->GetBBox(bbox); |
1441 } | 1422 } |
1442 FX_FLOAT fLeft = std::max(0.0f, bbox.left * fScale); | 1423 FX_FLOAT fLeft = std::max(0.0f, bbox.left * fScale); |
1443 FX_FLOAT fHeight = FXSYS_fabs(bbox.height * fScale); | 1424 FX_FLOAT fHeight = FXSYS_fabs(bbox.height * fScale); |
1444 rtArray.RemoveAll(); | 1425 rtArray.RemoveAll(); |
1445 rtArray.SetSize(iLength); | 1426 rtArray.SetSize(iLength); |
1446 uint32_t dwStyles = pText->dwLayoutStyles; | 1427 uint32_t dwStyles = pText->dwLayoutStyles; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1512 rtBBoxF.height = fHeight; | 1493 rtBBoxF.height = fHeight; |
1513 rtBBoxF.top = std::max(rtBBoxF.top, 0.0f); | 1494 rtBBoxF.top = std::max(rtBBoxF.top, 0.0f); |
1514 } | 1495 } |
1515 rtArray.SetAt(i, rtBBoxF); | 1496 rtArray.SetAt(i, rtBBoxF); |
1516 continue; | 1497 continue; |
1517 } | 1498 } |
1518 rtArray.SetAt(i, rect); | 1499 rtArray.SetAt(i, rect); |
1519 } | 1500 } |
1520 return iLength; | 1501 return iLength; |
1521 } | 1502 } |
OLD | NEW |