void CScript_LayoutPseudoModel::PageImp(CFXJSE_Arguments* pArguments, FX_BOOL bAbsPage) { int32_t iLength = pArguments->GetLength(); if (iLength != 1) { const FX_WCHAR* methodName; if (bAbsPage) { methodName = L"absPage"; } else { methodName = L"page"; } ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, methodName); return; } CXFA_Node* pNode = nullptr; if (iLength >= 1) { pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); } int32_t iPage = 0; CFXJSE_Value* pValue = pArguments->GetReturnValue(); if (!pNode && pValue) pValue->SetInteger(iPage); CXFA_LayoutProcessor* pDocLayout = m_pDocument->GetDocLayout(); if (!pDocLayout) { return; } CXFA_LayoutItem* pLayoutItem = pDocLayout->GetLayoutItem(pNode); if (!pLayoutItem) { pValue->SetInteger(-1); return; } iPage = pLayoutItem->GetFirst()->GetPage()->GetPageIndex(); if (pValue) pValue->SetInteger(bAbsPage ? iPage : iPage + 1); }
void CScript_LayoutPseudoModel::PageSpan(CFXJSE_Arguments* pArguments) { int32_t iLength = pArguments->GetLength(); if (iLength != 1) { ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"pageSpan"); return; } CXFA_Node* pNode = nullptr; if (iLength >= 1) { pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); } if (!pNode) { return; } CXFA_LayoutProcessor* pDocLayout = m_pDocument->GetDocLayout(); if (!pDocLayout) { return; } CFXJSE_Value* pValue = pArguments->GetReturnValue(); CXFA_LayoutItem* pLayoutItem = pDocLayout->GetLayoutItem(pNode); if (!pLayoutItem) { pValue->SetInteger(-1); return; } int32_t iLast = pLayoutItem->GetLast()->GetPage()->GetPageIndex(); int32_t iFirst = pLayoutItem->GetFirst()->GetPage()->GetPageIndex(); int32_t iPageSpan = iLast - iFirst + 1; if (pValue) pValue->SetInteger(iPageSpan); }
void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_PageSpan( CFXJSE_Arguments* pArguments) { int32_t iLength = pArguments->GetLength(); if (iLength != 1) { ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"pageSpan"); return; } CXFA_Node* pNode = NULL; if (iLength >= 1) { pNode = (CXFA_Node*)pArguments->GetObject(0); } if (!pNode) { return; } IXFA_DocLayout* pDocLayout = m_pDocument->GetDocLayout(); if (!pDocLayout) { return; } FXJSE_HVALUE hValue = pArguments->GetReturnValue(); CXFA_LayoutItem* pLayoutItem = pDocLayout->GetLayoutItem(pNode); if (!pLayoutItem) { FXJSE_Value_SetInteger(hValue, -1); return; } int32_t iLast = pLayoutItem->GetLast()->GetPage()->GetPageIndex(); int32_t iFirst = pLayoutItem->GetFirst()->GetPage()->GetPageIndex(); int32_t iPageSpan = iLast - iFirst + 1; if (hValue) { FXJSE_Value_SetInteger(hValue, iPageSpan); } }
void CScript_LayoutPseudoModel::Script_LayoutPseudoModel_PageImp( CFXJSE_Arguments* pArguments, FX_BOOL bAbsPage) { int32_t iLength = pArguments->GetLength(); if (iLength != 1) { const FX_WCHAR* methodName; if (bAbsPage) { methodName = L"absPage"; } else { methodName = L"page"; } ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, methodName); return; } CXFA_Node* pNode = NULL; if (iLength >= 1) { pNode = (CXFA_Node*)pArguments->GetObject(0); } int32_t iPage = 0; FXJSE_HVALUE hValue = pArguments->GetReturnValue(); if (!pNode && hValue) { FXJSE_Value_SetInteger(hValue, iPage); } IXFA_DocLayout* pDocLayout = m_pDocument->GetDocLayout(); if (!pDocLayout) { return; } CXFA_LayoutItem* pLayoutItem = pDocLayout->GetLayoutItem(pNode); if (!pLayoutItem) { FXJSE_Value_SetInteger(hValue, -1); return; } iPage = pLayoutItem->GetFirst()->GetPage()->GetPageIndex(); if (hValue) { FXJSE_Value_SetInteger(hValue, bAbsPage ? iPage : iPage + 1); } }
void CXFA_FFField::CapPlacement() { CFX_RectF rtWidget; GetRectWithoutRotate(rtWidget); CXFA_Margin mgWidget = m_pDataAcc->GetMargin(); if (mgWidget) { CXFA_LayoutItem* pItem = this; FX_FLOAT fLeftInset = 0, fRightInset = 0, fTopInset = 0, fBottomInset = 0; mgWidget.GetLeftInset(fLeftInset); mgWidget.GetRightInset(fRightInset); mgWidget.GetTopInset(fTopInset); mgWidget.GetBottomInset(fBottomInset); if (!pItem->GetPrev() && !pItem->GetNext()) { rtWidget.Deflate(fLeftInset, fTopInset, fRightInset, fBottomInset); } else { if (!pItem->GetPrev()) { rtWidget.Deflate(fLeftInset, fTopInset, fRightInset, 0); } else if (!pItem->GetNext()) { rtWidget.Deflate(fLeftInset, 0, fRightInset, fBottomInset); } else { rtWidget.Deflate(fLeftInset, 0, fRightInset, 0); } } } XFA_ATTRIBUTEENUM iCapPlacement = XFA_ATTRIBUTEENUM_Unknown; FX_FLOAT fCapReserve = 0; CXFA_Caption caption = m_pDataAcc->GetCaption(); if (caption && caption.GetPresence() != XFA_ATTRIBUTEENUM_Hidden) { iCapPlacement = (XFA_ATTRIBUTEENUM)caption.GetPlacementType(); if (iCapPlacement == XFA_ATTRIBUTEENUM_Top && GetPrev()) { m_rtCaption.Set(0, 0, 0, 0); } else if (iCapPlacement == XFA_ATTRIBUTEENUM_Bottom && GetNext()) { m_rtCaption.Set(0, 0, 0, 0); } else { fCapReserve = caption.GetReserve(); CXFA_LayoutItem* pItem = this; if (!pItem->GetPrev() && !pItem->GetNext()) { m_rtCaption.Set(rtWidget.left, rtWidget.top, rtWidget.width, rtWidget.height); } else { pItem = pItem->GetFirst(); pItem->GetRect(m_rtCaption); pItem = pItem->GetNext(); while (pItem) { CFX_RectF rtRect; pItem->GetRect(rtRect); m_rtCaption.height += rtRect.Height(); pItem = pItem->GetNext(); } XFA_RectWidthoutMargin(m_rtCaption, mgWidget); } CXFA_TextLayout* pCapTextLayout = m_pDataAcc->GetCaptionTextLayout(); if (fCapReserve <= 0 && pCapTextLayout) { CFX_SizeF size; CFX_SizeF minSize; CFX_SizeF maxSize; pCapTextLayout->CalcSize(minSize, maxSize, size); if (iCapPlacement == XFA_ATTRIBUTEENUM_Top || iCapPlacement == XFA_ATTRIBUTEENUM_Bottom) { fCapReserve = size.y; } else { fCapReserve = size.x; } } } } m_rtUI = rtWidget; switch (iCapPlacement) { case XFA_ATTRIBUTEENUM_Left: { m_rtCaption.width = fCapReserve; CapLeftRightPlacement(caption, rtWidget, iCapPlacement); m_rtUI.width -= fCapReserve; m_rtUI.left += fCapReserve; } break; case XFA_ATTRIBUTEENUM_Top: { m_rtCaption.height = fCapReserve; CapTopBottomPlacement(caption, rtWidget, iCapPlacement); m_rtUI.top += fCapReserve; m_rtUI.height -= fCapReserve; } break; case XFA_ATTRIBUTEENUM_Right: { m_rtCaption.left = m_rtCaption.right() - fCapReserve; m_rtCaption.width = fCapReserve; CapLeftRightPlacement(caption, rtWidget, iCapPlacement); m_rtUI.width -= fCapReserve; } break; case XFA_ATTRIBUTEENUM_Bottom: { m_rtCaption.top = m_rtCaption.bottom() - fCapReserve; m_rtCaption.height = fCapReserve; CapTopBottomPlacement(caption, rtWidget, iCapPlacement); m_rtUI.height -= fCapReserve; } break; case XFA_ATTRIBUTEENUM_Inline: break; default: break; } CXFA_Border borderUI = m_pDataAcc->GetUIBorder(); if (borderUI) { CXFA_Margin margin = borderUI.GetMargin(); if (margin) { XFA_RectWidthoutMargin(m_rtUI, margin); } } m_rtUI.Normalize(); }