| 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/fxfa/app/xfa_textlayout.h" | 7 #include "xfa/fxfa/app/xfa_textlayout.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 pFontStyle->SetColor(font.GetColor()); | 163 pFontStyle->SetColor(font.GetColor()); |
| 164 pFontStyle->SetFontStyle(font.IsItalic() ? FDE_CSSFONTSTYLE_Italic | 164 pFontStyle->SetFontStyle(font.IsItalic() ? FDE_CSSFONTSTYLE_Italic |
| 165 : FDE_CSSFONTSTYLE_Normal); | 165 : FDE_CSSFONTSTYLE_Normal); |
| 166 pFontStyle->SetFontWeight(font.IsBold() ? FXFONT_FW_BOLD | 166 pFontStyle->SetFontWeight(font.IsBold() ? FXFONT_FW_BOLD |
| 167 : FXFONT_FW_NORMAL); | 167 : FXFONT_FW_NORMAL); |
| 168 pParaStyle->SetNumberVerticalAlign(-font.GetBaselineShift()); | 168 pParaStyle->SetNumberVerticalAlign(-font.GetBaselineShift()); |
| 169 fFontSize = font.GetFontSize(); | 169 fFontSize = font.GetFontSize(); |
| 170 FDE_CSSLENGTH letterSpacing; | 170 FDE_CSSLENGTH letterSpacing; |
| 171 letterSpacing.Set(FDE_CSSLENGTHUNIT_Point, font.GetLetterSpacing()); | 171 letterSpacing.Set(FDE_CSSLENGTHUNIT_Point, font.GetLetterSpacing()); |
| 172 pParaStyle->SetLetterSpacing(letterSpacing); | 172 pParaStyle->SetLetterSpacing(letterSpacing); |
| 173 FX_DWORD dwDecoration = 0; | 173 uint32_t dwDecoration = 0; |
| 174 if (font.GetLineThrough() > 0) { | 174 if (font.GetLineThrough() > 0) { |
| 175 dwDecoration |= FDE_CSSTEXTDECORATION_LineThrough; | 175 dwDecoration |= FDE_CSSTEXTDECORATION_LineThrough; |
| 176 } | 176 } |
| 177 if (font.GetUnderline() > 1) { | 177 if (font.GetUnderline() > 1) { |
| 178 dwDecoration |= FDE_CSSTEXTDECORATION_Double; | 178 dwDecoration |= FDE_CSSTEXTDECORATION_Double; |
| 179 } else if (font.GetUnderline() > 0) { | 179 } else if (font.GetUnderline() > 0) { |
| 180 dwDecoration |= FDE_CSSTEXTDECORATION_Underline; | 180 dwDecoration |= FDE_CSSTEXTDECORATION_Underline; |
| 181 } | 181 } |
| 182 pParaStyle->SetTextDecoration(dwDecoration); | 182 pParaStyle->SetTextDecoration(dwDecoration); |
| 183 } | 183 } |
| 184 pParaStyle->SetLineHeight(fLineHeight); | 184 pParaStyle->SetLineHeight(fLineHeight); |
| 185 pFontStyle->SetFontSize(fFontSize); | 185 pFontStyle->SetFontSize(fFontSize); |
| 186 return pStyle; | 186 return pStyle; |
| 187 } | 187 } |
| 188 IFDE_CSSComputedStyle* CXFA_TextParser::CreateStyle( | 188 IFDE_CSSComputedStyle* CXFA_TextParser::CreateStyle( |
| 189 IFDE_CSSComputedStyle* pParentStyle) { | 189 IFDE_CSSComputedStyle* pParentStyle) { |
| 190 IFDE_CSSComputedStyle* pNewStyle = | 190 IFDE_CSSComputedStyle* pNewStyle = |
| 191 m_pSelector->CreateComputedStyle(pParentStyle); | 191 m_pSelector->CreateComputedStyle(pParentStyle); |
| 192 FXSYS_assert(pNewStyle); | 192 FXSYS_assert(pNewStyle); |
| 193 if (pParentStyle) { | 193 if (pParentStyle) { |
| 194 IFDE_CSSParagraphStyle* pParaStyle = pParentStyle->GetParagraphStyles(); | 194 IFDE_CSSParagraphStyle* pParaStyle = pParentStyle->GetParagraphStyles(); |
| 195 FX_DWORD dwDecoration = pParaStyle->GetTextDecoration(); | 195 uint32_t dwDecoration = pParaStyle->GetTextDecoration(); |
| 196 FX_FLOAT fBaseLine = 0; | 196 FX_FLOAT fBaseLine = 0; |
| 197 if (pParaStyle->GetVerticalAlign() == FDE_CSSVERTICALALIGN_Number) { | 197 if (pParaStyle->GetVerticalAlign() == FDE_CSSVERTICALALIGN_Number) { |
| 198 fBaseLine = pParaStyle->GetNumberVerticalAlign(); | 198 fBaseLine = pParaStyle->GetNumberVerticalAlign(); |
| 199 } | 199 } |
| 200 pParaStyle = pNewStyle->GetParagraphStyles(); | 200 pParaStyle = pNewStyle->GetParagraphStyles(); |
| 201 pParaStyle->SetTextDecoration(dwDecoration); | 201 pParaStyle->SetTextDecoration(dwDecoration); |
| 202 pParaStyle->SetNumberVerticalAlign(fBaseLine); | 202 pParaStyle->SetNumberVerticalAlign(fBaseLine); |
| 203 IFDE_CSSBoundaryStyle* pBoundarytyle = pParentStyle->GetBoundaryStyles(); | 203 IFDE_CSSBoundaryStyle* pBoundarytyle = pParentStyle->GetBoundaryStyles(); |
| 204 const FDE_CSSRECT* pRect = pBoundarytyle->GetMarginWidth(); | 204 const FDE_CSSRECT* pRect = pBoundarytyle->GetMarginWidth(); |
| 205 if (pRect) { | 205 if (pRect) { |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 pXMLNode->GetNodeItem(IFDE_XMLNode::FirstChild); | 282 pXMLNode->GetNodeItem(IFDE_XMLNode::FirstChild); |
| 283 pXMLChild; | 283 pXMLChild; |
| 284 pXMLChild = pXMLChild->GetNodeItem(IFDE_XMLNode::NextSibling)) { | 284 pXMLChild = pXMLChild->GetNodeItem(IFDE_XMLNode::NextSibling)) { |
| 285 ParseRichText(pXMLChild, pNewStyle); | 285 ParseRichText(pXMLChild, pNewStyle); |
| 286 } | 286 } |
| 287 if (pNewStyle) | 287 if (pNewStyle) |
| 288 pNewStyle->Release(); | 288 pNewStyle->Release(); |
| 289 } | 289 } |
| 290 void CXFA_TextParser::ParseTagInfo(IFDE_XMLNode* pXMLNode, | 290 void CXFA_TextParser::ParseTagInfo(IFDE_XMLNode* pXMLNode, |
| 291 CXFA_CSSTagProvider& tagProvider) { | 291 CXFA_CSSTagProvider& tagProvider) { |
| 292 static const FX_DWORD s_XFATagName[] = { | 292 static const uint32_t s_XFATagName[] = { |
| 293 0x61, 0x62, 0x69, 0x70, 0x0001f714, | 293 0x61, 0x62, 0x69, 0x70, 0x0001f714, |
| 294 0x00022a55, 0x000239bb, 0x00025881, 0x0bd37faa, 0x0bd37fb8, | 294 0x00022a55, 0x000239bb, 0x00025881, 0x0bd37faa, 0x0bd37fb8, |
| 295 0xa73e3af2, 0xb182eaae, 0xdb8ac455, | 295 0xa73e3af2, 0xb182eaae, 0xdb8ac455, |
| 296 }; | 296 }; |
| 297 CFX_WideString wsName; | 297 CFX_WideString wsName; |
| 298 if (pXMLNode->GetType() == FDE_XMLNODE_Element) { | 298 if (pXMLNode->GetType() == FDE_XMLNODE_Element) { |
| 299 IFDE_XMLElement* pXMLElement = (IFDE_XMLElement*)pXMLNode; | 299 IFDE_XMLElement* pXMLElement = (IFDE_XMLElement*)pXMLNode; |
| 300 pXMLElement->GetLocalTagName(wsName); | 300 pXMLElement->GetLocalTagName(wsName); |
| 301 tagProvider.SetTagNameObj(wsName); | 301 tagProvider.SetTagNameObj(wsName); |
| 302 FX_DWORD dwHashCode = | 302 uint32_t dwHashCode = |
| 303 FX_HashCode_String_GetW(wsName, wsName.GetLength(), TRUE); | 303 FX_HashCode_String_GetW(wsName, wsName.GetLength(), TRUE); |
| 304 static const int32_t s_iCount = sizeof(s_XFATagName) / sizeof(FX_DWORD); | 304 static const int32_t s_iCount = sizeof(s_XFATagName) / sizeof(uint32_t); |
| 305 CFX_DSPATemplate<FX_DWORD> lookup; | 305 CFX_DSPATemplate<uint32_t> lookup; |
| 306 tagProvider.m_bTagAviliable = | 306 tagProvider.m_bTagAviliable = |
| 307 lookup.Lookup(dwHashCode, s_XFATagName, s_iCount) > -1; | 307 lookup.Lookup(dwHashCode, s_XFATagName, s_iCount) > -1; |
| 308 CFX_WideString wsValue; | 308 CFX_WideString wsValue; |
| 309 pXMLElement->GetString(FX_WSTRC(L"style").GetPtr(), wsValue); | 309 pXMLElement->GetString(FX_WSTRC(L"style").GetPtr(), wsValue); |
| 310 if (!wsValue.IsEmpty()) { | 310 if (!wsValue.IsEmpty()) { |
| 311 tagProvider.SetAttribute(FX_WSTRC(L"style"), wsValue); | 311 tagProvider.SetAttribute(FX_WSTRC(L"style"), wsValue); |
| 312 } | 312 } |
| 313 } else if (pXMLNode->GetType() == FDE_XMLNODE_Text) { | 313 } else if (pXMLNode->GetType() == FDE_XMLNODE_Text) { |
| 314 tagProvider.m_bTagAviliable = TRUE; | 314 tagProvider.m_bTagAviliable = TRUE; |
| 315 tagProvider.m_bContent = TRUE; | 315 tagProvider.m_bContent = TRUE; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 342 CFX_WideString wsValue; | 342 CFX_WideString wsValue; |
| 343 if (pStyle && pStyle->GetCustomStyle(FX_WSTRC(L"xfa-spacerun"), wsValue)) { | 343 if (pStyle && pStyle->GetCustomStyle(FX_WSTRC(L"xfa-spacerun"), wsValue)) { |
| 344 wsValue.MakeLower(); | 344 wsValue.MakeLower(); |
| 345 return wsValue == FX_WSTRC(L"yes"); | 345 return wsValue == FX_WSTRC(L"yes"); |
| 346 } | 346 } |
| 347 return FALSE; | 347 return FALSE; |
| 348 } | 348 } |
| 349 IFX_Font* CXFA_TextParser::GetFont(IXFA_TextProvider* pTextProvider, | 349 IFX_Font* CXFA_TextParser::GetFont(IXFA_TextProvider* pTextProvider, |
| 350 IFDE_CSSComputedStyle* pStyle) const { | 350 IFDE_CSSComputedStyle* pStyle) const { |
| 351 CFX_WideStringC wsFamily = FX_WSTRC(L"Courier"); | 351 CFX_WideStringC wsFamily = FX_WSTRC(L"Courier"); |
| 352 FX_DWORD dwStyle = 0; | 352 uint32_t dwStyle = 0; |
| 353 CXFA_Font font = pTextProvider->GetFontNode(); | 353 CXFA_Font font = pTextProvider->GetFontNode(); |
| 354 if (font) { | 354 if (font) { |
| 355 font.GetTypeface(wsFamily); | 355 font.GetTypeface(wsFamily); |
| 356 if (font.IsBold()) { | 356 if (font.IsBold()) { |
| 357 dwStyle |= FX_FONTSTYLE_Bold; | 357 dwStyle |= FX_FONTSTYLE_Bold; |
| 358 } | 358 } |
| 359 if (font.IsItalic()) { | 359 if (font.IsItalic()) { |
| 360 dwStyle |= FX_FONTSTYLE_Italic; | 360 dwStyle |= FX_FONTSTYLE_Italic; |
| 361 } | 361 } |
| 362 } | 362 } |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 } | 427 } |
| 428 return 100; | 428 return 100; |
| 429 } | 429 } |
| 430 void CXFA_TextParser::GetUnderline(IXFA_TextProvider* pTextProvider, | 430 void CXFA_TextParser::GetUnderline(IXFA_TextProvider* pTextProvider, |
| 431 IFDE_CSSComputedStyle* pStyle, | 431 IFDE_CSSComputedStyle* pStyle, |
| 432 int32_t& iUnderline, | 432 int32_t& iUnderline, |
| 433 int32_t& iPeriod) const { | 433 int32_t& iPeriod) const { |
| 434 iUnderline = 0; | 434 iUnderline = 0; |
| 435 iPeriod = XFA_ATTRIBUTEENUM_All; | 435 iPeriod = XFA_ATTRIBUTEENUM_All; |
| 436 if (pStyle) { | 436 if (pStyle) { |
| 437 FX_DWORD dwDecoration = pStyle->GetParagraphStyles()->GetTextDecoration(); | 437 uint32_t dwDecoration = pStyle->GetParagraphStyles()->GetTextDecoration(); |
| 438 if (dwDecoration & FDE_CSSTEXTDECORATION_Double) { | 438 if (dwDecoration & FDE_CSSTEXTDECORATION_Double) { |
| 439 iUnderline = 2; | 439 iUnderline = 2; |
| 440 } else if (dwDecoration & FDE_CSSTEXTDECORATION_Underline) { | 440 } else if (dwDecoration & FDE_CSSTEXTDECORATION_Underline) { |
| 441 iUnderline = 1; | 441 iUnderline = 1; |
| 442 } | 442 } |
| 443 CFX_WideString wsValue; | 443 CFX_WideString wsValue; |
| 444 if (pStyle->GetCustomStyle(FX_WSTRC(L"underlinePeriod"), wsValue)) { | 444 if (pStyle->GetCustomStyle(FX_WSTRC(L"underlinePeriod"), wsValue)) { |
| 445 if (wsValue == FX_WSTRC(L"word")) { | 445 if (wsValue == FX_WSTRC(L"word")) { |
| 446 iPeriod = XFA_ATTRIBUTEENUM_Word; | 446 iPeriod = XFA_ATTRIBUTEENUM_Word; |
| 447 } | 447 } |
| 448 } else if (CXFA_Font font = pTextProvider->GetFontNode()) { | 448 } else if (CXFA_Font font = pTextProvider->GetFontNode()) { |
| 449 iPeriod = font.GetUnderlinePeriod(); | 449 iPeriod = font.GetUnderlinePeriod(); |
| 450 } | 450 } |
| 451 } else { | 451 } else { |
| 452 CXFA_Font font = pTextProvider->GetFontNode(); | 452 CXFA_Font font = pTextProvider->GetFontNode(); |
| 453 if (font) { | 453 if (font) { |
| 454 iUnderline = font.GetUnderline(); | 454 iUnderline = font.GetUnderline(); |
| 455 iPeriod = font.GetUnderlinePeriod(); | 455 iPeriod = font.GetUnderlinePeriod(); |
| 456 } | 456 } |
| 457 } | 457 } |
| 458 } | 458 } |
| 459 void CXFA_TextParser::GetLinethrough(IXFA_TextProvider* pTextProvider, | 459 void CXFA_TextParser::GetLinethrough(IXFA_TextProvider* pTextProvider, |
| 460 IFDE_CSSComputedStyle* pStyle, | 460 IFDE_CSSComputedStyle* pStyle, |
| 461 int32_t& iLinethrough) const { | 461 int32_t& iLinethrough) const { |
| 462 if (pStyle) { | 462 if (pStyle) { |
| 463 FX_DWORD dwDecoration = pStyle->GetParagraphStyles()->GetTextDecoration(); | 463 uint32_t dwDecoration = pStyle->GetParagraphStyles()->GetTextDecoration(); |
| 464 iLinethrough = (dwDecoration & FDE_CSSTEXTDECORATION_LineThrough) ? 1 : 0; | 464 iLinethrough = (dwDecoration & FDE_CSSTEXTDECORATION_LineThrough) ? 1 : 0; |
| 465 } else { | 465 } else { |
| 466 CXFA_Font font = pTextProvider->GetFontNode(); | 466 CXFA_Font font = pTextProvider->GetFontNode(); |
| 467 if (font) { | 467 if (font) { |
| 468 iLinethrough = font.GetLineThrough(); | 468 iLinethrough = font.GetLineThrough(); |
| 469 } | 469 } |
| 470 } | 470 } |
| 471 } | 471 } |
| 472 FX_ARGB CXFA_TextParser::GetColor(IXFA_TextProvider* pTextProvider, | 472 FX_ARGB CXFA_TextParser::GetColor(IXFA_TextProvider* pTextProvider, |
| 473 IFDE_CSSComputedStyle* pStyle) const { | 473 IFDE_CSSComputedStyle* pStyle) const { |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 633 } | 633 } |
| 634 while (iCur < iLength && pTabStops[iCur] <= ' ') { | 634 while (iCur < iLength && pTabStops[iCur] <= ' ') { |
| 635 iCur++; | 635 iCur++; |
| 636 } | 636 } |
| 637 iLast = iCur; | 637 iLast = iCur; |
| 638 eStatus = XFA_TABSTOPSSTATUS_Location; | 638 eStatus = XFA_TABSTOPSSTATUS_Location; |
| 639 } | 639 } |
| 640 break; | 640 break; |
| 641 case XFA_TABSTOPSSTATUS_Location: | 641 case XFA_TABSTOPSSTATUS_Location: |
| 642 if (ch == ' ') { | 642 if (ch == ' ') { |
| 643 FX_DWORD dwHashCode = | 643 uint32_t dwHashCode = |
| 644 FX_HashCode_String_GetW(wsAlign, wsAlign.GetLength(), TRUE); | 644 FX_HashCode_String_GetW(wsAlign, wsAlign.GetLength(), TRUE); |
| 645 CXFA_Measurement ms(CFX_WideStringC(pTabStops + iLast, iCur - iLast)); | 645 CXFA_Measurement ms(CFX_WideStringC(pTabStops + iLast, iCur - iLast)); |
| 646 FX_FLOAT fPos = ms.ToUnit(XFA_UNIT_Pt); | 646 FX_FLOAT fPos = ms.ToUnit(XFA_UNIT_Pt); |
| 647 pTabstopContext->Append(dwHashCode, fPos); | 647 pTabstopContext->Append(dwHashCode, fPos); |
| 648 wsAlign.Empty(); | 648 wsAlign.Empty(); |
| 649 eStatus = XFA_TABSTOPSSTATUS_None; | 649 eStatus = XFA_TABSTOPSSTATUS_None; |
| 650 } | 650 } |
| 651 iCur++; | 651 iCur++; |
| 652 break; | 652 break; |
| 653 default: | 653 default: |
| 654 break; | 654 break; |
| 655 } | 655 } |
| 656 } | 656 } |
| 657 if (!wsAlign.IsEmpty()) { | 657 if (!wsAlign.IsEmpty()) { |
| 658 FX_DWORD dwHashCode = | 658 uint32_t dwHashCode = |
| 659 FX_HashCode_String_GetW(wsAlign, wsAlign.GetLength(), TRUE); | 659 FX_HashCode_String_GetW(wsAlign, wsAlign.GetLength(), TRUE); |
| 660 CXFA_Measurement ms(CFX_WideStringC(pTabStops + iLast, iCur - iLast)); | 660 CXFA_Measurement ms(CFX_WideStringC(pTabStops + iLast, iCur - iLast)); |
| 661 FX_FLOAT fPos = ms.ToUnit(XFA_UNIT_Pt); | 661 FX_FLOAT fPos = ms.ToUnit(XFA_UNIT_Pt); |
| 662 pTabstopContext->Append(dwHashCode, fPos); | 662 pTabstopContext->Append(dwHashCode, fPos); |
| 663 } | 663 } |
| 664 return TRUE; | 664 return TRUE; |
| 665 } | 665 } |
| 666 CXFA_TextLayout::CXFA_TextLayout(IXFA_TextProvider* pTextProvider) | 666 CXFA_TextLayout::CXFA_TextLayout(IXFA_TextProvider* pTextProvider) |
| 667 : m_bHasBlock(FALSE), | 667 : m_bHasBlock(FALSE), |
| 668 m_pTextProvider(pTextProvider), | 668 m_pTextProvider(pTextProvider), |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 730 if (wsTag.Equal(FX_WSTRC(L"body")) || wsTag.Equal(FX_WSTRC(L"html"))) { | 730 if (wsTag.Equal(FX_WSTRC(L"body")) || wsTag.Equal(FX_WSTRC(L"html"))) { |
| 731 pXMLContainer = pXMLChild; | 731 pXMLContainer = pXMLChild; |
| 732 break; | 732 break; |
| 733 } | 733 } |
| 734 } | 734 } |
| 735 } | 735 } |
| 736 } | 736 } |
| 737 return pXMLContainer; | 737 return pXMLContainer; |
| 738 } | 738 } |
| 739 IFX_RTFBreak* CXFA_TextLayout::CreateBreak(FX_BOOL bDefault) { | 739 IFX_RTFBreak* CXFA_TextLayout::CreateBreak(FX_BOOL bDefault) { |
| 740 FX_DWORD dwStyle = FX_RTFLAYOUTSTYLE_ExpandTab; | 740 uint32_t dwStyle = FX_RTFLAYOUTSTYLE_ExpandTab; |
| 741 if (!bDefault) { | 741 if (!bDefault) { |
| 742 dwStyle |= FX_RTFLAYOUTSTYLE_Pagination; | 742 dwStyle |= FX_RTFLAYOUTSTYLE_Pagination; |
| 743 } | 743 } |
| 744 IFX_RTFBreak* pBreak = IFX_RTFBreak::Create(0); | 744 IFX_RTFBreak* pBreak = IFX_RTFBreak::Create(0); |
| 745 pBreak->SetLayoutStyles(dwStyle); | 745 pBreak->SetLayoutStyles(dwStyle); |
| 746 pBreak->SetLineBreakChar(L'\n'); | 746 pBreak->SetLineBreakChar(L'\n'); |
| 747 pBreak->SetLineBreakTolerance(1); | 747 pBreak->SetLineBreakTolerance(1); |
| 748 pBreak->SetFont(m_textParser.GetFont(m_pTextProvider, NULL)); | 748 pBreak->SetFont(m_textParser.GetFont(m_pTextProvider, NULL)); |
| 749 pBreak->SetFontSize(m_textParser.GetFontSize(m_pTextProvider, NULL)); | 749 pBreak->SetFontSize(m_textParser.GetFontSize(m_pTextProvider, NULL)); |
| 750 return pBreak; | 750 return pBreak; |
| (...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1528 if (bCurLi) { | 1528 if (bCurLi) { |
| 1529 EndBreak(FX_RTFBREAK_LineBreak, fLinePos, bSavePieces); | 1529 EndBreak(FX_RTFBREAK_LineBreak, fLinePos, bSavePieces); |
| 1530 } | 1530 } |
| 1531 } else { | 1531 } else { |
| 1532 if (pContext) { | 1532 if (pContext) { |
| 1533 eDisplay = pContext->GetDisplay(); | 1533 eDisplay = pContext->GetDisplay(); |
| 1534 } | 1534 } |
| 1535 } | 1535 } |
| 1536 if (m_bBlockContinue) { | 1536 if (m_bBlockContinue) { |
| 1537 if (pContext && !bContentNode) { | 1537 if (pContext && !bContentNode) { |
| 1538 FX_DWORD dwStatus = (eDisplay == FDE_CSSDISPLAY_Block) | 1538 uint32_t dwStatus = (eDisplay == FDE_CSSDISPLAY_Block) |
| 1539 ? FX_RTFBREAK_ParagraphBreak | 1539 ? FX_RTFBREAK_ParagraphBreak |
| 1540 : FX_RTFBREAK_PieceBreak; | 1540 : FX_RTFBREAK_PieceBreak; |
| 1541 EndBreak(dwStatus, fLinePos, bSavePieces); | 1541 EndBreak(dwStatus, fLinePos, bSavePieces); |
| 1542 if (eDisplay == FDE_CSSDISPLAY_Block) { | 1542 if (eDisplay == FDE_CSSDISPLAY_Block) { |
| 1543 fLinePos += fSpaceBelow; | 1543 fLinePos += fSpaceBelow; |
| 1544 if (m_pTabstopContext) { | 1544 if (m_pTabstopContext) { |
| 1545 m_pTabstopContext->RemoveAll(); | 1545 m_pTabstopContext->RemoveAll(); |
| 1546 } | 1546 } |
| 1547 } | 1547 } |
| 1548 if (wsName == FX_WSTRC(L"a")) { | 1548 if (wsName == FX_WSTRC(L"a")) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1565 } | 1565 } |
| 1566 } | 1566 } |
| 1567 if (pStyle) | 1567 if (pStyle) |
| 1568 pStyle->Release(); | 1568 pStyle->Release(); |
| 1569 return TRUE; | 1569 return TRUE; |
| 1570 } | 1570 } |
| 1571 FX_BOOL CXFA_TextLayout::AppendChar(const CFX_WideString& wsText, | 1571 FX_BOOL CXFA_TextLayout::AppendChar(const CFX_WideString& wsText, |
| 1572 FX_FLOAT& fLinePos, | 1572 FX_FLOAT& fLinePos, |
| 1573 FX_FLOAT fSpaceAbove, | 1573 FX_FLOAT fSpaceAbove, |
| 1574 FX_BOOL bSavePieces) { | 1574 FX_BOOL bSavePieces) { |
| 1575 FX_DWORD dwStatus = 0; | 1575 uint32_t dwStatus = 0; |
| 1576 int32_t iChar = 0; | 1576 int32_t iChar = 0; |
| 1577 if (m_pLoader) { | 1577 if (m_pLoader) { |
| 1578 iChar = m_pLoader->m_iChar; | 1578 iChar = m_pLoader->m_iChar; |
| 1579 } | 1579 } |
| 1580 int32_t iLength = wsText.GetLength(); | 1580 int32_t iLength = wsText.GetLength(); |
| 1581 for (int32_t i = iChar; i < iLength; i++) { | 1581 for (int32_t i = iChar; i < iLength; i++) { |
| 1582 FX_WCHAR wch = wsText.GetAt(i); | 1582 FX_WCHAR wch = wsText.GetAt(i); |
| 1583 if (wch == 0xA0) { | 1583 if (wch == 0xA0) { |
| 1584 wch = 0x20; | 1584 wch = 0x20; |
| 1585 } | 1585 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1624 } | 1624 } |
| 1625 if (wch == 0x20 && wPrev == 0x20) { | 1625 if (wch == 0x20 && wPrev == 0x20) { |
| 1626 continue; | 1626 continue; |
| 1627 } | 1627 } |
| 1628 wPrev = wch; | 1628 wPrev = wch; |
| 1629 psz[iTrimLeft++] = wch; | 1629 psz[iTrimLeft++] = wch; |
| 1630 } | 1630 } |
| 1631 wsText.ReleaseBuffer(iLen); | 1631 wsText.ReleaseBuffer(iLen); |
| 1632 wsText = wsText.Left(iTrimLeft); | 1632 wsText = wsText.Left(iTrimLeft); |
| 1633 } | 1633 } |
| 1634 void CXFA_TextLayout::EndBreak(FX_DWORD dwStatus, | 1634 void CXFA_TextLayout::EndBreak(uint32_t dwStatus, |
| 1635 FX_FLOAT& fLinePos, | 1635 FX_FLOAT& fLinePos, |
| 1636 FX_BOOL bSavePieces) { | 1636 FX_BOOL bSavePieces) { |
| 1637 dwStatus = m_pBreak->EndBreak(dwStatus); | 1637 dwStatus = m_pBreak->EndBreak(dwStatus); |
| 1638 if (dwStatus > FX_RTFBREAK_PieceBreak) { | 1638 if (dwStatus > FX_RTFBREAK_PieceBreak) { |
| 1639 AppendTextLine(dwStatus, fLinePos, bSavePieces, TRUE); | 1639 AppendTextLine(dwStatus, fLinePos, bSavePieces, TRUE); |
| 1640 } | 1640 } |
| 1641 } | 1641 } |
| 1642 void CXFA_TextLayout::DoTabstops(IFDE_CSSComputedStyle* pStyle, | 1642 void CXFA_TextLayout::DoTabstops(IFDE_CSSComputedStyle* pStyle, |
| 1643 CXFA_PieceLine* pPieceLine) { | 1643 CXFA_PieceLine* pPieceLine) { |
| 1644 if (m_pTabstopContext == NULL || m_pTabstopContext->m_iTabCount == 0) { | 1644 if (m_pTabstopContext == NULL || m_pTabstopContext->m_iTabCount == 0) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1665 XFA_TextPiece* p = pPieceLine->m_textPieces.GetAt(iPieces - 2); | 1665 XFA_TextPiece* p = pPieceLine->m_textPieces.GetAt(iPieces - 2); |
| 1666 fRight = p->rtPiece.right(); | 1666 fRight = p->rtPiece.right(); |
| 1667 } | 1667 } |
| 1668 m_pTabstopContext->m_fTabWidth = | 1668 m_pTabstopContext->m_fTabWidth = |
| 1669 pPiece->rtPiece.width + pPiece->rtPiece.left - fRight; | 1669 pPiece->rtPiece.width + pPiece->rtPiece.left - fRight; |
| 1670 } else if (iTabstopsIndex > -1) { | 1670 } else if (iTabstopsIndex > -1) { |
| 1671 FX_FLOAT fLeft = 0; | 1671 FX_FLOAT fLeft = 0; |
| 1672 if (m_pTabstopContext->m_bTabstops) { | 1672 if (m_pTabstopContext->m_bTabstops) { |
| 1673 XFA_TABSTOPS* pTabstops = | 1673 XFA_TABSTOPS* pTabstops = |
| 1674 m_pTabstopContext->m_tabstops.GetDataPtr(iTabstopsIndex); | 1674 m_pTabstopContext->m_tabstops.GetDataPtr(iTabstopsIndex); |
| 1675 FX_DWORD dwAlgin = pTabstops->dwAlign; | 1675 uint32_t dwAlgin = pTabstops->dwAlign; |
| 1676 if (dwAlgin == FX_HashCode_String_GetW(L"center", 6)) { | 1676 if (dwAlgin == FX_HashCode_String_GetW(L"center", 6)) { |
| 1677 fLeft = pPiece->rtPiece.width / 2.0f; | 1677 fLeft = pPiece->rtPiece.width / 2.0f; |
| 1678 } else if (dwAlgin == FX_HashCode_String_GetW(L"right", 5) || | 1678 } else if (dwAlgin == FX_HashCode_String_GetW(L"right", 5) || |
| 1679 dwAlgin == FX_HashCode_String_GetW(L"before", 6)) { | 1679 dwAlgin == FX_HashCode_String_GetW(L"before", 6)) { |
| 1680 fLeft = pPiece->rtPiece.width; | 1680 fLeft = pPiece->rtPiece.width; |
| 1681 } else if (dwAlgin == FX_HashCode_String_GetW(L"decimal", 7)) { | 1681 } else if (dwAlgin == FX_HashCode_String_GetW(L"decimal", 7)) { |
| 1682 int32_t iChars = pPiece->iChars; | 1682 int32_t iChars = pPiece->iChars; |
| 1683 for (int32_t i = 0; i < iChars; i++) { | 1683 for (int32_t i = 0; i < iChars; i++) { |
| 1684 if (pPiece->pszText[i] == L'.') { | 1684 if (pPiece->pszText[i] == L'.') { |
| 1685 break; | 1685 break; |
| 1686 } | 1686 } |
| 1687 fLeft += pPiece->pWidths[i] / 20000.0f; | 1687 fLeft += pPiece->pWidths[i] / 20000.0f; |
| 1688 } | 1688 } |
| 1689 } | 1689 } |
| 1690 m_pTabstopContext->m_fLeft = | 1690 m_pTabstopContext->m_fLeft = |
| 1691 std::min(fLeft, m_pTabstopContext->m_fTabWidth); | 1691 std::min(fLeft, m_pTabstopContext->m_fTabWidth); |
| 1692 m_pTabstopContext->m_bTabstops = FALSE; | 1692 m_pTabstopContext->m_bTabstops = FALSE; |
| 1693 m_pTabstopContext->m_fTabWidth = 0; | 1693 m_pTabstopContext->m_fTabWidth = 0; |
| 1694 } | 1694 } |
| 1695 pPiece->rtPiece.left -= m_pTabstopContext->m_fLeft; | 1695 pPiece->rtPiece.left -= m_pTabstopContext->m_fLeft; |
| 1696 } | 1696 } |
| 1697 } | 1697 } |
| 1698 void CXFA_TextLayout::AppendTextLine(FX_DWORD dwStatus, | 1698 void CXFA_TextLayout::AppendTextLine(uint32_t dwStatus, |
| 1699 FX_FLOAT& fLinePos, | 1699 FX_FLOAT& fLinePos, |
| 1700 FX_BOOL bSavePieces, | 1700 FX_BOOL bSavePieces, |
| 1701 FX_BOOL bEndBreak) { | 1701 FX_BOOL bEndBreak) { |
| 1702 int32_t iPieces = m_pBreak->CountBreakPieces(); | 1702 int32_t iPieces = m_pBreak->CountBreakPieces(); |
| 1703 if (iPieces < 1) { | 1703 if (iPieces < 1) { |
| 1704 return; | 1704 return; |
| 1705 } | 1705 } |
| 1706 IFDE_CSSComputedStyle* pStyle = NULL; | 1706 IFDE_CSSComputedStyle* pStyle = NULL; |
| 1707 if (bSavePieces) { | 1707 if (bSavePieces) { |
| 1708 CXFA_PieceLine* pPieceLine = FXTARGET_NewWith(m_pAllocator) CXFA_PieceLine; | 1708 CXFA_PieceLine* pPieceLine = FXTARGET_NewWith(m_pAllocator) CXFA_PieceLine; |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1992 tr.iLength = iLength; | 1992 tr.iLength = iLength; |
| 1993 tr.fFontSize = pPiece->fFontSize; | 1993 tr.fFontSize = pPiece->fFontSize; |
| 1994 tr.iBidiLevel = pPiece->iBidiLevel; | 1994 tr.iBidiLevel = pPiece->iBidiLevel; |
| 1995 tr.iCharRotation = 0; | 1995 tr.iCharRotation = 0; |
| 1996 tr.wLineBreakChar = L'\n'; | 1996 tr.wLineBreakChar = L'\n'; |
| 1997 tr.iVerticalScale = pPiece->iVerScale; | 1997 tr.iVerticalScale = pPiece->iVerScale; |
| 1998 tr.dwLayoutStyles = FX_RTFLAYOUTSTYLE_ExpandTab; | 1998 tr.dwLayoutStyles = FX_RTFLAYOUTSTYLE_ExpandTab; |
| 1999 tr.iHorizontalScale = pPiece->iHorScale; | 1999 tr.iHorizontalScale = pPiece->iHorScale; |
| 2000 return TRUE; | 2000 return TRUE; |
| 2001 } | 2001 } |
| OLD | NEW |