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_textbreak.h" | 7 #include "xfa/fgas/layout/fgas_textbreak.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 "core/fxcrt/include/fx_memory.h" | 13 #include "core/fxcrt/include/fx_memory.h" |
14 #include "xfa/fgas/layout/fgas_linebreak.h" | 14 #include "xfa/fgas/layout/fgas_linebreak.h" |
15 #include "xfa/fgas/layout/fgas_unicode.h" | 15 #include "xfa/fgas/layout/fgas_unicode.h" |
16 | 16 |
17 CFX_TxtBreak::CFX_TxtBreak(uint32_t dwPolicies) | 17 CFX_TxtBreak::CFX_TxtBreak(uint32_t dwPolicies) |
18 : m_dwPolicies(dwPolicies), | 18 : m_dwPolicies(dwPolicies), |
19 m_iLineWidth(2000000), | 19 m_iLineWidth(2000000), |
20 m_dwLayoutStyles(0), | 20 m_dwLayoutStyles(0), |
21 m_bVertical(FALSE), | 21 m_bVertical(FALSE), |
22 m_bArabicContext(FALSE), | 22 m_bArabicContext(FALSE), |
23 m_bArabicShapes(FALSE), | 23 m_bArabicShapes(FALSE), |
24 m_bRTL(FALSE), | 24 m_bRTL(FALSE), |
25 m_bSingleLine(FALSE), | 25 m_bSingleLine(FALSE), |
26 m_bCombText(FALSE), | 26 m_bCombText(FALSE), |
27 m_iArabicContext(1), | 27 m_iArabicContext(1), |
28 m_iCurArabicContext(1), | 28 m_iCurArabicContext(1), |
29 m_pFont(NULL), | 29 m_pFont(nullptr), |
30 m_iFontSize(240), | 30 m_iFontSize(240), |
31 m_bEquidistant(TRUE), | 31 m_bEquidistant(TRUE), |
32 m_iTabWidth(720000), | 32 m_iTabWidth(720000), |
33 m_wDefChar(0xFEFF), | 33 m_wDefChar(0xFEFF), |
34 m_wParagBreakChar(L'\n'), | 34 m_wParagBreakChar(L'\n'), |
35 m_iDefChar(0), | 35 m_iDefChar(0), |
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_iAlignment(FX_TXTLINEALIGNMENT_Left), | 39 m_iAlignment(FX_TXTLINEALIGNMENT_Left), |
40 m_dwContextCharStyles(0), | 40 m_dwContextCharStyles(0), |
41 m_iCombWidth(360000), | 41 m_iCombWidth(360000), |
42 m_pUserData(NULL), | 42 m_pUserData(nullptr), |
43 m_eCharType(FX_CHARTYPE_Unknown), | 43 m_eCharType(FX_CHARTYPE_Unknown), |
44 m_bArabicNumber(FALSE), | 44 m_bArabicNumber(FALSE), |
45 m_bArabicComma(FALSE), | 45 m_bArabicComma(FALSE), |
46 m_pCurLine(NULL), | 46 m_pCurLine(nullptr), |
47 m_iReady(0), | 47 m_iReady(0), |
48 m_iTolerance(0), | 48 m_iTolerance(0), |
49 m_iHorScale(100), | 49 m_iHorScale(100), |
50 m_iVerScale(100), | 50 m_iVerScale(100), |
51 m_iCharSpace(0) { | 51 m_iCharSpace(0) { |
52 m_bPagination = (m_dwPolicies & FX_TXTBREAKPOLICY_Pagination) != 0; | 52 m_bPagination = (m_dwPolicies & FX_TXTBREAKPOLICY_Pagination) != 0; |
53 if (m_bPagination) { | 53 if (m_bPagination) { |
54 m_pTxtLine1 = new CFX_TxtLine(sizeof(CFX_Char)); | 54 m_pTxtLine1 = new CFX_TxtLine(sizeof(CFX_Char)); |
55 m_pTxtLine2 = new CFX_TxtLine(sizeof(CFX_Char)); | 55 m_pTxtLine2 = new CFX_TxtLine(sizeof(CFX_Char)); |
56 } else { | 56 } else { |
(...skipping 30 matching lines...) Expand all Loading... |
87 m_bArabicShapes = (m_dwLayoutStyles & FX_TXTLAYOUTSTYLE_ArabicShapes) != 0; | 87 m_bArabicShapes = (m_dwLayoutStyles & FX_TXTLAYOUTSTYLE_ArabicShapes) != 0; |
88 m_bRTL = (m_dwLayoutStyles & FX_TXTLAYOUTSTYLE_RTLReadingOrder) != 0; | 88 m_bRTL = (m_dwLayoutStyles & FX_TXTLAYOUTSTYLE_RTLReadingOrder) != 0; |
89 m_bSingleLine = (m_dwLayoutStyles & FX_TXTLAYOUTSTYLE_SingleLine) != 0; | 89 m_bSingleLine = (m_dwLayoutStyles & FX_TXTLAYOUTSTYLE_SingleLine) != 0; |
90 m_bCombText = (m_dwLayoutStyles & FX_TXTLAYOUTSTYLE_CombText) != 0; | 90 m_bCombText = (m_dwLayoutStyles & FX_TXTLAYOUTSTYLE_CombText) != 0; |
91 ResetArabicContext(); | 91 ResetArabicContext(); |
92 m_iLineRotation = GetLineRotation(m_dwLayoutStyles); | 92 m_iLineRotation = GetLineRotation(m_dwLayoutStyles); |
93 m_iRotation = m_iLineRotation + m_iCharRotation; | 93 m_iRotation = m_iLineRotation + m_iCharRotation; |
94 m_iRotation %= 4; | 94 m_iRotation %= 4; |
95 } | 95 } |
96 void CFX_TxtBreak::SetFont(IFGAS_Font* pFont) { | 96 void CFX_TxtBreak::SetFont(IFGAS_Font* pFont) { |
97 if (pFont == NULL) { | 97 if (!pFont || m_pFont == pFont) |
98 return; | 98 return; |
99 } | 99 |
100 if (m_pFont == pFont) { | |
101 return; | |
102 } | |
103 SetBreakStatus(); | 100 SetBreakStatus(); |
104 m_pFont = pFont; | 101 m_pFont = pFont; |
105 m_iDefChar = 0; | 102 m_iDefChar = 0; |
106 if (m_wDefChar != 0xFEFF && m_pFont != NULL) { | 103 if (m_wDefChar != 0xFEFF && m_pFont) { |
107 m_pFont->GetCharWidth(m_wDefChar, m_iDefChar, FALSE); | 104 m_pFont->GetCharWidth(m_wDefChar, m_iDefChar, FALSE); |
108 m_iDefChar *= m_iFontSize; | 105 m_iDefChar *= m_iFontSize; |
109 } | 106 } |
110 } | 107 } |
111 void CFX_TxtBreak::SetFontSize(FX_FLOAT fFontSize) { | 108 void CFX_TxtBreak::SetFontSize(FX_FLOAT fFontSize) { |
112 int32_t iFontSize = FXSYS_round(fFontSize * 20.0f); | 109 int32_t iFontSize = FXSYS_round(fFontSize * 20.0f); |
113 if (m_iFontSize == iFontSize) { | 110 if (m_iFontSize == iFontSize) { |
114 return; | 111 return; |
115 } | 112 } |
116 SetBreakStatus(); | 113 SetBreakStatus(); |
117 m_iFontSize = iFontSize; | 114 m_iFontSize = iFontSize; |
118 m_iDefChar = 0; | 115 m_iDefChar = 0; |
119 if (m_wDefChar != 0xFEFF && m_pFont != NULL) { | 116 if (m_wDefChar != 0xFEFF && m_pFont) { |
120 m_pFont->GetCharWidth(m_wDefChar, m_iDefChar, FALSE); | 117 m_pFont->GetCharWidth(m_wDefChar, m_iDefChar, FALSE); |
121 m_iDefChar *= m_iFontSize; | 118 m_iDefChar *= m_iFontSize; |
122 } | 119 } |
123 } | 120 } |
124 void CFX_TxtBreak::SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant) { | 121 void CFX_TxtBreak::SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant) { |
125 m_iTabWidth = FXSYS_round(fTabWidth * 20000.0f); | 122 m_iTabWidth = FXSYS_round(fTabWidth * 20000.0f); |
126 if (m_iTabWidth < FX_TXTBREAK_MinimumTabWidth) { | 123 if (m_iTabWidth < FX_TXTBREAK_MinimumTabWidth) { |
127 m_iTabWidth = FX_TXTBREAK_MinimumTabWidth; | 124 m_iTabWidth = FX_TXTBREAK_MinimumTabWidth; |
128 } | 125 } |
129 m_bEquidistant = bEquidistant; | 126 m_bEquidistant = bEquidistant; |
130 } | 127 } |
131 void CFX_TxtBreak::SetDefaultChar(FX_WCHAR wch) { | 128 void CFX_TxtBreak::SetDefaultChar(FX_WCHAR wch) { |
132 m_wDefChar = wch; | 129 m_wDefChar = wch; |
133 m_iDefChar = 0; | 130 m_iDefChar = 0; |
134 if (m_wDefChar != 0xFEFF && m_pFont != NULL) { | 131 if (m_wDefChar != 0xFEFF && m_pFont) { |
135 m_pFont->GetCharWidth(m_wDefChar, m_iDefChar, FALSE); | 132 m_pFont->GetCharWidth(m_wDefChar, m_iDefChar, FALSE); |
136 if (m_iDefChar < 0) { | 133 if (m_iDefChar < 0) { |
137 m_iDefChar = 0; | 134 m_iDefChar = 0; |
138 } else { | 135 } else { |
139 m_iDefChar *= m_iFontSize; | 136 m_iDefChar *= m_iFontSize; |
140 } | 137 } |
141 } | 138 } |
142 } | 139 } |
143 void CFX_TxtBreak::SetParagraphBreakChar(FX_WCHAR wch) { | 140 void CFX_TxtBreak::SetParagraphBreakChar(FX_WCHAR wch) { |
144 if (wch != L'\r' && wch != L'\n') { | 141 if (wch != L'\r' && wch != L'\n') { |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 m_iCharSpace = FXSYS_round(fCharSpace * 20000.0f); | 237 m_iCharSpace = FXSYS_round(fCharSpace * 20000.0f); |
241 } | 238 } |
242 static const int32_t gs_FX_TxtLineRotations[8] = {0, 3, 1, 0, 2, 1, 3, 2}; | 239 static const int32_t gs_FX_TxtLineRotations[8] = {0, 3, 1, 0, 2, 1, 3, 2}; |
243 int32_t CFX_TxtBreak::GetLineRotation(uint32_t dwStyles) const { | 240 int32_t CFX_TxtBreak::GetLineRotation(uint32_t dwStyles) const { |
244 return gs_FX_TxtLineRotations[(dwStyles & 0x0E) >> 1]; | 241 return gs_FX_TxtLineRotations[(dwStyles & 0x0E) >> 1]; |
245 } | 242 } |
246 CFX_TxtChar* CFX_TxtBreak::GetLastChar(int32_t index, FX_BOOL bOmitChar) const { | 243 CFX_TxtChar* CFX_TxtBreak::GetLastChar(int32_t index, FX_BOOL bOmitChar) const { |
247 CFX_TxtCharArray& ca = *m_pCurLine->m_pLineChars; | 244 CFX_TxtCharArray& ca = *m_pCurLine->m_pLineChars; |
248 int32_t iCount = ca.GetSize(); | 245 int32_t iCount = ca.GetSize(); |
249 if (index < 0 || index >= iCount) { | 246 if (index < 0 || index >= iCount) { |
250 return NULL; | 247 return nullptr; |
251 } | 248 } |
252 CFX_TxtChar* pTC; | 249 CFX_TxtChar* pTC; |
253 int32_t iStart = iCount - 1; | 250 int32_t iStart = iCount - 1; |
254 while (iStart > -1) { | 251 while (iStart > -1) { |
255 pTC = ca.GetDataPtr(iStart--); | 252 pTC = ca.GetDataPtr(iStart--); |
256 if (bOmitChar && pTC->GetCharType() == FX_CHARTYPE_Combination) { | 253 if (bOmitChar && pTC->GetCharType() == FX_CHARTYPE_Combination) { |
257 continue; | 254 continue; |
258 } | 255 } |
259 if (--index < 0) { | 256 if (--index < 0) { |
260 return pTC; | 257 return pTC; |
261 } | 258 } |
262 } | 259 } |
263 return NULL; | 260 return nullptr; |
264 } | 261 } |
265 CFX_TxtLine* CFX_TxtBreak::GetTxtLine(FX_BOOL bReady) const { | 262 CFX_TxtLine* CFX_TxtBreak::GetTxtLine(FX_BOOL bReady) const { |
266 if (!bReady) { | 263 if (!bReady) { |
267 return m_pCurLine; | 264 return m_pCurLine; |
268 } | 265 } |
269 if (m_iReady == 1) { | 266 if (m_iReady == 1) { |
270 return m_pTxtLine1; | 267 return m_pTxtLine1; |
271 } else if (m_iReady == 2) { | 268 } else if (m_iReady == 2) { |
272 return m_pTxtLine2; | 269 return m_pTxtLine2; |
273 } else { | 270 } else { |
274 return NULL; | 271 return nullptr; |
275 } | 272 } |
276 } | 273 } |
277 CFX_TxtPieceArray* CFX_TxtBreak::GetTxtPieces(FX_BOOL bReady) const { | 274 CFX_TxtPieceArray* CFX_TxtBreak::GetTxtPieces(FX_BOOL bReady) const { |
278 CFX_TxtLine* pTxtLine = GetTxtLine(bReady); | 275 CFX_TxtLine* pTxtLine = GetTxtLine(bReady); |
279 if (pTxtLine == NULL) { | 276 return pTxtLine ? pTxtLine->m_pLinePieces : nullptr; |
280 return NULL; | |
281 } | |
282 return pTxtLine->m_pLinePieces; | |
283 } | 277 } |
284 inline FX_CHARTYPE CFX_TxtBreak::GetUnifiedCharType( | 278 inline FX_CHARTYPE CFX_TxtBreak::GetUnifiedCharType( |
285 FX_CHARTYPE chartype) const { | 279 FX_CHARTYPE chartype) const { |
286 return chartype >= FX_CHARTYPE_ArabicAlef ? FX_CHARTYPE_Arabic : chartype; | 280 return chartype >= FX_CHARTYPE_ArabicAlef ? FX_CHARTYPE_Arabic : chartype; |
287 } | 281 } |
288 void CFX_TxtBreak::ResetArabicContext() { | 282 void CFX_TxtBreak::ResetArabicContext() { |
289 if (m_bArabicContext) { | 283 if (m_bArabicContext) { |
290 m_bCurRTL = m_iCurArabicContext > 1; | 284 m_bCurRTL = m_iCurArabicContext > 1; |
291 m_iCurAlignment = m_iCurArabicContext > 1 ? FX_TXTLINEALIGNMENT_Right | 285 m_iCurAlignment = m_iCurArabicContext > 1 ? FX_TXTLINEALIGNMENT_Right |
292 : FX_TXTLINEALIGNMENT_Left; | 286 : FX_TXTLINEALIGNMENT_Left; |
(...skipping 30 matching lines...) Expand all Loading... |
323 : ((iBidiCls == FX_BIDICLASS_L || iBidiCls == FX_BIDICLASS_S) ? 0 | 317 : ((iBidiCls == FX_BIDICLASS_L || iBidiCls == FX_BIDICLASS_S) ? 0 |
324 : 1); | 318 : 1); |
325 if (iArabicContext != m_iArabicContext && iArabicContext != 1) { | 319 if (iArabicContext != m_iArabicContext && iArabicContext != 1) { |
326 m_iArabicContext = iArabicContext; | 320 m_iArabicContext = iArabicContext; |
327 if (m_iCurArabicContext == 1) { | 321 if (m_iCurArabicContext == 1) { |
328 m_iCurArabicContext = iArabicContext; | 322 m_iCurArabicContext = iArabicContext; |
329 } | 323 } |
330 ResetArabicContext(); | 324 ResetArabicContext(); |
331 if (!m_bPagination) { | 325 if (!m_bPagination) { |
332 CFX_TxtChar* pLastChar = (CFX_TxtChar*)GetLastChar(1, FALSE); | 326 CFX_TxtChar* pLastChar = (CFX_TxtChar*)GetLastChar(1, FALSE); |
333 if (pLastChar != NULL && pLastChar->m_dwStatus < 1) { | 327 if (pLastChar && pLastChar->m_dwStatus < 1) { |
334 pLastChar->m_dwStatus = FX_TXTBREAK_PieceBreak; | 328 pLastChar->m_dwStatus = FX_TXTBREAK_PieceBreak; |
335 } | 329 } |
336 } | 330 } |
337 } | 331 } |
338 } | 332 } |
339 pCurChar->m_dwCharStyles = m_dwContextCharStyles; | 333 pCurChar->m_dwCharStyles = m_dwContextCharStyles; |
340 } | 334 } |
341 uint32_t CFX_TxtBreak::AppendChar_Combination(CFX_Char* pCurChar, | 335 uint32_t CFX_TxtBreak::AppendChar_Combination(CFX_Char* pCurChar, |
342 int32_t iRotation) { | 336 int32_t iRotation) { |
343 ASSERT(pCurChar != NULL); | |
344 FX_WCHAR wch = pCurChar->m_wCharCode; | 337 FX_WCHAR wch = pCurChar->m_wCharCode; |
345 FX_WCHAR wForm; | 338 FX_WCHAR wForm; |
346 int32_t iCharWidth = 0; | 339 int32_t iCharWidth = 0; |
347 CFX_Char* pLastChar; | 340 CFX_Char* pLastChar; |
348 pCurChar->m_iCharWidth = -1; | 341 pCurChar->m_iCharWidth = -1; |
349 if (m_bCombText) { | 342 if (m_bCombText) { |
350 iCharWidth = m_iCombWidth; | 343 iCharWidth = m_iCombWidth; |
351 } else { | 344 } else { |
352 if (m_bVertical != FX_IsOdd(iRotation)) { | 345 if (m_bVertical != FX_IsOdd(iRotation)) { |
353 iCharWidth = 1000; | 346 iCharWidth = 1000; |
354 } else { | 347 } else { |
355 wForm = wch; | 348 wForm = wch; |
356 if (!m_bPagination) { | 349 if (!m_bPagination) { |
357 pLastChar = GetLastChar(0, FALSE); | 350 pLastChar = GetLastChar(0, FALSE); |
358 if (pLastChar != NULL && | 351 if (pLastChar && |
359 (((CFX_TxtChar*)pLastChar)->m_dwCharStyles & | 352 (((CFX_TxtChar*)pLastChar)->m_dwCharStyles & |
360 FX_TXTCHARSTYLE_ArabicShadda) == 0) { | 353 FX_TXTCHARSTYLE_ArabicShadda) == 0) { |
361 FX_BOOL bShadda = FALSE; | 354 FX_BOOL bShadda = FALSE; |
362 if (wch == 0x0651) { | 355 if (wch == 0x0651) { |
363 FX_WCHAR wLast = pLastChar->m_wCharCode; | 356 FX_WCHAR wLast = pLastChar->m_wCharCode; |
364 if (wLast >= 0x064C && wLast <= 0x0650) { | 357 if (wLast >= 0x064C && wLast <= 0x0650) { |
365 wForm = FX_GetArabicFromShaddaTable(wLast); | 358 wForm = FX_GetArabicFromShaddaTable(wLast); |
366 bShadda = TRUE; | 359 bShadda = TRUE; |
367 } | 360 } |
368 } else if (wch >= 0x064C && wch <= 0x0650) { | 361 } else if (wch >= 0x064C && wch <= 0x0650) { |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 } | 438 } |
446 } | 439 } |
447 return dwRet; | 440 return dwRet; |
448 } | 441 } |
449 uint32_t CFX_TxtBreak::AppendChar_Arabic(CFX_Char* pCurChar, | 442 uint32_t CFX_TxtBreak::AppendChar_Arabic(CFX_Char* pCurChar, |
450 int32_t iRotation) { | 443 int32_t iRotation) { |
451 FX_CHARTYPE chartype = pCurChar->GetCharType(); | 444 FX_CHARTYPE chartype = pCurChar->GetCharType(); |
452 int32_t& iLineWidth = m_pCurLine->m_iWidth; | 445 int32_t& iLineWidth = m_pCurLine->m_iWidth; |
453 FX_WCHAR wForm; | 446 FX_WCHAR wForm; |
454 int32_t iCharWidth = 0; | 447 int32_t iCharWidth = 0; |
455 CFX_Char* pLastChar = NULL; | 448 CFX_Char* pLastChar = nullptr; |
456 FX_BOOL bAlef = FALSE; | 449 FX_BOOL bAlef = FALSE; |
457 if (!m_bCombText && m_eCharType >= FX_CHARTYPE_ArabicAlef && | 450 if (!m_bCombText && m_eCharType >= FX_CHARTYPE_ArabicAlef && |
458 m_eCharType <= FX_CHARTYPE_ArabicDistortion) { | 451 m_eCharType <= FX_CHARTYPE_ArabicDistortion) { |
459 pLastChar = GetLastChar(1); | 452 pLastChar = GetLastChar(1); |
460 if (pLastChar != NULL) { | 453 if (pLastChar) { |
461 iCharWidth = pLastChar->m_iCharWidth; | 454 iCharWidth = pLastChar->m_iCharWidth; |
462 if (iCharWidth > 0) { | 455 if (iCharWidth > 0) { |
463 iLineWidth -= iCharWidth; | 456 iLineWidth -= iCharWidth; |
464 } | 457 } |
465 CFX_Char* pPrevChar = GetLastChar(2); | 458 CFX_Char* pPrevChar = GetLastChar(2); |
466 wForm = pdfium::arabic::GetFormChar(pLastChar, pPrevChar, pCurChar); | 459 wForm = pdfium::arabic::GetFormChar(pLastChar, pPrevChar, pCurChar); |
467 bAlef = (wForm == 0xFEFF && | 460 bAlef = (wForm == 0xFEFF && |
468 pLastChar->GetCharType() == FX_CHARTYPE_ArabicAlef); | 461 pLastChar->GetCharType() == FX_CHARTYPE_ArabicAlef); |
469 int32_t iLastRotation = pLastChar->m_nRotation + m_iLineRotation; | 462 int32_t iLastRotation = pLastChar->m_nRotation + m_iLineRotation; |
470 if (m_bVertical && (pLastChar->m_dwCharProps & 0x8000) != 0) { | 463 if (m_bVertical && (pLastChar->m_dwCharProps & 0x8000) != 0) { |
471 iLastRotation++; | 464 iLastRotation++; |
472 } | 465 } |
473 if (m_bVertical != FX_IsOdd(iLastRotation)) { | 466 if (m_bVertical != FX_IsOdd(iLastRotation)) { |
474 iCharWidth = 1000; | 467 iCharWidth = 1000; |
475 } else { | 468 } else { |
476 m_pFont->GetCharWidth(wForm, iCharWidth, FALSE); | 469 m_pFont->GetCharWidth(wForm, iCharWidth, FALSE); |
477 } | 470 } |
478 if (wForm == 0xFEFF) { | 471 if (wForm == 0xFEFF) { |
479 iCharWidth = m_iDefChar; | 472 iCharWidth = m_iDefChar; |
480 } | 473 } |
481 iCharWidth *= m_iFontSize; | 474 iCharWidth *= m_iFontSize; |
482 iCharWidth = iCharWidth * m_iHorScale / 100; | 475 iCharWidth = iCharWidth * m_iHorScale / 100; |
483 pLastChar->m_iCharWidth = iCharWidth; | 476 pLastChar->m_iCharWidth = iCharWidth; |
484 iLineWidth += iCharWidth; | 477 iLineWidth += iCharWidth; |
485 iCharWidth = 0; | 478 iCharWidth = 0; |
486 } | 479 } |
487 } | 480 } |
488 m_eCharType = chartype; | 481 m_eCharType = chartype; |
489 wForm = pdfium::arabic::GetFormChar(pCurChar, bAlef ? NULL : pLastChar, NULL); | 482 wForm = pdfium::arabic::GetFormChar(pCurChar, bAlef ? nullptr : pLastChar, |
| 483 nullptr); |
490 if (m_bCombText) { | 484 if (m_bCombText) { |
491 iCharWidth = m_iCombWidth; | 485 iCharWidth = m_iCombWidth; |
492 } else { | 486 } else { |
493 if (m_bVertical != FX_IsOdd(iRotation)) { | 487 if (m_bVertical != FX_IsOdd(iRotation)) { |
494 iCharWidth = 1000; | 488 iCharWidth = 1000; |
495 } else { | 489 } else { |
496 m_pFont->GetCharWidth(wForm, iCharWidth, FALSE); | 490 m_pFont->GetCharWidth(wForm, iCharWidth, FALSE); |
497 } | 491 } |
498 if (wForm == 0xFEFF) { | 492 if (wForm == 0xFEFF) { |
499 iCharWidth = m_iDefChar; | 493 iCharWidth = m_iDefChar; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
573 pCurChar->m_dwCharProps = dwProps; | 567 pCurChar->m_dwCharProps = dwProps; |
574 pCurChar->m_dwCharStyles = 0; | 568 pCurChar->m_dwCharStyles = 0; |
575 pCurChar->m_iCharWidth = 0; | 569 pCurChar->m_iCharWidth = 0; |
576 pCurChar->m_iHorizontalScale = m_iHorScale; | 570 pCurChar->m_iHorizontalScale = m_iHorScale; |
577 pCurChar->m_iVertialScale = m_iVerScale; | 571 pCurChar->m_iVertialScale = m_iVerScale; |
578 pCurChar->m_dwStatus = 0; | 572 pCurChar->m_dwStatus = 0; |
579 pCurChar->m_iBidiClass = 0; | 573 pCurChar->m_iBidiClass = 0; |
580 pCurChar->m_iBidiLevel = 0; | 574 pCurChar->m_iBidiLevel = 0; |
581 pCurChar->m_iBidiPos = 0; | 575 pCurChar->m_iBidiPos = 0; |
582 pCurChar->m_iBidiOrder = 0; | 576 pCurChar->m_iBidiOrder = 0; |
583 pCurChar->m_pUserData = NULL; | 577 pCurChar->m_pUserData = nullptr; |
584 AppendChar_PageLoad(pCurChar, dwProps); | 578 AppendChar_PageLoad(pCurChar, dwProps); |
585 uint32_t dwRet1 = FX_TXTBREAK_None; | 579 uint32_t dwRet1 = FX_TXTBREAK_None; |
586 if (chartype != FX_CHARTYPE_Combination && | 580 if (chartype != FX_CHARTYPE_Combination && |
587 GetUnifiedCharType(m_eCharType) != GetUnifiedCharType(chartype)) { | 581 GetUnifiedCharType(m_eCharType) != GetUnifiedCharType(chartype)) { |
588 if (m_eCharType != FX_CHARTYPE_Unknown && | 582 if (m_eCharType != FX_CHARTYPE_Unknown && |
589 m_pCurLine->m_iWidth > m_iLineWidth + m_iTolerance && !m_bSingleLine) { | 583 m_pCurLine->m_iWidth > m_iLineWidth + m_iTolerance && !m_bSingleLine) { |
590 if (m_eCharType != FX_CHARTYPE_Space || chartype != FX_CHARTYPE_Control) { | 584 if (m_eCharType != FX_CHARTYPE_Space || chartype != FX_CHARTYPE_Control) { |
591 dwRet1 = EndBreak(FX_TXTBREAK_LineBreak); | 585 dwRet1 = EndBreak(FX_TXTBREAK_LineBreak); |
592 int32_t iCount = m_pCurLine->CountChars(); | 586 int32_t iCount = m_pCurLine->CountChars(); |
593 if (iCount > 0) { | 587 if (iCount > 0) { |
(...skipping 24 matching lines...) Expand all Loading... |
618 pCur = m_pCurLine->GetCharPtr(1); | 612 pCur = m_pCurLine->GetCharPtr(1); |
619 FX_WCHAR wch, wForm; | 613 FX_WCHAR wch, wForm; |
620 FX_BOOL bNextNum; | 614 FX_BOOL bNextNum; |
621 int32_t i = 1, iCharWidth, iRotation; | 615 int32_t i = 1, iCharWidth, iRotation; |
622 do { | 616 do { |
623 i++; | 617 i++; |
624 if (i < iCount) { | 618 if (i < iCount) { |
625 pNext = m_pCurLine->GetCharPtr(i); | 619 pNext = m_pCurLine->GetCharPtr(i); |
626 bNextNum = (pNext->m_dwCharStyles & FX_TXTCHARSTYLE_ArabicIndic) != 0; | 620 bNextNum = (pNext->m_dwCharStyles & FX_TXTCHARSTYLE_ArabicIndic) != 0; |
627 } else { | 621 } else { |
628 pNext = NULL; | 622 pNext = nullptr; |
629 bNextNum = FALSE; | 623 bNextNum = FALSE; |
630 } | 624 } |
631 wch = pCur->m_wCharCode; | 625 wch = pCur->m_wCharCode; |
632 if (wch == L'.') { | 626 if (wch == L'.') { |
633 if (bPrevNum && bNextNum) { | 627 if (bPrevNum && bNextNum) { |
634 iRotation = m_iRotation; | 628 iRotation = m_iRotation; |
635 if (m_bVertical && (pCur->m_dwCharProps & 0x8000) != 0) { | 629 if (m_bVertical && (pCur->m_dwCharProps & 0x8000) != 0) { |
636 iRotation = ((iRotation + 1) & 0x03); | 630 iRotation = ((iRotation + 1) & 0x03); |
637 } | 631 } |
638 wForm = wch == L'.' ? 0x066B : 0x066C; | 632 wForm = wch == L'.' ? 0x066B : 0x066C; |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
911 if (iCount > 0) { | 905 if (iCount > 0) { |
912 CFX_TxtPiece* pLastPiece = pCurPieces->GetPtrAt(--iCount); | 906 CFX_TxtPiece* pLastPiece = pCurPieces->GetPtrAt(--iCount); |
913 if (dwStatus > FX_TXTBREAK_PieceBreak) { | 907 if (dwStatus > FX_TXTBREAK_PieceBreak) { |
914 pLastPiece->m_dwStatus = dwStatus; | 908 pLastPiece->m_dwStatus = dwStatus; |
915 } else { | 909 } else { |
916 dwStatus = pLastPiece->m_dwStatus; | 910 dwStatus = pLastPiece->m_dwStatus; |
917 } | 911 } |
918 return dwStatus; | 912 return dwStatus; |
919 } else { | 913 } else { |
920 CFX_TxtLine* pLastLine = GetTxtLine(TRUE); | 914 CFX_TxtLine* pLastLine = GetTxtLine(TRUE); |
921 if (pLastLine != NULL) { | 915 if (pLastLine) { |
922 pCurPieces = pLastLine->m_pLinePieces; | 916 pCurPieces = pLastLine->m_pLinePieces; |
923 iCount = pCurPieces->GetSize(); | 917 iCount = pCurPieces->GetSize(); |
924 if (iCount-- > 0) { | 918 if (iCount-- > 0) { |
925 CFX_TxtPiece* pLastPiece = pCurPieces->GetPtrAt(iCount); | 919 CFX_TxtPiece* pLastPiece = pCurPieces->GetPtrAt(iCount); |
926 if (dwStatus > FX_TXTBREAK_PieceBreak) { | 920 if (dwStatus > FX_TXTBREAK_PieceBreak) { |
927 pLastPiece->m_dwStatus = dwStatus; | 921 pLastPiece->m_dwStatus = dwStatus; |
928 } else { | 922 } else { |
929 dwStatus = pLastPiece->m_dwStatus; | 923 dwStatus = pLastPiece->m_dwStatus; |
930 } | 924 } |
931 return dwStatus; | 925 return dwStatus; |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1064 } | 1058 } |
1065 if (iLast > -1) { | 1059 if (iLast > -1) { |
1066 iEndPos = iLastPos; | 1060 iEndPos = iLastPos; |
1067 return iLast; | 1061 return iLast; |
1068 } | 1062 } |
1069 return 0; | 1063 return 0; |
1070 } | 1064 } |
1071 void CFX_TxtBreak::SplitTextLine(CFX_TxtLine* pCurLine, | 1065 void CFX_TxtBreak::SplitTextLine(CFX_TxtLine* pCurLine, |
1072 CFX_TxtLine* pNextLine, | 1066 CFX_TxtLine* pNextLine, |
1073 FX_BOOL bAllChars) { | 1067 FX_BOOL bAllChars) { |
1074 ASSERT(pCurLine != NULL && pNextLine != NULL); | |
1075 int32_t iCount = pCurLine->CountChars(); | 1068 int32_t iCount = pCurLine->CountChars(); |
1076 if (iCount < 2) { | 1069 if (iCount < 2) { |
1077 return; | 1070 return; |
1078 } | 1071 } |
1079 int32_t iEndPos = pCurLine->m_iWidth; | 1072 int32_t iEndPos = pCurLine->m_iWidth; |
1080 CFX_TxtCharArray& curChars = *pCurLine->m_pLineChars; | 1073 CFX_TxtCharArray& curChars = *pCurLine->m_pLineChars; |
1081 int32_t iCharPos = GetBreakPos(curChars, iEndPos, bAllChars, FALSE); | 1074 int32_t iCharPos = GetBreakPos(curChars, iEndPos, bAllChars, FALSE); |
1082 if (iCharPos < 0) { | 1075 if (iCharPos < 0) { |
1083 iCharPos = 0; | 1076 iCharPos = 0; |
1084 } | 1077 } |
(...skipping 29 matching lines...) Expand all Loading... |
1114 } | 1107 } |
1115 if (m_bPagination) { | 1108 if (m_bPagination) { |
1116 continue; | 1109 continue; |
1117 } | 1110 } |
1118 pTC->m_dwStatus = 0; | 1111 pTC->m_dwStatus = 0; |
1119 } | 1112 } |
1120 pNextLine->m_iWidth = iWidth; | 1113 pNextLine->m_iWidth = iWidth; |
1121 } | 1114 } |
1122 int32_t CFX_TxtBreak::CountBreakChars() const { | 1115 int32_t CFX_TxtBreak::CountBreakChars() const { |
1123 CFX_TxtLine* pTxtLine = GetTxtLine(TRUE); | 1116 CFX_TxtLine* pTxtLine = GetTxtLine(TRUE); |
1124 return pTxtLine == NULL ? 0 : pTxtLine->CountChars(); | 1117 return pTxtLine ? pTxtLine->CountChars() : 0; |
1125 } | 1118 } |
1126 int32_t CFX_TxtBreak::CountBreakPieces() const { | 1119 int32_t CFX_TxtBreak::CountBreakPieces() const { |
1127 CFX_TxtPieceArray* pTxtPieces = GetTxtPieces(TRUE); | 1120 CFX_TxtPieceArray* pTxtPieces = GetTxtPieces(TRUE); |
1128 if (pTxtPieces == NULL) { | 1121 return pTxtPieces ? pTxtPieces->GetSize() : 0; |
1129 return 0; | |
1130 } | |
1131 return pTxtPieces->GetSize(); | |
1132 } | 1122 } |
1133 const CFX_TxtPiece* CFX_TxtBreak::GetBreakPiece(int32_t index) const { | 1123 const CFX_TxtPiece* CFX_TxtBreak::GetBreakPiece(int32_t index) const { |
1134 CFX_TxtPieceArray* pTxtPieces = GetTxtPieces(TRUE); | 1124 CFX_TxtPieceArray* pTxtPieces = GetTxtPieces(TRUE); |
1135 if (pTxtPieces == NULL) { | 1125 if (!pTxtPieces) |
1136 return NULL; | 1126 return nullptr; |
1137 } | 1127 if (index < 0 || index >= pTxtPieces->GetSize()) |
1138 if (index < 0 || index >= pTxtPieces->GetSize()) { | 1128 return nullptr; |
1139 return NULL; | |
1140 } | |
1141 return pTxtPieces->GetPtrAt(index); | 1129 return pTxtPieces->GetPtrAt(index); |
1142 } | 1130 } |
1143 void CFX_TxtBreak::ClearBreakPieces() { | 1131 void CFX_TxtBreak::ClearBreakPieces() { |
1144 CFX_TxtLine* pTxtLine = GetTxtLine(TRUE); | 1132 CFX_TxtLine* pTxtLine = GetTxtLine(TRUE); |
1145 if (pTxtLine != NULL) { | 1133 if (pTxtLine) |
1146 pTxtLine->RemoveAll(TRUE); | 1134 pTxtLine->RemoveAll(TRUE); |
1147 } | |
1148 m_iReady = 0; | 1135 m_iReady = 0; |
1149 } | 1136 } |
1150 void CFX_TxtBreak::Reset() { | 1137 void CFX_TxtBreak::Reset() { |
1151 m_eCharType = FX_CHARTYPE_Unknown; | 1138 m_eCharType = FX_CHARTYPE_Unknown; |
1152 m_iArabicContext = m_iCurArabicContext = 1; | 1139 m_iArabicContext = m_iCurArabicContext = 1; |
1153 ResetArabicContext(); | 1140 ResetArabicContext(); |
1154 m_pTxtLine1->RemoveAll(TRUE); | 1141 m_pTxtLine1->RemoveAll(TRUE); |
1155 m_pTxtLine2->RemoveAll(TRUE); | 1142 m_pTxtLine2->RemoveAll(TRUE); |
1156 } | 1143 } |
1157 | 1144 |
1158 struct FX_FORMCHAR { | 1145 struct FX_FORMCHAR { |
1159 uint16_t wch; | 1146 uint16_t wch; |
1160 uint16_t wForm; | 1147 uint16_t wForm; |
1161 int32_t iWidth; | 1148 int32_t iWidth; |
1162 }; | 1149 }; |
1163 | 1150 |
1164 int32_t CFX_TxtBreak::GetDisplayPos(const FX_TXTRUN* pTxtRun, | 1151 int32_t CFX_TxtBreak::GetDisplayPos(const FX_TXTRUN* pTxtRun, |
1165 FXTEXT_CHARPOS* pCharPos, | 1152 FXTEXT_CHARPOS* pCharPos, |
1166 FX_BOOL bCharCode, | 1153 FX_BOOL bCharCode, |
1167 CFX_WideString* pWSForms, | 1154 CFX_WideString* pWSForms, |
1168 FX_AdjustCharDisplayPos pAdjustPos) const { | 1155 FX_AdjustCharDisplayPos pAdjustPos) const { |
1169 if (pTxtRun == NULL || pTxtRun->iLength < 1) { | 1156 if (!pTxtRun || pTxtRun->iLength < 1) |
1170 return 0; | 1157 return 0; |
1171 } | 1158 |
1172 IFX_TxtAccess* pAccess = pTxtRun->pAccess; | 1159 IFX_TxtAccess* pAccess = pTxtRun->pAccess; |
1173 void* pIdentity = pTxtRun->pIdentity; | 1160 void* pIdentity = pTxtRun->pIdentity; |
1174 const FX_WCHAR* pStr = pTxtRun->wsStr.c_str(); | 1161 const FX_WCHAR* pStr = pTxtRun->wsStr.c_str(); |
1175 int32_t* pWidths = pTxtRun->pWidths; | 1162 int32_t* pWidths = pTxtRun->pWidths; |
1176 int32_t iLength = pTxtRun->iLength - 1; | 1163 int32_t iLength = pTxtRun->iLength - 1; |
1177 IFGAS_Font* pFont = pTxtRun->pFont; | 1164 IFGAS_Font* pFont = pTxtRun->pFont; |
1178 uint32_t dwStyles = pTxtRun->dwStyles; | 1165 uint32_t dwStyles = pTxtRun->dwStyles; |
1179 CFX_RectF rtText(*pTxtRun->pRect); | 1166 CFX_RectF rtText(*pTxtRun->pRect); |
1180 FX_BOOL bRTLPiece = | 1167 FX_BOOL bRTLPiece = |
1181 (pTxtRun->dwCharStyles & FX_TXTCHARSTYLE_OddBidiLevel) != 0; | 1168 (pTxtRun->dwCharStyles & FX_TXTCHARSTYLE_OddBidiLevel) != 0; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1216 int32_t iNext = 0; | 1203 int32_t iNext = 0; |
1217 FX_WCHAR wPrev = 0xFEFF; | 1204 FX_WCHAR wPrev = 0xFEFF; |
1218 FX_WCHAR wNext = 0xFEFF; | 1205 FX_WCHAR wNext = 0xFEFF; |
1219 FX_WCHAR wForm = 0xFEFF; | 1206 FX_WCHAR wForm = 0xFEFF; |
1220 FX_WCHAR wLast = 0xFEFF; | 1207 FX_WCHAR wLast = 0xFEFF; |
1221 FX_BOOL bShadda = FALSE; | 1208 FX_BOOL bShadda = FALSE; |
1222 FX_BOOL bLam = FALSE; | 1209 FX_BOOL bLam = FALSE; |
1223 for (int32_t i = 0; i <= iLength; i++) { | 1210 for (int32_t i = 0; i <= iLength; i++) { |
1224 int32_t iWidth; | 1211 int32_t iWidth; |
1225 FX_WCHAR wch; | 1212 FX_WCHAR wch; |
1226 if (pAccess != NULL) { | 1213 if (pAccess) { |
1227 wch = pAccess->GetChar(pIdentity, i); | 1214 wch = pAccess->GetChar(pIdentity, i); |
1228 iWidth = pAccess->GetWidth(pIdentity, i); | 1215 iWidth = pAccess->GetWidth(pIdentity, i); |
1229 } else { | 1216 } else { |
1230 wch = *pStr++; | 1217 wch = *pStr++; |
1231 iWidth = *pWidths++; | 1218 iWidth = *pWidths++; |
1232 } | 1219 } |
1233 uint32_t dwProps = FX_GetUnicodeProperties(wch); | 1220 uint32_t dwProps = FX_GetUnicodeProperties(wch); |
1234 FX_CHARTYPE chartype = GetCharTypeFromProp(dwProps); | 1221 FX_CHARTYPE chartype = GetCharTypeFromProp(dwProps); |
1235 if (chartype == FX_CHARTYPE_ArabicAlef && iWidth == 0) { | 1222 if (chartype == FX_CHARTYPE_ArabicAlef && iWidth == 0) { |
1236 wPrev = 0xFEFF; | 1223 wPrev = 0xFEFF; |
1237 wLast = wch; | 1224 wLast = wch; |
1238 continue; | 1225 continue; |
1239 } | 1226 } |
1240 if (chartype >= FX_CHARTYPE_ArabicAlef) { | 1227 if (chartype >= FX_CHARTYPE_ArabicAlef) { |
1241 if (i < iLength) { | 1228 if (i < iLength) { |
1242 if (pAccess != NULL) { | 1229 if (pAccess) { |
1243 iNext = i + 1; | 1230 iNext = i + 1; |
1244 while (iNext <= iLength) { | 1231 while (iNext <= iLength) { |
1245 wNext = pAccess->GetChar(pIdentity, iNext); | 1232 wNext = pAccess->GetChar(pIdentity, iNext); |
1246 dwProps = FX_GetUnicodeProperties(wNext); | 1233 dwProps = FX_GetUnicodeProperties(wNext); |
1247 if ((dwProps & FX_CHARTYPEBITSMASK) != FX_CHARTYPE_Combination) { | 1234 if ((dwProps & FX_CHARTYPEBITSMASK) != FX_CHARTYPE_Combination) { |
1248 break; | 1235 break; |
1249 } | 1236 } |
1250 iNext++; | 1237 iNext++; |
1251 } | 1238 } |
1252 if (iNext > iLength) { | 1239 if (iNext > iLength) { |
(...skipping 19 matching lines...) Expand all Loading... |
1272 wForm = pdfium::arabic::GetFormChar(wch, wPrev, wNext); | 1259 wForm = pdfium::arabic::GetFormChar(wch, wPrev, wNext); |
1273 bLam = (wPrev == 0x0644 && wch == 0x0644 && wNext == 0x0647); | 1260 bLam = (wPrev == 0x0644 && wch == 0x0644 && wNext == 0x0647); |
1274 } else if (chartype == FX_CHARTYPE_Combination) { | 1261 } else if (chartype == FX_CHARTYPE_Combination) { |
1275 wForm = wch; | 1262 wForm = wch; |
1276 if (wch >= 0x064C && wch <= 0x0651) { | 1263 if (wch >= 0x064C && wch <= 0x0651) { |
1277 if (bShadda) { | 1264 if (bShadda) { |
1278 wForm = 0xFEFF; | 1265 wForm = 0xFEFF; |
1279 bShadda = FALSE; | 1266 bShadda = FALSE; |
1280 } else { | 1267 } else { |
1281 wNext = 0xFEFF; | 1268 wNext = 0xFEFF; |
1282 if (pAccess != NULL) { | 1269 if (pAccess) { |
1283 iNext = i + 1; | 1270 iNext = i + 1; |
1284 if (iNext <= iLength) { | 1271 if (iNext <= iLength) { |
1285 wNext = pAccess->GetChar(pIdentity, iNext); | 1272 wNext = pAccess->GetChar(pIdentity, iNext); |
1286 } | 1273 } |
1287 } else { | 1274 } else { |
1288 if (i < iLength) { | 1275 if (i < iLength) { |
1289 wNext = *pStr; | 1276 wNext = *pStr; |
1290 } | 1277 } |
1291 } | 1278 } |
1292 if (wch == 0x0651) { | 1279 if (wch == 0x0651) { |
(...skipping 13 matching lines...) Expand all Loading... |
1306 } | 1293 } |
1307 } else if (chartype == FX_CHARTYPE_Numeric) { | 1294 } else if (chartype == FX_CHARTYPE_Numeric) { |
1308 wForm = wch; | 1295 wForm = wch; |
1309 if (bArabicNumber) { | 1296 if (bArabicNumber) { |
1310 wForm += 0x0630; | 1297 wForm += 0x0630; |
1311 } | 1298 } |
1312 } else if (wch == L'.') { | 1299 } else if (wch == L'.') { |
1313 wForm = wch; | 1300 wForm = wch; |
1314 if (bArabicNumber) { | 1301 if (bArabicNumber) { |
1315 wNext = 0xFEFF; | 1302 wNext = 0xFEFF; |
1316 if (pAccess != NULL) { | 1303 if (pAccess) { |
1317 iNext = i + 1; | 1304 iNext = i + 1; |
1318 if (iNext <= iLength) { | 1305 if (iNext <= iLength) { |
1319 wNext = pAccess->GetChar(pIdentity, iNext); | 1306 wNext = pAccess->GetChar(pIdentity, iNext); |
1320 } | 1307 } |
1321 } else { | 1308 } else { |
1322 if (i < iLength) { | 1309 if (i < iLength) { |
1323 wNext = *pStr; | 1310 wNext = *pStr; |
1324 } | 1311 } |
1325 } | 1312 } |
1326 if (wNext >= L'0' && wNext <= L'9') { | 1313 if (wNext >= L'0' && wNext <= L'9') { |
(...skipping 22 matching lines...) Expand all Loading... |
1349 iCharRotation++; | 1336 iCharRotation++; |
1350 } | 1337 } |
1351 iCharRotation %= 4; | 1338 iCharRotation %= 4; |
1352 FX_BOOL bEmptyChar = | 1339 FX_BOOL bEmptyChar = |
1353 (chartype >= FX_CHARTYPE_Tab && chartype <= FX_CHARTYPE_Control); | 1340 (chartype >= FX_CHARTYPE_Tab && chartype <= FX_CHARTYPE_Control); |
1354 if (wForm == 0xFEFF) { | 1341 if (wForm == 0xFEFF) { |
1355 bEmptyChar = TRUE; | 1342 bEmptyChar = TRUE; |
1356 } | 1343 } |
1357 int32_t iForms = bLam ? 3 : 1; | 1344 int32_t iForms = bLam ? 3 : 1; |
1358 iCount += (bEmptyChar && bSkipSpace) ? 0 : iForms; | 1345 iCount += (bEmptyChar && bSkipSpace) ? 0 : iForms; |
1359 if (pCharPos == NULL) { | 1346 if (!pCharPos) { |
1360 if (iWidth > 0) { | 1347 if (iWidth > 0) { |
1361 wPrev = wch; | 1348 wPrev = wch; |
1362 } | 1349 } |
1363 wLast = wch; | 1350 wLast = wch; |
1364 continue; | 1351 continue; |
1365 } | 1352 } |
1366 int32_t iCharWidth = iWidth; | 1353 int32_t iCharWidth = iWidth; |
1367 if (iCharWidth < 0) { | 1354 if (iCharWidth < 0) { |
1368 iCharWidth = -iCharWidth; | 1355 iCharWidth = -iCharWidth; |
1369 } | 1356 } |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1544 if (iWidth > 0) { | 1531 if (iWidth > 0) { |
1545 wPrev = (FX_WCHAR)formChars[0].wch; | 1532 wPrev = (FX_WCHAR)formChars[0].wch; |
1546 } | 1533 } |
1547 wLast = wch; | 1534 wLast = wch; |
1548 } | 1535 } |
1549 return iCount; | 1536 return iCount; |
1550 } | 1537 } |
1551 int32_t CFX_TxtBreak::GetCharRects(const FX_TXTRUN* pTxtRun, | 1538 int32_t CFX_TxtBreak::GetCharRects(const FX_TXTRUN* pTxtRun, |
1552 CFX_RectFArray& rtArray, | 1539 CFX_RectFArray& rtArray, |
1553 FX_BOOL bCharBBox) const { | 1540 FX_BOOL bCharBBox) const { |
1554 if (pTxtRun == NULL || pTxtRun->iLength < 1) { | 1541 if (!pTxtRun || pTxtRun->iLength < 1) |
1555 return 0; | 1542 return 0; |
1556 } | 1543 |
1557 IFX_TxtAccess* pAccess = pTxtRun->pAccess; | 1544 IFX_TxtAccess* pAccess = pTxtRun->pAccess; |
1558 void* pIdentity = pTxtRun->pIdentity; | 1545 void* pIdentity = pTxtRun->pIdentity; |
1559 const FX_WCHAR* pStr = pTxtRun->wsStr.c_str(); | 1546 const FX_WCHAR* pStr = pTxtRun->wsStr.c_str(); |
1560 int32_t* pWidths = pTxtRun->pWidths; | 1547 int32_t* pWidths = pTxtRun->pWidths; |
1561 int32_t iLength = pTxtRun->iLength; | 1548 int32_t iLength = pTxtRun->iLength; |
1562 CFX_RectF rect(*pTxtRun->pRect); | 1549 CFX_RectF rect(*pTxtRun->pRect); |
1563 FX_BOOL bRTLPiece = | 1550 FX_BOOL bRTLPiece = |
1564 (pTxtRun->dwCharStyles & FX_TXTCHARSTYLE_OddBidiLevel) != 0; | 1551 (pTxtRun->dwCharStyles & FX_TXTCHARSTYLE_OddBidiLevel) != 0; |
1565 FX_FLOAT fFontSize = pTxtRun->fFontSize; | 1552 FX_FLOAT fFontSize = pTxtRun->fFontSize; |
1566 int32_t iFontSize = FXSYS_round(fFontSize * 20.0f); | 1553 int32_t iFontSize = FXSYS_round(fFontSize * 20.0f); |
1567 FX_FLOAT fScale = fFontSize / 1000.0f; | 1554 FX_FLOAT fScale = fFontSize / 1000.0f; |
1568 IFGAS_Font* pFont = pTxtRun->pFont; | 1555 IFGAS_Font* pFont = pTxtRun->pFont; |
1569 if (pFont == NULL) { | 1556 if (!pFont) |
1570 bCharBBox = FALSE; | 1557 bCharBBox = FALSE; |
1571 } | 1558 |
1572 CFX_Rect bbox; | 1559 CFX_Rect bbox; |
1573 bbox.Set(0, 0, 0, 0); | 1560 bbox.Set(0, 0, 0, 0); |
1574 if (bCharBBox) { | 1561 if (bCharBBox) { |
1575 bCharBBox = pFont->GetBBox(bbox); | 1562 bCharBBox = pFont->GetBBox(bbox); |
1576 } | 1563 } |
1577 FX_FLOAT fLeft = std::max(0.0f, bbox.left * fScale); | 1564 FX_FLOAT fLeft = std::max(0.0f, bbox.left * fScale); |
1578 FX_FLOAT fHeight = FXSYS_fabs(bbox.height * fScale); | 1565 FX_FLOAT fHeight = FXSYS_fabs(bbox.height * fScale); |
1579 rtArray.RemoveAll(); | 1566 rtArray.RemoveAll(); |
1580 rtArray.SetSize(iLength); | 1567 rtArray.SetSize(iLength); |
1581 FX_BOOL bVertical = | 1568 FX_BOOL bVertical = |
1582 (pTxtRun->dwStyles & FX_TXTLAYOUTSTYLE_VerticalLayout) != 0; | 1569 (pTxtRun->dwStyles & FX_TXTLAYOUTSTYLE_VerticalLayout) != 0; |
1583 FX_BOOL bSingleLine = (pTxtRun->dwStyles & FX_TXTLAYOUTSTYLE_SingleLine) != 0; | 1570 FX_BOOL bSingleLine = (pTxtRun->dwStyles & FX_TXTLAYOUTSTYLE_SingleLine) != 0; |
1584 FX_BOOL bCombText = (pTxtRun->dwStyles & FX_TXTLAYOUTSTYLE_CombText) != 0; | 1571 FX_BOOL bCombText = (pTxtRun->dwStyles & FX_TXTLAYOUTSTYLE_CombText) != 0; |
1585 FX_WCHAR wch, wLineBreakChar = pTxtRun->wLineBreakChar; | 1572 FX_WCHAR wch, wLineBreakChar = pTxtRun->wLineBreakChar; |
1586 int32_t iCharSize; | 1573 int32_t iCharSize; |
1587 FX_FLOAT fCharSize, fStart; | 1574 FX_FLOAT fCharSize, fStart; |
1588 if (bVertical) { | 1575 if (bVertical) { |
1589 fStart = bRTLPiece ? rect.bottom() : rect.top; | 1576 fStart = bRTLPiece ? rect.bottom() : rect.top; |
1590 } else { | 1577 } else { |
1591 fStart = bRTLPiece ? rect.right() : rect.left; | 1578 fStart = bRTLPiece ? rect.right() : rect.left; |
1592 } | 1579 } |
1593 for (int32_t i = 0; i < iLength; i++) { | 1580 for (int32_t i = 0; i < iLength; i++) { |
1594 if (pAccess != NULL) { | 1581 if (pAccess) { |
1595 wch = pAccess->GetChar(pIdentity, i); | 1582 wch = pAccess->GetChar(pIdentity, i); |
1596 iCharSize = pAccess->GetWidth(pIdentity, i); | 1583 iCharSize = pAccess->GetWidth(pIdentity, i); |
1597 } else { | 1584 } else { |
1598 wch = *pStr++; | 1585 wch = *pStr++; |
1599 iCharSize = *pWidths++; | 1586 iCharSize = *pWidths++; |
1600 } | 1587 } |
1601 fCharSize = (FX_FLOAT)iCharSize / 20000.0f; | 1588 fCharSize = (FX_FLOAT)iCharSize / 20000.0f; |
1602 FX_BOOL bRet = (!bSingleLine && FX_IsCtrlCode(wch)); | 1589 FX_BOOL bRet = (!bSingleLine && FX_IsCtrlCode(wch)); |
1603 if (!(wch == L'\v' || wch == L'\f' || wch == 0x2028 || wch == 0x2029 || | 1590 if (!(wch == L'\v' || wch == L'\f' || wch == 0x2028 || wch == 0x2029 || |
1604 (wLineBreakChar != 0xFEFF && wch == wLineBreakChar))) { | 1591 (wLineBreakChar != 0xFEFF && wch == wLineBreakChar))) { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1652 rtBBoxF.height = fHeight; | 1639 rtBBoxF.height = fHeight; |
1653 rtBBoxF.top = std::max(rtBBoxF.top, 0.0f); | 1640 rtBBoxF.top = std::max(rtBBoxF.top, 0.0f); |
1654 } | 1641 } |
1655 rtArray.SetAt(i, rtBBoxF); | 1642 rtArray.SetAt(i, rtBBoxF); |
1656 continue; | 1643 continue; |
1657 } | 1644 } |
1658 rtArray.SetAt(i, rect); | 1645 rtArray.SetAt(i, rect); |
1659 } | 1646 } |
1660 return iLength; | 1647 return iLength; |
1661 } | 1648 } |
OLD | NEW |