Home | History | Annotate | Download | only in parser
      1 // Copyright 2014 PDFium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
      6 
      7 #include "xfa/src/foxitlib.h"
      8 #include "xfa/src/fxfa/src/common/xfa_utils.h"
      9 #include "xfa/src/fxfa/src/common/xfa_object.h"
     10 #include "xfa/src/fxfa/src/common/xfa_document.h"
     11 #include "xfa/src/fxfa/src/common/xfa_parser.h"
     12 #include "xfa/src/fxfa/src/common/xfa_script.h"
     13 #include "xfa/src/fxfa/src/common/xfa_docdata.h"
     14 #include "xfa/src/fxfa/src/common/xfa_doclayout.h"
     15 #include "xfa/src/fxfa/src/common/xfa_localemgr.h"
     16 #include "xfa/src/fxfa/src/common/xfa_fm2jsapi.h"
     17 #include "xfa_document_layout_imp.h"
     18 #include "xfa_layout_itemlayout.h"
     19 #include "xfa_layout_pagemgr_new.h"
     20 #include "xfa_layout_appadapter.h"
     21 FX_DWORD XFA_GetRelevant(CXFA_Node* pFormItem, FX_DWORD dwParentRelvant) {
     22   FX_DWORD dwRelevant = XFA_LAYOUTSTATUS_Viewable | XFA_LAYOUTSTATUS_Printable;
     23   CFX_WideStringC wsRelevant;
     24   if (pFormItem->TryCData(XFA_ATTRIBUTE_Relevant, wsRelevant)) {
     25     if (wsRelevant == FX_WSTRC(L"+print") || wsRelevant == FX_WSTRC(L"print")) {
     26       dwRelevant &= ~XFA_LAYOUTSTATUS_Viewable;
     27     } else if (wsRelevant == FX_WSTRC(L"-print")) {
     28       dwRelevant &= ~XFA_LAYOUTSTATUS_Printable;
     29     }
     30   }
     31   if (!(dwParentRelvant & XFA_LAYOUTSTATUS_Viewable) &&
     32       (dwRelevant != XFA_LAYOUTSTATUS_Viewable)) {
     33     dwRelevant &= ~XFA_LAYOUTSTATUS_Viewable;
     34   }
     35   if (!(dwParentRelvant & XFA_LAYOUTSTATUS_Printable) &&
     36       (dwRelevant != XFA_LAYOUTSTATUS_Printable)) {
     37     dwRelevant &= ~XFA_LAYOUTSTATUS_Printable;
     38   }
     39   return dwRelevant;
     40 }
     41 void XFA_ReleaseLayoutItem(CXFA_LayoutItem* pLayoutItem) {
     42   CXFA_LayoutItem* pNode = pLayoutItem->m_pFirstChild;
     43   while (pNode) {
     44     CXFA_LayoutItem* pNext = pNode->m_pNextSibling;
     45     pNode->m_pParent = nullptr;
     46     XFA_ReleaseLayoutItem(pNode);
     47     pNode = pNext;
     48   }
     49   IXFA_Notify* pNotify =
     50       pLayoutItem->m_pFormNode->GetDocument()->GetParser()->GetNotify();
     51   if (pLayoutItem->m_pFormNode->GetClassID() == XFA_ELEMENT_PageArea) {
     52     pNotify->OnPageEvent(static_cast<CXFA_ContainerLayoutItem*>(pLayoutItem),
     53                          XFA_PAGEEVENT_PageRemoved);
     54   }
     55   delete pLayoutItem;
     56 }
     57