Home | History | Annotate | Download | only in parser
      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 "fxjs/xfa/cjx_object.h"
     10 #include "xfa/fxfa/parser/cxfa_layoutpagemgr.h"
     11 #include "xfa/fxfa/parser/cxfa_layoutprocessor.h"
     12 #include "xfa/fxfa/parser/cxfa_measurement.h"
     13 #include "xfa/fxfa/parser/cxfa_medium.h"
     14 #include "xfa/fxfa/parser/cxfa_node.h"
     15 
     16 CXFA_ContainerLayoutItem::CXFA_ContainerLayoutItem(CXFA_Node* pNode)
     17     : CXFA_LayoutItem(pNode, false), m_pOldSubform(nullptr) {}
     18 
     19 CXFA_LayoutProcessor* CXFA_ContainerLayoutItem::GetLayout() const {
     20   return m_pFormNode->GetDocument()->GetLayoutProcessor();
     21 }
     22 
     23 int32_t CXFA_ContainerLayoutItem::GetPageIndex() const {
     24   return m_pFormNode->GetDocument()
     25       ->GetLayoutProcessor()
     26       ->GetLayoutPageMgr()
     27       ->GetPageIndex(this);
     28 }
     29 
     30 CFX_SizeF CXFA_ContainerLayoutItem::GetPageSize() const {
     31   CFX_SizeF size;
     32   CXFA_Medium* pMedium =
     33       m_pFormNode->GetFirstChildByClass<CXFA_Medium>(XFA_Element::Medium);
     34   if (!pMedium)
     35     return size;
     36 
     37   size = CFX_SizeF(pMedium->JSObject()
     38                        ->GetMeasure(XFA_Attribute::Short)
     39                        .ToUnit(XFA_Unit::Pt),
     40                    pMedium->JSObject()
     41                        ->GetMeasure(XFA_Attribute::Long)
     42                        .ToUnit(XFA_Unit::Pt));
     43   if (pMedium->JSObject()->GetEnum(XFA_Attribute::Orientation) ==
     44       XFA_AttributeEnum::Landscape) {
     45     size = CFX_SizeF(size.height, size.width);
     46   }
     47   return size;
     48 }
     49 
     50 CXFA_Node* CXFA_ContainerLayoutItem::GetMasterPage() const {
     51   return m_pFormNode;
     52 }
     53