| 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 |
| 11 #include "core/fxcrt/include/fx_ext.h" | 11 #include "core/fxcrt/include/fx_ext.h" |
| 12 #include "xfa/fde/cfde_path.h" | 12 #include "xfa/fde/cfde_path.h" |
| 13 #include "xfa/fde/css/fde_csscache.h" | 13 #include "xfa/fde/css/fde_csscache.h" |
| 14 #include "xfa/fde/css/fde_cssstyleselector.h" |
| 14 #include "xfa/fde/fde_gedevice.h" | 15 #include "xfa/fde/fde_gedevice.h" |
| 15 #include "xfa/fde/fde_object.h" | 16 #include "xfa/fde/fde_object.h" |
| 16 #include "xfa/fde/xml/fde_xml_imp.h" | 17 #include "xfa/fde/xml/fde_xml_imp.h" |
| 17 #include "xfa/fgas/crt/fgas_algorithm.h" | 18 #include "xfa/fgas/crt/fgas_algorithm.h" |
| 18 #include "xfa/fgas/crt/fgas_codepage.h" | 19 #include "xfa/fgas/crt/fgas_codepage.h" |
| 19 #include "xfa/fxfa/app/xfa_ffwidgetacc.h" | 20 #include "xfa/fxfa/app/xfa_ffwidgetacc.h" |
| 20 #include "xfa/fxfa/include/xfa_ffapp.h" | 21 #include "xfa/fxfa/include/xfa_ffapp.h" |
| 21 #include "xfa/fxfa/include/xfa_ffdoc.h" | 22 #include "xfa/fxfa/include/xfa_ffdoc.h" |
| 22 #include "xfa/fxfa/include/xfa_fontmgr.h" | 23 #include "xfa/fxfa/include/xfa_fontmgr.h" |
| 23 | 24 |
| 24 void CXFA_TextParseContext::SetDecls(const IFDE_CSSDeclaration** ppDeclArray, | 25 void CXFA_TextParseContext::SetDecls(const CFDE_CSSDeclaration** ppDeclArray, |
| 25 int32_t iDeclCount) { | 26 int32_t iDeclCount) { |
| 26 if (iDeclCount <= 0 || !ppDeclArray) | 27 if (iDeclCount <= 0 || !ppDeclArray) |
| 27 return; | 28 return; |
| 28 | 29 |
| 29 m_dwMatchedDecls = iDeclCount; | 30 m_dwMatchedDecls = iDeclCount; |
| 30 m_ppMatchedDecls = FX_Alloc(IFDE_CSSDeclaration*, iDeclCount); | 31 m_ppMatchedDecls = FX_Alloc(CFDE_CSSDeclaration*, iDeclCount); |
| 31 FXSYS_memcpy(m_ppMatchedDecls, ppDeclArray, | 32 FXSYS_memcpy(m_ppMatchedDecls, ppDeclArray, |
| 32 iDeclCount * sizeof(IFDE_CSSDeclaration*)); | 33 iDeclCount * sizeof(CFDE_CSSDeclaration*)); |
| 33 } | 34 } |
| 34 CXFA_TextParser::~CXFA_TextParser() { | 35 CXFA_TextParser::~CXFA_TextParser() { |
| 35 if (m_pUASheet) | 36 if (m_pUASheet) |
| 36 m_pUASheet->Release(); | 37 m_pUASheet->Release(); |
| 37 if (m_pSelector) | 38 if (m_pSelector) |
| 38 m_pSelector->Release(); | 39 m_pSelector->Release(); |
| 39 if (m_pAllocator) | 40 if (m_pAllocator) |
| 40 m_pAllocator->Release(); | 41 m_pAllocator->Release(); |
| 41 FX_POSITION ps = m_mapXMLNodeToParseContext.GetStartPosition(); | 42 FX_POSITION ps = m_mapXMLNodeToParseContext.GetStartPosition(); |
| 42 while (ps) { | 43 while (ps) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 64 } | 65 } |
| 65 } | 66 } |
| 66 void CXFA_TextParser::InitCSSData(CXFA_TextProvider* pTextProvider) { | 67 void CXFA_TextParser::InitCSSData(CXFA_TextProvider* pTextProvider) { |
| 67 if (pTextProvider == NULL) { | 68 if (pTextProvider == NULL) { |
| 68 return; | 69 return; |
| 69 } | 70 } |
| 70 if (m_pSelector == NULL) { | 71 if (m_pSelector == NULL) { |
| 71 CXFA_FFDoc* pDoc = pTextProvider->GetDocNode(); | 72 CXFA_FFDoc* pDoc = pTextProvider->GetDocNode(); |
| 72 IFX_FontMgr* pFontMgr = pDoc->GetApp()->GetFDEFontMgr(); | 73 IFX_FontMgr* pFontMgr = pDoc->GetApp()->GetFDEFontMgr(); |
| 73 ASSERT(pFontMgr); | 74 ASSERT(pFontMgr); |
| 74 m_pSelector = IFDE_CSSStyleSelector::Create(); | 75 m_pSelector = new CFDE_CSSStyleSelector; |
| 75 m_pSelector->SetFontMgr(pFontMgr); | 76 m_pSelector->SetFontMgr(pFontMgr); |
| 76 FX_FLOAT fFontSize = 10; | 77 FX_FLOAT fFontSize = 10; |
| 77 CXFA_Font font = pTextProvider->GetFontNode(); | 78 CXFA_Font font = pTextProvider->GetFontNode(); |
| 78 if (font) { | 79 if (font) { |
| 79 fFontSize = font.GetFontSize(); | 80 fFontSize = font.GetFontSize(); |
| 80 } | 81 } |
| 81 m_pSelector->SetDefFontSize(fFontSize); | 82 m_pSelector->SetDefFontSize(fFontSize); |
| 82 } | 83 } |
| 83 if (m_pUASheet == NULL) { | 84 if (m_pUASheet == NULL) { |
| 84 m_pUASheet = LoadDefaultSheetStyle(); | 85 m_pUASheet = LoadDefaultSheetStyle(); |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 CXFA_TextParseContext* pTextContext = | 235 CXFA_TextParseContext* pTextContext = |
| 235 FXTARGET_NewWith(m_pAllocator) CXFA_TextParseContext; | 236 FXTARGET_NewWith(m_pAllocator) CXFA_TextParseContext; |
| 236 FDE_CSSDISPLAY eDisplay = FDE_CSSDISPLAY_Inline; | 237 FDE_CSSDISPLAY eDisplay = FDE_CSSDISPLAY_Inline; |
| 237 if (!tagProvider.m_bContent) { | 238 if (!tagProvider.m_bContent) { |
| 238 pNewStyle = CreateStyle(pParentStyle); | 239 pNewStyle = CreateStyle(pParentStyle); |
| 239 CFDE_CSSAccelerator* pCSSAccel = m_pSelector->InitAccelerator(); | 240 CFDE_CSSAccelerator* pCSSAccel = m_pSelector->InitAccelerator(); |
| 240 pCSSAccel->OnEnterTag(&tagProvider); | 241 pCSSAccel->OnEnterTag(&tagProvider); |
| 241 CFDE_CSSDeclarationArray DeclArray; | 242 CFDE_CSSDeclarationArray DeclArray; |
| 242 int32_t iMatchedDecls = | 243 int32_t iMatchedDecls = |
| 243 m_pSelector->MatchDeclarations(&tagProvider, DeclArray); | 244 m_pSelector->MatchDeclarations(&tagProvider, DeclArray); |
| 244 const IFDE_CSSDeclaration** ppMatchDecls = | 245 const CFDE_CSSDeclaration** ppMatchDecls = |
| 245 (const IFDE_CSSDeclaration**)DeclArray.GetData(); | 246 const_cast<const CFDE_CSSDeclaration**>(DeclArray.GetData()); |
| 246 m_pSelector->ComputeStyle(&tagProvider, ppMatchDecls, iMatchedDecls, | 247 m_pSelector->ComputeStyle(&tagProvider, ppMatchDecls, iMatchedDecls, |
| 247 pNewStyle); | 248 pNewStyle); |
| 248 pCSSAccel->OnLeaveTag(&tagProvider); | 249 pCSSAccel->OnLeaveTag(&tagProvider); |
| 249 if (iMatchedDecls > 0) { | 250 if (iMatchedDecls > 0) { |
| 250 pTextContext->SetDecls(ppMatchDecls, iMatchedDecls); | 251 pTextContext->SetDecls(ppMatchDecls, iMatchedDecls); |
| 251 } | 252 } |
| 252 eDisplay = pNewStyle->GetPositionStyles()->GetDisplay(); | 253 eDisplay = pNewStyle->GetPositionStyles()->GetDisplay(); |
| 253 } | 254 } |
| 254 pTextContext->SetDisplay(eDisplay); | 255 pTextContext->SetDisplay(eDisplay); |
| 255 m_mapXMLNodeToParseContext.SetAt(pXMLNode, pTextContext); | 256 m_mapXMLNodeToParseContext.SetAt(pXMLNode, pTextContext); |
| (...skipping 1704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1960 tr.iLength = iLength; | 1961 tr.iLength = iLength; |
| 1961 tr.fFontSize = pPiece->fFontSize; | 1962 tr.fFontSize = pPiece->fFontSize; |
| 1962 tr.iBidiLevel = pPiece->iBidiLevel; | 1963 tr.iBidiLevel = pPiece->iBidiLevel; |
| 1963 tr.iCharRotation = 0; | 1964 tr.iCharRotation = 0; |
| 1964 tr.wLineBreakChar = L'\n'; | 1965 tr.wLineBreakChar = L'\n'; |
| 1965 tr.iVerticalScale = pPiece->iVerScale; | 1966 tr.iVerticalScale = pPiece->iVerScale; |
| 1966 tr.dwLayoutStyles = FX_RTFLAYOUTSTYLE_ExpandTab; | 1967 tr.dwLayoutStyles = FX_RTFLAYOUTSTYLE_ExpandTab; |
| 1967 tr.iHorizontalScale = pPiece->iHorScale; | 1968 tr.iHorizontalScale = pPiece->iHorScale; |
| 1968 return TRUE; | 1969 return TRUE; |
| 1969 } | 1970 } |
| OLD | NEW |