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 19 matching lines...) Expand all Loading... |
30 m_dwMatchedDecls = iDeclCount; | 30 m_dwMatchedDecls = iDeclCount; |
31 m_ppMatchedDecls = FX_Alloc(CFDE_CSSDeclaration*, iDeclCount); | 31 m_ppMatchedDecls = FX_Alloc(CFDE_CSSDeclaration*, iDeclCount); |
32 FXSYS_memcpy(m_ppMatchedDecls, ppDeclArray, | 32 FXSYS_memcpy(m_ppMatchedDecls, ppDeclArray, |
33 iDeclCount * sizeof(CFDE_CSSDeclaration*)); | 33 iDeclCount * sizeof(CFDE_CSSDeclaration*)); |
34 } | 34 } |
35 CXFA_TextParser::~CXFA_TextParser() { | 35 CXFA_TextParser::~CXFA_TextParser() { |
36 if (m_pUASheet) | 36 if (m_pUASheet) |
37 m_pUASheet->Release(); | 37 m_pUASheet->Release(); |
38 if (m_pSelector) | 38 if (m_pSelector) |
39 m_pSelector->Release(); | 39 m_pSelector->Release(); |
40 if (m_pAllocator) | 40 delete m_pAllocator; |
41 m_pAllocator->Release(); | |
42 FX_POSITION ps = m_mapXMLNodeToParseContext.GetStartPosition(); | 41 FX_POSITION ps = m_mapXMLNodeToParseContext.GetStartPosition(); |
43 while (ps) { | 42 while (ps) { |
44 CFDE_XMLNode* pXMLNode; | 43 CFDE_XMLNode* pXMLNode; |
45 CXFA_TextParseContext* pParseContext; | 44 CXFA_TextParseContext* pParseContext; |
46 m_mapXMLNodeToParseContext.GetNextAssoc(ps, pXMLNode, pParseContext); | 45 m_mapXMLNodeToParseContext.GetNextAssoc(ps, pXMLNode, pParseContext); |
47 if (pParseContext) | 46 if (pParseContext) |
48 FXTARGET_DeleteWith(CXFA_TextParseContext, m_pAllocator, pParseContext); | 47 FXTARGET_DeleteWith(CXFA_TextParseContext, m_pAllocator, pParseContext); |
49 } | 48 } |
50 m_mapXMLNodeToParseContext.RemoveAll(); | 49 m_mapXMLNodeToParseContext.RemoveAll(); |
51 } | 50 } |
52 void CXFA_TextParser::Reset() { | 51 void CXFA_TextParser::Reset() { |
53 FX_POSITION ps = m_mapXMLNodeToParseContext.GetStartPosition(); | 52 FX_POSITION ps = m_mapXMLNodeToParseContext.GetStartPosition(); |
54 while (ps) { | 53 while (ps) { |
55 CFDE_XMLNode* pXMLNode; | 54 CFDE_XMLNode* pXMLNode; |
56 CXFA_TextParseContext* pParseContext; | 55 CXFA_TextParseContext* pParseContext; |
57 m_mapXMLNodeToParseContext.GetNextAssoc(ps, pXMLNode, pParseContext); | 56 m_mapXMLNodeToParseContext.GetNextAssoc(ps, pXMLNode, pParseContext); |
58 if (pParseContext) | 57 if (pParseContext) |
59 FXTARGET_DeleteWith(CXFA_TextParseContext, m_pAllocator, pParseContext); | 58 FXTARGET_DeleteWith(CXFA_TextParseContext, m_pAllocator, pParseContext); |
60 } | 59 } |
61 m_mapXMLNodeToParseContext.RemoveAll(); | 60 m_mapXMLNodeToParseContext.RemoveAll(); |
62 if (m_pAllocator) { | 61 delete m_pAllocator; |
63 m_pAllocator->Release(); | 62 m_pAllocator = nullptr; |
64 m_pAllocator = NULL; | |
65 } | |
66 } | 63 } |
67 void CXFA_TextParser::InitCSSData(CXFA_TextProvider* pTextProvider) { | 64 void CXFA_TextParser::InitCSSData(CXFA_TextProvider* pTextProvider) { |
68 if (pTextProvider == NULL) { | 65 if (pTextProvider == NULL) { |
69 return; | 66 return; |
70 } | 67 } |
71 if (m_pSelector == NULL) { | 68 if (m_pSelector == NULL) { |
72 CXFA_FFDoc* pDoc = pTextProvider->GetDocNode(); | 69 CXFA_FFDoc* pDoc = pTextProvider->GetDocNode(); |
73 IFX_FontMgr* pFontMgr = pDoc->GetApp()->GetFDEFontMgr(); | 70 IFX_FontMgr* pFontMgr = pDoc->GetApp()->GetFDEFontMgr(); |
74 ASSERT(pFontMgr); | 71 ASSERT(pFontMgr); |
75 m_pSelector = new CFDE_CSSStyleSelector; | 72 m_pSelector = new CFDE_CSSStyleSelector; |
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
658 int32_t iCount = m_pieceLines.GetSize(); | 655 int32_t iCount = m_pieceLines.GetSize(); |
659 for (int32_t i = 0; i < iCount; i++) { | 656 for (int32_t i = 0; i < iCount; i++) { |
660 CXFA_PieceLine* pLine = m_pieceLines.GetAt(i); | 657 CXFA_PieceLine* pLine = m_pieceLines.GetAt(i); |
661 FXTARGET_DeleteWith(CXFA_PieceLine, m_pAllocator, pLine); | 658 FXTARGET_DeleteWith(CXFA_PieceLine, m_pAllocator, pLine); |
662 } | 659 } |
663 m_pieceLines.RemoveAll(); | 660 m_pieceLines.RemoveAll(); |
664 if (m_pBreak) { | 661 if (m_pBreak) { |
665 m_pBreak->Release(); | 662 m_pBreak->Release(); |
666 m_pBreak = NULL; | 663 m_pBreak = NULL; |
667 } | 664 } |
668 if (m_pAllocator) { | 665 delete m_pAllocator; |
669 m_pAllocator->Release(); | 666 m_pAllocator = nullptr; |
670 m_pAllocator = NULL; | |
671 } | |
672 } | 667 } |
673 const CXFA_PieceLineArray* CXFA_TextLayout::GetPieceLines() { | 668 const CXFA_PieceLineArray* CXFA_TextLayout::GetPieceLines() { |
674 return &m_pieceLines; | 669 return &m_pieceLines; |
675 } | 670 } |
676 void CXFA_TextLayout::GetTextDataNode() { | 671 void CXFA_TextLayout::GetTextDataNode() { |
677 if (m_pTextProvider == NULL) { | 672 if (m_pTextProvider == NULL) { |
678 return; | 673 return; |
679 } | 674 } |
680 CXFA_Node* pNode = m_pTextProvider->GetTextNode(m_bRichText); | 675 CXFA_Node* pNode = m_pTextProvider->GetTextNode(m_bRichText); |
681 if (pNode && m_bRichText) { | 676 if (pNode && m_bRichText) { |
(...skipping 1277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1959 tr.iLength = iLength; | 1954 tr.iLength = iLength; |
1960 tr.fFontSize = pPiece->fFontSize; | 1955 tr.fFontSize = pPiece->fFontSize; |
1961 tr.iBidiLevel = pPiece->iBidiLevel; | 1956 tr.iBidiLevel = pPiece->iBidiLevel; |
1962 tr.iCharRotation = 0; | 1957 tr.iCharRotation = 0; |
1963 tr.wLineBreakChar = L'\n'; | 1958 tr.wLineBreakChar = L'\n'; |
1964 tr.iVerticalScale = pPiece->iVerScale; | 1959 tr.iVerticalScale = pPiece->iVerScale; |
1965 tr.dwLayoutStyles = FX_RTFLAYOUTSTYLE_ExpandTab; | 1960 tr.dwLayoutStyles = FX_RTFLAYOUTSTYLE_ExpandTab; |
1966 tr.iHorizontalScale = pPiece->iHorScale; | 1961 tr.iHorizontalScale = pPiece->iHorScale; |
1967 return TRUE; | 1962 return TRUE; |
1968 } | 1963 } |
OLD | NEW |