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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 } | 112 } |
113 | 113 |
114 CXFA_LoaderContext::CXFA_LoaderContext() | 114 CXFA_LoaderContext::CXFA_LoaderContext() |
115 : m_bSaveLineHeight(FALSE), | 115 : m_bSaveLineHeight(FALSE), |
116 m_fWidth(0), | 116 m_fWidth(0), |
117 m_fHeight(0), | 117 m_fHeight(0), |
118 m_fLastPos(0), | 118 m_fLastPos(0), |
119 m_fStartLineOffset(0), | 119 m_fStartLineOffset(0), |
120 m_iChar(0), | 120 m_iChar(0), |
121 m_iTotalLines(-1), | 121 m_iTotalLines(-1), |
122 m_pXMLNode(NULL), | 122 m_pXMLNode(nullptr), |
123 m_pNode(NULL), | 123 m_pNode(nullptr), |
124 m_pParentStyle(NULL), | 124 m_pParentStyle(nullptr), |
125 m_dwFlags(0) {} | 125 m_dwFlags(0) {} |
126 | 126 |
127 CXFA_LoaderContext::~CXFA_LoaderContext() {} | 127 CXFA_LoaderContext::~CXFA_LoaderContext() {} |
128 | 128 |
129 IFDE_CSSStyleSheet* CXFA_TextParser::LoadDefaultSheetStyle() { | 129 IFDE_CSSStyleSheet* CXFA_TextParser::LoadDefaultSheetStyle() { |
130 static const FX_WCHAR s_pStyle[] = | 130 static const FX_WCHAR s_pStyle[] = |
131 L"html,body,ol,p,ul{display:block}" | 131 L"html,body,ol,p,ul{display:block}" |
132 L"li{display:list-item}" | 132 L"li{display:list-item}" |
133 L"ol,ul{padding-left:33px}ol{list-style-type:decimal}ol,ul{margin-top:0;" | 133 L"ol,ul{padding-left:33px}ol{list-style-type:decimal}ol,ul{margin-top:0;" |
134 L"margin-bottom:0}ul,ol{margin:1.12em 0}" | 134 L"margin-bottom:0}ul,ol{margin:1.12em 0}" |
135 L"a{color:#0000ff;text-decoration:underline}b{font-weight:bolder}i{font-" | 135 L"a{color:#0000ff;text-decoration:underline}b{font-weight:bolder}i{font-" |
136 L"style:italic}" | 136 L"style:italic}" |
137 L"sup{vertical-align:+15em;font-size:.66em}sub{vertical-align:-15em;font-" | 137 L"sup{vertical-align:+15em;font-size:.66em}sub{vertical-align:-15em;font-" |
138 L"size:.66em}"; | 138 L"size:.66em}"; |
139 return IFDE_CSSStyleSheet::LoadFromBuffer( | 139 return IFDE_CSSStyleSheet::LoadFromBuffer( |
140 CFX_WideString(), s_pStyle, FXSYS_wcslen(s_pStyle), FX_CODEPAGE_UTF8); | 140 CFX_WideString(), s_pStyle, FXSYS_wcslen(s_pStyle), FX_CODEPAGE_UTF8); |
141 } | 141 } |
142 IFDE_CSSComputedStyle* CXFA_TextParser::CreateRootStyle( | 142 IFDE_CSSComputedStyle* CXFA_TextParser::CreateRootStyle( |
143 CXFA_TextProvider* pTextProvider) { | 143 CXFA_TextProvider* pTextProvider) { |
144 CXFA_Font font = pTextProvider->GetFontNode(); | 144 CXFA_Font font = pTextProvider->GetFontNode(); |
145 CXFA_Para para = pTextProvider->GetParaNode(); | 145 CXFA_Para para = pTextProvider->GetParaNode(); |
146 IFDE_CSSComputedStyle* pStyle = m_pSelector->CreateComputedStyle(NULL); | 146 IFDE_CSSComputedStyle* pStyle = m_pSelector->CreateComputedStyle(nullptr); |
147 IFDE_CSSFontStyle* pFontStyle = pStyle->GetFontStyles(); | 147 IFDE_CSSFontStyle* pFontStyle = pStyle->GetFontStyles(); |
148 IFDE_CSSParagraphStyle* pParaStyle = pStyle->GetParagraphStyles(); | 148 IFDE_CSSParagraphStyle* pParaStyle = pStyle->GetParagraphStyles(); |
149 FX_FLOAT fLineHeight = 0, fFontSize = 10; | 149 FX_FLOAT fLineHeight = 0, fFontSize = 10; |
150 if (para) { | 150 if (para) { |
151 fLineHeight = para.GetLineHeight(); | 151 fLineHeight = para.GetLineHeight(); |
152 FDE_CSSLENGTH indent; | 152 FDE_CSSLENGTH indent; |
153 indent.Set(FDE_CSSLENGTHUNIT_Point, para.GetTextIndent()); | 153 indent.Set(FDE_CSSLENGTHUNIT_Point, para.GetTextIndent()); |
154 pParaStyle->SetTextIndent(indent); | 154 pParaStyle->SetTextIndent(indent); |
155 FDE_CSSTEXTALIGN hAlign = FDE_CSSTEXTALIGN_Left; | 155 FDE_CSSTEXTALIGN hAlign = FDE_CSSTEXTALIGN_Left; |
156 switch (para.GetHorizontalAlign()) { | 156 switch (para.GetHorizontalAlign()) { |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 IFDE_CSSComputedStyle* pStyle = CreateStyle(pParentStyle); | 241 IFDE_CSSComputedStyle* pStyle = CreateStyle(pParentStyle); |
242 CFDE_CSSAccelerator* pCSSAccel = m_pSelector->InitAccelerator(); | 242 CFDE_CSSAccelerator* pCSSAccel = m_pSelector->InitAccelerator(); |
243 pCSSAccel->OnEnterTag(&tagProvider); | 243 pCSSAccel->OnEnterTag(&tagProvider); |
244 m_pSelector->ComputeStyle(&tagProvider, pContext->GetDecls(), | 244 m_pSelector->ComputeStyle(&tagProvider, pContext->GetDecls(), |
245 pContext->CountDecls(), pStyle); | 245 pContext->CountDecls(), pStyle); |
246 pCSSAccel->OnLeaveTag(&tagProvider); | 246 pCSSAccel->OnLeaveTag(&tagProvider); |
247 return pStyle; | 247 return pStyle; |
248 } | 248 } |
249 void CXFA_TextParser::DoParse(CFDE_XMLNode* pXMLContainer, | 249 void CXFA_TextParser::DoParse(CFDE_XMLNode* pXMLContainer, |
250 CXFA_TextProvider* pTextProvider) { | 250 CXFA_TextProvider* pTextProvider) { |
251 if (pXMLContainer == NULL || pTextProvider == NULL || m_pAllocator) { | 251 if (!pXMLContainer || !pTextProvider || m_pAllocator) { |
252 return; | 252 return; |
253 } | 253 } |
254 m_pAllocator.reset(IFX_MemoryAllocator::Create(FX_ALLOCTYPE_Fixed, 32, | 254 m_pAllocator.reset(IFX_MemoryAllocator::Create(FX_ALLOCTYPE_Fixed, 32, |
255 sizeof(CXFA_CSSTagProvider))); | 255 sizeof(CXFA_CSSTagProvider))); |
256 InitCSSData(pTextProvider); | 256 InitCSSData(pTextProvider); |
257 IFDE_CSSComputedStyle* pRootStyle = CreateRootStyle(pTextProvider); | 257 IFDE_CSSComputedStyle* pRootStyle = CreateRootStyle(pTextProvider); |
258 ParseRichText(pXMLContainer, pRootStyle); | 258 ParseRichText(pXMLContainer, pRootStyle); |
259 pRootStyle->Release(); | 259 pRootStyle->Release(); |
260 } | 260 } |
261 void CXFA_TextParser::ParseRichText(CFDE_XMLNode* pXMLNode, | 261 void CXFA_TextParser::ParseRichText(CFDE_XMLNode* pXMLNode, |
262 IFDE_CSSComputedStyle* pParentStyle) { | 262 IFDE_CSSComputedStyle* pParentStyle) { |
263 if (!pXMLNode) | 263 if (!pXMLNode) |
264 return; | 264 return; |
265 | 265 |
266 CXFA_CSSTagProvider tagProvider; | 266 CXFA_CSSTagProvider tagProvider; |
267 ParseTagInfo(pXMLNode, tagProvider); | 267 ParseTagInfo(pXMLNode, tagProvider); |
268 if (!tagProvider.m_bTagAvailable) | 268 if (!tagProvider.m_bTagAvailable) |
269 return; | 269 return; |
270 | 270 |
271 IFDE_CSSComputedStyle* pNewStyle = NULL; | 271 IFDE_CSSComputedStyle* pNewStyle = nullptr; |
272 if ((tagProvider.GetTagName() != FX_WSTRC(L"body")) || | 272 if ((tagProvider.GetTagName() != FX_WSTRC(L"body")) || |
273 (tagProvider.GetTagName() != FX_WSTRC(L"html"))) { | 273 (tagProvider.GetTagName() != FX_WSTRC(L"html"))) { |
274 CXFA_TextParseContext* pTextContext = | 274 CXFA_TextParseContext* pTextContext = |
275 FXTARGET_NewWith(m_pAllocator.get()) CXFA_TextParseContext; | 275 FXTARGET_NewWith(m_pAllocator.get()) CXFA_TextParseContext; |
276 FDE_CSSDISPLAY eDisplay = FDE_CSSDISPLAY_Inline; | 276 FDE_CSSDISPLAY eDisplay = FDE_CSSDISPLAY_Inline; |
277 if (!tagProvider.m_bContent) { | 277 if (!tagProvider.m_bContent) { |
278 pNewStyle = CreateStyle(pParentStyle); | 278 pNewStyle = CreateStyle(pParentStyle); |
279 CFDE_CSSAccelerator* pCSSAccel = m_pSelector->InitAccelerator(); | 279 CFDE_CSSAccelerator* pCSSAccel = m_pSelector->InitAccelerator(); |
280 pCSSAccel->OnEnterTag(&tagProvider); | 280 pCSSAccel->OnEnterTag(&tagProvider); |
281 CFDE_CSSDeclarationArray DeclArray; | 281 CFDE_CSSDeclarationArray DeclArray; |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 } else if (fLineHeight < 0.1f) { | 538 } else if (fLineHeight < 0.1f) { |
539 fLineHeight = GetFontSize(pTextProvider, pStyle) * 1.2f; | 539 fLineHeight = GetFontSize(pTextProvider, pStyle) * 1.2f; |
540 } | 540 } |
541 fLineHeight *= fVerScale; | 541 fLineHeight *= fVerScale; |
542 return fLineHeight; | 542 return fLineHeight; |
543 } | 543 } |
544 FX_BOOL CXFA_TextParser::GetEmbbedObj(CXFA_TextProvider* pTextProvider, | 544 FX_BOOL CXFA_TextParser::GetEmbbedObj(CXFA_TextProvider* pTextProvider, |
545 CFDE_XMLNode* pXMLNode, | 545 CFDE_XMLNode* pXMLNode, |
546 CFX_WideString& wsValue) { | 546 CFX_WideString& wsValue) { |
547 wsValue.clear(); | 547 wsValue.clear(); |
548 if (pXMLNode == NULL) { | 548 if (!pXMLNode) { |
549 return FALSE; | 549 return FALSE; |
550 } | 550 } |
551 FX_BOOL bRet = FALSE; | 551 FX_BOOL bRet = FALSE; |
552 if (pXMLNode->GetType() == FDE_XMLNODE_Element) { | 552 if (pXMLNode->GetType() == FDE_XMLNODE_Element) { |
553 CFDE_XMLElement* pElement = static_cast<CFDE_XMLElement*>(pXMLNode); | 553 CFDE_XMLElement* pElement = static_cast<CFDE_XMLElement*>(pXMLNode); |
554 CFX_WideString wsAttr; | 554 CFX_WideString wsAttr; |
555 pElement->GetString(L"xfa:embed", wsAttr); | 555 pElement->GetString(L"xfa:embed", wsAttr); |
556 if (wsAttr.IsEmpty()) { | 556 if (wsAttr.IsEmpty()) { |
557 return FALSE; | 557 return FALSE; |
558 } | 558 } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 XFA_TABSTOPSSTATUS_EOS, | 595 XFA_TABSTOPSSTATUS_EOS, |
596 XFA_TABSTOPSSTATUS_None, | 596 XFA_TABSTOPSSTATUS_None, |
597 XFA_TABSTOPSSTATUS_Alignment, | 597 XFA_TABSTOPSSTATUS_Alignment, |
598 XFA_TABSTOPSSTATUS_StartLeader, | 598 XFA_TABSTOPSSTATUS_StartLeader, |
599 XFA_TABSTOPSSTATUS_Leader, | 599 XFA_TABSTOPSSTATUS_Leader, |
600 XFA_TABSTOPSSTATUS_Location, | 600 XFA_TABSTOPSSTATUS_Location, |
601 }; | 601 }; |
602 FX_BOOL CXFA_TextParser::GetTabstops( | 602 FX_BOOL CXFA_TextParser::GetTabstops( |
603 IFDE_CSSComputedStyle* pStyle, | 603 IFDE_CSSComputedStyle* pStyle, |
604 CXFA_TextTabstopsContext* pTabstopContext) { | 604 CXFA_TextTabstopsContext* pTabstopContext) { |
605 if (pStyle == NULL || pTabstopContext == NULL) { | 605 if (!pStyle || !pTabstopContext) { |
606 return FALSE; | 606 return FALSE; |
607 } | 607 } |
608 CFX_WideString wsValue; | 608 CFX_WideString wsValue; |
609 if (!pStyle->GetCustomStyle(FX_WSTRC(L"xfa-tab-stops"), wsValue) && | 609 if (!pStyle->GetCustomStyle(FX_WSTRC(L"xfa-tab-stops"), wsValue) && |
610 !pStyle->GetCustomStyle(FX_WSTRC(L"tab-stops"), wsValue)) { | 610 !pStyle->GetCustomStyle(FX_WSTRC(L"tab-stops"), wsValue)) { |
611 return FALSE; | 611 return FALSE; |
612 } | 612 } |
613 int32_t iLength = wsValue.GetLength(); | 613 int32_t iLength = wsValue.GetLength(); |
614 const FX_WCHAR* pTabStops = wsValue.c_str(); | 614 const FX_WCHAR* pTabStops = wsValue.c_str(); |
615 int32_t iCur = 0; | 615 int32_t iCur = 0; |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
709 FXTARGET_DeleteWith(CXFA_PieceLine, m_pAllocator.get(), pLine); | 709 FXTARGET_DeleteWith(CXFA_PieceLine, m_pAllocator.get(), pLine); |
710 } | 710 } |
711 m_pieceLines.RemoveAll(); | 711 m_pieceLines.RemoveAll(); |
712 m_pBreak.reset(); | 712 m_pBreak.reset(); |
713 m_pAllocator.reset(); | 713 m_pAllocator.reset(); |
714 } | 714 } |
715 const CXFA_PieceLineArray* CXFA_TextLayout::GetPieceLines() { | 715 const CXFA_PieceLineArray* CXFA_TextLayout::GetPieceLines() { |
716 return &m_pieceLines; | 716 return &m_pieceLines; |
717 } | 717 } |
718 void CXFA_TextLayout::GetTextDataNode() { | 718 void CXFA_TextLayout::GetTextDataNode() { |
719 if (m_pTextProvider == NULL) { | 719 if (!m_pTextProvider) { |
720 return; | 720 return; |
721 } | 721 } |
722 CXFA_Node* pNode = m_pTextProvider->GetTextNode(m_bRichText); | 722 CXFA_Node* pNode = m_pTextProvider->GetTextNode(m_bRichText); |
723 if (pNode && m_bRichText) { | 723 if (pNode && m_bRichText) { |
724 m_textParser.Reset(); | 724 m_textParser.Reset(); |
725 } | 725 } |
726 m_pTextDataNode = pNode; | 726 m_pTextDataNode = pNode; |
727 } | 727 } |
728 CFDE_XMLNode* CXFA_TextLayout::GetXMLContainerNode() { | 728 CFDE_XMLNode* CXFA_TextLayout::GetXMLContainerNode() { |
729 CFDE_XMLNode* pXMLContainer = NULL; | 729 CFDE_XMLNode* pXMLContainer = nullptr; |
730 if (m_bRichText) { | 730 if (m_bRichText) { |
731 CFDE_XMLNode* pXMLRoot = m_pTextDataNode->GetXMLMappingNode(); | 731 CFDE_XMLNode* pXMLRoot = m_pTextDataNode->GetXMLMappingNode(); |
732 if (!pXMLRoot) { | 732 if (!pXMLRoot) { |
733 return pXMLContainer; | 733 return pXMLContainer; |
734 } | 734 } |
735 for (CFDE_XMLNode* pXMLChild = | 735 for (CFDE_XMLNode* pXMLChild = |
736 pXMLRoot->GetNodeItem(CFDE_XMLNode::FirstChild); | 736 pXMLRoot->GetNodeItem(CFDE_XMLNode::FirstChild); |
737 pXMLChild; | 737 pXMLChild; |
738 pXMLChild = pXMLChild->GetNodeItem(CFDE_XMLNode::NextSibling)) { | 738 pXMLChild = pXMLChild->GetNodeItem(CFDE_XMLNode::NextSibling)) { |
739 if (pXMLChild->GetType() == FDE_XMLNODE_Element) { | 739 if (pXMLChild->GetType() == FDE_XMLNODE_Element) { |
(...skipping 11 matching lines...) Expand all Loading... |
751 } | 751 } |
752 CFX_RTFBreak* CXFA_TextLayout::CreateBreak(FX_BOOL bDefault) { | 752 CFX_RTFBreak* CXFA_TextLayout::CreateBreak(FX_BOOL bDefault) { |
753 uint32_t dwStyle = FX_RTFLAYOUTSTYLE_ExpandTab; | 753 uint32_t dwStyle = FX_RTFLAYOUTSTYLE_ExpandTab; |
754 if (!bDefault) { | 754 if (!bDefault) { |
755 dwStyle |= FX_RTFLAYOUTSTYLE_Pagination; | 755 dwStyle |= FX_RTFLAYOUTSTYLE_Pagination; |
756 } | 756 } |
757 CFX_RTFBreak* pBreak = new CFX_RTFBreak(0); | 757 CFX_RTFBreak* pBreak = new CFX_RTFBreak(0); |
758 pBreak->SetLayoutStyles(dwStyle); | 758 pBreak->SetLayoutStyles(dwStyle); |
759 pBreak->SetLineBreakChar(L'\n'); | 759 pBreak->SetLineBreakChar(L'\n'); |
760 pBreak->SetLineBreakTolerance(1); | 760 pBreak->SetLineBreakTolerance(1); |
761 pBreak->SetFont(m_textParser.GetFont(m_pTextProvider, NULL)); | 761 pBreak->SetFont(m_textParser.GetFont(m_pTextProvider, nullptr)); |
762 pBreak->SetFontSize(m_textParser.GetFontSize(m_pTextProvider, NULL)); | 762 pBreak->SetFontSize(m_textParser.GetFontSize(m_pTextProvider, nullptr)); |
763 return pBreak; | 763 return pBreak; |
764 } | 764 } |
765 void CXFA_TextLayout::InitBreak(FX_FLOAT fLineWidth) { | 765 void CXFA_TextLayout::InitBreak(FX_FLOAT fLineWidth) { |
766 CXFA_Font font = m_pTextProvider->GetFontNode(); | 766 CXFA_Font font = m_pTextProvider->GetFontNode(); |
767 CXFA_Para para = m_pTextProvider->GetParaNode(); | 767 CXFA_Para para = m_pTextProvider->GetParaNode(); |
768 FX_FLOAT fStart = 0; | 768 FX_FLOAT fStart = 0; |
769 FX_FLOAT fStartPos = 0; | 769 FX_FLOAT fStartPos = 0; |
770 if (para) { | 770 if (para) { |
771 int32_t iAlign = FX_RTFLINEALIGNMENT_Left; | 771 int32_t iAlign = FX_RTFLINEALIGNMENT_Left; |
772 switch (para.GetHorizontalAlign()) { | 772 switch (para.GetHorizontalAlign()) { |
(...skipping 28 matching lines...) Expand all Loading... |
801 fStartPos += fIndent; | 801 fStartPos += fIndent; |
802 } | 802 } |
803 } | 803 } |
804 m_pBreak->SetLineBoundary(fStart, fLineWidth); | 804 m_pBreak->SetLineBoundary(fStart, fLineWidth); |
805 m_pBreak->SetLineStartPos(fStartPos); | 805 m_pBreak->SetLineStartPos(fStartPos); |
806 if (font) { | 806 if (font) { |
807 m_pBreak->SetHorizontalScale((int32_t)font.GetHorizontalScale()); | 807 m_pBreak->SetHorizontalScale((int32_t)font.GetHorizontalScale()); |
808 m_pBreak->SetVerticalScale((int32_t)font.GetVerticalScale()); | 808 m_pBreak->SetVerticalScale((int32_t)font.GetVerticalScale()); |
809 m_pBreak->SetCharSpace(font.GetLetterSpacing()); | 809 m_pBreak->SetCharSpace(font.GetLetterSpacing()); |
810 } | 810 } |
811 FX_FLOAT fFontSize = m_textParser.GetFontSize(m_pTextProvider, NULL); | 811 FX_FLOAT fFontSize = m_textParser.GetFontSize(m_pTextProvider, nullptr); |
812 m_pBreak->SetFontSize(fFontSize); | 812 m_pBreak->SetFontSize(fFontSize); |
813 m_pBreak->SetFont(m_textParser.GetFont(m_pTextProvider, NULL)); | 813 m_pBreak->SetFont(m_textParser.GetFont(m_pTextProvider, nullptr)); |
814 m_pBreak->SetLineBreakTolerance(fFontSize * 0.2f); | 814 m_pBreak->SetLineBreakTolerance(fFontSize * 0.2f); |
815 } | 815 } |
816 void CXFA_TextLayout::InitBreak(IFDE_CSSComputedStyle* pStyle, | 816 void CXFA_TextLayout::InitBreak(IFDE_CSSComputedStyle* pStyle, |
817 FDE_CSSDISPLAY eDisplay, | 817 FDE_CSSDISPLAY eDisplay, |
818 FX_FLOAT fLineWidth, | 818 FX_FLOAT fLineWidth, |
819 CFDE_XMLNode* pXMLNode, | 819 CFDE_XMLNode* pXMLNode, |
820 IFDE_CSSComputedStyle* pParentStyle) { | 820 IFDE_CSSComputedStyle* pParentStyle) { |
821 if (pStyle == NULL) { | 821 if (!pStyle) { |
822 InitBreak(fLineWidth); | 822 InitBreak(fLineWidth); |
823 return; | 823 return; |
824 } | 824 } |
825 IFDE_CSSParagraphStyle* pParaStyle = pStyle->GetParagraphStyles(); | 825 IFDE_CSSParagraphStyle* pParaStyle = pStyle->GetParagraphStyles(); |
826 if (eDisplay == FDE_CSSDISPLAY_Block || eDisplay == FDE_CSSDISPLAY_ListItem) { | 826 if (eDisplay == FDE_CSSDISPLAY_Block || eDisplay == FDE_CSSDISPLAY_ListItem) { |
827 int32_t iAlign = FX_RTFLINEALIGNMENT_Left; | 827 int32_t iAlign = FX_RTFLINEALIGNMENT_Left; |
828 switch (pParaStyle->GetTextAlign()) { | 828 switch (pParaStyle->GetTextAlign()) { |
829 case FDE_CSSTEXTALIGN_Right: | 829 case FDE_CSSTEXTALIGN_Right: |
830 iAlign = FX_RTFLINEALIGNMENT_Right; | 830 iAlign = FX_RTFLINEALIGNMENT_Right; |
831 break; | 831 break; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
901 int32_t CXFA_TextLayout::GetText(CFX_WideString& wsText) { | 901 int32_t CXFA_TextLayout::GetText(CFX_WideString& wsText) { |
902 GetTextDataNode(); | 902 GetTextDataNode(); |
903 wsText.clear(); | 903 wsText.clear(); |
904 if (m_bRichText) { | 904 if (m_bRichText) { |
905 } else { | 905 } else { |
906 wsText = m_pTextDataNode->GetContent(); | 906 wsText = m_pTextDataNode->GetContent(); |
907 } | 907 } |
908 return wsText.GetLength(); | 908 return wsText.GetLength(); |
909 } | 909 } |
910 FX_FLOAT CXFA_TextLayout::GetLayoutHeight() { | 910 FX_FLOAT CXFA_TextLayout::GetLayoutHeight() { |
911 if (m_pLoader == NULL) { | 911 if (!m_pLoader) { |
912 return 0; | 912 return 0; |
913 } | 913 } |
914 int32_t iCount = m_pLoader->m_lineHeights.GetSize(); | 914 int32_t iCount = m_pLoader->m_lineHeights.GetSize(); |
915 if (iCount == 0 && m_pLoader->m_fWidth > 0) { | 915 if (iCount == 0 && m_pLoader->m_fWidth > 0) { |
916 CFX_SizeF szMax(m_pLoader->m_fWidth, m_pLoader->m_fHeight); | 916 CFX_SizeF szMax(m_pLoader->m_fWidth, m_pLoader->m_fHeight); |
917 CFX_SizeF szDef; | 917 CFX_SizeF szDef; |
918 m_pLoader->m_bSaveLineHeight = TRUE; | 918 m_pLoader->m_bSaveLineHeight = TRUE; |
919 m_pLoader->m_fLastPos = 0; | 919 m_pLoader->m_fLastPos = 0; |
920 CalcSize(szMax, szMax, szDef); | 920 CalcSize(szMax, szMax, szDef); |
921 m_pLoader->m_bSaveLineHeight = FALSE; | 921 m_pLoader->m_bSaveLineHeight = FALSE; |
(...skipping 28 matching lines...) Expand all Loading... |
950 CalcSize(szMax, szMax, szDef); | 950 CalcSize(szMax, szMax, szDef); |
951 m_pLoader->m_bSaveLineHeight = FALSE; | 951 m_pLoader->m_bSaveLineHeight = FALSE; |
952 fWidth = szDef.x; | 952 fWidth = szDef.x; |
953 } | 953 } |
954 return fWidth; | 954 return fWidth; |
955 } | 955 } |
956 FX_BOOL CXFA_TextLayout::DoLayout(int32_t iBlockIndex, | 956 FX_BOOL CXFA_TextLayout::DoLayout(int32_t iBlockIndex, |
957 FX_FLOAT& fCalcHeight, | 957 FX_FLOAT& fCalcHeight, |
958 FX_FLOAT fContentAreaHeight, | 958 FX_FLOAT fContentAreaHeight, |
959 FX_FLOAT fTextHeight) { | 959 FX_FLOAT fTextHeight) { |
960 if (m_pLoader == NULL) { | 960 if (!m_pLoader) { |
961 return FALSE; | 961 return FALSE; |
962 } | 962 } |
963 int32_t iBlockCount = m_Blocks.GetSize(); | 963 int32_t iBlockCount = m_Blocks.GetSize(); |
964 FX_FLOAT fHeight = fTextHeight; | 964 FX_FLOAT fHeight = fTextHeight; |
965 if (fHeight < 0) { | 965 if (fHeight < 0) { |
966 fHeight = GetLayoutHeight(); | 966 fHeight = GetLayoutHeight(); |
967 } | 967 } |
968 m_pLoader->m_fHeight = fHeight; | 968 m_pLoader->m_fHeight = fHeight; |
969 if (fContentAreaHeight < 0) { | 969 if (fContentAreaHeight < 0) { |
970 return FALSE; | 970 return FALSE; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1044 defaultSize.x = maxSize.x; | 1044 defaultSize.x = maxSize.x; |
1045 if (defaultSize.x < 1) | 1045 if (defaultSize.x < 1) |
1046 defaultSize.x = 0xFFFF; | 1046 defaultSize.x = 0xFFFF; |
1047 | 1047 |
1048 m_pBreak.reset(CreateBreak(FALSE)); | 1048 m_pBreak.reset(CreateBreak(FALSE)); |
1049 FX_FLOAT fLinePos = 0; | 1049 FX_FLOAT fLinePos = 0; |
1050 m_iLines = 0; | 1050 m_iLines = 0; |
1051 m_fMaxWidth = 0; | 1051 m_fMaxWidth = 0; |
1052 Loader(defaultSize, fLinePos, FALSE); | 1052 Loader(defaultSize, fLinePos, FALSE); |
1053 if (fLinePos < 0.1f) | 1053 if (fLinePos < 0.1f) |
1054 fLinePos = m_textParser.GetFontSize(m_pTextProvider, NULL); | 1054 fLinePos = m_textParser.GetFontSize(m_pTextProvider, nullptr); |
1055 | 1055 |
1056 m_pTabstopContext.reset(); | 1056 m_pTabstopContext.reset(); |
1057 defaultSize = CFX_SizeF(m_fMaxWidth, fLinePos); | 1057 defaultSize = CFX_SizeF(m_fMaxWidth, fLinePos); |
1058 return TRUE; | 1058 return TRUE; |
1059 } | 1059 } |
1060 | 1060 |
1061 FX_BOOL CXFA_TextLayout::Layout(const CFX_SizeF& size, FX_FLOAT* fHeight) { | 1061 FX_BOOL CXFA_TextLayout::Layout(const CFX_SizeF& size, FX_FLOAT* fHeight) { |
1062 if (size.x < 1) | 1062 if (size.x < 1) |
1063 return FALSE; | 1063 return FALSE; |
1064 | 1064 |
1065 Unload(); | 1065 Unload(); |
1066 m_pBreak.reset(CreateBreak(TRUE)); | 1066 m_pBreak.reset(CreateBreak(TRUE)); |
1067 if (m_pLoader) { | 1067 if (m_pLoader) { |
1068 m_pLoader->m_iTotalLines = -1; | 1068 m_pLoader->m_iTotalLines = -1; |
1069 m_pLoader->m_iChar = 0; | 1069 m_pLoader->m_iChar = 0; |
1070 } | 1070 } |
1071 m_iLines = 0; | 1071 m_iLines = 0; |
1072 FX_FLOAT fLinePos = 0; | 1072 FX_FLOAT fLinePos = 0; |
1073 Loader(size, fLinePos, TRUE); | 1073 Loader(size, fLinePos, TRUE); |
1074 UpdateAlign(size.y, fLinePos); | 1074 UpdateAlign(size.y, fLinePos); |
1075 m_pTabstopContext.reset(); | 1075 m_pTabstopContext.reset(); |
1076 if (fHeight) | 1076 if (fHeight) |
1077 *fHeight = fLinePos; | 1077 *fHeight = fLinePos; |
1078 return TRUE; | 1078 return TRUE; |
1079 } | 1079 } |
1080 | 1080 |
1081 FX_BOOL CXFA_TextLayout::Layout(int32_t iBlock) { | 1081 FX_BOOL CXFA_TextLayout::Layout(int32_t iBlock) { |
1082 if (m_pLoader == NULL || iBlock < 0 || iBlock >= CountBlocks()) | 1082 if (!m_pLoader || iBlock < 0 || iBlock >= CountBlocks()) |
1083 return FALSE; | 1083 return FALSE; |
1084 if (m_pLoader->m_fWidth < 1) | 1084 if (m_pLoader->m_fWidth < 1) |
1085 return FALSE; | 1085 return FALSE; |
1086 | 1086 |
1087 m_pLoader->m_iTotalLines = -1; | 1087 m_pLoader->m_iTotalLines = -1; |
1088 m_iLines = 0; | 1088 m_iLines = 0; |
1089 FX_FLOAT fLinePos = 0; | 1089 FX_FLOAT fLinePos = 0; |
1090 CXFA_Node* pNode = NULL; | 1090 CXFA_Node* pNode = nullptr; |
1091 CFX_SizeF szText(m_pLoader->m_fWidth, m_pLoader->m_fHeight); | 1091 CFX_SizeF szText(m_pLoader->m_fWidth, m_pLoader->m_fHeight); |
1092 int32_t iCount = m_Blocks.GetSize(); | 1092 int32_t iCount = m_Blocks.GetSize(); |
1093 int32_t iBlocksHeightCount = m_pLoader->m_BlocksHeight.GetSize(); | 1093 int32_t iBlocksHeightCount = m_pLoader->m_BlocksHeight.GetSize(); |
1094 iBlocksHeightCount /= 2; | 1094 iBlocksHeightCount /= 2; |
1095 if (iBlock < iBlocksHeightCount) | 1095 if (iBlock < iBlocksHeightCount) |
1096 return TRUE; | 1096 return TRUE; |
1097 if (iBlock == iBlocksHeightCount) { | 1097 if (iBlock == iBlocksHeightCount) { |
1098 Unload(); | 1098 Unload(); |
1099 m_pBreak.reset(CreateBreak(TRUE)); | 1099 m_pBreak.reset(CreateBreak(TRUE)); |
1100 fLinePos = m_pLoader->m_fStartLineOffset; | 1100 fLinePos = m_pLoader->m_fStartLineOffset; |
(...skipping 25 matching lines...) Expand all Loading... |
1126 if (!LoadRichText(pXMLNode, szText, fLinePos, m_pLoader->m_pParentStyle, | 1126 if (!LoadRichText(pXMLNode, szText, fLinePos, m_pLoader->m_pParentStyle, |
1127 TRUE)) { | 1127 TRUE)) { |
1128 break; | 1128 break; |
1129 } | 1129 } |
1130 } | 1130 } |
1131 while (!pXMLNode) { | 1131 while (!pXMLNode) { |
1132 pXMLNode = pSaveXMLNode->GetNodeItem(CFDE_XMLNode::Parent); | 1132 pXMLNode = pSaveXMLNode->GetNodeItem(CFDE_XMLNode::Parent); |
1133 if (pXMLNode == pContainerNode) | 1133 if (pXMLNode == pContainerNode) |
1134 break; | 1134 break; |
1135 if (!LoadRichText(pXMLNode, szText, fLinePos, m_pLoader->m_pParentStyle, | 1135 if (!LoadRichText(pXMLNode, szText, fLinePos, m_pLoader->m_pParentStyle, |
1136 TRUE, NULL, FALSE)) { | 1136 TRUE, nullptr, FALSE)) { |
1137 break; | 1137 break; |
1138 } | 1138 } |
1139 pSaveXMLNode = pXMLNode; | 1139 pSaveXMLNode = pXMLNode; |
1140 pXMLNode = pXMLNode->GetNodeItem(CFDE_XMLNode::NextSibling); | 1140 pXMLNode = pXMLNode->GetNodeItem(CFDE_XMLNode::NextSibling); |
1141 if (!pXMLNode) | 1141 if (!pXMLNode) |
1142 continue; | 1142 continue; |
1143 for (; pXMLNode; | 1143 for (; pXMLNode; |
1144 pXMLNode = pXMLNode->GetNodeItem(CFDE_XMLNode::NextSibling)) { | 1144 pXMLNode = pXMLNode->GetNodeItem(CFDE_XMLNode::NextSibling)) { |
1145 if (!LoadRichText(pXMLNode, szText, fLinePos, | 1145 if (!LoadRichText(pXMLNode, szText, fLinePos, |
1146 m_pLoader->m_pParentStyle, TRUE)) { | 1146 m_pLoader->m_pParentStyle, TRUE)) { |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1215 pDevice->SetClipRect(rtClip); | 1215 pDevice->SetClipRect(rtClip); |
1216 | 1216 |
1217 std::unique_ptr<CFDE_Brush> pSolidBrush(new CFDE_Brush); | 1217 std::unique_ptr<CFDE_Brush> pSolidBrush(new CFDE_Brush); |
1218 std::unique_ptr<CFDE_Pen> pPen(new CFDE_Pen); | 1218 std::unique_ptr<CFDE_Pen> pPen(new CFDE_Pen); |
1219 if (m_pieceLines.GetSize() == 0) { | 1219 if (m_pieceLines.GetSize() == 0) { |
1220 int32_t iBlockCount = CountBlocks(); | 1220 int32_t iBlockCount = CountBlocks(); |
1221 for (int32_t i = 0; i < iBlockCount; i++) { | 1221 for (int32_t i = 0; i < iBlockCount; i++) { |
1222 Layout(i); | 1222 Layout(i); |
1223 } | 1223 } |
1224 } | 1224 } |
1225 FXTEXT_CHARPOS* pCharPos = NULL; | 1225 FXTEXT_CHARPOS* pCharPos = nullptr; |
1226 int32_t iCharCount = 0; | 1226 int32_t iCharCount = 0; |
1227 int32_t iLineStart = 0; | 1227 int32_t iLineStart = 0; |
1228 int32_t iPieceLines = m_pieceLines.GetSize(); | 1228 int32_t iPieceLines = m_pieceLines.GetSize(); |
1229 int32_t iCount = m_Blocks.GetSize(); | 1229 int32_t iCount = m_Blocks.GetSize(); |
1230 if (iCount > 0) { | 1230 if (iCount > 0) { |
1231 iBlock *= 2; | 1231 iBlock *= 2; |
1232 if (iBlock < iCount) { | 1232 if (iBlock < iCount) { |
1233 iLineStart = m_Blocks.ElementAt(iBlock); | 1233 iLineStart = m_Blocks.ElementAt(iBlock); |
1234 iPieceLines = m_Blocks.ElementAt(iBlock + 1); | 1234 iPieceLines = m_Blocks.ElementAt(iBlock + 1); |
1235 } else { | 1235 } else { |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1349 } | 1349 } |
1350 FX_BOOL CXFA_TextLayout::LoadRichText(CFDE_XMLNode* pXMLNode, | 1350 FX_BOOL CXFA_TextLayout::LoadRichText(CFDE_XMLNode* pXMLNode, |
1351 const CFX_SizeF& szText, | 1351 const CFX_SizeF& szText, |
1352 FX_FLOAT& fLinePos, | 1352 FX_FLOAT& fLinePos, |
1353 IFDE_CSSComputedStyle* pParentStyle, | 1353 IFDE_CSSComputedStyle* pParentStyle, |
1354 FX_BOOL bSavePieces, | 1354 FX_BOOL bSavePieces, |
1355 CXFA_LinkUserData* pLinkData, | 1355 CXFA_LinkUserData* pLinkData, |
1356 FX_BOOL bEndBreak, | 1356 FX_BOOL bEndBreak, |
1357 FX_BOOL bIsOl, | 1357 FX_BOOL bIsOl, |
1358 int32_t iLiCount) { | 1358 int32_t iLiCount) { |
1359 if (pXMLNode == NULL) { | 1359 if (!pXMLNode) { |
1360 return FALSE; | 1360 return FALSE; |
1361 } | 1361 } |
1362 CXFA_TextParseContext* pContext = | 1362 CXFA_TextParseContext* pContext = |
1363 m_textParser.GetParseContextFromMap(pXMLNode); | 1363 m_textParser.GetParseContextFromMap(pXMLNode); |
1364 FDE_CSSDISPLAY eDisplay = FDE_CSSDISPLAY_None; | 1364 FDE_CSSDISPLAY eDisplay = FDE_CSSDISPLAY_None; |
1365 FX_BOOL bContentNode = FALSE; | 1365 FX_BOOL bContentNode = FALSE; |
1366 FX_FLOAT fSpaceBelow = 0; | 1366 FX_FLOAT fSpaceBelow = 0; |
1367 IFDE_CSSComputedStyle* pStyle = NULL; | 1367 IFDE_CSSComputedStyle* pStyle = nullptr; |
1368 CFX_WideString wsName; | 1368 CFX_WideString wsName; |
1369 if (bEndBreak) { | 1369 if (bEndBreak) { |
1370 FX_BOOL bCurOl = FALSE; | 1370 FX_BOOL bCurOl = FALSE; |
1371 FX_BOOL bCurLi = FALSE; | 1371 FX_BOOL bCurLi = FALSE; |
1372 CFDE_XMLElement* pElement = NULL; | 1372 CFDE_XMLElement* pElement = nullptr; |
1373 if (pContext) { | 1373 if (pContext) { |
1374 if (m_bBlockContinue || | 1374 if (m_bBlockContinue || |
1375 (m_pLoader && pXMLNode == m_pLoader->m_pXMLNode)) { | 1375 (m_pLoader && pXMLNode == m_pLoader->m_pXMLNode)) { |
1376 m_bBlockContinue = TRUE; | 1376 m_bBlockContinue = TRUE; |
1377 } | 1377 } |
1378 if (pXMLNode->GetType() == FDE_XMLNODE_Text) { | 1378 if (pXMLNode->GetType() == FDE_XMLNODE_Text) { |
1379 bContentNode = TRUE; | 1379 bContentNode = TRUE; |
1380 } else if (pXMLNode->GetType() == FDE_XMLNODE_Element) { | 1380 } else if (pXMLNode->GetType() == FDE_XMLNODE_Element) { |
1381 pElement = static_cast<CFDE_XMLElement*>(pXMLNode); | 1381 pElement = static_cast<CFDE_XMLElement*>(pXMLNode); |
1382 pElement->GetLocalTagName(wsName); | 1382 pElement->GetLocalTagName(wsName); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1458 (m_pLoader->m_dwFlags & XFA_LOADERCNTXTFLG_FILTERSPACE)) { | 1458 (m_pLoader->m_dwFlags & XFA_LOADERCNTXTFLG_FILTERSPACE)) { |
1459 m_pLoader->m_dwFlags &= ~XFA_LOADERCNTXTFLG_FILTERSPACE; | 1459 m_pLoader->m_dwFlags &= ~XFA_LOADERCNTXTFLG_FILTERSPACE; |
1460 } else if (wsText.GetLength() > 0 && | 1460 } else if (wsText.GetLength() > 0 && |
1461 (0x20 == wsText.GetAt(wsText.GetLength() - 1))) { | 1461 (0x20 == wsText.GetAt(wsText.GetLength() - 1))) { |
1462 m_pLoader->m_dwFlags |= XFA_LOADERCNTXTFLG_FILTERSPACE; | 1462 m_pLoader->m_dwFlags |= XFA_LOADERCNTXTFLG_FILTERSPACE; |
1463 } else if (wsText.GetLength() != 0) { | 1463 } else if (wsText.GetLength() != 0) { |
1464 m_pLoader->m_dwFlags &= ~XFA_LOADERCNTXTFLG_FILTERSPACE; | 1464 m_pLoader->m_dwFlags &= ~XFA_LOADERCNTXTFLG_FILTERSPACE; |
1465 } | 1465 } |
1466 } | 1466 } |
1467 if (wsText.GetLength() > 0) { | 1467 if (wsText.GetLength() > 0) { |
1468 if (m_pLoader == NULL || m_pLoader->m_iChar == 0) { | 1468 if (!m_pLoader || m_pLoader->m_iChar == 0) { |
1469 if (pLinkData) { | 1469 if (pLinkData) { |
1470 pLinkData->Retain(); | 1470 pLinkData->Retain(); |
1471 } | 1471 } |
1472 CXFA_TextUserData* pUserData = FXTARGET_NewWith(m_pAllocator.get()) | 1472 CXFA_TextUserData* pUserData = FXTARGET_NewWith(m_pAllocator.get()) |
1473 CXFA_TextUserData(m_pAllocator.get(), | 1473 CXFA_TextUserData(m_pAllocator.get(), |
1474 bContentNode ? pParentStyle : pStyle, | 1474 bContentNode ? pParentStyle : pStyle, |
1475 pLinkData); | 1475 pLinkData); |
1476 m_pBreak->SetUserData(pUserData); | 1476 m_pBreak->SetUserData(pUserData); |
1477 } | 1477 } |
1478 if (AppendChar(wsText, fLinePos, 0, bSavePieces)) { | 1478 if (AppendChar(wsText, fLinePos, 0, bSavePieces)) { |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1622 void CXFA_TextLayout::EndBreak(uint32_t dwStatus, | 1622 void CXFA_TextLayout::EndBreak(uint32_t dwStatus, |
1623 FX_FLOAT& fLinePos, | 1623 FX_FLOAT& fLinePos, |
1624 FX_BOOL bSavePieces) { | 1624 FX_BOOL bSavePieces) { |
1625 dwStatus = m_pBreak->EndBreak(dwStatus); | 1625 dwStatus = m_pBreak->EndBreak(dwStatus); |
1626 if (dwStatus > FX_RTFBREAK_PieceBreak) { | 1626 if (dwStatus > FX_RTFBREAK_PieceBreak) { |
1627 AppendTextLine(dwStatus, fLinePos, bSavePieces, TRUE); | 1627 AppendTextLine(dwStatus, fLinePos, bSavePieces, TRUE); |
1628 } | 1628 } |
1629 } | 1629 } |
1630 void CXFA_TextLayout::DoTabstops(IFDE_CSSComputedStyle* pStyle, | 1630 void CXFA_TextLayout::DoTabstops(IFDE_CSSComputedStyle* pStyle, |
1631 CXFA_PieceLine* pPieceLine) { | 1631 CXFA_PieceLine* pPieceLine) { |
1632 if (m_pTabstopContext == NULL || m_pTabstopContext->m_iTabCount == 0) { | 1632 if (!m_pTabstopContext || m_pTabstopContext->m_iTabCount == 0) { |
1633 return; | 1633 return; |
1634 } | 1634 } |
1635 if (pStyle == NULL || pPieceLine == NULL) { | 1635 if (!pStyle || !pPieceLine) { |
1636 return; | 1636 return; |
1637 } | 1637 } |
1638 int32_t iPieces = pPieceLine->m_textPieces.GetSize(); | 1638 int32_t iPieces = pPieceLine->m_textPieces.GetSize(); |
1639 if (iPieces == 0) { | 1639 if (iPieces == 0) { |
1640 return; | 1640 return; |
1641 } | 1641 } |
1642 XFA_TextPiece* pPiece = pPieceLine->m_textPieces.GetAt(iPieces - 1); | 1642 XFA_TextPiece* pPiece = pPieceLine->m_textPieces.GetAt(iPieces - 1); |
1643 int32_t& iTabstopsIndex = m_pTabstopContext->m_iTabIndex; | 1643 int32_t& iTabstopsIndex = m_pTabstopContext->m_iTabIndex; |
1644 int32_t iCount = m_textParser.CountTabs(pStyle); | 1644 int32_t iCount = m_textParser.CountTabs(pStyle); |
1645 if (iTabstopsIndex > m_pTabstopContext->m_iTabCount - 1) { | 1645 if (iTabstopsIndex > m_pTabstopContext->m_iTabCount - 1) { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1684 } | 1684 } |
1685 } | 1685 } |
1686 void CXFA_TextLayout::AppendTextLine(uint32_t dwStatus, | 1686 void CXFA_TextLayout::AppendTextLine(uint32_t dwStatus, |
1687 FX_FLOAT& fLinePos, | 1687 FX_FLOAT& fLinePos, |
1688 FX_BOOL bSavePieces, | 1688 FX_BOOL bSavePieces, |
1689 FX_BOOL bEndBreak) { | 1689 FX_BOOL bEndBreak) { |
1690 int32_t iPieces = m_pBreak->CountBreakPieces(); | 1690 int32_t iPieces = m_pBreak->CountBreakPieces(); |
1691 if (iPieces < 1) { | 1691 if (iPieces < 1) { |
1692 return; | 1692 return; |
1693 } | 1693 } |
1694 IFDE_CSSComputedStyle* pStyle = NULL; | 1694 IFDE_CSSComputedStyle* pStyle = nullptr; |
1695 if (bSavePieces) { | 1695 if (bSavePieces) { |
1696 CXFA_PieceLine* pPieceLine = | 1696 CXFA_PieceLine* pPieceLine = |
1697 FXTARGET_NewWith(m_pAllocator.get()) CXFA_PieceLine; | 1697 FXTARGET_NewWith(m_pAllocator.get()) CXFA_PieceLine; |
1698 m_pieceLines.Add(pPieceLine); | 1698 m_pieceLines.Add(pPieceLine); |
1699 if (m_pTabstopContext) { | 1699 if (m_pTabstopContext) { |
1700 m_pTabstopContext->Reset(); | 1700 m_pTabstopContext->Reset(); |
1701 } | 1701 } |
1702 FX_FLOAT fLineStep = 0, fBaseLine = 0; | 1702 FX_FLOAT fLineStep = 0, fBaseLine = 0; |
1703 int32_t i = 0; | 1703 int32_t i = 0; |
1704 for (i = 0; i < iPieces; i++) { | 1704 for (i = 0; i < iPieces; i++) { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1741 fBaseLineTemp = 0; | 1741 fBaseLineTemp = 0; |
1742 } | 1742 } |
1743 } else if (fBaseLine < -fBaseLineTemp) { | 1743 } else if (fBaseLine < -fBaseLineTemp) { |
1744 fBaseLine = -fBaseLineTemp; | 1744 fBaseLine = -fBaseLineTemp; |
1745 } | 1745 } |
1746 fLineStep = std::max(fLineStep, fLineHeight); | 1746 fLineStep = std::max(fLineStep, fLineHeight); |
1747 if (pUserData && pUserData->m_pLinkData) { | 1747 if (pUserData && pUserData->m_pLinkData) { |
1748 pUserData->m_pLinkData->Retain(); | 1748 pUserData->m_pLinkData->Retain(); |
1749 pTP->pLinkData = pUserData->m_pLinkData; | 1749 pTP->pLinkData = pUserData->m_pLinkData; |
1750 } else { | 1750 } else { |
1751 pTP->pLinkData = NULL; | 1751 pTP->pLinkData = nullptr; |
1752 } | 1752 } |
1753 DoTabstops(pStyle, pPieceLine); | 1753 DoTabstops(pStyle, pPieceLine); |
1754 } | 1754 } |
1755 for (i = 0; i < iPieces; i++) { | 1755 for (i = 0; i < iPieces; i++) { |
1756 XFA_TextPiece* pTP = pPieceLine->m_textPieces.GetAt(i); | 1756 XFA_TextPiece* pTP = pPieceLine->m_textPieces.GetAt(i); |
1757 FX_FLOAT& fTop = pTP->rtPiece.top; | 1757 FX_FLOAT& fTop = pTP->rtPiece.top; |
1758 FX_FLOAT fBaseLineTemp = fTop; | 1758 FX_FLOAT fBaseLineTemp = fTop; |
1759 fTop = fLinePos + fLineStep - pTP->rtPiece.height - fBaseLineTemp; | 1759 fTop = fLinePos + fLineStep - pTP->rtPiece.height - fBaseLineTemp; |
1760 fTop = std::max(0.0f, fTop); | 1760 fTop = std::max(0.0f, fTop); |
1761 } | 1761 } |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1951 pPath->AddLine(pt1, pt2); | 1951 pPath->AddLine(pt1, pt2); |
1952 fEndY += 2.0f; | 1952 fEndY += 2.0f; |
1953 } | 1953 } |
1954 } | 1954 } |
1955 pDevice->DrawPath(pPen, 1, pPath.get(), &tmDoc2Device); | 1955 pDevice->DrawPath(pPen, 1, pPath.get(), &tmDoc2Device); |
1956 } | 1956 } |
1957 | 1957 |
1958 int32_t CXFA_TextLayout::GetDisplayPos(const XFA_TextPiece* pPiece, | 1958 int32_t CXFA_TextLayout::GetDisplayPos(const XFA_TextPiece* pPiece, |
1959 FXTEXT_CHARPOS* pCharPos, | 1959 FXTEXT_CHARPOS* pCharPos, |
1960 FX_BOOL bCharCode) { | 1960 FX_BOOL bCharCode) { |
1961 if (pPiece == NULL) { | 1961 if (!pPiece) { |
1962 return 0; | 1962 return 0; |
1963 } | 1963 } |
1964 FX_RTFTEXTOBJ tr; | 1964 FX_RTFTEXTOBJ tr; |
1965 if (!ToRun(pPiece, tr)) { | 1965 if (!ToRun(pPiece, tr)) { |
1966 return 0; | 1966 return 0; |
1967 } | 1967 } |
1968 return m_pBreak->GetDisplayPos(&tr, pCharPos, bCharCode); | 1968 return m_pBreak->GetDisplayPos(&tr, pCharPos, bCharCode); |
1969 } | 1969 } |
1970 FX_BOOL CXFA_TextLayout::ToRun(const XFA_TextPiece* pPiece, FX_RTFTEXTOBJ& tr) { | 1970 FX_BOOL CXFA_TextLayout::ToRun(const XFA_TextPiece* pPiece, FX_RTFTEXTOBJ& tr) { |
1971 int32_t iLength = pPiece->iChars; | 1971 int32_t iLength = pPiece->iChars; |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2082 m_tabstops.RemoveAll(); | 2082 m_tabstops.RemoveAll(); |
2083 m_iTabCount = 0; | 2083 m_iTabCount = 0; |
2084 } | 2084 } |
2085 | 2085 |
2086 void CXFA_TextTabstopsContext::Reset() { | 2086 void CXFA_TextTabstopsContext::Reset() { |
2087 m_iTabIndex = -1; | 2087 m_iTabIndex = -1; |
2088 m_bTabstops = FALSE; | 2088 m_bTabstops = FALSE; |
2089 m_fTabWidth = 0; | 2089 m_fTabWidth = 0; |
2090 m_fLeft = 0; | 2090 m_fLeft = 0; |
2091 } | 2091 } |
OLD | NEW |