| 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 |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 m_iWordSpace = FXSYS_round(fWordSpace * 20000.0f); | 232 m_iWordSpace = FXSYS_round(fWordSpace * 20000.0f); |
| 233 } | 233 } |
| 234 void CFX_RTFBreak::SetReadingOrder(FX_BOOL bRTL) { | 234 void CFX_RTFBreak::SetReadingOrder(FX_BOOL bRTL) { |
| 235 m_bRTL = bRTL; | 235 m_bRTL = bRTL; |
| 236 } | 236 } |
| 237 void CFX_RTFBreak::SetAlignment(int32_t iAlignment) { | 237 void CFX_RTFBreak::SetAlignment(int32_t iAlignment) { |
| 238 ASSERT(iAlignment >= FX_RTFLINEALIGNMENT_Left && | 238 ASSERT(iAlignment >= FX_RTFLINEALIGNMENT_Left && |
| 239 iAlignment <= FX_RTFLINEALIGNMENT_Distributed); | 239 iAlignment <= FX_RTFLINEALIGNMENT_Distributed); |
| 240 m_iAlignment = iAlignment; | 240 m_iAlignment = iAlignment; |
| 241 } | 241 } |
| 242 void CFX_RTFBreak::SetUserData(IFX_Unknown* pUserData) { | 242 void CFX_RTFBreak::SetUserData(IFX_Retainable* pUserData) { |
| 243 if (m_pUserData == pUserData) { | 243 if (m_pUserData == pUserData) { |
| 244 return; | 244 return; |
| 245 } | 245 } |
| 246 SetBreakStatus(); | 246 SetBreakStatus(); |
| 247 if (m_pUserData != NULL) { | 247 if (m_pUserData != NULL) { |
| 248 m_pUserData->Release(); | 248 m_pUserData->Release(); |
| 249 } | 249 } |
| 250 m_pUserData = pUserData; | 250 m_pUserData = pUserData; |
| 251 if (m_pUserData != NULL) { | 251 if (m_pUserData != NULL) { |
| 252 m_pUserData->AddRef(); | 252 m_pUserData->Retain(); |
| 253 } | 253 } |
| 254 } | 254 } |
| 255 static const int32_t gs_FX_RTFLineRotations[8] = {0, 3, 1, 0, 2, 1, 3, 2}; | 255 static const int32_t gs_FX_RTFLineRotations[8] = {0, 3, 1, 0, 2, 1, 3, 2}; |
| 256 int32_t CFX_RTFBreak::GetLineRotation(uint32_t dwStyles) const { | 256 int32_t CFX_RTFBreak::GetLineRotation(uint32_t dwStyles) const { |
| 257 return gs_FX_RTFLineRotations[(dwStyles & 0x0E) >> 1]; | 257 return gs_FX_RTFLineRotations[(dwStyles & 0x0E) >> 1]; |
| 258 } | 258 } |
| 259 void CFX_RTFBreak::SetBreakStatus() { | 259 void CFX_RTFBreak::SetBreakStatus() { |
| 260 m_dwIdentity++; | 260 m_dwIdentity++; |
| 261 int32_t iCount = m_pCurLine->CountChars(); | 261 int32_t iCount = m_pCurLine->CountChars(); |
| 262 if (iCount < 1) { | 262 if (iCount < 1) { |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 pCurChar->m_dwCharStyles = 0; | 355 pCurChar->m_dwCharStyles = 0; |
| 356 pCurChar->m_dwLayoutStyles = 0; | 356 pCurChar->m_dwLayoutStyles = 0; |
| 357 pCurChar->m_iFontSize = m_iFontSize; | 357 pCurChar->m_iFontSize = m_iFontSize; |
| 358 pCurChar->m_iFontHeight = m_iFontHeight; | 358 pCurChar->m_iFontHeight = m_iFontHeight; |
| 359 pCurChar->m_iHorizontalScale = m_iHorizontalScale; | 359 pCurChar->m_iHorizontalScale = m_iHorizontalScale; |
| 360 pCurChar->m_iVertialScale = m_iVerticalScale; | 360 pCurChar->m_iVertialScale = m_iVerticalScale; |
| 361 pCurChar->m_nRotation = m_iCharRotation; | 361 pCurChar->m_nRotation = m_iCharRotation; |
| 362 pCurChar->m_iCharWidth = 0; | 362 pCurChar->m_iCharWidth = 0; |
| 363 pCurChar->m_dwIdentity = m_dwIdentity; | 363 pCurChar->m_dwIdentity = m_dwIdentity; |
| 364 if (m_pUserData != NULL) { | 364 if (m_pUserData != NULL) { |
| 365 m_pUserData->AddRef(); | 365 m_pUserData->Retain(); |
| 366 } | 366 } |
| 367 pCurChar->m_pUserData = m_pUserData; | 367 pCurChar->m_pUserData = m_pUserData; |
| 368 uint32_t dwRet1 = FX_RTFBREAK_None; | 368 uint32_t dwRet1 = FX_RTFBREAK_None; |
| 369 if (chartype != FX_CHARTYPE_Combination && | 369 if (chartype != FX_CHARTYPE_Combination && |
| 370 GetUnifiedCharType(m_eCharType) != GetUnifiedCharType(chartype)) { | 370 GetUnifiedCharType(m_eCharType) != GetUnifiedCharType(chartype)) { |
| 371 if (!m_bSingleLine && !m_bOrphanLine && | 371 if (!m_bSingleLine && !m_bOrphanLine && |
| 372 m_eCharType != FX_CHARTYPE_Unknown && | 372 m_eCharType != FX_CHARTYPE_Unknown && |
| 373 m_pCurLine->GetLineEnd() > m_iBoundaryEnd + m_iTolerance) { | 373 m_pCurLine->GetLineEnd() > m_iBoundaryEnd + m_iTolerance) { |
| 374 if (m_eCharType != FX_CHARTYPE_Space || chartype != FX_CHARTYPE_Control) { | 374 if (m_eCharType != FX_CHARTYPE_Space || chartype != FX_CHARTYPE_Control) { |
| 375 dwRet1 = EndBreak(FX_RTFBREAK_LineBreak); | 375 dwRet1 = EndBreak(FX_RTFBREAK_LineBreak); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 402 pCurChar->m_dwCharStyles = 0; | 402 pCurChar->m_dwCharStyles = 0; |
| 403 pCurChar->m_dwLayoutStyles = m_dwLayoutStyles; | 403 pCurChar->m_dwLayoutStyles = m_dwLayoutStyles; |
| 404 pCurChar->m_iFontSize = m_iFontSize; | 404 pCurChar->m_iFontSize = m_iFontSize; |
| 405 pCurChar->m_iFontHeight = m_iFontHeight; | 405 pCurChar->m_iFontHeight = m_iFontHeight; |
| 406 pCurChar->m_iHorizontalScale = m_iHorizontalScale; | 406 pCurChar->m_iHorizontalScale = m_iHorizontalScale; |
| 407 pCurChar->m_iVertialScale = m_iVerticalScale; | 407 pCurChar->m_iVertialScale = m_iVerticalScale; |
| 408 pCurChar->m_nRotation = m_iCharRotation; | 408 pCurChar->m_nRotation = m_iCharRotation; |
| 409 pCurChar->m_iCharWidth = 0; | 409 pCurChar->m_iCharWidth = 0; |
| 410 pCurChar->m_dwIdentity = m_dwIdentity; | 410 pCurChar->m_dwIdentity = m_dwIdentity; |
| 411 if (m_pUserData != NULL) { | 411 if (m_pUserData != NULL) { |
| 412 m_pUserData->AddRef(); | 412 m_pUserData->Retain(); |
| 413 } | 413 } |
| 414 pCurChar->m_pUserData = m_pUserData; | 414 pCurChar->m_pUserData = m_pUserData; |
| 415 int32_t iCharWidth = 0; | 415 int32_t iCharWidth = 0; |
| 416 if (m_bVertical != FX_IsOdd(m_iRotation)) { | 416 if (m_bVertical != FX_IsOdd(m_iRotation)) { |
| 417 iCharWidth = 1000; | 417 iCharWidth = 1000; |
| 418 } else { | 418 } else { |
| 419 if (!m_pFont->GetCharWidth(wch, iCharWidth, TRUE)) { | 419 if (!m_pFont->GetCharWidth(wch, iCharWidth, TRUE)) { |
| 420 iCharWidth = m_iDefChar; | 420 iCharWidth = m_iDefChar; |
| 421 } | 421 } |
| 422 } | 422 } |
| (...skipping 1090 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1513 rtBBoxF.height = fHeight; | 1513 rtBBoxF.height = fHeight; |
| 1514 rtBBoxF.top = std::max(rtBBoxF.top, 0.0f); | 1514 rtBBoxF.top = std::max(rtBBoxF.top, 0.0f); |
| 1515 } | 1515 } |
| 1516 rtArray.SetAt(i, rtBBoxF); | 1516 rtArray.SetAt(i, rtBBoxF); |
| 1517 continue; | 1517 continue; |
| 1518 } | 1518 } |
| 1519 rtArray.SetAt(i, rect); | 1519 rtArray.SetAt(i, rect); |
| 1520 } | 1520 } |
| 1521 return iLength; | 1521 return iLength; |
| 1522 } | 1522 } |
| OLD | NEW |