OLD | NEW |
| (Empty) |
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 #ifndef XFA_FXFA_PARSER_XFA_DOCLAYOUT_H_ | |
8 #define XFA_FXFA_PARSER_XFA_DOCLAYOUT_H_ | |
9 | |
10 #include "xfa/fxfa/parser/xfa_document.h" | |
11 | |
12 class CXFA_ContainerLayoutItem; | |
13 class CXFA_ContentLayoutItem; | |
14 class CXFA_LayoutProcessor; | |
15 | |
16 class CXFA_LayoutItem { | |
17 public: | |
18 virtual ~CXFA_LayoutItem(); | |
19 | |
20 FX_BOOL IsContainerLayoutItem() const { return !m_bIsContentLayoutItem; } | |
21 FX_BOOL IsContentLayoutItem() const { return m_bIsContentLayoutItem; } | |
22 inline CXFA_ContainerLayoutItem* AsContainerLayoutItem(); | |
23 inline CXFA_ContentLayoutItem* AsContentLayoutItem(); | |
24 | |
25 CXFA_ContainerLayoutItem* GetPage() const; | |
26 CXFA_Node* GetFormNode() const; | |
27 void GetRect(CFX_RectF& rtLayout, FX_BOOL bRelative = FALSE) const; | |
28 int32_t GetIndex() const; | |
29 int32_t GetCount() const; | |
30 CXFA_LayoutItem* GetParent() const; | |
31 const CXFA_LayoutItem* GetFirst() const; | |
32 CXFA_LayoutItem* GetFirst(); | |
33 const CXFA_LayoutItem* GetLast() const; | |
34 CXFA_LayoutItem* GetLast(); | |
35 CXFA_LayoutItem* GetPrev() const; | |
36 CXFA_LayoutItem* GetNext() const; | |
37 | |
38 void AddChild(CXFA_LayoutItem* pChildItem); | |
39 void AddHeadChild(CXFA_LayoutItem* pChildItem); | |
40 void RemoveChild(CXFA_LayoutItem* pChildItem); | |
41 void InsertChild(CXFA_LayoutItem* pBeforeItem, CXFA_LayoutItem* pChildItem); | |
42 | |
43 CXFA_Node* m_pFormNode; | |
44 CXFA_LayoutItem* m_pParent; | |
45 CXFA_LayoutItem* m_pNextSibling; | |
46 CXFA_LayoutItem* m_pFirstChild; | |
47 | |
48 protected: | |
49 CXFA_LayoutItem(CXFA_Node* pNode, FX_BOOL bIsContentLayoutItem); | |
50 | |
51 FX_BOOL m_bIsContentLayoutItem; | |
52 }; | |
53 | |
54 class CXFA_ContainerLayoutItem : public CXFA_LayoutItem { | |
55 public: | |
56 CXFA_ContainerLayoutItem(CXFA_Node* pNode); | |
57 | |
58 CXFA_LayoutProcessor* GetLayout() const; | |
59 int32_t GetPageIndex() const; | |
60 void GetPageSize(CFX_SizeF& size) const; | |
61 CXFA_Node* GetMasterPage() const; | |
62 | |
63 CXFA_Node* m_pOldSubform; | |
64 }; | |
65 | |
66 class CXFA_ContentLayoutItem : public CXFA_LayoutItem { | |
67 public: | |
68 CXFA_ContentLayoutItem(CXFA_Node* pNode); | |
69 ~CXFA_ContentLayoutItem() override; | |
70 | |
71 CXFA_ContentLayoutItem* m_pPrev; | |
72 CXFA_ContentLayoutItem* m_pNext; | |
73 CFX_PointF m_sPos; | |
74 CFX_SizeF m_sSize; | |
75 uint32_t m_dwStatus; | |
76 }; | |
77 | |
78 CXFA_ContainerLayoutItem* CXFA_LayoutItem::AsContainerLayoutItem() { | |
79 return IsContainerLayoutItem() ? static_cast<CXFA_ContainerLayoutItem*>(this) | |
80 : nullptr; | |
81 } | |
82 CXFA_ContentLayoutItem* CXFA_LayoutItem::AsContentLayoutItem() { | |
83 return IsContentLayoutItem() ? static_cast<CXFA_ContentLayoutItem*>(this) | |
84 : nullptr; | |
85 } | |
86 inline CXFA_ContainerLayoutItem* ToContainerLayoutItem(CXFA_LayoutItem* pItem) { | |
87 return pItem ? pItem->AsContainerLayoutItem() : nullptr; | |
88 } | |
89 inline CXFA_ContentLayoutItem* ToContentLayoutItem(CXFA_LayoutItem* pItem) { | |
90 return pItem ? pItem->AsContentLayoutItem() : nullptr; | |
91 } | |
92 | |
93 class CXFA_TraverseStrategy_LayoutItem { | |
94 public: | |
95 static inline CXFA_LayoutItem* GetFirstChild(CXFA_LayoutItem* pLayoutItem) { | |
96 return pLayoutItem->m_pFirstChild; | |
97 } | |
98 static inline CXFA_LayoutItem* GetNextSibling(CXFA_LayoutItem* pLayoutItem) { | |
99 return pLayoutItem->m_pNextSibling; | |
100 } | |
101 static inline CXFA_LayoutItem* GetParent(CXFA_LayoutItem* pLayoutItem) { | |
102 return pLayoutItem->m_pParent; | |
103 } | |
104 }; | |
105 | |
106 #endif // XFA_FXFA_PARSER_XFA_DOCLAYOUT_H_ | |
OLD | NEW |