Merge XFA to PDFium master at 4dc95e7 on 10/28/2014
[pdfium.git] / xfa / src / fxfa / src / parser / xfa_layout_appadapter.h
1 // Copyright 2014 PDFium Authors. All rights reserved.\r
2 // Use of this source code is governed by a BSD-style license that can be\r
3 // found in the LICENSE file.\r
4 \r
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com\r
6 \r
7 #ifndef _XFA_LAYOUT_APPADAPTER_H_\r
8 #define _XFA_LAYOUT_APPADAPTER_H_\r
9 class CXFA_TraverseStrategy_PageAreaContainerLayoutItem\r
10 {\r
11 public:\r
12     static inline CXFA_ContainerLayoutItemImpl* GetFirstChild(CXFA_ContainerLayoutItemImpl* pLayoutItem)\r
13     {\r
14         if(pLayoutItem->m_pFormNode->GetClassID() == XFA_ELEMENT_PageSet) {\r
15             return (CXFA_ContainerLayoutItemImpl*)pLayoutItem->m_pFirstChild;\r
16         }\r
17         return NULL;\r
18     }\r
19     static inline CXFA_ContainerLayoutItemImpl* GetNextSibling(CXFA_ContainerLayoutItemImpl* pLayoutItem)\r
20     {\r
21         return (CXFA_ContainerLayoutItemImpl*)pLayoutItem->m_pNextSibling;\r
22     }\r
23     static inline CXFA_ContainerLayoutItemImpl* GetParent(CXFA_ContainerLayoutItemImpl* pLayoutItem)\r
24     {\r
25         return (CXFA_ContainerLayoutItemImpl*)pLayoutItem->m_pParent;\r
26     }\r
27 };\r
28 class CXFA_TraverseStrategy_ContentAreaContainerLayoutItem\r
29 {\r
30 public:\r
31     static inline CXFA_ContainerLayoutItemImpl* GetFirstChild(CXFA_ContainerLayoutItemImpl* pLayoutItem)\r
32     {\r
33         for(CXFA_LayoutItemImpl* pChildItem = pLayoutItem->m_pFirstChild; pChildItem; pChildItem = pChildItem->m_pNextSibling) {\r
34             if(pChildItem->IsContentLayoutItem()) {\r
35                 continue;\r
36             }\r
37             return (CXFA_ContainerLayoutItemImpl*)pChildItem;\r
38         }\r
39         return NULL;\r
40     }\r
41     static inline CXFA_ContainerLayoutItemImpl* GetNextSibling(CXFA_ContainerLayoutItemImpl* pLayoutItem)\r
42     {\r
43         for(CXFA_LayoutItemImpl* pChildItem = pLayoutItem->m_pNextSibling; pChildItem; pChildItem = pChildItem->m_pNextSibling) {\r
44             if(pChildItem->IsContentLayoutItem()) {\r
45                 continue;\r
46             }\r
47             return (CXFA_ContainerLayoutItemImpl*)pChildItem;\r
48         }\r
49         return NULL;\r
50     }\r
51     static inline CXFA_ContainerLayoutItemImpl* GetParent(CXFA_ContainerLayoutItemImpl* pLayoutItem)\r
52     {\r
53         return (CXFA_ContainerLayoutItemImpl*)pLayoutItem->m_pParent;\r
54     }\r
55 };\r
56 class CXFA_TraverseStrategy_ContentLayoutItem\r
57 {\r
58 public:\r
59     static inline CXFA_ContentLayoutItemImpl* GetFirstChild(CXFA_ContentLayoutItemImpl* pLayoutItem)\r
60     {\r
61         return (CXFA_ContentLayoutItemImpl*)pLayoutItem->m_pFirstChild;\r
62     }\r
63     static inline CXFA_ContentLayoutItemImpl* GetNextSibling(CXFA_ContentLayoutItemImpl* pLayoutItem)\r
64     {\r
65         return (CXFA_ContentLayoutItemImpl*)pLayoutItem->m_pNextSibling;\r
66     }\r
67     static inline CXFA_ContentLayoutItemImpl* GetParent(CXFA_ContentLayoutItemImpl* pLayoutItem)\r
68     {\r
69         return (CXFA_ContentLayoutItemImpl*)pLayoutItem->m_pParent;\r
70     }\r
71 };\r
72 FX_DWORD        XFA_GetRelevant(CXFA_Node* pFormItem, FX_DWORD dwParentRelvant);\r
73 void            XFA_ReleaseLayoutItem(CXFA_LayoutItemImpl* pLayoutItem);\r
74 #endif\r