| 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 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 m_iLineWidth(2000000), | 38 m_iLineWidth(2000000), |
| 39 m_dwLayoutStyles(0), | 39 m_dwLayoutStyles(0), |
| 40 m_bVertical(FALSE), | 40 m_bVertical(FALSE), |
| 41 m_bArabicContext(FALSE), | 41 m_bArabicContext(FALSE), |
| 42 m_bArabicShapes(FALSE), | 42 m_bArabicShapes(FALSE), |
| 43 m_bRTL(FALSE), | 43 m_bRTL(FALSE), |
| 44 m_bSingleLine(FALSE), | 44 m_bSingleLine(FALSE), |
| 45 m_bCombText(FALSE), | 45 m_bCombText(FALSE), |
| 46 m_iArabicContext(1), | 46 m_iArabicContext(1), |
| 47 m_iCurArabicContext(1), | 47 m_iCurArabicContext(1), |
| 48 m_pFont(NULL), | 48 m_pFont(nullptr), |
| 49 m_iFontSize(240), | 49 m_iFontSize(240), |
| 50 m_bEquidistant(TRUE), | 50 m_bEquidistant(TRUE), |
| 51 m_iTabWidth(720000), | 51 m_iTabWidth(720000), |
| 52 m_wDefChar(0xFEFF), | 52 m_wDefChar(0xFEFF), |
| 53 m_wParagBreakChar(L'\n'), | 53 m_wParagBreakChar(L'\n'), |
| 54 m_iDefChar(0), | 54 m_iDefChar(0), |
| 55 m_iLineRotation(0), | 55 m_iLineRotation(0), |
| 56 m_iCharRotation(0), | 56 m_iCharRotation(0), |
| 57 m_iRotation(0), | 57 m_iRotation(0), |
| 58 m_iAlignment(FX_TXTLINEALIGNMENT_Left), | 58 m_iAlignment(FX_TXTLINEALIGNMENT_Left), |
| 59 m_dwContextCharStyles(0), | 59 m_dwContextCharStyles(0), |
| 60 m_iCombWidth(360000), | 60 m_iCombWidth(360000), |
| 61 m_pUserData(NULL), | 61 m_pUserData(nullptr), |
| 62 m_eCharType(FX_CHARTYPE_Unknown), | 62 m_eCharType(FX_CHARTYPE_Unknown), |
| 63 m_bArabicNumber(FALSE), | 63 m_bArabicNumber(FALSE), |
| 64 m_bArabicComma(FALSE), | 64 m_bArabicComma(FALSE), |
| 65 m_pCurLine(NULL), | 65 m_pCurLine(nullptr), |
| 66 m_iReady(0), | 66 m_iReady(0), |
| 67 m_iTolerance(0), | 67 m_iTolerance(0), |
| 68 m_iHorScale(100), | 68 m_iHorScale(100), |
| 69 m_iVerScale(100), | 69 m_iVerScale(100), |
| 70 m_iCharSpace(0) { | 70 m_iCharSpace(0) { |
| 71 m_bPagination = (m_dwPolicies & FX_TXTBREAKPOLICY_Pagination) != 0; | 71 m_bPagination = (m_dwPolicies & FX_TXTBREAKPOLICY_Pagination) != 0; |
| 72 if (m_bPagination) { | 72 if (m_bPagination) { |
| 73 m_pTxtLine1 = new CFX_TxtLine(sizeof(CFX_Char)); | 73 m_pTxtLine1 = new CFX_TxtLine(sizeof(CFX_Char)); |
| 74 m_pTxtLine2 = new CFX_TxtLine(sizeof(CFX_Char)); | 74 m_pTxtLine2 = new CFX_TxtLine(sizeof(CFX_Char)); |
| 75 } else { | 75 } else { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 106 m_bArabicShapes = (m_dwLayoutStyles & FX_TXTLAYOUTSTYLE_ArabicShapes) != 0; | 106 m_bArabicShapes = (m_dwLayoutStyles & FX_TXTLAYOUTSTYLE_ArabicShapes) != 0; |
| 107 m_bRTL = (m_dwLayoutStyles & FX_TXTLAYOUTSTYLE_RTLReadingOrder) != 0; | 107 m_bRTL = (m_dwLayoutStyles & FX_TXTLAYOUTSTYLE_RTLReadingOrder) != 0; |
| 108 m_bSingleLine = (m_dwLayoutStyles & FX_TXTLAYOUTSTYLE_SingleLine) != 0; | 108 m_bSingleLine = (m_dwLayoutStyles & FX_TXTLAYOUTSTYLE_SingleLine) != 0; |
| 109 m_bCombText = (m_dwLayoutStyles & FX_TXTLAYOUTSTYLE_CombText) != 0; | 109 m_bCombText = (m_dwLayoutStyles & FX_TXTLAYOUTSTYLE_CombText) != 0; |
| 110 ResetArabicContext(); | 110 ResetArabicContext(); |
| 111 m_iLineRotation = GetLineRotation(m_dwLayoutStyles); | 111 m_iLineRotation = GetLineRotation(m_dwLayoutStyles); |
| 112 m_iRotation = m_iLineRotation + m_iCharRotation; | 112 m_iRotation = m_iLineRotation + m_iCharRotation; |
| 113 m_iRotation %= 4; | 113 m_iRotation %= 4; |
| 114 } | 114 } |
| 115 void CFX_TxtBreak::SetFont(CFGAS_GEFont* pFont) { | 115 void CFX_TxtBreak::SetFont(CFGAS_GEFont* pFont) { |
| 116 if (pFont == NULL) { | 116 if (!pFont) { |
| 117 return; | 117 return; |
| 118 } | 118 } |
| 119 if (m_pFont == pFont) { | 119 if (m_pFont == pFont) { |
| 120 return; | 120 return; |
| 121 } | 121 } |
| 122 SetBreakStatus(); | 122 SetBreakStatus(); |
| 123 m_pFont = pFont; | 123 m_pFont = pFont; |
| 124 m_iDefChar = 0; | 124 m_iDefChar = 0; |
| 125 if (m_wDefChar != 0xFEFF && m_pFont != NULL) { | 125 if (m_wDefChar != 0xFEFF && m_pFont) { |
| 126 m_pFont->GetCharWidth(m_wDefChar, m_iDefChar, FALSE); | 126 m_pFont->GetCharWidth(m_wDefChar, m_iDefChar, FALSE); |
| 127 m_iDefChar *= m_iFontSize; | 127 m_iDefChar *= m_iFontSize; |
| 128 } | 128 } |
| 129 } | 129 } |
| 130 void CFX_TxtBreak::SetFontSize(FX_FLOAT fFontSize) { | 130 void CFX_TxtBreak::SetFontSize(FX_FLOAT fFontSize) { |
| 131 int32_t iFontSize = FXSYS_round(fFontSize * 20.0f); | 131 int32_t iFontSize = FXSYS_round(fFontSize * 20.0f); |
| 132 if (m_iFontSize == iFontSize) { | 132 if (m_iFontSize == iFontSize) { |
| 133 return; | 133 return; |
| 134 } | 134 } |
| 135 SetBreakStatus(); | 135 SetBreakStatus(); |
| 136 m_iFontSize = iFontSize; | 136 m_iFontSize = iFontSize; |
| 137 m_iDefChar = 0; | 137 m_iDefChar = 0; |
| 138 if (m_wDefChar != 0xFEFF && m_pFont != NULL) { | 138 if (m_wDefChar != 0xFEFF && m_pFont) { |
| 139 m_pFont->GetCharWidth(m_wDefChar, m_iDefChar, FALSE); | 139 m_pFont->GetCharWidth(m_wDefChar, m_iDefChar, FALSE); |
| 140 m_iDefChar *= m_iFontSize; | 140 m_iDefChar *= m_iFontSize; |
| 141 } | 141 } |
| 142 } | 142 } |
| 143 void CFX_TxtBreak::SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant) { | 143 void CFX_TxtBreak::SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant) { |
| 144 m_iTabWidth = FXSYS_round(fTabWidth * 20000.0f); | 144 m_iTabWidth = FXSYS_round(fTabWidth * 20000.0f); |
| 145 if (m_iTabWidth < FX_TXTBREAK_MinimumTabWidth) { | 145 if (m_iTabWidth < FX_TXTBREAK_MinimumTabWidth) { |
| 146 m_iTabWidth = FX_TXTBREAK_MinimumTabWidth; | 146 m_iTabWidth = FX_TXTBREAK_MinimumTabWidth; |
| 147 } | 147 } |
| 148 m_bEquidistant = bEquidistant; | 148 m_bEquidistant = bEquidistant; |
| 149 } | 149 } |
| 150 void CFX_TxtBreak::SetDefaultChar(FX_WCHAR wch) { | 150 void CFX_TxtBreak::SetDefaultChar(FX_WCHAR wch) { |
| 151 m_wDefChar = wch; | 151 m_wDefChar = wch; |
| 152 m_iDefChar = 0; | 152 m_iDefChar = 0; |
| 153 if (m_wDefChar != 0xFEFF && m_pFont != NULL) { | 153 if (m_wDefChar != 0xFEFF && m_pFont) { |
| 154 m_pFont->GetCharWidth(m_wDefChar, m_iDefChar, FALSE); | 154 m_pFont->GetCharWidth(m_wDefChar, m_iDefChar, FALSE); |
| 155 if (m_iDefChar < 0) { | 155 if (m_iDefChar < 0) { |
| 156 m_iDefChar = 0; | 156 m_iDefChar = 0; |
| 157 } else { | 157 } else { |
| 158 m_iDefChar *= m_iFontSize; | 158 m_iDefChar *= m_iFontSize; |
| 159 } | 159 } |
| 160 } | 160 } |
| 161 } | 161 } |
| 162 void CFX_TxtBreak::SetParagraphBreakChar(FX_WCHAR wch) { | 162 void CFX_TxtBreak::SetParagraphBreakChar(FX_WCHAR wch) { |
| 163 if (wch != L'\r' && wch != L'\n') { | 163 if (wch != L'\r' && wch != L'\n') { |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 m_iCharSpace = FXSYS_round(fCharSpace * 20000.0f); | 259 m_iCharSpace = FXSYS_round(fCharSpace * 20000.0f); |
| 260 } | 260 } |
| 261 static const int32_t gs_FX_TxtLineRotations[8] = {0, 3, 1, 0, 2, 1, 3, 2}; | 261 static const int32_t gs_FX_TxtLineRotations[8] = {0, 3, 1, 0, 2, 1, 3, 2}; |
| 262 int32_t CFX_TxtBreak::GetLineRotation(uint32_t dwStyles) const { | 262 int32_t CFX_TxtBreak::GetLineRotation(uint32_t dwStyles) const { |
| 263 return gs_FX_TxtLineRotations[(dwStyles & 0x0E) >> 1]; | 263 return gs_FX_TxtLineRotations[(dwStyles & 0x0E) >> 1]; |
| 264 } | 264 } |
| 265 CFX_TxtChar* CFX_TxtBreak::GetLastChar(int32_t index, FX_BOOL bOmitChar) const { | 265 CFX_TxtChar* CFX_TxtBreak::GetLastChar(int32_t index, FX_BOOL bOmitChar) const { |
| 266 CFX_TxtCharArray& ca = *m_pCurLine->m_pLineChars; | 266 CFX_TxtCharArray& ca = *m_pCurLine->m_pLineChars; |
| 267 int32_t iCount = ca.GetSize(); | 267 int32_t iCount = ca.GetSize(); |
| 268 if (index < 0 || index >= iCount) { | 268 if (index < 0 || index >= iCount) { |
| 269 return NULL; | 269 return nullptr; |
| 270 } | 270 } |
| 271 CFX_TxtChar* pTC; | 271 CFX_TxtChar* pTC; |
| 272 int32_t iStart = iCount - 1; | 272 int32_t iStart = iCount - 1; |
| 273 while (iStart > -1) { | 273 while (iStart > -1) { |
| 274 pTC = ca.GetDataPtr(iStart--); | 274 pTC = ca.GetDataPtr(iStart--); |
| 275 if (bOmitChar && pTC->GetCharType() == FX_CHARTYPE_Combination) { | 275 if (bOmitChar && pTC->GetCharType() == FX_CHARTYPE_Combination) { |
| 276 continue; | 276 continue; |
| 277 } | 277 } |
| 278 if (--index < 0) { | 278 if (--index < 0) { |
| 279 return pTC; | 279 return pTC; |
| 280 } | 280 } |
| 281 } | 281 } |
| 282 return NULL; | 282 return nullptr; |
| 283 } | 283 } |
| 284 CFX_TxtLine* CFX_TxtBreak::GetTxtLine(FX_BOOL bReady) const { | 284 CFX_TxtLine* CFX_TxtBreak::GetTxtLine(FX_BOOL bReady) const { |
| 285 if (!bReady) { | 285 if (!bReady) |
| 286 return m_pCurLine; | 286 return m_pCurLine; |
| 287 } | 287 if (m_iReady == 1) |
| 288 if (m_iReady == 1) { | |
| 289 return m_pTxtLine1; | 288 return m_pTxtLine1; |
| 290 } else if (m_iReady == 2) { | 289 if (m_iReady == 2) |
| 291 return m_pTxtLine2; | 290 return m_pTxtLine2; |
| 292 } else { | 291 return nullptr; |
| 293 return NULL; | |
| 294 } | |
| 295 } | 292 } |
| 296 CFX_TxtPieceArray* CFX_TxtBreak::GetTxtPieces(FX_BOOL bReady) const { | 293 CFX_TxtPieceArray* CFX_TxtBreak::GetTxtPieces(FX_BOOL bReady) const { |
| 297 CFX_TxtLine* pTxtLine = GetTxtLine(bReady); | 294 CFX_TxtLine* pTxtLine = GetTxtLine(bReady); |
| 298 if (pTxtLine == NULL) { | 295 if (!pTxtLine) { |
| 299 return NULL; | 296 return nullptr; |
| 300 } | 297 } |
| 301 return pTxtLine->m_pLinePieces; | 298 return pTxtLine->m_pLinePieces; |
| 302 } | 299 } |
| 303 inline FX_CHARTYPE CFX_TxtBreak::GetUnifiedCharType( | 300 inline FX_CHARTYPE CFX_TxtBreak::GetUnifiedCharType( |
| 304 FX_CHARTYPE chartype) const { | 301 FX_CHARTYPE chartype) const { |
| 305 return chartype >= FX_CHARTYPE_ArabicAlef ? FX_CHARTYPE_Arabic : chartype; | 302 return chartype >= FX_CHARTYPE_ArabicAlef ? FX_CHARTYPE_Arabic : chartype; |
| 306 } | 303 } |
| 307 void CFX_TxtBreak::ResetArabicContext() { | 304 void CFX_TxtBreak::ResetArabicContext() { |
| 308 if (m_bArabicContext) { | 305 if (m_bArabicContext) { |
| 309 m_bCurRTL = m_iCurArabicContext > 1; | 306 m_bCurRTL = m_iCurArabicContext > 1; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 : ((iBidiCls == FX_BIDICLASS_L || iBidiCls == FX_BIDICLASS_S) ? 0 | 340 : ((iBidiCls == FX_BIDICLASS_L || iBidiCls == FX_BIDICLASS_S) ? 0 |
| 344 : 1); | 341 : 1); |
| 345 if (iArabicContext != m_iArabicContext && iArabicContext != 1) { | 342 if (iArabicContext != m_iArabicContext && iArabicContext != 1) { |
| 346 m_iArabicContext = iArabicContext; | 343 m_iArabicContext = iArabicContext; |
| 347 if (m_iCurArabicContext == 1) { | 344 if (m_iCurArabicContext == 1) { |
| 348 m_iCurArabicContext = iArabicContext; | 345 m_iCurArabicContext = iArabicContext; |
| 349 } | 346 } |
| 350 ResetArabicContext(); | 347 ResetArabicContext(); |
| 351 if (!m_bPagination) { | 348 if (!m_bPagination) { |
| 352 CFX_TxtChar* pLastChar = GetLastChar(1, FALSE); | 349 CFX_TxtChar* pLastChar = GetLastChar(1, FALSE); |
| 353 if (pLastChar != NULL && pLastChar->m_dwStatus < 1) { | 350 if (pLastChar && pLastChar->m_dwStatus < 1) { |
| 354 pLastChar->m_dwStatus = FX_TXTBREAK_PieceBreak; | 351 pLastChar->m_dwStatus = FX_TXTBREAK_PieceBreak; |
| 355 } | 352 } |
| 356 } | 353 } |
| 357 } | 354 } |
| 358 } | 355 } |
| 359 pCurChar->m_dwCharStyles = m_dwContextCharStyles; | 356 pCurChar->m_dwCharStyles = m_dwContextCharStyles; |
| 360 } | 357 } |
| 361 uint32_t CFX_TxtBreak::AppendChar_Combination(CFX_TxtChar* pCurChar, | 358 uint32_t CFX_TxtBreak::AppendChar_Combination(CFX_TxtChar* pCurChar, |
| 362 int32_t iRotation) { | 359 int32_t iRotation) { |
| 363 FX_WCHAR wch = pCurChar->m_wCharCode; | 360 FX_WCHAR wch = pCurChar->m_wCharCode; |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 } | 458 } |
| 462 } | 459 } |
| 463 return dwRet; | 460 return dwRet; |
| 464 } | 461 } |
| 465 uint32_t CFX_TxtBreak::AppendChar_Arabic(CFX_TxtChar* pCurChar, | 462 uint32_t CFX_TxtBreak::AppendChar_Arabic(CFX_TxtChar* pCurChar, |
| 466 int32_t iRotation) { | 463 int32_t iRotation) { |
| 467 FX_CHARTYPE chartype = pCurChar->GetCharType(); | 464 FX_CHARTYPE chartype = pCurChar->GetCharType(); |
| 468 int32_t& iLineWidth = m_pCurLine->m_iWidth; | 465 int32_t& iLineWidth = m_pCurLine->m_iWidth; |
| 469 FX_WCHAR wForm; | 466 FX_WCHAR wForm; |
| 470 int32_t iCharWidth = 0; | 467 int32_t iCharWidth = 0; |
| 471 CFX_Char* pLastChar = NULL; | 468 CFX_Char* pLastChar = nullptr; |
| 472 FX_BOOL bAlef = FALSE; | 469 FX_BOOL bAlef = FALSE; |
| 473 if (!m_bCombText && m_eCharType >= FX_CHARTYPE_ArabicAlef && | 470 if (!m_bCombText && m_eCharType >= FX_CHARTYPE_ArabicAlef && |
| 474 m_eCharType <= FX_CHARTYPE_ArabicDistortion) { | 471 m_eCharType <= FX_CHARTYPE_ArabicDistortion) { |
| 475 pLastChar = GetLastChar(1); | 472 pLastChar = GetLastChar(1); |
| 476 if (pLastChar != NULL) { | 473 if (pLastChar) { |
| 477 iCharWidth = pLastChar->m_iCharWidth; | 474 iCharWidth = pLastChar->m_iCharWidth; |
| 478 if (iCharWidth > 0) { | 475 if (iCharWidth > 0) { |
| 479 iLineWidth -= iCharWidth; | 476 iLineWidth -= iCharWidth; |
| 480 } | 477 } |
| 481 CFX_Char* pPrevChar = GetLastChar(2); | 478 CFX_Char* pPrevChar = GetLastChar(2); |
| 482 wForm = pdfium::arabic::GetFormChar(pLastChar, pPrevChar, pCurChar); | 479 wForm = pdfium::arabic::GetFormChar(pLastChar, pPrevChar, pCurChar); |
| 483 bAlef = (wForm == 0xFEFF && | 480 bAlef = (wForm == 0xFEFF && |
| 484 pLastChar->GetCharType() == FX_CHARTYPE_ArabicAlef); | 481 pLastChar->GetCharType() == FX_CHARTYPE_ArabicAlef); |
| 485 int32_t iLastRotation = pLastChar->m_nRotation + m_iLineRotation; | 482 int32_t iLastRotation = pLastChar->m_nRotation + m_iLineRotation; |
| 486 if (m_bVertical && (pLastChar->m_dwCharProps & 0x8000) != 0) { | 483 if (m_bVertical && (pLastChar->m_dwCharProps & 0x8000) != 0) { |
| 487 iLastRotation++; | 484 iLastRotation++; |
| 488 } | 485 } |
| 489 if (m_bVertical != FX_IsOdd(iLastRotation)) { | 486 if (m_bVertical != FX_IsOdd(iLastRotation)) { |
| 490 iCharWidth = 1000; | 487 iCharWidth = 1000; |
| 491 } else { | 488 } else { |
| 492 m_pFont->GetCharWidth(wForm, iCharWidth, FALSE); | 489 m_pFont->GetCharWidth(wForm, iCharWidth, FALSE); |
| 493 } | 490 } |
| 494 if (wForm == 0xFEFF) { | 491 if (wForm == 0xFEFF) { |
| 495 iCharWidth = m_iDefChar; | 492 iCharWidth = m_iDefChar; |
| 496 } | 493 } |
| 497 iCharWidth *= m_iFontSize; | 494 iCharWidth *= m_iFontSize; |
| 498 iCharWidth = iCharWidth * m_iHorScale / 100; | 495 iCharWidth = iCharWidth * m_iHorScale / 100; |
| 499 pLastChar->m_iCharWidth = iCharWidth; | 496 pLastChar->m_iCharWidth = iCharWidth; |
| 500 iLineWidth += iCharWidth; | 497 iLineWidth += iCharWidth; |
| 501 iCharWidth = 0; | 498 iCharWidth = 0; |
| 502 } | 499 } |
| 503 } | 500 } |
| 504 m_eCharType = chartype; | 501 m_eCharType = chartype; |
| 505 wForm = pdfium::arabic::GetFormChar(pCurChar, bAlef ? NULL : pLastChar, NULL); | 502 wForm = pdfium::arabic::GetFormChar(pCurChar, bAlef ? nullptr : pLastChar, |
| 503 nullptr); |
| 506 if (m_bCombText) { | 504 if (m_bCombText) { |
| 507 iCharWidth = m_iCombWidth; | 505 iCharWidth = m_iCombWidth; |
| 508 } else { | 506 } else { |
| 509 if (m_bVertical != FX_IsOdd(iRotation)) { | 507 if (m_bVertical != FX_IsOdd(iRotation)) { |
| 510 iCharWidth = 1000; | 508 iCharWidth = 1000; |
| 511 } else { | 509 } else { |
| 512 m_pFont->GetCharWidth(wForm, iCharWidth, FALSE); | 510 m_pFont->GetCharWidth(wForm, iCharWidth, FALSE); |
| 513 } | 511 } |
| 514 if (wForm == 0xFEFF) { | 512 if (wForm == 0xFEFF) { |
| 515 iCharWidth = m_iDefChar; | 513 iCharWidth = m_iDefChar; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 pCurChar->m_dwCharProps = dwProps; | 576 pCurChar->m_dwCharProps = dwProps; |
| 579 pCurChar->m_dwCharStyles = 0; | 577 pCurChar->m_dwCharStyles = 0; |
| 580 pCurChar->m_iCharWidth = 0; | 578 pCurChar->m_iCharWidth = 0; |
| 581 pCurChar->m_iHorizontalScale = m_iHorScale; | 579 pCurChar->m_iHorizontalScale = m_iHorScale; |
| 582 pCurChar->m_iVertialScale = m_iVerScale; | 580 pCurChar->m_iVertialScale = m_iVerScale; |
| 583 pCurChar->m_dwStatus = 0; | 581 pCurChar->m_dwStatus = 0; |
| 584 pCurChar->m_iBidiClass = 0; | 582 pCurChar->m_iBidiClass = 0; |
| 585 pCurChar->m_iBidiLevel = 0; | 583 pCurChar->m_iBidiLevel = 0; |
| 586 pCurChar->m_iBidiPos = 0; | 584 pCurChar->m_iBidiPos = 0; |
| 587 pCurChar->m_iBidiOrder = 0; | 585 pCurChar->m_iBidiOrder = 0; |
| 588 pCurChar->m_pUserData = NULL; | 586 pCurChar->m_pUserData = nullptr; |
| 589 AppendChar_PageLoad(pCurChar, dwProps); | 587 AppendChar_PageLoad(pCurChar, dwProps); |
| 590 uint32_t dwRet1 = FX_TXTBREAK_None; | 588 uint32_t dwRet1 = FX_TXTBREAK_None; |
| 591 if (chartype != FX_CHARTYPE_Combination && | 589 if (chartype != FX_CHARTYPE_Combination && |
| 592 GetUnifiedCharType(m_eCharType) != GetUnifiedCharType(chartype)) { | 590 GetUnifiedCharType(m_eCharType) != GetUnifiedCharType(chartype)) { |
| 593 if (m_eCharType != FX_CHARTYPE_Unknown && | 591 if (m_eCharType != FX_CHARTYPE_Unknown && |
| 594 m_pCurLine->m_iWidth > m_iLineWidth + m_iTolerance && !m_bSingleLine) { | 592 m_pCurLine->m_iWidth > m_iLineWidth + m_iTolerance && !m_bSingleLine) { |
| 595 if (m_eCharType != FX_CHARTYPE_Space || chartype != FX_CHARTYPE_Control) { | 593 if (m_eCharType != FX_CHARTYPE_Space || chartype != FX_CHARTYPE_Control) { |
| 596 dwRet1 = EndBreak(FX_TXTBREAK_LineBreak); | 594 dwRet1 = EndBreak(FX_TXTBREAK_LineBreak); |
| 597 int32_t iCount = m_pCurLine->CountChars(); | 595 int32_t iCount = m_pCurLine->CountChars(); |
| 598 if (iCount > 0) { | 596 if (iCount > 0) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 623 pCur = m_pCurLine->GetCharPtr(1); | 621 pCur = m_pCurLine->GetCharPtr(1); |
| 624 FX_WCHAR wch, wForm; | 622 FX_WCHAR wch, wForm; |
| 625 FX_BOOL bNextNum; | 623 FX_BOOL bNextNum; |
| 626 int32_t i = 1, iCharWidth, iRotation; | 624 int32_t i = 1, iCharWidth, iRotation; |
| 627 do { | 625 do { |
| 628 i++; | 626 i++; |
| 629 if (i < iCount) { | 627 if (i < iCount) { |
| 630 pNext = m_pCurLine->GetCharPtr(i); | 628 pNext = m_pCurLine->GetCharPtr(i); |
| 631 bNextNum = (pNext->m_dwCharStyles & FX_TXTCHARSTYLE_ArabicIndic) != 0; | 629 bNextNum = (pNext->m_dwCharStyles & FX_TXTCHARSTYLE_ArabicIndic) != 0; |
| 632 } else { | 630 } else { |
| 633 pNext = NULL; | 631 pNext = nullptr; |
| 634 bNextNum = FALSE; | 632 bNextNum = FALSE; |
| 635 } | 633 } |
| 636 wch = pCur->m_wCharCode; | 634 wch = pCur->m_wCharCode; |
| 637 if (wch == L'.') { | 635 if (wch == L'.') { |
| 638 if (bPrevNum && bNextNum) { | 636 if (bPrevNum && bNextNum) { |
| 639 iRotation = m_iRotation; | 637 iRotation = m_iRotation; |
| 640 if (m_bVertical && (pCur->m_dwCharProps & 0x8000) != 0) { | 638 if (m_bVertical && (pCur->m_dwCharProps & 0x8000) != 0) { |
| 641 iRotation = ((iRotation + 1) & 0x03); | 639 iRotation = ((iRotation + 1) & 0x03); |
| 642 } | 640 } |
| 643 wForm = wch == L'.' ? 0x066B : 0x066C; | 641 wForm = wch == L'.' ? 0x066B : 0x066C; |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 916 if (iCount > 0) { | 914 if (iCount > 0) { |
| 917 CFX_TxtPiece* pLastPiece = pCurPieces->GetPtrAt(--iCount); | 915 CFX_TxtPiece* pLastPiece = pCurPieces->GetPtrAt(--iCount); |
| 918 if (dwStatus > FX_TXTBREAK_PieceBreak) { | 916 if (dwStatus > FX_TXTBREAK_PieceBreak) { |
| 919 pLastPiece->m_dwStatus = dwStatus; | 917 pLastPiece->m_dwStatus = dwStatus; |
| 920 } else { | 918 } else { |
| 921 dwStatus = pLastPiece->m_dwStatus; | 919 dwStatus = pLastPiece->m_dwStatus; |
| 922 } | 920 } |
| 923 return dwStatus; | 921 return dwStatus; |
| 924 } else { | 922 } else { |
| 925 CFX_TxtLine* pLastLine = GetTxtLine(TRUE); | 923 CFX_TxtLine* pLastLine = GetTxtLine(TRUE); |
| 926 if (pLastLine != NULL) { | 924 if (pLastLine) { |
| 927 pCurPieces = pLastLine->m_pLinePieces; | 925 pCurPieces = pLastLine->m_pLinePieces; |
| 928 iCount = pCurPieces->GetSize(); | 926 iCount = pCurPieces->GetSize(); |
| 929 if (iCount-- > 0) { | 927 if (iCount-- > 0) { |
| 930 CFX_TxtPiece* pLastPiece = pCurPieces->GetPtrAt(iCount); | 928 CFX_TxtPiece* pLastPiece = pCurPieces->GetPtrAt(iCount); |
| 931 if (dwStatus > FX_TXTBREAK_PieceBreak) { | 929 if (dwStatus > FX_TXTBREAK_PieceBreak) { |
| 932 pLastPiece->m_dwStatus = dwStatus; | 930 pLastPiece->m_dwStatus = dwStatus; |
| 933 } else { | 931 } else { |
| 934 dwStatus = pLastPiece->m_dwStatus; | 932 dwStatus = pLastPiece->m_dwStatus; |
| 935 } | 933 } |
| 936 return dwStatus; | 934 return dwStatus; |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1067 } | 1065 } |
| 1068 if (iLast > -1) { | 1066 if (iLast > -1) { |
| 1069 iEndPos = iLastPos; | 1067 iEndPos = iLastPos; |
| 1070 return iLast; | 1068 return iLast; |
| 1071 } | 1069 } |
| 1072 return 0; | 1070 return 0; |
| 1073 } | 1071 } |
| 1074 void CFX_TxtBreak::SplitTextLine(CFX_TxtLine* pCurLine, | 1072 void CFX_TxtBreak::SplitTextLine(CFX_TxtLine* pCurLine, |
| 1075 CFX_TxtLine* pNextLine, | 1073 CFX_TxtLine* pNextLine, |
| 1076 FX_BOOL bAllChars) { | 1074 FX_BOOL bAllChars) { |
| 1077 ASSERT(pCurLine != NULL && pNextLine != NULL); | 1075 ASSERT(pCurLine && pNextLine); |
| 1078 int32_t iCount = pCurLine->CountChars(); | 1076 int32_t iCount = pCurLine->CountChars(); |
| 1079 if (iCount < 2) { | 1077 if (iCount < 2) { |
| 1080 return; | 1078 return; |
| 1081 } | 1079 } |
| 1082 int32_t iEndPos = pCurLine->m_iWidth; | 1080 int32_t iEndPos = pCurLine->m_iWidth; |
| 1083 CFX_TxtCharArray& curChars = *pCurLine->m_pLineChars; | 1081 CFX_TxtCharArray& curChars = *pCurLine->m_pLineChars; |
| 1084 int32_t iCharPos = GetBreakPos(curChars, iEndPos, bAllChars, FALSE); | 1082 int32_t iCharPos = GetBreakPos(curChars, iEndPos, bAllChars, FALSE); |
| 1085 if (iCharPos < 0) { | 1083 if (iCharPos < 0) { |
| 1086 iCharPos = 0; | 1084 iCharPos = 0; |
| 1087 } | 1085 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1117 } | 1115 } |
| 1118 if (m_bPagination) { | 1116 if (m_bPagination) { |
| 1119 continue; | 1117 continue; |
| 1120 } | 1118 } |
| 1121 pTC->m_dwStatus = 0; | 1119 pTC->m_dwStatus = 0; |
| 1122 } | 1120 } |
| 1123 pNextLine->m_iWidth = iWidth; | 1121 pNextLine->m_iWidth = iWidth; |
| 1124 } | 1122 } |
| 1125 int32_t CFX_TxtBreak::CountBreakChars() const { | 1123 int32_t CFX_TxtBreak::CountBreakChars() const { |
| 1126 CFX_TxtLine* pTxtLine = GetTxtLine(TRUE); | 1124 CFX_TxtLine* pTxtLine = GetTxtLine(TRUE); |
| 1127 return pTxtLine == NULL ? 0 : pTxtLine->CountChars(); | 1125 return pTxtLine ? pTxtLine->CountChars() : 0; |
| 1128 } | 1126 } |
| 1129 int32_t CFX_TxtBreak::CountBreakPieces() const { | 1127 int32_t CFX_TxtBreak::CountBreakPieces() const { |
| 1130 CFX_TxtPieceArray* pTxtPieces = GetTxtPieces(TRUE); | 1128 CFX_TxtPieceArray* pTxtPieces = GetTxtPieces(TRUE); |
| 1131 if (pTxtPieces == NULL) { | 1129 return pTxtPieces ? pTxtPieces->GetSize() : 0; |
| 1132 return 0; | |
| 1133 } | |
| 1134 return pTxtPieces->GetSize(); | |
| 1135 } | 1130 } |
| 1136 const CFX_TxtPiece* CFX_TxtBreak::GetBreakPiece(int32_t index) const { | 1131 const CFX_TxtPiece* CFX_TxtBreak::GetBreakPiece(int32_t index) const { |
| 1137 CFX_TxtPieceArray* pTxtPieces = GetTxtPieces(TRUE); | 1132 CFX_TxtPieceArray* pTxtPieces = GetTxtPieces(TRUE); |
| 1138 if (pTxtPieces == NULL) { | 1133 if (!pTxtPieces) { |
| 1139 return NULL; | 1134 return nullptr; |
| 1140 } | 1135 } |
| 1141 if (index < 0 || index >= pTxtPieces->GetSize()) { | 1136 if (index < 0 || index >= pTxtPieces->GetSize()) { |
| 1142 return NULL; | 1137 return nullptr; |
| 1143 } | 1138 } |
| 1144 return pTxtPieces->GetPtrAt(index); | 1139 return pTxtPieces->GetPtrAt(index); |
| 1145 } | 1140 } |
| 1146 void CFX_TxtBreak::ClearBreakPieces() { | 1141 void CFX_TxtBreak::ClearBreakPieces() { |
| 1147 CFX_TxtLine* pTxtLine = GetTxtLine(TRUE); | 1142 CFX_TxtLine* pTxtLine = GetTxtLine(TRUE); |
| 1148 if (pTxtLine != NULL) { | 1143 if (pTxtLine) { |
| 1149 pTxtLine->RemoveAll(TRUE); | 1144 pTxtLine->RemoveAll(TRUE); |
| 1150 } | 1145 } |
| 1151 m_iReady = 0; | 1146 m_iReady = 0; |
| 1152 } | 1147 } |
| 1153 void CFX_TxtBreak::Reset() { | 1148 void CFX_TxtBreak::Reset() { |
| 1154 m_eCharType = FX_CHARTYPE_Unknown; | 1149 m_eCharType = FX_CHARTYPE_Unknown; |
| 1155 m_iArabicContext = m_iCurArabicContext = 1; | 1150 m_iArabicContext = m_iCurArabicContext = 1; |
| 1156 ResetArabicContext(); | 1151 ResetArabicContext(); |
| 1157 m_pTxtLine1->RemoveAll(TRUE); | 1152 m_pTxtLine1->RemoveAll(TRUE); |
| 1158 m_pTxtLine2->RemoveAll(TRUE); | 1153 m_pTxtLine2->RemoveAll(TRUE); |
| 1159 } | 1154 } |
| 1160 | 1155 |
| 1161 struct FX_FORMCHAR { | 1156 struct FX_FORMCHAR { |
| 1162 uint16_t wch; | 1157 uint16_t wch; |
| 1163 uint16_t wForm; | 1158 uint16_t wForm; |
| 1164 int32_t iWidth; | 1159 int32_t iWidth; |
| 1165 }; | 1160 }; |
| 1166 | 1161 |
| 1167 int32_t CFX_TxtBreak::GetDisplayPos(const FX_TXTRUN* pTxtRun, | 1162 int32_t CFX_TxtBreak::GetDisplayPos(const FX_TXTRUN* pTxtRun, |
| 1168 FXTEXT_CHARPOS* pCharPos, | 1163 FXTEXT_CHARPOS* pCharPos, |
| 1169 FX_BOOL bCharCode, | 1164 FX_BOOL bCharCode, |
| 1170 CFX_WideString* pWSForms, | 1165 CFX_WideString* pWSForms, |
| 1171 FX_AdjustCharDisplayPos pAdjustPos) const { | 1166 FX_AdjustCharDisplayPos pAdjustPos) const { |
| 1172 if (pTxtRun == NULL || pTxtRun->iLength < 1) { | 1167 if (!pTxtRun || pTxtRun->iLength < 1) { |
| 1173 return 0; | 1168 return 0; |
| 1174 } | 1169 } |
| 1175 IFX_TxtAccess* pAccess = pTxtRun->pAccess; | 1170 IFX_TxtAccess* pAccess = pTxtRun->pAccess; |
| 1176 const FDE_TEXTEDITPIECE* pIdentity = pTxtRun->pIdentity; | 1171 const FDE_TEXTEDITPIECE* pIdentity = pTxtRun->pIdentity; |
| 1177 const FX_WCHAR* pStr = pTxtRun->wsStr.c_str(); | 1172 const FX_WCHAR* pStr = pTxtRun->wsStr.c_str(); |
| 1178 int32_t* pWidths = pTxtRun->pWidths; | 1173 int32_t* pWidths = pTxtRun->pWidths; |
| 1179 int32_t iLength = pTxtRun->iLength - 1; | 1174 int32_t iLength = pTxtRun->iLength - 1; |
| 1180 CFGAS_GEFont* pFont = pTxtRun->pFont; | 1175 CFGAS_GEFont* pFont = pTxtRun->pFont; |
| 1181 uint32_t dwStyles = pTxtRun->dwStyles; | 1176 uint32_t dwStyles = pTxtRun->dwStyles; |
| 1182 CFX_RectF rtText(*pTxtRun->pRect); | 1177 CFX_RectF rtText(*pTxtRun->pRect); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1219 int32_t iNext = 0; | 1214 int32_t iNext = 0; |
| 1220 FX_WCHAR wPrev = 0xFEFF; | 1215 FX_WCHAR wPrev = 0xFEFF; |
| 1221 FX_WCHAR wNext = 0xFEFF; | 1216 FX_WCHAR wNext = 0xFEFF; |
| 1222 FX_WCHAR wForm = 0xFEFF; | 1217 FX_WCHAR wForm = 0xFEFF; |
| 1223 FX_WCHAR wLast = 0xFEFF; | 1218 FX_WCHAR wLast = 0xFEFF; |
| 1224 FX_BOOL bShadda = FALSE; | 1219 FX_BOOL bShadda = FALSE; |
| 1225 FX_BOOL bLam = FALSE; | 1220 FX_BOOL bLam = FALSE; |
| 1226 for (int32_t i = 0; i <= iLength; i++) { | 1221 for (int32_t i = 0; i <= iLength; i++) { |
| 1227 int32_t iWidth; | 1222 int32_t iWidth; |
| 1228 FX_WCHAR wch; | 1223 FX_WCHAR wch; |
| 1229 if (pAccess != NULL) { | 1224 if (pAccess) { |
| 1230 wch = pAccess->GetChar(pIdentity, i); | 1225 wch = pAccess->GetChar(pIdentity, i); |
| 1231 iWidth = pAccess->GetWidth(pIdentity, i); | 1226 iWidth = pAccess->GetWidth(pIdentity, i); |
| 1232 } else { | 1227 } else { |
| 1233 wch = *pStr++; | 1228 wch = *pStr++; |
| 1234 iWidth = *pWidths++; | 1229 iWidth = *pWidths++; |
| 1235 } | 1230 } |
| 1236 uint32_t dwProps = FX_GetUnicodeProperties(wch); | 1231 uint32_t dwProps = FX_GetUnicodeProperties(wch); |
| 1237 FX_CHARTYPE chartype = GetCharTypeFromProp(dwProps); | 1232 FX_CHARTYPE chartype = GetCharTypeFromProp(dwProps); |
| 1238 if (chartype == FX_CHARTYPE_ArabicAlef && iWidth == 0) { | 1233 if (chartype == FX_CHARTYPE_ArabicAlef && iWidth == 0) { |
| 1239 wPrev = 0xFEFF; | 1234 wPrev = 0xFEFF; |
| 1240 wLast = wch; | 1235 wLast = wch; |
| 1241 continue; | 1236 continue; |
| 1242 } | 1237 } |
| 1243 if (chartype >= FX_CHARTYPE_ArabicAlef) { | 1238 if (chartype >= FX_CHARTYPE_ArabicAlef) { |
| 1244 if (i < iLength) { | 1239 if (i < iLength) { |
| 1245 if (pAccess != NULL) { | 1240 if (pAccess) { |
| 1246 iNext = i + 1; | 1241 iNext = i + 1; |
| 1247 while (iNext <= iLength) { | 1242 while (iNext <= iLength) { |
| 1248 wNext = pAccess->GetChar(pIdentity, iNext); | 1243 wNext = pAccess->GetChar(pIdentity, iNext); |
| 1249 dwProps = FX_GetUnicodeProperties(wNext); | 1244 dwProps = FX_GetUnicodeProperties(wNext); |
| 1250 if ((dwProps & FX_CHARTYPEBITSMASK) != FX_CHARTYPE_Combination) { | 1245 if ((dwProps & FX_CHARTYPEBITSMASK) != FX_CHARTYPE_Combination) { |
| 1251 break; | 1246 break; |
| 1252 } | 1247 } |
| 1253 iNext++; | 1248 iNext++; |
| 1254 } | 1249 } |
| 1255 if (iNext > iLength) { | 1250 if (iNext > iLength) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1275 wForm = pdfium::arabic::GetFormChar(wch, wPrev, wNext); | 1270 wForm = pdfium::arabic::GetFormChar(wch, wPrev, wNext); |
| 1276 bLam = (wPrev == 0x0644 && wch == 0x0644 && wNext == 0x0647); | 1271 bLam = (wPrev == 0x0644 && wch == 0x0644 && wNext == 0x0647); |
| 1277 } else if (chartype == FX_CHARTYPE_Combination) { | 1272 } else if (chartype == FX_CHARTYPE_Combination) { |
| 1278 wForm = wch; | 1273 wForm = wch; |
| 1279 if (wch >= 0x064C && wch <= 0x0651) { | 1274 if (wch >= 0x064C && wch <= 0x0651) { |
| 1280 if (bShadda) { | 1275 if (bShadda) { |
| 1281 wForm = 0xFEFF; | 1276 wForm = 0xFEFF; |
| 1282 bShadda = FALSE; | 1277 bShadda = FALSE; |
| 1283 } else { | 1278 } else { |
| 1284 wNext = 0xFEFF; | 1279 wNext = 0xFEFF; |
| 1285 if (pAccess != NULL) { | 1280 if (pAccess) { |
| 1286 iNext = i + 1; | 1281 iNext = i + 1; |
| 1287 if (iNext <= iLength) { | 1282 if (iNext <= iLength) { |
| 1288 wNext = pAccess->GetChar(pIdentity, iNext); | 1283 wNext = pAccess->GetChar(pIdentity, iNext); |
| 1289 } | 1284 } |
| 1290 } else { | 1285 } else { |
| 1291 if (i < iLength) { | 1286 if (i < iLength) { |
| 1292 wNext = *pStr; | 1287 wNext = *pStr; |
| 1293 } | 1288 } |
| 1294 } | 1289 } |
| 1295 if (wch == 0x0651) { | 1290 if (wch == 0x0651) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1309 } | 1304 } |
| 1310 } else if (chartype == FX_CHARTYPE_Numeric) { | 1305 } else if (chartype == FX_CHARTYPE_Numeric) { |
| 1311 wForm = wch; | 1306 wForm = wch; |
| 1312 if (bArabicNumber) { | 1307 if (bArabicNumber) { |
| 1313 wForm += 0x0630; | 1308 wForm += 0x0630; |
| 1314 } | 1309 } |
| 1315 } else if (wch == L'.') { | 1310 } else if (wch == L'.') { |
| 1316 wForm = wch; | 1311 wForm = wch; |
| 1317 if (bArabicNumber) { | 1312 if (bArabicNumber) { |
| 1318 wNext = 0xFEFF; | 1313 wNext = 0xFEFF; |
| 1319 if (pAccess != NULL) { | 1314 if (pAccess) { |
| 1320 iNext = i + 1; | 1315 iNext = i + 1; |
| 1321 if (iNext <= iLength) { | 1316 if (iNext <= iLength) { |
| 1322 wNext = pAccess->GetChar(pIdentity, iNext); | 1317 wNext = pAccess->GetChar(pIdentity, iNext); |
| 1323 } | 1318 } |
| 1324 } else { | 1319 } else { |
| 1325 if (i < iLength) { | 1320 if (i < iLength) { |
| 1326 wNext = *pStr; | 1321 wNext = *pStr; |
| 1327 } | 1322 } |
| 1328 } | 1323 } |
| 1329 if (wNext >= L'0' && wNext <= L'9') { | 1324 if (wNext >= L'0' && wNext <= L'9') { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1352 iCharRotation++; | 1347 iCharRotation++; |
| 1353 } | 1348 } |
| 1354 iCharRotation %= 4; | 1349 iCharRotation %= 4; |
| 1355 FX_BOOL bEmptyChar = | 1350 FX_BOOL bEmptyChar = |
| 1356 (chartype >= FX_CHARTYPE_Tab && chartype <= FX_CHARTYPE_Control); | 1351 (chartype >= FX_CHARTYPE_Tab && chartype <= FX_CHARTYPE_Control); |
| 1357 if (wForm == 0xFEFF) { | 1352 if (wForm == 0xFEFF) { |
| 1358 bEmptyChar = TRUE; | 1353 bEmptyChar = TRUE; |
| 1359 } | 1354 } |
| 1360 int32_t iForms = bLam ? 3 : 1; | 1355 int32_t iForms = bLam ? 3 : 1; |
| 1361 iCount += (bEmptyChar && bSkipSpace) ? 0 : iForms; | 1356 iCount += (bEmptyChar && bSkipSpace) ? 0 : iForms; |
| 1362 if (pCharPos == NULL) { | 1357 if (!pCharPos) { |
| 1363 if (iWidth > 0) { | 1358 if (iWidth > 0) { |
| 1364 wPrev = wch; | 1359 wPrev = wch; |
| 1365 } | 1360 } |
| 1366 wLast = wch; | 1361 wLast = wch; |
| 1367 continue; | 1362 continue; |
| 1368 } | 1363 } |
| 1369 int32_t iCharWidth = iWidth; | 1364 int32_t iCharWidth = iWidth; |
| 1370 if (iCharWidth < 0) { | 1365 if (iCharWidth < 0) { |
| 1371 iCharWidth = -iCharWidth; | 1366 iCharWidth = -iCharWidth; |
| 1372 } | 1367 } |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1549 if (iWidth > 0) { | 1544 if (iWidth > 0) { |
| 1550 wPrev = (FX_WCHAR)formChars[0].wch; | 1545 wPrev = (FX_WCHAR)formChars[0].wch; |
| 1551 } | 1546 } |
| 1552 wLast = wch; | 1547 wLast = wch; |
| 1553 } | 1548 } |
| 1554 return iCount; | 1549 return iCount; |
| 1555 } | 1550 } |
| 1556 int32_t CFX_TxtBreak::GetCharRects(const FX_TXTRUN* pTxtRun, | 1551 int32_t CFX_TxtBreak::GetCharRects(const FX_TXTRUN* pTxtRun, |
| 1557 CFX_RectFArray& rtArray, | 1552 CFX_RectFArray& rtArray, |
| 1558 FX_BOOL bCharBBox) const { | 1553 FX_BOOL bCharBBox) const { |
| 1559 if (pTxtRun == NULL || pTxtRun->iLength < 1) { | 1554 if (!pTxtRun || pTxtRun->iLength < 1) { |
| 1560 return 0; | 1555 return 0; |
| 1561 } | 1556 } |
| 1562 IFX_TxtAccess* pAccess = pTxtRun->pAccess; | 1557 IFX_TxtAccess* pAccess = pTxtRun->pAccess; |
| 1563 const FDE_TEXTEDITPIECE* pIdentity = pTxtRun->pIdentity; | 1558 const FDE_TEXTEDITPIECE* pIdentity = pTxtRun->pIdentity; |
| 1564 const FX_WCHAR* pStr = pTxtRun->wsStr.c_str(); | 1559 const FX_WCHAR* pStr = pTxtRun->wsStr.c_str(); |
| 1565 int32_t* pWidths = pTxtRun->pWidths; | 1560 int32_t* pWidths = pTxtRun->pWidths; |
| 1566 int32_t iLength = pTxtRun->iLength; | 1561 int32_t iLength = pTxtRun->iLength; |
| 1567 CFX_RectF rect(*pTxtRun->pRect); | 1562 CFX_RectF rect(*pTxtRun->pRect); |
| 1568 FX_BOOL bRTLPiece = | 1563 FX_BOOL bRTLPiece = |
| 1569 (pTxtRun->dwCharStyles & FX_TXTCHARSTYLE_OddBidiLevel) != 0; | 1564 (pTxtRun->dwCharStyles & FX_TXTCHARSTYLE_OddBidiLevel) != 0; |
| 1570 FX_FLOAT fFontSize = pTxtRun->fFontSize; | 1565 FX_FLOAT fFontSize = pTxtRun->fFontSize; |
| 1571 int32_t iFontSize = FXSYS_round(fFontSize * 20.0f); | 1566 int32_t iFontSize = FXSYS_round(fFontSize * 20.0f); |
| 1572 FX_FLOAT fScale = fFontSize / 1000.0f; | 1567 FX_FLOAT fScale = fFontSize / 1000.0f; |
| 1573 CFGAS_GEFont* pFont = pTxtRun->pFont; | 1568 CFGAS_GEFont* pFont = pTxtRun->pFont; |
| 1574 if (pFont == NULL) { | 1569 if (!pFont) { |
| 1575 bCharBBox = FALSE; | 1570 bCharBBox = FALSE; |
| 1576 } | 1571 } |
| 1577 CFX_Rect bbox; | 1572 CFX_Rect bbox; |
| 1578 bbox.Set(0, 0, 0, 0); | 1573 bbox.Set(0, 0, 0, 0); |
| 1579 if (bCharBBox) { | 1574 if (bCharBBox) { |
| 1580 bCharBBox = pFont->GetBBox(bbox); | 1575 bCharBBox = pFont->GetBBox(bbox); |
| 1581 } | 1576 } |
| 1582 FX_FLOAT fLeft = std::max(0.0f, bbox.left * fScale); | 1577 FX_FLOAT fLeft = std::max(0.0f, bbox.left * fScale); |
| 1583 FX_FLOAT fHeight = FXSYS_fabs(bbox.height * fScale); | 1578 FX_FLOAT fHeight = FXSYS_fabs(bbox.height * fScale); |
| 1584 rtArray.RemoveAll(); | 1579 rtArray.RemoveAll(); |
| 1585 rtArray.SetSize(iLength); | 1580 rtArray.SetSize(iLength); |
| 1586 FX_BOOL bVertical = | 1581 FX_BOOL bVertical = |
| 1587 (pTxtRun->dwStyles & FX_TXTLAYOUTSTYLE_VerticalLayout) != 0; | 1582 (pTxtRun->dwStyles & FX_TXTLAYOUTSTYLE_VerticalLayout) != 0; |
| 1588 FX_BOOL bSingleLine = (pTxtRun->dwStyles & FX_TXTLAYOUTSTYLE_SingleLine) != 0; | 1583 FX_BOOL bSingleLine = (pTxtRun->dwStyles & FX_TXTLAYOUTSTYLE_SingleLine) != 0; |
| 1589 FX_BOOL bCombText = (pTxtRun->dwStyles & FX_TXTLAYOUTSTYLE_CombText) != 0; | 1584 FX_BOOL bCombText = (pTxtRun->dwStyles & FX_TXTLAYOUTSTYLE_CombText) != 0; |
| 1590 FX_WCHAR wch, wLineBreakChar = pTxtRun->wLineBreakChar; | 1585 FX_WCHAR wch, wLineBreakChar = pTxtRun->wLineBreakChar; |
| 1591 int32_t iCharSize; | 1586 int32_t iCharSize; |
| 1592 FX_FLOAT fCharSize, fStart; | 1587 FX_FLOAT fCharSize, fStart; |
| 1593 if (bVertical) { | 1588 if (bVertical) { |
| 1594 fStart = bRTLPiece ? rect.bottom() : rect.top; | 1589 fStart = bRTLPiece ? rect.bottom() : rect.top; |
| 1595 } else { | 1590 } else { |
| 1596 fStart = bRTLPiece ? rect.right() : rect.left; | 1591 fStart = bRTLPiece ? rect.right() : rect.left; |
| 1597 } | 1592 } |
| 1598 for (int32_t i = 0; i < iLength; i++) { | 1593 for (int32_t i = 0; i < iLength; i++) { |
| 1599 if (pAccess != NULL) { | 1594 if (pAccess) { |
| 1600 wch = pAccess->GetChar(pIdentity, i); | 1595 wch = pAccess->GetChar(pIdentity, i); |
| 1601 iCharSize = pAccess->GetWidth(pIdentity, i); | 1596 iCharSize = pAccess->GetWidth(pIdentity, i); |
| 1602 } else { | 1597 } else { |
| 1603 wch = *pStr++; | 1598 wch = *pStr++; |
| 1604 iCharSize = *pWidths++; | 1599 iCharSize = *pWidths++; |
| 1605 } | 1600 } |
| 1606 fCharSize = (FX_FLOAT)iCharSize / 20000.0f; | 1601 fCharSize = (FX_FLOAT)iCharSize / 20000.0f; |
| 1607 FX_BOOL bRet = (!bSingleLine && FX_IsCtrlCode(wch)); | 1602 FX_BOOL bRet = (!bSingleLine && FX_IsCtrlCode(wch)); |
| 1608 if (!(wch == L'\v' || wch == L'\f' || wch == 0x2028 || wch == 0x2029 || | 1603 if (!(wch == L'\v' || wch == L'\f' || wch == 0x2028 || wch == 0x2029 || |
| 1609 (wLineBreakChar != 0xFEFF && wch == wLineBreakChar))) { | 1604 (wLineBreakChar != 0xFEFF && wch == wLineBreakChar))) { |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1689 : m_dwStatus(FX_TXTBREAK_PieceBreak), | 1684 : m_dwStatus(FX_TXTBREAK_PieceBreak), |
| 1690 m_iStartPos(0), | 1685 m_iStartPos(0), |
| 1691 m_iWidth(-1), | 1686 m_iWidth(-1), |
| 1692 m_iStartChar(0), | 1687 m_iStartChar(0), |
| 1693 m_iChars(0), | 1688 m_iChars(0), |
| 1694 m_iBidiLevel(0), | 1689 m_iBidiLevel(0), |
| 1695 m_iBidiPos(0), | 1690 m_iBidiPos(0), |
| 1696 m_iHorizontalScale(100), | 1691 m_iHorizontalScale(100), |
| 1697 m_iVerticalScale(100), | 1692 m_iVerticalScale(100), |
| 1698 m_dwCharStyles(0), | 1693 m_dwCharStyles(0), |
| 1699 m_pChars(NULL), | 1694 m_pChars(nullptr), |
| 1700 m_pUserData(NULL) {} | 1695 m_pUserData(nullptr) {} |
| 1701 | 1696 |
| 1702 CFX_TxtLine::CFX_TxtLine(int32_t iBlockSize) | 1697 CFX_TxtLine::CFX_TxtLine(int32_t iBlockSize) |
| 1703 : m_iStart(0), m_iWidth(0), m_iArabicChars(0) { | 1698 : m_iStart(0), m_iWidth(0), m_iArabicChars(0) { |
| 1704 m_pLineChars = new CFX_TxtCharArray; | 1699 m_pLineChars = new CFX_TxtCharArray; |
| 1705 m_pLinePieces = new CFX_TxtPieceArray(16); | 1700 m_pLinePieces = new CFX_TxtPieceArray(16); |
| 1706 } | 1701 } |
| 1707 | 1702 |
| 1708 CFX_TxtLine::~CFX_TxtLine() { | 1703 CFX_TxtLine::~CFX_TxtLine() { |
| 1709 RemoveAll(); | 1704 RemoveAll(); |
| 1710 delete m_pLineChars; | 1705 delete m_pLineChars; |
| 1711 delete m_pLinePieces; | 1706 delete m_pLinePieces; |
| 1712 } | 1707 } |
| OLD | NEW |