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/include/xfa_ffdocview.h" | 7 #include "xfa/fxfa/include/xfa_ffdocview.h" |
8 | 8 |
9 #include "core/fxcrt/include/fx_ext.h" | 9 #include "core/fxcrt/include/fx_ext.h" |
10 #include "xfa/fxfa/app/xfa_ffbarcode.h" | 10 #include "xfa/fxfa/app/xfa_ffbarcode.h" |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
168 } | 168 } |
169 m_arrNullTestMsg.RemoveAll(); | 169 m_arrNullTestMsg.RemoveAll(); |
170 } | 170 } |
171 void CXFA_FFDocView::UpdateDocView() { | 171 void CXFA_FFDocView::UpdateDocView() { |
172 if (IsUpdateLocked()) { | 172 if (IsUpdateLocked()) { |
173 return; | 173 return; |
174 } | 174 } |
175 LockUpdate(); | 175 LockUpdate(); |
176 int32_t iNewAdds = m_NewAddedNodes.GetSize(); | 176 int32_t iNewAdds = m_NewAddedNodes.GetSize(); |
177 for (int32_t i = 0; i < iNewAdds; i++) { | 177 for (int32_t i = 0; i < iNewAdds; i++) { |
178 CXFA_Node* pNode = reinterpret_cast<CXFA_Node*>(m_NewAddedNodes[i]); | 178 CXFA_Node* pNode = m_NewAddedNodes[i]; |
179 InitCalculate(pNode); | 179 InitCalculate(pNode); |
180 InitValidate(pNode); | 180 InitValidate(pNode); |
181 ExecEventActivityByDeepFirst(pNode, XFA_EVENT_Ready, TRUE); | 181 ExecEventActivityByDeepFirst(pNode, XFA_EVENT_Ready, TRUE); |
182 } | 182 } |
183 m_NewAddedNodes.RemoveAll(); | 183 m_NewAddedNodes.RemoveAll(); |
184 RunSubformIndexChange(); | 184 RunSubformIndexChange(); |
185 RunCalculateWidgets(); | 185 RunCalculateWidgets(); |
186 RunValidate(); | 186 RunValidate(); |
187 ShowNullTestMsg(); | 187 ShowNullTestMsg(); |
188 if (RunLayout() && m_bLayoutEvent) { | 188 if (RunLayout() && m_bLayoutEvent) { |
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
592 } | 592 } |
593 m_bInLayoutStatus = FALSE; | 593 m_bInLayoutStatus = FALSE; |
594 m_pDoc->GetDocProvider()->PageViewEvent(nullptr, | 594 m_pDoc->GetDocProvider()->PageViewEvent(nullptr, |
595 XFA_PAGEVIEWEVENT_StopLayout); | 595 XFA_PAGEVIEWEVENT_StopLayout); |
596 UnlockUpdate(); | 596 UnlockUpdate(); |
597 return FALSE; | 597 return FALSE; |
598 } | 598 } |
599 void CXFA_FFDocView::RunSubformIndexChange() { | 599 void CXFA_FFDocView::RunSubformIndexChange() { |
600 int32_t iSubforms = m_IndexChangedSubforms.GetSize(); | 600 int32_t iSubforms = m_IndexChangedSubforms.GetSize(); |
601 for (int32_t i = 0; i < iSubforms; i++) { | 601 for (int32_t i = 0; i < iSubforms; i++) { |
602 CXFA_Node* pSubformNode = | 602 CXFA_Node* pSubformNode = m_IndexChangedSubforms[i]; |
603 reinterpret_cast<CXFA_Node*>(m_IndexChangedSubforms[i]); | |
604 CXFA_WidgetAcc* pWidgetAcc = (CXFA_WidgetAcc*)pSubformNode->GetWidgetData(); | 603 CXFA_WidgetAcc* pWidgetAcc = (CXFA_WidgetAcc*)pSubformNode->GetWidgetData(); |
605 if (!pWidgetAcc) { | 604 if (!pWidgetAcc) { |
606 continue; | 605 continue; |
607 } | 606 } |
608 CXFA_EventParam eParam; | 607 CXFA_EventParam eParam; |
609 eParam.m_eType = XFA_EVENT_IndexChange; | 608 eParam.m_eType = XFA_EVENT_IndexChange; |
610 eParam.m_pTarget = pWidgetAcc; | 609 eParam.m_pTarget = pWidgetAcc; |
611 pWidgetAcc->ProcessEvent(XFA_ATTRIBUTEENUM_IndexChange, &eParam); | 610 pWidgetAcc->ProcessEvent(XFA_ATTRIBUTEENUM_IndexChange, &eParam); |
612 } | 611 } |
613 m_IndexChangedSubforms.RemoveAll(); | 612 m_IndexChangedSubforms.RemoveAll(); |
(...skipping 12 matching lines...) Expand all Loading... | |
626 if (!pRootItem) { | 625 if (!pRootItem) { |
627 return; | 626 return; |
628 } | 627 } |
629 ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_DocClose); | 628 ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_DocClose); |
630 } | 629 } |
631 void CXFA_FFDocView::DestroyDocView() { | 630 void CXFA_FFDocView::DestroyDocView() { |
632 ClearInvalidateList(); | 631 ClearInvalidateList(); |
633 m_iStatus = XFA_DOCVIEW_LAYOUTSTATUS_None; | 632 m_iStatus = XFA_DOCVIEW_LAYOUTSTATUS_None; |
634 m_iLock = 0; | 633 m_iLock = 0; |
635 m_ValidateAccs.RemoveAll(); | 634 m_ValidateAccs.RemoveAll(); |
636 m_bindItems.RemoveAll(); | 635 m_BindItems.RemoveAll(); |
637 m_CalculateAccs.RemoveAll(); | 636 m_CalculateAccs.RemoveAll(); |
638 } | 637 } |
639 FX_BOOL CXFA_FFDocView::IsStaticNotify() { | 638 FX_BOOL CXFA_FFDocView::IsStaticNotify() { |
640 return m_pDoc->GetDocType() == XFA_DOCTYPE_Static; | 639 return m_pDoc->GetDocType() == XFA_DOCTYPE_Static; |
641 } | 640 } |
642 void CXFA_FFDocView::AddCalculateWidgetAcc(CXFA_WidgetAcc* pWidgetAcc) { | 641 void CXFA_FFDocView::AddCalculateWidgetAcc(CXFA_WidgetAcc* pWidgetAcc) { |
643 int32_t iAccs = m_CalculateAccs.GetSize(); | 642 int32_t iAccs = m_CalculateAccs.GetSize(); |
644 CXFA_WidgetAcc* pCurrentAcc = | 643 CXFA_WidgetAcc* pCurrentAcc = |
645 (iAccs < 1) ? (CXFA_WidgetAcc*)NULL | 644 iAccs > 0 ? m_CalculateAccs[iAccs - 1] : nullptr; |
646 : (CXFA_WidgetAcc*)m_CalculateAccs[iAccs - 1]; | |
647 if (pCurrentAcc != pWidgetAcc) { | 645 if (pCurrentAcc != pWidgetAcc) { |
648 m_CalculateAccs.Add(pWidgetAcc); | 646 m_CalculateAccs.Add(pWidgetAcc); |
649 } | 647 } |
650 } | 648 } |
651 void CXFA_FFDocView::AddCalculateNodeNotify(CXFA_Node* pNodeChange) { | 649 void CXFA_FFDocView::AddCalculateNodeNotify(CXFA_Node* pNodeChange) { |
652 CXFA_CalcData* pGlobalData = | 650 CXFA_CalcData* pGlobalData = |
653 (CXFA_CalcData*)pNodeChange->GetUserData(XFA_CalcData); | 651 (CXFA_CalcData*)pNodeChange->GetUserData(XFA_CalcData); |
654 int32_t iCount = pGlobalData ? pGlobalData->m_Globals.GetSize() : 0; | 652 int32_t iCount = pGlobalData ? pGlobalData->m_Globals.GetSize() : 0; |
655 for (int32_t i = 0; i < iCount; i++) { | 653 for (int32_t i = 0; i < iCount; i++) { |
656 CXFA_WidgetAcc* pResultAcc = (CXFA_WidgetAcc*)pGlobalData->m_Globals[i]; | 654 CXFA_WidgetAcc* pResultAcc = (CXFA_WidgetAcc*)pGlobalData->m_Globals[i]; |
657 if (pResultAcc->GetNode()->HasFlag(XFA_NODEFLAG_HasRemoved)) { | 655 if (pResultAcc->GetNode()->HasFlag(XFA_NODEFLAG_HasRemoved)) { |
658 continue; | 656 continue; |
659 } | 657 } |
660 int32_t iAccs = m_CalculateAccs.GetSize(); | 658 int32_t iAccs = m_CalculateAccs.GetSize(); |
661 CXFA_WidgetAcc* pCurrentAcc = | 659 CXFA_WidgetAcc* pCurrentAcc = |
662 (iAccs < 1) ? (CXFA_WidgetAcc*)NULL | 660 iAccs > 0 ? m_CalculateAccs[iAccs - 1] : nullptr; |
663 : (CXFA_WidgetAcc*)m_CalculateAccs[iAccs - 1]; | |
664 if (pCurrentAcc != pResultAcc) { | 661 if (pCurrentAcc != pResultAcc) { |
665 m_CalculateAccs.Add(pResultAcc); | 662 m_CalculateAccs.Add(pResultAcc); |
666 } | 663 } |
667 } | 664 } |
668 } | 665 } |
669 void CXFA_FFDocView::RunCalculateRecursive(int32_t& iIndex) { | 666 void CXFA_FFDocView::RunCalculateRecursive(int32_t& iIndex) { |
670 while (iIndex < m_CalculateAccs.GetSize()) { | 667 while (iIndex < m_CalculateAccs.GetSize()) { |
671 CXFA_WidgetAcc* pCurAcc = (CXFA_WidgetAcc*)m_CalculateAccs[iIndex]; | 668 CXFA_WidgetAcc* pCurAcc = m_CalculateAccs[iIndex]; |
672 AddCalculateNodeNotify(pCurAcc->GetNode()); | 669 AddCalculateNodeNotify(pCurAcc->GetNode()); |
673 int32_t iRefCount = | 670 int32_t iRefCount = |
674 (int32_t)(uintptr_t)pCurAcc->GetNode()->GetUserData(XFA_CalcRefCount); | 671 (int32_t)(uintptr_t)pCurAcc->GetNode()->GetUserData(XFA_CalcRefCount); |
675 iRefCount++; | 672 iRefCount++; |
676 pCurAcc->GetNode()->SetUserData(XFA_CalcRefCount, | 673 pCurAcc->GetNode()->SetUserData(XFA_CalcRefCount, |
677 (void*)(uintptr_t)iRefCount); | 674 (void*)(uintptr_t)iRefCount); |
678 if (iRefCount > 11) { | 675 if (iRefCount > 11) { |
679 break; | 676 break; |
680 } | 677 } |
681 if ((pCurAcc->ProcessCalculate()) == XFA_EVENTERROR_Success) { | 678 if ((pCurAcc->ProcessCalculate()) == XFA_EVENTERROR_Success) { |
682 AddValidateWidget(pCurAcc); | 679 AddValidateWidget(pCurAcc); |
683 } | 680 } |
684 iIndex++; | 681 iIndex++; |
685 RunCalculateRecursive(iIndex); | 682 RunCalculateRecursive(iIndex); |
686 } | 683 } |
687 } | 684 } |
688 int32_t CXFA_FFDocView::RunCalculateWidgets() { | 685 int32_t CXFA_FFDocView::RunCalculateWidgets() { |
689 if (!m_pDoc->GetDocProvider()->IsCalculationsEnabled(m_pDoc)) { | 686 if (!m_pDoc->GetDocProvider()->IsCalculationsEnabled(m_pDoc)) { |
690 return XFA_EVENTERROR_Disabled; | 687 return XFA_EVENTERROR_Disabled; |
691 } | 688 } |
692 int32_t iCounts = m_CalculateAccs.GetSize(); | 689 int32_t iCounts = m_CalculateAccs.GetSize(); |
693 int32_t iIndex = 0; | 690 int32_t iIndex = 0; |
694 if (iCounts > 0) { | 691 if (iCounts > 0) { |
695 RunCalculateRecursive(iIndex); | 692 RunCalculateRecursive(iIndex); |
696 } | 693 } |
697 for (int32_t i = 0; i < m_CalculateAccs.GetSize(); i++) { | 694 for (int32_t i = 0; i < m_CalculateAccs.GetSize(); i++) { |
698 CXFA_WidgetAcc* pCurAcc = (CXFA_WidgetAcc*)m_CalculateAccs[i]; | 695 CXFA_WidgetAcc* pCurAcc = m_CalculateAccs[i]; |
699 pCurAcc->GetNode()->SetUserData(XFA_CalcRefCount, (void*)(uintptr_t)0); | 696 pCurAcc->GetNode()->SetUserData(XFA_CalcRefCount, (void*)(uintptr_t)0); |
700 } | 697 } |
701 m_CalculateAccs.RemoveAll(); | 698 m_CalculateAccs.RemoveAll(); |
702 return XFA_EVENTERROR_Success; | 699 return XFA_EVENTERROR_Success; |
703 } | 700 } |
704 void CXFA_FFDocView::AddValidateWidget(CXFA_WidgetAcc* pWidget) { | 701 void CXFA_FFDocView::AddValidateWidget(CXFA_WidgetAcc* pWidget) { |
705 if (m_ValidateAccs.Find(pWidget) < 0) { | 702 if (m_ValidateAccs.Find(pWidget) < 0) |
706 m_ValidateAccs.Add(pWidget); | 703 m_ValidateAccs.Add(pWidget); |
707 } | |
708 } | 704 } |
709 FX_BOOL CXFA_FFDocView::InitCalculate(CXFA_Node* pNode) { | 705 FX_BOOL CXFA_FFDocView::InitCalculate(CXFA_Node* pNode) { |
710 ExecEventActivityByDeepFirst(pNode, XFA_EVENT_InitCalculate); | 706 ExecEventActivityByDeepFirst(pNode, XFA_EVENT_InitCalculate); |
711 return TRUE; | 707 return TRUE; |
712 } | 708 } |
713 FX_BOOL CXFA_FFDocView::InitValidate(CXFA_Node* pNode) { | 709 FX_BOOL CXFA_FFDocView::InitValidate(CXFA_Node* pNode) { |
714 if (!m_pDoc->GetDocProvider()->IsValidationsEnabled(m_pDoc)) { | 710 if (!m_pDoc->GetDocProvider()->IsValidationsEnabled(m_pDoc)) { |
715 return FALSE; | 711 return FALSE; |
716 } | 712 } |
717 ExecEventActivityByDeepFirst(pNode, XFA_EVENT_Validate); | 713 ExecEventActivityByDeepFirst(pNode, XFA_EVENT_Validate); |
718 m_ValidateAccs.RemoveAll(); | 714 m_ValidateAccs.RemoveAll(); |
719 return TRUE; | 715 return TRUE; |
720 } | 716 } |
721 FX_BOOL CXFA_FFDocView::RunValidate() { | 717 FX_BOOL CXFA_FFDocView::RunValidate() { |
722 if (!m_pDoc->GetDocProvider()->IsValidationsEnabled(m_pDoc)) { | 718 if (!m_pDoc->GetDocProvider()->IsValidationsEnabled(m_pDoc)) { |
723 return FALSE; | 719 return FALSE; |
724 } | 720 } |
725 int32_t iCounts = m_ValidateAccs.GetSize(); | 721 int32_t iCounts = m_ValidateAccs.GetSize(); |
726 for (int32_t i = 0; i < iCounts; i++) { | 722 for (int32_t i = 0; i < iCounts; i++) { |
727 CXFA_WidgetAcc* pAcc = (CXFA_WidgetAcc*)m_ValidateAccs[i]; | 723 CXFA_WidgetAcc* pAcc = m_ValidateAccs[i]; |
728 if (pAcc->GetNode()->HasFlag(XFA_NODEFLAG_HasRemoved)) { | 724 if (pAcc->GetNode()->HasFlag(XFA_NODEFLAG_HasRemoved)) { |
729 continue; | 725 continue; |
730 } | 726 } |
731 pAcc->ProcessValidate(); | 727 pAcc->ProcessValidate(); |
732 } | 728 } |
733 m_ValidateAccs.RemoveAll(); | 729 m_ValidateAccs.RemoveAll(); |
734 return TRUE; | 730 return TRUE; |
735 } | 731 } |
736 FX_BOOL CXFA_FFDocView::RunEventLayoutReady() { | 732 FX_BOOL CXFA_FFDocView::RunEventLayoutReady() { |
737 CXFA_Node* pRootItem = | 733 CXFA_Node* pRootItem = |
738 ToNode(m_pDoc->GetXFADoc()->GetXFAObject(XFA_HASHCODE_Form)); | 734 ToNode(m_pDoc->GetXFADoc()->GetXFAObject(XFA_HASHCODE_Form)); |
739 if (!pRootItem) { | 735 if (!pRootItem) { |
740 return FALSE; | 736 return FALSE; |
741 } | 737 } |
742 ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_Ready); | 738 ExecEventActivityByDeepFirst(pRootItem, XFA_EVENT_Ready); |
743 RunLayout(); | 739 RunLayout(); |
744 return TRUE; | 740 return TRUE; |
745 } | 741 } |
746 void CXFA_FFDocView::RunBindItems() { | 742 void CXFA_FFDocView::RunBindItems() { |
747 int32_t iCount = m_bindItems.GetSize(); | 743 int32_t iCount = m_BindItems.GetSize(); |
748 for (int32_t i = 0; i < iCount; i++) { | 744 for (int32_t i = 0; i < iCount; i++) { |
749 if (reinterpret_cast<CXFA_Node*>(m_bindItems[i]) | 745 if (m_BindItems[i]->HasFlag(XFA_NODEFLAG_HasRemoved)) { |
Lei Zhang
2016/04/27 22:32:51
no braces
| |
750 ->HasFlag(XFA_NODEFLAG_HasRemoved)) { | |
751 continue; | 746 continue; |
752 } | 747 } |
753 CXFA_Node* pWidgetNode = reinterpret_cast<CXFA_Node*>(m_bindItems[i]) | 748 CXFA_Node* pWidgetNode = m_BindItems[i]->GetNodeItem(XFA_NODEITEM_Parent); |
754 ->GetNodeItem(XFA_NODEITEM_Parent); | |
755 CXFA_WidgetAcc* pAcc = (CXFA_WidgetAcc*)pWidgetNode->GetWidgetData(); | 749 CXFA_WidgetAcc* pAcc = (CXFA_WidgetAcc*)pWidgetNode->GetWidgetData(); |
756 if (!pAcc) { | 750 if (!pAcc) { |
757 continue; | 751 continue; |
758 } | 752 } |
759 CXFA_BindItems binditems(reinterpret_cast<CXFA_Node*>(m_bindItems[i])); | 753 CXFA_BindItems binditems(m_BindItems[i]); |
760 CXFA_ScriptContext* pScriptContext = | 754 CXFA_ScriptContext* pScriptContext = |
761 pWidgetNode->GetDocument()->GetScriptContext(); | 755 pWidgetNode->GetDocument()->GetScriptContext(); |
762 CFX_WideStringC wsRef; | 756 CFX_WideStringC wsRef; |
763 binditems.GetRef(wsRef); | 757 binditems.GetRef(wsRef); |
764 uint32_t dwStyle = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties | | 758 uint32_t dwStyle = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties | |
765 XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent | | 759 XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent | |
766 XFA_RESOLVENODE_ALL; | 760 XFA_RESOLVENODE_ALL; |
767 XFA_RESOLVENODE_RS rs; | 761 XFA_RESOLVENODE_RS rs; |
768 pScriptContext->ResolveObjects(pWidgetNode, wsRef, rs, dwStyle); | 762 pScriptContext->ResolveObjects(pWidgetNode, wsRef, rs, dwStyle); |
769 int32_t iCount = rs.nodes.GetSize(); | 763 int32_t iCount = rs.nodes.GetSize(); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
805 CXFA_Node* nodeLabel = refNode->GetFirstChildByName(wsLabelRef); | 799 CXFA_Node* nodeLabel = refNode->GetFirstChildByName(wsLabelRef); |
806 if (nodeLabel) | 800 if (nodeLabel) |
807 wsLabel = nodeLabel->GetContent(); | 801 wsLabel = nodeLabel->GetContent(); |
808 } | 802 } |
809 } else { | 803 } else { |
810 wsLabel = wsValue; | 804 wsLabel = wsValue; |
811 } | 805 } |
812 pAcc->InsertItem(wsLabel, wsValue); | 806 pAcc->InsertItem(wsLabel, wsValue); |
813 } | 807 } |
814 } | 808 } |
815 m_bindItems.RemoveAll(); | 809 m_BindItems.RemoveAll(); |
816 } | 810 } |
817 void CXFA_FFDocView::SetChangeMark() { | 811 void CXFA_FFDocView::SetChangeMark() { |
818 if (m_iStatus < XFA_DOCVIEW_LAYOUTSTATUS_End) { | 812 if (m_iStatus < XFA_DOCVIEW_LAYOUTSTATUS_End) { |
819 return; | 813 return; |
820 } | 814 } |
821 m_pDoc->GetDocProvider()->SetChangeMark(m_pDoc); | 815 m_pDoc->GetDocProvider()->SetChangeMark(m_pDoc); |
822 } | 816 } |
823 CXFA_Node* CXFA_FFDocView::GetRootSubform() { | 817 CXFA_Node* CXFA_FFDocView::GetRootSubform() { |
824 CXFA_Node* pFormPacketNode = | 818 CXFA_Node* pFormPacketNode = |
825 ToNode(m_pDoc->GetXFADoc()->GetXFAObject(XFA_HASHCODE_Form)); | 819 ToNode(m_pDoc->GetXFADoc()->GetXFAObject(XFA_HASHCODE_Form)); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
906 CXFA_WidgetAcc* CXFA_WidgetAccIterator::GetCurrentWidgetAcc() { | 900 CXFA_WidgetAcc* CXFA_WidgetAccIterator::GetCurrentWidgetAcc() { |
907 return NULL; | 901 return NULL; |
908 } | 902 } |
909 FX_BOOL CXFA_WidgetAccIterator::SetCurrentWidgetAcc(CXFA_WidgetAcc* hWidget) { | 903 FX_BOOL CXFA_WidgetAccIterator::SetCurrentWidgetAcc(CXFA_WidgetAcc* hWidget) { |
910 return FALSE; | 904 return FALSE; |
911 } | 905 } |
912 void CXFA_WidgetAccIterator::SkipTree() { | 906 void CXFA_WidgetAccIterator::SkipTree() { |
913 m_ContentIterator.SkipChildrenAndMoveToNext(); | 907 m_ContentIterator.SkipChildrenAndMoveToNext(); |
914 m_pCurWidgetAcc = NULL; | 908 m_pCurWidgetAcc = NULL; |
915 } | 909 } |
OLD | NEW |