Chromium Code Reviews| 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 } |
| 288 if (m_iReady == 1) { | 288 if (m_iReady == 1) { |
| 289 return m_pTxtLine1; | 289 return m_pTxtLine1; |
| 290 } else if (m_iReady == 2) { | 290 } else if (m_iReady == 2) { |
|
Lei Zhang
2016/06/23 17:56:00
get rid of the else after returns
dsinclair
2016/06/23 18:46:53
Done.
| |
| 291 return m_pTxtLine2; | 291 return m_pTxtLine2; |
| 292 } else { | 292 } else { |
| 293 return NULL; | 293 return nullptr; |
| 294 } | 294 } |
| 295 } | 295 } |
| 296 CFX_TxtPieceArray* CFX_TxtBreak::GetTxtPieces(FX_BOOL bReady) const { | 296 CFX_TxtPieceArray* CFX_TxtBreak::GetTxtPieces(FX_BOOL bReady) const { |
| 297 CFX_TxtLine* pTxtLine = GetTxtLine(bReady); | 297 CFX_TxtLine* pTxtLine = GetTxtLine(bReady); |
| 298 if (pTxtLine == NULL) { | 298 if (!pTxtLine) { |
| 299 return NULL; | 299 return nullptr; |
| 300 } | 300 } |
| 301 return pTxtLine->m_pLinePieces; | 301 return pTxtLine->m_pLinePieces; |
| 302 } | 302 } |
| 303 inline FX_CHARTYPE CFX_TxtBreak::GetUnifiedCharType( | 303 inline FX_CHARTYPE CFX_TxtBreak::GetUnifiedCharType( |
| 304 FX_CHARTYPE chartype) const { | 304 FX_CHARTYPE chartype) const { |
| 305 return chartype >= FX_CHARTYPE_ArabicAlef ? FX_CHARTYPE_Arabic : chartype; | 305 return chartype >= FX_CHARTYPE_ArabicAlef ? FX_CHARTYPE_Arabic : chartype; |
| 306 } | 306 } |
| 307 void CFX_TxtBreak::ResetArabicContext() { | 307 void CFX_TxtBreak::ResetArabicContext() { |
| 308 if (m_bArabicContext) { | 308 if (m_bArabicContext) { |
| 309 m_bCurRTL = m_iCurArabicContext > 1; | 309 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 | 343 : ((iBidiCls == FX_BIDICLASS_L || iBidiCls == FX_BIDICLASS_S) ? 0 |
| 344 : 1); | 344 : 1); |
| 345 if (iArabicContext != m_iArabicContext && iArabicContext != 1) { | 345 if (iArabicContext != m_iArabicContext && iArabicContext != 1) { |
| 346 m_iArabicContext = iArabicContext; | 346 m_iArabicContext = iArabicContext; |
| 347 if (m_iCurArabicContext == 1) { | 347 if (m_iCurArabicContext == 1) { |
| 348 m_iCurArabicContext = iArabicContext; | 348 m_iCurArabicContext = iArabicContext; |
| 349 } | 349 } |
| 350 ResetArabicContext(); | 350 ResetArabicContext(); |
| 351 if (!m_bPagination) { | 351 if (!m_bPagination) { |
| 352 CFX_TxtChar* pLastChar = GetLastChar(1, FALSE); | 352 CFX_TxtChar* pLastChar = GetLastChar(1, FALSE); |
| 353 if (pLastChar != NULL && pLastChar->m_dwStatus < 1) { | 353 if (pLastChar && pLastChar->m_dwStatus < 1) { |
| 354 pLastChar->m_dwStatus = FX_TXTBREAK_PieceBreak; | 354 pLastChar->m_dwStatus = FX_TXTBREAK_PieceBreak; |
| 355 } | 355 } |
| 356 } | 356 } |
| 357 } | 357 } |
| 358 } | 358 } |
| 359 pCurChar->m_dwCharStyles = m_dwContextCharStyles; | 359 pCurChar->m_dwCharStyles = m_dwContextCharStyles; |
| 360 } | 360 } |
| 361 uint32_t CFX_TxtBreak::AppendChar_Combination(CFX_TxtChar* pCurChar, | 361 uint32_t CFX_TxtBreak::AppendChar_Combination(CFX_TxtChar* pCurChar, |
| 362 int32_t iRotation) { | 362 int32_t iRotation) { |
| 363 FX_WCHAR wch = pCurChar->m_wCharCode; | 363 FX_WCHAR wch = pCurChar->m_wCharCode; |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 461 } | 461 } |
| 462 } | 462 } |
| 463 return dwRet; | 463 return dwRet; |
| 464 } | 464 } |
| 465 uint32_t CFX_TxtBreak::AppendChar_Arabic(CFX_TxtChar* pCurChar, | 465 uint32_t CFX_TxtBreak::AppendChar_Arabic(CFX_TxtChar* pCurChar, |
| 466 int32_t iRotation) { | 466 int32_t iRotation) { |
| 467 FX_CHARTYPE chartype = pCurChar->GetCharType(); | 467 FX_CHARTYPE chartype = pCurChar->GetCharType(); |
| 468 int32_t& iLineWidth = m_pCurLine->m_iWidth; | 468 int32_t& iLineWidth = m_pCurLine->m_iWidth; |
| 469 FX_WCHAR wForm; | 469 FX_WCHAR wForm; |
| 470 int32_t iCharWidth = 0; | 470 int32_t iCharWidth = 0; |
| 471 CFX_Char* pLastChar = NULL; | 471 CFX_Char* pLastChar = nullptr; |
| 472 FX_BOOL bAlef = FALSE; | 472 FX_BOOL bAlef = FALSE; |
| 473 if (!m_bCombText && m_eCharType >= FX_CHARTYPE_ArabicAlef && | 473 if (!m_bCombText && m_eCharType >= FX_CHARTYPE_ArabicAlef && |
| 474 m_eCharType <= FX_CHARTYPE_ArabicDistortion) { | 474 m_eCharType <= FX_CHARTYPE_ArabicDistortion) { |
| 475 pLastChar = GetLastChar(1); | 475 pLastChar = GetLastChar(1); |
| 476 if (pLastChar != NULL) { | 476 if (pLastChar) { |
| 477 iCharWidth = pLastChar->m_iCharWidth; | 477 iCharWidth = pLastChar->m_iCharWidth; |
| 478 if (iCharWidth > 0) { | 478 if (iCharWidth > 0) { |
| 479 iLineWidth -= iCharWidth; | 479 iLineWidth -= iCharWidth; |
| 480 } | 480 } |
| 481 CFX_Char* pPrevChar = GetLastChar(2); | 481 CFX_Char* pPrevChar = GetLastChar(2); |
| 482 wForm = pdfium::arabic::GetFormChar(pLastChar, pPrevChar, pCurChar); | 482 wForm = pdfium::arabic::GetFormChar(pLastChar, pPrevChar, pCurChar); |
| 483 bAlef = (wForm == 0xFEFF && | 483 bAlef = (wForm == 0xFEFF && |
| 484 pLastChar->GetCharType() == FX_CHARTYPE_ArabicAlef); | 484 pLastChar->GetCharType() == FX_CHARTYPE_ArabicAlef); |
| 485 int32_t iLastRotation = pLastChar->m_nRotation + m_iLineRotation; | 485 int32_t iLastRotation = pLastChar->m_nRotation + m_iLineRotation; |
| 486 if (m_bVertical && (pLastChar->m_dwCharProps & 0x8000) != 0) { | 486 if (m_bVertical && (pLastChar->m_dwCharProps & 0x8000) != 0) { |
| 487 iLastRotation++; | 487 iLastRotation++; |
| 488 } | 488 } |
| 489 if (m_bVertical != FX_IsOdd(iLastRotation)) { | 489 if (m_bVertical != FX_IsOdd(iLastRotation)) { |
| 490 iCharWidth = 1000; | 490 iCharWidth = 1000; |
| 491 } else { | 491 } else { |
| 492 m_pFont->GetCharWidth(wForm, iCharWidth, FALSE); | 492 m_pFont->GetCharWidth(wForm, iCharWidth, FALSE); |
| 493 } | 493 } |
| 494 if (wForm == 0xFEFF) { | 494 if (wForm == 0xFEFF) { |
| 495 iCharWidth = m_iDefChar; | 495 iCharWidth = m_iDefChar; |
| 496 } | 496 } |
| 497 iCharWidth *= m_iFontSize; | 497 iCharWidth *= m_iFontSize; |
| 498 iCharWidth = iCharWidth * m_iHorScale / 100; | 498 iCharWidth = iCharWidth * m_iHorScale / 100; |
| 499 pLastChar->m_iCharWidth = iCharWidth; | 499 pLastChar->m_iCharWidth = iCharWidth; |
| 500 iLineWidth += iCharWidth; | 500 iLineWidth += iCharWidth; |
| 501 iCharWidth = 0; | 501 iCharWidth = 0; |
| 502 } | 502 } |
| 503 } | 503 } |
| 504 m_eCharType = chartype; | 504 m_eCharType = chartype; |
| 505 wForm = pdfium::arabic::GetFormChar(pCurChar, bAlef ? NULL : pLastChar, NULL); | 505 wForm = pdfium::arabic::GetFormChar(pCurChar, bAlef ? nullptr : pLastChar, |
| 506 nullptr); | |
| 506 if (m_bCombText) { | 507 if (m_bCombText) { |
| 507 iCharWidth = m_iCombWidth; | 508 iCharWidth = m_iCombWidth; |
| 508 } else { | 509 } else { |
| 509 if (m_bVertical != FX_IsOdd(iRotation)) { | 510 if (m_bVertical != FX_IsOdd(iRotation)) { |
| 510 iCharWidth = 1000; | 511 iCharWidth = 1000; |
| 511 } else { | 512 } else { |
| 512 m_pFont->GetCharWidth(wForm, iCharWidth, FALSE); | 513 m_pFont->GetCharWidth(wForm, iCharWidth, FALSE); |
| 513 } | 514 } |
| 514 if (wForm == 0xFEFF) { | 515 if (wForm == 0xFEFF) { |
| 515 iCharWidth = m_iDefChar; | 516 iCharWidth = m_iDefChar; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 578 pCurChar->m_dwCharProps = dwProps; | 579 pCurChar->m_dwCharProps = dwProps; |
| 579 pCurChar->m_dwCharStyles = 0; | 580 pCurChar->m_dwCharStyles = 0; |
| 580 pCurChar->m_iCharWidth = 0; | 581 pCurChar->m_iCharWidth = 0; |
| 581 pCurChar->m_iHorizontalScale = m_iHorScale; | 582 pCurChar->m_iHorizontalScale = m_iHorScale; |
| 582 pCurChar->m_iVertialScale = m_iVerScale; | 583 pCurChar->m_iVertialScale = m_iVerScale; |
| 583 pCurChar->m_dwStatus = 0; | 584 pCurChar->m_dwStatus = 0; |
| 584 pCurChar->m_iBidiClass = 0; | 585 pCurChar->m_iBidiClass = 0; |
| 585 pCurChar->m_iBidiLevel = 0; | 586 pCurChar->m_iBidiLevel = 0; |
| 586 pCurChar->m_iBidiPos = 0; | 587 pCurChar->m_iBidiPos = 0; |
| 587 pCurChar->m_iBidiOrder = 0; | 588 pCurChar->m_iBidiOrder = 0; |
| 588 pCurChar->m_pUserData = NULL; | 589 pCurChar->m_pUserData = nullptr; |
| 589 AppendChar_PageLoad(pCurChar, dwProps); | 590 AppendChar_PageLoad(pCurChar, dwProps); |
| 590 uint32_t dwRet1 = FX_TXTBREAK_None; | 591 uint32_t dwRet1 = FX_TXTBREAK_None; |
| 591 if (chartype != FX_CHARTYPE_Combination && | 592 if (chartype != FX_CHARTYPE_Combination && |
| 592 GetUnifiedCharType(m_eCharType) != GetUnifiedCharType(chartype)) { | 593 GetUnifiedCharType(m_eCharType) != GetUnifiedCharType(chartype)) { |
| 593 if (m_eCharType != FX_CHARTYPE_Unknown && | 594 if (m_eCharType != FX_CHARTYPE_Unknown && |
| 594 m_pCurLine->m_iWidth > m_iLineWidth + m_iTolerance && !m_bSingleLine) { | 595 m_pCurLine->m_iWidth > m_iLineWidth + m_iTolerance && !m_bSingleLine) { |
| 595 if (m_eCharType != FX_CHARTYPE_Space || chartype != FX_CHARTYPE_Control) { | 596 if (m_eCharType != FX_CHARTYPE_Space || chartype != FX_CHARTYPE_Control) { |
| 596 dwRet1 = EndBreak(FX_TXTBREAK_LineBreak); | 597 dwRet1 = EndBreak(FX_TXTBREAK_LineBreak); |
| 597 int32_t iCount = m_pCurLine->CountChars(); | 598 int32_t iCount = m_pCurLine->CountChars(); |
| 598 if (iCount > 0) { | 599 if (iCount > 0) { |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 623 pCur = m_pCurLine->GetCharPtr(1); | 624 pCur = m_pCurLine->GetCharPtr(1); |
| 624 FX_WCHAR wch, wForm; | 625 FX_WCHAR wch, wForm; |
| 625 FX_BOOL bNextNum; | 626 FX_BOOL bNextNum; |
| 626 int32_t i = 1, iCharWidth, iRotation; | 627 int32_t i = 1, iCharWidth, iRotation; |
| 627 do { | 628 do { |
| 628 i++; | 629 i++; |
| 629 if (i < iCount) { | 630 if (i < iCount) { |
| 630 pNext = m_pCurLine->GetCharPtr(i); | 631 pNext = m_pCurLine->GetCharPtr(i); |
| 631 bNextNum = (pNext->m_dwCharStyles & FX_TXTCHARSTYLE_ArabicIndic) != 0; | 632 bNextNum = (pNext->m_dwCharStyles & FX_TXTCHARSTYLE_ArabicIndic) != 0; |
| 632 } else { | 633 } else { |
| 633 pNext = NULL; | 634 pNext = nullptr; |
| 634 bNextNum = FALSE; | 635 bNextNum = FALSE; |
| 635 } | 636 } |
| 636 wch = pCur->m_wCharCode; | 637 wch = pCur->m_wCharCode; |
| 637 if (wch == L'.') { | 638 if (wch == L'.') { |
| 638 if (bPrevNum && bNextNum) { | 639 if (bPrevNum && bNextNum) { |
| 639 iRotation = m_iRotation; | 640 iRotation = m_iRotation; |
| 640 if (m_bVertical && (pCur->m_dwCharProps & 0x8000) != 0) { | 641 if (m_bVertical && (pCur->m_dwCharProps & 0x8000) != 0) { |
| 641 iRotation = ((iRotation + 1) & 0x03); | 642 iRotation = ((iRotation + 1) & 0x03); |
| 642 } | 643 } |
| 643 wForm = wch == L'.' ? 0x066B : 0x066C; | 644 wForm = wch == L'.' ? 0x066B : 0x066C; |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 916 if (iCount > 0) { | 917 if (iCount > 0) { |
| 917 CFX_TxtPiece* pLastPiece = pCurPieces->GetPtrAt(--iCount); | 918 CFX_TxtPiece* pLastPiece = pCurPieces->GetPtrAt(--iCount); |
| 918 if (dwStatus > FX_TXTBREAK_PieceBreak) { | 919 if (dwStatus > FX_TXTBREAK_PieceBreak) { |
| 919 pLastPiece->m_dwStatus = dwStatus; | 920 pLastPiece->m_dwStatus = dwStatus; |
| 920 } else { | 921 } else { |
| 921 dwStatus = pLastPiece->m_dwStatus; | 922 dwStatus = pLastPiece->m_dwStatus; |
| 922 } | 923 } |
| 923 return dwStatus; | 924 return dwStatus; |
| 924 } else { | 925 } else { |
| 925 CFX_TxtLine* pLastLine = GetTxtLine(TRUE); | 926 CFX_TxtLine* pLastLine = GetTxtLine(TRUE); |
| 926 if (pLastLine != NULL) { | 927 if (pLastLine) { |
| 927 pCurPieces = pLastLine->m_pLinePieces; | 928 pCurPieces = pLastLine->m_pLinePieces; |
| 928 iCount = pCurPieces->GetSize(); | 929 iCount = pCurPieces->GetSize(); |
| 929 if (iCount-- > 0) { | 930 if (iCount-- > 0) { |
| 930 CFX_TxtPiece* pLastPiece = pCurPieces->GetPtrAt(iCount); | 931 CFX_TxtPiece* pLastPiece = pCurPieces->GetPtrAt(iCount); |
| 931 if (dwStatus > FX_TXTBREAK_PieceBreak) { | 932 if (dwStatus > FX_TXTBREAK_PieceBreak) { |
| 932 pLastPiece->m_dwStatus = dwStatus; | 933 pLastPiece->m_dwStatus = dwStatus; |
| 933 } else { | 934 } else { |
| 934 dwStatus = pLastPiece->m_dwStatus; | 935 dwStatus = pLastPiece->m_dwStatus; |
| 935 } | 936 } |
| 936 return dwStatus; | 937 return dwStatus; |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1067 } | 1068 } |
| 1068 if (iLast > -1) { | 1069 if (iLast > -1) { |
| 1069 iEndPos = iLastPos; | 1070 iEndPos = iLastPos; |
| 1070 return iLast; | 1071 return iLast; |
| 1071 } | 1072 } |
| 1072 return 0; | 1073 return 0; |
| 1073 } | 1074 } |
| 1074 void CFX_TxtBreak::SplitTextLine(CFX_TxtLine* pCurLine, | 1075 void CFX_TxtBreak::SplitTextLine(CFX_TxtLine* pCurLine, |
| 1075 CFX_TxtLine* pNextLine, | 1076 CFX_TxtLine* pNextLine, |
| 1076 FX_BOOL bAllChars) { | 1077 FX_BOOL bAllChars) { |
| 1077 ASSERT(pCurLine != NULL && pNextLine != NULL); | 1078 ASSERT(pCurLine && pNextLine); |
| 1078 int32_t iCount = pCurLine->CountChars(); | 1079 int32_t iCount = pCurLine->CountChars(); |
| 1079 if (iCount < 2) { | 1080 if (iCount < 2) { |
| 1080 return; | 1081 return; |
| 1081 } | 1082 } |
| 1082 int32_t iEndPos = pCurLine->m_iWidth; | 1083 int32_t iEndPos = pCurLine->m_iWidth; |
| 1083 CFX_TxtCharArray& curChars = *pCurLine->m_pLineChars; | 1084 CFX_TxtCharArray& curChars = *pCurLine->m_pLineChars; |
| 1084 int32_t iCharPos = GetBreakPos(curChars, iEndPos, bAllChars, FALSE); | 1085 int32_t iCharPos = GetBreakPos(curChars, iEndPos, bAllChars, FALSE); |
| 1085 if (iCharPos < 0) { | 1086 if (iCharPos < 0) { |
| 1086 iCharPos = 0; | 1087 iCharPos = 0; |
| 1087 } | 1088 } |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 1117 } | 1118 } |
| 1118 if (m_bPagination) { | 1119 if (m_bPagination) { |
| 1119 continue; | 1120 continue; |
| 1120 } | 1121 } |
| 1121 pTC->m_dwStatus = 0; | 1122 pTC->m_dwStatus = 0; |
| 1122 } | 1123 } |
| 1123 pNextLine->m_iWidth = iWidth; | 1124 pNextLine->m_iWidth = iWidth; |
| 1124 } | 1125 } |
| 1125 int32_t CFX_TxtBreak::CountBreakChars() const { | 1126 int32_t CFX_TxtBreak::CountBreakChars() const { |
| 1126 CFX_TxtLine* pTxtLine = GetTxtLine(TRUE); | 1127 CFX_TxtLine* pTxtLine = GetTxtLine(TRUE); |
| 1127 return pTxtLine == NULL ? 0 : pTxtLine->CountChars(); | 1128 return !pTxtLine ? 0 : pTxtLine->CountChars(); |
|
Lei Zhang
2016/06/23 17:56:00
flip
dsinclair
2016/06/23 18:46:53
Done.
| |
| 1128 } | 1129 } |
| 1129 int32_t CFX_TxtBreak::CountBreakPieces() const { | 1130 int32_t CFX_TxtBreak::CountBreakPieces() const { |
| 1130 CFX_TxtPieceArray* pTxtPieces = GetTxtPieces(TRUE); | 1131 CFX_TxtPieceArray* pTxtPieces = GetTxtPieces(TRUE); |
| 1131 if (pTxtPieces == NULL) { | 1132 if (!pTxtPieces) { |
|
Lei Zhang
2016/06/23 17:56:00
ternary
dsinclair
2016/06/23 18:46:53
Done.
| |
| 1132 return 0; | 1133 return 0; |
| 1133 } | 1134 } |
| 1134 return pTxtPieces->GetSize(); | 1135 return pTxtPieces->GetSize(); |
| 1135 } | 1136 } |
| 1136 const CFX_TxtPiece* CFX_TxtBreak::GetBreakPiece(int32_t index) const { | 1137 const CFX_TxtPiece* CFX_TxtBreak::GetBreakPiece(int32_t index) const { |
| 1137 CFX_TxtPieceArray* pTxtPieces = GetTxtPieces(TRUE); | 1138 CFX_TxtPieceArray* pTxtPieces = GetTxtPieces(TRUE); |
| 1138 if (pTxtPieces == NULL) { | 1139 if (!pTxtPieces) { |
| 1139 return NULL; | 1140 return nullptr; |
| 1140 } | 1141 } |
| 1141 if (index < 0 || index >= pTxtPieces->GetSize()) { | 1142 if (index < 0 || index >= pTxtPieces->GetSize()) { |
| 1142 return NULL; | 1143 return nullptr; |
| 1143 } | 1144 } |
| 1144 return pTxtPieces->GetPtrAt(index); | 1145 return pTxtPieces->GetPtrAt(index); |
| 1145 } | 1146 } |
| 1146 void CFX_TxtBreak::ClearBreakPieces() { | 1147 void CFX_TxtBreak::ClearBreakPieces() { |
| 1147 CFX_TxtLine* pTxtLine = GetTxtLine(TRUE); | 1148 CFX_TxtLine* pTxtLine = GetTxtLine(TRUE); |
| 1148 if (pTxtLine != NULL) { | 1149 if (pTxtLine) { |
| 1149 pTxtLine->RemoveAll(TRUE); | 1150 pTxtLine->RemoveAll(TRUE); |
| 1150 } | 1151 } |
| 1151 m_iReady = 0; | 1152 m_iReady = 0; |
| 1152 } | 1153 } |
| 1153 void CFX_TxtBreak::Reset() { | 1154 void CFX_TxtBreak::Reset() { |
| 1154 m_eCharType = FX_CHARTYPE_Unknown; | 1155 m_eCharType = FX_CHARTYPE_Unknown; |
| 1155 m_iArabicContext = m_iCurArabicContext = 1; | 1156 m_iArabicContext = m_iCurArabicContext = 1; |
| 1156 ResetArabicContext(); | 1157 ResetArabicContext(); |
| 1157 m_pTxtLine1->RemoveAll(TRUE); | 1158 m_pTxtLine1->RemoveAll(TRUE); |
| 1158 m_pTxtLine2->RemoveAll(TRUE); | 1159 m_pTxtLine2->RemoveAll(TRUE); |
| 1159 } | 1160 } |
| 1160 | 1161 |
| 1161 struct FX_FORMCHAR { | 1162 struct FX_FORMCHAR { |
| 1162 uint16_t wch; | 1163 uint16_t wch; |
| 1163 uint16_t wForm; | 1164 uint16_t wForm; |
| 1164 int32_t iWidth; | 1165 int32_t iWidth; |
| 1165 }; | 1166 }; |
| 1166 | 1167 |
| 1167 int32_t CFX_TxtBreak::GetDisplayPos(const FX_TXTRUN* pTxtRun, | 1168 int32_t CFX_TxtBreak::GetDisplayPos(const FX_TXTRUN* pTxtRun, |
| 1168 FXTEXT_CHARPOS* pCharPos, | 1169 FXTEXT_CHARPOS* pCharPos, |
| 1169 FX_BOOL bCharCode, | 1170 FX_BOOL bCharCode, |
| 1170 CFX_WideString* pWSForms, | 1171 CFX_WideString* pWSForms, |
| 1171 FX_AdjustCharDisplayPos pAdjustPos) const { | 1172 FX_AdjustCharDisplayPos pAdjustPos) const { |
| 1172 if (pTxtRun == NULL || pTxtRun->iLength < 1) { | 1173 if (!pTxtRun || pTxtRun->iLength < 1) { |
| 1173 return 0; | 1174 return 0; |
| 1174 } | 1175 } |
| 1175 IFX_TxtAccess* pAccess = pTxtRun->pAccess; | 1176 IFX_TxtAccess* pAccess = pTxtRun->pAccess; |
| 1176 const FDE_TEXTEDITPIECE* pIdentity = pTxtRun->pIdentity; | 1177 const FDE_TEXTEDITPIECE* pIdentity = pTxtRun->pIdentity; |
| 1177 const FX_WCHAR* pStr = pTxtRun->wsStr.c_str(); | 1178 const FX_WCHAR* pStr = pTxtRun->wsStr.c_str(); |
| 1178 int32_t* pWidths = pTxtRun->pWidths; | 1179 int32_t* pWidths = pTxtRun->pWidths; |
| 1179 int32_t iLength = pTxtRun->iLength - 1; | 1180 int32_t iLength = pTxtRun->iLength - 1; |
| 1180 CFGAS_GEFont* pFont = pTxtRun->pFont; | 1181 CFGAS_GEFont* pFont = pTxtRun->pFont; |
| 1181 uint32_t dwStyles = pTxtRun->dwStyles; | 1182 uint32_t dwStyles = pTxtRun->dwStyles; |
| 1182 CFX_RectF rtText(*pTxtRun->pRect); | 1183 CFX_RectF rtText(*pTxtRun->pRect); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1219 int32_t iNext = 0; | 1220 int32_t iNext = 0; |
| 1220 FX_WCHAR wPrev = 0xFEFF; | 1221 FX_WCHAR wPrev = 0xFEFF; |
| 1221 FX_WCHAR wNext = 0xFEFF; | 1222 FX_WCHAR wNext = 0xFEFF; |
| 1222 FX_WCHAR wForm = 0xFEFF; | 1223 FX_WCHAR wForm = 0xFEFF; |
| 1223 FX_WCHAR wLast = 0xFEFF; | 1224 FX_WCHAR wLast = 0xFEFF; |
| 1224 FX_BOOL bShadda = FALSE; | 1225 FX_BOOL bShadda = FALSE; |
| 1225 FX_BOOL bLam = FALSE; | 1226 FX_BOOL bLam = FALSE; |
| 1226 for (int32_t i = 0; i <= iLength; i++) { | 1227 for (int32_t i = 0; i <= iLength; i++) { |
| 1227 int32_t iWidth; | 1228 int32_t iWidth; |
| 1228 FX_WCHAR wch; | 1229 FX_WCHAR wch; |
| 1229 if (pAccess != NULL) { | 1230 if (pAccess) { |
| 1230 wch = pAccess->GetChar(pIdentity, i); | 1231 wch = pAccess->GetChar(pIdentity, i); |
| 1231 iWidth = pAccess->GetWidth(pIdentity, i); | 1232 iWidth = pAccess->GetWidth(pIdentity, i); |
| 1232 } else { | 1233 } else { |
| 1233 wch = *pStr++; | 1234 wch = *pStr++; |
| 1234 iWidth = *pWidths++; | 1235 iWidth = *pWidths++; |
| 1235 } | 1236 } |
| 1236 uint32_t dwProps = FX_GetUnicodeProperties(wch); | 1237 uint32_t dwProps = FX_GetUnicodeProperties(wch); |
| 1237 FX_CHARTYPE chartype = GetCharTypeFromProp(dwProps); | 1238 FX_CHARTYPE chartype = GetCharTypeFromProp(dwProps); |
| 1238 if (chartype == FX_CHARTYPE_ArabicAlef && iWidth == 0) { | 1239 if (chartype == FX_CHARTYPE_ArabicAlef && iWidth == 0) { |
| 1239 wPrev = 0xFEFF; | 1240 wPrev = 0xFEFF; |
| 1240 wLast = wch; | 1241 wLast = wch; |
| 1241 continue; | 1242 continue; |
| 1242 } | 1243 } |
| 1243 if (chartype >= FX_CHARTYPE_ArabicAlef) { | 1244 if (chartype >= FX_CHARTYPE_ArabicAlef) { |
| 1244 if (i < iLength) { | 1245 if (i < iLength) { |
| 1245 if (pAccess != NULL) { | 1246 if (pAccess) { |
| 1246 iNext = i + 1; | 1247 iNext = i + 1; |
| 1247 while (iNext <= iLength) { | 1248 while (iNext <= iLength) { |
| 1248 wNext = pAccess->GetChar(pIdentity, iNext); | 1249 wNext = pAccess->GetChar(pIdentity, iNext); |
| 1249 dwProps = FX_GetUnicodeProperties(wNext); | 1250 dwProps = FX_GetUnicodeProperties(wNext); |
| 1250 if ((dwProps & FX_CHARTYPEBITSMASK) != FX_CHARTYPE_Combination) { | 1251 if ((dwProps & FX_CHARTYPEBITSMASK) != FX_CHARTYPE_Combination) { |
| 1251 break; | 1252 break; |
| 1252 } | 1253 } |
| 1253 iNext++; | 1254 iNext++; |
| 1254 } | 1255 } |
| 1255 if (iNext > iLength) { | 1256 if (iNext > iLength) { |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 1275 wForm = pdfium::arabic::GetFormChar(wch, wPrev, wNext); | 1276 wForm = pdfium::arabic::GetFormChar(wch, wPrev, wNext); |
| 1276 bLam = (wPrev == 0x0644 && wch == 0x0644 && wNext == 0x0647); | 1277 bLam = (wPrev == 0x0644 && wch == 0x0644 && wNext == 0x0647); |
| 1277 } else if (chartype == FX_CHARTYPE_Combination) { | 1278 } else if (chartype == FX_CHARTYPE_Combination) { |
| 1278 wForm = wch; | 1279 wForm = wch; |
| 1279 if (wch >= 0x064C && wch <= 0x0651) { | 1280 if (wch >= 0x064C && wch <= 0x0651) { |
| 1280 if (bShadda) { | 1281 if (bShadda) { |
| 1281 wForm = 0xFEFF; | 1282 wForm = 0xFEFF; |
| 1282 bShadda = FALSE; | 1283 bShadda = FALSE; |
| 1283 } else { | 1284 } else { |
| 1284 wNext = 0xFEFF; | 1285 wNext = 0xFEFF; |
| 1285 if (pAccess != NULL) { | 1286 if (pAccess) { |
| 1286 iNext = i + 1; | 1287 iNext = i + 1; |
| 1287 if (iNext <= iLength) { | 1288 if (iNext <= iLength) { |
| 1288 wNext = pAccess->GetChar(pIdentity, iNext); | 1289 wNext = pAccess->GetChar(pIdentity, iNext); |
| 1289 } | 1290 } |
| 1290 } else { | 1291 } else { |
| 1291 if (i < iLength) { | 1292 if (i < iLength) { |
| 1292 wNext = *pStr; | 1293 wNext = *pStr; |
| 1293 } | 1294 } |
| 1294 } | 1295 } |
| 1295 if (wch == 0x0651) { | 1296 if (wch == 0x0651) { |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 1309 } | 1310 } |
| 1310 } else if (chartype == FX_CHARTYPE_Numeric) { | 1311 } else if (chartype == FX_CHARTYPE_Numeric) { |
| 1311 wForm = wch; | 1312 wForm = wch; |
| 1312 if (bArabicNumber) { | 1313 if (bArabicNumber) { |
| 1313 wForm += 0x0630; | 1314 wForm += 0x0630; |
| 1314 } | 1315 } |
| 1315 } else if (wch == L'.') { | 1316 } else if (wch == L'.') { |
| 1316 wForm = wch; | 1317 wForm = wch; |
| 1317 if (bArabicNumber) { | 1318 if (bArabicNumber) { |
| 1318 wNext = 0xFEFF; | 1319 wNext = 0xFEFF; |
| 1319 if (pAccess != NULL) { | 1320 if (pAccess) { |
| 1320 iNext = i + 1; | 1321 iNext = i + 1; |
| 1321 if (iNext <= iLength) { | 1322 if (iNext <= iLength) { |
| 1322 wNext = pAccess->GetChar(pIdentity, iNext); | 1323 wNext = pAccess->GetChar(pIdentity, iNext); |
| 1323 } | 1324 } |
| 1324 } else { | 1325 } else { |
| 1325 if (i < iLength) { | 1326 if (i < iLength) { |
| 1326 wNext = *pStr; | 1327 wNext = *pStr; |
| 1327 } | 1328 } |
| 1328 } | 1329 } |
| 1329 if (wNext >= L'0' && wNext <= L'9') { | 1330 if (wNext >= L'0' && wNext <= L'9') { |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 1352 iCharRotation++; | 1353 iCharRotation++; |
| 1353 } | 1354 } |
| 1354 iCharRotation %= 4; | 1355 iCharRotation %= 4; |
| 1355 FX_BOOL bEmptyChar = | 1356 FX_BOOL bEmptyChar = |
| 1356 (chartype >= FX_CHARTYPE_Tab && chartype <= FX_CHARTYPE_Control); | 1357 (chartype >= FX_CHARTYPE_Tab && chartype <= FX_CHARTYPE_Control); |
| 1357 if (wForm == 0xFEFF) { | 1358 if (wForm == 0xFEFF) { |
| 1358 bEmptyChar = TRUE; | 1359 bEmptyChar = TRUE; |
| 1359 } | 1360 } |
| 1360 int32_t iForms = bLam ? 3 : 1; | 1361 int32_t iForms = bLam ? 3 : 1; |
| 1361 iCount += (bEmptyChar && bSkipSpace) ? 0 : iForms; | 1362 iCount += (bEmptyChar && bSkipSpace) ? 0 : iForms; |
| 1362 if (pCharPos == NULL) { | 1363 if (!pCharPos) { |
| 1363 if (iWidth > 0) { | 1364 if (iWidth > 0) { |
| 1364 wPrev = wch; | 1365 wPrev = wch; |
| 1365 } | 1366 } |
| 1366 wLast = wch; | 1367 wLast = wch; |
| 1367 continue; | 1368 continue; |
| 1368 } | 1369 } |
| 1369 int32_t iCharWidth = iWidth; | 1370 int32_t iCharWidth = iWidth; |
| 1370 if (iCharWidth < 0) { | 1371 if (iCharWidth < 0) { |
| 1371 iCharWidth = -iCharWidth; | 1372 iCharWidth = -iCharWidth; |
| 1372 } | 1373 } |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1549 if (iWidth > 0) { | 1550 if (iWidth > 0) { |
| 1550 wPrev = (FX_WCHAR)formChars[0].wch; | 1551 wPrev = (FX_WCHAR)formChars[0].wch; |
| 1551 } | 1552 } |
| 1552 wLast = wch; | 1553 wLast = wch; |
| 1553 } | 1554 } |
| 1554 return iCount; | 1555 return iCount; |
| 1555 } | 1556 } |
| 1556 int32_t CFX_TxtBreak::GetCharRects(const FX_TXTRUN* pTxtRun, | 1557 int32_t CFX_TxtBreak::GetCharRects(const FX_TXTRUN* pTxtRun, |
| 1557 CFX_RectFArray& rtArray, | 1558 CFX_RectFArray& rtArray, |
| 1558 FX_BOOL bCharBBox) const { | 1559 FX_BOOL bCharBBox) const { |
| 1559 if (pTxtRun == NULL || pTxtRun->iLength < 1) { | 1560 if (!pTxtRun || pTxtRun->iLength < 1) { |
| 1560 return 0; | 1561 return 0; |
| 1561 } | 1562 } |
| 1562 IFX_TxtAccess* pAccess = pTxtRun->pAccess; | 1563 IFX_TxtAccess* pAccess = pTxtRun->pAccess; |
| 1563 const FDE_TEXTEDITPIECE* pIdentity = pTxtRun->pIdentity; | 1564 const FDE_TEXTEDITPIECE* pIdentity = pTxtRun->pIdentity; |
| 1564 const FX_WCHAR* pStr = pTxtRun->wsStr.c_str(); | 1565 const FX_WCHAR* pStr = pTxtRun->wsStr.c_str(); |
| 1565 int32_t* pWidths = pTxtRun->pWidths; | 1566 int32_t* pWidths = pTxtRun->pWidths; |
| 1566 int32_t iLength = pTxtRun->iLength; | 1567 int32_t iLength = pTxtRun->iLength; |
| 1567 CFX_RectF rect(*pTxtRun->pRect); | 1568 CFX_RectF rect(*pTxtRun->pRect); |
| 1568 FX_BOOL bRTLPiece = | 1569 FX_BOOL bRTLPiece = |
| 1569 (pTxtRun->dwCharStyles & FX_TXTCHARSTYLE_OddBidiLevel) != 0; | 1570 (pTxtRun->dwCharStyles & FX_TXTCHARSTYLE_OddBidiLevel) != 0; |
| 1570 FX_FLOAT fFontSize = pTxtRun->fFontSize; | 1571 FX_FLOAT fFontSize = pTxtRun->fFontSize; |
| 1571 int32_t iFontSize = FXSYS_round(fFontSize * 20.0f); | 1572 int32_t iFontSize = FXSYS_round(fFontSize * 20.0f); |
| 1572 FX_FLOAT fScale = fFontSize / 1000.0f; | 1573 FX_FLOAT fScale = fFontSize / 1000.0f; |
| 1573 CFGAS_GEFont* pFont = pTxtRun->pFont; | 1574 CFGAS_GEFont* pFont = pTxtRun->pFont; |
| 1574 if (pFont == NULL) { | 1575 if (!pFont) { |
| 1575 bCharBBox = FALSE; | 1576 bCharBBox = FALSE; |
| 1576 } | 1577 } |
| 1577 CFX_Rect bbox; | 1578 CFX_Rect bbox; |
| 1578 bbox.Set(0, 0, 0, 0); | 1579 bbox.Set(0, 0, 0, 0); |
| 1579 if (bCharBBox) { | 1580 if (bCharBBox) { |
| 1580 bCharBBox = pFont->GetBBox(bbox); | 1581 bCharBBox = pFont->GetBBox(bbox); |
| 1581 } | 1582 } |
| 1582 FX_FLOAT fLeft = std::max(0.0f, bbox.left * fScale); | 1583 FX_FLOAT fLeft = std::max(0.0f, bbox.left * fScale); |
| 1583 FX_FLOAT fHeight = FXSYS_fabs(bbox.height * fScale); | 1584 FX_FLOAT fHeight = FXSYS_fabs(bbox.height * fScale); |
| 1584 rtArray.RemoveAll(); | 1585 rtArray.RemoveAll(); |
| 1585 rtArray.SetSize(iLength); | 1586 rtArray.SetSize(iLength); |
| 1586 FX_BOOL bVertical = | 1587 FX_BOOL bVertical = |
| 1587 (pTxtRun->dwStyles & FX_TXTLAYOUTSTYLE_VerticalLayout) != 0; | 1588 (pTxtRun->dwStyles & FX_TXTLAYOUTSTYLE_VerticalLayout) != 0; |
| 1588 FX_BOOL bSingleLine = (pTxtRun->dwStyles & FX_TXTLAYOUTSTYLE_SingleLine) != 0; | 1589 FX_BOOL bSingleLine = (pTxtRun->dwStyles & FX_TXTLAYOUTSTYLE_SingleLine) != 0; |
| 1589 FX_BOOL bCombText = (pTxtRun->dwStyles & FX_TXTLAYOUTSTYLE_CombText) != 0; | 1590 FX_BOOL bCombText = (pTxtRun->dwStyles & FX_TXTLAYOUTSTYLE_CombText) != 0; |
| 1590 FX_WCHAR wch, wLineBreakChar = pTxtRun->wLineBreakChar; | 1591 FX_WCHAR wch, wLineBreakChar = pTxtRun->wLineBreakChar; |
| 1591 int32_t iCharSize; | 1592 int32_t iCharSize; |
| 1592 FX_FLOAT fCharSize, fStart; | 1593 FX_FLOAT fCharSize, fStart; |
| 1593 if (bVertical) { | 1594 if (bVertical) { |
| 1594 fStart = bRTLPiece ? rect.bottom() : rect.top; | 1595 fStart = bRTLPiece ? rect.bottom() : rect.top; |
| 1595 } else { | 1596 } else { |
| 1596 fStart = bRTLPiece ? rect.right() : rect.left; | 1597 fStart = bRTLPiece ? rect.right() : rect.left; |
| 1597 } | 1598 } |
| 1598 for (int32_t i = 0; i < iLength; i++) { | 1599 for (int32_t i = 0; i < iLength; i++) { |
| 1599 if (pAccess != NULL) { | 1600 if (pAccess) { |
| 1600 wch = pAccess->GetChar(pIdentity, i); | 1601 wch = pAccess->GetChar(pIdentity, i); |
| 1601 iCharSize = pAccess->GetWidth(pIdentity, i); | 1602 iCharSize = pAccess->GetWidth(pIdentity, i); |
| 1602 } else { | 1603 } else { |
| 1603 wch = *pStr++; | 1604 wch = *pStr++; |
| 1604 iCharSize = *pWidths++; | 1605 iCharSize = *pWidths++; |
| 1605 } | 1606 } |
| 1606 fCharSize = (FX_FLOAT)iCharSize / 20000.0f; | 1607 fCharSize = (FX_FLOAT)iCharSize / 20000.0f; |
| 1607 FX_BOOL bRet = (!bSingleLine && FX_IsCtrlCode(wch)); | 1608 FX_BOOL bRet = (!bSingleLine && FX_IsCtrlCode(wch)); |
| 1608 if (!(wch == L'\v' || wch == L'\f' || wch == 0x2028 || wch == 0x2029 || | 1609 if (!(wch == L'\v' || wch == L'\f' || wch == 0x2028 || wch == 0x2029 || |
| 1609 (wLineBreakChar != 0xFEFF && wch == wLineBreakChar))) { | 1610 (wLineBreakChar != 0xFEFF && wch == wLineBreakChar))) { |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1689 : m_dwStatus(FX_TXTBREAK_PieceBreak), | 1690 : m_dwStatus(FX_TXTBREAK_PieceBreak), |
| 1690 m_iStartPos(0), | 1691 m_iStartPos(0), |
| 1691 m_iWidth(-1), | 1692 m_iWidth(-1), |
| 1692 m_iStartChar(0), | 1693 m_iStartChar(0), |
| 1693 m_iChars(0), | 1694 m_iChars(0), |
| 1694 m_iBidiLevel(0), | 1695 m_iBidiLevel(0), |
| 1695 m_iBidiPos(0), | 1696 m_iBidiPos(0), |
| 1696 m_iHorizontalScale(100), | 1697 m_iHorizontalScale(100), |
| 1697 m_iVerticalScale(100), | 1698 m_iVerticalScale(100), |
| 1698 m_dwCharStyles(0), | 1699 m_dwCharStyles(0), |
| 1699 m_pChars(NULL), | 1700 m_pChars(nullptr), |
| 1700 m_pUserData(NULL) {} | 1701 m_pUserData(nullptr) {} |
| 1701 | 1702 |
| 1702 CFX_TxtLine::CFX_TxtLine(int32_t iBlockSize) | 1703 CFX_TxtLine::CFX_TxtLine(int32_t iBlockSize) |
| 1703 : m_iStart(0), m_iWidth(0), m_iArabicChars(0) { | 1704 : m_iStart(0), m_iWidth(0), m_iArabicChars(0) { |
| 1704 m_pLineChars = new CFX_TxtCharArray; | 1705 m_pLineChars = new CFX_TxtCharArray; |
| 1705 m_pLinePieces = new CFX_TxtPieceArray(16); | 1706 m_pLinePieces = new CFX_TxtPieceArray(16); |
| 1706 } | 1707 } |
| 1707 | 1708 |
| 1708 CFX_TxtLine::~CFX_TxtLine() { | 1709 CFX_TxtLine::~CFX_TxtLine() { |
| 1709 RemoveAll(); | 1710 RemoveAll(); |
| 1710 delete m_pLineChars; | 1711 delete m_pLineChars; |
| 1711 delete m_pLinePieces; | 1712 delete m_pLinePieces; |
| 1712 } | 1713 } |
| OLD | NEW |