OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "xfa/fgas/layout/fgas_rtfbreak.h" | 7 #include "xfa/fgas/layout/fgas_rtfbreak.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
11 #include "core/fxcrt/include/fx_arabic.h" | 11 #include "core/fxcrt/include/fx_arabic.h" |
12 #include "core/fxcrt/include/fx_arb.h" | 12 #include "core/fxcrt/include/fx_arb.h" |
| 13 #include "xfa/fgas/font/fgas_gefont.h" |
13 #include "xfa/fgas/layout/fgas_linebreak.h" | 14 #include "xfa/fgas/layout/fgas_linebreak.h" |
14 #include "xfa/fgas/layout/fgas_unicode.h" | 15 #include "xfa/fgas/layout/fgas_unicode.h" |
15 | 16 |
16 CFX_RTFBreak::CFX_RTFBreak(uint32_t dwPolicies) | 17 CFX_RTFBreak::CFX_RTFBreak(uint32_t dwPolicies) |
17 : m_dwPolicies(dwPolicies), | 18 : m_dwPolicies(dwPolicies), |
18 m_iBoundaryStart(0), | 19 m_iBoundaryStart(0), |
19 m_iBoundaryEnd(2000000), | 20 m_iBoundaryEnd(2000000), |
20 m_dwLayoutStyles(0), | 21 m_dwLayoutStyles(0), |
21 m_bPagination(FALSE), | 22 m_bPagination(FALSE), |
22 m_bVertical(FALSE), | 23 m_bVertical(FALSE), |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 SetBreakStatus(); | 80 SetBreakStatus(); |
80 m_dwLayoutStyles = dwLayoutStyles; | 81 m_dwLayoutStyles = dwLayoutStyles; |
81 m_bPagination = (m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_Pagination) != 0; | 82 m_bPagination = (m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_Pagination) != 0; |
82 m_bVertical = (m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_VerticalChars) != 0; | 83 m_bVertical = (m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_VerticalChars) != 0; |
83 m_bSingleLine = (m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_SingleLine) != 0; | 84 m_bSingleLine = (m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_SingleLine) != 0; |
84 m_bCharCode = (m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_MBCSCode) != 0; | 85 m_bCharCode = (m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_MBCSCode) != 0; |
85 m_iLineRotation = GetLineRotation(m_dwLayoutStyles); | 86 m_iLineRotation = GetLineRotation(m_dwLayoutStyles); |
86 m_iRotation = m_iLineRotation + m_iCharRotation; | 87 m_iRotation = m_iLineRotation + m_iCharRotation; |
87 m_iRotation %= 4; | 88 m_iRotation %= 4; |
88 } | 89 } |
89 void CFX_RTFBreak::SetFont(IFGAS_Font* pFont) { | 90 void CFX_RTFBreak::SetFont(CFGAS_GEFont* pFont) { |
90 if (pFont == NULL) { | 91 if (pFont == NULL) { |
91 return; | 92 return; |
92 } | 93 } |
93 if (m_pFont == pFont) { | 94 if (m_pFont == pFont) { |
94 return; | 95 return; |
95 } | 96 } |
96 SetBreakStatus(); | 97 SetBreakStatus(); |
97 m_pFont = pFont; | 98 m_pFont = pFont; |
98 m_iDefChar = 0; | 99 m_iDefChar = 0; |
99 if (m_pFont != NULL) { | 100 if (m_pFont != NULL) { |
(...skipping 1077 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1177 CFX_WideString* pWSForms, | 1178 CFX_WideString* pWSForms, |
1178 FX_AdjustCharDisplayPos pAdjustPos) const { | 1179 FX_AdjustCharDisplayPos pAdjustPos) const { |
1179 if (pText == NULL || pText->iLength < 1) { | 1180 if (pText == NULL || pText->iLength < 1) { |
1180 return 0; | 1181 return 0; |
1181 } | 1182 } |
1182 ASSERT(pText->pStr != NULL && pText->pWidths != NULL && | 1183 ASSERT(pText->pStr != NULL && pText->pWidths != NULL && |
1183 pText->pFont != NULL && pText->pRect != NULL); | 1184 pText->pFont != NULL && pText->pRect != NULL); |
1184 const FX_WCHAR* pStr = pText->pStr; | 1185 const FX_WCHAR* pStr = pText->pStr; |
1185 int32_t* pWidths = pText->pWidths; | 1186 int32_t* pWidths = pText->pWidths; |
1186 int32_t iLength = pText->iLength - 1; | 1187 int32_t iLength = pText->iLength - 1; |
1187 IFGAS_Font* pFont = pText->pFont; | 1188 CFGAS_GEFont* pFont = pText->pFont; |
1188 uint32_t dwStyles = pText->dwLayoutStyles; | 1189 uint32_t dwStyles = pText->dwLayoutStyles; |
1189 CFX_RectF rtText(*pText->pRect); | 1190 CFX_RectF rtText(*pText->pRect); |
1190 FX_BOOL bRTLPiece = FX_IsOdd(pText->iBidiLevel); | 1191 FX_BOOL bRTLPiece = FX_IsOdd(pText->iBidiLevel); |
1191 FX_FLOAT fFontSize = pText->fFontSize; | 1192 FX_FLOAT fFontSize = pText->fFontSize; |
1192 int32_t iFontSize = FXSYS_round(fFontSize * 20.0f); | 1193 int32_t iFontSize = FXSYS_round(fFontSize * 20.0f); |
1193 int32_t iAscent = pFont->GetAscent(); | 1194 int32_t iAscent = pFont->GetAscent(); |
1194 int32_t iDescent = pFont->GetDescent(); | 1195 int32_t iDescent = pFont->GetDescent(); |
1195 int32_t iMaxHeight = iAscent - iDescent; | 1196 int32_t iMaxHeight = iAscent - iDescent; |
1196 FX_FLOAT fFontHeight = fFontSize; | 1197 FX_FLOAT fFontHeight = fFontSize; |
1197 FX_FLOAT fAscent = fFontHeight * (FX_FLOAT)iAscent / (FX_FLOAT)iMaxHeight; | 1198 FX_FLOAT fAscent = fFontHeight * (FX_FLOAT)iAscent / (FX_FLOAT)iMaxHeight; |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1423 ASSERT(pText->pStr != NULL && pText->pWidths != NULL && | 1424 ASSERT(pText->pStr != NULL && pText->pWidths != NULL && |
1424 pText->pFont != NULL && pText->pRect != NULL); | 1425 pText->pFont != NULL && pText->pRect != NULL); |
1425 const FX_WCHAR* pStr = pText->pStr; | 1426 const FX_WCHAR* pStr = pText->pStr; |
1426 int32_t* pWidths = pText->pWidths; | 1427 int32_t* pWidths = pText->pWidths; |
1427 int32_t iLength = pText->iLength; | 1428 int32_t iLength = pText->iLength; |
1428 CFX_RectF rect(*pText->pRect); | 1429 CFX_RectF rect(*pText->pRect); |
1429 FX_BOOL bRTLPiece = FX_IsOdd(pText->iBidiLevel); | 1430 FX_BOOL bRTLPiece = FX_IsOdd(pText->iBidiLevel); |
1430 FX_FLOAT fFontSize = pText->fFontSize; | 1431 FX_FLOAT fFontSize = pText->fFontSize; |
1431 int32_t iFontSize = FXSYS_round(fFontSize * 20.0f); | 1432 int32_t iFontSize = FXSYS_round(fFontSize * 20.0f); |
1432 FX_FLOAT fScale = fFontSize / 1000.0f; | 1433 FX_FLOAT fScale = fFontSize / 1000.0f; |
1433 IFGAS_Font* pFont = pText->pFont; | 1434 CFGAS_GEFont* pFont = pText->pFont; |
1434 if (pFont == NULL) { | 1435 if (pFont == NULL) { |
1435 bCharBBox = FALSE; | 1436 bCharBBox = FALSE; |
1436 } | 1437 } |
1437 CFX_Rect bbox; | 1438 CFX_Rect bbox; |
1438 bbox.Set(0, 0, 0, 0); | 1439 bbox.Set(0, 0, 0, 0); |
1439 if (bCharBBox) { | 1440 if (bCharBBox) { |
1440 bCharBBox = pFont->GetBBox(bbox); | 1441 bCharBBox = pFont->GetBBox(bbox); |
1441 } | 1442 } |
1442 FX_FLOAT fLeft = std::max(0.0f, bbox.left * fScale); | 1443 FX_FLOAT fLeft = std::max(0.0f, bbox.left * fScale); |
1443 FX_FLOAT fHeight = FXSYS_fabs(bbox.height * fScale); | 1444 FX_FLOAT fHeight = FXSYS_fabs(bbox.height * fScale); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1512 rtBBoxF.height = fHeight; | 1513 rtBBoxF.height = fHeight; |
1513 rtBBoxF.top = std::max(rtBBoxF.top, 0.0f); | 1514 rtBBoxF.top = std::max(rtBBoxF.top, 0.0f); |
1514 } | 1515 } |
1515 rtArray.SetAt(i, rtBBoxF); | 1516 rtArray.SetAt(i, rtBBoxF); |
1516 continue; | 1517 continue; |
1517 } | 1518 } |
1518 rtArray.SetAt(i, rect); | 1519 rtArray.SetAt(i, rect); |
1519 } | 1520 } |
1520 return iLength; | 1521 return iLength; |
1521 } | 1522 } |
OLD | NEW |