Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(275)

Side by Side Diff: xfa/fxfa/app/xfa_textlayout.cpp

Issue 2003843002: Remove Release() from CFX_RTFBreak (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Consistent use of override. Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/fxfa/app/xfa_textlayout.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 15 matching lines...) Expand all
26 int32_t iDeclCount) { 26 int32_t iDeclCount) {
27 if (iDeclCount <= 0 || !ppDeclArray) 27 if (iDeclCount <= 0 || !ppDeclArray)
28 return; 28 return;
29 29
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 35
36 CXFA_TextParser::CXFA_TextParser() : m_pAllocator(NULL), m_pUASheet(NULL) {} 36 CXFA_TextParser::CXFA_TextParser() : m_pUASheet(nullptr) {}
37 37
38 CXFA_TextParser::~CXFA_TextParser() { 38 CXFA_TextParser::~CXFA_TextParser() {
39 if (m_pUASheet) 39 if (m_pUASheet)
40 m_pUASheet->Release(); 40 m_pUASheet->Release();
41 41
42 delete m_pAllocator;
43 FX_POSITION ps = m_mapXMLNodeToParseContext.GetStartPosition(); 42 FX_POSITION ps = m_mapXMLNodeToParseContext.GetStartPosition();
44 while (ps) { 43 while (ps) {
45 CFDE_XMLNode* pXMLNode; 44 CFDE_XMLNode* pXMLNode;
46 CXFA_TextParseContext* pParseContext; 45 CXFA_TextParseContext* pParseContext;
47 m_mapXMLNodeToParseContext.GetNextAssoc(ps, pXMLNode, pParseContext); 46 m_mapXMLNodeToParseContext.GetNextAssoc(ps, pXMLNode, pParseContext);
48 if (pParseContext) 47 if (pParseContext)
49 FXTARGET_DeleteWith(CXFA_TextParseContext, m_pAllocator, pParseContext); 48 FXTARGET_DeleteWith(CXFA_TextParseContext, m_pAllocator.get(),
49 pParseContext);
50 } 50 }
51 m_mapXMLNodeToParseContext.RemoveAll(); 51 m_mapXMLNodeToParseContext.RemoveAll();
52 } 52 }
53 void CXFA_TextParser::Reset() { 53 void CXFA_TextParser::Reset() {
54 FX_POSITION ps = m_mapXMLNodeToParseContext.GetStartPosition(); 54 FX_POSITION ps = m_mapXMLNodeToParseContext.GetStartPosition();
55 while (ps) { 55 while (ps) {
56 CFDE_XMLNode* pXMLNode; 56 CFDE_XMLNode* pXMLNode;
57 CXFA_TextParseContext* pParseContext; 57 CXFA_TextParseContext* pParseContext;
58 m_mapXMLNodeToParseContext.GetNextAssoc(ps, pXMLNode, pParseContext); 58 m_mapXMLNodeToParseContext.GetNextAssoc(ps, pXMLNode, pParseContext);
59 if (pParseContext) 59 if (pParseContext)
60 FXTARGET_DeleteWith(CXFA_TextParseContext, m_pAllocator, pParseContext); 60 FXTARGET_DeleteWith(CXFA_TextParseContext, m_pAllocator.get(),
61 pParseContext);
61 } 62 }
62 m_mapXMLNodeToParseContext.RemoveAll(); 63 m_mapXMLNodeToParseContext.RemoveAll();
63 delete m_pAllocator; 64 m_pAllocator.reset();
64 m_pAllocator = nullptr;
65 } 65 }
66 void CXFA_TextParser::InitCSSData(CXFA_TextProvider* pTextProvider) { 66 void CXFA_TextParser::InitCSSData(CXFA_TextProvider* pTextProvider) {
67 if (!pTextProvider) 67 if (!pTextProvider)
68 return; 68 return;
69 69
70 if (!m_pSelector) { 70 if (!m_pSelector) {
71 CXFA_FFDoc* pDoc = pTextProvider->GetDocNode(); 71 CXFA_FFDoc* pDoc = pTextProvider->GetDocNode();
72 IFX_FontMgr* pFontMgr = pDoc->GetApp()->GetFDEFontMgr(); 72 IFX_FontMgr* pFontMgr = pDoc->GetApp()->GetFDEFontMgr();
73 ASSERT(pFontMgr); 73 ASSERT(pFontMgr);
74 m_pSelector.reset(new CFDE_CSSStyleSelector); 74 m_pSelector.reset(new CFDE_CSSStyleSelector);
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
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);
207 return pStyle; 207 return pStyle;
208 } 208 }
209 void CXFA_TextParser::DoParse(CFDE_XMLNode* pXMLContainer, 209 void CXFA_TextParser::DoParse(CFDE_XMLNode* pXMLContainer,
210 CXFA_TextProvider* pTextProvider) { 210 CXFA_TextProvider* pTextProvider) {
211 if (pXMLContainer == NULL || pTextProvider == NULL || m_pAllocator) { 211 if (pXMLContainer == NULL || pTextProvider == NULL || m_pAllocator) {
212 return; 212 return;
213 } 213 }
214 m_pAllocator = IFX_MemoryAllocator::Create(FX_ALLOCTYPE_Fixed, 32, 214 m_pAllocator.reset(IFX_MemoryAllocator::Create(FX_ALLOCTYPE_Fixed, 32,
215 sizeof(CXFA_CSSTagProvider)); 215 sizeof(CXFA_CSSTagProvider)));
216 InitCSSData(pTextProvider); 216 InitCSSData(pTextProvider);
217 IFDE_CSSComputedStyle* pRootStyle = CreateRootStyle(pTextProvider); 217 IFDE_CSSComputedStyle* pRootStyle = CreateRootStyle(pTextProvider);
218 ParseRichText(pXMLContainer, pRootStyle); 218 ParseRichText(pXMLContainer, pRootStyle);
219 pRootStyle->Release(); 219 pRootStyle->Release();
220 } 220 }
221 void CXFA_TextParser::ParseRichText(CFDE_XMLNode* pXMLNode, 221 void CXFA_TextParser::ParseRichText(CFDE_XMLNode* pXMLNode,
222 IFDE_CSSComputedStyle* pParentStyle) { 222 IFDE_CSSComputedStyle* pParentStyle) {
223 if (!pXMLNode) 223 if (!pXMLNode)
224 return; 224 return;
225 225
226 CXFA_CSSTagProvider tagProvider; 226 CXFA_CSSTagProvider tagProvider;
227 ParseTagInfo(pXMLNode, tagProvider); 227 ParseTagInfo(pXMLNode, tagProvider);
228 if (!tagProvider.m_bTagAvailable) 228 if (!tagProvider.m_bTagAvailable)
229 return; 229 return;
230 230
231 IFDE_CSSComputedStyle* pNewStyle = NULL; 231 IFDE_CSSComputedStyle* pNewStyle = NULL;
232 if ((tagProvider.GetTagName() != FX_WSTRC(L"body")) || 232 if ((tagProvider.GetTagName() != FX_WSTRC(L"body")) ||
233 (tagProvider.GetTagName() != FX_WSTRC(L"html"))) { 233 (tagProvider.GetTagName() != FX_WSTRC(L"html"))) {
234 CXFA_TextParseContext* pTextContext = 234 CXFA_TextParseContext* pTextContext =
235 FXTARGET_NewWith(m_pAllocator) CXFA_TextParseContext; 235 FXTARGET_NewWith(m_pAllocator.get()) CXFA_TextParseContext;
236 FDE_CSSDISPLAY eDisplay = FDE_CSSDISPLAY_Inline; 236 FDE_CSSDISPLAY eDisplay = FDE_CSSDISPLAY_Inline;
237 if (!tagProvider.m_bContent) { 237 if (!tagProvider.m_bContent) {
238 pNewStyle = CreateStyle(pParentStyle); 238 pNewStyle = CreateStyle(pParentStyle);
239 CFDE_CSSAccelerator* pCSSAccel = m_pSelector->InitAccelerator(); 239 CFDE_CSSAccelerator* pCSSAccel = m_pSelector->InitAccelerator();
240 pCSSAccel->OnEnterTag(&tagProvider); 240 pCSSAccel->OnEnterTag(&tagProvider);
241 CFDE_CSSDeclarationArray DeclArray; 241 CFDE_CSSDeclarationArray DeclArray;
242 int32_t iMatchedDecls = 242 int32_t iMatchedDecls =
243 m_pSelector->MatchDeclarations(&tagProvider, DeclArray); 243 m_pSelector->MatchDeclarations(&tagProvider, DeclArray);
244 const CFDE_CSSDeclaration** ppMatchDecls = 244 const CFDE_CSSDeclaration** ppMatchDecls =
245 const_cast<const CFDE_CSSDeclaration**>(DeclArray.GetData()); 245 const_cast<const CFDE_CSSDeclaration**>(DeclArray.GetData());
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 m_pBreak(nullptr), 657 m_pBreak(nullptr),
658 m_pLoader(nullptr), 658 m_pLoader(nullptr),
659 m_iLines(0), 659 m_iLines(0),
660 m_fMaxWidth(0), 660 m_fMaxWidth(0),
661 m_pTabstopContext(nullptr), 661 m_pTabstopContext(nullptr),
662 m_bBlockContinue(TRUE) { 662 m_bBlockContinue(TRUE) {
663 ASSERT(m_pTextProvider); 663 ASSERT(m_pTextProvider);
664 } 664 }
665 CXFA_TextLayout::~CXFA_TextLayout() { 665 CXFA_TextLayout::~CXFA_TextLayout() {
666 m_textParser.Reset(); 666 m_textParser.Reset();
667 delete m_pLoader;
668 delete m_pTabstopContext;
669 Unload(); 667 Unload();
670 } 668 }
671 void CXFA_TextLayout::Unload() { 669 void CXFA_TextLayout::Unload() {
672 int32_t iCount = m_pieceLines.GetSize(); 670 int32_t iCount = m_pieceLines.GetSize();
673 for (int32_t i = 0; i < iCount; i++) { 671 for (int32_t i = 0; i < iCount; i++) {
674 CXFA_PieceLine* pLine = m_pieceLines.GetAt(i); 672 CXFA_PieceLine* pLine = m_pieceLines.GetAt(i);
675 FXTARGET_DeleteWith(CXFA_PieceLine, m_pAllocator, pLine); 673 FXTARGET_DeleteWith(CXFA_PieceLine, m_pAllocator.get(), pLine);
676 } 674 }
677 m_pieceLines.RemoveAll(); 675 m_pieceLines.RemoveAll();
678 if (m_pBreak) { 676 m_pBreak.reset();
679 m_pBreak->Release(); 677 m_pAllocator.reset();
680 m_pBreak = NULL;
681 }
682 delete m_pAllocator;
683 m_pAllocator = nullptr;
684 } 678 }
685 const CXFA_PieceLineArray* CXFA_TextLayout::GetPieceLines() { 679 const CXFA_PieceLineArray* CXFA_TextLayout::GetPieceLines() {
686 return &m_pieceLines; 680 return &m_pieceLines;
687 } 681 }
688 void CXFA_TextLayout::GetTextDataNode() { 682 void CXFA_TextLayout::GetTextDataNode() {
689 if (m_pTextProvider == NULL) { 683 if (m_pTextProvider == NULL) {
690 return; 684 return;
691 } 685 }
692 CXFA_Node* pNode = m_pTextProvider->GetTextNode(m_bRichText); 686 CXFA_Node* pNode = m_pTextProvider->GetTextNode(m_bRichText);
693 if (pNode && m_bRichText) { 687 if (pNode && m_bRichText) {
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
844 pStyle->GetBoundaryStyles()->SetMarginWidth(pNewRect); 838 pStyle->GetBoundaryStyles()->SetMarginWidth(pNewRect);
845 } 839 }
846 } 840 }
847 m_pBreak->SetLineBoundary(fStart, fLineWidth); 841 m_pBreak->SetLineBoundary(fStart, fLineWidth);
848 FX_FLOAT fIndent = pParaStyle->GetTextIndent().GetValue(); 842 FX_FLOAT fIndent = pParaStyle->GetTextIndent().GetValue();
849 if (fIndent > 0) { 843 if (fIndent > 0) {
850 fStart += fIndent; 844 fStart += fIndent;
851 } 845 }
852 m_pBreak->SetLineStartPos(fStart); 846 m_pBreak->SetLineStartPos(fStart);
853 m_pBreak->SetTabWidth(m_textParser.GetTabInterval(pStyle)); 847 m_pBreak->SetTabWidth(m_textParser.GetTabInterval(pStyle));
854 if (m_pTabstopContext == NULL) { 848 if (!m_pTabstopContext)
855 m_pTabstopContext = new CXFA_TextTabstopsContext; 849 m_pTabstopContext.reset(new CXFA_TextTabstopsContext);
856 } 850 m_textParser.GetTabstops(pStyle, m_pTabstopContext.get());
857 m_textParser.GetTabstops(pStyle, m_pTabstopContext);
858 for (int32_t i = 0; i < m_pTabstopContext->m_iTabCount; i++) { 851 for (int32_t i = 0; i < m_pTabstopContext->m_iTabCount; i++) {
859 XFA_TABSTOPS* pTab = m_pTabstopContext->m_tabstops.GetDataPtr(i); 852 XFA_TABSTOPS* pTab = m_pTabstopContext->m_tabstops.GetDataPtr(i);
860 m_pBreak->AddPositionedTab(pTab->fTabstops); 853 m_pBreak->AddPositionedTab(pTab->fTabstops);
861 } 854 }
862 } 855 }
863 FX_FLOAT fFontSize = m_textParser.GetFontSize(m_pTextProvider, pStyle); 856 FX_FLOAT fFontSize = m_textParser.GetFontSize(m_pTextProvider, pStyle);
864 m_pBreak->SetFontSize(fFontSize); 857 m_pBreak->SetFontSize(fFontSize);
865 m_pBreak->SetLineBreakTolerance(fFontSize * 0.2f); 858 m_pBreak->SetLineBreakTolerance(fFontSize * 0.2f);
866 m_pBreak->SetFont(m_textParser.GetFont(m_pTextProvider, pStyle)); 859 m_pBreak->SetFont(m_textParser.GetFont(m_pTextProvider, pStyle));
867 m_pBreak->SetHorizontalScale( 860 m_pBreak->SetHorizontalScale(
(...skipping 27 matching lines...) Expand all
895 FX_FLOAT fHeight = m_pLoader->m_fHeight; 888 FX_FLOAT fHeight = m_pLoader->m_fHeight;
896 if (fHeight < 0.1f) { 889 if (fHeight < 0.1f) {
897 fHeight = 0; 890 fHeight = 0;
898 for (int32_t i = 0; i < iCount; i++) { 891 for (int32_t i = 0; i < iCount; i++) {
899 fHeight += m_pLoader->m_lineHeights.ElementAt(i); 892 fHeight += m_pLoader->m_lineHeights.ElementAt(i);
900 } 893 }
901 } 894 }
902 return fHeight; 895 return fHeight;
903 } 896 }
904 FX_FLOAT CXFA_TextLayout::StartLayout(FX_FLOAT fWidth) { 897 FX_FLOAT CXFA_TextLayout::StartLayout(FX_FLOAT fWidth) {
905 if (m_pLoader == NULL) { 898 if (!m_pLoader)
906 m_pLoader = new CXFA_LoaderContext; 899 m_pLoader.reset(new CXFA_LoaderContext);
907 } 900
908 if (fWidth < 0 || (m_pLoader->m_fWidth > -1 && 901 if (fWidth < 0 || (m_pLoader->m_fWidth > -1 &&
909 FXSYS_fabs(fWidth - m_pLoader->m_fWidth) > 0)) { 902 FXSYS_fabs(fWidth - m_pLoader->m_fWidth) > 0)) {
910 m_pLoader->m_lineHeights.RemoveAll(); 903 m_pLoader->m_lineHeights.RemoveAll();
911 m_Blocks.RemoveAll(); 904 m_Blocks.RemoveAll();
912 Unload(); 905 Unload();
913 m_pLoader->m_fStartLineOffset = 0; 906 m_pLoader->m_fStartLineOffset = 0;
914 } 907 }
915 m_pLoader->m_fWidth = fWidth; 908 m_pLoader->m_fWidth = fWidth;
916 if (fWidth < 0) { 909 if (fWidth < 0) {
917 CFX_SizeF szMax; 910 CFX_SizeF szMax;
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1006 } 999 }
1007 int32_t CXFA_TextLayout::CountBlocks() const { 1000 int32_t CXFA_TextLayout::CountBlocks() const {
1008 int32_t iCount = m_Blocks.GetSize() / 2; 1001 int32_t iCount = m_Blocks.GetSize() / 2;
1009 return iCount > 0 ? iCount : 1; 1002 return iCount > 0 ? iCount : 1;
1010 } 1003 }
1011 1004
1012 FX_BOOL CXFA_TextLayout::CalcSize(const CFX_SizeF& minSize, 1005 FX_BOOL CXFA_TextLayout::CalcSize(const CFX_SizeF& minSize,
1013 const CFX_SizeF& maxSize, 1006 const CFX_SizeF& maxSize,
1014 CFX_SizeF& defaultSize) { 1007 CFX_SizeF& defaultSize) {
1015 defaultSize.x = maxSize.x; 1008 defaultSize.x = maxSize.x;
1016 if (defaultSize.x < 1) { 1009 if (defaultSize.x < 1)
1017 defaultSize.x = 0xFFFF; 1010 defaultSize.x = 0xFFFF;
1018 }
1019 if (m_pBreak)
1020 m_pBreak->Release();
1021 1011
1022 m_pBreak = CreateBreak(FALSE); 1012 m_pBreak.reset(CreateBreak(FALSE));
1023 FX_FLOAT fLinePos = 0; 1013 FX_FLOAT fLinePos = 0;
1024 m_iLines = 0; 1014 m_iLines = 0;
1025 m_fMaxWidth = 0; 1015 m_fMaxWidth = 0;
1026 Loader(defaultSize, fLinePos, FALSE); 1016 Loader(defaultSize, fLinePos, FALSE);
1027 if (fLinePos < 0.1f) { 1017 if (fLinePos < 0.1f)
1028 fLinePos = m_textParser.GetFontSize(m_pTextProvider, NULL); 1018 fLinePos = m_textParser.GetFontSize(m_pTextProvider, NULL);
1029 } 1019
1030 delete m_pTabstopContext; 1020 m_pTabstopContext.reset();
1031 m_pTabstopContext = nullptr;
1032 defaultSize = CFX_SizeF(m_fMaxWidth, fLinePos); 1021 defaultSize = CFX_SizeF(m_fMaxWidth, fLinePos);
1033 return TRUE; 1022 return TRUE;
1034 } 1023 }
1035 1024
1036 FX_BOOL CXFA_TextLayout::Layout(const CFX_SizeF& size, FX_FLOAT* fHeight) { 1025 FX_BOOL CXFA_TextLayout::Layout(const CFX_SizeF& size, FX_FLOAT* fHeight) {
1037 if (size.x < 1) { 1026 if (size.x < 1)
1038 return FALSE; 1027 return FALSE;
1039 } 1028
1040 Unload(); 1029 Unload();
1041 m_pBreak = CreateBreak(TRUE); 1030 m_pBreak.reset(CreateBreak(TRUE));
1042 if (m_pLoader) { 1031 if (m_pLoader) {
1043 m_pLoader->m_iTotalLines = -1; 1032 m_pLoader->m_iTotalLines = -1;
1044 m_pLoader->m_iChar = 0; 1033 m_pLoader->m_iChar = 0;
1045 } 1034 }
1046 m_iLines = 0; 1035 m_iLines = 0;
1047 FX_FLOAT fLinePos = 0; 1036 FX_FLOAT fLinePos = 0;
1048 Loader(size, fLinePos, TRUE); 1037 Loader(size, fLinePos, TRUE);
1049 UpdateAlign(size.y, fLinePos); 1038 UpdateAlign(size.y, fLinePos);
1050 delete m_pTabstopContext; 1039 m_pTabstopContext.reset();
1051 m_pTabstopContext = nullptr;
1052 if (fHeight) 1040 if (fHeight)
1053 *fHeight = fLinePos; 1041 *fHeight = fLinePos;
1054 return TRUE; 1042 return TRUE;
1055 } 1043 }
1056 1044
1057 FX_BOOL CXFA_TextLayout::Layout(int32_t iBlock) { 1045 FX_BOOL CXFA_TextLayout::Layout(int32_t iBlock) {
1058 if (m_pLoader == NULL || iBlock < 0 || iBlock >= CountBlocks()) { 1046 if (m_pLoader == NULL || iBlock < 0 || iBlock >= CountBlocks()) {
1059 return FALSE; 1047 return FALSE;
1060 } 1048 }
1061 if (m_pLoader->m_fWidth < 1) { 1049 if (m_pLoader->m_fWidth < 1) {
1062 return FALSE; 1050 return FALSE;
1063 } 1051 }
1064 m_pLoader->m_iTotalLines = -1; 1052 m_pLoader->m_iTotalLines = -1;
1065 m_iLines = 0; 1053 m_iLines = 0;
1066 FX_FLOAT fLinePos = 0; 1054 FX_FLOAT fLinePos = 0;
1067 CXFA_Node* pNode = NULL; 1055 CXFA_Node* pNode = NULL;
1068 CFX_SizeF szText(m_pLoader->m_fWidth, m_pLoader->m_fHeight); 1056 CFX_SizeF szText(m_pLoader->m_fWidth, m_pLoader->m_fHeight);
1069 int32_t iCount = m_Blocks.GetSize(); 1057 int32_t iCount = m_Blocks.GetSize();
1070 int32_t iBlocksHeightCount = m_pLoader->m_BlocksHeight.GetSize(); 1058 int32_t iBlocksHeightCount = m_pLoader->m_BlocksHeight.GetSize();
1071 iBlocksHeightCount /= 2; 1059 iBlocksHeightCount /= 2;
1072 if (iBlock < iBlocksHeightCount) { 1060 if (iBlock < iBlocksHeightCount) {
1073 return TRUE; 1061 return TRUE;
1074 } 1062 }
1075 if (iBlock == iBlocksHeightCount) { 1063 if (iBlock == iBlocksHeightCount) {
1076 Unload(); 1064 Unload();
1077 m_pBreak = CreateBreak(TRUE); 1065 m_pBreak.reset(CreateBreak(TRUE));
1078 fLinePos = m_pLoader->m_fStartLineOffset; 1066 fLinePos = m_pLoader->m_fStartLineOffset;
1079 for (int32_t i = 0; i < iBlocksHeightCount; i++) { 1067 for (int32_t i = 0; i < iBlocksHeightCount; i++) {
1080 fLinePos -= m_pLoader->m_BlocksHeight.ElementAt(i * 2 + 1); 1068 fLinePos -= m_pLoader->m_BlocksHeight.ElementAt(i * 2 + 1);
1081 } 1069 }
1082 m_pLoader->m_iChar = 0; 1070 m_pLoader->m_iChar = 0;
1083 if (iCount > 1) { 1071 if (iCount > 1) {
1084 m_pLoader->m_iTotalLines = m_Blocks.ElementAt(iBlock * 2 + 1); 1072 m_pLoader->m_iTotalLines = m_Blocks.ElementAt(iBlock * 2 + 1);
1085 } 1073 }
1086 Loader(szText, fLinePos, TRUE); 1074 Loader(szText, fLinePos, TRUE);
1087 if (iCount == 0 && m_pLoader->m_fStartLineOffset < 0.1f) { 1075 if (iCount == 0 && m_pLoader->m_fStartLineOffset < 0.1f) {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1138 } 1126 }
1139 } else { 1127 } else {
1140 pNode = m_pLoader->m_pNode; 1128 pNode = m_pLoader->m_pNode;
1141 if (pNode == NULL) { 1129 if (pNode == NULL) {
1142 return TRUE; 1130 return TRUE;
1143 } 1131 }
1144 LoadText(pNode, szText, fLinePos, TRUE); 1132 LoadText(pNode, szText, fLinePos, TRUE);
1145 } 1133 }
1146 } 1134 }
1147 if (iBlock == iCount) { 1135 if (iBlock == iCount) {
1148 delete m_pTabstopContext; 1136 m_pTabstopContext.reset();
1149 m_pTabstopContext = nullptr; 1137 m_pLoader.reset();
1150 delete m_pLoader;
1151 m_pLoader = nullptr;
1152 } 1138 }
1153 return TRUE; 1139 return TRUE;
1154 } 1140 }
1155 void CXFA_TextLayout::ItemBlocks(const CFX_RectF& rtText, int32_t iBlockIndex) { 1141 void CXFA_TextLayout::ItemBlocks(const CFX_RectF& rtText, int32_t iBlockIndex) {
1156 if (!m_pLoader) { 1142 if (!m_pLoader) {
1157 return; 1143 return;
1158 } 1144 }
1159 int32_t iCountHeight = m_pLoader->m_lineHeights.GetSize(); 1145 int32_t iCountHeight = m_pLoader->m_lineHeights.GetSize();
1160 if (iCountHeight == 0) { 1146 if (iCountHeight == 0) {
1161 return; 1147 return;
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1276 for (int32_t j = 0; j < iPieces; j++) { 1262 for (int32_t j = 0; j < iPieces; j++) {
1277 XFA_TextPiece* pPiece = pPieceLine->m_textPieces.GetAt(j); 1263 XFA_TextPiece* pPiece = pPieceLine->m_textPieces.GetAt(j);
1278 CFX_RectF& rect = pPiece->rtPiece; 1264 CFX_RectF& rect = pPiece->rtPiece;
1279 rect.top += fHeight; 1265 rect.top += fHeight;
1280 } 1266 }
1281 } 1267 }
1282 } 1268 }
1283 FX_BOOL CXFA_TextLayout::Loader(const CFX_SizeF& szText, 1269 FX_BOOL CXFA_TextLayout::Loader(const CFX_SizeF& szText,
1284 FX_FLOAT& fLinePos, 1270 FX_FLOAT& fLinePos,
1285 FX_BOOL bSavePieces) { 1271 FX_BOOL bSavePieces) {
1286 if (!m_pAllocator) 1272 if (!m_pAllocator) {
1287 m_pAllocator = IFX_MemoryAllocator::Create(FX_ALLOCTYPE_Static, 256, 0); 1273 m_pAllocator.reset(
1274 IFX_MemoryAllocator::Create(FX_ALLOCTYPE_Static, 256, 0));
1275 }
1276 GetTextDataNode();
1277 if (!m_pTextDataNode)
1278 return TRUE;
1288 1279
1289 GetTextDataNode();
1290 if (m_pTextDataNode == NULL) {
1291 return TRUE;
1292 }
1293 if (m_bRichText) { 1280 if (m_bRichText) {
1294 CFDE_XMLNode* pXMLContainer = GetXMLContainerNode(); 1281 CFDE_XMLNode* pXMLContainer = GetXMLContainerNode();
1295 if (pXMLContainer) { 1282 if (pXMLContainer) {
1296 if (!m_textParser.IsParsed()) { 1283 if (!m_textParser.IsParsed()) {
1297 m_textParser.DoParse(pXMLContainer, m_pTextProvider); 1284 m_textParser.DoParse(pXMLContainer, m_pTextProvider);
1298 } 1285 }
1299 IFDE_CSSComputedStyle* pRootStyle = 1286 IFDE_CSSComputedStyle* pRootStyle =
1300 m_textParser.CreateRootStyle(m_pTextProvider); 1287 m_textParser.CreateRootStyle(m_pTextProvider);
1301 LoadRichText(pXMLContainer, szText, fLinePos, pRootStyle, bSavePieces); 1288 LoadRichText(pXMLContainer, szText, fLinePos, pRootStyle, bSavePieces);
1302 pRootStyle->Release(); 1289 pRootStyle->Release();
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
1396 if (pRect) { 1383 if (pRect) {
1397 fLinePos += pRect->top.GetValue(); 1384 fLinePos += pRect->top.GetValue();
1398 fSpaceBelow = pRect->bottom.GetValue(); 1385 fSpaceBelow = pRect->bottom.GetValue();
1399 } 1386 }
1400 } 1387 }
1401 if (wsName == FX_WSTRC(L"a")) { 1388 if (wsName == FX_WSTRC(L"a")) {
1402 CFX_WideString wsLinkContent; 1389 CFX_WideString wsLinkContent;
1403 ASSERT(pElement); 1390 ASSERT(pElement);
1404 pElement->GetString(L"href", wsLinkContent); 1391 pElement->GetString(L"href", wsLinkContent);
1405 if (!wsLinkContent.IsEmpty()) { 1392 if (!wsLinkContent.IsEmpty()) {
1406 pLinkData = FXTARGET_NewWith(m_pAllocator) CXFA_LinkUserData( 1393 pLinkData = FXTARGET_NewWith(m_pAllocator.get()) CXFA_LinkUserData(
1407 m_pAllocator, 1394 m_pAllocator.get(),
1408 wsLinkContent.GetBuffer(wsLinkContent.GetLength())); 1395 wsLinkContent.GetBuffer(wsLinkContent.GetLength()));
1409 wsLinkContent.ReleaseBuffer(wsLinkContent.GetLength()); 1396 wsLinkContent.ReleaseBuffer(wsLinkContent.GetLength());
1410 } 1397 }
1411 } 1398 }
1412 int32_t iTabCount = 1399 int32_t iTabCount =
1413 m_textParser.CountTabs(bContentNode ? pParentStyle : pStyle); 1400 m_textParser.CountTabs(bContentNode ? pParentStyle : pStyle);
1414 FX_BOOL bSpaceRun = 1401 FX_BOOL bSpaceRun =
1415 m_textParser.IsSpaceRun(bContentNode ? pParentStyle : pStyle); 1402 m_textParser.IsSpaceRun(bContentNode ? pParentStyle : pStyle);
1416 CFX_WideString wsText; 1403 CFX_WideString wsText;
1417 if (bContentNode && iTabCount == 0) { 1404 if (bContentNode && iTabCount == 0) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1452 m_pLoader->m_dwFlags |= XFA_LOADERCNTXTFLG_FILTERSPACE; 1439 m_pLoader->m_dwFlags |= XFA_LOADERCNTXTFLG_FILTERSPACE;
1453 } else if (wsText.GetLength() != 0) { 1440 } else if (wsText.GetLength() != 0) {
1454 m_pLoader->m_dwFlags &= ~XFA_LOADERCNTXTFLG_FILTERSPACE; 1441 m_pLoader->m_dwFlags &= ~XFA_LOADERCNTXTFLG_FILTERSPACE;
1455 } 1442 }
1456 } 1443 }
1457 if (wsText.GetLength() > 0) { 1444 if (wsText.GetLength() > 0) {
1458 if (m_pLoader == NULL || m_pLoader->m_iChar == 0) { 1445 if (m_pLoader == NULL || m_pLoader->m_iChar == 0) {
1459 if (pLinkData) { 1446 if (pLinkData) {
1460 pLinkData->AddRef(); 1447 pLinkData->AddRef();
1461 } 1448 }
1462 CXFA_TextUserData* pUserData = FXTARGET_NewWith(m_pAllocator) 1449 CXFA_TextUserData* pUserData = FXTARGET_NewWith(m_pAllocator.get())
1463 CXFA_TextUserData(m_pAllocator, 1450 CXFA_TextUserData(m_pAllocator.get(),
1464 bContentNode ? pParentStyle : pStyle, 1451 bContentNode ? pParentStyle : pStyle,
1465 pLinkData); 1452 pLinkData);
1466 m_pBreak->SetUserData(pUserData); 1453 m_pBreak->SetUserData(pUserData);
1467 } 1454 }
1468 if (AppendChar(wsText, fLinePos, 0, bSavePieces)) { 1455 if (AppendChar(wsText, fLinePos, 0, bSavePieces)) {
1469 if (m_pLoader) { 1456 if (m_pLoader) {
1470 m_pLoader->m_dwFlags &= ~XFA_LOADERCNTXTFLG_FILTERSPACE; 1457 m_pLoader->m_dwFlags &= ~XFA_LOADERCNTXTFLG_FILTERSPACE;
1471 } 1458 }
1472 if (IsEnd(bSavePieces)) { 1459 if (IsEnd(bSavePieces)) {
1473 if (m_pLoader && m_pLoader->m_iTotalLines > -1) { 1460 if (m_pLoader && m_pLoader->m_iTotalLines > -1) {
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
1676 void CXFA_TextLayout::AppendTextLine(uint32_t dwStatus, 1663 void CXFA_TextLayout::AppendTextLine(uint32_t dwStatus,
1677 FX_FLOAT& fLinePos, 1664 FX_FLOAT& fLinePos,
1678 FX_BOOL bSavePieces, 1665 FX_BOOL bSavePieces,
1679 FX_BOOL bEndBreak) { 1666 FX_BOOL bEndBreak) {
1680 int32_t iPieces = m_pBreak->CountBreakPieces(); 1667 int32_t iPieces = m_pBreak->CountBreakPieces();
1681 if (iPieces < 1) { 1668 if (iPieces < 1) {
1682 return; 1669 return;
1683 } 1670 }
1684 IFDE_CSSComputedStyle* pStyle = NULL; 1671 IFDE_CSSComputedStyle* pStyle = NULL;
1685 if (bSavePieces) { 1672 if (bSavePieces) {
1686 CXFA_PieceLine* pPieceLine = FXTARGET_NewWith(m_pAllocator) CXFA_PieceLine; 1673 CXFA_PieceLine* pPieceLine =
1674 FXTARGET_NewWith(m_pAllocator.get()) CXFA_PieceLine;
1687 m_pieceLines.Add(pPieceLine); 1675 m_pieceLines.Add(pPieceLine);
1688 if (m_pTabstopContext) { 1676 if (m_pTabstopContext) {
1689 m_pTabstopContext->Reset(); 1677 m_pTabstopContext->Reset();
1690 } 1678 }
1691 FX_FLOAT fLineStep = 0, fBaseLine = 0; 1679 FX_FLOAT fLineStep = 0, fBaseLine = 0;
1692 int32_t i = 0; 1680 int32_t i = 0;
1693 for (i = 0; i < iPieces; i++) { 1681 for (i = 0; i < iPieces; i++) {
1694 const CFX_RTFPiece* pPiece = m_pBreak->GetBreakPiece(i); 1682 const CFX_RTFPiece* pPiece = m_pBreak->GetBreakPiece(i);
1695 CXFA_TextUserData* pUserData = (CXFA_TextUserData*)pPiece->m_pUserData; 1683 CXFA_TextUserData* pUserData = (CXFA_TextUserData*)pPiece->m_pUserData;
1696 if (pUserData) 1684 if (pUserData)
1697 pStyle = pUserData->m_pStyle; 1685 pStyle = pUserData->m_pStyle;
1698 FX_FLOAT fVerScale = pPiece->m_iVerticalScale / 100.0f; 1686 FX_FLOAT fVerScale = pPiece->m_iVerticalScale / 100.0f;
1699 XFA_TextPiece* pTP = FXTARGET_NewWith(m_pAllocator) XFA_TextPiece(); 1687 XFA_TextPiece* pTP = FXTARGET_NewWith(m_pAllocator.get()) XFA_TextPiece();
1700 pTP->pszText = 1688 pTP->pszText =
1701 (FX_WCHAR*)m_pAllocator->Alloc(pPiece->m_iChars * sizeof(FX_WCHAR)); 1689 (FX_WCHAR*)m_pAllocator->Alloc(pPiece->m_iChars * sizeof(FX_WCHAR));
1702 pTP->pWidths = 1690 pTP->pWidths =
1703 (int32_t*)m_pAllocator->Alloc(pPiece->m_iChars * sizeof(int32_t)); 1691 (int32_t*)m_pAllocator->Alloc(pPiece->m_iChars * sizeof(int32_t));
1704 pTP->iChars = pPiece->m_iChars; 1692 pTP->iChars = pPiece->m_iChars;
1705 pPiece->GetString(pTP->pszText); 1693 pPiece->GetString(pTP->pszText);
1706 pPiece->GetWidths(pTP->pWidths); 1694 pPiece->GetWidths(pTP->pWidths);
1707 pTP->iBidiLevel = pPiece->m_iBidiLevel; 1695 pTP->iBidiLevel = pPiece->m_iBidiLevel;
1708 pTP->iHorScale = pPiece->m_iHorizontalScale; 1696 pTP->iHorScale = pPiece->m_iHorizontalScale;
1709 pTP->iVerScale = pPiece->m_iVerticalScale; 1697 pTP->iVerScale = pPiece->m_iVerticalScale;
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
1970 tr.iLength = iLength; 1958 tr.iLength = iLength;
1971 tr.fFontSize = pPiece->fFontSize; 1959 tr.fFontSize = pPiece->fFontSize;
1972 tr.iBidiLevel = pPiece->iBidiLevel; 1960 tr.iBidiLevel = pPiece->iBidiLevel;
1973 tr.iCharRotation = 0; 1961 tr.iCharRotation = 0;
1974 tr.wLineBreakChar = L'\n'; 1962 tr.wLineBreakChar = L'\n';
1975 tr.iVerticalScale = pPiece->iVerScale; 1963 tr.iVerticalScale = pPiece->iVerScale;
1976 tr.dwLayoutStyles = FX_RTFLAYOUTSTYLE_ExpandTab; 1964 tr.dwLayoutStyles = FX_RTFLAYOUTSTYLE_ExpandTab;
1977 tr.iHorizontalScale = pPiece->iHorScale; 1965 tr.iHorizontalScale = pPiece->iHorScale;
1978 return TRUE; 1966 return TRUE;
1979 } 1967 }
OLDNEW
« no previous file with comments | « xfa/fxfa/app/xfa_textlayout.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698