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/include/xfa_ffpageview.h" | 7 #include "xfa/fxfa/include/xfa_ffpageview.h" |
8 | 8 |
9 #include "xfa/fde/fde_render.h" | 9 #include "xfa/fde/fde_render.h" |
10 #include "xfa/fxfa/app/xfa_ffcheckbutton.h" | 10 #include "xfa/fxfa/app/xfa_ffcheckbutton.h" |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 m_sIterator.Reset(); | 143 m_sIterator.Reset(); |
144 } | 144 } |
145 CXFA_FFWidget* CXFA_FFPageWidgetIterator::MoveToFirst() { | 145 CXFA_FFWidget* CXFA_FFPageWidgetIterator::MoveToFirst() { |
146 m_sIterator.Reset(); | 146 m_sIterator.Reset(); |
147 for (CXFA_LayoutItem* pLayoutItem = m_sIterator.GetCurrent(); pLayoutItem; | 147 for (CXFA_LayoutItem* pLayoutItem = m_sIterator.GetCurrent(); pLayoutItem; |
148 pLayoutItem = m_sIterator.MoveToNext()) { | 148 pLayoutItem = m_sIterator.MoveToNext()) { |
149 if (CXFA_FFWidget* hWidget = GetWidget(pLayoutItem)) { | 149 if (CXFA_FFWidget* hWidget = GetWidget(pLayoutItem)) { |
150 return hWidget; | 150 return hWidget; |
151 } | 151 } |
152 } | 152 } |
153 return NULL; | 153 return nullptr; |
154 } | 154 } |
155 CXFA_FFWidget* CXFA_FFPageWidgetIterator::MoveToLast() { | 155 CXFA_FFWidget* CXFA_FFPageWidgetIterator::MoveToLast() { |
156 m_sIterator.SetCurrent(NULL); | 156 m_sIterator.SetCurrent(nullptr); |
157 return MoveToPrevious(); | 157 return MoveToPrevious(); |
158 } | 158 } |
159 CXFA_FFWidget* CXFA_FFPageWidgetIterator::MoveToNext() { | 159 CXFA_FFWidget* CXFA_FFPageWidgetIterator::MoveToNext() { |
160 for (CXFA_LayoutItem* pLayoutItem = m_sIterator.MoveToNext(); pLayoutItem; | 160 for (CXFA_LayoutItem* pLayoutItem = m_sIterator.MoveToNext(); pLayoutItem; |
161 pLayoutItem = m_sIterator.MoveToNext()) { | 161 pLayoutItem = m_sIterator.MoveToNext()) { |
162 if (CXFA_FFWidget* hWidget = GetWidget(pLayoutItem)) { | 162 if (CXFA_FFWidget* hWidget = GetWidget(pLayoutItem)) { |
163 return hWidget; | 163 return hWidget; |
164 } | 164 } |
165 } | 165 } |
166 return NULL; | 166 return nullptr; |
167 } | 167 } |
168 CXFA_FFWidget* CXFA_FFPageWidgetIterator::MoveToPrevious() { | 168 CXFA_FFWidget* CXFA_FFPageWidgetIterator::MoveToPrevious() { |
169 for (CXFA_LayoutItem* pLayoutItem = m_sIterator.MoveToPrev(); pLayoutItem; | 169 for (CXFA_LayoutItem* pLayoutItem = m_sIterator.MoveToPrev(); pLayoutItem; |
170 pLayoutItem = m_sIterator.MoveToPrev()) { | 170 pLayoutItem = m_sIterator.MoveToPrev()) { |
171 if (CXFA_FFWidget* hWidget = GetWidget(pLayoutItem)) { | 171 if (CXFA_FFWidget* hWidget = GetWidget(pLayoutItem)) { |
172 return hWidget; | 172 return hWidget; |
173 } | 173 } |
174 } | 174 } |
175 return NULL; | 175 return nullptr; |
176 } | 176 } |
177 CXFA_FFWidget* CXFA_FFPageWidgetIterator::GetCurrentWidget() { | 177 CXFA_FFWidget* CXFA_FFPageWidgetIterator::GetCurrentWidget() { |
178 CXFA_LayoutItem* pLayoutItem = m_sIterator.GetCurrent(); | 178 CXFA_LayoutItem* pLayoutItem = m_sIterator.GetCurrent(); |
179 return pLayoutItem ? XFA_GetWidgetFromLayoutItem(pLayoutItem) : NULL; | 179 return pLayoutItem ? XFA_GetWidgetFromLayoutItem(pLayoutItem) : nullptr; |
180 } | 180 } |
181 FX_BOOL CXFA_FFPageWidgetIterator::SetCurrentWidget(CXFA_FFWidget* hWidget) { | 181 FX_BOOL CXFA_FFPageWidgetIterator::SetCurrentWidget(CXFA_FFWidget* hWidget) { |
182 return hWidget && m_sIterator.SetCurrent(hWidget); | 182 return hWidget && m_sIterator.SetCurrent(hWidget); |
183 } | 183 } |
184 CXFA_FFWidget* CXFA_FFPageWidgetIterator::GetWidget( | 184 CXFA_FFWidget* CXFA_FFPageWidgetIterator::GetWidget( |
185 CXFA_LayoutItem* pLayoutItem) { | 185 CXFA_LayoutItem* pLayoutItem) { |
186 if (CXFA_FFWidget* pWidget = XFA_GetWidgetFromLayoutItem(pLayoutItem)) { | 186 if (CXFA_FFWidget* pWidget = XFA_GetWidgetFromLayoutItem(pLayoutItem)) { |
187 if (!PageWidgetFilter(pWidget, m_dwFilter, FALSE, m_bIgnorerelevant)) { | 187 if (!PageWidgetFilter(pWidget, m_dwFilter, FALSE, m_bIgnorerelevant)) { |
188 return NULL; | 188 return nullptr; |
189 } | 189 } |
190 if (!pWidget->IsLoaded() && | 190 if (!pWidget->IsLoaded() && |
191 (pWidget->GetStatus() & XFA_WidgetStatus_Visible) != 0) { | 191 (pWidget->GetStatus() & XFA_WidgetStatus_Visible) != 0) { |
192 pWidget->LoadWidget(); | 192 pWidget->LoadWidget(); |
193 } | 193 } |
194 return pWidget; | 194 return pWidget; |
195 } | 195 } |
196 return NULL; | 196 return nullptr; |
197 } | 197 } |
198 | 198 |
199 CXFA_FFTabOrderPageWidgetIterator::CXFA_FFTabOrderPageWidgetIterator( | 199 CXFA_FFTabOrderPageWidgetIterator::CXFA_FFTabOrderPageWidgetIterator( |
200 CXFA_FFPageView* pPageView, | 200 CXFA_FFPageView* pPageView, |
201 uint32_t dwFilter) | 201 uint32_t dwFilter) |
202 : m_pPageView(pPageView), m_dwFilter(dwFilter), m_iCurWidget(-1) { | 202 : m_pPageView(pPageView), m_dwFilter(dwFilter), m_iCurWidget(-1) { |
203 m_bIgnorerelevant = | 203 m_bIgnorerelevant = |
204 m_pPageView->GetDocView()->GetDoc()->GetXFADoc()->GetCurVersionMode() < | 204 m_pPageView->GetDocView()->GetDoc()->GetXFADoc()->GetCurVersionMode() < |
205 XFA_VERSION_205; | 205 XFA_VERSION_205; |
206 Reset(); | 206 Reset(); |
207 } | 207 } |
208 | 208 |
209 CXFA_FFTabOrderPageWidgetIterator::~CXFA_FFTabOrderPageWidgetIterator() {} | 209 CXFA_FFTabOrderPageWidgetIterator::~CXFA_FFTabOrderPageWidgetIterator() {} |
210 | 210 |
211 void CXFA_FFTabOrderPageWidgetIterator::Reset() { | 211 void CXFA_FFTabOrderPageWidgetIterator::Reset() { |
212 CreateTabOrderWidgetArray(); | 212 CreateTabOrderWidgetArray(); |
213 m_iCurWidget = -1; | 213 m_iCurWidget = -1; |
214 } | 214 } |
215 CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::MoveToFirst() { | 215 CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::MoveToFirst() { |
216 if (m_TabOrderWidgetArray.GetSize() > 0) { | 216 if (m_TabOrderWidgetArray.GetSize() > 0) { |
217 for (int32_t i = 0; i < m_TabOrderWidgetArray.GetSize(); i++) { | 217 for (int32_t i = 0; i < m_TabOrderWidgetArray.GetSize(); i++) { |
218 if (PageWidgetFilter(m_TabOrderWidgetArray[i], m_dwFilter, TRUE, | 218 if (PageWidgetFilter(m_TabOrderWidgetArray[i], m_dwFilter, TRUE, |
219 m_bIgnorerelevant)) { | 219 m_bIgnorerelevant)) { |
220 m_iCurWidget = i; | 220 m_iCurWidget = i; |
221 return m_TabOrderWidgetArray[m_iCurWidget]; | 221 return m_TabOrderWidgetArray[m_iCurWidget]; |
222 } | 222 } |
223 } | 223 } |
224 } | 224 } |
225 return NULL; | 225 return nullptr; |
226 } | 226 } |
227 CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::MoveToLast() { | 227 CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::MoveToLast() { |
228 if (m_TabOrderWidgetArray.GetSize() > 0) { | 228 if (m_TabOrderWidgetArray.GetSize() > 0) { |
229 for (int32_t i = m_TabOrderWidgetArray.GetSize() - 1; i >= 0; i--) { | 229 for (int32_t i = m_TabOrderWidgetArray.GetSize() - 1; i >= 0; i--) { |
230 if (PageWidgetFilter(m_TabOrderWidgetArray[i], m_dwFilter, TRUE, | 230 if (PageWidgetFilter(m_TabOrderWidgetArray[i], m_dwFilter, TRUE, |
231 m_bIgnorerelevant)) { | 231 m_bIgnorerelevant)) { |
232 m_iCurWidget = i; | 232 m_iCurWidget = i; |
233 return m_TabOrderWidgetArray[m_iCurWidget]; | 233 return m_TabOrderWidgetArray[m_iCurWidget]; |
234 } | 234 } |
235 } | 235 } |
236 } | 236 } |
237 return NULL; | 237 return nullptr; |
238 } | 238 } |
239 CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::MoveToNext() { | 239 CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::MoveToNext() { |
240 for (int32_t i = m_iCurWidget + 1; i < m_TabOrderWidgetArray.GetSize(); i++) { | 240 for (int32_t i = m_iCurWidget + 1; i < m_TabOrderWidgetArray.GetSize(); i++) { |
241 if (PageWidgetFilter(m_TabOrderWidgetArray[i], m_dwFilter, TRUE, | 241 if (PageWidgetFilter(m_TabOrderWidgetArray[i], m_dwFilter, TRUE, |
242 m_bIgnorerelevant)) { | 242 m_bIgnorerelevant)) { |
243 m_iCurWidget = i; | 243 m_iCurWidget = i; |
244 return m_TabOrderWidgetArray[m_iCurWidget]; | 244 return m_TabOrderWidgetArray[m_iCurWidget]; |
245 } | 245 } |
246 } | 246 } |
247 m_iCurWidget = -1; | 247 m_iCurWidget = -1; |
248 return NULL; | 248 return nullptr; |
249 } | 249 } |
250 CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::MoveToPrevious() { | 250 CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::MoveToPrevious() { |
251 for (int32_t i = m_iCurWidget - 1; i >= 0; i--) { | 251 for (int32_t i = m_iCurWidget - 1; i >= 0; i--) { |
252 if (PageWidgetFilter(m_TabOrderWidgetArray[i], m_dwFilter, TRUE, | 252 if (PageWidgetFilter(m_TabOrderWidgetArray[i], m_dwFilter, TRUE, |
253 m_bIgnorerelevant)) { | 253 m_bIgnorerelevant)) { |
254 m_iCurWidget = i; | 254 m_iCurWidget = i; |
255 return m_TabOrderWidgetArray[m_iCurWidget]; | 255 return m_TabOrderWidgetArray[m_iCurWidget]; |
256 } | 256 } |
257 } | 257 } |
258 m_iCurWidget = -1; | 258 m_iCurWidget = -1; |
259 return NULL; | 259 return nullptr; |
260 } | 260 } |
261 CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::GetCurrentWidget() { | 261 CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::GetCurrentWidget() { |
262 if (m_iCurWidget >= 0) { | 262 if (m_iCurWidget >= 0) { |
263 return m_TabOrderWidgetArray[m_iCurWidget]; | 263 return m_TabOrderWidgetArray[m_iCurWidget]; |
264 } | 264 } |
265 return NULL; | 265 return nullptr; |
266 } | 266 } |
267 FX_BOOL CXFA_FFTabOrderPageWidgetIterator::SetCurrentWidget( | 267 FX_BOOL CXFA_FFTabOrderPageWidgetIterator::SetCurrentWidget( |
268 CXFA_FFWidget* hWidget) { | 268 CXFA_FFWidget* hWidget) { |
269 int32_t iWidgetIndex = m_TabOrderWidgetArray.Find(hWidget); | 269 int32_t iWidgetIndex = m_TabOrderWidgetArray.Find(hWidget); |
270 if (iWidgetIndex >= 0) { | 270 if (iWidgetIndex >= 0) { |
271 m_iCurWidget = iWidgetIndex; | 271 m_iCurWidget = iWidgetIndex; |
272 return TRUE; | 272 return TRUE; |
273 } | 273 } |
274 return FALSE; | 274 return FALSE; |
275 } | 275 } |
276 CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::GetTraverseWidget( | 276 CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::GetTraverseWidget( |
277 CXFA_FFWidget* pWidget) { | 277 CXFA_FFWidget* pWidget) { |
278 CXFA_WidgetAcc* pAcc = pWidget->GetDataAcc(); | 278 CXFA_WidgetAcc* pAcc = pWidget->GetDataAcc(); |
279 CXFA_Node* pTraversal = pAcc->GetNode()->GetChild(0, XFA_Element::Traversal); | 279 CXFA_Node* pTraversal = pAcc->GetNode()->GetChild(0, XFA_Element::Traversal); |
280 if (pTraversal) { | 280 if (pTraversal) { |
281 CXFA_Node* pTraverse = pTraversal->GetChild(0, XFA_Element::Traverse); | 281 CXFA_Node* pTraverse = pTraversal->GetChild(0, XFA_Element::Traverse); |
282 if (pTraverse) { | 282 if (pTraverse) { |
283 CFX_WideString wsTraverseWidgetName; | 283 CFX_WideString wsTraverseWidgetName; |
284 if (pTraverse->GetAttribute(XFA_ATTRIBUTE_Ref, wsTraverseWidgetName)) { | 284 if (pTraverse->GetAttribute(XFA_ATTRIBUTE_Ref, wsTraverseWidgetName)) { |
285 return FindWidgetByName(wsTraverseWidgetName, pWidget); | 285 return FindWidgetByName(wsTraverseWidgetName, pWidget); |
286 } | 286 } |
287 } | 287 } |
288 } | 288 } |
289 return NULL; | 289 return nullptr; |
290 } | 290 } |
291 CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::FindWidgetByName( | 291 CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::FindWidgetByName( |
292 const CFX_WideString& wsWidgetName, | 292 const CFX_WideString& wsWidgetName, |
293 CXFA_FFWidget* pRefWidget) { | 293 CXFA_FFWidget* pRefWidget) { |
294 return pRefWidget->GetDocView()->GetWidgetByName(wsWidgetName, pRefWidget); | 294 return pRefWidget->GetDocView()->GetWidgetByName(wsWidgetName, pRefWidget); |
295 } | 295 } |
296 void CXFA_FFTabOrderPageWidgetIterator::CreateTabOrderWidgetArray() { | 296 void CXFA_FFTabOrderPageWidgetIterator::CreateTabOrderWidgetArray() { |
297 m_TabOrderWidgetArray.RemoveAll(); | 297 m_TabOrderWidgetArray.RemoveAll(); |
298 CXFA_WidgetArray SpaceOrderWidgetArray; | 298 CXFA_WidgetArray SpaceOrderWidgetArray; |
299 CreateSpaceOrderWidgetArray(SpaceOrderWidgetArray); | 299 CreateSpaceOrderWidgetArray(SpaceOrderWidgetArray); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 } | 401 } |
402 tabParams.RemoveAll(); | 402 tabParams.RemoveAll(); |
403 } | 403 } |
404 void CXFA_FFTabOrderPageWidgetIterator::CreateSpaceOrderWidgetArray( | 404 void CXFA_FFTabOrderPageWidgetIterator::CreateSpaceOrderWidgetArray( |
405 CXFA_WidgetArray& WidgetArray) { | 405 CXFA_WidgetArray& WidgetArray) { |
406 CXFA_LayoutItemIterator sIterator; | 406 CXFA_LayoutItemIterator sIterator; |
407 sIterator.Init(m_pPageView); | 407 sIterator.Init(m_pPageView); |
408 CXFA_TabParam* pParam = new CXFA_TabParam; | 408 CXFA_TabParam* pParam = new CXFA_TabParam; |
409 FX_BOOL bCurrentItem = FALSE; | 409 FX_BOOL bCurrentItem = FALSE; |
410 FX_BOOL bContentArea = FALSE; | 410 FX_BOOL bContentArea = FALSE; |
411 OrderContainer(&sIterator, NULL, pParam, bCurrentItem, bContentArea); | 411 OrderContainer(&sIterator, nullptr, pParam, bCurrentItem, bContentArea); |
412 if (pParam->m_Children.GetSize() > 0) { | 412 if (pParam->m_Children.GetSize() > 0) { |
413 WidgetArray.Append(pParam->m_Children); | 413 WidgetArray.Append(pParam->m_Children); |
414 } | 414 } |
415 sIterator.Reset(); | 415 sIterator.Reset(); |
416 bCurrentItem = FALSE; | 416 bCurrentItem = FALSE; |
417 bContentArea = FALSE; | 417 bContentArea = FALSE; |
418 pParam->m_Children.RemoveAll(); | 418 pParam->m_Children.RemoveAll(); |
419 OrderContainer(&sIterator, NULL, pParam, bCurrentItem, bContentArea, TRUE); | 419 OrderContainer(&sIterator, nullptr, pParam, bCurrentItem, bContentArea, TRUE); |
420 if (pParam->m_Children.GetSize() > 0) { | 420 if (pParam->m_Children.GetSize() > 0) { |
421 WidgetArray.Append(pParam->m_Children); | 421 WidgetArray.Append(pParam->m_Children); |
422 } | 422 } |
423 delete pParam; | 423 delete pParam; |
424 } | 424 } |
425 CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::GetWidget( | 425 CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::GetWidget( |
426 CXFA_LayoutItem* pLayoutItem) { | 426 CXFA_LayoutItem* pLayoutItem) { |
427 if (CXFA_FFWidget* pWidget = XFA_GetWidgetFromLayoutItem(pLayoutItem)) { | 427 if (CXFA_FFWidget* pWidget = XFA_GetWidgetFromLayoutItem(pLayoutItem)) { |
428 if (!pWidget->IsLoaded() && | 428 if (!pWidget->IsLoaded() && |
429 (pWidget->GetStatus() & XFA_WidgetStatus_Visible)) { | 429 (pWidget->GetStatus() & XFA_WidgetStatus_Visible)) { |
430 pWidget->LoadWidget(); | 430 pWidget->LoadWidget(); |
431 } | 431 } |
432 return pWidget; | 432 return pWidget; |
433 } | 433 } |
434 return NULL; | 434 return nullptr; |
435 } | 435 } |
436 | 436 |
437 CXFA_TabParam::CXFA_TabParam() : m_pWidget(NULL) {} | 437 CXFA_TabParam::CXFA_TabParam() : m_pWidget(nullptr) {} |
438 | 438 |
439 CXFA_TabParam::~CXFA_TabParam() {} | 439 CXFA_TabParam::~CXFA_TabParam() {} |
OLD | NEW |