summaryrefslogtreecommitdiff
path: root/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fxfa/parser/cxfa_layoutpagemgr.cpp')
-rw-r--r--xfa/fxfa/parser/cxfa_layoutpagemgr.cpp32
1 files changed, 12 insertions, 20 deletions
diff --git a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp
index e301825735..72f5594982 100644
--- a/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp
+++ b/xfa/fxfa/parser/cxfa_layoutpagemgr.cpp
@@ -645,9 +645,8 @@ void CXFA_LayoutPageMgr::FinishPaginatedPageSets() {
XFA_ATTRIBUTEENUM eCurChoice =
pNode->JSNode()->GetEnum(XFA_Attribute::PagePosition);
if (eCurChoice == XFA_ATTRIBUTEENUM_Last) {
- XFA_ATTRIBUTEENUM eOddOrEven = XFA_ATTRIBUTEENUM_Any;
- pNode->JSNode()->TryEnum(XFA_Attribute::OddOrEven, eOddOrEven,
- true);
+ XFA_ATTRIBUTEENUM eOddOrEven =
+ pNode->JSNode()->GetEnum(XFA_Attribute::OddOrEven);
XFA_ATTRIBUTEENUM eLastChoice =
pLastPageAreaLayoutItem->m_pFormNode->JSNode()->GetEnum(
XFA_Attribute::PagePosition);
@@ -1216,7 +1215,7 @@ bool CXFA_LayoutPageMgr::FindPageAreaFromPageSet_SimplexDuplex(
for (; pCurrentNode;
pCurrentNode = pCurrentNode->GetNodeItem(XFA_NODEITEM_NextSibling)) {
if (pCurrentNode->GetElementType() == XFA_Element::PageArea) {
- if (!MatchPageAreaOddOrEven(pCurrentNode, false))
+ if (!MatchPageAreaOddOrEven(pCurrentNode))
continue;
XFA_ATTRIBUTEENUM eCurPagePosition =
@@ -1266,8 +1265,7 @@ bool CXFA_LayoutPageMgr::FindPageAreaFromPageSet_SimplexDuplex(
!pFallbackPageArea) {
pFallbackPageArea = pCurrentNode;
}
- } else if (pTargetPageArea &&
- !MatchPageAreaOddOrEven(pTargetPageArea, false)) {
+ } else if (pTargetPageArea && !MatchPageAreaOddOrEven(pTargetPageArea)) {
CXFA_ContainerRecord* pNewRecord = CreateContainerRecord();
AddPageAreaLayoutItem(pNewRecord, pCurrentNode);
AddContentAreaLayoutItem(pNewRecord, pCurrentNode->GetFirstChildByClass(
@@ -1304,23 +1302,17 @@ bool CXFA_LayoutPageMgr::FindPageAreaFromPageSet_SimplexDuplex(
return true;
}
-bool CXFA_LayoutPageMgr::MatchPageAreaOddOrEven(CXFA_Node* pPageArea,
- bool bLastMatch) {
+bool CXFA_LayoutPageMgr::MatchPageAreaOddOrEven(CXFA_Node* pPageArea) {
if (m_ePageSetMode != XFA_ATTRIBUTEENUM_DuplexPaginated)
return true;
- XFA_ATTRIBUTEENUM eOddOrEven = XFA_ATTRIBUTEENUM_Any;
- pPageArea->JSNode()->TryEnum(XFA_Attribute::OddOrEven, eOddOrEven, true);
- if (eOddOrEven != XFA_ATTRIBUTEENUM_Any) {
- int32_t iPageCount = GetPageCount();
- if (bLastMatch) {
- return eOddOrEven == XFA_ATTRIBUTEENUM_Odd ? iPageCount % 2 == 1
- : iPageCount % 2 == 0;
- }
- return eOddOrEven == XFA_ATTRIBUTEENUM_Odd ? iPageCount % 2 == 0
- : iPageCount % 2 == 1;
- }
- return true;
+ pdfium::Optional<XFA_ATTRIBUTEENUM> ret =
+ pPageArea->JSNode()->TryEnum(XFA_Attribute::OddOrEven, true);
+ if (!ret || *ret == XFA_ATTRIBUTEENUM_Any)
+ return true;
+
+ int32_t iPageLast = GetPageCount() % 2;
+ return *ret == XFA_ATTRIBUTEENUM_Odd ? iPageLast == 0 : iPageLast == 1;
}
CXFA_Node* CXFA_LayoutPageMgr::GetNextAvailPageArea(