diff options
Diffstat (limited to 'xfa')
-rw-r--r-- | xfa/fxfa/cxfa_ffcheckbutton.cpp | 11 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_ffcombobox.cpp | 9 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_ffdatetimeedit.cpp | 6 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_ffdocview.cpp | 20 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_fffield.cpp | 36 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_ffimage.cpp | 3 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_ffimageedit.cpp | 2 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_fflistbox.cpp | 2 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_ffnotify.cpp | 11 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_ffnumericedit.cpp | 5 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_ffpasswordedit.cpp | 5 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_ffpushbutton.cpp | 4 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_fftextedit.cpp | 7 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_ffwidget.cpp | 4 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_ffwidgethandler.cpp | 10 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_fwltheme.cpp | 6 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_textlayout.cpp | 12 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_textlayout.h | 3 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_textparser.cpp | 6 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_textparser.h | 4 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_textprovider.h | 2 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_widgetacc.cpp | 236 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_widgetacc.h | 76 |
23 files changed, 248 insertions, 232 deletions
diff --git a/xfa/fxfa/cxfa_ffcheckbutton.cpp b/xfa/fxfa/cxfa_ffcheckbutton.cpp index d82deb3dd0..e7f8e27bc0 100644 --- a/xfa/fxfa/cxfa_ffcheckbutton.cpp +++ b/xfa/fxfa/cxfa_ffcheckbutton.cpp @@ -315,19 +315,22 @@ void CXFA_FFCheckButton::OnProcessEvent(CFWL_Event* pEvent) { if (pFFExclGroup) { m_pDocView->AddValidateWidget(pFFExclGroup); m_pDocView->AddCalculateWidgetAcc(pFFExclGroup); - pFFExclGroup->ProcessEvent(XFA_AttributeEnum::Change, &eParam); + pFFExclGroup->ProcessEvent(GetDocView(), XFA_AttributeEnum::Change, + &eParam); } eParam.m_pTarget = m_pDataAcc.Get(); - m_pDataAcc->ProcessEvent(XFA_AttributeEnum::Change, &eParam); + m_pDataAcc->ProcessEvent(GetDocView(), XFA_AttributeEnum::Change, + &eParam); } else { SetFWLCheckState(m_pDataAcc->GetCheckState()); } if (pFFExclGroup) { eParam.m_pTarget = pFFExclGroup; - pFFExclGroup->ProcessEvent(XFA_AttributeEnum::Click, &eParam); + pFFExclGroup->ProcessEvent(GetDocView(), XFA_AttributeEnum::Click, + &eParam); } eParam.m_pTarget = m_pDataAcc.Get(); - m_pDataAcc->ProcessEvent(XFA_AttributeEnum::Click, &eParam); + m_pDataAcc->ProcessEvent(GetDocView(), XFA_AttributeEnum::Click, &eParam); break; } default: diff --git a/xfa/fxfa/cxfa_ffcombobox.cpp b/xfa/fxfa/cxfa_ffcombobox.cpp index 706c430717..58a0f94f9d 100644 --- a/xfa/fxfa/cxfa_ffcombobox.cpp +++ b/xfa/fxfa/cxfa_ffcombobox.cpp @@ -78,8 +78,7 @@ void CXFA_FFComboBox::UpdateWidgetProperty() { dwEditStyles &= ~FWL_STYLEEXT_EDT_ReadOnly; dwExtendedStyle |= FWL_STYLEEXT_CMB_DropDown; } - if (!m_pDataAcc->IsOpenAccess() || - !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { + if (!m_pDataAcc->IsOpenAccess() || !GetDoc()->GetXFADoc()->IsInteractive()) { dwEditStyles |= FWL_STYLEEXT_EDT_ReadOnly; dwExtendedStyle |= FWL_STYLEEXT_CMB_ReadOnly; } @@ -136,7 +135,7 @@ void CXFA_FFComboBox::FWLEventSelChange(CXFA_EventParam* pParam) { pParam->m_eType = XFA_EVENT_Change; pParam->m_pTarget = m_pDataAcc.Get(); pParam->m_wsNewText = ToComboBox(m_pNormalWidget.get())->GetEditText(); - m_pDataAcc->ProcessEvent(XFA_AttributeEnum::Change, pParam); + m_pDataAcc->ProcessEvent(GetDocView(), XFA_AttributeEnum::Change, pParam); } uint32_t CXFA_FFComboBox::GetAlignment() { @@ -302,14 +301,14 @@ void CXFA_FFComboBox::OnPreOpen(CFWL_Widget* pWidget) { CXFA_EventParam eParam; eParam.m_eType = XFA_EVENT_PreOpen; eParam.m_pTarget = m_pDataAcc.Get(); - m_pDataAcc->ProcessEvent(XFA_AttributeEnum::PreOpen, &eParam); + m_pDataAcc->ProcessEvent(GetDocView(), XFA_AttributeEnum::PreOpen, &eParam); } void CXFA_FFComboBox::OnPostOpen(CFWL_Widget* pWidget) { CXFA_EventParam eParam; eParam.m_eType = XFA_EVENT_PostOpen; eParam.m_pTarget = m_pDataAcc.Get(); - m_pDataAcc->ProcessEvent(XFA_AttributeEnum::PostOpen, &eParam); + m_pDataAcc->ProcessEvent(GetDocView(), XFA_AttributeEnum::PostOpen, &eParam); } void CXFA_FFComboBox::OnProcessMessage(CFWL_Message* pMessage) { diff --git a/xfa/fxfa/cxfa_ffdatetimeedit.cpp b/xfa/fxfa/cxfa_ffdatetimeedit.cpp index 728ad0e11f..d4f925c179 100644 --- a/xfa/fxfa/cxfa_ffdatetimeedit.cpp +++ b/xfa/fxfa/cxfa_ffdatetimeedit.cpp @@ -89,10 +89,8 @@ void CXFA_FFDateTimeEdit::UpdateWidgetProperty() { dwEditStyles |= FWL_STYLEEXT_EDT_CombText; pWidget->SetEditLimit(*numCells); } - if (!m_pDataAcc->IsOpenAccess() || - !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { + if (!m_pDataAcc->IsOpenAccess() || !GetDoc()->GetXFADoc()->IsInteractive()) dwEditStyles |= FWL_STYLEEXT_EDT_ReadOnly; - } if (!m_pDataAcc->IsHorizontalScrollPolicyOff()) dwEditStyles |= FWL_STYLEEXT_EDT_AutoHScroll; @@ -200,7 +198,7 @@ void CXFA_FFDateTimeEdit::OnSelectChanged(CFWL_Widget* pWidget, eParam.m_eType = XFA_EVENT_Change; eParam.m_pTarget = m_pDataAcc.Get(); eParam.m_wsNewText = m_pDataAcc->GetValue(XFA_VALUEPICTURE_Raw); - m_pDataAcc->ProcessEvent(XFA_AttributeEnum::Change, &eParam); + m_pDataAcc->ProcessEvent(GetDocView(), XFA_AttributeEnum::Change, &eParam); } void CXFA_FFDateTimeEdit::OnProcessEvent(CFWL_Event* pEvent) { diff --git a/xfa/fxfa/cxfa_ffdocview.cpp b/xfa/fxfa/cxfa_ffdocview.cpp index 9468624780..a2f5ac4bb1 100644 --- a/xfa/fxfa/cxfa_ffdocview.cpp +++ b/xfa/fxfa/cxfa_ffdocview.cpp @@ -413,12 +413,11 @@ static int32_t XFA_ProcessEvent(CXFA_FFDocView* pDocView, switch (pParam->m_eType) { case XFA_EVENT_Calculate: - return pWidgetAcc->ProcessCalculate(); + return pWidgetAcc->ProcessCalculate(pDocView); case XFA_EVENT_Validate: - if (((CXFA_FFDoc*)pDocView->GetDoc()) - ->GetDocEnvironment() - ->IsValidationsEnabled(pDocView->GetDoc())) { - return pWidgetAcc->ProcessValidate(0x01); + if (pDocView->GetDoc()->GetDocEnvironment()->IsValidationsEnabled( + pDocView->GetDoc())) { + return pWidgetAcc->ProcessValidate(pDocView, 0x01); } return XFA_EVENTERROR_Disabled; case XFA_EVENT_InitCalculate: { @@ -428,13 +427,14 @@ static int32_t XFA_ProcessEvent(CXFA_FFDocView* pDocView, if (pWidgetAcc->GetNode()->IsUserInteractive()) return XFA_EVENTERROR_Disabled; - return pWidgetAcc->ExecuteScript(calc->GetScript(), pParam); + return pWidgetAcc->ExecuteScript(pDocView, calc->GetScript(), pParam); } default: break; } - return pWidgetAcc->ProcessEvent(gs_EventActivity[pParam->m_eType], pParam); + return pWidgetAcc->ProcessEvent(pDocView, gs_EventActivity[pParam->m_eType], + pParam); } int32_t CXFA_FFDocView::ExecEventActivityByDeepFirst(CXFA_Node* pFormNode, @@ -587,7 +587,7 @@ void CXFA_FFDocView::RunSubformIndexChange() { CXFA_EventParam eParam; eParam.m_eType = XFA_EVENT_IndexChange; eParam.m_pTarget = pWidgetAcc; - pWidgetAcc->ProcessEvent(XFA_AttributeEnum::IndexChange, &eParam); + pWidgetAcc->ProcessEvent(this, XFA_AttributeEnum::IndexChange, &eParam); } m_IndexChangedSubforms.clear(); } @@ -648,7 +648,7 @@ size_t CXFA_FFDocView::RunCalculateRecursive(size_t index) { pCurAcc->GetNode()->JSObject()->SetCalcRecursionCount(recurse); if (recurse > 11) break; - if (pCurAcc->ProcessCalculate() == XFA_EVENTERROR_Success) + if (pCurAcc->ProcessCalculate(this) == XFA_EVENTERROR_Success) AddValidateWidget(pCurAcc); index = RunCalculateRecursive(++index); @@ -701,7 +701,7 @@ bool CXFA_FFDocView::RunValidate() { for (CXFA_WidgetAcc* pAcc : m_ValidateAccs) { if (!pAcc->GetNode()->HasRemovedChildren()) - pAcc->ProcessValidate(0); + pAcc->ProcessValidate(this, 0); } m_ValidateAccs.clear(); return true; diff --git a/xfa/fxfa/cxfa_fffield.cpp b/xfa/fxfa/cxfa_fffield.cpp index fbe0d958cb..4fd0a39276 100644 --- a/xfa/fxfa/cxfa_fffield.cpp +++ b/xfa/fxfa/cxfa_fffield.cpp @@ -84,7 +84,7 @@ void CXFA_FFField::DrawHighlight(CXFA_Graphics* pGS, CFX_Matrix* pMatrix, uint32_t dwStatus, bool bEllipse) { - if (m_rtUI.IsEmpty() || !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) + if (m_rtUI.IsEmpty() || !GetDoc()->GetXFADoc()->IsInteractive()) return; if (!(dwStatus & XFA_WidgetStatus_Highlight) || !m_pDataAcc->IsOpenAccess()) return; @@ -127,7 +127,7 @@ bool CXFA_FFField::IsLoaded() { bool CXFA_FFField::LoadWidget() { SetFWLThemeProvider(); - m_pDataAcc->LoadCaption(); + m_pDataAcc->LoadCaption(GetDoc()); PerformLayout(); return true; } @@ -348,7 +348,7 @@ void CXFA_FFField::SetFWLRect() { CFX_RectF rtUi = m_rtUI; if (rtUi.width < 1.0) rtUi.width = 1.0; - if (!m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { + if (!GetDoc()->GetXFADoc()->IsInteractive()) { float fFontSize = m_pDataAcc->GetFontSize(); if (rtUi.height < fFontSize) rtUi.height = fFontSize; @@ -384,10 +384,8 @@ CFX_PointF CXFA_FFField::FWLToClient(const CFX_PointF& point) { bool CXFA_FFField::OnLButtonDown(uint32_t dwFlags, const CFX_PointF& point) { if (!m_pNormalWidget) return false; - if (!m_pDataAcc->IsOpenAccess() || - !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { + if (!m_pDataAcc->IsOpenAccess() || !GetDoc()->GetXFADoc()->IsInteractive()) return false; - } if (!PtInActiveRect(point)) return false; @@ -456,10 +454,8 @@ bool CXFA_FFField::OnMouseWheel(uint32_t dwFlags, bool CXFA_FFField::OnRButtonDown(uint32_t dwFlags, const CFX_PointF& point) { if (!m_pNormalWidget) return false; - if (!m_pDataAcc->IsOpenAccess() || - !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { + if (!m_pDataAcc->IsOpenAccess() || !GetDoc()->GetXFADoc()->IsInteractive()) return false; - } if (!PtInActiveRect(point)) return false; @@ -525,7 +521,7 @@ bool CXFA_FFField::OnKillFocus(CXFA_FFWidget* pNewWidget) { } bool CXFA_FFField::OnKeyDown(uint32_t dwKeyCode, uint32_t dwFlags) { - if (!m_pNormalWidget || !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) + if (!m_pNormalWidget || !GetDoc()->GetXFADoc()->IsInteractive()) return false; CFWL_MessageKey ms(nullptr, m_pNormalWidget.get()); @@ -537,7 +533,7 @@ bool CXFA_FFField::OnKeyDown(uint32_t dwKeyCode, uint32_t dwFlags) { } bool CXFA_FFField::OnKeyUp(uint32_t dwKeyCode, uint32_t dwFlags) { - if (!m_pNormalWidget || !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) + if (!m_pNormalWidget || !GetDoc()->GetXFADoc()->IsInteractive()) return false; CFWL_MessageKey ms(nullptr, m_pNormalWidget.get()); @@ -549,7 +545,7 @@ bool CXFA_FFField::OnKeyUp(uint32_t dwKeyCode, uint32_t dwFlags) { } bool CXFA_FFField::OnChar(uint32_t dwChar, uint32_t dwFlags) { - if (!m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) + if (!GetDoc()->GetXFADoc()->IsInteractive()) return false; if (dwChar == FWL_VKEY_Tab) return true; @@ -665,7 +661,7 @@ int32_t CXFA_FFField::CalculateWidgetAcc(CXFA_WidgetAcc* pAcc) { if (!calc) return 1; - XFA_VERSION version = pAcc->GetDoc()->GetXFADoc()->GetCurVersionMode(); + XFA_VERSION version = GetDoc()->GetXFADoc()->GetCurVersionMode(); switch (calc->GetOverride()) { case XFA_AttributeEnum::Error: { if (version <= XFA_VERSION_204) @@ -739,22 +735,26 @@ void CXFA_FFField::OnProcessEvent(CFWL_Event* pEvent) { CXFA_EventParam eParam; eParam.m_eType = XFA_EVENT_MouseEnter; eParam.m_pTarget = m_pDataAcc.Get(); - m_pDataAcc->ProcessEvent(XFA_AttributeEnum::MouseEnter, &eParam); + m_pDataAcc->ProcessEvent(GetDocView(), XFA_AttributeEnum::MouseEnter, + &eParam); } else if (event->m_dwCmd == FWL_MouseCommand::Leave) { CXFA_EventParam eParam; eParam.m_eType = XFA_EVENT_MouseExit; eParam.m_pTarget = m_pDataAcc.Get(); - m_pDataAcc->ProcessEvent(XFA_AttributeEnum::MouseExit, &eParam); + m_pDataAcc->ProcessEvent(GetDocView(), XFA_AttributeEnum::MouseExit, + &eParam); } else if (event->m_dwCmd == FWL_MouseCommand::LeftButtonDown) { CXFA_EventParam eParam; eParam.m_eType = XFA_EVENT_MouseDown; eParam.m_pTarget = m_pDataAcc.Get(); - m_pDataAcc->ProcessEvent(XFA_AttributeEnum::MouseDown, &eParam); + m_pDataAcc->ProcessEvent(GetDocView(), XFA_AttributeEnum::MouseDown, + &eParam); } else if (event->m_dwCmd == FWL_MouseCommand::LeftButtonUp) { CXFA_EventParam eParam; eParam.m_eType = XFA_EVENT_MouseUp; eParam.m_pTarget = m_pDataAcc.Get(); - m_pDataAcc->ProcessEvent(XFA_AttributeEnum::MouseUp, &eParam); + m_pDataAcc->ProcessEvent(GetDocView(), XFA_AttributeEnum::MouseUp, + &eParam); } break; } @@ -762,7 +762,7 @@ void CXFA_FFField::OnProcessEvent(CFWL_Event* pEvent) { CXFA_EventParam eParam; eParam.m_eType = XFA_EVENT_Click; eParam.m_pTarget = m_pDataAcc.Get(); - m_pDataAcc->ProcessEvent(XFA_AttributeEnum::Click, &eParam); + m_pDataAcc->ProcessEvent(GetDocView(), XFA_AttributeEnum::Click, &eParam); break; } default: diff --git a/xfa/fxfa/cxfa_ffimage.cpp b/xfa/fxfa/cxfa_ffimage.cpp index a285ac907d..2f75264cb2 100644 --- a/xfa/fxfa/cxfa_ffimage.cpp +++ b/xfa/fxfa/cxfa_ffimage.cpp @@ -29,7 +29,8 @@ bool CXFA_FFImage::LoadWidget() { if (GetDataAcc()->GetImageImage()) return true; - return GetDataAcc()->LoadImageImage() ? CXFA_FFDraw::LoadWidget() : false; + return GetDataAcc()->LoadImageImage(GetDoc()) ? CXFA_FFDraw::LoadWidget() + : false; } void CXFA_FFImage::UnloadWidget() { diff --git a/xfa/fxfa/cxfa_ffimageedit.cpp b/xfa/fxfa/cxfa_ffimageedit.cpp index 291b1862bb..3b1338c4d1 100644 --- a/xfa/fxfa/cxfa_ffimageedit.cpp +++ b/xfa/fxfa/cxfa_ffimageedit.cpp @@ -129,7 +129,7 @@ bool CXFA_FFImageEdit::CommitData() { bool CXFA_FFImageEdit::UpdateFWLData() { m_pDataAcc->SetImageEditImage(nullptr); - m_pDataAcc->LoadImageEditImage(); + m_pDataAcc->LoadImageEditImage(GetDoc()); return true; } diff --git a/xfa/fxfa/cxfa_fflistbox.cpp b/xfa/fxfa/cxfa_fflistbox.cpp index c8cb403e55..4099bdbfa6 100644 --- a/xfa/fxfa/cxfa_fflistbox.cpp +++ b/xfa/fxfa/cxfa_fflistbox.cpp @@ -160,7 +160,7 @@ void CXFA_FFListBox::OnSelectChanged(CFWL_Widget* pWidget) { CFWL_ListItem* item = pListBox->GetSelItem(0); eParam.m_wsNewText = item ? item->GetText() : L""; } - m_pDataAcc->ProcessEvent(XFA_AttributeEnum::Change, &eParam); + m_pDataAcc->ProcessEvent(GetDocView(), XFA_AttributeEnum::Change, &eParam); } void CXFA_FFListBox::SetItemState(int32_t nIndex, bool bSelected) { diff --git a/xfa/fxfa/cxfa_ffnotify.cpp b/xfa/fxfa/cxfa_ffnotify.cpp index 1897a4e58f..193c31162e 100644 --- a/xfa/fxfa/cxfa_ffnotify.cpp +++ b/xfa/fxfa/cxfa_ffnotify.cpp @@ -189,14 +189,15 @@ void CXFA_FFNotify::StartFieldDrawLayout(CXFA_Node* pItem, if (!pAcc) return; - pAcc->StartWidgetLayout(fCalcWidth, fCalcHeight); + pAcc->StartWidgetLayout(m_pDoc.Get(), fCalcWidth, fCalcHeight); } bool CXFA_FFNotify::FindSplitPos(CXFA_Node* pItem, int32_t iBlockIndex, float& fCalcHeightPos) { CXFA_WidgetAcc* pAcc = pItem->GetWidgetAcc(); - return pAcc && pAcc->FindSplitPos(iBlockIndex, fCalcHeightPos); + return pAcc && + pAcc->FindSplitPos(m_pDoc->GetDocView(), iBlockIndex, fCalcHeightPos); } bool CXFA_FFNotify::RunScript(CXFA_Script* pScript, CXFA_Node* pFormItem) { @@ -213,7 +214,8 @@ bool CXFA_FFNotify::RunScript(CXFA_Script* pScript, CXFA_Node* pFormItem) { int32_t iRet; bool bRet; - std::tie(iRet, bRet) = pWidgetAcc->ExecuteBoolScript(pScript, &EventParam); + std::tie(iRet, bRet) = + pWidgetAcc->ExecuteBoolScript(pDocView, pScript, &EventParam); return iRet == XFA_EVENTERROR_Success && bRet; } @@ -337,8 +339,7 @@ void CXFA_FFNotify::OnNodeReady(CXFA_Node* pNode) { XFA_Element eType = pNode->GetElementType(); if (XFA_IsCreateWidget(eType)) { - pNode->JSObject()->SetWidgetAcc( - pdfium::MakeUnique<CXFA_WidgetAcc>(pDocView, pNode)); + pNode->JSObject()->SetWidgetAcc(pdfium::MakeUnique<CXFA_WidgetAcc>(pNode)); return; } switch (eType) { diff --git a/xfa/fxfa/cxfa_ffnumericedit.cpp b/xfa/fxfa/cxfa_ffnumericedit.cpp index 6229fdcd2c..be0b306802 100644 --- a/xfa/fxfa/cxfa_ffnumericedit.cpp +++ b/xfa/fxfa/cxfa_ffnumericedit.cpp @@ -59,10 +59,9 @@ void CXFA_FFNumericEdit::UpdateWidgetProperty() { pWidget->SetLimit(*numCells); } dwExtendedStyle |= GetAlignment(); - if (!m_pDataAcc->IsOpenAccess() || - !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { + if (!m_pDataAcc->IsOpenAccess() || !GetDoc()->GetXFADoc()->IsInteractive()) dwExtendedStyle |= FWL_STYLEEXT_EDT_ReadOnly; - } + m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); } diff --git a/xfa/fxfa/cxfa_ffpasswordedit.cpp b/xfa/fxfa/cxfa_ffpasswordedit.cpp index 3bb2eb5b90..c5851ccd2c 100644 --- a/xfa/fxfa/cxfa_ffpasswordedit.cpp +++ b/xfa/fxfa/cxfa_ffpasswordedit.cpp @@ -53,10 +53,9 @@ void CXFA_FFPasswordEdit::UpdateWidgetProperty() { pWidget->SetAliasChar(password[0]); if (!m_pDataAcc->IsHorizontalScrollPolicyOff()) dwExtendedStyle |= FWL_STYLEEXT_EDT_AutoHScroll; - if (!m_pDataAcc->IsOpenAccess() || - !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { + if (!m_pDataAcc->IsOpenAccess() || !GetDoc()->GetXFADoc()->IsInteractive()) dwExtendedStyle |= FWL_STYLEEXT_EDT_ReadOnly; - } + dwExtendedStyle |= GetAlignment(); m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); } diff --git a/xfa/fxfa/cxfa_ffpushbutton.cpp b/xfa/fxfa/cxfa_ffpushbutton.cpp index 0e8548411c..a1250b5785 100644 --- a/xfa/fxfa/cxfa_ffpushbutton.cpp +++ b/xfa/fxfa/cxfa_ffpushbutton.cpp @@ -143,7 +143,7 @@ void CXFA_FFPushButton::LoadHighlightCaption() { m_pDataAcc.Get(), XFA_TEXTPROVIDERTYPE_Rollover); } m_pRolloverTextLayout = - pdfium::MakeUnique<CXFA_TextLayout>(m_pRollProvider.get()); + pdfium::MakeUnique<CXFA_TextLayout>(GetDoc(), m_pRollProvider.get()); } if (m_pDataAcc->HasButtonDown()) { @@ -152,7 +152,7 @@ void CXFA_FFPushButton::LoadHighlightCaption() { m_pDataAcc.Get(), XFA_TEXTPROVIDERTYPE_Down); } m_pDownTextLayout = - pdfium::MakeUnique<CXFA_TextLayout>(m_pDownProvider.get()); + pdfium::MakeUnique<CXFA_TextLayout>(GetDoc(), m_pDownProvider.get()); } } diff --git a/xfa/fxfa/cxfa_fftextedit.cpp b/xfa/fxfa/cxfa_fftextedit.cpp index f1ca3cc565..6f782b34cc 100644 --- a/xfa/fxfa/cxfa_fftextedit.cpp +++ b/xfa/fxfa/cxfa_fftextedit.cpp @@ -80,8 +80,7 @@ void CXFA_FFTextEdit::UpdateWidgetProperty() { } else if (!m_pDataAcc->IsHorizontalScrollPolicyOff()) { dwExtendedStyle |= FWL_STYLEEXT_EDT_AutoHScroll; } - if (!m_pDataAcc->IsOpenAccess() || - !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { + if (!m_pDataAcc->IsOpenAccess() || !GetDoc()->GetXFADoc()->IsInteractive()) { dwExtendedStyle |= FWL_STYLEEXT_EDT_ReadOnly; dwExtendedStyle |= FWL_STYLEEXT_EDT_MultiLine; } @@ -317,14 +316,14 @@ void CXFA_FFTextEdit::OnTextChanged(CFWL_Widget* pWidget, if (pEdit->HasSelection()) std::tie(eParam.m_iSelStart, eParam.m_iSelEnd) = pEdit->GetSelection(); } - m_pDataAcc->ProcessEvent(XFA_AttributeEnum::Change, &eParam); + m_pDataAcc->ProcessEvent(GetDocView(), XFA_AttributeEnum::Change, &eParam); } void CXFA_FFTextEdit::OnTextFull(CFWL_Widget* pWidget) { CXFA_EventParam eParam; eParam.m_eType = XFA_EVENT_Full; eParam.m_pTarget = m_pDataAcc.Get(); - m_pDataAcc->ProcessEvent(XFA_AttributeEnum::Full, &eParam); + m_pDataAcc->ProcessEvent(GetDocView(), XFA_AttributeEnum::Full, &eParam); } bool CXFA_FFTextEdit::CheckWord(const ByteStringView& sWord) { diff --git a/xfa/fxfa/cxfa_ffwidget.cpp b/xfa/fxfa/cxfa_ffwidget.cpp index 467cc7568b..1314b8a3cd 100644 --- a/xfa/fxfa/cxfa_ffwidget.cpp +++ b/xfa/fxfa/cxfa_ffwidget.cpp @@ -1090,7 +1090,7 @@ bool CXFA_FFWidget::OnSetFocus(CXFA_FFWidget* pOldWidget) { CXFA_EventParam eParam; eParam.m_eType = XFA_EVENT_Enter; eParam.m_pTarget = m_pDataAcc.Get(); - m_pDataAcc->ProcessEvent(XFA_AttributeEnum::Enter, &eParam); + m_pDataAcc->ProcessEvent(GetDocView(), XFA_AttributeEnum::Enter, &eParam); return true; } @@ -1342,7 +1342,7 @@ void CXFA_FFWidget::EventKillFocus() { CXFA_EventParam eParam; eParam.m_eType = XFA_EVENT_Exit; eParam.m_pTarget = m_pDataAcc.Get(); - m_pDataAcc->ProcessEvent(XFA_AttributeEnum::Exit, &eParam); + m_pDataAcc->ProcessEvent(GetDocView(), XFA_AttributeEnum::Exit, &eParam); } bool CXFA_FFWidget::IsButtonDown() { diff --git a/xfa/fxfa/cxfa_ffwidgethandler.cpp b/xfa/fxfa/cxfa_ffwidgethandler.cpp index b65321f379..4c21c24e2e 100644 --- a/xfa/fxfa/cxfa_ffwidgethandler.cpp +++ b/xfa/fxfa/cxfa_ffwidgethandler.cpp @@ -216,11 +216,11 @@ int32_t CXFA_FFWidgetHandler::ProcessEvent(CXFA_WidgetAcc* pWidgetAcc, switch (pParam->m_eType) { case XFA_EVENT_Calculate: - return pWidgetAcc->ProcessCalculate(); + return pWidgetAcc->ProcessCalculate(m_pDocView); case XFA_EVENT_Validate: if (m_pDocView->GetDoc()->GetDocEnvironment()->IsValidationsEnabled( m_pDocView->GetDoc())) { - return pWidgetAcc->ProcessValidate(0); + return pWidgetAcc->ProcessValidate(m_pDocView, 0); } return XFA_EVENTERROR_Disabled; case XFA_EVENT_InitCalculate: { @@ -229,13 +229,13 @@ int32_t CXFA_FFWidgetHandler::ProcessEvent(CXFA_WidgetAcc* pWidgetAcc, return XFA_EVENTERROR_NotExist; if (pWidgetAcc->GetNode()->IsUserInteractive()) return XFA_EVENTERROR_Disabled; - return pWidgetAcc->ExecuteScript(calc->GetScript(), pParam); + return pWidgetAcc->ExecuteScript(m_pDocView, calc->GetScript(), pParam); } default: break; } - int32_t iRet = - pWidgetAcc->ProcessEvent(gs_EventActivity[pParam->m_eType], pParam); + int32_t iRet = pWidgetAcc->ProcessEvent( + m_pDocView, gs_EventActivity[pParam->m_eType], pParam); return iRet; } diff --git a/xfa/fxfa/cxfa_fwltheme.cpp b/xfa/fxfa/cxfa_fwltheme.cpp index 8330ed49d8..f42c9ac022 100644 --- a/xfa/fxfa/cxfa_fwltheme.cpp +++ b/xfa/fxfa/cxfa_fwltheme.cpp @@ -133,7 +133,7 @@ void CXFA_FWLTheme::DrawText(CFWL_ThemeText* pParams) { m_pTextOut->SetStyles(pParams->m_dwTTOStyles); m_pTextOut->SetAlignment(pParams->m_iTTOAlign); - m_pTextOut->SetFont(pAcc->GetFDEFont()); + m_pTextOut->SetFont(pAcc->GetFDEFont(pWidget->GetDoc())); m_pTextOut->SetFontSize(pAcc->GetFontSize()); m_pTextOut->SetTextColor(pAcc->GetTextColor()); CFX_Matrix mtPart = pParams->m_matrix; @@ -190,7 +190,7 @@ float CXFA_FWLTheme::GetFontSize(CFWL_ThemePart* pThemePart) const { RetainPtr<CFGAS_GEFont> CXFA_FWLTheme::GetFont( CFWL_ThemePart* pThemePart) const { if (CXFA_FFWidget* pWidget = XFA_ThemeGetOuterWidget(pThemePart->m_pWidget)) - return pWidget->GetDataAcc()->GetFDEFont(); + return pWidget->GetDataAcc()->GetFDEFont(pWidget->GetDoc()); return GetTheme(pThemePart->m_pWidget)->GetFont(); } @@ -242,7 +242,7 @@ void CXFA_FWLTheme::CalcTextRect(CFWL_ThemeText* pParams, CFX_RectF& rect) { return; CXFA_WidgetAcc* pAcc = pWidget->GetDataAcc(); - m_pTextOut->SetFont(pAcc->GetFDEFont()); + m_pTextOut->SetFont(pAcc->GetFDEFont(pWidget->GetDoc())); m_pTextOut->SetFontSize(pAcc->GetFontSize()); m_pTextOut->SetTextColor(pAcc->GetTextColor()); if (!pParams) diff --git a/xfa/fxfa/cxfa_textlayout.cpp b/xfa/fxfa/cxfa_textlayout.cpp index 6f19e8add1..3be45352f7 100644 --- a/xfa/fxfa/cxfa_textlayout.cpp +++ b/xfa/fxfa/cxfa_textlayout.cpp @@ -33,8 +33,10 @@ #define XFA_LOADERCNTXTFLG_FILTERSPACE 0x001 -CXFA_TextLayout::CXFA_TextLayout(CXFA_TextProvider* pTextProvider) +CXFA_TextLayout::CXFA_TextLayout(CXFA_FFDoc* doc, + CXFA_TextProvider* pTextProvider) : m_bHasBlock(false), + m_pDoc(doc), m_pTextProvider(pTextProvider), m_pTextDataNode(nullptr), m_bRichText(false), @@ -96,7 +98,7 @@ std::unique_ptr<CFX_RTFBreak> CXFA_TextLayout::CreateBreak(bool bDefault) { auto pBreak = pdfium::MakeUnique<CFX_RTFBreak>(dwStyle); pBreak->SetLineBreakTolerance(1); - pBreak->SetFont(m_textParser.GetFont(m_pTextProvider, nullptr)); + pBreak->SetFont(m_textParser.GetFont(m_pDoc, m_pTextProvider, nullptr)); pBreak->SetFontSize(m_textParser.GetFontSize(m_pTextProvider, nullptr)); return pBreak; } @@ -158,7 +160,7 @@ void CXFA_TextLayout::InitBreak(float fLineWidth) { float fFontSize = m_textParser.GetFontSize(m_pTextProvider, nullptr); m_pBreak->SetFontSize(fFontSize); - m_pBreak->SetFont(m_textParser.GetFont(m_pTextProvider, nullptr)); + m_pBreak->SetFont(m_textParser.GetFont(m_pDoc, m_pTextProvider, nullptr)); m_pBreak->SetLineBreakTolerance(fFontSize * 0.2f); } @@ -238,7 +240,7 @@ void CXFA_TextLayout::InitBreak(CFX_CSSComputedStyle* pStyle, float fFontSize = m_textParser.GetFontSize(m_pTextProvider, pStyle); m_pBreak->SetFontSize(fFontSize); m_pBreak->SetLineBreakTolerance(fFontSize * 0.2f); - m_pBreak->SetFont(m_textParser.GetFont(m_pTextProvider, pStyle)); + m_pBreak->SetFont(m_textParser.GetFont(m_pDoc, m_pTextProvider, pStyle)); m_pBreak->SetHorizontalScale( m_textParser.GetHorScale(m_pTextProvider, pStyle, pXMLNode)); m_pBreak->SetVerticalScale(m_textParser.GetVerScale(m_pTextProvider, pStyle)); @@ -1031,7 +1033,7 @@ void CXFA_TextLayout::AppendTextLine(CFX_BreakType dwStatus, m_textParser.GetLinethrough(m_pTextProvider, pStyle.Get(), pTP->iLineThrough); pTP->dwColor = m_textParser.GetColor(m_pTextProvider, pStyle.Get()); - pTP->pFont = m_textParser.GetFont(m_pTextProvider, pStyle.Get()); + pTP->pFont = m_textParser.GetFont(m_pDoc, m_pTextProvider, pStyle.Get()); pTP->fFontSize = m_textParser.GetFontSize(m_pTextProvider, pStyle.Get()); pTP->rtPiece.left = pPiece->m_iStartPos / 20000.0f; pTP->rtPiece.width = pPiece->m_iWidth / 20000.0f; diff --git a/xfa/fxfa/cxfa_textlayout.h b/xfa/fxfa/cxfa_textlayout.h index 070a2bd87d..73aee36eef 100644 --- a/xfa/fxfa/cxfa_textlayout.h +++ b/xfa/fxfa/cxfa_textlayout.h @@ -30,7 +30,7 @@ class CXFA_TextPiece; class CXFA_TextLayout { public: - explicit CXFA_TextLayout(CXFA_TextProvider* pTextProvider); + explicit CXFA_TextLayout(CXFA_FFDoc* doc, CXFA_TextProvider* pTextProvider); ~CXFA_TextLayout(); float GetLayoutHeight(); @@ -110,6 +110,7 @@ class CXFA_TextLayout { bool Layout(int32_t iBlock); int32_t CountBlocks() const; + CXFA_FFDoc* m_pDoc; CXFA_TextProvider* m_pTextProvider; CXFA_Node* m_pTextDataNode; bool m_bRichText; diff --git a/xfa/fxfa/cxfa_textparser.cpp b/xfa/fxfa/cxfa_textparser.cpp index b6538aa933..03cba8e8e2 100644 --- a/xfa/fxfa/cxfa_textparser.cpp +++ b/xfa/fxfa/cxfa_textparser.cpp @@ -325,6 +325,7 @@ bool CXFA_TextParser::IsSpaceRun(CFX_CSSComputedStyle* pStyle) const { } RetainPtr<CFGAS_GEFont> CXFA_TextParser::GetFont( + CXFA_FFDoc* doc, CXFA_TextProvider* pTextProvider, CFX_CSSComputedStyle* pStyle) const { WideString wsFamily = L"Courier"; @@ -350,9 +351,8 @@ RetainPtr<CFGAS_GEFont> CXFA_TextParser::GetFont( dwStyle |= FXFONT_ITALIC; } - CXFA_FFDoc* pDoc = pTextProvider->GetDocNode(); - CXFA_FontMgr* pFontMgr = pDoc->GetApp()->GetXFAFontMgr(); - return pFontMgr->GetFont(pDoc, wsFamily.AsStringView(), dwStyle); + CXFA_FontMgr* pFontMgr = doc->GetApp()->GetXFAFontMgr(); + return pFontMgr->GetFont(doc, wsFamily.AsStringView(), dwStyle); } float CXFA_TextParser::GetFontSize(CXFA_TextProvider* pTextProvider, diff --git a/xfa/fxfa/cxfa_textparser.h b/xfa/fxfa/cxfa_textparser.h index 4c0c95e356..336e227221 100644 --- a/xfa/fxfa/cxfa_textparser.h +++ b/xfa/fxfa/cxfa_textparser.h @@ -21,6 +21,7 @@ class CFX_CSSComputedStyle; class CFX_CSSStyleSelector; class CFX_CSSStyleSheet; class CFX_XMLNode; +class CXFA_FFDoc; class CXFA_TextParseContext; class CXFA_TextProvider; class CXFA_TextTabstopsContext; @@ -50,7 +51,8 @@ class CXFA_TextParser { bool GetTabstops(CFX_CSSComputedStyle* pStyle, CXFA_TextTabstopsContext* pTabstopContext); - RetainPtr<CFGAS_GEFont> GetFont(CXFA_TextProvider* pTextProvider, + RetainPtr<CFGAS_GEFont> GetFont(CXFA_FFDoc* doc, + CXFA_TextProvider* pTextProvider, CFX_CSSComputedStyle* pStyle) const; float GetFontSize(CXFA_TextProvider* pTextProvider, CFX_CSSComputedStyle* pStyle) const; diff --git a/xfa/fxfa/cxfa_textprovider.h b/xfa/fxfa/cxfa_textprovider.h index 875355a27c..8a69d87812 100644 --- a/xfa/fxfa/cxfa_textprovider.h +++ b/xfa/fxfa/cxfa_textprovider.h @@ -11,7 +11,6 @@ #include "xfa/fxfa/cxfa_textlayout.h" #include "xfa/fxfa/cxfa_widgetacc.h" -class CXFA_FFDoc; class CXFA_Font; class CXFA_Node; @@ -35,7 +34,6 @@ class CXFA_TextProvider { CXFA_Para* GetPara(); CXFA_Font* GetFont(); bool IsCheckButtonAndAutoWidth(); - CXFA_FFDoc* GetDocNode() { return m_pWidgetAcc->GetDoc(); } bool GetEmbbedObj(bool bURI, bool bRaw, const WideString& wsAttr, diff --git a/xfa/fxfa/cxfa_widgetacc.cpp b/xfa/fxfa/cxfa_widgetacc.cpp index 96701512f9..88aaf42a55 100644 --- a/xfa/fxfa/cxfa_widgetacc.cpp +++ b/xfa/fxfa/cxfa_widgetacc.cpp @@ -68,13 +68,14 @@ class CXFA_TextLayoutData : public CXFA_WidgetLayoutData { CXFA_TextLayout* GetTextLayout() const { return m_pTextLayout.get(); } CXFA_TextProvider* GetTextProvider() const { return m_pTextProvider.get(); } - void LoadText(CXFA_WidgetAcc* pAcc) { + void LoadText(CXFA_FFDoc* doc, CXFA_WidgetAcc* pAcc) { if (m_pTextLayout) return; m_pTextProvider = pdfium::MakeUnique<CXFA_TextProvider>(pAcc, XFA_TEXTPROVIDERTYPE_Text); - m_pTextLayout = pdfium::MakeUnique<CXFA_TextLayout>(m_pTextProvider.get()); + m_pTextLayout = + pdfium::MakeUnique<CXFA_TextLayout>(doc, m_pTextProvider.get()); } private: @@ -89,7 +90,7 @@ class CXFA_ImageLayoutData : public CXFA_WidgetLayoutData { ~CXFA_ImageLayoutData() override {} - bool LoadImageData(CXFA_WidgetAcc* pAcc) { + bool LoadImageData(CXFA_FFDoc* doc, CXFA_WidgetAcc* pAcc) { if (m_pDIBitmap) return true; @@ -101,8 +102,7 @@ class CXFA_ImageLayoutData : public CXFA_WidgetLayoutData { if (!image) return false; - CXFA_FFDoc* pFFDoc = pAcc->GetDoc(); - pAcc->SetImageImage(XFA_LoadImageData(pFFDoc, image, m_bNamedImage, + pAcc->SetImageImage(XFA_LoadImageData(doc, image, m_bNamedImage, m_iImageXDpi, m_iImageYDpi)); return !!m_pDIBitmap; } @@ -118,7 +118,7 @@ class CXFA_FieldLayoutData : public CXFA_WidgetLayoutData { CXFA_FieldLayoutData() {} ~CXFA_FieldLayoutData() override {} - bool LoadCaption(CXFA_WidgetAcc* pAcc) { + bool LoadCaption(CXFA_FFDoc* doc, CXFA_WidgetAcc* pAcc) { if (m_pCapTextLayout) return true; CXFA_Caption* caption = pAcc->GetCaption(); @@ -128,7 +128,7 @@ class CXFA_FieldLayoutData : public CXFA_WidgetLayoutData { m_pCapTextProvider = pdfium::MakeUnique<CXFA_TextProvider>( pAcc, XFA_TEXTPROVIDERTYPE_Caption); m_pCapTextLayout = - pdfium::MakeUnique<CXFA_TextLayout>(m_pCapTextProvider.get()); + pdfium::MakeUnique<CXFA_TextLayout>(doc, m_pCapTextProvider.get()); return true; } @@ -138,9 +138,7 @@ class CXFA_FieldLayoutData : public CXFA_WidgetLayoutData { std::vector<float> m_FieldSplitArray; }; -class CXFA_TextEditData : public CXFA_FieldLayoutData { - public: -}; +class CXFA_TextEditData : public CXFA_FieldLayoutData {}; class CXFA_ImageEditData : public CXFA_FieldLayoutData { public: @@ -149,7 +147,7 @@ class CXFA_ImageEditData : public CXFA_FieldLayoutData { ~CXFA_ImageEditData() override {} - bool LoadImageData(CXFA_WidgetAcc* pAcc) { + bool LoadImageData(CXFA_FFDoc* doc, CXFA_WidgetAcc* pAcc) { if (m_pDIBitmap) return true; @@ -158,8 +156,7 @@ class CXFA_ImageEditData : public CXFA_FieldLayoutData { return false; CXFA_Image* image = value->GetImage(); - CXFA_FFDoc* pFFDoc = pAcc->GetDoc(); - pAcc->SetImageEditImage(XFA_LoadImageData(pFFDoc, image, m_bNamedImage, + pAcc->SetImageEditImage(XFA_LoadImageData(doc, image, m_bNamedImage, m_iImageXDpi, m_iImageYDpi)); return !!m_pDIBitmap; } @@ -357,9 +354,8 @@ CXFA_Node* CreateUIChild(CXFA_Node* pNode, XFA_Element& eWidgetType) { } // namespace -CXFA_WidgetAcc::CXFA_WidgetAcc(CXFA_FFDocView* pDocView, CXFA_Node* pNode) - : m_pDocView(pDocView), - m_nRecursionDepth(0), +CXFA_WidgetAcc::CXFA_WidgetAcc(CXFA_Node* pNode) + : m_nRecursionDepth(0), m_bIsNull(true), m_bPreNull(true), m_pUiChildNode(nullptr), @@ -480,15 +476,8 @@ CXFA_WidgetAcc* CXFA_WidgetAcc::GetExclGroup() { return pExcl->GetWidgetAcc(); } -CXFA_FFDoc* CXFA_WidgetAcc::GetDoc() { - return m_pDocView->GetDoc(); -} - -IXFA_AppProvider* CXFA_WidgetAcc::GetAppProvider() { - return GetDoc()->GetApp()->GetAppProvider(); -} - -int32_t CXFA_WidgetAcc::ProcessEvent(XFA_AttributeEnum iActivity, +int32_t CXFA_WidgetAcc::ProcessEvent(CXFA_FFDocView* docView, + XFA_AttributeEnum iActivity, CXFA_EventParam* pEventParam) { if (GetElementType() == XFA_Element::Draw) return XFA_EVENTERROR_NotExist; @@ -498,7 +487,7 @@ int32_t CXFA_WidgetAcc::ProcessEvent(XFA_AttributeEnum iActivity, bool first = true; int32_t iRet = XFA_EVENTERROR_NotExist; for (CXFA_Event* event : eventArray) { - int32_t result = ProcessEvent(event, pEventParam); + int32_t result = ProcessEvent(docView, event, pEventParam); if (first || result == XFA_EVENTERROR_Success) iRet = result; first = false; @@ -506,7 +495,8 @@ int32_t CXFA_WidgetAcc::ProcessEvent(XFA_AttributeEnum iActivity, return iRet; } -int32_t CXFA_WidgetAcc::ProcessEvent(CXFA_Event* event, +int32_t CXFA_WidgetAcc::ProcessEvent(CXFA_FFDocView* docView, + CXFA_Event* event, CXFA_EventParam* pEventParam) { if (!event) return XFA_EVENTERROR_NotExist; @@ -515,19 +505,19 @@ int32_t CXFA_WidgetAcc::ProcessEvent(CXFA_Event* event, case XFA_Element::Execute: break; case XFA_Element::Script: - return ExecuteScript(event->GetScript(), pEventParam); + return ExecuteScript(docView, event->GetScript(), pEventParam); case XFA_Element::SignData: break; case XFA_Element::Submit: - return GetDoc()->GetDocEnvironment()->Submit(GetDoc(), - event->GetSubmit()); + return docView->GetDoc()->GetDocEnvironment()->Submit(docView->GetDoc(), + event->GetSubmit()); default: break; } return XFA_EVENTERROR_NotExist; } -int32_t CXFA_WidgetAcc::ProcessCalculate() { +int32_t CXFA_WidgetAcc::ProcessCalculate(CXFA_FFDocView* docView) { if (GetElementType() == XFA_Element::Draw) return XFA_EVENTERROR_NotExist; @@ -539,18 +529,19 @@ int32_t CXFA_WidgetAcc::ProcessCalculate() { CXFA_EventParam EventParam; EventParam.m_eType = XFA_EVENT_Calculate; - int32_t iRet = ExecuteScript(calc->GetScript(), &EventParam); + int32_t iRet = ExecuteScript(docView, calc->GetScript(), &EventParam); if (iRet != XFA_EVENTERROR_Success) return iRet; if (GetRawValue() != EventParam.m_wsResult) { SetValue(XFA_VALUEPICTURE_Raw, EventParam.m_wsResult); - UpdateUIDisplay(m_pDocView, nullptr); + UpdateUIDisplay(docView, nullptr); } return XFA_EVENTERROR_Success; } -void CXFA_WidgetAcc::ProcessScriptTestValidate(CXFA_Validate* validate, +void CXFA_WidgetAcc::ProcessScriptTestValidate(CXFA_FFDocView* docView, + CXFA_Validate* validate, int32_t iRet, bool bRetValue, bool bVersionFlag) { @@ -559,7 +550,8 @@ void CXFA_WidgetAcc::ProcessScriptTestValidate(CXFA_Validate* validate, if (bRetValue) return; - IXFA_AppProvider* pAppProvider = GetAppProvider(); + IXFA_AppProvider* pAppProvider = + docView->GetDoc()->GetApp()->GetAppProvider(); if (!pAppProvider) return; @@ -587,7 +579,8 @@ void CXFA_WidgetAcc::ProcessScriptTestValidate(CXFA_Validate* validate, pAppProvider->MsgBox(wsScriptMsg, wsTitle, XFA_MBICON_Error, XFA_MB_OK); } -int32_t CXFA_WidgetAcc::ProcessFormatTestValidate(CXFA_Validate* validate, +int32_t CXFA_WidgetAcc::ProcessFormatTestValidate(CXFA_FFDocView* docView, + CXFA_Validate* validate, bool bVersionFlag) { WideString wsRawValue = GetRawValue(); if (!wsRawValue.IsEmpty()) { @@ -602,7 +595,8 @@ int32_t CXFA_WidgetAcc::ProcessFormatTestValidate(CXFA_Validate* validate, CXFA_LocaleValue lcValue = XFA_GetLocaleValue(this); if (!lcValue.ValidateValue(lcValue.GetValue(), wsPicture, pLocale, nullptr)) { - IXFA_AppProvider* pAppProvider = GetAppProvider(); + IXFA_AppProvider* pAppProvider = + docView->GetDoc()->GetApp()->GetAppProvider(); if (!pAppProvider) return XFA_EVENTERROR_NotExist; @@ -634,7 +628,8 @@ int32_t CXFA_WidgetAcc::ProcessFormatTestValidate(CXFA_Validate* validate, return XFA_EVENTERROR_NotExist; } -int32_t CXFA_WidgetAcc::ProcessNullTestValidate(CXFA_Validate* validate, +int32_t CXFA_WidgetAcc::ProcessNullTestValidate(CXFA_FFDocView* docView, + CXFA_Validate* validate, int32_t iFlags, bool bVersionFlag) { if (!GetValue(XFA_VALUEPICTURE_Raw).IsEmpty()) @@ -651,7 +646,7 @@ int32_t CXFA_WidgetAcc::ProcessNullTestValidate(CXFA_Validate* validate, if (!wsNullMsg.IsEmpty()) { if (eNullTest != XFA_AttributeEnum::Disabled) { - m_pDocView->m_arrNullTestMsg.push_back(wsNullMsg); + docView->m_arrNullTestMsg.push_back(wsNullMsg); return XFA_EVENTERROR_Error; } return XFA_EVENTERROR_Success; @@ -662,7 +657,8 @@ int32_t CXFA_WidgetAcc::ProcessNullTestValidate(CXFA_Validate* validate, eNullTest != XFA_AttributeEnum::Disabled) { return XFA_EVENTERROR_Error; } - IXFA_AppProvider* pAppProvider = GetAppProvider(); + IXFA_AppProvider* pAppProvider = + docView->GetDoc()->GetApp()->GetAppProvider(); if (!pAppProvider) return XFA_EVENTERROR_NotExist; @@ -735,7 +731,8 @@ WideString CXFA_WidgetAcc::GetValidateMessage(bool bError, bool bVersionFlag) { wsCaptionName.c_str(), wsCaptionName.c_str()); } -int32_t CXFA_WidgetAcc::ProcessValidate(int32_t iFlags) { +int32_t CXFA_WidgetAcc::ProcessValidate(CXFA_FFDocView* docView, + int32_t iFlags) { if (GetElementType() == XFA_Element::Draw) return XFA_EVENTERROR_NotExist; @@ -744,7 +741,7 @@ int32_t CXFA_WidgetAcc::ProcessValidate(int32_t iFlags) { return XFA_EVENTERROR_NotExist; bool bInitDoc = validate->NeedsInitApp(); - bool bStatus = m_pDocView->GetLayoutStatus() < XFA_DOCVIEW_LAYOUTSTATUS_End; + bool bStatus = docView->GetLayoutStatus() < XFA_DOCVIEW_LAYOUTSTATUS_End; int32_t iFormat = 0; int32_t iRet = XFA_EVENTERROR_NotExist; CXFA_Script* script = validate->GetScript(); @@ -754,10 +751,10 @@ int32_t CXFA_WidgetAcc::ProcessValidate(int32_t iFlags) { CXFA_EventParam eParam; eParam.m_eType = XFA_EVENT_Validate; eParam.m_pTarget = this; - std::tie(iRet, bRet) = ExecuteBoolScript(script, &eParam); + std::tie(iRet, bRet) = ExecuteBoolScript(docView, script, &eParam); } - XFA_VERSION version = GetDoc()->GetXFADoc()->GetCurVersionMode(); + XFA_VERSION version = docView->GetDoc()->GetXFADoc()->GetCurVersionMode(); bool bVersionFlag = false; if (version < XFA_VERSION_208) bVersionFlag = true; @@ -765,28 +762,32 @@ int32_t CXFA_WidgetAcc::ProcessValidate(int32_t iFlags) { if (bInitDoc) { validate->ClearFlag(XFA_NodeFlag_NeedsInitApp); } else { - iFormat = ProcessFormatTestValidate(validate, bVersionFlag); - if (!bVersionFlag) - bVersionFlag = GetDoc()->GetXFADoc()->HasFlag(XFA_DOCFLAG_Scripting); + iFormat = ProcessFormatTestValidate(docView, validate, bVersionFlag); + if (!bVersionFlag) { + bVersionFlag = + docView->GetDoc()->GetXFADoc()->HasFlag(XFA_DOCFLAG_Scripting); + } - iRet |= ProcessNullTestValidate(validate, iFlags, bVersionFlag); + iRet |= ProcessNullTestValidate(docView, validate, iFlags, bVersionFlag); } if (iFormat != XFA_EVENTERROR_Success && hasBoolResult) - ProcessScriptTestValidate(validate, iRet, bRet, bVersionFlag); + ProcessScriptTestValidate(docView, validate, iRet, bRet, bVersionFlag); return iRet | iFormat; } -int32_t CXFA_WidgetAcc::ExecuteScript(CXFA_Script* script, +int32_t CXFA_WidgetAcc::ExecuteScript(CXFA_FFDocView* docView, + CXFA_Script* script, CXFA_EventParam* pEventParam) { bool bRet; int32_t iRet; - std::tie(iRet, bRet) = ExecuteBoolScript(script, pEventParam); + std::tie(iRet, bRet) = ExecuteBoolScript(docView, script, pEventParam); return iRet; } std::pair<int32_t, bool> CXFA_WidgetAcc::ExecuteBoolScript( + CXFA_FFDocView* docView, CXFA_Script* script, CXFA_EventParam* pEventParam) { static const uint32_t MAX_RECURSION_DEPTH = 2; @@ -807,7 +808,7 @@ std::pair<int32_t, bool> CXFA_WidgetAcc::ExecuteBoolScript( if (eScriptType == CXFA_Script::Type::Unknown) return {XFA_EVENTERROR_Success, false}; - CXFA_FFDoc* pDoc = GetDoc(); + CXFA_FFDoc* pDoc = docView->GetDoc(); CFXJSE_Engine* pContext = pDoc->GetXFADoc()->GetScriptContext(); pContext->SetEventParam(*pEventParam); pContext->SetRunAtType(script->GetRunAt()); @@ -840,7 +841,7 @@ std::pair<int32_t, bool> CXFA_WidgetAcc::ExecuteBoolScript( if ((iRet == XFA_EVENTERROR_Success) && (GetRawValue() != pEventParam->m_wsResult)) { SetValue(XFA_VALUEPICTURE_Raw, pEventParam->m_wsResult); - m_pDocView->AddValidateWidget(this); + docView->AddValidateWidget(this); } } for (CXFA_Node* pRefNode : refNodes) { @@ -880,12 +881,13 @@ void CXFA_WidgetAcc::UpdateUIDisplay(CXFA_FFDocView* docView, } } -void CXFA_WidgetAcc::CalcCaptionSize(CFX_SizeF& szCap) { +void CXFA_WidgetAcc::CalcCaptionSize(CXFA_FFDoc* doc, CFX_SizeF& szCap) { CXFA_Caption* caption = GetCaption(); if (!caption || !caption->IsVisible()) return; - LoadCaption(); + LoadCaption(doc); + XFA_Element eUIType = GetUIType(); XFA_AttributeEnum iCapPlacement = caption->GetPlacementType(); float fCapReserve = caption->GetReserve(); @@ -938,9 +940,10 @@ void CXFA_WidgetAcc::CalcCaptionSize(CFX_SizeF& szCap) { } } -bool CXFA_WidgetAcc::CalculateFieldAutoSize(CFX_SizeF& size) { +bool CXFA_WidgetAcc::CalculateFieldAutoSize(CXFA_FFDoc* doc, CFX_SizeF& size) { CFX_SizeF szCap; - CalcCaptionSize(szCap); + CalcCaptionSize(doc, szCap); + CFX_RectF rtUIMargin = GetUIMargin(); size.width += rtUIMargin.left + rtUIMargin.width; size.height += rtUIMargin.top + rtUIMargin.height; @@ -1003,7 +1006,8 @@ bool CXFA_WidgetAcc::CalculateWidgetAutoSize(CFX_SizeF& size) { return true; } -void CXFA_WidgetAcc::CalculateTextContentSize(CFX_SizeF& size) { +void CXFA_WidgetAcc::CalculateTextContentSize(CXFA_FFDoc* doc, + CFX_SizeF& size) { float fFontSize = GetFontSize(); WideString wsText = GetValue(XFA_VALUEPICTURE_Display); if (wsText.IsEmpty()) { @@ -1021,7 +1025,7 @@ void CXFA_WidgetAcc::CalculateTextContentSize(CFX_SizeF& size) { if (!layoutData->m_pTextOut) { layoutData->m_pTextOut = pdfium::MakeUnique<CFDE_TextOut>(); CFDE_TextOut* pTextOut = layoutData->m_pTextOut.get(); - pTextOut->SetFont(GetFDEFont()); + pTextOut->SetFont(GetFDEFont(doc)); pTextOut->SetFontSize(fFontSize); pTextOut->SetLineBreakTolerance(fFontSize * 0.2f); pTextOut->SetLineSpace(GetLineHeight()); @@ -1036,11 +1040,12 @@ void CXFA_WidgetAcc::CalculateTextContentSize(CFX_SizeF& size) { layoutData->m_pTextOut->CalcLogicSize(wsText, size); } -bool CXFA_WidgetAcc::CalculateTextEditAutoSize(CFX_SizeF& size) { +bool CXFA_WidgetAcc::CalculateTextEditAutoSize(CXFA_FFDoc* doc, + CFX_SizeF& size) { if (size.width > 0) { CFX_SizeF szOrz = size; CFX_SizeF szCap; - CalcCaptionSize(szCap); + CalcCaptionSize(doc, szCap); bool bCapExit = szCap.width > 0.01 && szCap.height > 0.01; XFA_AttributeEnum iCapPlacement = XFA_AttributeEnum::Unknown; if (bCapExit) { @@ -1061,7 +1066,7 @@ bool CXFA_WidgetAcc::CalculateTextEditAutoSize(CFX_SizeF& size) { if (margin) size.width -= margin->GetLeftInset() + margin->GetRightInset(); - CalculateTextContentSize(size); + CalculateTextContentSize(doc, size); size.height += rtUIMargin.top + rtUIMargin.height; if (bCapExit) { switch (iCapPlacement) { @@ -1081,18 +1086,20 @@ bool CXFA_WidgetAcc::CalculateTextEditAutoSize(CFX_SizeF& size) { size.width = szOrz.width; return CalculateWidgetAutoSize(size); } - CalculateTextContentSize(size); - return CalculateFieldAutoSize(size); + CalculateTextContentSize(doc, size); + return CalculateFieldAutoSize(doc, size); } -bool CXFA_WidgetAcc::CalculateCheckButtonAutoSize(CFX_SizeF& size) { +bool CXFA_WidgetAcc::CalculateCheckButtonAutoSize(CXFA_FFDoc* doc, + CFX_SizeF& size) { float fCheckSize = GetCheckButtonSize(); size = CFX_SizeF(fCheckSize, fCheckSize); - return CalculateFieldAutoSize(size); + return CalculateFieldAutoSize(doc, size); } -bool CXFA_WidgetAcc::CalculatePushButtonAutoSize(CFX_SizeF& size) { - CalcCaptionSize(size); +bool CXFA_WidgetAcc::CalculatePushButtonAutoSize(CXFA_FFDoc* doc, + CFX_SizeF& size) { + CalcCaptionSize(doc, size); return CalculateWidgetAutoSize(size); } @@ -1123,9 +1130,9 @@ CFX_SizeF CXFA_WidgetAcc::CalculateImageSize(float img_width, return rtFit.Size(); } -bool CXFA_WidgetAcc::CalculateImageAutoSize(CFX_SizeF& size) { +bool CXFA_WidgetAcc::CalculateImageAutoSize(CXFA_FFDoc* doc, CFX_SizeF& size) { if (!GetImageImage()) - LoadImageImage(); + LoadImageImage(doc); size.clear(); RetainPtr<CFX_DIBitmap> pBitmap = GetImageImage(); @@ -1141,14 +1148,15 @@ bool CXFA_WidgetAcc::CalculateImageAutoSize(CFX_SizeF& size) { return CalculateWidgetAutoSize(size); } -bool CXFA_WidgetAcc::CalculateImageEditAutoSize(CFX_SizeF& size) { +bool CXFA_WidgetAcc::CalculateImageEditAutoSize(CXFA_FFDoc* doc, + CFX_SizeF& size) { if (!GetImageEditImage()) - LoadImageEditImage(); + LoadImageEditImage(doc); size.clear(); RetainPtr<CFX_DIBitmap> pBitmap = GetImageEditImage(); if (!pBitmap) - return CalculateFieldAutoSize(size); + return CalculateFieldAutoSize(doc, size); int32_t iImageXDpi = 0; int32_t iImageYDpi = 0; @@ -1156,19 +1164,19 @@ bool CXFA_WidgetAcc::CalculateImageEditAutoSize(CFX_SizeF& size) { size = CalculateImageSize(pBitmap->GetWidth(), pBitmap->GetHeight(), iImageXDpi, iImageYDpi); - return CalculateFieldAutoSize(size); + return CalculateFieldAutoSize(doc, size); } -bool CXFA_WidgetAcc::LoadImageImage() { +bool CXFA_WidgetAcc::LoadImageImage(CXFA_FFDoc* doc) { InitLayoutData(); return static_cast<CXFA_ImageLayoutData*>(m_pLayoutData.get()) - ->LoadImageData(this); + ->LoadImageData(doc, this); } -bool CXFA_WidgetAcc::LoadImageEditImage() { +bool CXFA_WidgetAcc::LoadImageEditImage(CXFA_FFDoc* doc) { InitLayoutData(); return static_cast<CXFA_ImageEditData*>(m_pLayoutData.get()) - ->LoadImageData(this); + ->LoadImageData(doc, this); } void CXFA_WidgetAcc::GetImageDpi(int32_t& iImageXDpi, int32_t& iImageYDpi) { @@ -1185,20 +1193,9 @@ void CXFA_WidgetAcc::GetImageEditDpi(int32_t& iImageXDpi, int32_t& iImageYDpi) { iImageYDpi = pData->m_iImageYDpi; } -bool CXFA_WidgetAcc::CalculateTextAutoSize(CFX_SizeF& size) { - LoadText(); - CXFA_TextLayout* pTextLayout = - static_cast<CXFA_TextLayoutData*>(m_pLayoutData.get())->GetTextLayout(); - if (pTextLayout) { - size.width = pTextLayout->StartLayout(size.width); - size.height = pTextLayout->GetLayoutHeight(); - } - return CalculateWidgetAutoSize(size); -} - -void CXFA_WidgetAcc::LoadText() { +void CXFA_WidgetAcc::LoadText(CXFA_FFDoc* doc) { InitLayoutData(); - static_cast<CXFA_TextLayoutData*>(m_pLayoutData.get())->LoadText(this); + static_cast<CXFA_TextLayoutData*>(m_pLayoutData.get())->LoadText(doc, this); } float CXFA_WidgetAcc::CalculateWidgetAutoWidth(float fWidthCalc) { @@ -1247,12 +1244,15 @@ float CXFA_WidgetAcc::GetHeightWithoutMargin(float fHeightCalc) { return fHeightCalc; } -void CXFA_WidgetAcc::StartWidgetLayout(float& fCalcWidth, float& fCalcHeight) { +void CXFA_WidgetAcc::StartWidgetLayout(CXFA_FFDoc* doc, + float& fCalcWidth, + float& fCalcHeight) { InitLayoutData(); + XFA_Element eUIType = GetUIType(); if (eUIType == XFA_Element::Text) { m_pLayoutData->m_fWidgetHeight = TryHeight().value_or(-1); - StartTextLayout(fCalcWidth, fCalcHeight); + StartTextLayout(doc, fCalcWidth, fCalcHeight); return; } if (fCalcWidth > 0 && fCalcHeight > 0) @@ -1265,7 +1265,7 @@ void CXFA_WidgetAcc::StartWidgetLayout(float& fCalcWidth, float& fCalcHeight) { if (height) fCalcHeight = *height; else - CalculateAccWidthAndHeight(eUIType, fCalcWidth, fCalcHeight); + CalculateAccWidthAndHeight(doc, eUIType, fCalcWidth, fCalcHeight); m_pLayoutData->m_fWidgetHeight = fCalcHeight; return; @@ -1281,14 +1281,15 @@ void CXFA_WidgetAcc::StartWidgetLayout(float& fCalcWidth, float& fCalcHeight) { fCalcHeight = *height; } if (!width || !height) - CalculateAccWidthAndHeight(eUIType, fWidth, fCalcHeight); + CalculateAccWidthAndHeight(doc, eUIType, fWidth, fCalcHeight); fCalcWidth = fWidth; } m_pLayoutData->m_fWidgetHeight = fCalcHeight; } -void CXFA_WidgetAcc::CalculateAccWidthAndHeight(XFA_Element eUIType, +void CXFA_WidgetAcc::CalculateAccWidthAndHeight(CXFA_FFDoc* doc, + XFA_Element eUIType, float& fWidth, float& fCalcHeight) { CFX_SizeF sz(fWidth, m_pLayoutData->m_fWidgetHeight); @@ -1296,25 +1297,25 @@ void CXFA_WidgetAcc::CalculateAccWidthAndHeight(XFA_Element eUIType, case XFA_Element::Barcode: case XFA_Element::ChoiceList: case XFA_Element::Signature: - CalculateFieldAutoSize(sz); + CalculateFieldAutoSize(doc, sz); break; case XFA_Element::ImageEdit: - CalculateImageEditAutoSize(sz); + CalculateImageEditAutoSize(doc, sz); break; case XFA_Element::Button: - CalculatePushButtonAutoSize(sz); + CalculatePushButtonAutoSize(doc, sz); break; case XFA_Element::CheckButton: - CalculateCheckButtonAutoSize(sz); + CalculateCheckButtonAutoSize(doc, sz); break; case XFA_Element::DateTimeEdit: case XFA_Element::NumericEdit: case XFA_Element::PasswordEdit: case XFA_Element::TextEdit: - CalculateTextEditAutoSize(sz); + CalculateTextEditAutoSize(doc, sz); break; case XFA_Element::Image: - CalculateImageAutoSize(sz); + CalculateImageAutoSize(doc, sz); break; case XFA_Element::Arc: case XFA_Element::Line: @@ -1331,7 +1332,9 @@ void CXFA_WidgetAcc::CalculateAccWidthAndHeight(XFA_Element eUIType, fCalcHeight = sz.height; } -bool CXFA_WidgetAcc::FindSplitPos(int32_t iBlockIndex, float& fCalcHeight) { +bool CXFA_WidgetAcc::FindSplitPos(CXFA_FFDocView* docView, + int32_t iBlockIndex, + float& fCalcHeight) { XFA_Element eUIType = GetUIType(); if (eUIType == XFA_Element::Subform) return false; @@ -1409,7 +1412,7 @@ bool CXFA_WidgetAcc::FindSplitPos(int32_t iBlockIndex, float& fCalcHeight) { // TODO(dsinclair): Inline fWidth when the 2nd param of // CalculateAccWidthAndHeight isn't a ref-param. float fWidth = TryWidth().value_or(0); - CalculateAccWidthAndHeight(eUIType, fWidth, fHeight); + CalculateAccWidthAndHeight(docView->GetDoc(), eUIType, fWidth, fHeight); } iLinesCount = pFieldData->m_pTextOut->GetTotalLines(); } @@ -1463,7 +1466,7 @@ bool CXFA_WidgetAcc::FindSplitPos(int32_t iBlockIndex, float& fCalcHeight) { else pFieldArray->push_back(fStartOffset); - XFA_VERSION version = GetDoc()->GetXFADoc()->GetCurVersionMode(); + XFA_VERSION version = docView->GetDoc()->GetXFADoc()->GetCurVersionMode(); bool bCanSplitNoContent = false; XFA_AttributeEnum eLayoutMode = GetNode() ->GetNodeItem(XFA_NODEITEM_Parent) @@ -1586,8 +1589,11 @@ void CXFA_WidgetAcc::InitLayoutData() { m_pLayoutData = pdfium::MakeUnique<CXFA_WidgetLayoutData>(); } -void CXFA_WidgetAcc::StartTextLayout(float& fCalcWidth, float& fCalcHeight) { - LoadText(); +void CXFA_WidgetAcc::StartTextLayout(CXFA_FFDoc* doc, + float& fCalcWidth, + float& fCalcHeight) { + LoadText(doc); + CXFA_TextLayout* pTextLayout = static_cast<CXFA_TextLayoutData*>(m_pLayoutData.get())->GetTextLayout(); float fTextHeight = 0; @@ -1627,10 +1633,10 @@ void CXFA_WidgetAcc::StartTextLayout(float& fCalcWidth, float& fCalcHeight) { fCalcHeight = m_pLayoutData->m_fWidgetHeight; } -bool CXFA_WidgetAcc::LoadCaption() { +bool CXFA_WidgetAcc::LoadCaption(CXFA_FFDoc* doc) { InitLayoutData(); return static_cast<CXFA_FieldLayoutData*>(m_pLayoutData.get()) - ->LoadCaption(this); + ->LoadCaption(doc, this); } CXFA_TextLayout* CXFA_WidgetAcc::GetCaptionTextLayout() { @@ -1676,7 +1682,7 @@ void CXFA_WidgetAcc::SetImageEditImage( pData->m_pDIBitmap = newImage; } -RetainPtr<CFGAS_GEFont> CXFA_WidgetAcc::GetFDEFont() { +RetainPtr<CFGAS_GEFont> CXFA_WidgetAcc::GetFDEFont(CXFA_FFDoc* doc) { WideString wsFontName = L"Courier"; uint32_t dwFontStyle = 0; CXFA_Font* font = GetFont(false); @@ -1688,10 +1694,8 @@ RetainPtr<CFGAS_GEFont> CXFA_WidgetAcc::GetFDEFont() { wsFontName = font->GetTypeface(); } - - auto* pDoc = GetDoc(); - return pDoc->GetApp()->GetXFAFontMgr()->GetFont( - pDoc, wsFontName.AsStringView(), dwFontStyle); + return doc->GetApp()->GetXFAFontMgr()->GetFont(doc, wsFontName.AsStringView(), + dwFontStyle); } float CXFA_WidgetAcc::GetFontSize() { @@ -2063,7 +2067,7 @@ CXFA_Node* CXFA_WidgetAcc::GetSelectedMember() { for (CXFA_Node* pNode = ToNode(m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild)); pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { - CXFA_WidgetAcc widgetData(nullptr, pNode); + CXFA_WidgetAcc widgetData(pNode); if (widgetData.GetCheckState() == XFA_CHECKSTATE_On) { pSelectedMember = pNode; break; @@ -2078,7 +2082,7 @@ CXFA_Node* CXFA_WidgetAcc::SetSelectedMember(const WideStringView& wsName, for (CXFA_Node* pNode = ToNode(m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild)); pNode; pNode = pNode->GetNodeItem(XFA_NODEITEM_NextSibling)) { if (pNode->GetNameHash() == nameHash) { - CXFA_WidgetAcc widgetData(nullptr, pNode); + CXFA_WidgetAcc widgetData(pNode); widgetData.SetCheckState(XFA_CHECKSTATE_On, bNotify); return pNode; } diff --git a/xfa/fxfa/cxfa_widgetacc.h b/xfa/fxfa/cxfa_widgetacc.h index 976540df4d..2039d369b5 100644 --- a/xfa/fxfa/cxfa_widgetacc.h +++ b/xfa/fxfa/cxfa_widgetacc.h @@ -53,12 +53,11 @@ class CXFA_TextLayout; class CXFA_Value; class CXFA_Validate; class CXFA_WidgetLayoutData; -class IXFA_AppProvider; class IFX_Locale; class CXFA_WidgetAcc { public: - CXFA_WidgetAcc(CXFA_FFDocView* pDocView, CXFA_Node* pNode); + explicit CXFA_WidgetAcc(CXFA_Node* pNode); ~CXFA_WidgetAcc(); void ResetData(); @@ -66,29 +65,38 @@ class CXFA_WidgetAcc { XFA_Element GetElementType() const; CXFA_WidgetAcc* GetExclGroup(); - CXFA_FFDoc* GetDoc(); - int32_t ProcessEvent(XFA_AttributeEnum iActivity, + int32_t ProcessEvent(CXFA_FFDocView* docView, + XFA_AttributeEnum iActivity, CXFA_EventParam* pEventParam); - int32_t ProcessEvent(CXFA_Event* event, CXFA_EventParam* pEventParam); - int32_t ProcessCalculate(); - int32_t ProcessValidate(int32_t iFlags); - int32_t ExecuteScript(CXFA_Script* script, CXFA_EventParam* pEventParam); - std::pair<int32_t, bool> ExecuteBoolScript(CXFA_Script* script, + int32_t ProcessEvent(CXFA_FFDocView* docView, + CXFA_Event* event, + CXFA_EventParam* pEventParam); + int32_t ProcessCalculate(CXFA_FFDocView* docView); + int32_t ProcessValidate(CXFA_FFDocView* docView, int32_t iFlags); + int32_t ExecuteScript(CXFA_FFDocView* docView, + CXFA_Script* script, + CXFA_EventParam* pEventParam); + std::pair<int32_t, bool> ExecuteBoolScript(CXFA_FFDocView* docView, + CXFA_Script* script, CXFA_EventParam* pEventParam); CXFA_FFWidget* GetNextWidget(CXFA_FFWidget* pWidget); - void StartWidgetLayout(float& fCalcWidth, float& fCalcHeight); - bool FindSplitPos(int32_t iBlockIndex, float& fCalcHeight); - - bool LoadCaption(); + void StartWidgetLayout(CXFA_FFDoc* doc, + float& fCalcWidth, + float& fCalcHeight); + bool FindSplitPos(CXFA_FFDocView* docView, + int32_t iBlockIndex, + float& fCalcHeight); + + bool LoadCaption(CXFA_FFDoc* doc); CXFA_TextLayout* GetCaptionTextLayout(); - void LoadText(); + void LoadText(CXFA_FFDoc* doc); CXFA_TextLayout* GetTextLayout(); - bool LoadImageImage(); - bool LoadImageEditImage(); + bool LoadImageImage(CXFA_FFDoc* doc); + bool LoadImageEditImage(CXFA_FFDoc* doc); void GetImageDpi(int32_t& iImageXDpi, int32_t& iImageYDpi); void GetImageEditDpi(int32_t& iImageXDpi, int32_t& iImageYDpi); @@ -102,7 +110,7 @@ class CXFA_WidgetAcc { void UpdateUIDisplay(CXFA_FFDocView* docView, CXFA_FFWidget* pExcept); CXFA_Node* GetDatasets(); - RetainPtr<CFGAS_GEFont> GetFDEFont(); + RetainPtr<CFGAS_GEFont> GetFDEFont(CXFA_FFDoc* doc); float GetFontSize(); FX_ARGB GetTextColor(); float GetLineHeight(); @@ -237,40 +245,43 @@ class CXFA_WidgetAcc { void SetIsNull(bool val) { m_bIsNull = val; } private: - IXFA_AppProvider* GetAppProvider(); - void ProcessScriptTestValidate(CXFA_Validate* validate, + void ProcessScriptTestValidate(CXFA_FFDocView* docView, + CXFA_Validate* validate, int32_t iRet, bool pRetValue, bool bVersionFlag); - int32_t ProcessFormatTestValidate(CXFA_Validate* validate, bool bVersionFlag); - int32_t ProcessNullTestValidate(CXFA_Validate* validate, + int32_t ProcessFormatTestValidate(CXFA_FFDocView* docView, + CXFA_Validate* validate, + bool bVersionFlag); + int32_t ProcessNullTestValidate(CXFA_FFDocView* docView, + CXFA_Validate* validate, int32_t iFlags, bool bVersionFlag); WideString GetValidateCaptionName(bool bVersionFlag); WideString GetValidateMessage(bool bError, bool bVersionFlag); - void CalcCaptionSize(CFX_SizeF& szCap); - bool CalculateFieldAutoSize(CFX_SizeF& size); + void CalcCaptionSize(CXFA_FFDoc* doc, CFX_SizeF& szCap); + bool CalculateFieldAutoSize(CXFA_FFDoc* doc, CFX_SizeF& size); bool CalculateWidgetAutoSize(CFX_SizeF& size); - bool CalculateTextEditAutoSize(CFX_SizeF& size); - bool CalculateCheckButtonAutoSize(CFX_SizeF& size); - bool CalculatePushButtonAutoSize(CFX_SizeF& size); + bool CalculateTextEditAutoSize(CXFA_FFDoc* doc, CFX_SizeF& size); + bool CalculateCheckButtonAutoSize(CXFA_FFDoc* doc, CFX_SizeF& size); + bool CalculatePushButtonAutoSize(CXFA_FFDoc* doc, CFX_SizeF& size); CFX_SizeF CalculateImageSize(float img_width, float img_height, float dpi_x, float dpi_y); - bool CalculateImageEditAutoSize(CFX_SizeF& size); - bool CalculateImageAutoSize(CFX_SizeF& size); - bool CalculateTextAutoSize(CFX_SizeF& size); + bool CalculateImageEditAutoSize(CXFA_FFDoc* doc, CFX_SizeF& size); + bool CalculateImageAutoSize(CXFA_FFDoc* doc, CFX_SizeF& size); float CalculateWidgetAutoHeight(float fHeightCalc); float CalculateWidgetAutoWidth(float fWidthCalc); float GetWidthWithoutMargin(float fWidthCalc); float GetHeightWithoutMargin(float fHeightCalc); - void CalculateTextContentSize(CFX_SizeF& size); - void CalculateAccWidthAndHeight(XFA_Element eUIType, + void CalculateTextContentSize(CXFA_FFDoc* doc, CFX_SizeF& size); + void CalculateAccWidthAndHeight(CXFA_FFDoc* doc, + XFA_Element eUIType, float& fWidth, float& fCalcHeight); void InitLayoutData(); - void StartTextLayout(float& fCalcWidth, float& fCalcHeight); + void StartTextLayout(CXFA_FFDoc* doc, float& fCalcWidth, float& fCalcHeight); CXFA_Bind* GetBind(); void InsertListTextItem(CXFA_Node* pItems, @@ -280,7 +291,6 @@ class CXFA_WidgetAcc { CXFA_Node* GetExclGroupNode(); void GetItemLabel(const WideStringView& wsValue, WideString& wsLabel); - CXFA_FFDocView* m_pDocView; std::unique_ptr<CXFA_WidgetLayoutData> m_pLayoutData; uint32_t m_nRecursionDepth; bool m_bIsNull; |