1 // Copyright 2016 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_LAYOUT_CXFA_LAYOUTITEM_H_ 8 #define XFA_FXFA_LAYOUT_CXFA_LAYOUTITEM_H_ 9 10 #include "core/fxcrt/retain_ptr.h" 11 #include "core/fxcrt/retained_tree_node.h" 12 #include "core/fxcrt/unowned_ptr.h" 13 #include "xfa/fxfa/parser/cxfa_document.h" 14 15 class CXFA_ContentLayoutItem; 16 class CXFA_LayoutProcessor; 17 class CXFA_ViewLayoutItem; 18 19 class CXFA_LayoutItem : public RetainedTreeNode<CXFA_LayoutItem> { 20 public: 21 ~CXFA_LayoutItem() override; 22 IsViewLayoutItem()23 bool IsViewLayoutItem() const { return m_ItemType == kViewItem; } IsContentLayoutItem()24 bool IsContentLayoutItem() const { return m_ItemType == kContentItem; } 25 CXFA_ViewLayoutItem* AsViewLayoutItem(); 26 const CXFA_ViewLayoutItem* AsViewLayoutItem() const; 27 CXFA_ContentLayoutItem* AsContentLayoutItem(); 28 const CXFA_ContentLayoutItem* AsContentLayoutItem() const; 29 30 const CXFA_ViewLayoutItem* GetPage() const; GetFormNode()31 CXFA_Node* GetFormNode() const { return m_pFormNode.Get(); } SetFormNode(CXFA_Node * pNode)32 void SetFormNode(CXFA_Node* pNode) { m_pFormNode = pNode; } 33 34 protected: 35 enum ItemType { kViewItem, kContentItem }; 36 CXFA_LayoutItem(CXFA_Node* pNode, ItemType type); 37 38 private: 39 const ItemType m_ItemType; 40 UnownedPtr<CXFA_Node> m_pFormNode; 41 }; 42 ToViewLayoutItem(CXFA_LayoutItem * item)43inline CXFA_ViewLayoutItem* ToViewLayoutItem(CXFA_LayoutItem* item) { 44 return item ? item->AsViewLayoutItem() : nullptr; 45 } 46 ToContentLayoutItem(CXFA_LayoutItem * item)47inline CXFA_ContentLayoutItem* ToContentLayoutItem(CXFA_LayoutItem* item) { 48 return item ? item->AsContentLayoutItem() : nullptr; 49 } 50 51 void XFA_ReleaseLayoutItem(const RetainPtr<CXFA_LayoutItem>& pLayoutItem); 52 53 #endif // XFA_FXFA_LAYOUT_CXFA_LAYOUTITEM_H_ 54