summaryrefslogtreecommitdiff
path: root/xfa/fxfa/parser/cxfa_contentlayoutitem.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fxfa/parser/cxfa_contentlayoutitem.cpp')
-rw-r--r--xfa/fxfa/parser/cxfa_contentlayoutitem.cpp79
1 files changed, 79 insertions, 0 deletions
diff --git a/xfa/fxfa/parser/cxfa_contentlayoutitem.cpp b/xfa/fxfa/parser/cxfa_contentlayoutitem.cpp
index 1ee364b9b7..e763e2d5da 100644
--- a/xfa/fxfa/parser/cxfa_contentlayoutitem.cpp
+++ b/xfa/fxfa/parser/cxfa_contentlayoutitem.cpp
@@ -7,6 +7,7 @@
#include "xfa/fxfa/parser/cxfa_contentlayoutitem.h"
#include "fxjs/xfa/cjx_object.h"
+#include "xfa/fxfa/parser/cxfa_margin.h"
#include "xfa/fxfa/parser/cxfa_node.h"
CXFA_ContentLayoutItem::CXFA_ContentLayoutItem(CXFA_Node* pNode)
@@ -19,3 +20,81 @@ CXFA_ContentLayoutItem::~CXFA_ContentLayoutItem() {
if (m_pFormNode->JSObject()->GetLayoutItem() == this)
m_pFormNode->JSObject()->SetLayoutItem(nullptr);
}
+
+CXFA_ContentLayoutItem* CXFA_ContentLayoutItem::GetFirst() {
+ CXFA_ContentLayoutItem* pCurNode = this;
+ while (pCurNode->m_pPrev)
+ pCurNode = pCurNode->m_pPrev;
+
+ return pCurNode;
+}
+
+CXFA_ContentLayoutItem* CXFA_ContentLayoutItem::GetLast() {
+ CXFA_ContentLayoutItem* pCurNode = this;
+ while (pCurNode->m_pNext)
+ pCurNode = pCurNode->m_pNext;
+
+ return pCurNode;
+}
+
+CFX_RectF CXFA_ContentLayoutItem::GetRect(bool bRelative) const {
+ CFX_PointF sPos = m_sPos;
+ CFX_SizeF sSize = m_sSize;
+ if (bRelative)
+ return CFX_RectF(sPos, sSize);
+
+ for (CXFA_LayoutItem* pLayoutItem = m_pParent; pLayoutItem;
+ pLayoutItem = pLayoutItem->m_pParent) {
+ if (CXFA_ContentLayoutItem* pContent = pLayoutItem->AsContentLayoutItem()) {
+ sPos += pContent->m_sPos;
+ CXFA_Margin* pMarginNode =
+ pContent->m_pFormNode->GetFirstChildByClass<CXFA_Margin>(
+ XFA_Element::Margin);
+ if (pMarginNode) {
+ sPos += CFX_PointF(pMarginNode->JSObject()
+ ->GetMeasure(XFA_Attribute::LeftInset)
+ .ToUnit(XFA_Unit::Pt),
+ pMarginNode->JSObject()
+ ->GetMeasure(XFA_Attribute::TopInset)
+ .ToUnit(XFA_Unit::Pt));
+ }
+ continue;
+ }
+
+ if (pLayoutItem->GetFormNode()->GetElementType() ==
+ XFA_Element::ContentArea) {
+ sPos += CFX_PointF(pLayoutItem->GetFormNode()
+ ->JSObject()
+ ->GetMeasure(XFA_Attribute::X)
+ .ToUnit(XFA_Unit::Pt),
+ pLayoutItem->GetFormNode()
+ ->JSObject()
+ ->GetMeasure(XFA_Attribute::Y)
+ .ToUnit(XFA_Unit::Pt));
+ break;
+ }
+ if (pLayoutItem->GetFormNode()->GetElementType() == XFA_Element::PageArea)
+ break;
+ }
+ return CFX_RectF(sPos, sSize);
+}
+
+int32_t CXFA_ContentLayoutItem::GetIndex() const {
+ int32_t iIndex = 0;
+ const CXFA_ContentLayoutItem* pCurNode = this;
+ while (pCurNode->m_pPrev) {
+ pCurNode = pCurNode->m_pPrev;
+ ++iIndex;
+ }
+ return iIndex;
+}
+
+int32_t CXFA_ContentLayoutItem::GetCount() const {
+ int32_t iCount = GetIndex() + 1;
+ const CXFA_ContentLayoutItem* pCurNode = this;
+ while (pCurNode->m_pNext) {
+ pCurNode = pCurNode->m_pNext;
+ iCount++;
+ }
+ return iCount;
+}