From 21068062a038db72b5ee40512fe638acbdd17c3d Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Fri, 17 Aug 2018 01:24:57 +0000 Subject: Remove optionals in CXFA_LayoutPageMgr methods. Change-Id: If57552b9e48d9607f84e853aadb2742a8c135b46 Reviewed-on: https://pdfium-review.googlesource.com/40470 Reviewed-by: Lei Zhang Commit-Queue: Tom Sepez --- xfa/fxfa/parser/cxfa_layoutpagemgr.cpp | 47 +++++++++++++++++++--------------- xfa/fxfa/parser/cxfa_layoutpagemgr.h | 16 ++++++------ 2 files changed, 35 insertions(+), 28 deletions(-) (limited to 'xfa/fxfa') diff --git a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp index cf3d61e644..e603d91002 100644 --- a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp +++ b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp @@ -424,7 +424,7 @@ bool CXFA_LayoutPageMgr::AppendNewPage(bool bFirstTemPage) { if (m_CurrentContainerRecordIter != GetTailPosition()) return true; - CXFA_Node* pPageNode = GetNextAvailPageArea(nullptr); + CXFA_Node* pPageNode = GetNextAvailPageArea(nullptr, nullptr, false, false); if (!pPageNode) return false; @@ -484,7 +484,7 @@ void CXFA_LayoutPageMgr::SubmitContentItem( if (eStatus != XFA_ItemLayoutProcessorResult::Done) { if (eStatus == XFA_ItemLayoutProcessorResult::PageFullBreak && m_CurrentContainerRecordIter == GetTailPosition()) { - AppendNewPage(); + AppendNewPage(false); } m_CurrentContainerRecordIter = GetTailPosition(); m_pCurPageArea = GetCurrentContainerRecord()->pCurPageArea->GetFormNode(); @@ -665,7 +665,8 @@ void CXFA_LayoutPageMgr::FinishPaginatedPageSets() { if (eLastChoice == XFA_AttributeEnum::First && (ePageRelation == XFA_AttributeEnum::SimplexPaginated || eOddOrEven != XFA_AttributeEnum::Odd)) { - CXFA_ContainerRecord* pRecord = CreateContainerRecord(); + CXFA_ContainerRecord* pRecord = + CreateContainerRecord(nullptr, false); AddPageAreaLayoutItem(pRecord, pNode); break; } @@ -733,7 +734,8 @@ void CXFA_LayoutPageMgr::FinishPaginatedPageSets() { } } else if (pNode->JSObject()->GetEnum(XFA_Attribute::PagePosition) == XFA_AttributeEnum::Last) { - CXFA_ContainerRecord* pRecord = CreateContainerRecord(); + CXFA_ContainerRecord* pRecord = + CreateContainerRecord(nullptr, false); AddPageAreaLayoutItem(pRecord, pNode); } } break; @@ -776,7 +778,7 @@ bool CXFA_LayoutPageMgr::RunBreak(XFA_Element eBreakType, if (pTarget) pPageArea = pTarget->GetParent(); - pPageArea = GetNextAvailPageArea(pPageArea, pTarget); + pPageArea = GetNextAvailPageArea(pPageArea, pTarget, false, false); bRet = !!pPageArea; } break; @@ -787,7 +789,8 @@ bool CXFA_LayoutPageMgr::RunBreak(XFA_Element eBreakType, m_CurrentContainerRecordIter == m_ProposedContainerRecords.end() || pTarget != GetCurrentContainerRecord()->pCurPageArea->GetFormNode() || bStartNew) { - CXFA_Node* pPageArea = GetNextAvailPageArea(pTarget, nullptr, true); + CXFA_Node* pPageArea = + GetNextAvailPageArea(pTarget, nullptr, true, false); bRet = !!pPageArea; } break; @@ -1154,7 +1157,7 @@ bool CXFA_LayoutPageMgr::FindPageAreaFromPageSet_Ordered( if (!pCurrentNode->GetFirstChildByClass( XFA_Element::ContentArea)) { if (pTargetPageArea == pCurrentNode) { - CreateMinPageRecord(pCurrentNode, true); + CreateMinPageRecord(pCurrentNode, true, false); pTargetPageArea = nullptr; } continue; @@ -1176,7 +1179,7 @@ bool CXFA_LayoutPageMgr::FindPageAreaFromPageSet_Ordered( break; } if (!bQuery) - CreateMinPageRecord(pCurrentNode, false); + CreateMinPageRecord(pCurrentNode, false, false); } else if (pCurrentNode->GetElementType() == XFA_Element::PageSet) { if (FindPageAreaFromPageSet_Ordered(pCurrentNode, nullptr, pTargetPageArea, pTargetContentArea, @@ -1226,7 +1229,8 @@ bool CXFA_LayoutPageMgr::FindPageAreaFromPageSet_SimplexDuplex( pPreferredPageArea = pCurrentNode; break; } - CXFA_ContainerRecord* pNewRecord = CreateContainerRecord(); + CXFA_ContainerRecord* pNewRecord = + CreateContainerRecord(nullptr, false); AddPageAreaLayoutItem(pNewRecord, pCurrentNode); AddContentAreaLayoutItem( pNewRecord, pCurrentNode->GetFirstChildByClass( @@ -1249,7 +1253,8 @@ bool CXFA_LayoutPageMgr::FindPageAreaFromPageSet_SimplexDuplex( if (!pCurrentNode->GetFirstChildByClass( XFA_Element::ContentArea)) { if (pTargetPageArea == pCurrentNode) { - CXFA_ContainerRecord* pNewRecord = CreateContainerRecord(); + CXFA_ContainerRecord* pNewRecord = + CreateContainerRecord(nullptr, false); AddPageAreaLayoutItem(pNewRecord, pCurrentNode); pTargetPageArea = nullptr; } @@ -1265,7 +1270,8 @@ bool CXFA_LayoutPageMgr::FindPageAreaFromPageSet_SimplexDuplex( pFallbackPageArea = pCurrentNode; } } else if (pTargetPageArea && !MatchPageAreaOddOrEven(pTargetPageArea)) { - CXFA_ContainerRecord* pNewRecord = CreateContainerRecord(); + CXFA_ContainerRecord* pNewRecord = + CreateContainerRecord(nullptr, false); AddPageAreaLayoutItem(pNewRecord, pCurrentNode); AddContentAreaLayoutItem( pNewRecord, pCurrentNode->GetFirstChildByClass( @@ -1290,7 +1296,7 @@ bool CXFA_LayoutPageMgr::FindPageAreaFromPageSet_SimplexDuplex( return false; if (!bQuery) { - CXFA_ContainerRecord* pNewRecord = CreateContainerRecord(); + CXFA_ContainerRecord* pNewRecord = CreateContainerRecord(nullptr, false); AddPageAreaLayoutItem(pNewRecord, pCurPageArea); if (!pTargetContentArea) { pTargetContentArea = pCurPageArea->GetFirstChildByClass( @@ -1344,7 +1350,7 @@ CXFA_Node* CXFA_LayoutPageMgr::GetNextAvailPageArea( if ((iMax < 0 || m_nCurPageCount < iMax)) { if (!bQuery) { CXFA_ContainerRecord* pNewRecord = - CreateContainerRecord(m_pCurPageArea); + CreateContainerRecord(m_pCurPageArea, false); AddPageAreaLayoutItem(pNewRecord, m_pCurPageArea); if (!pTargetContentArea) { pTargetContentArea = @@ -1374,7 +1380,7 @@ CXFA_Node* CXFA_LayoutPageMgr::GetNextAvailPageArea( return m_pCurPageArea; } if (!bQuery && IsPageSetRootOrderedOccurrence()) - CreateMinPageSetRecord(pPageSet); + CreateMinPageSetRecord(pPageSet, false); if (FindPageAreaFromPageSet(nullptr, pPageSet, pTargetPageArea, pTargetContentArea, bNewPage, bQuery)) { return m_pCurPageArea; @@ -1406,7 +1412,8 @@ bool CXFA_LayoutPageMgr::GetNextContentArea(CXFA_Node* pContentArea) { } if (pContentAreaLayout) { if (pContentAreaLayout->GetFormNode() != pCurContentNode) { - CXFA_ContainerRecord* pNewRecord = CreateContainerRecord(); + CXFA_ContainerRecord* pNewRecord = + CreateContainerRecord(nullptr, false); pNewRecord->pCurContentArea = pContentAreaLayout; return true; } @@ -1414,7 +1421,7 @@ bool CXFA_LayoutPageMgr::GetNextContentArea(CXFA_Node* pContentArea) { } } - CXFA_ContainerRecord* pNewRecord = CreateContainerRecord(); + CXFA_ContainerRecord* pNewRecord = CreateContainerRecord(nullptr, false); AddContentAreaLayoutItem(pNewRecord, pContentArea); return true; } @@ -1464,7 +1471,7 @@ int32_t CXFA_LayoutPageMgr::CreateMinPageRecord(CXFA_Node* pPageArea, i = m_nCurPageCount; for (; i < iMin; i++) { - CXFA_ContainerRecord* pNewRecord = CreateContainerRecord(); + CXFA_ContainerRecord* pNewRecord = CreateContainerRecord(nullptr, false); AddPageAreaLayoutItem(pNewRecord, pPageArea); AddContentAreaLayoutItem(pNewRecord, pContentArea); } @@ -1498,7 +1505,7 @@ void CXFA_LayoutPageMgr::CreateMinPageSetRecord(CXFA_Node* pPageSet, for (CXFA_Node* node = pPageSet->GetFirstChild(); node; node = node->GetNextSibling()) { if (node->GetElementType() == XFA_Element::PageArea) - CreateMinPageRecord(node, false); + CreateMinPageRecord(node, false, false); else if (node->GetElementType() == XFA_Element::PageSet) CreateMinPageSetRecord(node, true); } @@ -1513,7 +1520,7 @@ void CXFA_LayoutPageMgr::CreateNextMinRecord(CXFA_Node* pRecordNode) { for (CXFA_Node* pCurrentNode = pRecordNode->GetNextSibling(); pCurrentNode; pCurrentNode = pCurrentNode->GetNextSibling()) { if (pCurrentNode->GetElementType() == XFA_Element::PageArea) - CreateMinPageRecord(pCurrentNode, false); + CreateMinPageRecord(pCurrentNode, false, false); else if (pCurrentNode->GetElementType() == XFA_Element::PageSet) CreateMinPageSetRecord(pCurrentNode, true); } @@ -1524,7 +1531,7 @@ void CXFA_LayoutPageMgr::ProcessLastPageSet() { CreateNextMinRecord(m_pCurPageArea); CXFA_Node* pPageSet = m_pCurPageArea->GetParent(); while (true) { - CreateMinPageSetRecord(pPageSet); + CreateMinPageSetRecord(pPageSet, false); if (pPageSet == m_pTemplatePageSetRoot) break; diff --git a/xfa/fxfa/parser/cxfa_layoutpagemgr.h b/xfa/fxfa/parser/cxfa_layoutpagemgr.h index 7c9055dcf8..6acd5b4aff 100644 --- a/xfa/fxfa/parser/cxfa_layoutpagemgr.h +++ b/xfa/fxfa/parser/cxfa_layoutpagemgr.h @@ -53,7 +53,7 @@ class CXFA_LayoutPageMgr { CXFA_Node*& pBookendAppendNode); private: - bool AppendNewPage(bool bFirstTemPage = false); + bool AppendNewPage(bool bFirstTemPage); void ReorderPendingLayoutRecordToTail(CXFA_ContainerRecord* pNewRecord, CXFA_ContainerRecord* pPrevRecord); void RemoveLayoutRecord(CXFA_ContainerRecord* pNewRecord, @@ -65,8 +65,8 @@ class CXFA_LayoutPageMgr { auto iter = m_ProposedContainerRecords.end(); return !m_ProposedContainerRecords.empty() ? std::prev(iter) : iter; } - CXFA_ContainerRecord* CreateContainerRecord(CXFA_Node* pPageNode = nullptr, - bool bCreateNew = false); + CXFA_ContainerRecord* CreateContainerRecord(CXFA_Node* pPageNode, + bool bCreateNew); void AddPageAreaLayoutItem(CXFA_ContainerRecord* pNewRecord, CXFA_Node* pNewPageArea); void AddContentAreaLayoutItem(CXFA_ContainerRecord* pNewRecord, @@ -89,8 +89,8 @@ class CXFA_LayoutPageMgr { int32_t CreateMinPageRecord(CXFA_Node* pPageArea, bool bTargetPageArea, - bool bCreateLast = false); - void CreateMinPageSetRecord(CXFA_Node* pPageSet, bool bCreateAll = false); + bool bCreateLast); + void CreateMinPageSetRecord(CXFA_Node* pPageSet, bool bCreateAll); void CreateNextMinRecord(CXFA_Node* pRecordNode); bool FindPageAreaFromPageSet(CXFA_Node* pPageSet, CXFA_Node* pStartChild, @@ -114,9 +114,9 @@ class CXFA_LayoutPageMgr { XFA_AttributeEnum ePreferredPosition = XFA_AttributeEnum::First); bool MatchPageAreaOddOrEven(CXFA_Node* pPageArea); CXFA_Node* GetNextAvailPageArea(CXFA_Node* pTargetPageArea, - CXFA_Node* pTargetContentArea = nullptr, - bool bNewPage = false, - bool bQuery = false); + CXFA_Node* pTargetContentArea, + bool bNewPage, + bool bQuery); bool GetNextContentArea(CXFA_Node* pTargetContentArea); void InitPageSetMap(); void ProcessLastPageSet(); -- cgit v1.2.3