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

Side by Side Diff: xfa/src/fxfa/src/parser/xfa_layout_pagemgr_new.cpp

Issue 1668003003: Call CXFA_Object::ToNode() rather than C-style casting. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 4 years, 10 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
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/src/foxitlib.h" 7 #include "xfa/src/foxitlib.h"
8 #include "xfa/src/fxfa/src/common/xfa_utils.h" 8 #include "xfa/src/fxfa/src/common/xfa_utils.h"
9 #include "xfa/src/fxfa/src/common/xfa_object.h" 9 #include "xfa/src/fxfa/src/common/xfa_object.h"
10 #include "xfa/src/fxfa/src/common/xfa_document.h" 10 #include "xfa/src/fxfa/src/common/xfa_document.h"
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 wsTargetAll.Mid(iSpliteIndex, iSpliteNextIndex - iSpliteIndex); 286 wsTargetAll.Mid(iSpliteIndex, iSpliteNextIndex - iSpliteIndex);
287 } else { 287 } else {
288 wsTargetExpr = wsTargetAll; 288 wsTargetExpr = wsTargetAll;
289 } 289 }
290 if (wsTargetExpr.IsEmpty()) { 290 if (wsTargetExpr.IsEmpty()) {
291 return NULL; 291 return NULL;
292 } 292 }
293 bTargetAllFind = FALSE; 293 bTargetAllFind = FALSE;
294 if (wsTargetExpr.GetAt(0) == '#') { 294 if (wsTargetExpr.GetAt(0) == '#') {
295 CXFA_Node* pNode = pDocument->GetNodeByID( 295 CXFA_Node* pNode = pDocument->GetNodeByID(
296 (CXFA_Node*)pDocument->GetXFAObject(XFA_HASHCODE_Template), 296 ToNode(pDocument->GetXFAObject(XFA_HASHCODE_Template)),
297 wsTargetExpr.Mid(1)); 297 wsTargetExpr.Mid(1));
298 if (pNode) { 298 if (pNode) {
299 return pNode; 299 return pNode;
300 } 300 }
301 } else if (bNewExprStyle) { 301 } else if (bNewExprStyle) {
302 CFX_WideString wsProcessedTarget = wsTargetExpr; 302 CFX_WideString wsProcessedTarget = wsTargetExpr;
303 if (wsTargetExpr.Left(4) == FX_WSTRC(L"som(") && 303 if (wsTargetExpr.Left(4) == FX_WSTRC(L"som(") &&
304 wsTargetExpr.Right(1) == FX_WSTRC(L")")) { 304 wsTargetExpr.Right(1) == FX_WSTRC(L")")) {
305 wsProcessedTarget = wsTargetExpr.Mid(4, wsTargetExpr.GetLength() - 5); 305 wsProcessedTarget = wsTargetExpr.Mid(4, wsTargetExpr.GetLength() - 5);
306 } 306 }
307 XFA_RESOLVENODE_RS rs; 307 XFA_RESOLVENODE_RS rs;
308 int32_t iCount = pDocument->GetScriptContext()->ResolveObjects( 308 int32_t iCount = pDocument->GetScriptContext()->ResolveObjects(
309 pPageSetRoot, wsProcessedTarget, rs, 309 pPageSetRoot, wsProcessedTarget, rs,
310 XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties | 310 XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties |
311 XFA_RESOLVENODE_Attributes | XFA_RESOLVENODE_Siblings | 311 XFA_RESOLVENODE_Attributes | XFA_RESOLVENODE_Siblings |
312 XFA_RESOLVENODE_Parent); 312 XFA_RESOLVENODE_Parent);
313 if (iCount > 0 && rs.nodes[0]->IsNode()) { 313 if (iCount > 0 && rs.nodes[0]->IsNode()) {
314 return (CXFA_Node*)rs.nodes[0]; 314 return rs.nodes[0]->AsNode();
315 } 315 }
316 } 316 }
317 iSpliteIndex = iSpliteNextIndex; 317 iSpliteIndex = iSpliteNextIndex;
318 } 318 }
319 return NULL; 319 return NULL;
320 } 320 }
321 321
322 FX_BOOL XFA_LayoutPageMgr_RunBreakTestScript(CXFA_Node* pTestScript) { 322 FX_BOOL XFA_LayoutPageMgr_RunBreakTestScript(CXFA_Node* pTestScript) {
323 CFX_WideString wsExpression; 323 CFX_WideString wsExpression;
324 pTestScript->TryContent(wsExpression); 324 pTestScript->TryContent(wsExpression);
(...skipping 1407 matching lines...) Expand 10 before | Expand all | Expand 10 after
1732 } 1732 }
1733 } 1733 }
1734 if (pExistingNode) { 1734 if (pExistingNode) {
1735 pParentNode->RemoveChild(pExistingNode); 1735 pParentNode->RemoveChild(pExistingNode);
1736 } 1736 }
1737 } 1737 }
1738 pContainerItem->m_pOldSubform = pNewSubform; 1738 pContainerItem->m_pOldSubform = pNewSubform;
1739 } 1739 }
1740 pContainerItem->m_pFormNode = pDocument->DataMerge_CopyContainer( 1740 pContainerItem->m_pFormNode = pDocument->DataMerge_CopyContainer(
1741 pContainerItem->m_pFormNode, pParentNode, 1741 pContainerItem->m_pFormNode, pParentNode,
1742 (CXFA_Node*)pDocument->GetXFAObject(XFA_HASHCODE_Record), TRUE); 1742 ToNode(pDocument->GetXFAObject(XFA_HASHCODE_Record)), TRUE);
1743 } break; 1743 } break;
1744 case XFA_ELEMENT_ContentArea: { 1744 case XFA_ELEMENT_ContentArea: {
1745 CXFA_Node* pParentNode = pContainerItem->m_pParent->m_pFormNode; 1745 CXFA_Node* pParentNode = pContainerItem->m_pParent->m_pFormNode;
1746 for (CXFA_Node* pChildNode = 1746 for (CXFA_Node* pChildNode =
1747 pParentNode->GetNodeItem(XFA_NODEITEM_FirstChild); 1747 pParentNode->GetNodeItem(XFA_NODEITEM_FirstChild);
1748 pChildNode; 1748 pChildNode;
1749 pChildNode = pChildNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { 1749 pChildNode = pChildNode->GetNodeItem(XFA_NODEITEM_NextSibling)) {
1750 if (pChildNode->GetTemplateNode() != pContainerItem->m_pFormNode) { 1750 if (pChildNode->GetTemplateNode() != pContainerItem->m_pFormNode) {
1751 continue; 1751 continue;
1752 } 1752 }
1753 pContainerItem->m_pFormNode = pChildNode; 1753 pContainerItem->m_pFormNode = pChildNode;
1754 break; 1754 break;
1755 } 1755 }
1756 } break; 1756 } break;
1757 default: 1757 default:
1758 break; 1758 break;
1759 } 1759 }
1760 } 1760 }
1761 if (!pPendingPageSet->GetNodeItem(XFA_NODEITEM_Parent)) { 1761 if (!pPendingPageSet->GetNodeItem(XFA_NODEITEM_Parent)) {
1762 CXFA_Node* pFormToplevelSubform = 1762 CXFA_Node* pFormToplevelSubform =
1763 ((CXFA_Node*)pDocument->GetXFAObject(XFA_HASHCODE_Form)) 1763 pDocument->GetXFAObject(XFA_HASHCODE_Form)
1764 ->AsNode()
1764 ->GetFirstChildByClass(XFA_ELEMENT_Subform); 1765 ->GetFirstChildByClass(XFA_ELEMENT_Subform);
1765 pFormToplevelSubform->InsertChild(pPendingPageSet); 1766 pFormToplevelSubform->InsertChild(pPendingPageSet);
1766 } 1767 }
1767 pDocument->DataMerge_UpdateBindingRelations(pPendingPageSet); 1768 pDocument->DataMerge_UpdateBindingRelations(pPendingPageSet);
1768 pPendingPageSet->SetFlag(XFA_NODEFLAG_Initialized); 1769 pPendingPageSet->SetFlag(XFA_NODEFLAG_Initialized);
1769 } 1770 }
1770 pPendingPageSet = GetRootLayoutItem()->m_pFormNode; 1771 pPendingPageSet = GetRootLayoutItem()->m_pFormNode;
1771 while (pPendingPageSet) { 1772 while (pPendingPageSet) {
1772 CXFA_Node* pNextPendingPageSet = 1773 CXFA_Node* pNextPendingPageSet =
1773 pPendingPageSet->GetNextSameClassSibling(XFA_ELEMENT_PageSet); 1774 pPendingPageSet->GetNextSameClassSibling(XFA_ELEMENT_PageSet);
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
2008 } 2009 }
2009 pRootLayoutItem = m_pPageSetLayoutItemRoot; 2010 pRootLayoutItem = m_pPageSetLayoutItemRoot;
2010 CXFA_ContainerLayoutItem* pNextLayout = NULL; 2011 CXFA_ContainerLayoutItem* pNextLayout = NULL;
2011 for (; pRootLayoutItem; pRootLayoutItem = pNextLayout) { 2012 for (; pRootLayoutItem; pRootLayoutItem = pNextLayout) {
2012 pNextLayout = (CXFA_ContainerLayoutItem*)pRootLayoutItem->m_pNextSibling; 2013 pNextLayout = (CXFA_ContainerLayoutItem*)pRootLayoutItem->m_pNextSibling;
2013 XFA_ReleaseLayoutItem_NoPageArea(pRootLayoutItem); 2014 XFA_ReleaseLayoutItem_NoPageArea(pRootLayoutItem);
2014 } 2015 }
2015 m_pPageSetLayoutItemRoot = NULL; 2016 m_pPageSetLayoutItemRoot = NULL;
2016 #endif 2017 #endif
2017 } 2018 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698