Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
cxfa_viewlayoutitem.cpp
Go to the documentation of this file.
1// Copyright 2016 The PDFium Authors
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/layout/cxfa_viewlayoutitem.h"
8
9#include "fxjs/xfa/cjx_object.h"
10#include "xfa/fxfa/cxfa_ffpageview.h"
11#include "xfa/fxfa/layout/cxfa_layoutprocessor.h"
12#include "xfa/fxfa/layout/cxfa_viewlayoutprocessor.h"
13#include "xfa/fxfa/parser/cxfa_measurement.h"
14#include "xfa/fxfa/parser/cxfa_medium.h"
15#include "xfa/fxfa/parser/cxfa_node.h"
16
17CXFA_ViewLayoutItem::CXFA_ViewLayoutItem(CXFA_Node* pNode,
18 CXFA_FFPageView* pPageView)
19 : CXFA_LayoutItem(pNode, kViewItem), m_pFFPageView(pPageView) {
20 if (m_pFFPageView)
21 m_pFFPageView->SetLayoutItem(this);
22}
23
24CXFA_ViewLayoutItem::~CXFA_ViewLayoutItem() = default;
25
26void CXFA_ViewLayoutItem::Trace(cppgc::Visitor* visitor) const {
27 CXFA_LayoutItem::Trace(visitor);
28 visitor->Trace(m_pOldSubform);
29 visitor->Trace(m_pFFPageView);
30}
31
32CXFA_LayoutProcessor* CXFA_ViewLayoutItem::GetLayout() const {
33 return CXFA_LayoutProcessor::FromDocument(GetFormNode()->GetDocument());
34}
35
36int32_t CXFA_ViewLayoutItem::GetPageIndex() const {
37 auto* pLayout =
38 CXFA_LayoutProcessor::FromDocument(GetFormNode()->GetDocument());
39 return pLayout->GetLayoutPageMgr()->GetPageIndex(this);
40}
41
42CFX_SizeF CXFA_ViewLayoutItem::GetPageSize() const {
43 CFX_SizeF size;
44 CXFA_Medium* pMedium =
45 GetFormNode()->GetFirstChildByClass<CXFA_Medium>(XFA_Element::Medium);
46 if (!pMedium)
47 return size;
48
49 size = CFX_SizeF(
50 pMedium->JSObject()->GetMeasureInUnit(XFA_Attribute::Short, XFA_Unit::Pt),
51 pMedium->JSObject()->GetMeasureInUnit(XFA_Attribute::Long, XFA_Unit::Pt));
52 if (pMedium->JSObject()->GetEnum(XFA_Attribute::Orientation) ==
53 XFA_AttributeValue::Landscape) {
54 size = CFX_SizeF(size.height, size.width);
55 }
56 return size;
57}
58
59CXFA_Node* CXFA_ViewLayoutItem::GetMasterPage() const {
60 return GetFormNode();
61}
62
63void CXFA_ViewLayoutItem::SetOldSubform(CXFA_Node* pSubform) {
64 m_pOldSubform = pSubform;
65}
CXFA_Node * GetFormNode() const
CXFA_LayoutItem(CXFA_Node *pNode, ItemType type)
static CXFA_LayoutProcessor * FromDocument(const CXFA_Document *pXFADoc)
~CXFA_ViewLayoutItem() override
CXFA_Node * GetMasterPage() const
CFX_SizeF GetPageSize() const
void SetOldSubform(CXFA_Node *pSubform)
CXFA_LayoutProcessor * GetLayout() const
void Trace(cppgc::Visitor *visitor) const override
XFA_Unit
Definition fxfa_basic.h:91
XFA_Attribute
Definition fxfa_basic.h:67
XFA_Element
Definition fxfa_basic.h:75
XFA_AttributeValue
Definition fxfa_basic.h:60
Definition heap.h:12