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

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

Issue 2467203003: Remove FX_BOOL from xfa. (Closed)
Patch Set: Created 4 years, 1 month 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_rtfbreak.h ('k') | xfa/fgas/layout/fgas_textbreak.h » ('j') | 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_rtfbreak.h" 7 #include "xfa/fgas/layout/fgas_rtfbreak.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 10 matching lines...) Expand all
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(nullptr), 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(nullptr), 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(nullptr), 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;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 } 98 }
99 if (m_pFont == pFont) { 99 if (m_pFont == pFont) {
100 return; 100 return;
101 } 101 }
102 SetBreakStatus(); 102 SetBreakStatus();
103 m_pFont = pFont; 103 m_pFont = pFont;
104 m_iDefChar = 0; 104 m_iDefChar = 0;
105 if (m_pFont) { 105 if (m_pFont) {
106 m_iFontHeight = m_iFontSize; 106 m_iFontHeight = m_iFontSize;
107 if (m_wDefChar != 0xFEFF) { 107 if (m_wDefChar != 0xFEFF) {
108 m_pFont->GetCharWidth(m_wDefChar, m_iDefChar, FALSE); 108 m_pFont->GetCharWidth(m_wDefChar, m_iDefChar, false);
109 m_iDefChar *= m_iFontSize; 109 m_iDefChar *= m_iFontSize;
110 } 110 }
111 } 111 }
112 } 112 }
113 void CFX_RTFBreak::SetFontSize(FX_FLOAT fFontSize) { 113 void CFX_RTFBreak::SetFontSize(FX_FLOAT fFontSize) {
114 int32_t iFontSize = FXSYS_round(fFontSize * 20.0f); 114 int32_t iFontSize = FXSYS_round(fFontSize * 20.0f);
115 if (m_iFontSize == iFontSize) { 115 if (m_iFontSize == iFontSize) {
116 return; 116 return;
117 } 117 }
118 SetBreakStatus(); 118 SetBreakStatus();
119 m_iFontSize = iFontSize; 119 m_iFontSize = iFontSize;
120 m_iDefChar = 0; 120 m_iDefChar = 0;
121 if (m_pFont) { 121 if (m_pFont) {
122 m_iFontHeight = m_iFontSize; 122 m_iFontHeight = m_iFontSize;
123 if (m_wDefChar != 0xFEFF) { 123 if (m_wDefChar != 0xFEFF) {
124 m_pFont->GetCharWidth(m_wDefChar, m_iDefChar, FALSE); 124 m_pFont->GetCharWidth(m_wDefChar, m_iDefChar, false);
125 m_iDefChar *= m_iFontSize; 125 m_iDefChar *= m_iFontSize;
126 } 126 }
127 } 127 }
128 } 128 }
129 void CFX_RTFBreak::SetTabWidth(FX_FLOAT fTabWidth) { 129 void CFX_RTFBreak::SetTabWidth(FX_FLOAT fTabWidth) {
130 m_iTabWidth = FXSYS_round(fTabWidth * 20000.0f); 130 m_iTabWidth = FXSYS_round(fTabWidth * 20000.0f);
131 } 131 }
132 void CFX_RTFBreak::AddPositionedTab(FX_FLOAT fTabPos) { 132 void CFX_RTFBreak::AddPositionedTab(FX_FLOAT fTabPos) {
133 int32_t iLineEnd = m_iBoundaryEnd; 133 int32_t iLineEnd = m_iBoundaryEnd;
134 int32_t iTabPos = FXSYS_round(fTabPos * 20000.0f) + m_iBoundaryStart; 134 int32_t iTabPos = FXSYS_round(fTabPos * 20000.0f) + m_iBoundaryStart;
135 if (iTabPos > iLineEnd) { 135 if (iTabPos > iLineEnd) {
136 iTabPos = iLineEnd; 136 iTabPos = iLineEnd;
137 } 137 }
138 if (m_PositionedTabs.Find(iTabPos, 0) > -1) { 138 if (m_PositionedTabs.Find(iTabPos, 0) > -1) {
139 return; 139 return;
140 } 140 }
141 int32_t iCount = m_PositionedTabs.GetSize(); 141 int32_t iCount = m_PositionedTabs.GetSize();
142 int32_t iFind = 0; 142 int32_t iFind = 0;
143 for (; iFind < iCount; iFind++) { 143 for (; iFind < iCount; iFind++) {
144 if (m_PositionedTabs[iFind] > iTabPos) { 144 if (m_PositionedTabs[iFind] > iTabPos) {
145 break; 145 break;
146 } 146 }
147 } 147 }
148 m_PositionedTabs.InsertAt(iFind, iTabPos); 148 m_PositionedTabs.InsertAt(iFind, iTabPos);
149 if (m_dwPolicies & FX_RTFBREAKPOLICY_OrphanPositionedTab) { 149 if (m_dwPolicies & FX_RTFBREAKPOLICY_OrphanPositionedTab) {
150 m_bOrphanLine = GetLastPositionedTab() >= iLineEnd; 150 m_bOrphanLine = GetLastPositionedTab() >= iLineEnd;
151 } else { 151 } else {
152 m_bOrphanLine = FALSE; 152 m_bOrphanLine = false;
153 } 153 }
154 } 154 }
155 void CFX_RTFBreak::SetPositionedTabs(const CFX_FloatArray& tabs) { 155 void CFX_RTFBreak::SetPositionedTabs(const CFX_FloatArray& tabs) {
156 m_PositionedTabs.RemoveAll(); 156 m_PositionedTabs.RemoveAll();
157 int32_t iCount = tabs.GetSize(); 157 int32_t iCount = tabs.GetSize();
158 m_PositionedTabs.SetSize(iCount); 158 m_PositionedTabs.SetSize(iCount);
159 int32_t iLineEnd = m_iBoundaryEnd; 159 int32_t iLineEnd = m_iBoundaryEnd;
160 int32_t iTabPos; 160 int32_t iTabPos;
161 for (int32_t i = 0; i < iCount; i++) { 161 for (int32_t i = 0; i < iCount; i++) {
162 iTabPos = FXSYS_round(tabs[i] * 20000.0f) + m_iBoundaryStart; 162 iTabPos = FXSYS_round(tabs[i] * 20000.0f) + m_iBoundaryStart;
163 if (iTabPos > iLineEnd) { 163 if (iTabPos > iLineEnd) {
164 iTabPos = iLineEnd; 164 iTabPos = iLineEnd;
165 } 165 }
166 m_PositionedTabs[i] = iTabPos; 166 m_PositionedTabs[i] = iTabPos;
167 } 167 }
168 if (m_dwPolicies & FX_RTFBREAKPOLICY_OrphanPositionedTab) { 168 if (m_dwPolicies & FX_RTFBREAKPOLICY_OrphanPositionedTab) {
169 m_bOrphanLine = GetLastPositionedTab() >= iLineEnd; 169 m_bOrphanLine = GetLastPositionedTab() >= iLineEnd;
170 } else { 170 } else {
171 m_bOrphanLine = FALSE; 171 m_bOrphanLine = false;
172 } 172 }
173 } 173 }
174 void CFX_RTFBreak::ClearPositionedTabs() { 174 void CFX_RTFBreak::ClearPositionedTabs() {
175 m_PositionedTabs.RemoveAll(); 175 m_PositionedTabs.RemoveAll();
176 m_bOrphanLine = FALSE; 176 m_bOrphanLine = false;
177 } 177 }
178 void CFX_RTFBreak::SetDefaultChar(FX_WCHAR wch) { 178 void CFX_RTFBreak::SetDefaultChar(FX_WCHAR wch) {
179 m_wDefChar = wch; 179 m_wDefChar = wch;
180 m_iDefChar = 0; 180 m_iDefChar = 0;
181 if (m_wDefChar != 0xFEFF && m_pFont) { 181 if (m_wDefChar != 0xFEFF && m_pFont) {
182 m_pFont->GetCharWidth(m_wDefChar, m_iDefChar, FALSE); 182 m_pFont->GetCharWidth(m_wDefChar, m_iDefChar, false);
183 if (m_iDefChar < 0) { 183 if (m_iDefChar < 0) {
184 m_iDefChar = 0; 184 m_iDefChar = 0;
185 } else { 185 } else {
186 m_iDefChar *= m_iFontSize; 186 m_iDefChar *= m_iFontSize;
187 } 187 }
188 } 188 }
189 } 189 }
190 void CFX_RTFBreak::SetLineBreakChar(FX_WCHAR wch) { 190 void CFX_RTFBreak::SetLineBreakChar(FX_WCHAR wch) {
191 if (wch != L'\r' && wch != L'\n') { 191 if (wch != L'\r' && wch != L'\n') {
192 return; 192 return;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 return; 226 return;
227 } 227 }
228 SetBreakStatus(); 228 SetBreakStatus();
229 m_iCharRotation = iCharRotation; 229 m_iCharRotation = iCharRotation;
230 m_iRotation = m_iLineRotation + m_iCharRotation; 230 m_iRotation = m_iLineRotation + m_iCharRotation;
231 m_iRotation %= 4; 231 m_iRotation %= 4;
232 } 232 }
233 void CFX_RTFBreak::SetCharSpace(FX_FLOAT fCharSpace) { 233 void CFX_RTFBreak::SetCharSpace(FX_FLOAT fCharSpace) {
234 m_iCharSpace = FXSYS_round(fCharSpace * 20000.0f); 234 m_iCharSpace = FXSYS_round(fCharSpace * 20000.0f);
235 } 235 }
236 void CFX_RTFBreak::SetWordSpace(FX_BOOL bDefault, FX_FLOAT fWordSpace) { 236 void CFX_RTFBreak::SetWordSpace(bool bDefault, FX_FLOAT fWordSpace) {
237 m_bWordSpace = !bDefault; 237 m_bWordSpace = !bDefault;
238 m_iWordSpace = FXSYS_round(fWordSpace * 20000.0f); 238 m_iWordSpace = FXSYS_round(fWordSpace * 20000.0f);
239 } 239 }
240 void CFX_RTFBreak::SetReadingOrder(FX_BOOL bRTL) { 240 void CFX_RTFBreak::SetReadingOrder(bool bRTL) {
241 m_bRTL = bRTL; 241 m_bRTL = bRTL;
242 } 242 }
243 void CFX_RTFBreak::SetAlignment(int32_t iAlignment) { 243 void CFX_RTFBreak::SetAlignment(int32_t iAlignment) {
244 ASSERT(iAlignment >= FX_RTFLINEALIGNMENT_Left && 244 ASSERT(iAlignment >= FX_RTFLINEALIGNMENT_Left &&
245 iAlignment <= FX_RTFLINEALIGNMENT_Distributed); 245 iAlignment <= FX_RTFLINEALIGNMENT_Distributed);
246 m_iAlignment = iAlignment; 246 m_iAlignment = iAlignment;
247 } 247 }
248 void CFX_RTFBreak::SetUserData(IFX_Retainable* pUserData) { 248 void CFX_RTFBreak::SetUserData(IFX_Retainable* pUserData) {
249 if (m_pUserData == pUserData) { 249 if (m_pUserData == pUserData) {
250 return; 250 return;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 pTC = tca.GetDataPtr(iStart--); 285 pTC = tca.GetDataPtr(iStart--);
286 if (pTC->m_iCharWidth >= 0 || 286 if (pTC->m_iCharWidth >= 0 ||
287 pTC->GetCharType() != FX_CHARTYPE_Combination) { 287 pTC->GetCharType() != FX_CHARTYPE_Combination) {
288 if (--index < 0) { 288 if (--index < 0) {
289 return pTC; 289 return pTC;
290 } 290 }
291 } 291 }
292 } 292 }
293 return nullptr; 293 return nullptr;
294 } 294 }
295 CFX_RTFLine* CFX_RTFBreak::GetRTFLine(FX_BOOL bReady) const { 295 CFX_RTFLine* CFX_RTFBreak::GetRTFLine(bool bReady) const {
296 if (bReady) { 296 if (bReady) {
297 if (m_iReady == 1) { 297 if (m_iReady == 1) {
298 return (CFX_RTFLine*)&m_RTFLine1; 298 return (CFX_RTFLine*)&m_RTFLine1;
299 } else if (m_iReady == 2) { 299 } else if (m_iReady == 2) {
300 return (CFX_RTFLine*)&m_RTFLine2; 300 return (CFX_RTFLine*)&m_RTFLine2;
301 } else { 301 } else {
302 return nullptr; 302 return nullptr;
303 } 303 }
304 } 304 }
305 ASSERT(m_pCurLine); 305 ASSERT(m_pCurLine);
306 return m_pCurLine; 306 return m_pCurLine;
307 } 307 }
308 CFX_RTFPieceArray* CFX_RTFBreak::GetRTFPieces(FX_BOOL bReady) const { 308 CFX_RTFPieceArray* CFX_RTFBreak::GetRTFPieces(bool bReady) const {
309 CFX_RTFLine* pRTFLine = GetRTFLine(bReady); 309 CFX_RTFLine* pRTFLine = GetRTFLine(bReady);
310 return pRTFLine ? &pRTFLine->m_LinePieces : nullptr; 310 return pRTFLine ? &pRTFLine->m_LinePieces : nullptr;
311 } 311 }
312 inline FX_CHARTYPE CFX_RTFBreak::GetUnifiedCharType( 312 inline FX_CHARTYPE CFX_RTFBreak::GetUnifiedCharType(
313 FX_CHARTYPE chartype) const { 313 FX_CHARTYPE chartype) const {
314 return chartype >= FX_CHARTYPE_ArabicAlef ? FX_CHARTYPE_Arabic : chartype; 314 return chartype >= FX_CHARTYPE_ArabicAlef ? FX_CHARTYPE_Arabic : chartype;
315 } 315 }
316 int32_t CFX_RTFBreak::GetLastPositionedTab() const { 316 int32_t CFX_RTFBreak::GetLastPositionedTab() const {
317 int32_t iCount = m_PositionedTabs.GetSize(); 317 int32_t iCount = m_PositionedTabs.GetSize();
318 if (iCount < 1) { 318 if (iCount < 1) {
319 return m_iBoundaryStart; 319 return m_iBoundaryStart;
320 } 320 }
321 return m_PositionedTabs[iCount - 1]; 321 return m_PositionedTabs[iCount - 1];
322 } 322 }
323 FX_BOOL CFX_RTFBreak::GetPositionedTab(int32_t& iTabPos) const { 323 bool CFX_RTFBreak::GetPositionedTab(int32_t& iTabPos) const {
324 int32_t iCount = m_PositionedTabs.GetSize(); 324 int32_t iCount = m_PositionedTabs.GetSize();
325 for (int32_t i = 0; i < iCount; i++) { 325 for (int32_t i = 0; i < iCount; i++) {
326 if (m_PositionedTabs[i] > iTabPos) { 326 if (m_PositionedTabs[i] > iTabPos) {
327 iTabPos = m_PositionedTabs[i]; 327 iTabPos = m_PositionedTabs[i];
328 return TRUE; 328 return true;
329 } 329 }
330 } 330 }
331 return FALSE; 331 return false;
332 } 332 }
333 typedef uint32_t (CFX_RTFBreak::*FX_RTFBreak_LPFAppendChar)( 333 typedef uint32_t (CFX_RTFBreak::*FX_RTFBreak_LPFAppendChar)(
334 CFX_RTFChar* pCurChar, 334 CFX_RTFChar* pCurChar,
335 int32_t iRotation); 335 int32_t iRotation);
336 static const FX_RTFBreak_LPFAppendChar g_FX_RTFBreak_lpfAppendChar[16] = { 336 static const FX_RTFBreak_LPFAppendChar g_FX_RTFBreak_lpfAppendChar[16] = {
337 &CFX_RTFBreak::AppendChar_Others, &CFX_RTFBreak::AppendChar_Tab, 337 &CFX_RTFBreak::AppendChar_Others, &CFX_RTFBreak::AppendChar_Tab,
338 &CFX_RTFBreak::AppendChar_Others, &CFX_RTFBreak::AppendChar_Control, 338 &CFX_RTFBreak::AppendChar_Others, &CFX_RTFBreak::AppendChar_Control,
339 &CFX_RTFBreak::AppendChar_Combination, &CFX_RTFBreak::AppendChar_Others, 339 &CFX_RTFBreak::AppendChar_Combination, &CFX_RTFBreak::AppendChar_Others,
340 &CFX_RTFBreak::AppendChar_Others, &CFX_RTFBreak::AppendChar_Arabic, 340 &CFX_RTFBreak::AppendChar_Others, &CFX_RTFBreak::AppendChar_Arabic,
341 &CFX_RTFBreak::AppendChar_Arabic, &CFX_RTFBreak::AppendChar_Arabic, 341 &CFX_RTFBreak::AppendChar_Arabic, &CFX_RTFBreak::AppendChar_Arabic,
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 pCurChar->m_iCharWidth = 0; 413 pCurChar->m_iCharWidth = 0;
414 pCurChar->m_dwIdentity = m_dwIdentity; 414 pCurChar->m_dwIdentity = m_dwIdentity;
415 if (m_pUserData) 415 if (m_pUserData)
416 m_pUserData->Retain(); 416 m_pUserData->Retain();
417 417
418 pCurChar->m_pUserData = m_pUserData; 418 pCurChar->m_pUserData = m_pUserData;
419 int32_t iCharWidth = 0; 419 int32_t iCharWidth = 0;
420 if (m_bVertical != FX_IsOdd(m_iRotation)) { 420 if (m_bVertical != FX_IsOdd(m_iRotation)) {
421 iCharWidth = 1000; 421 iCharWidth = 1000;
422 } else { 422 } else {
423 if (!m_pFont->GetCharWidth(wch, iCharWidth, TRUE)) { 423 if (!m_pFont->GetCharWidth(wch, iCharWidth, true)) {
424 iCharWidth = m_iDefChar; 424 iCharWidth = m_iDefChar;
425 } 425 }
426 } 426 }
427 iCharWidth *= m_iFontSize; 427 iCharWidth *= m_iFontSize;
428 iCharWidth = iCharWidth * m_iHorizontalScale / 100; 428 iCharWidth = iCharWidth * m_iHorizontalScale / 100;
429 iCharWidth += m_iCharSpace; 429 iCharWidth += m_iCharSpace;
430 pCurChar->m_iCharWidth = iCharWidth; 430 pCurChar->m_iCharWidth = iCharWidth;
431 m_pCurLine->m_iWidth += iCharWidth; 431 m_pCurLine->m_iWidth += iCharWidth;
432 m_eCharType = FX_CHARTYPE_Unknown; 432 m_eCharType = FX_CHARTYPE_Unknown;
433 if (!m_bSingleLine && 433 if (!m_bSingleLine &&
(...skipping 24 matching lines...) Expand all
458 } 458 }
459 pCurChar->m_iCharWidth = iCharWidth; 459 pCurChar->m_iCharWidth = iCharWidth;
460 if (iCharWidth > 0) { 460 if (iCharWidth > 0) {
461 m_pCurLine->m_iWidth += iCharWidth; 461 m_pCurLine->m_iWidth += iCharWidth;
462 } 462 }
463 return FX_RTFBREAK_None; 463 return FX_RTFBREAK_None;
464 } 464 }
465 uint32_t CFX_RTFBreak::AppendChar_Tab(CFX_RTFChar* pCurChar, 465 uint32_t CFX_RTFBreak::AppendChar_Tab(CFX_RTFChar* pCurChar,
466 int32_t iRotation) { 466 int32_t iRotation) {
467 if (m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_ExpandTab) { 467 if (m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_ExpandTab) {
468 FX_BOOL bBreak = FALSE; 468 bool bBreak = false;
469 if ((m_dwPolicies & FX_RTFBREAKPOLICY_TabBreak) != 0) { 469 if ((m_dwPolicies & FX_RTFBREAKPOLICY_TabBreak) != 0) {
470 bBreak = (m_pCurLine->GetLineEnd() > m_iBoundaryEnd + m_iTolerance); 470 bBreak = (m_pCurLine->GetLineEnd() > m_iBoundaryEnd + m_iTolerance);
471 } 471 }
472 int32_t& iLineWidth = m_pCurLine->m_iWidth; 472 int32_t& iLineWidth = m_pCurLine->m_iWidth;
473 int32_t iCharWidth = iLineWidth; 473 int32_t iCharWidth = iLineWidth;
474 if (GetPositionedTab(iCharWidth)) { 474 if (GetPositionedTab(iCharWidth)) {
475 iCharWidth -= iLineWidth; 475 iCharWidth -= iLineWidth;
476 } else { 476 } else {
477 iCharWidth = m_iTabWidth * (iLineWidth / m_iTabWidth + 1) - iLineWidth; 477 iCharWidth = m_iTabWidth * (iLineWidth / m_iTabWidth + 1) - iLineWidth;
478 } 478 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 } 511 }
512 return dwRet2; 512 return dwRet2;
513 } 513 }
514 514
515 uint32_t CFX_RTFBreak::AppendChar_Arabic(CFX_RTFChar* pCurChar, 515 uint32_t CFX_RTFBreak::AppendChar_Arabic(CFX_RTFChar* pCurChar,
516 int32_t iRotation) { 516 int32_t iRotation) {
517 CFX_RTFChar* pLastChar = nullptr; 517 CFX_RTFChar* pLastChar = nullptr;
518 int32_t& iLineWidth = m_pCurLine->m_iWidth; 518 int32_t& iLineWidth = m_pCurLine->m_iWidth;
519 int32_t iCharWidth = 0; 519 int32_t iCharWidth = 0;
520 FX_WCHAR wForm; 520 FX_WCHAR wForm;
521 FX_BOOL bAlef = FALSE; 521 bool bAlef = false;
522 if (m_eCharType >= FX_CHARTYPE_ArabicAlef && 522 if (m_eCharType >= FX_CHARTYPE_ArabicAlef &&
523 m_eCharType <= FX_CHARTYPE_ArabicDistortion) { 523 m_eCharType <= FX_CHARTYPE_ArabicDistortion) {
524 pLastChar = GetLastChar(1); 524 pLastChar = GetLastChar(1);
525 if (pLastChar) { 525 if (pLastChar) {
526 iLineWidth -= pLastChar->m_iCharWidth; 526 iLineWidth -= pLastChar->m_iCharWidth;
527 CFX_RTFChar* pPrevChar = GetLastChar(2); 527 CFX_RTFChar* pPrevChar = GetLastChar(2);
528 wForm = pdfium::arabic::GetFormChar(pLastChar, pPrevChar, pCurChar); 528 wForm = pdfium::arabic::GetFormChar(pLastChar, pPrevChar, pCurChar);
529 bAlef = (wForm == 0xFEFF && 529 bAlef = (wForm == 0xFEFF &&
530 pLastChar->GetCharType() == FX_CHARTYPE_ArabicAlef); 530 pLastChar->GetCharType() == FX_CHARTYPE_ArabicAlef);
531 int32_t iLastRotation = pLastChar->m_nRotation + m_iLineRotation; 531 int32_t iLastRotation = pLastChar->m_nRotation + m_iLineRotation;
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 int32_t iCount = pCurPieces->GetSize(); 618 int32_t iCount = pCurPieces->GetSize();
619 if (iCount > 0) { 619 if (iCount > 0) {
620 CFX_RTFPiece* pLastPiece = pCurPieces->GetPtrAt(--iCount); 620 CFX_RTFPiece* pLastPiece = pCurPieces->GetPtrAt(--iCount);
621 if (dwStatus > FX_RTFBREAK_PieceBreak) 621 if (dwStatus > FX_RTFBREAK_PieceBreak)
622 pLastPiece->m_dwStatus = dwStatus; 622 pLastPiece->m_dwStatus = dwStatus;
623 else 623 else
624 dwStatus = pLastPiece->m_dwStatus; 624 dwStatus = pLastPiece->m_dwStatus;
625 return dwStatus; 625 return dwStatus;
626 } 626 }
627 627
628 CFX_RTFLine* pLastLine = GetRTFLine(TRUE); 628 CFX_RTFLine* pLastLine = GetRTFLine(true);
629 if (pLastLine) { 629 if (pLastLine) {
630 pCurPieces = &pLastLine->m_LinePieces; 630 pCurPieces = &pLastLine->m_LinePieces;
631 iCount = pCurPieces->GetSize(); 631 iCount = pCurPieces->GetSize();
632 if (iCount-- > 0) { 632 if (iCount-- > 0) {
633 CFX_RTFPiece* pLastPiece = pCurPieces->GetPtrAt(iCount); 633 CFX_RTFPiece* pLastPiece = pCurPieces->GetPtrAt(iCount);
634 if (dwStatus > FX_RTFBREAK_PieceBreak) 634 if (dwStatus > FX_RTFBREAK_PieceBreak)
635 pLastPiece->m_dwStatus = dwStatus; 635 pLastPiece->m_dwStatus = dwStatus;
636 else 636 else
637 dwStatus = pLastPiece->m_dwStatus; 637 dwStatus = pLastPiece->m_dwStatus;
638 return dwStatus; 638 return dwStatus;
639 } 639 }
640 return FX_RTFBREAK_None; 640 return FX_RTFBREAK_None;
641 } 641 }
642 iCount = m_pCurLine->CountChars(); 642 iCount = m_pCurLine->CountChars();
643 if (iCount < 1) 643 if (iCount < 1)
644 return FX_RTFBREAK_None; 644 return FX_RTFBREAK_None;
645 645
646 CFX_RTFChar& tc = m_pCurLine->GetChar(iCount - 1); 646 CFX_RTFChar& tc = m_pCurLine->GetChar(iCount - 1);
647 tc.m_dwStatus = dwStatus; 647 tc.m_dwStatus = dwStatus;
648 if (dwStatus <= FX_RTFBREAK_PieceBreak) 648 if (dwStatus <= FX_RTFBREAK_PieceBreak)
649 return dwStatus; 649 return dwStatus;
650 650
651 m_iReady = (m_pCurLine == &m_RTFLine1) ? 1 : 2; 651 m_iReady = (m_pCurLine == &m_RTFLine1) ? 1 : 2;
652 CFX_RTFLine* pNextLine = 652 CFX_RTFLine* pNextLine =
653 (m_pCurLine == &m_RTFLine1) ? &m_RTFLine2 : &m_RTFLine1; 653 (m_pCurLine == &m_RTFLine1) ? &m_RTFLine2 : &m_RTFLine1;
654 FX_BOOL bAllChars = (m_iAlignment > FX_RTFLINEALIGNMENT_Right); 654 bool bAllChars = (m_iAlignment > FX_RTFLINEALIGNMENT_Right);
655 CFX_TPOArray tpos(100); 655 CFX_TPOArray tpos(100);
656 if (!EndBreak_SplitLine(pNextLine, bAllChars, dwStatus)) { 656 if (!EndBreak_SplitLine(pNextLine, bAllChars, dwStatus)) {
657 if (!m_bCharCode) 657 if (!m_bCharCode)
658 EndBreak_BidiLine(tpos, dwStatus); 658 EndBreak_BidiLine(tpos, dwStatus);
659 659
660 if (!m_bPagination && m_iAlignment > FX_RTFLINEALIGNMENT_Left) 660 if (!m_bPagination && m_iAlignment > FX_RTFLINEALIGNMENT_Left)
661 EndBreak_Alignment(tpos, bAllChars, dwStatus); 661 EndBreak_Alignment(tpos, bAllChars, dwStatus);
662 } 662 }
663 663
664 m_pCurLine = pNextLine; 664 m_pCurLine = pNextLine;
665 m_pCurLine->m_iStart = m_iBoundaryStart; 665 m_pCurLine->m_iStart = m_iBoundaryStart;
666 CFX_RTFChar* pTC = GetLastChar(0); 666 CFX_RTFChar* pTC = GetLastChar(0);
667 m_eCharType = pTC ? pTC->GetCharType() : FX_CHARTYPE_Unknown; 667 m_eCharType = pTC ? pTC->GetCharType() : FX_CHARTYPE_Unknown;
668 return dwStatus; 668 return dwStatus;
669 } 669 }
670 670
671 FX_BOOL CFX_RTFBreak::EndBreak_SplitLine(CFX_RTFLine* pNextLine, 671 bool CFX_RTFBreak::EndBreak_SplitLine(CFX_RTFLine* pNextLine,
672 FX_BOOL bAllChars, 672 bool bAllChars,
673 uint32_t dwStatus) { 673 uint32_t dwStatus) {
674 FX_BOOL bDone = FALSE; 674 bool bDone = false;
675 if (!m_bSingleLine && !m_bOrphanLine && 675 if (!m_bSingleLine && !m_bOrphanLine &&
676 m_pCurLine->GetLineEnd() > m_iBoundaryEnd + m_iTolerance) { 676 m_pCurLine->GetLineEnd() > m_iBoundaryEnd + m_iTolerance) {
677 CFX_RTFChar& tc = m_pCurLine->GetChar(m_pCurLine->CountChars() - 1); 677 CFX_RTFChar& tc = m_pCurLine->GetChar(m_pCurLine->CountChars() - 1);
678 switch (tc.GetCharType()) { 678 switch (tc.GetCharType()) {
679 case FX_CHARTYPE_Tab: 679 case FX_CHARTYPE_Tab:
680 if ((m_dwPolicies & FX_RTFBREAKPOLICY_TabBreak) != 0) { 680 if ((m_dwPolicies & FX_RTFBREAKPOLICY_TabBreak) != 0) {
681 SplitTextLine(m_pCurLine, pNextLine, !m_bPagination && bAllChars); 681 SplitTextLine(m_pCurLine, pNextLine, !m_bPagination && bAllChars);
682 bDone = TRUE; 682 bDone = true;
683 } 683 }
684 break; 684 break;
685 case FX_CHARTYPE_Control: 685 case FX_CHARTYPE_Control:
686 break; 686 break;
687 case FX_CHARTYPE_Space: 687 case FX_CHARTYPE_Space:
688 if ((m_dwPolicies & FX_RTFBREAKPOLICY_SpaceBreak) != 0) { 688 if ((m_dwPolicies & FX_RTFBREAKPOLICY_SpaceBreak) != 0) {
689 SplitTextLine(m_pCurLine, pNextLine, !m_bPagination && bAllChars); 689 SplitTextLine(m_pCurLine, pNextLine, !m_bPagination && bAllChars);
690 bDone = TRUE; 690 bDone = true;
691 } 691 }
692 break; 692 break;
693 default: 693 default:
694 SplitTextLine(m_pCurLine, pNextLine, !m_bPagination && bAllChars); 694 SplitTextLine(m_pCurLine, pNextLine, !m_bPagination && bAllChars);
695 bDone = TRUE; 695 bDone = true;
696 break; 696 break;
697 } 697 }
698 } 698 }
699 if (m_bPagination || m_pCurLine->m_iMBCSChars > 0) { 699 if (m_bPagination || m_pCurLine->m_iMBCSChars > 0) {
700 const CFX_RTFChar* pCurChars = m_pCurLine->m_LineChars.GetData(); 700 const CFX_RTFChar* pCurChars = m_pCurLine->m_LineChars.GetData();
701 const CFX_RTFChar* pTC; 701 const CFX_RTFChar* pTC;
702 CFX_RTFPieceArray* pCurPieces = &m_pCurLine->m_LinePieces; 702 CFX_RTFPieceArray* pCurPieces = &m_pCurLine->m_LinePieces;
703 CFX_RTFPiece tp; 703 CFX_RTFPiece tp;
704 tp.m_pChars = &m_pCurLine->m_LineChars; 704 tp.m_pChars = &m_pCurLine->m_LineChars;
705 FX_BOOL bNew = TRUE; 705 bool bNew = true;
706 uint32_t dwIdentity = (uint32_t)-1; 706 uint32_t dwIdentity = (uint32_t)-1;
707 int32_t iLast = m_pCurLine->CountChars() - 1, j = 0; 707 int32_t iLast = m_pCurLine->CountChars() - 1, j = 0;
708 for (int32_t i = 0; i <= iLast;) { 708 for (int32_t i = 0; i <= iLast;) {
709 pTC = pCurChars + i; 709 pTC = pCurChars + i;
710 if (bNew) { 710 if (bNew) {
711 tp.m_iStartChar = i; 711 tp.m_iStartChar = i;
712 tp.m_iStartPos += tp.m_iWidth; 712 tp.m_iStartPos += tp.m_iWidth;
713 tp.m_iWidth = 0; 713 tp.m_iWidth = 0;
714 tp.m_dwStatus = pTC->m_dwStatus; 714 tp.m_dwStatus = pTC->m_dwStatus;
715 tp.m_iFontSize = pTC->m_iFontSize; 715 tp.m_iFontSize = pTC->m_iFontSize;
716 tp.m_iFontHeight = pTC->m_iFontHeight; 716 tp.m_iFontHeight = pTC->m_iFontHeight;
717 tp.m_iHorizontalScale = pTC->m_iHorizontalScale; 717 tp.m_iHorizontalScale = pTC->m_iHorizontalScale;
718 tp.m_iVerticalScale = pTC->m_iVertialScale; 718 tp.m_iVerticalScale = pTC->m_iVertialScale;
719 tp.m_dwLayoutStyles = pTC->m_dwLayoutStyles; 719 tp.m_dwLayoutStyles = pTC->m_dwLayoutStyles;
720 dwIdentity = pTC->m_dwIdentity; 720 dwIdentity = pTC->m_dwIdentity;
721 tp.m_dwIdentity = dwIdentity; 721 tp.m_dwIdentity = dwIdentity;
722 tp.m_pUserData = pTC->m_pUserData; 722 tp.m_pUserData = pTC->m_pUserData;
723 j = i; 723 j = i;
724 bNew = FALSE; 724 bNew = false;
725 } 725 }
726 if (i == iLast || pTC->m_dwStatus != FX_RTFBREAK_None || 726 if (i == iLast || pTC->m_dwStatus != FX_RTFBREAK_None ||
727 pTC->m_dwIdentity != dwIdentity) { 727 pTC->m_dwIdentity != dwIdentity) {
728 tp.m_iChars = i - j; 728 tp.m_iChars = i - j;
729 if (pTC->m_dwIdentity == dwIdentity) { 729 if (pTC->m_dwIdentity == dwIdentity) {
730 tp.m_dwStatus = pTC->m_dwStatus; 730 tp.m_dwStatus = pTC->m_dwStatus;
731 tp.m_iWidth += pTC->m_iCharWidth; 731 tp.m_iWidth += pTC->m_iCharWidth;
732 tp.m_iChars += 1; 732 tp.m_iChars += 1;
733 i++; 733 i++;
734 } 734 }
735 pCurPieces->Add(tp); 735 pCurPieces->Add(tp);
736 bNew = TRUE; 736 bNew = true;
737 } else { 737 } else {
738 tp.m_iWidth += pTC->m_iCharWidth; 738 tp.m_iWidth += pTC->m_iCharWidth;
739 i++; 739 i++;
740 } 740 }
741 } 741 }
742 return TRUE; 742 return true;
743 } 743 }
744 if (bAllChars && !bDone) { 744 if (bAllChars && !bDone) {
745 int32_t iEndPos = m_pCurLine->GetLineEnd(); 745 int32_t iEndPos = m_pCurLine->GetLineEnd();
746 GetBreakPos(m_pCurLine->m_LineChars, iEndPos, bAllChars, TRUE); 746 GetBreakPos(m_pCurLine->m_LineChars, iEndPos, bAllChars, true);
747 } 747 }
748 return FALSE; 748 return false;
749 } 749 }
750 void CFX_RTFBreak::EndBreak_BidiLine(CFX_TPOArray& tpos, uint32_t dwStatus) { 750 void CFX_RTFBreak::EndBreak_BidiLine(CFX_TPOArray& tpos, uint32_t dwStatus) {
751 FX_TPO tpo; 751 FX_TPO tpo;
752 CFX_RTFPiece tp; 752 CFX_RTFPiece tp;
753 CFX_RTFChar* pTC; 753 CFX_RTFChar* pTC;
754 int32_t i, j; 754 int32_t i, j;
755 CFX_RTFCharArray& chars = m_pCurLine->m_LineChars; 755 CFX_RTFCharArray& chars = m_pCurLine->m_LineChars;
756 int32_t iCount = m_pCurLine->CountChars(); 756 int32_t iCount = m_pCurLine->CountChars();
757 FX_BOOL bDone = (!m_bPagination && !m_bCharCode && 757 bool bDone = (!m_bPagination && !m_bCharCode &&
758 (m_pCurLine->m_iArabicChars > 0 || m_bRTL)); 758 (m_pCurLine->m_iArabicChars > 0 || m_bRTL));
759 if (bDone) { 759 if (bDone) {
760 int32_t iBidiNum = 0; 760 int32_t iBidiNum = 0;
761 for (i = 0; i < iCount; i++) { 761 for (i = 0; i < iCount; i++) {
762 pTC = chars.GetDataPtr(i); 762 pTC = chars.GetDataPtr(i);
763 pTC->m_iBidiPos = i; 763 pTC->m_iBidiPos = i;
764 if (pTC->GetCharType() != FX_CHARTYPE_Control) { 764 if (pTC->GetCharType() != FX_CHARTYPE_Control) {
765 iBidiNum = i; 765 iBidiNum = i;
766 } 766 }
767 if (i == 0) { 767 if (i == 0) {
768 pTC->m_iBidiLevel = 1; 768 pTC->m_iBidiLevel = 1;
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 int32_t iStartPos = m_pCurLine->m_iStart; 837 int32_t iStartPos = m_pCurLine->m_iStart;
838 for (i = 0; i <= j; i++) { 838 for (i = 0; i <= j; i++) {
839 tpo = tpos.GetAt(i); 839 tpo = tpos.GetAt(i);
840 CFX_RTFPiece& ttp = pCurPieces->GetAt(tpo.index); 840 CFX_RTFPiece& ttp = pCurPieces->GetAt(tpo.index);
841 ttp.m_iStartPos = iStartPos; 841 ttp.m_iStartPos = iStartPos;
842 iStartPos += ttp.m_iWidth; 842 iStartPos += ttp.m_iWidth;
843 } 843 }
844 } 844 }
845 } 845 }
846 void CFX_RTFBreak::EndBreak_Alignment(CFX_TPOArray& tpos, 846 void CFX_RTFBreak::EndBreak_Alignment(CFX_TPOArray& tpos,
847 FX_BOOL bAllChars, 847 bool bAllChars,
848 uint32_t dwStatus) { 848 uint32_t dwStatus) {
849 CFX_RTFPieceArray* pCurPieces = &m_pCurLine->m_LinePieces; 849 CFX_RTFPieceArray* pCurPieces = &m_pCurLine->m_LinePieces;
850 int32_t iNetWidth = m_pCurLine->m_iWidth, iGapChars = 0, iCharWidth; 850 int32_t iNetWidth = m_pCurLine->m_iWidth, iGapChars = 0, iCharWidth;
851 int32_t iCount = pCurPieces->GetSize(); 851 int32_t iCount = pCurPieces->GetSize();
852 FX_BOOL bFind = FALSE; 852 bool bFind = false;
853 uint32_t dwCharType; 853 uint32_t dwCharType;
854 int32_t i, j; 854 int32_t i, j;
855 FX_TPO tpo; 855 FX_TPO tpo;
856 for (i = iCount - 1; i > -1; i--) { 856 for (i = iCount - 1; i > -1; i--) {
857 tpo = tpos.GetAt(i); 857 tpo = tpos.GetAt(i);
858 CFX_RTFPiece& ttp = pCurPieces->GetAt(tpo.index); 858 CFX_RTFPiece& ttp = pCurPieces->GetAt(tpo.index);
859 if (!bFind) { 859 if (!bFind) {
860 iNetWidth = ttp.GetEndPos(); 860 iNetWidth = ttp.GetEndPos();
861 } 861 }
862 FX_BOOL bArabic = FX_IsOdd(ttp.m_iBidiLevel); 862 bool bArabic = FX_IsOdd(ttp.m_iBidiLevel);
863 j = bArabic ? 0 : ttp.m_iChars - 1; 863 j = bArabic ? 0 : ttp.m_iChars - 1;
864 while (j > -1 && j < ttp.m_iChars) { 864 while (j > -1 && j < ttp.m_iChars) {
865 const CFX_RTFChar& tc = ttp.GetChar(j); 865 const CFX_RTFChar& tc = ttp.GetChar(j);
866 if (tc.m_nBreakType == FX_LBT_DIRECT_BRK) { 866 if (tc.m_nBreakType == FX_LBT_DIRECT_BRK) {
867 iGapChars++; 867 iGapChars++;
868 } 868 }
869 if (!bFind || !bAllChars) { 869 if (!bFind || !bAllChars) {
870 dwCharType = tc.GetCharType(); 870 dwCharType = tc.GetCharType();
871 if (dwCharType == FX_CHARTYPE_Space || 871 if (dwCharType == FX_CHARTYPE_Space ||
872 dwCharType == FX_CHARTYPE_Control) { 872 dwCharType == FX_CHARTYPE_Control) {
873 if (!bFind) { 873 if (!bFind) {
874 iCharWidth = tc.m_iCharWidth; 874 iCharWidth = tc.m_iCharWidth;
875 if (bAllChars && iCharWidth > 0) { 875 if (bAllChars && iCharWidth > 0) {
876 iNetWidth -= iCharWidth; 876 iNetWidth -= iCharWidth;
877 } 877 }
878 } 878 }
879 } else { 879 } else {
880 bFind = TRUE; 880 bFind = true;
881 if (!bAllChars) { 881 if (!bAllChars) {
882 break; 882 break;
883 } 883 }
884 } 884 }
885 } 885 }
886 j += bArabic ? 1 : -1; 886 j += bArabic ? 1 : -1;
887 } 887 }
888 if (!bAllChars && bFind) { 888 if (!bAllChars && bFind) {
889 break; 889 break;
890 } 890 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
929 for (i = 0; i < iCount; i++) { 929 for (i = 0; i < iCount; i++) {
930 CFX_RTFPiece& ttp = pCurPieces->GetAt(i); 930 CFX_RTFPiece& ttp = pCurPieces->GetAt(i);
931 ttp.m_iStartPos += iOffset; 931 ttp.m_iStartPos += iOffset;
932 } 932 }
933 } 933 }
934 } 934 }
935 } 935 }
936 936
937 int32_t CFX_RTFBreak::GetBreakPos(CFX_RTFCharArray& tca, 937 int32_t CFX_RTFBreak::GetBreakPos(CFX_RTFCharArray& tca,
938 int32_t& iEndPos, 938 int32_t& iEndPos,
939 FX_BOOL bAllChars, 939 bool bAllChars,
940 FX_BOOL bOnlyBrk) { 940 bool bOnlyBrk) {
941 int32_t iLength = tca.GetSize() - 1; 941 int32_t iLength = tca.GetSize() - 1;
942 if (iLength < 1) 942 if (iLength < 1)
943 return iLength; 943 return iLength;
944 944
945 int32_t iBreak = -1, iBreakPos = -1, iIndirect = -1, iIndirectPos = -1, 945 int32_t iBreak = -1, iBreakPos = -1, iIndirect = -1, iIndirectPos = -1,
946 iLast = -1, iLastPos = -1; 946 iLast = -1, iLastPos = -1;
947 if (m_bSingleLine || m_bOrphanLine || iEndPos <= m_iBoundaryEnd) { 947 if (m_bSingleLine || m_bOrphanLine || iEndPos <= m_iBoundaryEnd) {
948 if (!bAllChars || m_bCharCode) 948 if (!bAllChars || m_bCharCode)
949 return iLength; 949 return iLength;
950 950
951 iBreak = iLength; 951 iBreak = iLength;
952 iBreakPos = iEndPos; 952 iBreakPos = iEndPos;
953 } 953 }
954 CFX_RTFChar* pCharArray = tca.GetData(); 954 CFX_RTFChar* pCharArray = tca.GetData();
955 if (m_bCharCode) { 955 if (m_bCharCode) {
956 const CFX_RTFChar* pChar; 956 const CFX_RTFChar* pChar;
957 int32_t iCharWidth; 957 int32_t iCharWidth;
958 while (iLength > 0) { 958 while (iLength > 0) {
959 if (iEndPos <= m_iBoundaryEnd) 959 if (iEndPos <= m_iBoundaryEnd)
960 break; 960 break;
961 961
962 pChar = pCharArray + iLength--; 962 pChar = pCharArray + iLength--;
963 iCharWidth = pChar->m_iCharWidth; 963 iCharWidth = pChar->m_iCharWidth;
964 if (iCharWidth > 0) 964 if (iCharWidth > 0)
965 iEndPos -= iCharWidth; 965 iEndPos -= iCharWidth;
966 } 966 }
967 return iLength; 967 return iLength;
968 } 968 }
969 FX_BOOL bSpaceBreak = (m_dwPolicies & FX_RTFBREAKPOLICY_SpaceBreak) != 0; 969 bool bSpaceBreak = (m_dwPolicies & FX_RTFBREAKPOLICY_SpaceBreak) != 0;
970 FX_BOOL bTabBreak = (m_dwPolicies & FX_RTFBREAKPOLICY_TabBreak) != 0; 970 bool bTabBreak = (m_dwPolicies & FX_RTFBREAKPOLICY_TabBreak) != 0;
971 FX_BOOL bNumberBreak = (m_dwPolicies & FX_RTFBREAKPOLICY_NumberBreak) != 0; 971 bool bNumberBreak = (m_dwPolicies & FX_RTFBREAKPOLICY_NumberBreak) != 0;
972 FX_BOOL bInfixBreak = (m_dwPolicies & FX_RTFBREAKPOLICY_InfixBreak) != 0; 972 bool bInfixBreak = (m_dwPolicies & FX_RTFBREAKPOLICY_InfixBreak) != 0;
973 FX_LINEBREAKTYPE eType; 973 FX_LINEBREAKTYPE eType;
974 uint32_t nCodeProp, nCur, nNext; 974 uint32_t nCodeProp, nCur, nNext;
975 CFX_RTFChar* pCur = pCharArray + iLength--; 975 CFX_RTFChar* pCur = pCharArray + iLength--;
976 if (bAllChars) { 976 if (bAllChars) {
977 pCur->m_nBreakType = FX_LBT_UNKNOWN; 977 pCur->m_nBreakType = FX_LBT_UNKNOWN;
978 } 978 }
979 nCodeProp = pCur->m_dwCharProps; 979 nCodeProp = pCur->m_dwCharProps;
980 nNext = nCodeProp & 0x003F; 980 nNext = nCodeProp & 0x003F;
981 int32_t iCharWidth = pCur->m_iCharWidth; 981 int32_t iCharWidth = pCur->m_iCharWidth;
982 if (iCharWidth > 0) { 982 if (iCharWidth > 0) {
983 iEndPos -= iCharWidth; 983 iEndPos -= iCharWidth;
984 } 984 }
985 while (iLength >= 0) { 985 while (iLength >= 0) {
986 pCur = pCharArray + iLength; 986 pCur = pCharArray + iLength;
987 nCodeProp = pCur->m_dwCharProps; 987 nCodeProp = pCur->m_dwCharProps;
988 nCur = nCodeProp & 0x003F; 988 nCur = nCodeProp & 0x003F;
989 FX_BOOL bNeedBreak = FALSE; 989 bool bNeedBreak = false;
990 if (nCur == FX_CBP_SP) { 990 if (nCur == FX_CBP_SP) {
991 bNeedBreak = !bSpaceBreak; 991 bNeedBreak = !bSpaceBreak;
992 if (nNext == FX_CBP_SP) { 992 if (nNext == FX_CBP_SP) {
993 eType = bSpaceBreak ? FX_LBT_DIRECT_BRK : FX_LBT_PROHIBITED_BRK; 993 eType = bSpaceBreak ? FX_LBT_DIRECT_BRK : FX_LBT_PROHIBITED_BRK;
994 } else { 994 } else {
995 eType = gs_FX_LineBreak_PairTable[nCur][nNext]; 995 eType = gs_FX_LineBreak_PairTable[nCur][nNext];
996 } 996 }
997 } else if (nCur == FX_CBP_TB) { 997 } else if (nCur == FX_CBP_TB) {
998 bNeedBreak = !bTabBreak; 998 bNeedBreak = !bTabBreak;
999 if (nNext == FX_CBP_TB) { 999 if (nNext == FX_CBP_TB) {
1000 eType = bTabBreak ? FX_LBT_DIRECT_BRK : FX_LBT_PROHIBITED_BRK; 1000 eType = bTabBreak ? FX_LBT_DIRECT_BRK : FX_LBT_PROHIBITED_BRK;
1001 } else { 1001 } else {
1002 eType = gs_FX_LineBreak_PairTable[nCur][nNext]; 1002 eType = gs_FX_LineBreak_PairTable[nCur][nNext];
1003 } 1003 }
1004 } else if ((bNumberBreak && nCur == FX_CBP_NU && nNext == FX_CBP_NU) || 1004 } else if ((bNumberBreak && nCur == FX_CBP_NU && nNext == FX_CBP_NU) ||
1005 (bInfixBreak && nCur == FX_CBP_IS && nNext == FX_CBP_IS)) { 1005 (bInfixBreak && nCur == FX_CBP_IS && nNext == FX_CBP_IS)) {
1006 eType = FX_LBT_DIRECT_BRK; 1006 eType = FX_LBT_DIRECT_BRK;
1007 } else { 1007 } else {
1008 if (nNext == FX_CBP_SP) { 1008 if (nNext == FX_CBP_SP) {
1009 eType = FX_LBT_PROHIBITED_BRK; 1009 eType = FX_LBT_PROHIBITED_BRK;
1010 } else { 1010 } else {
1011 eType = gs_FX_LineBreak_PairTable[nCur][nNext]; 1011 eType = gs_FX_LineBreak_PairTable[nCur][nNext];
1012 } 1012 }
1013 } 1013 }
1014 if (bAllChars) { 1014 if (bAllChars) {
1015 pCur->m_nBreakType = eType; 1015 pCur->m_nBreakType = eType;
1016 } 1016 }
1017 if (!bOnlyBrk) { 1017 if (!bOnlyBrk) {
1018 iCharWidth = pCur->m_iCharWidth; 1018 iCharWidth = pCur->m_iCharWidth;
1019 FX_BOOL bBreak = FALSE; 1019 bool bBreak = false;
1020 if (nCur == FX_CBP_TB && bTabBreak) { 1020 if (nCur == FX_CBP_TB && bTabBreak) {
1021 bBreak = iCharWidth > 0 && iEndPos - iCharWidth <= m_iBoundaryEnd; 1021 bBreak = iCharWidth > 0 && iEndPos - iCharWidth <= m_iBoundaryEnd;
1022 } else { 1022 } else {
1023 bBreak = iEndPos <= m_iBoundaryEnd; 1023 bBreak = iEndPos <= m_iBoundaryEnd;
1024 } 1024 }
1025 if (m_bSingleLine || m_bOrphanLine || bBreak || bNeedBreak) { 1025 if (m_bSingleLine || m_bOrphanLine || bBreak || bNeedBreak) {
1026 if (eType == FX_LBT_DIRECT_BRK && iBreak < 0) { 1026 if (eType == FX_LBT_DIRECT_BRK && iBreak < 0) {
1027 iBreak = iLength; 1027 iBreak = iLength;
1028 iBreakPos = iEndPos; 1028 iBreakPos = iEndPos;
1029 if (!bAllChars) { 1029 if (!bAllChars) {
(...skipping 28 matching lines...) Expand all
1058 } 1058 }
1059 if (iLast > -1) { 1059 if (iLast > -1) {
1060 iEndPos = iLastPos; 1060 iEndPos = iLastPos;
1061 return iLast; 1061 return iLast;
1062 } 1062 }
1063 return 0; 1063 return 0;
1064 } 1064 }
1065 1065
1066 void CFX_RTFBreak::SplitTextLine(CFX_RTFLine* pCurLine, 1066 void CFX_RTFBreak::SplitTextLine(CFX_RTFLine* pCurLine,
1067 CFX_RTFLine* pNextLine, 1067 CFX_RTFLine* pNextLine,
1068 FX_BOOL bAllChars) { 1068 bool bAllChars) {
1069 ASSERT(pCurLine && pNextLine); 1069 ASSERT(pCurLine && pNextLine);
1070 int32_t iCount = pCurLine->CountChars(); 1070 int32_t iCount = pCurLine->CountChars();
1071 if (iCount < 2) { 1071 if (iCount < 2) {
1072 return; 1072 return;
1073 } 1073 }
1074 int32_t iEndPos = pCurLine->GetLineEnd(); 1074 int32_t iEndPos = pCurLine->GetLineEnd();
1075 CFX_RTFCharArray& curChars = pCurLine->m_LineChars; 1075 CFX_RTFCharArray& curChars = pCurLine->m_LineChars;
1076 int32_t iCharPos = GetBreakPos(curChars, iEndPos, bAllChars, FALSE); 1076 int32_t iCharPos = GetBreakPos(curChars, iEndPos, bAllChars, false);
1077 if (iCharPos < 0) { 1077 if (iCharPos < 0) {
1078 iCharPos = 0; 1078 iCharPos = 0;
1079 } 1079 }
1080 iCharPos++; 1080 iCharPos++;
1081 if (iCharPos >= iCount) { 1081 if (iCharPos >= iCount) {
1082 pNextLine->RemoveAll(TRUE); 1082 pNextLine->RemoveAll(true);
1083 CFX_Char* pTC = curChars.GetDataPtr(iCharPos - 1); 1083 CFX_Char* pTC = curChars.GetDataPtr(iCharPos - 1);
1084 pTC->m_nBreakType = FX_LBT_UNKNOWN; 1084 pTC->m_nBreakType = FX_LBT_UNKNOWN;
1085 return; 1085 return;
1086 } 1086 }
1087 CFX_RTFCharArray& nextChars = pNextLine->m_LineChars; 1087 CFX_RTFCharArray& nextChars = pNextLine->m_LineChars;
1088 int cur_size = curChars.GetSize(); 1088 int cur_size = curChars.GetSize();
1089 nextChars.SetSize(cur_size - iCharPos); 1089 nextChars.SetSize(cur_size - iCharPos);
1090 FXSYS_memcpy(nextChars.GetData(), curChars.GetDataPtr(iCharPos), 1090 FXSYS_memcpy(nextChars.GetData(), curChars.GetDataPtr(iCharPos),
1091 (cur_size - iCharPos) * sizeof(CFX_RTFChar)); 1091 (cur_size - iCharPos) * sizeof(CFX_RTFChar));
1092 iCount -= iCharPos; 1092 iCount -= iCharPos;
(...skipping 13 matching lines...) Expand all
1106 } 1106 }
1107 if (tc->m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_MBCSCode) { 1107 if (tc->m_dwLayoutStyles & FX_RTFLAYOUTSTYLE_MBCSCode) {
1108 pCurLine->m_iMBCSChars--; 1108 pCurLine->m_iMBCSChars--;
1109 pNextLine->m_iMBCSChars++; 1109 pNextLine->m_iMBCSChars++;
1110 } 1110 }
1111 tc->m_dwStatus = 0; 1111 tc->m_dwStatus = 0;
1112 } 1112 }
1113 } 1113 }
1114 1114
1115 int32_t CFX_RTFBreak::CountBreakPieces() const { 1115 int32_t CFX_RTFBreak::CountBreakPieces() const {
1116 CFX_RTFPieceArray* pRTFPieces = GetRTFPieces(TRUE); 1116 CFX_RTFPieceArray* pRTFPieces = GetRTFPieces(true);
1117 return pRTFPieces ? pRTFPieces->GetSize() : 0; 1117 return pRTFPieces ? pRTFPieces->GetSize() : 0;
1118 } 1118 }
1119 1119
1120 const CFX_RTFPiece* CFX_RTFBreak::GetBreakPiece(int32_t index) const { 1120 const CFX_RTFPiece* CFX_RTFBreak::GetBreakPiece(int32_t index) const {
1121 CFX_RTFPieceArray* pRTFPieces = GetRTFPieces(TRUE); 1121 CFX_RTFPieceArray* pRTFPieces = GetRTFPieces(true);
1122 if (!pRTFPieces) 1122 if (!pRTFPieces)
1123 return nullptr; 1123 return nullptr;
1124 1124
1125 if (index < 0 || index >= pRTFPieces->GetSize()) 1125 if (index < 0 || index >= pRTFPieces->GetSize())
1126 return nullptr; 1126 return nullptr;
1127 1127
1128 return pRTFPieces->GetPtrAt(index); 1128 return pRTFPieces->GetPtrAt(index);
1129 } 1129 }
1130 1130
1131 void CFX_RTFBreak::GetLineRect(CFX_RectF& rect) const { 1131 void CFX_RTFBreak::GetLineRect(CFX_RectF& rect) const {
1132 rect.top = 0; 1132 rect.top = 0;
1133 CFX_RTFLine* pRTFLine = GetRTFLine(TRUE); 1133 CFX_RTFLine* pRTFLine = GetRTFLine(true);
1134 if (!pRTFLine) { 1134 if (!pRTFLine) {
1135 rect.left = ((FX_FLOAT)m_iBoundaryStart) / 20000.0f; 1135 rect.left = ((FX_FLOAT)m_iBoundaryStart) / 20000.0f;
1136 rect.width = rect.height = 0; 1136 rect.width = rect.height = 0;
1137 return; 1137 return;
1138 } 1138 }
1139 rect.left = ((FX_FLOAT)pRTFLine->m_iStart) / 20000.0f; 1139 rect.left = ((FX_FLOAT)pRTFLine->m_iStart) / 20000.0f;
1140 rect.width = ((FX_FLOAT)pRTFLine->m_iWidth) / 20000.0f; 1140 rect.width = ((FX_FLOAT)pRTFLine->m_iWidth) / 20000.0f;
1141 CFX_RTFPieceArray& rtfPieces = pRTFLine->m_LinePieces; 1141 CFX_RTFPieceArray& rtfPieces = pRTFLine->m_LinePieces;
1142 int32_t iCount = rtfPieces.GetSize(); 1142 int32_t iCount = rtfPieces.GetSize();
1143 if (iCount < 1) { 1143 if (iCount < 1) {
1144 rect.width = 0; 1144 rect.width = 0;
1145 return; 1145 return;
1146 } 1146 }
1147 CFX_RTFPiece* pBreakPiece; 1147 CFX_RTFPiece* pBreakPiece;
1148 int32_t iLineHeight = 0, iMax; 1148 int32_t iLineHeight = 0, iMax;
1149 for (int32_t i = 0; i < iCount; i++) { 1149 for (int32_t i = 0; i < iCount; i++) {
1150 pBreakPiece = rtfPieces.GetPtrAt(i); 1150 pBreakPiece = rtfPieces.GetPtrAt(i);
1151 int32_t iFontHeight = FXSYS_round(pBreakPiece->m_iFontHeight * 1151 int32_t iFontHeight = FXSYS_round(pBreakPiece->m_iFontHeight *
1152 pBreakPiece->m_iVerticalScale / 100.0f); 1152 pBreakPiece->m_iVerticalScale / 100.0f);
1153 iMax = std::max(pBreakPiece->m_iFontSize, iFontHeight); 1153 iMax = std::max(pBreakPiece->m_iFontSize, iFontHeight);
1154 if (i == 0) { 1154 if (i == 0) {
1155 iLineHeight = iMax; 1155 iLineHeight = iMax;
1156 } else if (iLineHeight < iMax) { 1156 } else if (iLineHeight < iMax) {
1157 iLineHeight = iMax; 1157 iLineHeight = iMax;
1158 } 1158 }
1159 } 1159 }
1160 rect.height = ((FX_FLOAT)iLineHeight) / 20.0f; 1160 rect.height = ((FX_FLOAT)iLineHeight) / 20.0f;
1161 } 1161 }
1162 void CFX_RTFBreak::ClearBreakPieces() { 1162 void CFX_RTFBreak::ClearBreakPieces() {
1163 CFX_RTFLine* pRTFLine = GetRTFLine(TRUE); 1163 CFX_RTFLine* pRTFLine = GetRTFLine(true);
1164 if (pRTFLine) { 1164 if (pRTFLine) {
1165 pRTFLine->RemoveAll(TRUE); 1165 pRTFLine->RemoveAll(true);
1166 } 1166 }
1167 m_iReady = 0; 1167 m_iReady = 0;
1168 } 1168 }
1169 void CFX_RTFBreak::Reset() { 1169 void CFX_RTFBreak::Reset() {
1170 m_eCharType = FX_CHARTYPE_Unknown; 1170 m_eCharType = FX_CHARTYPE_Unknown;
1171 m_RTFLine1.RemoveAll(TRUE); 1171 m_RTFLine1.RemoveAll(true);
1172 m_RTFLine2.RemoveAll(TRUE); 1172 m_RTFLine2.RemoveAll(true);
1173 } 1173 }
1174 int32_t CFX_RTFBreak::GetDisplayPos(const FX_RTFTEXTOBJ* pText, 1174 int32_t CFX_RTFBreak::GetDisplayPos(const FX_RTFTEXTOBJ* pText,
1175 FXTEXT_CHARPOS* pCharPos, 1175 FXTEXT_CHARPOS* pCharPos,
1176 FX_BOOL bCharCode, 1176 bool bCharCode,
1177 CFX_WideString* pWSForms, 1177 CFX_WideString* pWSForms,
1178 FX_AdjustCharDisplayPos pAdjustPos) const { 1178 FX_AdjustCharDisplayPos pAdjustPos) const {
1179 if (!pText || pText->iLength < 1) { 1179 if (!pText || pText->iLength < 1) {
1180 return 0; 1180 return 0;
1181 } 1181 }
1182 ASSERT(pText->pStr && pText->pWidths && pText->pFont && pText->pRect); 1182 ASSERT(pText->pStr && pText->pWidths && pText->pFont && pText->pRect);
1183 const FX_WCHAR* pStr = pText->pStr; 1183 const FX_WCHAR* pStr = pText->pStr;
1184 int32_t* pWidths = pText->pWidths; 1184 int32_t* pWidths = pText->pWidths;
1185 int32_t iLength = pText->iLength - 1; 1185 int32_t iLength = pText->iLength - 1;
1186 CFGAS_GEFont* pFont = pText->pFont; 1186 CFGAS_GEFont* pFont = pText->pFont;
1187 uint32_t dwStyles = pText->dwLayoutStyles; 1187 uint32_t dwStyles = pText->dwLayoutStyles;
1188 CFX_RectF rtText(*pText->pRect); 1188 CFX_RectF rtText(*pText->pRect);
1189 FX_BOOL bRTLPiece = FX_IsOdd(pText->iBidiLevel); 1189 bool bRTLPiece = FX_IsOdd(pText->iBidiLevel);
1190 FX_FLOAT fFontSize = pText->fFontSize; 1190 FX_FLOAT fFontSize = pText->fFontSize;
1191 int32_t iFontSize = FXSYS_round(fFontSize * 20.0f); 1191 int32_t iFontSize = FXSYS_round(fFontSize * 20.0f);
1192 int32_t iAscent = pFont->GetAscent(); 1192 int32_t iAscent = pFont->GetAscent();
1193 int32_t iDescent = pFont->GetDescent(); 1193 int32_t iDescent = pFont->GetDescent();
1194 int32_t iMaxHeight = iAscent - iDescent; 1194 int32_t iMaxHeight = iAscent - iDescent;
1195 FX_FLOAT fFontHeight = fFontSize; 1195 FX_FLOAT fFontHeight = fFontSize;
1196 FX_FLOAT fAscent = fFontHeight * (FX_FLOAT)iAscent / (FX_FLOAT)iMaxHeight; 1196 FX_FLOAT fAscent = fFontHeight * (FX_FLOAT)iAscent / (FX_FLOAT)iMaxHeight;
1197 FX_FLOAT fDescent = fFontHeight * (FX_FLOAT)iDescent / (FX_FLOAT)iMaxHeight; 1197 FX_FLOAT fDescent = fFontHeight * (FX_FLOAT)iDescent / (FX_FLOAT)iMaxHeight;
1198 FX_BOOL bVerticalDoc = (dwStyles & FX_RTFLAYOUTSTYLE_VerticalLayout) != 0; 1198 bool bVerticalDoc = (dwStyles & FX_RTFLAYOUTSTYLE_VerticalLayout) != 0;
1199 FX_BOOL bVerticalChar = (dwStyles & FX_RTFLAYOUTSTYLE_VerticalChars) != 0; 1199 bool bVerticalChar = (dwStyles & FX_RTFLAYOUTSTYLE_VerticalChars) != 0;
1200 FX_BOOL bArabicNumber = (dwStyles & FX_RTFLAYOUTSTYLE_ArabicNumber) != 0; 1200 bool bArabicNumber = (dwStyles & FX_RTFLAYOUTSTYLE_ArabicNumber) != 0;
1201 FX_BOOL bMBCSCode = (dwStyles & FX_RTFLAYOUTSTYLE_MBCSCode) != 0; 1201 bool bMBCSCode = (dwStyles & FX_RTFLAYOUTSTYLE_MBCSCode) != 0;
1202 int32_t iRotation = GetLineRotation(dwStyles) + pText->iCharRotation; 1202 int32_t iRotation = GetLineRotation(dwStyles) + pText->iCharRotation;
1203 int32_t iCharRotation; 1203 int32_t iCharRotation;
1204 FX_WCHAR wch, wPrev = 0xFEFF, wNext, wForm; 1204 FX_WCHAR wch, wPrev = 0xFEFF, wNext, wForm;
1205 int32_t iWidth, iCharWidth, iCharHeight; 1205 int32_t iWidth, iCharWidth, iCharHeight;
1206 FX_FLOAT fX, fY, fCharWidth, fCharHeight; 1206 FX_FLOAT fX, fY, fCharWidth, fCharHeight;
1207 int32_t iHorScale = pText->iHorizontalScale; 1207 int32_t iHorScale = pText->iHorizontalScale;
1208 int32_t iVerScale = pText->iVerticalScale; 1208 int32_t iVerScale = pText->iVerticalScale;
1209 FX_BOOL bEmptyChar; 1209 bool bEmptyChar;
1210 uint32_t dwProps, dwCharType; 1210 uint32_t dwProps, dwCharType;
1211 fX = rtText.left; 1211 fX = rtText.left;
1212 fY = rtText.top; 1212 fY = rtText.top;
1213 if (bVerticalDoc) { 1213 if (bVerticalDoc) {
1214 fX += (rtText.width - fFontSize) / 2.0f; 1214 fX += (rtText.width - fFontSize) / 2.0f;
1215 if (bRTLPiece) { 1215 if (bRTLPiece) {
1216 fY = rtText.bottom(); 1216 fY = rtText.bottom();
1217 } 1217 }
1218 } else { 1218 } else {
1219 if (bRTLPiece) { 1219 if (bRTLPiece) {
(...skipping 18 matching lines...) Expand all
1238 } 1238 }
1239 if (iWidth != 0) { 1239 if (iWidth != 0) {
1240 iCharWidth = iWidth; 1240 iCharWidth = iWidth;
1241 if (iCharWidth < 0) { 1241 if (iCharWidth < 0) {
1242 iCharWidth = -iCharWidth; 1242 iCharWidth = -iCharWidth;
1243 } 1243 }
1244 if (!bMBCSCode) { 1244 if (!bMBCSCode) {
1245 bEmptyChar = (dwCharType >= FX_CHARTYPE_Tab && 1245 bEmptyChar = (dwCharType >= FX_CHARTYPE_Tab &&
1246 dwCharType <= FX_CHARTYPE_Control); 1246 dwCharType <= FX_CHARTYPE_Control);
1247 } else { 1247 } else {
1248 bEmptyChar = FALSE; 1248 bEmptyChar = false;
1249 } 1249 }
1250 if (!bEmptyChar) { 1250 if (!bEmptyChar) {
1251 iCount++; 1251 iCount++;
1252 } 1252 }
1253 if (pCharPos) { 1253 if (pCharPos) {
1254 iCharWidth /= iFontSize; 1254 iCharWidth /= iFontSize;
1255 wForm = wch; 1255 wForm = wch;
1256 if (!bMBCSCode) { 1256 if (!bMBCSCode) {
1257 if (dwCharType >= FX_CHARTYPE_ArabicAlef) { 1257 if (dwCharType >= FX_CHARTYPE_ArabicAlef) {
1258 if (i < iLength) { 1258 if (i < iLength) {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1305 fCharHeight = fFontSize * iCharHeight / 1000.0f; 1305 fCharHeight = fFontSize * iCharHeight / 1000.0f;
1306 if (!bMBCSCode && bRTLPiece && dwCharType != FX_CHARTYPE_Combination) { 1306 if (!bMBCSCode && bRTLPiece && dwCharType != FX_CHARTYPE_Combination) {
1307 if (bVerticalDoc) { 1307 if (bVerticalDoc) {
1308 fY -= fCharHeight; 1308 fY -= fCharHeight;
1309 } else { 1309 } else {
1310 fX -= fCharWidth; 1310 fX -= fCharWidth;
1311 } 1311 }
1312 } 1312 }
1313 if (!bEmptyChar) { 1313 if (!bEmptyChar) {
1314 CFX_PointF ptOffset; 1314 CFX_PointF ptOffset;
1315 FX_BOOL bAdjusted = FALSE; 1315 bool bAdjusted = false;
1316 if (pAdjustPos) { 1316 if (pAdjustPos) {
1317 bAdjusted = pAdjustPos(wForm, bMBCSCode, pFont, fFontSize, 1317 bAdjusted = pAdjustPos(wForm, bMBCSCode, pFont, fFontSize,
1318 bVerticalChar, ptOffset); 1318 bVerticalChar, ptOffset);
1319 } 1319 }
1320 if (!bAdjusted && bVerticalChar && (dwProps & 0x00010000) != 0) { 1320 if (!bAdjusted && bVerticalChar && (dwProps & 0x00010000) != 0) {
1321 CFX_Rect rtBBox; 1321 CFX_Rect rtBBox;
1322 rtBBox.Reset(); 1322 rtBBox.Reset();
1323 if (pFont->GetCharBBox(wForm, rtBBox, bMBCSCode)) { 1323 if (pFont->GetCharBBox(wForm, rtBBox, bMBCSCode)) {
1324 ptOffset.x = fFontSize * (850 - rtBBox.right()) / 1000.0f; 1324 ptOffset.x = fFontSize * (850 - rtBBox.right()) / 1000.0f;
1325 ptOffset.y = fFontSize * (1000 - rtBBox.height) / 2000.0f; 1325 ptOffset.y = fFontSize * (1000 - rtBBox.height) / 2000.0f;
1326 } 1326 }
1327 } 1327 }
1328 pCharPos->m_OriginX = fX + ptOffset.x; 1328 pCharPos->m_OriginX = fX + ptOffset.x;
1329 pCharPos->m_OriginY = fY - ptOffset.y; 1329 pCharPos->m_OriginY = fY - ptOffset.y;
1330 } 1330 }
1331 if (!bRTLPiece && dwCharType != FX_CHARTYPE_Combination) { 1331 if (!bRTLPiece && dwCharType != FX_CHARTYPE_Combination) {
1332 if (bVerticalDoc) { 1332 if (bVerticalDoc) {
1333 fY += fCharHeight; 1333 fY += fCharHeight;
1334 } else { 1334 } else {
1335 fX += fCharWidth; 1335 fX += fCharWidth;
1336 } 1336 }
1337 } 1337 }
1338 if (!bEmptyChar) { 1338 if (!bEmptyChar) {
1339 pCharPos->m_bGlyphAdjust = TRUE; 1339 pCharPos->m_bGlyphAdjust = true;
1340 if (bVerticalDoc) { 1340 if (bVerticalDoc) {
1341 if (iCharRotation == 0) { 1341 if (iCharRotation == 0) {
1342 pCharPos->m_AdjustMatrix[0] = -1; 1342 pCharPos->m_AdjustMatrix[0] = -1;
1343 pCharPos->m_AdjustMatrix[1] = 0; 1343 pCharPos->m_AdjustMatrix[1] = 0;
1344 pCharPos->m_AdjustMatrix[2] = 0; 1344 pCharPos->m_AdjustMatrix[2] = 0;
1345 pCharPos->m_AdjustMatrix[3] = 1; 1345 pCharPos->m_AdjustMatrix[3] = 1;
1346 pCharPos->m_OriginY += fAscent * iVerScale / 100.0f; 1346 pCharPos->m_OriginY += fAscent * iVerScale / 100.0f;
1347 } else if (iCharRotation == 1) { 1347 } else if (iCharRotation == 1) {
1348 pCharPos->m_AdjustMatrix[0] = 0; 1348 pCharPos->m_AdjustMatrix[0] = 0;
1349 pCharPos->m_AdjustMatrix[1] = -1; 1349 pCharPos->m_AdjustMatrix[1] = -1;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1410 } 1410 }
1411 } 1411 }
1412 if (iWidth > 0) { 1412 if (iWidth > 0) {
1413 wPrev = wch; 1413 wPrev = wch;
1414 } 1414 }
1415 } 1415 }
1416 return iCount; 1416 return iCount;
1417 } 1417 }
1418 int32_t CFX_RTFBreak::GetCharRects(const FX_RTFTEXTOBJ* pText, 1418 int32_t CFX_RTFBreak::GetCharRects(const FX_RTFTEXTOBJ* pText,
1419 CFX_RectFArray& rtArray, 1419 CFX_RectFArray& rtArray,
1420 FX_BOOL bCharBBox) const { 1420 bool bCharBBox) const {
1421 if (!pText || pText->iLength < 1) { 1421 if (!pText || pText->iLength < 1) {
1422 return 0; 1422 return 0;
1423 } 1423 }
1424 ASSERT(pText->pStr && pText->pWidths && pText->pFont && pText->pRect); 1424 ASSERT(pText->pStr && pText->pWidths && pText->pFont && pText->pRect);
1425 const FX_WCHAR* pStr = pText->pStr; 1425 const FX_WCHAR* pStr = pText->pStr;
1426 int32_t* pWidths = pText->pWidths; 1426 int32_t* pWidths = pText->pWidths;
1427 int32_t iLength = pText->iLength; 1427 int32_t iLength = pText->iLength;
1428 CFX_RectF rect(*pText->pRect); 1428 CFX_RectF rect(*pText->pRect);
1429 FX_BOOL bRTLPiece = FX_IsOdd(pText->iBidiLevel); 1429 bool bRTLPiece = FX_IsOdd(pText->iBidiLevel);
1430 FX_FLOAT fFontSize = pText->fFontSize; 1430 FX_FLOAT fFontSize = pText->fFontSize;
1431 int32_t iFontSize = FXSYS_round(fFontSize * 20.0f); 1431 int32_t iFontSize = FXSYS_round(fFontSize * 20.0f);
1432 FX_FLOAT fScale = fFontSize / 1000.0f; 1432 FX_FLOAT fScale = fFontSize / 1000.0f;
1433 CFGAS_GEFont* pFont = pText->pFont; 1433 CFGAS_GEFont* pFont = pText->pFont;
1434 if (!pFont) { 1434 if (!pFont) {
1435 bCharBBox = FALSE; 1435 bCharBBox = false;
1436 } 1436 }
1437 CFX_Rect bbox; 1437 CFX_Rect bbox;
1438 bbox.Set(0, 0, 0, 0); 1438 bbox.Set(0, 0, 0, 0);
1439 if (bCharBBox) { 1439 if (bCharBBox) {
1440 bCharBBox = pFont->GetBBox(bbox); 1440 bCharBBox = pFont->GetBBox(bbox);
1441 } 1441 }
1442 FX_FLOAT fLeft = std::max(0.0f, bbox.left * fScale); 1442 FX_FLOAT fLeft = std::max(0.0f, bbox.left * fScale);
1443 FX_FLOAT fHeight = FXSYS_fabs(bbox.height * fScale); 1443 FX_FLOAT fHeight = FXSYS_fabs(bbox.height * fScale);
1444 rtArray.RemoveAll(); 1444 rtArray.RemoveAll();
1445 rtArray.SetSize(iLength); 1445 rtArray.SetSize(iLength);
1446 uint32_t dwStyles = pText->dwLayoutStyles; 1446 uint32_t dwStyles = pText->dwLayoutStyles;
1447 FX_BOOL bVertical = (dwStyles & FX_RTFLAYOUTSTYLE_VerticalLayout) != 0; 1447 bool bVertical = (dwStyles & FX_RTFLAYOUTSTYLE_VerticalLayout) != 0;
1448 FX_BOOL bSingleLine = (dwStyles & FX_RTFLAYOUTSTYLE_SingleLine) != 0; 1448 bool bSingleLine = (dwStyles & FX_RTFLAYOUTSTYLE_SingleLine) != 0;
1449 FX_BOOL bCombText = (dwStyles & FX_TXTLAYOUTSTYLE_CombText) != 0; 1449 bool bCombText = (dwStyles & FX_TXTLAYOUTSTYLE_CombText) != 0;
1450 FX_WCHAR wch, wLineBreakChar = pText->wLineBreakChar; 1450 FX_WCHAR wch, wLineBreakChar = pText->wLineBreakChar;
1451 int32_t iCharSize; 1451 int32_t iCharSize;
1452 FX_FLOAT fCharSize, fStart; 1452 FX_FLOAT fCharSize, fStart;
1453 if (bVertical) { 1453 if (bVertical) {
1454 fStart = bRTLPiece ? rect.bottom() : rect.top; 1454 fStart = bRTLPiece ? rect.bottom() : rect.top;
1455 } else { 1455 } else {
1456 fStart = bRTLPiece ? rect.right() : rect.left; 1456 fStart = bRTLPiece ? rect.right() : rect.left;
1457 } 1457 }
1458 for (int32_t i = 0; i < iLength; i++) { 1458 for (int32_t i = 0; i < iLength; i++) {
1459 wch = *pStr++; 1459 wch = *pStr++;
1460 iCharSize = *pWidths++; 1460 iCharSize = *pWidths++;
1461 fCharSize = (FX_FLOAT)iCharSize / 20000.0f; 1461 fCharSize = (FX_FLOAT)iCharSize / 20000.0f;
1462 FX_BOOL bRet = (!bSingleLine && FX_IsCtrlCode(wch)); 1462 bool bRet = (!bSingleLine && FX_IsCtrlCode(wch));
1463 if (!(wch == L'\v' || wch == L'\f' || wch == 0x2028 || wch == 0x2029 || 1463 if (!(wch == L'\v' || wch == L'\f' || wch == 0x2028 || wch == 0x2029 ||
1464 (wLineBreakChar != 0xFEFF && wch == wLineBreakChar))) { 1464 (wLineBreakChar != 0xFEFF && wch == wLineBreakChar))) {
1465 bRet = FALSE; 1465 bRet = false;
1466 } 1466 }
1467 if (bRet) { 1467 if (bRet) {
1468 iCharSize = iFontSize * 500; 1468 iCharSize = iFontSize * 500;
1469 fCharSize = fFontSize / 2.0f; 1469 fCharSize = fFontSize / 2.0f;
1470 } 1470 }
1471 if (bVertical) { 1471 if (bVertical) {
1472 rect.top = fStart; 1472 rect.top = fStart;
1473 if (bRTLPiece) { 1473 if (bRTLPiece) {
1474 rect.top -= fCharSize; 1474 rect.top -= fCharSize;
1475 fStart -= fCharSize; 1475 fStart -= fCharSize;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
1558 iLength(0), 1558 iLength(0),
1559 pFont(nullptr), 1559 pFont(nullptr),
1560 fFontSize(12.0f), 1560 fFontSize(12.0f),
1561 dwLayoutStyles(0), 1561 dwLayoutStyles(0),
1562 iCharRotation(0), 1562 iCharRotation(0),
1563 iBidiLevel(0), 1563 iBidiLevel(0),
1564 pRect(nullptr), 1564 pRect(nullptr),
1565 wLineBreakChar(L'\n'), 1565 wLineBreakChar(L'\n'),
1566 iHorizontalScale(100), 1566 iHorizontalScale(100),
1567 iVerticalScale(100) {} 1567 iVerticalScale(100) {}
OLDNEW
« no previous file with comments | « xfa/fgas/layout/fgas_rtfbreak.h ('k') | xfa/fgas/layout/fgas_textbreak.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698