From a440bb3f11f42b7a22624e9771dd8d9c57075f06 Mon Sep 17 00:00:00 2001 From: dsinclair Date: Wed, 14 Sep 2016 07:01:54 -0700 Subject: Split CPDFXFA_Document apart [DO NOT COMMIT] This CL renames IXFA_DocProvider to IXFA_DocEnvironment to better describe the purpose. Then, CPDFXFA_Document has all of the IXFA_DocEnvironment methods removed and placed in CPDFXFA_DocEnvironment. The CPDFXFA_Document then has a CPDFXFA_DocEnvironment. This splits the code related to the document apart from the XFA callback methods to work with that document. Review-Url: https://codereview.chromium.org/2328573002 --- xfa/fxfa/app/xfa_ffapp.cpp | 8 ++++---- xfa/fxfa/app/xfa_ffchoicelist.cpp | 2 +- xfa/fxfa/app/xfa_ffdoc.cpp | 4 ++-- xfa/fxfa/app/xfa_ffdocview.cpp | 26 +++++++++++++------------- xfa/fxfa/app/xfa_fffield.cpp | 2 +- xfa/fxfa/app/xfa_ffnotify.cpp | 12 ++++++------ xfa/fxfa/app/xfa_ffnotify.h | 2 +- xfa/fxfa/app/xfa_fftext.cpp | 2 +- xfa/fxfa/app/xfa_fftextedit.cpp | 4 ++-- xfa/fxfa/app/xfa_ffwidget.cpp | 10 +++++----- xfa/fxfa/app/xfa_ffwidgetacc.cpp | 2 +- xfa/fxfa/app/xfa_ffwidgethandler.cpp | 10 +++++----- xfa/fxfa/app/xfa_fwladapter.cpp | 2 +- 13 files changed, 43 insertions(+), 43 deletions(-) (limited to 'xfa/fxfa/app') diff --git a/xfa/fxfa/app/xfa_ffapp.cpp b/xfa/fxfa/app/xfa_ffapp.cpp index 18e2d76552..9e86c3aa68 100644 --- a/xfa/fxfa/app/xfa_ffapp.cpp +++ b/xfa/fxfa/app/xfa_ffapp.cpp @@ -96,20 +96,20 @@ CXFA_FFDocHandler* CXFA_FFApp::GetDocHandler() { return m_pDocHandler.get(); } -CXFA_FFDoc* CXFA_FFApp::CreateDoc(IXFA_DocProvider* pProvider, +CXFA_FFDoc* CXFA_FFApp::CreateDoc(IXFA_DocEnvironment* pDocEnvironment, IFX_FileRead* pStream, FX_BOOL bTakeOverFile) { - std::unique_ptr pDoc(new CXFA_FFDoc(this, pProvider)); + std::unique_ptr pDoc(new CXFA_FFDoc(this, pDocEnvironment)); FX_BOOL bSuccess = pDoc->OpenDoc(pStream, bTakeOverFile); return bSuccess ? pDoc.release() : nullptr; } -CXFA_FFDoc* CXFA_FFApp::CreateDoc(IXFA_DocProvider* pProvider, +CXFA_FFDoc* CXFA_FFApp::CreateDoc(IXFA_DocEnvironment* pDocEnvironment, CPDF_Document* pPDFDoc) { if (!pPDFDoc) return nullptr; - std::unique_ptr pDoc(new CXFA_FFDoc(this, pProvider)); + std::unique_ptr pDoc(new CXFA_FFDoc(this, pDocEnvironment)); FX_BOOL bSuccess = pDoc->OpenDoc(pPDFDoc); return bSuccess ? pDoc.release() : nullptr; } diff --git a/xfa/fxfa/app/xfa_ffchoicelist.cpp b/xfa/fxfa/app/xfa_ffchoicelist.cpp index e6cb1090ad..94090d6123 100644 --- a/xfa/fxfa/app/xfa_ffchoicelist.cpp +++ b/xfa/fxfa/app/xfa_ffchoicelist.cpp @@ -287,7 +287,7 @@ FX_BOOL CXFA_FFComboBox::OnRButtonUp(uint32_t dwFlags, if (!CXFA_FFField::OnRButtonUp(dwFlags, fx, fy)) return FALSE; - GetDoc()->GetDocProvider()->PopupMenu(this, CFX_PointF(fx, fy)); + GetDoc()->GetDocEnvironment()->PopupMenu(this, CFX_PointF(fx, fy)); return TRUE; } FX_BOOL CXFA_FFComboBox::OnKillFocus(CXFA_FFWidget* pNewWidget) { diff --git a/xfa/fxfa/app/xfa_ffdoc.cpp b/xfa/fxfa/app/xfa_ffdoc.cpp index 1aed9c640e..14c4f2d2b4 100644 --- a/xfa/fxfa/app/xfa_ffdoc.cpp +++ b/xfa/fxfa/app/xfa_ffdoc.cpp @@ -147,8 +147,8 @@ int32_t Base64DecodeW(const FX_WCHAR* pSrc, int32_t iSrcLen, uint8_t* pDst) { } // namespace -CXFA_FFDoc::CXFA_FFDoc(CXFA_FFApp* pApp, IXFA_DocProvider* pDocProvider) - : m_pDocProvider(pDocProvider), +CXFA_FFDoc::CXFA_FFDoc(CXFA_FFApp* pApp, IXFA_DocEnvironment* pDocEnvironment) + : m_pDocEnvironment(pDocEnvironment), m_pDocumentParser(nullptr), m_pStream(nullptr), m_pApp(pApp), diff --git a/xfa/fxfa/app/xfa_ffdocview.cpp b/xfa/fxfa/app/xfa_ffdocview.cpp index 0efdef6db1..7dff9d44f4 100644 --- a/xfa/fxfa/app/xfa_ffdocview.cpp +++ b/xfa/fxfa/app/xfa_ffdocview.cpp @@ -250,7 +250,7 @@ void CXFA_FFDocView::ResetWidgetData(CXFA_WidgetAcc* pWidgetAcc) { } } if (bChanged) { - m_pDoc->GetDocProvider()->SetChangeMark(m_pDoc); + m_pDoc->GetDocEnvironment()->SetChangeMark(m_pDoc); } } int32_t CXFA_FFDocView::ProcessWidgetEvent(CXFA_EventParam* pParam, @@ -387,7 +387,7 @@ void CXFA_FFDocView::SetFocusWidgetAcc(CXFA_WidgetAcc* pWidgetAcc) { if (SetFocus(pNewFocus)) { m_pFocusAcc = pWidgetAcc; if (m_iStatus == XFA_DOCVIEW_LAYOUTSTATUS_End) { - m_pDoc->GetDocProvider()->SetFocusWidget(m_pDoc, m_pFocusWidget); + m_pDoc->GetDocEnvironment()->SetFocusWidget(m_pDoc, m_pFocusWidget); } } } @@ -412,7 +412,7 @@ static int32_t XFA_ProcessEvent(CXFA_FFDocView* pDocView, return pWidgetAcc->ProcessCalculate(); case XFA_EVENT_Validate: if (((CXFA_FFDoc*)pDocView->GetDoc()) - ->GetDocProvider() + ->GetDocEnvironment() ->IsValidationsEnabled(pDocView->GetDoc())) { return pWidgetAcc->ProcessValidate(0x01); } @@ -526,7 +526,7 @@ CXFA_WidgetAcc* CXFA_FFDocView::GetWidgetAccByName( void CXFA_FFDocView::OnPageEvent(CXFA_ContainerLayoutItem* pSender, uint32_t dwEvent) { CXFA_FFPageView* pFFPageView = static_cast(pSender); - m_pDoc->GetDocProvider()->PageViewEvent(pFFPageView, dwEvent); + m_pDoc->GetDocEnvironment()->PageViewEvent(pFFPageView, dwEvent); } void CXFA_FFDocView::LockUpdate() { @@ -560,7 +560,7 @@ void CXFA_FFDocView::AddInvalidateRect(CXFA_FFPageView* pPageView, void CXFA_FFDocView::RunInvalidate() { for (const auto& pair : m_mapPageInvalidate) - m_pDoc->GetDocProvider()->InvalidateRect(pair.first, *pair.second, 0); + m_pDoc->GetDocEnvironment()->InvalidateRect(pair.first, *pair.second, 0); m_mapPageInvalidate.clear(); } @@ -572,13 +572,13 @@ FX_BOOL CXFA_FFDocView::RunLayout() { m_pXFADocLayout->DoLayout(); UnlockUpdate(); m_bInLayoutStatus = FALSE; - m_pDoc->GetDocProvider()->PageViewEvent(nullptr, - XFA_PAGEVIEWEVENT_StopLayout); + m_pDoc->GetDocEnvironment()->PageViewEvent(nullptr, + XFA_PAGEVIEWEVENT_StopLayout); return TRUE; } m_bInLayoutStatus = FALSE; - m_pDoc->GetDocProvider()->PageViewEvent(nullptr, - XFA_PAGEVIEWEVENT_StopLayout); + m_pDoc->GetDocEnvironment()->PageViewEvent(nullptr, + XFA_PAGEVIEWEVENT_StopLayout); UnlockUpdate(); return FALSE; } @@ -671,7 +671,7 @@ void CXFA_FFDocView::RunCalculateRecursive(int32_t& iIndex) { } } int32_t CXFA_FFDocView::RunCalculateWidgets() { - if (!m_pDoc->GetDocProvider()->IsCalculationsEnabled(m_pDoc)) { + if (!m_pDoc->GetDocEnvironment()->IsCalculationsEnabled(m_pDoc)) { return XFA_EVENTERROR_Disabled; } int32_t iCounts = m_CalculateAccs.GetSize(); @@ -696,7 +696,7 @@ FX_BOOL CXFA_FFDocView::InitCalculate(CXFA_Node* pNode) { return TRUE; } FX_BOOL CXFA_FFDocView::InitValidate(CXFA_Node* pNode) { - if (!m_pDoc->GetDocProvider()->IsValidationsEnabled(m_pDoc)) { + if (!m_pDoc->GetDocEnvironment()->IsValidationsEnabled(m_pDoc)) { return FALSE; } ExecEventActivityByDeepFirst(pNode, XFA_EVENT_Validate, FALSE, TRUE, nullptr); @@ -704,7 +704,7 @@ FX_BOOL CXFA_FFDocView::InitValidate(CXFA_Node* pNode) { return TRUE; } FX_BOOL CXFA_FFDocView::RunValidate() { - if (!m_pDoc->GetDocProvider()->IsValidationsEnabled(m_pDoc)) { + if (!m_pDoc->GetDocEnvironment()->IsValidationsEnabled(m_pDoc)) { return FALSE; } int32_t iCounts = m_ValidateAccs.GetSize(); @@ -798,7 +798,7 @@ void CXFA_FFDocView::SetChangeMark() { if (m_iStatus < XFA_DOCVIEW_LAYOUTSTATUS_End) { return; } - m_pDoc->GetDocProvider()->SetChangeMark(m_pDoc); + m_pDoc->GetDocEnvironment()->SetChangeMark(m_pDoc); } CXFA_Node* CXFA_FFDocView::GetRootSubform() { CXFA_Node* pFormPacketNode = diff --git a/xfa/fxfa/app/xfa_fffield.cpp b/xfa/fxfa/app/xfa_fffield.cpp index 3274477005..b1a6b5f915 100644 --- a/xfa/fxfa/app/xfa_fffield.cpp +++ b/xfa/fxfa/app/xfa_fffield.cpp @@ -83,7 +83,7 @@ void CXFA_FFField::DrawHighlight(CFX_Graphics* pGS, if ((dwStatus & XFA_WidgetStatus_Highlight) && m_pDataAcc->GetAccess() == XFA_ATTRIBUTEENUM_Open) { CXFA_FFDoc* pDoc = GetDoc(); - CFX_Color crHighlight(pDoc->GetDocProvider()->GetHighlightColor(pDoc)); + CFX_Color crHighlight(pDoc->GetDocEnvironment()->GetHighlightColor(pDoc)); pGS->SetFillColor(&crHighlight); CFX_Path path; path.Create(); diff --git a/xfa/fxfa/app/xfa_ffnotify.cpp b/xfa/fxfa/app/xfa_ffnotify.cpp index 09003f023c..859de5ca39 100644 --- a/xfa/fxfa/app/xfa_ffnotify.cpp +++ b/xfa/fxfa/app/xfa_ffnotify.cpp @@ -238,8 +238,8 @@ void CXFA_FFNotify::AddCalcValidate(CXFA_Node* pNode) { CXFA_FFDoc* CXFA_FFNotify::GetHDOC() { return m_pDoc; } -IXFA_DocProvider* CXFA_FFNotify::GetDocProvider() { - return m_pDoc->GetDocProvider(); +IXFA_DocEnvironment* CXFA_FFNotify::GetDocEnvironment() const { + return m_pDoc->GetDocEnvironment(); } IXFA_AppProvider* CXFA_FFNotify::GetAppProvider() { return m_pDoc->GetApp()->GetAppProvider(); @@ -444,7 +444,7 @@ void CXFA_FFNotify::OnChildAdded(CXFA_Node* pSender) { !(pDocView->m_bInLayoutStatus) && (pDocView->GetLayoutStatus() == XFA_DOCVIEW_LAYOUTSTATUS_End); if (bLayoutReady) - m_pDoc->GetDocProvider()->SetChangeMark(m_pDoc); + m_pDoc->GetDocEnvironment()->SetChangeMark(m_pDoc); } void CXFA_FFNotify::OnChildRemoved() { @@ -456,7 +456,7 @@ void CXFA_FFNotify::OnChildRemoved() { !(pDocView->m_bInLayoutStatus) && (pDocView->GetLayoutStatus() == XFA_DOCVIEW_LAYOUTSTATUS_End); if (bLayoutReady) - m_pDoc->GetDocProvider()->SetChangeMark(m_pDoc); + m_pDoc->GetDocEnvironment()->SetChangeMark(m_pDoc); } void CXFA_FFNotify::OnLayoutItemAdded(CXFA_LayoutProcessor* pLayout, @@ -480,7 +480,7 @@ void CXFA_FFNotify::OnLayoutItemAdded(CXFA_LayoutProcessor* pLayout, (dwStatus & (XFA_WidgetStatus_Visible | XFA_WidgetStatus_Viewable)) == (XFA_WidgetStatus_Visible | XFA_WidgetStatus_Viewable)) { pWidget->SetPageView(pNewPageView); - m_pDoc->GetDocProvider()->WidgetPostAdd(pWidget, pWidget->GetDataAcc()); + m_pDoc->GetDocEnvironment()->WidgetPostAdd(pWidget, pWidget->GetDataAcc()); } if (pDocView->GetLayoutStatus() != XFA_DOCVIEW_LAYOUTSTATUS_End || !(dwStatus & XFA_WidgetStatus_Visible)) { @@ -508,6 +508,6 @@ void CXFA_FFNotify::OnLayoutItemRemoving(CXFA_LayoutProcessor* pLayout, return; pDocView->DeleteLayoutItem(pWidget); - m_pDoc->GetDocProvider()->WidgetPreRemove(pWidget, pWidget->GetDataAcc()); + m_pDoc->GetDocEnvironment()->WidgetPreRemove(pWidget, pWidget->GetDataAcc()); pWidget->AddInvalidateRect(nullptr); } diff --git a/xfa/fxfa/app/xfa_ffnotify.h b/xfa/fxfa/app/xfa_ffnotify.h index ef34afb7b8..fae683c29e 100644 --- a/xfa/fxfa/app/xfa_ffnotify.h +++ b/xfa/fxfa/app/xfa_ffnotify.h @@ -57,7 +57,7 @@ class CXFA_FFNotify { CXFA_WidgetAcc* pExclude = nullptr); void AddCalcValidate(CXFA_Node* pNode); CXFA_FFDoc* GetHDOC(); - IXFA_DocProvider* GetDocProvider(); + IXFA_DocEnvironment* GetDocEnvironment() const; IXFA_AppProvider* GetAppProvider(); CXFA_FFWidgetHandler* GetWidgetHandler(); CXFA_FFWidget* GetHWidget(CXFA_LayoutItem* pLayoutItem); diff --git a/xfa/fxfa/app/xfa_fftext.cpp b/xfa/fxfa/app/xfa_fftext.cpp index 3e5b3df8e9..2e5bb6420d 100644 --- a/xfa/fxfa/app/xfa_fftext.cpp +++ b/xfa/fxfa/app/xfa_fftext.cpp @@ -135,7 +135,7 @@ FX_BOOL CXFA_FFText::OnLButtonUp(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy) { return FALSE; } CXFA_FFDoc* pDoc = GetDoc(); - pDoc->GetDocProvider()->GotoURL(pDoc, wsURLContent, FALSE); + pDoc->GetDocEnvironment()->GotoURL(pDoc, wsURLContent, FALSE); return TRUE; } FWL_WidgetHit CXFA_FFText::OnHitTest(FX_FLOAT fx, FX_FLOAT fy) { diff --git a/xfa/fxfa/app/xfa_fftextedit.cpp b/xfa/fxfa/app/xfa_fftextedit.cpp index 8418da4a81..1dc11adbef 100644 --- a/xfa/fxfa/app/xfa_fftextedit.cpp +++ b/xfa/fxfa/app/xfa_fftextedit.cpp @@ -146,7 +146,7 @@ FX_BOOL CXFA_FFTextEdit::OnRButtonUp(uint32_t dwFlags, if (!CXFA_FFField::OnRButtonUp(dwFlags, fx, fy)) return FALSE; - GetDoc()->GetDocProvider()->PopupMenu(this, CFX_PointF(fx, fy)); + GetDoc()->GetDocEnvironment()->PopupMenu(this, CFX_PointF(fx, fy)); return TRUE; } FX_BOOL CXFA_FFTextEdit::OnSetFocus(CXFA_FFWidget* pOldWidget) { @@ -772,7 +772,7 @@ void CXFA_FFDateTimeEdit::OnSelectChanged(IFWL_Widget* pWidget, CFWL_DateTimePicker* pDateTime = (CFWL_DateTimePicker*)m_pNormalWidget; pDateTime->SetEditText(wsDate); pDateTime->Update(); - GetDoc()->GetDocProvider()->SetFocusWidget(GetDoc(), nullptr); + GetDoc()->GetDocEnvironment()->SetFocusWidget(GetDoc(), nullptr); CXFA_EventParam eParam; eParam.m_eType = XFA_EVENT_Change; eParam.m_pTarget = m_pDataAcc; diff --git a/xfa/fxfa/app/xfa_ffwidget.cpp b/xfa/fxfa/app/xfa_ffwidget.cpp index e8de02d7bd..d71783b275 100644 --- a/xfa/fxfa/app/xfa_ffwidget.cpp +++ b/xfa/fxfa/app/xfa_ffwidget.cpp @@ -153,11 +153,11 @@ void CXFA_FFWidget::InvalidateWidget(const CFX_RectF* pRect) { CFX_RectF rtWidget; GetBBox(rtWidget, XFA_WidgetStatus_Focused); rtWidget.Inflate(2, 2); - GetDoc()->GetDocProvider()->InvalidateRect(m_pPageView, rtWidget, - XFA_INVALIDATE_CurrentPage); + GetDoc()->GetDocEnvironment()->InvalidateRect(m_pPageView, rtWidget, + XFA_INVALIDATE_CurrentPage); } else { - GetDoc()->GetDocProvider()->InvalidateRect(m_pPageView, *pRect, - XFA_INVALIDATE_CurrentPage); + GetDoc()->GetDocEnvironment()->InvalidateRect(m_pPageView, *pRect, + XFA_INVALIDATE_CurrentPage); } } void CXFA_FFWidget::AddInvalidateRect(const CFX_RectF* pRect) { @@ -1083,7 +1083,7 @@ CFX_DIBitmap* XFA_LoadImageData(CXFA_FFDoc* pDoc, return pBitmap; } } - pImageFileRead = pDoc->GetDocProvider()->OpenLinkedFile(pDoc, wsURL); + pImageFileRead = pDoc->GetDocEnvironment()->OpenLinkedFile(pDoc, wsURL); } if (!pImageFileRead) { FX_Free(pImageBuffer); diff --git a/xfa/fxfa/app/xfa_ffwidgetacc.cpp b/xfa/fxfa/app/xfa_ffwidgetacc.cpp index 075f2aa548..592074f916 100644 --- a/xfa/fxfa/app/xfa_ffwidgetacc.cpp +++ b/xfa/fxfa/app/xfa_ffwidgetacc.cpp @@ -334,7 +334,7 @@ int32_t CXFA_WidgetAcc::ProcessEvent(CXFA_Event& event, break; case XFA_Element::Submit: { CXFA_Submit submit = event.GetSubmit(); - return GetDoc()->GetDocProvider()->SubmitData(GetDoc(), submit); + return GetDoc()->GetDocEnvironment()->SubmitData(GetDoc(), submit); } default: break; diff --git a/xfa/fxfa/app/xfa_ffwidgethandler.cpp b/xfa/fxfa/app/xfa_ffwidgethandler.cpp index 7d3da448bf..1c8e5f793b 100644 --- a/xfa/fxfa/app/xfa_ffwidgethandler.cpp +++ b/xfa/fxfa/app/xfa_ffwidgethandler.cpp @@ -46,8 +46,8 @@ FX_BOOL CXFA_FFWidgetHandler::OnLButtonDown(CXFA_FFWidget* hWidget, hWidget->Rotate2Normal(fx, fy); FX_BOOL bRet = hWidget->OnLButtonDown(dwFlags, fx, fy); if (bRet && m_pDocView->SetFocus(hWidget)) { - m_pDocView->GetDoc()->GetDocProvider()->SetFocusWidget(m_pDocView->GetDoc(), - hWidget); + m_pDocView->GetDoc()->GetDocEnvironment()->SetFocusWidget( + m_pDocView->GetDoc(), hWidget); } m_pDocView->UnlockUpdate(); m_pDocView->UpdateDocView(); @@ -105,8 +105,8 @@ FX_BOOL CXFA_FFWidgetHandler::OnRButtonDown(CXFA_FFWidget* hWidget, hWidget->Rotate2Normal(fx, fy); FX_BOOL bRet = hWidget->OnRButtonDown(dwFlags, fx, fy); if (bRet && m_pDocView->SetFocus(hWidget)) { - m_pDocView->GetDoc()->GetDocProvider()->SetFocusWidget(m_pDocView->GetDoc(), - hWidget); + m_pDocView->GetDoc()->GetDocEnvironment()->SetFocusWidget( + m_pDocView->GetDoc(), hWidget); } m_pDocView->RunInvalidate(); return bRet; @@ -225,7 +225,7 @@ int32_t CXFA_FFWidgetHandler::ProcessEvent(CXFA_WidgetAcc* pWidgetAcc, case XFA_EVENT_Calculate: return pWidgetAcc->ProcessCalculate(); case XFA_EVENT_Validate: - if (m_pDocView->GetDoc()->GetDocProvider()->IsValidationsEnabled( + if (m_pDocView->GetDoc()->GetDocEnvironment()->IsValidationsEnabled( m_pDocView->GetDoc())) { return pWidgetAcc->ProcessValidate(); } diff --git a/xfa/fxfa/app/xfa_fwladapter.cpp b/xfa/fxfa/app/xfa_fwladapter.cpp index ea63d84dfb..b0b5f4bc32 100644 --- a/xfa/fxfa/app/xfa_fwladapter.cpp +++ b/xfa/fxfa/app/xfa_fwladapter.cpp @@ -38,7 +38,7 @@ FX_BOOL CXFA_FWLAdapterWidgetMgr::GetPopupPos(IFWL_Widget* pWidget, pFFWidget->GetRotateMatrix(mt); CFX_RectF rtRotateAnchor(rtAnchor); mt.TransformRect(rtRotateAnchor); - pFFWidget->GetDoc()->GetDocProvider()->GetPopupPos( + pFFWidget->GetDoc()->GetDocEnvironment()->GetPopupPos( pFFWidget, fMinHeight, fMaxHeight, rtRotateAnchor, rtPopup); return TRUE; } -- cgit v1.2.3