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

Side by Side Diff: xfa/fxfa/parser/cxfa_layoutprocessor.cpp

Issue 2467203003: Remove FX_BOOL from xfa. (Closed)
Patch Set: Created 4 years, 1 month 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/parser/cxfa_layoutprocessor.h ('k') | xfa/fxfa/parser/cxfa_line.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 PDFium Authors. All rights reserved. 1 // Copyright 2016 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/parser/cxfa_layoutprocessor.h" 7 #include "xfa/fxfa/parser/cxfa_layoutprocessor.h"
8 8
9 #include "xfa/fxfa/parser/cxfa_contentlayoutitem.h" 9 #include "xfa/fxfa/parser/cxfa_contentlayoutitem.h"
10 #include "xfa/fxfa/parser/cxfa_document.h" 10 #include "xfa/fxfa/parser/cxfa_document.h"
(...skipping 15 matching lines...) Expand all
26 26
27 CXFA_LayoutProcessor* CXFA_Document::GetDocLayout() { 27 CXFA_LayoutProcessor* CXFA_Document::GetDocLayout() {
28 return GetLayoutProcessor(); 28 return GetLayoutProcessor();
29 } 29 }
30 30
31 CXFA_LayoutProcessor::CXFA_LayoutProcessor(CXFA_Document* pDocument) 31 CXFA_LayoutProcessor::CXFA_LayoutProcessor(CXFA_Document* pDocument)
32 : m_pDocument(pDocument), 32 : m_pDocument(pDocument),
33 m_pRootItemLayoutProcessor(nullptr), 33 m_pRootItemLayoutProcessor(nullptr),
34 m_pLayoutPageMgr(nullptr), 34 m_pLayoutPageMgr(nullptr),
35 m_nProgressCounter(0), 35 m_nProgressCounter(0),
36 m_bNeeLayout(TRUE) {} 36 m_bNeeLayout(true) {}
37 37
38 CXFA_LayoutProcessor::~CXFA_LayoutProcessor() { 38 CXFA_LayoutProcessor::~CXFA_LayoutProcessor() {
39 ClearLayoutData(); 39 ClearLayoutData();
40 } 40 }
41 41
42 CXFA_Document* CXFA_LayoutProcessor::GetDocument() const { 42 CXFA_Document* CXFA_LayoutProcessor::GetDocument() const {
43 return m_pDocument; 43 return m_pDocument;
44 } 44 }
45 45
46 int32_t CXFA_LayoutProcessor::StartLayout(FX_BOOL bForceRestart) { 46 int32_t CXFA_LayoutProcessor::StartLayout(bool bForceRestart) {
47 if (!bForceRestart && !IsNeedLayout()) 47 if (!bForceRestart && !IsNeedLayout())
48 return 100; 48 return 100;
49 49
50 delete m_pRootItemLayoutProcessor; 50 delete m_pRootItemLayoutProcessor;
51 m_pRootItemLayoutProcessor = nullptr; 51 m_pRootItemLayoutProcessor = nullptr;
52 m_nProgressCounter = 0; 52 m_nProgressCounter = 0;
53 CXFA_Node* pFormPacketNode = 53 CXFA_Node* pFormPacketNode =
54 ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Form)); 54 ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Form));
55 if (!pFormPacketNode) 55 if (!pFormPacketNode)
56 return -1; 56 return -1;
(...skipping 18 matching lines...) Expand all
75 if (m_nProgressCounter < 1) 75 if (m_nProgressCounter < 1)
76 return -1; 76 return -1;
77 77
78 XFA_ItemLayoutProcessorResult eStatus; 78 XFA_ItemLayoutProcessorResult eStatus;
79 CXFA_Node* pFormNode = m_pRootItemLayoutProcessor->GetFormNode(); 79 CXFA_Node* pFormNode = m_pRootItemLayoutProcessor->GetFormNode();
80 FX_FLOAT fPosX = pFormNode->GetMeasure(XFA_ATTRIBUTE_X).ToUnit(XFA_UNIT_Pt); 80 FX_FLOAT fPosX = pFormNode->GetMeasure(XFA_ATTRIBUTE_X).ToUnit(XFA_UNIT_Pt);
81 FX_FLOAT fPosY = pFormNode->GetMeasure(XFA_ATTRIBUTE_Y).ToUnit(XFA_UNIT_Pt); 81 FX_FLOAT fPosY = pFormNode->GetMeasure(XFA_ATTRIBUTE_Y).ToUnit(XFA_UNIT_Pt);
82 do { 82 do {
83 FX_FLOAT fAvailHeight = m_pLayoutPageMgr->GetAvailHeight(); 83 FX_FLOAT fAvailHeight = m_pLayoutPageMgr->GetAvailHeight();
84 eStatus = 84 eStatus =
85 m_pRootItemLayoutProcessor->DoLayout(TRUE, fAvailHeight, fAvailHeight); 85 m_pRootItemLayoutProcessor->DoLayout(true, fAvailHeight, fAvailHeight);
86 if (eStatus != XFA_ItemLayoutProcessorResult_Done) 86 if (eStatus != XFA_ItemLayoutProcessorResult_Done)
87 m_nProgressCounter++; 87 m_nProgressCounter++;
88 88
89 CXFA_ContentLayoutItem* pLayoutItem = 89 CXFA_ContentLayoutItem* pLayoutItem =
90 m_pRootItemLayoutProcessor->ExtractLayoutItem(); 90 m_pRootItemLayoutProcessor->ExtractLayoutItem();
91 if (pLayoutItem) 91 if (pLayoutItem)
92 pLayoutItem->m_sPos = CFX_PointF(fPosX, fPosY); 92 pLayoutItem->m_sPos = CFX_PointF(fPosX, fPosY);
93 93
94 m_pLayoutPageMgr->SubmitContentItem(pLayoutItem, eStatus); 94 m_pLayoutPageMgr->SubmitContentItem(pLayoutItem, eStatus);
95 } while (eStatus != XFA_ItemLayoutProcessorResult_Done && 95 } while (eStatus != XFA_ItemLayoutProcessorResult_Done &&
96 (!pPause || !pPause->NeedToPauseNow())); 96 (!pPause || !pPause->NeedToPauseNow()));
97 97
98 if (eStatus == XFA_ItemLayoutProcessorResult_Done) { 98 if (eStatus == XFA_ItemLayoutProcessorResult_Done) {
99 m_pLayoutPageMgr->FinishPaginatedPageSets(); 99 m_pLayoutPageMgr->FinishPaginatedPageSets();
100 m_pLayoutPageMgr->SyncLayoutData(); 100 m_pLayoutPageMgr->SyncLayoutData();
101 m_bNeeLayout = FALSE; 101 m_bNeeLayout = false;
102 m_rgChangedContainers.RemoveAll(); 102 m_rgChangedContainers.RemoveAll();
103 } 103 }
104 return 100 * (eStatus == XFA_ItemLayoutProcessorResult_Done 104 return 100 * (eStatus == XFA_ItemLayoutProcessorResult_Done
105 ? m_nProgressCounter 105 ? m_nProgressCounter
106 : m_nProgressCounter - 1) / 106 : m_nProgressCounter - 1) /
107 m_nProgressCounter; 107 m_nProgressCounter;
108 } 108 }
109 109
110 FX_BOOL CXFA_LayoutProcessor::IncrementLayout() { 110 bool CXFA_LayoutProcessor::IncrementLayout() {
111 if (m_bNeeLayout) { 111 if (m_bNeeLayout) {
112 StartLayout(TRUE); 112 StartLayout(true);
113 return DoLayout(nullptr) == 100; 113 return DoLayout(nullptr) == 100;
114 } 114 }
115 115
116 for (int32_t i = 0, c = m_rgChangedContainers.GetSize(); i < c; i++) { 116 for (int32_t i = 0, c = m_rgChangedContainers.GetSize(); i < c; i++) {
117 CXFA_Node* pNode = m_rgChangedContainers[i]; 117 CXFA_Node* pNode = m_rgChangedContainers[i];
118 CXFA_Node* pParentNode = 118 CXFA_Node* pParentNode =
119 pNode->GetNodeItem(XFA_NODEITEM_Parent, XFA_ObjectType::ContainerNode); 119 pNode->GetNodeItem(XFA_NODEITEM_Parent, XFA_ObjectType::ContainerNode);
120 if (!pParentNode) 120 if (!pParentNode)
121 return FALSE; 121 return false;
122 if (!CXFA_ItemLayoutProcessor::IncrementRelayoutNode(this, pNode, 122 if (!CXFA_ItemLayoutProcessor::IncrementRelayoutNode(this, pNode,
123 pParentNode)) { 123 pParentNode)) {
124 return FALSE; 124 return false;
125 } 125 }
126 } 126 }
127 m_rgChangedContainers.RemoveAll(); 127 m_rgChangedContainers.RemoveAll();
128 return TRUE; 128 return true;
129 } 129 }
130 130
131 int32_t CXFA_LayoutProcessor::CountPages() const { 131 int32_t CXFA_LayoutProcessor::CountPages() const {
132 return m_pLayoutPageMgr ? m_pLayoutPageMgr->GetPageCount() : 0; 132 return m_pLayoutPageMgr ? m_pLayoutPageMgr->GetPageCount() : 0;
133 } 133 }
134 134
135 CXFA_ContainerLayoutItem* CXFA_LayoutProcessor::GetPage(int32_t index) const { 135 CXFA_ContainerLayoutItem* CXFA_LayoutProcessor::GetPage(int32_t index) const {
136 return m_pLayoutPageMgr ? m_pLayoutPageMgr->GetPage(index) : nullptr; 136 return m_pLayoutPageMgr ? m_pLayoutPageMgr->GetPage(index) : nullptr;
137 } 137 }
138 138
(...skipping 12 matching lines...) Expand all
151 } 151 }
152 152
153 void CXFA_LayoutProcessor::ClearLayoutData() { 153 void CXFA_LayoutProcessor::ClearLayoutData() {
154 delete m_pLayoutPageMgr; 154 delete m_pLayoutPageMgr;
155 m_pLayoutPageMgr = nullptr; 155 m_pLayoutPageMgr = nullptr;
156 delete m_pRootItemLayoutProcessor; 156 delete m_pRootItemLayoutProcessor;
157 m_pRootItemLayoutProcessor = nullptr; 157 m_pRootItemLayoutProcessor = nullptr;
158 m_nProgressCounter = 0; 158 m_nProgressCounter = 0;
159 } 159 }
160 160
161 FX_BOOL CXFA_LayoutProcessor::IsNeedLayout() { 161 bool CXFA_LayoutProcessor::IsNeedLayout() {
162 return m_bNeeLayout || m_rgChangedContainers.GetSize() > 0; 162 return m_bNeeLayout || m_rgChangedContainers.GetSize() > 0;
163 } 163 }
OLDNEW
« no previous file with comments | « xfa/fxfa/parser/cxfa_layoutprocessor.h ('k') | xfa/fxfa/parser/cxfa_line.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698