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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 return pNewStyle; | 186 return pNewStyle; |
187 } | 187 } |
188 IFDE_CSSComputedStyle* CXFA_TextParser::ComputeStyle( | 188 IFDE_CSSComputedStyle* CXFA_TextParser::ComputeStyle( |
189 CFDE_XMLNode* pXMLNode, | 189 CFDE_XMLNode* pXMLNode, |
190 IFDE_CSSComputedStyle* pParentStyle) { | 190 IFDE_CSSComputedStyle* pParentStyle) { |
191 CXFA_TextParseContext* pContext = static_cast<CXFA_TextParseContext*>( | 191 CXFA_TextParseContext* pContext = static_cast<CXFA_TextParseContext*>( |
192 m_mapXMLNodeToParseContext.GetValueAt(pXMLNode)); | 192 m_mapXMLNodeToParseContext.GetValueAt(pXMLNode)); |
193 if (!pContext) | 193 if (!pContext) |
194 return nullptr; | 194 return nullptr; |
195 pContext->m_pParentStyle = pParentStyle; | 195 pContext->m_pParentStyle = pParentStyle; |
196 pParentStyle->AddRef(); | 196 pParentStyle->Retain(); |
197 CXFA_CSSTagProvider tagProvider; | 197 CXFA_CSSTagProvider tagProvider; |
198 ParseTagInfo(pXMLNode, tagProvider); | 198 ParseTagInfo(pXMLNode, tagProvider); |
199 if (tagProvider.m_bContent) | 199 if (tagProvider.m_bContent) |
200 return nullptr; | 200 return nullptr; |
201 IFDE_CSSComputedStyle* pStyle = CreateStyle(pParentStyle); | 201 IFDE_CSSComputedStyle* pStyle = CreateStyle(pParentStyle); |
202 CFDE_CSSAccelerator* pCSSAccel = m_pSelector->InitAccelerator(); | 202 CFDE_CSSAccelerator* pCSSAccel = m_pSelector->InitAccelerator(); |
203 pCSSAccel->OnEnterTag(&tagProvider); | 203 pCSSAccel->OnEnterTag(&tagProvider); |
204 m_pSelector->ComputeStyle(&tagProvider, pContext->GetDecls(), | 204 m_pSelector->ComputeStyle(&tagProvider, pContext->GetDecls(), |
205 pContext->CountDecls(), pStyle); | 205 pContext->CountDecls(), pStyle); |
206 pCSSAccel->OnLeaveTag(&tagProvider); | 206 pCSSAccel->OnLeaveTag(&tagProvider); |
(...skipping 1230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1437 } else if (wsText.GetLength() > 0 && | 1437 } else if (wsText.GetLength() > 0 && |
1438 (0x20 == wsText.GetAt(wsText.GetLength() - 1))) { | 1438 (0x20 == wsText.GetAt(wsText.GetLength() - 1))) { |
1439 m_pLoader->m_dwFlags |= XFA_LOADERCNTXTFLG_FILTERSPACE; | 1439 m_pLoader->m_dwFlags |= XFA_LOADERCNTXTFLG_FILTERSPACE; |
1440 } else if (wsText.GetLength() != 0) { | 1440 } else if (wsText.GetLength() != 0) { |
1441 m_pLoader->m_dwFlags &= ~XFA_LOADERCNTXTFLG_FILTERSPACE; | 1441 m_pLoader->m_dwFlags &= ~XFA_LOADERCNTXTFLG_FILTERSPACE; |
1442 } | 1442 } |
1443 } | 1443 } |
1444 if (wsText.GetLength() > 0) { | 1444 if (wsText.GetLength() > 0) { |
1445 if (m_pLoader == NULL || m_pLoader->m_iChar == 0) { | 1445 if (m_pLoader == NULL || m_pLoader->m_iChar == 0) { |
1446 if (pLinkData) { | 1446 if (pLinkData) { |
1447 pLinkData->AddRef(); | 1447 pLinkData->Retain(); |
1448 } | 1448 } |
1449 CXFA_TextUserData* pUserData = FXTARGET_NewWith(m_pAllocator.get()) | 1449 CXFA_TextUserData* pUserData = FXTARGET_NewWith(m_pAllocator.get()) |
1450 CXFA_TextUserData(m_pAllocator.get(), | 1450 CXFA_TextUserData(m_pAllocator.get(), |
1451 bContentNode ? pParentStyle : pStyle, | 1451 bContentNode ? pParentStyle : pStyle, |
1452 pLinkData); | 1452 pLinkData); |
1453 m_pBreak->SetUserData(pUserData); | 1453 m_pBreak->SetUserData(pUserData); |
1454 } | 1454 } |
1455 if (AppendChar(wsText, fLinePos, 0, bSavePieces)) { | 1455 if (AppendChar(wsText, fLinePos, 0, bSavePieces)) { |
1456 if (m_pLoader) { | 1456 if (m_pLoader) { |
1457 m_pLoader->m_dwFlags &= ~XFA_LOADERCNTXTFLG_FILTERSPACE; | 1457 m_pLoader->m_dwFlags &= ~XFA_LOADERCNTXTFLG_FILTERSPACE; |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1715 if (fLineHeight < fLineHeightTmp) { | 1715 if (fLineHeight < fLineHeightTmp) { |
1716 fLineHeight = fLineHeightTmp; | 1716 fLineHeight = fLineHeightTmp; |
1717 } else { | 1717 } else { |
1718 fBaseLineTemp = 0; | 1718 fBaseLineTemp = 0; |
1719 } | 1719 } |
1720 } else if (fBaseLine < -fBaseLineTemp) { | 1720 } else if (fBaseLine < -fBaseLineTemp) { |
1721 fBaseLine = -fBaseLineTemp; | 1721 fBaseLine = -fBaseLineTemp; |
1722 } | 1722 } |
1723 fLineStep = std::max(fLineStep, fLineHeight); | 1723 fLineStep = std::max(fLineStep, fLineHeight); |
1724 if (pUserData && pUserData->m_pLinkData) { | 1724 if (pUserData && pUserData->m_pLinkData) { |
1725 pUserData->m_pLinkData->AddRef(); | 1725 pUserData->m_pLinkData->Retain(); |
1726 pTP->pLinkData = pUserData->m_pLinkData; | 1726 pTP->pLinkData = pUserData->m_pLinkData; |
1727 } else { | 1727 } else { |
1728 pTP->pLinkData = NULL; | 1728 pTP->pLinkData = NULL; |
1729 } | 1729 } |
1730 DoTabstops(pStyle, pPieceLine); | 1730 DoTabstops(pStyle, pPieceLine); |
1731 } | 1731 } |
1732 for (i = 0; i < iPieces; i++) { | 1732 for (i = 0; i < iPieces; i++) { |
1733 XFA_TextPiece* pTP = pPieceLine->m_textPieces.GetAt(i); | 1733 XFA_TextPiece* pTP = pPieceLine->m_textPieces.GetAt(i); |
1734 FX_FLOAT& fTop = pTP->rtPiece.top; | 1734 FX_FLOAT& fTop = pTP->rtPiece.top; |
1735 FX_FLOAT fBaseLineTemp = fTop; | 1735 FX_FLOAT fBaseLineTemp = fTop; |
(...skipping 25 matching lines...) Expand all Loading... |
1761 } | 1761 } |
1762 fLinePos += fLineStep; | 1762 fLinePos += fLineStep; |
1763 m_fMaxWidth = std::max(m_fMaxWidth, fLineWidth); | 1763 m_fMaxWidth = std::max(m_fMaxWidth, fLineWidth); |
1764 if (m_pLoader && m_pLoader->m_bSaveLineHeight) { | 1764 if (m_pLoader && m_pLoader->m_bSaveLineHeight) { |
1765 FX_FLOAT fHeight = fLinePos - m_pLoader->m_fLastPos; | 1765 FX_FLOAT fHeight = fLinePos - m_pLoader->m_fLastPos; |
1766 m_pLoader->m_fLastPos = fLinePos; | 1766 m_pLoader->m_fLastPos = fLinePos; |
1767 m_pLoader->m_lineHeights.Add(fHeight); | 1767 m_pLoader->m_lineHeights.Add(fHeight); |
1768 } | 1768 } |
1769 } | 1769 } |
1770 if (pStyle) { | 1770 if (pStyle) { |
1771 pStyle->AddRef(); | 1771 pStyle->Retain(); |
1772 } | 1772 } |
1773 m_pBreak->ClearBreakPieces(); | 1773 m_pBreak->ClearBreakPieces(); |
1774 if (dwStatus == FX_RTFBREAK_ParagraphBreak) { | 1774 if (dwStatus == FX_RTFBREAK_ParagraphBreak) { |
1775 m_pBreak->Reset(); | 1775 m_pBreak->Reset(); |
1776 if (!pStyle && bEndBreak) { | 1776 if (!pStyle && bEndBreak) { |
1777 CXFA_Para para = m_pTextProvider->GetParaNode(); | 1777 CXFA_Para para = m_pTextProvider->GetParaNode(); |
1778 if (para) { | 1778 if (para) { |
1779 FX_FLOAT fStartPos = para.GetMarginLeft(); | 1779 FX_FLOAT fStartPos = para.GetMarginLeft(); |
1780 FX_FLOAT fIndent = para.GetTextIndent(); | 1780 FX_FLOAT fIndent = para.GetTextIndent(); |
1781 if (fIndent > 0) { | 1781 if (fIndent > 0) { |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1958 tr.iLength = iLength; | 1958 tr.iLength = iLength; |
1959 tr.fFontSize = pPiece->fFontSize; | 1959 tr.fFontSize = pPiece->fFontSize; |
1960 tr.iBidiLevel = pPiece->iBidiLevel; | 1960 tr.iBidiLevel = pPiece->iBidiLevel; |
1961 tr.iCharRotation = 0; | 1961 tr.iCharRotation = 0; |
1962 tr.wLineBreakChar = L'\n'; | 1962 tr.wLineBreakChar = L'\n'; |
1963 tr.iVerticalScale = pPiece->iVerScale; | 1963 tr.iVerticalScale = pPiece->iVerScale; |
1964 tr.dwLayoutStyles = FX_RTFLAYOUTSTYLE_ExpandTab; | 1964 tr.dwLayoutStyles = FX_RTFLAYOUTSTYLE_ExpandTab; |
1965 tr.iHorizontalScale = pPiece->iHorScale; | 1965 tr.iHorizontalScale = pPiece->iHorScale; |
1966 return TRUE; | 1966 return TRUE; |
1967 } | 1967 } |
OLD | NEW |