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/parser/xfa_layout_appadapter.h" | 7 #include "xfa/fxfa/parser/xfa_layout_appadapter.h" |
8 | 8 |
9 #include "xfa/fxfa/app/xfa_ffnotify.h" | 9 #include "xfa/fxfa/app/xfa_ffnotify.h" |
10 #include "xfa/fxfa/fm2js/xfa_fm2jsapi.h" | 10 #include "xfa/fxfa/fm2js/xfa_fm2jsapi.h" |
11 #include "xfa/fxfa/parser/xfa_doclayout.h" | 11 #include "xfa/fxfa/parser/xfa_doclayout.h" |
12 #include "xfa/fxfa/parser/xfa_document.h" | 12 #include "xfa/fxfa/parser/xfa_document.h" |
13 #include "xfa/fxfa/parser/xfa_document_layout_imp.h" | 13 #include "xfa/fxfa/parser/xfa_document_layout_imp.h" |
14 #include "xfa/fxfa/parser/xfa_layout_itemlayout.h" | 14 #include "xfa/fxfa/parser/xfa_layout_itemlayout.h" |
15 #include "xfa/fxfa/parser/xfa_layout_pagemgr_new.h" | 15 #include "xfa/fxfa/parser/xfa_layout_pagemgr_new.h" |
16 #include "xfa/fxfa/parser/xfa_localemgr.h" | 16 #include "xfa/fxfa/parser/xfa_localemgr.h" |
17 #include "xfa/fxfa/parser/xfa_object.h" | 17 #include "xfa/fxfa/parser/xfa_object.h" |
18 #include "xfa/fxfa/parser/xfa_parser.h" | 18 #include "xfa/fxfa/parser/xfa_parser.h" |
19 #include "xfa/fxfa/parser/xfa_parser_imp.h" | 19 #include "xfa/fxfa/parser/xfa_parser_imp.h" |
20 #include "xfa/fxfa/parser/xfa_script.h" | 20 #include "xfa/fxfa/parser/xfa_script.h" |
21 #include "xfa/fxfa/parser/xfa_utils.h" | 21 #include "xfa/fxfa/parser/xfa_utils.h" |
22 | 22 |
23 uint32_t XFA_GetRelevant(CXFA_Node* pFormItem, uint32_t dwParentRelvant) { | |
24 uint32_t dwRelevant = XFA_LAYOUTSTATUS_Viewable | XFA_LAYOUTSTATUS_Printable; | |
25 CFX_WideStringC wsRelevant; | |
26 if (pFormItem->TryCData(XFA_ATTRIBUTE_Relevant, wsRelevant)) { | |
27 if (wsRelevant == FX_WSTRC(L"+print") || wsRelevant == FX_WSTRC(L"print")) { | |
28 dwRelevant &= ~XFA_LAYOUTSTATUS_Viewable; | |
29 } else if (wsRelevant == FX_WSTRC(L"-print")) { | |
30 dwRelevant &= ~XFA_LAYOUTSTATUS_Printable; | |
31 } | |
32 } | |
33 if (!(dwParentRelvant & XFA_LAYOUTSTATUS_Viewable) && | |
34 (dwRelevant != XFA_LAYOUTSTATUS_Viewable)) { | |
35 dwRelevant &= ~XFA_LAYOUTSTATUS_Viewable; | |
36 } | |
37 if (!(dwParentRelvant & XFA_LAYOUTSTATUS_Printable) && | |
38 (dwRelevant != XFA_LAYOUTSTATUS_Printable)) { | |
39 dwRelevant &= ~XFA_LAYOUTSTATUS_Printable; | |
40 } | |
41 return dwRelevant; | |
42 } | |
43 void XFA_ReleaseLayoutItem(CXFA_LayoutItem* pLayoutItem) { | 23 void XFA_ReleaseLayoutItem(CXFA_LayoutItem* pLayoutItem) { |
44 CXFA_LayoutItem* pNode = pLayoutItem->m_pFirstChild; | 24 CXFA_LayoutItem* pNode = pLayoutItem->m_pFirstChild; |
45 CXFA_FFNotify* pNotify = | 25 CXFA_FFNotify* pNotify = |
46 pLayoutItem->m_pFormNode->GetDocument()->GetParser()->GetNotify(); | 26 pLayoutItem->m_pFormNode->GetDocument()->GetParser()->GetNotify(); |
47 CXFA_LayoutProcessor* pDocLayout = | 27 CXFA_LayoutProcessor* pDocLayout = |
48 pLayoutItem->m_pFormNode->GetDocument()->GetDocLayout(); | 28 pLayoutItem->m_pFormNode->GetDocument()->GetDocLayout(); |
49 while (pNode) { | 29 while (pNode) { |
50 CXFA_LayoutItem* pNext = pNode->m_pNextSibling; | 30 CXFA_LayoutItem* pNext = pNode->m_pNextSibling; |
51 pNode->m_pParent = nullptr; | 31 pNode->m_pParent = nullptr; |
52 pNotify->OnLayoutItemRemoving(pDocLayout, | 32 pNotify->OnLayoutItemRemoving(pDocLayout, |
53 static_cast<CXFA_LayoutItem*>(pNode)); | 33 static_cast<CXFA_LayoutItem*>(pNode)); |
54 XFA_ReleaseLayoutItem(pNode); | 34 XFA_ReleaseLayoutItem(pNode); |
55 pNode = pNext; | 35 pNode = pNext; |
56 } | 36 } |
57 pNotify->OnLayoutItemRemoving(pDocLayout, pLayoutItem); | 37 pNotify->OnLayoutItemRemoving(pDocLayout, pLayoutItem); |
58 if (pLayoutItem->m_pFormNode->GetClassID() == XFA_ELEMENT_PageArea) { | 38 if (pLayoutItem->m_pFormNode->GetClassID() == XFA_ELEMENT_PageArea) { |
59 pNotify->OnPageEvent(static_cast<CXFA_ContainerLayoutItem*>(pLayoutItem), | 39 pNotify->OnPageEvent(static_cast<CXFA_ContainerLayoutItem*>(pLayoutItem), |
60 XFA_PAGEVIEWEVENT_PostRemoved); | 40 XFA_PAGEVIEWEVENT_PostRemoved); |
61 } | 41 } |
62 delete pLayoutItem; | 42 delete pLayoutItem; |
63 } | 43 } |
OLD | NEW |