OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "xfa/fxfa/app/xfa_ffnotify.h" | 7 #include "xfa/fxfa/app/xfa_ffnotify.h" |
8 | 8 |
9 #include "fxjs/cfxjse_value.h" | 9 #include "fxjs/cfxjse_value.h" |
10 #include "xfa/fxfa/app/xfa_ffbarcode.h" | 10 #include "xfa/fxfa/app/xfa_ffbarcode.h" |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 void CXFA_FFNotify::StartFieldDrawLayout(CXFA_Node* pItem, | 173 void CXFA_FFNotify::StartFieldDrawLayout(CXFA_Node* pItem, |
174 FX_FLOAT& fCalcWidth, | 174 FX_FLOAT& fCalcWidth, |
175 FX_FLOAT& fCalcHeight) { | 175 FX_FLOAT& fCalcHeight) { |
176 CXFA_WidgetAcc* pAcc = static_cast<CXFA_WidgetAcc*>(pItem->GetWidgetData()); | 176 CXFA_WidgetAcc* pAcc = static_cast<CXFA_WidgetAcc*>(pItem->GetWidgetData()); |
177 if (!pAcc) | 177 if (!pAcc) |
178 return; | 178 return; |
179 | 179 |
180 pAcc->StartWidgetLayout(fCalcWidth, fCalcHeight); | 180 pAcc->StartWidgetLayout(fCalcWidth, fCalcHeight); |
181 } | 181 } |
182 | 182 |
183 FX_BOOL CXFA_FFNotify::FindSplitPos(CXFA_Node* pItem, | 183 bool CXFA_FFNotify::FindSplitPos(CXFA_Node* pItem, |
184 int32_t iBlockIndex, | 184 int32_t iBlockIndex, |
185 FX_FLOAT& fCalcHeightPos) { | 185 FX_FLOAT& fCalcHeightPos) { |
186 CXFA_WidgetAcc* pAcc = static_cast<CXFA_WidgetAcc*>(pItem->GetWidgetData()); | 186 CXFA_WidgetAcc* pAcc = static_cast<CXFA_WidgetAcc*>(pItem->GetWidgetData()); |
187 return pAcc && pAcc->FindSplitPos(iBlockIndex, fCalcHeightPos); | 187 return pAcc && pAcc->FindSplitPos(iBlockIndex, fCalcHeightPos); |
188 } | 188 } |
189 | 189 |
190 FX_BOOL CXFA_FFNotify::RunScript(CXFA_Node* pScript, CXFA_Node* pFormItem) { | 190 bool CXFA_FFNotify::RunScript(CXFA_Node* pScript, CXFA_Node* pFormItem) { |
191 FX_BOOL bRet = FALSE; | 191 bool bRet = false; |
192 CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); | 192 CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); |
193 if (!pDocView) { | 193 if (!pDocView) { |
194 return bRet; | 194 return bRet; |
195 } | 195 } |
196 CXFA_WidgetAcc* pWidgetAcc = | 196 CXFA_WidgetAcc* pWidgetAcc = |
197 static_cast<CXFA_WidgetAcc*>(pFormItem->GetWidgetData()); | 197 static_cast<CXFA_WidgetAcc*>(pFormItem->GetWidgetData()); |
198 if (!pWidgetAcc) { | 198 if (!pWidgetAcc) { |
199 return bRet; | 199 return bRet; |
200 } | 200 } |
201 CXFA_EventParam EventParam; | 201 CXFA_EventParam EventParam; |
202 EventParam.m_eType = XFA_EVENT_Unknown; | 202 EventParam.m_eType = XFA_EVENT_Unknown; |
203 CFXJSE_Value* pRetValue = nullptr; | 203 CFXJSE_Value* pRetValue = nullptr; |
204 int32_t iRet = | 204 int32_t iRet = |
205 pWidgetAcc->ExecuteScript(CXFA_Script(pScript), &EventParam, &pRetValue); | 205 pWidgetAcc->ExecuteScript(CXFA_Script(pScript), &EventParam, &pRetValue); |
206 if (iRet == XFA_EVENTERROR_Success && pRetValue) { | 206 if (iRet == XFA_EVENTERROR_Success && pRetValue) { |
207 bRet = pRetValue->ToBoolean(); | 207 bRet = pRetValue->ToBoolean(); |
208 delete pRetValue; | 208 delete pRetValue; |
209 } | 209 } |
210 return bRet; | 210 return bRet; |
211 } | 211 } |
212 int32_t CXFA_FFNotify::ExecEventByDeepFirst(CXFA_Node* pFormNode, | 212 int32_t CXFA_FFNotify::ExecEventByDeepFirst(CXFA_Node* pFormNode, |
213 XFA_EVENTTYPE eEventType, | 213 XFA_EVENTTYPE eEventType, |
214 FX_BOOL bIsFormReady, | 214 bool bIsFormReady, |
215 FX_BOOL bRecursive, | 215 bool bRecursive, |
216 CXFA_WidgetAcc* pExclude) { | 216 CXFA_WidgetAcc* pExclude) { |
217 CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); | 217 CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); |
218 if (!pDocView) { | 218 if (!pDocView) { |
219 return XFA_EVENTERROR_NotExist; | 219 return XFA_EVENTERROR_NotExist; |
220 } | 220 } |
221 return pDocView->ExecEventActivityByDeepFirst( | 221 return pDocView->ExecEventActivityByDeepFirst( |
222 pFormNode, eEventType, bIsFormReady, bRecursive, | 222 pFormNode, eEventType, bIsFormReady, bRecursive, |
223 pExclude ? pExclude->GetNode() : nullptr); | 223 pExclude ? pExclude->GetNode() : nullptr); |
224 } | 224 } |
225 void CXFA_FFNotify::AddCalcValidate(CXFA_Node* pNode) { | 225 void CXFA_FFNotify::AddCalcValidate(CXFA_Node* pNode) { |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 if (!pDocView) | 373 if (!pDocView) |
374 return; | 374 return; |
375 | 375 |
376 if (!(pSender->GetPacketID() & XFA_XDPPACKET_Form)) { | 376 if (!(pSender->GetPacketID() & XFA_XDPPACKET_Form)) { |
377 if (eAttr == XFA_ATTRIBUTE_Value) | 377 if (eAttr == XFA_ATTRIBUTE_Value) |
378 pDocView->AddCalculateNodeNotify(pSender); | 378 pDocView->AddCalculateNodeNotify(pSender); |
379 return; | 379 return; |
380 } | 380 } |
381 | 381 |
382 XFA_Element eType = pParentNode->GetElementType(); | 382 XFA_Element eType = pParentNode->GetElementType(); |
383 FX_BOOL bIsContainerNode = pParentNode->IsContainerNode(); | 383 bool bIsContainerNode = pParentNode->IsContainerNode(); |
384 CXFA_WidgetAcc* pWidgetAcc = | 384 CXFA_WidgetAcc* pWidgetAcc = |
385 static_cast<CXFA_WidgetAcc*>(pWidgetNode->GetWidgetData()); | 385 static_cast<CXFA_WidgetAcc*>(pWidgetNode->GetWidgetData()); |
386 if (!pWidgetAcc) | 386 if (!pWidgetAcc) |
387 return; | 387 return; |
388 | 388 |
389 bool bUpdateProperty = false; | 389 bool bUpdateProperty = false; |
390 pDocView->SetChangeMark(); | 390 pDocView->SetChangeMark(); |
391 switch (eType) { | 391 switch (eType) { |
392 case XFA_Element::Caption: { | 392 case XFA_Element::Caption: { |
393 CXFA_TextLayout* pCapOut = pWidgetAcc->GetCaptionTextLayout(); | 393 CXFA_TextLayout* pCapOut = pWidgetAcc->GetCaptionTextLayout(); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 } | 433 } |
434 | 434 |
435 void CXFA_FFNotify::OnChildAdded(CXFA_Node* pSender) { | 435 void CXFA_FFNotify::OnChildAdded(CXFA_Node* pSender) { |
436 if (!pSender->IsFormContainer()) { | 436 if (!pSender->IsFormContainer()) { |
437 return; | 437 return; |
438 } | 438 } |
439 CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); | 439 CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); |
440 if (!pDocView) { | 440 if (!pDocView) { |
441 return; | 441 return; |
442 } | 442 } |
443 FX_BOOL bLayoutReady = | 443 bool bLayoutReady = |
444 !(pDocView->m_bInLayoutStatus) && | 444 !(pDocView->m_bInLayoutStatus) && |
445 (pDocView->GetLayoutStatus() == XFA_DOCVIEW_LAYOUTSTATUS_End); | 445 (pDocView->GetLayoutStatus() == XFA_DOCVIEW_LAYOUTSTATUS_End); |
446 if (bLayoutReady) | 446 if (bLayoutReady) |
447 m_pDoc->GetDocEnvironment()->SetChangeMark(m_pDoc); | 447 m_pDoc->GetDocEnvironment()->SetChangeMark(m_pDoc); |
448 } | 448 } |
449 | 449 |
450 void CXFA_FFNotify::OnChildRemoved() { | 450 void CXFA_FFNotify::OnChildRemoved() { |
451 CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); | 451 CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); |
452 if (!pDocView) | 452 if (!pDocView) |
453 return; | 453 return; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 return; | 504 return; |
505 | 505 |
506 CXFA_FFWidget* pWidget = XFA_GetWidgetFromLayoutItem(pSender); | 506 CXFA_FFWidget* pWidget = XFA_GetWidgetFromLayoutItem(pSender); |
507 if (!pWidget) | 507 if (!pWidget) |
508 return; | 508 return; |
509 | 509 |
510 pDocView->DeleteLayoutItem(pWidget); | 510 pDocView->DeleteLayoutItem(pWidget); |
511 m_pDoc->GetDocEnvironment()->WidgetPreRemove(pWidget, pWidget->GetDataAcc()); | 511 m_pDoc->GetDocEnvironment()->WidgetPreRemove(pWidget, pWidget->GetDataAcc()); |
512 pWidget->AddInvalidateRect(nullptr); | 512 pWidget->AddInvalidateRect(nullptr); |
513 } | 513 } |
OLD | NEW |