| 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 L"style:italic}" | 95 L"style:italic}" |
| 96 L"sup{vertical-align:+15em;font-size:.66em}sub{vertical-align:-15em;font-" | 96 L"sup{vertical-align:+15em;font-size:.66em}sub{vertical-align:-15em;font-" |
| 97 L"size:.66em}"; | 97 L"size:.66em}"; |
| 98 return IFDE_CSSStyleSheet::LoadFromBuffer( | 98 return IFDE_CSSStyleSheet::LoadFromBuffer( |
| 99 CFX_WideString(), s_pStyle, FXSYS_wcslen(s_pStyle), FX_CODEPAGE_UTF8); | 99 CFX_WideString(), s_pStyle, FXSYS_wcslen(s_pStyle), FX_CODEPAGE_UTF8); |
| 100 } | 100 } |
| 101 IFDE_CSSComputedStyle* CXFA_TextParser::CreateRootStyle( | 101 IFDE_CSSComputedStyle* CXFA_TextParser::CreateRootStyle( |
| 102 CXFA_TextProvider* pTextProvider) { | 102 CXFA_TextProvider* pTextProvider) { |
| 103 CXFA_Font font = pTextProvider->GetFontNode(); | 103 CXFA_Font font = pTextProvider->GetFontNode(); |
| 104 CXFA_Para para = pTextProvider->GetParaNode(); | 104 CXFA_Para para = pTextProvider->GetParaNode(); |
| 105 IFDE_CSSComputedStyle* pStyle = m_pSelector->CreateComputedStyle(NULL); | 105 IFDE_CSSComputedStyle* pStyle = m_pSelector->CreateComputedStyle(nullptr); |
| 106 IFDE_CSSFontStyle* pFontStyle = pStyle->GetFontStyles(); | 106 IFDE_CSSFontStyle* pFontStyle = pStyle->GetFontStyles(); |
| 107 IFDE_CSSParagraphStyle* pParaStyle = pStyle->GetParagraphStyles(); | 107 IFDE_CSSParagraphStyle* pParaStyle = pStyle->GetParagraphStyles(); |
| 108 FX_FLOAT fLineHeight = 0, fFontSize = 10; | 108 FX_FLOAT fLineHeight = 0, fFontSize = 10; |
| 109 if (para) { | 109 if (para) { |
| 110 fLineHeight = para.GetLineHeight(); | 110 fLineHeight = para.GetLineHeight(); |
| 111 FDE_CSSLENGTH indent; | 111 FDE_CSSLENGTH indent; |
| 112 indent.Set(FDE_CSSLENGTHUNIT_Point, para.GetTextIndent()); | 112 indent.Set(FDE_CSSLENGTHUNIT_Point, para.GetTextIndent()); |
| 113 pParaStyle->SetTextIndent(indent); | 113 pParaStyle->SetTextIndent(indent); |
| 114 FDE_CSSTEXTALIGN hAlign = FDE_CSSTEXTALIGN_Left; | 114 FDE_CSSTEXTALIGN hAlign = FDE_CSSTEXTALIGN_Left; |
| 115 switch (para.GetHorizontalAlign()) { | 115 switch (para.GetHorizontalAlign()) { |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 IFDE_CSSComputedStyle* pStyle = CreateStyle(pParentStyle); | 200 IFDE_CSSComputedStyle* pStyle = CreateStyle(pParentStyle); |
| 201 CFDE_CSSAccelerator* pCSSAccel = m_pSelector->InitAccelerator(); | 201 CFDE_CSSAccelerator* pCSSAccel = m_pSelector->InitAccelerator(); |
| 202 pCSSAccel->OnEnterTag(&tagProvider); | 202 pCSSAccel->OnEnterTag(&tagProvider); |
| 203 m_pSelector->ComputeStyle(&tagProvider, pContext->GetDecls(), | 203 m_pSelector->ComputeStyle(&tagProvider, pContext->GetDecls(), |
| 204 pContext->CountDecls(), pStyle); | 204 pContext->CountDecls(), pStyle); |
| 205 pCSSAccel->OnLeaveTag(&tagProvider); | 205 pCSSAccel->OnLeaveTag(&tagProvider); |
| 206 return pStyle; | 206 return pStyle; |
| 207 } | 207 } |
| 208 void CXFA_TextParser::DoParse(CFDE_XMLNode* pXMLContainer, | 208 void CXFA_TextParser::DoParse(CFDE_XMLNode* pXMLContainer, |
| 209 CXFA_TextProvider* pTextProvider) { | 209 CXFA_TextProvider* pTextProvider) { |
| 210 if (pXMLContainer == NULL || pTextProvider == NULL || m_pAllocator) { | 210 if (!pXMLContainer || !pTextProvider || m_pAllocator) |
| 211 return; | 211 return; |
| 212 } | 212 |
| 213 m_pAllocator.reset(IFX_MemoryAllocator::Create(FX_ALLOCTYPE_Fixed, 32, | 213 m_pAllocator.reset(IFX_MemoryAllocator::Create(FX_ALLOCTYPE_Fixed, 32, |
| 214 sizeof(CXFA_CSSTagProvider))); | 214 sizeof(CXFA_CSSTagProvider))); |
| 215 InitCSSData(pTextProvider); | 215 InitCSSData(pTextProvider); |
| 216 IFDE_CSSComputedStyle* pRootStyle = CreateRootStyle(pTextProvider); | 216 IFDE_CSSComputedStyle* pRootStyle = CreateRootStyle(pTextProvider); |
| 217 ParseRichText(pXMLContainer, pRootStyle); | 217 ParseRichText(pXMLContainer, pRootStyle); |
| 218 pRootStyle->Release(); | 218 pRootStyle->Release(); |
| 219 } | 219 } |
| 220 void CXFA_TextParser::ParseRichText(CFDE_XMLNode* pXMLNode, | 220 void CXFA_TextParser::ParseRichText(CFDE_XMLNode* pXMLNode, |
| 221 IFDE_CSSComputedStyle* pParentStyle) { | 221 IFDE_CSSComputedStyle* pParentStyle) { |
| 222 if (!pXMLNode) | 222 if (!pXMLNode) |
| 223 return; | 223 return; |
| 224 | 224 |
| 225 CXFA_CSSTagProvider tagProvider; | 225 CXFA_CSSTagProvider tagProvider; |
| 226 ParseTagInfo(pXMLNode, tagProvider); | 226 ParseTagInfo(pXMLNode, tagProvider); |
| 227 if (!tagProvider.m_bTagAvailable) | 227 if (!tagProvider.m_bTagAvailable) |
| 228 return; | 228 return; |
| 229 | 229 |
| 230 IFDE_CSSComputedStyle* pNewStyle = NULL; | 230 IFDE_CSSComputedStyle* pNewStyle = nullptr; |
| 231 if ((tagProvider.GetTagName() != FX_WSTRC(L"body")) || | 231 if ((tagProvider.GetTagName() != FX_WSTRC(L"body")) || |
| 232 (tagProvider.GetTagName() != FX_WSTRC(L"html"))) { | 232 (tagProvider.GetTagName() != FX_WSTRC(L"html"))) { |
| 233 CXFA_TextParseContext* pTextContext = | 233 CXFA_TextParseContext* pTextContext = |
| 234 FXTARGET_NewWith(m_pAllocator.get()) CXFA_TextParseContext; | 234 FXTARGET_NewWith(m_pAllocator.get()) CXFA_TextParseContext; |
| 235 FDE_CSSDISPLAY eDisplay = FDE_CSSDISPLAY_Inline; | 235 FDE_CSSDISPLAY eDisplay = FDE_CSSDISPLAY_Inline; |
| 236 if (!tagProvider.m_bContent) { | 236 if (!tagProvider.m_bContent) { |
| 237 pNewStyle = CreateStyle(pParentStyle); | 237 pNewStyle = CreateStyle(pParentStyle); |
| 238 CFDE_CSSAccelerator* pCSSAccel = m_pSelector->InitAccelerator(); | 238 CFDE_CSSAccelerator* pCSSAccel = m_pSelector->InitAccelerator(); |
| 239 pCSSAccel->OnEnterTag(&tagProvider); | 239 pCSSAccel->OnEnterTag(&tagProvider); |
| 240 CFDE_CSSDeclarationArray DeclArray; | 240 CFDE_CSSDeclarationArray DeclArray; |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 } else if (fLineHeight < 0.1f) { | 497 } else if (fLineHeight < 0.1f) { |
| 498 fLineHeight = GetFontSize(pTextProvider, pStyle) * 1.2f; | 498 fLineHeight = GetFontSize(pTextProvider, pStyle) * 1.2f; |
| 499 } | 499 } |
| 500 fLineHeight *= fVerScale; | 500 fLineHeight *= fVerScale; |
| 501 return fLineHeight; | 501 return fLineHeight; |
| 502 } | 502 } |
| 503 FX_BOOL CXFA_TextParser::GetEmbbedObj(CXFA_TextProvider* pTextProvider, | 503 FX_BOOL CXFA_TextParser::GetEmbbedObj(CXFA_TextProvider* pTextProvider, |
| 504 CFDE_XMLNode* pXMLNode, | 504 CFDE_XMLNode* pXMLNode, |
| 505 CFX_WideString& wsValue) { | 505 CFX_WideString& wsValue) { |
| 506 wsValue.clear(); | 506 wsValue.clear(); |
| 507 if (pXMLNode == NULL) { | 507 if (!pXMLNode) |
| 508 return FALSE; | 508 return FALSE; |
| 509 } | 509 |
| 510 FX_BOOL bRet = FALSE; | 510 FX_BOOL bRet = FALSE; |
| 511 if (pXMLNode->GetType() == FDE_XMLNODE_Element) { | 511 if (pXMLNode->GetType() == FDE_XMLNODE_Element) { |
| 512 CFDE_XMLElement* pElement = static_cast<CFDE_XMLElement*>(pXMLNode); | 512 CFDE_XMLElement* pElement = static_cast<CFDE_XMLElement*>(pXMLNode); |
| 513 CFX_WideString wsAttr; | 513 CFX_WideString wsAttr; |
| 514 pElement->GetString(L"xfa:embed", wsAttr); | 514 pElement->GetString(L"xfa:embed", wsAttr); |
| 515 if (wsAttr.IsEmpty()) { | 515 if (wsAttr.IsEmpty()) { |
| 516 return FALSE; | 516 return FALSE; |
| 517 } | 517 } |
| 518 if (wsAttr.GetAt(0) == L'#') { | 518 if (wsAttr.GetAt(0) == L'#') { |
| 519 wsAttr.Delete(0); | 519 wsAttr.Delete(0); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 554 XFA_TABSTOPSSTATUS_EOS, | 554 XFA_TABSTOPSSTATUS_EOS, |
| 555 XFA_TABSTOPSSTATUS_None, | 555 XFA_TABSTOPSSTATUS_None, |
| 556 XFA_TABSTOPSSTATUS_Alignment, | 556 XFA_TABSTOPSSTATUS_Alignment, |
| 557 XFA_TABSTOPSSTATUS_StartLeader, | 557 XFA_TABSTOPSSTATUS_StartLeader, |
| 558 XFA_TABSTOPSSTATUS_Leader, | 558 XFA_TABSTOPSSTATUS_Leader, |
| 559 XFA_TABSTOPSSTATUS_Location, | 559 XFA_TABSTOPSSTATUS_Location, |
| 560 }; | 560 }; |
| 561 FX_BOOL CXFA_TextParser::GetTabstops( | 561 FX_BOOL CXFA_TextParser::GetTabstops( |
| 562 IFDE_CSSComputedStyle* pStyle, | 562 IFDE_CSSComputedStyle* pStyle, |
| 563 CXFA_TextTabstopsContext* pTabstopContext) { | 563 CXFA_TextTabstopsContext* pTabstopContext) { |
| 564 if (pStyle == NULL || pTabstopContext == NULL) { | 564 if (!pStyle || !pTabstopContext) |
| 565 return FALSE; | 565 return FALSE; |
| 566 } | 566 |
| 567 CFX_WideString wsValue; | 567 CFX_WideString wsValue; |
| 568 if (!pStyle->GetCustomStyle(FX_WSTRC(L"xfa-tab-stops"), wsValue) && | 568 if (!pStyle->GetCustomStyle(FX_WSTRC(L"xfa-tab-stops"), wsValue) && |
| 569 !pStyle->GetCustomStyle(FX_WSTRC(L"tab-stops"), wsValue)) { | 569 !pStyle->GetCustomStyle(FX_WSTRC(L"tab-stops"), wsValue)) { |
| 570 return FALSE; | 570 return FALSE; |
| 571 } | 571 } |
| 572 int32_t iLength = wsValue.GetLength(); | 572 int32_t iLength = wsValue.GetLength(); |
| 573 const FX_WCHAR* pTabStops = wsValue.c_str(); | 573 const FX_WCHAR* pTabStops = wsValue.c_str(); |
| 574 int32_t iCur = 0; | 574 int32_t iCur = 0; |
| 575 int32_t iLast = 0; | 575 int32_t iLast = 0; |
| 576 CFX_WideString wsAlign; | 576 CFX_WideString wsAlign; |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 668 FXTARGET_DeleteWith(CXFA_PieceLine, m_pAllocator.get(), pLine); | 668 FXTARGET_DeleteWith(CXFA_PieceLine, m_pAllocator.get(), pLine); |
| 669 } | 669 } |
| 670 m_pieceLines.RemoveAll(); | 670 m_pieceLines.RemoveAll(); |
| 671 m_pBreak.reset(); | 671 m_pBreak.reset(); |
| 672 m_pAllocator.reset(); | 672 m_pAllocator.reset(); |
| 673 } | 673 } |
| 674 const CXFA_PieceLineArray* CXFA_TextLayout::GetPieceLines() { | 674 const CXFA_PieceLineArray* CXFA_TextLayout::GetPieceLines() { |
| 675 return &m_pieceLines; | 675 return &m_pieceLines; |
| 676 } | 676 } |
| 677 void CXFA_TextLayout::GetTextDataNode() { | 677 void CXFA_TextLayout::GetTextDataNode() { |
| 678 if (m_pTextProvider == NULL) { | 678 if (!m_pTextProvider) |
| 679 return; | 679 return; |
| 680 } | 680 |
| 681 CXFA_Node* pNode = m_pTextProvider->GetTextNode(m_bRichText); | 681 CXFA_Node* pNode = m_pTextProvider->GetTextNode(m_bRichText); |
| 682 if (pNode && m_bRichText) { | 682 if (pNode && m_bRichText) { |
| 683 m_textParser.Reset(); | 683 m_textParser.Reset(); |
| 684 } | 684 } |
| 685 m_pTextDataNode = pNode; | 685 m_pTextDataNode = pNode; |
| 686 } | 686 } |
| 687 CFDE_XMLNode* CXFA_TextLayout::GetXMLContainerNode() { | 687 CFDE_XMLNode* CXFA_TextLayout::GetXMLContainerNode() { |
| 688 CFDE_XMLNode* pXMLContainer = NULL; | 688 CFDE_XMLNode* pXMLContainer = nullptr; |
| 689 if (m_bRichText) { | 689 if (m_bRichText) { |
| 690 CFDE_XMLNode* pXMLRoot = m_pTextDataNode->GetXMLMappingNode(); | 690 CFDE_XMLNode* pXMLRoot = m_pTextDataNode->GetXMLMappingNode(); |
| 691 if (!pXMLRoot) { | 691 if (!pXMLRoot) { |
| 692 return pXMLContainer; | 692 return pXMLContainer; |
| 693 } | 693 } |
| 694 for (CFDE_XMLNode* pXMLChild = | 694 for (CFDE_XMLNode* pXMLChild = |
| 695 pXMLRoot->GetNodeItem(CFDE_XMLNode::FirstChild); | 695 pXMLRoot->GetNodeItem(CFDE_XMLNode::FirstChild); |
| 696 pXMLChild; | 696 pXMLChild; |
| 697 pXMLChild = pXMLChild->GetNodeItem(CFDE_XMLNode::NextSibling)) { | 697 pXMLChild = pXMLChild->GetNodeItem(CFDE_XMLNode::NextSibling)) { |
| 698 if (pXMLChild->GetType() == FDE_XMLNODE_Element) { | 698 if (pXMLChild->GetType() == FDE_XMLNODE_Element) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 710 } | 710 } |
| 711 CFX_RTFBreak* CXFA_TextLayout::CreateBreak(FX_BOOL bDefault) { | 711 CFX_RTFBreak* CXFA_TextLayout::CreateBreak(FX_BOOL bDefault) { |
| 712 uint32_t dwStyle = FX_RTFLAYOUTSTYLE_ExpandTab; | 712 uint32_t dwStyle = FX_RTFLAYOUTSTYLE_ExpandTab; |
| 713 if (!bDefault) { | 713 if (!bDefault) { |
| 714 dwStyle |= FX_RTFLAYOUTSTYLE_Pagination; | 714 dwStyle |= FX_RTFLAYOUTSTYLE_Pagination; |
| 715 } | 715 } |
| 716 CFX_RTFBreak* pBreak = new CFX_RTFBreak(0); | 716 CFX_RTFBreak* pBreak = new CFX_RTFBreak(0); |
| 717 pBreak->SetLayoutStyles(dwStyle); | 717 pBreak->SetLayoutStyles(dwStyle); |
| 718 pBreak->SetLineBreakChar(L'\n'); | 718 pBreak->SetLineBreakChar(L'\n'); |
| 719 pBreak->SetLineBreakTolerance(1); | 719 pBreak->SetLineBreakTolerance(1); |
| 720 pBreak->SetFont(m_textParser.GetFont(m_pTextProvider, NULL)); | 720 pBreak->SetFont(m_textParser.GetFont(m_pTextProvider, nullptr)); |
| 721 pBreak->SetFontSize(m_textParser.GetFontSize(m_pTextProvider, NULL)); | 721 pBreak->SetFontSize(m_textParser.GetFontSize(m_pTextProvider, nullptr)); |
| 722 return pBreak; | 722 return pBreak; |
| 723 } | 723 } |
| 724 void CXFA_TextLayout::InitBreak(FX_FLOAT fLineWidth) { | 724 void CXFA_TextLayout::InitBreak(FX_FLOAT fLineWidth) { |
| 725 CXFA_Font font = m_pTextProvider->GetFontNode(); | 725 CXFA_Font font = m_pTextProvider->GetFontNode(); |
| 726 CXFA_Para para = m_pTextProvider->GetParaNode(); | 726 CXFA_Para para = m_pTextProvider->GetParaNode(); |
| 727 FX_FLOAT fStart = 0; | 727 FX_FLOAT fStart = 0; |
| 728 FX_FLOAT fStartPos = 0; | 728 FX_FLOAT fStartPos = 0; |
| 729 if (para) { | 729 if (para) { |
| 730 int32_t iAlign = FX_RTFLINEALIGNMENT_Left; | 730 int32_t iAlign = FX_RTFLINEALIGNMENT_Left; |
| 731 switch (para.GetHorizontalAlign()) { | 731 switch (para.GetHorizontalAlign()) { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 760 fStartPos += fIndent; | 760 fStartPos += fIndent; |
| 761 } | 761 } |
| 762 } | 762 } |
| 763 m_pBreak->SetLineBoundary(fStart, fLineWidth); | 763 m_pBreak->SetLineBoundary(fStart, fLineWidth); |
| 764 m_pBreak->SetLineStartPos(fStartPos); | 764 m_pBreak->SetLineStartPos(fStartPos); |
| 765 if (font) { | 765 if (font) { |
| 766 m_pBreak->SetHorizontalScale((int32_t)font.GetHorizontalScale()); | 766 m_pBreak->SetHorizontalScale((int32_t)font.GetHorizontalScale()); |
| 767 m_pBreak->SetVerticalScale((int32_t)font.GetVerticalScale()); | 767 m_pBreak->SetVerticalScale((int32_t)font.GetVerticalScale()); |
| 768 m_pBreak->SetCharSpace(font.GetLetterSpacing()); | 768 m_pBreak->SetCharSpace(font.GetLetterSpacing()); |
| 769 } | 769 } |
| 770 FX_FLOAT fFontSize = m_textParser.GetFontSize(m_pTextProvider, NULL); | 770 FX_FLOAT fFontSize = m_textParser.GetFontSize(m_pTextProvider, nullptr); |
| 771 m_pBreak->SetFontSize(fFontSize); | 771 m_pBreak->SetFontSize(fFontSize); |
| 772 m_pBreak->SetFont(m_textParser.GetFont(m_pTextProvider, NULL)); | 772 m_pBreak->SetFont(m_textParser.GetFont(m_pTextProvider, nullptr)); |
| 773 m_pBreak->SetLineBreakTolerance(fFontSize * 0.2f); | 773 m_pBreak->SetLineBreakTolerance(fFontSize * 0.2f); |
| 774 } | 774 } |
| 775 void CXFA_TextLayout::InitBreak(IFDE_CSSComputedStyle* pStyle, | 775 void CXFA_TextLayout::InitBreak(IFDE_CSSComputedStyle* pStyle, |
| 776 FDE_CSSDISPLAY eDisplay, | 776 FDE_CSSDISPLAY eDisplay, |
| 777 FX_FLOAT fLineWidth, | 777 FX_FLOAT fLineWidth, |
| 778 CFDE_XMLNode* pXMLNode, | 778 CFDE_XMLNode* pXMLNode, |
| 779 IFDE_CSSComputedStyle* pParentStyle) { | 779 IFDE_CSSComputedStyle* pParentStyle) { |
| 780 if (pStyle == NULL) { | 780 if (!pStyle) { |
| 781 InitBreak(fLineWidth); | 781 InitBreak(fLineWidth); |
| 782 return; | 782 return; |
| 783 } | 783 } |
| 784 IFDE_CSSParagraphStyle* pParaStyle = pStyle->GetParagraphStyles(); | 784 IFDE_CSSParagraphStyle* pParaStyle = pStyle->GetParagraphStyles(); |
| 785 if (eDisplay == FDE_CSSDISPLAY_Block || eDisplay == FDE_CSSDISPLAY_ListItem) { | 785 if (eDisplay == FDE_CSSDISPLAY_Block || eDisplay == FDE_CSSDISPLAY_ListItem) { |
| 786 int32_t iAlign = FX_RTFLINEALIGNMENT_Left; | 786 int32_t iAlign = FX_RTFLINEALIGNMENT_Left; |
| 787 switch (pParaStyle->GetTextAlign()) { | 787 switch (pParaStyle->GetTextAlign()) { |
| 788 case FDE_CSSTEXTALIGN_Right: | 788 case FDE_CSSTEXTALIGN_Right: |
| 789 iAlign = FX_RTFLINEALIGNMENT_Right; | 789 iAlign = FX_RTFLINEALIGNMENT_Right; |
| 790 break; | 790 break; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 860 int32_t CXFA_TextLayout::GetText(CFX_WideString& wsText) { | 860 int32_t CXFA_TextLayout::GetText(CFX_WideString& wsText) { |
| 861 GetTextDataNode(); | 861 GetTextDataNode(); |
| 862 wsText.clear(); | 862 wsText.clear(); |
| 863 if (m_bRichText) { | 863 if (m_bRichText) { |
| 864 } else { | 864 } else { |
| 865 wsText = m_pTextDataNode->GetContent(); | 865 wsText = m_pTextDataNode->GetContent(); |
| 866 } | 866 } |
| 867 return wsText.GetLength(); | 867 return wsText.GetLength(); |
| 868 } | 868 } |
| 869 FX_FLOAT CXFA_TextLayout::GetLayoutHeight() { | 869 FX_FLOAT CXFA_TextLayout::GetLayoutHeight() { |
| 870 if (m_pLoader == NULL) { | 870 if (!m_pLoader) |
| 871 return 0; | 871 return 0; |
| 872 } | 872 |
| 873 int32_t iCount = m_pLoader->m_lineHeights.GetSize(); | 873 int32_t iCount = m_pLoader->m_lineHeights.GetSize(); |
| 874 if (iCount == 0 && m_pLoader->m_fWidth > 0) { | 874 if (iCount == 0 && m_pLoader->m_fWidth > 0) { |
| 875 CFX_SizeF szMax(m_pLoader->m_fWidth, m_pLoader->m_fHeight); | 875 CFX_SizeF szMax(m_pLoader->m_fWidth, m_pLoader->m_fHeight); |
| 876 CFX_SizeF szDef; | 876 CFX_SizeF szDef; |
| 877 m_pLoader->m_bSaveLineHeight = TRUE; | 877 m_pLoader->m_bSaveLineHeight = TRUE; |
| 878 m_pLoader->m_fLastPos = 0; | 878 m_pLoader->m_fLastPos = 0; |
| 879 CalcSize(szMax, szMax, szDef); | 879 CalcSize(szMax, szMax, szDef); |
| 880 m_pLoader->m_bSaveLineHeight = FALSE; | 880 m_pLoader->m_bSaveLineHeight = FALSE; |
| 881 return szDef.y; | 881 return szDef.y; |
| 882 } | 882 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 909 CalcSize(szMax, szMax, szDef); | 909 CalcSize(szMax, szMax, szDef); |
| 910 m_pLoader->m_bSaveLineHeight = FALSE; | 910 m_pLoader->m_bSaveLineHeight = FALSE; |
| 911 fWidth = szDef.x; | 911 fWidth = szDef.x; |
| 912 } | 912 } |
| 913 return fWidth; | 913 return fWidth; |
| 914 } | 914 } |
| 915 FX_BOOL CXFA_TextLayout::DoLayout(int32_t iBlockIndex, | 915 FX_BOOL CXFA_TextLayout::DoLayout(int32_t iBlockIndex, |
| 916 FX_FLOAT& fCalcHeight, | 916 FX_FLOAT& fCalcHeight, |
| 917 FX_FLOAT fContentAreaHeight, | 917 FX_FLOAT fContentAreaHeight, |
| 918 FX_FLOAT fTextHeight) { | 918 FX_FLOAT fTextHeight) { |
| 919 if (m_pLoader == NULL) { | 919 if (!m_pLoader) |
| 920 return FALSE; | 920 return FALSE; |
| 921 } | 921 |
| 922 int32_t iBlockCount = m_Blocks.GetSize(); | 922 int32_t iBlockCount = m_Blocks.GetSize(); |
| 923 FX_FLOAT fHeight = fTextHeight; | 923 FX_FLOAT fHeight = fTextHeight; |
| 924 if (fHeight < 0) { | 924 if (fHeight < 0) { |
| 925 fHeight = GetLayoutHeight(); | 925 fHeight = GetLayoutHeight(); |
| 926 } | 926 } |
| 927 m_pLoader->m_fHeight = fHeight; | 927 m_pLoader->m_fHeight = fHeight; |
| 928 if (fContentAreaHeight < 0) { | 928 if (fContentAreaHeight < 0) { |
| 929 return FALSE; | 929 return FALSE; |
| 930 } | 930 } |
| 931 m_bHasBlock = TRUE; | 931 m_bHasBlock = TRUE; |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1003 defaultSize.x = maxSize.x; | 1003 defaultSize.x = maxSize.x; |
| 1004 if (defaultSize.x < 1) | 1004 if (defaultSize.x < 1) |
| 1005 defaultSize.x = 0xFFFF; | 1005 defaultSize.x = 0xFFFF; |
| 1006 | 1006 |
| 1007 m_pBreak.reset(CreateBreak(FALSE)); | 1007 m_pBreak.reset(CreateBreak(FALSE)); |
| 1008 FX_FLOAT fLinePos = 0; | 1008 FX_FLOAT fLinePos = 0; |
| 1009 m_iLines = 0; | 1009 m_iLines = 0; |
| 1010 m_fMaxWidth = 0; | 1010 m_fMaxWidth = 0; |
| 1011 Loader(defaultSize, fLinePos, FALSE); | 1011 Loader(defaultSize, fLinePos, FALSE); |
| 1012 if (fLinePos < 0.1f) | 1012 if (fLinePos < 0.1f) |
| 1013 fLinePos = m_textParser.GetFontSize(m_pTextProvider, NULL); | 1013 fLinePos = m_textParser.GetFontSize(m_pTextProvider, nullptr); |
| 1014 | 1014 |
| 1015 m_pTabstopContext.reset(); | 1015 m_pTabstopContext.reset(); |
| 1016 defaultSize = CFX_SizeF(m_fMaxWidth, fLinePos); | 1016 defaultSize = CFX_SizeF(m_fMaxWidth, fLinePos); |
| 1017 return TRUE; | 1017 return TRUE; |
| 1018 } | 1018 } |
| 1019 | 1019 |
| 1020 FX_BOOL CXFA_TextLayout::Layout(const CFX_SizeF& size, FX_FLOAT* fHeight) { | 1020 FX_BOOL CXFA_TextLayout::Layout(const CFX_SizeF& size, FX_FLOAT* fHeight) { |
| 1021 if (size.x < 1) | 1021 if (size.x < 1) |
| 1022 return FALSE; | 1022 return FALSE; |
| 1023 | 1023 |
| 1024 Unload(); | 1024 Unload(); |
| 1025 m_pBreak.reset(CreateBreak(TRUE)); | 1025 m_pBreak.reset(CreateBreak(TRUE)); |
| 1026 if (m_pLoader) { | 1026 if (m_pLoader) { |
| 1027 m_pLoader->m_iTotalLines = -1; | 1027 m_pLoader->m_iTotalLines = -1; |
| 1028 m_pLoader->m_iChar = 0; | 1028 m_pLoader->m_iChar = 0; |
| 1029 } | 1029 } |
| 1030 m_iLines = 0; | 1030 m_iLines = 0; |
| 1031 FX_FLOAT fLinePos = 0; | 1031 FX_FLOAT fLinePos = 0; |
| 1032 Loader(size, fLinePos, TRUE); | 1032 Loader(size, fLinePos, TRUE); |
| 1033 UpdateAlign(size.y, fLinePos); | 1033 UpdateAlign(size.y, fLinePos); |
| 1034 m_pTabstopContext.reset(); | 1034 m_pTabstopContext.reset(); |
| 1035 if (fHeight) | 1035 if (fHeight) |
| 1036 *fHeight = fLinePos; | 1036 *fHeight = fLinePos; |
| 1037 return TRUE; | 1037 return TRUE; |
| 1038 } | 1038 } |
| 1039 | 1039 |
| 1040 FX_BOOL CXFA_TextLayout::Layout(int32_t iBlock) { | 1040 FX_BOOL CXFA_TextLayout::Layout(int32_t iBlock) { |
| 1041 if (m_pLoader == NULL || iBlock < 0 || iBlock >= CountBlocks()) | 1041 if (!m_pLoader || iBlock < 0 || iBlock >= CountBlocks()) |
| 1042 return FALSE; | 1042 return FALSE; |
| 1043 if (m_pLoader->m_fWidth < 1) | 1043 if (m_pLoader->m_fWidth < 1) |
| 1044 return FALSE; | 1044 return FALSE; |
| 1045 | 1045 |
| 1046 m_pLoader->m_iTotalLines = -1; | 1046 m_pLoader->m_iTotalLines = -1; |
| 1047 m_iLines = 0; | 1047 m_iLines = 0; |
| 1048 FX_FLOAT fLinePos = 0; | 1048 FX_FLOAT fLinePos = 0; |
| 1049 CXFA_Node* pNode = NULL; | 1049 CXFA_Node* pNode = nullptr; |
| 1050 CFX_SizeF szText(m_pLoader->m_fWidth, m_pLoader->m_fHeight); | 1050 CFX_SizeF szText(m_pLoader->m_fWidth, m_pLoader->m_fHeight); |
| 1051 int32_t iCount = m_Blocks.GetSize(); | 1051 int32_t iCount = m_Blocks.GetSize(); |
| 1052 int32_t iBlocksHeightCount = m_pLoader->m_BlocksHeight.GetSize(); | 1052 int32_t iBlocksHeightCount = m_pLoader->m_BlocksHeight.GetSize(); |
| 1053 iBlocksHeightCount /= 2; | 1053 iBlocksHeightCount /= 2; |
| 1054 if (iBlock < iBlocksHeightCount) | 1054 if (iBlock < iBlocksHeightCount) |
| 1055 return TRUE; | 1055 return TRUE; |
| 1056 if (iBlock == iBlocksHeightCount) { | 1056 if (iBlock == iBlocksHeightCount) { |
| 1057 Unload(); | 1057 Unload(); |
| 1058 m_pBreak.reset(CreateBreak(TRUE)); | 1058 m_pBreak.reset(CreateBreak(TRUE)); |
| 1059 fLinePos = m_pLoader->m_fStartLineOffset; | 1059 fLinePos = m_pLoader->m_fStartLineOffset; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1085 if (!LoadRichText(pXMLNode, szText, fLinePos, m_pLoader->m_pParentStyle, | 1085 if (!LoadRichText(pXMLNode, szText, fLinePos, m_pLoader->m_pParentStyle, |
| 1086 TRUE)) { | 1086 TRUE)) { |
| 1087 break; | 1087 break; |
| 1088 } | 1088 } |
| 1089 } | 1089 } |
| 1090 while (!pXMLNode) { | 1090 while (!pXMLNode) { |
| 1091 pXMLNode = pSaveXMLNode->GetNodeItem(CFDE_XMLNode::Parent); | 1091 pXMLNode = pSaveXMLNode->GetNodeItem(CFDE_XMLNode::Parent); |
| 1092 if (pXMLNode == pContainerNode) | 1092 if (pXMLNode == pContainerNode) |
| 1093 break; | 1093 break; |
| 1094 if (!LoadRichText(pXMLNode, szText, fLinePos, m_pLoader->m_pParentStyle, | 1094 if (!LoadRichText(pXMLNode, szText, fLinePos, m_pLoader->m_pParentStyle, |
| 1095 TRUE, NULL, FALSE)) { | 1095 TRUE, nullptr, FALSE)) { |
| 1096 break; | 1096 break; |
| 1097 } | 1097 } |
| 1098 pSaveXMLNode = pXMLNode; | 1098 pSaveXMLNode = pXMLNode; |
| 1099 pXMLNode = pXMLNode->GetNodeItem(CFDE_XMLNode::NextSibling); | 1099 pXMLNode = pXMLNode->GetNodeItem(CFDE_XMLNode::NextSibling); |
| 1100 if (!pXMLNode) | 1100 if (!pXMLNode) |
| 1101 continue; | 1101 continue; |
| 1102 for (; pXMLNode; | 1102 for (; pXMLNode; |
| 1103 pXMLNode = pXMLNode->GetNodeItem(CFDE_XMLNode::NextSibling)) { | 1103 pXMLNode = pXMLNode->GetNodeItem(CFDE_XMLNode::NextSibling)) { |
| 1104 if (!LoadRichText(pXMLNode, szText, fLinePos, | 1104 if (!LoadRichText(pXMLNode, szText, fLinePos, |
| 1105 m_pLoader->m_pParentStyle, TRUE)) { | 1105 m_pLoader->m_pParentStyle, TRUE)) { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1174 pDevice->SetClipRect(rtClip); | 1174 pDevice->SetClipRect(rtClip); |
| 1175 | 1175 |
| 1176 std::unique_ptr<CFDE_Brush> pSolidBrush(new CFDE_Brush); | 1176 std::unique_ptr<CFDE_Brush> pSolidBrush(new CFDE_Brush); |
| 1177 std::unique_ptr<CFDE_Pen> pPen(new CFDE_Pen); | 1177 std::unique_ptr<CFDE_Pen> pPen(new CFDE_Pen); |
| 1178 if (m_pieceLines.GetSize() == 0) { | 1178 if (m_pieceLines.GetSize() == 0) { |
| 1179 int32_t iBlockCount = CountBlocks(); | 1179 int32_t iBlockCount = CountBlocks(); |
| 1180 for (int32_t i = 0; i < iBlockCount; i++) { | 1180 for (int32_t i = 0; i < iBlockCount; i++) { |
| 1181 Layout(i); | 1181 Layout(i); |
| 1182 } | 1182 } |
| 1183 } | 1183 } |
| 1184 FXTEXT_CHARPOS* pCharPos = NULL; | 1184 FXTEXT_CHARPOS* pCharPos = nullptr; |
| 1185 int32_t iCharCount = 0; | 1185 int32_t iCharCount = 0; |
| 1186 int32_t iLineStart = 0; | 1186 int32_t iLineStart = 0; |
| 1187 int32_t iPieceLines = m_pieceLines.GetSize(); | 1187 int32_t iPieceLines = m_pieceLines.GetSize(); |
| 1188 int32_t iCount = m_Blocks.GetSize(); | 1188 int32_t iCount = m_Blocks.GetSize(); |
| 1189 if (iCount > 0) { | 1189 if (iCount > 0) { |
| 1190 iBlock *= 2; | 1190 iBlock *= 2; |
| 1191 if (iBlock < iCount) { | 1191 if (iBlock < iCount) { |
| 1192 iLineStart = m_Blocks.ElementAt(iBlock); | 1192 iLineStart = m_Blocks.ElementAt(iBlock); |
| 1193 iPieceLines = m_Blocks.ElementAt(iBlock + 1); | 1193 iPieceLines = m_Blocks.ElementAt(iBlock + 1); |
| 1194 } else { | 1194 } else { |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1308 } | 1308 } |
| 1309 FX_BOOL CXFA_TextLayout::LoadRichText(CFDE_XMLNode* pXMLNode, | 1309 FX_BOOL CXFA_TextLayout::LoadRichText(CFDE_XMLNode* pXMLNode, |
| 1310 const CFX_SizeF& szText, | 1310 const CFX_SizeF& szText, |
| 1311 FX_FLOAT& fLinePos, | 1311 FX_FLOAT& fLinePos, |
| 1312 IFDE_CSSComputedStyle* pParentStyle, | 1312 IFDE_CSSComputedStyle* pParentStyle, |
| 1313 FX_BOOL bSavePieces, | 1313 FX_BOOL bSavePieces, |
| 1314 CXFA_LinkUserData* pLinkData, | 1314 CXFA_LinkUserData* pLinkData, |
| 1315 FX_BOOL bEndBreak, | 1315 FX_BOOL bEndBreak, |
| 1316 FX_BOOL bIsOl, | 1316 FX_BOOL bIsOl, |
| 1317 int32_t iLiCount) { | 1317 int32_t iLiCount) { |
| 1318 if (pXMLNode == NULL) { | 1318 if (!pXMLNode) |
| 1319 return FALSE; | 1319 return FALSE; |
| 1320 } | 1320 |
| 1321 CXFA_TextParseContext* pContext = | 1321 CXFA_TextParseContext* pContext = |
| 1322 m_textParser.GetParseContextFromMap(pXMLNode); | 1322 m_textParser.GetParseContextFromMap(pXMLNode); |
| 1323 FDE_CSSDISPLAY eDisplay = FDE_CSSDISPLAY_None; | 1323 FDE_CSSDISPLAY eDisplay = FDE_CSSDISPLAY_None; |
| 1324 FX_BOOL bContentNode = FALSE; | 1324 FX_BOOL bContentNode = FALSE; |
| 1325 FX_FLOAT fSpaceBelow = 0; | 1325 FX_FLOAT fSpaceBelow = 0; |
| 1326 IFDE_CSSComputedStyle* pStyle = NULL; | 1326 IFDE_CSSComputedStyle* pStyle = nullptr; |
| 1327 CFX_WideString wsName; | 1327 CFX_WideString wsName; |
| 1328 if (bEndBreak) { | 1328 if (bEndBreak) { |
| 1329 FX_BOOL bCurOl = FALSE; | 1329 FX_BOOL bCurOl = FALSE; |
| 1330 FX_BOOL bCurLi = FALSE; | 1330 FX_BOOL bCurLi = FALSE; |
| 1331 CFDE_XMLElement* pElement = NULL; | 1331 CFDE_XMLElement* pElement = nullptr; |
| 1332 if (pContext) { | 1332 if (pContext) { |
| 1333 if (m_bBlockContinue || | 1333 if (m_bBlockContinue || |
| 1334 (m_pLoader && pXMLNode == m_pLoader->m_pXMLNode)) { | 1334 (m_pLoader && pXMLNode == m_pLoader->m_pXMLNode)) { |
| 1335 m_bBlockContinue = TRUE; | 1335 m_bBlockContinue = TRUE; |
| 1336 } | 1336 } |
| 1337 if (pXMLNode->GetType() == FDE_XMLNODE_Text) { | 1337 if (pXMLNode->GetType() == FDE_XMLNODE_Text) { |
| 1338 bContentNode = TRUE; | 1338 bContentNode = TRUE; |
| 1339 } else if (pXMLNode->GetType() == FDE_XMLNODE_Element) { | 1339 } else if (pXMLNode->GetType() == FDE_XMLNODE_Element) { |
| 1340 pElement = static_cast<CFDE_XMLElement*>(pXMLNode); | 1340 pElement = static_cast<CFDE_XMLElement*>(pXMLNode); |
| 1341 pElement->GetLocalTagName(wsName); | 1341 pElement->GetLocalTagName(wsName); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1417 (m_pLoader->m_dwFlags & XFA_LOADERCNTXTFLG_FILTERSPACE)) { | 1417 (m_pLoader->m_dwFlags & XFA_LOADERCNTXTFLG_FILTERSPACE)) { |
| 1418 m_pLoader->m_dwFlags &= ~XFA_LOADERCNTXTFLG_FILTERSPACE; | 1418 m_pLoader->m_dwFlags &= ~XFA_LOADERCNTXTFLG_FILTERSPACE; |
| 1419 } else if (wsText.GetLength() > 0 && | 1419 } else if (wsText.GetLength() > 0 && |
| 1420 (0x20 == wsText.GetAt(wsText.GetLength() - 1))) { | 1420 (0x20 == wsText.GetAt(wsText.GetLength() - 1))) { |
| 1421 m_pLoader->m_dwFlags |= XFA_LOADERCNTXTFLG_FILTERSPACE; | 1421 m_pLoader->m_dwFlags |= XFA_LOADERCNTXTFLG_FILTERSPACE; |
| 1422 } else if (wsText.GetLength() != 0) { | 1422 } else if (wsText.GetLength() != 0) { |
| 1423 m_pLoader->m_dwFlags &= ~XFA_LOADERCNTXTFLG_FILTERSPACE; | 1423 m_pLoader->m_dwFlags &= ~XFA_LOADERCNTXTFLG_FILTERSPACE; |
| 1424 } | 1424 } |
| 1425 } | 1425 } |
| 1426 if (wsText.GetLength() > 0) { | 1426 if (wsText.GetLength() > 0) { |
| 1427 if (m_pLoader == NULL || m_pLoader->m_iChar == 0) { | 1427 if (!m_pLoader || m_pLoader->m_iChar == 0) { |
| 1428 if (pLinkData) { | 1428 if (pLinkData) { |
| 1429 pLinkData->Retain(); | 1429 pLinkData->Retain(); |
| 1430 } | 1430 } |
| 1431 CXFA_TextUserData* pUserData = FXTARGET_NewWith(m_pAllocator.get()) | 1431 CXFA_TextUserData* pUserData = FXTARGET_NewWith(m_pAllocator.get()) |
| 1432 CXFA_TextUserData(m_pAllocator.get(), | 1432 CXFA_TextUserData(m_pAllocator.get(), |
| 1433 bContentNode ? pParentStyle : pStyle, | 1433 bContentNode ? pParentStyle : pStyle, |
| 1434 pLinkData); | 1434 pLinkData); |
| 1435 m_pBreak->SetUserData(pUserData); | 1435 m_pBreak->SetUserData(pUserData); |
| 1436 } | 1436 } |
| 1437 if (AppendChar(wsText, fLinePos, 0, bSavePieces)) { | 1437 if (AppendChar(wsText, fLinePos, 0, bSavePieces)) { |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1581 void CXFA_TextLayout::EndBreak(uint32_t dwStatus, | 1581 void CXFA_TextLayout::EndBreak(uint32_t dwStatus, |
| 1582 FX_FLOAT& fLinePos, | 1582 FX_FLOAT& fLinePos, |
| 1583 FX_BOOL bSavePieces) { | 1583 FX_BOOL bSavePieces) { |
| 1584 dwStatus = m_pBreak->EndBreak(dwStatus); | 1584 dwStatus = m_pBreak->EndBreak(dwStatus); |
| 1585 if (dwStatus > FX_RTFBREAK_PieceBreak) { | 1585 if (dwStatus > FX_RTFBREAK_PieceBreak) { |
| 1586 AppendTextLine(dwStatus, fLinePos, bSavePieces, TRUE); | 1586 AppendTextLine(dwStatus, fLinePos, bSavePieces, TRUE); |
| 1587 } | 1587 } |
| 1588 } | 1588 } |
| 1589 void CXFA_TextLayout::DoTabstops(IFDE_CSSComputedStyle* pStyle, | 1589 void CXFA_TextLayout::DoTabstops(IFDE_CSSComputedStyle* pStyle, |
| 1590 CXFA_PieceLine* pPieceLine) { | 1590 CXFA_PieceLine* pPieceLine) { |
| 1591 if (m_pTabstopContext == NULL || m_pTabstopContext->m_iTabCount == 0) { | 1591 if (!m_pTabstopContext || m_pTabstopContext->m_iTabCount == 0) |
| 1592 return; | 1592 return; |
| 1593 } | 1593 |
| 1594 if (pStyle == NULL || pPieceLine == NULL) { | 1594 if (!pStyle || !pPieceLine) |
| 1595 return; | 1595 return; |
| 1596 } | 1596 |
| 1597 int32_t iPieces = pPieceLine->m_textPieces.GetSize(); | 1597 int32_t iPieces = pPieceLine->m_textPieces.GetSize(); |
| 1598 if (iPieces == 0) { | 1598 if (iPieces == 0) { |
| 1599 return; | 1599 return; |
| 1600 } | 1600 } |
| 1601 XFA_TextPiece* pPiece = pPieceLine->m_textPieces.GetAt(iPieces - 1); | 1601 XFA_TextPiece* pPiece = pPieceLine->m_textPieces.GetAt(iPieces - 1); |
| 1602 int32_t& iTabstopsIndex = m_pTabstopContext->m_iTabIndex; | 1602 int32_t& iTabstopsIndex = m_pTabstopContext->m_iTabIndex; |
| 1603 int32_t iCount = m_textParser.CountTabs(pStyle); | 1603 int32_t iCount = m_textParser.CountTabs(pStyle); |
| 1604 if (iTabstopsIndex > m_pTabstopContext->m_iTabCount - 1) { | 1604 if (iTabstopsIndex > m_pTabstopContext->m_iTabCount - 1) { |
| 1605 return; | 1605 return; |
| 1606 } | 1606 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1643 } | 1643 } |
| 1644 } | 1644 } |
| 1645 void CXFA_TextLayout::AppendTextLine(uint32_t dwStatus, | 1645 void CXFA_TextLayout::AppendTextLine(uint32_t dwStatus, |
| 1646 FX_FLOAT& fLinePos, | 1646 FX_FLOAT& fLinePos, |
| 1647 FX_BOOL bSavePieces, | 1647 FX_BOOL bSavePieces, |
| 1648 FX_BOOL bEndBreak) { | 1648 FX_BOOL bEndBreak) { |
| 1649 int32_t iPieces = m_pBreak->CountBreakPieces(); | 1649 int32_t iPieces = m_pBreak->CountBreakPieces(); |
| 1650 if (iPieces < 1) { | 1650 if (iPieces < 1) { |
| 1651 return; | 1651 return; |
| 1652 } | 1652 } |
| 1653 IFDE_CSSComputedStyle* pStyle = NULL; | 1653 IFDE_CSSComputedStyle* pStyle = nullptr; |
| 1654 if (bSavePieces) { | 1654 if (bSavePieces) { |
| 1655 CXFA_PieceLine* pPieceLine = | 1655 CXFA_PieceLine* pPieceLine = |
| 1656 FXTARGET_NewWith(m_pAllocator.get()) CXFA_PieceLine; | 1656 FXTARGET_NewWith(m_pAllocator.get()) CXFA_PieceLine; |
| 1657 m_pieceLines.Add(pPieceLine); | 1657 m_pieceLines.Add(pPieceLine); |
| 1658 if (m_pTabstopContext) { | 1658 if (m_pTabstopContext) { |
| 1659 m_pTabstopContext->Reset(); | 1659 m_pTabstopContext->Reset(); |
| 1660 } | 1660 } |
| 1661 FX_FLOAT fLineStep = 0, fBaseLine = 0; | 1661 FX_FLOAT fLineStep = 0, fBaseLine = 0; |
| 1662 int32_t i = 0; | 1662 int32_t i = 0; |
| 1663 for (i = 0; i < iPieces; i++) { | 1663 for (i = 0; i < iPieces; i++) { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1700 fBaseLineTemp = 0; | 1700 fBaseLineTemp = 0; |
| 1701 } | 1701 } |
| 1702 } else if (fBaseLine < -fBaseLineTemp) { | 1702 } else if (fBaseLine < -fBaseLineTemp) { |
| 1703 fBaseLine = -fBaseLineTemp; | 1703 fBaseLine = -fBaseLineTemp; |
| 1704 } | 1704 } |
| 1705 fLineStep = std::max(fLineStep, fLineHeight); | 1705 fLineStep = std::max(fLineStep, fLineHeight); |
| 1706 if (pUserData && pUserData->m_pLinkData) { | 1706 if (pUserData && pUserData->m_pLinkData) { |
| 1707 pUserData->m_pLinkData->Retain(); | 1707 pUserData->m_pLinkData->Retain(); |
| 1708 pTP->pLinkData = pUserData->m_pLinkData; | 1708 pTP->pLinkData = pUserData->m_pLinkData; |
| 1709 } else { | 1709 } else { |
| 1710 pTP->pLinkData = NULL; | 1710 pTP->pLinkData = nullptr; |
| 1711 } | 1711 } |
| 1712 DoTabstops(pStyle, pPieceLine); | 1712 DoTabstops(pStyle, pPieceLine); |
| 1713 } | 1713 } |
| 1714 for (i = 0; i < iPieces; i++) { | 1714 for (i = 0; i < iPieces; i++) { |
| 1715 XFA_TextPiece* pTP = pPieceLine->m_textPieces.GetAt(i); | 1715 XFA_TextPiece* pTP = pPieceLine->m_textPieces.GetAt(i); |
| 1716 FX_FLOAT& fTop = pTP->rtPiece.top; | 1716 FX_FLOAT& fTop = pTP->rtPiece.top; |
| 1717 FX_FLOAT fBaseLineTemp = fTop; | 1717 FX_FLOAT fBaseLineTemp = fTop; |
| 1718 fTop = fLinePos + fLineStep - pTP->rtPiece.height - fBaseLineTemp; | 1718 fTop = fLinePos + fLineStep - pTP->rtPiece.height - fBaseLineTemp; |
| 1719 fTop = std::max(0.0f, fTop); | 1719 fTop = std::max(0.0f, fTop); |
| 1720 } | 1720 } |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1910 pPath->AddLine(pt1, pt2); | 1910 pPath->AddLine(pt1, pt2); |
| 1911 fEndY += 2.0f; | 1911 fEndY += 2.0f; |
| 1912 } | 1912 } |
| 1913 } | 1913 } |
| 1914 pDevice->DrawPath(pPen, 1, pPath.get(), &tmDoc2Device); | 1914 pDevice->DrawPath(pPen, 1, pPath.get(), &tmDoc2Device); |
| 1915 } | 1915 } |
| 1916 | 1916 |
| 1917 int32_t CXFA_TextLayout::GetDisplayPos(const XFA_TextPiece* pPiece, | 1917 int32_t CXFA_TextLayout::GetDisplayPos(const XFA_TextPiece* pPiece, |
| 1918 FXTEXT_CHARPOS* pCharPos, | 1918 FXTEXT_CHARPOS* pCharPos, |
| 1919 FX_BOOL bCharCode) { | 1919 FX_BOOL bCharCode) { |
| 1920 if (pPiece == NULL) { | 1920 if (!pPiece) |
| 1921 return 0; | 1921 return 0; |
| 1922 } | 1922 |
| 1923 FX_RTFTEXTOBJ tr; | 1923 FX_RTFTEXTOBJ tr; |
| 1924 if (!ToRun(pPiece, tr)) { | 1924 if (!ToRun(pPiece, tr)) { |
| 1925 return 0; | 1925 return 0; |
| 1926 } | 1926 } |
| 1927 return m_pBreak->GetDisplayPos(&tr, pCharPos, bCharCode); | 1927 return m_pBreak->GetDisplayPos(&tr, pCharPos, bCharCode); |
| 1928 } | 1928 } |
| 1929 FX_BOOL CXFA_TextLayout::ToRun(const XFA_TextPiece* pPiece, FX_RTFTEXTOBJ& tr) { | 1929 FX_BOOL CXFA_TextLayout::ToRun(const XFA_TextPiece* pPiece, FX_RTFTEXTOBJ& tr) { |
| 1930 int32_t iLength = pPiece->iChars; | 1930 int32_t iLength = pPiece->iChars; |
| 1931 if (iLength < 1) { | 1931 if (iLength < 1) { |
| 1932 return FALSE; | 1932 return FALSE; |
| 1933 } | 1933 } |
| 1934 tr.pStr = pPiece->pszText; | 1934 tr.pStr = pPiece->pszText; |
| 1935 tr.pFont = pPiece->pFont; | 1935 tr.pFont = pPiece->pFont; |
| 1936 tr.pRect = &pPiece->rtPiece; | 1936 tr.pRect = &pPiece->rtPiece; |
| 1937 tr.pWidths = pPiece->pWidths; | 1937 tr.pWidths = pPiece->pWidths; |
| 1938 tr.iLength = iLength; | 1938 tr.iLength = iLength; |
| 1939 tr.fFontSize = pPiece->fFontSize; | 1939 tr.fFontSize = pPiece->fFontSize; |
| 1940 tr.iBidiLevel = pPiece->iBidiLevel; | 1940 tr.iBidiLevel = pPiece->iBidiLevel; |
| 1941 tr.iCharRotation = 0; | 1941 tr.iCharRotation = 0; |
| 1942 tr.wLineBreakChar = L'\n'; | 1942 tr.wLineBreakChar = L'\n'; |
| 1943 tr.iVerticalScale = pPiece->iVerScale; | 1943 tr.iVerticalScale = pPiece->iVerScale; |
| 1944 tr.dwLayoutStyles = FX_RTFLAYOUTSTYLE_ExpandTab; | 1944 tr.dwLayoutStyles = FX_RTFLAYOUTSTYLE_ExpandTab; |
| 1945 tr.iHorizontalScale = pPiece->iHorScale; | 1945 tr.iHorizontalScale = pPiece->iHorScale; |
| 1946 return TRUE; | 1946 return TRUE; |
| 1947 } | 1947 } |
| OLD | NEW |