cxfa_containerlayoutitem.cpp revision 4d3acf4ec42bf6e838f9060103aff98fbf170794
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#include "xfa/fxfa/parser/cxfa_containerlayoutitem.h"
8
9#include "xfa/fxfa/parser/cxfa_layoutpagemgr.h"
10#include "xfa/fxfa/parser/cxfa_layoutprocessor.h"
11#include "xfa/fxfa/parser/cxfa_measurement.h"
12
13CXFA_ContainerLayoutItem::CXFA_ContainerLayoutItem(CXFA_Node* pNode)
14    : CXFA_LayoutItem(pNode, false), m_pOldSubform(nullptr) {}
15
16CXFA_LayoutProcessor* CXFA_ContainerLayoutItem::GetLayout() const {
17  return m_pFormNode->GetDocument()->GetLayoutProcessor();
18}
19
20int32_t CXFA_ContainerLayoutItem::GetPageIndex() const {
21  return m_pFormNode->GetDocument()
22      ->GetLayoutProcessor()
23      ->GetLayoutPageMgr()
24      ->GetPageIndex(this);
25}
26
27CFX_SizeF CXFA_ContainerLayoutItem::GetPageSize() const {
28  CFX_SizeF size;
29  CXFA_Node* pMedium = m_pFormNode->GetFirstChildByClass(XFA_Element::Medium);
30  if (!pMedium)
31    return size;
32
33  size = CFX_SizeF(pMedium->GetMeasure(XFA_ATTRIBUTE_Short).ToUnit(XFA_UNIT_Pt),
34                   pMedium->GetMeasure(XFA_ATTRIBUTE_Long).ToUnit(XFA_UNIT_Pt));
35  if (pMedium->GetEnum(XFA_ATTRIBUTE_Orientation) ==
36      XFA_ATTRIBUTEENUM_Landscape) {
37    size = CFX_SizeF(size.y, size.x);
38  }
39  return size;
40}
41
42CXFA_Node* CXFA_ContainerLayoutItem::GetMasterPage() const {
43  return m_pFormNode;
44}
45