diff options
author | dsinclair <dsinclair@chromium.org> | 2016-05-17 10:32:18 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-05-17 10:32:19 -0700 |
commit | 935d8d5dcbf1da2b3198675428cbf7ca0406788f (patch) | |
tree | 9fc8595b3b169a1b7a5f9e9ead95f41be879fc67 /xfa | |
parent | 59ce240d509a3079dab64f891a5363b11d4de3c7 (diff) | |
download | pdfium-935d8d5dcbf1da2b3198675428cbf7ca0406788f.tar.xz |
XFA_WIDGETSTATUS cleanup.
This CL moves all of the XFA_WIDGETSTATUS values into a single enum instead
of multiple defines. The values are also normalized.
The name was updated to be XFA_WidgetStatus.
The XFA_WIDGETFILTER and XFA_LAYOUTSTATUS defines had to
match up to XFA_WIDGETSTATUS. This Cl replaces those so
we just have a single enum to work with.
Review-Url: https://codereview.chromium.org/1986503002
Diffstat (limited to 'xfa')
-rw-r--r-- | xfa/fxfa/app/xfa_ffdocview.cpp | 10 | ||||
-rw-r--r-- | xfa/fxfa/app/xfa_fffield.cpp | 8 | ||||
-rw-r--r-- | xfa/fxfa/app/xfa_ffnotify.cpp | 10 | ||||
-rw-r--r-- | xfa/fxfa/app/xfa_ffpageview.cpp | 66 | ||||
-rw-r--r-- | xfa/fxfa/app/xfa_fftextedit.cpp | 18 | ||||
-rw-r--r-- | xfa/fxfa/app/xfa_ffwidget.cpp | 28 | ||||
-rw-r--r-- | xfa/fxfa/app/xfa_ffwidgethandler.cpp | 4 | ||||
-rw-r--r-- | xfa/fxfa/app/xfa_rendercontext.cpp | 10 | ||||
-rw-r--r-- | xfa/fxfa/include/fxfa.h | 27 | ||||
-rw-r--r-- | xfa/fxfa/include/xfa_ffpageview.h | 5 | ||||
-rw-r--r-- | xfa/fxfa/parser/xfa_doclayout.h | 7 | ||||
-rw-r--r-- | xfa/fxfa/parser/xfa_document.h | 4 | ||||
-rw-r--r-- | xfa/fxfa/parser/xfa_layout_appadapter.cpp | 20 | ||||
-rw-r--r-- | xfa/fxfa/parser/xfa_layout_appadapter.h | 2 | ||||
-rw-r--r-- | xfa/fxfa/parser/xfa_layout_pagemgr_new.cpp | 457 |
15 files changed, 335 insertions, 341 deletions
diff --git a/xfa/fxfa/app/xfa_ffdocview.cpp b/xfa/fxfa/app/xfa_ffdocview.cpp index 4a610495dd..faf5c8baff 100644 --- a/xfa/fxfa/app/xfa_ffdocview.cpp +++ b/xfa/fxfa/app/xfa_ffdocview.cpp @@ -329,7 +329,7 @@ CXFA_FFWidget* CXFA_FFDocView::GetFocusWidget() { } void CXFA_FFDocView::KillFocus() { if (m_pFocusWidget && - (m_pFocusWidget->GetStatus() & XFA_WIDGETSTATUS_Focused)) { + (m_pFocusWidget->GetStatus() & XFA_WidgetStatus_Focused)) { (m_pFocusWidget)->OnKillFocus(NULL); } m_pFocusAcc = NULL; @@ -345,10 +345,10 @@ FX_BOOL CXFA_FFDocView::SetFocus(CXFA_FFWidget* hWidget) { m_pOldFocusWidget = pNewFocus; if (pOldFocus) { if (m_pFocusWidget != m_pOldFocusWidget && - (pOldFocus->GetStatus() & XFA_WIDGETSTATUS_Focused)) { + (pOldFocus->GetStatus() & XFA_WidgetStatus_Focused)) { m_pFocusWidget = pOldFocus; pOldFocus->OnKillFocus(pNewFocus); - } else if ((pOldFocus->GetStatus() & XFA_WIDGETSTATUS_Visible)) { + } else if ((pOldFocus->GetStatus() & XFA_WidgetStatus_Visible)) { if (!pOldFocus->IsLoaded()) { pOldFocus->LoadWidget(); } @@ -368,7 +368,7 @@ FX_BOOL CXFA_FFDocView::SetFocus(CXFA_FFWidget* hWidget) { m_pOldFocusWidget = NULL; return FALSE; } - if (pNewFocus && (pNewFocus->GetStatus() & XFA_WIDGETSTATUS_Visible)) { + if (pNewFocus && (pNewFocus->GetStatus() & XFA_WidgetStatus_Visible)) { if (!pNewFocus->IsLoaded()) { pNewFocus->LoadWidget(); } @@ -844,7 +844,7 @@ CXFA_FFWidget* CXFA_FFDocWidgetIterator::MoveToNext() { if (CXFA_WidgetAcc* pAcc = (CXFA_WidgetAcc*)pItem->GetWidgetData()) { while ((m_pCurWidget = pAcc->GetNextWidget(NULL))) { if (!m_pCurWidget->IsLoaded() && - (m_pCurWidget->GetStatus() & XFA_WIDGETSTATUS_Visible)) { + (m_pCurWidget->GetStatus() & XFA_WidgetStatus_Visible)) { m_pCurWidget->LoadWidget(); } return m_pCurWidget; diff --git a/xfa/fxfa/app/xfa_fffield.cpp b/xfa/fxfa/app/xfa_fffield.cpp index 7cf0c6e3fc..5b70caa924 100644 --- a/xfa/fxfa/app/xfa_fffield.cpp +++ b/xfa/fxfa/app/xfa_fffield.cpp @@ -81,7 +81,7 @@ void CXFA_FFField::DrawHighlight(CFX_Graphics* pGS, if (m_rtUI.IsEmpty() || !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { return; } - if ((dwStatus & XFA_WIDGETSTATUS_Highlight) && + if ((dwStatus & XFA_WidgetStatus_Highlight) && m_pDataAcc->GetAccess() == XFA_ATTRIBUTEENUM_Open) { CXFA_FFDoc* pDoc = GetDoc(); CFX_Color crHighlight(pDoc->GetDocProvider()->GetHighlightColor(pDoc)); @@ -97,7 +97,7 @@ void CXFA_FFField::DrawHighlight(CFX_Graphics* pGS, } } void CXFA_FFField::DrawFocus(CFX_Graphics* pGS, CFX_Matrix* pMatrix) { - if (m_dwStatus & XFA_WIDGETSTATUS_Focused) { + if (m_dwStatus & XFA_WidgetStatus_Focused) { CFX_Color cr(0xFF000000); pGS->SetStrokeColor(&cr); FX_FLOAT DashPattern[2] = {1, 1}; @@ -533,7 +533,7 @@ FX_BOOL CXFA_FFField::OnSetFocus(CXFA_FFWidget* pOldWidget) { ms.m_pDstTarget = m_pNormalWidget->m_pIface; ms.m_pSrcTarget = NULL; TranslateFWLMessage(&ms); - m_dwStatus |= XFA_WIDGETSTATUS_Focused; + m_dwStatus |= XFA_WidgetStatus_Focused; AddInvalidateRect(); return TRUE; } @@ -545,7 +545,7 @@ FX_BOOL CXFA_FFField::OnKillFocus(CXFA_FFWidget* pNewWidget) { ms.m_pDstTarget = m_pNormalWidget->m_pIface; ms.m_pSrcTarget = NULL; TranslateFWLMessage(&ms); - m_dwStatus &= ~XFA_WIDGETSTATUS_Focused; + m_dwStatus &= ~XFA_WidgetStatus_Focused; AddInvalidateRect(); CXFA_FFWidget::OnKillFocus(pNewWidget); return TRUE; diff --git a/xfa/fxfa/app/xfa_ffnotify.cpp b/xfa/fxfa/app/xfa_ffnotify.cpp index a28888e7d8..4d7d4799f2 100644 --- a/xfa/fxfa/app/xfa_ffnotify.cpp +++ b/xfa/fxfa/app/xfa_ffnotify.cpp @@ -473,18 +473,18 @@ void CXFA_FFNotify::OnLayoutItemAdded(CXFA_LayoutProcessor* pLayout, return; CXFA_FFPageView* pNewPageView = pDocView->GetPageView(iPageIdx); - uint32_t dwFilter = XFA_WIDGETSTATUS_Visible | XFA_WIDGETSTATUS_Viewable | - XFA_WIDGETSTATUS_Printable; + uint32_t dwFilter = XFA_WidgetStatus_Visible | XFA_WidgetStatus_Viewable | + XFA_WidgetStatus_Printable; pWidget->ModifyStatus(dwStatus, dwFilter); CXFA_FFPageView* pPrePageView = pWidget->GetPageView(); if (pPrePageView != pNewPageView || - (dwStatus & (XFA_WIDGETSTATUS_Visible | XFA_WIDGETSTATUS_Viewable)) == - (XFA_WIDGETSTATUS_Visible | XFA_WIDGETSTATUS_Viewable)) { + (dwStatus & (XFA_WidgetStatus_Visible | XFA_WidgetStatus_Viewable)) == + (XFA_WidgetStatus_Visible | XFA_WidgetStatus_Viewable)) { pWidget->SetPageView(pNewPageView); m_pDoc->GetDocProvider()->WidgetPostAdd(pWidget, pWidget->GetDataAcc()); } if (pDocView->GetLayoutStatus() != XFA_DOCVIEW_LAYOUTSTATUS_End || - !(dwStatus & XFA_WIDGETSTATUS_Visible)) { + !(dwStatus & XFA_WidgetStatus_Visible)) { return; } if (pWidget->IsLoaded()) { diff --git a/xfa/fxfa/app/xfa_ffpageview.cpp b/xfa/fxfa/app/xfa_ffpageview.cpp index e5a05734dc..16461eb07c 100644 --- a/xfa/fxfa/app/xfa_ffpageview.cpp +++ b/xfa/fxfa/app/xfa_ffpageview.cpp @@ -69,7 +69,30 @@ void GetPageMatrix(CFX_Matrix& pageMatrix, pageMatrix = m; } +bool PageWidgetFilter(CXFA_FFWidget* pWidget, + uint32_t dwFilter, + FX_BOOL bTraversal, + FX_BOOL bIgnorerelevant) { + CXFA_WidgetAcc* pWidgetAcc = pWidget->GetDataAcc(); + + if (!!(dwFilter & XFA_WidgetStatus_Focused) && + pWidgetAcc->GetClassID() != XFA_ELEMENT_Field) { + return false; + } + + uint32_t dwStatus = pWidget->GetStatus(); + if (bTraversal && (dwStatus & XFA_WidgetStatus_Disabled)) + return false; + if (bIgnorerelevant) + return !!(dwStatus & XFA_WidgetStatus_Visible); + + dwFilter &= (XFA_WidgetStatus_Visible | XFA_WidgetStatus_Viewable | + XFA_WidgetStatus_Printable); + return (dwFilter & dwStatus) == dwFilter; +} + } // namespace + CXFA_FFPageView::CXFA_FFPageView(CXFA_FFDocView* pDocView, CXFA_Node* pPageArea) : CXFA_ContainerLayoutItem(pPageArea), m_pDocView(pDocView) {} @@ -110,27 +133,6 @@ IXFA_WidgetIterator* CXFA_FFPageView::CreateWidgetIterator( return nullptr; } -static FX_BOOL XFA_PageWidgetFilter(CXFA_FFWidget* pWidget, - uint32_t dwFilter, - FX_BOOL bTraversal, - FX_BOOL bIgnorerelevant) { - CXFA_WidgetAcc* pWidgetAcc = pWidget->GetDataAcc(); - uint32_t dwType = dwFilter & XFA_WIDGETFILTER_AllType; - if ((dwType == XFA_WIDGETFILTER_Field) && - (pWidgetAcc->GetClassID() != XFA_ELEMENT_Field)) { - return FALSE; - } - uint32_t dwStatus = pWidget->GetStatus(); - if (bTraversal && (dwStatus & XFA_WIDGETSTATUS_Disabled)) { - return FALSE; - } - if (bIgnorerelevant) { - return (dwStatus & XFA_WIDGETFILTER_Visible) != 0; - } - dwFilter &= (XFA_WIDGETFILTER_Visible | XFA_WIDGETFILTER_Viewable | - XFA_WIDGETFILTER_Printable); - return (dwFilter & dwStatus) == dwFilter; -} CXFA_FFPageWidgetIterator::CXFA_FFPageWidgetIterator(CXFA_FFPageView* pPageView, uint32_t dwFilter) { m_pPageView = pPageView; @@ -186,11 +188,11 @@ FX_BOOL CXFA_FFPageWidgetIterator::SetCurrentWidget(CXFA_FFWidget* hWidget) { CXFA_FFWidget* CXFA_FFPageWidgetIterator::GetWidget( CXFA_LayoutItem* pLayoutItem) { if (CXFA_FFWidget* pWidget = XFA_GetWidgetFromLayoutItem(pLayoutItem)) { - if (!XFA_PageWidgetFilter(pWidget, m_dwFilter, FALSE, m_bIgnorerelevant)) { + if (!PageWidgetFilter(pWidget, m_dwFilter, FALSE, m_bIgnorerelevant)) { return NULL; } if (!pWidget->IsLoaded() && - (pWidget->GetStatus() & XFA_WIDGETSTATUS_Visible) != 0) { + (pWidget->GetStatus() & XFA_WidgetStatus_Visible) != 0) { pWidget->LoadWidget(); } return pWidget; @@ -217,8 +219,8 @@ void CXFA_FFTabOrderPageWidgetIterator::Reset() { CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::MoveToFirst() { if (m_TabOrderWidgetArray.GetSize() > 0) { for (int32_t i = 0; i < m_TabOrderWidgetArray.GetSize(); i++) { - if (XFA_PageWidgetFilter(m_TabOrderWidgetArray[i], m_dwFilter, TRUE, - m_bIgnorerelevant)) { + if (PageWidgetFilter(m_TabOrderWidgetArray[i], m_dwFilter, TRUE, + m_bIgnorerelevant)) { m_iCurWidget = i; return m_TabOrderWidgetArray[m_iCurWidget]; } @@ -229,8 +231,8 @@ CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::MoveToFirst() { CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::MoveToLast() { if (m_TabOrderWidgetArray.GetSize() > 0) { for (int32_t i = m_TabOrderWidgetArray.GetSize() - 1; i >= 0; i--) { - if (XFA_PageWidgetFilter(m_TabOrderWidgetArray[i], m_dwFilter, TRUE, - m_bIgnorerelevant)) { + if (PageWidgetFilter(m_TabOrderWidgetArray[i], m_dwFilter, TRUE, + m_bIgnorerelevant)) { m_iCurWidget = i; return m_TabOrderWidgetArray[m_iCurWidget]; } @@ -240,8 +242,8 @@ CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::MoveToLast() { } CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::MoveToNext() { for (int32_t i = m_iCurWidget + 1; i < m_TabOrderWidgetArray.GetSize(); i++) { - if (XFA_PageWidgetFilter(m_TabOrderWidgetArray[i], m_dwFilter, TRUE, - m_bIgnorerelevant)) { + if (PageWidgetFilter(m_TabOrderWidgetArray[i], m_dwFilter, TRUE, + m_bIgnorerelevant)) { m_iCurWidget = i; return m_TabOrderWidgetArray[m_iCurWidget]; } @@ -251,8 +253,8 @@ CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::MoveToNext() { } CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::MoveToPrevious() { for (int32_t i = m_iCurWidget - 1; i >= 0; i--) { - if (XFA_PageWidgetFilter(m_TabOrderWidgetArray[i], m_dwFilter, TRUE, - m_bIgnorerelevant)) { + if (PageWidgetFilter(m_TabOrderWidgetArray[i], m_dwFilter, TRUE, + m_bIgnorerelevant)) { m_iCurWidget = i; return m_TabOrderWidgetArray[m_iCurWidget]; } @@ -427,7 +429,7 @@ CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::GetWidget( CXFA_LayoutItem* pLayoutItem) { if (CXFA_FFWidget* pWidget = XFA_GetWidgetFromLayoutItem(pLayoutItem)) { if (!pWidget->IsLoaded() && - (pWidget->GetStatus() & XFA_WIDGETSTATUS_Visible)) { + (pWidget->GetStatus() & XFA_WidgetStatus_Visible)) { pWidget->LoadWidget(); } return pWidget; diff --git a/xfa/fxfa/app/xfa_fftextedit.cpp b/xfa/fxfa/app/xfa_fftextedit.cpp index ea641f2066..89c9d356bd 100644 --- a/xfa/fxfa/app/xfa_fftextedit.cpp +++ b/xfa/fxfa/app/xfa_fftextedit.cpp @@ -101,7 +101,7 @@ FX_BOOL CXFA_FFTextEdit::OnLButtonDown(uint32_t dwFlags, return FALSE; } if (!IsFocused()) { - m_dwStatus |= XFA_WIDGETSTATUS_Focused; + m_dwStatus |= XFA_WidgetStatus_Focused; UpdateFWLData(); AddInvalidateRect(); } @@ -126,7 +126,7 @@ FX_BOOL CXFA_FFTextEdit::OnRButtonDown(uint32_t dwFlags, return FALSE; } if (!IsFocused()) { - m_dwStatus |= XFA_WIDGETSTATUS_Focused; + m_dwStatus |= XFA_WidgetStatus_Focused; UpdateFWLData(); AddInvalidateRect(); } @@ -150,9 +150,9 @@ FX_BOOL CXFA_FFTextEdit::OnRButtonUp(uint32_t dwFlags, return TRUE; } FX_BOOL CXFA_FFTextEdit::OnSetFocus(CXFA_FFWidget* pOldWidget) { - m_dwStatus &= ~XFA_WIDGETSTATUS_TextEditValueChanged; + m_dwStatus &= ~XFA_WidgetStatus_TextEditValueChanged; if (!IsFocused()) { - m_dwStatus |= XFA_WIDGETSTATUS_Focused; + m_dwStatus |= XFA_WidgetStatus_Focused; UpdateFWLData(); AddInvalidateRect(); } @@ -168,13 +168,13 @@ FX_BOOL CXFA_FFTextEdit::OnKillFocus(CXFA_FFWidget* pNewWidget) { ms.m_pDstTarget = m_pNormalWidget->m_pIface; ms.m_pSrcTarget = NULL; TranslateFWLMessage(&ms); - m_dwStatus &= ~XFA_WIDGETSTATUS_Focused; + m_dwStatus &= ~XFA_WidgetStatus_Focused; SetEditScrollOffset(); ProcessCommittedData(); UpdateFWLData(); AddInvalidateRect(); CXFA_FFWidget::OnKillFocus(pNewWidget); - m_dwStatus &= ~XFA_WIDGETSTATUS_TextEditValueChanged; + m_dwStatus &= ~XFA_WidgetStatus_TextEditValueChanged; return TRUE; } FX_BOOL CXFA_FFTextEdit::CommitData() { @@ -205,7 +205,7 @@ void CXFA_FFTextEdit::ValidateNumberField(const CFX_WideString& wsText) { } } FX_BOOL CXFA_FFTextEdit::IsDataChanged() { - return (m_dwStatus & XFA_WIDGETSTATUS_TextEditValueChanged) != 0; + return (m_dwStatus & XFA_WidgetStatus_TextEditValueChanged) != 0; } uint32_t CXFA_FFTextEdit::GetAlignment() { uint32_t dwExtendedStyle = 0; @@ -356,7 +356,7 @@ FX_BOOL CXFA_FFTextEdit::ReplaceSpellCheckWord( void CXFA_FFTextEdit::OnTextChanged(IFWL_Widget* pWidget, const CFX_WideString& wsChanged, const CFX_WideString& wsPrevText) { - m_dwStatus |= XFA_WIDGETSTATUS_TextEditValueChanged; + m_dwStatus |= XFA_WidgetStatus_TextEditValueChanged; CXFA_EventParam eParam; eParam.m_eType = XFA_EVENT_Change; eParam.m_wsChange = wsChanged; @@ -712,7 +712,7 @@ FX_BOOL CXFA_FFDateTimeEdit::UpdateFWLData() { return TRUE; } FX_BOOL CXFA_FFDateTimeEdit::IsDataChanged() { - if (m_dwStatus & XFA_WIDGETSTATUS_TextEditValueChanged) { + if (m_dwStatus & XFA_WidgetStatus_TextEditValueChanged) { return TRUE; } CFX_WideString wsText; diff --git a/xfa/fxfa/app/xfa_ffwidget.cpp b/xfa/fxfa/app/xfa_ffwidget.cpp index 5f141e4e84..3af84a6bbe 100644 --- a/xfa/fxfa/app/xfa_ffwidget.cpp +++ b/xfa/fxfa/app/xfa_ffwidget.cpp @@ -39,14 +39,14 @@ void CXFA_FFWidget::SetPageView(CXFA_FFPageView* pPageView) { m_pPageView = pPageView; } void CXFA_FFWidget::GetWidgetRect(CFX_RectF& rtWidget) { - if ((m_dwStatus & XFA_WIDGETSTATUS_RectCached) == 0) { - m_dwStatus |= XFA_WIDGETSTATUS_RectCached; + if ((m_dwStatus & XFA_WidgetStatus_RectCached) == 0) { + m_dwStatus |= XFA_WidgetStatus_RectCached; GetRect(m_rtWidget); } rtWidget = m_rtWidget; } CFX_RectF CXFA_FFWidget::ReCacheWidgetRect() { - m_dwStatus |= XFA_WIDGETSTATUS_RectCached; + m_dwStatus |= XFA_WidgetStatus_RectCached; GetRect(m_rtWidget); return m_rtWidget; } @@ -146,7 +146,7 @@ void CXFA_FFWidget::DrawBorder(CFX_Graphics* pGS, void CXFA_FFWidget::InvalidateWidget(const CFX_RectF* pRect) { if (!pRect) { CFX_RectF rtWidget; - GetBBox(rtWidget, XFA_WIDGETSTATUS_Focused); + GetBBox(rtWidget, XFA_WidgetStatus_Focused); rtWidget.Inflate(2, 2); GetDoc()->GetDocProvider()->InvalidateRect(m_pPageView, rtWidget, XFA_INVALIDATE_CurrentPage); @@ -160,7 +160,7 @@ void CXFA_FFWidget::AddInvalidateRect(const CFX_RectF* pRect) { if (pRect) { rtWidget = *pRect; } else { - GetBBox(rtWidget, XFA_WIDGETSTATUS_Focused); + GetBBox(rtWidget, XFA_WidgetStatus_Focused); rtWidget.Inflate(2, 2); } m_pDocView->AddInvalidateRect(m_pPageView, rtWidget); @@ -175,7 +175,7 @@ FX_BOOL CXFA_FFWidget::GetCaptionText(CFX_WideString& wsCap) { } bool CXFA_FFWidget::IsFocused() { - return !!(m_dwStatus & XFA_WIDGETSTATUS_Focused); + return !!(m_dwStatus & XFA_WidgetStatus_Focused); } FX_BOOL CXFA_FFWidget::OnMouseEnter() { @@ -225,7 +225,7 @@ FX_BOOL CXFA_FFWidget::OnSetFocus(CXFA_FFWidget* pOldWidget) { if (pParent && !pParent->IsAncestorOf(pOldWidget)) { pParent->OnSetFocus(pOldWidget); } - m_dwStatus |= XFA_WIDGETSTATUS_Focused; + m_dwStatus |= XFA_WidgetStatus_Focused; CXFA_EventParam eParam; eParam.m_eType = XFA_EVENT_Enter; eParam.m_pTarget = m_pDataAcc; @@ -233,7 +233,7 @@ FX_BOOL CXFA_FFWidget::OnSetFocus(CXFA_FFWidget* pOldWidget) { return TRUE; } FX_BOOL CXFA_FFWidget::OnKillFocus(CXFA_FFWidget* pNewWidget) { - m_dwStatus &= ~XFA_WIDGETSTATUS_Focused; + m_dwStatus &= ~XFA_WidgetStatus_Focused; EventKillFocus(); if (pNewWidget) { CXFA_FFWidget* pParent = GetParent(); @@ -405,12 +405,12 @@ void CXFA_FFWidget::GetMinMaxHeight(FX_FLOAT fMinHeight, FX_FLOAT fMaxHeight) { } bool CXFA_FFWidget::IsMatchVisibleStatus(uint32_t dwStatus) { - return !!(m_dwStatus & XFA_WIDGETSTATUS_Visible); + return !!(m_dwStatus & XFA_WidgetStatus_Visible); } void CXFA_FFWidget::EventKillFocus() { - if (m_dwStatus & XFA_WIDGETSTATUS_Access) { - m_dwStatus &= ~XFA_WIDGETSTATUS_Access; + if (m_dwStatus & XFA_WidgetStatus_Access) { + m_dwStatus &= ~XFA_WidgetStatus_Access; return; } CXFA_EventParam eParam; @@ -419,11 +419,11 @@ void CXFA_FFWidget::EventKillFocus() { m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Exit, &eParam); } FX_BOOL CXFA_FFWidget::IsButtonDown() { - return (m_dwStatus & XFA_WIDGETSTATUS_ButtonDown) != 0; + return (m_dwStatus & XFA_WidgetStatus_ButtonDown) != 0; } void CXFA_FFWidget::SetButtonDown(FX_BOOL bSet) { - bSet ? m_dwStatus |= XFA_WIDGETSTATUS_ButtonDown - : m_dwStatus &= ~XFA_WIDGETSTATUS_ButtonDown; + bSet ? m_dwStatus |= XFA_WidgetStatus_ButtonDown + : m_dwStatus &= ~XFA_WidgetStatus_ButtonDown; } int32_t XFA_StrokeTypeSetLineDash(CFX_Graphics* pGraphics, int32_t iStrokeType, diff --git a/xfa/fxfa/app/xfa_ffwidgethandler.cpp b/xfa/fxfa/app/xfa_ffwidgethandler.cpp index 13cee333a5..027c3d9fa8 100644 --- a/xfa/fxfa/app/xfa_ffwidgethandler.cpp +++ b/xfa/fxfa/app/xfa_ffwidgethandler.cpp @@ -163,7 +163,7 @@ FX_BOOL CXFA_FFWidgetHandler::OnChar(CXFA_FFWidget* hWidget, FWL_WidgetHit CXFA_FFWidgetHandler::OnHitTest(CXFA_FFWidget* hWidget, FX_FLOAT fx, FX_FLOAT fy) { - if (!(hWidget->GetStatus() & XFA_WIDGETSTATUS_Visible)) + if (!(hWidget->GetStatus() & XFA_WidgetStatus_Visible)) return FWL_WidgetHit::Unknown; hWidget->Rotate2Normal(fx, fy); @@ -182,7 +182,7 @@ void CXFA_FFWidgetHandler::RenderWidget(CXFA_FFWidget* hWidget, CFX_Matrix* pMatrix, FX_BOOL bHighlight) { hWidget->RenderWidget(pGS, pMatrix, - bHighlight ? XFA_WIDGETSTATUS_Highlight : 0, 0); + bHighlight ? XFA_WidgetStatus_Highlight : 0, 0); } FX_BOOL CXFA_FFWidgetHandler::HasEvent(CXFA_WidgetAcc* pWidgetAcc, diff --git a/xfa/fxfa/app/xfa_rendercontext.cpp b/xfa/fxfa/app/xfa_rendercontext.cpp index e7bacec281..7bfd9630cb 100644 --- a/xfa/fxfa/app/xfa_rendercontext.cpp +++ b/xfa/fxfa/app/xfa_rendercontext.cpp @@ -38,10 +38,10 @@ int32_t CXFA_RenderContext::StartRender(CXFA_FFPageView* pPageView, mtRes.SetReverse(matrix); m_rtClipRect.Set(rtPage.left, rtPage.top, rtPage.width, rtPage.height); mtRes.TransformRect(m_rtClipRect); - m_dwStatus = m_options.m_bHighlight ? XFA_WIDGETSTATUS_Highlight : 0; - uint32_t dwFilterType = XFA_WIDGETFILTER_Visible | XFA_WIDGETFILTER_AllType | - (m_options.m_bPrint ? XFA_WIDGETSTATUS_Printable - : XFA_WIDGETSTATUS_Viewable); + m_dwStatus = m_options.m_bHighlight ? XFA_WidgetStatus_Highlight : 0; + uint32_t dwFilterType = XFA_WidgetStatus_Visible | + (m_options.m_bPrint ? XFA_WidgetStatus_Printable + : XFA_WidgetStatus_Viewable); m_pWidgetIterator = m_pPageView->CreateWidgetIterator(XFA_TRAVERSEWAY_Form, dwFilterType); m_pWidget = m_pWidgetIterator->MoveToNext(); @@ -52,7 +52,7 @@ int32_t CXFA_RenderContext::DoRender(IFX_Pause* pPause) { while (m_pWidget) { CXFA_FFWidget* pWidget = (CXFA_FFWidget*)m_pWidget; CFX_RectF rtWidgetBox; - pWidget->GetBBox(rtWidgetBox, XFA_WIDGETSTATUS_Visible); + pWidget->GetBBox(rtWidgetBox, XFA_WidgetStatus_Visible); rtWidgetBox.width += 1; rtWidgetBox.height += 1; if (rtWidgetBox.IntersectWith(m_rtClipRect)) { diff --git a/xfa/fxfa/include/fxfa.h b/xfa/fxfa/include/fxfa.h index 582702220f..f7f4a04166 100644 --- a/xfa/fxfa/include/fxfa.h +++ b/xfa/fxfa/include/fxfa.h @@ -177,18 +177,21 @@ class IXFA_WidgetIterator; #define XFA_TRAVERSEWAY_Tranvalse 0x0001 #define XFA_TRAVERSEWAY_Form 0x0002 -#define XFA_WIDGETFILTER_Visible 0x0001 -#define XFA_WIDGETFILTER_Viewable 0x0010 -#define XFA_WIDGETFILTER_Printable 0x0020 -#define XFA_WIDGETFILTER_Field 0x0100 -#define XFA_WIDGETFILTER_AllType 0x0F00 - -#define XFA_WIDGETSTATUS_Visible 0x00000001 -#define XFA_WIDGETSTATUS_Invisible 0x00000002 -#define XFA_WIDGETSTATUS_Hidden 0x00000004 -#define XFA_WIDGETSTATUS_Viewable 0x00000010 -#define XFA_WIDGETSTATUS_Printable 0x00000020 -#define XFA_WIDGETSTATUS_Focused 0x00000100 + +enum XFA_WidgetStatus { + XFA_WidgetStatus_None = 0, + + XFA_WidgetStatus_Access = 1 << 0, + XFA_WidgetStatus_ButtonDown = 1 << 1, + XFA_WidgetStatus_Disabled = 1 << 2, + XFA_WidgetStatus_Focused = 1 << 3, + XFA_WidgetStatus_Highlight = 1 << 4, + XFA_WidgetStatus_Printable = 1 << 5, + XFA_WidgetStatus_RectCached = 1 << 6, + XFA_WidgetStatus_TextEditValueChanged = 1 << 7, + XFA_WidgetStatus_Viewable = 1 << 8, + XFA_WidgetStatus_Visible = 1 << 9 +}; enum XFA_EVENTTYPE { XFA_EVENT_Click, diff --git a/xfa/fxfa/include/xfa_ffpageview.h b/xfa/fxfa/include/xfa_ffpageview.h index 79b0afb602..124c8db4d2 100644 --- a/xfa/fxfa/include/xfa_ffpageview.h +++ b/xfa/fxfa/include/xfa_ffpageview.h @@ -25,9 +25,8 @@ class CXFA_FFPageView : public CXFA_ContainerLayoutItem { int32_t iRotate) const; IXFA_WidgetIterator* CreateWidgetIterator( uint32_t dwTraverseWay = XFA_TRAVERSEWAY_Form, - uint32_t dwWidgetFilter = XFA_WIDGETFILTER_Visible | - XFA_WIDGETFILTER_Viewable | - XFA_WIDGETFILTER_AllType); + uint32_t dwWidgetFilter = XFA_WidgetStatus_Visible | + XFA_WidgetStatus_Viewable); protected: CXFA_FFDocView* const m_pDocView; diff --git a/xfa/fxfa/parser/xfa_doclayout.h b/xfa/fxfa/parser/xfa_doclayout.h index 267f79980b..a0b29e5ff8 100644 --- a/xfa/fxfa/parser/xfa_doclayout.h +++ b/xfa/fxfa/parser/xfa_doclayout.h @@ -63,13 +63,6 @@ class CXFA_ContainerLayoutItem : public CXFA_LayoutItem { CXFA_Node* m_pOldSubform; }; -#define XFA_WIDGETSTATUS_Access 0x80000000 -#define XFA_WIDGETSTATUS_Disabled 0x40000000 -#define XFA_WIDGETSTATUS_RectCached 0x20000000 -#define XFA_WIDGETSTATUS_ButtonDown 0x10000000 -#define XFA_WIDGETSTATUS_Highlight 0x08000000 -#define XFA_WIDGETSTATUS_TextEditValueChanged 0x04000000 - class CXFA_ContentLayoutItem : public CXFA_LayoutItem { public: CXFA_ContentLayoutItem(CXFA_Node* pNode); diff --git a/xfa/fxfa/parser/xfa_document.h b/xfa/fxfa/parser/xfa_document.h index 16428ea781..86b2a6f62c 100644 --- a/xfa/fxfa/parser/xfa_document.h +++ b/xfa/fxfa/parser/xfa_document.h @@ -39,10 +39,6 @@ enum XFA_VERSION { XFA_VERSION_MAX = 400, }; -#define XFA_LAYOUTSTATUS_Visible 0x0001 -#define XFA_LAYOUTSTATUS_Viewable 0x0010 -#define XFA_LAYOUTSTATUS_Printable 0x0020 - enum XFA_LAYOUTRESULT { XFA_LAYOUTRESULT_Continue, XFA_LAYOUTRESULT_Done, diff --git a/xfa/fxfa/parser/xfa_layout_appadapter.cpp b/xfa/fxfa/parser/xfa_layout_appadapter.cpp index 2331972c75..dca11da80f 100644 --- a/xfa/fxfa/parser/xfa_layout_appadapter.cpp +++ b/xfa/fxfa/parser/xfa_layout_appadapter.cpp @@ -20,26 +20,6 @@ #include "xfa/fxfa/parser/xfa_script.h" #include "xfa/fxfa/parser/xfa_utils.h" -uint32_t XFA_GetRelevant(CXFA_Node* pFormItem, uint32_t dwParentRelvant) { - uint32_t dwRelevant = XFA_LAYOUTSTATUS_Viewable | XFA_LAYOUTSTATUS_Printable; - CFX_WideStringC wsRelevant; - if (pFormItem->TryCData(XFA_ATTRIBUTE_Relevant, wsRelevant)) { - if (wsRelevant == FX_WSTRC(L"+print") || wsRelevant == FX_WSTRC(L"print")) { - dwRelevant &= ~XFA_LAYOUTSTATUS_Viewable; - } else if (wsRelevant == FX_WSTRC(L"-print")) { - dwRelevant &= ~XFA_LAYOUTSTATUS_Printable; - } - } - if (!(dwParentRelvant & XFA_LAYOUTSTATUS_Viewable) && - (dwRelevant != XFA_LAYOUTSTATUS_Viewable)) { - dwRelevant &= ~XFA_LAYOUTSTATUS_Viewable; - } - if (!(dwParentRelvant & XFA_LAYOUTSTATUS_Printable) && - (dwRelevant != XFA_LAYOUTSTATUS_Printable)) { - dwRelevant &= ~XFA_LAYOUTSTATUS_Printable; - } - return dwRelevant; -} void XFA_ReleaseLayoutItem(CXFA_LayoutItem* pLayoutItem) { CXFA_LayoutItem* pNode = pLayoutItem->m_pFirstChild; CXFA_FFNotify* pNotify = diff --git a/xfa/fxfa/parser/xfa_layout_appadapter.h b/xfa/fxfa/parser/xfa_layout_appadapter.h index eb4a9631d6..be7072b704 100644 --- a/xfa/fxfa/parser/xfa_layout_appadapter.h +++ b/xfa/fxfa/parser/xfa_layout_appadapter.h @@ -71,7 +71,7 @@ class CXFA_TraverseStrategy_ContentLayoutItem { return (CXFA_ContentLayoutItem*)pLayoutItem->m_pParent; } }; -uint32_t XFA_GetRelevant(CXFA_Node* pFormItem, uint32_t dwParentRelvant); + void XFA_ReleaseLayoutItem(CXFA_LayoutItem* pLayoutItem); #endif // XFA_FXFA_PARSER_XFA_LAYOUT_APPADAPTER_H_ diff --git a/xfa/fxfa/parser/xfa_layout_pagemgr_new.cpp b/xfa/fxfa/parser/xfa_layout_pagemgr_new.cpp index 08ce54f844..374d1dc44e 100644 --- a/xfa/fxfa/parser/xfa_layout_pagemgr_new.cpp +++ b/xfa/fxfa/parser/xfa_layout_pagemgr_new.cpp @@ -22,6 +22,206 @@ #include "xfa/fxfa/parser/xfa_script_imp.h" #include "xfa/fxfa/parser/xfa_utils.h" +namespace { + +class PageSetContainerLayoutItem { + public: + static inline CXFA_ContainerLayoutItem* GetFirstChild( + CXFA_ContainerLayoutItem* pLayoutItem) { + if (pLayoutItem->m_pFormNode->GetClassID() != XFA_ELEMENT_PageSet) + return nullptr; + + CXFA_ContainerLayoutItem* pChildItem = + static_cast<CXFA_ContainerLayoutItem*>(pLayoutItem->m_pFirstChild); + while (pChildItem && + pChildItem->m_pFormNode->GetClassID() != XFA_ELEMENT_PageSet) { + pChildItem = + static_cast<CXFA_ContainerLayoutItem*>(pChildItem->m_pNextSibling); + } + return pChildItem; + } + + static inline CXFA_ContainerLayoutItem* GetNextSibling( + CXFA_ContainerLayoutItem* pLayoutItem) { + CXFA_ContainerLayoutItem* pChildItem = + static_cast<CXFA_ContainerLayoutItem*>(pLayoutItem->m_pNextSibling); + while (pChildItem && + pChildItem->m_pFormNode->GetClassID() != XFA_ELEMENT_PageSet) { + pChildItem = + static_cast<CXFA_ContainerLayoutItem*>(pChildItem->m_pNextSibling); + } + return pChildItem; + } + + static inline CXFA_ContainerLayoutItem* GetParent( + CXFA_ContainerLayoutItem* pLayoutItem) { + return static_cast<CXFA_ContainerLayoutItem*>(pLayoutItem->m_pParent); + } +}; + +uint32_t GetRelevant(CXFA_Node* pFormItem, uint32_t dwParentRelvant) { + uint32_t dwRelevant = XFA_WidgetStatus_Viewable | XFA_WidgetStatus_Printable; + CFX_WideStringC wsRelevant; + if (pFormItem->TryCData(XFA_ATTRIBUTE_Relevant, wsRelevant)) { + if (wsRelevant == FX_WSTRC(L"+print") || wsRelevant == FX_WSTRC(L"print")) + dwRelevant &= ~XFA_WidgetStatus_Viewable; + else if (wsRelevant == FX_WSTRC(L"-print")) + dwRelevant &= ~XFA_WidgetStatus_Printable; + } + if (!(dwParentRelvant & XFA_WidgetStatus_Viewable) && + (dwRelevant != XFA_WidgetStatus_Viewable)) { + dwRelevant &= ~XFA_WidgetStatus_Viewable; + } + if (!(dwParentRelvant & XFA_WidgetStatus_Printable) && + (dwRelevant != XFA_WidgetStatus_Printable)) { + dwRelevant &= ~XFA_WidgetStatus_Printable; + } + return dwRelevant; +} + +void SyncContainer(CXFA_FFNotify* pNotify, + CXFA_LayoutProcessor* pDocLayout, + CXFA_LayoutItem* pContainerItem, + uint32_t dwRelevant, + FX_BOOL bVisible, + int32_t nPageIndex) { + FX_BOOL bVisibleItem = FALSE; + uint32_t dwStatus = 0; + uint32_t dwRelevantContainer = 0; + if (bVisible) { + XFA_ATTRIBUTEENUM eAttributeValue = + pContainerItem->m_pFormNode->GetEnum(XFA_ATTRIBUTE_Presence); + if (eAttributeValue == XFA_ATTRIBUTEENUM_Visible || + eAttributeValue == XFA_ATTRIBUTEENUM_Unknown) { + bVisibleItem = TRUE; + } + dwRelevantContainer = GetRelevant(pContainerItem->m_pFormNode, dwRelevant); + dwStatus = + (bVisibleItem ? XFA_WidgetStatus_Visible : 0) | dwRelevantContainer; + } + pNotify->OnLayoutItemAdded(pDocLayout, pContainerItem, nPageIndex, dwStatus); + for (CXFA_LayoutItem* pChild = pContainerItem->m_pFirstChild; pChild; + pChild = pChild->m_pNextSibling) { + if (pChild->IsContentLayoutItem()) { + SyncContainer(pNotify, pDocLayout, pChild, dwRelevantContainer, + bVisibleItem, nPageIndex); + } + } +} + +void ReorderLayoutItemToTail(CXFA_ContainerLayoutItem* pLayoutItem) { + CXFA_ContainerLayoutItem* pParentLayoutItem = + (CXFA_ContainerLayoutItem*)pLayoutItem->m_pParent; + if (!pParentLayoutItem) + return; + + pParentLayoutItem->RemoveChild(pLayoutItem); + pParentLayoutItem->AddChild(pLayoutItem); +} + +void RemoveLayoutItem(CXFA_ContainerLayoutItem* pLayoutItem) { + CXFA_ContainerLayoutItem* pParentLayoutItem = + (CXFA_ContainerLayoutItem*)pLayoutItem->m_pParent; + if (!pParentLayoutItem) + return; + + pParentLayoutItem->RemoveChild(pLayoutItem); +} + +CXFA_Node* ResolveBreakTarget(CXFA_Node* pPageSetRoot, + FX_BOOL bNewExprStyle, + CFX_WideStringC& wsTargetExpr) { + CXFA_Document* pDocument = pPageSetRoot->GetDocument(); + if (wsTargetExpr.IsEmpty()) + return nullptr; + + CFX_WideString wsTargetAll(wsTargetExpr); + wsTargetAll.TrimLeft(); + wsTargetAll.TrimRight(); + int32_t iSpliteIndex = 0; + FX_BOOL bTargetAllFind = TRUE; + while (iSpliteIndex != -1) { + CFX_WideString wsTargetExpr; + int32_t iSpliteNextIndex = 0; + if (!bTargetAllFind) { + iSpliteNextIndex = wsTargetAll.Find(' ', iSpliteIndex); + wsTargetExpr = + wsTargetAll.Mid(iSpliteIndex, iSpliteNextIndex - iSpliteIndex); + } else { + wsTargetExpr = wsTargetAll; + } + if (wsTargetExpr.IsEmpty()) + return nullptr; + + bTargetAllFind = FALSE; + if (wsTargetExpr.GetAt(0) == '#') { + CXFA_Node* pNode = pDocument->GetNodeByID( + ToNode(pDocument->GetXFAObject(XFA_HASHCODE_Template)), + wsTargetExpr.Mid(1).AsStringC()); + if (pNode) + return pNode; + } else if (bNewExprStyle) { + CFX_WideString wsProcessedTarget = wsTargetExpr; + if (wsTargetExpr.Left(4) == FX_WSTRC(L"som(") && + wsTargetExpr.Right(1) == FX_WSTRC(L")")) { + wsProcessedTarget = wsTargetExpr.Mid(4, wsTargetExpr.GetLength() - 5); + } + XFA_RESOLVENODE_RS rs; + int32_t iCount = pDocument->GetScriptContext()->ResolveObjects( + pPageSetRoot, wsProcessedTarget.AsStringC(), rs, + XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties | + XFA_RESOLVENODE_Attributes | XFA_RESOLVENODE_Siblings | + XFA_RESOLVENODE_Parent); + if (iCount > 0 && rs.nodes[0]->IsNode()) + return rs.nodes[0]->AsNode(); + } + iSpliteIndex = iSpliteNextIndex; + } + return nullptr; +} + +void SetLayoutGeneratedNodeFlag(CXFA_Node* pNode) { + pNode->SetFlag(XFA_NODEFLAG_LayoutGeneratedNode, false); + pNode->ClearFlag(XFA_NODEFLAG_UnusedNode); +} + +FX_BOOL CheckContentAreaNotUsed( + CXFA_ContainerLayoutItem* pPageAreaLayoutItem, + CXFA_Node* pContentArea, + CXFA_ContainerLayoutItem*& pContentAreaLayoutItem) { + for (CXFA_ContainerLayoutItem* pLayoutItem = + (CXFA_ContainerLayoutItem*)pPageAreaLayoutItem->m_pFirstChild; + pLayoutItem; + pLayoutItem = (CXFA_ContainerLayoutItem*)pLayoutItem->m_pNextSibling) { + if (pLayoutItem->m_pFormNode == pContentArea) { + if (pLayoutItem->m_pFirstChild == NULL) { + pContentAreaLayoutItem = pLayoutItem; + return TRUE; + } + return FALSE; + } + } + return TRUE; +} + +void SyncRemoveLayoutItem(CXFA_LayoutItem* pParentLayoutItem, + CXFA_FFNotify* pNotify, + CXFA_LayoutProcessor* pDocLayout) { + CXFA_LayoutItem* pNextLayoutItem; + CXFA_LayoutItem* pCurLayoutItem = pParentLayoutItem->m_pFirstChild; + while (pCurLayoutItem) { + pNextLayoutItem = pCurLayoutItem->m_pNextSibling; + if (pCurLayoutItem->m_pFirstChild) + SyncRemoveLayoutItem(pCurLayoutItem, pNotify, pDocLayout); + + pNotify->OnLayoutItemRemoving(pDocLayout, pCurLayoutItem); + delete pCurLayoutItem; + pCurLayoutItem = pNextLayoutItem; + } +} + +} // namespace + CXFA_LayoutPageMgr::CXFA_LayoutPageMgr(CXFA_LayoutProcessor* pLayoutProcessor) : m_pLayoutProcessor(pLayoutProcessor), m_pTemplatePageSetRoot(nullptr), @@ -179,40 +379,22 @@ FX_BOOL CXFA_LayoutPageMgr::AppendNewPage(FX_BOOL bFirstTemPage) { } return !bFirstTemPage || m_pCurrentContainerRecord; } -static void XFA_LayoutItemMgr_ReorderLayoutItemToTail( - CXFA_ContainerLayoutItem* pLayoutItem) { - CXFA_ContainerLayoutItem* pParentLayoutItem = - (CXFA_ContainerLayoutItem*)pLayoutItem->m_pParent; - if (!pParentLayoutItem) { - return; - } - pParentLayoutItem->RemoveChild(pLayoutItem); - pParentLayoutItem->AddChild(pLayoutItem); -} -static void XFA_LayoutItemMgr_RemoveLayoutItem( - CXFA_ContainerLayoutItem* pLayoutItem) { - CXFA_ContainerLayoutItem* pParentLayoutItem = - (CXFA_ContainerLayoutItem*)pLayoutItem->m_pParent; - if (!pParentLayoutItem) { - return; - } - pParentLayoutItem->RemoveChild(pLayoutItem); -} + void CXFA_LayoutPageMgr::RemoveLayoutRecord(CXFA_ContainerRecord* pNewRecord, CXFA_ContainerRecord* pPrevRecord) { if (!pNewRecord || !pPrevRecord) { return; } if (pNewRecord->pCurPageSet != pPrevRecord->pCurPageSet) { - XFA_LayoutItemMgr_RemoveLayoutItem(pNewRecord->pCurPageSet); + RemoveLayoutItem(pNewRecord->pCurPageSet); return; } if (pNewRecord->pCurPageArea != pPrevRecord->pCurPageArea) { - XFA_LayoutItemMgr_RemoveLayoutItem(pNewRecord->pCurPageArea); + RemoveLayoutItem(pNewRecord->pCurPageArea); return; } if (pNewRecord->pCurContentArea != pPrevRecord->pCurContentArea) { - XFA_LayoutItemMgr_RemoveLayoutItem(pNewRecord->pCurContentArea); + RemoveLayoutItem(pNewRecord->pCurContentArea); return; } } @@ -223,15 +405,15 @@ void CXFA_LayoutPageMgr::ReorderPendingLayoutRecordToTail( return; } if (pNewRecord->pCurPageSet != pPrevRecord->pCurPageSet) { - XFA_LayoutItemMgr_ReorderLayoutItemToTail(pNewRecord->pCurPageSet); + ReorderLayoutItemToTail(pNewRecord->pCurPageSet); return; } if (pNewRecord->pCurPageArea != pPrevRecord->pCurPageArea) { - XFA_LayoutItemMgr_ReorderLayoutItemToTail(pNewRecord->pCurPageArea); + ReorderLayoutItemToTail(pNewRecord->pCurPageArea); return; } if (pNewRecord->pCurContentArea != pPrevRecord->pCurContentArea) { - XFA_LayoutItemMgr_ReorderLayoutItemToTail(pNewRecord->pCurContentArea); + ReorderLayoutItemToTail(pNewRecord->pCurContentArea); return; } } @@ -267,59 +449,6 @@ FX_FLOAT CXFA_LayoutPageMgr::GetAvailHeight() { } return XFA_LAYOUT_FLOAT_MAX; } -static CXFA_Node* XFA_ResolveBreakTarget(CXFA_Node* pPageSetRoot, - FX_BOOL bNewExprStyle, - CFX_WideStringC& wsTargetExpr) { - CXFA_Document* pDocument = pPageSetRoot->GetDocument(); - if (wsTargetExpr.IsEmpty()) { - return NULL; - } - CFX_WideString wsTargetAll(wsTargetExpr); - wsTargetAll.TrimLeft(); - wsTargetAll.TrimRight(); - int32_t iSpliteIndex = 0; - FX_BOOL bTargetAllFind = TRUE; - while (iSpliteIndex != -1) { - CFX_WideString wsTargetExpr; - int32_t iSpliteNextIndex = 0; - if (!bTargetAllFind) { - iSpliteNextIndex = wsTargetAll.Find(' ', iSpliteIndex); - wsTargetExpr = - wsTargetAll.Mid(iSpliteIndex, iSpliteNextIndex - iSpliteIndex); - } else { - wsTargetExpr = wsTargetAll; - } - if (wsTargetExpr.IsEmpty()) { - return NULL; - } - bTargetAllFind = FALSE; - if (wsTargetExpr.GetAt(0) == '#') { - CXFA_Node* pNode = pDocument->GetNodeByID( - ToNode(pDocument->GetXFAObject(XFA_HASHCODE_Template)), - wsTargetExpr.Mid(1).AsStringC()); - if (pNode) { - return pNode; - } - } else if (bNewExprStyle) { - CFX_WideString wsProcessedTarget = wsTargetExpr; - if (wsTargetExpr.Left(4) == FX_WSTRC(L"som(") && - wsTargetExpr.Right(1) == FX_WSTRC(L")")) { - wsProcessedTarget = wsTargetExpr.Mid(4, wsTargetExpr.GetLength() - 5); - } - XFA_RESOLVENODE_RS rs; - int32_t iCount = pDocument->GetScriptContext()->ResolveObjects( - pPageSetRoot, wsProcessedTarget.AsStringC(), rs, - XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties | - XFA_RESOLVENODE_Attributes | XFA_RESOLVENODE_Siblings | - XFA_RESOLVENODE_Parent); - if (iCount > 0 && rs.nodes[0]->IsNode()) { - return rs.nodes[0]->AsNode(); - } - } - iSpliteIndex = iSpliteNextIndex; - } - return NULL; -} FX_BOOL XFA_LayoutPageMgr_RunBreakTestScript(CXFA_Node* pTestScript) { CFX_WideString wsExpression; @@ -434,43 +563,14 @@ void CXFA_LayoutPageMgr::AddContentAreaLayoutItem( pNewRecord->pCurPageArea->AddChild(pNewContentAreaLayoutItem); pNewRecord->pCurContentArea = pNewContentAreaLayoutItem; } -class CXFA_TraverseStrategy_PageSetContainerLayoutItem { - public: - static inline CXFA_ContainerLayoutItem* GetFirstChild( - CXFA_ContainerLayoutItem* pLayoutItem) { - if (pLayoutItem->m_pFormNode->GetClassID() == XFA_ELEMENT_PageSet) { - CXFA_ContainerLayoutItem* pChildItem = - (CXFA_ContainerLayoutItem*)pLayoutItem->m_pFirstChild; - while (pChildItem && - pChildItem->m_pFormNode->GetClassID() != XFA_ELEMENT_PageSet) { - pChildItem = (CXFA_ContainerLayoutItem*)pChildItem->m_pNextSibling; - } - return pChildItem; - } - return NULL; - } - static inline CXFA_ContainerLayoutItem* GetNextSibling( - CXFA_ContainerLayoutItem* pLayoutItem) { - CXFA_ContainerLayoutItem* pChildItem = - (CXFA_ContainerLayoutItem*)pLayoutItem->m_pNextSibling; - while (pChildItem && - pChildItem->m_pFormNode->GetClassID() != XFA_ELEMENT_PageSet) { - pChildItem = (CXFA_ContainerLayoutItem*)pChildItem->m_pNextSibling; - } - return pChildItem; - } - static inline CXFA_ContainerLayoutItem* GetParent( - CXFA_ContainerLayoutItem* pLayoutItem) { - return (CXFA_ContainerLayoutItem*)pLayoutItem->m_pParent; - } -}; + void CXFA_LayoutPageMgr::FinishPaginatedPageSets() { CXFA_ContainerLayoutItem* pRootPageSetLayoutItem = m_pPageSetLayoutItemRoot; for (; pRootPageSetLayoutItem; pRootPageSetLayoutItem = (CXFA_ContainerLayoutItem*)pRootPageSetLayoutItem->m_pNextSibling) { CXFA_NodeIteratorTemplate<CXFA_ContainerLayoutItem, - CXFA_TraverseStrategy_PageSetContainerLayoutItem> + PageSetContainerLayoutItem> sIterator(pRootPageSetLayoutItem); for (CXFA_ContainerLayoutItem* pPageSetLayoutItem = sIterator.GetCurrent(); pPageSetLayoutItem; pPageSetLayoutItem = sIterator.MoveToNext()) { @@ -647,25 +747,11 @@ FX_BOOL CXFA_LayoutPageMgr::RunBreak(XFA_ELEMENT eBreakType, if (pTarget && pTarget->GetClassID() != XFA_ELEMENT_PageArea) { pTarget = NULL; } - if (m_nAvailPages % 2 != 1 || !m_pCurrentContainerRecord || - (pTarget && - pTarget != GetCurrentContainerRecord()->pCurPageArea->m_pFormNode) || - bStartNew) { - if (m_nAvailPages % 2 == 1) { - } - } break; case XFA_ATTRIBUTEENUM_PageEven: if (pTarget && pTarget->GetClassID() != XFA_ELEMENT_PageArea) { pTarget = NULL; } - if (m_nAvailPages % 2 != 0 || !m_pCurrentContainerRecord || - (pTarget && - pTarget != GetCurrentContainerRecord()->pCurPageArea->m_pFormNode) || - bStartNew) { - if (m_nAvailPages % 2 == 0) { - } - } break; case XFA_ATTRIBUTEENUM_Auto: default: @@ -693,13 +779,13 @@ FX_BOOL CXFA_LayoutPageMgr::ExecuteBreakBeforeOrAfter( } CFX_WideStringC wsTarget = pCurNode->GetCData(XFA_ATTRIBUTE_Target); CXFA_Node* pTarget = - XFA_ResolveBreakTarget(m_pTemplatePageSetRoot, TRUE, wsTarget); + ResolveBreakTarget(m_pTemplatePageSetRoot, TRUE, wsTarget); wsBreakTrailer = pCurNode->GetCData(XFA_ATTRIBUTE_Trailer); wsBreakLeader = pCurNode->GetCData(XFA_ATTRIBUTE_Leader); pBreakLeaderTemplate = - XFA_ResolveBreakTarget(pContainer, TRUE, wsBreakLeader); + ResolveBreakTarget(pContainer, TRUE, wsBreakLeader); pBreakTrailerTemplate = - XFA_ResolveBreakTarget(pContainer, TRUE, wsBreakTrailer); + ResolveBreakTarget(pContainer, TRUE, wsBreakTrailer); if (RunBreak(eType, pCurNode->GetEnum(XFA_ATTRIBUTE_TargetType), pTarget, bStartNew)) { return TRUE; @@ -729,7 +815,7 @@ FX_BOOL CXFA_LayoutPageMgr::ExecuteBreakBeforeOrAfter( CFX_WideStringC wsTarget = pCurNode->GetCData( bBefore ? XFA_ATTRIBUTE_BeforeTarget : XFA_ATTRIBUTE_AfterTarget); CXFA_Node* pTarget = - XFA_ResolveBreakTarget(m_pTemplatePageSetRoot, TRUE, wsTarget); + ResolveBreakTarget(m_pTemplatePageSetRoot, TRUE, wsTarget); if (RunBreak(bBefore ? XFA_ELEMENT_BreakBefore : XFA_ELEMENT_BreakAfter, pCurNode->GetEnum(bBefore ? XFA_ATTRIBUTE_Before : XFA_ATTRIBUTE_After), @@ -742,10 +828,7 @@ FX_BOOL CXFA_LayoutPageMgr::ExecuteBreakBeforeOrAfter( } return FALSE; } -static void XFA_SetLayoutGeneratedNodeFlag(CXFA_Node* pNode) { - pNode->SetFlag(XFA_NODEFLAG_LayoutGeneratedNode, false); - pNode->ClearFlag(XFA_NODEFLAG_UnusedNode); -} + FX_BOOL CXFA_LayoutPageMgr::ProcessBreakBeforeOrAfter( CXFA_Node* pBreakNode, FX_BOOL bBefore, @@ -769,7 +852,7 @@ FX_BOOL CXFA_LayoutPageMgr::ProcessBreakBeforeOrAfter( pBreakLeaderNode = pDocument->DataMerge_CopyContainer( pLeaderTemplate, pFormNode, pDataScope, TRUE); pDocument->DataMerge_UpdateBindingRelations(pBreakLeaderNode); - XFA_SetLayoutGeneratedNodeFlag(pBreakLeaderNode); + SetLayoutGeneratedNodeFlag(pBreakLeaderNode); } if (pTrailerTemplate) { if (!pDataScope) { @@ -778,7 +861,7 @@ FX_BOOL CXFA_LayoutPageMgr::ProcessBreakBeforeOrAfter( pBreakTrailerNode = pDocument->DataMerge_CopyContainer( pTrailerTemplate, pFormNode, pDataScope, TRUE); pDocument->DataMerge_UpdateBindingRelations(pBreakTrailerNode); - XFA_SetLayoutGeneratedNodeFlag(pBreakTrailerNode); + SetLayoutGeneratedNodeFlag(pBreakTrailerNode); } return TRUE; } @@ -801,7 +884,7 @@ FX_BOOL CXFA_LayoutPageMgr::ProcessBookendLeaderOrTrailer( pBookendAppendNode = pDocument->DataMerge_CopyContainer( pLeaderTemplate, pFormNode, pDataScope, TRUE); pDocument->DataMerge_UpdateBindingRelations(pBookendAppendNode); - XFA_SetLayoutGeneratedNodeFlag(pBookendAppendNode); + SetLayoutGeneratedNodeFlag(pBookendAppendNode); return TRUE; } } @@ -827,8 +910,8 @@ CXFA_Node* CXFA_LayoutPageMgr::BreakOverflow(CXFA_Node* pOverflowNode, !wsOverflowTarget.IsEmpty()) { if (!wsOverflowTarget.IsEmpty() && bCreatePage && !m_bCreateOverFlowPage) { - CXFA_Node* pTarget = XFA_ResolveBreakTarget(m_pTemplatePageSetRoot, - TRUE, wsOverflowTarget); + CXFA_Node* pTarget = + ResolveBreakTarget(m_pTemplatePageSetRoot, TRUE, wsOverflowTarget); if (pTarget) { m_bCreateOverFlowPage = TRUE; switch (pTarget->GetClassID()) { @@ -847,9 +930,9 @@ CXFA_Node* CXFA_LayoutPageMgr::BreakOverflow(CXFA_Node* pOverflowNode, } if (!bCreatePage) { pLeaderTemplate = - XFA_ResolveBreakTarget(pContainer, TRUE, wsOverflowLeader); + ResolveBreakTarget(pContainer, TRUE, wsOverflowLeader); pTrailerTemplate = - XFA_ResolveBreakTarget(pContainer, TRUE, wsOverflowTrailer); + ResolveBreakTarget(pContainer, TRUE, wsOverflowTrailer); } return pOverflowNode; } @@ -860,8 +943,8 @@ CXFA_Node* CXFA_LayoutPageMgr::BreakOverflow(CXFA_Node* pOverflowNode, pOverflowNode->TryCData(XFA_ATTRIBUTE_Trailer, wsOverflowTrailer); pOverflowNode->TryCData(XFA_ATTRIBUTE_Target, wsOverflowTarget); if (!wsOverflowTarget.IsEmpty() && bCreatePage && !m_bCreateOverFlowPage) { - CXFA_Node* pTarget = XFA_ResolveBreakTarget(m_pTemplatePageSetRoot, TRUE, - wsOverflowTarget); + CXFA_Node* pTarget = + ResolveBreakTarget(m_pTemplatePageSetRoot, TRUE, wsOverflowTarget); if (pTarget) { m_bCreateOverFlowPage = TRUE; switch (pTarget->GetClassID()) { @@ -879,10 +962,9 @@ CXFA_Node* CXFA_LayoutPageMgr::BreakOverflow(CXFA_Node* pOverflowNode, } } if (!bCreatePage) { - pLeaderTemplate = - XFA_ResolveBreakTarget(pContainer, TRUE, wsOverflowLeader); + pLeaderTemplate = ResolveBreakTarget(pContainer, TRUE, wsOverflowLeader); pTrailerTemplate = - XFA_ResolveBreakTarget(pContainer, TRUE, wsOverflowTrailer); + ResolveBreakTarget(pContainer, TRUE, wsOverflowTrailer); } return pOverflowNode; } @@ -920,7 +1002,7 @@ FX_BOOL CXFA_LayoutPageMgr::ProcessOverflow(CXFA_Node* pFormNode, pLeaderNode = pDocument->DataMerge_CopyContainer( pLeaderTemplate, pFormNode, pDataScope, TRUE); pDocument->DataMerge_UpdateBindingRelations(pLeaderNode); - XFA_SetLayoutGeneratedNodeFlag(pLeaderNode); + SetLayoutGeneratedNodeFlag(pLeaderNode); } if (pTrailerTemplate) { if (!pDataScope) { @@ -929,7 +1011,7 @@ FX_BOOL CXFA_LayoutPageMgr::ProcessOverflow(CXFA_Node* pFormNode, pTrailerNode = pDocument->DataMerge_CopyContainer( pTrailerTemplate, pFormNode, pDataScope, TRUE); pDocument->DataMerge_UpdateBindingRelations(pTrailerNode); - XFA_SetLayoutGeneratedNodeFlag(pTrailerNode); + SetLayoutGeneratedNodeFlag(pTrailerNode); } return TRUE; } @@ -954,7 +1036,7 @@ FX_BOOL CXFA_LayoutPageMgr::ResolveBookendLeaderOrTrailer( wsBookendLeader); if (!wsBookendLeader.IsEmpty()) { pBookendAppendTemplate = - XFA_ResolveBreakTarget(pContainer, FALSE, wsBookendLeader); + ResolveBreakTarget(pContainer, FALSE, wsBookendLeader); return TRUE; } return FALSE; @@ -963,7 +1045,7 @@ FX_BOOL CXFA_LayoutPageMgr::ResolveBookendLeaderOrTrailer( bLeader ? XFA_ATTRIBUTE_Leader : XFA_ATTRIBUTE_Trailer, wsBookendLeader); pBookendAppendTemplate = - XFA_ResolveBreakTarget(pContainer, TRUE, wsBookendLeader); + ResolveBreakTarget(pContainer, TRUE, wsBookendLeader); return TRUE; } return FALSE; @@ -1251,24 +1333,7 @@ CXFA_Node* CXFA_LayoutPageMgr::GetNextAvailPageArea( } return NULL; } -static FX_BOOL XFA_LayoutPageMgr_CheckContentAreaNotUsed( - CXFA_ContainerLayoutItem* pPageAreaLayoutItem, - CXFA_Node* pContentArea, - CXFA_ContainerLayoutItem*& pContentAreaLayoutItem) { - for (CXFA_ContainerLayoutItem* pLayoutItem = - (CXFA_ContainerLayoutItem*)pPageAreaLayoutItem->m_pFirstChild; - pLayoutItem; - pLayoutItem = (CXFA_ContainerLayoutItem*)pLayoutItem->m_pNextSibling) { - if (pLayoutItem->m_pFormNode == pContentArea) { - if (pLayoutItem->m_pFirstChild == NULL) { - pContentAreaLayoutItem = pLayoutItem; - return TRUE; - } - return FALSE; - } - } - return TRUE; -} + FX_BOOL CXFA_LayoutPageMgr::GetNextContentArea(CXFA_Node* pContentArea) { CXFA_Node* pCurContentNode = GetCurrentContainerRecord()->pCurContentArea->m_pFormNode; @@ -1283,9 +1348,8 @@ FX_BOOL CXFA_LayoutPageMgr::GetNextContentArea(CXFA_Node* pContentArea) { return FALSE; } CXFA_ContainerLayoutItem* pContentAreaLayout = NULL; - if (!XFA_LayoutPageMgr_CheckContentAreaNotUsed( - GetCurrentContainerRecord()->pCurPageArea, pContentArea, - pContentAreaLayout)) { + if (!CheckContentAreaNotUsed(GetCurrentContainerRecord()->pCurPageArea, + pContentArea, pContentAreaLayout)) { return FALSE; } if (pContentAreaLayout) { @@ -1495,21 +1559,7 @@ CXFA_LayoutItem* CXFA_LayoutPageMgr::FindOrCreateLayoutItem( return pFormNode->GetDocument()->GetParser()->GetNotify()->OnCreateLayoutItem( pFormNode); } -static void XFA_SyncRemoveLayoutItem(CXFA_LayoutItem* pParentLayoutItem, - CXFA_FFNotify* pNotify, - CXFA_LayoutProcessor* pDocLayout) { - CXFA_LayoutItem* pNextLayoutItem; - CXFA_LayoutItem* pCurLayoutItem = pParentLayoutItem->m_pFirstChild; - while (pCurLayoutItem) { - pNextLayoutItem = pCurLayoutItem->m_pNextSibling; - if (pCurLayoutItem->m_pFirstChild) { - XFA_SyncRemoveLayoutItem(pCurLayoutItem, pNotify, pDocLayout); - } - pNotify->OnLayoutItemRemoving(pDocLayout, pCurLayoutItem); - delete pCurLayoutItem; - pCurLayoutItem = pNextLayoutItem; - } -} + void CXFA_LayoutPageMgr::SaveLayoutItem(CXFA_LayoutItem* pParentLayoutItem) { CXFA_LayoutItem* pNextLayoutItem; CXFA_LayoutItem* pCurLayoutItem = pParentLayoutItem->m_pFirstChild; @@ -1523,7 +1573,7 @@ void CXFA_LayoutPageMgr::SaveLayoutItem(CXFA_LayoutItem* pParentLayoutItem) { CXFA_LayoutProcessor* pDocLayout = m_pTemplatePageSetRoot->GetDocument()->GetDocLayout(); if (pCurLayoutItem->m_pFirstChild) { - XFA_SyncRemoveLayoutItem(pCurLayoutItem, pNotify, pDocLayout); + SyncRemoveLayoutItem(pCurLayoutItem, pNotify, pDocLayout); } pNotify->OnLayoutItemRemoving(pDocLayout, pCurLayoutItem); delete pCurLayoutItem; @@ -1787,36 +1837,7 @@ void CXFA_LayoutPageMgr::LayoutPageSetContents() { } } } -void XFA_SyncContainer(CXFA_FFNotify* pNotify, - CXFA_LayoutProcessor* pDocLayout, - CXFA_LayoutItem* pContainerItem, - uint32_t dwRelevant, - FX_BOOL bVisible, - int32_t nPageIndex) { - FX_BOOL bVisibleItem = FALSE; - uint32_t dwStatus = 0; - uint32_t dwRelevantContainer = 0; - if (bVisible) { - XFA_ATTRIBUTEENUM eAttributeValue = - pContainerItem->m_pFormNode->GetEnum(XFA_ATTRIBUTE_Presence); - if (eAttributeValue == XFA_ATTRIBUTEENUM_Visible || - eAttributeValue == XFA_ATTRIBUTEENUM_Unknown) { - bVisibleItem = TRUE; - } - dwRelevantContainer = - XFA_GetRelevant(pContainerItem->m_pFormNode, dwRelevant); - dwStatus = - (bVisibleItem ? XFA_LAYOUTSTATUS_Visible : 0) | dwRelevantContainer; - } - pNotify->OnLayoutItemAdded(pDocLayout, pContainerItem, nPageIndex, dwStatus); - for (CXFA_LayoutItem* pChild = pContainerItem->m_pFirstChild; pChild; - pChild = pChild->m_pNextSibling) { - if (pChild->IsContentLayoutItem()) { - XFA_SyncContainer(pNotify, pDocLayout, pChild, dwRelevantContainer, - bVisibleItem, nPageIndex); - } - } -} + void CXFA_LayoutPageMgr::SyncLayoutData() { MergePageSetContents(); LayoutPageSetContents(); @@ -1837,7 +1858,7 @@ void CXFA_LayoutPageMgr::SyncLayoutData() { case XFA_ELEMENT_PageArea: { nPageIdx++; uint32_t dwRelevant = - XFA_LAYOUTSTATUS_Viewable | XFA_LAYOUTSTATUS_Printable; + XFA_WidgetStatus_Viewable | XFA_WidgetStatus_Printable; CXFA_NodeIteratorTemplate<CXFA_LayoutItem, CXFA_TraverseStrategy_LayoutItem> iterator(pContainerItem); @@ -1853,9 +1874,9 @@ void CXFA_LayoutPageMgr::SyncLayoutData() { (pContentItem->m_pFormNode->GetEnum(XFA_ATTRIBUTE_Presence) == XFA_ATTRIBUTEENUM_Visible); uint32_t dwRelevantChild = - XFA_GetRelevant(pContentItem->m_pFormNode, dwRelevant); - XFA_SyncContainer(pNotify, m_pLayoutProcessor, pContentItem, - dwRelevantChild, bVisible, nPageIdx); + GetRelevant(pContentItem->m_pFormNode, dwRelevant); + SyncContainer(pNotify, m_pLayoutProcessor, pContentItem, + dwRelevantChild, bVisible, nPageIdx); pChildLayoutItem = iterator.SkipChildrenAndMoveToNext(); } } break; |