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_PARSER_CXFA_LAYOUTITEM_H_
8#define XFA_FXFA_PARSER_CXFA_LAYOUTITEM_H_
9
10#include "xfa/fxfa/parser/cxfa_document.h"
11
12class CXFA_ContainerLayoutItem;
13class CXFA_ContentLayoutItem;
14class CXFA_LayoutProcessor;
15
16void XFA_ReleaseLayoutItem(CXFA_LayoutItem* pLayoutItem);
17
18class CXFA_LayoutItem {
19 public:
20  virtual ~CXFA_LayoutItem();
21
22  bool IsContainerLayoutItem() const { return !m_bIsContentLayoutItem; }
23  bool IsContentLayoutItem() const { return m_bIsContentLayoutItem; }
24  CXFA_ContainerLayoutItem* AsContainerLayoutItem();
25  CXFA_ContentLayoutItem* AsContentLayoutItem();
26
27  CXFA_ContainerLayoutItem* GetPage() const;
28  CXFA_Node* GetFormNode() const { return m_pFormNode; }
29  CFX_RectF GetRect(bool bRelative) const;
30
31  int32_t GetIndex() const;
32  int32_t GetCount() const;
33
34  CXFA_LayoutItem* GetParent() const { return m_pParent; }
35  CXFA_LayoutItem* GetFirst();
36  const CXFA_LayoutItem* GetLast() const;
37  CXFA_LayoutItem* GetPrev() const;
38  CXFA_LayoutItem* GetNext() const;
39
40  void AddChild(CXFA_LayoutItem* pChildItem);
41  void AddHeadChild(CXFA_LayoutItem* pChildItem);
42  void RemoveChild(CXFA_LayoutItem* pChildItem);
43  void InsertChild(CXFA_LayoutItem* pBeforeItem, CXFA_LayoutItem* pChildItem);
44
45  CXFA_Node* m_pFormNode;
46  CXFA_LayoutItem* m_pParent;
47  CXFA_LayoutItem* m_pNextSibling;
48  CXFA_LayoutItem* m_pFirstChild;
49
50 protected:
51  CXFA_LayoutItem(CXFA_Node* pNode, bool bIsContentLayoutItem);
52
53  bool m_bIsContentLayoutItem;
54};
55
56#endif  // XFA_FXFA_PARSER_CXFA_LAYOUTITEM_H_
57