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/font/fgas_gefont.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_RTFBreak::CFX_RTFBreak(uint32_t dwPolicies) | 17 CFX_RTFBreak::CFX_RTFBreak(uint32_t dwPolicies) |
18 : m_dwPolicies(dwPolicies), | 18 : m_dwPolicies(dwPolicies), |
19 m_iBoundaryStart(0), | 19 m_iBoundaryStart(0), |
20 m_iBoundaryEnd(2000000), | 20 m_iBoundaryEnd(2000000), |
21 m_dwLayoutStyles(0), | 21 m_dwLayoutStyles(0), |
22 m_bPagination(FALSE), | 22 m_bPagination(FALSE), |
23 m_bVertical(FALSE), | 23 m_bVertical(FALSE), |
24 m_bSingleLine(FALSE), | 24 m_bSingleLine(FALSE), |
25 m_bCharCode(FALSE), | 25 m_bCharCode(FALSE), |
26 m_pFont(NULL), | 26 m_pFont(nullptr), |
27 m_iFontHeight(240), | 27 m_iFontHeight(240), |
28 m_iFontSize(240), | 28 m_iFontSize(240), |
29 m_iTabWidth(720000), | 29 m_iTabWidth(720000), |
30 m_PositionedTabs(), | 30 m_PositionedTabs(), |
31 m_bOrphanLine(FALSE), | 31 m_bOrphanLine(FALSE), |
32 m_wDefChar(0xFEFF), | 32 m_wDefChar(0xFEFF), |
33 m_iDefChar(0), | 33 m_iDefChar(0), |
34 m_wLineBreakChar(L'\n'), | 34 m_wLineBreakChar(L'\n'), |
35 m_iHorizontalScale(100), | 35 m_iHorizontalScale(100), |
36 m_iVerticalScale(100), | 36 m_iVerticalScale(100), |
37 m_iLineRotation(0), | 37 m_iLineRotation(0), |
38 m_iCharRotation(0), | 38 m_iCharRotation(0), |
39 m_iRotation(0), | 39 m_iRotation(0), |
40 m_iCharSpace(0), | 40 m_iCharSpace(0), |
41 m_bWordSpace(FALSE), | 41 m_bWordSpace(FALSE), |
42 m_iWordSpace(0), | 42 m_iWordSpace(0), |
43 m_bRTL(FALSE), | 43 m_bRTL(FALSE), |
44 m_iAlignment(FX_RTFLINEALIGNMENT_Left), | 44 m_iAlignment(FX_RTFLINEALIGNMENT_Left), |
45 m_pUserData(NULL), | 45 m_pUserData(nullptr), |
46 m_eCharType(FX_CHARTYPE_Unknown), | 46 m_eCharType(FX_CHARTYPE_Unknown), |
47 m_dwIdentity(0), | 47 m_dwIdentity(0), |
48 m_RTFLine1(), | 48 m_RTFLine1(), |
49 m_RTFLine2(), | 49 m_RTFLine2(), |
50 m_pCurLine(NULL), | 50 m_pCurLine(nullptr), |
51 m_iReady(0), | 51 m_iReady(0), |
52 m_iTolerance(0) { | 52 m_iTolerance(0) { |
53 m_pCurLine = &m_RTFLine1; | 53 m_pCurLine = &m_RTFLine1; |
54 } | 54 } |
55 CFX_RTFBreak::~CFX_RTFBreak() { | 55 CFX_RTFBreak::~CFX_RTFBreak() { |
56 Reset(); | 56 Reset(); |
57 m_PositionedTabs.RemoveAll(); | 57 m_PositionedTabs.RemoveAll(); |
58 if (m_pUserData != NULL) { | 58 if (m_pUserData) { |
59 m_pUserData->Release(); | 59 m_pUserData->Release(); |
60 } | 60 } |
61 } | 61 } |
62 void CFX_RTFBreak::SetLineBoundary(FX_FLOAT fLineStart, FX_FLOAT fLineEnd) { | 62 void CFX_RTFBreak::SetLineBoundary(FX_FLOAT fLineStart, FX_FLOAT fLineEnd) { |
63 if (fLineStart > fLineEnd) | 63 if (fLineStart > fLineEnd) |
64 return; | 64 return; |
65 m_iBoundaryStart = FXSYS_round(fLineStart * 20000.0f); | 65 m_iBoundaryStart = FXSYS_round(fLineStart * 20000.0f); |
66 m_iBoundaryEnd = FXSYS_round(fLineEnd * 20000.0f); | 66 m_iBoundaryEnd = FXSYS_round(fLineEnd * 20000.0f); |
67 m_pCurLine->m_iStart = std::min(m_pCurLine->m_iStart, m_iBoundaryEnd); | 67 m_pCurLine->m_iStart = std::min(m_pCurLine->m_iStart, m_iBoundaryEnd); |
68 m_pCurLine->m_iStart = std::max(m_pCurLine->m_iStart, m_iBoundaryStart); | 68 m_pCurLine->m_iStart = std::max(m_pCurLine->m_iStart, m_iBoundaryStart); |
(...skipping 12 matching lines...) Expand all Loading... |
81 m_dwLayoutStyles = dwLayoutStyles; | 81 m_dwLayoutStyles = dwLayoutStyles; |
82 m_bPagination = (m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_Pagination) != 0; | 82 m_bPagination = (m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_Pagination) != 0; |
83 m_bVertical = (m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_VerticalChars) != 0; | 83 m_bVertical = (m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_VerticalChars) != 0; |
84 m_bSingleLine = (m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_SingleLine) != 0; | 84 m_bSingleLine = (m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_SingleLine) != 0; |
85 m_bCharCode = (m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_MBCSCode) != 0; | 85 m_bCharCode = (m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_MBCSCode) != 0; |
86 m_iLineRotation = GetLineRotation(m_dwLayoutStyles); | 86 m_iLineRotation = GetLineRotation(m_dwLayoutStyles); |
87 m_iRotation = m_iLineRotation + m_iCharRotation; | 87 m_iRotation = m_iLineRotation + m_iCharRotation; |
88 m_iRotation %= 4; | 88 m_iRotation %= 4; |
89 } | 89 } |
90 void CFX_RTFBreak::SetFont(CFGAS_GEFont* pFont) { | 90 void CFX_RTFBreak::SetFont(CFGAS_GEFont* pFont) { |
91 if (pFont == NULL) { | 91 if (!pFont) { |
92 return; | 92 return; |
93 } | 93 } |
94 if (m_pFont == pFont) { | 94 if (m_pFont == pFont) { |
95 return; | 95 return; |
96 } | 96 } |
97 SetBreakStatus(); | 97 SetBreakStatus(); |
98 m_pFont = pFont; | 98 m_pFont = pFont; |
99 m_iDefChar = 0; | 99 m_iDefChar = 0; |
100 if (m_pFont != NULL) { | 100 if (m_pFont) { |
101 m_iFontHeight = m_iFontSize; | 101 m_iFontHeight = m_iFontSize; |
102 if (m_wDefChar != 0xFEFF) { | 102 if (m_wDefChar != 0xFEFF) { |
103 m_pFont->GetCharWidth(m_wDefChar, m_iDefChar, FALSE); | 103 m_pFont->GetCharWidth(m_wDefChar, m_iDefChar, FALSE); |
104 m_iDefChar *= m_iFontSize; | 104 m_iDefChar *= m_iFontSize; |
105 } | 105 } |
106 } | 106 } |
107 } | 107 } |
108 void CFX_RTFBreak::SetFontSize(FX_FLOAT fFontSize) { | 108 void CFX_RTFBreak::SetFontSize(FX_FLOAT fFontSize) { |
109 int32_t iFontSize = FXSYS_round(fFontSize * 20.0f); | 109 int32_t iFontSize = FXSYS_round(fFontSize * 20.0f); |
110 if (m_iFontSize == iFontSize) { | 110 if (m_iFontSize == iFontSize) { |
111 return; | 111 return; |
112 } | 112 } |
113 SetBreakStatus(); | 113 SetBreakStatus(); |
114 m_iFontSize = iFontSize; | 114 m_iFontSize = iFontSize; |
115 m_iDefChar = 0; | 115 m_iDefChar = 0; |
116 if (m_pFont != NULL) { | 116 if (m_pFont) { |
117 m_iFontHeight = m_iFontSize; | 117 m_iFontHeight = m_iFontSize; |
118 if (m_wDefChar != 0xFEFF) { | 118 if (m_wDefChar != 0xFEFF) { |
119 m_pFont->GetCharWidth(m_wDefChar, m_iDefChar, FALSE); | 119 m_pFont->GetCharWidth(m_wDefChar, m_iDefChar, FALSE); |
120 m_iDefChar *= m_iFontSize; | 120 m_iDefChar *= m_iFontSize; |
121 } | 121 } |
122 } | 122 } |
123 } | 123 } |
124 void CFX_RTFBreak::SetTabWidth(FX_FLOAT fTabWidth) { | 124 void CFX_RTFBreak::SetTabWidth(FX_FLOAT fTabWidth) { |
125 m_iTabWidth = FXSYS_round(fTabWidth * 20000.0f); | 125 m_iTabWidth = FXSYS_round(fTabWidth * 20000.0f); |
126 } | 126 } |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 m_bOrphanLine = FALSE; | 166 m_bOrphanLine = FALSE; |
167 } | 167 } |
168 } | 168 } |
169 void CFX_RTFBreak::ClearPositionedTabs() { | 169 void CFX_RTFBreak::ClearPositionedTabs() { |
170 m_PositionedTabs.RemoveAll(); | 170 m_PositionedTabs.RemoveAll(); |
171 m_bOrphanLine = FALSE; | 171 m_bOrphanLine = FALSE; |
172 } | 172 } |
173 void CFX_RTFBreak::SetDefaultChar(FX_WCHAR wch) { | 173 void CFX_RTFBreak::SetDefaultChar(FX_WCHAR wch) { |
174 m_wDefChar = wch; | 174 m_wDefChar = wch; |
175 m_iDefChar = 0; | 175 m_iDefChar = 0; |
176 if (m_wDefChar != 0xFEFF && m_pFont != NULL) { | 176 if (m_wDefChar != 0xFEFF && m_pFont) { |
177 m_pFont->GetCharWidth(m_wDefChar, m_iDefChar, FALSE); | 177 m_pFont->GetCharWidth(m_wDefChar, m_iDefChar, FALSE); |
178 if (m_iDefChar < 0) { | 178 if (m_iDefChar < 0) { |
179 m_iDefChar = 0; | 179 m_iDefChar = 0; |
180 } else { | 180 } else { |
181 m_iDefChar *= m_iFontSize; | 181 m_iDefChar *= m_iFontSize; |
182 } | 182 } |
183 } | 183 } |
184 } | 184 } |
185 void CFX_RTFBreak::SetLineBreakChar(FX_WCHAR wch) { | 185 void CFX_RTFBreak::SetLineBreakChar(FX_WCHAR wch) { |
186 if (wch != L'\r' && wch != L'\n') { | 186 if (wch != L'\r' && wch != L'\n') { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 void CFX_RTFBreak::SetAlignment(int32_t iAlignment) { | 238 void CFX_RTFBreak::SetAlignment(int32_t iAlignment) { |
239 ASSERT(iAlignment >= FX_RTFLINEALIGNMENT_Left && | 239 ASSERT(iAlignment >= FX_RTFLINEALIGNMENT_Left && |
240 iAlignment <= FX_RTFLINEALIGNMENT_Distributed); | 240 iAlignment <= FX_RTFLINEALIGNMENT_Distributed); |
241 m_iAlignment = iAlignment; | 241 m_iAlignment = iAlignment; |
242 } | 242 } |
243 void CFX_RTFBreak::SetUserData(IFX_Retainable* pUserData) { | 243 void CFX_RTFBreak::SetUserData(IFX_Retainable* pUserData) { |
244 if (m_pUserData == pUserData) { | 244 if (m_pUserData == pUserData) { |
245 return; | 245 return; |
246 } | 246 } |
247 SetBreakStatus(); | 247 SetBreakStatus(); |
248 if (m_pUserData != NULL) { | 248 if (m_pUserData) { |
249 m_pUserData->Release(); | 249 m_pUserData->Release(); |
250 } | 250 } |
251 m_pUserData = pUserData; | 251 m_pUserData = pUserData; |
252 if (m_pUserData != NULL) { | 252 if (m_pUserData) { |
253 m_pUserData->Retain(); | 253 m_pUserData->Retain(); |
254 } | 254 } |
255 } | 255 } |
256 static const int32_t gs_FX_RTFLineRotations[8] = {0, 3, 1, 0, 2, 1, 3, 2}; | 256 static const int32_t gs_FX_RTFLineRotations[8] = {0, 3, 1, 0, 2, 1, 3, 2}; |
257 int32_t CFX_RTFBreak::GetLineRotation(uint32_t dwStyles) const { | 257 int32_t CFX_RTFBreak::GetLineRotation(uint32_t dwStyles) const { |
258 return gs_FX_RTFLineRotations[(dwStyles & 0x0E) >> 1]; | 258 return gs_FX_RTFLineRotations[(dwStyles & 0x0E) >> 1]; |
259 } | 259 } |
260 void CFX_RTFBreak::SetBreakStatus() { | 260 void CFX_RTFBreak::SetBreakStatus() { |
261 m_dwIdentity++; | 261 m_dwIdentity++; |
262 int32_t iCount = m_pCurLine->CountChars(); | 262 int32_t iCount = m_pCurLine->CountChars(); |
263 if (iCount < 1) { | 263 if (iCount < 1) { |
264 return; | 264 return; |
265 } | 265 } |
266 CFX_RTFChar& tc = m_pCurLine->GetChar(iCount - 1); | 266 CFX_RTFChar& tc = m_pCurLine->GetChar(iCount - 1); |
267 if (tc.m_dwStatus == 0) { | 267 if (tc.m_dwStatus == 0) { |
268 tc.m_dwStatus = FX_RTFBREAK_PieceBreak; | 268 tc.m_dwStatus = FX_RTFBREAK_PieceBreak; |
269 } | 269 } |
270 } | 270 } |
271 CFX_RTFChar* CFX_RTFBreak::GetLastChar(int32_t index) const { | 271 CFX_RTFChar* CFX_RTFBreak::GetLastChar(int32_t index) const { |
272 CFX_RTFCharArray& tca = m_pCurLine->m_LineChars; | 272 CFX_RTFCharArray& tca = m_pCurLine->m_LineChars; |
273 int32_t iCount = tca.GetSize(); | 273 int32_t iCount = tca.GetSize(); |
274 if (index < 0 || index >= iCount) { | 274 if (index < 0 || index >= iCount) { |
275 return NULL; | 275 return nullptr; |
276 } | 276 } |
277 CFX_RTFChar* pTC; | 277 CFX_RTFChar* pTC; |
278 int32_t iStart = iCount - 1; | 278 int32_t iStart = iCount - 1; |
279 while (iStart > -1) { | 279 while (iStart > -1) { |
280 pTC = tca.GetDataPtr(iStart--); | 280 pTC = tca.GetDataPtr(iStart--); |
281 if (pTC->m_iCharWidth >= 0 || | 281 if (pTC->m_iCharWidth >= 0 || |
282 pTC->GetCharType() != FX_CHARTYPE_Combination) { | 282 pTC->GetCharType() != FX_CHARTYPE_Combination) { |
283 if (--index < 0) { | 283 if (--index < 0) { |
284 return pTC; | 284 return pTC; |
285 } | 285 } |
286 } | 286 } |
287 } | 287 } |
288 return NULL; | 288 return nullptr; |
289 } | 289 } |
290 CFX_RTFLine* CFX_RTFBreak::GetRTFLine(FX_BOOL bReady) const { | 290 CFX_RTFLine* CFX_RTFBreak::GetRTFLine(FX_BOOL bReady) const { |
291 if (bReady) { | 291 if (bReady) { |
292 if (m_iReady == 1) { | 292 if (m_iReady == 1) { |
293 return (CFX_RTFLine*)&m_RTFLine1; | 293 return (CFX_RTFLine*)&m_RTFLine1; |
294 } else if (m_iReady == 2) { | 294 } else if (m_iReady == 2) { |
295 return (CFX_RTFLine*)&m_RTFLine2; | 295 return (CFX_RTFLine*)&m_RTFLine2; |
296 } else { | 296 } else { |
297 return NULL; | 297 return nullptr; |
298 } | 298 } |
299 } | 299 } |
300 ASSERT(m_pCurLine != NULL); | 300 ASSERT(m_pCurLine); |
301 return m_pCurLine; | 301 return m_pCurLine; |
302 } | 302 } |
303 CFX_RTFPieceArray* CFX_RTFBreak::GetRTFPieces(FX_BOOL bReady) const { | 303 CFX_RTFPieceArray* CFX_RTFBreak::GetRTFPieces(FX_BOOL bReady) const { |
304 CFX_RTFLine* pRTFLine = GetRTFLine(bReady); | 304 CFX_RTFLine* pRTFLine = GetRTFLine(bReady); |
305 if (pRTFLine == NULL) { | 305 return pRTFLine ? &pRTFLine->m_LinePieces : nullptr; |
306 return NULL; | |
307 } | |
308 return &pRTFLine->m_LinePieces; | |
309 } | 306 } |
310 inline FX_CHARTYPE CFX_RTFBreak::GetUnifiedCharType( | 307 inline FX_CHARTYPE CFX_RTFBreak::GetUnifiedCharType( |
311 FX_CHARTYPE chartype) const { | 308 FX_CHARTYPE chartype) const { |
312 return chartype >= FX_CHARTYPE_ArabicAlef ? FX_CHARTYPE_Arabic : chartype; | 309 return chartype >= FX_CHARTYPE_ArabicAlef ? FX_CHARTYPE_Arabic : chartype; |
313 } | 310 } |
314 int32_t CFX_RTFBreak::GetLastPositionedTab() const { | 311 int32_t CFX_RTFBreak::GetLastPositionedTab() const { |
315 int32_t iCount = m_PositionedTabs.GetSize(); | 312 int32_t iCount = m_PositionedTabs.GetSize(); |
316 if (iCount < 1) { | 313 if (iCount < 1) { |
317 return m_iBoundaryStart; | 314 return m_iBoundaryStart; |
318 } | 315 } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 pCurChar->m_dwCharProps = dwProps; | 352 pCurChar->m_dwCharProps = dwProps; |
356 pCurChar->m_dwCharStyles = 0; | 353 pCurChar->m_dwCharStyles = 0; |
357 pCurChar->m_dwLayoutStyles = 0; | 354 pCurChar->m_dwLayoutStyles = 0; |
358 pCurChar->m_iFontSize = m_iFontSize; | 355 pCurChar->m_iFontSize = m_iFontSize; |
359 pCurChar->m_iFontHeight = m_iFontHeight; | 356 pCurChar->m_iFontHeight = m_iFontHeight; |
360 pCurChar->m_iHorizontalScale = m_iHorizontalScale; | 357 pCurChar->m_iHorizontalScale = m_iHorizontalScale; |
361 pCurChar->m_iVertialScale = m_iVerticalScale; | 358 pCurChar->m_iVertialScale = m_iVerticalScale; |
362 pCurChar->m_nRotation = m_iCharRotation; | 359 pCurChar->m_nRotation = m_iCharRotation; |
363 pCurChar->m_iCharWidth = 0; | 360 pCurChar->m_iCharWidth = 0; |
364 pCurChar->m_dwIdentity = m_dwIdentity; | 361 pCurChar->m_dwIdentity = m_dwIdentity; |
365 if (m_pUserData != NULL) { | 362 if (m_pUserData) { |
366 m_pUserData->Retain(); | 363 m_pUserData->Retain(); |
367 } | 364 } |
368 pCurChar->m_pUserData = m_pUserData; | 365 pCurChar->m_pUserData = m_pUserData; |
369 uint32_t dwRet1 = FX_RTFBREAK_None; | 366 uint32_t dwRet1 = FX_RTFBREAK_None; |
370 if (chartype != FX_CHARTYPE_Combination && | 367 if (chartype != FX_CHARTYPE_Combination && |
371 GetUnifiedCharType(m_eCharType) != GetUnifiedCharType(chartype)) { | 368 GetUnifiedCharType(m_eCharType) != GetUnifiedCharType(chartype)) { |
372 if (!m_bSingleLine && !m_bOrphanLine && | 369 if (!m_bSingleLine && !m_bOrphanLine && |
373 m_eCharType != FX_CHARTYPE_Unknown && | 370 m_eCharType != FX_CHARTYPE_Unknown && |
374 m_pCurLine->GetLineEnd() > m_iBoundaryEnd + m_iTolerance) { | 371 m_pCurLine->GetLineEnd() > m_iBoundaryEnd + m_iTolerance) { |
375 if (m_eCharType != FX_CHARTYPE_Space || chartype != FX_CHARTYPE_Control) { | 372 if (m_eCharType != FX_CHARTYPE_Space || chartype != FX_CHARTYPE_Control) { |
376 dwRet1 = EndBreak(FX_RTFBREAK_LineBreak); | 373 dwRet1 = EndBreak(FX_RTFBREAK_LineBreak); |
377 int32_t iCount = m_pCurLine->CountChars(); | 374 int32_t iCount = m_pCurLine->CountChars(); |
378 if (iCount > 0) { | 375 if (iCount > 0) { |
379 pCurChar = m_pCurLine->m_LineChars.GetDataPtr(iCount - 1); | 376 pCurChar = m_pCurLine->m_LineChars.GetDataPtr(iCount - 1); |
380 } | 377 } |
381 } | 378 } |
382 } | 379 } |
383 } | 380 } |
384 int32_t iRotation = m_iRotation; | 381 int32_t iRotation = m_iRotation; |
385 if (m_bVertical && (dwProps & 0x8000) != 0) { | 382 if (m_bVertical && (dwProps & 0x8000) != 0) { |
386 iRotation = (iRotation + 1) % 4; | 383 iRotation = (iRotation + 1) % 4; |
387 } | 384 } |
388 uint32_t dwRet2 = | 385 uint32_t dwRet2 = |
389 (this->*g_FX_RTFBreak_lpfAppendChar[chartype >> FX_CHARTYPEBITS])( | 386 (this->*g_FX_RTFBreak_lpfAppendChar[chartype >> FX_CHARTYPEBITS])( |
390 pCurChar, iRotation); | 387 pCurChar, iRotation); |
391 m_eCharType = chartype; | 388 m_eCharType = chartype; |
392 return std::max(dwRet1, dwRet2); | 389 return std::max(dwRet1, dwRet2); |
393 } | 390 } |
394 uint32_t CFX_RTFBreak::AppendChar_CharCode(FX_WCHAR wch) { | 391 uint32_t CFX_RTFBreak::AppendChar_CharCode(FX_WCHAR wch) { |
395 ASSERT(m_pFont != NULL && m_pCurLine != NULL); | 392 ASSERT(m_pFont && m_pCurLine); |
396 ASSERT(m_bCharCode); | 393 ASSERT(m_bCharCode); |
397 m_pCurLine->m_iMBCSChars++; | 394 m_pCurLine->m_iMBCSChars++; |
398 CFX_RTFCharArray& tca = m_pCurLine->m_LineChars; | 395 CFX_RTFCharArray& tca = m_pCurLine->m_LineChars; |
399 CFX_RTFChar* pCurChar = tca.AddSpace(); | 396 CFX_RTFChar* pCurChar = tca.AddSpace(); |
400 pCurChar->m_dwStatus = 0; | 397 pCurChar->m_dwStatus = 0; |
401 pCurChar->m_wCharCode = wch; | 398 pCurChar->m_wCharCode = wch; |
402 pCurChar->m_dwCharProps = 0; | 399 pCurChar->m_dwCharProps = 0; |
403 pCurChar->m_dwCharStyles = 0; | 400 pCurChar->m_dwCharStyles = 0; |
404 pCurChar->m_dwLayoutStyles = m_dwLayoutStyles; | 401 pCurChar->m_dwLayoutStyles = m_dwLayoutStyles; |
405 pCurChar->m_iFontSize = m_iFontSize; | 402 pCurChar->m_iFontSize = m_iFontSize; |
406 pCurChar->m_iFontHeight = m_iFontHeight; | 403 pCurChar->m_iFontHeight = m_iFontHeight; |
407 pCurChar->m_iHorizontalScale = m_iHorizontalScale; | 404 pCurChar->m_iHorizontalScale = m_iHorizontalScale; |
408 pCurChar->m_iVertialScale = m_iVerticalScale; | 405 pCurChar->m_iVertialScale = m_iVerticalScale; |
409 pCurChar->m_nRotation = m_iCharRotation; | 406 pCurChar->m_nRotation = m_iCharRotation; |
410 pCurChar->m_iCharWidth = 0; | 407 pCurChar->m_iCharWidth = 0; |
411 pCurChar->m_dwIdentity = m_dwIdentity; | 408 pCurChar->m_dwIdentity = m_dwIdentity; |
412 if (m_pUserData != NULL) { | 409 if (m_pUserData) { |
413 m_pUserData->Retain(); | 410 m_pUserData->Retain(); |
414 } | 411 } |
415 pCurChar->m_pUserData = m_pUserData; | 412 pCurChar->m_pUserData = m_pUserData; |
416 int32_t iCharWidth = 0; | 413 int32_t iCharWidth = 0; |
417 if (m_bVertical != FX_IsOdd(m_iRotation)) { | 414 if (m_bVertical != FX_IsOdd(m_iRotation)) { |
418 iCharWidth = 1000; | 415 iCharWidth = 1000; |
419 } else { | 416 } else { |
420 if (!m_pFont->GetCharWidth(wch, iCharWidth, TRUE)) { | 417 if (!m_pFont->GetCharWidth(wch, iCharWidth, TRUE)) { |
421 iCharWidth = m_iDefChar; | 418 iCharWidth = m_iDefChar; |
422 } | 419 } |
(...skipping 17 matching lines...) Expand all Loading... |
440 iCharWidth = 1000; | 437 iCharWidth = 1000; |
441 } else { | 438 } else { |
442 if (!m_pFont->GetCharWidth(pCurChar->m_wCharCode, iCharWidth, | 439 if (!m_pFont->GetCharWidth(pCurChar->m_wCharCode, iCharWidth, |
443 m_bCharCode)) { | 440 m_bCharCode)) { |
444 iCharWidth = 0; | 441 iCharWidth = 0; |
445 } | 442 } |
446 } | 443 } |
447 iCharWidth *= m_iFontSize; | 444 iCharWidth *= m_iFontSize; |
448 iCharWidth = iCharWidth * m_iHorizontalScale / 100; | 445 iCharWidth = iCharWidth * m_iHorizontalScale / 100; |
449 CFX_RTFChar* pLastChar = GetLastChar(0); | 446 CFX_RTFChar* pLastChar = GetLastChar(0); |
450 if (pLastChar != NULL && pLastChar->GetCharType() > FX_CHARTYPE_Combination) { | 447 if (pLastChar && pLastChar->GetCharType() > FX_CHARTYPE_Combination) { |
451 iCharWidth = -iCharWidth; | 448 iCharWidth = -iCharWidth; |
452 } else { | 449 } else { |
453 m_eCharType = FX_CHARTYPE_Combination; | 450 m_eCharType = FX_CHARTYPE_Combination; |
454 } | 451 } |
455 pCurChar->m_iCharWidth = iCharWidth; | 452 pCurChar->m_iCharWidth = iCharWidth; |
456 if (iCharWidth > 0) { | 453 if (iCharWidth > 0) { |
457 m_pCurLine->m_iWidth += iCharWidth; | 454 m_pCurLine->m_iWidth += iCharWidth; |
458 } | 455 } |
459 return FX_RTFBREAK_None; | 456 return FX_RTFBREAK_None; |
460 } | 457 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 break; | 499 break; |
503 } | 500 } |
504 if (dwRet2 != FX_RTFBREAK_None) { | 501 if (dwRet2 != FX_RTFBREAK_None) { |
505 dwRet2 = EndBreak(dwRet2); | 502 dwRet2 = EndBreak(dwRet2); |
506 } | 503 } |
507 } | 504 } |
508 return dwRet2; | 505 return dwRet2; |
509 } | 506 } |
510 uint32_t CFX_RTFBreak::AppendChar_Arabic(CFX_RTFChar* pCurChar, | 507 uint32_t CFX_RTFBreak::AppendChar_Arabic(CFX_RTFChar* pCurChar, |
511 int32_t iRotation) { | 508 int32_t iRotation) { |
512 CFX_RTFChar* pLastChar = NULL; | 509 CFX_RTFChar* pLastChar = nullptr; |
513 int32_t& iLineWidth = m_pCurLine->m_iWidth; | 510 int32_t& iLineWidth = m_pCurLine->m_iWidth; |
514 int32_t iCharWidth = 0; | 511 int32_t iCharWidth = 0; |
515 FX_WCHAR wForm; | 512 FX_WCHAR wForm; |
516 FX_BOOL bAlef = FALSE; | 513 FX_BOOL bAlef = FALSE; |
517 if (m_eCharType >= FX_CHARTYPE_ArabicAlef && | 514 if (m_eCharType >= FX_CHARTYPE_ArabicAlef && |
518 m_eCharType <= FX_CHARTYPE_ArabicDistortion) { | 515 m_eCharType <= FX_CHARTYPE_ArabicDistortion) { |
519 pLastChar = GetLastChar(1); | 516 pLastChar = GetLastChar(1); |
520 if (pLastChar != NULL) { | 517 if (pLastChar) { |
521 iLineWidth -= pLastChar->m_iCharWidth; | 518 iLineWidth -= pLastChar->m_iCharWidth; |
522 CFX_RTFChar* pPrevChar = GetLastChar(2); | 519 CFX_RTFChar* pPrevChar = GetLastChar(2); |
523 wForm = pdfium::arabic::GetFormChar(pLastChar, pPrevChar, pCurChar); | 520 wForm = pdfium::arabic::GetFormChar(pLastChar, pPrevChar, pCurChar); |
524 bAlef = (wForm == 0xFEFF && | 521 bAlef = (wForm == 0xFEFF && |
525 pLastChar->GetCharType() == FX_CHARTYPE_ArabicAlef); | 522 pLastChar->GetCharType() == FX_CHARTYPE_ArabicAlef); |
526 int32_t iLastRotation = pLastChar->m_nRotation + m_iLineRotation; | 523 int32_t iLastRotation = pLastChar->m_nRotation + m_iLineRotation; |
527 if (m_bVertical && (pLastChar->m_dwCharProps & 0x8000) != 0) { | 524 if (m_bVertical && (pLastChar->m_dwCharProps & 0x8000) != 0) { |
528 iLastRotation++; | 525 iLastRotation++; |
529 } | 526 } |
530 if (m_bVertical != FX_IsOdd(iLastRotation)) { | 527 if (m_bVertical != FX_IsOdd(iLastRotation)) { |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
614 if (iCount > 0) { | 611 if (iCount > 0) { |
615 CFX_RTFPiece* pLastPiece = pCurPieces->GetPtrAt(--iCount); | 612 CFX_RTFPiece* pLastPiece = pCurPieces->GetPtrAt(--iCount); |
616 if (dwStatus > FX_RTFBREAK_PieceBreak) { | 613 if (dwStatus > FX_RTFBREAK_PieceBreak) { |
617 pLastPiece->m_dwStatus = dwStatus; | 614 pLastPiece->m_dwStatus = dwStatus; |
618 } else { | 615 } else { |
619 dwStatus = pLastPiece->m_dwStatus; | 616 dwStatus = pLastPiece->m_dwStatus; |
620 } | 617 } |
621 return dwStatus; | 618 return dwStatus; |
622 } else { | 619 } else { |
623 CFX_RTFLine* pLastLine = GetRTFLine(TRUE); | 620 CFX_RTFLine* pLastLine = GetRTFLine(TRUE); |
624 if (pLastLine != NULL) { | 621 if (pLastLine) { |
625 pCurPieces = &pLastLine->m_LinePieces; | 622 pCurPieces = &pLastLine->m_LinePieces; |
626 iCount = pCurPieces->GetSize(); | 623 iCount = pCurPieces->GetSize(); |
627 if (iCount-- > 0) { | 624 if (iCount-- > 0) { |
628 CFX_RTFPiece* pLastPiece = pCurPieces->GetPtrAt(iCount); | 625 CFX_RTFPiece* pLastPiece = pCurPieces->GetPtrAt(iCount); |
629 if (dwStatus > FX_RTFBREAK_PieceBreak) { | 626 if (dwStatus > FX_RTFBREAK_PieceBreak) { |
630 pLastPiece->m_dwStatus = dwStatus; | 627 pLastPiece->m_dwStatus = dwStatus; |
631 } else { | 628 } else { |
632 dwStatus = pLastPiece->m_dwStatus; | 629 dwStatus = pLastPiece->m_dwStatus; |
633 } | 630 } |
634 return dwStatus; | 631 return dwStatus; |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1056 } | 1053 } |
1057 if (iLast > -1) { | 1054 if (iLast > -1) { |
1058 iEndPos = iLastPos; | 1055 iEndPos = iLastPos; |
1059 return iLast; | 1056 return iLast; |
1060 } | 1057 } |
1061 return 0; | 1058 return 0; |
1062 } | 1059 } |
1063 void CFX_RTFBreak::SplitTextLine(CFX_RTFLine* pCurLine, | 1060 void CFX_RTFBreak::SplitTextLine(CFX_RTFLine* pCurLine, |
1064 CFX_RTFLine* pNextLine, | 1061 CFX_RTFLine* pNextLine, |
1065 FX_BOOL bAllChars) { | 1062 FX_BOOL bAllChars) { |
1066 ASSERT(pCurLine != NULL && pNextLine != NULL); | 1063 ASSERT(pCurLine && pNextLine); |
1067 int32_t iCount = pCurLine->CountChars(); | 1064 int32_t iCount = pCurLine->CountChars(); |
1068 if (iCount < 2) { | 1065 if (iCount < 2) { |
1069 return; | 1066 return; |
1070 } | 1067 } |
1071 int32_t iEndPos = pCurLine->GetLineEnd(); | 1068 int32_t iEndPos = pCurLine->GetLineEnd(); |
1072 CFX_RTFCharArray& curChars = pCurLine->m_LineChars; | 1069 CFX_RTFCharArray& curChars = pCurLine->m_LineChars; |
1073 int32_t iCharPos = GetBreakPos(curChars, iEndPos, bAllChars, FALSE); | 1070 int32_t iCharPos = GetBreakPos(curChars, iEndPos, bAllChars, FALSE); |
1074 if (iCharPos < 0) { | 1071 if (iCharPos < 0) { |
1075 iCharPos = 0; | 1072 iCharPos = 0; |
1076 } | 1073 } |
(...skipping 26 matching lines...) Expand all Loading... |
1103 } | 1100 } |
1104 if (tc->m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_MBCSCode) { | 1101 if (tc->m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_MBCSCode) { |
1105 pCurLine->m_iMBCSChars--; | 1102 pCurLine->m_iMBCSChars--; |
1106 pNextLine->m_iMBCSChars++; | 1103 pNextLine->m_iMBCSChars++; |
1107 } | 1104 } |
1108 tc->m_dwStatus = 0; | 1105 tc->m_dwStatus = 0; |
1109 } | 1106 } |
1110 } | 1107 } |
1111 int32_t CFX_RTFBreak::CountBreakPieces() const { | 1108 int32_t CFX_RTFBreak::CountBreakPieces() const { |
1112 CFX_RTFPieceArray* pRTFPieces = GetRTFPieces(TRUE); | 1109 CFX_RTFPieceArray* pRTFPieces = GetRTFPieces(TRUE); |
1113 if (pRTFPieces == NULL) { | 1110 return pRTFPieces ? pRTFPieces->GetSize() : 0; |
1114 return 0; | |
1115 } | |
1116 return pRTFPieces->GetSize(); | |
1117 } | 1111 } |
1118 const CFX_RTFPiece* CFX_RTFBreak::GetBreakPiece(int32_t index) const { | 1112 const CFX_RTFPiece* CFX_RTFBreak::GetBreakPiece(int32_t index) const { |
1119 CFX_RTFPieceArray* pRTFPieces = GetRTFPieces(TRUE); | 1113 CFX_RTFPieceArray* pRTFPieces = GetRTFPieces(TRUE); |
1120 if (pRTFPieces == NULL) { | 1114 if (!pRTFPieces) { |
1121 return NULL; | 1115 return nullptr; |
1122 } | 1116 } |
1123 if (index < 0 || index >= pRTFPieces->GetSize()) { | 1117 if (index < 0 || index >= pRTFPieces->GetSize()) { |
1124 return NULL; | 1118 return nullptr; |
1125 } | 1119 } |
1126 return pRTFPieces->GetPtrAt(index); | 1120 return pRTFPieces->GetPtrAt(index); |
1127 } | 1121 } |
1128 void CFX_RTFBreak::GetLineRect(CFX_RectF& rect) const { | 1122 void CFX_RTFBreak::GetLineRect(CFX_RectF& rect) const { |
1129 rect.top = 0; | 1123 rect.top = 0; |
1130 CFX_RTFLine* pRTFLine = GetRTFLine(TRUE); | 1124 CFX_RTFLine* pRTFLine = GetRTFLine(TRUE); |
1131 if (pRTFLine == NULL) { | 1125 if (!pRTFLine) { |
1132 rect.left = ((FX_FLOAT)m_iBoundaryStart) / 20000.0f; | 1126 rect.left = ((FX_FLOAT)m_iBoundaryStart) / 20000.0f; |
1133 rect.width = rect.height = 0; | 1127 rect.width = rect.height = 0; |
1134 return; | 1128 return; |
1135 } | 1129 } |
1136 rect.left = ((FX_FLOAT)pRTFLine->m_iStart) / 20000.0f; | 1130 rect.left = ((FX_FLOAT)pRTFLine->m_iStart) / 20000.0f; |
1137 rect.width = ((FX_FLOAT)pRTFLine->m_iWidth) / 20000.0f; | 1131 rect.width = ((FX_FLOAT)pRTFLine->m_iWidth) / 20000.0f; |
1138 CFX_RTFPieceArray& rtfPieces = pRTFLine->m_LinePieces; | 1132 CFX_RTFPieceArray& rtfPieces = pRTFLine->m_LinePieces; |
1139 int32_t iCount = rtfPieces.GetSize(); | 1133 int32_t iCount = rtfPieces.GetSize(); |
1140 if (iCount < 1) { | 1134 if (iCount < 1) { |
1141 rect.width = 0; | 1135 rect.width = 0; |
1142 return; | 1136 return; |
1143 } | 1137 } |
1144 CFX_RTFPiece* pBreakPiece; | 1138 CFX_RTFPiece* pBreakPiece; |
1145 int32_t iLineHeight = 0, iMax; | 1139 int32_t iLineHeight = 0, iMax; |
1146 for (int32_t i = 0; i < iCount; i++) { | 1140 for (int32_t i = 0; i < iCount; i++) { |
1147 pBreakPiece = rtfPieces.GetPtrAt(i); | 1141 pBreakPiece = rtfPieces.GetPtrAt(i); |
1148 int32_t iFontHeight = FXSYS_round(pBreakPiece->m_iFontHeight * | 1142 int32_t iFontHeight = FXSYS_round(pBreakPiece->m_iFontHeight * |
1149 pBreakPiece->m_iVerticalScale / 100.0f); | 1143 pBreakPiece->m_iVerticalScale / 100.0f); |
1150 iMax = std::max(pBreakPiece->m_iFontSize, iFontHeight); | 1144 iMax = std::max(pBreakPiece->m_iFontSize, iFontHeight); |
1151 if (i == 0) { | 1145 if (i == 0) { |
1152 iLineHeight = iMax; | 1146 iLineHeight = iMax; |
1153 } else if (iLineHeight < iMax) { | 1147 } else if (iLineHeight < iMax) { |
1154 iLineHeight = iMax; | 1148 iLineHeight = iMax; |
1155 } | 1149 } |
1156 } | 1150 } |
1157 rect.height = ((FX_FLOAT)iLineHeight) / 20.0f; | 1151 rect.height = ((FX_FLOAT)iLineHeight) / 20.0f; |
1158 } | 1152 } |
1159 void CFX_RTFBreak::ClearBreakPieces() { | 1153 void CFX_RTFBreak::ClearBreakPieces() { |
1160 CFX_RTFLine* pRTFLine = GetRTFLine(TRUE); | 1154 CFX_RTFLine* pRTFLine = GetRTFLine(TRUE); |
1161 if (pRTFLine != NULL) { | 1155 if (pRTFLine) { |
1162 pRTFLine->RemoveAll(TRUE); | 1156 pRTFLine->RemoveAll(TRUE); |
1163 } | 1157 } |
1164 m_iReady = 0; | 1158 m_iReady = 0; |
1165 } | 1159 } |
1166 void CFX_RTFBreak::Reset() { | 1160 void CFX_RTFBreak::Reset() { |
1167 m_eCharType = FX_CHARTYPE_Unknown; | 1161 m_eCharType = FX_CHARTYPE_Unknown; |
1168 m_RTFLine1.RemoveAll(TRUE); | 1162 m_RTFLine1.RemoveAll(TRUE); |
1169 m_RTFLine2.RemoveAll(TRUE); | 1163 m_RTFLine2.RemoveAll(TRUE); |
1170 } | 1164 } |
1171 int32_t CFX_RTFBreak::GetDisplayPos(const FX_RTFTEXTOBJ* pText, | 1165 int32_t CFX_RTFBreak::GetDisplayPos(const FX_RTFTEXTOBJ* pText, |
1172 FXTEXT_CHARPOS* pCharPos, | 1166 FXTEXT_CHARPOS* pCharPos, |
1173 FX_BOOL bCharCode, | 1167 FX_BOOL bCharCode, |
1174 CFX_WideString* pWSForms, | 1168 CFX_WideString* pWSForms, |
1175 FX_AdjustCharDisplayPos pAdjustPos) const { | 1169 FX_AdjustCharDisplayPos pAdjustPos) const { |
1176 if (pText == NULL || pText->iLength < 1) { | 1170 if (!pText || pText->iLength < 1) { |
1177 return 0; | 1171 return 0; |
1178 } | 1172 } |
1179 ASSERT(pText->pStr != NULL && pText->pWidths != NULL && | 1173 ASSERT(pText->pStr && pText->pWidths && pText->pFont && pText->pRect); |
1180 pText->pFont != NULL && pText->pRect != NULL); | |
1181 const FX_WCHAR* pStr = pText->pStr; | 1174 const FX_WCHAR* pStr = pText->pStr; |
1182 int32_t* pWidths = pText->pWidths; | 1175 int32_t* pWidths = pText->pWidths; |
1183 int32_t iLength = pText->iLength - 1; | 1176 int32_t iLength = pText->iLength - 1; |
1184 CFGAS_GEFont* pFont = pText->pFont; | 1177 CFGAS_GEFont* pFont = pText->pFont; |
1185 uint32_t dwStyles = pText->dwLayoutStyles; | 1178 uint32_t dwStyles = pText->dwLayoutStyles; |
1186 CFX_RectF rtText(*pText->pRect); | 1179 CFX_RectF rtText(*pText->pRect); |
1187 FX_BOOL bRTLPiece = FX_IsOdd(pText->iBidiLevel); | 1180 FX_BOOL bRTLPiece = FX_IsOdd(pText->iBidiLevel); |
1188 FX_FLOAT fFontSize = pText->fFontSize; | 1181 FX_FLOAT fFontSize = pText->fFontSize; |
1189 int32_t iFontSize = FXSYS_round(fFontSize * 20.0f); | 1182 int32_t iFontSize = FXSYS_round(fFontSize * 20.0f); |
1190 int32_t iAscent = pFont->GetAscent(); | 1183 int32_t iAscent = pFont->GetAscent(); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1241 } | 1234 } |
1242 if (!bMBCSCode) { | 1235 if (!bMBCSCode) { |
1243 bEmptyChar = (dwCharType >= FX_CHARTYPE_Tab && | 1236 bEmptyChar = (dwCharType >= FX_CHARTYPE_Tab && |
1244 dwCharType <= FX_CHARTYPE_Control); | 1237 dwCharType <= FX_CHARTYPE_Control); |
1245 } else { | 1238 } else { |
1246 bEmptyChar = FALSE; | 1239 bEmptyChar = FALSE; |
1247 } | 1240 } |
1248 if (!bEmptyChar) { | 1241 if (!bEmptyChar) { |
1249 iCount++; | 1242 iCount++; |
1250 } | 1243 } |
1251 if (pCharPos != NULL) { | 1244 if (pCharPos) { |
1252 iCharWidth /= iFontSize; | 1245 iCharWidth /= iFontSize; |
1253 wForm = wch; | 1246 wForm = wch; |
1254 if (!bMBCSCode) { | 1247 if (!bMBCSCode) { |
1255 if (dwCharType >= FX_CHARTYPE_ArabicAlef) { | 1248 if (dwCharType >= FX_CHARTYPE_ArabicAlef) { |
1256 if (i < iLength) { | 1249 if (i < iLength) { |
1257 wNext = *pStr; | 1250 wNext = *pStr; |
1258 if (*pWidths < 0) { | 1251 if (*pWidths < 0) { |
1259 if (i + 1 < iLength) { | 1252 if (i + 1 < iLength) { |
1260 wNext = pStr[1]; | 1253 wNext = pStr[1]; |
1261 } | 1254 } |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1409 } | 1402 } |
1410 if (iWidth > 0) { | 1403 if (iWidth > 0) { |
1411 wPrev = wch; | 1404 wPrev = wch; |
1412 } | 1405 } |
1413 } | 1406 } |
1414 return iCount; | 1407 return iCount; |
1415 } | 1408 } |
1416 int32_t CFX_RTFBreak::GetCharRects(const FX_RTFTEXTOBJ* pText, | 1409 int32_t CFX_RTFBreak::GetCharRects(const FX_RTFTEXTOBJ* pText, |
1417 CFX_RectFArray& rtArray, | 1410 CFX_RectFArray& rtArray, |
1418 FX_BOOL bCharBBox) const { | 1411 FX_BOOL bCharBBox) const { |
1419 if (pText == NULL || pText->iLength < 1) { | 1412 if (!pText || pText->iLength < 1) { |
1420 return 0; | 1413 return 0; |
1421 } | 1414 } |
1422 ASSERT(pText->pStr != NULL && pText->pWidths != NULL && | 1415 ASSERT(pText->pStr && pText->pWidths && pText->pFont && pText->pRect); |
1423 pText->pFont != NULL && pText->pRect != NULL); | |
1424 const FX_WCHAR* pStr = pText->pStr; | 1416 const FX_WCHAR* pStr = pText->pStr; |
1425 int32_t* pWidths = pText->pWidths; | 1417 int32_t* pWidths = pText->pWidths; |
1426 int32_t iLength = pText->iLength; | 1418 int32_t iLength = pText->iLength; |
1427 CFX_RectF rect(*pText->pRect); | 1419 CFX_RectF rect(*pText->pRect); |
1428 FX_BOOL bRTLPiece = FX_IsOdd(pText->iBidiLevel); | 1420 FX_BOOL bRTLPiece = FX_IsOdd(pText->iBidiLevel); |
1429 FX_FLOAT fFontSize = pText->fFontSize; | 1421 FX_FLOAT fFontSize = pText->fFontSize; |
1430 int32_t iFontSize = FXSYS_round(fFontSize * 20.0f); | 1422 int32_t iFontSize = FXSYS_round(fFontSize * 20.0f); |
1431 FX_FLOAT fScale = fFontSize / 1000.0f; | 1423 FX_FLOAT fScale = fFontSize / 1000.0f; |
1432 CFGAS_GEFont* pFont = pText->pFont; | 1424 CFGAS_GEFont* pFont = pText->pFont; |
1433 if (pFont == NULL) { | 1425 if (!pFont) { |
1434 bCharBBox = FALSE; | 1426 bCharBBox = FALSE; |
1435 } | 1427 } |
1436 CFX_Rect bbox; | 1428 CFX_Rect bbox; |
1437 bbox.Set(0, 0, 0, 0); | 1429 bbox.Set(0, 0, 0, 0); |
1438 if (bCharBBox) { | 1430 if (bCharBBox) { |
1439 bCharBBox = pFont->GetBBox(bbox); | 1431 bCharBBox = pFont->GetBBox(bbox); |
1440 } | 1432 } |
1441 FX_FLOAT fLeft = std::max(0.0f, bbox.left * fScale); | 1433 FX_FLOAT fLeft = std::max(0.0f, bbox.left * fScale); |
1442 FX_FLOAT fHeight = FXSYS_fabs(bbox.height * fScale); | 1434 FX_FLOAT fHeight = FXSYS_fabs(bbox.height * fScale); |
1443 rtArray.RemoveAll(); | 1435 rtArray.RemoveAll(); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1526 m_iStartChar(0), | 1518 m_iStartChar(0), |
1527 m_iChars(0), | 1519 m_iChars(0), |
1528 m_iBidiLevel(0), | 1520 m_iBidiLevel(0), |
1529 m_iBidiPos(0), | 1521 m_iBidiPos(0), |
1530 m_iFontSize(0), | 1522 m_iFontSize(0), |
1531 m_iFontHeight(0), | 1523 m_iFontHeight(0), |
1532 m_iHorizontalScale(100), | 1524 m_iHorizontalScale(100), |
1533 m_iVerticalScale(100), | 1525 m_iVerticalScale(100), |
1534 m_dwLayoutStyles(0), | 1526 m_dwLayoutStyles(0), |
1535 m_dwIdentity(0), | 1527 m_dwIdentity(0), |
1536 m_pChars(NULL), | 1528 m_pChars(nullptr), |
1537 m_pUserData(NULL) {} | 1529 m_pUserData(nullptr) {} |
1538 | 1530 |
1539 CFX_RTFPiece::~CFX_RTFPiece() { | 1531 CFX_RTFPiece::~CFX_RTFPiece() { |
1540 Reset(); | 1532 Reset(); |
1541 } | 1533 } |
1542 | 1534 |
1543 CFX_RTFLine::CFX_RTFLine() | 1535 CFX_RTFLine::CFX_RTFLine() |
1544 : m_LinePieces(16), | 1536 : m_LinePieces(16), |
1545 m_iStart(0), | 1537 m_iStart(0), |
1546 m_iWidth(0), | 1538 m_iWidth(0), |
1547 m_iArabicChars(0), | 1539 m_iArabicChars(0), |
1548 m_iMBCSChars(0) {} | 1540 m_iMBCSChars(0) {} |
1549 | 1541 |
1550 CFX_RTFLine::~CFX_RTFLine() { | 1542 CFX_RTFLine::~CFX_RTFLine() { |
1551 RemoveAll(); | 1543 RemoveAll(); |
1552 } | 1544 } |
1553 | 1545 |
1554 FX_RTFTEXTOBJ::FX_RTFTEXTOBJ() | 1546 FX_RTFTEXTOBJ::FX_RTFTEXTOBJ() |
1555 : pStr(nullptr), | 1547 : pStr(nullptr), |
1556 pWidths(nullptr), | 1548 pWidths(nullptr), |
1557 iLength(0), | 1549 iLength(0), |
1558 pFont(nullptr), | 1550 pFont(nullptr), |
1559 fFontSize(12.0f), | 1551 fFontSize(12.0f), |
1560 dwLayoutStyles(0), | 1552 dwLayoutStyles(0), |
1561 iCharRotation(0), | 1553 iCharRotation(0), |
1562 iBidiLevel(0), | 1554 iBidiLevel(0), |
1563 pRect(nullptr), | 1555 pRect(nullptr), |
1564 wLineBreakChar(L'\n'), | 1556 wLineBreakChar(L'\n'), |
1565 iHorizontalScale(100), | 1557 iHorizontalScale(100), |
1566 iVerticalScale(100) {} | 1558 iVerticalScale(100) {} |
OLD | NEW |