Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Side by Side Diff: xfa/fgas/layout/fgas_textbreak.cpp

Issue 1954593004: CFX_ArabicChar contains only static methods, no need to instantiate. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: re-namespace Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/fgas/layout/fgas_textbreak.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_pArabicChar(NULL),
20 m_iLineWidth(2000000), 19 m_iLineWidth(2000000),
21 m_dwLayoutStyles(0), 20 m_dwLayoutStyles(0),
22 m_bVertical(FALSE), 21 m_bVertical(FALSE),
23 m_bArabicContext(FALSE), 22 m_bArabicContext(FALSE),
24 m_bArabicShapes(FALSE), 23 m_bArabicShapes(FALSE),
25 m_bRTL(FALSE), 24 m_bRTL(FALSE),
26 m_bSingleLine(FALSE), 25 m_bSingleLine(FALSE),
27 m_bCombText(FALSE), 26 m_bCombText(FALSE),
28 m_iArabicContext(1), 27 m_iArabicContext(1),
29 m_iCurArabicContext(1), 28 m_iCurArabicContext(1),
(...skipping 14 matching lines...) Expand all
44 m_dwCharType(0), 43 m_dwCharType(0),
45 m_bArabicNumber(FALSE), 44 m_bArabicNumber(FALSE),
46 m_bArabicComma(FALSE), 45 m_bArabicComma(FALSE),
47 m_pCurLine(NULL), 46 m_pCurLine(NULL),
48 m_iReady(0), 47 m_iReady(0),
49 m_iTolerance(0), 48 m_iTolerance(0),
50 m_iHorScale(100), 49 m_iHorScale(100),
51 m_iVerScale(100), 50 m_iVerScale(100),
52 m_iCharSpace(0) { 51 m_iCharSpace(0) {
53 m_bPagination = (m_dwPolicies & FX_TXTBREAKPOLICY_Pagination) != 0; 52 m_bPagination = (m_dwPolicies & FX_TXTBREAKPOLICY_Pagination) != 0;
54 m_pArabicChar = new CFX_ArabicChar;
55 if (m_bPagination) { 53 if (m_bPagination) {
56 m_pTxtLine1 = new CFX_TxtLine(sizeof(CFX_Char)); 54 m_pTxtLine1 = new CFX_TxtLine(sizeof(CFX_Char));
57 m_pTxtLine2 = new CFX_TxtLine(sizeof(CFX_Char)); 55 m_pTxtLine2 = new CFX_TxtLine(sizeof(CFX_Char));
58 } else { 56 } else {
59 m_pTxtLine1 = new CFX_TxtLine(sizeof(CFX_TxtChar)); 57 m_pTxtLine1 = new CFX_TxtLine(sizeof(CFX_TxtChar));
60 m_pTxtLine2 = new CFX_TxtLine(sizeof(CFX_TxtChar)); 58 m_pTxtLine2 = new CFX_TxtLine(sizeof(CFX_TxtChar));
61 } 59 }
62 m_pCurLine = m_pTxtLine1; 60 m_pCurLine = m_pTxtLine1;
63 ResetArabicContext(); 61 ResetArabicContext();
64 } 62 }
65 CFX_TxtBreak::~CFX_TxtBreak() { 63 CFX_TxtBreak::~CFX_TxtBreak() {
66 Reset(); 64 Reset();
67 delete m_pTxtLine1; 65 delete m_pTxtLine1;
68 delete m_pTxtLine2; 66 delete m_pTxtLine2;
69 m_pArabicChar->Release();
70 } 67 }
71 void CFX_TxtBreak::SetLineWidth(FX_FLOAT fLineWidth) { 68 void CFX_TxtBreak::SetLineWidth(FX_FLOAT fLineWidth) {
72 m_iLineWidth = FXSYS_round(fLineWidth * 20000.0f); 69 m_iLineWidth = FXSYS_round(fLineWidth * 20000.0f);
73 ASSERT(m_iLineWidth >= 20000); 70 ASSERT(m_iLineWidth >= 20000);
74 } 71 }
75 void CFX_TxtBreak::SetLinePos(FX_FLOAT fLinePos) { 72 void CFX_TxtBreak::SetLinePos(FX_FLOAT fLinePos) {
76 int32_t iLinePos = FXSYS_round(fLinePos * 20000.0f); 73 int32_t iLinePos = FXSYS_round(fLinePos * 20000.0f);
77 if (iLinePos < 0) { 74 if (iLinePos < 0) {
78 iLinePos = 0; 75 iLinePos = 0;
79 } 76 }
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 FX_BOOL bAlef = FALSE; 455 FX_BOOL bAlef = FALSE;
459 if (!m_bCombText && m_dwCharType >= FX_CHARTYPE_ArabicAlef && 456 if (!m_bCombText && m_dwCharType >= FX_CHARTYPE_ArabicAlef &&
460 m_dwCharType <= FX_CHARTYPE_ArabicDistortion) { 457 m_dwCharType <= FX_CHARTYPE_ArabicDistortion) {
461 pLastChar = GetLastChar(1); 458 pLastChar = GetLastChar(1);
462 if (pLastChar != NULL) { 459 if (pLastChar != NULL) {
463 iCharWidth = pLastChar->m_iCharWidth; 460 iCharWidth = pLastChar->m_iCharWidth;
464 if (iCharWidth > 0) { 461 if (iCharWidth > 0) {
465 iLineWidth -= iCharWidth; 462 iLineWidth -= iCharWidth;
466 } 463 }
467 CFX_Char* pPrevChar = GetLastChar(2); 464 CFX_Char* pPrevChar = GetLastChar(2);
468 wForm = m_pArabicChar->GetFormChar(pLastChar, pPrevChar, pCurChar); 465 wForm = pdfium::arabic::GetFormChar(pLastChar, pPrevChar, pCurChar);
469 bAlef = (wForm == 0xFEFF && 466 bAlef = (wForm == 0xFEFF &&
470 pLastChar->GetCharType() == FX_CHARTYPE_ArabicAlef); 467 pLastChar->GetCharType() == FX_CHARTYPE_ArabicAlef);
471 int32_t iLastRotation = pLastChar->m_nRotation + m_iLineRotation; 468 int32_t iLastRotation = pLastChar->m_nRotation + m_iLineRotation;
472 if (m_bVertical && (pLastChar->m_dwCharProps & 0x8000) != 0) { 469 if (m_bVertical && (pLastChar->m_dwCharProps & 0x8000) != 0) {
473 iLastRotation++; 470 iLastRotation++;
474 } 471 }
475 if (m_bVertical != FX_IsOdd(iLastRotation)) { 472 if (m_bVertical != FX_IsOdd(iLastRotation)) {
476 iCharWidth = 1000; 473 iCharWidth = 1000;
477 } else { 474 } else {
478 m_pFont->GetCharWidth(wForm, iCharWidth, FALSE); 475 m_pFont->GetCharWidth(wForm, iCharWidth, FALSE);
479 } 476 }
480 if (wForm == 0xFEFF) { 477 if (wForm == 0xFEFF) {
481 iCharWidth = m_iDefChar; 478 iCharWidth = m_iDefChar;
482 } 479 }
483 iCharWidth *= m_iFontSize; 480 iCharWidth *= m_iFontSize;
484 iCharWidth = iCharWidth * m_iHorScale / 100; 481 iCharWidth = iCharWidth * m_iHorScale / 100;
485 pLastChar->m_iCharWidth = iCharWidth; 482 pLastChar->m_iCharWidth = iCharWidth;
486 iLineWidth += iCharWidth; 483 iLineWidth += iCharWidth;
487 iCharWidth = 0; 484 iCharWidth = 0;
488 } 485 }
489 } 486 }
490 m_dwCharType = dwType; 487 m_dwCharType = dwType;
491 wForm = m_pArabicChar->GetFormChar(pCurChar, bAlef ? NULL : pLastChar, NULL); 488 wForm = pdfium::arabic::GetFormChar(pCurChar, bAlef ? NULL : pLastChar, NULL);
492 if (m_bCombText) { 489 if (m_bCombText) {
493 iCharWidth = m_iCombWidth; 490 iCharWidth = m_iCombWidth;
494 } else { 491 } else {
495 if (m_bVertical != FX_IsOdd(iRotation)) { 492 if (m_bVertical != FX_IsOdd(iRotation)) {
496 iCharWidth = 1000; 493 iCharWidth = 1000;
497 } else { 494 } else {
498 m_pFont->GetCharWidth(wForm, iCharWidth, FALSE); 495 m_pFont->GetCharWidth(wForm, iCharWidth, FALSE);
499 } 496 }
500 if (wForm == 0xFEFF) { 497 if (wForm == 0xFEFF) {
501 iCharWidth = m_iDefChar; 498 iCharWidth = m_iDefChar;
(...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after
1261 wNext = pStr[j]; 1258 wNext = pStr[j];
1262 dwProps = FX_GetUnicodeProperties(wNext); 1259 dwProps = FX_GetUnicodeProperties(wNext);
1263 } while ((dwProps & FX_CHARTYPEBITSMASK) == FX_CHARTYPE_Combination); 1260 } while ((dwProps & FX_CHARTYPEBITSMASK) == FX_CHARTYPE_Combination);
1264 if (i + j >= iLength) { 1261 if (i + j >= iLength) {
1265 wNext = 0xFEFF; 1262 wNext = 0xFEFF;
1266 } 1263 }
1267 } 1264 }
1268 } else { 1265 } else {
1269 wNext = 0xFEFF; 1266 wNext = 0xFEFF;
1270 } 1267 }
1271 wForm = m_pArabicChar->GetFormChar(wch, wPrev, wNext); 1268 wForm = pdfium::arabic::GetFormChar(wch, wPrev, wNext);
1272 bLam = (wPrev == 0x0644 && wch == 0x0644 && wNext == 0x0647); 1269 bLam = (wPrev == 0x0644 && wch == 0x0644 && wNext == 0x0647);
1273 } else if (dwCharType == FX_CHARTYPE_Combination) { 1270 } else if (dwCharType == FX_CHARTYPE_Combination) {
1274 wForm = wch; 1271 wForm = wch;
1275 if (wch >= 0x064C && wch <= 0x0651) { 1272 if (wch >= 0x064C && wch <= 0x0651) {
1276 if (bShadda) { 1273 if (bShadda) {
1277 wForm = 0xFEFF; 1274 wForm = 0xFEFF;
1278 bShadda = FALSE; 1275 bShadda = FALSE;
1279 } else { 1276 } else {
1280 wNext = 0xFEFF; 1277 wNext = 0xFEFF;
1281 if (pAccess != NULL) { 1278 if (pAccess != NULL) {
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
1650 rtBBoxF.height = fHeight; 1647 rtBBoxF.height = fHeight;
1651 rtBBoxF.top = std::max(rtBBoxF.top, 0.0f); 1648 rtBBoxF.top = std::max(rtBBoxF.top, 0.0f);
1652 } 1649 }
1653 rtArray.SetAt(i, rtBBoxF); 1650 rtArray.SetAt(i, rtBBoxF);
1654 continue; 1651 continue;
1655 } 1652 }
1656 rtArray.SetAt(i, rect); 1653 rtArray.SetAt(i, rect);
1657 } 1654 }
1658 return iLength; 1655 return iLength;
1659 } 1656 }
OLDNEW
« no previous file with comments | « xfa/fgas/layout/fgas_textbreak.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698