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::SheetInBatch(CFXJSE_Arguments* pArguments) { int32_t iLength = pArguments->GetLength(); if (iLength != 1) { ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"sheetInBatch"); return; } CXFA_Node* pNode = nullptr; if (iLength >= 1) { pNode = static_cast<CXFA_Node*>(pArguments->GetObject(0)); } if (!pNode) { return; } CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); if (!pNotify) { return; } CXFA_LayoutProcessor* pDocLayout = m_pDocument->GetDocLayout(); if (!pDocLayout) { return; } CXFA_FFWidget* hWidget = pNotify->GetHWidget(pDocLayout->GetLayoutItem(pNode)); if (!hWidget) { return; } CXFA_FFDoc* hDoc = pNotify->GetHDOC(); int32_t iPageCount = pNotify->GetDocProvider()->SheetInBatch(hDoc, hWidget); CFXJSE_Value* pValue = pArguments->GetReturnValue(); if (pValue) pValue->SetInteger(iPageCount); }
void CScript_LayoutPseudoModel::NumberedPageCount(CFXJSE_Arguments* pArguments, FX_BOOL bNumbered) { CXFA_LayoutProcessor* pDocLayout = m_pDocument->GetDocLayout(); if (!pDocLayout) { return; } int32_t iPageCount = 0; int32_t iPageNum = pDocLayout->CountPages(); if (bNumbered) { for (int32_t i = 0; i < iPageNum; i++) { CXFA_ContainerLayoutItem* pLayoutPage = pDocLayout->GetPage(i); if (!pLayoutPage) { continue; } CXFA_Node* pMasterPage = pLayoutPage->GetMasterPage(); if (pMasterPage->GetInteger(XFA_ATTRIBUTE_Numbered)) { iPageCount++; } } } else { iPageCount = iPageNum; } CFXJSE_Value* pValue = pArguments->GetReturnValue(); if (pValue) pValue->SetInteger(iPageCount); }
void CScript_SignaturePseudoModel::Verify(CFXJSE_Arguments* pArguments) { int32_t iLength = pArguments->GetLength(); if (iLength < 1 || iLength > 4) { ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"verify"); return; } CFXJSE_Value* pValue = pArguments->GetReturnValue(); if (pValue) pValue->SetInteger(0); }
void CScript_LayoutPseudoModel::SheetCountInBatch( CFXJSE_Arguments* pArguments) { CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); if (!pNotify) { return; } CXFA_FFDoc* hDoc = pNotify->GetHDOC(); int32_t iPageCount = pNotify->GetDocProvider()->SheetCountInBatch(hDoc); CFXJSE_Value* pValue = pArguments->GetReturnValue(); if (pValue) pValue->SetInteger(iPageCount); }
void CScript_HostPseudoModel::MessageBox(CFXJSE_Arguments* pArguments) { if (!m_pDocument->GetScriptContext()->IsRunAtClient()) { return; } int32_t iLength = pArguments->GetLength(); if (iLength < 1 || iLength > 4) { ThrowException(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, L"messageBox"); return; } CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); if (!pNotify) { return; } CFX_WideString wsMessage; CFX_WideString bsTitle; uint32_t dwMessageType = XFA_MBICON_Error; uint32_t dwButtonType = XFA_MB_OK; if (iLength >= 1) { if (!ValidateArgsForMsg(pArguments, 0, wsMessage)) { return; } } if (iLength >= 2) { if (!ValidateArgsForMsg(pArguments, 1, bsTitle)) { return; } } if (iLength >= 3) { dwMessageType = pArguments->GetInt32(2); if (dwMessageType > XFA_MBICON_Status) { dwMessageType = XFA_MBICON_Error; } } if (iLength >= 4) { dwButtonType = pArguments->GetInt32(3); if (dwButtonType > XFA_MB_YesNoCancel) { dwButtonType = XFA_MB_OK; } } int32_t iValue = pNotify->GetAppProvider()->MsgBox( wsMessage, bsTitle, dwMessageType, dwButtonType); CFXJSE_Value* pValue = pArguments->GetReturnValue(); if (pValue) pValue->SetInteger(iValue); }
void FXJSE_Value_SetInteger(FXJSE_HVALUE hValue, int32_t nInteger) { CFXJSE_Value* lpValue = reinterpret_cast<CFXJSE_Value*>(hValue); ASSERT(lpValue); return lpValue->SetInteger(nInteger); }