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_layoutitem.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_layoutitem.h"
8
9#include "fxjs/xfa/cjx_object.h"
10#include "xfa/fxfa/cxfa_ffnotify.h"
11#include "xfa/fxfa/layout/cxfa_contentlayoutitem.h"
12#include "xfa/fxfa/layout/cxfa_layoutprocessor.h"
13#include "xfa/fxfa/layout/cxfa_viewlayoutitem.h"
14#include "xfa/fxfa/parser/cxfa_margin.h"
15#include "xfa/fxfa/parser/cxfa_measurement.h"
16#include "xfa/fxfa/parser/cxfa_node.h"
17
19 CXFA_LayoutItem* pNode = pLayoutItem->GetFirstChild();
20 while (pNode) {
21 CXFA_LayoutItem* pNext = pNode->GetNextSibling();
23 pNode = pNext;
24 }
25 CXFA_Document* pDocument = pLayoutItem->GetFormNode()->GetDocument();
26 CXFA_FFNotify* pNotify = pDocument->GetNotify();
27 auto* pDocLayout = CXFA_LayoutProcessor::FromDocument(pDocument);
28 pNotify->OnLayoutItemRemoving(pDocLayout, pLayoutItem);
29 if (pLayoutItem->GetFormNode()->GetElementType() == XFA_Element::PageArea) {
32 }
33 pLayoutItem->RemoveSelfIfParented();
34}
35
37 : m_ItemType(type), m_pFormNode(pNode) {}
38
40
42 if (!m_pFormNode)
43 return;
44
45 auto* pJSObj = m_pFormNode->JSObject();
46 if (pJSObj && pJSObj->GetLayoutItem() == this)
47 pJSObj->SetLayoutItem(nullptr);
48}
49
50void CXFA_LayoutItem::Trace(cppgc::Visitor* visitor) const {
51 GCedTreeNode<CXFA_LayoutItem>::Trace(visitor);
52 visitor->Trace(m_pFormNode);
53}
54
55CXFA_ViewLayoutItem* CXFA_LayoutItem::AsViewLayoutItem() {
56 return IsViewLayoutItem() ? static_cast<CXFA_ViewLayoutItem*>(this) : nullptr;
57}
58
59const CXFA_ViewLayoutItem* CXFA_LayoutItem::AsViewLayoutItem() const {
60 return IsViewLayoutItem() ? static_cast<const CXFA_ViewLayoutItem*>(this)
61 : nullptr;
62}
63
64CXFA_ContentLayoutItem* CXFA_LayoutItem::AsContentLayoutItem() {
65 return IsContentLayoutItem() ? static_cast<CXFA_ContentLayoutItem*>(this)
66 : nullptr;
67}
68
69const CXFA_ContentLayoutItem* CXFA_LayoutItem::AsContentLayoutItem() const {
71 ? static_cast<const CXFA_ContentLayoutItem*>(this)
72 : nullptr;
73}
74
75const CXFA_ViewLayoutItem* CXFA_LayoutItem::GetPage() const {
76 for (CXFA_LayoutItem* pCurNode = const_cast<CXFA_LayoutItem*>(this); pCurNode;
77 pCurNode = pCurNode->GetParent()) {
78 if (pCurNode->m_pFormNode->GetElementType() == XFA_Element::PageArea)
79 return pCurNode->AsViewLayoutItem();
80 }
81 return nullptr;
82}
83
85 // Not in header, assignment requires complete type, not just forward decl.
86 m_pFormNode = pNode;
87}
CXFA_FFNotify * GetNotify() const
void OnPageViewEvent(CXFA_ViewLayoutItem *pSender, CXFA_FFDoc::PageViewEvent eEvent)
void OnLayoutItemRemoving(CXFA_LayoutProcessor *pLayout, CXFA_LayoutItem *pSender)
bool IsContentLayoutItem() const
const CXFA_ViewLayoutItem * GetPage() const
CXFA_ViewLayoutItem * AsViewLayoutItem()
bool IsViewLayoutItem() const
void SetFormNode(CXFA_Node *pNode)
~CXFA_LayoutItem() override
CXFA_ContentLayoutItem * AsContentLayoutItem()
CXFA_Node * GetFormNode() const
CXFA_LayoutItem(CXFA_Node *pNode, ItemType type)
const CXFA_ContentLayoutItem * AsContentLayoutItem() const
void Trace(cppgc::Visitor *visitor) const override
const CXFA_ViewLayoutItem * AsViewLayoutItem() const
static CXFA_LayoutProcessor * FromDocument(const CXFA_Document *pXFADoc)
XFA_Element GetElementType() const
Definition cxfa_object.h:91
CXFA_Document * GetDocument() const
Definition cxfa_object.h:48
CXFA_ViewLayoutItem * ToViewLayoutItem(CXFA_LayoutItem *item)
void XFA_ReleaseLayoutItem(CXFA_LayoutItem *pLayoutItem)
XFA_Element
Definition fxfa_basic.h:75
Definition heap.h:12