• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_DOCLAYOUT_H_
8 #define _XFA_DOCLAYOUT_H_
9 #define _XFA_LAYOUTITEM_ProcessCACHE_
10 
11 class CXFA_ContainerLayoutItem;
12 class CXFA_ContentLayoutItem;
13 
14 class IXFA_LayoutPage {
15  public:
~IXFA_LayoutPage()16   virtual ~IXFA_LayoutPage() {}
17   virtual IXFA_DocLayout* GetLayout() const = 0;
18   virtual int32_t GetPageIndex() const = 0;
19   virtual void GetPageSize(CFX_SizeF& size) = 0;
20   virtual CXFA_Node* GetMasterPage() const = 0;
21 };
22 
23 class CXFA_LayoutItem {
24  public:
25   virtual ~CXFA_LayoutItem();
26 
IsContainerLayoutItem()27   FX_BOOL IsContainerLayoutItem() const { return !m_bIsContentLayoutItem; }
IsContentLayoutItem()28   FX_BOOL IsContentLayoutItem() const { return m_bIsContentLayoutItem; }
29   inline CXFA_ContainerLayoutItem* AsContainerLayoutItem();
30   inline CXFA_ContentLayoutItem* AsContentLayoutItem();
31 
32   IXFA_LayoutPage* GetPage() const;
33   CXFA_Node* GetFormNode() const;
34   void GetRect(CFX_RectF& rtLayout, FX_BOOL bRelative = FALSE) const;
35   int32_t GetIndex() const;
36   int32_t GetCount() const;
37   CXFA_LayoutItem* GetParent() const;
38   const CXFA_LayoutItem* GetFirst() const;
39   CXFA_LayoutItem* GetFirst();
40   const CXFA_LayoutItem* GetLast() const;
41   CXFA_LayoutItem* GetLast();
42   CXFA_LayoutItem* GetPrev() const;
43   CXFA_LayoutItem* GetNext() const;
44 
45   void AddChild(CXFA_LayoutItem* pChildItem);
46   void AddHeadChild(CXFA_LayoutItem* pChildItem);
47   void RemoveChild(CXFA_LayoutItem* pChildItem);
48   void InsertChild(CXFA_LayoutItem* pBeforeItem, CXFA_LayoutItem* pChildItem);
49 
50   CXFA_Node* m_pFormNode;
51   CXFA_LayoutItem* m_pParent;
52   CXFA_LayoutItem* m_pNextSibling;
53   CXFA_LayoutItem* m_pFirstChild;
54 
55  protected:
56   CXFA_LayoutItem(CXFA_Node* pNode, FX_BOOL bIsContentLayoutItem);
57 
58   FX_BOOL m_bIsContentLayoutItem;
59 };
60 
61 class CXFA_ContainerLayoutItem : public CXFA_LayoutItem,
62                                  public IXFA_LayoutPage {
63  public:
64   CXFA_ContainerLayoutItem(CXFA_Node* pNode);
65 
66   // IXFA_LayoutPage:
67   IXFA_DocLayout* GetLayout() const override;
68   int32_t GetPageIndex() const override;
69   void GetPageSize(CFX_SizeF& size) override;
70   CXFA_Node* GetMasterPage() const override;
71 
72   CXFA_Node* m_pOldSubform;
73 };
74 
75 #define XFA_WIDGETSTATUS_Access 0x80000000
76 #define XFA_WIDGETSTATUS_Disabled 0x40000000
77 #define XFA_WIDGETSTATUS_RectCached 0x20000000
78 #define XFA_WIDGETSTATUS_ButtonDown 0x10000000
79 #define XFA_WIDGETSTATUS_Highlight 0x08000000
80 #define XFA_WIDGETSTATUS_TextEditValueChanged 0x04000000
81 
82 class CXFA_ContentLayoutItem : public CXFA_LayoutItem {
83  public:
84   CXFA_ContentLayoutItem(CXFA_Node* pNode);
85   virtual ~CXFA_ContentLayoutItem();
86 
87   CXFA_ContentLayoutItem* m_pPrev;
88   CXFA_ContentLayoutItem* m_pNext;
89   CFX_PointF m_sPos;
90   CFX_SizeF m_sSize;
91   FX_DWORD m_dwStatus;
92 };
93 
AsContainerLayoutItem()94 CXFA_ContainerLayoutItem* CXFA_LayoutItem::AsContainerLayoutItem() {
95   return IsContainerLayoutItem() ? static_cast<CXFA_ContainerLayoutItem*>(this)
96                                  : nullptr;
97 }
AsContentLayoutItem()98 CXFA_ContentLayoutItem* CXFA_LayoutItem::AsContentLayoutItem() {
99   return IsContentLayoutItem() ? static_cast<CXFA_ContentLayoutItem*>(this)
100                                : nullptr;
101 }
ToContainerLayoutItem(CXFA_LayoutItem * pItem)102 inline CXFA_ContainerLayoutItem* ToContainerLayoutItem(CXFA_LayoutItem* pItem) {
103   return pItem ? pItem->AsContainerLayoutItem() : nullptr;
104 }
ToContentLayoutItem(CXFA_LayoutItem * pItem)105 inline CXFA_ContentLayoutItem* ToContentLayoutItem(CXFA_LayoutItem* pItem) {
106   return pItem ? pItem->AsContentLayoutItem() : nullptr;
107 }
108 
109 class CXFA_TraverseStrategy_LayoutItem {
110  public:
GetFirstChild(CXFA_LayoutItem * pLayoutItem)111   static inline CXFA_LayoutItem* GetFirstChild(CXFA_LayoutItem* pLayoutItem) {
112     return pLayoutItem->m_pFirstChild;
113   }
GetNextSibling(CXFA_LayoutItem * pLayoutItem)114   static inline CXFA_LayoutItem* GetNextSibling(CXFA_LayoutItem* pLayoutItem) {
115     return pLayoutItem->m_pNextSibling;
116   }
GetParent(CXFA_LayoutItem * pLayoutItem)117   static inline CXFA_LayoutItem* GetParent(CXFA_LayoutItem* pLayoutItem) {
118     return pLayoutItem->m_pParent;
119   }
120 };
121 
122 class IXFA_DocLayout {
123  public:
~IXFA_DocLayout()124   virtual ~IXFA_DocLayout() {}
125   virtual CXFA_Document* GetDocument() const = 0;
126   virtual int32_t StartLayout(FX_BOOL bForceRestart = FALSE) = 0;
127   virtual int32_t DoLayout(IFX_Pause* pPause = NULL) = 0;
128   virtual FX_BOOL IncrementLayout() = 0;
129   virtual int32_t CountPages() const = 0;
130   virtual IXFA_LayoutPage* GetPage(int32_t index) const = 0;
131   virtual CXFA_LayoutItem* GetLayoutItem(CXFA_Node* pFormItem) = 0;
132 };
133 #endif
134