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 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 m_pSelector->ComputeStyle(&tagProvider, pContext->GetDecls(), | 205 m_pSelector->ComputeStyle(&tagProvider, pContext->GetDecls(), |
206 pContext->CountDecls(), pStyle); | 206 pContext->CountDecls(), pStyle); |
207 pCSSAccel->OnLeaveTag(&tagProvider); | 207 pCSSAccel->OnLeaveTag(&tagProvider); |
208 return pStyle; | 208 return pStyle; |
209 } | 209 } |
210 void CXFA_TextParser::DoParse(CFDE_XMLNode* pXMLContainer, | 210 void CXFA_TextParser::DoParse(CFDE_XMLNode* pXMLContainer, |
211 CXFA_TextProvider* pTextProvider) { | 211 CXFA_TextProvider* pTextProvider) { |
212 if (pXMLContainer == NULL || pTextProvider == NULL || m_pAllocator) { | 212 if (pXMLContainer == NULL || pTextProvider == NULL || m_pAllocator) { |
213 return; | 213 return; |
214 } | 214 } |
215 m_pAllocator = | 215 m_pAllocator = IFX_MemoryAllocator::Create(FX_ALLOCTYPE_Fixed, 32, |
216 FX_CreateAllocator(FX_ALLOCTYPE_Fixed, 32, sizeof(CXFA_CSSTagProvider)); | 216 sizeof(CXFA_CSSTagProvider)); |
217 InitCSSData(pTextProvider); | 217 InitCSSData(pTextProvider); |
218 IFDE_CSSComputedStyle* pRootStyle = CreateRootStyle(pTextProvider); | 218 IFDE_CSSComputedStyle* pRootStyle = CreateRootStyle(pTextProvider); |
219 ParseRichText(pXMLContainer, pRootStyle); | 219 ParseRichText(pXMLContainer, pRootStyle); |
220 pRootStyle->Release(); | 220 pRootStyle->Release(); |
221 } | 221 } |
222 void CXFA_TextParser::ParseRichText(CFDE_XMLNode* pXMLNode, | 222 void CXFA_TextParser::ParseRichText(CFDE_XMLNode* pXMLNode, |
223 IFDE_CSSComputedStyle* pParentStyle) { | 223 IFDE_CSSComputedStyle* pParentStyle) { |
224 if (pXMLNode == NULL) { | 224 if (pXMLNode == NULL) { |
225 return; | 225 return; |
226 } | 226 } |
(...skipping 1038 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1265 for (int32_t j = 0; j < iPieces; j++) { | 1265 for (int32_t j = 0; j < iPieces; j++) { |
1266 XFA_TextPiece* pPiece = pPieceLine->m_textPieces.GetAt(j); | 1266 XFA_TextPiece* pPiece = pPieceLine->m_textPieces.GetAt(j); |
1267 CFX_RectF& rect = pPiece->rtPiece; | 1267 CFX_RectF& rect = pPiece->rtPiece; |
1268 rect.top += fHeight; | 1268 rect.top += fHeight; |
1269 } | 1269 } |
1270 } | 1270 } |
1271 } | 1271 } |
1272 FX_BOOL CXFA_TextLayout::Loader(const CFX_SizeF& szText, | 1272 FX_BOOL CXFA_TextLayout::Loader(const CFX_SizeF& szText, |
1273 FX_FLOAT& fLinePos, | 1273 FX_FLOAT& fLinePos, |
1274 FX_BOOL bSavePieces) { | 1274 FX_BOOL bSavePieces) { |
1275 if (m_pAllocator == NULL) { | 1275 if (!m_pAllocator) |
1276 m_pAllocator = FX_CreateAllocator(FX_ALLOCTYPE_Static, 256, 0); | 1276 m_pAllocator = IFX_MemoryAllocator::Create(FX_ALLOCTYPE_Static, 256, 0); |
1277 } | 1277 |
1278 GetTextDataNode(); | 1278 GetTextDataNode(); |
1279 if (m_pTextDataNode == NULL) { | 1279 if (m_pTextDataNode == NULL) { |
1280 return TRUE; | 1280 return TRUE; |
1281 } | 1281 } |
1282 if (m_bRichText) { | 1282 if (m_bRichText) { |
1283 CFDE_XMLNode* pXMLContainer = GetXMLContainerNode(); | 1283 CFDE_XMLNode* pXMLContainer = GetXMLContainerNode(); |
1284 if (pXMLContainer) { | 1284 if (pXMLContainer) { |
1285 if (!m_textParser.IsParsed()) { | 1285 if (!m_textParser.IsParsed()) { |
1286 m_textParser.DoParse(pXMLContainer, m_pTextProvider); | 1286 m_textParser.DoParse(pXMLContainer, m_pTextProvider); |
1287 } | 1287 } |
(...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1959 tr.iLength = iLength; | 1959 tr.iLength = iLength; |
1960 tr.fFontSize = pPiece->fFontSize; | 1960 tr.fFontSize = pPiece->fFontSize; |
1961 tr.iBidiLevel = pPiece->iBidiLevel; | 1961 tr.iBidiLevel = pPiece->iBidiLevel; |
1962 tr.iCharRotation = 0; | 1962 tr.iCharRotation = 0; |
1963 tr.wLineBreakChar = L'\n'; | 1963 tr.wLineBreakChar = L'\n'; |
1964 tr.iVerticalScale = pPiece->iVerScale; | 1964 tr.iVerticalScale = pPiece->iVerScale; |
1965 tr.dwLayoutStyles = FX_RTFLAYOUTSTYLE_ExpandTab; | 1965 tr.dwLayoutStyles = FX_RTFLAYOUTSTYLE_ExpandTab; |
1966 tr.iHorizontalScale = pPiece->iHorScale; | 1966 tr.iHorizontalScale = pPiece->iHorScale; |
1967 return TRUE; | 1967 return TRUE; |
1968 } | 1968 } |
OLD | NEW |