| 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/parser/xfa_script_layoutpseudomodel.h" | 7 #include "xfa/fxfa/parser/xfa_script_layoutpseudomodel.h" |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 if (CXFA_Node* pMasterPage = pLayoutPage->m_pFormNode) { | 235 if (CXFA_Node* pMasterPage = pLayoutPage->m_pFormNode) { |
| 236 retArray.Add(pMasterPage); | 236 retArray.Add(pMasterPage); |
| 237 } | 237 } |
| 238 for (CXFA_LayoutItem* pItem = pLayoutPage->m_pFirstChild; pItem; | 238 for (CXFA_LayoutItem* pItem = pLayoutPage->m_pFirstChild; pItem; |
| 239 pItem = pItem->m_pNextSibling) { | 239 pItem = pItem->m_pNextSibling) { |
| 240 if (pItem->m_pFormNode->GetClassID() == XFA_ELEMENT_ContentArea) { | 240 if (pItem->m_pFormNode->GetClassID() == XFA_ELEMENT_ContentArea) { |
| 241 retArray.Add(pItem->m_pFormNode); | 241 retArray.Add(pItem->m_pFormNode); |
| 242 if (!bOnPageArea) { | 242 if (!bOnPageArea) { |
| 243 CXFA_NodeIteratorTemplate<CXFA_ContentLayoutItem, | 243 CXFA_NodeIteratorTemplate<CXFA_ContentLayoutItem, |
| 244 CXFA_TraverseStrategy_ContentLayoutItem> | 244 CXFA_TraverseStrategy_ContentLayoutItem> |
| 245 iterator((CXFA_ContentLayoutItem*)pItem->m_pFirstChild); | 245 iterator(static_cast<CXFA_ContentLayoutItem*>(pItem->m_pFirstChild)); |
| 246 for (CXFA_ContentLayoutItem* pItemChild = iterator.GetCurrent(); | 246 for (CXFA_ContentLayoutItem* pItemChild = iterator.GetCurrent(); |
| 247 pItemChild; pItemChild = iterator.MoveToNext()) { | 247 pItemChild; pItemChild = iterator.MoveToNext()) { |
| 248 if (!pItemChild->IsContentLayoutItem()) { | 248 if (!pItemChild->IsContentLayoutItem()) { |
| 249 continue; | 249 continue; |
| 250 } | 250 } |
| 251 XFA_ELEMENT eElementType = pItemChild->m_pFormNode->GetClassID(); | 251 XFA_ELEMENT eElementType = pItemChild->m_pFormNode->GetClassID(); |
| 252 if (eElementType != XFA_ELEMENT_Field && | 252 if (eElementType != XFA_ELEMENT_Field && |
| 253 eElementType != XFA_ELEMENT_Draw && | 253 eElementType != XFA_ELEMENT_Draw && |
| 254 eElementType != XFA_ELEMENT_Subform && | 254 eElementType != XFA_ELEMENT_Subform && |
| 255 eElementType != XFA_ELEMENT_Area) { | 255 eElementType != XFA_ELEMENT_Area) { |
| 256 continue; | 256 continue; |
| 257 } | 257 } |
| 258 if (pdfium::ContainsValue(formItems, pItemChild->m_pFormNode)) | 258 if (pdfium::ContainsValue(formItems, pItemChild->m_pFormNode)) |
| 259 continue; | 259 continue; |
| 260 | 260 |
| 261 formItems.insert(pItemChild->m_pFormNode); | 261 formItems.insert(pItemChild->m_pFormNode); |
| 262 retArray.Add(pItemChild->m_pFormNode); | 262 retArray.Add(pItemChild->m_pFormNode); |
| 263 } | 263 } |
| 264 } | 264 } |
| 265 } else { | 265 } else { |
| 266 if (bOnPageArea) { | 266 if (bOnPageArea) { |
| 267 CXFA_NodeIteratorTemplate<CXFA_ContentLayoutItem, | 267 CXFA_NodeIteratorTemplate<CXFA_ContentLayoutItem, |
| 268 CXFA_TraverseStrategy_ContentLayoutItem> | 268 CXFA_TraverseStrategy_ContentLayoutItem> |
| 269 iterator((CXFA_ContentLayoutItem*)pItem); | 269 iterator(static_cast<CXFA_ContentLayoutItem*>(pItem)); |
| 270 for (CXFA_ContentLayoutItem* pItemChild = iterator.GetCurrent(); | 270 for (CXFA_ContentLayoutItem* pItemChild = iterator.GetCurrent(); |
| 271 pItemChild; pItemChild = iterator.MoveToNext()) { | 271 pItemChild; pItemChild = iterator.MoveToNext()) { |
| 272 if (!pItemChild->IsContentLayoutItem()) { | 272 if (!pItemChild->IsContentLayoutItem()) { |
| 273 continue; | 273 continue; |
| 274 } | 274 } |
| 275 XFA_ELEMENT eElementType = pItemChild->m_pFormNode->GetClassID(); | 275 XFA_ELEMENT eElementType = pItemChild->m_pFormNode->GetClassID(); |
| 276 if (eElementType != XFA_ELEMENT_Field && | 276 if (eElementType != XFA_ELEMENT_Field && |
| 277 eElementType != XFA_ELEMENT_Draw && | 277 eElementType != XFA_ELEMENT_Draw && |
| 278 eElementType != XFA_ELEMENT_Subform && | 278 eElementType != XFA_ELEMENT_Subform && |
| 279 eElementType != XFA_ELEMENT_Area) { | 279 eElementType != XFA_ELEMENT_Area) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 299 } else if (wsType == FX_WSTRC(L"area")) { | 299 } else if (wsType == FX_WSTRC(L"area")) { |
| 300 eType = XFA_ELEMENT_Area; | 300 eType = XFA_ELEMENT_Area; |
| 301 } | 301 } |
| 302 if (eType != XFA_ELEMENT_UNKNOWN) { | 302 if (eType != XFA_ELEMENT_UNKNOWN) { |
| 303 for (CXFA_LayoutItem* pItem = pLayoutPage->m_pFirstChild; pItem; | 303 for (CXFA_LayoutItem* pItem = pLayoutPage->m_pFirstChild; pItem; |
| 304 pItem = pItem->m_pNextSibling) { | 304 pItem = pItem->m_pNextSibling) { |
| 305 if (pItem->m_pFormNode->GetClassID() == XFA_ELEMENT_ContentArea) { | 305 if (pItem->m_pFormNode->GetClassID() == XFA_ELEMENT_ContentArea) { |
| 306 if (!bOnPageArea) { | 306 if (!bOnPageArea) { |
| 307 CXFA_NodeIteratorTemplate<CXFA_ContentLayoutItem, | 307 CXFA_NodeIteratorTemplate<CXFA_ContentLayoutItem, |
| 308 CXFA_TraverseStrategy_ContentLayoutItem> | 308 CXFA_TraverseStrategy_ContentLayoutItem> |
| 309 iterator((CXFA_ContentLayoutItem*)pItem->m_pFirstChild); | 309 iterator(static_cast<CXFA_ContentLayoutItem*>(pItem->m_pFirstChild)); |
| 310 for (CXFA_ContentLayoutItem* pItemChild = iterator.GetCurrent(); | 310 for (CXFA_ContentLayoutItem* pItemChild = iterator.GetCurrent(); |
| 311 pItemChild; pItemChild = iterator.MoveToNext()) { | 311 pItemChild; pItemChild = iterator.MoveToNext()) { |
| 312 if (!pItemChild->IsContentLayoutItem()) | 312 if (!pItemChild->IsContentLayoutItem()) |
| 313 continue; | 313 continue; |
| 314 if (pItemChild->m_pFormNode->GetClassID() != eType) | 314 if (pItemChild->m_pFormNode->GetClassID() != eType) |
| 315 continue; | 315 continue; |
| 316 if (pdfium::ContainsValue(formItems, pItemChild->m_pFormNode)) | 316 if (pdfium::ContainsValue(formItems, pItemChild->m_pFormNode)) |
| 317 continue; | 317 continue; |
| 318 formItems.insert(pItemChild->m_pFormNode); | 318 formItems.insert(pItemChild->m_pFormNode); |
| 319 retArray.Add(pItemChild->m_pFormNode); | 319 retArray.Add(pItemChild->m_pFormNode); |
| 320 } | 320 } |
| 321 } | 321 } |
| 322 } else { | 322 } else { |
| 323 if (bOnPageArea) { | 323 if (bOnPageArea) { |
| 324 CXFA_NodeIteratorTemplate<CXFA_ContentLayoutItem, | 324 CXFA_NodeIteratorTemplate<CXFA_ContentLayoutItem, |
| 325 CXFA_TraverseStrategy_ContentLayoutItem> | 325 CXFA_TraverseStrategy_ContentLayoutItem> |
| 326 iterator((CXFA_ContentLayoutItem*)pItem); | 326 iterator(static_cast<CXFA_ContentLayoutItem*>(pItem)); |
| 327 for (CXFA_ContentLayoutItem* pItemChild = iterator.GetCurrent(); | 327 for (CXFA_ContentLayoutItem* pItemChild = iterator.GetCurrent(); |
| 328 pItemChild; pItemChild = iterator.MoveToNext()) { | 328 pItemChild; pItemChild = iterator.MoveToNext()) { |
| 329 if (!pItemChild->IsContentLayoutItem()) | 329 if (!pItemChild->IsContentLayoutItem()) |
| 330 continue; | 330 continue; |
| 331 if (pItemChild->m_pFormNode->GetClassID() != eType) | 331 if (pItemChild->m_pFormNode->GetClassID() != eType) |
| 332 continue; | 332 continue; |
| 333 if (pdfium::ContainsValue(formItems, pItemChild->m_pFormNode)) | 333 if (pdfium::ContainsValue(formItems, pItemChild->m_pFormNode)) |
| 334 continue; | 334 continue; |
| 335 formItems.insert(pItemChild->m_pFormNode); | 335 formItems.insert(pItemChild->m_pFormNode); |
| 336 retArray.Add(pItemChild->m_pFormNode); | 336 retArray.Add(pItemChild->m_pFormNode); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 CXFA_LayoutProcessor* pDocLayout = m_pDocument->GetDocLayout(); | 368 CXFA_LayoutProcessor* pDocLayout = m_pDocument->GetDocLayout(); |
| 369 if (!pDocLayout) { | 369 if (!pDocLayout) { |
| 370 return; | 370 return; |
| 371 } | 371 } |
| 372 CXFA_NodeArray retArray; | 372 CXFA_NodeArray retArray; |
| 373 Script_LayoutPseudoModel_GetObjArray(pDocLayout, iIndex, wsType, bOnPageArea, | 373 Script_LayoutPseudoModel_GetObjArray(pDocLayout, iIndex, wsType, bOnPageArea, |
| 374 retArray); | 374 retArray); |
| 375 CXFA_ArrayNodeList* pArrayNodeList = new CXFA_ArrayNodeList(m_pDocument); | 375 CXFA_ArrayNodeList* pArrayNodeList = new CXFA_ArrayNodeList(m_pDocument); |
| 376 pArrayNodeList->SetArrayNodeList(retArray); | 376 pArrayNodeList->SetArrayNodeList(retArray); |
| 377 pArguments->GetReturnValue()->SetObject( | 377 pArguments->GetReturnValue()->SetObject( |
| 378 (CXFA_Object*)pArrayNodeList, | 378 pArrayNodeList, m_pDocument->GetScriptContext()->GetJseNormalClass()); |
| 379 m_pDocument->GetScriptContext()->GetJseNormalClass()); | |
| 380 } | 379 } |
| 381 void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_AbsPageCount( | 380 void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_AbsPageCount( |
| 382 CFXJSE_Arguments* pArguments) { | 381 CFXJSE_Arguments* pArguments) { |
| 383 Script_LayoutPseudoModel_NumberedPageCount(pArguments, FALSE); | 382 Script_LayoutPseudoModel_NumberedPageCount(pArguments, FALSE); |
| 384 } | 383 } |
| 385 void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_AbsPageCountInBatch( | 384 void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_AbsPageCountInBatch( |
| 386 CFXJSE_Arguments* pArguments) { | 385 CFXJSE_Arguments* pArguments) { |
| 387 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); | 386 CXFA_FFNotify* pNotify = m_pDocument->GetParser()->GetNotify(); |
| 388 if (!pNotify) { | 387 if (!pNotify) { |
| 389 return; | 388 return; |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 } | 530 } |
| 532 CXFA_LayoutItem* pLayoutItem = pDocLayout->GetLayoutItem(pNode); | 531 CXFA_LayoutItem* pLayoutItem = pDocLayout->GetLayoutItem(pNode); |
| 533 if (!pLayoutItem) { | 532 if (!pLayoutItem) { |
| 534 pValue->SetInteger(-1); | 533 pValue->SetInteger(-1); |
| 535 return; | 534 return; |
| 536 } | 535 } |
| 537 iPage = pLayoutItem->GetFirst()->GetPage()->GetPageIndex(); | 536 iPage = pLayoutItem->GetFirst()->GetPage()->GetPageIndex(); |
| 538 if (pValue) | 537 if (pValue) |
| 539 pValue->SetInteger(bAbsPage ? iPage : iPage + 1); | 538 pValue->SetInteger(bAbsPage ? iPage : iPage + 1); |
| 540 } | 539 } |
| OLD | NEW |