| 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 "../../../foxitlib.h" | 7 #include "../../../foxitlib.h" |
| 8 #include "../common/xfa_utils.h" | 8 #include "../common/xfa_utils.h" |
| 9 #include "../common/xfa_object.h" | 9 #include "../common/xfa_object.h" |
| 10 #include "../common/xfa_document.h" | 10 #include "../common/xfa_document.h" |
| 11 #include "../common/xfa_parser.h" | 11 #include "../common/xfa_parser.h" |
| 12 #include "../common/xfa_script.h" | 12 #include "../common/xfa_script.h" |
| 13 #include "../common/xfa_docdata.h" | 13 #include "../common/xfa_docdata.h" |
| 14 #include "../common/xfa_doclayout.h" | 14 #include "../common/xfa_doclayout.h" |
| 15 #include "../common/xfa_debug.h" | 15 #include "../common/xfa_debug.h" |
| 16 #include "../common/xfa_localemgr.h" | 16 #include "../common/xfa_localemgr.h" |
| 17 #include "../common/xfa_fm2jsapi.h" | 17 #include "../common/xfa_fm2jsapi.h" |
| 18 #include "xfa_debug_parser.h" | 18 #include "xfa_debug_parser.h" |
| 19 #include "xfa_document_layout_imp.h" | 19 #include "xfa_document_layout_imp.h" |
| 20 #include "xfa_layout_itemlayout.h" | 20 #include "xfa_layout_itemlayout.h" |
| 21 #include "xfa_layout_pagemgr_new.h" | 21 #include "xfa_layout_pagemgr_new.h" |
| 22 #include "xfa_layout_appadapter.h" | 22 #include "xfa_layout_appadapter.h" |
| 23 IXFA_DocLayout* IXFA_LayoutPage::GetLayout() const { | 23 IXFA_DocLayout* IXFA_LayoutPage::GetLayout() const { |
| 24 CXFA_ContainerLayoutItemImpl* pThis = (CXFA_ContainerLayoutItemImpl*)this; | 24 CXFA_ContainerLayoutItem* pThis = (CXFA_ContainerLayoutItem*)this; |
| 25 return pThis->m_pFormNode->GetDocument()->GetLayoutProcessor(); | 25 return pThis->m_pFormNode->GetDocument()->GetLayoutProcessor(); |
| 26 } | 26 } |
| 27 int32_t IXFA_LayoutPage::GetPageIndex() const { | 27 int32_t IXFA_LayoutPage::GetPageIndex() const { |
| 28 CXFA_ContainerLayoutItemImpl* pThis = (CXFA_ContainerLayoutItemImpl*)this; | 28 CXFA_ContainerLayoutItem* pThis = (CXFA_ContainerLayoutItem*)this; |
| 29 return pThis->m_pFormNode->GetDocument() | 29 return pThis->m_pFormNode->GetDocument() |
| 30 ->GetLayoutProcessor() | 30 ->GetLayoutProcessor() |
| 31 ->GetLayoutPageMgr() | 31 ->GetLayoutPageMgr() |
| 32 ->GetPageIndex((IXFA_LayoutPage*)this); | 32 ->GetPageIndex((IXFA_LayoutPage*)this); |
| 33 } | 33 } |
| 34 void IXFA_LayoutPage::GetPageSize(CFX_SizeF& size) { | 34 void IXFA_LayoutPage::GetPageSize(CFX_SizeF& size) { |
| 35 CXFA_ContainerLayoutItemImpl* pThis = (CXFA_ContainerLayoutItemImpl*)this; | 35 CXFA_ContainerLayoutItem* pThis = (CXFA_ContainerLayoutItem*)this; |
| 36 size.Set(0, 0); | 36 size.Set(0, 0); |
| 37 CXFA_Node* pMedium = | 37 CXFA_Node* pMedium = |
| 38 pThis->m_pFormNode->GetFirstChildByClass(XFA_ELEMENT_Medium); | 38 pThis->m_pFormNode->GetFirstChildByClass(XFA_ELEMENT_Medium); |
| 39 if (pMedium) { | 39 if (pMedium) { |
| 40 size.x = pMedium->GetMeasure(XFA_ATTRIBUTE_Short).ToUnit(XFA_UNIT_Pt); | 40 size.x = pMedium->GetMeasure(XFA_ATTRIBUTE_Short).ToUnit(XFA_UNIT_Pt); |
| 41 size.y = pMedium->GetMeasure(XFA_ATTRIBUTE_Long).ToUnit(XFA_UNIT_Pt); | 41 size.y = pMedium->GetMeasure(XFA_ATTRIBUTE_Long).ToUnit(XFA_UNIT_Pt); |
| 42 if (pMedium->GetEnum(XFA_ATTRIBUTE_Orientation) == | 42 if (pMedium->GetEnum(XFA_ATTRIBUTE_Orientation) == |
| 43 XFA_ATTRIBUTEENUM_Landscape) { | 43 XFA_ATTRIBUTEENUM_Landscape) { |
| 44 size.Set(size.y, size.x); | 44 size.Set(size.y, size.x); |
| 45 } | 45 } |
| 46 } | 46 } |
| 47 } | 47 } |
| 48 CXFA_Node* IXFA_LayoutPage::GetMasterPage() const { | 48 CXFA_Node* IXFA_LayoutPage::GetMasterPage() const { |
| 49 CXFA_ContainerLayoutItemImpl* pThis = (CXFA_ContainerLayoutItemImpl*)this; | 49 CXFA_ContainerLayoutItem* pThis = (CXFA_ContainerLayoutItem*)this; |
| 50 return pThis->m_pFormNode; | 50 return pThis->m_pFormNode; |
| 51 } | 51 } |
| 52 FX_DWORD XFA_GetRelevant(CXFA_Node* pFormItem, FX_DWORD dwParentRelvant) { | 52 FX_DWORD XFA_GetRelevant(CXFA_Node* pFormItem, FX_DWORD dwParentRelvant) { |
| 53 FX_DWORD dwRelevant = XFA_LAYOUTSTATUS_Viewable | XFA_LAYOUTSTATUS_Printable; | 53 FX_DWORD dwRelevant = XFA_LAYOUTSTATUS_Viewable | XFA_LAYOUTSTATUS_Printable; |
| 54 CFX_WideStringC wsRelevant; | 54 CFX_WideStringC wsRelevant; |
| 55 if (pFormItem->TryCData(XFA_ATTRIBUTE_Relevant, wsRelevant)) { | 55 if (pFormItem->TryCData(XFA_ATTRIBUTE_Relevant, wsRelevant)) { |
| 56 if (wsRelevant == FX_WSTRC(L"+print") || wsRelevant == FX_WSTRC(L"print")) { | 56 if (wsRelevant == FX_WSTRC(L"+print") || wsRelevant == FX_WSTRC(L"print")) { |
| 57 dwRelevant &= ~XFA_LAYOUTSTATUS_Viewable; | 57 dwRelevant &= ~XFA_LAYOUTSTATUS_Viewable; |
| 58 } else if (wsRelevant == FX_WSTRC(L"-print")) { | 58 } else if (wsRelevant == FX_WSTRC(L"-print")) { |
| 59 dwRelevant &= ~XFA_LAYOUTSTATUS_Printable; | 59 dwRelevant &= ~XFA_LAYOUTSTATUS_Printable; |
| 60 } | 60 } |
| 61 } | 61 } |
| 62 if (!(dwParentRelvant & XFA_LAYOUTSTATUS_Viewable) && | 62 if (!(dwParentRelvant & XFA_LAYOUTSTATUS_Viewable) && |
| 63 (dwRelevant != XFA_LAYOUTSTATUS_Viewable)) { | 63 (dwRelevant != XFA_LAYOUTSTATUS_Viewable)) { |
| 64 dwRelevant &= ~XFA_LAYOUTSTATUS_Viewable; | 64 dwRelevant &= ~XFA_LAYOUTSTATUS_Viewable; |
| 65 } | 65 } |
| 66 if (!(dwParentRelvant & XFA_LAYOUTSTATUS_Printable) && | 66 if (!(dwParentRelvant & XFA_LAYOUTSTATUS_Printable) && |
| 67 (dwRelevant != XFA_LAYOUTSTATUS_Printable)) { | 67 (dwRelevant != XFA_LAYOUTSTATUS_Printable)) { |
| 68 dwRelevant &= ~XFA_LAYOUTSTATUS_Printable; | 68 dwRelevant &= ~XFA_LAYOUTSTATUS_Printable; |
| 69 } | 69 } |
| 70 return dwRelevant; | 70 return dwRelevant; |
| 71 } | 71 } |
| 72 void XFA_ReleaseLayoutItem(CXFA_LayoutItemImpl* pLayoutItem) { | 72 void XFA_ReleaseLayoutItem(CXFA_LayoutItem* pLayoutItem) { |
| 73 CXFA_LayoutItemImpl *pNext, *pNode = pLayoutItem->m_pFirstChild; | 73 CXFA_LayoutItem* pNext, * pNode = pLayoutItem->m_pFirstChild; |
| 74 while (pNode) { | 74 while (pNode) { |
| 75 pNext = pNode->m_pNextSibling; | 75 pNext = pNode->m_pNextSibling; |
| 76 pNode->m_pParent = NULL; | 76 pNode->m_pParent = NULL; |
| 77 XFA_ReleaseLayoutItem(pNode); | 77 XFA_ReleaseLayoutItem(pNode); |
| 78 pNode = pNext; | 78 pNode = pNext; |
| 79 } | 79 } |
| 80 delete pLayoutItem; | 80 delete pLayoutItem; |
| 81 } | 81 } |
| OLD | NEW |