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

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

Issue 2612923002: Remove CFX_MapPtrToPtr from xfa/fxfa. (Closed)
Patch Set: endless loop Created 3 years, 11 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/parser/cxfa_layoutpagemgr.h ('k') | xfa/fxfa/parser/cxfa_node.cpp » ('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 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/cxfa_layoutpagemgr.h" 7 #include "xfa/fxfa/parser/cxfa_layoutpagemgr.h"
8 8
9 #include "xfa/fxfa/app/xfa_ffnotify.h" 9 #include "xfa/fxfa/app/xfa_ffnotify.h"
10 #include "xfa/fxfa/parser/cxfa_containerlayoutitem.h" 10 #include "xfa/fxfa/parser/cxfa_containerlayoutitem.h"
(...skipping 1102 matching lines...) Expand 10 before | Expand all | Expand 10 after
1113 1113
1114 bool CXFA_LayoutPageMgr::FindPageAreaFromPageSet_Ordered( 1114 bool CXFA_LayoutPageMgr::FindPageAreaFromPageSet_Ordered(
1115 CXFA_Node* pPageSet, 1115 CXFA_Node* pPageSet,
1116 CXFA_Node* pStartChild, 1116 CXFA_Node* pStartChild,
1117 CXFA_Node* pTargetPageArea, 1117 CXFA_Node* pTargetPageArea,
1118 CXFA_Node* pTargetContentArea, 1118 CXFA_Node* pTargetContentArea,
1119 bool bNewPage, 1119 bool bNewPage,
1120 bool bQuery) { 1120 bool bQuery) {
1121 int32_t iPageSetCount = 0; 1121 int32_t iPageSetCount = 0;
1122 if (!pStartChild && !bQuery) { 1122 if (!pStartChild && !bQuery) {
1123 m_pPageSetMap.Lookup(pPageSet, iPageSetCount); 1123 auto it = m_pPageSetMap.find(pPageSet);
1124 if (it != m_pPageSetMap.end())
1125 iPageSetCount = it->second;
1124 int32_t iMax = -1; 1126 int32_t iMax = -1;
1125 CXFA_Node* pOccurNode = pPageSet->GetFirstChildByClass(XFA_Element::Occur); 1127 CXFA_Node* pOccurNode = pPageSet->GetFirstChildByClass(XFA_Element::Occur);
1126 if (pOccurNode) 1128 if (pOccurNode)
1127 pOccurNode->TryInteger(XFA_ATTRIBUTE_Max, iMax, false); 1129 pOccurNode->TryInteger(XFA_ATTRIBUTE_Max, iMax, false);
1128 if (iMax >= 0 && iMax <= iPageSetCount) 1130 if (iMax >= 0 && iMax <= iPageSetCount)
1129 return false; 1131 return false;
1130 } 1132 }
1131
1132 bool bRes = false; 1133 bool bRes = false;
1133 CXFA_Node* pCurrentNode = 1134 CXFA_Node* pCurrentNode =
1134 pStartChild ? pStartChild->GetNodeItem(XFA_NODEITEM_NextSibling) 1135 pStartChild ? pStartChild->GetNodeItem(XFA_NODEITEM_NextSibling)
1135 : pPageSet->GetNodeItem(XFA_NODEITEM_FirstChild); 1136 : pPageSet->GetNodeItem(XFA_NODEITEM_FirstChild);
1136 for (; pCurrentNode; 1137 for (; pCurrentNode;
1137 pCurrentNode = pCurrentNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { 1138 pCurrentNode = pCurrentNode->GetNodeItem(XFA_NODEITEM_NextSibling)) {
1138 if (pCurrentNode->GetElementType() == XFA_Element::PageArea) { 1139 if (pCurrentNode->GetElementType() == XFA_Element::PageArea) {
1139 if ((pTargetPageArea == pCurrentNode || !pTargetPageArea)) { 1140 if ((pTargetPageArea == pCurrentNode || !pTargetPageArea)) {
1140 if (!pCurrentNode->GetFirstChildByClass(XFA_Element::ContentArea)) { 1141 if (!pCurrentNode->GetFirstChildByClass(XFA_Element::ContentArea)) {
1141 if (pTargetPageArea == pCurrentNode) { 1142 if (pTargetPageArea == pCurrentNode) {
(...skipping 24 matching lines...) Expand all
1166 pTargetPageArea, pTargetContentArea, 1167 pTargetPageArea, pTargetContentArea,
1167 bNewPage, bQuery)) { 1168 bNewPage, bQuery)) {
1168 bRes = true; 1169 bRes = true;
1169 break; 1170 break;
1170 } 1171 }
1171 if (!bQuery) 1172 if (!bQuery)
1172 CreateMinPageSetRecord(pCurrentNode, true); 1173 CreateMinPageSetRecord(pCurrentNode, true);
1173 } 1174 }
1174 } 1175 }
1175 if (!pStartChild && bRes && !bQuery) 1176 if (!pStartChild && bRes && !bQuery)
1176 m_pPageSetMap.SetAt(pPageSet, ++iPageSetCount); 1177 m_pPageSetMap[pPageSet] = ++iPageSetCount;
1177 return bRes; 1178 return bRes;
1178 } 1179 }
1179 1180
1180 bool CXFA_LayoutPageMgr::FindPageAreaFromPageSet_SimplexDuplex( 1181 bool CXFA_LayoutPageMgr::FindPageAreaFromPageSet_SimplexDuplex(
1181 CXFA_Node* pPageSet, 1182 CXFA_Node* pPageSet,
1182 CXFA_Node* pStartChild, 1183 CXFA_Node* pStartChild,
1183 CXFA_Node* pTargetPageArea, 1184 CXFA_Node* pTargetPageArea,
1184 CXFA_Node* pTargetContentArea, 1185 CXFA_Node* pTargetContentArea,
1185 bool bNewPage, 1186 bool bNewPage,
1186 bool bQuery, 1187 bool bQuery,
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
1407 if (!IsPageSetRootOrderedOccurrence()) 1408 if (!IsPageSetRootOrderedOccurrence())
1408 return; 1409 return;
1409 1410
1410 CXFA_NodeIterator sIterator(m_pTemplatePageSetRoot); 1411 CXFA_NodeIterator sIterator(m_pTemplatePageSetRoot);
1411 for (CXFA_Node* pPageSetNode = sIterator.GetCurrent(); pPageSetNode; 1412 for (CXFA_Node* pPageSetNode = sIterator.GetCurrent(); pPageSetNode;
1412 pPageSetNode = sIterator.MoveToNext()) { 1413 pPageSetNode = sIterator.MoveToNext()) {
1413 if (pPageSetNode->GetElementType() == XFA_Element::PageSet) { 1414 if (pPageSetNode->GetElementType() == XFA_Element::PageSet) {
1414 XFA_ATTRIBUTEENUM eRelation = 1415 XFA_ATTRIBUTEENUM eRelation =
1415 pPageSetNode->GetEnum(XFA_ATTRIBUTE_Relation); 1416 pPageSetNode->GetEnum(XFA_ATTRIBUTE_Relation);
1416 if (eRelation == XFA_ATTRIBUTEENUM_OrderedOccurrence) 1417 if (eRelation == XFA_ATTRIBUTEENUM_OrderedOccurrence)
1417 m_pPageSetMap.SetAt(pPageSetNode, 0); 1418 m_pPageSetMap[pPageSetNode] = 0;
1418 } 1419 }
1419 } 1420 }
1420 } 1421 }
1421 1422
1422 int32_t CXFA_LayoutPageMgr::CreateMinPageRecord(CXFA_Node* pPageArea, 1423 int32_t CXFA_LayoutPageMgr::CreateMinPageRecord(CXFA_Node* pPageArea,
1423 bool bTargetPageArea, 1424 bool bTargetPageArea,
1424 bool bCreateLast) { 1425 bool bCreateLast) {
1425 if (!pPageArea) 1426 if (!pPageArea)
1426 return 0; 1427 return 0;
1427 1428
(...skipping 17 matching lines...) Expand all
1445 } 1446 }
1446 } 1447 }
1447 return iMin; 1448 return iMin;
1448 } 1449 }
1449 1450
1450 void CXFA_LayoutPageMgr::CreateMinPageSetRecord(CXFA_Node* pPageSet, 1451 void CXFA_LayoutPageMgr::CreateMinPageSetRecord(CXFA_Node* pPageSet,
1451 bool bCreateAll) { 1452 bool bCreateAll) {
1452 if (!pPageSet) 1453 if (!pPageSet)
1453 return; 1454 return;
1454 1455
1455 int32_t iCurSetCount = 0; 1456 auto it = m_pPageSetMap.find(pPageSet);
1456 if (!m_pPageSetMap.Lookup(pPageSet, iCurSetCount)) 1457 if (it == m_pPageSetMap.end())
1457 return; 1458 return;
1459
1460 int32_t iCurSetCount = it->second;
1458 if (bCreateAll) 1461 if (bCreateAll)
1459 iCurSetCount = 0; 1462 iCurSetCount = 0;
1460 1463
1461 CXFA_Node* pOccurNode = pPageSet->GetFirstChildByClass(XFA_Element::Occur); 1464 CXFA_Node* pOccurNode = pPageSet->GetFirstChildByClass(XFA_Element::Occur);
1462 int32_t iMin = 0; 1465 int32_t iMin = 0;
1463 if (pOccurNode && pOccurNode->TryInteger(XFA_ATTRIBUTE_Min, iMin, false)) { 1466 if (pOccurNode && pOccurNode->TryInteger(XFA_ATTRIBUTE_Min, iMin, false)) {
1464 if (iCurSetCount < iMin) { 1467 if (iCurSetCount < iMin) {
1465 for (int32_t i = 0; i < iMin - iCurSetCount; i++) { 1468 for (int32_t i = 0; i < iMin - iCurSetCount; i++) {
1466 for (CXFA_Node* pCurrentPageNode = 1469 for (CXFA_Node* pCurrentPageNode =
1467 pPageSet->GetNodeItem(XFA_NODEITEM_FirstChild); 1470 pPageSet->GetNodeItem(XFA_NODEITEM_FirstChild);
1468 pCurrentPageNode; pCurrentPageNode = pCurrentPageNode->GetNodeItem( 1471 pCurrentPageNode; pCurrentPageNode = pCurrentPageNode->GetNodeItem(
1469 XFA_NODEITEM_NextSibling)) { 1472 XFA_NODEITEM_NextSibling)) {
1470 if (pCurrentPageNode->GetElementType() == XFA_Element::PageArea) { 1473 if (pCurrentPageNode->GetElementType() == XFA_Element::PageArea) {
1471 CreateMinPageRecord(pCurrentPageNode, false); 1474 CreateMinPageRecord(pCurrentPageNode, false);
1472 } else if (pCurrentPageNode->GetElementType() == 1475 } else if (pCurrentPageNode->GetElementType() ==
1473 XFA_Element::PageSet) { 1476 XFA_Element::PageSet) {
1474 CreateMinPageSetRecord(pCurrentPageNode, true); 1477 CreateMinPageSetRecord(pCurrentPageNode, true);
1475 } 1478 }
1476 } 1479 }
1477 } 1480 }
1478 m_pPageSetMap.SetAt(pPageSet, iMin); 1481 m_pPageSetMap[pPageSet] = iMin;
1479 } 1482 }
1480 } 1483 }
1481 } 1484 }
1482 1485
1483 void CXFA_LayoutPageMgr::CreateNextMinRecord(CXFA_Node* pRecordNode) { 1486 void CXFA_LayoutPageMgr::CreateNextMinRecord(CXFA_Node* pRecordNode) {
1484 if (!pRecordNode) 1487 if (!pRecordNode)
1485 return; 1488 return;
1486 1489
1487 for (CXFA_Node* pCurrentNode = 1490 for (CXFA_Node* pCurrentNode =
1488 pRecordNode->GetNodeItem(XFA_NODEITEM_NextSibling); 1491 pRecordNode->GetNodeItem(XFA_NODEITEM_NextSibling);
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
1575 auto sPos = m_ProposedContainerRecords.begin(); 1578 auto sPos = m_ProposedContainerRecords.begin();
1576 while (sPos != m_ProposedContainerRecords.end()) { 1579 while (sPos != m_ProposedContainerRecords.end()) {
1577 CXFA_ContainerRecord* pRecord = *sPos++; 1580 CXFA_ContainerRecord* pRecord = *sPos++;
1578 delete pRecord; 1581 delete pRecord;
1579 } 1582 }
1580 m_ProposedContainerRecords.clear(); 1583 m_ProposedContainerRecords.clear();
1581 m_CurrentContainerRecordIter = m_ProposedContainerRecords.end(); 1584 m_CurrentContainerRecordIter = m_ProposedContainerRecords.end();
1582 m_pCurPageArea = nullptr; 1585 m_pCurPageArea = nullptr;
1583 m_nCurPageCount = 0; 1586 m_nCurPageCount = 0;
1584 m_bCreateOverFlowPage = false; 1587 m_bCreateOverFlowPage = false;
1585 m_pPageSetMap.RemoveAll(); 1588 m_pPageSetMap.clear();
1586 } 1589 }
1587 1590
1588 CXFA_LayoutItem* CXFA_LayoutPageMgr::FindOrCreateLayoutItem( 1591 CXFA_LayoutItem* CXFA_LayoutPageMgr::FindOrCreateLayoutItem(
1589 CXFA_Node* pFormNode) { 1592 CXFA_Node* pFormNode) {
1590 return pFormNode->GetDocument()->GetNotify()->OnCreateLayoutItem(pFormNode); 1593 return pFormNode->GetDocument()->GetNotify()->OnCreateLayoutItem(pFormNode);
1591 } 1594 }
1592 1595
1593 void CXFA_LayoutPageMgr::SaveLayoutItem(CXFA_LayoutItem* pParentLayoutItem) { 1596 void CXFA_LayoutPageMgr::SaveLayoutItem(CXFA_LayoutItem* pParentLayoutItem) {
1594 CXFA_LayoutItem* pNextLayoutItem; 1597 CXFA_LayoutItem* pNextLayoutItem;
1595 CXFA_LayoutItem* pCurLayoutItem = pParentLayoutItem->m_pFirstChild; 1598 CXFA_LayoutItem* pCurLayoutItem = pParentLayoutItem->m_pFirstChild;
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
1982 pRootLayoutItem = m_pPageSetLayoutItemRoot; 1985 pRootLayoutItem = m_pPageSetLayoutItemRoot;
1983 CXFA_ContainerLayoutItem* pNextLayout = nullptr; 1986 CXFA_ContainerLayoutItem* pNextLayout = nullptr;
1984 for (; pRootLayoutItem; pRootLayoutItem = pNextLayout) { 1987 for (; pRootLayoutItem; pRootLayoutItem = pNextLayout) {
1985 pNextLayout = 1988 pNextLayout =
1986 static_cast<CXFA_ContainerLayoutItem*>(pRootLayoutItem->m_pNextSibling); 1989 static_cast<CXFA_ContainerLayoutItem*>(pRootLayoutItem->m_pNextSibling);
1987 SaveLayoutItem(pRootLayoutItem); 1990 SaveLayoutItem(pRootLayoutItem);
1988 delete pRootLayoutItem; 1991 delete pRootLayoutItem;
1989 } 1992 }
1990 m_pPageSetLayoutItemRoot = nullptr; 1993 m_pPageSetLayoutItemRoot = nullptr;
1991 } 1994 }
OLDNEW
« no previous file with comments | « xfa/fxfa/parser/cxfa_layoutpagemgr.h ('k') | xfa/fxfa/parser/cxfa_node.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698